DEFINE STRING SPACE 256 DEFINE STRING COUNT 16 BITMAP ENABLE(16) CLS wagonLRImage := LOAD IMAGE( "/usr/src/mine-rails/resources/wagonLR.png") wagonUDImage := LOAD IMAGE( "/usr/src/mine-rails/resources/wagonUD.png") level1 := LOAD TILEMAP("/usr/src/mine-rails/resources/level1.tmx") tileset := TILESET(level1) '''''''' POSITIVE CONST startX = 1 POSITIVE CONST startY = 1 POSITIVE CONST tileWidth = TILE WIDTH( tileset ) POSITIVE CONST tileWidth2 = (SCREEN SPRITE RATIO X / 100 ) * tileWidth POSITIVE CONST tileHeight = TILE HEIGHT( tileset ) POSITIVE CONST screenWidthInTiles = SCREEN WIDTH / tileWidth POSITIVE CONST screenHeightInTiles = SCREEN HEIGHT / tileHeight POSITIVE CONST maxPageX = ( ( TILEMAP WIDTH( level1 ) - 1 ) / screenWidthInTiles ) + 1 POSITIVE CONST maxPageY = ( ( TILEMAP HEIGHT( level1 ) - 1 ) / screenHeightInTiles ) + 1 CONST offsetX = tileWidth2/2 - 8 CONST offsetY = 4 POSITIVE CONST wagonSpeed = 1 POSITIVE CONST wagonSpeedX = 1 POSITIVE CONST wagonSpeedY = 1 '''''' POSITIVE CONST railLU = TILE ID( tileset, railLU ) POSITIVE CONST railLD = TILE ID( tileset, railLD ) POSITIVE CONST railRU = TILE ID( tileset, railRU ) POSITIVE CONST railRD = TILE ID( tileset, railRD ) POSITIVE CONST railLR = TILE ID( tileset, railLR ) POSITIVE CONST railUD = TILE ID( tileset, railUD ) POSITIVE CONST terrain = TILE ID( tileset, terrain ) POSITIVE CONST terrain2 = TILE ID( tileset, terrain2 ) POSITIVE CONST score = TILE ID( tileset, score ) POSITIVE CONST digit0 = TILE ID( tileset, digit0 ) POSITIVE CONST wagonST = TILE ID( tileset, wagonST ) POSITIVE CONST railLRbroken = TILE ID( tileset, railLRbroken ) POSITIVE CONST railUDbroken = TILE ID( tileset, railUDbroken ) POSITIVE CONST sign = TILE ID( tileset, sign ) POSITIVE CONST wagonLR = 0 POSITIVE CONST wagonUD = 1 wagon = CSPRITE( wagonLRImage ) POSITIVE CONST wagonImageWidth = IMAGE WIDTH( wagonLRImage ) POSITIVE CONST wagonImageHeight = IMAGE HEIGHT( wagonLRImage ) POSITIVE CONST minWagonX = SCREEN BORDER X POSITIVE CONST minWagonY = SCREEN BORDER Y POSITIVE CONST screenWidthInWagonCoords = ( SCREEN WIDTH * SCREEN SPRITE RATIO X ) / 100 POSITIVE CONST screenHeightInWagonCoords = ( SCREEN HEIGHT * SCREEN SPRITE RATIO Y ) / 100 POSITIVE CONST maxWagonX = SCREEN BORDER X + offsetX + screenWidthInWagonCoords - wagonImageWidth POSITIVE CONST maxWagonY = SCREEN BORDER Y + offsetY + screenHeightInWagonCoords - ( wagonImageHeight * SCREEN SPRITE RATIO X ) / 100 DIM actualPageX AS SIGNED BYTE DIM actualPageY AS SIGNED BYTE DIM previousPageX AS SIGNED BYTE = -1 DIM previousPageY AS SIGNED BYTE = -1 DIM x AS POSITION = SCREEN BORDER X + offsetX + startX*tileWidth2 DIM y AS POSITION = SCREEN BORDER Y + offsetY + startY*tileHeight DIM px AS POSITION = -1 DIM py AS POSITION = -1 DIM dx AS POSITION = 0 DIM dy AS POSITION = 0 DIM c AS POSITION = 0 ''''''''' DIM previousRail AS BYTE DIM actualRail AS BYTE ''''''''' DIM tx AS BYTE = startX DIM ty AS BYTE = startY DIM wagonId AS BYTE = 0 PROCEDURE changeWagonSpriteAndDirection[ rail AS BYTE, previous AS BYTE ] SHARED wagon, level1, tileset, tx, ty SHARED wagonUDImage, wagonLRImage, x, y, dx, dy SHARED actualPageX, actualPageY, previousPageX, previousPageY DIM tocheck AS BYTE tocheck = rail IF rail = terrain OR rail = terrain2 THEN tocheck = previous ENDIF IF ( dx > 0 ) AND ( tocheck <> railLR ) THEN dx = 0 dy = 0 IF tocheck = previous THEN DEC tx ENDIF SELECT CASE tocheck CASE railLU dx = 0 dy = -wagonSpeedY wagon = CSPRITE( wagonUDImage, wagon ) wagonId = wagonUD CASE railLD dx = 0 dy = wagonSpeedY wagon = CSPRITE( wagonUDImage, wagon ) wagonId = wagonUD ENDSELECT ELSE IF ( dx < 0 ) AND ( tocheck <> railLR ) THEN dx = 0 dy = 0 IF tocheck = previous THEN INC tx ENDIF SELECT CASE tocheck CASE railRU dx = 0 dy = -wagonSpeedY wagon = CSPRITE( wagonUDImage, wagon ) wagonId = wagonUD CASE railRD dx = 0 dy = wagonSpeedY wagon = CSPRITE( wagonUDImage, wagon ) wagonId = wagonUD ENDSELECT ELSE IF ( dy > 0 ) AND ( tocheck <> railUD ) THEN dx = 0 dy = 0 IF tocheck = previous THEN DEC ty ENDIF SELECT CASE tocheck CASE railLU dx = -wagonSpeedX dy = 0 wagon = CSPRITE( wagonLRImage, wagon ) wagonId = wagonLR CASE railRU dx = wagonSpeedX dy = 0 wagon = CSPRITE( wagonLRImage, wagon ) wagonId = wagonLR ENDSELECT ELSE IF ( dy < 0 ) AND ( tocheck <> railUD ) THEN dx = 0 dy = 0 IF tocheck = previous THEN INC ty ENDIF SELECT CASE tocheck CASE railLD dx = -wagonSpeedX dy = 0 wagon = CSPRITE( wagonLRImage, wagon ) wagonId = wagonLR CASE railRD dx = wagonSpeedX dy = 0 wagon = CSPRITE( wagonLRImage, wagon ) wagonId = wagonLR ENDSELECT ENDIF END PROC PROCEDURE moveWagonToStart SHARED tx, ty, x, y, dx, dy SHARED actualPageX, actualPageY SHARED previousPageX, previousPageY tx = startX ty = startY x = SCREEN BORDER X + offsetX + startX*tileWidth2 y = SCREEN BORDER Y + offsetY + startY*tileHeight actualPageX = 0 actualPageY = 0 previousPageX = -1 previousPageY = -1 dx = wagonSpeedX dy = 0 changeWagonSpriteAndDirection[ railLR, terrain ] END PROC PROCEDURE prepareBitmaps ON CPC, ATARI, ATARIXL, COCO, DRAGON, MO5, PC128OP, ZX SHARED wagonImage SHARED wagonBackground wagonBackground := NEW IMAGE( wagonImageWidth, wagonImageHeight ) END PROC PROCEDURE drawWagonSprite ON C64, C128, COLECO, MSX, SC3000, SG1000 SHARED x, y SHARED wagon SPRITE wagon ENABLE AT x+offsetX, y+offsetY END PROC PROCEDURE hideWagonSprite ON C64, C128, COLECO, MSX, SC3000, SG1000 SHARED wagon SPRITE wagon DISABLE END PROC PROCEDURE saveWagonBackground ON CPC, ATARI, ATARIXL, COCO, DRAGON, MO5, PC128OP, ZX SHARED x, y SHARED wagonBackground GET IMAGE wagonBackground FROM x, y END PROC PROCEDURE drawWagonBitmap ON CPC, ATARI, ATARIXL, COCO, DRAGON, MO5, PC128OP, ZX SHARED x, y SHARED px, py SHARED wagonLRImage, wagonUDImage, wagonBackground, tileset IF ( px <> x ) OR ( py <> y ) THEN WHILE RASTER LINE < y WAIT 1 CYCLES WEND IF (px<>-1) AND (py<>-1) THEN PUT IMAGE wagonBackground AT px, py ENDIF saveWagonBackground[] ON CPC, ATARI, ATARIXL, COCO, DRAGON, MO5, PC128OP, ZX IF wagonId = wagonLR THEN PUT IMAGE wagonLRImage AT x,y WITH TRANSPARENCY ELSE IF wagonId = wagonUD THEN PUT IMAGE wagonUDImage AT x,y WITH TRANSPARENCY ENDIF WHILE RASTER LINE > 0 WAIT 1 CYCLES WEND px = x py = y ENDIF END PROC PARALLEL PROCEDURE drawWagon SHARED x, y, dx, dy, tx, ty SHARED wagon DIM ti AS WORD ti = TIMER DO IF ( TIMER - ti ) > 0 THEN ADD x, dx IF ( ( ( (x - SCREEN BORDER X) AND (tileWidth2-1) ) = 0 ) ) THEN IF ( dx <> 0 ) THEN IF dx > 0 THEN INC tx ELSE IF dx < 0 THEN DEC tx ENDIF ENDIF ENDIF YIELD ADD y, dy IF ( ( ( ( y - SCREEN BORDER Y ) AND (tileHeight-1) ) = 0 ) ) THEN IF ( dy <> 0 ) THEN IF dy > 0 THEN INC ty ELSE IF dy < 0 THEN DEC ty ENDIF ENDIF ENDIF YIELD drawWagonSprite[] ON C64, C128, COLECO, MSX, SC3000, SG1000 drawWagonBitmap[] ON CPC, ATARI, ATARIXL, COCO, DRAGON, MO5, PC128OP, ZX YIELD ti = TIMER ENDIF LOOP END PROC PROCEDURE drawMap SHARED level1 SHARED actualPageX, actualPageY SHARED previousPageX, previousPageY SHARED px, py SHARED wagonBackground IF ( previousPageX <> actualPageX ) OR ( previousPageY <> actualPageY ) THEN hideWagonSprite[] ON C64, C128, COLECO, MSX, SC3000, SG1000 PUT TILEMAP level1 FROM actualPageX * screenWidthInTiles, actualPageY * screenHeightInTiles GET IMAGE wagonBackground FROM px, py previousPageX = actualPageX previousPageY = actualPageY ENDIF END PROC PROCEDURE checkMapLocation SHARED actualRail, previousRail SHARED tx, ty, actualPageX, actualPageY actualRail = TILEMAP level1 AT( tx, ty ) IF actualRail = railLRbroken THEN actualRail = railLR ENDIF IF actualRail = railUDbroken THEN actualRail = railUD ENDIF IF actualRail = railLRbroken OR actualRail = railUDbroken THEN EVERY OFF HALT moveWagonToStart[] ELSE IF previousRail <> actualRail THEN changeWagonSpriteAndDirection[ actualRail, previousRail ] previousRail = actualRail ENDIF ENDIF IF ( actualPageX < maxPageX ) AND tx >= ( (actualPageX+1) * screenWidthInTiles ) THEN x = minWagonX INC actualPageX ELSE IF ( actualPageX > 0 ) AND tx < ( (actualPageX) * screenWidthInTiles ) THEN x = maxWagonX - tileWidth2 - 1 DEC actualPageX ELSE IF ( actualPageY < maxPageY ) AND ty >= ( (actualPageY+1) * screenHeightInTiles ) THEN y = minWagonY INC actualPageY ELSE IF ( actualPageY > 0 ) AND ty < ( (actualPageY) * screenHeightInTiles ) THEN y = maxWagonY - 1 DEC actualPageY ENDIF END PROC prepareBitmaps[] ON CPC, ATARI, ATARIXL, COCO, DRAGON, MO5, PC128OP, ZX moveWagonToStart[] SPAWN drawWagon DO drawMap[] checkMapLocation[] RUN PARALLEL LOOP
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 test2.bas -o example.xex altirra example.xex # Windows ugbc.atari.exe test2.bas -o example.xex altirra example.xex
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 test2.bas -o example.xex altirra example.xex # Windows ugbc.atarixl.exe test2.bas -o example.xex altirra example.xex
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 test2.bas -o example.prg x64sc example.prg # Windows ugbc.c64.exe test2.bas -o example.prg x64sc example.prg
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 test2.bas -o example.prg yape example.prg # Windows ugbc.plus4.exe test2.bas -o example.prg yape example.prg
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 test2.bas -o example.prg xplus4 example.prg # Windows ugbc.plus4.exe test2.bas -o example.prg xplus4 example.prg
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 test2.bas -o example.bin xroar -rompath (percorso ROM) example.bin # Windows ugbc.d32.exe test2.bas -o example.bin xroar.exe -rompath (percorso ROM) example.bin
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 test2.bas -o example.bin xroar -rompath (percorso ROM) example.bin # Windows ugbc.d64.exe test2.bas -o example.bin xroar.exe -rompath (percorso ROM) example.bin
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 test2.bas -o example.bin dcmoto example.bin (scegliere example.bin) (scegliere BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC # Windows ugbc.pc128op.exe test2.bas -o example.bin dcmoto example.bin (scegliere BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC
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 test2.bas -o example.bin dcmoto example.bin (scegliere example.bin) (scegliere BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC # Windows ugbc.mo5.exe test2.bas -o example.bin dcmoto example.bin (scegliere BASIC 128) CLEAR,&H2FFF: LOADM"CASS:",R: EXEC
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 test2.bas -o example.prg xvic --memory 24k example.prg # Windows ugbc.vic20.exe test2.bas -o example.prg xvic --memory 24k example.prg
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 test2.bas -o example.tap Speccy example.tap # Windows ugbc.zx.exe test2.bas -o example.tap Speccy example.tap
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:
# Linux ugbc.coleco test2.bas -o example.rom openmsx -machine \"COL - ColecoVision\" -cart example.rom # Windows ugbc.coleco.exe test2.bas -o example.rom bluemsx -machine \"COL - ColecoVision\" example.rom
# Linux ugbc.coleco test2.bas -o example.rom bluemsx /machine \"COL - ColecoVision\" /rom1 example.rom # Windows ugbc.coleco.exe test2.bas -o example.rom bluemsx /machine \"COL - ColecoVision\" /rom1 example.rom
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 test2.bas -o example.rom bluemsx /machine \"SEGA - SC-3000\" /rom1 example.rom # Windows ugbc.sc3000.exe test2.bas -o example.rom bluemsx /machine \"SEGA - SC-3000\" /rom1 example.rom
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 test2.bas -o example.rom bluemsx /machine \"SEGA - SG-1000\" /rom1 example.rom # Windows ugbc.sg1000.exe test2.bas -o example.rom bluemsx /machine \"SEGA - SG-1000\" /rom1 example.rom
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, apri una segnalazione su GitHub per questo specifico esempio. Grazie!