fix CSM bugs

This commit is contained in:
wbcbz7 2025-08-21 02:04:43 +07:00
parent 0bf06f38d1
commit 487c7d5b4c
38 changed files with 178 additions and 79 deletions

Binary file not shown.

View file

@ -48,19 +48,56 @@ start:
out (c), a
ld hl, reg_buffer
call player.reg_out
ld a, 2 : out (0xfe), a
ld a, 1 : 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 a, 1 : out (0xfe), a
; draw vu meters
ld bc, 0x4000+2048*2+32*7+0
call vumeter.draw_e
.vu0 equ $-2
ld bc, 0x4000+2048*2+32*7+1
call vumeter.draw_e
.vu1 equ $-2
ld bc, 0x4000+2048*2+32*7+2
call vumeter.draw_e
.vu2 equ $-2
ld bc, 0x4000+2048*2+32*7+3
call vumeter.draw_e
.vu3 equ $-2
ld bc, 0x4000+2048*2+32*7+4
call vumeter.draw_e
.vu4 equ $-2
ld bc, 0x4000+2048*2+32*7+5
call vumeter.draw_e
.vu5 equ $-2
ld bc, 0x4000+2048*2+32*7+6
call vumeter.draw_e
.vu6 equ $-2
ld bc, 0x4000+2048*2+32*7+7
call vumeter.draw_e
.vu7 equ $-2
ld bc, 0x4000+2048*2+32*7+8
call vumeter.draw_e
.vu8 equ $-2
ld bc, 0x4000+2048*2+32*7+9
call vumeter.draw_e
.vu9 equ $-2
ld bc, 0x4000+2048*2+32*7+10
call vumeter.draw_e
.vu10 equ $-2
ld bc, 0x4000+2048*2+32*7+11
call vumeter.draw_e
.vu11 equ $-2
ld iy, reg_buffer
call player.play_tick
ld a, 1 : out (0xfe), a
call vumeter.init_frame
xor a : out (0xfe), a
; and jump to next frame
@ -70,26 +107,45 @@ start:
; ----------------------------------------------------
; vu meters
; orig by natt, rewritten by me
if 0
if 1
vumeter:
ld a, 0
call .get_address
ld [start.vu0], hl
ld a, 1
call .get_address
ld [start.vu1], hl
ld a, 2
call .get_address
ld [start.vu2], hl
ld a, 3
call .get_address
ld [start.vu3], hl
ld a, 4
call .get_address
ld [start.vu4], hl
ld a, 5
call .get_address
ld [start.vu5], hl
.init_frame:
ld a, [player.player_channels+(player.channel_struct_t*1)+player.channel_struct_t.volume]
call .get_address
ld [start.vu0], hl
ld a, [player.player_channels+(player.channel_struct_t*2)+player.channel_struct_t.volume]
call .get_address
ld [start.vu1], hl
ld a, [player.player_channels+(player.channel_struct_t*3)+player.channel_struct_t.volume]
call .get_address
ld [start.vu2], hl
ld a, [player.player_channels+(player.channel_struct_t*4)+player.channel_struct_t.volume]
call .get_address
ld [start.vu3], hl
ld a, [player.player_channels+(player.channel_struct_t*5)+player.channel_struct_t.volume]
call .get_address
ld [start.vu4], hl
ld a, [player.player_channels+(player.channel_struct_t*6)+player.channel_struct_t.volume]
call .get_address
ld [start.vu5], hl
ld a, [player.player_channels+(player.channel_struct_t*9)+player.channel_struct_t.volume]
call .get_address
ld [start.vu6], hl
ld a, [player.player_channels+(player.channel_struct_t*10)+player.channel_struct_t.volume]
call .get_address
ld [start.vu7], hl
ld a, [player.player_channels+(player.channel_struct_t*11)+player.channel_struct_t.volume]
call .get_address
ld [start.vu8], hl
ld a, [player.player_channels+(player.channel_struct_t*12)+player.channel_struct_t.volume]
call .get_address
ld [start.vu9], hl
ld a, [player.player_channels+(player.channel_struct_t*13)+player.channel_struct_t.volume]
call .get_address
ld [start.vu10], hl
ld a, [player.player_channels+(player.channel_struct_t*14)+player.channel_struct_t.volume]
call .get_address
ld [start.vu11], hl
ret
@ -161,6 +217,26 @@ vumeter:
include "player.asm"
; music
; not so hidden text
db ".......................... hey there again!", 10, 13
db "another arson? another arson!", 10, 13
db "this time for the TurboSound FM! (2 x YM2203)", 10, 13
db 10, 13
db "player code - artemka", 10, 13
db "splash screen - rui8bit", 10, 13
db "music - Abstract 64, Alex Winston, Natt, nIk0, Pator and Rei8bit", 10, 13
db "support and tools - AArt1526", 10, 13
db 10, 13
db "released at Xenium 2o25", 10, 13
db 10, 13
db "greets to everyone pushing the limits and keeping the scene alive! (and whatever ;)", 10, 13
db "special thanks to CHRV for the TSFMPro board :)", 10, 13
db 10, 13
db 10, 13
db "come to Multimatograf 2026 - the party that cares about the demoscene - spring 2026 - events.retroscene.org", 10, 13
code_end
; -------------------------------------------------
@ -168,58 +244,56 @@ code_end
page 0
emptytap "page0.tap"
org 0xC000
music_p0_ch2:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch2.bin"
music_p0_ch11:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch11.bin"
music_p0_ch12:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch12.bin"
music_p0_ch14:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch14.bin"
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch12.bin"
music_p0_ch10:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch10.bin"
savetap "page0.tap",CODE,"page0",0xC000,$-0xC000
; ------------------------------------------------
page 1
emptytap "page1.tap"
org 0xC000
music_p0_ch0:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch0.bin"
music_p0_ch1:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch1.bin"
music_p0_ch3:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch3.bin"
music_p0_ch4:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch4.bin"
music_p0_ch5:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch5.bin"
music_p0_ch6:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch6.bin"
music_p0_ch7:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch7.bin"
music_p0_ch8:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch8.bin"
music_p0_ch9:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch9.bin"
music_p0_ch10:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch10.bin"
music_p0_ch13:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch13.bin"
music_p0_ch15:
incbin "tsfm_1708_2214_optimized/tsfm_1708_2214_optimized_ch15.bin"
music_p0_ch14:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch14.bin"
music_p0_ch2:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch2.bin"
savetap "page1.tap",CODE,"page1",0xC000,$-0xC000
; ------------------------------------------------
page 3
emptytap "page3.tap"
org 0xC000
db 0
music_p0_ch11:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch11.bin"
music_p0_ch8:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch8.bin"
music_p0_ch1:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch1.bin"
music_p0_ch6:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch6.bin"
savetap "page3.tap",CODE,"page3",0xC000,$-0xC000
; ------------------------------------------------
page 4
emptytap "page4.tap"
org 0xC000
db 0
music_p0_ch9:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch9.bin"
music_p0_ch4:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch4.bin"
music_p0_ch13:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch13.bin"
music_p0_ch15:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch15.bin"
music_p0_ch5:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch5.bin"
music_p0_ch7:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch7.bin"
music_p0_ch0:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch0.bin"
music_p0_ch3:
incbin "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized_ch3.bin"
savetap "page4.tap",CODE,"page4",0xC000,$-0xC000
; ------------------------------------------------

