176 lines
2.6 KiB
ArmAsm
176 lines
2.6 KiB
ArmAsm
SAVMSC = $58
|
|
SDMCTL = $22F
|
|
SDLSTL = $230
|
|
SDLSTH = $231
|
|
COLPF0 = $D016
|
|
COLPF1 = $D017
|
|
COLPF2 = $D018
|
|
COLPF3 = $D019
|
|
COLBK = $D01A
|
|
|
|
WSYNC = $D40A
|
|
VCOUNT = $D40B
|
|
NMIEN = $D40E
|
|
|
|
framebuffer = $a000
|
|
framebuffer2 = $b000
|
|
|
|
temp1l = $80
|
|
temp1h = $81
|
|
temp1 = temp1l
|
|
temp2l = $82
|
|
temp2h = $83
|
|
temp2 = temp2l
|
|
|
|
height = 192
|
|
bytes_per_line = 40
|
|
pages_per_frame = 32
|
|
|
|
.data
|
|
|
|
.import palette1
|
|
.import palette2
|
|
.import palette3
|
|
.import bitmap
|
|
|
|
displaylist:
|
|
; @fixme resolve the line counts
|
|
.repeat 3
|
|
.byte $70 ; 8 blank lines
|
|
.endrep
|
|
; ANTIC mode e (160px 2bpp, 1 scan line per line)
|
|
.byte $4e
|
|
.addr framebuffer
|
|
.repeat height / 2 - 1
|
|
.byte $0e
|
|
.endrep
|
|
.byte $4e
|
|
.addr framebuffer2
|
|
.repeat height / 2 - 1
|
|
.byte $0e
|
|
.endrep
|
|
.repeat 3
|
|
.byte $70 ; 8 blank lines
|
|
.endrep
|
|
.byte $41 ; jump and blank
|
|
.addr displaylist
|
|
|
|
|
|
.code
|
|
|
|
.export start
|
|
|
|
.proc start
|
|
; Copy the bitmap into our framebuffer
|
|
lda #.lobyte(bitmap)
|
|
sta temp1l
|
|
lda #.hibyte(bitmap)
|
|
sta temp1h
|
|
lda #.lobyte(framebuffer)
|
|
sta temp2h
|
|
lda #.hibyte(framebuffer)
|
|
sta temp2h
|
|
jsr copy_half_frame
|
|
|
|
; Second half of bitmap has to be separately aligned
|
|
lda #.lobyte(framebuffer2)
|
|
sta temp2h
|
|
lda #.hibyte(framebuffer2)
|
|
sta temp2h
|
|
jsr copy_half_frame
|
|
|
|
|
|
; Disable display DMA
|
|
lda #$00
|
|
sta SDMCTL
|
|
|
|
; Set up the display list
|
|
lda #.lobyte(displaylist)
|
|
sta SDLSTL
|
|
lda #.hibyte(displaylist)
|
|
sta SDLSTH
|
|
|
|
; Manually wait for first scan line
|
|
wait_vblank:
|
|
lda VCOUNT
|
|
bne wait_vblank
|
|
|
|
; Re-enable display DMA
|
|
lda #$22
|
|
sta SDMCTL
|
|
|
|
wait_start:
|
|
sta WSYNC
|
|
lda VCOUNT
|
|
cmp #15
|
|
bne wait_start
|
|
ldy #0
|
|
|
|
each_scanline:
|
|
tya
|
|
pha
|
|
|
|
lda palette1,y
|
|
pha
|
|
ldx palette2,y
|
|
lda palette3,y
|
|
tay
|
|
pla
|
|
|
|
; Wait for horizontal blank
|
|
sta WSYNC
|
|
|
|
; Update color registers as fast as possible
|
|
sta COLPF0
|
|
stx COLPF1
|
|
sty COLPF2
|
|
|
|
pla
|
|
tay
|
|
iny
|
|
cpy height
|
|
bne each_scanline
|
|
|
|
jmp wait_start
|
|
|
|
.endproc
|
|
|
|
; temp1 contains source address
|
|
; temp2 contains dest address
|
|
; clobbers a/x/y
|
|
; incremepts temp1 and temp2 to the end of their regions
|
|
.proc copy_half_frame
|
|
ldx #0
|
|
|
|
copy_loop_lines:
|
|
ldy #00
|
|
|
|
copy_loop_bytes:
|
|
lda (temp1),y
|
|
sta (temp2),y
|
|
iny
|
|
cpy #bytes_per_line
|
|
bne copy_loop_bytes
|
|
|
|
clc
|
|
lda temp1l
|
|
adc #bytes_per_line
|
|
sta temp1l
|
|
lda temp1h
|
|
adc #00
|
|
sta temp1h
|
|
|
|
clc
|
|
lda temp2l
|
|
adc #bytes_per_line
|
|
sta temp2l
|
|
lda temp2h
|
|
adc #00
|
|
sta temp2h
|
|
|
|
inx
|
|
cpx #(height / 2)
|
|
bne copy_loop_lines
|
|
|
|
rts
|
|
.endproc
|