scene.org File Archive

File download

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

File size:
106 371 bytes (103.88K)
File date:
2025-01-04 05:45:02
Download count:
all-time: 3

Preview

  • diamonds.asm 778B
  • diamonds.asm.txt 778B
  • diamonds.prg 39B
  • file_id.diz 1.81K
  • result.png 104.18K

file_id.diz

25 byte Christmas Diamonds in Assembler

Author: serato / finnish gold
Category: Christmas Challenge
System:   C64
Language: C64 "64tass" Assembler
Len source code: 778
Len exe file:    39
Len code only:   25
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 could be rendered by repeatedly printing an asterisk every sixth 
character, with the output wrapped on a text width of 19 characters. To create the
backward leaning stripes we widen the area by 18 characters and fold the new output
horizontally. This code uses the Carry flag to keep track of whether the cursor is
moving forward or backward, incrementing and decrementing Y respectively. The code
for counting every 6th character must not affect the carry flag. This is straight-
forward using the X register, but as it is initially 0, testing X for 0 or $80 will
not begin the pattern at the correct offset. The solution used here is to apply the
unintended opcode XAA $f to binary AND the X value with $f, and test for 0. This is
effectively testing for 0 modulo 16. This results in the first asterisk being output
at column 16. The whole pattern is indented 1 character for this to be a valid start
position. The character code for asterisk, 42 = 10 mod 16 (i.e. 6 short of 16), so X
may be loaded each time with the unintended opcode LAX #'*'.
A zero page counter that defaults to 13 is used to count 115 stars as the exit
condition.
Comments:
Both of the unintended opcodes are considered "unstable", involving magic constants
that depend on the hardware. The most common constant for LAX is $ee which does not
affect this use. The most common constant for XAA is $ef, which also does not affect
this usage.