tokumaru wrote:
I wouldn't put it like this... "culprit" implies it's doing something wrong, which it isn't. No programs should rely on RAM being 0 or any other value, they must always initialize all RAM they use.
Yup, lesson learned. I've just finished writing a RAM clear and it is now displaying the correct title screen on the everdrive.
nesrocks wrote:
Be careful when doing stuff like this. I'm sure that the guys who programmed a full NES game know how to code a simple loop, but since they went for the unrolled version, there probably is a reason for it. Slower code might not be a problem in the middle of the game logic, but if this is for VRAM updates, slower code could mean going past the end of vblank, causing visual glitches.
True, I've been learning about this just recently. My loop costs 1799 cycles while the verbose version costs only 960. But in the case of this game it seems safe to redo anything that looks weird (and then test it, of course), because the game isn't really well made, to say the least. I believe they may have done this particular section like this "just to be safe".
@tepples:
Code:
00:841C:AD 28 03 LDA $0328 = #$00
00:841F:8D 07 20 STA $2007 = #$FF
00:8422:AD 29 03 LDA $0329 = #$00
00:8425:8D 07 20 STA $2007 = #$FF
00:8428:AD 2A 03 LDA $032A = #$00
00:842B:8D 07 20 STA $2007 = #$FF
00:842E:AD 2B 03 LDA $032B = #$00
00:8431:8D 07 20 STA $2007 = #$FF
00:8434:AD 2C 03 LDA $032C = #$00
00:8437:8D 07 20 STA $2007 = #$FF
...
00:843A:AD 2D 03 LDA $039F = #$00
00:843D:8D 07 20 STA $2007 = #$FF
I converted to...
Code:
00:841C:A2 00 LDX #$00
loop:
00:841E:BD 28 03 LDA $0328,X @ $03A0 = #$0F
00:8421:8D 07 20 STA $2007 = #$00
00:8424:E8 INX
00:8425:E0 78 CPX #$78
00:8427:D0 F5 BNE loop
Or this for readability? Making x start at #$28 and end on #$9F seems more intuitive.
Code:
00:8337:A2 28 LDX #$28
loop:
00:8339:BD 00 03 LDA $0300,X @ $03A1 = #$10
00:833C:8D 07 20 STA $2007 = #$00
00:833F:E8 INX
00:8340:E0 A0 CPX #$A0
00:8342:D0 F5 BNE loop