From b437d458d4f7add241d99f36729b0acb57e13142 Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Wed, 13 Jun 2012 19:50:35 +0000 Subject: [PATCH] CPC Mode 5 fixes : * Be case unsensitive when looking for the GFX-file, * When an underlay is hidden, do not use it and replace it with color 0, 1, 2 or 3. Allows to see pixel data alone or disable rasters on one color, as it's possible to get confused quite easily. git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@1964 416bcca6-2ee7-4201-b75f-2eb2f807beb1 --- src/graph.c | 6 ++++-- src/miscfileformats.c | 23 +++++++++++++++++------ src/pages.c | 5 ++++- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/graph.c b/src/graph.c index 82b03756..7e1bae28 100644 --- a/src/graph.c +++ b/src/graph.c @@ -3143,7 +3143,8 @@ void Pixel_in_screen_overlay(word x,word y,byte color) // Paste in depth buffer *(Main_visible_image_depth_buffer.Image+x+y*Main_image_width)=color; // Fetch pixel color from the target raster layer - color=*(Main_backups->Pages->Image[color].Pixels + x+y*Main_image_width); + if (Main_layers_visible & (1 << color)) + color=*(Main_backups->Pages->Image[color].Pixels + x+y*Main_image_width); // Draw that color on the visible image buffer *(x+y*Main_image_width+Main_screen)=color; } @@ -3159,7 +3160,8 @@ void Pixel_in_screen_overlay_with_preview(word x,word y,byte color) // Paste in depth buffer *(Main_visible_image_depth_buffer.Image+x+y*Main_image_width)=color; // Fetch pixel color from the target raster layer - color=*(Main_backups->Pages->Image[color].Pixels + x+y*Main_image_width); + if (Main_layers_visible & (1 << color)) + color=*(Main_backups->Pages->Image[color].Pixels + x+y*Main_image_width); // Draw that color on the visible image buffer *(x+y*Main_image_width+Main_screen)=color; diff --git a/src/miscfileformats.c b/src/miscfileformats.c index cbd1614d..cda0f312 100644 --- a/src/miscfileformats.c +++ b/src/miscfileformats.c @@ -3101,14 +3101,25 @@ void Load_CM5(T_IO_Context* context) fclose(file); // Load the pixeldata to the 5th layer - filename[strlen(filename) - 3] = 0; - strcat(filename,"gfx"); - if (!(file = fopen(filename, "rb"))) { - File_error = 1; - return; - } + char* ext = filename + strlen(filename) - 3; + int idx = 8; + do { + if (-- idx < 0) + { + File_error = 1; + return; + } + ext[0] = (idx & 1) ? 'g':'G'; + ext[1] = (idx & 2) ? 'f':'F'; + ext[2] = (idx & 4) ? 'x':'X'; + + printf("trying to load %s...\n", filename); + + file = fopen(filename, "rb"); + } while(file == NULL); + } Set_loading_layer(context, 4); for (ty = 0; ty < 256; ty++) diff --git a/src/pages.c b/src/pages.c index fe511e5c..0864482c 100644 --- a/src/pages.c +++ b/src/pages.c @@ -212,7 +212,10 @@ void Redraw_layered_image(void) for (i=0; i< Main_image_width*Main_image_height; i++) { layer = *(Main_backups->Pages->Image[4].Pixels+i); - Main_visible_image.Image[i]=*(Main_backups->Pages->Image[layer].Pixels+i); + if (Main_layers_visible & (1 << layer)) + Main_visible_image.Image[i]=*(Main_backups->Pages->Image[layer].Pixels+i); + else + Main_visible_image.Image[i] = layer; } // Copy it to the depth buffer