Skip to content

Commit c391be8

Browse files
committed
Fix ym2610 reentrant write to port A (part 2)
Follow up fix to f5e2268, in the interrupt handler, the driver should not recapture the register context when writing to the YM2610's port A.
1 parent 1dd7529 commit c391be8

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

nullsound/timer.s

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ update_timer_state_tracker::
8686
call ym2610_wait_available
8787

8888
;; reset interrupt timer B
89+
;; YM2610 register context is only captured by regular code,
90+
;; i.e. outside of the interrupt handler
8991
ld b, #REG_TIMER_FLAGS
9092
ld c, #0x2a
91-
call ym2610_write_port_a
93+
call ym2610_write_port_a_no_ctx
9294

9395
;; step2: at this stage, if we interrupted a ym2610_write_port_a,
9496
;; restore the YM2610 register context before returning from the

nullsound/ym2610.s

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,25 @@ ym2610_write_port_a::
6363
pop af
6464
ret
6565

66+
;;; ym2610_write_port_a_no_ctx
67+
;;; --------------------------
68+
;;; IN:
69+
;;; b: register address in ym2610
70+
;;; c: data to set
71+
;;; (all registers are preserved)
72+
ym2610_write_port_a_no_ctx::
73+
push af
74+
;; select register address
75+
ld a, b
76+
out (PORT_YM2610_A_ADDR), a
77+
call _ym2610_wait_address_write
78+
;; set data in the selected register
79+
ld a, c
80+
out (PORT_YM2610_A_VALUE), a
81+
call _ym2610_wait_data_write
82+
pop af
83+
ret
84+
6685
;;; ym2610_write_port_b
6786
;;; -------------------
6887
;;; IN:

0 commit comments

Comments
 (0)