I own a SUPER NES EMULATOR SE with Assembler, Linker and Debugger.
I modified a public code for assemble and link it. After assemble it without error, I found 2 issues when run it:
First : $4212 register never return $01 but $?2. How is possible to return 2 value when only bit 0, 6 an 7 can be set?
Second : When I CMP with $02 value in VBlank, only the first two conditions works (Red and Yellow BEQ) but not all others.
Please, look at the screenshot attachment. I can provide the ISX file is needed. Thanks for your help!
Here is the main file code :
Code: Select all
; bgcolor
; Press the A, B, X and Y buttons to change the background color.
file head.s
file reg.s
file set.s
file val.s
file init.s
bank0 group 0
org $8000
Reset:
Reset
Main:
; Set accumulator register to 8-bit
sep #$20
; Set color 0 of palette 0 to white
stz CGADD
lda #$FF
sta CGDATA
lda #$7F
sta CGDATA
; Enable the screen at full brightness
lda #$0F
sta INIDISP
; Enable VBlank and the joypad
lda #(NMITIMEN_NMI_ENABLE | NMITIMEN_JOY_ENABLE)
sta NMITIMEN
; Keep waiting for interrupts
w00 wai
jmp w00
VBlank:
; Wait until the joypad input can be read
lda #HVBJOY_JOYREADY
w01 and HVBJOY
cmp #HVBJOY_JOYREADY
bne w01
; Prepare to change color 0 of palette 0
stz CGADD
; Reset accumulator register to 16-bit
rep #$20
on16a
; Jump to label Yellow if the A and Y buttons were pressed
lda #(JOY_RED + JOY_GREEN)
and JOY1
cmp #(JOY_RED + JOY_GREEN)
beq Yellow
; Jump to label Red if the A button was pressed
lda #JOY_RED
and JOY1
cmp #JOY_RED
beq Red
; Jump to label Yellow if the B button was pressed
lda #JOY_YELLOW
and JOY1
cmp #JOY_YELLOW
beq Yellow
; Jump to label Blue if the X button was pressed
lda #JOY_BLUE
and JOY1
cmp #JOY_BLUE
beq Blue
; Jump to label Green if the Y button was pressed
lda #JOY_GREEN
and JOY1
cmp #JOY_GREEN
beq Green
lda #RDNMI
off16a
rti
Red:
; Set accumulator register back to 8-bit
sep #$20
; Set color 0 of palette 0 to red
lda #%00011111
sta CGDATA
lda #%00000000
sta CGDATA
rti
Green:
; Set accumulator register back to 8-bit
sep #$20
; Set color 0 of palette 0 to green
lda #%11100000
sta CGDATA
lda #%00000011
sta CGDATA
rti
Blue:
; Set accumulator register back to 8-bit
sep #$20
; Set color 0 of palette 0 to blue
lda #%00000000
sta CGDATA
lda #%01111100
sta CGDATA
rti
Yellow:
; Set accumulator register back to 8-bit
sep #$20
; Set color 0 of palette 0 to yellow
lda #%11111111
sta CGDATA
lda #%00000011
sta CGDATA
rti
EmptyHandler:
rti
end