View file

@ -26,8 +26,8 @@ stack block channel_stack_t*MAX_STACK_DEPTH, 0 ; stack
; reg cache
reg_extch3_fhi block 3, 0 ; extch3 block/fnum-high reg
reg_fhi db 0 ; block/fnum-high reg
op4_vol db 0
reserved db 0
volume db 0
tl_cache db 0
ends
struct player_struct_t
@ -43,22 +43,22 @@ ssg_r7 block 2, 0
; instantinate structures
align 256
player_channels:
channel_struct_t 1, music_p0_ch0 ; TODO: fill start offsets here
channel_struct_t 1, music_p0_ch1
channel_struct_t 0, music_p0_ch2
channel_struct_t 1, music_p0_ch3
channel_struct_t 1, music_p0_ch4
channel_struct_t 1, music_p0_ch5
channel_struct_t 1, music_p0_ch6
channel_struct_t 1, music_p0_ch7
channel_struct_t 1, music_p0_ch8
channel_struct_t 1, music_p0_ch9
channel_struct_t 1, music_p0_ch10
channel_struct_t 0, music_p0_ch11
channel_struct_t 4, music_p0_ch0 ; TODO: fill start offsets here
channel_struct_t 3, music_p0_ch1
channel_struct_t 1, music_p0_ch2
channel_struct_t 4, music_p0_ch3
channel_struct_t 4, music_p0_ch4
channel_struct_t 4, music_p0_ch5
channel_struct_t 3, music_p0_ch6
channel_struct_t 4, music_p0_ch7
channel_struct_t 3, music_p0_ch8
channel_struct_t 4, music_p0_ch9
channel_struct_t 0, music_p0_ch10
channel_struct_t 3, music_p0_ch11
channel_struct_t 0, music_p0_ch12
channel_struct_t 1, music_p0_ch13
channel_struct_t 0, music_p0_ch14
channel_struct_t 1, music_p0_ch15
channel_struct_t 4, music_p0_ch13
channel_struct_t 1, music_p0_ch14
channel_struct_t 4, music_p0_ch15
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)
@ -175,6 +175,7 @@ parse_ay_channel_stream:
ldi [iy], a
ld a, b : and OPM_AYTONE_CMD00_VOLUME_MASK
ldi [iy], a
ld [ix+channel_struct_t.volume], a
; if (mask & OPM_AYTONE_CMD00_PERIOD_LOW) opn_write_reg(chip_index, 0 + (ch<<1), *data++);
bit OPM_AYTONE_CMD00_PERIOD_LOW_BIT, b
@ -402,7 +403,7 @@ parse_fm_control_stream:
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
bit OPM_CTRL_CMD80_REG22_BIT, b
jp z, 1f
ldi [iy], 0x22 : ldi a, [hl] : ldi [iy], a
1:
@ -547,7 +548,13 @@ parse_fm_channel_stream:
;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
ld a, 0x40 : add c : ldi [iy], a
ld a, c : and 12 : cp 12 : jp nz, 2f
ld a, [hl] : rrca : and 0x3F : xor 0x3F
sub 0x30 : jp nc, 3f : xor a
3:
ld [ix + channel_struct_t.tl_cache], a
2:
ldi a, [hl] : ldi [iy], a
1:
;if (mask & OPM_FM_CMD40_REG90) opn_write_reg(chip_index, 0x90 + regbase, *data++);
@ -619,6 +626,9 @@ parse_fm_channel_stream:
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
and 0xF0 : jp z, 1f
ld a, [ix + channel_struct_t.tl_cache]
ld [ix + channel_struct_t.volume], a
1:
; if (mask & OPM_FM_CMDA0_EOF) endOfFrame = true;
bit OPM_FM_CMDA0_EOF_BIT, b
@ -742,6 +752,16 @@ parse_stream:
ld [ix+channel_struct_t.ptr], hl
ret
; advance volume on FM streams
; IX - channel ptr
advance_vol:
ld a, [ix+channel_struct_t.volume]
and a
ret z
dec a
ld [ix+channel_struct_t.volume], a
ret
; -----------------------------
; -----------------------------
; play one tick!!!
@ -765,18 +785,21 @@ play_tick:
ld bc, parse_fm_channel_stream
ld a, 0 : ld [player_struct.channel_idx], a
call parse_stream
call advance_vol
; 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
call advance_vol
; 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
call advance_vol
endif
if 1
@ -825,18 +848,21 @@ play_tick:
ld bc, parse_fm_channel_stream
ld a, 0 : ld [player_struct.channel_idx], a
call parse_stream
call advance_vol
; 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
call advance_vol
; 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
call advance_vol
endif
if 1

