add FM part to the speccy player, also untested :D
This commit is contained in:
parent
808dd7c045
commit
641bde75e5
|
@ -30,8 +30,8 @@ reserved block 2, 0
|
|||
ends
|
||||
|
||||
struct player_struct_t
|
||||
ch3_ofs_ch0 dw 0
|
||||
ch3_ofs_ch1 dw 0
|
||||
ch3_ofs_chip0 dw 0
|
||||
ch3_ofs_chip1 dw 0
|
||||
chip_idx db 0 ; current chip active
|
||||
channel_idx db 0
|
||||
end_of_frame db 0
|
||||
|
@ -59,8 +59,14 @@ player_channels:
|
|||
channel_struct_t 0, 0
|
||||
channel_struct_t 0, 0
|
||||
|
||||
player_struct player_struct_t player_channels+(channel_struct_t*(3+0)), player_channels+(channel_struct_t*(3+8))
|
||||
player_struct player_struct_t player_channels+(channel_struct_t*(3+0)+channel_struct_t.reg_extch3_fhi), player_channels+(channel_struct_t*(3+8)+channel_struct_t.reg_extch3_fhi)
|
||||
|
||||
.i = 0
|
||||
dup 16
|
||||
display "channel ", /h, .i, " struct ofs: ", /h, player_channels+(channel_struct_t*.i)
|
||||
.i = .i + 1
|
||||
edup
|
||||
|
||||
; -----------------------------
|
||||
; -----------------------------
|
||||
; OPN register dump output
|
||||
|
@ -287,7 +293,7 @@ parse_ay_channel_stream:
|
|||
and a ; clear carry
|
||||
ret
|
||||
|
||||
; parse AY envalope/noise stream
|
||||
; parse AY envelope/noise stream
|
||||
; HL - stream data, IX- channel context, IY - register buffer, CF - do next op
|
||||
parse_ay_envnoise_stream:
|
||||
ld b, [hl]
|
||||
|
@ -378,6 +384,260 @@ parse_ay_envnoise_stream:
|
|||
.not_period:
|
||||
ret
|
||||
|
||||
; parse FM control stream
|
||||
; HL - stream data, IX- channel context, IY - register buffer, CF - do next op
|
||||
parse_fm_control_stream:
|
||||
ld b, [hl]
|
||||
; if ((*(data) & 0xE0) == OPM_CTRL_TIMER_CSM) {
|
||||
ld a, b : and 0xE0 : cp OPM_CTRL_TIMER_CSM
|
||||
jp nz, .not_timer_csm
|
||||
|
||||
inc hl
|
||||
;if (mask & OPM_CTRL_CMD80_REG25) opn_write_reg(chip_index, 0x25, *data++);
|
||||
bit OPM_CTRL_CMD80_REG25_BIT, b
|
||||
jp nz, 1f
|
||||
ldi [iy], 0x25 : ldi a, [hl] : ldi [iy], a
|
||||
1:
|
||||
;if (mask & OPM_CTRL_CMD80_REG24) opn_write_reg(chip_index, 0x24, *data++);
|
||||
bit OPM_CTRL_CMD80_REG24_BIT, b
|
||||
jp nz, 1f
|
||||
ldi [iy], 0x24 : ldi a, [hl] : ldi [iy], a
|
||||
1:
|
||||
;if (mask & OPM_CTRL_CMD80_REG27) opn_write_reg(chip_index, 0x27, *data++);
|
||||
bit OPM_CTRL_CMD80_REG27_BIT, b
|
||||
jp nz, 1f
|
||||
ldi [iy], 0x27 : ldi a, [hl] : ldi [iy], a
|
||||
1:
|
||||
;if (mask & OPM_CTRL_CMD80_REG22) opn_write_reg(chip_index, 0x22, *data++);
|
||||
bit OPM_CTRL_CMD80_REG25_BIT, b
|
||||
jp nz, 1f
|
||||
ldi [iy], 0x22 : ldi a, [hl] : ldi [iy], a
|
||||
1:
|
||||
;if (mask & OPM_CTRL_CMD80_EOF) endOfFrame = true;
|
||||
bit OPM_CTRL_CMD80_EOF_BIT, b
|
||||
jp nz, 1f
|
||||
ld a, b : ld [player_struct.end_of_frame], a
|
||||
1:
|
||||
scf
|
||||
ret
|
||||
|
||||
.not_timer_csm:
|
||||
; if ((*(data) & 0x80) == OPM_CTRL_EXTCH3) {
|
||||
ld a, b : and 0x80 : cp OPM_CTRL_EXTCH3
|
||||
jp nz, .not_extch3
|
||||
|
||||
inc hl
|
||||
; extract extch3 offset
|
||||
push hl
|
||||
ld a, [player_struct.chip_idx] : add a : ld e, a : ld d, 0
|
||||
ld hl, player_struct.ch3_ofs_ch0 : add hl, de
|
||||
ld e, [hl] : inc hl : ld d, [hl] ; de - channel 3 extch3 block
|
||||
pop hl
|
||||
|
||||
; if (mask & OPM_CTRL_EXTCH3_OP1_HIGH) ctx->extch3_block[chip_index][0] = *data++;
|
||||
; if (mask & OPM_CTRL_EXTCH3_OP1_LOW) {
|
||||
; opn_write_reg(chip_index, 0xAD, ctx->extch3_block[chip_index][0]);
|
||||
; opn_write_reg(chip_index, 0xA9, *data++);
|
||||
; }
|
||||
bit OPM_CTRL_EXTCH3_OP1_HIGH_BIT, b
|
||||
jp nz, 1f
|
||||
ld a, [hl] : ld [de], a : inc hl
|
||||
1:
|
||||
bit OPM_CTRL_EXTCH3_OP1_LOW_BIT, b
|
||||
jp nz, 1f
|
||||
ldi [iy], 0xAD : ld a, [de] : ldi [iy], a
|
||||
ldi [iy], 0xA9 : ldi a, [hl] : ldi [iy], a
|
||||
1:
|
||||
inc e
|
||||
; if (mask & OPM_CTRL_EXTCH3_OP2_HIGH) ctx->extch3_block[chip_index][1] = *data++;
|
||||
; if (mask & OPM_CTRL_EXTCH3_OP2_LOW) {
|
||||
; opn_write_reg(chip_index, 0xAC, ctx->extch3_block[chip_index][1]);
|
||||
; opn_write_reg(chip_index, 0xA8, *data++);
|
||||
; }
|
||||
bit OPM_CTRL_EXTCH3_OP2_HIGH_BIT, b
|
||||
jp nz, 1f
|
||||
ld a, [hl] : ld [de], a : inc hl
|
||||
1:
|
||||
bit OPM_CTRL_EXTCH3_OP2_LOW_BIT, b
|
||||
jp nz, 1f
|
||||
ldi [iy], 0xAC : ld a, [de] : ldi [iy], a
|
||||
ldi [iy], 0xA8 : ldi a, [hl] : ldi [iy], a
|
||||
1:
|
||||
inc e
|
||||
|
||||
; if (mask & OPM_CTRL_EXTCH3_OP3_HIGH) ctx->extch3_block[chip_index][2] = *data++;
|
||||
; if (mask & OPM_CTRL_EXTCH3_OP3_LOW) {
|
||||
; opn_write_reg(chip_index, 0xAE, ctx->extch3_block[chip_index][2]);
|
||||
; opn_write_reg(chip_index, 0xAA, *data++);
|
||||
; }
|
||||
bit OPM_CTRL_EXTCH3_OP3_HIGH, b
|
||||
jp nz, 1f
|
||||
ld a, [hl] : ld [de], a : inc hl
|
||||
1:
|
||||
bit OPM_CTRL_EXTCH3_OP3_LOW, b
|
||||
jp nz, 1f
|
||||
ldi [iy], 0xAE : ld a, [de] : ldi [iy], a
|
||||
ldi [iy], 0xAA : ldi a, [hl] : ldi [iy], a
|
||||
1:
|
||||
|
||||
; if (mask & OPM_CTRL_EXTCH3_EOF) endOfFrame = true;
|
||||
bit OPM_CTRL_EXTCH3_EOF, b
|
||||
jp nz, 1f
|
||||
ld a, b : ld [player_struct.end_of_frame], a
|
||||
1:
|
||||
scf
|
||||
ret
|
||||
|
||||
.not_extch3:
|
||||
ret
|
||||
|
||||
; c - channel offset
|
||||
macro FM_STREAM_EMIT bit_ofs, regbase
|
||||
|
||||
endm
|
||||
|
||||
; parse FM channel stream
|
||||
; HL - stream data, IX- channel context, IY - register buffer, CF - do next op
|
||||
parse_fm_channel_stream:
|
||||
ld b, [hl]
|
||||
; if ((*(data) & 0xC0) == OPM_FM_ADSR) {
|
||||
ld a, b : and 0xC0 : cp OPM_FM_ADSR
|
||||
jp nz, .not_adsr
|
||||
|
||||
inc hl
|
||||
; int regbase = (ch & 3) + ((mask & OPM_FM_CMD00_OP_MASK) >> 2);
|
||||
ld a, b : and OPM_FM_CMD00_OP_MASK : rrca : rrca
|
||||
ld c, [player_struct.channel_idx] : or c : ld c, a
|
||||
|
||||
;if (mask & OPM_FM_CMD00_REG50) opn_write_reg(chip_index, 0x50 + regbase, *data++);
|
||||
bit OPM_FM_CMD00_REG50_BIT, b
|
||||
jp nz, 1f
|
||||
ld a, 0x50 : add c : ldi [iy], a
|
||||
ldi a, [hl] : ld [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 nz, 1f
|
||||
ld a, 0x60 : add c : ldi [iy], a
|
||||
ldi a, [hl] : ld [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 nz, 1f
|
||||
ld a, 0x70 : add c : ldi [iy], a
|
||||
ldi a, [hl] : ld [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 nz, 1f
|
||||
ld a, 0x80 : add c : ldi [iy], a
|
||||
ldi a, [hl] : ld [iy], a
|
||||
1:
|
||||
scf
|
||||
ret
|
||||
|
||||
.not_adsr:
|
||||
; if ((*(data) & 0xC0) == OPM_FM_MUL_TL_EG) {
|
||||
ld a, b : and 0xC0 : cp OPM_FM_MUL_TL_EG
|
||||
jp nz, .not_mul_tl_eg
|
||||
|
||||
; multplier\TL\SSG-EG
|
||||
inc hl
|
||||
; int regbase = (ch & 3) + ((mask & OPM_FM_CMD40_OP_MASK) >> 2);
|
||||
ld a, b : and OPM_FM_CMD40_OP_MASK : rrca : rrca
|
||||
ld c, [player_struct.channel_idx] : or c : ld c, a
|
||||
|
||||
;if (mask & OPM_FM_CMD40_REG30) opn_write_reg(chip_index, 0x30 + regbase, *data++);
|
||||
bit OPM_FM_CMD40_REG30_BIT, b
|
||||
jp nz, 1f
|
||||
ld a, 0x30 : add c : ldi [iy], a
|
||||
ldi a, [hl] : ld [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 nz, 1f
|
||||
ld a, 0x40 : add c : ldi [iy], a
|
||||
ldi a, [hl] : ld [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 nz, 1f
|
||||
ld a, 0x90 : add c : ldi [iy], a
|
||||
ldi a, [hl] : ld [iy], a
|
||||
1:
|
||||
;if (mask & OPM_FM_CMD40_EOF) endOfFrame = true;
|
||||
bit OPM_FM_CMD40_EOF_BIT, b
|
||||
jp nz, 1f
|
||||
ld a, b : ld [player_struct.end_of_frame], a
|
||||
1:
|
||||
scf
|
||||
ret
|
||||
|
||||
.not_mul_tl_eg:
|
||||
; if ((*(data) & 0xE0) == OPM_FM_FREQ_FB_PAN) {
|
||||
ld a, b : and 0xE0 : cp OPM_FM_FREQ_FB_PAN
|
||||
jp nz, .not_freq_fb_pan
|
||||
|
||||
inc hl
|
||||
ld c, [player_struct.channel_idx]
|
||||
|
||||
; if (mask & OPM_FM_CMD80_REGA4) chctx->block = *data++;
|
||||
bit OPM_FM_CMD80_REGA4_BIT, b
|
||||
jp nz, 1f
|
||||
ldi a, [hl] : ld [ix + channel_context_t.reg_fhi], a
|
||||
1:
|
||||
; if (mask & OPM_FM_CMD80_REGA0) {
|
||||
; opn_write_reg(chip_index, 0xA4 + ch, chctx->block);
|
||||
; opn_write_reg(chip_index, 0xA0 + ch, *data++);
|
||||
; }
|
||||
bit OPM_FM_CMD80_REGA0_BIT, b
|
||||
jp nz, 1f
|
||||
ld a, 0xA4 : add c : ldi [iy], a
|
||||
ld a, [ix + channel_context_t.reg_fhi] : ldi [iy], a
|
||||
ld a, 0xA0 : add c : ldi [iy], a
|
||||
ldi a, [hl] : ld [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 nz, 1f
|
||||
ld a, 0xb0 : add c : ldi [iy], a
|
||||
ldi a, [hl] : ld [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 nz, 1f
|
||||
ld a, 0xb4 : add c : ldi [iy], a
|
||||
ldi a, [hl] : ld [iy], a
|
||||
1:
|
||||
; if (mask & OPM_FM_CMD80_EOF) endOfFrame = true;
|
||||
bit OPM_FM_CMD80_EOF_BIT, b
|
||||
jp nz, 1f
|
||||
ld a, b : ld [player_struct.end_of_frame], a
|
||||
1:
|
||||
scf
|
||||
ret
|
||||
|
||||
.not_freq_fb_pan:
|
||||
; if ((*(data) & 0xE0) == OPM_FM_KEY) {
|
||||
ld a, b : and 0xE0 : cp OPM_FM_KEY
|
||||
jp nz, .not_key
|
||||
|
||||
; opn_write_reg(chip_index, 0x28, ((mask & OPM_FM_CMDA0_OP_MASK) << 4) + ch);
|
||||
ld c, [player_struct.channel_idx]
|
||||
ld a, b : and OPM_FM_CMDA0_OP_MASK
|
||||
add a, a : add a, a : add a, a : add a, a : add a, c
|
||||
ldi [iy], 0x28 : ldi [iy], a
|
||||
1:
|
||||
; if (mask & OPM_FM_CMDA0_EOF) endOfFrame = true;
|
||||
bit OPM_FM_CMDA0_EOF_BIT, b
|
||||
jp nz, 1f
|
||||
ld a, b : ld [player_struct.end_of_frame], a
|
||||
1:
|
||||
scf
|
||||
ret
|
||||
|
||||
.not_key:
|
||||
ret
|
||||
|
||||
; parse channel stream
|
||||
; in: IX - stream struct, IY - register buffer, BC - stream parser procedure, A - channel index
|
||||
|
@ -418,13 +678,12 @@ parse_stream:
|
|||
ld a, b : and 0xF0 : cp OPM_STREAM_BACKREF
|
||||
jp nz, .not_backref
|
||||
|
||||
; TODO
|
||||
; back reference, nested call :)
|
||||
; int distance = ((*(data + 0) & 0x0F) << 8) | (*(data + 1));
|
||||
ld a, b : and 0x0F : ld d, a : inc hl
|
||||
ldi e, [hl] ; de = distance
|
||||
ldi a, [hl] ; int frames_to_play = *(data + 2); data += 3
|
||||
exd : ld [ix + channel_struct_t.ptr], de ; chctx->stream.ptr = data + 3;
|
||||
ld [ix + channel_struct_t.ptr], hl ; chctx->stream.ptr = data + 3;
|
||||
|
||||
push af, de, hl
|
||||
call push_stack
|
||||
|
@ -527,8 +786,12 @@ play_tick:
|
|||
ld a, [player_struct.ssg_r7 + 0]
|
||||
ldi [iy], a
|
||||
|
||||
; chip_index = 1;
|
||||
xor a : ld [player_struct.chip_idx], a
|
||||
; select 2nd chip
|
||||
ldi [iy], 0b11111000
|
||||
ldi [iy], 0xFF
|
||||
|
||||
; chip_index = 1;
|
||||
ld a, 1 : ld [player_struct.chip_idx], a
|
||||
|
||||
; opmplay_parse_stream(ctx, ctx->channels + 4, 0, opmplay_parse_ay_channel_stream);
|
||||
ld ix, player_channels + (channel_struct_t * 4)
|
||||
|
@ -554,10 +817,9 @@ play_tick:
|
|||
call parse_stream
|
||||
|
||||
ldi [iy], 7
|
||||
ld a, [player_struct.ssg_r7 + 0]
|
||||
ld a, [player_struct.ssg_r7 + 1]
|
||||
ldi [iy], a
|
||||
|
||||
|
||||
; terminate list
|
||||
ldi [iy], -1
|
||||
ret
|
||||
|
|
Loading…
Reference in a new issue