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 From eaefc4887707c8ada8f67fa944c03793191d0b55 Mon Sep 17 00:00:00 2001 From: Javier Degirolmo Date: Sat, 15 Oct 2011 14:15:25 -0300 Subject: Somebody help me find WTF is going on --- README | 5 +++ built/massive-crash.bin | Bin 0 -> 4864 bytes src-z80/core/bgm.z80 | 33 ++++++++++----- src-z80/core/sfx.z80 | 34 +++++++-------- src-z80/core/vars.z80 | 3 +- src-z80/player/fm.z80 | 108 ++++++++++++++++++++++++------------------------ src-z80/player/freq.z80 | 2 +- 7 files changed, 102 insertions(+), 83 deletions(-) create mode 100644 built/massive-crash.bin diff --git a/README b/README index 122c26c..2172920 100644 --- a/README +++ b/README @@ -43,6 +43,11 @@ How to build: Available builds: + built/echo-massive-crash.bin + Massive Echo crasher o_o; Two tunes screw up if played repeatedly, two + tunes outright crash the entire system. This only happens on real + hardware, *not* in emulators. FML. + built/echo-timer-version-a.bin Timer test. Both timers get reloaded each time they're fired. built/echo-timer-version-b.bin diff --git a/built/massive-crash.bin b/built/massive-crash.bin new file mode 100644 index 0000000..ae74673 Binary files /dev/null and b/built/massive-crash.bin differ diff --git a/src-z80/core/bgm.z80 b/src-z80/core/bgm.z80 index f69235d..eac10d9 100644 --- a/src-z80/core/bgm.z80 +++ b/src-z80/core/bgm.z80 @@ -73,6 +73,7 @@ ProcessBGM: ld d, (hl) ex de, hl +ProcessBGMSkip: ProcessBGMRun: PollPCM ; Fetch next event call GetParam @@ -163,9 +164,7 @@ ProcessBGMSkip1: ; This is where we land after a locked event inc c .nobankskip1: -ProcessBGMSkip: ; This is where we land after a locked event - PollPCM ; without parameters - + PollPCM jp ProcessBGMRun ; Keep processing ;**************************************************************************** @@ -210,39 +209,51 @@ ClearBGM: or a call z, StopPCM +;---------------------------------------------------------------------------- + ld b, 4 ; Mute all non-locked PSG channels ld de, RAM_PSGData+48 ld hl, RAM_Locked+11 .mutepsg: PollPCM + ld a, (hl) or a - jr nz, .nopsgmute + jp nz, .nopsgmute xor a ld (de), a .nopsgmute: PollPCM + ld a, e sub 16 ld e, a + dec l djnz .mutepsg +;---------------------------------------------------------------------------- + ld b, 8 ; Mute all non-locked FM channels .mutefm: PollPCM - ld a, (hl) + + ld a, (hl) ; Check if channel is locked or a - jr nz, .nofmmute + jp nz, .nofmmute + PollPCM - dec b - ld (ix+0), $28 - ld (ix+1), b - inc b -.nofmmute: + + ld a, b ; Kill FM channel + dec a + call KillFM + +.nofmmute: ; Go for next channel dec l djnz .mutefm +;---------------------------------------------------------------------------- + ret ; End of subroutine ;**************************************************************************** diff --git a/src-z80/core/sfx.z80 b/src-z80/core/sfx.z80 index c778776..0a7d1e8 100644 --- a/src-z80/core/sfx.z80 +++ b/src-z80/core/sfx.z80 @@ -276,25 +276,9 @@ ClearSFX: ld a, b ; Kill ADSR call KillFM - ;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 - PollPCM - ;ld a, l ; Restore BGM FM instrument - ;sub 8*2 - ;ld l, a - - ld hl, RAM_BGMFMInstr + ld hl, RAM_BGMFMInstr ; Restore BGM FM instrument ld a, b add l ld l, a @@ -309,6 +293,22 @@ ClearSFX: pop de pop bc + ;PollPCM + + ;ld a, l + ;add 8 + ;ld l, a + + ;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 + PollPCM inc b .fmfree: diff --git a/src-z80/core/vars.z80 b/src-z80/core/vars.z80 index 3496845..64a1dde 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 diff --git a/src-z80/player/fm.z80 b/src-z80/player/fm.z80 index c492b91..c075f99 100644 --- a/src-z80/player/fm.z80 +++ b/src-z80/player/fm.z80 @@ -4,30 +4,32 @@ ;**************************************************************************** NoteOnFMSFX: + and $07 ; Get channel number call NoteOnFM ; We're just a wrapper jp ProcessSFXRun ; End of subroutine NoteOnFMBGM: + and $07 ; Get channel number ld b, a PollPCM - push hl + push hl ; Check if channel is free ld a, b - and $07 ; Check if channel is free - ld hl, RAM_Locked - add l + ld h, RAM_Locked>>8 + add RAM_Locked&$FF ld l, a ld a, (hl) pop hl or a jp nz, ProcessBGMSkip1 ; Don't play if locked + + PollPCM ld a, b call NoteOnFM ; We're just a wrapper jp ProcessBGMRun ; End of subroutine NoteOnFM: - and $07 ; Get channel ID ld (ix+0), $28 ; Note off ld (ix+1), a @@ -100,18 +102,20 @@ NoteOnFM: ;**************************************************************************** NoteOffFMSFX: + and $07 ; Get channel ID call NoteOffFM ; We're just a wrapper jp ProcessSFXRun ; End of subroutine NoteOffFMBGM: + and $07 ; Get channel ID + ld b, a PollPCM ld a, b - push hl - and $07 ; Check if channel is free - ld hl, RAM_Locked - add l + push hl ; Check if channel is free + ld h, RAM_Locked>>8 + add RAM_Locked&$FF ld l, a ld a, (hl) pop hl @@ -123,9 +127,9 @@ NoteOffFMBGM: jp ProcessBGMRun ; End of subroutine NoteOffFM: - and $07 ; Get channel ID ld (ix+0), $28 ; Note off ld (ix+1), a + ret ; End of subroutine ;**************************************************************************** @@ -144,8 +148,8 @@ SetNoteFMBGM: push hl and $07 ; Check if channel is free - ld hl, RAM_Locked - add l + ld h, RAM_Locked>>8 + add RAM_Locked&$FF ld l, a ld a, (hl) pop hl @@ -180,18 +184,15 @@ SetNoteFM: ld e, a PollPCM - ld (iy+0), e ; Load high byte ld (iy+1), b - PollPCM ; Load low byte - call GetParam + call GetParam ; Load low byte PollPCM ld a, e sub 4 ld e, a - ld (iy+0), e ld (iy+1), b @@ -205,26 +206,31 @@ SetNoteFM: ;**************************************************************************** LoadFMSFX: + and $07 ; Get channel ID call LoadFMEvent ; We're just a wrapper jp ProcessSFXRun ; End of subroutine LoadFMBGM: and $07 ; Get channel ID + ld b, a PollPCM push de push bc ld a, b - ld de, RAM_BGMFMInstr ; Store instrument ID - add e + + ld de, RAM_BGMFMInstr ; Where to keep instrument ID for BGM + add e ; (used when unlocking channels) ld e, a - PollPCM + + PollPCM ; Store instrument ID call GetParam PollPCM ex de, hl ld (hl), b ex de, hl + ld e, c pop bc ld c, e @@ -232,10 +238,10 @@ LoadFMBGM: PollPCM - push hl ; Check if channel is free - ld hl, RAM_Locked + push hl ; Check if channel is free ld a, b - add l + ld h, RAM_Locked>>8 + add RAM_Locked&$FF ld l, a ld a, (hl) pop hl @@ -244,8 +250,7 @@ LoadFMBGM: PollPCM - ld a, b - and $07 + ld a, b ; Get back the instrument ID push hl ld hl, RAM_BGMFMInstr add l @@ -253,23 +258,21 @@ LoadFMBGM: ld b, (hl) pop hl - push af + ex af, af' PollPCM - pop af + ex af, af' call LoadFMDirect ; We're just a wrapper jp ProcessBGMRun ; End of subroutine LoadFMEvent: - and $07 ; Get channel ID - ex af, af' PollPCM call GetParam ; Get instrument ID PollPCM ex af, af' + LoadFMDirect: - push af and $04 ; Determine which port to write rrca @@ -333,9 +336,14 @@ LoadFMDirect: call KillFM ld a, b - ld de, RAM_FMData ; Get address of FM data + ;ld de, RAM_FMData ; Get address of FM data + ;and $07 + ;add e + ;ld e, a + and $07 - add e + ld d, RAM_FMData>>8 + add RAM_FMData&$FF ld e, a push af @@ -577,9 +585,6 @@ SetFMVolLoad: jr c, .noop1 ld a, (hl) add b - ;cp $7F - ;jr c, .notooloud1 - ;ld a, $7F jp p, .notooloud1 ld a, $7F .notooloud1: @@ -600,9 +605,6 @@ SetFMVolLoad: jr c, .noop2 ld a, (hl) add b - ;cp $7F - ;jr c, .notooloud2 - ;ld a, $7F jp p, .notooloud2 ld a, $7F .notooloud2: @@ -623,9 +625,6 @@ SetFMVolLoad: jr c, .noop3 ld a, (hl) add b - ;cp $7F - ;jr c, .notooloud3 - ;ld a, $7F jp p, .notooloud3 ld a, $7F .notooloud3: @@ -643,9 +642,6 @@ SetFMVolLoad: ld l, a ld a, (hl) ; Process operator #4 add b - ;cp $7F - ;jr c, .notooloud4 - ;ld a, $7F jp p, .notooloud4 ld a, $7F .notooloud4: @@ -691,8 +687,7 @@ SetFMParam: ld b, a PollPCM - ;ld iyh, $40 ; Determine which port to write - ld a, b + ld a, b ; Determine which port to write and $04 rrca ld iyl, a @@ -752,12 +747,18 @@ LockChannelFM: ;**************************************************************************** KillFM: - push af + and $07 ; Trim non-channel bits + + push hl push de + push af - and $03 ; Load dummy FM instrument + ld (ix+0), $28 ; Note off + ld (ix+1), a + + and $03 ; Load dummy FM instrument add $40 - ld c, 6 + ld d, 6 ld hl, DummyFMInstr .loaddummy: ex af, af' @@ -779,19 +780,20 @@ KillFM: add 4 inc l - dec c + dec d jp nz, .loaddummy - pop de PollPCM pop af - - ld c, a ; Reset ADSR + + ld d, a ; Reset ADSR or $F0 ld (ix+0), $28 ld (ix+1), a ld (ix+0), $28 - ld (ix+1), c + ld (ix+1), d + pop de + pop hl PollPCM ret ; End of subroutine diff --git a/src-z80/player/freq.z80 b/src-z80/player/freq.z80 index a469c0b..0b529de 100644 --- a/src-z80/player/freq.z80 +++ b/src-z80/player/freq.z80 @@ -101,5 +101,5 @@ DummyFMInstr: db $1F ; $50..$5C db $1F ; $60..$6C db $1F ; $70..$7C - db $0F ; $80..$8C + db $FF ; $80..$8C db $00 ; $90..$9C -- cgit v1.2.3 From 021b61e18ed19cc97c57433772b15ccd8c9a27b6 Mon Sep 17 00:00:00 2001 From: Javier Degirolmo Date: Sat, 15 Oct 2011 14:17:39 -0300 Subject: Oops wrong filename in README --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 2172920..869ee66 100644 --- a/README +++ b/README @@ -43,7 +43,7 @@ How to build: Available builds: - built/echo-massive-crash.bin + built/massive-crash.bin Massive Echo crasher o_o; Two tunes screw up if played repeatedly, two tunes outright crash the entire system. This only happens on real hardware, *not* in emulators. FML. -- cgit v1.2.3