* Avoid crash when enabling mode 5 without enough layers (they are created)
* Display error code to terminal when loading an image fails. Mainly for debugging purposes. * Use different error codes for different errors in ILBM loader. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1818 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
parent
e875597964
commit
6672966661
@ -29,6 +29,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "brush.h"
|
||||||
#include "buttons.h"
|
#include "buttons.h"
|
||||||
#include "engine.h"
|
#include "engine.h"
|
||||||
#include "global.h"
|
#include "global.h"
|
||||||
@ -36,11 +37,11 @@
|
|||||||
#include "help.h"
|
#include "help.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
#include "misc.h"
|
#include "misc.h"
|
||||||
|
#include "pages.h"
|
||||||
#include "readline.h"
|
#include "readline.h"
|
||||||
#include "sdlscreen.h"
|
#include "sdlscreen.h"
|
||||||
#include "struct.h"
|
#include "struct.h"
|
||||||
#include "windows.h"
|
#include "windows.h"
|
||||||
#include "brush.h"
|
|
||||||
|
|
||||||
//---------- Menu dans lequel on tagge des couleurs (genre Stencil) ----------
|
//---------- Menu dans lequel on tagge des couleurs (genre Stencil) ----------
|
||||||
void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_cancel, const char *help_section, word close_shortcut)
|
void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_cancel, const char *help_section, word close_shortcut)
|
||||||
@ -166,6 +167,20 @@ void Menu_tag_colors(char * window_title, byte * table, byte * mode, byte can_ca
|
|||||||
void Button_Constraint_mode(void)
|
void Button_Constraint_mode(void)
|
||||||
{
|
{
|
||||||
Constraint_mode=!Constraint_mode;
|
Constraint_mode=!Constraint_mode;
|
||||||
|
|
||||||
|
if (Constraint_mode)
|
||||||
|
{
|
||||||
|
// TODO backup
|
||||||
|
// CPC Mode 5 - ensure there are at least 5 layers
|
||||||
|
while(Main_backups->Pages->Nb_layers < 5)
|
||||||
|
{
|
||||||
|
Add_layer(Main_backups, 0);
|
||||||
|
// Add layers below, so the picture is kept on the top one
|
||||||
|
// (the valuable pixel data)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO set the palette to a CPC one ?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -636,14 +636,14 @@ void Load_LBM(T_IO_Context * context)
|
|||||||
// On lit l'octet de padding du CMAP si la taille est impaire
|
// On lit l'octet de padding du CMAP si la taille est impaire
|
||||||
if (nb_colors&1)
|
if (nb_colors&1)
|
||||||
if (Read_byte(LBM_file,&temp_byte))
|
if (Read_byte(LBM_file,&temp_byte))
|
||||||
File_error=2;
|
File_error=20;
|
||||||
|
|
||||||
// Keep reading sections until we find the body
|
// Keep reading sections until we find the body
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (! Read_bytes(LBM_file,section,4))
|
if (! Read_bytes(LBM_file,section,4))
|
||||||
{
|
{
|
||||||
File_error=2;
|
File_error=46;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Found body : stop searching
|
// Found body : stop searching
|
||||||
@ -683,7 +683,7 @@ void Load_LBM(T_IO_Context * context)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
File_error=2;
|
File_error=47;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -692,7 +692,7 @@ void Load_LBM(T_IO_Context * context)
|
|||||||
// ignore any number of unknown sections
|
// ignore any number of unknown sections
|
||||||
if (!LBM_Skip_section())
|
if (!LBM_Skip_section())
|
||||||
{
|
{
|
||||||
File_error=2;
|
File_error=48;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -733,7 +733,7 @@ void Load_LBM(T_IO_Context * context)
|
|||||||
if (Read_bytes(LBM_file,LBM_buffer,line_size))
|
if (Read_bytes(LBM_file,LBM_buffer,line_size))
|
||||||
Draw_ILBM_line(context, y_pos,real_line_size);
|
Draw_ILBM_line(context, y_pos,real_line_size);
|
||||||
else
|
else
|
||||||
File_error=2;
|
File_error=21;
|
||||||
}
|
}
|
||||||
free(LBM_buffer);
|
free(LBM_buffer);
|
||||||
LBM_buffer = NULL;
|
LBM_buffer = NULL;
|
||||||
@ -750,7 +750,7 @@ void Load_LBM(T_IO_Context * context)
|
|||||||
{
|
{
|
||||||
if(Read_byte(LBM_file, &temp_byte)!=1)
|
if(Read_byte(LBM_file, &temp_byte)!=1)
|
||||||
{
|
{
|
||||||
File_error=2;
|
File_error=22;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Si temp_byte > 127 alors il faut répéter 256-'temp_byte' fois la couleur de l'octet suivant
|
// Si temp_byte > 127 alors il faut répéter 256-'temp_byte' fois la couleur de l'octet suivant
|
||||||
@ -759,7 +759,7 @@ void Load_LBM(T_IO_Context * context)
|
|||||||
{
|
{
|
||||||
if(Read_byte(LBM_file, &color)!=1)
|
if(Read_byte(LBM_file, &color)!=1)
|
||||||
{
|
{
|
||||||
File_error=2;
|
File_error=23;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
b256=(short)(256-temp_byte);
|
b256=(short)(256-temp_byte);
|
||||||
@ -767,12 +767,12 @@ void Load_LBM(T_IO_Context * context)
|
|||||||
if (x_pos<line_size)
|
if (x_pos<line_size)
|
||||||
LBM_buffer[x_pos++]=color;
|
LBM_buffer[x_pos++]=color;
|
||||||
else
|
else
|
||||||
File_error=2;
|
File_error=24;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
for (counter=0; counter<=(short)(temp_byte); counter++)
|
for (counter=0; counter<=(short)(temp_byte); counter++)
|
||||||
if (x_pos>=line_size || Read_byte(LBM_file, &(LBM_buffer[x_pos++]))!=1)
|
if (x_pos>=line_size || Read_byte(LBM_file, &(LBM_buffer[x_pos++]))!=1)
|
||||||
File_error=2;
|
File_error=25;
|
||||||
}
|
}
|
||||||
if (!File_error)
|
if (!File_error)
|
||||||
Draw_ILBM_line(context, y_pos,real_line_size);
|
Draw_ILBM_line(context, y_pos,real_line_size);
|
||||||
@ -796,7 +796,7 @@ void Load_LBM(T_IO_Context * context)
|
|||||||
for (x_pos=0; x_pos<context->Width; x_pos++)
|
for (x_pos=0; x_pos<context->Width; x_pos++)
|
||||||
Set_pixel(context, x_pos,y_pos,LBM_buffer[x_pos]);
|
Set_pixel(context, x_pos,y_pos,LBM_buffer[x_pos]);
|
||||||
else
|
else
|
||||||
File_error=2;
|
File_error=26;
|
||||||
}
|
}
|
||||||
free(LBM_buffer);
|
free(LBM_buffer);
|
||||||
LBM_buffer = NULL;
|
LBM_buffer = NULL;
|
||||||
@ -810,14 +810,14 @@ void Load_LBM(T_IO_Context * context)
|
|||||||
{
|
{
|
||||||
if(Read_byte(LBM_file, &temp_byte)!=1)
|
if(Read_byte(LBM_file, &temp_byte)!=1)
|
||||||
{
|
{
|
||||||
File_error=2;
|
File_error=27;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (temp_byte>127)
|
if (temp_byte>127)
|
||||||
{
|
{
|
||||||
if(Read_byte(LBM_file, &color)!=1)
|
if(Read_byte(LBM_file, &color)!=1)
|
||||||
{
|
{
|
||||||
File_error=2;
|
File_error=28;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
b256=256-temp_byte;
|
b256=256-temp_byte;
|
||||||
@ -830,7 +830,7 @@ void Load_LBM(T_IO_Context * context)
|
|||||||
byte byte_read=0;
|
byte byte_read=0;
|
||||||
if(Read_byte(LBM_file, &byte_read)!=1)
|
if(Read_byte(LBM_file, &byte_read)!=1)
|
||||||
{
|
{
|
||||||
File_error=2;
|
File_error=29;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Set_pixel(context, x_pos++,y_pos,byte_read);
|
Set_pixel(context, x_pos++,y_pos,byte_read);
|
||||||
|
|||||||
@ -624,7 +624,7 @@ void Load_image(T_IO_Context *context)
|
|||||||
|
|
||||||
if (File_error>0)
|
if (File_error>0)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"Unable to load file %s!\n",context->File_name);
|
fprintf(stderr,"Unable to load file %s (error %d)!\n",context->File_name, File_error);
|
||||||
if (context->Type!=CONTEXT_SURFACE)
|
if (context->Type!=CONTEXT_SURFACE)
|
||||||
Error(0);
|
Error(0);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user