Six
Registered: Apr 2002 Posts: 289 |
Conversion for petscii files from "PETSCII" editor
Not sure where to put this, but I wrote it to convert pics I made with the "PETSCII" tool to SEQ. No idea if anyone will find it useful, but here it is. Yeah, that's my BBS welcome screen encoded in there.
gcc, standard.
#include <stdio.h>
unsigned char colors[] = {
0x90, //black
0x05, //white
0x1c, //red
0x9f, //cyan
0x9c, //purple
0x1e, //green
0x1f, //blue
0x9e, //yellow
0x81, //orange
0x95, //brown
0x96, //pink
0x97, //grey 1
0x98, //grey 2
0x99, //lt green
0x9a, //lt blue
0x9b //grey 3
};
unsigned char revs_on = 0x12;
unsigned char revs_off = 0x92;
unsigned char revs_state = 0x00;
unsigned char current_color = 0xff;
unsigned char frame0000[]={// border,bg,chars,colors
14,0,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,85,73,32,32,32,32,32,32,32 ,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,85,68,74,75,68,73,32,32,32,32,32 ,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,103,86,86,86,86,101,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,103,86,86,86,86,101,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,103,86,86,86,86,101,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,103,86,86,86,86,101,32,32,32,32, 32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,100,100,122,100,100,100,100,76,100,100 ,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,20,8,5,32,32,32,32,32,32,32,32,32,77,100,66,32,32,32,32,66,100,78,32,32,32 ,32,32,32,32,32,32,32,32,32,32,32,32,32,
100,100,100,100,100,100,78,77,32,100,100,100,78,77,32,100,66,100,100,78,77,66,10 0,100,100,32,32,78,77,32,112,110,32,32,32,32,32,32,32,32,
77,32,32,32,32,32,32,32,77,77,32,32,32,32,77,77,32,32,32,32,32,77,77,32,32,77,78 ,32,78,67,125,109,67,67,67,67,67,67,32,67,
32,77,78,32,32,78,32,32,78,78,32,78,32,32,78,78,32,32,78,32,32,78,78,32,32,78,32 ,78,32,1,12,12,32,25,15,21,18,32,54,52,
32,78,32,32,78,32,32,78,78,32,32,32,32,78,78,32,32,100,32,32,78,78,32,32,32,32,7 8,32,1,18,5,32,2,5,12,15,14,7,32,32,
78,32,32,32,32,32,78,78,32,32,78,32,78,78,32,32,78,32,32,32,77,32,32,78,32,32,77 ,32,32,20,15,32,21,19,32,112,110,32,32,32,
77,100,100,100,100,78,32,77,100,78,77,78,32,77,100,78,77,100,32,32,78,100,78,77, 100,100,78,67,32,67,67,67,67,67,67,125,109,67,67,67,
32,32,112,110,32,32,32,32,32,32,32,32,32,32,100,100,100,100,77,78,78,77,32,32,32 ,32,100,100,100,100,78,77,32,100,100,100,100,78,77,32,
64,64,125,109,64,64,64,64,64,64,64,64,32,64,77,32,32,32,32,32,32,32,77,32,78,77, 77,32,32,32,32,32,77,77,32,32,32,32,32,77,
32,4,12,15,3,32,23,15,18,12,4,32,8,17,32,77,32,32,77,100,100,100,78,32,77,78,78, 32,32,78,32,32,78,78,32,100,100,100,100,78,
32,32,32,32,19,25,19,15,16,19,32,32,32,32,32,78,77,100,100,32,32,78,78,77,32,78, 32,32,78,32,32,78,78,32,100,29,100,100,32,32,
32,19,9,24,44,32,3,9,3,8,12,9,4,32,78,32,100,100,100,100,78,78,32,78,78,32,32,78 ,32,32,78,78,32,32,32,32,32,78,32,32,
64,32,64,64,64,64,64,64,64,64,110,112,64,64,77,78,32,101,32,93,32,77,78,32,77,32 ,32,100,100,78,78,32,100,100,100,100,78,32,32,32,
32,32,32,32,32,32,32,32,32,32,109,125,32,32,32,32,32,101,32,93,32,103,32,32,32,7 7,78,32,32,32,77,78,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,77,32,93,32,78,32,32,32,32,32 ,32,32,32,32,32,32,2,2,19,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,77,32,78,32,32,32,32,32,32 ,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,86,32,32,32,32,32,32,32 ,32,32,32,32,32,32,32,32,32,32,32,32,32,
32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32 ,32,32,32,32,32,32,32,32,32,32,32,32,32,
14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,2,2,14,14,14,14,14,14,14,1 4,14,14,14,14,14,14,14,14,14,14,14,14,
14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,7,7,2,2,7,7,14,14,14,14,14,14,14 ,14,14,14,14,14,14,14,14,14,14,14,
14,14,14,14,14,14,7,7,7,14,14,14,14,14,14,14,9,9,9,9,9,9,14,14,14,14,14,14,14,14 ,14,14,14,14,14,14,14,14,14,14,
14,14,14,14,14,7,7,14,7,14,14,14,14,14,14,14,9,9,9,9,9,9,14,14,14,14,14,14,14,14 ,14,14,14,14,14,14,14,14,14,14,
14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,9,9,9,9,9,9,14,14,14,14,14,14,14 ,14,14,14,14,14,14,14,14,14,14,14,
14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,9,9,9,9,9,9,14,14,14,14,14,14,14 ,14,14,14,14,14,14,14,14,14,14,14,
14,14,14,14,14,14,14,14,14,14,14,14,14,14,7,7,7,7,7,7,7,7,7,7,14,14,14,14,14,14, 14,14,14,14,14,14,14,14,14,14,
14,14,1,1,1,14,14,14,14,14,14,14,14,14,7,7,1,14,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,6,1 ,1,
14,14,14,14,14,14,14,14,14,14,3,3,14,14,14,6,14,2,14,11,14,15,14,14,14,6,6,14,14 ,14,6,6,14,14,14,14,14,14,14,14,
14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,2,14,2,14,15,14,6,6,6,6,6,6,6 ,6,6,14,1,1,1,14,14,14,14,
14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,2,14,2,14,14,14,6,6,6,6,6, 6,6,6,6,14,14,14,14,14,14,14,
14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,2,14,14,14,14,14,14,14, 14,14,14,14,14,14,14,14,14,14,14,14,14,
14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14 ,14,14,14,14,14,14,14,14,14,14,14,14,14
};
void main(){
FILE *fp;
//open output file
fp=fopen("output.seq", "wb");
int i = 0;
for (i = 2; i< 0x3ea; i++){
//What color is this cell?
unsigned char cell_color = frame0000[0x3e8+i];
unsigned char cell_char = frame0000[i];
unsigned char cell_revs = (frame0000[i] >=0x80)?1:0;
if (cell_color != current_color)
{
//Print color change character
fputc(colors[cell_color],fp);
current_color = cell_color;
}
//Is it revs-on or revs-off?
if (cell_revs==1){
//cell is revs, turn revs on if it's off.
if (revs_state == 0){
//just write the char
revs_state = 1;
fputc(revs_on,fp);
}
//And if revs is on, deduct 0x80 from the char
//cell_char = cell_char & 0x7f;
} else {
//cell is normal, turn revs off if it's on.
if (revs_state == 1){
revs_state = 0;
fputc(revs_off,fp);
}
}
// Screen code to petscii conversion
if ((cell_char >= 0) && (cell_char <= 0x1f)){
cell_char = cell_char + 0x40;
} else {
if ((cell_char >= 0x40) && (cell_char <= 0x5d)){
cell_char = cell_char + 0x80;
} else {
if (cell_char == 0x5e){
cell_char = 0xff;
} else {
if (cell_char == 0x95){
cell_char = 0xdf;
} else {
if ((cell_char >= 0x60) && (cell_char <= 0x7f)){
cell_char = cell_char + 0x80;
} else {
if ((cell_char >= 0x80) && (cell_char <= 0xbf)){
cell_char = cell_char - 0x80;
} else {
if ((cell_char >= 0xc0) && (cell_char <= 0xff)){
cell_char = cell_char -0x40;
}
}
}
}
}
}
}
//Now write the char
fputc(cell_char,fp);
}
//Close the file
fclose(fp);
}
|