scene.org File Archive

File download

<root>­/­parties­/­2024­/­vccc24­/­christmas_challenge/marcosretrobits_zxspectrum_basic_102b_vc3-2024.zip

File size:
7 384 bytes (7.21K)
File date:
2024-12-29 14:13:04
Download count:
all-time: 0

Preview

  • marcosretrobits_zxspectrum_basic_102b_vc3-2024/ dir
  • marcosretrobits_zxspectrum_basic_102b_vc3-2024/file_id.diz 2.85K
  • marcosretrobits_zxspectrum_basic_102b_vc3-2024/TheSpectrumPresent.bas 162B
  • marcosretrobits_zxspectrum_basic_102b_vc3-2024/TheSpectrumPresent.gif 7.91K
  • marcosretrobits_zxspectrum_basic_102b_vc3-2024/TheSpectrumPresent.tap 139B
  • marcosretrobits_zxspectrum_basic_102b_vc3-2024/TheSpectrumPresent_BasinC.bas 298B

file_id.diz

The Spectrum Present

Author: Marco's Retrobits
Category: Christmas Challenge
System:   Sinclair ZX Spectrum
Language: BASIC
Len source code: 102 bytes
Len exe file:    -
Len code only:   - (valid for assembler only; length of executable without BASIC stub)

Instructions:
Install Fuse, check that the emulated machine is ZX Spectrum 48K and that automatic media loading is enabled. 
Drag and drop the "TheSpectrumPresent.tap" file into the emulator window, then press either "ENTER" to see the listing or the "R" key and then "ENTER" to run.

Description:
The approach is similar to my entry from last year. 
The program, implemented in 1 line, consists of an endless loop; at each iteration, some pseudo-randomly chosen characters that make up the image are printed to the screen:
3 LET a=VAL "INT (RND*3)*9+1": LET b=VAL "INT (RND*8)+9*(RND>RND)+2": PRINT AT a,b;"-";AT b,a;"|";AT SIN PI,VAL "9";"\O/";AT a,VAL "INT (RND*3)*9+1";"+": GO TO PI
The gift box can be seen as three horizontal lines crossing three vertical lines, where each line is made up of 2 segments.
At first, the line number of one of the 3 horizontal lines is randomly chosen and stored into variable "a".
Then, the column number of a random "point" belonging to one of the 2 segments composing the selected line is randomly chosen and stored in "b".
The selected point belonging to one of the horizontal segments is thus printed using character "-".
Then, the "a" and "b" coordinates are swapped and the resulting point, belonging to one of the vertical segments, is printed using character "|".
Finally, the bow "\O/" is also printed, as well as a randomly chosen crossing point "+".
Compared to the original image, to improve the result on the ZX Spectrum, the "!" character has been replaced with "|", since the "!" character is not vertically aligned with the "+" character.
The program length is calculated using: PRINT PEEK 23627+256*PEEK 23628-23755 (i.e. the size in memory between the addresses pointed to by the PROG and VARS system variables).
The program source as text files (both for the BasinC IDE and as plain text) is also provided.
The following files are included in this archive:
file_id.diz:					this file
TheSpectrumPresent.tap:			tape image for usage with emulators (or real hardware!)
TheSpectrumPresent.bas:			program source as plain text
TheSpectrumPresent_BasinC.bas:	program source, to be used with the BasinC IDE
TheSpectrumPresent.gif:			animation showing the source code and the program running until the result is produced
Note: the code and result images are provided as an animated gif because the most relevant aspect of this program is *how* the picture is drawn!

Comments:
Actually, the ZX Spectrum (128K +2 model) was a Christmas present our parents gave me and my brother, many many years ago. So, what a better way to remember those times than a ZX Spectrum entry? ;-)