Added support for playing sounds via emulator.

This commit is contained in:
Martin Haye 2021-04-22 08:52:57 -07:00
parent 21312acdb8
commit f47713b4e0
6 changed files with 79 additions and 0 deletions

View File

@ -173,6 +173,9 @@
<block type="graphics_intimate_mode"></block>
</category>
<category name="Sound">
<block type="sound_play_emu_track"></block>
<block type="sound_play_emu_sfx"></block>
<block type="sound_stop_emu_playback"></block>
</category>
<category name="Preconnected">
<!-- Press any key -->

View File

@ -1001,6 +1001,47 @@ if (typeof Mythos === "undefined") {
this.setTooltip('Display the given portait image (by name)');
}
};
Blockly.Blocks['sound_play_emu_track'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);
this.setColour(54);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.appendDummyInput()
.appendField("Play track")
.appendField(new Blockly.FieldTextInput("1"), "NUM")
.appendField("in emulator")
.appendField(new Blockly.FieldDropdown([["once", "0"], ["repeating", "1"]]), "REPEAT");
this.setOutput(false);
this.setTooltip('Play track in emulator');
}
};
Blockly.Blocks['sound_play_emu_sfx'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);
this.setColour(54);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.appendDummyInput()
.appendField("Play special effect")
.appendField(new Blockly.FieldTextInput("1"), "NUM")
.appendField("in emulator");
this.setOutput(false);
this.setTooltip('Play special effect in emulator');
}
};
Blockly.Blocks['sound_stop_emu_playback'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);
this.setColour(54);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.appendDummyInput()
.appendField("Stop playback in emulator")
this.setOutput(false);
this.setTooltip('Stop playback in emulator');
}
};
Blockly.Blocks['graphics_set_avatar'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);

View File

@ -5013,6 +5013,11 @@ end
packBuyFromStore(blk); break
case 'interaction_sell_to_store':
packSellToStore(blk); break
case 'sound_play_emu_track':
case 'sound_play_emu_sfx':
packSoundPlayEmu(blk); break
case 'sound_stop_emu_playback':
packSoundStopEmu(blk); break
case ~/^Globalignore_.*$/:
packGlobalCall(blk); break
default:
@ -5175,6 +5180,28 @@ end
outIndented("promptAnyKey($clrFlg)\n")
}
def packSoundPlayEmu(blk)
{
assert blk.field.size() >= 1
assert blk.field[0].@name == 'NUM'
def soundNum = blk.field[0].text().toInteger()
assert soundNum >= 1 && soundNum <= 63
if (blk.@type == 'sound_play_emu_track') {
assert blk.field.size() == 2
assert blk.field[1].@name == 'REPEAT'
def repeatFlg = blk.field[1].text()
assert repeatFlg == "0" || repeatFlg == "1"
outIndented("soundPlayEmu($soundNum | ($repeatFlg << 6))\n")
}
else
outIndented("soundPlayEmu($soundNum | \$80)\n")
}
def packSoundStopEmu(blk)
{
outIndented("soundPlayEmu(0)\n")
}
def packVarSet(blk)
{
def name = "v_" + humanNameToSymbol(getSingle(blk.field, 'VAR'), false)

View File

@ -132,6 +132,7 @@ import gamelib
predef setMap(is3D, num, x, y, dir)#0
predef setRecordMode(enable)#0
predef setStoryMode(enable)#0
predef soundPlayEmu(numAndFlgs)#0
predef useMapWindow()#0
predef setBigWindow()#0
predef setPortrait(portraitNum)#0

View File

@ -1845,6 +1845,12 @@ def clearTextWindow()#0
fin
end
///////////////////////////////////////////////////////////////////////////////////////////////////
export def soundPlayEmu(numAndFlgs)#0
printf1("soundPlayEmu($%x)\n", numAndFlgs)
^EMUSOUND_PLAY = numAndFlgs
end
///////////////////////////////////////////////////////////////////////////////////////////////////
def hline(addr, startByte, midByte, midSize, endByte)#0
^addr = startByte

View File

@ -94,6 +94,7 @@ const EMUSIG_3D_MAP = $C04C // e.g. in town
const EMUSIG_AUTOMAP = $C04D // all color except the map title
const EMUSIG_STORY = $C04E // all text except a portrait
const EMUSIG_TITLE = $C04F // all color except title screen menu area
const EMUSOUND_PLAY = $C069 // num | ($40=repeat) | ($80=SFX)
// Game load/save
const RWTS_SEEK = 0