From 1ab6ee37f3a7a04a3cac0c6ffcf2bb34d052cf1a Mon Sep 17 00:00:00 2001 From: Colin McMillen Date: Fri, 22 May 2015 15:09:14 -0400 Subject: [PATCH] Set background color on every frame. Make some comments more clear. --- header.asm | 2 ++ pewpew.asm | 18 +++++++++--------- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/header.asm b/header.asm index eded764..cca4917 100644 --- a/header.asm +++ b/header.asm @@ -53,4 +53,6 @@ EmptyHandler: .ENDS +; Fills unused areas with $00. +; This is the opcode for BRK, which will halt the SNES if executed. .EMPTYFILL $00 \ No newline at end of file diff --git a/pewpew.asm b/pewpew.asm index c53a69a..ddc662e 100644 --- a/pewpew.asm +++ b/pewpew.asm @@ -16,12 +16,7 @@ Start: InitSNES ; Initialize SNES. - - ; Set the background color. - ; $2121 is the color palette selection register [CGADD]. - ; Storing 0 because that's the SNES background color. - stz $2121 - + ; Turn on the screen. ; $2100: Screen display register [INIDISP] ; @@ -148,7 +143,7 @@ JoypadY: bne JoypadDone ; Button not pressed. lda $21 cmp #0 - beq JoypadDone + beq JoypadDone ; Value saturated. dec $21 JoypadDone: @@ -174,7 +169,7 @@ SetBackgroundColor: ; $20 $21 $22 are (R, G, B), each ranging from [0-31]. ; The palette color format is 15-bit: [0bbbbbgg][gggrrrrr] - ; Compute and store the low-order byte. + ; Compute and the low-order byte and store it in CGDATA. lda $21 ; Green. .rept 5 asl @@ -182,7 +177,7 @@ SetBackgroundColor: ora $20 ; Red. sta $2122 - ; Compute and store the high-order byte. + ; Compute the high-order byte and store it in CGDATA. lda $22 ; Blue. .rept 2 asl @@ -194,6 +189,11 @@ SetBackgroundColor: .endr ora $00 sta $2122 + + ; Set the background color. + ; $2121 is the color palette selection register [CGADD]. + ; Entry 0 corresponds to the SNES background color. + stz $2121 rts