{{htmlmetatags>metatag-robots=() metatag-title=(VARI ALTRI CONTRIBUTI MINIGIOCO | ugBASIC User Manual) metatag-keywords=(ugBASIC,Commodore 64,Commodore PLUS/4,ZX Spectrum) metatag-description=(An isomorphic language for retrocomputers) metatag-media-og:image=(:ugbasic:logo-ugbasic-fb.png) metatag-og:title=(VARI ALTRI CONTRIBUTI MINIGIOCO | ugBASIC User Manual) metatag-og:description=(An isomorphic language for retrocomputers) }} ====== ugBASIC Manuale Utente ====== ===== VARI ALTRI CONTRIBUTI MINIGIOCO ===== ==== SCOPO ==== Questo è un breve gioco di Endi Baráth, originariamente pubblicato sul gruppo BASIC Programming Language. E' stato convertito in ugBASIC da Marco Spedaletti, perché funzionasse sulla maggior parte dei computer a 8 bit. E' neecssario disporre almeno della version 1.6.2-beta per compilarsi. Un riferimento al sorgente originale è stato aggiunto come commento. ==== SORGENTE ==== ' 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 ' 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 ' 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: ") ' 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); ==== FILE ==== * ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/game.bas|game.bas]]'' ==== COME ESEGUIRLO ==== === Atari 400/800 === Per poter eseguire l'esempio, è necessario disporre dell'emulatore Altirra, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.atari game.bas -o example.xex altirra example.xex # Windows ugbc.atari.exe game.bas -o example.xex altirra example.xex === Atari 600XL/800XL/1200XL/XG(SE) === Per poter eseguire l'esempio, è necessario disporre dell'emulatore Altirra, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.atarixl game.bas -o example.xex altirra example.xex # Windows ugbc.atarixl.exe game.bas -o example.xex altirra example.xex === Commodore 64 === Per poter eseguire l'esempio, è necessario disporre dell'emulatore VICE, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.c64 game.bas -o example.prg x64sc example.prg # Windows ugbc.c64.exe game.bas -o example.prg x64sc example.prg === Commodore 64+REU === Per poter eseguire l'esempio, è necessario disporre dell'emulatore VICE, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.c64reu game.bas -o example.prg x64sc -reu example.prg # Windows ugbc.c64reu.exe game.bas -o example.prg x64sc -reu example.prg === Commodore PLUS/4 === == Usando YAPE == Per poter eseguire l'esempio, è necessario disporre dell'emulatore YAPE, e in particolare che l'eseguibile ''yape'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.plus4 game.bas -o example.prg yape example.prg # Windows ugbc.plus4.exe game.bas -o example.prg yape example.prg == Usando VICE == Per poter eseguire l'esempio, è necessario disporre dell'emulatore VICE, e in particolare che l'eseguibile ''xplus4'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.plus4 game.bas -o example.prg xplus4 example.prg # Windows ugbc.plus4.exe game.bas -o example.prg xplus4 example.prg === Dragon 32 === Per poter eseguire l'esempio, è necessario disporre dell'emulatore XROAR, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.d32 game.bas -o example.bin xroar -rompath (percorso ROM) example.bin # Windows ugbc.d32.exe game.bas -o example.bin xroar.exe -rompath (percorso ROM) example.bin === Dragon 64 === Per poter eseguire l'esempio, è necessario disporre dell'emulatore XROAR, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.d64 game.bas -o example.bin xroar -rompath (percorso ROM) example.bin # Windows ugbc.d64.exe game.bas -o example.bin xroar.exe -rompath (percorso ROM) example.bin === PC128 Olivetti Prodest === Per poter eseguire l'esempio, è necessario disporre dell'emulatore DCMOTO, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi i seguenti comandi: # Linux ugbc.pc128op game.bas -o example.bin dcmoto example.bin (scegliere example.bin) (scegliere BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC # Windows ugbc.pc128op.exe game.bas -o example.bin dcmoto example.bin (scegliere BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC === Thomson MO5 === Per poter eseguire l'esempio, è necessario disporre dell'emulatore DCMOTO, e in particolare che l'eseguibile ''x64sc'' sia accessibile. Digitare quindi i seguenti comandi: # Linux ugbc.mo5 game.bas -o example.bin dcmoto example.bin (scegliere example.bin) (scegliere BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC # Windows ugbc.mo5.exe game.bas -o example.bin dcmoto example.bin (scegliere BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC === Commodore VIC-20 === Per poter eseguire l'esempio, è necessario disporre dell'emulatore XEMU, e in particolare che l'eseguibile ''xmega65'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.vic20 game.bas -o example.prg xvic --memory 24k example.prg # Windows ugbc.vic20.exe game.bas -o example.prg xvic --memory 24k example.prg === ZX Spectrum === Per poter eseguire l'esempio, è necessario disporre dell'emulatore Speccy, e in particolare che l'eseguibile ''speccy'' sia accessibile. Digitare quindi il seguente comando: # Linux ugbc.zx game.bas -o example.tap Speccy example.tap # Windows ugbc.zx.exe game.bas -o example.tap Speccy example.tap === ColecoVision === Per compilare e mandare in esecuzione l'esempio, hai bisogno di avere l'emulatore openMsx oppure il BlueMSX, e in particolare che il suo eseguibile sia accessibile. Dopo di che, digita questo comando sulla linea di comando: == openMSX == # Linux ugbc.coleco game.bas -o example.rom openmsx -machine \"COL - ColecoVision\" -cart example.rom # Windows ugbc.coleco.exe game.bas -o example.rom bluemsx -machine \"COL - ColecoVision\" example.rom == blueMSX == # Linux ugbc.coleco game.bas -o example.rom bluemsx /machine \"COL - ColecoVision\" /rom1 example.rom # Windows ugbc.coleco.exe game.bas -o example.rom bluemsx /machine \"COL - ColecoVision\" /rom1 example.rom === SEGA SC-3000 === Per compilare e mandare in esecuzione l'esempio, hai bisogno di avere l'emulatore BlueMSX, e in particolare che il suo eseguibile sia accessibile. Dopo di che, digita questo comando sulla linea di comando: # Linux ugbc.sc3000 game.bas -o example.rom bluemsx /machine \"SEGA - SC-3000\" /rom1 example.rom # Windows ugbc.sc3000.exe game.bas -o example.rom bluemsx /machine \"SEGA - SC-3000\" /rom1 example.rom === SEGA SG-1000 === Per compilare e mandare in esecuzione l'esempio, hai bisogno di avere l'emulatore BlueMSX, e in particolare che il suo eseguibile sia accessibile. Dopo di che, digita questo comando sulla linea di comando: # Linux ugbc.sg1000 game.bas -o example.rom bluemsx /machine \"SEGA - SG-1000\" /rom1 example.rom # Windows ugbc.sg1000.exe game.bas -o example.rom bluemsx /machine \"SEGA - SG-1000\" /rom1 example.rom ==== PROBLEMI? ==== Se hai trovato un problema nel cercare di eseguire questo esempio, se pensi che ci sia un bug o, più semplicemente, vorresti che fosse migliorato, [[https://github.com/spotlessmind1975/ugbasic/issues/new?title=MIGLIORARE VARI ALTRI CONTRIBUTI MINIGIOCO|apri una segnalazione]] su GitHub per questo specifico esempio. Grazie!===== POWERED BY ===== [[:it:ugbasic:user:examples|{{ :ugbasic:user:logo-ugbasic.png?nolink&600 |}}]]