Added a 'get any key' block.

This commit is contained in:
Martin Haye
2015-06-03 07:56:19 -07:00
parent 44be65de1a
commit 5fa973ea7c
4 changed files with 29 additions and 0 deletions

View File

@@ -65,6 +65,7 @@
<block type="text_moveto"></block>
<block type="text_print"></block>
<block type="text_println"></block>
<block type="text_getanykey"></block>
<block type="text_mode"></block>
<block type="text_scroll"></block>
<block type="text"></block>

View File

@@ -264,6 +264,18 @@ if (typeof Mythos === "undefined") {
this.setTooltip('Print text and leave cursor at end of last printed character');
}
};
Blockly.Blocks['text_getanykey'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);
this.setColour(54);
this.setPreviousStatement(true);
this.setNextStatement(true);
this.appendDummyInput()
.appendField("Get any key");
this.setOutput(false);
this.setTooltip('Get a key from the keyboard (and discard it)');
}
};
Blockly.Blocks['text_mode'] = {
init: function () {
this.setHelpUrl(Mythos.helpUrl);

View File

@@ -1399,6 +1399,7 @@ class PackPartitions
def vec_setPortrait = 0x318
def vec_clrPortrait = 0x31B
def vec_moveBackward = 0x31E
def vec_getCharacter = 0x321
def emitAuxString(str)
{
@@ -1513,6 +1514,8 @@ class PackPartitions
case 'text_print':
case 'text_println':
packTextPrint(blk); break
case 'text_getanykey':
packGetAnyKey(); break
case 'controls_if':
packIfStmt(blk); break
case 'events_set_map':
@@ -1617,6 +1620,15 @@ class PackPartitions
emitCodeByte(0x30) // DROP
}
def packGetAnyKey(blk)
{
//println " get any key"
emitCodeByte(0x54) // CALL
emitCodeWord(vec_getCharacter)
emitCodeByte(0x30) // DROP
}
def packIfStmt(blk)
{
if (blk.value.size() == 0) {

View File

@@ -1313,6 +1313,10 @@ def setCallbacks()
// $31E
callbacks.30 = $4c
callbacks:31 = @moveBackward
// $321
callbacks.33 = $4c
callbacks:34 = @getUpperKey
end
///////////////////////////////////////////////////////////////////////////////////////////////////