Purpose:
Writing a value to the RAM at a specific address.
Be it 8 digits (32 bit), 4 digits (16 bit) or 2 digits (8 bit). There's no codetype for writing 1 digit called nibble (4 bit).
Since 16 bit and 8 bit writes do not use the whole 8 digits specified for the value, there's room for the possibility of doing serial writes similar to this.
Templates:
32 bit:
TTYYYYYY XXXXXXXX
TT = Codetype:
YYYYYY = Address to write to
XXXXXXXX = Value to write
16 bit:
TTYYYYYY ZZZZXXXX
TT = Codetype:
YYYYYY = Address to write to
XXXX = Value to write
ZZZZ = Additional writes to perform
8 bit:
TTYYYYYY ZZZZ00XX
TT = Codetype:
YYYYYY = Address to write to
XXXX = Value to write
ZZZZ = Additional writes to perform
Example #1:
We want to write to address 81456780 using value 00000001. The maximum we ever need is 000000FF.
Since our value can either be 16 bit, 32 bit or 8 bit we can decide which one we'll use. Depending on how the game's value type is defined you may know what it is.
-> We'll take 8 bit because there's never need to write more than 2 digits.
01456780 00000001
In general:
Using less bit writes is better if you happen to affect other stuff unknowingly.
Example #2:
We're using a pointer with offset 5F0 and want to write to the RAM the value 03FF exactly 5 times in a row.
Obviously, we need 16 bit this time (4 digits!). Using pointer adds 0x10 to the codetype. The offset is calculated by subtracting the pointer value from the starting address. We're doing a serial write (4 additional ones).
120005F0 000403FF
Note:
Addresses on which 32 bit writes are performed should be divisible by 4. Respectively 16 bit by 2 und 8 bit by 1 (which is always possible).
Failing to get it right will only make you look stupid since
they still end up working properly.
Why?
The codehandler implicitly decreases the address until it's finally divisible and performs the write at the new address.
The following codes therefore do the same thing:
047FED0 12345678
047FED1 12345678
047FED2 12345678
047FED3 12345678
Doing a bad bit write has no purpose besides trying to steal credit.
-> Don't even try, you have been warned.
Example #3:
We're writing value 3F812345 to address 801A9F03.
Really that easy?
041A9F03 3F812345
Since the bit write is wrong it'll be changed to
041A9F00 3F812345
implicitly and does NOT act like expected / wanted. The string write codetype would be the way to go since it does allow these cases.
Alternatively, you can take one 8 bit write with 3F, a 16 bit write using 8000 and finally another 8 bit write using 00.
001A9F03 0000003F
021A9F04 00008123
001A9F06 00000045
Quite inconvenient but you'll almost never really need this case.
Writing a value to the RAM at a specific address.
Be it 8 digits (32 bit), 4 digits (16 bit) or 2 digits (8 bit). There's no codetype for writing 1 digit called nibble (4 bit).
Since 16 bit and 8 bit writes do not use the whole 8 digits specified for the value, there's room for the possibility of doing serial writes similar to this.
Templates:
32 bit:
TTYYYYYY XXXXXXXX
TT = Codetype:
Base address & address less than 0x81000000 or 0x91000000 | 04 |
Base address & address greater than 0x80FFFFFF or 0x90FFFFFF | 14 |
Pointer & address less than 0x81000000 or 0x91000000 | 05 |
Pointer & address greater than 0x80FFFFFF or 0x90FFFFFF | 15 |
YYYYYY = Address to write to
XXXXXXXX = Value to write
16 bit:
TTYYYYYY ZZZZXXXX
TT = Codetype:
Base address & address less than 0x81000000 or 0x91000000 | 02 |
Base address & address greater than 0x80FFFFFF or 0x90FFFFFF | 12 |
Pointer & address less than 0x81000000 or 0x91000000 | 03 |
Pointer & address greater than 0x80FFFFFF or 0x90FFFFFF | 13 |
YYYYYY = Address to write to
XXXX = Value to write
ZZZZ = Additional writes to perform
8 bit:
TTYYYYYY ZZZZ00XX
TT = Codetype:
Base address & address less than 0x81000000 or 0x91000000 | 00 |
Base address & address greater than 0x80FFFFFF or 0x90FFFFFF | 01 |
Pointer & address less than 0x81000000 or 0x91000000 | 10 |
Pointer & address greater than 0x80FFFFFF or 0x90FFFFFF | 11 |
YYYYYY = Address to write to
XXXX = Value to write
ZZZZ = Additional writes to perform
Example #1:
We want to write to address 81456780 using value 00000001. The maximum we ever need is 000000FF.
Since our value can either be 16 bit, 32 bit or 8 bit we can decide which one we'll use. Depending on how the game's value type is defined you may know what it is.
-> We'll take 8 bit because there's never need to write more than 2 digits.
01456780 00000001
In general:
Using less bit writes is better if you happen to affect other stuff unknowingly.
Example #2:
We're using a pointer with offset 5F0 and want to write to the RAM the value 03FF exactly 5 times in a row.
Obviously, we need 16 bit this time (4 digits!). Using pointer adds 0x10 to the codetype. The offset is calculated by subtracting the pointer value from the starting address. We're doing a serial write (4 additional ones).
120005F0 000403FF
Note:
Addresses on which 32 bit writes are performed should be divisible by 4. Respectively 16 bit by 2 und 8 bit by 1 (which is always possible).
Failing to get it right will only make you look stupid since
they still end up working properly.
Why?
The codehandler implicitly decreases the address until it's finally divisible and performs the write at the new address.
The following codes therefore do the same thing:
047FED0 12345678
047FED1 12345678
047FED2 12345678
047FED3 12345678
Doing a bad bit write has no purpose besides trying to steal credit.
-> Don't even try, you have been warned.
Example #3:
We're writing value 3F812345 to address 801A9F03.
Really that easy?
041A9F03 3F812345
Since the bit write is wrong it'll be changed to
041A9F00 3F812345
implicitly and does NOT act like expected / wanted. The string write codetype would be the way to go since it does allow these cases.
Alternatively, you can take one 8 bit write with 3F, a 16 bit write using 8000 and finally another 8 bit write using 00.
001A9F03 0000003F
021A9F04 00008123
001A9F06 00000045
Quite inconvenient but you'll almost never really need this case.