View file

@ -1 +0,0 @@
Ö0”@ĐC3¶p2ČL,ôËC2ČĐ0p+¶ĐL+NËC$ôĐ<p*ČĐL,ôËC2ČĐ<p+¶L+Nŕ3Đ0p3¶ĐL4*ËC4­Đ<p4­ĐH­ËBôĐxp:ČŕUp4­ţ

View file

@ -3,7 +3,7 @@
define MUSIC_INC
TICK_RATE equ 50
TOTAL_FRAMES equ 3840
TOTAL_FRAMES equ 8091
TOTAL_CHANNELS equ 16
FILEPATH equ "tsfm_1308_0451_optimized/tsfm_1308_0451_optimized"
FILEPATH equ "tsfm_2108_0045_optimized/tsfm_2108_0045_optimized"
endif

View file

@ -240,7 +240,7 @@ int vgm_parse_frame() {
case VGM_Stream_Opcode::YM2203_WRITE: {
// get register and data
int reg = *(it + 1), data = *(it + 2);
opna_regqueue[0].add(0, reg, data, 4);
opna_regqueue[0].add(0, reg, data, 16);
//opnachip->write(2, reg);
//opnachip->write(3, data);
break;
@ -248,7 +248,7 @@ int vgm_parse_frame() {
case VGM_Stream_Opcode::YM2203_CHIP2_WRITE: {
// get register and data
int reg = *(it + 1), data = *(it + 2);
opna_regqueue[1].add(0, reg, data, 4);
opna_regqueue[1].add(0, reg, data, 16);
//opnachip->write(0, reg);
//opnachip->write(1, data);
break;