nes/main.s

94 lines
1.3 KiB
ArmAsm

.segment "HEADER"
.byte $4E, $45, $53, $1A ;Nes header identifier
.byte 2 ;2x 16KB PRG code
.byte 1 ; 1x 8KB CHR Data
.byte $01, $00 ; mapper 0, vertical mirroring
.segment "VECTORS"
.addr nmi ; nmi interrupt
.addr reset ; reset interrupt
.addr 0 ; external interrupt
.segment "STARTUP"
.segment "CHARS"
.incbin "./CHR-ROM.bin"
.segment "CODE"
bg_pallets:
.byte 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
check:
cmp #5
bcc skip
clc
adc #3
skip:
rts
reset:
ldx #0
lda #$3F
sta $2006
lda #$00
sta $2006
loop:
lda bg_pallets, x
sta $2007
inx
cpx #16
bne loop
lda #173
sta $00
lda #0
sta $01
sta $02
dabble:
; check first digit
lda $01
and #$F
jsr check
sta $03
lda #$F0
and $01
ora $03
sta $01
; check second digit
lda $01
and #$F0
lsr
lsr
lsr
lsr
jsr check
asl
asl
asl
asl
sta $03
lda #$F
and $01
ora $03
sta $01
; check third digit
lda $02
and #$F
jsr check
sta $03
lda #$F0
and $02
ora $03
sta $02
; Shift
clc
rol $00
rol $01
rol $02
lda $00
cmp #0
bne dabble
rts
nmi:
rti