ok, so what i'm doing is creating an nes game from the ground up. nothing major for my first attempt, but I want to have a bare bones rom. I'm using MMC3 as my mapper. So far I have a functioning controller, sound engine (borrowed from Capcom) and a vram buffer (borrowed from Zelda)
Now here's the problem. I wanted to see if I can have tiles drawn on screen, either horizontally, or vertically, to see if I had this setup correctly for when I want to create a scroll based game. My vram buffer is within the $300ram section. Now, I've been doing manual pastes into the ram of the nes. I'll do 20 tiles horizontaly at a time, and it displays without glitches. I've done a vertical string of tiles as well, all the way down before the attribute section $23C0-$23FFppu, they display correctly with no glitches. So my problem is, I wanted to perform a test using my controller, when a specific button is pressed, it will load the appropriate value for the vram buffer to load the tile construction from a table. Everytime I do it that way, it glitches, i'll get violent screen shaking, i'll even get palette rewrites. I just want to be able to have a constructed vram engine, before I go any further with deciding wht type of game I want to play. Here is my code, and I apologize but this is straight from the fceux debugger.
I don't know what i'm missing, or what i'm doing wrong, ive added the LDA $2002 BPL, etc etc for the proper time the system is needed to have before writing to the screen. Also, I feel it has something to do with timing. Because when I have ppu rendering off, and I use my d-pad to initiate my writes, they are constructed properly. Thanks for reading.
Now here's the problem. I wanted to see if I can have tiles drawn on screen, either horizontally, or vertically, to see if I had this setup correctly for when I want to create a scroll based game. My vram buffer is within the $300ram section. Now, I've been doing manual pastes into the ram of the nes. I'll do 20 tiles horizontaly at a time, and it displays without glitches. I've done a vertical string of tiles as well, all the way down before the attribute section $23C0-$23FFppu, they display correctly with no glitches. So my problem is, I wanted to perform a test using my controller, when a specific button is pressed, it will load the appropriate value for the vram buffer to load the tile construction from a table. Everytime I do it that way, it glitches, i'll get violent screen shaking, i'll even get palette rewrites. I just want to be able to have a constructed vram engine, before I go any further with deciding wht type of game I want to play. Here is my code, and I apologize but this is straight from the fceux debugger.
I don't know what i'm missing, or what i'm doing wrong, ive added the LDA $2002 BPL, etc etc for the proper time the system is needed to have before writing to the screen. Also, I feel it has something to do with timing. Because when I have ppu rendering off, and I use my d-pad to initiate my writes, they are constructed properly. Thanks for reading.
Code:
;nmi
0F:C000:78 SEI
0F:C001:08 PHP
0F:C002:48 PHA
0F:C003:8A TXA
0F:C004:48 PHA
0F:C005:98 TYA
0F:C006:48 PHA
;jsr to joypad routine
0F:C007:20 8E FF JSR $FF8E
;here is where i begin setting up vram
0F:C00A:A9 00 LDA #$00
0F:C00C:8D 03 20 STA $2003 = #$00
0F:C00F:A9 02 LDA #$02
0F:C011:8D 14 40 STA $4014 = #$FF
;jsr to vram bufer
0F:C014:20 92 FE JSR $FE92
0F:C017:A9 3F LDA #$3F
0F:C019:8D 06 20 STA $2006 = #$00
0F:C01C:A9 00 LDA #$00
0F:C01E:8D 06 20 STA $2006 = #$00
0F:C021:8D 06 20 STA $2006 = #$00
0F:C024:8D 06 20 STA $2006 = #$00
0F:C027:AD 02 20 LDA $2002 = #$88
0F:C02A:29 40 AND #$40
0F:C02C:D0 F9 BNE $C027
0F:C02E:AD 02 20 LDA $2002 = #$88
0F:C031:A5 FF LDA $00FF = #$88
0F:C033:8D 00 20 STA $2000 = #$88
0F:C036:A5 FD LDA $00FD = #$00
0F:C038:8D 05 20 STA $2005 = #$00
0F:C03B:A5 FC LDA $00FC = #$00
0F:C03D:8D 05 20 STA $2005 = #$00
0F:C040:A5 FE LDA $00FE = #$00
0F:C042:8D 01 20 STA $2001 = #$00
;end of vram stuff
;mmc3 chr registers
0F:C045:A2 05 LDX #$05
0F:C047:8E 00 80 STX $8000 = #$4C
0F:C04A:B5 F0 LDA $F0,X @ $00F0 = #$00
0F:C04C:8D 01 80 STA $8001 = #$6C
0F:C04F:CA DEX
0F:C050:10 F5 BPL $C047
;frame counter
0F:C052:E6 F6 INC $00F6 = #$00
;jsr to sound engine
0F:C054:20 00 80 JSR $8000
;custom d-pad setups to test vram & sound
0F:C057:A5 F8 LDA $00F8 = #$00
0F:C059:29 80 AND #$80
0F:C05B:F0 05 BEQ $C062
0F:C05D:A9 05 LDA #$05
0F:C05F:20 03 80 JSR $8003
0F:C062:A5 F8 LDA $00F8 = #$00
0F:C064:29 04 AND #$04
0F:C066:F0 0C BEQ $C074
0F:C068:A9 04 LDA #$04
0F:C06A:85 F7 STA $00F7 = #$02
0F:C06C:A9 DC LDA #$DC
0F:C06E:85 F0 STA $00F0 = #$00
0F:C070:A9 DE LDA #$DE
0F:C072:85 F1 STA $00F1 = #$00
0F:C074:A5 F8 LDA $00F8 = #$00
0F:C076:29 20 AND #$20
0F:C078:F0 04 BEQ $C07E
0F:C07A:A9 1E LDA #$1E
0F:C07C:85 FE STA $00FE = #$00
0F:C07E:A5 F8 LDA $00F8 = #$00
0F:C080:29 10 AND #$10
0F:C082:F0 04 BEQ $C088
0F:C084:A9 00 LDA #$00
0F:C086:85 FE STA $00FE = #$00
0F:C088:A5 F8 LDA $00F8 = #$00
0F:C08A:29 08 AND #$08
0F:C08C:F0 0C BEQ $C09A
0F:C08E:A9 06 LDA #$06
0F:C090:85 F7 STA $00F7 = #$02
0F:C092:A9 DC LDA #$DC
0F:C094:85 F0 STA $00F0 = #$00
0F:C096:A9 DE LDA #$DE
0F:C098:85 F1 STA $00F1 = #$00
0F:C09A:68 PLA
0F:C09B:A8 TAY
0F:C09C:68 PLA
0F:C09D:AA TAX
0F:C09E:68 PLA
0F:C09F:28 PLP
0F:C0A0:40 RTI
;END
0F:C000:78 SEI
0F:C001:08 PHP
0F:C002:48 PHA
0F:C003:8A TXA
0F:C004:48 PHA
0F:C005:98 TYA
0F:C006:48 PHA
;jsr to joypad routine
0F:C007:20 8E FF JSR $FF8E
;here is where i begin setting up vram
0F:C00A:A9 00 LDA #$00
0F:C00C:8D 03 20 STA $2003 = #$00
0F:C00F:A9 02 LDA #$02
0F:C011:8D 14 40 STA $4014 = #$FF
;jsr to vram bufer
0F:C014:20 92 FE JSR $FE92
0F:C017:A9 3F LDA #$3F
0F:C019:8D 06 20 STA $2006 = #$00
0F:C01C:A9 00 LDA #$00
0F:C01E:8D 06 20 STA $2006 = #$00
0F:C021:8D 06 20 STA $2006 = #$00
0F:C024:8D 06 20 STA $2006 = #$00
0F:C027:AD 02 20 LDA $2002 = #$88
0F:C02A:29 40 AND #$40
0F:C02C:D0 F9 BNE $C027
0F:C02E:AD 02 20 LDA $2002 = #$88
0F:C031:A5 FF LDA $00FF = #$88
0F:C033:8D 00 20 STA $2000 = #$88
0F:C036:A5 FD LDA $00FD = #$00
0F:C038:8D 05 20 STA $2005 = #$00
0F:C03B:A5 FC LDA $00FC = #$00
0F:C03D:8D 05 20 STA $2005 = #$00
0F:C040:A5 FE LDA $00FE = #$00
0F:C042:8D 01 20 STA $2001 = #$00
;end of vram stuff
;mmc3 chr registers
0F:C045:A2 05 LDX #$05
0F:C047:8E 00 80 STX $8000 = #$4C
0F:C04A:B5 F0 LDA $F0,X @ $00F0 = #$00
0F:C04C:8D 01 80 STA $8001 = #$6C
0F:C04F:CA DEX
0F:C050:10 F5 BPL $C047
;frame counter
0F:C052:E6 F6 INC $00F6 = #$00
;jsr to sound engine
0F:C054:20 00 80 JSR $8000
;custom d-pad setups to test vram & sound
0F:C057:A5 F8 LDA $00F8 = #$00
0F:C059:29 80 AND #$80
0F:C05B:F0 05 BEQ $C062
0F:C05D:A9 05 LDA #$05
0F:C05F:20 03 80 JSR $8003
0F:C062:A5 F8 LDA $00F8 = #$00
0F:C064:29 04 AND #$04
0F:C066:F0 0C BEQ $C074
0F:C068:A9 04 LDA #$04
0F:C06A:85 F7 STA $00F7 = #$02
0F:C06C:A9 DC LDA #$DC
0F:C06E:85 F0 STA $00F0 = #$00
0F:C070:A9 DE LDA #$DE
0F:C072:85 F1 STA $00F1 = #$00
0F:C074:A5 F8 LDA $00F8 = #$00
0F:C076:29 20 AND #$20
0F:C078:F0 04 BEQ $C07E
0F:C07A:A9 1E LDA #$1E
0F:C07C:85 FE STA $00FE = #$00
0F:C07E:A5 F8 LDA $00F8 = #$00
0F:C080:29 10 AND #$10
0F:C082:F0 04 BEQ $C088
0F:C084:A9 00 LDA #$00
0F:C086:85 FE STA $00FE = #$00
0F:C088:A5 F8 LDA $00F8 = #$00
0F:C08A:29 08 AND #$08
0F:C08C:F0 0C BEQ $C09A
0F:C08E:A9 06 LDA #$06
0F:C090:85 F7 STA $00F7 = #$02
0F:C092:A9 DC LDA #$DC
0F:C094:85 F0 STA $00F0 = #$00
0F:C096:A9 DE LDA #$DE
0F:C098:85 F1 STA $00F1 = #$00
0F:C09A:68 PLA
0F:C09B:A8 TAY
0F:C09C:68 PLA
0F:C09D:AA TAX
0F:C09E:68 PLA
0F:C09F:28 PLP
0F:C0A0:40 RTI
;END