NMI:
LDA #$00
STA $2003 ; set the low byte (00) of the RAM address
LDA #$02
STA $4014 ; set the high byte (02) of the RAM address, start the transfer
JSR DrawScore
;;This is the PPU clean up section, so rendering the next frame starts properly.
LDA #%10010000 ; enable NMI, sprites from Pattern Table 0, background from Pattern Table 1
STA $2000
LDA #%00011110 ; enable sprites, enable background, no clipping on left side
STA $2001
LDA #$00 ;;tell the ppu there is no background scrolling
STA $2005
STA $2005
;;;all graphics updates done by here, run game engine
JSR ReadController1 ;;get the current button data for player 1
JSR ReadController2 ;;get the current button data for player 2
GameEngine:
LDA gamestate
CMP #STATETITLE
BEQ EngineTitle ;;game is displaying title screen
LDA gamestate
CMP #STATEGAMEOVER
BEQ EngineGameOver ;;game is displaying ending screen
LDA gamestate
CMP #STATEPLAYING
BEQ EnginePlaying ;;game is playing
GameEngineDone:
JSR UpdateSprites ;;set ball/paddle sprites from positions
RTI ; return from interrupt