reindent Save_C64_multi() and Save_C64_fli()
This commit is contained in:
parent
2b22a7fe1d
commit
cb5dd7ae69
@ -2726,7 +2726,6 @@ int Save_C64_hires(T_IO_Context *context, byte saveWhat, byte loadAddr)
|
|||||||
if (pixel==c2) bits|=1;
|
if (pixel==c2) bits|=1;
|
||||||
}
|
}
|
||||||
bitmap[pos++]=bits;
|
bitmap[pos++]=bits;
|
||||||
//Write_byte(file,bits&255);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2862,137 +2861,123 @@ int Save_C64_multi(T_IO_Context *context, byte saveWhat, byte loadAddr)
|
|||||||
(int)background, (int)background, (unsigned)candidates, (unsigned)invalids);
|
(int)background, (int)background, (unsigned)candidates, (unsigned)invalids);
|
||||||
|
|
||||||
|
|
||||||
// Now that we know which color is the background, we can encode the cells
|
// Now that we know which color is the background, we can encode the cells
|
||||||
for(cy=0; cy<25; cy++)
|
for(cy=0; cy<25; cy++)
|
||||||
{
|
{
|
||||||
for(cx=0; cx<40; cx++)
|
for(cx=0; cx<40; cx++)
|
||||||
{
|
|
||||||
numcolors=Count_used_colors_area(cusage,cx*4,cy*8,4,8);
|
|
||||||
if(numcolors>4)
|
|
||||||
{
|
|
||||||
Warning_with_format("More than 4 colors\nin 4x8 pixel cell: (%d, %d)\nRect: (%d, %d, %d, %d)", cx, cy, cx * 4, cy * 8, cx * 4 + 3, cy * 8 + 7);
|
|
||||||
// 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_ram and color_ram
|
|
||||||
screen_ram[cx+cy*40]=c[1]<<4|c[2];
|
|
||||||
color_ram[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 = Get_pixel(context, cx*4+x,cy*8+y);
|
|
||||||
bits = (bits << 2) | lut[pixel];
|
|
||||||
|
|
||||||
}
|
|
||||||
bitmap[pos++]=bits;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
file = Open_file_write(context);
|
|
||||||
|
|
||||||
if(!file)
|
|
||||||
{
|
{
|
||||||
Warning_message("File open failed");
|
numcolors=Count_used_colors_area(cusage,cx*4,cy*8,4,8);
|
||||||
File_error = 2;
|
if(numcolors>4)
|
||||||
return 2;
|
{
|
||||||
|
Warning_with_format("More than 4 colors\nin 4x8 pixel cell: (%d, %d)\nRect: (%d, %d, %d, %d)", cx, cy, cx * 4, cy * 8, cx * 4 + 3, cy * 8 + 7);
|
||||||
|
// TODO hilite offending block
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
color=1;
|
||||||
|
c[0]=background;
|
||||||
|
for(i=0; i<16; i++)
|
||||||
|
{
|
||||||
|
lut[i]=0;
|
||||||
|
if(cusage[i] && (i!=background))
|
||||||
|
{
|
||||||
|
lut[i]=color;
|
||||||
|
c[color]=i;
|
||||||
|
color++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// add to screen_ram and color_ram
|
||||||
|
screen_ram[cx+cy*40]=c[1]<<4|c[2];
|
||||||
|
color_ram[cx+cy*40]=c[3];
|
||||||
|
|
||||||
|
for(y=0;y<8;y++)
|
||||||
|
{
|
||||||
|
bits=0;
|
||||||
|
for(x=0;x<4;x++)
|
||||||
|
{
|
||||||
|
pixel = Get_pixel(context, cx*4+x,cy*8+y);
|
||||||
|
bits = (bits << 2) | lut[pixel];
|
||||||
|
}
|
||||||
|
bitmap[pos++]=bits;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
setvbuf(file, NULL, _IOFBF, 64*1024);
|
file = Open_file_write(context);
|
||||||
|
|
||||||
if (loadAddr)
|
if(!file)
|
||||||
{
|
{
|
||||||
Write_byte(file,0);
|
Warning_message("File open failed");
|
||||||
Write_byte(file,loadAddr);
|
File_error = 2;
|
||||||
}
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (saveWhat==0 || saveWhat==1)
|
setvbuf(file, NULL, _IOFBF, 64*1024);
|
||||||
Write_bytes(file,bitmap,8000);
|
|
||||||
|
|
||||||
if (saveWhat==0 || saveWhat==2)
|
if (loadAddr)
|
||||||
Write_bytes(file,screen_ram,1000);
|
{
|
||||||
|
Write_byte(file,0);
|
||||||
|
Write_byte(file,loadAddr);
|
||||||
|
}
|
||||||
|
|
||||||
if (saveWhat==0 || saveWhat==3)
|
if (saveWhat==0 || saveWhat==1)
|
||||||
Write_bytes(file,color_ram,1000);
|
Write_bytes(file,bitmap,8000);
|
||||||
|
|
||||||
if (saveWhat==0)
|
if (saveWhat==0 || saveWhat==2)
|
||||||
Write_byte(file,background);
|
Write_bytes(file,screen_ram,1000);
|
||||||
|
|
||||||
fclose(file);
|
if (saveWhat==0 || saveWhat==3)
|
||||||
return 0;
|
Write_bytes(file,color_ram,1000);
|
||||||
|
|
||||||
|
if (saveWhat==0)
|
||||||
|
Write_byte(file,background);
|
||||||
|
|
||||||
|
fclose(file);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Save_C64_fli(T_IO_Context * context, byte saveWhat, byte loadAddr)
|
int Save_C64_fli(T_IO_Context * context, byte saveWhat, byte loadAddr)
|
||||||
{
|
{
|
||||||
|
FILE *file;
|
||||||
|
byte file_buffer[17474];
|
||||||
|
|
||||||
FILE *file;
|
memset(file_buffer,0,sizeof(file_buffer));
|
||||||
byte file_buffer[17474];
|
|
||||||
|
|
||||||
memset(file_buffer,0,sizeof(file_buffer));
|
if (C64_FLI(file_buffer+9474, file_buffer+1282, file_buffer+258, file_buffer+2))
|
||||||
|
{
|
||||||
|
File_error=1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (C64_FLI(file_buffer+9474, file_buffer+1282, file_buffer+258, file_buffer+2))
|
file = Open_file_write(context);
|
||||||
{
|
|
||||||
File_error=1;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
file = Open_file_write(context);
|
if(!file)
|
||||||
|
{
|
||||||
|
Warning_message("File open failed");
|
||||||
|
File_error = 1;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
if(!file)
|
if (loadAddr)
|
||||||
{
|
{
|
||||||
Warning_message("File open failed");
|
file_buffer[0]=0;
|
||||||
File_error = 1;
|
file_buffer[1]=loadAddr;
|
||||||
return 1;
|
Write_bytes(file,file_buffer,2);
|
||||||
}
|
}
|
||||||
|
|
||||||
setvbuf(file, NULL, _IOFBF, 64*1024);
|
if (saveWhat==0)
|
||||||
|
Write_bytes(file,file_buffer+2,256); // Background colors for lines 0-199 (+ 56bytes padding)
|
||||||
|
|
||||||
if (loadAddr)
|
if (saveWhat==0 || saveWhat==3)
|
||||||
{
|
Write_bytes(file,file_buffer+258,1024); // Color RAM (1000 bytes + padding 24)
|
||||||
file_buffer[0]=0;
|
|
||||||
file_buffer[1]=loadAddr;
|
|
||||||
Write_bytes(file,file_buffer,2);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (saveWhat==0)
|
if (saveWhat==0 || saveWhat==1)
|
||||||
Write_bytes(file,file_buffer+2,256);
|
Write_bytes(file,file_buffer+1282,8192); // Screen RAMs 8 x (1000 bytes + padding 24)
|
||||||
|
|
||||||
if (saveWhat==0 || saveWhat==3)
|
if (saveWhat==0 || saveWhat==2)
|
||||||
Write_bytes(file,file_buffer+258,1024);
|
Write_bytes(file,file_buffer+9474,8000); // BitMap
|
||||||
|
|
||||||
if (saveWhat==0 || saveWhat==1)
|
fclose(file);
|
||||||
Write_bytes(file,file_buffer+1282,8192);
|
return 0;
|
||||||
|
|
||||||
if (saveWhat==0 || saveWhat==2)
|
|
||||||
Write_bytes(file,file_buffer+9474,8000);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fclose(file);
|
|
||||||
//printf("\nbg:%d\n",background);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Save_C64(T_IO_Context * context)
|
void Save_C64(T_IO_Context * context)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user