scene.org File Archive

File download

<root>­/­parties­/­2022­/­vccc22­/­christmas_star_challenge/club77_c64_basicv2_vc3-2022.zip

File size:
8 871 bytes (8.66K)
File date:
2022-12-30 11:32:13
Download count:
all-time: 4

Preview

  • file_id.diz 2.47K
  • pokestar one.prg 77B
  • result.png 3.12K
  • source.png 2.87K
  • source.txt 79B

file_id.diz

POKEstar ONE

Author: Carlo Luciano Bianco
Category: Christmas Challenge
System:   C64
Language: CBM BASIC v2
Len source code: 79 bytes
Len exe file:    77 bytes
Len code only:   75 bytes

Instructions:
Install vice, run x64sc, drag and drop the prg file into it.

Description:
The basic idea is to compute the coordinates of the screen where the "*" have to be placed and then to POKE the appropriate screen code (i.e. "42") in the corresponding memory locations, hence the name of the program (POKE-star). The star can be considered the superposition of four right triangles, each one with legs that are 13 "*"s long, duly shifted and mirrored. Therefore it is possible to make a very compact code by using nested for...next loops.

To be more specific:

for j=0 to 12
This is the first loop, over the line number within each pair of triangles (the upper pair and the lower pair).

a=1371+k*640+(-1)^k*40*j
This computes the memory location corresponding to the first element of the current line. It depends on a variable k, because when drawing the upper pair of triangles (k=0) we start from the top and we go down, while when we are drawing the lower pair of triangles (k=1) we start from the bottom and we go up. In this way we can reuse the same loop over j for both cases. Since the basic interpreter sets all variables to 0 after a "run" command, we can save space and omit the k=0 declaration at the beginning. The 1371 value has been chosen to have the star in the bottom right corner of the screen, so to leave untouched all other things written on the screen.

for i=0 to j
This is the second loop, over the position within each line.

poke a+i,42:poke 8+a-i,42
These are the two actual drawing POKEs. The first one adds a "*" to the leftmost triangle of the current pair going onward along the current line and the second one adds a "*" to the rightmost triangle of the current pair going backward along the same current line. 

next:next
These are the terminations of the nested loops.

k=1:goto 0
After computing the first pair of triangles (with k=0), k is set to 1 and the whole code is executed again to draw the second pair of triangles (k=1).


Comments:
Compared to may previous POKEstar, this POKEstar ONE is less elegant: it omits the k=0 declaration at the beginning and it does not end but keeps redrawing the lower pair of triangles (k=1) in an infinite loop. However, it is much smaller and, most of all, it is finally an oneliner (hence the ONE in its name)!