4-space tabs for c64 load/save code
git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1018 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
b92e8f288e
commit
b934f1d57c
639
loadsave.c
639
loadsave.c
@ -5878,379 +5878,380 @@ void Save_NEO(void)
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
void Test_C64(void)
|
void Test_C64(void)
|
||||||
{
|
{
|
||||||
FILE* file;
|
FILE* file;
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
char filename[MAX_PATH_CHARACTERS];
|
||||||
long file_size;
|
long file_size;
|
||||||
|
|
||||||
Get_full_filename(filename,0);
|
Get_full_filename(filename,0);
|
||||||
|
|
||||||
file = fopen(filename,"rb");
|
file = fopen(filename,"rb");
|
||||||
|
|
||||||
if (file)
|
if (file)
|
||||||
{
|
|
||||||
file_size = File_length_file(file);
|
|
||||||
switch (file_size)
|
|
||||||
{
|
{
|
||||||
case 8000: // raw bitmap
|
file_size = File_length_file(file);
|
||||||
case 8002: // raw bitmap with loadaddr
|
switch (file_size)
|
||||||
case 9000: // bitmap + screen
|
{
|
||||||
case 9002: // bitmap + screen + loadaddr
|
case 8000: // raw bitmap
|
||||||
case 10001: // multicolor
|
case 8002: // raw bitmap with loadaddr
|
||||||
case 10003: // multicolor + loadaddr
|
case 9000: // bitmap + screen
|
||||||
File_error = 0;
|
case 9002: // bitmap + screen + loadaddr
|
||||||
break;
|
case 10001: // multicolor
|
||||||
default: // then we don't know for now.
|
case 10003: // multicolor + loadaddr
|
||||||
File_error = 1;
|
File_error = 0;
|
||||||
|
break;
|
||||||
|
default: // then we don't know for now.
|
||||||
|
File_error = 1;
|
||||||
|
}
|
||||||
|
fclose (file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
File_error = 1;
|
||||||
}
|
}
|
||||||
fclose (file);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
File_error = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Load_C64_hires(byte *bitmap, byte *colors)
|
void Load_C64_hires(byte *bitmap, byte *colors)
|
||||||
{
|
{
|
||||||
int cx,cy,x,y,c[4],pixel,color;
|
int cx,cy,x,y,c[4],pixel,color;
|
||||||
|
|
||||||
for(cy=0; cy<25; cy++)
|
for(cy=0; cy<25; cy++)
|
||||||
{
|
|
||||||
for(cx=0; cx<40; cx++)
|
|
||||||
{
|
{
|
||||||
c[1]=colors[cy*40+cx]&15;
|
for(cx=0; cx<40; cx++)
|
||||||
c[0]=colors[cy*40+cx]>>4;
|
|
||||||
for(y=0; y<8; y++)
|
|
||||||
{
|
|
||||||
pixel=bitmap[cy*320+cx*8+y];
|
|
||||||
for(x=0; x<8; x++)
|
|
||||||
{
|
{
|
||||||
color=c[pixel&(1<<(7-x))?1:0];
|
c[1]=colors[cy*40+cx]&15;
|
||||||
Pixel_load_function(cx*8+x,cy*8+y,color);
|
c[0]=colors[cy*40+cx]>>4;
|
||||||
|
for(y=0; y<8; y++)
|
||||||
|
{
|
||||||
|
pixel=bitmap[cy*320+cx*8+y];
|
||||||
|
for(x=0; x<8; x++)
|
||||||
|
{
|
||||||
|
color=c[pixel&(1<<(7-x))?1:0];
|
||||||
|
Pixel_load_function(cx*8+x,cy*8+y,color);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Load_C64_multi(byte *bitmap, byte *colors, byte *nybble, byte background)
|
void Load_C64_multi(byte *bitmap, byte *colors, byte *nybble, byte background)
|
||||||
{
|
{
|
||||||
int cx,cy,x,y,c[4],pixel,color;
|
int cx,cy,x,y,c[4],pixel,color;
|
||||||
c[0]=background;
|
c[0]=background;
|
||||||
for(cy=0; cy<25; cy++)
|
for(cy=0; cy<25; cy++)
|
||||||
{
|
|
||||||
for(cx=0; cx<40; cx++)
|
|
||||||
{
|
{
|
||||||
c[1]=colors[cy*40+cx]>>4;
|
for(cx=0; cx<40; cx++)
|
||||||
c[2]=colors[cy*40+cx]&15;
|
|
||||||
c[3]=nybble[cy*40+cx];
|
|
||||||
|
|
||||||
for(y=0; y<8; y++)
|
|
||||||
{
|
|
||||||
pixel=bitmap[cy*320+cx*8+y];
|
|
||||||
for(x=0; x<4; x++)
|
|
||||||
{
|
{
|
||||||
color=c[(pixel&3)];
|
c[1]=colors[cy*40+cx]>>4;
|
||||||
pixel>>=2;
|
c[2]=colors[cy*40+cx]&15;
|
||||||
Pixel_load_function(cx*4+(3-x),cy*8+y,color);
|
c[3]=nybble[cy*40+cx];
|
||||||
|
|
||||||
|
for(y=0; y<8; y++)
|
||||||
|
{
|
||||||
|
pixel=bitmap[cy*320+cx*8+y];
|
||||||
|
for(x=0; x<4; x++)
|
||||||
|
{
|
||||||
|
color=c[(pixel&3)];
|
||||||
|
pixel>>=2;
|
||||||
|
Pixel_load_function(cx*4+(3-x),cy*8+y,color);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Load_C64(void)
|
void Load_C64(void)
|
||||||
{
|
{
|
||||||
FILE* file;
|
FILE* file;
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
char filename[MAX_PATH_CHARACTERS];
|
||||||
long file_size;
|
long file_size;
|
||||||
byte background;
|
byte background;
|
||||||
|
|
||||||
// Palette from http://www.pepto.de/projects/colorvic/
|
|
||||||
byte pal[48]={
|
|
||||||
0x00, 0x00, 0x00,
|
|
||||||
0xFF, 0xFF, 0xFF,
|
|
||||||
0x68, 0x37, 0x2B,
|
|
||||||
0x70, 0xA4, 0xB2,
|
|
||||||
0x6F, 0x3D, 0x86,
|
|
||||||
0x58, 0x8D, 0x43,
|
|
||||||
0x35, 0x28, 0x79,
|
|
||||||
0xB8, 0xC7, 0x6F,
|
|
||||||
0x6F, 0x4F, 0x25,
|
|
||||||
0x43, 0x39, 0x00,
|
|
||||||
0x9A, 0x67, 0x59,
|
|
||||||
0x44, 0x44, 0x44,
|
|
||||||
0x6C, 0x6C, 0x6C,
|
|
||||||
0x9A, 0xD2, 0x84,
|
|
||||||
0x6C, 0x5E, 0xB5,
|
|
||||||
0x95, 0x95, 0x95};
|
|
||||||
|
|
||||||
byte bitmap[8000],colors[1000],nybble[1000];
|
|
||||||
word width=320, height=200;
|
|
||||||
|
|
||||||
Get_full_filename(filename,0);
|
|
||||||
file = fopen(filename,"rb");
|
|
||||||
|
|
||||||
if(file)
|
|
||||||
{
|
|
||||||
|
|
||||||
memcpy(Main_palette,pal,48); // this set the software palette for grafx2
|
// Palette from http://www.pepto.de/projects/colorvic/
|
||||||
Set_palette(Main_palette); // this set the hardware palette for SDL
|
byte pal[48]={
|
||||||
Remap_fileselector(); // Always call it if you change the palette
|
0x00, 0x00, 0x00,
|
||||||
|
0xFF, 0xFF, 0xFF,
|
||||||
file_size = File_length_file(file);
|
0x68, 0x37, 0x2B,
|
||||||
|
0x70, 0xA4, 0xB2,
|
||||||
if(file_size>9002)
|
0x6F, 0x3D, 0x86,
|
||||||
|
0x58, 0x8D, 0x43,
|
||||||
|
0x35, 0x28, 0x79,
|
||||||
|
0xB8, 0xC7, 0x6F,
|
||||||
|
0x6F, 0x4F, 0x25,
|
||||||
|
0x43, 0x39, 0x00,
|
||||||
|
0x9A, 0x67, 0x59,
|
||||||
|
0x44, 0x44, 0x44,
|
||||||
|
0x6C, 0x6C, 0x6C,
|
||||||
|
0x9A, 0xD2, 0x84,
|
||||||
|
0x6C, 0x5E, 0xB5,
|
||||||
|
0x95, 0x95, 0x95};
|
||||||
|
|
||||||
|
byte bitmap[8000],colors[1000],nybble[1000];
|
||||||
|
word width=320, height=200;
|
||||||
|
|
||||||
|
Get_full_filename(filename,0);
|
||||||
|
file = fopen(filename,"rb");
|
||||||
|
|
||||||
|
if(file)
|
||||||
{
|
{
|
||||||
width=160;
|
|
||||||
Ratio_of_loaded_image = PIXEL_WIDE;
|
memcpy(Main_palette,pal,48); // this set the software palette for grafx2
|
||||||
|
Set_palette(Main_palette); // this set the hardware palette for SDL
|
||||||
|
Remap_fileselector(); // Always call it if you change the palette
|
||||||
|
|
||||||
|
file_size = File_length_file(file);
|
||||||
|
|
||||||
|
if(file_size>9002)
|
||||||
|
{
|
||||||
|
width=160;
|
||||||
|
Ratio_of_loaded_image = PIXEL_WIDE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Ratio_of_loaded_image = PIXEL_SIMPLE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Init_preview(width, height, file_size, FORMAT_C64, Ratio_of_loaded_image); // Do this as soon as you can
|
||||||
|
|
||||||
|
Main_image_width = width ;
|
||||||
|
Main_image_height = height;
|
||||||
|
|
||||||
|
Read_bytes(file,bitmap,8000);
|
||||||
|
if(file_size>8002)
|
||||||
|
Read_bytes(file,colors,1000);
|
||||||
|
|
||||||
|
if(width==160)
|
||||||
|
{
|
||||||
|
Read_bytes(file,nybble,1000);
|
||||||
|
Read_byte(file,&background);
|
||||||
|
Load_C64_multi(bitmap,colors,nybble,background);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Load_C64_hires(bitmap,colors);
|
||||||
|
}
|
||||||
|
|
||||||
|
File_error = 0;
|
||||||
|
fclose(file);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
File_error = 1;
|
||||||
Ratio_of_loaded_image = PIXEL_SIMPLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
Init_preview(width, height, file_size, FORMAT_C64, Ratio_of_loaded_image); // Do this as soon as you can
|
|
||||||
|
|
||||||
Main_image_width = width ;
|
|
||||||
Main_image_height = height;
|
|
||||||
|
|
||||||
Read_bytes(file,bitmap,8000);
|
|
||||||
if(file_size>8002)
|
|
||||||
Read_bytes(file,colors,1000);
|
|
||||||
|
|
||||||
if(width==160)
|
|
||||||
{
|
|
||||||
Read_bytes(file,nybble,1000);
|
|
||||||
Read_byte(file,&background);
|
|
||||||
Load_C64_multi(bitmap,colors,nybble,background);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Load_C64_hires(bitmap,colors);
|
|
||||||
}
|
|
||||||
|
|
||||||
File_error = 0;
|
|
||||||
fclose(file);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
File_error = 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int Save_C64_hires(char *filename)
|
int Save_C64_hires(char *filename)
|
||||||
{
|
{
|
||||||
int cx,cy,x,y,c1,c2,i,pixel,bits,pos=0;
|
int cx,cy,x,y,c1,c2,i,pixel,bits,pos=0;
|
||||||
word numcolors;
|
word numcolors;
|
||||||
dword cusage[256];
|
dword cusage[256];
|
||||||
byte colors[1000],bitmap[8000];
|
byte colors[1000],bitmap[8000];
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|
||||||
|
for(x=0;x<1000;x++)
|
||||||
|
colors[x]=1; // init colormem to black/white
|
||||||
|
|
||||||
for(x=0;x<1000;x++)colors[x]=1; // init colormem to black/white
|
for(cy=0; cy<25; cy++) // Character line, 25 lines
|
||||||
|
|
||||||
for(cy=0; cy<25; cy++) // Character line, 25 lines
|
|
||||||
{
|
|
||||||
for(cx=0; cx<40; cx++) // Character column, 40 columns
|
|
||||||
{
|
{
|
||||||
for(i=0;i<256;i++) cusage[i]=0;
|
for(cx=0; cx<40; cx++) // Character column, 40 columns
|
||||||
|
{
|
||||||
|
for(i=0;i<256;i++) cusage[i]=0;
|
||||||
|
|
||||||
|
numcolors=Count_used_colors_area(cusage,cx*8,cy*8,8,8);
|
||||||
|
if (numcolors>2)
|
||||||
|
{
|
||||||
|
Warning_message("More than 2 colors in 8x8 pixels");
|
||||||
|
// TODO here we should hilite the offending block
|
||||||
|
printf("\nerror at %dx%d (%d colors)\n",cx*8,cy*8,numcolors);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
for(i=0;i<16;i++)
|
||||||
|
{
|
||||||
|
if(cusage[i])
|
||||||
|
{
|
||||||
|
c2=i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
c1=c2;
|
||||||
|
for(i=c2+1;i<16;i++)
|
||||||
|
{
|
||||||
|
if(cusage[i])
|
||||||
|
{
|
||||||
|
c1=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
colors[cx+cy*40]=(c2<<4)|c1;
|
||||||
|
|
||||||
numcolors=Count_used_colors_area(cusage,cx*8,cy*8,8,8);
|
for(y=0; y<8; y++)
|
||||||
if (numcolors>2)
|
{
|
||||||
{
|
bits=0;
|
||||||
Warning_message("More than 2 colors in 8x8 pixels");
|
for(x=0; x<8; x++)
|
||||||
// TODO here we should hilite the offending block
|
{
|
||||||
printf("\nerror at %dx%d (%d colors)\n",cx*8,cy*8,numcolors);
|
pixel=Read_pixel_function(x+cx*8,y+cy*8);
|
||||||
return 1;
|
if(pixel>15)
|
||||||
}
|
{
|
||||||
for(i=0;i<16;i++)
|
Warning_message("Color above 15 used");
|
||||||
{
|
// TODO hilite offending block here too?
|
||||||
if(cusage[i])
|
// or make it smarter with color allocation?
|
||||||
{
|
// However, the palette is fixed to the 16 first colors
|
||||||
c2=i;
|
return 1;
|
||||||
break;
|
}
|
||||||
|
bits=bits<<1;
|
||||||
|
if (pixel==c1) bits|=1;
|
||||||
|
}
|
||||||
|
bitmap[pos++]=bits;
|
||||||
|
//Write_byte(file,bits&255);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
c1=c2;
|
|
||||||
for(i=c2+1;i<16;i++)
|
|
||||||
{
|
|
||||||
if(cusage[i])
|
|
||||||
{
|
|
||||||
c1=i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
colors[cx+cy*40]=(c2<<4)|c1;
|
|
||||||
|
|
||||||
for(y=0; y<8; y++)
|
|
||||||
{
|
|
||||||
bits=0;
|
|
||||||
for(x=0; x<8; x++)
|
|
||||||
{
|
|
||||||
pixel=Read_pixel_function(x+cx*8,y+cy*8);
|
|
||||||
if(pixel>15)
|
|
||||||
{
|
|
||||||
Warning_message("Color above 15 used");
|
|
||||||
// TODO hilite offending block here too?
|
|
||||||
// or make it smarter with color allocation?
|
|
||||||
// However, the palette is fixed to the 16 first colors
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
bits=bits<<1;
|
|
||||||
if (pixel==c1) bits|=1;
|
|
||||||
}
|
|
||||||
bitmap[pos++]=bits;
|
|
||||||
//Write_byte(file,bits&255);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
file = fopen(filename,"wb");
|
file = fopen(filename,"wb");
|
||||||
|
|
||||||
if(!file)
|
if(!file)
|
||||||
{
|
{
|
||||||
Warning_message("File open failed");
|
Warning_message("File open failed");
|
||||||
File_error = 1;
|
File_error = 1;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Write_bytes(file,bitmap,8000) ||
|
if (!Write_bytes(file,bitmap,8000) ||
|
||||||
!Write_bytes(file,colors,1000))
|
!Write_bytes(file,colors,1000))
|
||||||
File_error = 1;
|
File_error = 1;
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Save_C64_multi(char *filename)
|
int Save_C64_multi(char *filename)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
BITS COLOR INFORMATION COMES FROM
|
BITS COLOR INFORMATION COMES FROM
|
||||||
00 Background color #0 (screen color)
|
00 Background color #0 (screen color)
|
||||||
01 Upper 4 bits of screen memory
|
01 Upper 4 bits of screen memory
|
||||||
10 Lower 4 bits of screen memory
|
10 Lower 4 bits of screen memory
|
||||||
11 Color nybble (nybble = 1/2 byte = 4 bits)
|
11 Color nybble (nybble = 1/2 byte = 4 bits)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int cx,cy,x,y,c[4]={0,0,0,0},color,lut[16],bits,pixel,pos=0;
|
int cx,cy,x,y,c[4]={0,0,0,0},color,lut[16],bits,pixel,pos=0;
|
||||||
byte bitmap[8000],screen[1000],nybble[1000];
|
byte bitmap[8000],screen[1000],nybble[1000];
|
||||||
word numcolors,count;
|
word numcolors,count;
|
||||||
dword cusage[256];
|
dword cusage[256];
|
||||||
byte i,background=0;
|
byte i,background=0;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
|
|
||||||
|
numcolors=Count_used_colors(cusage);
|
||||||
|
|
||||||
numcolors=Count_used_colors(cusage);
|
count=0;
|
||||||
|
for(x=0;x<16;x++)
|
||||||
count=0;
|
|
||||||
for(x=0;x<16;x++)
|
|
||||||
{
|
|
||||||
//printf("color %d, pixels %d\n",x,cusage[x]);
|
|
||||||
if(cusage[x]>count)
|
|
||||||
{
|
{
|
||||||
count=cusage[x];
|
//printf("color %d, pixels %d\n",x,cusage[x]);
|
||||||
background=x;
|
if(cusage[x]>count)
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for(cy=0; cy<25; cy++)
|
|
||||||
{
|
|
||||||
//printf("\ny:%2d ",cy);
|
|
||||||
for(cx=0; cx<40; cx++)
|
|
||||||
{
|
|
||||||
numcolors=Count_used_colors_area(cusage,cx*4,cy*8,4,8);
|
|
||||||
if(numcolors>4)
|
|
||||||
{
|
|
||||||
Warning_message("More than 4 colors in 4x8");
|
|
||||||
// TODO hilite offending block
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
color=1;
|
|
||||||
c[0]=background;
|
|
||||||
for(i=0; i<16; i++)
|
|
||||||
{
|
|
||||||
lut[i]=0;
|
|
||||||
if(cusage[i])
|
|
||||||
{
|
{
|
||||||
if(i!=background)
|
count=cusage[x];
|
||||||
{
|
background=x;
|
||||||
lut[i]=color;
|
|
||||||
c[color]=i;
|
|
||||||
color++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
lut[i]=0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
// add to screen and nybble
|
|
||||||
screen[cx+cy*40]=c[1]<<4|c[2];
|
|
||||||
nybble[cx+cy*40]=c[3];
|
|
||||||
//printf("%x%x%x ",c[1],c[2],c[3]);
|
|
||||||
for(y=0;y<8;y++)
|
|
||||||
{
|
|
||||||
bits=0;
|
|
||||||
for(x=0;x<4;x++)
|
|
||||||
{
|
|
||||||
pixel=Read_pixel_function(cx*4+x,cy*8+y);
|
|
||||||
if(pixel>15)
|
|
||||||
{
|
|
||||||
Warning_message("Color above 15 used");
|
|
||||||
// TODO hilite as in hires, you should stay to
|
|
||||||
// the fixed 16 color palette
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
bits=bits<<2;
|
|
||||||
bits|=lut[pixel];
|
|
||||||
|
|
||||||
}
|
|
||||||
//Write_byte(file,bits&255);
|
|
||||||
bitmap[pos++]=bits;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
file = fopen(filename,"wb");
|
for(cy=0; cy<25; cy++)
|
||||||
|
{
|
||||||
|
//printf("\ny:%2d ",cy);
|
||||||
|
for(cx=0; cx<40; cx++)
|
||||||
|
{
|
||||||
|
numcolors=Count_used_colors_area(cusage,cx*4,cy*8,4,8);
|
||||||
|
if(numcolors>4)
|
||||||
|
{
|
||||||
|
Warning_message("More than 4 colors in 4x8");
|
||||||
|
// TODO hilite offending block
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
color=1;
|
||||||
|
c[0]=background;
|
||||||
|
for(i=0; i<16; i++)
|
||||||
|
{
|
||||||
|
lut[i]=0;
|
||||||
|
if(cusage[i])
|
||||||
|
{
|
||||||
|
if(i!=background)
|
||||||
|
{
|
||||||
|
lut[i]=color;
|
||||||
|
c[color]=i;
|
||||||
|
color++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lut[i]=0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// add to screen and nybble
|
||||||
|
screen[cx+cy*40]=c[1]<<4|c[2];
|
||||||
|
nybble[cx+cy*40]=c[3];
|
||||||
|
//printf("%x%x%x ",c[1],c[2],c[3]);
|
||||||
|
for(y=0;y<8;y++)
|
||||||
|
{
|
||||||
|
bits=0;
|
||||||
|
for(x=0;x<4;x++)
|
||||||
|
{
|
||||||
|
pixel=Read_pixel_function(cx*4+x,cy*8+y);
|
||||||
|
if(pixel>15)
|
||||||
|
{
|
||||||
|
Warning_message("Color above 15 used");
|
||||||
|
// TODO hilite as in hires, you should stay to
|
||||||
|
// the fixed 16 color palette
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
bits=bits<<2;
|
||||||
|
bits|=lut[pixel];
|
||||||
|
|
||||||
|
}
|
||||||
|
//Write_byte(file,bits&255);
|
||||||
|
bitmap[pos++]=bits;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(!file)
|
file = fopen(filename,"wb");
|
||||||
{
|
|
||||||
Warning_message("File open failed");
|
if(!file)
|
||||||
File_error = 1;
|
{
|
||||||
return 1;
|
Warning_message("File open failed");
|
||||||
}
|
File_error = 1;
|
||||||
if (!Write_bytes(file,bitmap,8000) ||
|
return 1;
|
||||||
!Write_bytes(file,screen,1000) ||
|
}
|
||||||
!Write_bytes(file,nybble,1000) ||
|
if (!Write_bytes(file,bitmap,8000) ||
|
||||||
!Write_byte(file,background))
|
!Write_bytes(file,screen,1000) ||
|
||||||
File_error = 1;
|
!Write_bytes(file,nybble,1000) ||
|
||||||
|
!Write_byte(file,background))
|
||||||
fclose(file);
|
File_error = 1;
|
||||||
//printf("\nbg:%d\n",background);
|
|
||||||
return 0;
|
fclose(file);
|
||||||
|
//printf("\nbg:%d\n",background);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Save_C64(void)
|
void Save_C64(void)
|
||||||
{
|
{
|
||||||
char filename[MAX_PATH_CHARACTERS];
|
char filename[MAX_PATH_CHARACTERS];
|
||||||
dword numcolors, cusage[256];
|
dword numcolors, cusage[256];
|
||||||
numcolors=Count_used_colors(cusage);
|
numcolors=Count_used_colors(cusage);
|
||||||
|
|
||||||
Get_full_filename(filename,0);
|
|
||||||
|
|
||||||
if (numcolors>16)
|
|
||||||
{
|
|
||||||
Warning_message("Error: Max 16 colors");
|
|
||||||
File_error = 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (((Main_image_width!=320) && (Main_image_width!=160)) || Main_image_height!=200)
|
|
||||||
{
|
|
||||||
Warning_message("must be 320x200 or 160x200");
|
|
||||||
File_error = 1;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Main_image_width==320)
|
Get_full_filename(filename,0);
|
||||||
File_error = Save_C64_hires(filename);
|
|
||||||
else
|
if (numcolors>16)
|
||||||
File_error = Save_C64_multi(filename);
|
{
|
||||||
|
Warning_message("Error: Max 16 colors");
|
||||||
|
File_error = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (((Main_image_width!=320) && (Main_image_width!=160)) || Main_image_height!=200)
|
||||||
|
{
|
||||||
|
Warning_message("must be 320x200 or 160x200");
|
||||||
|
File_error = 1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Main_image_width==320)
|
||||||
|
File_error = Save_C64_hires(filename);
|
||||||
|
else
|
||||||
|
File_error = Save_C64_multi(filename);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user