scene.org File Archive

File download

<root>­/­parties­/­2023­/­vccc23­/­christmas-diamonds/serato_c64_asm_vc3-2023.zip

File size:
88 388 bytes (86.32K)
File date:
2024-01-03 14:15:18
Download count:
all-time: 10

Screenshot (by pouët.net)

Screenshot

Preview

  • diamonds-asm.txt 593B
  • diamonds.asm 593B
  • diamonds.prg 40B
  • file_id.diz 1.75K
  • result.png 85.44K

file_id.diz

26 byte Christmas Diamonds in Assembler

Author: serato / finnish gold
Category: Christmas Challenge
System:   C64
Language: C64 "64tass" Assembler
Len source code: 593
Len exe file:    40
Len code only:   26
Instructions:
Load PRG and run
Description:
The desired repeating diamond pattern may be constructed as the union of forward-
leaning diagonal stripes /// and backward-leaning diagonal stripes \\\. The forward-
leaning stripes are easily rendered by repeatedly printing an asterisk every sixth 
character, with the output wrapped on a text width of 19 characters. The backward-
leaning stripes are a simple mirror image of the forward-leaning ones.
The code uses the CHROUT routine to advance the Kernal's cursor from left to right, 
while simultaneously counting the Y register down and using STA (PNT),y to write the 
mirrored output directly to screen memory. When the Y register underflows, a carriage
return is output. The X register is used to count the gaps between asterisks. A zero 
page counter that defaults to 58 is used as the exit condition.
Comments:
1. Cursor right must be used instead of space, so as to not overwrite the mirrored 
output
2. The unintended opcode LAX #'*' is used to load X and A simultaneously with 42. 
Although this is an "unstable" opcode, this use is considered safe as A is $1d
immediately prior, and OR'd with the most common magic constant of $ee gives $ff.
3. To effect the correct spacing of asterisks, X is compared with '*'+6, ie 48. This 
ensures the correct pattern is drawn, but also provides for the correct indentation 
of the first line. X register is 0 by default, so the first asterisk is placed on the
48th character. This results in the first asterisk being drawn on the 10th column 
after 2 empty lines (of 19).