got FM working

This commit is contained in:
wbcbz7 2025-08-14 21:54:55 +07:00
parent 7e5040925a
commit 038e4b3c35

View file

@ -42,18 +42,18 @@ ssg_r7 block 2, 0
; instantinate structures
align 256
player_channels:
channel_struct_t 0, 0 ; TODO: fill start offsets here
channel_struct_t 0, 0
channel_struct_t 0, 0
channel_struct_t 0, 0
channel_struct_t 0, music_p0_ch0 ; TODO: fill start offsets here
channel_struct_t 0, music_p0_ch1
channel_struct_t 0, music_p0_ch2
channel_struct_t 0, music_p0_ch3
channel_struct_t 0, music_p0_ch4
channel_struct_t 0, music_p0_ch5
channel_struct_t 0, music_p0_ch6
channel_struct_t 0, music_p0_ch7
channel_struct_t 0, 0
channel_struct_t 0, 0
channel_struct_t 0, 0
channel_struct_t 0, 0
channel_struct_t 0, music_p0_ch8
channel_struct_t 0, music_p0_ch9
channel_struct_t 0, music_p0_ch10
channel_struct_t 0, music_p0_ch11
channel_struct_t 0, music_p0_ch12
channel_struct_t 0, music_p0_ch13
channel_struct_t 0, music_p0_ch14
@ -83,7 +83,7 @@ reg_out:
outi
ld b, e
outi
dup 4: nop : edup ; delay
dup 10: nop : edup ; delay
jp .loop
; ------------------------
@ -508,25 +508,25 @@ parse_fm_channel_stream:
bit OPM_FM_CMD00_REG50_BIT, b
jp z, 1f
ld a, 0x50 : add c : ldi [iy], a
ldi a, [hl] : ld [iy], a
ldi a, [hl] : ldi [iy], a
1:
;if (mask & OPM_FM_CMD00_REG60) opn_write_reg(chip_index, 0x60 + regbase, *data++);
bit OPM_FM_CMD00_REG60_BIT, b
jp z, 1f
ld a, 0x60 : add c : ldi [iy], a
ldi a, [hl] : ld [iy], a
ldi a, [hl] : ldi [iy], a
1:
;if (mask & OPM_FM_CMD00_REG70) opn_write_reg(chip_index, 0x70 + regbase, *data++);
bit OPM_FM_CMD00_REG70_BIT, b
jp z, 1f
ld a, 0x70 : add c : ldi [iy], a
ldi a, [hl] : ld [iy], a
ldi a, [hl] : ldi [iy], a
1:
;if (mask & OPM_FM_CMD00_REG80) opn_write_reg(chip_index, 0x80 + regbase, *data++);
bit OPM_FM_CMD00_REG80_BIT, b
jp z, 1f
ld a, 0x80 : add c : ldi [iy], a
ldi a, [hl] : ld [iy], a
ldi a, [hl] : ldi [iy], a
1:
scf
ret
@ -547,19 +547,19 @@ parse_fm_channel_stream:
bit OPM_FM_CMD40_REG30_BIT, b
jp z, 1f
ld a, 0x30 : add c : ldi [iy], a
ldi a, [hl] : ld [iy], a
ldi a, [hl] : ldi [iy], a
1:
;if (mask & OPM_FM_CMD40_REG40) opn_write_reg(chip_index, 0x40 + regbase, *data++);
bit OPM_FM_CMD40_REG40_BIT, b
jp z, 1f
ld a, 0x40 : add c : ldi [iy], a
ldi a, [hl] : ld [iy], a
ldi a, [hl] : ldi [iy], a
1:
;if (mask & OPM_FM_CMD40_REG90) opn_write_reg(chip_index, 0x90 + regbase, *data++);
bit OPM_FM_CMD40_REG90_BIT, b
jp z, 1f
ld a, 0x90 : add c : ldi [iy], a
ldi a, [hl] : ld [iy], a
ldi a, [hl] : ldi [iy], a
1:
;if (mask & OPM_FM_CMD40_EOF) endOfFrame = true;
bit OPM_FM_CMD40_EOF_BIT, b
@ -591,19 +591,19 @@ parse_fm_channel_stream:
ld a, 0xA4 : add c : ldi [iy], a
ld a, [ix + channel_struct_t.reg_fhi] : ldi [iy], a
ld a, 0xA0 : add c : ldi [iy], a
ldi a, [hl] : ld [iy], a
ldi a, [hl] : ldi [iy], a
1:
; if (mask & OPM_FM_CMD80_REGB0) opn_write_reg(chip_index, 0xB0 + ch, *data++);
bit OPM_FM_CMD80_REGB0_BIT, b
jp z, 1f
ld a, 0xb0 : add c : ldi [iy], a
ldi a, [hl] : ld [iy], a
ldi a, [hl] : ldi [iy], a
1:
; if (mask & OPM_FM_CMD80_REGB4) opn_write_reg(chip_index, 0xB4 + ch, *data++);
bit OPM_FM_CMD80_REGB4_BIT, b
jp z, 1f
ld a, 0xb4 : add c : ldi [iy], a
ldi a, [hl] : ld [iy], a
ldi a, [hl] : ldi [iy], a
1:
; if (mask & OPM_FM_CMD80_EOF) endOfFrame = true;
bit OPM_FM_CMD80_EOF_BIT, b
@ -618,6 +618,7 @@ parse_fm_channel_stream:
ld a, b : and 0xE0 : cp OPM_FM_KEY
jp nz, .not_key
inc hl
; opn_write_reg(chip_index, 0x28, ((mask & OPM_FM_CMDA0_OP_MASK) << 4) + ch);
ld a, [player_struct.channel_idx] : ld c, a
ld a, b : and OPM_FM_CMDA0_OP_MASK
@ -758,6 +759,30 @@ play_tick:
; chip_index = 0;
xor a : ld [player_struct.chip_idx], a
; opmplay_parse_stream(ctx, ctx->channels + 0, 0, opmplay_parse_fm_control_stream);
ld ix, player_channels + (channel_struct_t * 0)
ld bc, parse_fm_control_stream
call parse_stream
; opmplay_parse_stream(ctx, ctx->channels + 1, 0, opmplay_parse_fm_channel_stream);
ld ix, player_channels + (channel_struct_t * 1)
ld bc, parse_fm_channel_stream
ld a, 0 : ld [player_struct.channel_idx], a
call parse_stream
; opmplay_parse_stream(ctx, ctx->channels + 2, 1, opmplay_parse_fm_channel_stream);
ld ix, player_channels + (channel_struct_t * 2)
ld bc, parse_fm_channel_stream
ld a, 1 : ld [player_struct.channel_idx], a
call parse_stream
; opmplay_parse_stream(ctx, ctx->channels + 3, 2, opmplay_parse_fm_channel_stream);
ld ix, player_channels + (channel_struct_t * 3)
ld bc, parse_fm_channel_stream
ld a, 2 : ld [player_struct.channel_idx], a
call parse_stream
if 0
; opmplay_parse_stream(ctx, ctx->channels + 4, 0, opmplay_parse_ay_channel_stream);
ld ix, player_channels + (channel_struct_t * 4)
ld bc, parse_ay_channel_stream
@ -784,6 +809,7 @@ play_tick:
ldi [iy], 7
ld a, [player_struct.ssg_r7 + 0]
ldi [iy], a
endif
; terminate list
ldi [iy], -1
@ -791,6 +817,30 @@ play_tick:
; chip_index = 1;
ld a, 1 : ld [player_struct.chip_idx], a
; opmplay_parse_stream(ctx, ctx->channels + 0, 0, opmplay_parse_fm_control_stream);
ld ix, player_channels + (channel_struct_t * 8)
ld bc, parse_fm_control_stream
call parse_stream
; opmplay_parse_stream(ctx, ctx->channels + 1, 0, opmplay_parse_fm_channel_stream);
ld ix, player_channels + (channel_struct_t * 9)
ld bc, parse_fm_channel_stream
ld a, 0 : ld [player_struct.channel_idx], a
call parse_stream
; opmplay_parse_stream(ctx, ctx->channels + 2, 1, opmplay_parse_fm_channel_stream);
ld ix, player_channels + (channel_struct_t * 10)
ld bc, parse_fm_channel_stream
ld a, 1 : ld [player_struct.channel_idx], a
call parse_stream
; opmplay_parse_stream(ctx, ctx->channels + 3, 2, opmplay_parse_fm_channel_stream);
ld ix, player_channels + (channel_struct_t * 11)
ld bc, parse_fm_channel_stream
ld a, 2 : ld [player_struct.channel_idx], a
call parse_stream
if 0
; opmplay_parse_stream(ctx, ctx->channels + 4, 0, opmplay_parse_ay_channel_stream);
ld ix, player_channels + (channel_struct_t * 12)
ld bc, parse_ay_channel_stream
@ -817,6 +867,7 @@ play_tick:
ldi [iy], 7
ld a, [player_struct.ssg_r7 + 1]
ldi [iy], a
endif
; terminate list
ldi [iy], -1