logoalt Hacker News

Porting my 3D points renderer on a ZX Spectrum 48K

64 pointsby ttsiodrasyesterday at 8:55 AM9 commentsview on HN

Comments

flohofwoetoday at 1:13 PM

Heh, I did a similar thing a couple of years ago when dogfooding my '8-bit homecomputer IDE' for VSCode (https://marketplace.visualstudio.com/items?itemName=floooh.v...).

I've come to the conclusion that it wasn't coding on assembly level that made development in the 80s slow, but old vs modern tooling. E.g with good tools coding in assembly isn't all that much less productive than coding in a higher level language (unless you're just glueing together 3rd-party packages of course).

With a good macro assembler you're already much closer to a highlevel language like C than to machine code, and with a quick 'edit-compile-debug' loop using an emulator for running the debugee that allows to inspect the entire machine state (and not just the CPU state) you get pretty much the same productivity as working in a "proper" high level programming language, just with a slightly different approach to abstractions (in assembly code, subroutine calls and data layout are your abstraction tools, not the type system of a highlevel language).

Here's the demo I built (no sound, because I suck at sound):

Source: https://github.com/floooh/kcide-sample-kc854 (note: if you're logged in to Github you can just press '.' (dot) to start into the web-version of VSCode which after a little while will ask to install recommended extensions).

Running in emulator via WASM: https://floooh.github.io/kcide-sample/kc854.html?file=demo.k...

show 1 reply
terramextoday at 3:17 PM

> Then again, maybe you, kind reader, can try this out on your Speccy - and tell me if it works?

It does, here is 'Statue' loading and running on Belarusian 'Bajt' ZX Spectrum clone: https://youtube.com/shorts/0LaItots33Q?feature=share

show 1 reply
Dwedittoday at 2:15 PM

If you want to write faster Z80 code, pretend it's a Game Boy, and use the IX/IY registers sparingly. You can use 256-byte aligned tables. Then you put your index into the low byte of the register pair, and which table into the high byte of the register pair. You don't even need to completely use the table if you don't need all 256 entries, you can treat the rest of a table as free space to put other variables in there.

edit: At the time I made the post, the thread title was something like "Doing Z80 40 years later", and did not mention the ZX spectrum.

show 1 reply
ggambettatoday at 1:08 PM

I love this! Happy to see I'm not the only crazy out there trying to port modern renderers to the Spectrum :D I've been meaning to experiment with assembly, but haven't gotten to that yet. This has some good ideas I'd love to play with.

IndianAISupporttoday at 2:25 PM

[flagged]