scene.org File Archive

File download

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

File size:
1 253 932 bytes (1.20M)
File date:
2022-12-30 11:32:13
Download count:
all-time: 3

Preview

  • $.STAR 162B
  • $.STAR.inf 31B
  • 3d-List-loaded-fromDisk.png 398.78K
  • 3D-Result-loaded-fromDisk.png 486.62K
  • file_id.diz 3.57K
  • List-starbbc.png 126.97K
  • Result-starbbc.png 132.96K
  • size.png 88.65K
  • star.ssd 2.50K
  • starbbc.txt 199B

file_id.diz

<Name of Release>

Author: Katutech / Retrowiki
Category: Christmas Challenge 
System:   BBC Micro
Language: BASIC, BBC Micro
Len source code: <199 bytes> (starbbc.txt file)
Len exe file:    <162 bytes> ($.STAR, 0000A2 bytes, see included $.STAR.inf file or execute *INFO "STAR" on emulator)
Len code only:   <# bytes> (valid for assembler only; length of executable without BASIC stub)
Instructions:
Option 1:
1.- Open a BBC micro emulator. For example https://virtual.bbcmic.ro/ 
2.- Load the SSD disk image ("Games"->"From examples or local"->"Examine" on said web)
3.- Once loaded the disk, load the program by typing:
LOAD "STAR"
4.- Run it by typing RUN.

Option 2:
1.- Go to https://bbc.godbolt.org/ (Another online BBC Micro emulator)
2.- Select the content of the file starbbc.txt, copy, and paste it on the text area with the text "Paste text or drop files here".
3.- Once the text has been copied, click on the screen of the BBC Micro (or the emulated system will reboot) and press enter.
4.- Run it.

Description:
There are two nested loops. The inner writes 8 5 character lenght diagonal and the outher one repeats those diagonals until the required length.
The printing is easy: every inner loop makes 8 calls to a defined procedure to print every one of the * that makes the 8 "diagonals" that conforms the arms of the star.

The original program, without any lenght optimization was the following:

10 CLS
20 I=0
30 C=0
40 A=15
50 REPEAT
60 REPEAT
70 PRINT TAB(A+I,A+I+C)"*"
80 PRINT TAB(A-I,A+I+C)"*"
90 PRINT TAB(A+I,A-I-C)"*"
100 PRINT TAB(A-I,A-I-C)"*"
110 PRINT TAB(A+I+C,A+I)"*"
120 PRINT TAB(A+I+C,A-I)"*"
130 PRINT TAB(A-I-C,A-I)"*"
140 PRINT TAB(A-I-C,A+I)"*"
150 I=I+1
160 UNTIL I=5
170 I=0:C=C+1
180 UNTIL C=5

1st transformation, Change of variables (A+I->J, A-I->K, J+C->L, K-C->M):

10 CLS:I=0:C=0:A=15
20 REPEAT
30 REPEAT
40 J=A+I:K=A-I:L=J+C:M=K-C
50 PRINT TAB(J,L)"*"
60 PRINT TAB(K,L)"*"
70 PRINT TAB(J,M)"*"
80 PRINT TAB(K,M)"*"
90 PRINT TAB(L,J)"*"
100 PRINT TAB(L,K)"*"
110 PRINT TAB(M,K)"*"
120 PRINT TAB(M,J)"*"
130 I=I+1
140 UNTIL I=5
150 I=0:C=C+1
160 UNTIL C=5

2nd transformation, concatenate lines:

10 CLS:I=0:C=0:A=15:REPEAT:REPEAT
20 J=A+I:K=A-I:L=J+C:M=K-C
30 PRINT TAB(J,L)"*"
40 PRINT TAB(K,L)"*"
50 PRINT TAB(J,M)"*"
60 PRINT TAB(K,M)"*"
70 PRINT TAB(L,J)"*"
80 PRINT TAB(L,K)"*"
90 PRINT TAB(M,K)"*"
100 PRINT TAB(M,J)"*"
110 I=I+1:UNTIL I=5:I=0:C=C+1:UNTIL C=5

3rd transformation, create a procedure to print a * on X,Y:

10 CLS:I=0:C=0:A=15:REPEAT:REPEAT
20 J=A+I:K=A-I:L=J+C:M=K-C
30 PROCF(J,L)
40 PROCF(K,L)
50 PROCF(J,M)
60 PROCF(K,M)
70 PROCF(L,J)
80 PROCF(L,K)
90 PROCF(M,K)
100 PROCF(M,J)
110 I=I+1:UNTIL I=5:I=0:C=C+1:UNTIL C=5
120 DEF PROCF(X,Y)
130 PRINT TAB(X,Y)"*"
140 ENDPROC

4th transformation, more line concatenation and new start coordinate=(9,9), was (15,15):

1 CLS:I=0:C=0:A=9:REPEAT:REPEAT:J=A+I:K=A-I:L=J+C:M=K-C:PROCF(J,L):PROCF(K,L):PROCF(J,M):PROCF(K,M):PROCF(L,J):PROCF(L,K):PROCF(M,K):PROCF(M,J):I=I+1:UNTIL I=5:I=0:C=C+1:UNTIL C=5
2 DEF PROCF(X,Y):PRINT TAB(X,Y)"*":ENDPROC

5th transformation, finally, using the BBC Micro Basic abbreviations:

1CLS:I=0:C=0:A=9:REP.:REP.:J=A+I:K=A-I:L=J+C:M=K-C:PROCF(J,L):PROCF(K,L):PROCF(J,M):PROCF(K,M):PROCF(L,J):PROCF(L,K):PROCF(M,K):PROCF(M,J):I=I+1:U.I=5:I=0:C=C+1:U.C=5
2DEF PROCF(X,Y):P.TAB(X,Y)"*":E.


Comments:
It seems that a line can be 255 character long and the program could have been coded in a line, but the procedure definition seems that has to have it's own line.  

Very interesting challenge, thank you.