{{htmlmetatags>metatag-robots=() metatag-title=( | 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=( | ugBASIC User Manual) metatag-og:description=(An isomorphic language for retrocomputers) }} ====== ugBASIC Manuale Utente ====== ===== ===== ==== SCOPO ==== ==== SORGENTE ==== BITMAP ENABLE(16) CLS map := LOAD TILEMAP("/usr/src/the-village/resources/village.tmx") tileset := TILESET(map) POSITIVE CONST startX = 1 POSITIVE CONST startY = 1 POSITIVE CONST tileWidth = TILE WIDTH( TILESET( map ) ) POSITIVE CONST tileWidth2 = (SCREEN SPRITE RATIO / 100 ) * tileWidth POSITIVE CONST tileHeight = TILE HEIGHT( TILESET( map ) ) POSITIVE CONST screenWidthInTiles = SCREEN WIDTH / tileWidth POSITIVE CONST screenHeightInTiles = SCREEN HEIGHT / tileHeight POSITIVE CONST offsetWidthInTiles = ( TILEMAP WIDTH( map ) - screenWidthInTiles ) / 2 POSITIVE CONST offsetHeightInTiles = ( TILEMAP HEIGHT( map ) - screenHeightInTiles ) / 2 POSITIVE CONST maxPageX = TILEMAP WIDTH( map ) / screenWidthInTiles POSITIVE CONST maxPageY = TILEMAP HEIGHT( map ) / screenHeightInTiles POSITIVE CONST railLU = TILE ID( TILESET( map ), railLU ) POSITIVE CONST railLD = TILE ID( TILESET( map ), railLD ) POSITIVE CONST railRU = TILE ID( TILESET( map ), railRU ) POSITIVE CONST railRD = TILE ID( TILESET( map ), railRD ) POSITIVE CONST railLR = TILE ID( TILESET( map ), railLR ) POSITIVE CONST railUD = TILE ID( TILESET( map ), railUD ) POSITIVE CONST terrain = TILE ID( TILESET( map ), terrain ) POSITIVE CONST terrain2 = TILE ID( TILESET( map ), terrain2 ) POSITIVE CONST score = TILE ID( TILESET( map ), score ) POSITIVE CONST digit0 = TILE ID( TILESET( map ), digit0 ) POSITIVE CONST vagonST = TILE ID( TILESET( map ), vagonST ) POSITIVE CONST railLRbroken = TILE ID( TILESET( map ), railLRbroken ) POSITIVE CONST railUDbroken = TILE ID( TILESET( map ), railUDbroken ) DIM vagon AS SPRITE DIM previousRail AS BYTE DIM actualRail AS BYTE DIM actualPageX AS BYTE DIM actualPageY AS BYTE DIM previousPageX AS BYTE = -1 DIM previousPageY AS BYTE = -1 DIM tx AS BYTE = startX DIM ty AS BYTE = startY DIM x AS POSITION = SCREEN BORDER X + startX*tileWidth2 DIM y AS POSITION = SCREEN BORDER Y + startY*tileHeight DIM directionX AS POSITION = 1 DIM directionY AS POSITION = 0 DIM jumpAY AS BYTE = 0 DIM jumpY AS BYTE = 0 vagon = CSPRITE( IMAGE( tileset TILE NAMED vagonLR ) ) vagonUDImage = IMAGE( tileset TILE NAMED vagonUD ) vagonLRImage = IMAGE( tileset TILE NAMED vagonLR ) GLOBAL vagon, map, tileset, directionX, directionY, tx, ty GLOBAL vagonUDImage, vagonLRImage, x, y, directionX, directionY GLOBAL actualPageX, actualPageY, previousPageX, previousPageY GLOBAL jumpAY, jumpY PROCEDURE drawVagon ON C128, COLECO IF jumpAY > 0 THEN IF jumpAY > ( tileWidth2 / 2 ) THEN jumpY = 4 ELSE IF jumpAY > ( tileWidth2 / 4 ) THEN jumpY = 2 ELSE jumpY = 1 ENDIF DEC jumpAY ELSE jumpY = 0 ENDIF SPRITE vagon ENABLE AT x, y - jumpY END PROC PROCEDURE drawVagon ON ALL BUT C128, COLECO END PROC PROCEDURE drawScore PUT IMAGE tileset TILE score AT 0, 0 PUT IMAGE tileset TILE score+1 AT tileWidth, 0 PUT IMAGE tileset TILE digit0 AT 2*tileWidth, 0 PUT IMAGE tileset TILE digit0 AT 3*tileWidth, 0 PUT IMAGE tileset TILE digit0 AT 4*tileWidth, 0 PUT IMAGE tileset TILE digit0 AT 5*tileWidth, 0 PUT IMAGE tileset TILE digit0 AT 6*tileWidth, 0 END PROC PROCEDURE changeVagonSpriteAndDirection[ rail AS BYTE, previous AS BYTE ] DIM tocheck AS BYTE tocheck = rail IF rail = terrain OR rail = terrain2 THEN tocheck = previous ENDIF IF ( directionX > 0 ) AND ( tocheck <> railLR ) THEN directionX = 0 directionY = 0 IF tocheck = previous THEN DEC tx ENDIF SELECT CASE tocheck CASE railLU directionX = 0 directionY = -1 vagon = CSPRITE( vagonUDImage, vagon ) CASE railLD directionX = 0 directionY = 1 vagon = CSPRITE( vagonUDImage, vagon ) ENDSELECT ELSE IF ( directionX < 0 ) AND ( tocheck <> railLR ) THEN directionX = 0 directionY = 0 IF tocheck = previous THEN INC tx ENDIF SELECT CASE tocheck CASE railRU directionX = 0 directionY = -1 vagon = CSPRITE( vagonUDImage, vagon ) CASE railRD directionX = 0 directionY = 1 vagon = CSPRITE( vagonUDImage, vagon ) ENDSELECT ELSE IF ( directionY > 0 ) AND ( tocheck <> railUD ) THEN directionX = 0 directionY = 0 IF tocheck = previous THEN DEC ty ENDIF SELECT CASE tocheck CASE railLU directionX = -1 directionY = 0 vagon = CSPRITE( vagonLRImage, vagon ) CASE railRU directionX = 1 directionY = 0 vagon = CSPRITE( vagonLRImage, vagon ) ENDSELECT ELSE IF ( directionY < 0 ) AND ( tocheck <> railUD ) THEN directionX = 0 directionY = 0 IF tocheck = previous THEN INC ty ENDIF SELECT CASE tocheck CASE railLD directionX = -1 directionY = 0 vagon = CSPRITE( vagonLRImage, vagon ) CASE railRD directionX = 1 directionY = 0 vagon = CSPRITE( vagonLRImage, vagon ) ENDSELECT ENDIF END PROC PROCEDURE moveVagonToStart tx = startX ty = startY x = SCREEN BORDER X + startX*tileWidth2 y = SCREEN BORDER Y + startY*tileHeight actualPageX = 0 actualPageY = 0 previousPageX = -1 previousPageY = -1 directionX = 1 directionY = 0 jumpAY = 0 jumpY = 0 changeVagonSpriteAndDirection[ railLR, terrain ] drawVagon[] END PROC moveVagonToStart[] DO ADD x, directionX IF ( ( x AND (tileWidth2-1) ) = 0 ) AND ( directionX <> 0 ) THEN IF directionX > 0 THEN INC tx ELSE IF directionX < 0 THEN DEC tx ENDIF ENDIF ADD y, directionY IF ( ( y AND (tileHeight-1) ) = 0 ) AND ( directionY <> 0 ) THEN IF directionY > 0 THEN INC ty ELSE IF directionY < 0 THEN DEC ty ENDIF ENDIF IF ( previousPageX <> actualPageX ) OR ( previousPageY <> actualPageY ) THEN PUT TILEMAP map FROM actualPageX * screenWidthInTiles, actualPageY * screenHeightInTiles drawScore[] previousPageX = actualPageX previousPageY = actualPageY ENDIF actualRail = TILEMAP map AT( tx, ty ) IF actualRail = railLRbroken OR actualRail = railUDbroken THEN IF jumpY <= 1 THEN moveVagonToStart[] ENDIF ELSE IF previousRail <> actualRail THEN changeVagonSpriteAndDirection[ actualRail, previousRail ] previousRail = actualRail ENDIF ENDIF IF ( actualPageX < maxPageX ) AND tx > ( (actualPageX+1) * screenWidthInTiles ) THEN x = SCREEN BORDER X + tileWidth2 INC actualPageX ELSE IF ( actualPageX > 0 ) AND tx < ( (actualPageX) * screenWidthInTiles ) THEN x = SCREEN BORDER X + tileWidth2*(screenWidthInTiles-1) DEC actualPageX ELSE IF ( actualPageY < maxPageY ) AND ty > ( (actualPageY+1) * screenHeightInTiles ) THEN y = SCREEN BORDER Y INC actualPageY ELSE IF ( actualPageY > 0 ) AND ty < ( (actualPageY) * screenHeightInTiles ) THEN y = SCREEN BORDER Y + tileHeight*(screenHeightInTiles-1) - tileHeight DEC actualPageY ENDIF drawVagon[] 'PRINT INKEY; 'IF KEY PRESSED( KEY SPACE ) AND jumpAY = 0 THEN ' jumpAY = tileWidth2 'ENDIF LOOP ==== FILE ==== * ''[[https://github.com/spotlessmind1975/ugbasic/tree/main/examples/the-village.bas|the-village.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 the-village.bas -o example.xex altirra example.xex # Windows ugbc.atari.exe the-village.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 the-village.bas -o example.xex altirra example.xex # Windows ugbc.atarixl.exe the-village.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 the-village.bas -o example.prg x64sc example.prg # Windows ugbc.c64.exe the-village.bas -o example.prg x64sc 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 the-village.bas -o example.prg yape example.prg # Windows ugbc.plus4.exe the-village.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 the-village.bas -o example.prg xplus4 example.prg # Windows ugbc.plus4.exe the-village.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 the-village.bas -o example.bin xroar -rompath (percorso ROM) example.bin # Windows ugbc.d32.exe the-village.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 the-village.bas -o example.bin xroar -rompath (percorso ROM) example.bin # Windows ugbc.d64.exe the-village.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 the-village.bas -o example.bin dcmoto example.bin (scegliere example.bin) (scegliere BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC # Windows ugbc.pc128op.exe the-village.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 the-village.bas -o example.bin dcmoto example.bin (scegliere example.bin) (scegliere BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC # Windows ugbc.mo5.exe the-village.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 the-village.bas -o example.prg xvic --memory 24k example.prg # Windows ugbc.vic20.exe the-village.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 the-village.bas -o example.tap Speccy example.tap # Windows ugbc.zx.exe the-village.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 the-village.bas -o example.rom openmsx -machine \"COL - ColecoVision\" -cart example.rom # Windows ugbc.coleco.exe the-village.bas -o example.rom bluemsx -machine \"COL - ColecoVision\" example.rom == blueMSX == # Linux ugbc.coleco the-village.bas -o example.rom bluemsx /machine \"COL - ColecoVision\" /rom1 example.rom # Windows ugbc.coleco.exe the-village.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 the-village.bas -o example.rom bluemsx /machine \"SEGA - SC-3000\" /rom1 example.rom # Windows ugbc.sc3000.exe the-village.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 the-village.bas -o example.rom bluemsx /machine \"SEGA - SG-1000\" /rom1 example.rom # Windows ugbc.sg1000.exe the-village.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 |apri una segnalazione]] su GitHub per questo specifico esempio. Grazie!===== POWERED BY ===== [[:it:ugbasic:user:examples|{{ :ugbasic:user:logo-ugbasic.png?nolink&600 |}}]]