Opened 19 years ago

Closed 2 months ago

#2536 closed defect (fixed)

SCUMM: MM (NES) - Minor newgame sound glitch

Reported by: SF/quietust Owned by: dwatteau
Priority: normal Component: Engine: SCUMM
Version: Keywords: NES
Cc: Game: Maniac Mansion

Description

Normally, when starting a new game, the "Pickup Item" sound can be heard before the starting room (full moon with all 3 characters) is drawn, immediately followed by Dave's music.

In ScummVM, however, this sound is never played, and the "crickets" sound is played in the room before Dave's music starts playing.

Ticket imported from: #1451721. Ticket imported from: bugs/2536.

Change History (13)

comment:1 by Kirben, 19 years ago

Summary: MMNES - Minor newgame glitchMANIACNES: Minor newgame glitch

comment:2 by fingolfin, 18 years ago

Summary: MANIACNES: Minor newgame glitchMANIACNES: Minor newgame sound glitch

comment:3 by SF/saturnyne, 17 years ago

Along that lines, would it be possible/reasonable to put the music and sound effects on different channels? It would allow scummvm to surpass just basic NES emulation by making it so that SFX and BGM don't have to borrow channels from each other when one interferes with the other.

comment:4 by sev-, 15 years ago

Owner: set to sev-
Priority: normalhigh

comment:5 by sev-, 15 years ago

This bug is nice to get fixed before the release. Raising priority for keeping the track.

comment:6 by digitall, 14 years ago

Confirmed that this is still the behaviour i.e. crickets, no pickup sound; with current master i.e. desc/1.3.0git-3499-gd054280 and Maniac Mansion (Europe).

comment:7 by sev-, 13 years ago

Owner: sev- removed

comment:8 by sev-, 12 years ago

Priority: highnormal

comment:9 by raziel-, 4 years ago

Summary: MANIACNES: Minor newgame sound glitchSCUMM: MM (NES) - Minor newgame sound glitch

comment:10 by dwatteau, 2 years ago

Some debug output when this part of the game is triggered:

Script 131, offset 0x42: [50] o2_pickupObject()
Adding object 49 from room 44 into inventory
getResourceAddress(Room,44)
_res->createResource(Inventory,0,237)
ensureResourceLoaded(Sound,51)
loadResource(Sound,51)
openRoom(41)
openResourceFile(41.LFL)
Opening hashed: 41.LFL
_res->createResource(Sound,51,19)
getResourceAddress(Sound,51)
...
getResourceAddress(Costume,3)
playSound #51
getResourceAddress(Sound,51)
getResourceAddress(Sound,51)
playSound #51
getResourceAddress(Sound,51)
getResourceAddress(Sound,51)
playSound #51
getResourceAddress(Sound,51)
getResourceAddress(Sound,51)
playSound #38
getResourceAddress(Sound,38)
getResourceAddress(Sound,38)

Sound no. 51 is the "Pickup item" sound, while sound no. 38 is the cricket sound (which is part of the background noise when you're outside). The pickup action is automatically triggered by the inventory initialization (one "CD" is given to each kid) at the top of script 44-131.

Playing the pickup sound is not done by the scripts, though; it's hardcoded in the engine:

https://github.com/scummvm/scummvm/blob/v2.6.0/engines/scumm/script_v2.cpp#L1670

void ScummEngine_v2::o2_pickupObject() {
...
	runInventoryScript(1);
	if (_game.platform == Common::kPlatformNES)
		_sound->addSoundToQueue(51);	// play 'pickup' sound
}

If I do this:

diff --git a/engines/scumm/script_v2.cpp b/engines/scumm/script_v2.cpp
index 99db95ce3d1..12daa6b56c4 100644
@@ -1681,7 +1681,7 @@ void ScummEngine_v2::o2_pickupObject() {
 
 	runInventoryScript(1);
 	if (_game.platform == Common::kPlatformNES)
-		_sound->addSoundToQueue(51);	// play 'pickup' sound
+		_sound->playSound(51);	// play 'pickup' sound
 }
 
 void ScummEngine_v2::o2_cursorCommand() {	// TODO: Define the magic numbers

then the pickup sound always takes priority, and the newgame sound now appears to be OK. But I don't know if that's the right way to fix this, and if it's safe to bypass the sound queue.

comment:11 by AndywinXp, 2 months ago

I just checked a NES disassembly and the fix above is what our code should do. It immediately calls startSound, which seems to immediately parse the sound and manipulate the four NES wave channels.

Want to commit it yourself?

comment:12 by dwatteau, 2 months ago

In 7f6aa593:

SCUMM: MM (NES): Fix sound effect when starting a new game (Trac#2536)

We should play the "Pickum item" sound when starting a new game, but until
now, only the "crickets" sound was played in ScummVM.

Using triggerSound() instead of addSoundToQueue() to deal with this sound
effect fixes this, and AndywinXp confirmed from 6502 disasm that "whatever
is called through startSound is executed immediately", and "there doesn't
seem to be a sound queue."

Thanks a lot again, Andy! :)

in reply to:  11 comment:13 by dwatteau, 2 months ago

Keywords: NES added
Owner: set to dwatteau
Resolution: fixed
Status: newclosed

Replying to AndywinXp:

I just checked a NES disassembly and the fix above is what our code should do. It immediately calls startSound, which seems to immediately parse the sound and manipulate the four NES wave channels.

Want to commit it yourself?

Thanks! I've just done so, so I'm closing this ticket.

Thanks again for looking at the disasm!

Note: See TracTickets for help on using tickets.