Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
 Welcome to our latest new user Rodrigo Yeowtch ! (Registered 2024-11-24) You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > Conversion for petscii files from "PETSCII" editor
2014-09-29 03:43
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,14,14,14,1,7,7,14,14,14,14,14,14 ,14,14,14,14,14,14,14,14,14,14,
6,6,6,6,6,6,6,6,14,6,6,6,6,6,6,6,1,6,6,6,6,1,6,6,6,6,6,6,6,6,3,3,1,1,1,1,14,1,14 ,14,
6,1,6,6,6,1,1,1,6,6,1,1,1,1,6,6,6,6,1,1,1,6,6,1,6,6,6,6,6,3,3,3,3,3,3,3,3,3,3,3, 
1,6,6,14,14,6,14,14,6,6,14,6,14,6,6,6,6,6,6,14,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7 ,14,7,7,
14,6,14,14,6,14,14,6,6,14,1,1,6,6,6,6,6,6,14,6,6,6,6,14,6,6,6,6,7,7,7,14,7,7,7,7 ,7,7,14,14,
6,14,14,14,14,14,6,6,14,6,6,6,6,6,6,6,6,6,1,6,6,6,6,6,6,6,6,14,14,7,7,14,7,7,14, 3,3,14,14,14,
6,6,6,6,6,6,14,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,3,14,3,3,3,3,3,3,3,3,3,3, 3,
14,14,3,3,14,14,14,14,14,14,14,14,14,14,6,6,6,6,6,6,6,6,14,14,6,6,6,6,6,6,6,6,6, 6,6,6,6,6,6,14,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,6,6,6,6,6,6,6,6,6,1,6,6,6,1,1,1,1,6,6,6,1,1,1,1,1,6, 
14,7,7,7,7,14,7,7,7,7,7,14,7,7,14,6,6,6,6,6,6,6,6,1,6,6,6,1,1,6,6,6,6,6,1,6,6,6, 6,6,
14,14,14,14,7,7,7,7,7,7,14,14,14,14,14,6,6,6,6,1,1,6,6,6,6,6,6,1,6,14,14,6,6,6,6 ,6,6,6,1,14,
14,7,7,7,7,14,7,7,7,7,7,7,7,14,6,14,6,6,6,6,6,6,1,6,6,1,1,6,1,1,6,6,6,1,1,14,14, 6,1,14,
3,3,3,3,3,3,3,3,3,3,3,3,3,3,6,6,6,2,14,11,1,6,6,14,6,1,6,6,6,6,6,6,6,6,6,6,6,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);
}
2014-09-29 11:01
Scarzix

Registered: Aug 2010
Posts: 143
Nice I was actually looking for something where I could draw some PETSCII and then later import it into my assembler code as data.

This might come in handy.

Thanks a lot!
2014-09-29 11:40
Six

Registered: Apr 2002
Posts: 289
Well, this one will convert the output from PETSCII into a seq file. If you're just wanting screen + color ram data, that editor already does that. It just doesn't have an export to seq feature yet, afaik.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Guests online: 61
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Coma Light 13  (9.7)
4 Edge of Disgrace  (9.6)
5 Mojo  (9.6)
6 The Demo Coder  (9.6)
7 Uncensored  (9.6)
8 Wonderland XIV  (9.6)
9 Comaland 100%  (9.6)
10 What Is The Matrix 2  (9.6)
Top onefile Demos
1 Layers  (9.6)
2 Party Elk 2  (9.6)
3 Cubic Dream  (9.6)
4 Copper Booze  (9.6)
5 Libertongo  (9.5)
6 Rainbow Connection  (9.5)
7 Onscreen 5k  (9.5)
8 Morph  (9.5)
9 Dawnfall V1.1  (9.5)
10 It's More Fun to Com..  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Nostalgia  (9.3)
5 Censor Design  (9.3)
Top Original Suppliers
1 Derbyshire Ram  (9.7)
2 Fungus  (9.3)
3 Black Beard  (9.2)
4 Baracuda  (9.2)
5 hedning  (9.1)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.032 sec.