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