Author: SpaceWumpus
Category: Christmas Challenge
System: 16/48k ZX Spectrum
Language: Assembler (sjasmplus)
Len source code: 98 bytes (BASIC stub incorporating the assembled code embedded in REM statement)
Len exe file: 112 bytes (plus standard 17 byte header)
Len code only: 88 bytes
Instructions:
Code is a standard compressed TAP file (TGZ), which should be loadable in any ZX Spectrum emulator.
Tested with Fuse emulator. Install and start Fuse, drag 'star.tzx' file into the window. That's it!
Description:
Assembled code is embedded into a REM (remark aka comment) in a BASIC program.
The BASIC program auto-runs after loading, and calls the machine code.
This is a little more compact that the more conventional approach of having the BASIC stub load the assembled code as a separate file.
The code itself has a number of steps:
0. Disables interrupts. (1 byte)
1. Calls ROM routine at $0daf to clear screen and set cursor at top-left. (3 bytes)
2. Prints (most of) a screen full of *'s using RST $10 ROM restart routine. (11 bytes)
3. Sets all attributes to black ink on black paper to give a black display. (10 bytes)
4. Draws the top-right of the star as a series of 5 nested L-shaped regions. (29 bytes)
5. Modifies the code from 4 to draw a reversed L region for the top-left, and jumps back into that code. (17 bytes)
6. Copies the attribute data for the bottom half of the star in reverse from that of the top half. (16 bytes)
7. Halts and waits for an interrupt, which will never come because we disabled them. (1 byte)
Total length 88 bytes.
Comments:
I've only recently started learning/writing Z80, and I'm pretty happy with what I've achieved.
This was a fun chance to practice.