Hacker News new | ask | show | jobs
by an-unknown 755 days ago
This project looks interesting. I saw you use stty to configure the console, but there is a native "UNIX way" to do this via tcgetattr/tcsetattr, you'll have to figure out how to use these C functions elegantly in Go though / if there is some Go package which wraps them already. On Windows you'll have to configure the console via win32 API calls GetConsoleMode/SetConsoleMode and again you'll have to figure out how to do this from Go ⇒ you'll have to add some compile time switch between "UNIX like" OS and Windows to support both. The "UNIX like" version should work on Linux, macOS, and various other UNIX like systems.

You could also improve the debugging experience with full execution trace recording (record all executed instructions / memory accesses / … to a trace file) which would not only give you detailed information about what exactly went wrong if something goes wrong but also allow you to directly debug your own Z80 code on assembler level.

3 comments

Thanks for the feedback - there's a disjoined comment in the README on portability that points to the golang package x/term, and a single open bug report that says "fix it".

So I have a plan, but it's a bit more annoying than I'd like to handle. At least the "conditional compilation" via build-tags is nice and straight-forward!

There is a trace of all CP/M syscalls made, available via the "-log-path" command-line option, but so far I've not needed to debug actual Z80 opcodes.

I dabble with the CP/M simulator in z80pack.

And I had to use stty to make it work better from the command line. At least from BASH on MacOS.

Minimally, you need to disable ^Z, or you send it into the background. ^Z is the EOF character for text files in CP/M.

The other is ^Y. Which is another suspend process command for BASH. ^Y is important for Turbo Pascal, it’s a key editing command.

I don’t think I’ve have to fix any others. Those two have let me do what I want so far.

> you'll have to add some compile time switch

Isn't it best to use the switch already built into Go?