scene.org File Archive

File download

<root>­/­parties­/­2025­/­vccc25­/­christmas_challenge/kaidokotoni_msx_basic_144b_vc3-2025.zip

File size:
23 072 bytes (22.53K)
File date:
2025-12-30 23:34:07
Download count:
all-time: 2

Preview

  • file_id.diz 5.71K
  • file_id_jp.diz 3.28K
  • KaidoKotoni_MSX_BASIC_144b_vc3-2025 Code.png 9.81K
  • KaidoKotoni_MSX_BASIC_144b_vc3-2025 Result.png 9.70K
  • KaidoKotoni_MSX_BASIC_144b_vc3-2025.BAS 175B
  • KaidoKotoni_MSX_BASIC_144b_vc3-2025.dsk 720.00K

file_id.diz

ÿþKaidoKotoni_MSX_BASIC_144b_vc3-2025



Author:		Kaido Kotoni

Category: 	The Main Challenge (Compo)

System: 	All MSX ( MSX / MSX2 / MSX2+ / MSXturboR ) NTSC / PAL

Language: 	MSX BASIC

Size source:	175 byte ( Text size, including line numbers )

Size file: 	144 byte ( Size on disk )



!! This file is unicode ( little endian ) !!





* Execution Method

"KaidoKotoni_MSX_BASIC_144b_vc3-2025.dsk" is a disk image file that can be used with an emulator. Since it is a standard image file, it can be used with openMSX / blueMSX / WebMSX. It is set for auto-execution. Please set the image file and start the system.



For actual hardware, it would probably be faster to type in the source code than to write the disk image back ;D.





* Source

1 CLEAR400:WIDTH19:FORI=1TO36:D=ASC(MID$("Hd((H(20(945:,((.@.,P,,@,,((,,0,.,,+",I,1))-35:S$=SPACE$(D\4):C=DAND3:C$=STRING$(C-(C=0)*9,42):PRINTS$C$;:D$=C$+S$+D$:NEXT:PRINT"*"D$





* Variable

I  Data loop

D  Expansion pattern data

S$ Expanded space characters

C$ Expanded * characters

D$ Inverted lower pattern





* Data format

 0sssss:cc

  s 5 bits, number of spaces

  c 2 bits, number of asterisks (*). If 0, it means 9 asterisks.

Double quotation marks are avoided by adding 35, converting it to an ASCII character.





* Explanation

I used features unique to MSX. In BASIC outside of MSX, you can only set fixed values for the width, such as 40 or 80, but MSX allows you to set any desired width.

By setting the width to 19 characters, there is no need for a line break, and the screen can be treated as a single string of 361 characters (19*19).

Since the number of characters for the figure is odd, the central asterisk "*" is output by code to perfectly divide it in half.

The figure is divided vertically at the center (180 characters), and the lower part is the inverse of the upper part. Since compressed data is smaller than horizontal inversion code, only the vertical inversion is created using code.



The "spaces" and "*" in this string are compressed using run-length encoding.

By counting carefully, the maximum consecutive count for "spaces" is 16, and for "*" it is 1, 2, 3, and 9 (because of the division at the center).

I tried to represent this efficiently.

Since "spaces" and "*" appear alternately, it is not necessary to include the character type in the data.

"Spaces" can be represented with 5 bits, and "*" with 2 bits, totaling 1 byte. To represent the 1 byte as an ASCII character, 35 is added to shift it into the ASCII character range.



The 361-character figure was compressed into 36 characters.





* MSX BASIC-Specific Notes

- CLEAR n

 n bytes are allocated for the string variable area.

- WIDTH n

 MSX allows setting an arbitrary width. Setting it to 19 makes the line wrap at 19 characters.

- STRING$(n,c)

 Repeats the character code c for n times.

- SPACE$(n)

 Repeats the space character for n times.