viz ok, audio needs work

This commit is contained in:
Brooke Vibber 2022-11-30 03:04:31 -08:00
parent 6776951aea
commit d44924aeb4

View file

@ -25,11 +25,14 @@ temp2 = temp2l
sample_ptrl = $84 sample_ptrl = $84
sample_ptrh = $85 sample_ptrh = $85
sample_ptr = sample_ptrl sample_ptr = sample_ptrl
scanline = $86
height = 192 height = 192
bytes_per_line = 40 bytes_per_line = 40
pages_per_frame = 32 pages_per_frame = 32
lines_per_frame = 262 lines_per_frame = 262
scanline_offset = 31
scanline_max = (lines_per_frame - scanline_offset) / 2
.data .data
@ -108,7 +111,7 @@ displaylist:
; Manually wait for first scan line ; Manually wait for first scan line
wait_vblank: wait_vblank:
;sta WSYNC sta WSYNC
lda VCOUNT lda VCOUNT
bne wait_vblank bne wait_vblank
@ -116,44 +119,40 @@ wait_vblank:
lda #$22 lda #$22
sta DMACTL sta DMACTL
; Wait for the next even scanline (VCOUNT is scan line / 2, so look for a change)
wait_start: wait_start:
lda VCOUNT ; Wait for the vblank
sta temp1 ; Resynchronize the scanline counter
wait_loop: wait_loop:
lda VCOUNT lda VCOUNT
cmp temp1 bne wait_loop
beq wait_loop lda #(256 - scanline_offset)
sta scanline
each_scanline: each_scanline:
lda VCOUNT
; Resynchronize the scanline counter
; it'll fire on unused lines, but harmlessly ; it'll fire on unused lines, but harmlessly
clc
sbc #15
asl
tay
.macro audio_prep .macro audio_prep
; audio sample; low nybble ; audio sample; low nybble
ldx #0 ;ldx #0
lda (sample_ptr,x) ;lda (sample_ptr,x)
sta temp2 ;sta temp2
; high nybble ; high nybble
lsr a ;lsr a
lsr a ;lsr a
lsr a ;lsr a
lsr a ;lsr a
; set the volume-only bit ; set the volume-only bit
ora #$10 ;ora #$10
pha ;pha
; low nybble ; low nybble
lda temp2 ;lda temp2
and #$0f ;and #$0f
; set the volume-only bit ; set the volume-only bit
ora #$10 ;ora #$10
lda #0
pha
pha pha
.endmacro .endmacro
@ -182,6 +181,8 @@ each_scanline:
.endmacro .endmacro
.macro inner_scanline .macro inner_scanline
ldy scanline
; Leisurely memory fetches ; Leisurely memory fetches
lda palette1,y lda palette1,y
pha pha
@ -199,19 +200,22 @@ each_scanline:
sty COLPF2 sty COLPF2
; Audio sample ; Audio sample
pla ;pla
sta AUDC1 ;sta AUDC1
.endmacro .endmacro
audio_prep ;audio_prep
inner_scanline inner_scanline
inc scanline
audio_inc ;audio_inc ; too slow?
iny
inner_scanline inner_scanline
inc scanline
;jmp wait_start lda VCOUNT
jmp each_scanline cmp #130
bne each_scanline
jmp wait_start
.endproc .endproc