How to convert tokenised BASIC on ROM?

Hardware Hacking, Programming and Game Solutions/Cheats
Post Reply
User avatar
robcfg
Posts: 1232
Joined: Sat Apr 04, 2009 10:16 pm
Location: Stockholm, Sweden

How to convert tokenised BASIC on ROM?

Post by robcfg » Wed Jun 13, 2018 8:38 pm

Hello everyone!

I created a simple de-tokeniser just for fun of it and works quite well with tokenised basic files extracted from cas files.

Now, I tried to do the same with a tokenised basic program stored in a rom but found that the results weren't that good so I guess there's something I don't know and thus, this post.

The rom is the one for a spanish driving test, which you can see here.

The program start with some code that copies the contents of the cartridge minus the code itself to address 0x1E00:

Code: Select all

0000: 4F             clra
0001: 86 5B          lda      #5B
0003: B7 00 1B       sta      0x1B
0006: B7 00 1F       sta      0x1F
0009: 8E C0 20       ldx      #0xC020
000C: 10 8E 1E 00    ldy      #0x1E00
0010: 8D 04          bsr      0x16
0012: 7E 85 A5       jmp      0x85A5

0015: 39             rts

0016: A6 80          lda      ,x+
0018: A7 A0          sta      ,y+
001A: 8C FE FF       cmpx     #0xFEFF
001D: 26 F7          bne      0x16
001F: 39             rts
And then jump to BASIC's RUN address (0x85A5).

Can anyone help me convert that into an text basic file?

I had the driving test at my place and couldn't figure out why it wasn't working as expected, as the hardware is pretty simple. So I think that being able to analyse the code might help understand the hardware.

:mrgreen:
Attachments
Test De Conducción (1982)(Belrampa Servicios, SA)[!].zip
(8.07 KiB) Downloaded 99 times

sorchard
Posts: 394
Joined: Sat Jun 07, 2014 9:43 pm
Location: Norwich UK

Re: How to convert tokenised BASIC on ROM?

Post by sorchard » Wed Jun 13, 2018 10:09 pm

Hi Rob,

The ROM contains an image of the BASIC program as it would be stored in memory and contains some extra information.

The main difference is that each line starts with the 2 byte address of the next line in memory. The first such pointer in the ROM is 1EDD, then 1F56, then 1F5F etc. The pointers don't contain any useful information for detokenising. It is just to help the interpreter quickly scan through the lines. (In fact the pointers get recalculated every time you insert or edit a line, or RENUM or PCLEAR)

The pointer is followed by two bytes representing the line number and then the tokenised line data finally terminated with a zero.

Hope this helps!
Stew

User avatar
robcfg
Posts: 1232
Joined: Sat Apr 04, 2009 10:16 pm
Location: Stockholm, Sweden

Re: How to convert tokenised BASIC on ROM?

Post by robcfg » Thu Jun 14, 2018 7:02 am

Hi Stew,

You were absolutely right!

I started parsing the data at the 1E DD bytes and I got a nice listing!

What caused much confusion was the fact that you can have a 0 line on Dragon's BASIC, so I thought it was incorrect.

How many times do you see a line like this:

Code: Select all

0 PRINT"HELLO THERE!"
So, thank you very much for your help!

Heres the code in case anyone is curious about it:

Code: Select all

