Romhacking.net

Romhacking => Programming => Topic started by: Boyle888 on August 05, 2019, 12:27:53 am

Title: Incrementing PPU offsey
Post by: Boyle888 on August 05, 2019, 12:27:53 am
So I have to convert a vertical box into being displayed horizontally. I've located the data for it and the code that writes it to the PPU, but it appears to be automatically adding #$20 to the PPU offset. For example the starting PPU offset is $2135 then the next is $2155 and etc. The thing that baffles me is that I don't see anything in the code telling it to do that.

Edit: Heh, looking at my NES address space doc, it appears the register at $2000 can increment the PPU address by x value. I think I might've solved my problem.

Code: [Select]
$C650:20 07 C5  JSR $C507                  A:C6 X:0C Y:68 S:F9 P:NvUbdIzc
$C507:38        SEC                        A:C6 X:0C Y:68 S:F7 P:NvUbdIzc
$C508:B0 01     BCS $C50B                  A:C6 X:0C Y:68 S:F7 P:NvUbdIzC
$C50B:A5 19     LDA $0019 = #$90           A:C6 X:0C Y:68 S:F7 P:NvUbdIzC
$C50D:29 7B     AND #$7B                   A:90 X:0C Y:68 S:F7 P:NvUbdIzC
$C50F:90 02     BCC $C513                  A:10 X:0C Y:68 S:F7 P:nvUbdIzC
$C511:09 04     ORA #$04                   A:10 X:0C Y:68 S:F7 P:nvUbdIzC
$C513:8D 00 20  STA $2000 = #$14           A:14 X:0C Y:68 S:F7 P:nvUbdIzC
$C516:A5 18     LDA $0018 = #$1E           A:14 X:0C Y:68 S:F7 P:nvUbdIzC
$C518:29 E1     AND #$E1                   A:1E X:0C Y:68 S:F7 P:nvUbdIzC
$C51A:8D 01 20  STA $2001 = #$00           A:00 X:0C Y:68 S:F7 P:nvUbdIZC
$C51D:60        RTS                        A:00 X:0C Y:68 S:F7 P:nvUbdIZC
$C653:B0 03     BCS $C658                  A:00 X:0C Y:68 S:F9 P:nvUbdIZC
$C658:20 2B C6  JSR $C62B                  A:00 X:0C Y:68 S:F9 P:nvUbdIZC
$C62B:C8        INY                        A:00 X:0C Y:68 S:F7 P:nvUbdIZC
$C62C:D0 02     BNE $C630                  A:00 X:0C Y:69 S:F7 P:nvUbdIzC
$C630:60        RTS                        A:00 X:0C Y:69 S:F7 P:nvUbdIzC
$C65B:AD 02 20  LDA $2002 = #$00           A:00 X:0C Y:69 S:F9 P:nvUbdIzC
$C65E:B1 C0     LDA ($C0),Y @ $D17D = #$21 A:00 X:0C Y:69 S:F9 P:nvUbdIZC
$C660:8D 06 20  STA $2006 = #$B2           A:21 X:0C Y:69 S:F9 P:nvUbdIzC
$C663:20 2B C6  JSR $C62B                  A:21 X:0C Y:69 S:F9 P:nvUbdIzC
$C62B:C8        INY                        A:21 X:0C Y:69 S:F7 P:nvUbdIzC
$C62C:D0 02     BNE $C630                  A:21 X:0C Y:6A S:F7 P:nvUbdIzC
$C630:60        RTS                        A:21 X:0C Y:6A S:F7 P:nvUbdIzC
$C666:B1 C0     LDA ($C0),Y @ $D17E = #$35 A:21 X:0C Y:6A S:F9 P:nvUbdIzC
$C668:8D 06 20  STA $2006 = #$B2           A:35 X:0C Y:6A S:F9 P:nvUbdIzC
$C66B:4C 0A C6  JMP $C60A                  A:35 X:0C Y:6A S:F9 P:nvUbdIzC
$C60A:C8        INY                        A:35 X:0C Y:6A S:F9 P:nvUbdIzC
$C60B:D0 F6     BNE $C603                  A:35 X:0C Y:6B S:F9 P:nvUbdIzC
$C603:B1 C0     LDA ($C0),Y @ $D17F = #$50 A:35 X:0C Y:6B S:F9 P:nvUbdIzC
//This is the first tile
$C605:F0 0D     BEQ $C614                  A:50 X:0C Y:6B S:F9 P:nvUbdIzC
$C607:8D 07 20  STA $2007 = #$66           A:50 X:0C Y:6B S:F9 P:nvUbdIzC
$C60A:C8        INY                        A:50 X:0C Y:6B S:F9 P:nvUbdIzC
$C60B:D0 F6     BNE $C603                  A:50 X:0C Y:6C S:F9 P:nvUbdIzC
$C603:B1 C0     LDA ($C0),Y @ $D180 = #$00 A:50 X:0C Y:6C S:F9 P:nvUbdIzC
$C605:F0 0D     BEQ $C614                  A:00 X:0C Y:6C S:F9 P:nvUbdIZC
$C614:20 2B C6  JSR $C62B                  A:00 X:0C Y:6C S:F9 P:nvUbdIZC
$C62B:C8        INY                        A:00 X:0C Y:6C S:F7 P:nvUbdIZC
$C62C:D0 02     BNE $C630                  A:00 X:0C Y:6D S:F7 P:nvUbdIzC
$C630:60        RTS                        A:00 X:0C Y:6D S:F7 P:nvUbdIzC
$C617:B1 C0     LDA ($C0),Y @ $D181 = #$05 A:00 X:0C Y:6D S:F9 P:nvUbdIzC
$C619:F0 EC     BEQ $C607                  A:05 X:0C Y:6D S:F9 P:nvUbdIzC
$C61B:30 14     BMI $C631                  A:05 X:0C Y:6D S:F9 P:nvUbdIzC
$C61D:AA        TAX                        A:05 X:0C Y:6D S:F9 P:nvUbdIzC
$C61E:20 2B C6  JSR $C62B                  A:05 X:05 Y:6D S:F9 P:nvUbdIzC
$C62B:C8        INY                        A:05 X:05 Y:6D S:F7 P:nvUbdIzC
$C62C:D0 02     BNE $C630                  A:05 X:05 Y:6E S:F7 P:nvUbdIzC
$C630:60        RTS                        A:05 X:05 Y:6E S:F7 P:nvUbdIzC
$C621:B1 C0     LDA ($C0),Y @ $D182 = #$55 A:05 X:05 Y:6E S:F9 P:nvUbdIzC
//second set tiles that is written to the PPU 5 times
$C623:8D 07 20  STA $2007 = #$66           A:55 X:05 Y:6E S:F9 P:nvUbdIzC
$C626:CA        DEX                        A:55 X:05 Y:6E S:F9 P:nvUbdIzC
$C627:D0 FA     BNE $C623                  A:55 X:04 Y:6E S:F9 P:nvUbdIzC
$C623:8D 07 20  STA $2007 = #$66           A:55 X:04 Y:6E S:F9 P:nvUbdIzC
$C626:CA        DEX                        A:55 X:04 Y:6E S:F9 P:nvUbdIzC
$C627:D0 FA     BNE $C623                  A:55 X:03 Y:6E S:F9 P:nvUbdIzC
$C623:8D 07 20  STA $2007 = #$66           A:55 X:03 Y:6E S:F9 P:nvUbdIzC
$C626:CA        DEX                        A:55 X:03 Y:6E S:F9 P:nvUbdIzC
$C627:D0 FA     BNE $C623                  A:55 X:02 Y:6E S:F9 P:nvUbdIzC
$C623:8D 07 20  STA $2007 = #$66           A:55 X:02 Y:6E S:F9 P:nvUbdIzC
$C626:CA        DEX                        A:55 X:02 Y:6E S:F9 P:nvUbdIzC
$C627:D0 FA     BNE $C623                  A:55 X:01 Y:6E S:F9 P:nvUbdIzC
$C623:8D 07 20  STA $2007 = #$66           A:55 X:01 Y:6E S:F9 P:nvUbdIzC