Aclock is a program that turns your mainframe, workstation, microcomputer or another kind of old and expensive equipment in an ASCII wall clock. Its binaries were executed in near of 250 computer systems and now is time to add MSX to this group.
This version has based on CP/M Plus release for ZX Spectrum +3 and has compiled using SDCC with a little help of Avelino Herrera’s MSX-DOS backend. It works on any MSX2, MSX2+ or MSX turbo R running MSX-DOS operating system. And, of course that it doesn’t work on MSX1 models due the lack of real time clock circuit.
By the way, this is a short version in (bad) English from my original post in Portuguese.
TL;DR The program running!
That’s the video of aclock running on my Panasonic FS-A1ST in R800 mode and in 80 columns text mode. Both source code, binary and disk image can be downloaded from my fork of the original repository on GitHub.
Why not MSX-C?
That’s a good question that needs an answer because MSX-C is the official “C” compiler for MSX system, released by ASCII Corporation in 1988 and containing all libraries needed to access MSX BIOS, MSX BDOS and MSX Mathpack. I’ve tried it but have had some problems with its “interesting” syntax, strange behaviour in printf() and, the most important, code compile only using a real/emulated machine.
Tweaks on original speccy‘s code
The original ZX Spectrum version has written in Hitech-C and compiles with small changes on SDCC but runs with bad performance and only showing 06 hours, 28 minutes and 15 seconds on screen.
So, some things need to be fixed or to be (re)done:
- Sine and cosine tables: To improve performance I’ve decided to not use sine and cosine functions from “math.h” and store all the needed sixty values in two arrays, sin_t and cos_t.
- Screen size: The original aclock‘s code adjusts itself to target’s screen size¹. MSX-DOS can runs in a dozen of text modes² in both ASCII and Kanji. To support them I read LINLEN (0xf3b0) and CRTCNT (0xf3b1) system variables to obtain current screen size and to calculate position and size of clock’s face and hands.
- Cursor position: Instead of sending VT-52 codes to move cursor position I cheat MSX-BIOS changing directly CSRY (0xf3dc) and CSRX (0xf3dd) system variables.
- System’s time: Remembering that SDCC‘s “time.h” isn’t properly working, so I’ve written a simple function in assembly to get system time calling MSX-BDOS‘s GetTime (0x2c) routine.
(¹) The speccy version runs in a 51×24 characters text mode.
(²) There are text modes with 32, 40, 64 or 80 columns and with 14 or 25 lines.
And to conclude
I haven’t a “deep knowledge” about C but did this conversion help me to learn a bit more about syntax and structure of the programming language and more about how a compiler works. Even that in few moments, I simply though in give up and rewrite everything in assembly! 😀