Skip to content

Commit 1f65a0c

Browse files
committed
fix(zq): more tile page problems from 4-bit: scaling, overlay
1 parent 5f76b78 commit 1f65a0c

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

src/tiles.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ void overlay_tile(tiledata *buf,int32_t dest,int32_t src,int32_t cs,bool backwar
448448

449449
unpack_tile(buf, src, 0, false);
450450

451-
if(buf[src].format>tf4Bit)
451+
// if(buf[src].format>tf4Bit)
452452
{
453453
cs=0;
454454
}
@@ -559,14 +559,17 @@ bool write_tile(tiledata *buf, BITMAP* src, int32_t dest, int32_t x, int32_t y,
559559
return true;
560560
}
561561

562+
// For the editor only, grabbing code mades weird assumptions where it deletes the first tile
563+
// just before drawing it, which relies on it being cached (see top of unpack_tile).
564+
// See draw_grab_scr. Crash would happen from calling `puttile16` after `newtilebuf[0].data=NULL;`.
565+
// No time to work this out just yet, so avoid the fast path in this case.
566+
// This is also need for the bottom two "previous data" tiles to render correctly in grab menu.
567+
bool zq_allow_tile_draw_cache = false;
568+
562569
static const byte* get_tile_bytes(int32_t tile, int32_t flip)
563570
{
564-
// For the editor only, grabbing code mades weird assumptions where it deletes the first tile
565-
// just before drawing it, which relies on it being cached (see top of unpack_tile).
566-
// See draw_grab_scr. Crash would happen from calling `puttile16` after `newtilebuf[0].data=NULL;`.
567-
// No time to work this out just yet, so avoid the fast path in this case.
568571
#if IS_EDITOR
569-
if (flip == 0 && tile != 0)
572+
if (flip == 0 && !zq_allow_tile_draw_cache)
570573
#else
571574
if (flip == 0)
572575
#endif

src/tiles.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ extern bool blank_tile_quarters_table[NEWMAXTILES*4]; //keeps track of bla
2121
extern byte unpackbuf[256];
2222
extern const char *tileformat_string[tfMax];
2323
extern comboclass *combo_class_buf;
24+
extern bool zq_allow_tile_draw_cache;
2425

2526
void register_blank_tiles();
2627
void register_blank_tiles(int32_t max);

src/zq/zq_tiles.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1804,7 +1804,7 @@ void normalize(int32_t tile,int32_t tile2, bool rect_sel, int32_t flip)
18041804
void rotate_tile(int32_t tile, bool backward)
18051805
{
18061806
unfloat_selection();
1807-
unpack_tile(newtilebuf, tile, 0, false);
1807+
unpack_tile(newtilebuf, tile, 0, true);
18081808
byte tempunpackbuf[256];
18091809
byte tempx, tempy;
18101810

@@ -4821,6 +4821,8 @@ void grab(byte(*dest)[256],byte *def, int32_t width, int32_t height, int32_t ofo
48214821
//Grabber is not grabbing to tile pages beyond pg. 252 right now. -ZX 18th June, 2019
48224822
void grab_tile(int32_t tile,int32_t &cs)
48234823
{
4824+
zq_allow_tile_draw_cache = true;
4825+
48244826
int window_w = 640+6+6, window_h = 480+25+6;
48254827
int window_x=(zq_screen_w-window_w)/2;
48264828
int window_y=(zq_screen_h-window_h)/2;
@@ -5469,6 +5471,8 @@ void grab_tile(int32_t tile,int32_t &cs)
54695471
calc_cset_reduce_table(imagepal, cs);
54705472
register_blank_tiles();
54715473
popup_zqdialog_end();
5474+
5475+
zq_allow_tile_draw_cache = false;
54725476
}
54735477

54745478
int32_t show_only_unused_tiles=4; //1 bit: hide used, 2 bit: hide unused, 4 bit: hide blank

0 commit comments

Comments
 (0)