Thanks to your help chalky I am able to have it saved in a disk image and now tomorrow I can play it on my real hardware MSX using megaflash cartridge.
THIS IS LITERALLY the funnest MSX game I have ever played so far hehe. I can now throw the printed book. I don't need the other titles.
You're welcome - I enjoyed the challenge. I wouldn't throw the book away until you're sure it's all fixed though. As I said, there may be problems with the other level definitions, and I'm not sure what will happen if you complete all the levels as the DATA pointer gets reset but (as far as I could tell) not the counter. You might also want to change the WELL DONE! message to something else (I changed it from HAPPY BIRTHDAY).
I agree that it's a good game - especially as it's written in BASIC - the compact method used to store levels is particularly clever IMO.
Found another one...
Change:
2560 DATA 6,2,8,21,-1,0,23,6,-,1,0
to:
2560 DATA 6,2,8,21,-1,0,23,6,-1,0
There could well be more...
WOW thanks!! It really is a fun game! I tried MSXBasic2ROM to compile it and convert it as ROM so I can enjoy it as digital cartridge...but msxbasic2rom compiles adds and removes things in the code that breaks it.
Like it adds ( to print tab and remove a complete conditional check in the if statement resulting:
ifthen240 instead.
How do I compile this as a full ROM? I want to keep flashing it in my megaflash in my real MSX when I want to play it. I want to put it into my other digital cartridge (ROM) games, even amongst the commercial ones. In my opinion, this game deserves to be sold as a physical cartridge game with manual and box, compiled into ASM for optimal speed, and sold for 29.99 euro. It deserves to be part of the MSXDev award, add more levels and even have a level editor. Add password screen to resume last level played. It have foundation to be a very great game...maybe add more train for much challenging levels, humans coming and changing the tracks for annoyance, etc.
How do I compile this as a full ROM? I want to keep flashing it in my megaflash in my real MSX when I want to play it. I want to put it into my other digital cartridge (ROM) games, even amongst the commercial ones.
If you're not looking for extra performance, you don't need to compile it. Just build a standard MSXBASIC cartridge. The MSX RED BOOK and MSX Top Secret books may help you with that!
Final version from me...
I've fixed the background music (you had multiple "0" chrs instead of "O" chrs in the PLAY statements [O=Octave]). While doing this I realised the reason I'd had to previously comment out [original] lines 1840-1850 (which I now know are there to keep the background music queue loaded) was because of a typo in the GOSUB line number.
I have added code to return to the title screen once all 10 levels have been completed (the original code simply reset the DATA pointer when level 11 was reached - an OUT OF DATA error would have occurred if the player reached level 21). I've also added an ONSTOPGOSUB so that the program exits cleanly to Screen 0 rather than breaking on Screen 1.
For some reason I find the keyboard response to be very sluggish at times - making gameplay somewhat frustrating - but unfortunately haven't been able to work out why.
100 REM *** RAILROAD *** 110 REM 120 REM Wilson F.Martins 130 REM 140 CLEAR5000:DEFINTA-Z:KEYOFF:ONSTOPGOSUB1910:STOPON 150 COLOR15,1,1:SCREEN1,2:WIDTH32 160 DEFFNQ$(A,B)=RIGHT$("00000"+MID$(STR$(A),2,LEN(STR$(A))-1),B) 170 DIMP$(14,2) 180 FORN=1TO10:B$="" 190 FORM=0TO31:READA$ 200 B$=B$+CHR$(VAL("&H"+A$)):NEXT 210 SPRITE$(N)=B$:NEXT 220 FORN=776TO855:READA$ 230 A=VAL("&H"+A$):VPOKEN,A:NEXT 240 FORN=896TO903:READA$ 250 A=VAL("&H"+A$):VPOKEN,A:NEXT 260 VPOKE8204,26:VPOKE8205,26 270 VPOKE8206,202 280 FORN=0TO14:FORM=0TO2 290 READP$(N,M):NEXTM,N 300 CLS 310 LOCATE6,4:PRINTSTRING$(20,112) 320 PRINTTAB(6);"p RAILROAD p" 330 PRINTTAB(6);STRING$(20,112) 340 LOCATE0,9:PRINTSTRING$(160,103) 350 LOCATE0,11:PRINTSTRING$(32,97) 360 LOCATE10,10:PRINTCHR$(105) 370 LOCATE3,22:PRINT" PRESS SPACEBAR TO BEGIN " 380 M=0:FORN=0TO1000:NEXT 390 M=M+1:PUTSPRITE1,(M,78),4,1 400 FORJS=0TO2:I=STRIG(JS) 410 IFITHEN430 420 NEXT:GOTO390 430 GOSUB1610 440 PO=0:VI=3:RESTORE2590:FA=1 450 GOSUB1640:TE=999 460 FORW=1TONT 470 IFW=1THENCO=1ELSECO=4 480 PUTSPRITEW+1,(X(W)*8,Y(W)*8-9),CO,PT(W) 490 FORN=2TONT 500 IFX(1)=X(N)ANDY(1)=Y(N)THEN1370 510 NEXTN 520 GOSUB700 530 NEXTW 540 LOCATE19,0:TE=TE-1:PRINTFNQ$(TE,3) 550 IFTE=0THENGOSUB1610:GOTO1530 560 ED=X(1)+Y(1)*32+6144 570 IFVPEEK(ED+1)=112THENVPOKEED+1,103:GOSUB840 580 IFVPEEK(ED-32)=112THENVPOKEED-32,103:GOSUB840 590 I=STICK(JS) 600 IFI=1THENCY=CY-3 610 IFI=5THENCY=CY+3 620 IFI=3THENCX=CX+3 630 IFI=7THENCX=CX-3 640 IFCX<2THENCX=29 650 IFCX>29THENCX=2 660 IFCY<3THENCY=21 670 IFCY>21THENCY=3 680 PUTSPRITE1,(CX*8-4, CY*8-5),6,9 690 GOTO460 700 X(W)=X(W)+FX(W):Y(W)=Y(W)+FY(W) 710 Q(W)=P(W) 720 P(W)=VPEEK(X(W)+Y(W)*32+6144)-97 730 IFP(W)=7THENRETURN 740 IFP(W)=Q(W)THENRETURN 750 IFP(W)=2AND(FX(W)=-1ORFY(W)=-1)THENPT(W)=4-4*FX(W):SWAPFX(W),FY(W):FX(W)=-FX(W):FY(W)=-FY(W):RETURN 760 IFP(W)=3AND(FX(W)=1ORFY(W)=-1)THENPT(W)=3-4*FY(W):SWAPFX(W),FY(W):RETURN 770 IFP(W)=4AND(FX(W)=1ORFY(W)=1)THENPT(W)=4+4*FY(W):SWAPFX(W),FY(W):FX(W)=-FX(W):FY(W)=-FY(W) 780 IFP(W)=5AND(FX(W)=-1ORFY(W)=1)THENPT(W)=3-4*FX(W):SWAPFX(W),FY(W):RETURN 790 IFQ(W)=0THENFX(W)=-FX(W):X(W)=X(W)+FX(W) 800 IFQ(W)=1THENFY(W)=-FY(W):Y(W)=Y(W)+FY(W) 810 IFP(W)=0THENPT(W)=3-2*FX(W) 820 IFP(W)=1THENPT(W)=4-2*FY(W) 830 RETURN 840 PO=PO+10 850 LOCATE7,0:PRINTFNQ$(PO,5) 860 SOUND7,56:SOUND10,16:SOUND13,0 870 SOUND12,10:SOUND5,1:SOUND4,0 880 NB=NB-1 890 IFNB>0THENRETURN 900 INTERVALOFF:STRIG(JS)OFF 910 BEEP:PLAY"S0M6000L8CC16C16DCEF2" 920 IFPLAY(0)THEN920 930 GOSUB1610 940 LOCATE8,11:PRINT" " 950 LOCATE8,12:PRINT" LEVEL COMPLETE " 960 LOCATE8,13:PRINT" " 970 FORN=0TO5000:NEXT 980 PLAY"V15L16CFB" 990 LOCATE8,12:PRINT" BONUS:";FNQ$(TE,3);" " 1000 FORN=0TO5000:NEXT 1010 PO=PO+TE 1020 FA=FA+1 1030 IFFA<11THEN450 1040 LOCATE8,11:PRINT" " 1050 LOCATE8,12:PRINT" GAME COMPLETED " 1060 LOCATE8,13:PRINT" " 1070 FORN=0TO5000:NEXT 1080 GOTO1580 1090 ED=CX+CY*32+6144 1100 DT=VPEEK(ED)-97:DA=DT 1110 IFDT>5ORDT<2THENRETURN 1120 DN=VPEEK(ED-32) 1130 DS=VPEEK(ED+32) 1140 DL=VPEEK(ED+1) 1150 D0=VPEEK(ED-1) 1160 DT=DT+1:IFDT=6THENDT=2 1170 IFDT=DATHENRETURN 1180 IFDT=2ANDDS<>103ANDDL<>103THEN1230 1190 IFDT=3ANDDS<>103ANDD0<>103THEN1230 1200 IFDT=4ANDDN<>103ANDD0<>103THEN1230 1210 IFDT=5ANDDN<>103ANDDL<>103THEN1230 1220 GOTO1160 1230 SOUND7,28:SOUND6,31:SOUND10,16 1240 SOUND13,4:SOUND12,2 1250 VPOKEED,DT+97:RETURN 1260 SOUND7,56:MU=MU+1 1270 IFMU=9THENMU=1 1280 IFMU>7THENRETURN 1290 IFMU=1THENPLAY"V9O4L4T254AF#8R8R2R4F#GA","T254O3V7DAO2AO3ADAO2AO3A" 1300 IFMU=2THENPLAY"O5F#R4F#R4D1","DO4DO2AO4DO3DBAF#" 1310 IFMU=3THENPLAY"O4AF#8R8R2R4F#GF#","O3DAO2AO3ADAO2AO3A" 1320 IFMU=4THENPLAY"O4AR4AR4G1","O3C#O4C#O2AO4C#O3C#EAB" 1330 IFMU=5THENPLAY"GE8R8R2R4EF#G","O4C#O3AO2AO4C#O3C#AO2AO4C#" 1340 IFMU=6THENPLAY"AF#8R8R2R4F#G#.F#8","O3DAO2AO3ADO4DC2" 1350 IFMU=7THENPLAY"EAR4F#G#ER4BA1A1","O3EAO4C#EO3EBO4DEC#O3AGEO2A" 1360 RETURN 1370 INTERVALOFF:STRIG(JS)OFF 1380 BEEP:SOUND7,7:SOUND8,16 1390 SOUND6,31:SOUND13,0:SOUND12,60 1400 PUTSPRITE1,(X(1)*8,Y(1)*8-9),6,10 1410 FORN=0TO5000:NEXT 1420 GOSUB1610 1430 VI=VI-1 1440 IFVI<0THEN1530 1450 FORN=1TONT 1460 X(N)=OG(N,1):Y(N)=OG(N,2) 1470 FX(N)=OG(N,3):FY(N)=OG(N,4) 1480 P(N)=VPEEK(X(N)+Y(N)*32+6144)-97 1490 PT(N)=P(N)-2*(FX(N)+FY(N))+3 1500 NEXT 1510 GOSUB1820 1520 GOTO460 1530 BEEP:STRIG(JS) OFF 1540 LOCATE10,11:PRINT" " 1550 LOCATE10,12:PRINT" GAME OVER! " 1560 LOCATE10,13:PRINT" " 1570 SOUND7,56:PLAY"V14L32BAGFEDC4" 1580 FORN=0TO2 1590 IFSTRIG(N)THEN300 1600 NEXT:GOTO1580 1610 FORN=0TONT 1620 PUTSPRITEN+1,(0,0),0,N:NEXT 1630 RETURN 1640 CLS:PRINT" SCORE:";FNQ$(PO,5);" BONUS:999 LEVEL:";FNQ$(FA,2) 1650 PRINT" ";STRING$(30,103) 1660 FORN=0TO6 1670 READA$:FORM=0TO9 1680 A=VAL("&H"+MID$(A$,M+1,1)) 1690 LOCATEM*3+1,N*3+2:PRINTP$(A,0) 1700 LOCATEM*3+1,N*3+3:PRINTP$(A,1) 1710 LOCATEM*3+1,N*3+4:PRINTP$(A,2) 1720 NEXTM,N 1730 READNB,NT:FORN=1TONT 1740 FORM=1TO4 1750 READOG(N,M):NEXTM,N 1760 FORN=1TONT 1770 X(N)=OG(N,1):Y(N)=OG(N,2) 1780 FX(N)=OG(N,3):FY(N)=OG(N,4) 1790 P(N)=VPEEK(X(N)+Y(N)*32+6144)-97 1800 PT(N)=P(N)-2*(FX(N)+FY(N))+3 1810 NEXT 1820 CX=2:CY=3 1830 LOCATE13,1 1840 PRINTSTRING$(VI,106);CHR$(103) 1850 MU=0:GOSUB1260 1860 STRIG(JS)ON 1870 ONSTRIGGOSUB1090,1090,1090 1880 INTERVALON 1890 ONINTERVAL=113GOSUB1260 1900 RETURN 1910 RETURN1920 1920 SCREEN0:KEYON:COLOR15,4:END 1930 DATA 00,00,00,00,FF,71,71,71 1940 DATA 7F,7F,7F,7F,FF,1E,0C,00 1950 DATA 00,00,00,00,3C,18,18,FE 1960 DATA FE,FF,FF,FE,FE,78,30,00 1970 DATA 10,1F,1F,3F,7F,7F,3F,1F 1980 DATA 1F,3F,7F,7F,3F,1F,1F,06 1990 DATA 10,F0,F0,F0,10,10,10,F0 2000 DATA 80,80,90,F0,F0,90,80,00 2010 DATA 02,07,0F,1E,3C,FE,FF,7F 2020 DATA 3F,7F,6F,07,03,07,06,00 2030 DATA 00,00,80,C0,60,30,64,C6 2040 DATA EF,FC,F8,FC,FC,F8,F8,60 2050 DATA 00,01,03,00,04,0E,1B,31 2060 DATA 63,F7,7F,3F,1F,0F,07,06 2070 DATA 80,80,D8,FE,7E,FF,FF,FE 2080 DATA FC,FE,F6,E0,C0,E0,60,00 2090 DATA 00,00,00,00,3C,18,18,7F 2100 DATA 7F,7F,FF,7F,7F,1E,0C,00 2110 DATA 00,00,00,00,FF,8E,8E,BE 2120 DATA FE,FE,FE,FE,FE,78,30,00 2130 DATA 06,1F,1F,3F,7F,7F,3F,1F 2140 DATA 1F,3F,7F,7F,3F,1F,1F,10 2150 DATA 00,80,90,F0,F0,90,80,80 2160 DATA F0,10,10,10,F0,F0,F0,10 2170 DATA 01,01,1B,7F,7E,FF,FF,7F 2180 DATA 3F,7F,6F,07,03,07,06,00 2190 DATA 00,80,C0,00,20,70,D8,8C 2200 DATA C6,EF,FE,FC,F8,F0,E0,60 2210 DATA 00,00,01,03,06,0C,26,63 2220 DATA F7,3F,1F,3F,3F,1F,1F,06 2230 DATA 40,E0,F0,78,3C,7F,FF,FE 2240 DATA FC,FE,F6,E0,C0,E0,60,00 2250 DATA FF,FF,C0,C0,C0,C0,C0,C0 2260 DATA C0,C0,C0,C0,C0,C0,FF,FF 2270 DATA FF,FF,03,03,03,03,03,03 2280 DATA 03,03,03,03,03,03,FF,FF 2290 DATA 08,0F,0F,07,07,07,1F,7F 2300 DATA FF,1F,03,03,07,07,0C,08 2310 DATA 01,03,07,0E,1E,FC,FC,F8 2320 DATA FC,FE,FF,F8,F8,38,18,08 2330 DATA 22,FF,22,22,22,22,FF,22 2340 DATA 42,42,FF,42,42,42,FF,42 2350 DATA 08,0F,1C,24,E2,72,4D,42 2360 DATA 10,F0,38,24,47,4E,B2,42 2370 DATA 42,B2,4E,47,24,38,F0,10 2380 DATA 42,4D,72,E2,24,1C,0F,08 2390 DATA 00,00,00,00,00,00,00,00 2400 DATA 42,FF,42,42,42,42,FF,42 2410 DATA 00,22,14,08,1C,2A,08,08 2420 DATA 00,38,2A,3F,3F,12,00,00 2430 DATA 60,78,7E,78,60,40,40,40 2440 DATA ggg,aaa,ggg 2450 DATA gbg,gbg,gbg 2460 DATA ggg,gca,gbg 2470 DATA ggg,adg,gbg 2480 DATA gbg,aeg,ggg 2490 DATA gbg,gfa,ggg 2500 DATA ggg,aca,gbg 2510 DATA gbg,adg,gbg 2520 DATA gbg,aea,ggg 2530 DATA gbg,gfa,gbg 2540 DATA gbg,aca,gbg 2550 DATA ggg,ggg,ggg 2560 DATA gbi,aha,gbg 2570 DATA gpg,aaa,ggg 2580 DATA gbg,gbp,gbg 2590 DATA BD00060D03,20600A3BE1,1B1BB15041,1BE20C00D1,1B5C07BBB1,1BB5080007,5000000D04 2600 DATA 6,2,17,21,-1,0,23,12,-1,0 2610 DATA 2006000003,E20A00003E,11B1EBBBE1,9C08CD60C7,11BB1B1B11,150080A041,500D008004 2620 DATA 6,2,8,21,-1,0,23,6,-1,0 2630 DATA 2600000D23,11206D0311,1112C03111,E1111B1111,1E158D4111,1580000C41,50000008D4 2640 DATA 6,3,14,21,1,0,8,3,1,0,23,12,0,1 2650 DATA 2060606063,1BEBEB1B11,90A0CDA07E,1B1B1B90CD,90ADA0C07E,1B1B1B1B11,5080808084 2660 DATA 7,3,14,18,0,-1,21,21,1,0,11,3,-1,0 2670 DATA 26D6666063,9C0CACCDC7,9CDCCCC0C7,9C0CCACDC7,9CDCCCC0C7,9C0CCCCDA7,58D8888084 2680 DATA 7,3,20,17,0,-1,15,9,1,0,8,18,-1,0 2690 DATA 2320D06003,1E12008031,9CAC06D3E1,11150A0CC7,11500C0411,E5000A0041,50000800D4 2700 DATA 6,4,8,21,1,0,26,15,0,1,2,15,0,1,14,9,-1,0 2710 DATA BEB1B2DB1B,0A0C0800CD,B1B1B200CD,2C0A0A00A0,11B1BEBB1B,11B1B1BB1B,E50808008D 2720 DATA 7,4,2,15,0,-1,2,18,0,1,29,21,-1,0,23,6,-1,0 2730 DATA 200000600B,900000C003,1D0060C0DE,9000A0A0D0,1D0080C0DE,9000008004,50000000DB 2740 DATA 8,4,26,3,-1,0,12,3,1,0,23,9,-1,0,12,18,1,0 2750 DATA B20DEED03B,B1D0AA0D1B,DA0D1ED0AD,DA00A000AD,DA0D1ED0AD,B1D0AA0D1B,B50DEED04B 2760 DATA 24,3,20,12,1,0,9,12,1,0,23,21,-1,0 2770 DATA 2000000003,1200000D67,11B2000311,11DC000711,1908000411,150000004E,5000000004 2780 DATA 3,4,29,15,0,-1,17,6,-1,0,14,12,-1,0,17,15,1,0
Have you played Level 3 yet? I'm pretty sure it's impossible as there doesn't seem to be time to move the cursor to where it needs to be before the trains collide - maybe this is due to the sluggishness of my keyboard...
Thaaaank yooou sssooo much!!! You are the best!! Concerning the keyboard input can we give the player a choice in the main menu to select between joystick/keyboard? I have the feeling this type of game should be joystick exclusive. But I prefer to give the player a choice using the keyboard in case they don’t have joystick yet but gives a chance for the player to try it out.
I disabled the music for me!! I cannot have that repeating endlessly!! - hits head with hammer - That is a torture chamber. But that is my version of the game...if someone else enjoying the constant repetitious tortures music of that train without any problem..please go for it.