Hello, I would appreciate any solutions to this.
I only implemented a nametable update. It basically writes a background tile to $2007
every 3 frames; to appear as animated text typing.
All code is in NMI and it works completly fine.
It resets fine when the animation is done but if it was RESET sometime during the animation,
it gives strange rows of $00 tiles on the upper part of the screen.
I used a couple macros to help conserve some development time.
I am also aware of the RESET issues for the NES hardware. Am I using my VBlank right? I just
can't seem to find the issue.
This is most of the important code. Also Forget about the Timer macro; I know its fine.
Code:
.inesprg 1 ; 1x 16KB PRG code
.ineschr 1 ; 1x 8KB CHR data
.inesmap 4 ; Mapper 4 = MMC3
.inesmir 3 ; Background Mirroring = Vertical with WRAM enabled
;=========VARIABLES==========
.rsset $0000
backgroundMaxRLE .rs 1
backgroundHi .rs 1
backgroundLo .rs 1
backgroundCounter .rs 1
textHi .rs 1
textLo .rs 1
textCounter .rs 1
textTimer .rs 1
textOnce .rs 1
.bank 0
.org $C000
;=========PALETTE DATA==========
starfoxesPalette:
.db $3F,$04,$30,$24, $3F,$3F,$3F,$3F, $3F,$3F,$3F,$3F, $3F,$3F,$3F,$3F
.db $3F,$04,$24,$30, $3F,$04,$30,$24, $3F,$3F,$3F,$3F, $3F,$3F,$3F,$3F
;=========TEXT DATA==========
introText:
.text0
.db "STARFOXESoPRESENTS>>>"
;=========BACKGROUND DATA==========
backgroundRLE1:
.db $FE,$2E,$FE,$2E,$FE,$2E,$C6,$2E ;8 BYTES
;ATTRIBUTES AS NORMAL
attributesRLE1:
.db %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
.db %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
.db %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
.db %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
.db %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
.db %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
.db %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
.db %00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000,%00000000
;=========MACROS==========
;loadPalette (HIGH BYTE, LOW BYTE, PALETTE, MAX)
.macro loadPalette
LDA $2002
LDA #\1
STA $2006
LDA #\2
STA $2006
LDX #$00
.Loop\@
LDA \3,X
STA $2007
INX
CPX #\4
BNE .Loop\@
.endm
;loadBackgroundRLE (HIGH BYTE, LOW BYTE, backgroundRLE, MAX BACKGROUND RLE, attributesRLE)
.macro loadBackgroundRLE
.loadBackground\@
LDA $2002
LDA #\1
STA $2006
LDA #\2
STA $2006
LDX #$FF
.loadDataRLE\@
INX
LDA \3,X
STA backgroundMaxRLE
INX
LDY #$00
.loadBackgroundLoop\@
LDA \3,X
STA $2007
INY
CPY backgroundMaxRLE
BNE .loadBackgroundLoop\@
.checkEndOfDataRLE\@
CPX #\4
BCC .loadDataRLE\@
LDX #$00
.loadAttributes\@
LDA \5,X
STA $2007
INX
CPX #$40
BNE .loadAttributes\@
.endm
;typeTextStart (HIGH BYTE, LOW BYTE)
.macro typeTextStart
.checkTextOnce\@
LDA textOnce
BNE .typeTextStartDone\@
.setTextVariables\@
LDA #\1
STA textHi
LDA #\2
STA textLo
LDA #$00
STA textCounter
LDA #$00
STA textTimer
.switchTextOnce\@
INC textOnce
.typeTextStartDone\@
.endm
;typeTextUpdate (textData, FRAME, INDENT BYTE, MAX)
.macro typeTextUpdate
.checkTextFrame\@
LDA textTimer
CMP #\2
BNE .typeTextUpdateDone\@
.checkTextMax\@
LDA textCounter
CMP #\4
BEQ .typeTextUpdateDone\@
.loadText\@
LDA $2002
LDA textHi
STA $2006
LDA textLo
STA $2006
.transferCounterToX\@
LDA textCounter
TAX
.updateTextCounter\@
INC textCounter
.convertByteToASCII\@
LDA \1,X
SEC
SBC #$30
STA \1,X
.writeTextByte\@
STA $2007
.updateTextLowByte\@
INC textLo
LDA textLo
AND #%00011111
BNE .updateLowByteDone\@
LDA textLo
CLC
ADC #\3
STA textLo
.updateLowByteDone\@
.updateTextHighByte\@
LDA textLo
CMP #\3
BNE .updateHighByteDone\@
INC textHi
.updateHighByteDone\@
.resetTextTimer\@
LDA #$00
STA textTimer
.typeTextUpdateDone\@
.endm
;Timer (INDEX, timer, START/STOP/RESET - 2/1/0 )
.macro Timer
LDX #\1
.checkTimerReset\@
LDA #\3
BEQ .resetTimer\@
.checkTimerStop\@
LDA #\3
CMP #$01
BEQ .stopTimer\@
.checkTimerUpdate\@
LDA #\3
CMP #$02
BEQ .updateTimer\@
.updateTimer\@
INC \2,X
JMP .stopTimer\@
.resetTimer\@
LDA #$00
STA \2,X
.stopTimer\@
.endm
.bank 1
.org $E000
Reset:
SEI
CLD
LDX #$40
STX $4017
LDX #$FF
TXS
INX
STX $2000
STX $2001
STX $4010
vBlankWait0:
BIT $2002
BPL vBlankWait0
clearMemory:
LDA #$00
STA $0000,X
STA $0100,X
STA $0300,X
STA $0400,X
STA $0500,X
STA $0600,X
STA $0700,X
LDA #$FE
STA $0200,X
INX
BNE clearMemory
vBlankWait1:
BIT $2002
BPL vBlankWait1
INIT:
vBlankWait2:
BIT $2002
BPL vBlankWait2
loadBackgroundRLE $20,$00,backgroundRLE1,$08,attributesRLE1 ;LOADS A FULL NAMETABLE OF BLACK TILES.
loadPalette $3F,$00,starfoxesPalette,$20 ;LOADS THE PALETTE.
INITDONE:
vBlankWait3:
BIT $2002
BPL vBlankWait3
LDA #%10010000
STA $2000
LDA #%00011110
STA $2001
LDA #$00
STA $2006
STA $2005
STA $2005
STA $2006
gameLoop:
JMP gameLoop
NMI:
LDA #$00
STA $2003
LDA #$02
STA $4014
drawText:
typeTextStart $22,$08
typeTextUpdate introText,$03,$00,$15
Timer $00,textTimer,$02
NMIDONE:
LDA #%10010000
STA $2000
LDA #%00011110
STA $2001
LDA #$00
STA $2006
STA $2006
STA $2005
STA $2005
.include "Controllers.asm"
RTI
;===VECTORS===
.org $FFFA
.dw NMI
.dw Reset
.dw 0
.bank 2
.org $0000
.include "Graphics.chr"