mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-10-04 12:58:04 +03:00
Implement MSG instruction
This commit is contained in:
+1
-1
@@ -135,7 +135,7 @@ const struct instruction instructions[NR_OPCODES] = {
|
||||
OP(A_FILL, 0),
|
||||
OP(C_REF, 0),
|
||||
OP(C_ASSIGN, 0),
|
||||
OP(MSG, 0), // TODO
|
||||
JMP(MSG, 1, INSTR_INT),
|
||||
OP(CALLHLL, 2, INSTR_INT, INSTR_INT),
|
||||
OP(PUSHSTRUCTPAGE, 0),
|
||||
JMP(CALLMETHOD, 1, INSTR_FUN),
|
||||
|
||||
@@ -120,4 +120,17 @@ void test_lang(void)
|
||||
test_equal("string switch (no default)", test_string_switch("d"), 100);
|
||||
test_equal("string switch (default)", test_string_switch_default("d"), 100);
|
||||
test_equal("local ref escape", (set_page_ref(42), gi), 42);
|
||||
'message1';
|
||||
'message2';
|
||||
}
|
||||
|
||||
int msg_count = 0;
|
||||
|
||||
void message(int msg_nr, int nr_messages, string msg)
|
||||
{
|
||||
if (msg_count == 0)
|
||||
test_string("message1", msg, "message1");
|
||||
else if (msg_count == 1)
|
||||
test_string("message2", msg, "message2");
|
||||
msg_count++;
|
||||
}
|
||||
|
||||
@@ -626,6 +626,14 @@ static void execute_instruction(int16_t opcode)
|
||||
case SJUMP:
|
||||
scenario_call(stack_pop().i);
|
||||
break;
|
||||
case MSG:
|
||||
if (ain->msgf < 0)
|
||||
break;
|
||||
stack_push(get_argument(0));
|
||||
stack_push(ain->nr_messages);
|
||||
stack_push_string(string_ref(ain->messages[get_argument(0)]));
|
||||
function_call(ain->msgf, instr_ptr + instruction_width(MSG));
|
||||
break;
|
||||
case JUMP: // ADDR
|
||||
instr_ptr = get_argument(0);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user