Skip to content

Commit

Permalink
Update Z80 driver
Browse files Browse the repository at this point in the history
  • Loading branch information
viciious committed Aug 25, 2023
1 parent 10a76b9 commit 6dc12c4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src-md/z80_vgm.s80
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,13 @@ waiting
; timer ticks ~= sample delay * 1.2
calc_timer
LD HL,(LOCAL_MEM+FM_SMPL)
LD BC,HL
#if ACCURATE
LD BC,54928 ; 65535 / 1.1953125
OR A ; clear carry
SBC HL,BC
JR NC,overflow
ADD HL,BC
LD BC,HL
SRL B
RR C
SRL B
Expand All @@ -203,23 +208,22 @@ calc_timer
SRL B
RR C ; samples/128
ADD HL,BC
JR C,overflow
POP BC
ADD HL,BC
JR C,overflow
POP BC
ADD HL,BC ; ticks = samples * 1.1953125
JR set_timer
#else
LD BC,HL
SRL B
RR C
SRL B
RR C ; samples >> 2
ADD HL,BC ; ticks = samples * 1.25
#endif
JR NC,set_timer
#endif
overflow
LD HL,$FFFF ; saturate to word ($FFFF)

LD HL,$FFFF
set_timer
LD (LOCAL_MEM+FM_TICL),HL ; save total ticks
LD (LOCAL_MEM+FM_TTTL),HL ; ticks for timer A = ticks
Expand Down

0 comments on commit 6dc12c4

Please sign in to comment.