m32script: added BUILD functions getclosestcol and divscale, made 2d drawing commands accept VGA-palette colors (-1 through -255) in addition to editor colors, made 2d mode show Polymer SE light outlines

git-svn-id: https://svn.eduke32.com/eduke32@1683 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2010-08-03 22:21:13 +00:00
parent fff9bbadd9
commit 2f15e237f7
4 changed files with 108 additions and 6 deletions

View file

@ -4,6 +4,7 @@
include names.h include names.h
// flag 1: per-block (top-level, event, or state) variable // flag 1: per-block (top-level, event, or state) variable
gamevar h 0 1
gamevar i 0 1 gamevar i 0 1
gamevar j 0 1 gamevar j 0 1
gamevar k 0 1 gamevar k 0 1
@ -13,9 +14,17 @@ gamevar p 0 1
gamevar q 0 1 gamevar q 0 1
gamevar r 0 1 gamevar r 0 1
gamearray xx 10
gamearray yy 10
gamevar c 0 0
gamevar d 0 0
gamevar x 0 0 gamevar x 0 0
gamevar y 0 0 gamevar y 0 0
gamevar x2 0 0
gamevar y2 0 0
gamevar z 0 0 gamevar z 0 0
gamevar frac 0 0
gamevar gi 0 0 gamevar gi 0 0
gamevar gj 0 0 gamevar gj 0 0
@ -29,6 +38,8 @@ gamevar dang 0 0
gamevar tmp 0 0 gamevar tmp 0 0
gamevar cnt 0 0 gamevar cnt 0 0
gamevar thecount 0 0
gamevar davr 65536 0 gamevar davr 65536 0
gamevar dayx 65536 0 gamevar dayx 65536 0
@ -50,8 +61,9 @@ definequote 6 time: %d ms
definequote 7 door sector not an island sector! definequote 7 door sector not an island sector!
definequote 8 door sector has no SE sprite! definequote 8 door sector has no SE sprite!
//light sector x y z range r g b radi fade angle horiz mins maxs prio tile //light x y z r g b mins maxs
definequote 9 light %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d definequote 9 light %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d
// sec range radius fade ang horiz prio tile
definequote 10 --PRLIGHTS-- definequote 10 --PRLIGHTS--
definequote 11 --ENDPRLIGHTS-- definequote 11 --ENDPRLIGHTS--
@ -60,7 +72,7 @@ definequote 13 GREEN:
definequote 14 BLUE: definequote 14 BLUE:
definequote 15 x/yoffset: %d %d definequote 15 x/yoffset: %d %d
definequote 16 (r/g/b)color: %d %d %d definequote 16 RGB color: %d %d %d
definequote 17 PICNUM: definequote 17 PICNUM:
definequote 18 NUMBER KEY: %d (SCANCODE: %d) definequote 18 NUMBER KEY: %d (SCANCODE: %d)
@ -154,8 +166,10 @@ defstate printlights
else else
set l 2 set l 2
} }
// range r g b
qsprintf TQUOTE 9 .sectnum .x .y .z .hitag .xvel .yvel .zvel qsprintf TQUOTE 9 .sectnum .x .y .z .hitag .xvel .yvel .zvel
j k .ang .extra .xoffset .yoffset l .owner j k .ang .extra .xoffset .yoffset l .owner
// radius fade horiz minshade maxshade prio tile
print TQUOTE print TQUOTE
} }
print 11 print 11
@ -472,6 +486,69 @@ onevent EVENT_DRAW2DSCREEN
ifactor LIZTROOP ifactor LIZTROOP
drawcircle16b sprite[i].x sprite[i].y 256 drawcol drawcircle16b sprite[i].x sprite[i].y 256 drawcol
*/ */
////////// polymer light 2d projections //////////
set tmp drawlinepat
set drawlinepat 0x11111111
for i spritesofsector cursectnum
{
ifactor SECTOREFFECTOR
{
ife .lotag 49 // point light
{
set d .hitag // light distance
mul d d, mul d 2, sqrt d d, div d 2
getclosestcol .xvel .yvel .zvel c // light color
inv c
set x .x, set x2 .x, set y .y, set y2 .y
add x d, add y d, sub x2 d, sub y2 d
drawline16b x y x2 y2 c
set x .x, set x2 .x, set y .y, set y2 .y
add x d, sub y d, sub x2 d, add y2 d
drawline16b x y x2 y2 c
drawcircle16b .x .y .hitag c
}
else ife .lotag 50 // spot light
{
set d .hitag // light distance
and d 65535
set r 128, sub r .shade, shiftl r 1 // light cone radius (BUILD angles)
getclosestcol .xvel .yvel .zvel c // light color
inv c
set x .x, set y .y, add x d
rotatepoint .x .y x y .ang x y
set h .extra // horiz
sub h 100
set tmp h, mul tmp tmp, add tmp 40000
sqrt tmp tmp
divscale h 200 tmp 15 // h: horizontal distance fraction
set dx .x, sub dx x
set dy .y, sub dy y
set tmp 32768, sub tmp h
mulscale dx dx tmp 15
mulscale dy dy tmp 15
set tmp 0, sub tmp r
rotatepoint .x .y x y tmp xx[0] yy[0]
set tmp 0, add tmp r
rotatepoint .x .y x y tmp xx[1] yy[1]
add xx[0] dx, add yy[0] dy
add xx[1] dx, add yy[1] dy
drawline16b .x .y xx[0] yy[0] c
drawline16b .x .y xx[1] yy[1] c
}
}
}
set drawlinepat tmp
endevent endevent
// LOCATORS auto-incrementer // LOCATORS auto-incrementer

