[Coco] Program to convert Orchestra 90 ".ASC" files for use with the Orchestra 90 cartridge
Barry Nelson
barry.nelson at amobiledevice.com
Sun Jun 12 15:58:48 EDT 2016
Here is a C language version. It does not block to 100 byte blocks, but this does not seem to matter.
o90cvn.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char **argv)
{
FILE * in;
FILE * out;
char ibuf[101];
char *p = ibuf;
char obuf[101];
int ln,pn;
if (argc<3)
{
fprintf(stdout,"%s: Usage: %s input_file.asc output_file\n",argv[0],argv[0]);
exit(1);
}
in=fopen(argv[1], "r");
out=fopen(argv[2], "w");
while (fgets(ibuf,100,in)!=NULL)
{
p=strchr(ibuf,'\n');
if (p!=NULL)
{
*p='\0';
}
ln=strlen(ibuf);
p=strchr(ibuf,'\r');
if (p!=NULL)
{
*p='\0';
}
if (ln>strlen(ibuf))
{
fseek(in,strlen(ibuf)-ln+1,SEEK_CUR);
}
if (strlen(ibuf)>0)
{
printf("%s\n",ibuf);
ln=strlen(ibuf);
pn=31;
while (strchr(ibuf,'/')!=NULL && ln>pn)
{
strncpy(obuf,ibuf,100);
strncpy(obuf+pn+1,ibuf+pn,100);
obuf[pn]=(char) 175;
pn=pn+31;
ln=ln+1;
strncpy(ibuf,obuf,100);
}
strncpy(obuf,ibuf,100);
obuf[0]=obuf[0]+128;
fprintf(out,"%s",obuf);
}
}
fclose(in);
fclose(out);
exit(0);
}
On Jun 11, 2016, at 7:00 PM, Barry Nelson <barry.nelson at amobiledevice.com> wrote:
> There already is a BASIC09 version here: http://www.colorcomputerarchive.com/coco/Orchestra-90/readme.txt
>
>> Bill Pierce ooogalapasooo at aol.com
>> Sat Jun 11 18:48:33 EDT 2016
>>
>> Thanks Barry, you beat me to it. Next we need a bulk renaming utility to strip the ".ASC" or ".MUS" from the file (really simple) and also capitalize any lower case named files.
>> I may convert your code to OS9 as I about have my Orch90 player for OS9 going. I've got to finish sorting out the flow of the "SCORE" function, then decide how I'm going to implement the tables.
>> I've got some projects going on in the studio at the moment ($$) and don't have much time for Coco stuff.
>>
>> On Jun 11, 2016, at 6:31 PM, Barry Nelson <barry.nelson at amobiledevice.com> wrote:
>>
>>> I noticed this software was missing from the internet so I rewrote it. It converts ".ASC" Orchestra 90 files so that the Orchestra 90 CoCo cartridge can use them.
>>>
>>> 1 REM PROGRAM TO CONVERT ORCHESTRA "ASC" FILES TO A FORMAT READABLE BY THE ORCHESTRA 90 CARTRIDGE
>>> 10 CLEAR 500:CLS
>>> 20 INPUT "FILE FOR CONVERSION";F$
>>> 25 REM CONSTRUCT OUTPUT FILE NAME, REMOVE .ASC EXTENSION, IF NO EXTENSION ADD -O
>>> 30 E$="":P=INSTR(F$,"."):IF P=0 THEN P=LEN(F$)+1:E$="-O"
>>> 40 O$=LEFT$(F$,P-1)
>>> 45 REM OPEN INPUT AND OUTPUT FILES
>>> 50 OPEN "I",1,F$:OPEN "O",2,O$+E$+"."
>>> 55 REM CHECK FOR END OF INPUT FILE
>>> 60 IF EOF(1) THEN GOTO 140
>>> 65 REM GET A LINE OF INPUT
>>> 70 LINE INPUT #1,N$
>>> 75 REM IF THE LINE IS EMPTY, GET THE NEXT LINE
>>> 80 IF LEN(N$)>0 THEN PRINT N$ ELSE 60
>>> 85 REM SPLIT UP COMMENT LINES LONGER THAN 31 CHARACTERS
>>> 90 LN=LEN(N$):PN=31
>>> 100 IF LN-PN>0 AND INSTR(N$,"/")>0 THEN N$=LEFT$(N$,PN)+CHR$(175)+MID$(N$,PN+1):PN=PN+31:LN=LN+1:GOTO 100
>>> 105 REM SET BIT 7 HI ON THE FIRST CHARACTER OF EACH LINE
>>> 110 N$=CHR$(ASC(LEFT$(N$,1)) OR 128)+MID$(N$,2)
>>> 115 REM WRITE OUT 100 CHARACTERS AT A TIME, NO CR OR LF
>>> 120 OP$=OP$+N$:IF LEN(OP$)>100 THEN PRINT #2,LEFT$(OP$,100);:OP$=MID$(OP$,101)
>>> 125 REM GET NEXT LINE
>>> 130 GOTO 60
>>> 135 REM CLOSE INPUT FILE
>>> 140 CLOSE #1
>>> 145 REM WRITE OUT LAST BLOCK OF 100 CHARACTERS, PADDING WITH SPACES
>>> 150 OP$=LEFT$(OP$+STRING$(100,32),100):PRINT #2,OP$;
>>> 155 REM CLOSE OUTPUT FILE
>>> 160 CLOSE #2
>>> 170 END
>>
More information about the Coco
mailing list