diff --git a/presets/nes/ex1.dasm b/presets/nes/ex1.dasm index 962d1a1b..48783496 100644 --- a/presets/nes/ex1.dasm +++ b/presets/nes/ex1.dasm @@ -35,6 +35,19 @@ Start: .endless jmp .endless ; endless loop +; set palette colors +SetPalette: subroutine +; set PPU address to palette start + PPU_SETADDR $3f00 + ldy #0 +.loop: + lda Palette,y ; lookup byte in ROM + sta PPU_DATA ; store byte to PPU data + iny ; Y = Y + 1 + cpy #32 ; is Y equal to 32? + bne .loop ; not yet, loop + rts ; return to caller + ; fill video RAM with "Hello World" msg HelloVRAM: subroutine ; set PPU address to name table A (row 1, col 1) @@ -54,19 +67,6 @@ HelloMsg: .byte "Hello, World!" .byte 0 ; zero terminator -; set palette colors -SetPalette: subroutine -; set PPU address to palette start - PPU_SETADDR $3f00 - ldy #0 -.loop: - lda Palette,y ; lookup byte in ROM - sta PPU_DATA ; store byte to PPU data - iny ; Y = Y + 1 - cpy #32 ; is Y equal to 32? - bne .loop ; not yet, loop - rts ; return to caller - ;;;;; COMMON SUBROUTINES include "nesppu.dasm" diff --git a/presets/nes/ex2.dasm b/presets/nes/ex2.dasm index d5bc7a64..23060dc4 100644 --- a/presets/nes/ex2.dasm +++ b/presets/nes/ex2.dasm @@ -37,6 +37,18 @@ Start: .endless jmp .endless ; endless loop +; set palette colors +SetPalette: subroutine + PPU_SETADDR $3f00 + ldy #0 +.loop: + lda Palette,y ; lookup byte in ROM + sta PPU_DATA ; store byte to PPU data + iny ; Y = Y + 1 + cpy #32 ; is Y equal to 32? + bne .loop ; not yet, loop + rts ; return to caller + ; fill video RAM FillVRAM: subroutine PPU_SETADDR $2000 @@ -55,18 +67,6 @@ PageData: hex 42424242 ; 'B' hex 41414141 ; 'A' -; set palette colors -SetPalette: subroutine - PPU_SETADDR $3f00 - ldy #0 -.loop: - lda Palette,y ; lookup byte in ROM - sta PPU_DATA ; store byte to PPU data - iny ; Y = Y + 1 - cpy #32 ; is Y equal to 32? - bne .loop ; not yet, loop - rts ; return to caller - ;;;;; COMMON SUBROUTINES diff --git a/presets/nes/ex3.dasm b/presets/nes/ex3.dasm index 6291f305..70d1c262 100644 --- a/presets/nes/ex3.dasm +++ b/presets/nes/ex3.dasm @@ -41,6 +41,18 @@ Start: .endless jmp .endless ;endless loop +; set palette colors +SetPalette: subroutine + PPU_SETADDR $3f00 + ldy #0 +.loop: + lda Palette,y ; lookup byte in ROM + sta PPU_DATA ; store byte to PPU data + iny ; Y = Y + 1 + cpy #32 ; is Y equal to 32? + bne .loop ; not yet, loop + rts ; return to caller + ; fill video RAM FillVRAM: subroutine PPU_SETADDR $2000 @@ -81,18 +93,6 @@ MoveSprites: subroutine bne .loop ; loop until X wraps rts ; return to caller -; set palette colors -SetPalette: subroutine - PPU_SETADDR $3f00 - ldy #0 -.loop: - lda Palette,y ; lookup byte in ROM - sta PPU_DATA ; store byte to PPU data - iny ; Y = Y + 1 - cpy #32 ; is Y equal to 32? - bne .loop ; not yet, loop - rts ; return to caller - ;;;;; COMMON SUBROUTINES diff --git a/presets/nes/ex4.dasm b/presets/nes/ex4.dasm index 9afb9f0f..8460facf 100644 --- a/presets/nes/ex4.dasm +++ b/presets/nes/ex4.dasm @@ -36,6 +36,18 @@ Start: .endless jmp .endless ;endless loop +; set palette colors +SetPalette: subroutine + PPU_SETADDR $3f00 + ldy #0 +.loop: + lda Palette,y ; lookup byte in ROM + sta PPU_DATA ; store byte to PPU data + iny ; Y = Y + 1 + cpy #32 ; is Y equal to 32? + bne .loop ; not yet, loop + rts ; return to caller + ; fill video RAM FillVRAM: subroutine PPU_SETADDR $2000 @@ -49,18 +61,6 @@ FillVRAM: subroutine bne .loop rts -; set palette colors -SetPalette: subroutine - PPU_SETADDR $3f00 - ldy #0 -.loop: - lda Palette,y ; lookup byte in ROM - sta PPU_DATA ; store byte to PPU data - iny ; Y = Y + 1 - cpy #32 ; is Y equal to 32? - bne .loop ; not yet, loop - rts ; return to caller - ;;;;; COMMON SUBROUTINES diff --git a/presets/nes/musicdemo.dasm b/presets/nes/musicdemo.dasm index 04ac0d7e..f1978262 100644 --- a/presets/nes/musicdemo.dasm +++ b/presets/nes/musicdemo.dasm @@ -80,7 +80,7 @@ ShowTimeEnd: include "nesppu.dasm" - include "famitone2.asm" + include "famitone2.dasm" ;;;;; INTERRUPT HANDLERS