From a73ee8e7d8abcc865c9c151ef0e53bc73143dedc Mon Sep 17 00:00:00 2001 From: Ashelyn Rose Date: Tue, 24 Dec 2024 17:43:08 -0700 Subject: Implement call variants --- src/opcodes.rs | 48 ++++++++++++++++++++++++++++++++---------------- 1 file changed, 32 insertions(+), 16 deletions(-) diff --git a/src/opcodes.rs b/src/opcodes.rs index 1fbc80f..c583909 100644 --- a/src/opcodes.rs +++ b/src/opcodes.rs @@ -174,17 +174,19 @@ generate_opcodes!( #[code(0x40)] fn Copy(param: u32) -> u32 { - return param + param }, #[code(0x41)] - fn Copys() { - todo!(); + fn Copys(param: u32) -> u32 { + panic!("Copys not implemented"); + param }, #[code(0x42)] - fn Copyb() { - todo!(); + fn Copyb(param: u32) -> u32 { + panic!("Copyb not implemented"); + param }, #[code(0x44)] @@ -386,8 +388,10 @@ generate_opcodes!( }, #[code(0x130)] - fn Glk() { - todo!(); + fn Glk(&mut interpreter, glk_func: u32, num_args: u32) -> u32 { + println!("glk({glk_func}, {num_args})"); + Glk::call_func(interpreter, glk_func, num_args); + return 0 }, #[code(0x140)] @@ -450,19 +454,31 @@ generate_opcodes!( return 0; }, - #[code(0x161)] - fn Callfi() { - todo!(); + #[code(0x161), no_store] + fn Callfi(&mut interpreter, func_addr: u32, param0: u32) -> u32 { + interpreter.create_return_stub(); + interpreter.call_function(func_addr, vec![param0]); + + // This gets ignored because of gen_return_stub but it's here for type reasons + return 0; }, - #[code(0x162)] - fn Callfii() { - todo!(); + #[code(0x162), no_store] + fn Callfii(&mut interpreter, func_addr: u32, param0: u32, param1: u32) -> u32 { + interpreter.create_return_stub(); + interpreter.call_function(func_addr, vec![param0, param1]); + + // This gets ignored because of gen_return_stub but it's here for type reasons + return 0; }, - #[code(0x163)] - fn Callfiii() { - todo!(); + #[code(0x163), no_store] + fn Callfiii(&mut interpreter, func_addr: u32, param0: u32, param1: u32, param2: u32) -> u32 { + interpreter.create_return_stub(); + interpreter.call_function(func_addr, vec![param0, param1, param2]); + + // This gets ignored because of gen_return_stub but it's here for type reasons + return 0; }, #[code(0x170)] -- cgit 1.4.1