Fill Screen With Zeros game (Sharp PC-1211 Pocket Computer) by aldweb
A downloadable game
Fill Screen With Zeros game (Sharp PC-1211 Pocket Computer) by aldweb
[BASIC 10Liner 2025] [PUR-80]
Submission: 14th edition of BASIC 10 Liner Contest, "PUR-80" category
Author: Laurent Duveau (aldweb), coded with fun in 2025, copyleft (but please mention authorship)
System requirements: Sharp PC-1210, PC-1211, PC-1212, Radio Shack Pocket Computer
System information: https://www.aldweb.com/articles.php?lng=en&pg=26
Language: S'-BASIC
Fill Screen With Zeros game rules
=================================
- The Fill Screen With Zeros game objective is to last as long as possible by avoiding to have a non zero digit moved out to the right of the screen.
- The game starts with twelve 0 digits, separated by a dot sign.
- Each turn, a random digit is added to the left of the screen, and one removed on the right, the other ones being pushed from left to right.
- Each time that the same digit is next one to another, the two digits are removed from the line, all digits on their right are moved back to the left, and empty positions on the right of the screen are replaced by a 0.
- 0 cannot be removed from the board, so they better be moved to the right side.
- You can swap two digits, the one in position N with the one in position N+1 (the following one on the right).
- Would you want not to swap digits, you may input [Enter] when you are asked for swapping, otherwise choose a position from 1 (left) to 11 (right).
- The board starts with 0 to 5 values. Every ten turns, a new digit is added: 6, then 7, 8 and up to 9.
- Every ten turns, two new digits appear on the left instead of one, and you get an extra digits swapping.
- The game stops when the right upmost digit is no more a 0 and it is being pushed to the right out of the screen.
Running the game
================
- Click on the [ON] button to boot the simulator (it really mimics the init sequence).
- Then, click on the R, U, and N keys, followed by [ENTER].
- "TURN #1" will flash briefly, followed by a first line of digits "5.0.0.0.0.0.0.0.0.0.0.0." (that's for the first time you play, sequence will vary afterwards).
- Click on [ENTER]. "SWAP? _" appears and it lets you decide if you wish to swap some numbers (nth position with (n+1)th one).
- For the purpose of this tutorial, click on the 1 key, followed by [ENTER].
- "0.5.0.0.0.0.0.0.0.0.0.0." will flash briefly, you can see that the 5 digit and the following 0 digit were swapped.
- "TURN #2" will flash briefly, followed by a first line of digits "1.0.5.0.0.0.0.0.0.0.0.0.",showing that a 1 digit appeared on the left.
- Once you know what you want to do, click on [ENTER].
- Choose if you wish to swap numbers, or not (in this case, just click on [ENTER]). I advise you to swap 2nd and 3rd numbers... click on 2 [ENTER].
- And so on, until a non 0 digit reaches the right side of the screen. The number of turns you succeeded to play will be displayed.
- NOTE: since everytime time you launch the simulator configured especially for this contest, the memory will be reset to its initial content, the pseudo random generator will start with the same initial value and the same game will be run. Would you wish for another game play, you better change the Z variable value with any value you want, like: Z=0.1234 [ENTER], or like: Z=123 [ENTER]. And then RUN [ENTER].
Listing the source code
=======================
- Anytime, when within a game, you may break the program execution by pressing the [ON] key. "BREAK AT 4" or similar will appear. Click [CL] key to clear the message.
- Click on [MODE] key twice until "PRO" is shown on the top right part of the screen.
- Key in LIST [ENTER] or click on the down key (at the right of the [ON] key) to start browsing the source code.
- Browsing the source code is as easy as clicking on down or up key to switch lines, and left arrow (the one with DEL printed on top of it) or right arrow (INS) to move inside a line of code.
- If you want to experiment coding on the simulator, feel free to do so, almost all of the Sharp PC-1211 statements are working very well. Please be warned that when you close the simulator, all changes will be lost and it will start again with the preloaded game's source code when you launch it again.
- If you want to run the game again (or any BASIC code you would have written instead), click back on the [MODE] key until "DEF" or "RUN" is shown on the top of the screen, then RUN [ENTER].
Coding challenges
=================
- The Sharp PC-1211 was the first pocket computer to be programmable in basic back in 1980, in S'-BASIC (S-prime) to be more adequate. It has two 4-bits processor, so we can extrapolate that it is a 2 x 4-bits = 8-bits processor ;-) Nevertheless, all subsequent Sharp Pocket Computers had an 8-bits computer. And the code submitted here can be used as is, without any change at all, with the Sharp PC-1251 for example. Sharp PC-1251 is mentioned as it is the successor of the Sharp PC-1211, it was released in 1983, and it has the same 24 characters display as the Sharp PC-1211.
- S'-BASIC appeared first in the PC-1210/PC-1211 pocket computers and was carried through most of the PC-12xx series. It uses a very efficient single-byte tokenizing system which contains every BASIC command, function and operator as well as the entire character set. Letters are upper-case only.
- Commands are tokenized and account only for 1 memory cell, so should account for one character. But all lines of this game's submission are anyway <80 characters even without this precise accounting.
- IF instruction has no ELSE feature, either the condition is true and the rest of the line will be executed, or it is false and the execution will move to the next line. In a 10 lines source code contest, this is a challenge, and therefore the objective is to limit its use as much as possible and it is best used as last instruction in a line.
- INPUT instruction accepts void entry only if it is the last command in a line, and again this is quite of a limitation in a 10 lines source code context!
- W to Z are faster variables at execution time, they are to be used in priority in FOR/NEXT loops, and frequent used calculations.
- A(1) to A(26) map A to Z variables, meaning that A(3) and C store the same value, this allows to use one letter variables as much as possible, and use array A(), which requires at least 3 more characters, only in mass calculations or values transfers.
- Multiplication sign can mostly be omitted: ZT is similar to Z*T (in line 3) or 221Z to 221*Z (in line 2), but I*F (calculation) is different from IF (keyword).
- No pseudo random function, so the code has to simulate one. No INKEY$, only basic INPUT, so limited game play capabilities on this device!
- Whatever you do, the execution time on a real Sharp PC-1211 device is... really slow! But just like any program running on this precursor device. My PC-1211 simulator and the PokecomGO emulator for the PC-1251 are much faster, and the game play is more convenient with them.
Listing
=======
chr tkn [41](32) 1:FOR X=1 TO 13:A(X)=0:NEXT X:W=0:T=6:S=1 [68](53) 2:FOR X=1 TO 11:A(13-X)=A(12-X):NEXT X:Z=221Z+.2113:IF T>10 LET T=10 [73](55) 3:Z=Z-INT Z:A=INT (ZT):W=W+S:IF ((W/10)=INT (W/10))S LET S=0:T=T+1:GOTO 2 [76](58) 4:BEEP 1:PAUSE "TURN #";W:PRINT A;B;C;D;E;F;G;H;I;J;K;L:U=0:INPUT "SWAP? ";U [32](23) 5:U=INT U:IF (U<1)+(U>11) GOTO 7 [29](30) 6:V=A(U):A(U)=A(U+1):A(U+1)=V [77](59) 7:FOR X=1 TO 11:IF (A(X)=A(X+1))A(X) FOR Y=X TO 10:A(Y)=A(Y+2):NEXT Y:K=0:L=0 [53](34) 8:NEXT X:IF S=0 BEEP 1:PAUSE "BONUS SWAP!":S=1:GOTO 4 [52](37) 9:IF L=0 BEEP 1:PAUSE A;B;C;D;E;F;G;H;I;J;K;L:GOTO 2 [47](36) 10:BEEP 2:PRINT "THE END AFTER ";W;" TURNS":END
[548] characters in source code (including spaces added for code readability), tokenized to (417) 8-bits memory cells, all 10 lines are <80 characters.
Some developers provide explanations for their source code in this contest. I believe it is much more fun to try to figure out what it does by yourself.
So, as not to spoil you, I do not present each line's doings. Some of the device's specific challenges were explained in the previous paragraph, and variables definition are provided in the next paragraph, this should help you figuring out the few used tricks.
Variables
=========
A-M Store cells, same as A(1)-A(13)
N-R <free>
S Bonus swap 1/0
T Max digits [5..T..9]
U Swap question and choice
V Temporary variable for swapping values between cells
W* Number of played turns
X* Primary FOR/NEXT loops
Y* Secondary FOR/NEXT loop
Z* Pseudo random number
Note: * means faster execution variables
Published | 3 days ago |
Status | Released |
Author | BASIC 10Liner |
Genre | Strategy |
Tags | 10liner, basic, pc1211, pocket-computer, sharp |
Download
Install instructions
Installing the game
===================
- There is no emulator for the Sharp PC-1211 as no information was ever given about its processor instructions and ROM instructions set.
- An alternative is to use the PokecomGO emulator for Android devices, running the Sharp PC-1251 emulator (the one I tested, I have not tried with later emulated Sharp Pocket Computers) which is the closest device to the Sharp PC-1211.
- Windows, macOS, Android and Online versions of PockEmul might be another alternative option, but the software now requires to be activated with a subscription...
- Back in 2019, I started coding a simulator (which runs on Windows computers) for the Sharp PC-1211. It is not yet finalized (will it ever be?), but it is functional enough to input and run the current game code. Therefore, I provide a downsized version of the simulator, preloaded with the game's source code, as well as full explanations for installing and running the game within the context of this submission.
- After extracting the ZIP file to a directory on a computer running Windows, launch Pocket80.exe program (to be found in the Pocket80sim sub directory).
- A right click on the main screen will open a popup menu, you might want to adjust the size of the simulator window or give a look to the About box :-)
Comments
Log in with itch.io to leave a comment.
Un jeu rétro simple mais addictif ! C’était un super défi qui montre une forme de créativité sans les avancées techniques d’aujourd’hui. À tester absolument !!
This game is fully functional on my TRS-80. After copying the code manually, I also tested it on the emulator. I have to admit, I'm impressed that someone actually took the time to create a simulator for such an old pocket computer that I own.