2022-06-13 16:00:17 -07:00
|
|
|
.p816
|
|
|
|
.smart
|
|
|
|
|
|
|
|
.include "macros.inc"
|
|
|
|
.include "registers.inc"
|
2022-06-16 13:40:58 -07:00
|
|
|
.include "keys.inc"
|
2022-06-13 16:00:17 -07:00
|
|
|
|
|
|
|
.include "header.asm"
|
|
|
|
|
2022-06-16 14:33:46 -07:00
|
|
|
.segment "ZEROPAGE"
|
|
|
|
|
|
|
|
nmi_count: .res 2
|
|
|
|
|
2022-06-13 16:00:17 -07:00
|
|
|
.segment "CODE"
|
|
|
|
|
2022-06-13 17:09:27 -07:00
|
|
|
VRAM_CHARS = $0000
|
|
|
|
VRAM_BG1 = $1000
|
|
|
|
|
2022-06-13 16:00:17 -07:00
|
|
|
start:
|
|
|
|
.include "init.asm"
|
|
|
|
|
|
|
|
; Set up the color palette
|
|
|
|
stz CGADD
|
2022-06-13 17:09:27 -07:00
|
|
|
|
|
|
|
; Color 0 - black
|
|
|
|
lda #$00
|
|
|
|
sta CGDATA
|
|
|
|
lda #$00
|
|
|
|
sta CGDATA
|
|
|
|
|
|
|
|
; Color 1 - red
|
2022-06-13 17:12:37 -07:00
|
|
|
lda #$1f
|
2022-06-13 17:09:27 -07:00
|
|
|
sta CGDATA
|
2022-06-13 17:12:37 -07:00
|
|
|
lda #$00
|
2022-06-13 17:09:27 -07:00
|
|
|
sta CGDATA
|
|
|
|
|
2022-06-15 11:06:47 -07:00
|
|
|
; Color 2 - green
|
2022-06-13 17:09:27 -07:00
|
|
|
lda #$e0
|
2022-06-13 16:00:17 -07:00
|
|
|
sta CGDATA
|
2022-06-13 16:00:41 -07:00
|
|
|
lda #$03
|
2022-06-13 16:00:17 -07:00
|
|
|
sta CGDATA
|
|
|
|
|
2022-06-15 11:06:47 -07:00
|
|
|
; Color 3 - blue
|
2022-06-13 17:09:27 -07:00
|
|
|
lda #$00
|
|
|
|
sta CGDATA
|
|
|
|
lda #$7c
|
|
|
|
sta CGDATA
|
|
|
|
|
|
|
|
; Graphics mode 0, 8x8 tiles
|
|
|
|
stz BGMODE
|
|
|
|
|
|
|
|
; Set BG1 and tile map and character data
|
|
|
|
lda #>VRAM_BG1
|
|
|
|
sta BG1SC
|
|
|
|
lda #VRAM_CHARS
|
|
|
|
sta BG12NBA
|
|
|
|
|
|
|
|
; Load character data into VRAM
|
|
|
|
lda #$80
|
|
|
|
sta VMAIN
|
|
|
|
ldx #VRAM_CHARS
|
|
|
|
stx VMADDL
|
|
|
|
@charset_loop:
|
|
|
|
lda charset,x
|
|
|
|
sta VMDATAL
|
|
|
|
inx
|
|
|
|
lda charset,x
|
|
|
|
sta VMDATAH
|
|
|
|
inx
|
|
|
|
cpx #(charset_end - charset)
|
|
|
|
bne @charset_loop
|
|
|
|
|
2022-06-13 18:06:18 -07:00
|
|
|
; Manually clear screen
|
|
|
|
ldx #(VRAM_BG1)
|
|
|
|
@loop:
|
|
|
|
stx VMADDL
|
2022-06-15 11:10:07 -07:00
|
|
|
lda #$00
|
2022-06-15 11:08:30 -07:00
|
|
|
sta VMDATAL
|
2022-06-13 18:06:18 -07:00
|
|
|
stz VMDATAH
|
|
|
|
inx
|
|
|
|
cpx #(VRAM_BG1 + 32 * 29)
|
|
|
|
bne @loop
|
|
|
|
|
2022-06-13 17:09:27 -07:00
|
|
|
; write tile to position (1, 1)
|
|
|
|
TILE_X = 1
|
|
|
|
TILE_Y = 1
|
|
|
|
ldx #(VRAM_BG1 + (TILE_Y * 32) + TILE_X)
|
|
|
|
stx VMADDL
|
|
|
|
lda #$01 ; tile number
|
|
|
|
sta VMDATAL
|
|
|
|
stz VMDATAH
|
|
|
|
|
|
|
|
; Show bg1
|
|
|
|
lda #%00000001
|
|
|
|
sta TM
|
|
|
|
|
2022-06-13 16:00:17 -07:00
|
|
|
lda #$0f
|
|
|
|
sta INIDISP
|
|
|
|
|
2022-06-16 14:33:46 -07:00
|
|
|
lda #%10000001
|
2022-06-15 11:30:27 -07:00
|
|
|
sta NMITIMEN
|
|
|
|
|
|
|
|
mainloop:
|
2022-06-16 14:33:46 -07:00
|
|
|
|
|
|
|
lda nmi_count
|
|
|
|
nmi_check:
|
|
|
|
wai
|
|
|
|
cmp nmi_count
|
|
|
|
beq nmi_check
|
|
|
|
|
|
|
|
|
2022-06-16 13:40:58 -07:00
|
|
|
lda JOY1L
|
|
|
|
bit #JOYL_L
|
2022-06-15 11:30:27 -07:00
|
|
|
beq down_not_pressed
|
|
|
|
; write tile 2 to position (4, 8)
|
|
|
|
TILE_X2= 4
|
|
|
|
TILE_Y2= 8
|
|
|
|
ldx #(VRAM_BG1 + (TILE_Y2* 32) + TILE_X2)
|
|
|
|
stx VMADDL
|
|
|
|
lda #$02
|
|
|
|
sta VMDATAL
|
|
|
|
stz VMDATAH
|
|
|
|
down_not_pressed:
|
|
|
|
|
|
|
|
bra mainloop
|
|
|
|
|
2022-06-13 16:00:17 -07:00
|
|
|
busywait:
|
|
|
|
bra busywait
|
|
|
|
|
|
|
|
nmi:
|
|
|
|
bit RDNMI
|
2022-06-16 14:33:46 -07:00
|
|
|
inc nmi_count
|
2022-06-13 16:00:17 -07:00
|
|
|
_rti:
|
|
|
|
rti
|
2022-06-13 17:09:27 -07:00
|
|
|
|
|
|
|
.include "charset.asm"
|