Open Esshahn opened 6 years ago
I've created a petscii2dirart converter in BASIC 2.0 that takes the BASIC listing export from PETSCII and creates files on an attached disk. It could be a start for investigation:
0 rem petscii to dir art converter
1 rem 2016 by awsm of mayday!
2 rem usage:
3 rem save pic from petscii app with "b" for basic
4 rem and replace the data in the script with the new data
5 rem only reads in first 16 chars from the left of the pic
6 rem do not use reverse charset characters!
7 rem -----------------------------------------
20 print chr$(147)
41 s= 0
42 fi$ = ""
43 rn$(0)="":rn$(1)=chr$(18)
44 rf$(0)="":rf$(1)=chr$(146)
50 for i=0 to 999:read a
51 s = s + 1
53 b=(aand127)+(aand64)+2*(a+32and32)
54 a$=rn$(1-(a<128))+chr$(b)+rf$(1-(a<128))
56 fi$ = fi$ + a$
57 if s = 16 then gosub 61
58 read a
59 next
60 goto 60
61 print fi$
63 open 2,8,4,fi$+",seq,w": close 2
64 fi$ = ""
65 s = 0
66 for g = 0 to 23: read a: read a: next g
68 return
69 rem -----------------------------------------
70 data 32,14,46,14,32,14,32,14
80 data 46,14,32,14,32,14,85,14
90 data 73,14,32,14,32,14,46,14
100 data 32,14,81,14,32,14,32,14
110 data 35,14,32,14,32,14,32,14
120 data 32,14,32,14,32,14,32,14
130 data 32,14,32,14,32,14,32,14
140 data 32,14,32,14,32,14,32,14
150 data 32,14,32,14,32,14,32,14
160 data 32,14,32,14,32,14,32,14
170 data 32,14,32,14,32,14,87,14
180 data 32,14,32,14,32,14,74,14
190 data 75,14,32,14,32,14,32,14
200 data 46,14,32,14,32,14,46,14
210 data 35,14,32,14,32,14,32,14
220 data 32,14,32,14,32,14,32,14
230 data 32,14,32,14,32,14,32,14
240 data 32,14,32,14,32,14,32,14
250 data 32,14,32,14,32,14,32,14
260 data 32,14,32,14,32,14,32,14
270 data 32,14,108,14,121,14,108,14
280 data 121,14,108,14,121,14,121,14
290 data 108,14,121,14,108,14,121,14
300 data 108,14,108,14,121,14,32,14
310 data 35,14,32,14,32,14,32,14
320 data 32,14,32,14,32,14,32,14
330 data 32,14,32,14,32,14,78,14
340 data 77,14,78,14,77,14,32,14
350 data 32,14,32,14,32,14,32,14
360 data 32,14,32,14,32,14,32,14
370 data 32,14,108,14,118,14,108,14
380 data 121,14,108,14,108,14,118,14
390 data 108,14,123,14,108,14,121,14
400 data 108,14,108,14,121,14,32,14
410 data 35,14,32,14,32,14,32,14
420 data 32,14,32,14,32,14,32,14
430 data 32,14,32,14,32,14,77,14
440 data 32,14,32,14,78,14,32,14
450 data 32,14,32,14,32,14,32,14
460 data 32,14,32,14,32,14,32,14
470 data 46,14,118,14,118,14,118,14
480 data 121,14,118,14,118,14,118,14
490 data 118,14,121,14,108,14,122,14
500 data 118,14,108,14,122,14,32,14
510 data 35,14,32,14,32,14,32,14
520 data 32,14,32,14,32,14,32,14
530 data 32,14,32,14,32,14,32,14
540 data 77,14,78,14,32,14,32,14
550 data 32,14,32,14,32,14,32,14
560 data 32,14,32,14,32,14,32,14
570 data 32,14,32,14,32,14,32,14
580 data 32,14,32,14,46,14,32,14
590 data 32,14,32,14,32,14,32,14
600 data 32,14,32,14,32,14,46,14
610 data 35,14,32,14,32,14,32,14
620 data 32,14,32,14,32,14,32,14
630 data 32,14,32,14,32,14,32,14
640 data 32,14,32,14,32,14,32,14
650 data 32,14,32,14,32,14,32,14
660 data 32,14,32,14,32,14,32,14
670 data 32,14,45,14,61,14,32,14
680 data 43,14,50,14,32,14,4,14
690 data 13,14,6,14,7,14,8,14
700 data 32,14,61,14,45,14,32,14
710 data 35,14,32,14,32,14,32,14
720 data 32,14,32,14,32,14,32,14
730 data 32,14,32,14,32,14,32,14
740 data 32,14,32,14,32,14,32,14
750 data 32,14,32,14,32,14,32,14
760 data 32,14,32,14,32,14,32,14
770 data 46,14,32,14,32,14,32,14
780 data 46,14,32,14,32,14,32,14
790 data 32,14,32,14,32,14,32,14
800 data 85,14,73,14,32,14,32,14
810 data 35,14,32,14,32,14,32,14
820 data 32,14,32,14,32,14,32,14
830 data 32,14,32,14,32,14,32,14
840 data 32,14,32,14,32,14,32,14
850 data 32,14,32,14,32,14,32,14
860 data 32,14,32,14,32,14,32,14
870 data 32,14,32,14,81,14,46,14
880 data 32,14,46,14,32,14,78,14
890 data 77,14,32,14,46,14,32,14
900 data 74,14,75,14,46,14,32,14
910 data 35,14,32,14,32,14,32,14
920 data 32,14,32,14,32,14,32,14
930 data 32,14,32,14,32,14,32,14
940 data 32,14,32,14,32,14,32,14
950 data 32,14,32,14,32,14,32,14
960 data 32,14,32,14,32,14,32,14
970 data 32,14,32,14,32,14,32,14
980 data 32,14,66,14,78,14,119,14
990 data 119,14,77,14,66,14,32,14
1000 data 32,14,32,14,32,14,32,14
1010 data 35,14,32,14,32,14,32,14
1020 data 32,14,32,14,32,14,32,14
1030 data 32,14,32,14,32,14,78,14
1040 data 77,14,78,14,77,14,32,14
1050 data 32,14,32,14,32,14,32,14
1060 data 32,14,32,14,32,14,32,14
1070 data 32,14,77,14,32,14,78,14
1080 data 119,14,119,14,119,14,69,14
1090 data 69,14,119,14,119,14,119,14
1100 data 77,14,32,14,78,14,32,14
1110 data 35,14,32,14,32,14,32,14
1120 data 32,14,32,14,32,14,32,14
1130 data 32,14,112,14,64,14,77,14
1140 data 32,14,32,14,78,14,64,14
1150 data 110,14,32,14,32,14,32,14
1160 data 32,14,32,14,32,14,32,14
1170 data 46,14,78,14,119,14,119,14
1180 data 32,14,69,14,85,14,61,14
1190 data 61,14,73,14,69,14,32,14
1200 data 119,14,119,14,77,14,32,14
1210 data 35,14,32,14,32,14,32,14
1220 data 32,14,32,14,32,14,32,14
1230 data 32,14,109,14,114,14,32,14
1240 data 77,14,78,14,32,14,114,14
1250 data 125,14,32,14,32,14,32,14
1260 data 32,14,32,14,32,14,32,14
1270 data 32,14,77,14,119,14,69,14
1280 data 119,14,69,14,85,14,46,14
1290 data 46,14,73,14,69,14,119,14
1300 data 69,14,119,14,78,14,32,14
1310 data 35,14,32,14,32,14,32,14
1320 data 32,14,32,14,32,14,32,14
1330 data 32,14,32,14,109,14,110,14
1340 data 66,14,93,14,112,14,125,14
1350 data 32,14,32,14,32,14,32,14
1360 data 32,14,32,14,32,14,32,14
1370 data 32,14,32,14,119,14,33,14
1380 data 119,14,119,14,77,14,111,14
1390 data 111,14,78,14,119,14,119,14
1400 data 33,14,119,14,32,14,46,14
1410 data 35,14,32,14,32,14,32,14
1420 data 32,14,32,14,32,14,32,14
1430 data 32,14,32,14,32,14,109,14
1440 data 125,14,109,14,125,14,32,14
1450 data 32,14,32,14,32,14,32,14
1460 data 32,14,32,14,32,14,32,14
1470 data 112,14,64,14,67,14,114,14
1480 data 67,14,114,14,114,14,110,14
1490 data 112,14,114,14,67,14,114,14
1500 data 114,14,73,14,112,14,73,14
1510 data 35,14,32,14,32,14,32,14
1520 data 32,14,32,14,32,14,32,14
1530 data 32,14,32,14,32,14,32,14
1540 data 32,14,32,14,32,14,32,14
1550 data 32,14,32,14,32,14,32,14
1560 data 32,14,32,14,32,14,32,14
1570 data 66,14,32,14,32,14,93,14
1580 data 32,14,93,14,33,14,107,14
1590 data 125,14,93,14,32,14,93,14
1600 data 33,14,93,14,93,14,93,14
1610 data 35,14,32,14,32,14,32,14
1620 data 32,14,32,14,32,14,32,14
1630 data 32,14,32,14,32,14,32,14
1640 data 32,14,32,14,32,14,32,14
1650 data 32,14,32,14,32,14,32,14
1660 data 32,14,32,14,32,14,32,14
1670 data 66,14,46,14,46,14,93,14
1680 data 93,14,93,14,32,14,93,14
1690 data 93,14,93,14,93,14,93,14
1700 data 32,14,93,14,93,14,93,14
1710 data 35,14,32,14,32,14,32,14
1720 data 32,14,32,14,32,14,32,14
1730 data 32,14,32,14,32,14,32,14
1740 data 32,14,32,14,32,14,32,14
1750 data 32,14,32,14,32,14,32,14
1760 data 32,14,32,14,32,14,32,14
1770 data 66,14,66,14,66,14,93,14
1780 data 46,14,107,14,32,14,93,14
1790 data 32,14,93,14,46,14,107,14
1800 data 32,14,93,14,107,14,115,14
1810 data 35,14,32,14,32,14,32,14
1820 data 32,14,32,14,32,14,32,14
1830 data 32,14,32,14,32,14,32,14
1840 data 32,14,32,14,32,14,32,14
1850 data 32,14,32,14,32,14,32,14
1860 data 32,14,32,14,32,14,32,14
1870 data 74,14,113,14,113,14,113,14
1880 data 113,14,113,14,78,14,77,14
1890 data 78,14,77,14,113,14,113,14
1900 data 67,14,75,14,102,14,75,14
1910 data 35,14,32,14,32,14,32,14
1920 data 32,14,32,14,32,14,32,14
1930 data 32,14,32,14,32,14,32,14
1940 data 32,14,32,14,32,14,32,14
1950 data 32,14,32,14,32,14,32,14
1960 data 32,14,32,14,32,14,32,14
1970 data 46,14,32,14,102,14,104,14
1980 data 112,14,64,14,77,14,32,14
1990 data 32,14,78,14,64,14,110,14
2000 data 104,14,102,14,92,14,46,14
2010 data 35,14,32,14,32,14,32,14
2020 data 32,14,112,14,64,14,64,14
2030 data 110,14,112,14,64,14,64,14
2040 data 110,14,32,14,32,14,32,14
2050 data 32,14,32,14,32,14,32,14
2060 data 32,14,32,14,32,14,32,14
2070 data 32,14,32,14,46,14,32,14
2080 data 109,14,114,14,32,14,77,14
2090 data 78,14,32,14,114,14,125,14
2100 data 32,14,32,14,32,14,32,14
2110 data 35,14,32,14,32,14,32,14
2120 data 32,14,109,14,114,14,32,14
2130 data 66,14,93,14,32,14,114,14
2140 data 125,14,32,14,32,14,32,14
2150 data 32,14,32,14,32,14,32,14
2160 data 32,14,32,14,32,14,32,14
2170 data 32,14,46,14,32,14,32,14
2180 data 32,14,109,14,110,14,66,14
2190 data 93,14,112,14,125,14,32,14
2200 data 32,14,46,14,32,14,32,14
2210 data 35,14,32,14,32,14,32,14
2220 data 32,14,32,14,109,14,110,14
2230 data 66,14,93,14,112,14,125,14
2240 data 32,14,32,14,32,14,32,14
2250 data 32,14,32,14,32,14,32,14
2260 data 32,14,32,14,32,14,32,14
2270 data 32,14,32,14,32,14,6,14
2280 data 15,14,18,14,109,14,125,14
2290 data 109,14,125,14,6,14,21,14
2300 data 14,14,32,14,32,14,46,14
2310 data 35,14,32,14,32,14,32,14
2320 data 32,14,32,14,32,14,109,14
2330 data 125,14,109,14,125,14,32,14
2340 data 32,14,32,14,32,14,32,14
2350 data 32,14,32,14,32,14,32,14
2360 data 32,14,32,14,32,14,32,14
2370 data 32,14,32,14,14,14,15,14
2380 data 20,14,32,14,6,14,15,14
2390 data 18,14,32,14,6,14,1,14
2400 data 13,14,5,14,32,14,32,14
2410 data 35,14,32,14,32,14,32,14
2420 data 32,14,32,14,32,14,32,14
2430 data 32,14,32,14,32,14,32,14
2440 data 32,14,32,14,32,14,32,14
2450 data 32,14,32,14,32,14,32,14
2460 data 32,14,32,14,32,14,32,14
2470 data 32,14,32,14,32,14,32,14
2480 data 32,14,32,14,32,14,32,14
2490 data 32,14,32,14,32,14,32,14
2500 data 32,14,32,14,32,14,32,14
2510 data 35,14,32,14,32,14,32,14
2520 data 32,14,32,14,32,14,32,14
2530 data 32,14,32,14,32,14,32,14
2540 data 32,14,32,14,32,14,32,14
2550 data 32,14,32,14,32,14,32,14
2560 data 32,14,32,14,32,14,32,14
2570 end
@Esshahn btw what's the right content pipeline for DirArt petscii. Suppose I have a .prg file, say a game or a demo, and then I want to release it as a .d64 with DirArt authored in Petmate.
What files do we need, how are these exported from Petmate, and how is the final .d64 packaged up?
Above you mention that Petmate should export .d64. But if someone's releasing a demo with Petmate dirart, do they not want to build the .d64 themselves somehow? I'm not well-versed in these tools (in fact, the dirart for my only C64 demo was packaged into a d64 by Lemming/Offence. :)
Not sure about how others do it, but this was my quirky way to success:
Create an empty D64 image in Vice (or the command tools, to be precise). I usually kept a copy and the file structure is likely the same always, so it can act as a stub.
Attach the new empty D64 image to Vice
Now I run my BASIC code above. As noted in the REM section, I exported a petscii from marq's tool as basic listing and then I replace the data statements in my listing with the generated code from marq. I do this in a text editor on the Mac of course. I can just paste the code into VICE then (also using warp mode).
The Code writes the data statements as filenames to the D64 You can see in the Code that I use SEQ file format, others are also possible. Note that any file write with character codes not allowed ($128+ charset) will result in errors.
Now that the the disc is prepared with proper DIR Art, attach the PRG you want on that disk There are likely better ways, but I actually used a C64 Copy Program in VICE and copied the PRG.
There are a bunch of Dir and File Manager EXE out there that might be of better use.
Now for the "perfect" workflow AKA "how Petpmate does it" :D
Create DirArt in PETSCII Ideal: Reduce risk of errors by a) only have a 16 chars wide editor (it can actually be much taller than 25 though) b) only show the chars that are allowed Hacky: a) ignore every char after 16 horizontal chars per line b) ignore every illegal char and replace it with $20
Allow "Save as D64" This could have some extra options like choosing the file extension or setting the directory header and ID
Create a D64 file with the DirArt I was thinking it might be cool if Petmate accepts user made D64 files (e.g. pre-filled with the PRG), but I guess that comes with lots of variables and worst case we accidentally destroy the D64 and the user didn't have a copy of it.
From this point on, I wouldn't care about how the user gets their PRG on that D64.
Does that make sense?
Having said that I think the amount of work needed to make this work is substantial and it might be a rarely used feature for most.
Yeah it sounds like I'd need a .d64 writer in JS. But an OSS JS library on NPM for writing .d64 might not be too bad to release. I need dirart too, so I have a some motivations of my own for this.
Have given this some more thought. So the right sized screens are now mostly supported.
But for plugging the actual petscii into a d64 file. Have to give that some more thought. My current thinking is that this won't be BASIC-based (hehe) but I also won't be implement a d64 parser/writer. I think a workable solution would be to have the export dialog maybe print copy&pasteable "c1541" (from VICE) commands that can be used to stick the dir art into an existing d64 file.
I made a tool that can be used to stick PETSCII into .d64 directory entries.
Installation:
npm -g i c1541
Usage:
Jannes-MBP:c1541 janne$ c1541js --help
Usage: c1541js [options] <src.d64> <dst.d64>
C64 c1541 directory filename editor
Options:
--petmate <path> read dirart from this .petmate file (choose first screen)
-V, --version output the version number
-h, --help output usage information
So like:
Jannes-MBP:c1541 janne$ c1541js d64/hrmu-visio2018.d64 foo.d64 --petmate=$HOME/Desktop/dirart.petmate
Modified .d64 file written in foo.d64
Jannes-MBP:c1541 janne$ c1541 -attach foo.d64 -list
0 "visio 2018 " hirmu
202 "visio2018 /hirmu" prg
0 " ...UCCCCCCI... " del
0 " . Uabcdeftest. " del
0 " .U.CCCCCCCC.I. " del
0 " %B hirmu B% " del
0 " :B and star B: " del
0 " .B events B. " del
0 " B present: B " del
0 " .B B. " del
0 " :B visio B: " del
0 " %B S 2018 S B% " del
0 " .J.CCCCCCCC.K. " del
0 " . J.CCCCCC.K . " del
0 " ...testing 123!" del
462 blocks free.
This IMO is something that might be better serviced by this script rather than doing this in the GUI.
This is just a quick test. Right now it just reads a .petmate file directly but I was thinking that a simple json export format would be handy so that it's super easy to read PETSCII in scripts. Reading petmate wasn't too bad either tho:
type Pix = { code: number, color: number };
const petmate = fs.readFileSync(program.petmate).toString();
const screencodes: number[][] =
JSON.parse(petmate).framebufs[0].framebuf.map((row: Pix[]) => {
return row.map((p: Pix) => p.code);
});
This is mostly done.. but the thing that's missing is the Petmate UI support for showing what screencodes are ok in dirart.
(just to document what we already noted)
It would be nice to have a "dirart" mode for Petmate.
Export format should be a D64 image containing filenames with the dirart.