Here is my bug-for-bug compatible 32-bit fixed-point decimal versions. I say bug-for-bug because my 16-bit integer version has a few bugs I need to fix. Download it and give it a try...see if it breaks on standard ZX81 BASIC (you can take .p files, convert them to BASIC and read that into ZXSimulator). Note that it does basic arithmetic, but no functions like COS, SIN, etc, have yet been implemented...that'll be the final step.
- zx.zip
- (38.14 KiB) Downloaded 114 times
First, I really enjoyed working on this. It made me remember how cool the QL was for me back in the 90's when all I had was it and a C compiler (Digital 'C' SE). Eventually I got a floppy and, along with a bit faster (and somewhat more reliable) media, I also got a subset of the TK2 instructions without losing my ROM port (i.e. I got ICE and a sub-TK2 all in ROM with no memory loss...those where the days).
Converting to 32-bit was a bit of a pain, mainly because I didn't want to wholesale replace every "int" with a "long" value. The issue with Digital 'C' SE is that it can do certain conversions but fails on others and it took me two solid days (until my wife had to get me as I was out in the tent coding past midnight each day) to figure it out. Luckily, good old prints in the code (which itself was a bit of a pain since I had to use the ZXprintf routine) helped.
So the compiler allows this:
...but then it struggles with any other cross type stuff. You cannot send an "int" into a function expecting a "long"...that one took most of my effort to figure out. The manual says that you must put an "L" after any literal, though that only seems to be the case in assignment since, if you leave it out within an "if" statement, it still works.
I used QLAY to do my work, and got tired of typing so I wrote a some helper scripts (SuperBASIC).
This was one of four that would recompile a module and link it, etc -- I had one each for cmd_c, aux_c, expr_c, and graph_c
(oh, and for whatever reason, on QLAY, the compiler hangs if I use WIN_ as devices, so I use MDV_ instead...it's a QLAY thing, not the compiler's fault):
Code: Select all
10 DELETE mdv2_zx: DELETE mdv2_expr_c: COPY win1_expr_c TO mdv2_expr_c: EXEC_W mdv3_cc;"expr_c -m -p": DELETE mdv2_expr_c: EXEC_W mdv3_cg;"zx cmd aux expr graph -nc": EXEC mdv2_zx
..and I wrote a distro script:
Code: Select all
10 DELETE win1_zx: COPY mdv2_zx TO win1_zx: DELETE mdv2_zx: DELETE mdv2_zx_zip: DELETE mdv2_src_zip
20 EXEC_W win7_zip;"src win1_cmd_h win1_cmd_c win1_aux_c win1_expr_c win1_graph_c"
30 DELETE win1_src_zip: COPY mdv2_src_zip TO win1_src_zip: DELETE mdv2_src_zip
40 EXEC_W win7_zip;"zx win1_zx win1_ball_bas win1_banner_bas win1_battleship_bas win1_elite_bas win1_src_zip"
[Edit: to see the new features, just work with fractions. It's only 2 decimal precision, but it does work. I haven't done the rounding yet that I thought I might do so all values just get truncated after the 2nd spot.]