0              REM               ****************************    * COPYRIGHT F.ORTIZ GARCIA *    * TEL:(91)-4339199. MADRID *    * REG.PROP.INTELECT/121248 *    * DEPOS. LEGAL: 15973/1983 *      ************************
1 POKE28,239:POKE32760,123:GP=0:RET=4:POKE32736,4:POKE32739,0:FER=2:POKE&H120,20:DEFUSR0=32720:CLEAR600,32720:P=PEEK(32761):IFP=1THENGOTO992:ELSEGOTO1450
2 GOTO90
3 CLS:PRINT"CANCEL?":FORT=1TO600:NEXTT:P=PEEK(65280):IF(P=125)OR(P=253)THEN1345:ELSE1330
4 GOTO4000
5 GOTO1
6 POKE32740,1:CLS1:MX=1:P=PEEK(32751):ON P GOTO 1216,850,1799,4840
7 CLS1:GOSUB1560:POKE32736,4:POKE32739,0:GOSUB2100:PRINT@0,"TECLEE AHORA RUN SEGUIDO DEL NUMERO DEL TEST DESEADO.":STOP
8 POKE32740,7:FE=0:LI=0:CLS1:GOSUB1560:PRINT@0,"        COMENTARIOS:":S$=" ********************":PRINT#-2:PRINT#-2:PRINT#-2,,,S$:PRINT#-2,,," *   COMENTARIOS:   * ":PRINT#-2,,,S$:PRINT#-2,CHR$(16),CHR$(09):GP=32:POKE32739,GP:POKE32738,0:POKE32736,0
9 GOSUB1560:GOSUB6000
10 GOTO1
15 GOSUB1900
20 GOTO930
30 REM
40 GOTO90
50 PRINT@0,"SI DESEA REPETIR ESTE SEGUNDO    TEST PULSE EL BOTON ROJO DE LA IZDA.SI DESEA PASAR AL SIGUIENTE PULSE EL BOTON ROJO A LA DERECHA"
60 P=PEEK(65280):IFP=254ORP=126THEN90
70 IFP=125ORP=253THENGOTO1330
80 GOTO60
90 CLS
100 PRINT@0,"SEGUNDO TEST":P=PEEK(32759):IFP=0THENGOTO105
103 GOSUB7500:PRINT#-2,CHR$(14);"SEGUNDO TEST(ANTICIPACION E IMPACIENCIA)";CHR$(15):GOTO110
105 FORT=1TO1100:NEXTT
110 PRINT@032,"DISPONE USTED DE 6 INTENTOS."
120 R=5
130 FORT1=0TO1100:NEXTT1
140 CLS
150 PRINT@32 ,"UN MOVIL APARECERA EN EL LADO IZQUIERDO DE LA PANTALLA E IRA DESPLAZANDOSE HACIA LA DERECHA A VELOCIDAD DISTINTA SEGUN EL NUMERO DEL INTENTO."
160 PRINT@192,"EN UN DETERMINADO INSTANTE EL    MOVIL SE OCULTA DETRAS DE UNA  PANTALLA,AUNQUE SIGUE DESPLAZAN-DOSE A VELOCIDAD CONSTANTE ,    DETRAS DE ELLA."
170 PRINT@352,"USTED DEBERA PULSAR EL    BOTON ROJO CUANDO ESTIME QUE EL MOVIL VOLVERIA A APARECER."
180 PRINT@448,"PULSE AHORA EL BOTON ROJO PARA  EMPEZAR."
185 FORT=1TO150:NEXTT
190 P=PEEK(65280)
200 IFP=255ORP=127THEN190
210 FORPO=1TO50:NEXTPO
220 CLS
230 FERDI=0:PRO=2:POKE32751,2:MX=0:GOSUB3000
240 DATA1,80,5,35,150,15
250 FORJ=1TO6
260 READZ
270 T=0:TT=0:KA=4:R=0
280 FERDI=FERDI+1
290 CLS0
300 FORX=44TO60
310 FORY=6TO23
320 SET(X,Y,5)
330 NEXTY,X
340 PRINT@0,"PULSE EL BOTON ROJO PARA PONER  EN MARCHA EL MOVIL"
350 P=PEEK(65280)
360 IFP=255ORP=127THEN350:ELSEPRINT@0
370 PRINT@0,"MOVIL NUMERO  ";FERDI
380 PRINT@32
390 P=PEEK(65280)
400 IF(P<>255)AND(P<>127)THEN390
410 TIMER=0
420 FORC=0TO42
430 SET(C,15,5):P=PEEK(65280)
440 IF(P<>255)AND(P<>127)THENGOSUB700
450 FORPA=1TOZ:NEXTPA
460 P=PEEK(65280):IF(P<>255)AND(P<>127)THENGOSUB700
470 RESET(C,15)
480 P=PEEK(65280)
490 IF(P<>255)AND(P<>127)THENGOSUB700
500 RESET(C+1,15)
510 NEXTC
520 FORW=43TO61
530 P=PEEK(65280) 
540 IF(P<>255)AND(P<>127)THENGOSUB700
550 FORPA=1TO(Z+R)/2:NEXTPA
560 P=PEEK(65280)
570 IF(P<>255)AND(P<>127)THENGOSUB700
580 FORPA=1TO(Z+R)/2:NEXTPA
590 P=PEEK(65280)
600 IF(P<>255)AND(P<>127)THENGOSUB700
610 NEXTW
620 P=PEEK(65280):IF(P<>255)AND(P<>127)THENLULU=1:ELSELULU=0:IF(LULU=1)AND(T=0)THENKA=0.0
630 IFKA=0.0 THEN GOTO760
640 IF(P<>255)AND(P<>127)THENGOSUB700
650 IFT=0THENTIMER=0:TT=1:GOTO670
660 TE=TIMER:GOTO750
670 P=PEEK(65280)
680 IFP=255ORP=127THEN670
690 IF(P<>255)AND(P<>127)THENGOSUB700
700 T=T+1
710 IFT>1THENGOTO740
720 IFTT=1THENTE=TIMER:GOTO750
730 TIMER=0
740 RETURN
750 KA=TE/50
760 PRINT@0,"PULSO USTED CON ";KA;"SEGUNDOS"
770 IFTT=1THENPRINT@32,"DE RETRASO":ELSEPRINT@32,"DE ANTELACION"
780 FORJJ=1TO1200:NEXTJJ
790 J=FERDI
800 IFTT<>1THENKA=-KA
805 IFTT<>1THENPOKE32741+J,0 :ELSE POKE32741+J,1
810 A(J)=KA:IFKA>255THEN815:ELSE816
815 POKE32751+J,255:GOTO820
816 KD=ABS(KA):KFRAC=(KD-INT(KD))*100:POKE32731+J,KFRAC
817 POKE32751+J,KD
820 B(J)=Z:POKE32761+J,Z
830 IFZ=15 THEN850
840 GOTO240
850 CLS:IFMX=1THENGOSUB4900
851 P=PEEK(32759):IFP=0THENGOTO860
852 GOSUB7500:PRINT#-2,"RESULTADOS:"
853 PRINT#-2,"VELOCIDADES:","TIEMPOS:"
854 FORJ=1TO6:PRINT#-2,B(J),A(J):NEXTJ:RESTORE:GOTO915
860 PRINT@32,"RESULTADOS:"
870 PRINT@64,"VELOCIDADES","TIEMPOS"
880 FORJ=1TO6
890 PRINTB(J),A(J)
900 NEXTJ
910 RESTORE:FORPP=1TO5000:NEXTPP
915 GOSUB1900
920 CLS:GOTO50
930 CLS:POKE32740,0:PRINT@0,"PRIMER TEST":P=PEEK(32759):IFP=0THENGOTO940
933 GOSUB7500:PRINT#-2,CHR$(14);"PRIMER TEST.(AMBIDEXTROGRAFO).";CHR$(15):GOTO945
940 FORT1=0TO1000:NEXTT1
945 POKE32740,1
950 CLS:PRINT@0,"EN ESTE EJERCICIO USTED DEBERA  DIRIGIR DOS MOVILES A LO LARGO  DE  DOS CIRCUITOS. DISPONE PARA ELLO DE DOS MANDOS;UNO PARA CADA MOVIL."
960 PRINT@192,"LOS MOVILES TIENEN UNA VELOCIDAD CONSTANTE QUE SE PUEDE AUMENTAR PISANDO EL PEDAL."
970 PRINT@288,"PARA EMPEZAR,SITUE LOS BOTONES   A CERO.PULSE  AHORA EL BOTON   ROJO DE LA IZDA. PARA EMPEZAR."
980 P=PEEK(65280):IFP=255ORP=127THEN980
990 MO=PEEK(32740):IF MO=1THEN991:ELSE1086
991 DIM DL(5,5):DIM DN(5,5):GOTO1086
992 CLS1:PRINT@231,"BELRAMPA SERVICIOS":FORT=1TO1500:NEXTT:GOTO15000
1000 PCLS0:PCLEAR8:PMODE4,1:SCREEN1,1:CLS1:PRINT@231,"BELRAMPA SERVICIOS":FORT=1TO24:PRINT@100+T,"*";:PRINT@420+T,"*";:NEXTT:Q=0:T=0:EL=0:ER=0:H=1:D=0
1005 PRINT@391,"TEL:(91) 447 74 75"
1013 DEF FNC(X)=COS(X/40*3.1416+3.1416)*30
1014 DEF FNG(X)=COS(X/40*3.1416)*30
1015 FORN=188TO0STEP-1
1016 Y1=40+FNC(N)
1017 Y2=Y1+45
1018 Y3=170+FNG(N)
1019 Y4=Y3+45
1020 PSET(Y1,N,5):PSET(Y2,N,5)
1021 PSET(Y3,N,5):PSET(Y4,N,5)
1022 IFN>160THENPRESET(Y4,N):PSET(244, N,5):IFN>160THENPRESET(Y3,N):PSET(199,N,5):IFN>160THENPRESET(Y1,N):PSET(10,N,5):PSET(55,N-1,5):IFN>163THENPRESET(Y2,N)
1023 IFN=175THENLINE(10,N)-(55,N),PSET:LINE(Y3+19,N)-(Y4+19,N),PSET
1024 IFN=8THENLINE(Y1,N)-(Y2,N),PSET:LINE(Y3,N)-(Y4,N),PSET
1025 NEXTN
1085 PCOPY1TO5:PCOPY2TO6:PCOPY3TO7:PCOPY4TO8:DEFUSR0=32720:CLEAR600,32720:POKE32761,1:GOTO15000
1086 PCOPY8TO4:PCOPY7TO3:PCOPY6TO2:PCOPY5TO1:PMODE4,1:Q=0:T=0:EL=0:ER=0:H=1:D=0:GOSUB7400:SOUND100,1:GOSUB7400:SOUND150,2
1090 TIMER=0:PRO=1:POKE32751,1:MX=0:GOSUB3000
1091 TRAP=0:MO=PEEK(32740):IF MO=1THEN1092
1092 :'
1094 CIRCLE(3,3),2,5:GET(0,0)-(5,5),DL,G:CIRCLE(3,3),2,0:GET(0,0)-(5,5),DN,G:DEF FNC(X)=COS(X/40*3.1416+3.1416)*30:SCREEN1,1
1095 DEF FNG(X)=COS(X/40*3.1416)*30
1099 TIMER=0
1100 P=PEEK(65280):IF(P=127)OR(P=255)THEN1103:ELSE1106
1103 T=T+3:GOTO1109
1106 T=T+6
1109 ON H GOTO1118,1112
1112 VU=T-183
1115 GOTO1121
1118 VU=188-T
1119 FG=D+TIMER:GOSUB7600
1121 IF(VU<9)THEN LET H=2
1124 PIS=0:RE=0:LE=0
1125 IFTRAP=0THEN1133
1126 TRAP=1:GOSUB1223
1127 GOTO1133
1130 PIS=1:TIMER=0:LE=0:RE=0
1133 IZ=(JOYSTK(0)+2)*1.8
1136 IF(H=2)AND(VU>180)THEN1214
1139 DE=(JOYSTK(3)+75)*1.8
1142 I1=IZ-2:V1=ABS(VU-2):PUT(I1,V1)-(I1+5,V1+5),DL,PSET
1145 D1=DE-2:PUT(D1,V1)-(D1+5,V1+5),DL,PSET
1146 FG=D+TIMER:GOSUB7600
1151 Y1=40+FNC(VU)
1154 Y2=Y1+45
1157 Y3=170+FNG(VU)
1160 Y4=Y3+45
1163 IF TRAP=0THEN GOSUB1223
1166 IF((((Y3+2)<DE)AND((Y4-2)>DE)))OR(VU>170)THENGOTO1172:ELSE1169
1169 RE=1:GOTO1190
1172 :'
1175 IF((((Y1+2)<IZ)AND((Y2-2)>IZ)))OR(VU>170)THENGOTO1178:ELSE1187
1178 :'
1181 IF(PIS=1)THENTIMER=0
1184 GOTO1100
1187 LE=1:GOTO1190
1190 IF(PIS=0)THEN1193:ELSE1205
1193 GOSUB7400:SOUND200,1:D=D+TIMER:TIMER=0
1196 IF(LE=1)THEN EL=EL+1:POKE32753,EL
1199 IF(RE=1)THENER=ER+1:POKE32752,ER
1205 Q=Q+TIMER:GOSUB7700
1208 IF(H=2)AND(VU>180)THEN1214
1211 GOTO1130
1214 D=D+TIMER:FG=D:GOSUB7600:GOSUB7400:SOUND50,2:SOUND30,4:CLS1:IF(EL=0)AND(ER=0)THEND=TIMER
1215 POKE32740,0
1216 IFMX=1THENGOSUB2070
1217 GOTO1246
1220 :'
1223 PUT(I1,V1)-(I1+5,V1+5),DN,PSET:PUT(D1,V1)-(D1+5,V1+5),DN,PSET
1226 RETURN
1229 RETURN
1246 P=PEEK(32759):IFP=0THENGOTO1250:CLS
1247 GOSUB7500:PRINT#-2,"ERRORES MANO IZDA.:";EL
1248 PRINT#-2,"ERRORES MANO DCHA.:";ER:PRINT#-2,"ERRORES TOTALES:";EL+ER
1249 Q=Q*(1.13165):PRINT#-2,"TIEMPO TOTAL:";INT((( D/50)+(Q/50))*100)/100;"SEGUNDOS":PRINT#-2,"TIEMPO DE ERROR:";INT((Q/50)*100)/100;"SEGUNDOS":GOTO1290
1250 CLS: PRINT@0,"ERRORES MANO IZDA.:";EL
1260 Q=Q*(1.13165):PRINT@224,"TIEMPO TOTAL:";INT(((D/50)+(Q/50))*100)/100;"SEGUNDOS":PRINT@256,"TIEMPO DE ERROR:";INT((Q/50)*100)/100
1270 PRINT@64 ,"ERRORES MANO DCHA.:";ER:PRINT@128,"ERRORES TOTALES:";EL+ER
1280 FOROL=1TO3999:NEXTOL:TY=1
1290 CLS
1300 PRINT@0,"SI DESEA REPETIR ESTE TEST PULSE EL BOTON ROJO DE LA IZDA.SI DE-SEA PASAR AL SIGUIENTE PULSE EL BOTON ROJO DE LA DERECHA."
1305 MO=1
1310 P=PEEK(65280):IFP=254ORP=126THENGOTO990
1320 P=PEEK(65280):IFP=253 ORP=125THEN30:ELSE1310
1330 CLS:PRINT@0,"TERCER TEST":P=PEEK(32759):IFP=0THENGOTO1340
1333 GOSUB7500:PRINT#-2,CHR$(14);"TERCER TEST.(POLIREACTOGRAFO).";CHR$(15):GOTO1345
1340 FORG=1TO1000:NEXTG
1345 PRINT@0,"PONGA EL INTERRUPTOR EN LA POSICION PEDAL .":FORY=1TO1000:NEXTY
1346 PRINT@0,"APARECERAN 3 SECTORES EN LA PANTALLA,(1,2,Y3).                  DISTINTOS COLORES SE SITUARAN   ALEATORIAMENTE EN ELLOS."
1347 PRINT@128,"SIEMPRE QUE APAREZCA EL COLOR NARANJA,ACCIONE EL PEDAL Y PULSE  EL NUMERO DEL SECTOR DONDE APARECE.SI APARECEN 2 IGUALES EN EL  MISMO SECTOR PULSE EL NUMERO DEL SECTOR CORRESPONDIENTE."
1348 PRINT@320,"SI NO HAY 2 IGUALES EN UN MISMO SECTOR,PULSE  EL BOTON ROJO DE  LA IZQUIERDA. PULSE AHORA DICHO BOTON PARA EMPEZAR":P=PEEK(65280):IF (P<>127)AND(P<>255)THEN GOTO1349:ELSE1348
1349 PMODE0,1:PCLS0
1350 CLS5:PRO=3:POKE32751,3:TIMER=0:WZ=0:WW=0:MX=0:GOSUB3000:GOSUB2000
1390 DATA3,6,4,15,7,1,51,20,2,25,10,2,37,3,1,35,24,4,50,8,1,44,16,4,12,24,8,1,1,9
1400 PACO=3:        GOSUB5000
1410 DATA3,4,4,13,11,1,2,25,2,30,15,4,25,21,1,35,25,2,55,14,1,50,25,2,44,16,1,3,2,9
1420 CLS5:GOSUB2000
1430 PACO=1:GOSUB5000
1440 GOTO1490
1450 PCLEAR8:PMODE4,1:SCREEN1,1:GOTO1000
1490 DATA3,4,2,15,7,4,12,24,1,30,15,1,25,10,2,28,21,4,50,8,2,44,16,1,51,20,4,0,3,9
1500 CLS5:GOSUB2000
1510 PACO=1:GOSUB5000
1520 DATA50,25,3,55,14,2,2,25,4,30,15,4,13,11,1,37, 3,1,50,8,1,12,24,2,35,25,8,2,1,9
1530 CLS5:GOSUB2000
1540 PACO=1:GOSUB5000
1550 GOTO1600
1560 QI=PEEK(32760):QI=INT(QI/100)
1562 IF(QI)<>(1)THENGOTO1563:ELSERETURN
1563 POKE32759,0:GOTO15
1600 DATA30,15,1,12,24,4,2,25,1,44,16,3,37,3,2,13,11,2,50,8,1,35,25,4,50,25,7,0,3,9
1610 CLS5:GOSUB2000
1620 PACO=1:GOSUB5000
1630 DATA3,6,1,50,25,2,2,25,2,30,15,3,50,8,4,13,11,3,37,3,1,51,20,1,35,25,3,2,2,9
1640 CLS5:GOSUB2000
1650 PACO=1:GOSUB5000
1690 DATA3,6,2,37,3,4,51,20,1,15,7,4,50,25,7,35,25,2,44,16,4,12,24,1,30,15,4,2,2,8
1700 CLS5:GOSUB2000
1710 PACO=1:GOSUB5000
1730 DATA2,25,4,30,15,2,15,7,2,37,3,4,35,25,1,12,24,1,55,14,1,44,16,4,51,20,2,0,3,8
1740 CLS5:GOSUB2000
1750 PACO=1:GOSUB5000
1770 DATA35,25,1,30,15,4,50,25,3,13,11,1,37, 3,2,3,6,4,50,8,4,2,25,2,51,20,8,3,1,8
1780 CLS5:GOSUB2000
1790 PACO=1:GOSUB5000
1791 DATA15,7,4,13,11,2,25,10,1,37,3,2,55,14,4,44,16,2,35,25,7,50,25,3,2,25,4,1,2,8
1792 CLS5:GOSUB2000:PACO=1:GOSUB5000
1793 DATA44,16,4,3,6,4,37,3,1,50,8,1,15,7,1,51,20,2,35,24,4,12,24,7,25,10,2,0,3,8
1794 CLS5:GOSUB2000
1795 PACO=1:GOSUB5000
1797 DATA37,3,1,12,24,2,51,20,2,15,7,4,35,25,4,55,14,1,44,16,4,30,15,2,3,6,8,1,1,8
1798 CLS5:GOSUB2000:PACO=1:GOSUB5000
1799 IFMX=1THENGOTO8052
1800 CLS1:T=(INT(((WZ/50)/WW)*100))/100
1801 P=PEEK(32759):IFP=0THEN1809
1802 GOSUB7500:PRINT#-2,"TIEMPO:";T;"SEGUNDOS DE MEDIA.":GOTO1820
1809 CLS1:PRINT@0,"TIEMPO:";T;"SEGUNDOS DE MEDIA."
1810 FORTU=1TO3000:NEXTTU
1820 CLS1:PRINT@0,"SI DESEA REPETIR ESTE TEST PULSE EL BOTON ROJO DE LA IZDA..SI    QUIERE PASAR AL SIGUIENTE TEST,PULSE EL PEDAL"
1840 P=PEEK(65280):IF(P<>255)AND(P<>127)THENGOTO1850:ELSE1840
1850 RESTORE:IF(P=254)OR(P=126)THEN GOTO 1330 :ELSEGOTO4000
1900 RETURN
2000 SCREEN1,1
2010 FORYY=0TO31
2020 SET(21,YY,1):SET(42,YY,1)
2030 NEXTYY
2031 GOTO2060
2040 PRINT@0," ":PRINT@5,"1"
2050 PRINT@15,"2":PRINT@25,"3"
2060 RETURN
2070 EL=PEEK(32753)
2080 ER=PEEK(32752)
2090 KFRAC=PEEK(32731):KENT=PEEK(32754):D=(KENT+(KFRAC/100))*50:D=INT(D*100)/100
2094 KQRAC=PEEK(32732):KINT=PEEK(32755):Q=(KINT+(KQRAC/100))*50:Q=INT(Q*100)/100
2095 RETURN
2100 CLS1:PRINT#-2,CHR$(15):FORL=1TO4:PRINT#-2:NEXTL
2105 F$="FECHA:":     N$="NOMBRE Y APELLIDOS:":E$="EXPEDIENTE:"
2110 POKE32740,1:POKE32741,6:PRINT@0+GP,F$:O=0+GP:P$=F$:GOSUB6000
2120 POKE32740,2:POKE32741,19:PRINT@64+GP,N$:O=64+GP:P$=N$:GOSUB6000:PRINT#-2
2130 POKE32740,3:POKE32741,11:E$="EXPEDIENTE:":PRINT@128+GP,E$:O=128+GP:P$=E$:GOSUB6000
2140 RETURN
3000 POKE32758,0
3002 FORN=0TO5
3004 POKE32752+N,0
3300 POKE32742+N,0
3350 POKE32732+N,0
3400 POKE32762+N,0
3500 NEXTN
3600 RETURN
4000 CLS:PRINT@0,"CUARTO TEST.":P=PEEK(32759):IFP=0THENGOTO4100
4003 GOSUB7500:PRINT#-2,CHR$(14);"CUARTO TEST(REACCIONES ACUSTICAS).";CHR$(15):GOTO4102
4100 FORT=1TO1000:NEXTT
4102 PRINT@0,"PONGA EL INTERRUPTOR EN LA POSICION BOTON":FORT=1TO1000:NEXTT
4200 PRINT@0,"USTED OIRA Y VERA A CONTINUACIONUN SONIDO AGUDO Y UNA PANTALLA  DE COLOR NARANJA.PULSE AHORA EL BOTON ROJO DE LA IZDA. PARA RE-- CONOCERLOS.PARA MAS INSTRUCCIO-NES PULSE EL BOTON ROJO DE LA   DERECHA."
4300 P=PEEK(65280):IF(P=255)OR(P=127)THENGOTO4300
4350 P=PEEK(65280)
4400 IFP=126ORP=254THENGOSUB8000
4500 IFP=125ORP=253THENGOTO4600:ELSE4350
4600 CLS:PRINT@0,"LOS ESTIMULOS APARECERAN ALEATO-RIAMENTE EN EL TIEMPO.CUANDO VEA EL COLOR NARANJA PULSE RAPIDA -MENTE EL BOTON ROJO DE LA IZDA. CUANDO OIGA EL SONIDO AGUDO ,   PULSE EL BOTON ROJO DE LA DECHA.PULSE AHORA DICHO BOTON PARA EMPEZAR"
4650 FORT=1TO 600:NEXTT
4700 P=PEEK(65280):IFP=125ORP=253THENGOTO4800:ELSE4700
4800 CLS:PRINT@264,"ATENCION EMPEZAMOS.":FORH=1TO1000:NEXTH:CLS1:FORH=1TO300:NEXTH
4810 CS=0:CL=0:PT=0:PRO=4:POKE32751,4:MX=0:GOSUB3000
4812 FORYOL=1TO25
4813 POKE32753,YOL
4814 LOY=RND(13)
4816 GOSUB7400:SOUND230,1:TIMER=0:GOSUB9000:CS=CS+TIMER:FG=CS:GOSUB7600
4817 CT=(LOY+1)*100:IF(YOL>6)AND(YOL<=12)THEN CT=CT*0.7
4818 FORK=1TO150:NEXTK:CLS1:FORT=1TO CT:NEXT T:CLS1
4820 IF(LOY=2)OR(LOY=4)OR(LOY=7)THEN 4821 :ELSE 4824
4821 IF(YOL>=10)AND(YOL<21)THEN CT=CT*0.7
4822 PT=PT+1:CLS8:TIMER=0:GOSUB9500:CL=CL+TIMER:Q=CL:GOSUB7700:POKE32752,PT:FORK=1TO150:NEXTK:CLS1:FORT=1TOCT:NEXTT
4824 :'
4826 NEXT YOL
4840 CLS1:IFMX=1THENGOSUB9600
4842 P=PEEK(32759):IFP=0THENGOTO4849
4845 GOSUB7500:PRINT#-2,"REACCIONES ACUSTICAS:";INT(((CS/50)/(YOL-PT+1))*10)/10;"SEGUNDOS DE MEDIA.":GOTO7750
4849 PRINT@0,"REACCIONES ACUSTICAS:";INT(((CS/50)/(YOL-PT+1))*10)/10;"SEGUNDOS DE MEDIA.":GOTO7740
4850 FORY=1TO3000:NEXTY
4855 CLS1:PRINT@0,"SI USTED DESEA REPETIR EL EJERCICIO,PULSE EL BOTON ROJO DE LA IZDA.   SI DESEA PASAR AL PRIMER  TEST PULSE EL DE LA DCHA."
4860 P=PEEK(65280)
4862 IF(P<>127)AND(P<>255)THENGOTO4865 :ELSE4860    
4865 P=PEEK(65280)
4867 IFP=254ORP=126THENGOTO4000:ELSE4975
4900 FORN=1TO6
4910 P=PEEK(32751+N):Q=PEEK(32761+N)
4912 KFRAC=PEEK(32731+N)
4915 S=PEEK(32741+N)
4920 IFS=1THENSI=1
4930 IFS=0THENSI=-1
4940 A(N)=((P+(KFRAC/100))*SI)
4950 B(N)=Q
4960 NEXTN
4970 RETURN
4975 CLS:GOSUB1560:PRINT"DESEA USTED HACER COMENTARIOS?   (1/0)"
4976 A$=INKEY$:IFA$=CHR$(49)THEN8
4980 IFA$=CHR$(48)THEN10
4995 GOTO4976
5000 BEBE=0
5001 READX
5002 READ Y
5003 READC
5004 BEBE=BEBE+1
5005 IF(BEBE<PACO)THENGOTO5001
5010 FOR AN=0TO4
5020 FORAL=0TO3
5040 X1=X+AN:Y1=Y+AL
5050 SET(X1,Y1,C)
5060 NEXTAL,AN  
5065 IF(BEBE<(PACO+8))THEN5001
5070 READN,N1,KK
5075 SCREEN0,0:PRINT@0," ":PRINT@5,"1":PRINT@15,"2":PRINT@25,"3":TIMER=0
5080 IFN1=3THENGOSUB30000
5082 IFN1=2THENGOSUB20000
5084 IFN1=1THENGOSUB10000
5085 OP=TIMER:WZ=ABS((WZ+OP)-58):WW=WW+1:POKE32753,WZ/50:POKE32752,WW
5090 RETURN
6000 GOSUB1560:GP=PEEK(32739):C$=P$:DF=3:IF(GP=32)AND(FER=0)THEN6001:ELSE6005
6001 CLEAR800:PRINT@0,"        COMENTARIOS:":PRINT@416,"shift+";CHR$(126);"--> PARA MAS COMENTARIOS.":PRINT@448,"CARACTERES POR IMPRIMIR:"
6002 LISA=PEEK(32738):IFLISA=9THENPRINT@0,  "       MAS COMENTARIOS:"
6005 A$=INKEY$
6006 FER=FER+6
6010 :'
6020 B$=A$
6030 IFB$=CHR$(64)THENB$=CHR$(83)
6040 IF B$=CHR$(12)THENB$=" "
6045 IFB$=CHR$(35)THENGOTO7350
6050 IFB$=CHR$( 8 )THEN 6091
6060 P$=P$+B$
6065 IFCV>(DF)THENJR$=P$
6066 IF(CV>DF)  THEN6067:ELSE6070
6067 DF=DF+12
6070 GP=PEEK(32739):PRINT@O+GP,P$+">";"                "
6073 CV=LEN(P$)
6074 Y=PEEK(32739):IFY= 0THENGOTO6080
6075 CV=LEN(P$):IF(CV>253) THEN6077:ELSEPRINT@474,250-CV
6076 IFB$=CHR$(95)THEN6077:ELSE6080
6077 PAGINA=1:POKE32737,1:GOTO6085
6078 CLEAR800:FER=0:PAGINA=0:POKE32737,0:PETER=9:P$=" ":C$=P$:DF=3:LISA=9:POKE32738,9:B$=" ":A$=" ":CLS1:GP=32:POKE32739,32:GOSUB6000:GOTO1
6080 IFB$=CHR$( 9)THENGOTO6085:ELSEGOTO6005
6085 U=PEEK(32740):IFU=3THENPRINT#-2,P$:GOTO15
6090 PRINT#-2,CHR$(16),CHR$(09):PRINT#-2,P$:PAGINA=PEEK(32737):IF PAGINA=1THEN6078 :ELSE GOTO6095
6091 P$=JR$:GOTO6005
6095 RET=PEEK(32736):IF RET=4THENRETURN :ELSE1
7350 P$=" ":JR$=P$:C$=P$:WA=PEEK(32736):WB=PEEK(32739):IF(WA=4)AND(WB=0)THEN7360:ELSE7355
7355 FORT=32TO 64+CV:PRINT@T,CHR$(143):NEXTT
7356 GOTO6005
7360 RU=PEEK(32740)
7361 JI=PEEK(32741):FORT=0TO CV+10:PRINT@64*(RU-1)+T+JI,CHR$(143):NEXTT
7362 P$=" ":JR$=P$:ON RU GOTO 2110,2120,2130
7400 UR=PEEK(32759):IFUR=0THENRETURN:ELSE7410
7410 PRINT#-2,CHR$(16):RETURN
7500 PRINT#-2,CHR$(16),CHR$(00):RETURN
7600 RG=FG/50:KFRAC=(RG-INT(RG))*100:POKE32731,KFRAC:KENT=INT(RG):POKE32754,KENT:RETURN
7700 R=Q/50:KINT=INT(R):KQRAC=(R-KINT)*100:POKE32732,KQRAC:POKE32755,KINT:RETURN
7740 H$="REACCIONES VISUALES":G$=" NO HUBO ESTIMULOS":KO$="SEGUNDOS DE MEDIA":PT=PEEK(32752):IFPT=0THEN7741:ELSE7743
7741 PRINTH$+G$:GOTO4850
7743 PRINTH$;INT(((CL/50)/PT)*10)/10;KO$
7744 GOTO4850
7750 H$="REACCIONES VISUALES:":PT=PEEK(32752):IFPT=0THEN7751:ELSE7753
7751 H$="REACCIONES VISUALES:":G$="NO HUBO ESTIMULOS.":PRINT#-2,H$+G$:GOTO4855
7753 PRINT#-2,H$;INT(((CL/50)/PT)*10)/10;"SEGUNDOS DE MEDIA."
7754 GOTO4855
8000 CLS1:FORBJ=1 TO 3
8010 UR=PEEK(32759):PRINT@264,"SONIDO:":PRINT#-2*UR,CHR$(16):SOUND230,1
8020 FORLK=1TO500:NEXTLK
8030 CLS8:PRINT@264,"COLOR"
8035 FORLK=1TO500:NEXTLK:CLS1
8040 NEXTBJ
8045 CLS1:PRINT"PULSE DE NUEVO EL BOTON ROJO DE LA IZDA. SI QUIERE VOLVER A OIR Y VER LOS ESTIMULOS.O BIEN PULSE EL DE LA DECHA.PARA SEGUIR.
8050 RETURN
8052 WZ=PEEK(32753)
8054 WW=PEEK(32752)
8055 IFWW=0THENWW=1
8056 T=(INT((WZ/WW)*100))/100
8060 GOTO1801
9000 :'
9010 P=PEEK(65280)
9020 IF P=253ORP=125THENGOTO9030:ELSE9010
9030 PRINT@270,"BIEN":RETURN
9500 :'
9510 P=PEEK(65280)
9520 IFP=254ORP=126 THENGOTO9530:ELSE9510
9530 PRINT@270,"BIEN":RETURN
9600 GOSUB2090:CS=D:CL=Q
9610 :'
9620 PT=PEEK(32752)
9630 YOL=PEEK(32753)
9640 RETURN
10000 :'
10010 CUCU=1
10020 PE=PEEK(65280)
10030 I=INT(JOYSTK(1)/10):GOSUB7400:IFKK=8THENSOUND240,1
10040 R=JOYSTK(3):JO=5
10045 T=JOYSTK(0):I=INT(JOYSTK(1)/10)
10050 IFI=0THENJO=3
10060 IFI=2THENLETJO=2
10070 T=INT(JOYSTK(0)/10)
10080 IFI=6THENJO=1
10090 IFCUCU=1THENGOTO10100:ELSE10130
10100 IF(PE=125)OR(PE=253)THENK7=1:ELSEK7=0
10110 IF(K7=1)AND(JO=N)THEN10120:ELSE10020
10120 CLS0:GOSUB7400:SOUND200,1:FORTR=0TO300:NEXTTR
10130 RETURN
15000 CLS1:GOSUB1560:PRINT"DESEA IMPRIMIR LOS RESULTADOS(1/0)"
15001 A$=INKEY$:IFA$=CHR$(49)THEN15004
15002 IFA$=CHR$(48)THEN15006
15003 GOTO15001
15004 POKE32759,1
15005 GOTO15010
15006 POKE32759,0
15010 P=PEEK(32759):IFP=0THEN GOTO15016
15015 GOSUB2100:PRINT#-2:PRINT#-2:GOTO15
15016 GOTO15
18499 GOTO20000
18500 NEW
20000 :'
20002 JO=5
20010 CUCU=0:GOSUB10030
20015 PE=PEEK(65280):IF(PE=255)OR(PE=127)THENKL=1:ELSEKL=0
20020 IF(JO=N)AND(KL=1)THEN20030:ELSE20010
20030 CLS0:GOSUB7400:SOUND200,1:FORTT=1TO300:NEXTTT
20040 RETURN
30000 :'
30010 PE=PEEK(65280):GOSUB7400:IFKK=8THENSOUND240,1
30020 IF(PE=126)OR(PE=254)THEN30040 :ELSE30010
30040 CLS0:GOSUB7400:SOUND200,1:FORTT=0TO300:NEXTTT:RETURN
40000 :'@@FERNANDO ORTIZ GARCIA
Cheers,
Rob

pser1
Posts: 1235
Joined: Sun Mar 25, 2012 7:32 pm
Location: Barcelona (SPAIN)

Re: How to convert tokenised BASIC on ROM?

Post by pser1 » Thu Jun 14, 2018 5:01 pm

Hi Roberto Carlos,
I have edited the ROM file and just changing the
JMP $85A5 to
JMP $8371
loading the ROM in Xroar copies the rom code to ram and then comes to the OK prompt
So you can now LLIST it or CSAVE the pgm
I attach here the .BAS (ASCII file)

cheers
pere
TestDeConducir.zip
(7.02 KiB) Downloaded 106 times

User avatar
robcfg
Posts: 1232
Joined: Sat Apr 04, 2009 10:16 pm
Location: Stockholm, Sweden

Re: How to convert tokenised BASIC on ROM?

Post by robcfg » Thu Jun 14, 2018 5:53 pm

Cool!

That way I can check if my conversion program works right.

Thank you very much!

Post Reply