VC3_2023
Author: B4rret
Category: Christmas Challenge
System: MSX
Language: MSX BASIC 1.0
Len source code: 121
Len exe file: 96
Len code only: <# bytes> (valid for assembler only; length of executable without BASIC stub)
Instructions:
You can use any emulator such as BlueMSX, openMSX, or WebMSX. In any of these, you can type the source code of the program. To load the BAS file, it is necessary to include it in a disk image (attached vc3_2023.dsk).
For example, in WebMSX (
https://webmsx.org/), you can load the image into the emulator by dragging the DSK file directly onto the screen. Next, you need to type LOAD "VC3_2023.BAS" so that the interpreter loads the program. From there, by typing LIST, you can view the code, and by typing RUN, you can execute it.
Another simpler way is by using the MSXPen framework (
https://msxpen.com/) that utilizes the same emulator. You can paste the code into the left text input screen, and by pressing the 'run' button, the emulator will start and load the program.
Finally, at the link
https://msxpen.com/codes/-Nl0vD7C8iZ_TqtayBnb, the program is already set up and ready to be executed in this framework.
Description:
The program first reduces the width of the screen to 19 characters, which is the width of the figure. Next, it prepares a string X$ consisting of 34 digits. Each digit represents the number of spaces between two asterisks in the figure. For example, the first line is 3 spaces, an asterisk, 5 spaces, an asterisk, 5 spaces, an asterisk. This is encoded as 355. In this way, the first 3 squares (the first 5 lines) are encoded in the string. The program runs a primary loop I for 3 iterations to write this three times. Within this loop, there is another loop J for 34 iterations. Using MID$() and VAL(), it extracts each digit from the string X$ and converts it to numeric form. Then, using SPC(), it writes that number of spaces followed by an asterisk. This process draws each group of 3 squares. Additionally, between each of the 3 iterations of loop I, a LOCATE 0 is executed to move the cursor back to the beginning of the row. This ensures the next group of squares starts drawing on the same line where the previous one ends. If this were not done, an extra line would be written (the one that ends the group of diamonds and the one that starts them).
Comments:
I have included a disk image (vc3_2023.dsk) that contains the file vc3_2023.bas, to facilitate its use in emulators