On my path to ExHiROM I decided to stop by HiROM first, so I've extended my code to handle HiROM. I chose a fun small project Super Piccross to test this HiROM functionality upon, its pic-cross how hard can it be right? Also to learn the Lua extensions so I can modify/augment gameplay.
However the code was weird, once I worked out the bank register changes it started to make a little more sense but then still weird.
Then I noticed things like this..
which screams "this was done by a compiler", then the weirdness made sense. What it does is, sets Y to the "struct" pointer, and Bank to 7e and then DP to the other structure. This way all the code is
Which is maddening, as I work out a variable, but even if I change the label for it to it, it doesn't help because the code references it with a lda $XXXX,r since it can shift the X and Y around depending upon what the code needs they don't even always have the same offsets when used in different code.
Anybody got tips for this kind of thing? Do you see it often is worth adding "set offset" and look up into stuct systems to my regenerator?
However the code was weird, once I worked out the bank register changes it started to make a little more sense but then still weird.
Then I noticed things like this..
Code:
jC07A04 lda #$7000
tax
lda #$0000
bra bC07A11
bC07A0D sta p7F6000,x
bC07A11 dex
dex
bpl bC07A0D
tax
lda #$0000
bra bC07A11
bC07A0D sta p7F6000,x
bC07A11 dex
dex
bpl bC07A0D
which screams "this was done by a compiler", then the weirdness made sense. What it does is, sets Y to the "struct" pointer, and Bank to 7e and then DP to the other structure. This way all the code is
Code:
lda $0024,y
ora $0036,y
clc
adc $7e08775
sta $0005,x
ora $0036,y
clc
adc $7e08775
sta $0005,x
Which is maddening, as I work out a variable, but even if I change the label for it to it, it doesn't help because the code references it with a lda $XXXX,r since it can shift the X and Y around depending upon what the code needs they don't even always have the same offsets when used in different code.
Anybody got tips for this kind of thing? Do you see it often is worth adding "set offset" and look up into stuct systems to my regenerator?