Vintage Computing Christmas Challenge 2023 C64 BASIC Entry
Author: Adam M
Category: Christmas Challenge
System: C64
Language: BASIC
Len source code: 91 bytes with abbreviations, 110 bytes not abbreviated
Len exe file: 88 bytes ( size of PRG file )
Len code only: N/A
Instructions:
Install / Run VICE Emulator - then drag'n'drop diamonds.prg into VICE.
Description:
In this program, we first calculate the modulus of the line l that gives a range from 0 to 5 for 3 vertically duplicated diamonds.
Then we subtract 3 from the modulus value and take the abs value of that and we get a number pattern of 3,2,1,0,1,2
This number pattern is used for generating a diamond because it determines the x positions to print the * for each row.
For example, position of 3 for the first line, positions 2 and 6-2=4 for the 2nd, and positions 1 and 6-1=4 for the 3rd line, etc...
Next we take a modulus of the column x to get values from 0 to 5 three times so the diamond pattern is repeated three times horizontally.
Finally we either print a *(ascii 42) or a space(ascii 32) for each line(l) and column(x) combination depending on the number pattern.
Comments:
This was a fun challenge. I was working towards minimum program size for this entry. I initially started with 4 loops with 2 of them duplicating 3 times vertically and 3 times horizontally,
but by using modulus I found I could eliminate 2 of the loops and save some code.
Files:
diamonds.prg - the program that outputs the diamonds
result.png - screenshot of the output of diamonds.prg
source.txt - unabbreviated source code
sourceabbreviated.txt - abbreviated source code
source.png - screeshot of both abbreviated and unabbreviated source on c64
file_id.diz - this description file