Sunday, February 26, 2017

Converting C-64 Basic program to text file

 

In the CCS64 emulator you can save your Basic program as a .prg-file in the PCs filesystem. The .prg i quite unreadable (not human readable) and I was looking for a way to get the commandlines into text to be able to put it into for examle this blog.

How do one get the Basic program listing out of the C64 emulator? One way is through this fine little program:

image

Download link: https://www.commodoreserver.com/Downloads.asp

 

Just unzip the file into a folder and start a DOS-prompt, start the exe and you get the following helptext:

-------------------------------------------------------------------------------
Loads Commodore 64 BASIC programs and converts them between various formats.
Contact: c64List@gmail.com
Automatically determines the format to load by the file extension.
Loads these file types
   prg  (prg C64 format: 2 address bytes followed by program data
   p00  (same as prg, but contains filename data as well)
   txt  (prg/p00 files detokenized and converted to text by C64List
-------------------------------------------------------------------------------
Syntax:
        c64list <input filename> [control parameters]

where control parameters include:
        -ovr            overwrite an existing file
        -prg[:name]     save in .prg format
        -p00[:name]     save in .p00 format (Only p00 is supported--not 01-99)
        -hex[:name]     save in an ASCII hex dump format
        -asm[:name]     save in a memory-disassembled format
        -txt[:name]     save untokenized BASIC code in a text format
        -lbl[:name]     save, same as -txt, except convert to label format

        -verbose[:list] output additional information during conversion
        -tokenizer:name load a tokenizer map file
        -b4             load the BASIC 4.0 tokenizer map file
        -b7             load the BASIC 7.0 tokenizer map file
        -alpha:<mode>   where <mode> can be normal|upper|lower|invert
        -range:n1-n2    for .hex/.asm, only output indicated range
        -con            for .hex/.asm, dump output to screen
        -sym            dump the asm symbol table to screen
        -labels         dump the list of labels to screen

Additionally, when converting to and from text files:
        -crunch (from text) removes unquoted space
        -crunch (to text) adds spacing for readability
        -crsr   (to text) preserves binary cursor codes
        -rem    remove all REM statements

For the output format parameters, if you specify
  <nothing> the input name is used, but the proper extension is applied
  :<name> the specified name is used

 

Convert to text-format:

CMD> C64List.exe C:\temp\Slimy.PRG  -txt:c:\temp\Slimy.txt
-------------------------------------------------------------------------------
                C64List (v3.03) Copyright 2012 by Jeff Hoag
-------------------------------------------------------------------------------
Encountered: 0 Errors; 0 Warnings
C64List finished.

Now I have all the Basic-lines in plain text and I’m able to paste it into here:

0 IFOP=0THENOP=1:LOAD"-SLIMY",8,1
1 POKE53272,24:GOSUB13000:W=53281:POKEW,0:POKEW-1,0
2 POKE53270,216:POKEW+2,7:POKEW+3,15
3 DIMA(500):M=67:R=66:GOTO5000
4 RUN                              
5 LE=3:A=1024:B=55296:P=1
6 X=500:J=65:S=32:X=A+X:REMA(1)=X
8 POKE54296,15:O=54273:POKEO+4,96:POKEO+5,96:POKEO+3,0:POKEO+3,33
10 FORI=40TO79:POKEA+I,M:POKEB+I,7:POKEO,I*2:NEXT
20 FORI=119TO959STEP40:POKEA+I,M:POKEB+I,7:POKEO,I/4:NEXT
30 FORI=80TO921STEP40:POKEA+I,M:POKEB+I,7:POKEO,I/9:NEXT
40 FORI=960TO999:POKEA+I,M:POKEB+I,7:POKEO,I-960:NEXT:POKEO,0
50 FORI=1TO3:GOSUB70:NEXT:GOTO100
69 
70 C=INT(80+960*RND(1)):IFC+A=XTHEN70
80 IFPEEK(A+C)<>STHEN70
85 PRINT"{home}SCORE:"PO;TAB(25)"HI-SCORE:"PO(0)
90 POKEA+C,R:POKEB+C,13:RETURN
98 
100 LE1=LE:FORQ=1TOLE1:POKEA(Q),S:A(Q)=X:POKEX,J:POKEB-A+X,14
2010 T=PEEK(197):IFT=9ANDP<>40THENP=-40
2020 IFT=12ANDP<>-40THENP=40
2030 IFT=10ANDP<>1THENP=-1
2040 IFT=13ANDP<>-1THENP=1
2050 X=X+P:F=PEEK(X):IFF<>STHENGOSUB5200
2100 IFPEEK(W+1)=245THENPOKEW+1,0:POKEW+2,5:GOTO2300
2110 POKEW+1,5:POKEW+2,0
2300 NEXT:GOTO100
2320 
4107 
5000 PRINT"{clear}{gray3}"
5010 PRINTSPC(10)"{$c4:3}{right}{$c4}{right:3}{$c4}{right}{$c4}{right:3}{$c4}{right}{$c4}{right}{$c4}"
5020 PRINTSPC(10)"{$c4}{right:3}{$c4}{right:3}{$c4}{right}{$c4:2}{right}{$c4:2}{right}{$c4}{right}{$c4}"
5030 PRINTSPC(10)"{$c4:3}{right}{$c4}{right:3}{$c4}{right}{$c4}{right}{$c4}{right}{$c4}{right}{$c4:3}"
5040 PRINTSPC(10)"{right:2}{$c4}{right}{$c4}{right:3}{$c4}{right}{$c4}{right:3}{$c4}{right:2}{$c4}{right}"
5050 PRINTSPC(10)"{$c4:3}{right}{$c4:3}{right}{$c4}{right}{$c4}{right:3}{$c4}{right:2}{$c4}{right}"
5055 PRINTSPC(10)"{lt. blue}{$c1:19}"
5060 PRINTSPC(18)"{yellow}{down:2}BY{down}"
5062 PRINTSPC(15)"ALPHA ZOFT{down:2}"
5065 PRINT"       {$d5}{$c0:24}{$c9}"
5066 PRINT"       {$dd}      INSTRUCTIONS      {$dd}"
5067 PRINT"       {$dd}                        {$dd}"
5068 PRINT"       {$dd}W=UP       {lt. green}{$c2}{yellow} 10 PTS     {$dd}"
5069 PRINT"       {$dd}Z=DOWN     {lt. green}{$c4}{yellow} WATCH OUT! {$dd}"
5070 PRINT"       {$dd}A=LEFT                  {$dd}"
5071 PRINT"       {$dd}S=RIGHT                 {$dd}"
5072 PRINT"       {$dd}                        {$dd}"
5074 PRINT"       {$dd}                        {$dd}"
5075 PRINT"       {$ca}{$c0:24}{$cb}"
5076 IFPEEK(W+1)=245THENPOKEW+1,0:POKEW+2,5:GOTO5080
5078 POKEW+1,5:POKEW+2,0
5080 FORI=1TO25:IFPEEK(197)<>60THENNEXT:GOTO5076
5100 PRINT"{clear}{down:8}":PO=0
5110 PRINTSPC(10)"GO FOR IT, SUCKER.":FORI=1TO1500:NEXT:PRINT"{clear}":GOTO5
5200 IFF=RTHENLE=LE+3:PO=PO+10:GOTO7000
5202 PRINT"{down:3}{right:13} GAME OVER !":FORI=1TO15:POKEW+3,I
5203 FORT=200TO100STEP-5:POKEO,T/I:NEXT:NEXT:POKEO,0
5210 FORI=1TO1000:NEXT:GOTO10000
7000 FORT=240TO0STEP-80:POKEO,T:NEXT
7100 IFPO/50<>INT(PO/50)THENGOSUB70:RETURN
7120 C=INT(80+960*RND(1)):IFPEEK(A+C)<>STHEN7120
7130 POKEA+C,68:POKEB+C,13:GOSUB70:RETURN
9999 
10000 POKE198,0:IFPO<=PO(9)THEN10400
10050 PRINT"{clear}{down:2}"SPC(5)"LUCKY, YOU GOT A GOOD SCORE."
10060 PRINT"{down}"SPC(7)"PLEASE ENTER YOUR NAME:{down:2}":PRINTSPC(5);
10105 OPEN1,0:INPUT#1,A$:CLOSE1:C$=LEFT$(A$,18)
10110 FORI=0TO9:IFPO>PO(I)THEN10200
10120 NEXT
10200 FORT=9TOISTEP-1:NA$(T+1)=NA$(T):PO(T+1)=PO(T):NEXT
10210 NA$(I)=C$:PO(I)=PO:GOSUB12000
10400 PRINT"{clear}"SPC(15)"{down:3}TOP 10"
10405 PRINTSPC(15)"======{down:2}"
10410 FORT=0TO9:PRINT,PO(T),NA$(T):NEXT
10430 WAIT197,32:GOTO5000
12000 OPEN8,8,8,"@8:HI-MASK1,S,W"
12010 FORI=0TO9:PRINT#8,NA$(I)
12020 PRINT#8,PO(I):NEXT:CLOSE8:RETURN
13000 OPEN8,8,8,"8:HI-MASK1,S,R"
13010 FORI=0TO9:INPUT#8,NA$(I)
13020 INPUT#8,PO(I):NEXT:CLOSE8:RETURN

Have a nice day and happy C64-hacking!

No comments:

Post a Comment