~Red
Camper
Posts: 68
|
Post by ~Red on Jan 14, 2010 3:15:14 GMT -5
How to I move blocks of data? So far I only know how to move one or two bytes of data at any one time.
|
|
|
Post by iimarckus on Jan 14, 2010 12:36:38 GMT -5
How to I move blocks of data? So far I only know how to move one or two bytes of data at any one time. The game developers put in routines to make this easier. In Pokémon Red, it looks like this: ld hl,$4000 ld de,$D000 ld bc,$10 call $00B5When this is run, $10 bytes starting at $4000 will be copied to $D000. Mnemonics for the parameters: byte count, destination. This register pattern often holds for other existing ASM routines, but it is of course not a hard-and-fast rule (we only have so many registers to work with). If you want to know how this copy routine was implemented, you can look at offset $B5.
|
|
~Red
Camper
Posts: 68
|
Post by ~Red on Jan 15, 2010 3:09:34 GMT -5
ASM doesn't seem that hard now I've been reviewing it. Also, you can compile ASM but can you decompile it? Or is that what you meant by the red decompile you are making, are you doing it opcode for opcode?
|
|
|
Post by iimarckus on Jan 15, 2010 17:03:58 GMT -5
Disassemblers do exist. The catch is that disassembling is a very hard problem to solve. Programs can't tell the difference between code and data -- to them, bytes are bytes. Good disassemblers will partially emulate the processor and disassemble code as they run it, but it's still impossible to exhaust all possible code paths.
The other problem is that you need a human to understand what the code's doing. What good is a disassembly if it's all inscrutable code, hardcoded addresses, and no comments or labels? If it says "ld hl,$4000", which $4000 is it referring to? How do you know it's even in the same bank? I would rather have a few important things (like trainer AI, data parsing, etc) disassembled by hand and readable and the rest of the ROM included as a binary blob than have a bunch of undocumented source code. Disassembling byte-by-byte lets me figure out what the programmers were trying to do.
That said, it is slow and even I don't have all Game Boy machine code memorized (although I do know many opcode-byte equivalents). I have an automated disassembly (I used wlad for that) that I use side-by-side with the hex editor so I don't have to look up opcodes.
|
|
~Red
Camper
Posts: 68
|
Post by ~Red on Jan 17, 2010 4:26:09 GMT -5
I've just figured out why my music wouldn't work. I added some music byte by byte to a blank part of the ROM but it wouldn't work. I'm guessing that it was in a different ROM Bank to the normal music so I'd need to switch banks for it to work.
|
|