gwenhael-le-moine / x48

HP48 calculator emulator (mirror of sourceforge's mirror of berlios)
GNU General Public License v2.0
38 stars 17 forks source link

Accessing emulated calculator stack/state? #10

Open jmbreuer opened 3 weeks ago

jmbreuer commented 3 weeks ago

I'm looking to extend the Android port of x48 by copy/paste functionality.

Therefore, I'm looking to access the (calculator, ie the one that's displayed on the screen) stack of the emulated device - any suggestions on how to best do that? Are there any docs that would allow me to make heads or tails of the fields in saturn_t e.g.?

An approximation of pasting could probably work by just simulating key press events... (?) From the perspective of people who might have at least some understanding of the architecture of the device and/or the emulator, is there an obvious 'better' approach?

gwenhael-le-moine commented 3 weeks ago

Hello,

I can only give some pointers to where you can look for inspiration... x48 does seem to implement the "simulating key press events" solution: https://github.com/gwenhael-le-moine/x48/blob/legacy/src/x48_x11.c#L3834

For accessing the stack's content there is this function in the debugger that prints it out: https://github.com/gwenhael-le-moine/x48/blob/legacy/src/debugger.c#L1034

Another emulator implements a load_file_on_stack() function that may interest you: https://codeberg.org/gwh/hpemung/src/branch/trunk/src/persistence.c#L278

To (try to) make sense of all this you could start with https://grack.com/writing/saturn/saturn.txt and https://www.hpcalc.org/contents/1693/asmtut.pdf

Good luck!

jmbreuer commented 3 weeks ago

Good luck!

Awesome, thank you so much for all the pointers!