scene.org File Archive

File download

<root>­/­parties­/­2022­/­vccc22­/­christmas_star_challenge/jghbbcbasic2022b.zip

File size:
531 662 bytes (519.20K)
File date:
2022-12-30 11:32:13
Download count:
all-time: 6

Preview

  • XMAS2022b/ dir
  • XMAS2022b/2022bAll.gif 161.60K
  • XMAS2022b/fileid.txt 2.11K
  • XMAS2022b/XMAS2022b 117B
  • XMAS2022b/XMAS2022b.bas 168B
  • XMAS2022b/XMASrt11.gif 9.74K
  • XMAS2022b/XMAStty.gif 338.39K
  • XMAS2022b/XMASunix.gif 5.55K

file_id.diz

Author:            Jonathan Harston
Category:          Christmas Challenge
System:            Any system that can run BBC BASIC
Language:          BBC BASIC
Source length:     117 bytes
Executable length: 117 bytes
Instructions:
On any system that can run BBC BASIC, load into BASIC and run. Demonstrated on
a PDP11 system running RT11 and Unix, and also an emulated ASR33 teletype at
mdfs.net/tty.
Description:
If the code is expanded out as:
   10 REM > XMAS2022c
   50 A$="453627180944434241"
   60 FOR L=-16 TO 16 STEP 2
   70 A=VALMID$(A$,ABSL+1,1)
   80 B=VALMID$(A$,ABSL+2,1)
   90 PRINT SPC(A);STRING$(B,"*");SPC(2*(9-A-B)-1+B/5);STRING$(B-INT(B/5),"*")
  100 NEXT

This is the same program as the self-centring program, but without the code
that depends on POS and VPOS, resulting in the star just being displayed
left-aligned on the immediately following lines.

The star is symetrical in four directions, two of which can be usefully used.
The right side is a reflection of the left side, and the bottom is a reflection
of the top. A slight complication arises in that the star is an odd number of
characters in size, so the one-character centre lines needs dealing with.

A$ is set to a string of nine pairs of single-digit values. These values are
the number of spaces and stars to make each line on the top-left corner. The
value pairs are in reverse order so we can scan through twice by counting
from a negative offset to a positive offset, and taking the absolute value.

We loop through the string in A$ and read out the values from it. This is
an example of "data without DATA", being able to use some fixed data in a
program without having to read it into variables. Another example is:
MID$("SunMonTueWedThuFriSat",day%*3-2,3)

The first value is the number of spaces to output. Next is the number of
stars. A bit of arithmetic works out the number of spaces between the stars
on the left and the stars on the right, then the stars are repeated, each
time adjusted to reduce by one to get an odd total number.

The loop passes through the data twice, backwards then forwards, which gives
the bottom half as a reflection of the top half.