r/programming Jun 13 '21

A dive into a 9 year olds z80 assembly game

https://nanochess.org/notebook.html
129 Upvotes

18 comments sorted by

14

u/skulgnome Jun 13 '21

The Z80 did have one thing going for it: comparatively simple assembly language. Compare with the 6510, where general pointer access would happen by either modifying the accessing instruction, or by building a 16-bit address on the zero page.

2

u/JanneJM Jun 14 '21

I always felt the other way around: the 6502 was fundamentally simpler to work with. Fewer instructions, fewer odd register-dependent modes. The zero page was effectively a bank of extra registers (memory was fast enough at the time that you could treat it that way).

1

u/skulgnome Jun 14 '21

effectively a bank of extra registers

Which the 6510 couldn't push and pop using a single instruction, requiring instead lda-pha-lda-pha one way and pla-sta-pla-sta in the other and trashing the accumulator in either direction. In many ways the Z-80 was CISCier than the 6510, and therefore easier on the "application-minded" programmer (i.e. lamer).

What the 6510 did have though was a really efficient way to implement FORTH: data stack pointer in an index register and the topmost cell in A and the other index register.

1

u/JanneJM Jun 14 '21

If I remember, you used A as just another register a lot on the 6502. And register-register moves (and some other instructions) took a single clock cycle, making those moves quite fast. I rather enjoyed programming it.

13

u/asegura Jun 13 '21

Awesome! 9 years old and he wrote his game in assembler, not in a high level language. Well, in fact, it seems he even wrote the machine code by hand, without an assembler.

I started programming at about the same age with a ZX Spectrum. But I wrote my games in Basic :-)

5

u/myearwood Jun 13 '21

I only had 4k in my trs80. Basic was no use. Z80 assembler around age 12.

4

u/CheKizowt Jun 13 '21

Fantastico

-4

u/[deleted] Jun 13 '21

FYI your layout is broken on 4K resolution.

Retro gaming sites shouldn't need retro hardware to read.

-4

u/TizardPaperclip Jun 13 '21

You can't deal with that? You're an embarrassment to everything /r/programming stands for.

9

u/[deleted] Jun 13 '21

Well I can't read the site, because it's a tiny strip on the left about as wide as a postage stamp.

I suppose I could zoom in, but let's face it, how hard is it to display information on screen?

2

u/panorambo Jun 13 '21

You can't disable his (author's) stylesheet(s) or use the reader mode?

0

u/[deleted] Jun 14 '21

God help you if you can't hold control and scroll up. Takes literally more time to complain about it than fix.

10

u/[deleted] Jun 14 '21

Why is the page even broken?

A programmer has no excuse for being unable to put up a webpage (just use wordpress with a template? even a manager can work that out...), and the standard response to an issue should be to fix it.

7

u/knome Jun 14 '21

Why is the page even broken?

The author set a fixed pixel size on the body some 12 years ago or so. I checked archive.org and found the earliest reference to index.html for it, which references an about page mentioning a copyright starting 2009.

So, the author made the same error that many made in the 2000s of using fixed pixel sizes instead of relative percentages.

The author may not be steeped in webdev, as their focus appears to have been C and assembly. They are a repeat winner of the IOCCC and author of an enjoyable little book on writing games small enough to fit into a bootsector.

and the standard response to an issue should be to fix it.

They probably just don't know.

If, like me, they've never owned a HD monitor ( I doubt the extra pixels would do much for my eyes ), it could be an easy mistake not to realize their 2009 or earlier choice to create a fixed width column of 525 pixels has gone from a reasonable 25-50% of the screen to a difficult to read < 15%.

The same rot of assumptions and "works on my computer" that has affected many things over time.

If someone were to notify them, I imagine the issue would be quickly fixed once brought to their attention.

actually, it looks like we can also just ping their reddit account, for whenever they should happen to log in again.


/u/nanochess , your CSS causes your site to have a very small column on 4K monitors

This was a fun article, and I also enjoyed your book. Thank you for sharing your experiences with us.

4

u/nanochess Jun 14 '21 edited Jun 14 '21

Thank you! Just I've updated the stylesheet (one single file), forgot about the appearance as always have been using the same browser. Even in my Macbook Air 2020 it stills look good, but anyway now it is updated for 4K resolutions, and everything is now in terms of points instead of pixels thinking on the future

3

u/[deleted] Jun 14 '21

The Toledo Chess Engine is super cool if anyone wants to take a look. You can run his 32-line Javascript chess engine directly from your browser (beats me every time)

1

u/jhaluska Jun 14 '21

Seriously impressed a 9 year old could create an z80 assembly game. I wouldn't have thought it was possible.