getting closer

This commit is contained in:
Brooke Vibber 2022-12-07 20:37:52 -08:00
parent 589ccdc7f1
commit 1c7a7551d7
2 changed files with 54 additions and 55 deletions

View file

@ -741,9 +741,11 @@ ${byte2byte(frames[1].bitmap.slice(half))}
.align 1024 .align 1024
displaylist: displaylist:
; 40 lines overscan ; 40 lines overscan
.repeat 5 .repeat 4
.byte $70 ; 8 blank lines .byte $70 ; 8 blank lines
.endrep .endrep
; include a DLI to mark us as frame 0
.byte $f0 ; 8 blank lines
; 160 lines graphics ; 160 lines graphics
; ANTIC mode e (160px 2bpp, 1 scan line per line) ; ANTIC mode e (160px 2bpp, 1 scan line per line)

105
dither4.s
View file

@ -1,4 +1,7 @@
SAVMSC = $58 SAVMSC = $58
VDSLST = $200
VDSLSTL = $200
VDSLSTH = $201
COLPF0 = $D016 COLPF0 = $D016
COLPF1 = $D017 COLPF1 = $D017
COLPF2 = $D018 COLPF2 = $D018
@ -24,6 +27,7 @@ sample_ptrh = $85
sample_ptr = sample_ptrl sample_ptr = sample_ptrl
scanline = $86 scanline = $86
audiotemp = $87 audiotemp = $87
frame_counter = $89
height = 160 height = 160
bytes_per_line = 40 bytes_per_line = 40
@ -99,6 +103,16 @@ audio_high_byte:
lda #.hibyte(displaylist) lda #.hibyte(displaylist)
sta DLISTH sta DLISTH
; Set up the DLI handler
lda #.lobyte(dli_handler)
sta VDSLSTL
lda #.hibyte(dli_handler)
sta VDSLSTH
; Disable VBI but allow Reset and DLI
lda #$a0
sta NMIEN
; Manually wait for first scan line ; Manually wait for first scan line
wait_vblank: wait_vblank:
sta WSYNC sta WSYNC
@ -113,25 +127,28 @@ wait_start:
; Wait for the vblank ; Wait for the vblank
; Resynchronize the scanline counter ; Resynchronize the scanline counter
wait_loop: wait_loop:
lda VCOUNT ldy VCOUNT
tay ; save for audio lookup
bne wait_loop bne wait_loop
lda #(256 - scanline_offset)
sta scanline
each_scanline:
.macro audio_prep .macro audio_prep
; Y is VCOUNT at entry ; Y is VCOUNT at entry
lda (sample_ptr),y ; 5/6 cyc lda (sample_ptr),y ; 5/6 cyc
sta audiotemp ; 3 cyc sta audiotemp ; 3 cyc
.endmacro .endmacro
.macro inner_scanline frame_base .macro inner_scanline palette1, palette2, palette3
; it'll fire on unused lines, but harmlessly ; it'll fire on unused lines, but harmlessly
ldy scanline ; 3 cyc ldy scanline ; 3 cyc
inc scanline ; 5 cyc inc scanline ; 5 cyc
; Leisurely memory fetches ; Leisurely memory fetches
; lda palette1,y ; 5 @FIXME alternate
; pha ; ...3?
; ldx palette2,y ; 5
; lda palette3,y ; 5
; tay
; pla
lda frame1_palette1,y ; 5 @FIXME alternate lda frame1_palette1,y ; 5 @FIXME alternate
pha ; ...3? pha ; ...3?
ldx frame1_palette2,y ; 5 ldx frame1_palette2,y ; 5
@ -186,57 +203,37 @@ each_scanline:
audio_cont: audio_cont:
.endmacro .endmacro
;audio_prep .macro run_frame palette1, palette2, palette3
inner_scanline .scope
;audio_play_lo each_scanline:
inner_scanline ;audio_prep
;audio_play_hi inner_scanline palette1, palette2, palette3
;audio_play_lo
inner_scanline palette1, palette2, palette3
;audio_play_hi
lda VCOUNT ldy VCOUNT ; save for audio lookup
tay ; save for audio lookup cpy #130
cmp #130 ;#130 bne each_scanline
bne each_scanline ;audio_inc
audio_inc inc frame_counter
jmp wait_start jmp wait_start
.endscope
.endmacro
lda #(256 - scanline_offset)
sta scanline
lda frame_counter
bne run_frame2
run_frame frame1_palette1, frame1_palette2, frame1_palette3
run_frame2:
run_frame frame2_palette1, frame2_palette2, frame2_palette3
.endproc .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: .proc dli_handler
ldy #00 lda #0
sta frame_counter
copy_loop_bytes: rti
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 .endproc