Description
I wanted to post a topic, giving examples on sub-memory routines.
There is many ways in San Andreas, what is the most common? Perhaps it's the via arrays sub-memory routine. Thus, we have three ways to handle the game memory. (For more information of the others, read this topic by Seemann).
Well, now, this is for San Andreas v1.0 US, and may-be the German version. If you find something un-working, then consider changing your EXE version, original v1.0 US, would therefore be beneficial.
SA arrays routine
Using the SA arrays to get an access to any addresses in range of 0..FFFFFFFF. The array indexes can contain 32-bit integer values that gives us an access to ANY in-game address in ranges 0x00000000..0xFFFFFFFF. This way all game addresses are accessible, some of addresses still may not be rewritable, (because of AccessViolation Error), which Sanny will give.
- Code:
// 0@ -address
// 2@ -new value
// 3@ -length (in bytes)
//--write specified number of bytes into memory
:MemoryWrite
0085: 5@ = 0@
0@ /= 4
0@ *= 4 // memory address
0062: 5@ -= 0@ // offset (0, 1, 2, 3)
:_GetInitValue // if you specify mem offset in 5@, you're able to gosub here
gosub @MemoryRead // get initial value
3@ *= 8 // bytes -> bits
5@ *= 8
dec(3@)
for 6@ = 0 to 3@
if
08B6: test 2@ bit 6@
then
08BF: set 1@ bit 5@ // 1
else
08C5: clear 1@ bit 5@ // 0
end
inc(5@) // next memory bit
end
008A: &0(0@,1i) = 1@ // write new value
return
//--write 32-bit value into memory-----------
:MemoryWrite32bit
0@ -= 0xA49960
0@ /= 4
008A: &0(0@,1i) = 1@
return
//--read 32-bit value from memory-----------
:MemoryRead
0@ -= 0xA49960
0@ /= 4
008B: 1@ = &0(0@,1i)
return
Examples
Here are some examples using that, code above:
This will remove the message "To stop Carl;(bla...bla)" when the player first
kicked someone out of his car.
- Code:
0@ = 0xC0BC15 // ADDRESS
2@ = 0x1 // VALUE
3@ = 0x1 // LENGTH (Byte)
gosub @MemoryWrite
Here are some helpful topics:
Seemann's San Andreas Memory Handling Topic
Changing hard-coded interface
Cheats