scene.org File Archive

File download

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

File size:
674 018 bytes (658.22K)
File date:
2022-12-30 11:32:13
Download count:
all-time: 4

Preview

  • XMAS2022a/ dir
  • XMAS2022a/2022aList.gif 192.61K
  • XMAS2022a/2022aRun.gif 149.66K
  • XMAS2022a/fileid.txt 2.79K
  • XMAS2022a/XMAS2022a 160B
  • XMAS2022a/XMAS2022a.bas 255B
  • XMAS2022a/XMASa2eList.gif 5.39K
  • XMAS2022a/XMASa2eRun.gif 2.94K
  • XMAS2022a/XMASbbcList.gif 21.02K
  • XMAS2022a/XMASbbcRun.gif 13.62K
  • XMAS2022a/XMASbbfwList.gif 88.05K
  • XMAS2022a/XMASbbfwRun.gif 86.86K
  • XMAS2022a/XMASc64List.gif 8.74K
  • XMAS2022a/XMASc64Run.gif 3.92K
  • XMAS2022a/XMAScpcList.gif 34.10K
  • XMAS2022a/XMAScpcRun.gif 5.47K
  • XMAS2022a/XMASdosList.gif 4.56K
  • XMAS2022a/XMASdosRun.gif 1.40K
  • XMAS2022a/XMASpdpList.gif 6.18K
  • XMAS2022a/XMASpdpRun.gif 3.49K
  • XMAS2022a/XMASukncList.gif 10.82K
  • XMAS2022a/XMASukncRun.gif 3.97K
  • XMAS2022a/XMASzxList.gif 5.95K
  • XMAS2022a/XMASzxRun.gif 2.65K

file_id.diz

Author:            Jonathan Harston
Category:          Christmas Challenge
System:            Any system that can run BBC BASIC with POS and VPOS implemented
Language:          BBC BASIC
Source length:     160 bytes
Executable length: 160 bytes
Instructions:
On any system that can run BBC BASIC where POS and VPOS is implemented, load into
BASIC and run. Demonstrated with BBC BASIC on Apple IIe, BBC Micro, Windows,
Commodore 64, Amstrad CPC128, PC-DOS, PDP11 Copro, UKNC/Electronica, ZX Spectrum.
Description:
If the code is expanded out as:
   10 REM > XMAS2022a
   20 PRINT CHR$8;:W=POS/2-8
   30 REPEAT:H=VPOS:PRINT:UNTIL H=VPOS
   40 CLS:PRINT STRING$(H/2-9,CHR$10)
   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(W+A);STRING$(B,"*");SPC(2*(9-A-B)-1+B/5);STRING$(B-INT(B/5),"*")
  100 NEXT

Printing CHR$8 backs off the left side of the screen and onto the right side
on the next line up. Reading POS tells us that column, and dividing by two
gives the centre of the screen. Subtracting 8 is half the width of the 17x17
star and gives the indent to centre it.

We then enter a loop, reading the vertical position with VPOS and then doing
a blank print to move to then next line. We loop until VPOS remains the same
because we've got to the bottom line.

We clear the screen and print enough blank lines to align with the first line
we want to display the star, again baring in mind that the star is an odd
number of characters in size.

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, we add that to the indent
to centre the line. 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.