pikuma_6502_nes/helloppu/helloppu.asm

68 lines
2.1 KiB
NASM
Raw Normal View History

2022-11-29 03:55:23 +00:00
.include "consts.inc"
.include "header.inc"
.include "reset.inc"
2022-11-28 18:15:40 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; PRG-ROM code located at $8000
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
.segment "CODE"
2022-11-29 03:55:23 +00:00
.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
2022-11-28 18:15:40 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Reset handler (called when the NES resets or powers on)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Reset:
2022-11-29 03:55:23 +00:00
INIT_NES
2022-11-28 18:15:40 +00:00
Main:
2022-11-29 03:55:23 +00:00
bit PPU_STATUS ; reset the latch
ldx #$3F
stx PPU_ADDR
ldx #$00
stx PPU_ADDR
2022-11-28 18:15:40 +00:00
2022-11-29 03:55:23 +00:00
jsr LoadPalette ;jump to subroutine
2022-11-28 18:15:40 +00:00
2022-11-29 03:55:23 +00:00
lda #%00011110
sta PPU_MASK
2022-11-28 18:15:40 +00:00
LoopForever:
2022-11-29 03:55:23 +00:00
jmp LoopForever
2022-11-28 18:15:40 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; NMI interrupt handler
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
NMI:
2022-11-29 03:55:23 +00:00
rti ; Return from interrupt
2022-11-28 18:15:40 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; IRQ interrupt handler
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
IRQ:
2022-11-29 03:55:23 +00:00
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
2022-11-28 18:15:40 +00:00
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; 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