From 09a96b98661257ef03b1dcdd10c546d2b3e99264 Mon Sep 17 00:00:00 2001 From: Javier Degirolmo Date: Wed, 12 Oct 2011 14:15:55 -0300 Subject: General update, trying to clean up FM volume code, work in progress --- src-68k/core/songlist.68k | 8 ++++++- src-68k/sound/bgms.68k | 10 +++++++++ src-z80/core/main.z80 | 2 +- src-z80/core/sfx.z80 | 32 ++++++++++++++++----------- src-z80/core/vars.z80 | 3 ++- src-z80/player/fm.z80 | 55 +++++++++++++++++++++++++++++------------------ 6 files changed, 73 insertions(+), 37 deletions(-) diff --git a/src-68k/core/songlist.68k b/src-68k/core/songlist.68k index 69562af..36bb12a 100644 --- a/src-68k/core/songlist.68k +++ b/src-68k/core/songlist.68k @@ -6,6 +6,8 @@ SongList: dc.l BGM_Minion, @Str_Minion_1, @Str_Minion_2, @Str_Minion_3 dc.l BGM_HoL, @Str_HoL_1, @Str_Null, @Str_Null + dc.l BGM_VolBug_B, @Str_VolBug_1, @Str_VolBug_2, @Str_Null + dc.l BGM_VolBug_F, @Str_VolBug_1, @Str_VolBug_2A, @Str_Null ; 012345678901234567890123456 @@ -18,6 +20,10 @@ SongList: @Str_HoL_1: dc.b "Hall of Loneliness", 0 +@Str_VolBug_1: dc.b "Volume bug test", 0 +@Str_VolBug_2: dc.b "Broken version", 0 +@Str_VolBug_2A: dc.b "Fixed version", 0 + even ;**************************************************************************** @@ -25,4 +31,4 @@ SongList: ; Number of songs in song list ;**************************************************************************** -NumSongs equ 2 +NumSongs equ 4 diff --git a/src-68k/sound/bgms.68k b/src-68k/sound/bgms.68k index 7264048..5d1d46e 100644 --- a/src-68k/sound/bgms.68k +++ b/src-68k/sound/bgms.68k @@ -21,3 +21,13 @@ BGM_Minion: BGM_HoL: incbin "data/music/hol.esf" + +;**************************************************************************** +; BGM_VolBug_* +; Volume bug test BGMs +;**************************************************************************** + +BGM_VolBug_B: + incbin "data/music/volbug_b.esf" +BGM_VolBug_F: + incbin "data/music/volbug_f.esf" diff --git a/src-z80/core/main.z80 b/src-z80/core/main.z80 index cb0329e..c5aef0f 100644 --- a/src-z80/core/main.z80 +++ b/src-z80/core/main.z80 @@ -87,7 +87,7 @@ EntryPoint: ld (ix+0), $25 ld (ix+1), $03 ld (ix+0), $26 - ld (ix+1), $C9 + ld (ix+1), $C8 ;ld (ix+1), $FF ld (ix+0), $27 ld (ix+1), $3F diff --git a/src-z80/core/sfx.z80 b/src-z80/core/sfx.z80 index b7e26aa..c778776 100644 --- a/src-z80/core/sfx.z80 +++ b/src-z80/core/sfx.z80 @@ -276,23 +276,29 @@ ClearSFX: ld a, b ; Kill ADSR call KillFM - PollPCM + ;PollPCM + + ;ld hl, RAM_BGMFMVol ; Restore BGM FM volume + ;ld a, b + ;add l + ;ld l, a + ;ld c, (hl) + ;ld a, l + ;add 8 + ;ld l, a + ;ld (hl), c - ld hl, RAM_BGMFMVol ; Restore BGM FM volume + PollPCM + + ;ld a, l ; Restore BGM FM instrument + ;sub 8*2 + ;ld l, a + + ld hl, RAM_BGMFMInstr ld a, b add l ld l, a - ld c, (hl) - ld a, l - add 8 - ld l, a - ld (hl), c - - PollPCM - - ld a, l ; Restore BGM FM instrument - sub 8*2 - ld l, a + push bc push de push hl diff --git a/src-z80/core/vars.z80 b/src-z80/core/vars.z80 index ef9a676..3496845 100644 --- a/src-z80/core/vars.z80 +++ b/src-z80/core/vars.z80 @@ -15,7 +15,8 @@ RAM_PSGData: ds 4*16 ; PSG envelope data RAM_BGMFMInstr: ds 8 ; FM instruments used by BGM RAM_BGMFMVol: ds 8 ; FM volumes used by BGM -RAM_FMVolume: ds 8 ; Volume of each FM channel +;RAM_FMVolume: ds 8 ; Volume of each FM channel + RAM_FMData: ds 8*5 ; FM info (for volume handling) ; ds 8*1 ... Register $B0 ; ds 8*1 ... Register $40 diff --git a/src-z80/player/fm.z80 b/src-z80/player/fm.z80 index 40cf5da..c492b91 100644 --- a/src-z80/player/fm.z80 +++ b/src-z80/player/fm.z80 @@ -519,34 +519,39 @@ SetFMVolBGM: jp ProcessBGMRun ; End of subroutine SetFMVolEvent: - push af + ex af, af' PollPCM call GetParam ; Get new volume PollPCM - pop af + ex af, af' SetFMVolBGMEvent: push bc push de push hl - ld hl, RAM_FMVolume ; Store new volume + ;ld hl, RAM_FMVolume ; Store new volume + ;and $07 + ;add l + ;ld l, a + ;ld (hl), b + + ;ld hl, RAM_FMData + ;ld a, l ; Get address of FM data + ;add 8 + ;ld l, a + + push af + ld hl, RAM_FMData ; Get address of FM data and $07 add l ld l, a - ld (hl), b - - ex af, af' PollPCM - ld a, l ; Get address of FM data - add 8 - ld l, a - ex af, af' + pop af SetFMVolLoad: push af - ;ld iyh, $40 ; Determine which port to write - and $04 + and $04 ; Determine which port to write rrca ld iyl, a PollPCM @@ -556,7 +561,7 @@ SetFMVolLoad: add $40 ld c, a - PollPCM + ;PollPCM ld a, (hl) ; Get algorithm and $07 @@ -572,8 +577,10 @@ SetFMVolLoad: jr c, .noop1 ld a, (hl) add b - cp $7F - jr c, .notooloud1 + ;cp $7F + ;jr c, .notooloud1 + ;ld a, $7F + jp p, .notooloud1 ld a, $7F .notooloud1: ld (iy+0), c @@ -593,8 +600,10 @@ SetFMVolLoad: jr c, .noop2 ld a, (hl) add b - cp $7F - jr c, .notooloud2 + ;cp $7F + ;jr c, .notooloud2 + ;ld a, $7F + jp p, .notooloud2 ld a, $7F .notooloud2: ld (iy+0), c @@ -614,8 +623,10 @@ SetFMVolLoad: jr c, .noop3 ld a, (hl) add b - cp $7F - jr c, .notooloud3 + ;cp $7F + ;jr c, .notooloud3 + ;ld a, $7F + jp p, .notooloud3 ld a, $7F .notooloud3: ld (iy+0), c @@ -632,8 +643,10 @@ SetFMVolLoad: ld l, a ld a, (hl) ; Process operator #4 add b - cp $7F - jr c, .notooloud4 + ;cp $7F + ;jr c, .notooloud4 + ;ld a, $7F + jp p, .notooloud4 ld a, $7F .notooloud4: ld (iy+0), c -- cgit v1.2.3