change C64_FLI() to use T_IO_Context
This commit is contained in:
parent
28fb91f265
commit
84068c5516
@ -1343,10 +1343,12 @@ void Main_handler(void)
|
||||
Layer_activate((key_index-SPECIAL_LAYER1_TOGGLE)/2, RIGHT_SIDE);
|
||||
action++;
|
||||
break;
|
||||
#if 0
|
||||
case SPECIAL_FORMAT_CHECKER:
|
||||
C64_FLI_enforcer();
|
||||
action++;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case SPECIAL_REPEAT_SCRIPT:
|
||||
#ifdef __ENABLE_LUA__
|
||||
|
||||
@ -114,7 +114,7 @@ const T_Format File_formats[] = {
|
||||
{FORMAT_KCF, " kcf", Test_KCF, Load_KCF, Save_KCF, 1, 0, 0, "kcf", "kcf"},
|
||||
{FORMAT_PAL, " pal", Test_PAL, Load_PAL, Save_PAL, 1, 0, 0, "pal", "pal"},
|
||||
{FORMAT_GPL, " gpl", Test_GPL, Load_GPL, Save_GPL, 1, 0, 0, "gpl", "gpl"},
|
||||
{FORMAT_C64, " c64", Test_C64, Load_C64, Save_C64, 0, 1, 0, "c64",
|
||||
{FORMAT_C64, " c64", Test_C64, Load_C64, Save_C64, 0, 1, 1, "c64",
|
||||
"c64;p64;a64;pi;rp;aas;art;dd;iph;ipt;hpc;ocp;koa;koala;fli;bml;cdu;prg;pmg;rpm"},
|
||||
{FORMAT_SCR, " cpc", Test_SCR, Load_SCR, Save_SCR, 0, 0, 0, "scr", "cpc;scr;win"},
|
||||
{FORMAT_CM5, " cm5", Test_CM5, Load_CM5, Save_CM5, 0, 0, 1, "cm5", "cm5"},
|
||||
|
||||
@ -3748,7 +3748,7 @@ int Save_C64_fli(T_IO_Context * context, byte saveWhat, byte loadAddr)
|
||||
|
||||
memset(file_buffer,0,sizeof(file_buffer));
|
||||
|
||||
switch(C64_FLI(file_buffer+9474, file_buffer+1282, file_buffer+258, file_buffer+2))
|
||||
switch(C64_FLI(context, file_buffer+9474, file_buffer+1282, file_buffer+258, file_buffer+2))
|
||||
{
|
||||
case 0: // OK
|
||||
break;
|
||||
@ -3831,10 +3831,11 @@ void Save_C64(T_IO_Context * context)
|
||||
return;
|
||||
}
|
||||
|
||||
Set_saving_layer(context, 0);
|
||||
switch (saveFormat)
|
||||
{
|
||||
case F_fli:
|
||||
if (Main.backups->Pages->Nb_layers < 3)
|
||||
if (context->Nb_layers < 3)
|
||||
File_error = Save_C64_fli_monolayer(context, saveWhat, loadAddr);
|
||||
else
|
||||
File_error = Save_C64_fli(context, saveWhat, loadAddr);
|
||||
|
||||
27
src/oldies.c
27
src/oldies.c
@ -46,12 +46,14 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
static void Set_Pixel_in_layer(word x,word y, byte layer, byte color)
|
||||
{
|
||||
*((y)*Main.image_width+(x)+Main.backups->Pages->Image[layer].Pixels)=color;
|
||||
}
|
||||
#endif
|
||||
|
||||
int C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background)
|
||||
int C64_FLI(T_IO_Context * context, byte *bitmap, byte *screen_ram, byte *color_ram, byte *background)
|
||||
{
|
||||
word used_colors[200][40];
|
||||
word block_used_colors[25][40];
|
||||
@ -67,9 +69,9 @@ int C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background)
|
||||
const byte no_color=16;
|
||||
|
||||
// Prerequisites
|
||||
if (Main.backups->Pages->Nb_layers < 3)
|
||||
if (context->Nb_layers < 3)
|
||||
return 1;
|
||||
if (Main.image_width != 160 || Main.image_height != 200)
|
||||
if (context->Width != 160 || context->Height != 200)
|
||||
return 2;
|
||||
|
||||
memset(used_colors,0,200*40*sizeof(word));
|
||||
@ -80,23 +82,25 @@ int C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background)
|
||||
// Initialize these as "unset"
|
||||
memset(line_color,no_color,200*sizeof(byte));
|
||||
memset(block_color,no_color,25*40*sizeof(byte));
|
||||
|
||||
|
||||
// Examine all 4-pixel blocks to fill used_colors[][]
|
||||
Set_saving_layer(context, 2);
|
||||
for (row=0;row<200;row++)
|
||||
{
|
||||
for (col=0;col<40;col++)
|
||||
{
|
||||
for (x=0;x<4;x++)
|
||||
{
|
||||
byte c=*((row)*Main.image_width+(col*4+x)+Main.backups->Pages->Image[2].Pixels);
|
||||
byte c = Get_pixel(context, col*4+x, row);
|
||||
used_colors[row][col] |= 1<<c;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Get "mandatory colors" from layer 1
|
||||
Set_saving_layer(context, 0);
|
||||
for (row=0;row<200;row++)
|
||||
{
|
||||
byte c=*((row)*Main.image_width+0+Main.backups->Pages->Image[0].Pixels);
|
||||
byte c = Get_pixel(context, 0, row);
|
||||
if (c<16)
|
||||
{
|
||||
line_color[row]=c;
|
||||
@ -108,11 +112,12 @@ int C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background)
|
||||
}
|
||||
}
|
||||
// Get "mandatory colors" from layer 2
|
||||
Set_saving_layer(context, 1);
|
||||
for (row=0;row<200;row+=8)
|
||||
{
|
||||
for (col=0;col<40;col++)
|
||||
{
|
||||
byte c=*((row)*Main.image_width+(col*4)+Main.backups->Pages->Image[1].Pixels);
|
||||
byte c = Get_pixel(context, col*4, row);
|
||||
if (c<16)
|
||||
{
|
||||
block_color[row/8][col]=c;
|
||||
@ -295,7 +300,9 @@ int C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Screen RAMs and Bitmap
|
||||
Set_saving_layer(context, 2);
|
||||
for(row=0; row<25; row++)
|
||||
{
|
||||
for(col=0; col<40; col++)
|
||||
@ -324,7 +331,7 @@ int C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background)
|
||||
for(x=0; x<4; x++)
|
||||
{
|
||||
byte bits;
|
||||
byte c=*((row*8+y)*Main.image_width+(col*4+x)+Main.backups->Pages->Image[2].Pixels);
|
||||
byte c = Get_pixel(context, col*4+x, row*8+y);
|
||||
|
||||
if (c==line_color[row*8+y])
|
||||
// BG color
|
||||
@ -357,6 +364,7 @@ int C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background)
|
||||
|
||||
}
|
||||
|
||||
#if 0
|
||||
int C64_FLI_enforcer(void)
|
||||
{
|
||||
byte background[200];
|
||||
@ -427,6 +435,7 @@ int C64_FLI_enforcer(void)
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
void C64_set_palette(T_Components * palette)
|
||||
{
|
||||
|
||||
@ -22,6 +22,8 @@
|
||||
///@file oldies.h
|
||||
/// functions relative to old computers (Commodore 64, Thomsons MO/TO, Amstrad CPC, ZX Spectrum, etc.)
|
||||
|
||||
#include "loadsave.h"
|
||||
|
||||
/** @defgroup c64 Commodore 64
|
||||
* Some C64 video mode related functions
|
||||
* @{
|
||||
@ -29,14 +31,16 @@
|
||||
/**
|
||||
* Save a 3 layer picture to C64 FLI format
|
||||
*
|
||||
* @param context the Save context
|
||||
* @param bitmap a 8000 byte buffer to store bitmap data
|
||||
* @param screen_ram a 8192 byte buffer to store the 8 screen RAMs
|
||||
* @param color_ram a 1000 byte buffer to store the color RAM
|
||||
* @param background a 200 byte buffer to store the background colors
|
||||
* @return 0 for success, 1 if the picture is less than 3 layers, 2 if the picture dimensions are not 160x200
|
||||
*/
|
||||
int C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background);
|
||||
int C64_FLI(T_IO_Context * context, byte *bitmap, byte *screen_ram, byte *color_ram, byte *background);
|
||||
|
||||
#if 0
|
||||
/**
|
||||
* FLI Check/enforcer
|
||||
*
|
||||
@ -46,6 +50,7 @@ int C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background);
|
||||
* @return 0 for success, 2 if the picture is not 4 layers, 1 if the picture dimensions are not 160x200
|
||||
*/
|
||||
int C64_FLI_enforcer(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Set the 16 colors Commodore 64 palette
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user