68 lines
2.1 KiB
NASM
Executable File
68 lines
2.1 KiB
NASM
Executable File
.include "consts.inc"
|
|
.include "header.inc"
|
|
.include "reset.inc"
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; PRG-ROM code located at $8000
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
.segment "CODE"
|
|
|
|
.proc LoadPalette
|
|
ldy #0
|
|
LoopPalette: ;unnamed label
|
|
lda PaletteData,y ; lookup byte in ROM
|
|
sta PPU_DATA ; set the value to send to PPU_DATA,
|
|
; will auto increment PPU_ADDR
|
|
|
|
iny
|
|
cpy #32
|
|
bne LoopPalette ; loop to previous label
|
|
|
|
rts ;return from subroutine
|
|
.endproc
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; Reset handler (called when the NES resets or powers on)
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
Reset:
|
|
INIT_NES
|
|
|
|
Main:
|
|
bit PPU_STATUS ; reset the latch
|
|
ldx #$3F
|
|
stx PPU_ADDR
|
|
ldx #$00
|
|
stx PPU_ADDR
|
|
|
|
jsr LoadPalette ;jump to subroutine
|
|
|
|
lda #%00011110
|
|
sta PPU_MASK
|
|
|
|
LoopForever:
|
|
jmp LoopForever
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; NMI interrupt handler
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
NMI:
|
|
rti ; Return from interrupt
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; IRQ interrupt handler
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
IRQ:
|
|
rti ; Return from interrupt
|
|
|
|
PaletteData:
|
|
.byte $0F,$2A,$0C,$3A, $0F,$2A,$0C,$3A, $0F,$2A,$0C,$3A, $0F,$2A,$0C,$3A ; background
|
|
.byte $0F,$10,$00,$26, $0F,$10,$00,$26, $0F,$10,$00,$26, $0F,$10,$00,$26 ; sprite
|
|
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;; Vectors with the addresses of the handlers that we always add at $FFFA
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
.segment "VECTORS"
|
|
.word NMI ; Address (2 bytes) of the NMI handler
|
|
.word Reset ; Address (2 bytes) of the Reset handler
|
|
.word IRQ ; Address (2 bytes) of the IRQ handler
|