oldies.c/.h: Document C64 FLI functions

This commit is contained in:
Thomas Bernard 2018-11-06 22:32:31 +01:00
parent 4b52718c1e
commit 4c8e56101f
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
2 changed files with 26 additions and 10 deletions

View File

@ -27,6 +27,7 @@
#include <stdlib.h>
#include <math.h>
#include "struct.h"
#include "oldies.h"
#include "global.h"
#include "errors.h"
#include "misc.h"
@ -35,12 +36,12 @@
#include "windows.h"
#include "layers.h"
void Pixel_in_layer(word x,word y, byte layer, byte color)
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;
}
byte C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background)
int C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background)
{
word used_colors[200][40];
word block_used_colors[25][40];
@ -346,7 +347,7 @@ byte C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background)
}
byte C64_FLI_enforcer(void)
int C64_FLI_enforcer(void)
{
byte background[200];
byte bitmap[8000];
@ -357,12 +358,15 @@ byte C64_FLI_enforcer(void)
byte c[4];
// Checks
if (Main.image_width != 160)
if (Main.image_width != 160 || Main.image_height != 200)
{
GFX2_Log(GFX2_WARNING, "C64_FLI_enforcer() requires 160x200 image resolution\n");
return 1;
if (Main.image_height != 200)
return 1;
if (Main.backups->Pages->Nb_layers != 4)
}
if (Main.backups->Pages->Nb_layers != 4) {
GFX2_Log(GFX2_WARNING, "C64_FLI_enforcer() requires 4 layers\n");
return 2;
}
Backup_layers(3);
@ -388,7 +392,7 @@ byte C64_FLI_enforcer(void)
{
int color=c[(pixel&3)];
pixel>>=2;
Pixel_in_layer(col*4+(3-x),row*8+y,3,color);
Set_Pixel_in_layer(col*4+(3-x),row*8+y,3,color);
}
}
}

View File

@ -18,7 +18,19 @@
along with Grafx2; if not, see <http://www.gnu.org/licenses/>
*/
byte C64_FLI(byte *bitmap, byte *screen_ram, byte *color_ram, byte *background);
///@file oldies.h
/// C64 FLI functions
byte C64_FLI_enforcer(void);
/**
* Save a 3 layer picture to C64 FLI format
*
* @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_enforcer(void);