This is a short game by Endi Baráth, originally published on the BASIC Programming Language group. It was converted to ugBASIC by Marco Spedaletti, to work on most 8-bit computers. It needs at least the 1.6.2-beta to compile. A reference to the original source has been added as comment.
' It is necessary to apply some techniques to reduce the memory actually ' used, so that the game can run even on rather limited platforms, ' such as ColecoVision. ' First, let's proceed to reduce the space occupied by dynamic strings. ' In ugBASIC this space, despite being dynamic, is statically allocated ' and occupies a certain memory space. With those pragmas we tell ugBASIC ' that we will never use more than 8 strings by a total of 32 bytes. ' Static strings, such as those in quotes, don't count. DEFINE STRING SPACE 32 DEFINE STRING COUNT 8 ' This procedure reads the fire button if a joystick is available. PROCEDURE control ON JOYSTICK AVAILABLE IF JFIRE(0) THEN RETURN TRUE ELSE RETURN FALSE ENDIF END PROC ' This procedure reads the space bar if a joystick is not available. PROCEDURE control ON JOYSTICK NOT AVAILABLE IF KEY STATE(KEY SPACE) THEN RETURN TRUE ELSE RETURN FALSE ENDIF END PROC ' ------------------------------------------------------------------ ' 100 GRAPHICS HIRES 4:SET BORDER 0:SET KEY CLICK OFF:SET STATUS OFF ' ------------------------------------------------------------------ ' We enable the "bitmap" graphics mode. This is the mode in which ' each individual pixel can be addressed individually, via primitive ' commands, such as those related to drawing a single pixel. BITMAP ENABLE ' We set the border color to black, at least for those targets for ' which this instruction makes sense. Since ugBASIC is an isomorphic ' language, it does not provide an abstraction of the concept of ' "border". Therefore, if the border exists, it will be colored, ' otherwise this statement corresponds to a "no operation". COLOR BORDER BLACK ' Let's define the (pixel) coordinates of the play field: ' ' (x1,y1) +---------+ ' | | ' | | ' +---------+ (x2,y2) POSITIVE CONST x1 = SCREEN WIDTH / 10 POSITIVE CONST x2 = x1 + (8 * ( SCREEN WIDTH / 10 )) POSITIVE CONST y1 = SCREEN HEIGHT / 10 POSITIVE CONST y2 = y1 + (7 * ( SCREEN HEIGHT / 10 )) ' Let's define the (characters) coordinates of the play field: ' ' (,r1) --> INSTRUCTIONS ' +---------+ ' | | ' | | ' +---------+ ' (,r2) --> COMMAND POSITIVE CONST r1 = 0 POSITIVE CONST r2 = ROWS-2 ' Instructions string. The lenght of this string depends on ' the width of the text screen. CONST instructions = IF(COLUMNS < 40, "press to turn", "GAME: press to turn direction") CONST final = IF(COLUMNS < 40, "SCORE: ", "YOUR SCORE: ") ' Repeat forever DO ' With this instruction we clear the screen, using (if possible) the color ' black. Remembering that ugBASIC is an isomorphic language, it is possible ' that the color indication is ignored, or a similar one is chosen. CLS BLACK ' Let's memorize the status of fire and the previous state itself. ' This allow to track the fact that the fire has been released. joy = FALSE: joyp = FALSE ' ---------------------------------------------------------- ' 110 SET INK 2:PLOT 500,200;800,200;800,500;500,500;500,200 ' ---------------------------------------------------------- ' Let's draw the yellow box as playfield. BOX x1,y1 TO x2,y2,YELLOW ' ------------------------------------------------------------ ' 120 PRINT #101,AT 2,2:"GAME: press a key to turn direction." ' ------------------------------------------------------------ ' Let's print the intructions at the center of the line. LOCATE ,r1 CENTER instructions; ' ------------------------------------------------- ' 130 SET INK 3:LET I=0:LET X=550:LET Y=220:LET S=0 ' ------------------------------------------------- i = 0 x = x1+x1 y = y1+y1 s = 0 ' +---------+ ' | * (x,y) | ' | | ' +---------+ ' Forever loop until finish. DO ' --------------------------- ' 140 LET I$=INKEY$:LET S=S+1 ' --------------------------- ' Slow down the program a bit, to make it playable. WAIT 25 MS ' Let's record if the button has been pressed AND released. IF joy THEN IF control[] = 0 THEN joyp = TRUE joy = FALSE ENDIF ELSE joy = control[] ENDIF ' Increment the score! INC s ' ------------- ' 150 PLOT X,Y, ' 160 LOOK A ' ------------- ' Take the color of destination pixel. a = POINT(x,y) ' Draw a pixel on it. PLOT x,y,WHITE ' --------------------------------------- ' 170 PLOT X,Y ' 180 IF I$ ≠ "" THEN LET I= (I+1) BAND 3 ' --------------------------------------- ' Each time the fire / space bar is pressed, the ' direction will be changed, in a clockwise manner. ' The (i+1) increment the direction, while the AND ' 3 will limit the value from 0 to 3. ' ' 3 ' ^ ' 2 <-+-> 0 ' v ' 1 IF joyp THEN i = (i+1) AND 3 ' Reset the button. joyp = FALSE ' ----------------------------------- ' 190 IF I=0 THEN LET X=X+4:LET Y=Y+0 ' ----------------------------------- ' Move the point to the right. IF i=0 THEN INC x ' ----------------------------------- ' 200 IF I=1 THEN LET X=X+0:LET Y=Y+4 ' ----------------------------------- ' Move the point down. IF i=1 THEN INC y ' ----------------------------------- ' 210 IF I=2 THEN LET X=X-4:LET Y=Y+0 ' ----------------------------------- ' Move the point to the left. IF i=2 THEN DEC x ' ----------------------------------- ' 220 IF I=3 THEN LET X=X+0:LET Y=Y-4 ' ----------------------------------- ' Move the point to the right. IF i=3 THEN DEC y ' ------------------------ ' 230 IF A=0 THEN GOTO 140 ' ------------------------ ' If the underlying pixel is black, we can move ' to the next position along the selected direction. ' Oherwise, we can exit. EXIT IF a<>BLACK LOOP ' --------------------------------------- ' 240 PRINT #101,AT 19,12:"YOUR SCORE:";S ' --------------------------------------- ' Print the score and ends. LOCATE , r2 CENTER final+STR$(s); ' Wait a key / fire to restart WAIT KEY OR FIRE RELEASE LOOP
The instructions here refer to compiling the example from the command line. For Microsoft Windows users we suggest using UGBASIC-IDE, which allows you to compile the example with just one click.
In order to compile and run the example, you need to have the Altirra emulator, and in particular that the altirra
executable is accessible.
Then, type this command on the command line:
# Linux ugbc.atari contrib_minigame.bas -o example.xex altirra example.xex # Windows ugbc.atari.exe contrib_minigame.bas -o example.xex altirra example.xex
In order to compile and run the example, you need to have the Altirra emulator, and in particular that the altirra
executable is accessible.
Then, type this command on the command line:
# Linux ugbc.atarixl contrib_minigame.bas -o example.xex altirra example.xex # Windows ugbc.atarixl.exe contrib_minigame.bas -o example.xex altirra example.xex
In order to compile and run the example, you need to have the VICE emulator, and in particular that the x64sc
executable is accessible.
Then, type this command on the command line:
# Linux ugbc.c64 contrib_minigame.bas -o example.prg x64sc example.prg # Windows ugbc.c64.exe contrib_minigame.bas -o example.prg x64sc example.prg
In order to compile and run the example, you need to have the VICE emulator, and in particular that the x64sc
executable is accessible.
Then, type this command on the command line:
# Linux ugbc.c64reu contrib_minigame.bas -o example.prg x64sc -reu example.prg # Windows ugbc.c64reu.exe contrib_minigame.bas -o example.prg x64sc -reu example.prg
In order to run the example, you need to have the YAPE emulator. In particular that the yape
executable is accessible.
Then, type this command on the command line:
# Linux ugbc.plus4 contrib_minigame.bas -o example.prg yape example.prg # Windows ugbc.plus4.exe contrib_minigame.bas -o example.prg yape example.prg
In order to run the example, you need to have the VICE emulator. In particular that the xplus4
executable is accessible.
Then, type this command on the command line:
# Linux ugbc.plus4 contrib_minigame.bas -o example.prg xplus4 example.prg # Windows ugbc.plus4.exe contrib_minigame.bas -o example.prg xplus4 example.prg
In order to compile and run the example, you need to have the XROAR emulator, and in particular that the xroar
executable is accessible.
Then, type this command on the command line:
# Linux ugbc.d32 contrib_minigame.bas -o example.bin xroar -rompath (your rom path) example.bin # Windows ugbc.d32.exe contrib_minigame.bas -o example.bin xroar.exe -rompath (your rom path) example.bin
In order to compile and run the example, you need to have the XROAR emulator, and in particular that the xroar
executable is accessible.
Then, type this command on the command line:
# Linux ugbc.d64 contrib_minigame.bas -o example.bin xroar -rompath (your rom path) example.bin # Windows ugbc.d64.exe contrib_minigame.bas -o example.bin xroar.exe -rompath (your rom path) example.bin
In order to compile and run the example, you need to have the DCMOTO emulator, and in particular that the dcmoto
executable is accessible.
Then, type this command on the command line and on the emulator:
# Linux ugbc.pc128op contrib_minigame.bas -o example.k7 dcmoto (choose BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC # Windows ugbc.pc128op.exe contrib_minigame.bas -o example.k7 dcmoto (choose example.k7) (choose BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC
In order to compile and run the example, you need to have the DCMOTO emulator, and in particular that the dcmoto
executable is accessible.
Then, type this command on the command line and on the emulator:
# Linux ugbc.pc128op contrib_minigame.bas -o example.k7 dcmoto (choose BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC # Windows ugbc.pc128op.exe contrib_minigame.bas -o example.k7 dcmoto (choose example.k7) (choose BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC
In order to compile and run the example, you need to have the VICE emulator, and in particular that the xvic
executable is accessible.
Then, type this command on the command line:
# Linux ugbc.vic20 contrib_minigame.bas -o example.prg xvic --memory 24k example.prg # Windows ugbc.vic20.exe contrib_minigame.bas -o example.prg xvic --memory 24k example.prg
In order to compile and run the example, you need to have the Speccy emulator, and in particular that the speccy
executable is accessible.
Then, type this command on the command line:
# Linux ugbc.zx contrib_minigame.bas -o example.tap Speccy example.tap # Windows ugbc.zx.exe contrib_minigame.bas -o example.tap Speccy example.tap
In order to compile and run the example, you need to have the openMsx or the BlueMSX emulator, and in particular that its executable is accessible.
Then, type this command on the command line:
# Linux ugbc.msx1 contrib_minigame.bas -o example.rom openmsx -cart example.rom # Windows ugbc.msx1.exe contrib_minigame.bas -o example.rom openmsx -cart example.rom
# Linux ugbc.msx1 contrib_minigame.bas -o example.rom bluemsx example.rom # Windows ugbc.msx1.exe contrib_minigame.bas -o example.rom bluemsx example.rom
In order to compile and run the example, you need to have the openMsx or the BlueMSX emulator, and in particular that its executable is accessible.
Then, type this command on the command line:
# Linux ugbc.coleco contrib_minigame.bas -o example.rom openmsx -machine \"COL - ColecoVision\" -cart example.rom # Windows ugbc.coleco.exe contrib_minigame.bas -o example.rom bluemsx -machine \"COL - ColecoVision\" example.rom
# Linux ugbc.coleco contrib_minigame.bas -o example.rom bluemsx /machine \"COL - ColecoVision\" /rom1 example.rom # Windows ugbc.coleco.exe contrib_minigame.bas -o example.rom bluemsx /machine \"COL - ColecoVision\" /rom1 example.rom
In order to compile and run the example, you need to have the BlueMSX emulator, and in particular that its executable is accessible.
Then, type this command on the command line:
# Linux ugbc.sc3000 contrib_minigame.bas -o example.rom bluemsx /machine \"SEGA - SC-3000\" /rom1 example.rom # Windows ugbc.sc3000.exe contrib_minigame.bas -o example.rom bluemsx /machine \"SEGA - SC-3000\" /rom1 example.rom
In order to compile and run the example, you need to have the BlueMSX emulator, and in particular that its executable is accessible.
Then, type this command on the command line:
# Linux ugbc.sg1000 contrib_minigame.bas -o example.rom bluemsx /machine \"SEGA - SG-1000\" /rom1 example.rom # Windows ugbc.sg1000.exe contrib_minigame.bas -o example.rom bluemsx /machine \"SEGA - SG-1000\" /rom1 example.rom
If you have found a problem trying to run this example, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub. Thank you!