From eb863ef1dc21f25257a38dd8f355ed79e0d0bd64 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 14 Nov 2015 23:40:57 +0000 Subject: [PATCH] Mapster32: introduce DEF command "2dcolidxrange ". is the editorcolor[] starting index is the actual color index start is the actual color index end So, editor colors from onward will be mapped to [ .. min(, 255)]. Takes precedence over '2dcol'. git-svn-id: https://svn.eduke32.com/eduke32@5427 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/defs.c | 15 ++++++++++++++- polymer/eduke32/source/astub.c | 7 +++++-- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/polymer/eduke32/build/src/defs.c b/polymer/eduke32/build/src/defs.c index d039ec040..922e376f2 100644 --- a/polymer/eduke32/build/src/defs.c +++ b/polymer/eduke32/build/src/defs.c @@ -81,7 +81,7 @@ enum scripttoken_t T_ORIGSIZEX,T_ORIGSIZEY, T_UNDEFMODEL,T_UNDEFMODELRANGE,T_UNDEFMODELOF,T_UNDEFTEXTURE,T_UNDEFTEXTURERANGE, T_ALPHAHACK,T_ALPHAHACKRANGE, - T_SPRITECOL,T_2DCOL, + T_SPRITECOL,T_2DCOL,T_2DCOLIDXRANGE, T_FOGPAL, T_LOADGRP, T_DUMMYTILE,T_DUMMYTILERANGE, @@ -367,6 +367,7 @@ static int32_t defsparser(scriptfile *script) { "alphahackrange", T_ALPHAHACKRANGE }, { "spritecol", T_SPRITECOL }, { "2dcol", T_2DCOL }, + { "2dcolidxrange", T_2DCOLIDXRANGE }, { "fogpal", T_FOGPAL }, { "loadgrp", T_LOADGRP }, { "dummytile", T_DUMMYTILE }, @@ -570,6 +571,18 @@ static int32_t defsparser(scriptfile *script) } } break; + case T_2DCOLIDXRANGE: // NOTE: takes precedence over 2dcol, see InitCustomColors() + { + int32_t col, idx, idxend; + + if (scriptfile_getnumber(script,&col)) break; + if (scriptfile_getnumber(script,&idx)) break; + if (scriptfile_getnumber(script,&idxend)) break; + + while ((unsigned)col < 256 && idx <= idxend) + editorcolors[col++] = idx++; + } + break; case T_FOGPAL: { int32_t p,r,g,b; diff --git a/polymer/eduke32/source/astub.c b/polymer/eduke32/source/astub.c index d06d6ed5d..16fa6cc64 100644 --- a/polymer/eduke32/source/astub.c +++ b/polymer/eduke32/source/astub.c @@ -7890,8 +7890,11 @@ static void InitCustomColors(void) for (i = 0; i<256; i++) { - edcol = (palette_t *)&vgapal16[4*i]; - editorcolors[i] = getclosestcol_lim(edcol->b,edcol->g,edcol->r, 239); + if (editorcolors[i] == 0) + { + edcol = (palette_t *)&vgapal16[4*i]; + editorcolors[i] = getclosestcol_lim(edcol->b,edcol->g,edcol->r, 239); + } } }