scene.org File Archive

File download

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

File size:
136 457 bytes (133.26K)
File date:
2024-01-03 14:15:18
Download count:
all-time: 6

Screenshot (by pouët.net)

Screenshot

Preview

  • diamonds-asm.txt 656B
  • diamonds.asm 656B
  • diamonds.prg 44B
  • file_id.diz 1.87K
  • result.png 130.68K

file_id.diz

30 byte Christmas Diamonds in Assembler

Author: serato / finnish gold
Category: Christmas Challenge
System:   VIC-20
Language: VIC-20 "64tass" Assembler
Len source code: 656
Len exe file:    44
Len code only:   30
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. However the VIC-20 does not set the colour of unprinted characters so an 
additional write to colour ram is required.
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).