Maze CPC is a maze generator in 12 bytes for Amstrad CPC664/6128 8-bit computers.
![screen shot](https://private-user-images.githubusercontent.com/241217/237895406-f9e88595-08b2-422b-9a97-06e546f54b31.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzg5NzM0OTEsIm5iZiI6MTczODk3MzE5MSwicGF0aCI6Ii8yNDEyMTcvMjM3ODk1NDA2LWY5ZTg4NTk1LTA4YjItNDIyYi05YTk3LTA2ZTU0NmY1NGIzMS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOFQwMDA2MzFaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT01ODcwZDM3MjU4ZTAwOTNiYTMwMDEyNGQ0ZDA3NzY1MTMyYmRmZTIzMTQ4NTI0ZDMyYWM5MzhkNmE5NWE1MDIzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.XrDJarL1y8j0OZN9LSApXk5HFpkNxzQ2wi_fIA8N6GA)
There is a book called "10 PRINT CHR$ (205.5 + RND (1)); : GOTO 10". Yes that's the title. It's about a small code piece in BASIC language that generates a maze. An interesting read for programmers. It delves into attempts to create it in assembly as small as possible, which seems to have become a trend in Commodore 64 demoscene.
I saw a blog post from Trixter who tried to port it to PC. It eventually got down to 10 bytes.
Tonight I wanted to give it a shot on Amstrad CPC and here it is, 11 14 12-bytes maze generator, created in a couple of hours.
I found it very hard to produce a series of "random bits" on a Z80 CPU. There is R register which increases every cycle but naturally deterministic in loops. To keep the code short, however, I relied on it and interrupts to introduce a slight entropy. I'm sure there is room for improvement.
Update Dec 29th, 2018: I made the random generator much better by sacrificing 3 more bytes. It's a 14-byte maze generator now.
Update May 2nd, 2023: I resorted to using firmware call for RND to get the random number,
saving another 2 bytes. But, the code doesn't run on CPC464 now due to missing firmware call. The 14-byte CPC464 version still exists in maze464.asm
.
SSG / arteffect, March 24th 2015