View file

@ -241,6 +241,7 @@ const char *keyw[] =
"inv", // inversion function.. not internal "inv", // inversion function.. not internal
"sqrt", "sqrt",
"mulscale", "mulscale",
"divscale",
"dist", "dist",
"ldist", "ldist",
"getangle", "getangle",
@ -332,6 +333,7 @@ const char *keyw[] =
"nextspritesect", "nextspritesect",
"sectorofwall", "sectorofwall",
"fixrepeats", "fixrepeats",
"getclosestcol",
"addlogvar", "addlogvar",
"addlog", "addlog",
@ -2618,6 +2620,7 @@ repeatcase:
} }
case CON_MULSCALE: case CON_MULSCALE:
case CON_DIVSCALE:
C_GetManyVars(4); C_GetManyVars(4);
return 0; return 0;
@ -2877,6 +2880,10 @@ repeatcase:
C_GetNextVar(); C_GetNextVar();
return 0; return 0;
case CON_GETCLOSESTCOL:
C_GetManyVars(4);
return 0;
// *** stuff // *** stuff
case CON_ADDLOGVAR: case CON_ADDLOGVAR:
// syntax: addlogvar <var> // syntax: addlogvar <var>

View file

@ -319,6 +319,7 @@ enum ScriptKeywords_t
CON_INV, CON_INV,
CON_SQRT, CON_SQRT,
CON_MULSCALE, CON_MULSCALE,
CON_DIVSCALE,
CON_DIST, CON_DIST,
CON_LDIST, CON_LDIST,
CON_GETANGLE, CON_GETANGLE,
@ -422,6 +423,7 @@ enum ScriptKeywords_t
CON_NEXTSPRITESECT, CON_NEXTSPRITESECT,
CON_SECTOROFWALL, CON_SECTOROFWALL,
CON_FIXREPEATS, CON_FIXREPEATS,
CON_GETCLOSESTCOL,
// stuff // stuff
CON_ADDLOGVAR, CON_ADDLOGVAR,

View file

@ -932,6 +932,15 @@ skip_check:
Gv_SetVarX(var1, mulscale(var2, var3, var4)); Gv_SetVarX(var1, mulscale(var2, var3, var4));
continue; continue;
} }
case CON_DIVSCALE:
insptr++;
{
int32_t var1 = *insptr++, var2 = Gv_GetVarX(*insptr++);
int32_t var3 = Gv_GetVarX(*insptr++), var4 = Gv_GetVarX(*insptr++);
Gv_SetVarX(var1, divscale(var2, var3, var4));
continue;
}
// *** if & while // *** if & while
case CON_IFVARVARAND: case CON_IFVARVARAND:
@ -1966,6 +1975,13 @@ badindex:
} }
continue; continue;
case CON_GETCLOSESTCOL:
insptr++;
{
int32_t r = Gv_GetVarX(*insptr++), g = Gv_GetVarX(*insptr++), b = Gv_GetVarX(*insptr++);
Gv_SetVarX(*insptr++, getclosestcol((r>>2)&63, (g>>2)&63, (b>>2)&63));
continue;
}
// *** stuff // *** stuff
case CON_GETTIMEDATE: case CON_GETTIMEDATE:
insptr++; insptr++;
@ -2548,7 +2564,7 @@ dodefault:
} }
drawlinepat = m32_drawlinepat; drawlinepat = m32_drawlinepat;
drawline16(xofs+x1,yofs+y1, xofs+x2,yofs+y2, editorcolors[col&15]); drawline16(xofs+x1,yofs+y1, xofs+x2,yofs+y2, col>=0?editorcolors[col&15]:(-col&255));
drawlinepat = odrawlinepat; drawlinepat = odrawlinepat;
continue; continue;
} }
@ -2572,7 +2588,7 @@ dodefault:
} }
drawlinepat = m32_drawlinepat; drawlinepat = m32_drawlinepat;
drawcircle16(xofs+x1, yofs+y1, r, editorcolors[col&15]); drawcircle16(xofs+x1, yofs+y1, r, col>=0?editorcolors[col&15]:(-col&255));
drawlinepat = odrawlinepat; drawlinepat = odrawlinepat;
continue; continue;
} }