fix R7 write

This commit is contained in:
wbcbz7 2025-08-14 19:33:16 +07:00
parent 0f6da89826
commit 347ca2f9a6
2 changed files with 31 additions and 23 deletions

View file

@ -42,8 +42,20 @@ start:
.loop: .loop:
halt halt
ld a, 1 : out (0xfe), a ld a, 1 : out (0xfe), a
ld bc, 0xFFFD
ld de, 0x00C0
ld a, 0b11111000
out (c), a
ld hl, reg_buffer
call player.reg_out call player.reg_out
ld a, 2 : out (0xfe), a ld a, 2 : out (0xfe), a
ld a, 0b11111001
ld b, 0xFF
out (c), a
inc hl
call player.reg_out
ld a, 3 : out (0xfe), a
ld iy, reg_buffer
call player.play_tick call player.play_tick
xor a : out (0xfe), a xor a : out (0xfe), a

View file

@ -70,14 +70,11 @@ player_struct player_struct_t player_channels+(channel_struct_t*(3+0)+channel_
; ----------------------------- ; -----------------------------
; ----------------------------- ; -----------------------------
; OPN register dump output ; OPN register dump output
; in: HL - registers in (reg:data) byte pairs, reg==0xFF - return ; in:
; BC = 0xFFFD
; DE = 0x00C0 ; 0xFFBF compensated for outi
; HL - registers in (reg:data) byte pairs, reg==0xFF - return
reg_out: reg_out:
ld bc, 0xFFFD
ld de, 0x00C0 ; 0xFFBF compensated for outi
; select 1st chip
ld a, 0b11111000
out (c), a
.loop: .loop:
ld b, d ld b, d
ld a, [hl] ld a, [hl]
@ -248,8 +245,7 @@ parse_ay_channel_stream:
push de, hl, ix push de, hl, ix
; ctx->ssg_r7[chip_index] &= ~(((1 << 3) | (1 << 0)) << ch); ; ctx->ssg_r7[chip_index] &= ~(((1 << 3) | (1 << 0)) << ch);
ld a, [player_struct.chip_idx] : ld e, a ld a, [player_struct.chip_idx] : ld e, a : ld d, 0
ld d, 0
ld ix, player_struct.ssg_r7 ld ix, player_struct.ssg_r7
add ix, de ; ix = ctx->ssg_r7[chip_index] add ix, de ; ix = ctx->ssg_r7[chip_index]
@ -668,6 +664,13 @@ parse_stream:
.tok_loop: .tok_loop:
ld a, [player_struct.end_of_frame] : and a : jp nz, .end_of_frame ld a, [player_struct.end_of_frame] : and a : jp nz, .end_of_frame
; common tokens
ld a, [hl]
cp OPM_STREAM_END
jp z, .tok_end_of_stream
cp OPM_STREAM_END_FRAME
jp z, .tok_end_of_frame
; call stream parser proc ; call stream parser proc
call 0 ; :grins: call 0 ; :grins:
.proc equ $-2 .proc equ $-2
@ -696,13 +699,7 @@ parse_stream:
ld e, a : ld d, 0 : ld [ix + channel_struct_t.frames_to_play], de ld e, a : ld d, 0 : ld [ix + channel_struct_t.frames_to_play], de
jp .tok_loop jp .tok_loop
.not_backref .not_backref:
ld a, b
cp OPM_STREAM_END
jp z, .tok_end_of_stream
cp OPM_STREAM_END_FRAME
jp z, .tok_end_of_frame
; then it's most likely an delay ; then it's most likely an delay
call set_delay call set_delay
ld [ix + channel_struct_t.reload], de ld [ix + channel_struct_t.reload], de
@ -788,33 +785,32 @@ play_tick:
ld a, [player_struct.ssg_r7 + 0] ld a, [player_struct.ssg_r7 + 0]
ldi [iy], a ldi [iy], a
; select 2nd chip ; terminate list
ldi [iy], 0b11111000 ldi [iy], -1
ldi [iy], 0xFF
; chip_index = 1; ; chip_index = 1;
ld a, 1 : ld [player_struct.chip_idx], a ld a, 1 : ld [player_struct.chip_idx], a
; opmplay_parse_stream(ctx, ctx->channels + 4, 0, opmplay_parse_ay_channel_stream); ; opmplay_parse_stream(ctx, ctx->channels + 4, 0, opmplay_parse_ay_channel_stream);
ld ix, player_channels + (channel_struct_t * 4) ld ix, player_channels + (channel_struct_t * 12)
ld bc, parse_ay_channel_stream ld bc, parse_ay_channel_stream
ld a, 0 : ld [player_struct.channel_idx], a ld a, 0 : ld [player_struct.channel_idx], a
call parse_stream call parse_stream
; opmplay_parse_stream(ctx, ctx->channels + 5, 1, opmplay_parse_ay_channel_stream); ; opmplay_parse_stream(ctx, ctx->channels + 5, 1, opmplay_parse_ay_channel_stream);
ld ix, player_channels + (channel_struct_t * 5) ld ix, player_channels + (channel_struct_t * 13)
ld bc, parse_ay_channel_stream ld bc, parse_ay_channel_stream
ld a, 1 : ld [player_struct.channel_idx], a ld a, 1 : ld [player_struct.channel_idx], a
call parse_stream call parse_stream
; opmplay_parse_stream(ctx, ctx->channels + 6, 2, opmplay_parse_ay_channel_stream); ; opmplay_parse_stream(ctx, ctx->channels + 6, 2, opmplay_parse_ay_channel_stream);
ld ix, player_channels + (channel_struct_t * 6) ld ix, player_channels + (channel_struct_t * 14)
ld bc, parse_ay_channel_stream ld bc, parse_ay_channel_stream
ld a, 2 : ld [player_struct.channel_idx], a ld a, 2 : ld [player_struct.channel_idx], a
call parse_stream call parse_stream
; opmplay_parse_stream(ctx, ctx->channels + 7, 0, opmplay_parse_ay_channel_stream); ; opmplay_parse_stream(ctx, ctx->channels + 7, 0, opmplay_parse_ay_channel_stream);
ld ix, player_channels + (channel_struct_t * 7) ld ix, player_channels + (channel_struct_t * 15)
ld bc, parse_ay_envnoise_stream ld bc, parse_ay_envnoise_stream
call parse_stream call parse_stream