Fake I/O port using TCL?

By Creepy

Champion (335)

Creepy's picture

26-06-2017, 21:38

I'm looking for a way to return data to the emulated MSX via an I/O port for debugging en testing purposes. I was hoping to use a TCL script for that, but my knowledge of TCL is not that great, and at this time I do not even have a clue if this is possible.

What I want to do is testing some code that reads ascii chars from an I/O port. I would like to be able to specificy which data is returned when reading from a given I/O port. Is this possible in OpenMSX? And if not with TCL, maby it's possible with some sort of (fake) pluggable device?

Login or register to post comments

By Grauw

Ascended (10180)

Grauw's picture

26-06-2017, 22:04

Not sure whether a watchpoint executes before or after the read but; in the former case you could set a memory watchpoint and poke your values into a RAM memory address (which is then read), in the latter case you could alter the register value (probably want to assume it is “a” or sth for simplicity).

By Creepy

Champion (335)

Creepy's picture

27-06-2017, 11:23

A memory breakpoint is a good idea. The input is read into a buffer so with a breakpoint on the buffer I can change the values from the debugger.


Enlighted (5889)

NYYRIKKI's picture

27-06-2017, 11:26

I don't have much to add... but from more technical point of view you can trigger a TCL script with:
debug set_watchpoint read_io port {additional condition} {your routine name}

You then need to figure out what is going on with "peek" and "reg PC" you can use reg-command also to return the value to Z80 or with poke to memory in case ie. INIR was executed. Indeed some Z80 emulation will be required. I've used similar yet simpler trick to load the CAS-files, but in that case I was trapping only BIOS calls.