Compare commits

...
1943 Commits
Author SHA1 Message Date
indev 5a44afcd9f Disable multithreading in R_DrawMaskedList 2025-07-01 16:09:18 +03:00
Alug 3c282b5022 this can use min/max 2025-07-01 14:42:28 +02:00
Alug f4d40bd55f "-Wno-aggregate-return" for c++ 2025-07-01 14:38:42 +02:00
Alug 465fea8bb3 "restrict" macro for c++
since it does not have it, use __restrict instead
2025-06-30 12:18:21 +02:00
Alug d47e20b54e those can be const 2025-06-29 11:44:29 +02:00
Alug 4e9f9b7e0e Revert "add "for_each" to srb2 threadpool"
This reverts commit 604bc40021.
2025-06-27 16:38:19 +02:00
Alug 9650139470 Revert "allocate tiltlighting buffer in R_AllocViewMemory again"
This reverts commit b541de4f8c.
2025-06-27 16:38:16 +02:00
Alug 054a40a4b2 Revert "omit realloc and use unique_ptr for our tiltlighting buffer"
This reverts commit e351c1e62a.
2025-06-27 16:38:13 +02:00
Alug 972ee5cf76 remove erronous BACKSLASH
was from when this was a macro lel
edit: screw you comptime
2025-06-26 20:17:33 +02:00
Gustaf Alhäll aef02cb347 Fix one-pixel wide gaps in tall sprites 2025-06-26 20:09:16 +02:00
Alug 36e485b2a3 move gl portalcullsector check back to the right place lel
oopsie
2025-06-26 15:13:54 +02:00
Alug d23c51e707 mark node as restrict again pointonside 2025-06-26 13:22:17 +02:00
Alug 0db437aadd do some more tiny optimizations
-those can all be declared with restrict
-our ternary clamp macro is slightly faster than std::clamp
2025-06-26 13:22:15 +02:00
Alug e351c1e62a omit realloc and use unique_ptr for our tiltlighting buffer
this makes asan shut up, since those effectively clean up after themselves
2025-06-26 13:22:11 +02:00
Alug b541de4f8c allocate tiltlighting buffer in R_AllocViewMemory again
just removes the ugly stuff in the span drawers
needs to be tested a little, but should be fine
2025-06-26 13:21:56 +02:00
Alug 604bc40021 add "for_each" to srb2 threadpool
this exectures something for EACH thread not some abritatrily choosen ones
2025-06-26 13:21:52 +02:00
Alug be8ddebd80 forgor about the new signal handler oop 2025-06-26 00:39:01 +02:00
Alug b2a36850cb Merge branch 'Saturn-Next' into softwarecrap 2025-06-25 12:47:43 +02:00
Alug 8353c1efdd add toggle for software cyan cut stuff
"softwarecyancut"
this is disabled by default, since some vanilla maps were designed around this
also costs a bit of performance (splat span drawers are slooooow)
2025-06-25 12:47:25 +02:00
Alug d19a2e0912 attempt to make fofs in software always cut cyan pixels
if they do contain cyan pixels lel
kinda meh, and needs a toggle
2025-06-25 12:45:14 +02:00
Alug 07432c0381 turn angle stuff into a switch in R_SetupSkyScale 2025-06-25 12:29:58 +02:00
Alug 4fb3b63152 optimize R_StoreWallRange with cut down version of rendersegloop when a seg is untextured
from srb2, its just a cut down rendersegloop with alot less things to check and such
2025-06-23 19:38:57 +02:00
Alug 85b736620a Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Next 2025-06-23 19:26:07 +02:00
Alug 9f770993d4 proper init enterprecise 2025-06-23 19:25:50 +02:00
Alug 4bd02ad325 check if player is local here 2025-06-23 19:25:46 +02:00
Alug 6e7b45d15c simplify R_SetupAimingFrame 2025-06-23 19:25:34 +02:00
Alug 99ebca51d5 use const_cast for colfunccopy
idk its from rr idk why it was like this
2025-06-23 19:23:56 +02:00
Alug 24eb888af3 make skytextures support texture offsets in software 2025-06-23 19:20:20 +02:00
Alug 09ce33abb9 just always clamp the non psprite texture column
this may underflow, which the check in the lööp body does not account for
2025-06-23 19:18:11 +02:00
indev 044ff158a1 SF_HIRES is already handled via spritexscale and spriteyscale 2025-06-23 18:37:57 +03:00
Alug 36c68d055c minor optimizations r_things 2025-06-21 18:07:44 +02:00
Alug ddf7d7cdcb use templates for R_ClipWallSegment
actual slight speedup
2025-06-21 18:07:41 +02:00
Alug 38950d580f fix a clang warning 2025-06-20 09:54:20 +02:00
Alug 707701f317 do palette stuff in st_ticker
cleanup and dont call it in normal ogl at all unless palette render with flashpals is enabled
inspired by Nyan-Doom/Woof
2025-06-20 09:54:17 +02:00
Alug 09507d635b remove now unecessary type cast 2025-06-19 17:41:26 +02:00
Alug ab85d6a693 shut the up -Waggregate-return 2025-06-19 17:41:23 +02:00
Alug 5011b17f88 attempt at optimizing drawcolumn drawers a bit more
inspired by dsda/prboom
seems to be super slighty faster
2025-06-19 15:57:21 +02:00
Alug 7bef45f701 Merge remote-tracking branch 'origin/Saturn-Next' into softwarecrap 2025-06-19 15:50:55 +02:00
indev 40cbce8f9f Merge pull request #178 from Indev450/newmakefiles
Port over SRB2´s makefile rewrites + Port Dedicated server build
2025-06-19 16:47:34 +03:00
Alug 70a70084c9 macrofy ogl function pointer setup
should make it a little less annoying to add new functions
2025-06-17 19:21:09 +02:00
indev b6da6359d3 If gamestate resend took too long, abort resynching 2025-06-16 21:43:54 +03:00
Alug 97075ca5c5 remove some code dupe
starting to like those lambda things
2025-06-13 16:08:06 +02:00
Alug e94737945a fix double sided skies per addline clipping code
fixes greencave skybox
hopefully this is it and doesent break anything else sigh
2025-06-13 08:11:45 +02:00
Alug 57f15e0213 R_GenerateBlendTables can be static 2025-06-13 03:23:31 +02:00
Alug 2eae9b197c port the span and column drawer templates + tilted translucent splat drawer
took the liberty to also carry over our optimizations, this is actually slightly faster than what we had before
2025-06-13 03:23:25 +02:00
Alug 68c7620349 Merge branch 'Saturn-Next' into softwarecrap 2025-06-13 00:53:30 +02:00
Alug 7a3faf34e7 move this into an if else
saves us a little work
2025-06-13 00:20:59 +02:00
Alug d401644447 tweak the sky checks even more
apparently koda has a skybox, and checking like this makes it not trigger, lets hope this has no bad side effects Zzz...
2025-06-13 00:20:48 +02:00
Alug dfc349b230 Merge branch 'newmakefiles' into softwarecrap 2025-06-12 23:33:49 +02:00
Alug be3e5a964d pass -flto to linkerflags too
lel forgor
somehow this still worked anyways
2025-06-12 23:33:41 +02:00
Alug 687d2bd894 Merge remote-tracking branch 'origin/Saturn' into Saturn-Next 2025-06-12 23:18:45 +02:00
Alug 78b642cf2d Merge pull request #183 from P-AS/mac-fixes
Fix build on macOS
2025-06-12 21:46:39 +01:00
Alug cb3b6ca34b Merge pull request #184 from chromaticpipe/levelinterpolatorjitter
Fix level interpolators jittering during objectplace
2025-06-12 20:46:31 +01:00
Alug ad15bf0ea3 readd some lost comments in r_bsp 2025-06-12 19:48:58 +02:00
Alug 56021ed999 dont compile with software multithread if NOTHREADS/HAVE_THREADS=0
might be useful for smth ig
2025-06-12 19:48:55 +02:00
chromaticpipe 3d22a5906f Fix level interpolators jittering during objectplac 2025-06-12 11:37:25 -05:00
Alug b6d771b48f unnest the skybox scale setup stuff 2025-06-12 17:10:26 +02:00
Alug ab30fb2e5e check if seg has any texture at all
seems to work even better and less "false positives"
also removing some redundant conditons
2025-06-12 17:10:22 +02:00
Alug 618d9e4cdf add lugent to credits 2025-06-11 20:55:26 +02:00
Alug bf78ad9c75 absolute insanity to hopefully fix all sky issues while keeping skyvisible 2025-06-11 20:28:16 +02:00
Alug 918a4e8cd9 add tilted fog span drawer
fixes the red fog blocks on mkrevamp
2025-06-11 17:10:47 +02:00
Alug e90c84c9ac we have a var for that lul 2025-06-11 16:32:36 +02:00
PAS a9209a4887 Include errno.h on macOS 2025-06-10 21:53:43 -04:00
Eidolon 0a3e7ba09f Include poll.h on UNIXCOMMON
Apple was not including poll.h despite needing it.
2025-06-10 21:49:00 -04:00
Alug eb132b08c0 make the check a little more robust + account for slopes a little 2025-06-11 00:31:01 +02:00
Alug 82407c3560 add missing plane bounds check to R_DrawSkyPlane 2025-06-11 00:30:59 +02:00
Alug f1a8210663 another attempt at actually fixing sky issues
absolutely fucking horrible
but this also does account for single sided lines aswell and gets rid of artifacts and perf
2025-06-10 18:33:20 +02:00
Alug 1d722be4bc few smoler optimizations r_segs 2025-06-10 01:21:36 +02:00
Alug 62a660bfe1 maybe this makes perf better somehow 2025-06-10 01:21:34 +02:00
Alug 2984795175 kill the splitscreen lööps from R_RenderPlayerView
this already gets called from within the one that assigns viewssnum which we can just use here
2025-06-09 23:45:02 +02:00
Alug da706d89a5 absolutely disgusting hack for sky issues
instead of homremoval, we draw the fucking skyplane before everything lmao
there probably is a right way to fix this, but im too dumb for that
needs some performance testing, but since i could move the semaphores back, its even better in some instances
2025-06-09 22:59:52 +02:00
Alug a8005d5cec fix portals dying
due to nummasks being too small and causing an overflow
ty hannu!
2025-06-09 20:57:19 +02:00
Alug 793ccff6e6 fix the goddamn portal use after free
https://git.do.srb2.org/STJr/SRB2/-/commit/f536ab34674fb8d3ee262a0009753f552074305c
2025-06-09 19:02:58 +02:00
Alug e7db9bf1fd fix bad copy paste lul 2025-06-09 17:09:57 +02:00
Alug 88d62c93a1 fix SHITPLANESPARENCY and QUINCUNX
maybe
2025-06-09 17:06:31 +02:00
Alug d73532d019 fix some fofs not rendering in software
i did an oopsie in 7.2 X)
2025-06-09 17:06:23 +02:00
Alug 84d3d23936 declare fracstep as const 2025-06-09 17:06:20 +02:00
Alug 717947843b memset those 2025-06-09 17:06:16 +02:00
Alug 968584a316 make skyportals account for how kart sets the viewheight
no we still dont use it
2025-06-09 17:06:14 +02:00
Alug ccd67f621a dont set any texture mapped drawer when fog 2025-06-09 17:06:10 +02:00
Alug 80b301dbbe unnest the overflow_test stuff
its also a ternary now lul
2025-06-09 17:06:07 +02:00
Alug 001e61d39d Merge branch 'Saturn-Next' into softwarecrap 2025-06-09 17:06:02 +02:00
Alug 19c98a436a fix some fofs not rendering in software
i did an oopsie in 7.2 X)
2025-06-09 17:05:42 +02:00
Alug 8dd6d7cfdd fix the fov adjust check
lmao oops
2025-06-09 16:59:00 +02:00
Alug 7456b6e02c Revert "bring back old clipwallsegment stuff"
This reverts commit 6af77afc44.
2025-06-09 04:27:58 +02:00
Alug 5e8096f74c move hom removal to D_Renderview
removes the hwr code dupe and moves this out of the splitscreen loop
2025-06-09 00:21:41 +02:00
Alug 6af77afc44 bring back old clipwallsegment stuff
i just didnt like the flow of the new ones
2025-06-08 21:38:57 +02:00
Alug 42eeb7bdf5 fix the massive slowdown on ante
due to really bad loop layout
std::fill is only cause it looks fancy :3
2025-06-08 21:38:54 +02:00
Alug 6f4b1e5125 fix portals on slopes
idk this is quite the hack, but it works
this adjustment somehow got omitted from srb2 during the portal refactor
2025-06-08 20:03:09 +02:00
Alug 22e65cdda8 readd portalcullsector
+ sprite clipping improvements with portals
2025-06-08 20:03:06 +02:00
Alug 9d342d0f3d fix lightlist memory leak
not sure if we need to copy over the old shit, but this seems to work aswell
2025-06-08 17:24:18 +02:00
Alug 9583bed718 fix da rippled wöter
i hate fixed point maths lmao
2025-06-08 00:43:15 +02:00
Alug b69ce75712 do NOT use Z_ functions in threaded stuff
shit dies
2025-06-08 00:25:03 +02:00
Alug a1cd19b023 make the fov dependant init stuff bit more safe and stuff 2025-06-07 23:54:12 +02:00
Alug 6e50710b25 fix column data colormap shit in R_RenderThickSideRange
too lazy to explain so https://git.do.srb2.org/KartKrew/RingRacers/-/commit/1ccd41c3dbb3132ce7467edf0c12c9d420b189f9
2025-06-07 23:31:51 +02:00
indev 989a971d27 Fix 'C++11 requires a space between literal and string macro' warning 2025-06-07 23:18:55 +03:00
indev 24ee56ce7a ceepeepee 17 :3 2025-06-07 23:15:55 +03:00
Alug 52f99dd9c1 fix span corruption due to wrong types being used
i did not realise srb2 changed this at some point to use fixed_t
2025-06-07 20:05:51 +02:00
Alug 6374fda570 convert i_system to cpp add missing exit for threading errors 2025-06-07 20:05:48 +02:00
Alug cdd2d6323e dont think we need this twice lel 2025-06-07 20:05:03 +02:00
Alug c508a7ea78 smol makefile stuff 2025-06-07 20:05:01 +02:00
Alug 1380a394c7 remove duped declaration 2025-06-07 20:04:58 +02:00
Alug 2c937099d4 this does nothing lel 2025-06-07 20:04:55 +02:00
Alug 0a936b3bba fix le sourcefile 2025-06-07 20:04:52 +02:00
Alug 0a31e0a65e use realloc for batching stuff
seems to strangely speed things up even
didnt think those happen often?
2025-06-07 11:55:52 +02:00
Alug 8627a18452 Merge pull request #182 from chromaticpipe/fixedhelp
Fixed help command
2025-06-07 10:54:36 +01:00
Alug be528adea5 thanks michaelsoft! 2025-06-07 10:21:25 +01:00
James R. 5eb4ed8391 R_FindPlane: fix offsets rotation overflow for non-sloped planes 2025-06-07 11:43:13 +02:00
James R 9a00d30c0c Do not factor height into sprite thickseg sorting 2025-06-07 11:43:10 +02:00
James R 71237c5e11 Check that top of sprite is above plane or bottom is below
This fixes slightly raised fofs drawing on top of sprites that should be in
front of them. Previously would check that the bottom of the object was above
the plane. Now also uses sprite offsets like the fof seg sorting does.
2025-06-07 11:43:07 +02:00
Alug 9c6e32a1ab HACK: dont pass wflags to c++
silences some annoying compiler complaints lel
2025-06-07 11:43:04 +02:00
Alug 1bc18801c8 cleanup the software drawers even more + unroll them
looks pretty clean now, not sure if i want to port the templates, this is good enough for now
2025-06-07 11:43:01 +02:00
Alug 221f2a956e tiny optimizations 2025-06-07 11:42:58 +02:00
Alug b450abdf4d simplify R_ExpandPlane 2025-06-07 11:42:55 +02:00
Alug d36eed3c09 convert r_segs to ceepeepee + overflow fix from RR R_DrawRepeatMaskedColumn
+ alot of cleanup
should more or less function the same, just alot less messy
2025-06-07 11:42:52 +02:00
Alug 43ee791d4a fix slopes and slope flat alignment
software slopes finally are sane........
fixes certain maps like stardust speedway looking like complete butt
need to test ogl, not sure if theres any real change there
2025-06-07 11:42:48 +02:00
Alug c921945922 cleanup software drawer handling stuff
mostly ported from rr
is alot more readable and less confusing
2025-06-07 11:42:45 +02:00
Alug 5f8c77e752 test: allow multithreading for masked planes
quite a neat speedup on some maps
needs testing
2025-06-07 01:20:52 +02:00
Alug 064db977aa HACK: move semaphores into the drawplane loop, to fix a few visual glitches
a bit of slowdown, but i have no clue what exactly causes shit, so this is the best solution for now i guess
2025-06-07 01:20:48 +02:00
Alug 5868cd9777 make drawcolum lightlists use realloc again lel
otherwise theres a crapton of overlapping memory lel
2025-06-07 01:20:44 +02:00
Alug b0ddde996a forgor this from removing screen size static array stuff lel 2025-06-07 01:20:41 +02:00
Alug e03c3766f0 forgor to free the mask heads lel 2025-06-07 01:20:37 +02:00
Alug 953c0d7451 convert r_things to ceepeepee 2025-06-07 01:20:34 +02:00
Alug 97b303c362 split skin stuff from r_things into r_skins
what a mess
2025-06-07 01:20:31 +02:00
Alug 2ffe736a20 smol cleanup 2025-06-07 01:20:28 +02:00
Alug 21f2032f34 save smol amount of fixed to double conversions in R_StoreWallRange
also adds those as actual functions in case we wanna use it for smth else
2025-06-06 17:37:55 +02:00
Alug 2f66207205 make this less ugly 2025-06-06 16:55:38 +02:00
Alug 5a14b09c1f cache ds->transmap for translucent span drawers
super slight speedup
2025-06-06 16:35:26 +02:00
Alug 7e9da92dbe dont redundantly clamp the sprites texturecolumn
we already take care of this in the lööp header
2025-06-06 16:35:23 +02:00
Alug a27550b95b fix R_ProjectSprite clipping checks overflowing
was causing sprites to disappear in some angles
2025-06-06 14:43:03 +02:00
Alug 556883487d optimize software hud drawing
from srb2classic adjusted to our drawers
2025-06-06 01:17:36 +02:00
Alug 96f8533479 dont check for wraps on 0 height textures in column drawers
slight speedup thx srb2classic!
2025-06-06 01:04:20 +02:00
Alug f3cca27448 cache vid.width in the column drawers
shit was really slow lel
2025-06-06 00:55:23 +02:00
indev 252563725d Make tiltlighting buffer thread_local 2025-06-06 01:42:15 +03:00
indev 9a934a55e2 Revert "ok fuck you tiltlighting static buffer it is"
This reverts commit 2a023246be.
2025-06-06 01:39:51 +03:00
Alug f07d5d381e fix the goddamn boolean 2025-06-06 00:19:23 +02:00
Alug 3faab66ef4 add toggle for software multithread 2025-06-06 00:04:42 +02:00
Alug 2a023246be ok fuck you tiltlighting static buffer it is 2025-06-06 00:04:39 +02:00
Alug 006e7fe8f8 move this 2025-06-06 00:04:36 +02:00
Alug 1a7ff21a04 fix some warnings and plane ripple 2025-06-06 00:04:33 +02:00
Alug 98cb0fdcb2 fix slopes and other shit 2025-06-06 00:04:30 +02:00
indev 1fd7e9cdac Add -lpthread into libs and cxxopts into c++ compilation flags 2025-06-06 00:04:27 +02:00
indev 0a2eac4d3a Add ifdef __cplusplus into hardware/hw_main.h 2025-06-06 00:04:24 +02:00
Alug 9ac6fffd4d busted ass multithreading for le soft 2025-06-06 00:04:19 +02:00
Alug da20f4a087 Merge branch 'newmakefiles' into softwarecrap 2025-06-06 00:04:14 +02:00
Alug dbf822ced9 dont draw precip in the skybox lel 2025-06-05 15:05:29 +02:00
Alug 095842f4aa smol cleanup the splat drawers
didnt knew we actually use em so kinda didnt care lel
2025-06-05 15:00:35 +02:00
Alug 8c290d7597 kill static buffer for tiltlighting, again
kinda ugly but gets the job done lel
2025-06-05 14:48:50 +02:00
Alug 8a6f4db9af fix precip not drawing 2025-06-05 14:48:47 +02:00
Alug 99186a86db port masked drawlists for software + portal visplanes
Note: need to check if we gotta readd portalcullsector for ogl portals, technically this is alot faster and fixes the occasional portal disappearing, but may introduce occasional visual bugs
2025-06-05 14:48:44 +02:00
Alug c67bf97f7b unglobalize drawspandata 2025-06-05 14:48:41 +02:00
Alug 33a1540fcd unglobalise drawcolumndata
from RRs multithread
will follow up with spandata
2025-06-05 14:48:38 +02:00
Alug 529b0d643a delet dc_hires 2025-06-05 01:41:55 +02:00
Alug 4576efbe5c remove FIXMEs from draw column stuff 2025-06-05 01:27:34 +02:00
Alug 185375ece1 use ternaries for column clamp
it is slightly faster for me lel
also lets us get rid of an extra variable
npow2min is also declared static as its always -1
2025-06-05 01:25:33 +02:00
Alug d11521954e move those around + remove NOWATER ifdef 2025-06-05 01:01:31 +02:00
Alug 41c4300ec2 split r_draw8 into r_drawcolumn and r_drawspan
+ remove the _8 from the "namespace" since we dont have highcolor stuff
2025-06-05 00:52:53 +02:00
Alug 51d5023f29 those can be just "while" lööps 2025-06-05 00:44:59 +02:00
Alug d2878f8834 set MAXVIDWIDTH and MAXVIDHEIGHT to 8192
should accomidate absolutely everything
2025-06-04 23:03:17 +02:00
Alug 7808159d23 get rid of static screen size buffers, alloc em to current screen size instead
mostly taken from srb2s any-resolution branch
2025-06-04 23:03:14 +02:00
Alug e759431948 clamp shit so vhs effect doesent do oob writes on some resolutions
shoddy way but fuckit
2025-06-04 20:46:12 +02:00
Alug 268ccce955 move ripple blit stuff into own function 2025-06-04 20:00:06 +02:00
Alug f2d3432bf5 make software ripple splitscreen checks less awful to look at 2025-06-04 18:48:33 +02:00
Alug 2da89f1946 remove ylookup, columnofs and topleft lookups
move screens array to "vid" struct
remove a bunch of unused stuff

this speeds up 4 player splitscreen ever so slighty
mostly just alot cleaner than the mess it was before
2025-06-04 15:55:46 +02:00
Alug 6153733df4 unroll span drawer loops 2025-06-04 15:55:43 +02:00
Alug d280b39f9f use floats flor slope drawing
idea from srb2classic
2025-06-04 15:55:40 +02:00
indev 236e7b8d45 Fix game rendering only first splitscreen player in opengl 2025-06-04 03:57:54 +03:00
chromaticpipe dcccf672c9 Truncate trailing zeroes in float CVars 2025-06-03 13:18:02 -05:00
Alug 03f81bed16 dont initialise those twice lol 2025-06-03 20:00:52 +02:00
chromaticpipe fc51c1ba88 Fix help command for CV_FLOAT CVars 2025-06-03 11:38:46 -05:00
Alug 83d20a72ab delet this since its mostly wrong anyways 2025-06-02 20:05:09 +02:00
indev d50c1ab6d7 dedi's do run got_mapcmd :p 2025-06-02 14:21:34 +03:00
Alug 984c2ff8d6 Merge pull request #175 from chromaticpipe/serverinfo
Display server information before connecting to it
2025-06-01 21:03:19 +01:00
chromaticpipe 74646acdca Options. 2025-05-31 16:27:34 -05:00
indev 45ffe87ba6 Add new music credit draw style, 'songcredits Box' 2025-05-31 22:27:17 +03:00
Alug 37eb8cfa57 shut up curl im already long 2025-05-31 21:01:57 +02:00
Alug a0f903f162 i like switches mhhhm 2025-05-31 21:01:53 +02:00
Alug f1f0782256 fix memoryleak in pk3 verify functions 2025-05-31 17:30:19 +02:00
Alug 0e9a825f63 some crap from ceepeepeecheck 2025-05-31 17:27:07 +02:00
Alug 5c53a90eea hack: reset musiccredits when changing gamestate
otherwise they may persist if theyve been currently displayed
2025-05-31 16:20:58 +02:00
Alug 55c6ba6d12 fix awayview join crash
player->awayviewmobj may not exist yet in some cases
2025-05-31 15:57:20 +02:00
Alug 6617382f54 Revert "reset the palette earlier during levelload"
This reverts commit 5e532a76cf.
2025-05-30 23:59:08 +02:00
chromaticpipe dd499a410f Very bad gamepad support 2025-05-30 13:30:47 -05:00
chromaticpipe c04ba992a7 Forgort something 2025-05-30 13:26:27 -05:00
chromaticpipe 27c053cd48 Add Server info screen, ported from SRB2Classic 2025-05-30 13:23:36 -05:00
Alug 7d68c0598c Fix underflow in consistancy checking code
https://git.srb2.org/Hanicef/SRB2Classic/-/commit/9f5686ef48956cd64ef92f737e59cbbaa27d8cf9
2025-05-30 02:54:48 +02:00
Alug 201c725dc7 cleanup d_main a little 2025-05-30 02:54:45 +02:00
Alug e47e58a982 fixup ceepeepee support 2025-05-29 21:40:15 +02:00
Alug c05068f22f why are those still here lel 2025-05-29 19:35:15 +02:00
Alug f5cb473f3d thanks windoze very cool part 2 2025-05-29 19:33:46 +02:00
Alug c5b72f24b5 thanks windoze very cool 2025-05-29 19:33:37 +02:00
Alug 57b2316c42 didnt mean to change this lel 2025-05-29 19:01:19 +02:00
Alug fe682a8071 only make screentexture for postprocess if we need to
gives quite a neat perfboost on the gpu side
2025-05-29 19:01:16 +02:00
Alug bf44a054a1 move HWR_GetTexturePalette calls
to after early returns/where they are used
2025-05-29 18:17:26 +02:00
Alug eca9c60d9b call HWR_LoadMapTextures in paletterender toggle callback
from srb2 pr
2025-05-29 18:17:23 +02:00
Alug cf42c35b9f add mo checks to automap stuff 2025-05-29 13:40:57 +02:00
Alug a364068abb add a bunch of checks for if G_BuildMapTitle returns NULL 2025-05-29 13:40:53 +02:00
Alug e88093d9cf no need for an else here 2025-05-29 12:30:07 +02:00
Alug 5e532a76cf reset the palette earlier during levelload
generally make this behave like srb2/rr again
2025-05-29 12:30:05 +02:00
Alug fb9c459269 readd cubeapply check here 2025-05-29 12:30:00 +02:00
Alug 7c34733eea add nofork parameter to dedibuild 2025-05-28 23:58:10 +02:00
Alug a6898bd1cd this memset is incorrect and does nothing 2025-05-28 22:12:00 +02:00
Alug ff474d18ee remove this
prob wrong assumption, our netcode sucks massive ass
2025-05-28 21:44:38 +02:00
Alug f15d3be263 forgor the hw state lel 2025-05-28 18:39:20 +02:00
Alug 19e5366c5b add wireframe mode for ogl 2025-05-28 18:31:55 +02:00
Alug 346dee019c fix compiler warning bout playeringame 2025-05-28 18:31:37 +02:00
Alug 18914f22f2 remove crappy memcpy redifine from md5 2025-05-28 18:31:33 +02:00
Alug 1219ecf818 check for 32bit with __SIZEOF_POINTER__ for precip drawdistance
thx @chromaticpipe for the tip!
2025-05-28 16:27:40 +02:00
Alug b6923d0d0d readd flexible array for softwarepatch columnofs
how did this ever work lel
2025-05-28 16:21:57 +02:00
Alug 393ade780c add missing "time" include from dedi i_system 2025-05-28 14:43:27 +01:00
indev 8b2e6ea17b libpeethread 2025-05-28 16:54:37 +03:00
Alug 8c31682723 smol adjustments for main 2025-05-28 15:43:21 +02:00
Alug 7c87b5259a port SRB2s new makefiles + add dedicated build (squashed)
also fix some of the new warnings
to make a dedicated build just pass DEDICATED=1 to the compiler
TODO:make this compatible with bluajit
2025-05-28 15:38:25 +02:00
Alug e8969b0645 dont always print openmpt version to console
just use I_OutputMsg instead
2025-05-27 18:31:20 +02:00
Alug 7932c1af6f Print the current SDL_mixer version
when initializing the sound system
2025-05-27 18:30:55 +02:00
Alug 95b4228d3c update windoze libbacktrace
never was updated since we added this 2 years ago lel
2025-05-26 11:03:56 +01:00
Alug a0ff44043f Merge branch 'Saturn' into Saturn-Next 2025-05-25 17:37:40 +02:00
Alug 1e15816057 make screen tilt stuff slightly prettier lel 2025-05-25 17:36:38 +02:00
Alug a4566e9496 v8.2 2025-05-25 13:59:36 +01:00
Alug 18f88c28dd Merge pull request #174 from Indev450/Saturn-Next
Saturn v8.2
2025-05-25 14:59:06 +01:00
indev b8dc1b13df Merge pull request #173 from chromaticpipe/wateramplitude
Adjust the amplitude of GL underwater effect
2025-05-24 18:12:38 +03:00
chromaticpipe 33c03f1e7a Adjust the amplitude of GL underwater effect
Also fixed a string truncation warning
2025-05-24 09:02:49 -05:00
indev 7e5ae71714 Do backups for custom configs too 2025-05-23 15:14:42 +03:00
Alug b574ed0b1b allow capping the game fps seperately for when its unfocused 2025-05-22 23:17:48 +02:00
Alug 01c621832b Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Next 2025-05-21 12:14:51 +02:00
Alug 608cc66d78 try to fix curl crashing if you dont have write access to download folder 2025-05-21 12:14:45 +02:00
indev 35103ad810 Only run song credits drawer and ticker in menu instead of all hud 2025-05-20 16:48:51 +03:00
indev 5ac0262654 Fix 'make clean' keeping depend.dep file 2025-05-20 01:02:03 +03:00
Alug c361285790 we may fixed the double free, but now we fix the ghost hitlist also crashing 2025-05-19 20:01:29 +02:00
Alug a168b5e2b9 let resynch method be "toggable"
setting gamestate attempts to 0 should disable saturn resynch and setting resynchattempts to 0 should disable vanilla resynch
2025-05-19 16:40:02 +02:00
Alug f70c38a853 Merge pull request #171 from Indev450/votebgscaling
Better Vote Background scaling behaviour
2025-05-19 15:01:07 +01:00
Alug 4c05c063a9 oop this was always true effectively 2025-05-19 15:59:15 +02:00
Alug ed05a909cb add vote scaling to menu 2025-05-19 15:56:56 +02:00
Alug e1e45ad3ad readd player var to lib_pDoSuperTransformation
otherwise this may desynch?
2025-05-19 15:48:29 +02:00
Alug ca9b001c9f even more random cleanup 2
hope i got everything right lel
2025-05-19 15:30:54 +02:00
Alug 3976d80867 delet old tools
they dont work anymore anyways
2025-05-19 00:22:34 +02:00
Alug 1ee10457f8 delet dummy 2025-05-19 00:22:31 +02:00
Alug 116bcd0cb1 random cleanups
note: 2d camera didnt work anyways
2025-05-18 16:46:25 +02:00
Alug fcdccb96aa move camera to spawn if you press freecam toggle when spectating
since we dont use the toggle in spectatormode
might be useful to return to the mapstart fast or smth
this is mostly just copy pasted from P_ResetCamera, which should be fine hopefully since we dont move our spectators anymore
2025-05-17 14:54:11 +02:00
Alug 723286826b make this switch slighty prettier 2025-05-17 14:02:00 +02:00
Alug b190f09aea fix 3d models rollangle on gravflip
idk if this is correct, but it works lel
2025-05-17 14:01:57 +02:00
Alug ff6358b031 make ogl screenflip stuff directly assignable
those dont need to be seperate bools lel
also simplify the assignment aswell
2025-05-17 14:01:54 +02:00
Alug 5899a0c453 ok even more cleanup for animvote check 2025-05-16 14:22:19 +02:00
Alug db4d9a330a even more tiny cleanup votebg stuff 2025-05-16 14:22:16 +02:00
indev 03264e760f Allow music credit to be drawn in intermission and main menu 2025-05-16 13:36:05 +03:00
Alug 224e3b25e5 Revert "those appear to do nothing"
This reverts commit 5f40ff5a03.
2025-05-16 01:30:28 +02:00
Alug 03c624a77b make addon warning not print "(null)" if there is no refreshdirname
kinda lazy way but shrug
2025-05-15 21:41:05 +02:00
Alug 1ed76de58a macrofy redundant splitscreen menus
joystick and camera menus to be specific
2025-05-15 21:41:00 +02:00
Alug 5f40ff5a03 those appear to do nothing
free performance ig?
2025-05-15 01:26:57 +02:00
Alug b1baa90b19 move paletterender walllight stuff into HWR_CalcWallLight
just slightly cleaner
2025-05-15 01:26:36 +02:00
Alug f0579de244 HWR_UsePortals 2025-05-15 01:26:33 +02:00
Alug 044836b026 change gamepad powerup led behavior
it will instead always take the players mobj color, this makes it indirectly support things like acrobatics and the colourized banana snipe
also just makes it a value for cv_gamepadled instead of its own cvar
2025-05-15 01:26:27 +02:00
Alug c2a761c895 delet some clutter in screen.c 2025-05-14 16:37:04 +02:00
Alug 5b6e7abd91 fix copy paste error oops 2025-05-14 16:18:18 +02:00
Alug c47c6aa6e4 make votebg scaling behaviour changable 2025-05-14 16:18:15 +02:00
Alug 5a6a954d4f make an adaptive votescreen patch scaler
attempts to first fill the screen horizontally, if the screen is not filled vertically like that, it will then change the scaling to fill the screen vertically
like this effectively every votebg fills up the screen and accomidates most bgs that added padding for the weird vanilla behaviour
TODO: make the behaviour switchable
2025-05-14 16:18:12 +02:00
Alug 92bf8c0788 Make votescreen backgrounds resolution and dup independant
also some slight cleanup
currently this scales vertically to fill out the screen vertically
not sure if horizontally would be preferred, but thatd most likely cut off alot of parts from some votebgs
2025-05-14 16:18:08 +02:00
Alug 058139f52b dont allow changing grid sorting with item if item button is also enter 2025-05-13 22:38:32 +02:00
Alug 612d01a8ce disable this 2025-05-13 22:38:29 +02:00
Alug bc130ce1f9 clamp screentexture size to maximum supported texture resolution
also moves everything into GL_SetModelView again
also means screen texture sizes wont be recalculated every frame anymore
2025-05-13 04:39:21 +02:00
indev 8abab58a5c Fix game crashing when attempting to print '%s has no field named %s' for few lua userdata objects 2025-05-12 18:02:20 +03:00
Alug 740de2babe fix replay saving during intermission with manual save 2025-05-12 06:12:23 +02:00
Alug 9d54baf544 fix minimap angle display in encoremode 2025-05-11 18:47:45 +02:00
Alug c68c61975e Merge pull request #169 from Indev450/Saturn-Next
Saturn v8.1
2025-05-11 16:42:59 +01:00
Alug 6f7947dd5f fix smol oopsie for colourized speedlines 2025-05-11 17:41:25 +02:00
Alug cb8930fef6 v8.1 2025-05-11 17:13:22 +02:00
Alug 93d87e1132 fix oob write when map has playerstarts for 32 players
playerstarts is MAXPLAYERS big, which is 16 for us
2025-05-11 17:13:04 +02:00
Alug d5583ba040 add "nofork" parameter
to disable process forking
might be useful for gdb and perf
2025-05-11 17:12:56 +02:00
Alug 7bb3e4445e change colourized speeline behaviour slightly
"driftonly" will tone the lines completely instead of alternating between blue and driftcharge
"normal" will completely colourize speedlines in the player colour
2025-05-11 17:12:54 +02:00
Gustaf Alhäll 001a38bbd2 Fix off-by-one buffer overflow when getting LUT 255 2025-05-11 17:12:50 +02:00
Alug 463778cd88 fix 3d models tanking performance to hell 2025-05-11 01:23:07 +02:00
Alug f263585a72 make this check like vanilla did 2025-05-11 01:23:04 +02:00
Alug ec0ca0d1ab unlock everything when using modkartdata save
doesent make too much sense having to unlock everything again when playing mods
2025-05-10 23:43:04 +02:00
Alug 121540f428 dont check for how many controllers just attempt to reset "all"
JoyInfo->dev will be null
The crash before was most likely due to an oob read
2025-05-10 22:00:52 +02:00
Alug 8b5fd5f646 fix saturn menu 2025-05-10 19:16:32 +02:00
Alug 23a9afb727 fix typo in rumble reset 2025-05-10 18:59:56 +02:00
Alug 38b862ff16 Revert "skinlocal deez nuts"
This reverts commit 12ec3d11a2.
i hate localskins so much its unreal
2025-05-10 18:59:50 +02:00
Alug 7e31536ff9 Merge branch 'Saturn-Next' into Saturn 2025-05-10 16:23:03 +02:00
indev 679e582028 jin is with lowercase j 2025-05-10 17:01:14 +03:00
indev bfc34337a3 Add P_CheckSightFast into LUASTUFF.md 2025-05-10 16:54:53 +03:00
Alug c2cf6f17d1 Merge pull request #167 from Indev450/Saturn-Next
Saturn v8
2025-05-10 09:39:39 +01:00
Alug 5b44c03892 these should be reset in the loop 2025-05-10 08:35:52 +01:00
Alug 69e3722e81 Fix controls getting stuck when opening the pause menu
https://git.srb2.org/Hanicef/SRB2Classic/-/commit/ed53d96430dedac42b288bd6a5ca8152e6e6acc4
2025-05-09 15:17:30 +02:00
indev 2fbc1140c4 Fix NOWH compilation (only check if renderer supports palette if HWRENDER is defined, otherwise run subpalette code unconditionally) 2025-05-08 17:39:27 +03:00
indev 9747eab9f3 Add I_Sleep into CONS_Error so if a wad file was not found game won't take 100% of cpu 2025-05-08 17:20:28 +03:00
Alug f98e7b13f4 cleanup dpad scroll stuff even more
mostly just to make this more readable
2025-05-08 10:24:33 +02:00
Alug 5cc6743328 dont keepmusic music that is not flagged as keep on death
uuuuuggggghhhhhhhhhhhh
2025-05-06 22:06:53 +02:00
Alug c0d8f4fbfe idk where this stuff came from
but we can access delayremoved thinkers in kart cause bleh
2025-05-06 19:42:32 +02:00
Alug d7c1e464d4 Revert "optimize MT_TUBEWAYPOINT"
This reverts commit 3d0ac03f06.
2025-05-06 19:36:38 +02:00
Alug 7e5baeebaf dont free item patches at levelload lol 2025-05-06 17:37:57 +02:00
Alug 0c7d50b38a call M_ClearMenus in D_StartTitle 2025-05-06 17:08:54 +02:00
Alug fa951475ba fix 32bit windoze compile
everything needs time.h idk why it never errored out before lol
2025-05-06 11:53:27 +01:00
Alug a608676bbd fix the fast pointonsides 2025-05-05 12:51:37 +02:00
indev 8dd52f278b Merge pull request #166 from chromaticpipe/interpdebug
Add interpolation related stats to perfstats
2025-05-05 13:09:18 +03:00
chromaticpipe 7634859503 Use more correct flags for interpolation stats + misc fixes 2025-05-04 18:29:23 -05:00
chromaticpipe cf1abbd176 Add interpolation related stats to perfstats
These were commented out for some reason..
2025-05-04 12:13:02 -05:00
Alug b71c1152c6 skinlocal deez nuts 2025-05-04 01:36:01 +02:00
Alug 46f3529165 simplify this slightly 2025-05-04 00:48:01 +02:00
Alug ce99a3f5a6 print previously supressed warnings into log instead of console 2025-05-03 23:17:33 +02:00
Alug 880db98961 dont mindelay when record attacking
theres a few places that do not "lag compensate" at all in RA so this would completely mess things up
2025-05-03 23:10:43 +02:00
Alug d2d0e0c979 smol cleanup m_perfstats 2025-05-03 20:45:40 +02:00
Alug 7abee5ae11 add USELTO and USEASAN make flags
to compile with LTO or Address sanitizer
2025-05-03 17:21:18 +02:00
Alug e025404bbf forgor casting this 2025-05-02 11:12:12 +02:00
Alug f8b9c8290e let squishy speed be player choosable
idk why i just didnt do that lel
also adds stuff to the menus
2025-05-02 10:58:53 +02:00
Alug d1d9236539 Merge pull request #164 from Chearii/minimapheadlight
Add a minimap headlight
2025-05-02 09:36:10 +01:00
Alug 63abd00c6a that needs to come before old_ stuff gets reset 2025-05-02 10:23:11 +02:00
indev 5f01d1ff84 Refactor /pm draw code a little 2025-05-02 00:23:52 +03:00
Chearii 62fa1777dd ts pmo fr icl istg
me when my code has to be robust!!
(I also Forgot to remove the SHORT marcros oops!)
2025-05-01 15:47:50 -04:00
Chearii 59deb7c8c1 add a minimap headlight 2025-05-01 15:40:58 -04:00
indev d1c7e08496 Revert "Attempt to fix game freezing on windows when moving game window"
This reverts commit 231ff3b502.
2025-05-01 13:02:26 +03:00
indev 066b12f075 Revert "fix compile"
This reverts commit c0aa3e48cd.
2025-05-01 13:02:22 +03:00
Alug d1bb0b97d2 seriously screw you windoze 2025-05-01 08:56:43 +01:00
Alug c0aa3e48cd fix compile 2025-05-01 08:55:08 +01:00
Alug a1a4b7cfbf force c17 with gcc 15 for now
dont feel like porting stuff over to c24 or whatever for v8 so just force c17 so ppl can still compile
2025-05-01 00:31:37 +02:00
indev 231ff3b502 Attempt to fix game freezing on windows when moving game window 2025-05-01 01:06:00 +03:00
Alug 3fb4c6484d tiny more cleanup screencoord stuff 2025-04-30 14:58:06 +02:00
Alug 7a6e1bcf6c readd old nanosleep
since it appeared to work just fine in testing
actually forgor to remove it from the lol
2025-04-29 21:56:30 +02:00
Alug cd60ee1188 fix ghost mobj spritescale and offset interpolation
had this laying around in lugstuff since ages lol
2025-04-29 21:43:18 +02:00
Alug 4481911cd4 only check for votescreen replacements if we havent already replaced everything 2025-04-29 21:38:45 +02:00
Alug 53b3a994fc some reformatting lel 2025-04-29 21:38:28 +02:00
Alug ebcdb23d34 delet old high color software stuff 2025-04-29 21:13:18 +02:00
Alug 431c0f41d1 raise version number
so i dont forger about it later lol
2025-04-29 21:02:56 +02:00
Alug 838379d970 we dont have this on this branch 2025-04-29 18:30:23 +02:00
Alug 68c913a5e1 raise cmake minimum requiered to 3.5 2025-04-29 18:22:33 +02:00
Alug 5f82a3b799 Merge pull request #163 from Indev450/patchntexrefactor
Refactor Patch and Texture handling
2025-04-29 17:08:25 +01:00
Alug 2369a0c5a1 Merge branch 'Saturn-Testing' into Saturn-Next 2025-04-29 18:07:56 +02:00
Alug e995ad0499 Reapply "disable jit compilation for now"
This reverts commit a662a0a68f.
2025-04-28 22:19:59 +02:00
Alug 7ba21abacd tiny more cleanup speedometer stuffs
put check for color speedo into a function
and precalc the xtra 3 scale
2025-04-28 17:47:37 +02:00
Alug 4c1cfc91da quick and dirty gcc 15 compile fix
need to fix this properly
2025-04-28 13:26:08 +01:00
Alug 79d440d398 quick and dirty gcc 15 compile fix
need to fix this properly
2025-04-28 13:25:30 +01:00
Alug ace8256d73 Merge branch 'Saturn-Testing' into patchntexrefactor 2025-04-28 15:06:11 +02:00
Alug 984d501ee1 move doaddline block
slightly better branching since maps with portals are very uncommon in kart
2025-04-28 11:29:45 +02:00
Alug e138d540c8 skip rechecking for horizonlines when reloading gamestate
map remains the same during desynch, so safe some time
2025-04-28 11:21:24 +02:00
Alug 4f81349ea3 another tiny cleanup p_setup and p_saveg 2025-04-28 10:12:09 +02:00
Alug b960e3d848 fix replay ghost double free
kinda rare, but may happen when you resynch on the exact same time you got hit by something
2025-04-27 13:15:18 +02:00
Alug 9c8aee1bef tiny optimization
we dont need to recalc the bpm stuff
we can also divide the bounce in half just once
2025-04-27 00:57:53 +02:00
Alug cf453bad5f make a struct for squishy
this is horrid but should fix this speeding up when multiple players squish
2025-04-27 00:30:49 +02:00
Alug 8ad161f061 add a few more branching hints
also fix some indentation
2025-04-25 21:37:25 +02:00
Alug a18e81ee18 invert skywall offset
also fixes the issue, but doesent draw skywalls over actual walls in rare cases
lets hope this doesent draw walls over actual skywalls now (:
2025-04-25 21:34:36 +02:00
Alug 4f83d3b36b whitespace crap 2025-04-25 21:34:33 +02:00
indev 97093dbeb9 Don't free PU_SPRITE memory, since it invalidates some lua patches if they are using sprite frames 2025-04-25 12:15:57 +03:00
Alug 2468277068 Merge branch 'Saturn-Testing' into patchntexrefactor 2025-04-24 13:23:16 +02:00
Alug cd15c5d380 oops didnt think addskins would be used here lel 2025-04-24 13:17:34 +02:00
Alug b977cf72b7 deprecate "addskins" command
"addskins" is an incredibly ambigous name since its main purpose was to add skins LOCALLY
just prints a notice for now since there may be ppl that still use it
2025-04-24 13:17:31 +02:00
Alug 45506b381e take mobjscale into account when skipping small sectors for precip spawn 2025-04-24 13:11:24 +02:00
Alug b6fd7a1e96 put precip purge into a function
to reduce code dupe and branching
2025-04-24 13:03:35 +02:00
Alug 58a9e17500 fix spectator key lel
oopsie
2025-04-24 09:42:24 +02:00
Alug c14c28ac1e attempt at cleaning up gamecontrol splitscreen shit 2025-04-24 09:24:44 +02:00
Alug 5df33e0705 cleanup G_Responder
man
2025-04-24 09:24:41 +02:00
Alug 987d18fe99 memset those 2025-04-24 09:24:37 +02:00
Alug 7bb4b74c65 fix potential crash on startup
thx hanicef
2025-04-24 09:24:05 +02:00
Alug cf92df5faa skip checking skin array if localskin was found in localskin array 2025-04-24 09:24:01 +02:00
Alug f81488500c just mark it like this 2025-04-24 09:23:58 +02:00
Alug a099f825a7 missed removing this 2025-04-24 09:23:55 +02:00
Alug d75ce094ae Merge remote-tracking branch 'origin/Saturn-Testing' into patchntexrefactor 2025-04-23 19:24:12 +01:00
Alug 1bb52b9c2d check ceiling first in encore flat precaching
no clue why but this fixes the sides of the road on ORR not being encore remapped
2025-04-23 19:54:58 +02:00
indev 1d15f89433 Remove I_Assert in GetItemId in lua_hudlib_drawlist.c
It is legal for lua_getpc to be null (thanks GenericHeroGuy for investigating!)
2025-04-23 19:09:02 +03:00
Alug 117db36ed3 move saturn menu stuff around 2025-04-23 16:14:45 +02:00
Alug 9d1b8ba736 move saturn menu stuff around 2025-04-23 16:14:33 +02:00
Alug d2844e7087 add P_DivlineCrossedFast
to take more advantage of P_DivlineSideFast
2025-04-23 16:07:38 +02:00
Alug def4028028 add P_DivlineCrossedFast
to take more advantage of P_DivlineSideFast
2025-04-23 16:07:14 +02:00
Alug 61a4cb554a use P_UnlinkThinker
idk why it still was like this in here lel
2025-04-23 16:05:17 +02:00
Alug f75eb0d766 port RRs improved paranoia thinker/mobj prints
https://git.srb2.org/KartKrew/RingRacers/-/commit/509a023329ea1cd583c500a3287c488e5ee3e3a6
https://git.srb2.org/KartKrew/RingRacers/-/commit/17aaf178d587970a3a845aa6c2f3807077996a77
2025-04-23 16:05:13 +02:00
Alug ede95c8ec4 use P_UnlinkThinker
idk why it still was like this in here lel
2025-04-23 16:04:53 +02:00
Alug 55704f2ba2 port RRs improved paranoia thinker/mobj prints
https://git.srb2.org/KartKrew/RingRacers/-/commit/509a023329ea1cd583c500a3287c488e5ee3e3a6
https://git.srb2.org/KartKrew/RingRacers/-/commit/17aaf178d587970a3a845aa6c2f3807077996a77
2025-04-23 16:02:41 +02:00
Alug 87fd33793d fix P_RemoveSavegameMobj triggering assert in P_UnlinkThinker 2025-04-23 14:02:28 +02:00
Alug 6509e7fdf9 nooo PARANOIA dont set our thinker next to NULL 2025-04-23 14:02:15 +02:00
Alug cd7177682a fix P_RemoveSavegameMobj triggering assert in P_UnlinkThinker 2025-04-23 14:01:38 +02:00
Alug 0ceeac4726 nooo PARANOIA dont set our thinker next to NULL 2025-04-23 14:01:38 +02:00
Alug 0b515939ad we have a global to check if config was loaded 2025-04-23 13:23:52 +02:00
Alug abba2a9eac fix cv_set being called for allowsaturnjoin before its registered 2025-04-23 13:23:47 +02:00
Alug 72ea257a06 we have a global to check if config was loaded 2025-04-23 13:22:53 +02:00
Alug e87ca3fe1b fix cv_set being called for allowsaturnjoin before its registered 2025-04-23 13:22:50 +02:00
Alug ca756fd647 Merge branch 'Saturn-Testing' into patchntexrefactor 2025-04-23 11:40:13 +02:00
Alug ef93209d40 delet bunch of stuff 2025-04-23 11:23:09 +02:00
Alug af104c2d12 Merge remote-tracking branch 'origin/Saturn-Testing' into Saturn-Next 2025-04-23 11:20:22 +02:00
Alug 0e3ab1354b Merge pull request #161 from Indev450/kartstats
Kartstats
2025-04-23 09:28:35 +01:00
Alug 5dc1576496 Merge pull request #160 from Indev450/oglprecache
Fix up texture precaching + add Opengl texture precaching
2025-04-23 09:28:23 +01:00
Alug c4aba91e79 shh 2025-04-23 09:04:54 +02:00
Alug 5aca7e12c7 :3 2025-04-23 09:00:52 +02:00
Alug 60e0e50141 try to fix skywalls zfighting
just apply a small polygonoffset to them
lets hope this is small enough so they dont end up rendering infront of actual textures and such
2025-04-23 01:04:04 +02:00
Alug db9435f810 reset palette cvars when toggling paletterendering
everything gets wiped anyways, so this would be just confusing
2025-04-22 22:11:02 +02:00
Alug 8edec89a36 fix cloud tops palette not applying 2025-04-22 21:52:55 +02:00
Alug b43ca1f3c7 let saltyhop work without gravstretch 2025-04-22 20:13:44 +02:00
Alug 89906cf384 Revert "speed up ogl palette stuff"
why is windows like this?

This reverts commit 1ffb655131.
2025-04-22 18:43:40 +01:00
Alug 2a3e4c4c6d smol cleanup z_zone 2025-04-22 20:28:19 +02:00
Alug e2b1a87ca5 Merge branch 'Saturn-Testing' into patchntexrefactor 2025-04-22 20:28:16 +02:00
indev e5e63a56a1 Don't resume music when game is paused (happens when you pause -> lose window focus -> regain window focus) 2025-04-22 18:24:59 +03:00
Alug 1ffb655131 speed up ogl palette stuff
doesent wipe all our gpu textures if palette hasnt changed too lol
2025-04-22 05:04:04 +02:00
Alug 4ce111139f add cv_palette and cv_palettenum
so palettes can be changed midgame
note: subpalettes do not work properly in opengl with paletterendering disabled, so palettenum will NOT work there
2025-04-22 04:58:40 +02:00
Alug 7c4b93fba8 add some savety to the hudlib
just error instead of crashing so we can track down any issues more easily
2025-04-21 14:16:35 +02:00
Alug fc7405e542 dont free our hud patches when loading an addon lel
appears to work fine in RR so we do it here
fixes some weird issues and crashes with certain hud elements
2025-04-21 14:16:31 +02:00
Alug a57afd046e Merge remote-tracking branch 'origin/Saturn-Testing' into patchntexrefactor 2025-04-21 12:36:41 +02:00
Alug bc6ce84a26 replace instances of malloc + memset with calloc 2025-04-21 12:27:52 +02:00
Alug 9638ae56c5 add missing pglDisableClientState 2025-04-21 12:25:50 +02:00
Gustaf Alhäll f398c0ceea Fix use-after-free when loading addons after searching addons 2025-04-21 12:25:47 +02:00
Alug af544e4e16 Fix server listing refusing to list servers on resolution failure 2025-04-21 12:25:44 +02:00
Alug 7ca201ea1b Merge branch 'Saturn-Testing' into patchntexrefactor 2025-04-20 23:36:04 +02:00
Alug b622fbb653 add mindelay and gentlemens stuff to menu 2025-04-20 23:35:55 +02:00
Alug 00e59c480e remove lagless camera from the menu
and change cvar name to reset it for everyone
2025-04-20 23:35:52 +02:00
Alug cd2f8577a0 big cleanup "GetZAt" stuff
GetZAt now takes 4 parameters (slope, x, y, normalheight)
and everything now uses their designated getzatfunction
2025-04-20 23:01:53 +02:00
Alug fe632340b4 fix P_CameraLineOpening
lel this was always botched
2025-04-20 23:01:40 +02:00
Alug e872f25ce6 check for sloperoll first 2025-04-20 23:01:37 +02:00
Alug f838ff528e dont need this anymore 2025-04-20 23:01:29 +02:00
Alug 5ba6021010 dont let postload free our waitingplayer spritepatches 2025-04-20 23:00:49 +02:00
Alug 2e5e753d2e pass hardware patch to HWR_DrawSpriteShadow 2025-04-20 16:40:35 +02:00
Alug e195126ac0 Merge branch 'Saturn-Testing' into patchntexrefactor 2025-04-19 10:30:22 +02:00
Alug 7bcf8df6fc unnest timedemo stop stuff 2025-04-19 10:29:33 +02:00
Alug ce77a29892 fix titlescreen demos crashing, again 2025-04-19 10:29:30 +02:00
Alug 56392d4e78 whoop this is only used by curl 2025-04-19 07:46:43 +01:00
Alug 6cc37b9160 cleanup http download stuff a little
unglobalise a bunch of stuffand put into a struct
also hopefully made the progressbar less funky
2025-04-19 07:46:39 +01:00
Alug 2f736fb28c a 2025-04-19 01:25:51 +02:00
Alug 127e8b52d1 a 2025-04-19 01:25:45 +02:00
Alug 9e8fb1293f Merge branch 'Saturn-Testing' into patchntexrefactor 2025-04-19 01:24:02 +02:00
Alug fa3d2abe13 Merge branch 'kartstats' into Saturn-Testing 2025-04-19 01:23:51 +02:00
Alug c9faccae64 fix software sprite clipping 2025-04-19 01:19:35 +02:00
Alug 126d26cc98 smol software stuffs 2025-04-19 01:19:32 +02:00
Alug dc49502884 smol fix for R_AddSingleSpriteDef 2025-04-18 23:29:03 +02:00
Alug f03a12241d fix hwrpatch grabbing the wrong patch
getmapped patch needs to be called before this is referenced to avoid potential issues
2025-04-18 22:45:27 +02:00
Alug 3fe77da35f readd missing SHORT macro for patch_create 2025-04-18 22:45:24 +02:00
Alug c79f986a8f make a backup of save data before writing to it 2025-04-18 12:52:35 +02:00
Alug 2b299039e6 reword this lel 2025-04-18 12:47:31 +02:00
Alug 167e8e9258 Merge branch 'Saturn-Testing' into patchntexrefactor 2025-04-18 11:43:06 +02:00
Alug 8943b6a3b7 reset record attack state in G_ResetDemoPlayback
should fix some wonky issues in a few cases
2025-04-18 11:29:52 +02:00
Alug 08f208e4a0 fix record attack condition in G_CheckDemoStatus 2025-04-18 11:24:49 +02:00
Alug 963eb427cf reset demo stuff for multiplayer demos when using connect command
so if smth happens and we cannot connect the game wont be stuck in some weird replay limbo state
2025-04-18 11:24:46 +02:00
Alug c4fd47657e fix crash when using connect command from within replays 2025-04-18 11:24:42 +02:00
Alug 6d15fc1ce4 close menus when replay stops 2025-04-18 10:09:52 +02:00
Alug db43b90b70 Revert "convert fixed to float with multiplication instead of division"
i did not intend to push this to testing lel
2025-04-17 20:49:48 +02:00
Alug da5aaa7ebf Revert "SHORT ma balls"
This reverts commit 5401cb58bd.
2025-04-17 19:37:17 +01:00
Alug 2c290b7473 Merge branch 'Saturn-Testing' into patchntexrefactor 2025-04-17 19:36:50 +01:00
Alug 541c70498d we dont use MT_WAYPOINT lel
just use starposts
also remove rings cause duh
2025-04-17 14:03:03 +02:00
Alug f2d1cb5606 aaaa != 2025-04-17 13:50:35 +02:00
Alug 8702ddca60 those do not exist anymore lel 2025-04-17 13:49:13 +02:00
Alug f7acf7c2d3 fix up the automap again
got the rest of stuff working in a horrible way
automap aswell as minigen stuff looks good now
2025-04-17 13:49:10 +02:00
Alug bcf82970a4 fix oopsie in automap bounds calc 2025-04-17 13:49:07 +02:00
Alug 285c850628 fix automap colours
forgor those revert those when i ported RR code over, now they should match up with what they say
2025-04-17 13:49:04 +02:00
Alug 3b4ffa20bc why? 2025-04-16 23:21:41 +02:00
Alug 006931eaa8 why are these even seperated like that lel 2025-04-16 22:37:39 +02:00
Alug 5401cb58bd SHORT ma balls
need this for now
2025-04-16 22:33:21 +02:00
Alug efde25469e Merge branch 'Saturn-Testing' into patchntexrefactor 2025-04-16 22:31:54 +02:00
Alug b207a87f8b fix camera vertical look tooltip for green res
Zzz...
2025-04-16 22:31:42 +02:00
Alug 1da62eb63d add minimap icon dot to saturn hud menu 2025-04-16 22:31:39 +02:00
Alug 3e6f028061 add support for drawing a dot on the minimap showing player angle
mostly copy pasted from blankart so thx neppy c:
2025-04-16 22:04:34 +02:00
Alug 7bd835f43e fix minimap disappearing when having minimap trans on 10 2025-04-16 22:04:27 +02:00
Alug 8ec6b2e737 fix compile without ROTSPRITE 2025-04-16 20:28:07 +02:00
Alug f4fc185f5b move patch rotation stuff into their own files 2025-04-16 20:25:56 +02:00
Alug b28593dba7 turn rotcache into a lumpcache_t aswell
no need for slow aatrees
2025-04-16 19:22:28 +02:00
Alug 88dc5f25ad smol cleanup W_CachePatchNumPwad 2025-04-16 19:21:28 +02:00
Alug a0062060eb oop 2025-04-16 16:50:09 +02:00
Alug 8e6633d0bc fix the sprite shadows Zzz... 2025-04-16 16:36:41 +02:00
Alug 2c8d5f2625 dont clear all our textures if we dont intend to reload em
the multipart addfile stuff is awkward asf
2025-04-16 16:25:58 +02:00
Alug 46e10f67b2 more smol fixes 2025-04-16 16:21:13 +02:00
Alug 962b68c5c3 smol opitmizations and cleanup 2025-04-16 16:00:34 +02:00
Alug fccfcd12fd fix model blendpatches
we already have a functional check in HWR_GetBlendedTexture anyways
2025-04-16 15:58:55 +02:00
Alug 50caffd70f add tags for model textures 2025-04-16 15:58:45 +02:00
Alug 14a1c391a6 fix models lel 2025-04-16 15:58:40 +02:00
Alug 8ab097f166 dont free our rotsprites aa 2025-04-16 15:58:37 +02:00
Alug 41cb3e932a readd freeing those
dont want kart to use like 4gbs of memory for no reason lel
2025-04-16 15:58:30 +02:00
Alug 70f1a6bf48 readd hud gfx flushing
now that stuff doesent completely die lmao
2025-04-16 15:57:59 +02:00
indev 804d9e2e8e If GLENCORE is enabled, free both encore and noencore textures 2025-04-16 15:57:55 +02:00
Alug 123fe48cad simplify this 2025-04-16 15:57:52 +02:00
Alug 2e7ae45fdb cast Zzz... 2025-04-16 15:57:49 +02:00
Alug 6b44ac922e revert this part 2025-04-16 15:57:44 +02:00
Alug 1c95b2e464 idk anymore lel 2025-04-16 15:57:22 +02:00
Alug b0ba261e14 change those tags
also add PU_PATCH_DATA
2025-04-16 15:56:49 +02:00
Alug 39f8fa8d34 add more purge tags refactor patch freeing and stuff
currently dies when adding a wad midgame and the loading into another map
2025-04-16 15:56:41 +02:00
Alug fe1579e960 fuckit *unshortens your patch dimensions* 2025-04-16 15:56:13 +02:00
Alug 7256fb9d62 port srb2s patch refactor
still needs all the new purge tags
then we should hopefully be free of use after frees and everything
2025-04-16 15:55:06 +02:00
Alug 53f68784fc fix PARANOIA compile 2025-04-15 15:19:13 +02:00
Alug 9e53f3f8b0 fuck off goddamit 2025-04-15 05:08:30 +02:00
Alug a6bebb2d91 noooo dont free our lumppat
for some reason this occasioncally causes an use after free??
our memory management honestly is a fucking mess ngl
2025-04-15 04:59:38 +02:00
Alug 8a80f0571c cleanup R_ProjectSprite 2025-04-15 03:51:11 +02:00
Alug 13589499f8 cleanup rotated patch creation
kill unused adjustfeet code
add missing clamping
use malloc since stuff gets filled with 0xFF00 anyways
kill  rotated sprite "type" since its unused too
simplify getpatchpixel a little
2025-04-15 03:51:01 +02:00
Alug 50656b7afc Revert "flexible array stuff for columnofs"
This reverts commit 37a394ebaa.
2025-04-15 03:15:04 +02:00
Alug b2e0ad58f9 revert using modulu for frac calcs for colum drawers
this is fucking slow for some reason
2025-04-14 22:50:50 +02:00
Alug b2f22a379f whoops 2025-04-14 12:03:37 +02:00
Alug c8b318ba8e minor branching stuff 2025-04-14 11:49:26 +02:00
Alug 8db082501e only holepunch uses this 2025-04-14 11:30:51 +02:00
Alug 5c6c46848e missed those 2025-04-14 11:27:57 +02:00
Alug 69d86e69cb bunch of stuff from lugstuff
- precalc some float division for ogl transform code
- use strlen for the custom lua cvar menu setup
- mostly just cleanup
2025-04-14 11:27:18 +02:00
Alug 0d9ac01fea disable titlescreen demos if any addon (but musicpacks) are loaded
read comment
not a fan of this, but better than ppl constantly crashing
2025-04-13 22:33:52 +02:00
Alug fd14976a4d optimize colourcube conditional checks
screw u atoi
2025-04-13 21:49:08 +02:00
Alug fa06551bd8 Merge pull request #162 from Chearii/dialspeedometer
Add a dial speedometer
2025-04-13 17:44:39 +01:00
Alug 2342d92ae3 refactor K_StretchPlayerGravity
mostly just make it more readable lel
2025-04-13 18:43:50 +02:00
Alug 561b1c0b92 calloc takes care of those 2025-04-13 18:43:47 +02:00
Alug 7eb311d99c we dont need all this stuff for precip 2025-04-13 18:42:10 +02:00
Alug e5f9623113 move this to make it little more clear what this is for 2025-04-13 18:42:07 +02:00
Alug e29c1010d3 missed this with localskin stuff 2025-04-13 18:42:03 +02:00
Alug 494c6ca80d move drawnode stuff into a switch
i like switches uwu
2025-04-13 18:41:47 +02:00
Alug b4416c32ed move line polyseg check out of the lööp if theres no polyobjs on le map
seems to reduce a hotspot there significantly
2025-04-12 19:42:35 +02:00
Alug fa757c6695 throw mobjcache allocation shit into a inline function 2025-04-12 19:42:31 +02:00
Alug fb15cfe9f0 convert fixed to float with multiplication instead of division 2025-04-12 19:42:27 +02:00
Alug 94eebd2cd0 use mobjcache for savegame mobj load 2025-04-12 19:42:24 +02:00
Alug 7e6bde73e1 make a macro for this 2025-04-12 19:42:21 +02:00
Alug da5a2ceefa Merge remote-tracking branch 'origin/demodates' into Saturn-Testing 2025-04-12 19:42:17 +02:00
Alug e74340aabf spr->mobj not thing lel 2025-04-12 14:36:42 +01:00
Alug 48113cb156 spr->mobj not thing lel 2025-04-12 14:36:36 +01:00
Alug 6ae0b87686 Merge branch 'Saturn-Testing' into demodates 2025-04-12 14:33:35 +01:00
Alug 98f35b6e06 windoze stimky
well this atleast should work for everyone, but be noted that the normal "localtime" function is apparently not thread safe
2025-04-12 14:33:11 +01:00
Alug 2959a84b74 attempt at unmangling localskin stuff again
moved almost all the weird ass ternaries into functions
and should also probably fix some remaining issues where stuff was wrong
2025-04-11 20:45:46 +02:00
Alug 705bb4a8ea dont need to do any of this lel
the calloc takes care of those already
2025-04-11 17:16:11 +02:00
Alug 804ca985f3 just make the numlaps draw besides the date
idk theres no good place for this otherwise
2025-04-11 14:25:00 +02:00
Alug 892a59ff15 add cvar to change the demo date formatting
bruh
2025-04-11 14:24:56 +02:00
Alug 3e60b1b388 bigger buffer for demo version thing 2025-04-11 14:24:52 +02:00
Alug 9c25d99156 print demo version on "outdated" demos
idk if this is fine lel
2025-04-11 14:24:47 +02:00
Alug e8c6dca8c1 dont need le strncpy 2025-04-11 14:24:43 +02:00
Alug 02c1a9a58d apparently we have "nameonly"
ty indev <3
2025-04-11 14:24:40 +02:00
Alug 2201d58f7d try and get file creation time in some cases on windoze builds
untested as of right now
2025-04-11 14:24:36 +02:00
Alug b7542a2106 try to catch more bad demo dates
i mean this game did not exist in 2010 lmao
but occasionally it actually returned dates other than 1970 depending on what was passed to it lmao
2025-04-11 14:24:33 +02:00
Alug f1bcdaf68f do pathseperator check like this 2025-04-11 14:24:29 +02:00
Alug 1ebebb5690 extract the date out of replay + display em in replay hut
this is kinda horrid, but essentially, the number at the start of replay names is actually the time when the replay was recorded, so i can extract that and convert it to a readable format
this probably can be done alot cleaner lmao
2025-04-11 14:24:26 +02:00
Alug 1ddc663e8c add setting for cecho toggle to print to console instead
idk i hate doing string stuff, hope this doesent explode lmao
also ensures even if disabled all cecho stuff is printed to log file again
2025-04-10 22:54:55 +02:00
Alug 5b3edc2131 handle highres portraits and statdisplay text more gracefully on low resolutions
below 640x400 the highres portraits become an absolute mess so itll now fallback to the lowres portraits
the statdisplay name text also became completely unreadable so itll use V_DrawThinString instead on low resolutions
2025-04-10 22:54:52 +02:00
Chearii bc22830136 Fix up several HUD issues
ughhhh splitscreeeeeen
2025-04-10 01:59:59 -04:00
Chearii 90475c1128 Adjust dial rotation for MPH and FU/T 2025-04-10 01:08:15 -04:00
Alug ff6a13f042 simplify those 2025-04-09 23:23:37 +02:00
Chearii 92f08de1f6 Dial speedometer 2025-04-09 16:53:21 -04:00
Alug 29462b082b remove unused variables from FTransform struct 2025-04-09 22:44:34 +02:00
Alug bd9f436227 let item button also change skin grid sorting type 2025-04-07 19:40:27 +02:00
Alug 2b6f507785 reuse pwidth 2025-04-07 17:54:21 +02:00
Alug a0739e59e4 oops this needs be initialized 2025-04-07 15:07:50 +01:00
Alug 8251ac9ca8 sat credits a 2025-04-07 16:20:54 +02:00
Alug f99794884b avoid branching inside the while lööp 2025-04-07 09:10:19 +02:00
Alug dd93e1f7b0 use optimized P_DivlineSide instead of R_PointOnSideFast 2025-04-07 08:40:41 +02:00
Alug 6b12c55393 some software optimizations
from:
https://git.do.srb2.org/Hanicef/SRB2Classic/-/merge_requests/6#d4bba40be8388ccd557d03ef4e4a36d0728c7751_645_587

minus the buffer flipping change, karts resolution stuff is hell and even worse due to birdmod things
maybe will look into that sometime
2025-04-07 08:40:37 +02:00
Alug 4b8d072153 free ogl lighttables earlier
ogl lighttable data is owned by extracolormaps apparently, so it has to be freed ealier
2025-04-07 08:40:16 +02:00
Alug f159b18e96 this is unlikely 2025-04-07 08:40:13 +02:00
Alug 27653381d3 try to rectify some branch mispredictions
adds "LIKELY" and "UNLIKELY" macros
those can be used to tell the compiler which path is more likely to happen
2025-04-06 23:33:14 +02:00
Alug bd77b17c1c whoopy copy paste 2025-04-06 17:13:15 +02:00
Alug 3261fd12db dont need this 2025-04-06 16:25:46 +02:00
Alug 3aff53647d reorder those a little 2025-04-06 15:15:09 +02:00
Alug 4a703a4288 use the float vid dimensions
forgor here
2025-04-06 15:15:06 +02:00
Alug 4880177e65 cache the fofflags too 2025-04-06 11:24:54 +02:00
Alug 744e17a0d6 somehow this is slightly faster 2025-04-06 11:00:27 +02:00
Alug b706c55ed8 cache this
somehow this was unusually expensive lol
2025-04-06 10:50:03 +02:00
Alug fe3ad3487d delet this 2025-04-06 10:49:59 +02:00
Alug 5ff2b52522 more smoller optimizations
save some unneeded floattofixed calls
and move the linedef check earlier
2025-04-06 10:49:56 +02:00
Alug d57438bf8c check for horizonlines on mapload on opengl
this saves iterating through a crapton of lines every frame in ogl
2025-04-06 08:51:55 +02:00
Alug 5f2a8acfa2 Optimze horizonline check
noticed during profiling due to how it was checked R_PointOnSegSide was called extremely often even if the less expensive check  returned false
2025-04-06 08:51:28 +02:00
indev 01bf367ce1 Add 'inputdisplay' option for hud.enable, hud.enabled, hud.disable and hud.getOffsets 2025-04-05 18:36:48 +03:00
Alug 2550f1bee5 no need to scale the volume for splitscreen if we dont play a sound lol 2025-04-04 18:13:41 +02:00
Alug f2d2307fcc didnt mean to change that lel 2025-04-04 08:15:56 +02:00
Alug 33e904632c fix software crash on sparkcup due to invalid blendmode
also simplifies R_GetLinedefTransTable
it now just returns a normal translucency table in case of an invalid blendmode, similar to what vanilla got
not sure if this is 100% correct X)
2025-04-04 02:02:07 +02:00
Alug 2e34d71af6 bruh 2025-04-04 01:57:13 +02:00
Alug 2bc6754598 fix oopsie in R_Render2sidedMultiPatchColumn 2025-04-04 01:57:10 +02:00
Alug 086caa80bb fix OOB read of "playeringame"
not too sure if this is completely save, but it should technically
2025-04-03 21:36:40 +02:00
Alug ac85797a4f erronous endifma balls 2025-04-03 21:22:27 +02:00
Alug ba7d3324e6 kill SATURNSYNCH and can_receive_gamestate, change the detection of synch method
before we unconditionally sent PT_WILLRESENDGAMESTATE to every connected node that didnt desynch before, in a big lobby this could mean having to send out alot of reliable packets to potentially clients that couldnt use it anyways, like this we just check if a client is saturn, which gets set the moment a saturn client v7.1 and onwards joins (it sends a special packet to the server during connect)
this makes sure we only even attempt the new resynch system with clients WE KNOW can use it anyways
this is backwards compatible until v7.1, v7 when this was introduced did not send the special packet on join and relied on the willreceivegamestate packet, so they wont benefit from the better resynching anymore
2025-04-03 21:18:47 +02:00
Alug 6a97341835 update saturn credtis
baaaaaaaaaaarely fits now on greenres
had to kill the tooltip too :/
we should prob think of smth else than abusing a menu for this
2025-04-03 00:13:57 +02:00
Alug 2970ab6ae3 drift only option for coloured speelines
man
2025-04-02 19:48:51 +02:00
Alug 87447e9344 fix the wonky rendering issues on that one si-ht map
saturn regression introduced by the fof slope cutoff fix
hopefully this has no weiird side effects, but so far everything seemed fine
2025-04-02 18:42:50 +02:00
Alug 2980a87d09 use max 2025-04-02 18:42:47 +02:00
Alug 75d1b49aed check if texture exists first 2025-04-02 18:42:44 +02:00
Alug a5421d1a51 smol cleanup skyspecial handling for ogl 2025-04-02 18:42:41 +02:00
Alug 42b2e0622f slight cleanup drawOnMinimap 2025-04-02 18:42:35 +02:00
Alug 8033348aa1 change scr_depth to gr_texturedepth and allow it to change stuff midgame
its not used for software renderer anymore and before you had to restart the game to be able to see a change in gl
8bits and 24bits options have been removed since they had no effect
and it also allowed me to unglobal things
2025-04-02 18:42:03 +02:00
indev bd39a9c2f8 Add pageup and pagedown support in replay hut 2025-04-01 01:19:43 +03:00
Alug 633e9474b8 texfomats without alpha should have maxlod of 5 2025-03-31 22:54:46 +02:00
Alug 588ec05c80 disable compiling with ipv6
its non functional and disabling it just removes more things that could break
2025-03-31 20:34:06 +02:00
Alug dfcba501c4 remove unused stuff d_net 2025-03-31 20:10:54 +02:00
Alug c81e0d5816 put back networking shit into rendering code
just like vanilla yaaay
2025-03-29 18:45:39 +01:00
Alug 92cdc78dda also dont do this without localdelay 2025-03-29 18:01:45 +01:00
Alug 5971e12ea9 oop still need to update this 2025-03-29 18:00:01 +01:00
Alug 0cb18e2058 only do localdelay stuff at all if we intend to use it
shizo sanity check
2025-03-29 17:57:44 +01:00
Alug 501df0763b update ping only once per second again
read the comment on why
2025-03-29 17:33:07 +01:00
Alug 1762765c2f better and more errors for the tcp/udp stuff 2025-03-29 16:56:31 +01:00
indev 0a9ae254c8 Uncap S_UpdateSounds back
Some effects that rely on S_SoundPlaying don't work perfectly if
S_UpdateSounds is capped at 35 fps
2025-03-28 20:59:48 +03:00
Alug 8476e11065 can just set it to null directly 2025-03-28 17:13:13 +01:00
Alug 014c06a797 dont run anything director in dedi
we dont need to even init its stuff
2025-03-28 17:01:51 +01:00
Alug 256f4cf2a8 make a function that returns the newspeedometer style if its availible
makes stuff alot easier to read than constantly checking for if stuff exists everywhere
2025-03-28 16:34:08 +01:00
Alug e540cc901c tiny cleanup inputdisplay
just use V_DrawMappedPatch, it does the same but looks better in code lel
2025-03-28 16:34:04 +01:00
Alug 42f1a55fa7 can just reset this here 2025-03-28 16:33:58 +01:00
Alug 7f59674ea8 force switch player after 15 seconds max
not sure if its too strict but it gets really boring just watching the same person for ages
2025-03-28 16:33:56 +01:00
Alug 0899849681 forgor the header file 2025-03-28 16:33:53 +01:00
Alug 5f5c67601e instant switch if the player we watch is finishing
i dont need to watch the finishline for 5 seconds everytime lmao
2025-03-28 16:33:49 +01:00
Alug 5e8624c79c only count actually playing players for director
otherwise you could enable it if theres more than 1 person in the server but only 1 person is actually playing
2025-03-28 16:33:46 +01:00
Alug 72821f0f16 you cant memset this to -1 lel
prob fixes the director never switching when only one player was left
2025-03-28 16:33:43 +01:00
Alug c2e0e56a80 optimize director by checking for finishline waypoint on mapload
instead of every time this is called
2025-03-28 16:33:40 +01:00
Alug 6919e3cdc8 turn this into a switch for no reason 2025-03-27 23:38:01 +01:00
Alug 4a62b44526 remove pointless function 2025-03-27 23:33:37 +01:00
Alug ac181e238d add smol P-Meter patches
thx jin for those
2025-03-27 23:28:30 +01:00
Alug d323b78d3f seperate the colour hud patches out of here so they can be used without the vanilla colour hud 2025-03-27 23:28:27 +01:00
Alug 2582f6fe93 seperate the driftgauge colour patches into extra2 + add some more comments
was an oversight, extra2 should be for all colour hud patches
2025-03-27 23:28:25 +01:00
Alug 53d698573e fix driftgauge value "small" value being overwritten when having extra3 loaded 2025-03-27 22:12:39 +01:00
Alug 7560d272dd move saturn extra file checking into its own function
and also properly seperate all patch checks so they only get checked if you have the right file
may actually slightly speedup startup in some cases
2025-03-27 22:00:12 +01:00
Alug f6e5d09ffe fix stick setting showing wheel 2025-03-27 21:43:23 +01:00
Alug 825ab0afc0 make beta interscreen cvar also affect tab rankings 2025-03-27 21:43:20 +01:00
Alug 4c4efdfd11 just make the input display global toggle for it
mostly done so i can shorten the entry in the menu cause i cba to mangle stuff again
2025-03-27 21:43:17 +01:00
Alug 1fb34eb71c Add 'StickGFX' option for showinput cvar if graphics for it exist 2025-03-27 21:43:14 +01:00
Alug 3963943904 actually initalise those lmao 2025-03-27 21:41:52 +01:00
Alug d4f97f61c2 no need to check for this 2025-03-27 21:41:48 +01:00
Alug edf545c9a1 add support for sprite joystick knob
still needs proper toggle
2025-03-27 21:41:45 +01:00
Alug 15f9bf181a that comment belongs to this lmao 2025-03-27 21:41:42 +01:00
Alug 884c5d2578 fix vertical patch scale not working when horizontal scale is also not changed in opengl patch drawer 2025-03-27 21:41:39 +01:00
indev 0d6b42cc3f Fix limit_dist overflowing for some mapobjectscale values 2025-03-26 22:11:50 +03:00
Alug 1e8716450f better slope rotation for shadows
instead of copieng the target mobjs rotation we just use its standingslope instead, this means shadows properly rotate according to which slope theire on
should make them visually more cohesive if a player or other mobj is rotated midair
2025-03-26 20:06:31 +01:00
Alug 850272e783 fix spacing when compiled withou fbo support 2025-03-26 18:38:07 +01:00
Alug bf9edef146 add dummy entries so the tooltips dont fucking cutoff stuff in green res
if i only knew of this dumb hack earlier
2025-03-26 18:33:31 +01:00
Alug 35db2b0c8e muh huh durr hurr is above array bounds of deez nuts 2025-03-26 17:21:25 +01:00
Alug c5638d8dbb fix advanced video options in green res
god bruh
also removes the directional light entry since its planned to be deprecated
2025-03-26 18:17:40 +01:00
Alug 4a8a83bf09 fix sprite distort tooltips
Zzzzzzzzzz......
2025-03-26 18:05:31 +01:00
Alug 4b1110921b turn advanced sound ioptions into scoll menu 2025-03-26 18:05:27 +01:00
Alug e159a5f206 turn sprite distortion menu into scoll menu due to green res 2025-03-26 18:00:25 +01:00
Alug 856cdbda6b rename "Custom Options" to "Custom Addon Options"
to make it clear wtf this is even for
2025-03-26 18:00:22 +01:00
Alug 14df21a2ae turn screenshot options into a scoll menu cause of green res 2025-03-26 18:00:19 +01:00
Alug 2075587980 fix focus options for green res 2025-03-26 18:00:16 +01:00
Alug a35362f0ed move everything around in main options menu to fit stuff for green res 2025-03-26 18:00:13 +01:00
Alug 480c4111f9 fix bird menu from crashing (again) finally add an enum so this wont happen again 2025-03-26 18:00:10 +01:00
Alug e671cfebcf lel 2025-03-26 15:54:37 +01:00
Alug 25a80e378d add smol text indicating the autoload button 2025-03-26 15:37:38 +01:00
Alug 2d064d61a9 change menu autoload button to "END" instead of right shift
too many ppl accidentally press right shift and end up putting things they didnt intend into their autoload file
which sometimes caused alot of issues in online play
2025-03-26 15:37:35 +01:00
Alug 6b16d27576 brazil 2025-03-26 14:54:41 +01:00
Alug 5422ab4daf tab hell 2025-03-26 14:54:38 +01:00
Alug cbcfed133c change version string for testing "RC1"
were close to being done with v8, its now mostly just about catching any remaining bugs and regressions
2025-03-25 20:41:00 +01:00
Alug 064032175e grey out mouse grab when use_mouse is enabled 2025-03-25 20:05:13 +01:00
Alug e7eca015ac add onchange for "alwaysgrabmouse" 2025-03-25 20:05:10 +01:00
Alug d94b443eca put all the "game focus" options into a seperate menu 2025-03-25 19:36:05 +01:00
Alug 434048afad potentially fix "Received a file not requested" error in poor net conditions
needs a bit of testing
2025-03-25 16:53:07 +01:00
Alug 3614efa965 fix server lan discovery
which just returned EINVAL and triggered the I_Error in SOCK_Send
more information at: https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2219
2025-03-24 23:04:52 +01:00
Alug ec30b1a457 Merge branch 'socksnedstuff' into Saturn-Testing 2025-03-24 23:04:34 +01:00
Alug 3b43df0214 delet this 2025-03-24 19:37:52 +01:00
Alug ea3974d47e Revert "clean up some net stuff"
This reverts commit f8903e7ce7.
2025-03-24 19:37:49 +01:00
Alug f7e5f9f5b6 delet this 2025-03-24 19:36:41 +01:00
Alug c425400480 Revert "clean up some net stuff"
This reverts commit f8903e7ce7.
2025-03-24 19:36:38 +01:00
Alug aea03cc2b7 grey saltroll out in menu if sloperoll disabled 2025-03-24 18:22:22 +01:00
Alug e369fbded4 toggle for saltyhop sloperoll behaviour 2025-03-24 18:22:16 +01:00
indev 792806c20d No need to FLOAT_TO_FIXED here :з 2025-03-24 17:20:28 +01:00
indev fc894d8631 No need to FLOAT_TO_FIXED here :з 2025-03-24 19:15:43 +03:00
Alug dcc3b1294c remove the early returns in SOCK_Send
othewise it may never error out when it should
2025-03-24 16:32:56 +01:00
Alug 5d0a8ff6dd Do not error out if we don't have a socket for an address family we have disabled
from srb2
2025-03-24 16:32:53 +01:00
Alug c6cc7d3d29 Replace all instances of XD_KICK with a SendKick function 2025-03-24 16:00:15 +01:00
Alug d2838c2780 i hate menus 2025-03-23 18:31:47 +01:00
Alug 4e13febeaf this does not need be checked here 2025-03-23 18:24:55 +01:00
Alug 3e80554a0e k_throwdir already returns just -1, 0 and 1 2025-03-23 18:17:49 +01:00
Alug f3d8b2b3d1 add player blendeffects to menu + change when they apply
most of them now apply during sneakerboost
sparkles may also get add blendmode when you go really fast with them (like the speedlines)
2025-03-23 18:15:06 +01:00
Alug 475ba7ca10 change "verticallook" and "cameralookbackmom" to be per splitscreen player 2025-03-23 18:13:52 +01:00
Alug 16c13cb561 Merge pull request #155 from Indev450/rankingsrefactor
Refactor Rankings Drawing
2025-03-23 17:10:23 +01:00
Alug fd9902afd6 15 step increment Zzz... 2025-03-23 16:59:02 +01:00
Alug eb936a6f94 simplify the slider stuff slightly 2025-03-23 16:57:20 +01:00
Alug 184d171b74 make stretchfactor a cv_float again
for easier handling
now that we can use sliders this should hopefully work without issues
2025-03-23 16:57:17 +01:00
Alug dc8b9ffc7c make saltyhop height use slider 2025-03-23 16:57:14 +01:00
Alug f7fbb8b859 make menu sliders work on CV_FLOAT 2025-03-23 16:57:11 +01:00
Alug 8fce9e39a0 changable saltyhop height
dunno, it looks a bit off on higher values since the animation duration is always the same
also cv_float is weird
2025-03-23 16:57:08 +01:00
Alug dee640d32f forger P_IsLocalPlayer exists 2025-03-21 15:56:18 +01:00
Alug 0af6703c08 hack for stick input display if you watch some other player Zzz.... 2025-03-21 15:53:20 +01:00
Alug b0d6ccf572 dont run discord rpc callbacks every frame
ditto
2025-03-21 00:21:49 +01:00
Alug 9e3dcbd041 dont update sounds every frame
if this would break ppl on 35fps cap wouldve been always screwed lel
2025-03-21 00:21:46 +01:00
Alug 9283b443c1 kill this, i want vanilla behaviour 2025-03-20 19:42:10 +01:00
Alug 189a28f349 delet player_joining 2025-03-20 19:42:07 +01:00
Alug e02288b689 kill this, i want vanilla behaviour 2025-03-20 19:40:49 +01:00
Alug a90c44c7d8 delet player_joining 2025-03-20 19:40:43 +01:00
Alug eaac6cdbb3 Merge remote-tracking branch 'origin/serverstuttertest' into Saturn-Next 2025-03-20 17:49:29 +01:00
Alug aba138447c continue in P_NetArchiveThinkers lööp
if thinker is P_RemoveThinkerDelayed
2025-03-20 17:31:57 +01:00
indev 28af4e5277 Only reset replay query in M_ReplayHut if replay hut wasn't open previously 2025-03-20 01:16:57 +03:00
Alug a662a0a68f Revert "disable jit compilation for now"
This reverts commit 11f5d2fb07.
2025-03-17 18:52:27 +01:00
Alug 5aa081a01b Revert "Use PU_LEVEL for texture caching"
This reverts commit 5ecfc5e09d.
2025-03-17 18:43:45 +01:00
Alug 24e149634d remove this again 2025-03-17 18:41:29 +01:00
Alug 635b4110a4 move patch null checks into the patch drawers instead 2025-03-17 18:41:27 +01:00
Alug 56ddb5da23 revert this too just in case 2025-03-17 18:26:42 +01:00
GenericHeroGuy ece1122733 Fix tonumber leaking doubles when JITted 2025-03-17 17:18:33 +01:00
Alug dd70743bae make the banana throw speen be seperate from sloperoll toggle
were technically not rolling by slopes here
2025-03-17 15:56:22 +01:00
Alug 5ab7e8dd80 forgor about saltyhop condition 2025-03-17 15:56:14 +01:00
Alug c7473ddf42 add function to check if mobj should sloperoll
makes things slightly cleaner and we can apply sloperoll dist to everything
should probably save some time esp with the trailing item z calc
+ P_MobjPitchAndRoll should be able to be called always since it also does stuff seperate from sloperoll
2025-03-17 15:56:11 +01:00
Alug 0119eeb575 use quickcamdist for K_RollMobjBySlopes
we dont need this to be accurate at all
and its slightly faster so
2025-03-17 14:21:49 +01:00
Alug dc53fac53d fix midair driftsparks
somehow accidentally ended up doing what RR does lmao
hope this doesent do anything funky synchwise
2025-03-17 13:43:09 +01:00
Alug d86179f1a4 kill bunch of redundant calcs for some kart visual effects 2025-03-17 13:43:06 +01:00
Alug 53a73e9893 safe some time by returning early in K_RollMobjBySlopes
in case those mobjs are out of our set distance
2025-03-17 12:40:33 +01:00
Alug 3efb6c0241 dont let saltyhop stop our drift sounds for 1 tic
if you disable its sound effects
2025-03-17 11:15:27 +01:00
Alug f6535c8ad3 noo dont free our realpatch randomly
this used to be Z_Unlock which did nothing
checked against srb2 and rr and this should not be freed normally
2025-03-16 21:16:39 +01:00
indev 6d7035afac Fix gl_extensions being truncated when there are too many extensions 2025-03-16 17:28:30 +03:00
Alug 2c5c08e562 did not mean to push this 2025-03-16 15:25:28 +01:00
Alug 11f5d2fb07 disable jit compilation for now 2025-03-16 14:15:24 +01:00
Alug 74ee853b49 just skip this loop if P_RemoveThinkerDelayed
we cant do anything there anyways, so this might be ever so slightly faster
2025-03-16 13:27:13 +01:00
Alug 0af6c133c5 only do the nvidia fbo hack when sdl_renderer is "x11"
we dont need this on the wayland renderer anymore
2025-03-16 13:23:49 +01:00
Alug cefad32181 dont I_Error when direct downloader failed to open a file
just cancle the transfer and kick the receiving client lel
2025-03-16 13:19:28 +01:00
Alug 2b1eb51d94 goddamit 2025-03-16 12:24:53 +01:00
Alug 1df7d07abc oops 2025-03-16 12:24:00 +01:00
Alug fca3bb3cc3 slight cleanup HWR_ObjectLightLevelPost 2025-03-16 12:18:10 +01:00
Alug 45a7689518 Merge branch 'rankingsrefactor' into Saturn-Testing 2025-03-16 11:51:46 +01:00
Alug 16b74190e5 put player into var in rankingsdrawer 2025-03-16 11:22:15 +01:00
Alug 2f33b0eb79 Merge branch 'Saturn-Next' into rankingsrefactor 2025-03-16 11:13:02 +01:00
Alug cf64aa3823 Merge branch 'Saturn-Next' into Saturn-Testing 2025-03-16 11:09:25 +01:00
Alug 8c8fe976d7 dumb hack for input display in replays
since we cant get playerinput, just use throwdir to get some appoximation
maybe todo: idk maybe squeeze smth into replays?
2025-03-16 11:09:02 +01:00
Alug 8c43857bd3 add extra check to save a little bit of time 2025-03-16 11:08:55 +01:00
indev 380c8f65c8 aatree is used both with HWRENDER and ROTSPRITE, so just don't guard its include 2025-03-16 11:08:39 +01:00
Alug 5ec0af62d9 safe 2x "va" lel
V_GetSkincolorChar is unused now lel
2025-03-16 11:08:36 +01:00
Alug 3762b18159 just use splitflags 2025-03-16 11:08:31 +01:00
Alug b6de9e03d7 doesent need be an array 2025-03-16 11:08:27 +01:00
Alug 486f386f35 New input display option for stick display
thy neppy! https://codeberg.org/NepDisk/blankart/commit/52601bdfc2a6dd8916c3c401d70128d2ca11a1ff#diff-baf740b84aa99188fc2e5c1cb93e59fa2e319ff3

+ hellish abomination code cause kart
2025-03-16 11:08:23 +01:00
Alug 848d84147f Merge branch 'minispin' into Saturn-Next 2025-03-16 11:06:41 +01:00
Alug a980784771 replace magic number 2025-03-16 11:06:06 +01:00
Alug 0f675661a6 bruh 2025-03-16 11:05:28 +01:00
Alug 30deff7697 fix conflicts for minimap spinouts + some refactoring 2025-03-16 11:05:23 +01:00
Anonimus 21c267b319 Refactor to prevent desynchs 2025-03-16 11:05:19 +01:00
Anonimus cce363c8c8 Add a cvar for minimap icon spinouts 2025-03-16 11:05:15 +01:00
Alug 944d8187ba this needs be multiplied by 8 lel oops 2025-03-15 18:41:45 +01:00
Alug c9b3459a48 add extra check to save a little bit of time 2025-03-15 16:51:09 +01:00
Alug ec0a1a97e0 make this slightly look better lel 2025-03-15 16:33:58 +01:00
Alug dd81b2cc41 fix no previous prototype warning
:chaosleep:
2025-03-15 16:31:16 +01:00
Alug 7d58887138 replace magic number 2025-03-15 16:30:52 +01:00
Alug a79f2fa90a bruh 2025-03-15 16:29:54 +01:00
Alug 473c70fd70 Merge branch 'gitpls' into Saturn-Testing 2025-03-15 16:27:00 +01:00
Alug bbd967adad fix conflicts for minimap spinouts + some refactoring 2025-03-15 16:26:43 +01:00
Anonimus f55fdbf630 Refactor to prevent desynchs 2025-03-15 16:21:15 +01:00
Anonimus 6b23c70e37 Add a cvar for minimap icon spinouts 2025-03-15 16:21:05 +01:00
Alug 1d4e6ca825 Merge branch 'Saturn-Testing' into gitpls 2025-03-15 16:18:37 +01:00
indev deeae1ef56 aatree is used both with HWRENDER and ROTSPRITE, so just don't guard its include 2025-03-15 16:46:56 +03:00
Alug ed87c40d13 safe 2x "va" lel
V_GetSkincolorChar is unused now lel
2025-03-15 14:48:48 +01:00
Alug ac28e587e2 just use splitflags 2025-03-14 21:00:12 +01:00
Alug 55d2d2cce4 doesent need be an array 2025-03-14 20:56:57 +01:00
Alug f3d5c3f698 New input display option for stick display
thy neppy! https://codeberg.org/NepDisk/blankart/commit/52601bdfc2a6dd8916c3c401d70128d2ca11a1ff#diff-baf740b84aa99188fc2e5c1cb93e59fa2e319ff3

+ hellish abomination code cause kart
2025-03-14 20:46:52 +01:00
Alug d92ba0987b Merge branch 'Saturn-Next' into Saturn-Testing 2025-03-12 07:01:46 +01:00
Alug c081349f9b make freecam speed per splitscreenplayer + add to menu 2025-03-12 07:01:19 +01:00
Alug 88b78a5bf7 delet cam rotspeed cvar
lmao forgor this did nothing
2025-03-12 07:01:15 +01:00
indev cf9e7ff37b Add toggle for look up/down, also don't trigger it during countdown or when player is respawning 2025-03-11 14:59:24 +01:00
Alug 8775e5abc1 fix compile without ROTSPRITE 2025-03-10 17:53:17 +01:00
Alug 9b3fde7a19 fix compile without ROTSPRITE 2025-03-10 17:52:46 +01:00
Alug fe6b5a83f8 consolidate those 2025-03-10 17:29:20 +01:00
Alug e39a9c190a consolidate those 2025-03-10 17:29:13 +01:00
Alug 30fff79bd0 make this slightly less ugly 2025-03-10 14:59:46 +01:00
Alug 7781237c56 add cvar to force mouse grab and hide 2025-03-10 14:56:23 +01:00
Alug 288bcbd419 bruh 2025-03-10 14:06:18 +01:00
Alug 51408010e8 bruh 2025-03-10 14:06:12 +01:00
Alug 7aeaf76062 Merge branch 'Saturn-Next' into Saturn-Testing 2025-03-10 14:05:38 +01:00
Alug 4465b05bc8 p_sight stuff idk 2025-03-10 14:04:27 +01:00
indev 537aa30cfe Don't reset demo recording if player is still entering replay name in intermission 2025-03-10 13:16:44 +01:00
Alug e16ef100b8 try make this slightly more readable 2025-03-10 13:10:07 +01:00
indev a277d70ce2 Don't force specific characters in M_HandleConnectIP 2025-03-10 13:06:03 +01:00
Alug 6932a52463 change speelines blending condition
uuuhh, so, if you have sneakerboost they always will apply additive blending
otherwise if you go really fast (faster than sneakerboost)
2025-03-10 13:05:55 +01:00
Alug a686b29a7a only apply additive blend to speedlines when any kind of boost is happening
to emphasize that ure boosting or smth
2025-03-10 13:05:19 +01:00
Alug c133f0d751 add additive blending to fast speedlines 2025-03-10 13:05:09 +01:00
Alug 5ff125a429 spawn speedlines with non synched rng if ur in eggbox status
and well only if you have colourisation enabled
2025-03-10 13:05:01 +01:00
Alug b8cab84d2a super smol optimization 2025-03-10 13:04:11 +01:00
Alug d2975d2dcb toggle for keeping driftsparks while in air 2025-03-10 13:02:23 +01:00
indev e802ecf0b5 Add SHORT here for consistency with other code 2025-03-10 13:01:35 +01:00
indev 71378285b2 Check for missing patch earlier in W_CachePatchNameRotated 2025-03-10 13:01:32 +01:00
Alug ffe9a89552 remove erronous cv_sloperoll checks
this cvar is meant to be only the toggle for the player slope rotation, however, spriterotation should still be usable in any case with this disabled. the global toggle "cv_spriteroll" has been removed
2025-03-10 13:01:25 +01:00
indev ac9926eb17 spriteroll doesn't exist now :p 2025-03-10 13:01:19 +01:00
Anonimus 0b57389dcd HUD patch rotation 2025-03-10 13:01:16 +01:00
Alug e2b42b1647 delet memcpy doing nothing 2025-03-10 13:00:33 +01:00
Alug ad39ade286 split screentexture width and height
most displays are widescreen, so their width and height differ quite significantly, this may make the overall screentexture alot smaller
2025-03-10 12:59:25 +01:00
Alug 0ed21a171d remove stray bool in demovars struct 2025-03-10 12:58:18 +01:00
Alug ad65e3e968 allocate some extra buffer for demobuffer
incase this might overflow that we dont write to unvalid memory
thx indev <3
2025-03-10 12:56:51 +01:00
Alug d55d7e0efc smol replay fixes from rr 2025-03-10 12:54:39 +01:00
Alug ec7fa833d5 only ever touch this if player has a mobj
angleturn is broken in kart
2025-03-10 12:53:44 +01:00
Alug 2e6c1d9df4 revert this behaviour
be more like vanilla
2025-03-10 12:51:50 +01:00
Alug 7d55c46979 make P_InitCamera slightly prettier 2025-03-10 12:50:10 +01:00
Alug af2b22e91f cleanup P_SetupLevel
removed bunch of pointless vars, moved some things into functions
changed some stuff to be boolean
2025-03-10 12:50:03 +01:00
Alug e983174559 another check for realpatch lel 2025-03-10 12:47:46 +01:00
Alug 006bda5bfc Merge branch 'Saturn-Next' into serverstuttertest 2025-03-09 16:27:22 +01:00
indev 148b76f4a3 Add SHORT here for consistency with other code 2025-03-08 18:14:26 +03:00
indev 422e63a93d Check for missing patch earlier in W_CachePatchNameRotated 2025-03-08 18:14:26 +03:00
Alug 2aff0ed03a show smol notice in stat and ra menu when game is modded 2025-03-07 23:35:32 +01:00
Alug 341d592001 show smol notice in stat and ra menu when game is modded 2025-03-07 14:49:15 +01:00
Alug 568890e9b3 remove erronous cv_sloperoll checks
this cvar is meant to be only the toggle for the player slope rotation, however, spriterotation should still be usable in any case with this disabled. the global toggle "cv_spriteroll" has been removed
i kinda forgot to remove those when i did some refactoring ealier
2025-03-07 10:07:31 +01:00
indev a1e9cacb9f spriteroll doesn't exist now :p 2025-03-06 19:43:24 +03:00
Anonimus a258379a3b HUD patch rotation 2025-03-06 19:34:52 +03:00
Alug 3bde3b04ae try just passing the sector + add 50 trillion extra checks
idk anymore but this is literally now how vanilla kart behaved
2025-03-05 11:23:40 +01:00
Alug 9e070a6516 tiny cleanup SCR_DisplayTicRate 2025-03-05 11:22:51 +01:00
Alug 8d9c6ec65f localping color was lost 2025-03-05 11:21:22 +01:00
Alug ec263086d8 use lööps for those to look a little better lel 2025-03-05 11:18:32 +01:00
Alug 06ccb4f7b0 dont reset cam using f12 when only one player is ingame 2025-03-05 11:18:23 +01:00
Alug 95daa7eacc just set this directly
no need for all of this
2025-03-05 11:18:05 +01:00
Alug d18afa1781 dont run this if cam tilt disabled 2025-03-05 11:16:56 +01:00
Alug 883c382a1d slightly refactor chasecam stuff again 2025-03-05 11:16:23 +01:00
Alug c82eb25628 where did this come from 2025-03-05 11:14:45 +01:00
Alug 8c0294898e fix issues with models
- Sloperotation was weird, it now uses what we calculate in K_RollMobjsBySlopes
- in general uses srb2s newer system
- alot of cleanup of pointless variables
- sprinfo pivots should now work
- removed roillmodel since it was smth weird and broke rollangle
2025-03-05 11:14:06 +01:00
Alug d09c8bb8fd ss->touching_preciplist deez 2025-03-05 11:13:43 +01:00
Alug d397a07d96 dont recalc if precip sector didnt move
forgor i can just check this
2025-03-05 11:13:40 +01:00
Alug 96f842fd96 only need to recalc this once a tic
precip thinker thinks slightly more often, but we really dont need that tbh
2025-03-05 11:13:34 +01:00
Alug 105b3f37eb only recalc floorz for visible precip mobjs
before it apparently recalced it a crapton for the crapton not visible precipmobjs, which even on vanilla maps led to noticable jitter
2025-03-05 11:13:26 +01:00
Alug 24387b50bd missed this for keepmusic 2025-03-05 11:12:22 +01:00
Alug 0c4661c2a7 remove this 2025-03-05 11:11:27 +01:00
Alug 178c942dc6 pass slope to K_RollMobjBySlopes
removing some code dupe in the process and allows some more flexability
2025-03-05 11:09:19 +01:00
Alug 47d41e2c2a refactor M_DrawSlider
apparently fixes weird framerate issues with gamma slider
also shows the values on sliders
2025-03-05 11:09:01 +01:00
Alug 4d7c223565 Have replay recording of "hits" use the reference count system
https://git.srb2.org/KartKrew/RingRacers/-/commit/fa8bffabfc51ea1d7be86d833190bb7dcf494fca
2025-03-05 11:08:18 +01:00
Alug e3af2b0d58 better prints if a replay desynchs 2025-03-05 11:08:06 +01:00
Alug f4ed9b43cd refactor keepmusic again
- puts all music stuff into a struct "music_t"
- should hopefully fix numerous issues with keepmusic and skipintromusic
- keepmusic can now "recover" from a few cases, like restarting the map from intermission
2025-03-05 11:06:57 +01:00
Alug 55cd0fa08f ensure proper cast 2025-03-05 10:59:34 +01:00
Alug 8cce4f3ccf whitespace lul 2025-03-05 10:59:18 +01:00
Alug 1e21f6a378 only do mouse stuff if we wanna do mouse stuff 2025-03-05 10:59:03 +01:00
Alug a0af6f2461 remove unused stuff i_video 2025-03-05 10:57:55 +01:00
Alug 390e3db25d tiny cleanup keyboard stuff 2025-03-05 10:55:16 +01:00
Alug 3d9bb65e62 Merge pull request #157 from Indev450/gentlemens
Offline ping System
2025-03-05 10:53:10 +01:00
Alug 4f88a97739 inline a few hooklib functions 2025-03-05 10:52:34 +01:00
Alug de977167ca pointless inline 2025-03-05 10:52:15 +01:00
Alug 84028f52d8 few instances of int float conversions i forgor 2025-03-05 10:50:35 +01:00
Alug f693ca8333 optimize ogl drawer functions
by avoiding excessive interger to float conversions
2025-03-05 10:50:28 +01:00
Alug 64dd17d75d ensure proper casting 2025-03-05 10:48:25 +01:00
Alug b3ce832753 check for shader cvar ealier 2025-03-05 10:47:59 +01:00
Alug b9c89b381b nullcheck for realpatch 2025-03-05 10:47:12 +01:00
Alug c8a0a2bdae dont need to pass the viewnumber around 2025-03-05 10:46:30 +01:00
Alug 84d3d0d891 smol cleanup portal code again 2025-03-05 10:44:56 +01:00
Alug fe42f1bd3e change syntax
will stay uppercase to not conflict with some crap Zzz...
2025-03-05 10:41:09 +01:00
Alug b5803e8787 move this after the early returns
save some time when drifting
2025-03-05 10:40:10 +01:00
Alug 9f7aca5fe3 lmao 2025-03-05 10:39:57 +01:00
Alug ac8e25865e turn driftsparkGrowTimer into a player field
less hacky and avoids 3 loops lol
2025-03-05 10:39:52 +01:00
Alug 02b411f7ee kill redundant laptime code
just use the newer one
2025-03-05 10:39:41 +01:00
Alug 9dee892244 more kart hud cleanup
also removes erronous nametag toggles
2025-03-05 10:38:18 +01:00
Alug e5d832a642 slight cleanup kart hud 2025-03-05 10:38:14 +01:00
Alug b069c2cb3e tiny d_main cleanup 2025-03-05 10:37:10 +01:00
Alug 7235f9864e delete nonfunctional second mouse stuff 2025-03-05 10:34:18 +01:00
Alug e4e1f0c645 revert all the server ticking stuff 2025-03-05 10:33:49 +01:00
Alug 54747c6b53 Prevent dropped ticcmds due to interp timing jutter
kinda figured out what this does, and makes clients on uncapped listen servers alot less prone to drop gametics
2025-03-05 10:32:37 +01:00
Alug 9ed242cde2 where did this go? lel 2025-03-05 10:27:09 +01:00
Alug 9bcfe63e3e Merge branch 'Saturn-Next' into gentlemens 2025-03-05 10:25:46 +01:00
Alug b38460473d Merge pull request #153 from Indev450/freecamstuffs
Replace spec cam with Freecam + "democam" (now freecam) refactor
2025-03-05 10:24:46 +01:00
Alug fd77beabe1 Merge remote-tracking branch 'origin/Saturn' into Saturn-Next 2025-03-05 10:24:22 +01:00
Alug 5dfab42fcf Merge pull request #158 from Chearii/blendmodes
Blending modes (and a few refactors)
2025-03-05 10:12:55 +01:00
Alug 72d94b77ac fix blendmode oopsie 2025-03-04 19:46:05 -05:00
Chearii 54d73206ca Fix `hw_draw` gaffe 2025-03-04 19:42:59 -05:00
Alug 637499dcd7 use memcmp for R_IsEmptyLine
:chonkbuncle:
this actually is quite a little faster too
2025-03-05 00:09:35 +01:00
Alug 1e79d464b0 fix blendmode oopsie 2025-03-05 00:08:36 +01:00
Alug 932381052b try make this slightly more readable 2025-03-04 19:27:51 +01:00
Alug 367c4179fd change syntax
will stay uppercase to not conflict with some crap Zzz...
2025-03-04 19:14:57 +01:00
Alug 0fc9f2ec00 smth smth magic number 2025-03-04 19:14:54 +01:00
Alug 1646014561 pointless inline 2025-03-03 11:20:17 +01:00
Alug 9152ee826d empty function lel 2025-03-03 11:16:20 +01:00
Alug 08ce1b54ca delet memcpy doing nothing 2025-03-03 11:16:18 +01:00
Alug 37b74be3bb tiny cleanup keyboard stuff 2025-03-03 10:11:28 +01:00
Alug fac2e8ec98 tiny cleanup keyboard stuff 2025-03-03 09:56:49 +01:00
Alug 58fd729bec temp revert nanosleep for nix 2025-03-03 00:14:25 +01:00
GenericHeroGuy 0c2244d668 Figured out why that doesn't work 2025-03-03 01:34:24 +03:00
GenericHeroGuy 40d0d9d2b8 Properly constant-fold (0 or 123)
But not (0 and 123). Yay bug compatibility!
2025-03-03 01:34:24 +03:00
Alug 3ce78064ed guh 2025-03-02 23:29:07 +01:00
Alug 9db8d05206 muh huh truncuate my butt mingw32 2025-03-02 23:29:05 +01:00
indev 22a0ce1e20 Revert "Convert parsed numbers to doubles first in lj_strscan_scan"
This reverts commit 3f8fb365a0.
2025-03-03 01:04:06 +03:00
indev 3ff8a920c0 Revert "Restore setnumV for fmt == STRSCAN_NUM in lj_strscan_scan"
This reverts commit 644cd36286.
2025-03-03 01:04:06 +03:00
Alug 912e340028 bugger off UPX
dont want compressed executables, they BREAK backtraces
2025-03-02 23:02:54 +01:00
Alug 751885128a inlining failed in call to my butt 2025-03-02 22:11:50 +01:00
indev 644cd36286 Restore setnumV for fmt == STRSCAN_NUM in lj_strscan_scan 2025-03-03 00:01:06 +03:00
Alug 91601c8a2d forgor cleanup 2025-03-02 21:45:32 +01:00
Alug f70351fc75 screw you music system
no fucking clue but this fixes stuff showing the musiccredit too early on reload
2025-03-02 21:42:14 +01:00
Alug 976cb1ff25 lul 2025-03-02 21:41:58 +01:00
indev 3f8fb365a0 Convert parsed numbers to doubles first in lj_strscan_scan
Regular blua does something similar to that, and it changes how large
numeric literals are parsed. It's very rare for those to be used but can
still in theory cause synch issues between blua and bluajit clients
2025-03-02 14:48:12 +03:00
indev 5cfbc8ce48 Delet goto from bluajit, since regular blua doesn't support that 2025-03-01 03:44:15 +03:00
indev 89033de836 Fix water and fog shader missing #version 2025-02-28 22:31:27 +03:00
Alug ff4c6ea950 more kart hud cleanup
also removes erronous nametag toggles
2025-02-28 18:55:52 +01:00
indev c3f32da557 Don't reset demo recording if player is still entering replay name in intermission 2025-02-28 18:49:02 +03:00
Alug 9d7930ed3c slight cleanup kart hud 2025-02-28 09:51:51 +01:00
Alug 0dd54b112e add airsparks to saturn options 2025-02-27 19:46:04 +01:00
Alug b10a502b0e Merge remote-tracking branch 'origin/serverstuttertest' into Saturn-Testing
Rather not have this cause dumb issues like every single other time interp and ticking was touched, so just behave like vanilla
2025-02-27 19:41:24 +01:00
Alug 8f342110c9 color ping numbers for color hud 2025-02-27 19:40:32 +01:00
Alug 980d59c9be color ping numbers for color hud 2025-02-27 19:37:29 +01:00
Alug 6d977ea949 Revert "better M_Random implementation"
This reverts commit a353dceaa3.
2025-02-27 19:34:35 +01:00
Alug e723948756 do this in a less horrifieng manner 2025-02-27 19:12:07 +01:00
Alug d95e3c6e04 use floor shader for everything when paletterender disabled
just like vanilla!
not the way to do this properly, but whatever
2025-02-27 18:51:05 +01:00
Alug 7fdf986df4 actually can just use this directly 2025-02-26 13:04:35 +01:00
Alug 6b049ad86d turn this into a switch
else if stinky
2025-02-26 11:14:19 +01:00
indev a0fc6f7e22 Add toggle for look up/down, also don't trigger it during countdown or when player is respawning 2025-02-23 14:21:30 +03:00
Alug d0890c45e2 use lj_char_isspace 2025-02-21 22:31:32 +01:00
indev 93b3926008 Allow trailing spaces in lj_strscan_scan 2025-02-20 23:32:05 +03:00
Alug 3fe94b68a3 toggle for keeping driftsparks while in air 2025-02-19 12:05:56 +01:00
Alug 34f5a58692 reuse var 2025-02-19 12:05:52 +01:00
Alug b605c8e654 few instances of int float conversions i forgor 2025-02-19 12:05:50 +01:00
Alug 95df997198 Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Testing 2025-02-19 12:05:44 +01:00
indev 51ba4f1ec8 Merge branch 'Saturn-Next' into serverstuttertest 2025-02-18 19:14:52 +03:00
indev 1af9903439 Fix compilation with old sdl 2025-02-18 12:29:47 +03:00
Alug 457186fe40 Merge branch 'Saturn-Next' into Saturn-Testing 2025-02-17 21:34:18 +01:00
Alug b4269cba3e properly init numcontrollers 2025-02-17 21:34:09 +01:00
Alug 70a985e274 dont check number of controllers every frame 2025-02-17 21:34:06 +01:00
Alug f15f24914d initialize this 2025-02-17 21:24:28 +01:00
Alug a30aad04da Merge branch 'Saturn-Next' into serverstuttertest 2025-02-17 20:55:11 +01:00
Alug ad74af426b Merge branch 'Saturn-Next' into Saturn-Testing 2025-02-17 20:55:02 +01:00
Alug 75d69dc90d skip a bunch of stuff in dedi/render_none 2025-02-17 20:54:56 +01:00
Alug 115eea3828 revert all the server ticking stuff 2025-02-17 20:40:22 +01:00
Alug 7322d553ba Revert "Merge pull request #151 from Indev450/fixdupeacks"
This reverts commit 1fabc14ac9, reversing
changes made to d9492eee28.
2025-02-17 18:05:30 +01:00
Alug 5bf24e10b2 Merge remote-tracking branch 'origin/oglprecache' into Saturn-Testing 2025-02-17 17:24:10 +01:00
Alug 10f1507366 Revert "Merge pull request #151 from Indev450/fixdupeacks"
This reverts commit 1fabc14ac9, reversing
changes made to d9492eee28.
2025-02-17 18:04:38 +01:00
GenericHeroGuy badb8c7914 Add cleanjit target
Recompiling the whole game after changing a single flag is pretty tiring
2025-02-17 17:43:01 +01:00
GenericHeroGuy 13b2f6534e Fix some functions leaking doubles in INTONLY 2025-02-17 17:42:55 +01:00
Alug c78ecd8453 Revert "Fix "attempt to perform arithmetic on a number value" errors"
This reverts commit a9429caf09.
2025-02-17 17:42:49 +01:00
Alug b61e29ef0f die json 2025-02-17 17:06:36 +01:00
Alug ca555e7ea6 fix some typos lel 2025-02-17 17:02:09 +01:00
Alug a1f254a0bc ensure proper casting for elapsedseconds 2025-02-17 16:59:50 +01:00
indev a9429caf09 Fix "attempt to perform arithmetic on a number value" errors
Not best fix but i don't know why setnumV breaks here
2025-02-17 14:21:44 +03:00
Alug 7bf50c69e2 update software precache
spit stuff into functions
handle animated textures and flats too
2025-02-16 16:47:15 +01:00
Alug fcd8cfc4d5 better handling of sprite angles in precache
only cache stuff that we need
2025-02-16 16:38:56 +01:00
indev 9efd24e376 camara 2025-02-16 17:49:43 +03:00
Alug 5b0a662b40 skip checking sectors and lines multiple times 2025-02-16 15:38:16 +01:00
Alug 255c8437d7 slightly optimize ogl precaching
cleanup too
2025-02-16 15:38:11 +01:00
Alug 83b242a727 make texture precache toggable 2025-02-16 15:38:08 +01:00
Alug 4ef6c2ea34 guard this in sprite precache 2025-02-16 15:38:05 +01:00
Alug 29b93f63f7 precache animated textures too 2025-02-15 16:22:45 +01:00
Alug a403d96204 also precache animated flats
i have no clue how tf animated textures work
2025-02-15 16:22:42 +01:00
Alug c1a187084d dedicated server does not need to call texture precaching
prob leftover from back in the day, it doesent do anything at all anyways
also gives it a less ambigous name
2025-02-15 02:16:05 +01:00
Alug 7808dc5740 precache (most) sprites on ogl leveload 2025-02-15 02:16:02 +01:00
Alug 4417eabdc7 move texture precache into own function
unnesting stuff
2025-02-15 02:15:58 +01:00
Alug 119b18521f oops should be i 2025-02-15 02:15:55 +01:00
Alug ccefafd172 load both encore and non encore tex 2025-02-15 02:15:52 +01:00
Alug a75bf1b2bb move precache into hw_cache.c 2025-02-15 02:15:49 +01:00
Alug 15a0b9ab93 handle encore in ogl precaching
thx indev for help <3
2025-02-15 02:15:45 +01:00
Alug 9bed58a863 this is incorrect, dont need it anyways 2025-02-15 02:15:42 +01:00
Alug 19dd5ddbae disable ogl precaching on encore mode
noencore things need to be handled
for now just disable it until i figure out how to check for lineflags here
2025-02-15 02:15:39 +01:00
Alug 8cd636c213 precache level flats and textures on mapload in opengl
not entirely sure if this works correctly with encore, have to test a little
TODO: move this into hwr file or smth
2025-02-15 02:15:36 +01:00
Alug d156b716f6 add toggle for blendmode player effects
otherwise people will yell
enabled by default for now for demonstration purposes
2025-02-13 18:41:58 +01:00
Alug 3f910824e8 make P_InitCamera slightly prettier 2025-02-12 17:55:31 +01:00
Alug 3509b05d1e cleanup P_SetupLevel
removed bunch of pointless vars, moved some things into functions
changed some stuff to be boolean
2025-02-12 17:38:41 +01:00
Alug 164bd18234 split screentexture width and height
most displays are widescreen, so their width and height differ quite significantly, this may make the overall screentexture alot smaller
2025-02-12 14:34:36 +01:00
Alug 1eae8c6ea3 use correct type in P_InitMinimapInfo 2025-02-12 12:01:05 +01:00
Alug 14881e968a simplify local ping display 2025-02-12 12:00:54 +01:00
Alug fcc9cdcaef use correct type in P_InitMinimapInfo 2025-02-12 11:56:51 +01:00
Alug b32785f88c revert adding netbuffer to local ping
dont wanna revert the commit, since i keep the new way of determining the ping display, since its less awful than before
2025-02-11 15:01:57 +01:00
Alug 8c9808b2d6 fix online player localping display 2025-02-10 21:00:18 +01:00
Alug 5f0b2b0604 fix some level userdata not being invalidated
maybe fixed the random issues we had with the server?
2025-02-10 20:53:43 +01:00
Alug a80f520c38 fix some level userdata not being invalidated
maybe fixed the random issues we had with the server?
2025-02-10 20:53:33 +01:00
Alug 34c517defc dont add buffer delay when local delay is disabled 2025-02-10 19:06:09 +01:00
Alug d5a762f35c account for netticbuffer in offline ping
this makes it more accurately reflect how it would behave in an online game
2025-02-10 18:13:08 +01:00
Alug ab6ec6d11e add some comments + smol cleanup again for keepmusic 2025-02-10 18:13:01 +01:00
Alug c8a629d8a5 extend mapmusic_t struct and rename to music_t
didnt see that all the music stuff was more or less using the same things
2025-02-10 18:12:57 +01:00
Alug 71805500ca clean this up a bit 2025-02-10 18:12:54 +01:00
Alug 5e7c12dac7 optimize ogl drawer functions
by avoiding excessive interger to float conversions
2025-02-08 23:26:13 +01:00
Alug 29817d6627 fix clang uninitialised warning 2025-02-08 23:26:10 +01:00
Alug c010b7319e fix oopsie with mapmusic in glib 2025-02-08 18:10:02 +01:00
Alug 27b190cadf this should be static 2025-02-08 17:52:47 +01:00
Alug e1a02a0729 throw music vars into a struct "mapmusic_t"
simplifies everything, keepmusic vars use it too
2025-02-08 17:52:44 +01:00
Alug eb512022e0 handle music reloadreset stuff in seperate function
just tryin make it less ugly
2025-02-08 17:52:18 +01:00
Alug 0aec9a85bb rename this 2025-02-08 17:51:56 +01:00
Alug c1743eb18d Revert "Update position nums to use additive"
for now since it doesent work that well on bright maps, yes there is a mapheader , but cant expect anyone to go trough all maps and add it

This reverts commit 323fbb4713.
2025-02-08 17:21:02 +01:00
Alug ccd2855e01 always save keepmusic stuff
but set keepmusresume in stopmusic Zzz...
2025-02-08 16:47:41 +01:00
Alug d3338f5d81 attemp to fix playerreborn resetting keepmusic 2025-02-08 16:33:06 +01:00
Alug 73ea95ae61 just pass the controller directly
simplifies this alot
2025-02-08 15:44:20 +01:00
Alug 6532dacbb1 change speelines blending condition
uuuhh, so, if you have sneakerboost they always will apply additive blending
otherwise if you go really fast (faster than sneakerboost)
2025-02-08 15:36:49 +01:00
indev b42338ea38 Don't force specific characters in M_HandleConnectIP 2025-02-07 20:03:25 +03:00
Alug 8f07f183dd just pass the controller directly
simplifies this alot
2025-02-07 15:57:35 +01:00
Alug e66aedaaa1 Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Testing 2025-02-07 15:57:31 +01:00
indev affa366f7d Merge pull request #159 from chromaticpipe/proxy-makefile
Add a proxy Makefile at the top level
2025-02-07 02:30:48 +03:00
chromaticpipe 7d62b330d0 Add proxy makefile at top level 2025-02-06 16:15:16 -06:00
Alug 9ac9db0fe0 only apply additive blend to speedlines when any kind of boost is happening
to emphasize that ure boosting or smth
2025-02-06 17:25:43 +01:00
Alug b398dacf29 update controller led when connecting a controller 2025-02-06 14:43:35 +01:00
Alug 1b610242bc update controller led when connecting a controller 2025-02-06 14:43:28 +01:00
Alug a6a53f6b9c dont pass bogus values to I_GamepadRumble and I_SetGamepadIndicatorColor
- fixes rumble and led stuff not working after hotplugging
- also fixes sdl2-compat breaking
- i hate karts controller code
2025-02-06 03:01:51 +01:00
Alug be58dd19c1 dont pass bogus values to I_GamepadRumble and I_SetGamepadIndicatorColor
- fixes rumble and led stuff not working after hotplugging
- also fixes sdl2-compat breaking
- i hate karts controller code
2025-02-06 03:01:40 +01:00
Alug 0d2a1bac36 Revert ""kill" seenames"
This reverts commit 93a1a432d7.
2025-02-05 15:33:27 +01:00
Alug f67815b0d3 also add additive to boostflame 2025-02-05 00:36:05 +01:00
Alug d4c986fb84 no need pass this stuff 2025-02-04 23:12:35 +01:00
Alug b24a7e3faf forgor 2025-02-04 23:11:05 +01:00
Alug 18a78e2892 test add blendmodes to a bunch of player effects
going see how it looks
2025-02-04 23:06:08 +01:00
Alug 323fbb4713 Update position nums to use additive
https://git.srb2.org/KartKrew/RingRacers/-/commit/4d108930a94f44dbc916d1116eab8421e669e4b6
2025-02-04 23:05:07 +01:00
Alug bd6b699a1e keep track of map music
this is kinda horrible, but allows musicchanges which replace map music/tunes to also work with this system
2025-02-04 23:03:57 +01:00
Alug 4795af29ea reset keepmusposition in tunes command
mapmusic will be reset the moment the gamestate changes, so whatever was changed with tunes will not be kept sadly
2025-02-04 23:03:55 +01:00
Alug f76a62b7d2 save music position and try to fade back into mapmusic when the music changed from mapmusic when keepmusic is enabled
uhh idk how to explain lel
hope this doesent explode
2025-02-04 23:03:51 +01:00
Alug da7d200d92 skip intro sounds also with keepmusic lel 2025-02-04 23:03:47 +01:00
Alug 2de44e7563 check for realpatch here too 2025-02-04 23:03:08 +01:00
Alug f30cdc1933 stuff that was missing 2025-02-04 23:02:58 +01:00
Alug f9ccacf118 handle ogl lightlevelpost similar to rr
now that we have everything for it
2025-02-04 23:00:44 +01:00
Alug 6ed7e26d86 flag clash moment 2025-02-04 22:59:04 +01:00
Alug 91856ea145 fix merge conflicts 2025-02-04 22:58:46 +01:00
Alug 5b6b0f09e1 Merge remote-tracking branch 'Chearii/blendmodes' into Saturn-Testing 2025-02-04 22:57:17 +01:00
Alug 291677d0cf Merge branch 'Saturn-Next' into Saturn-Testing 2025-02-04 22:48:50 +01:00
Chearii ccc1c07930 Fix white pixel bug due to oversight
many thanks to indev for catching this!
2025-02-04 16:34:17 -05:00
Chearii d39e9447f3 Add line and FOF blending, fix model and shadow blending
also a bit of cleanup in r_things but it's too minor to headline
2025-02-03 04:46:27 -05:00
Chearii cd44e2d80c Prelim: Linedef alpha variable
realistically this was just because I'm Lazy
this makes figuring out linedef blending less of a brain twister
2025-02-02 21:14:48 -05:00
Chearii 36a1662afb Add blending modes 2025-02-02 20:37:19 -05:00
Alug 88d5ca0b8a should revert this completely 2025-02-02 00:19:38 +01:00
Alug 15eee102fd partly revert this
some of those "mightve" been changed at the point of the check
2025-01-30 13:25:19 +01:00
Alug ce00aef8b1 partly revert this
some of those "mightve" been changed at the point of the check
2025-01-30 13:25:12 +01:00
Alug c7a24199c7 make those const 2025-01-30 13:22:03 +01:00
Alug 0db2aebfda dont register a crapton of pointless stuff for dedi
should cleanup dedi config significantly lmao
2025-01-30 13:12:01 +01:00
Alug 7ec00a279c tiny cleanup i_video 2025-01-30 12:30:57 +01:00
Alug 6e81cdcb01 kill even more unused patches
+ nonexistant crosshair stuff
2025-01-30 10:42:01 +01:00
Alug 2a05f630b3 dont cache all those unused hud graphics 2025-01-30 10:41:55 +01:00
Alug bf9b738a0f use SRB2.2s general folder structure
- seperate addons folder (download folder remains in home directory unlike RR)
- seperate gif and screenshot folders
2025-01-30 10:41:48 +01:00
Alug 50fced2867 use SRB2.2´s logging system
- creates a new logfile each start instead of overwriting it everytime
2025-01-30 10:41:40 +01:00
Alug 6276243cc4 just keep a copy of musicchange before the lua hook
keep music can check for what was it stuff changed last to
2025-01-30 10:32:47 +01:00
Alug 22c48f19ba grow an invinc music also broke stuff
cant put it into the music exception list, otherwise it will always disable keepmusic when either one was used even once
2025-01-30 10:32:42 +01:00
Alug 9872640e77 the music system is truly amazing 2025-01-30 10:32:36 +01:00
Alug 80f7ddfb31 i hate conditions 2025-01-30 10:32:30 +01:00
Alug 5215fa4747 smol optimization comparePolygon
return slightly earlier for skywalls and horizonlines
2025-01-30 10:32:13 +01:00
Alug 7016b77ee8 also rotate eggboxes in air 2025-01-30 10:31:58 +01:00
Alug 5edb0d0e3d fall through deez 2025-01-30 10:31:46 +01:00
Alug a2c1fa5e23 delet if else hell 2025-01-30 10:31:41 +01:00
Alug 520f92e892 handle vote bg fallbacks more gracefully
if someone doesent provide a widescreen patch it now falls back to the replaced non widescreen one and vice versa instead of just falling back to what vanilla provides
2025-01-30 10:31:36 +01:00
Alug 305d408e02 forgor about the banan spin 2025-01-30 10:31:14 +01:00
Alug 8ccb747dcd j moment 2025-01-30 10:30:51 +01:00
Alug a1d5a2e1f9 simplify camtoggledelay and spectatedelay
just make em an array and use lööp
2025-01-30 10:30:34 +01:00
Alug 2f56487290 assign player later 2025-01-30 10:30:23 +01:00
Alug 2ebf66b99c kill P_TeleportMove
P_MoveOrigin literally just calls that so replace it with that
2025-01-30 10:30:19 +01:00
Alug 881da033b8 Merge branch 'Saturn-Next' into rankingsrefactor 2025-01-30 10:29:13 +01:00
Alug 1e972cbb65 reduce scope of those
makes it look slightly neater
2025-01-30 10:29:05 +01:00
Alug bab120235d draw non widescreen anim vote bg before falling back to vanilla bg
how it was before, the game just fallback to the vanila widescreen patch if there was no animated widescreen bg provided, just fall back to the non widescreen anim patch instead if it exists
2025-01-30 10:27:56 +01:00
Alug 36404fd93d inline bunch of one line HWR things 2025-01-30 10:27:36 +01:00
Alug 3b90038b62 inline G_TicsTo stuff
theyre smol and get called often
2025-01-30 10:27:25 +01:00
Alug 40660f2379 "makes integer from pointer without a cast" deez nuts 2025-01-30 10:27:19 +01:00
Alug 7ab7193592 remove noshowhelp from bunch of debug cvars
doesent make too much sense those are hidden tbh
2025-01-30 10:27:13 +01:00
Alug 1fabc14ac9 Merge pull request #151 from Indev450/fixdupeacks
Try to fix issues with clients locking up due to never receiving acks back in case of dropped packets
2025-01-30 10:26:33 +01:00
Alug d9492eee28 Merge pull request #152 from Indev450/delaynetxcommand
Delay netxcmds when buffer is full instead of dropping them
2025-01-30 10:26:14 +01:00
Alug e689deaa2b dont need to do all this crap if disabled 2025-01-30 00:17:20 +01:00
Alug 93a1a432d7 "kill" seenames
idk if anyone wants it, its still there, needed to move the netvar out of it tho lol
2025-01-30 00:17:17 +01:00
Alug 0b71bc2880 move this after the early returns
save some time when drifting
2025-01-30 00:17:14 +01:00
Alug 9f4b72800a lmao 2025-01-30 00:17:11 +01:00
Alug 5d2e08d124 turn driftsparkGrowTimer into a player field
less hacky and avoids 3 loops lol
2025-01-30 00:17:08 +01:00
Alug 5fb1b39742 kill redundant laptime code
just use the newer one
2025-01-30 00:17:05 +01:00
Alug 5ef8e5c447 renable jit compile
this branch is a mess lmao
2025-01-29 22:33:49 +01:00
GenericHeroGuy 3152cddb3d In rehashtab, do counthash before adding asize
Thanks alug!
2025-01-29 22:29:03 +01:00
Alug c2b87b46fc refactor M_DrawSlider
apparently fixes weird framerate issues with gamma slider
also shows the values on sliders
2025-01-29 19:35:04 +01:00
Alug d764941341 inline V_LocalTransFlag
its very smol
2025-01-29 19:35:01 +01:00
Alug 112ca2707a even more replay deb prints lel 2025-01-29 19:34:58 +01:00
Alug cf26092917 smol replay fixes from rr 2025-01-29 19:34:52 +01:00
Alug 842a252576 Have replay recording of "hits" use the reference count system
https://git.srb2.org/KartKrew/RingRacers/-/commit/fa8bffabfc51ea1d7be86d833190bb7dcf494fca
2025-01-29 19:34:46 +01:00
Alug e23d9bc3cc also print player name for item desynch 2025-01-29 00:46:25 +01:00
Alug e206ad3c08 better replay resynch prints 2025-01-29 00:40:21 +01:00
Alug 2eddddc6fc ss->touching_preciplist deez 2025-01-28 18:29:23 +01:00
Alug de6a078f01 inline a few hooklib functions 2025-01-28 18:26:20 +01:00
Alug 283f4d1e37 super smol optimization 2025-01-28 18:26:16 +01:00
Alug 0f3cd28019 pass slope to K_RollMobjBySlopes
removing some code dupe in the process and allows some more flexability
2025-01-28 18:26:13 +01:00
Alug 7fec7f8937 forgor to set those oop 2025-01-28 16:33:41 +01:00
Alug 3f54630531 fix issues with models
- Sloperotation was weird, it now uses what we calculate in K_RollMobjsBySlopes
- in general uses srb2s newer system
- alot of cleanup of pointless variables
- sprinfo pivots should now work
- removed roillmodel since it was smth weird and broke rollangle
2025-01-28 16:33:38 +01:00
Alug 7f864dba3a dont recalc if precip sector didnt move
forgor i can just check this
2025-01-27 23:42:10 +01:00
Alug 49644f10f5 only need to recalc this once a tic
precip thinker thinks slightly more often, but we really dont need that tbh
2025-01-27 23:42:07 +01:00
Alug f78b41dde3 only recalc floorz for visible precip mobjs
before it apparently recalced it a crapton for the crapton not visible precipmobjs, which even on vanilla maps led to noticable jitter
2025-01-27 23:42:04 +01:00
Alug 7163337a27 just keep a copy of musicchange before the lua hook
keep music can check for what was it stuff changed last to
2025-01-27 16:44:18 +01:00
Alug 27fd087631 grow an invinc music also broke stuff
cant put it into the music exception list, otherwise it will always disable keepmusic when either one was used even once
2025-01-27 16:13:14 +01:00
Alug 9b7ec4f266 the music system is truly amazing 2025-01-27 15:33:16 +01:00
Alug 90fd4b54b3 i hate conditions 2025-01-27 15:33:13 +01:00
Alug 97e5de1ee5 smol optimization comparePolygon
return slightly earlier for skywalls and horizonlines
2025-01-27 15:33:10 +01:00
Alug 5f247a6d11 Merge branch 'gentlemens' into Saturn-Testing 2025-01-27 15:33:07 +01:00
Alug 0dd4f3b3d3 make old ping bar be blue on d1 aswell as purple with mindelay 2025-01-27 09:19:38 +01:00
Alug ccc0189e70 also rotate eggboxes in air 2025-01-26 21:17:20 +01:00
Alug 8543636576 fall through deez 2025-01-26 17:29:19 +01:00
Alug b09025df08 delet if else hell 2025-01-26 18:18:33 +01:00
Alug 39c747e430 handle vote bg fallbacks more gracefully
if someone doesent provide a widescreen patch it now falls back to the replaced non widescreen one and vice versa instead of just falling back to what vanilla provides
2025-01-26 17:57:36 +01:00
Alug 2104822cac forgor about the banan spin 2025-01-26 16:18:41 +01:00
Alug bcf713932a reduce scope of those
makes it look slightly neater
2025-01-26 16:18:19 +01:00
Alug 6d671b6576 draw non widescreen anim vote bg before falling back to vanilla bg
how it was before, the game just fallback to the vanila widescreen patch if there was no animated widescreen bg provided, just fall back to the non widescreen anim patch instead if it exists
2025-01-26 16:18:16 +01:00
Alug b7345107d7 move this
no need to have two conditions for same thing
2025-01-26 16:18:14 +01:00
Alug 9cdfdf9bda spawn speedlines with non synched rng if ur in eggbox status
and well only if you have colourisation enabled
2025-01-25 21:22:51 +01:00
Alug 42f200aabd inline bunch of one line HWR things 2025-01-25 21:22:19 +01:00
Alug f8853ae902 inline G_TicsTo stuff
theyre smol and get called often
2025-01-25 21:21:43 +01:00
Alug 061201c0de "makes integer from pointer without a cast" deez nuts 2025-01-25 16:59:41 +01:00
Alug f11dab363f remove noshowhelp from bunch of debug cvars
doesent make too much sense those are hidden tbh
2025-01-25 16:21:16 +01:00
Alug 48dd50afe4 Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-25 09:33:34 +01:00
Alug 49cefa92e2 dont banan drag rumble when not driving lel 2025-01-25 09:33:14 +01:00
Alug 352e71d9e9 Merge branch 'directionallight' into Saturn-Testing 2025-01-25 08:41:28 +01:00
Alug 2b13af2367 setup maplight stuff earlier
otherwise it doesent init early enough
2025-01-25 08:41:22 +01:00
indev 2296ef0987 Fix 'total podium' stat display using totalwins 2025-01-25 01:10:06 +03:00
indev 30f11e4e46 Fix 'total podium' stat display using totalwins 2025-01-25 01:09:43 +03:00
Alug 97a5c15c36 just use D_NumPlayers 2025-01-24 20:44:50 +01:00
Alug 43dbaf7004 j moment 2025-01-24 20:16:32 +01:00
Alug 55bb65034f [0] 2025-01-24 20:16:21 +01:00
Alug 57ebb297c0 simplify camtoggledelay and spectatedelay
just make em an array and use lööp
2025-01-24 20:44:28 +01:00
Alug a513f10296 assign player later 2025-01-24 20:44:25 +01:00
Alug a1074852dd kill P_TeleportMove
P_MoveOrigin literally just calls that so replace it with that
2025-01-24 20:44:21 +01:00
Alug 5f546a3df8 just use D_NumPlayers 2025-01-24 20:44:12 +01:00
Alug 986c19ef6e Merge branch 'gentlemens' into Saturn-Testing 2025-01-24 20:43:49 +01:00
Alug bea7ad5876 Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-24 19:25:59 +01:00
Alug b1fa124032 add funny banan throw rotate thing
like rr
2025-01-24 19:25:53 +01:00
Alug a15de64160 think we should copy this 2025-01-24 19:25:50 +01:00
Alug af3a23ce66 make trailing items also be able to rotate on slopes
mostly stuff from RR thx!
2025-01-24 19:25:46 +01:00
Alug b55c654a81 oop 2025-01-24 06:43:54 +01:00
Alug b97841b6fd proper add server gentlemans
this should be a netvar, but we cant really do that, thought not a huge deal
however id wish to send some kinda message to all players but idk
2025-01-24 06:40:05 +01:00
Alug ac64428abb dont mess up realpingtable
when serverplayer has mindelay active
this was supposed to show mindelay for serverplayers but that doesent work :chaosleep: so just do not mess with it
2025-01-23 21:55:48 +01:00
Alug 1857ce5113 conflict fix 2 2025-01-23 21:29:08 +01:00
Alug f4f3f6e29c slight cleanup HU_drawPlayerPing 2025-01-23 21:27:42 +01:00
Alug 9354a0ab88 conflict fix 2025-01-23 21:27:07 +01:00
Alug 6ef9c0b305 colourise pingnumber when gentlemens is active 2025-01-23 18:11:00 +01:00
Alug 6b951d2773 division by zero moment 2025-01-23 18:10:57 +01:00
Alug 064e9d58af add gentlemens delay to ping display
+ display ping even offline if you have mindelay active
2025-01-23 18:10:53 +01:00
Alug 1d5092cf22 smol cleanup 2025-01-23 18:10:21 +01:00
Alug 861d35e8d3 port clientsided gentlemens delay
cant do the serverside stuff due to netvars
2025-01-23 18:10:18 +01:00
Alug f92c519d05 Prevent dropped ticcmds due to interp timing jutter
kinda figured out what this does, and makes clients on uncapped listen servers alot less prone to drop gametics
2025-01-23 15:07:37 +01:00
Alug ecd3ad40ae fix freecam not resetting online
idk local player handling is fucking awful in kart
2025-01-22 19:42:21 +01:00
Alug 6d94ff8d1f fix freecam not resetting online
idk local player handling is fucking awful in kart
2025-01-22 19:42:14 +01:00
Alug fad3c2bbdf Merge remote-tracking branch 'origin/Saturn-Testing' into Saturn-Testing 2025-01-22 19:05:16 +01:00
Alug 46c53ea679 try just passing the sector + add 50 trillion extra checks
idk anymore but this is literally now how vanilla kart behaved
2025-01-22 19:05:10 +01:00
Alug 062caa8f53 skip some stuffs when theres no portals
skip some portal checking incases wheres no portals
2025-01-22 18:10:54 +01:00
Alug f6a39fea4b Merge remote-tracking branch 'origin/kartstats' into Saturn-Testing 2025-01-22 17:33:49 +01:00
Alug bfabdb7b6a bruh 2025-01-22 17:24:11 +01:00
Alug ea82f89b53 bruh 2025-01-22 17:24:03 +01:00
Alug 7f9edddbcc remove redundand FTransform field 2025-01-22 16:58:30 +01:00
Alug 23443b2632 remove redundand FTransform field 2025-01-22 16:58:24 +01:00
Alug 114eab952b Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-22 15:47:41 +01:00
Alug 883cd3f516 more smol ogl sprite drawer optimizations 2025-01-22 15:46:44 +01:00
Alug a3e2d3ec71 also fix potential use-after-free in HWR_AddPrecipitationSprites
no clue why ogl didnt do it since its effectively the same code as software
2025-01-22 15:46:38 +01:00
Alug 7213f0dd5d split HWR_DrawSprites
saves on ALOT of conditional branching in a lööp when models are disabled
2025-01-22 15:45:25 +01:00
Alug f8472721ee fix level statistics page controls 2025-01-21 16:54:38 +01:00
indev 9634bc99bd Check for spectator in K_StatRound 2025-01-21 17:38:09 +03:00
Alug 81a0ba08bd use SRB2.2s general folder structure
- seperate addons folder (download folder remains in home directory unlike RR)
- seperate gif and screenshot folders
2025-01-21 01:35:24 +01:00
Alug 12f5bd141d use SRB2.2´s logging system
- creates a new logfile each start instead of overwriting it everytime
2025-01-21 01:35:21 +01:00
Alug 6e2b7e534b Merge branch 'freecamstuffs' into Saturn-Testing 2025-01-20 22:26:41 +01:00
Alug 3bbdd1ea72 e better play it safe 2025-01-20 22:26:26 +01:00
Alug 2b09e74dcf kill aiming stuff in BuildTiccmd 2025-01-20 22:26:23 +01:00
Alug 543365f296 cv_invertmouse2 moment 2025-01-20 22:22:13 +01:00
Alug da3bf945cb delete nonfunctional second mouse stuff 2025-01-20 22:18:59 +01:00
Alug 4e311ca279 kill even more unused patches
+ nonexistant crosshair stuff
2025-01-20 21:31:52 +01:00
Alug 18c449a9ed dont cache all those unused hud graphics 2025-01-20 21:18:31 +01:00
Alug d7293ef41d Merge branch 'freecamstuffs' into Saturn-Testing 2025-01-20 19:34:02 +01:00
Alug 5dc76d07ec Hold up/down for 2 seconds while not moving to pan the camera vertically
from RR
2025-01-20 19:33:56 +01:00
Alug ebfafd7b6e a 2025-01-20 19:21:44 +01:00
Alug 24ca9fdafa oops didnt init this 2025-01-20 19:21:42 +01:00
Alug 8cdb920f54 dont turn 90 degrees when switching to freecam 2025-01-20 19:00:22 +01:00
Alug cccf6449f9 fix freecam vertical look for the 500th thousand time
truly amazing code
2025-01-20 18:04:20 +01:00
Alug 88c8860548 Merge remote-tracking branch 'origin/freecamstuffs' into Saturn-Testing 2025-01-20 17:05:57 +01:00
Alug 85a64a6c14 put this thing onto its original place 2025-01-20 15:29:06 +01:00
Alug d7c3cf7d3e put this into switch
looks better
2025-01-20 15:29:02 +01:00
Alug 9bd2da04e2 put this thing onto its original place 2025-01-20 15:28:51 +01:00
Alug 56563507b6 null check target in P_DamageMobj
apparently this may be null
2025-01-19 18:21:13 +01:00
Alug fa98b06dba :chaosleep: 2025-01-19 18:10:25 +01:00
Alug a763d85122 make function for driftsparkcolour
reduce some code dupe
2025-01-19 17:45:28 +01:00
Alug db8b1ca0a3 replace common damage magic numbers with named macros
that stuff always confused me before lol
2025-01-19 17:38:32 +01:00
Alug 5106c391bb readd check for banan
this time without mobjwasremoved
just check if banan exists
2025-01-19 17:38:22 +01:00
Alug 0c2e285d2e remove some code dupe in R_AddLine 2025-01-19 17:35:00 +01:00
Alug f7df80f763 ; moment 2025-01-19 17:34:56 +01:00
Alug 676265a92a fix "lessprecip"
logic error lul
2025-01-19 17:34:52 +01:00
Alug f9ee18584e use MT_NULL instead of number 2025-01-19 17:34:42 +01:00
Alug 3d394bb621 refactor weather switching
from srb2
makes this more sane and makes PRECIP_STORM_NORAIN not spawn a crapton of invisible mobjs
2025-01-19 17:34:33 +01:00
Alug 913c0f4ae7 idk why we check this 2025-01-19 17:34:19 +01:00
Alug 04bf086a9e forgor to check for that flag 2025-01-19 17:34:12 +01:00
Alug 2a25328ce0 change tooltips slightly 2025-01-19 17:33:56 +01:00
Alug af7393832a add stuff to menu 2025-01-19 17:33:50 +01:00
Alug 516bea6e8a add toggle for item amount number display 2025-01-19 17:33:30 +01:00
Alug 82bd65eebd don use multiicon patches in 3/4p splitscreen
since it uses the smoler patches
also removes redundant assignments
2025-01-19 17:33:20 +01:00
Alug 44b6c53452 change banana default patch to match lua roulette hud behaviour 2025-01-19 17:33:02 +01:00
Alug 28b294f48a add support for multiitem patches (thx neppy!)
needs new patches, unsure if we just gonna add em to the extra file or make a new one
so it ambigous for now
2025-01-19 17:32:21 +01:00
Alug 56ed32d094 merge conflict moment 2025-01-19 17:31:55 +01:00
Alug 60d81037fd "Fix console text bleeding "
read https://git.do.srb2.org/STJr/SRB2/-/merge_requests/1434
2025-01-19 17:31:27 +01:00
Alug 8abe40cc81 cap console animation if uncappedhud is disabled
since thats "how vanilla done it" before
2025-01-19 17:31:20 +01:00
Alug cd9df8065d use R_GetHudUncap 2025-01-19 17:31:13 +01:00
Alug b6d50da809 add fancyroulette toggle 2025-01-19 17:31:08 +01:00
Alug 383cc71bb3 reorder saturn hud menu a little
also remove uncapped hud from it, since why would you ever wanna turn it off?
2025-01-19 17:30:49 +01:00
Alug d75c16bab5 add the fancy hudtrans flags 2025-01-19 17:30:08 +01:00
Alug 8efdbe40e4 dont fancy during respawn 2025-01-19 17:30:00 +01:00
indev ada779a97d Fancy :D 2025-01-19 17:29:56 +01:00
Alug 37d28464ea change how spritescales and offsets work
- now theres realoffsets aswell
- allows better control of changing things per lua and still do funky stuff in hardcode without conflicts
- spritescales and offsets now get reset centralised before any thinkers run
2025-01-19 17:29:41 +01:00
Alug 816ad7c2fc add banan jitter toggle to menu 2025-01-19 17:29:29 +01:00
Alug c4d1f9c6a2 add toggle for bananjitter 2025-01-19 17:29:24 +01:00
Alug 33e1cfc2ba le funny banan drag jumpy 2025-01-19 17:29:07 +01:00
Alug bce9990826 only rumble banan when on ground 2025-01-19 17:27:51 +01:00
Alug 923e0500df fix typo lel 2025-01-19 17:27:31 +01:00
Alug 017646e704 forgor about software again 2025-01-19 17:26:35 +01:00
Alug 4900177e8c TEST: skip prepping 3d floors for fofs without planes
or if they were already checked
2025-01-19 17:25:35 +01:00
Alug ed97d28254 split HWR_RenderBSPNode
to reduce function call overhead
its only microscopicly faster lel
2025-01-19 17:25:26 +01:00
Alug 15185e0450 simplify keepmusic
honestly no clue why i made stuff check on every music change
2025-01-19 17:23:52 +01:00
Alug a29f8d5f38 dont keep music if there is no music 2025-01-19 17:23:45 +01:00
Alug 8dc2d22996 Clear acktosend when initializing node
since it was never reset, values might been taken over from former node
2025-01-19 17:22:59 +01:00
indev 4d355f99c0 Add spb music to list of exceptions for keepmusic 2025-01-19 17:22:52 +01:00
indev aa0bf396e7 Fix spectator control text overlapping when showdirectorhud is off 2025-01-19 17:22:38 +01:00
indev 5f3dc081b5 Don't start invinc/grow alarm sound when player uses power item
It will still be started in K_UpdateInvincibilitySounds, but now if
player already had invincibility, they won't get 2 overlapping sounds
2025-01-19 17:33:44 +03:00
indev 8959d3aec4 Put playtime statistics at first page instead of RA medals 2025-01-19 03:04:24 +03:00
indev c589d04a32 New statistics menu (WIP) 2025-01-19 02:55:39 +03:00
indev 8ceda27817 Wipe kart stats on game data reload 2025-01-19 02:43:18 +03:00
indev 7260c2c77e That was from testing a 2025-01-19 02:29:41 +03:00
indev 7991dafe64 Make custom stats fully compatible between different versions, so new fields can be added in future without save corruptions 2025-01-19 02:28:16 +03:00
Alug 232790836b remove some code dupe in R_AddLine 2025-01-19 00:24:02 +01:00
Alug 9305b0a287 ; moment 2025-01-18 21:44:34 +01:00
Alug 4ff8b869db fix "lessprecip"
logic error lul
2025-01-18 21:24:47 +01:00
Alug c1df939ac8 use MT_NULL instead of number 2025-01-18 14:36:42 +01:00
Alug aea8cd1d62 refactor weather switching
from srb2
makes this more sane and makes PRECIP_STORM_NORAIN not spawn a crapton of invisible mobjs
2025-01-18 14:29:58 +01:00
Alug b816622129 idk why we check this 2025-01-18 14:29:55 +01:00
Alug d80613f26f forgor to check for that flag 2025-01-18 11:45:39 +01:00
Alug d5505080cf change tooltips slightly 2025-01-17 23:44:35 +01:00
Alug 92d6a541ae add stuff to menu 2025-01-17 23:44:32 +01:00
Alug 633948e8cc ok clang 2025-01-17 23:44:27 +01:00
Alug 2ac48f715a :chaosleep: 2025-01-17 19:53:42 +01:00
Alug e82c9a71ec add toggle for item amount number display 2025-01-17 17:15:36 +01:00
Alug 004f6d1495 Revert "turn on multiitemicons by default"
This reverts commit 9217cd3832.
2025-01-17 17:15:33 +01:00
Alug 32b54e1346 merge conflict moment 2025-01-17 15:04:13 +01:00
Alug f50b19968c disable jit compilation for now 2025-01-17 14:45:35 +01:00
Alug c9d0415d84 "Fix console text bleeding "
read https://git.do.srb2.org/STJr/SRB2/-/merge_requests/1434
2025-01-17 14:23:05 +01:00
Alug 625932e8f3 cap console animation if uncappedhud is disabled
since thats "how vanilla done it" before
2025-01-17 14:18:09 +01:00
Alug 5a03428d76 use R_GetHudUncap 2025-01-17 14:18:06 +01:00
Alug 33c6d13c7a add fancyroulette toggle 2025-01-17 14:18:04 +01:00
Alug ba5e15d29b add the fancy hudtrans flags 2025-01-17 14:18:01 +01:00
Alug de64eb6f8d dont fancy during respawn 2025-01-17 14:17:58 +01:00
indev 75589f9770 Fancy :D 2025-01-17 15:47:55 +03:00
Alug 9217cd3832 turn on multiitemicons by default 2025-01-17 12:58:56 +01:00
Alug 49d295535f add banan jitter toggle to menu 2025-01-17 12:58:52 +01:00
Alug bd489bd462 change how spritescales and offsets work
- now theres realoffsets aswell
- allows better control of changing things per lua and still do funky stuff in hardcode without conflicts
- spritescales and offsets now get reset centralised before any thinkers run
2025-01-17 01:31:12 +01:00
Alug 7d621b5b1d add toggle for bananjitter 2025-01-17 01:30:39 +01:00
Alug 22b60a07e5 le funny banan drag jumpy 2025-01-17 01:30:35 +01:00
Alug adf52e1520 only rumble banan when on ground 2025-01-16 23:33:18 +01:00
Alug b5d027b37c fix typo lel 2025-01-16 22:44:27 +01:00
Alug c5a1513cf5 don use multiicon patches in 3/4p splitscreen
since it uses the smoler patches
also removes redundant assignments
2025-01-16 21:58:56 +01:00
Alug 7116607881 ignore invisible fofs again 2025-01-16 21:43:30 +01:00
Alug 559b0bf45a also skip invisible fofs 2025-01-16 21:43:24 +01:00
Alug 72e72af6b1 Clear acktosend when initializing node
since it was never reset, values might been taken over from former node
2025-01-16 01:03:38 +01:00
Alug e0d6a6ae0f dont keep music if there is no music 2025-01-16 01:02:06 +01:00
indev 64588f8337 Add spb music to list of exceptions for keepmusic 2025-01-16 02:47:50 +03:00
indev 66b0931f07 Fix spectator control text overlapping when showdirectorhud is off 2025-01-15 21:17:56 +03:00
Alug 5ddabba0b2 Merge branch 'freecamstuffs' into Saturn-Testing 2025-01-15 13:00:33 +01:00
Alug 2e054d8bec Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-15 13:00:31 +01:00
Alug 1db9bcd6c9 oops 2025-01-15 12:59:49 +01:00
Alug 6f7a52a6a6 make freecam strafe be affected by freecamspeed cvar 2025-01-15 12:59:47 +01:00
Alug 2c3ff3a628 dont throw a warning about addons with custom gamedata
just ignore it
2025-01-15 12:59:38 +01:00
indev 976c74d694 G_PlayerReborn didn't work for 'respawns' stats, maybe G_DoReborn will? 2025-01-13 23:17:51 +03:00
indev e3adcfb62e Player kartstuff's get reset in G_PlayerFinishLevel, so need to call K_StatRound earlier 2025-01-13 23:11:52 +03:00
Alug cd76cc0e9f no need to strcmp just check for "savemoddata"
that bool only ever gets set to true if the savegame has been switched to the modded one and unlike in srb2 this WILL never be reset to false again
2025-01-13 17:42:33 +01:00
Alug e2e356d0c2 save vanilla save when switching to modified savegame
also add check so we dont rerun this everytime setgamemodified is called
2025-01-13 16:44:06 +01:00
Alug bb7c217ccc remove "majormods" checks from stuff that saves to savegame
so its only there to throw a notice when you load an addon
2025-01-13 16:44:04 +01:00
Alug cd3e664e6a oops fix menu stuff 2025-01-13 16:01:19 +01:00
indev e7d3e03169 Clear menus when running 'map' command 2025-01-13 15:53:51 +01:00
indev 591a2e5dbb Forgor respawns 2025-01-13 17:52:41 +03:00
Alug 4e4871fe93 remove "errorshitspam"
hooklib refactor indirectly fixed the root issue, so this is not needed anymore
2025-01-13 15:52:12 +01:00
Alug 6d1b754db5 remove this
hooklib refactor already indirectly fixed this so this code is pointless
2025-01-13 15:50:36 +01:00
indev cae9b754bc Oops 2025-01-13 17:37:50 +03:00
Alug 46e0c88280 make game use seperate save when addons are loaded
so you can record attack and it will also keep saving to statistics
also added a few things it now keeps track of
TODO: unfuck the statistics page and add a 2nd one perhaps? due to space reasons
menucode is hell
2025-01-13 17:36:07 +03:00
indev 4942db2806 Add kartstats 2025-01-13 17:13:40 +03:00
indev b5be515b9b Clear menus when running 'map' command 2025-01-13 14:25:14 +03:00
Alug 51067f2802 Merge branch 'Saturn-Next' into freecamstuffs 2025-01-13 08:39:38 +01:00
Alug 62a65c5c1d save a whopping 2ms from gamestart to race start on texture updating 2025-01-13 08:38:20 +01:00
Alug b9e23113c8 slightly cleanup gravstretch stuff 2025-01-13 08:34:52 +01:00
Alug 50f1a61182 fix having saltyhop disabled forcing player spriteyoffset to be forced 0
just clear out everything on toggle
2025-01-13 08:34:44 +01:00
Alug ed9adfae68 add toggle to colour sneakertrail flames (thx neppy!) 2025-01-13 08:34:34 +01:00
Alug cb4ef15c77 another attempt at fixing skipintro mus playing titlescreen music 2025-01-13 08:30:42 +01:00
Alug e4e18f0a62 check for 0 to avoid division by 0 2025-01-13 08:29:33 +01:00
Alug ab8cbcb450 reinit minimap stuff when a wad is added while ingame 2025-01-13 08:29:11 +01:00
Alug 4103fac605 slight cleanup r_draw8 2025-01-13 08:29:06 +01:00
Alug 0a58797f78 clamp to length-1 2025-01-13 08:29:02 +01:00
Alug 5db7f5f2e7 fix column drawers clamping stuff 2025-01-13 08:28:58 +01:00
Alug 47a3de8fe1 let "fovchange" work in software 2025-01-13 08:28:46 +01:00
Alug 2b725560cc add banandrag rumble lol 2025-01-13 08:28:36 +01:00
Alug 9f9cb833f0 add slight fadeout to spinout rumble 2025-01-13 08:28:22 +01:00
Alug f88290d34e kill unarchivevaluedemo
just pass if we load from replay or not and do stuff accordingly
2025-01-13 08:24:56 +01:00
Alug 157ff2df4f make gamestate download show total gamestate size 2025-01-13 08:24:38 +01:00
Alug a9117573fb add colourized speedlines
smth i had laying around in lugstuff
2025-01-13 08:23:02 +01:00
Alug cea28c591f slight cleanup minimap head stuff 2025-01-13 08:22:39 +01:00
Alug b963146faa split ra wheel and position number hud offsets
kinda ass due to the preset offset, but will just not apply if either was changed from its original position
2025-01-13 08:22:06 +01:00
Alug 181c948e86 toggle for camera turnaround on timeover 2025-01-13 08:21:58 +01:00
Alug d3b8e11783 one line this 2025-01-13 08:21:31 +01:00
Alug b3b19eff49 this doesent work out
breaks some textures not appearing on some maps
2025-01-13 08:04:10 +01:00
Alug d09d2dcffd this doesent work out
breaks some textures not appearing on some maps
2025-01-13 08:03:15 +01:00
GenericHeroGuy c5fddbbb69 Use references instead of upvalues for original I/O functions
No more unrestricted I/O through debug.getupvalue
2025-01-12 17:39:19 +01:00
GenericHeroGuy 2ef360a7ac Update to BLUAJIT 449b76f 2025-01-12 17:39:15 +01:00
Alug 509d26f938 forgor about software again 2025-01-12 17:37:40 +01:00
Alug 5a9efff87c TEST: skip prepping 3d floors for fofs without planes
or if they were already checked
2025-01-12 17:37:36 +01:00
Alug 24a93d107a split HWR_RenderBSPNode
to reduce function call overhead
its only microscopicly faster lel
2025-01-12 17:37:33 +01:00
Alug 67aa31439b dont rumble in freecam state 2025-01-12 17:25:57 +01:00
Alug 26902b4565 smol cleanup localskin ranking shit 2025-01-12 17:25:42 +01:00
Alug e320aff5dc dont rumble in freecam state 2025-01-12 17:24:50 +01:00
Alug 3f971fbab1 null check target in P_DamageMobj
apparently this may be null
2025-01-12 17:23:21 +01:00
Alug f24ce61cc9 slight cleanup minimap head stuff 2025-01-12 17:22:52 +01:00
Alug 137be1c7fa slightly cleanup gravstretch stuff 2025-01-12 17:08:16 +01:00
Alug 039018ddc9 change banana default patch to match lua roulette hud behaviour 2025-01-12 17:07:45 +01:00
Alug bef784b32a add support for multiitem patches (thx neppy!)
needs new patches, unsure if we just gonna add em to the extra file or make a new one
so it ambigous for now
2025-01-12 17:07:42 +01:00
Alug eaad3ebeac oops fix menu stuff 2025-01-12 17:07:33 +01:00
Alug af8637f8a4 fix having saltyhop disabled forcing player spriteyoffset to be forced 0
just clear out everything on toggle
2025-01-12 02:52:14 +01:00
Alug ba5ec70669 add toggle to colour sneakertrail flames (thx neppy!) 2025-01-12 02:52:10 +01:00
Alug 503f20a7f4 split ra wheel and position number hud offsets
kinda ass due to the preset offset, but will just not apply if either was changed from its original position
2025-01-12 02:52:07 +01:00
Alug 1237b553f7 toggle for camera turnaround on timeover 2025-01-12 02:52:04 +01:00
Alug 86c89a47da one line this 2025-01-12 02:51:59 +01:00
Alug ff895f3251 fix frame flag clash 2025-01-11 19:54:28 +01:00
Alug b40cb3331a fix frame flag clash 2025-01-11 19:54:13 +01:00
Alug 88025040c3 Merge branch 'directionallight' into Saturn-Testing 2025-01-11 18:10:29 +01:00
Alug 130c1aba67 put random direction light toggle into advanced video options
also make it a scoll menu
2025-01-11 18:10:24 +01:00
Alug e7c0cda77f reinit random maplight on mapchange when toggled
the condition may otherwise not change the light if you restart the same map
2025-01-11 08:52:55 +01:00
Alug a07c2f4c32 reinit random maplight on mapchange when toggled
the condition may otherwise not change the light if you restart the same map
2025-01-11 08:52:49 +01:00
Alug 99e64388ba Merge branch 'directionallight' into Saturn-Testing 2025-01-11 08:34:40 +01:00
Alug 96b7a4efe6 add FF_ABSOLUTELIGHTLEVEL
mobj_t.lightlevel is absolute instead of relative when set
2025-01-11 08:33:02 +01:00
Alug 124b2ff431 add encore variants of maplight 2025-01-11 08:32:59 +01:00
Alug c1ec72e606 oops 2025-01-11 08:28:57 +01:00
Alug ef1faf9f68 those somehow got lost 2025-01-11 08:26:12 +01:00
Alug 02595b9ea6 forgor this 2025-01-11 07:50:25 +01:00
Alug c1514635b0 if disabled and no soc overrides light behave like vanilla
always apply wall and slope contrast pls
2025-01-11 07:50:22 +01:00
Alug e5e7205c95 change how randomized light works
so it doesent kill actual soc set randomlight if you toggle it
2025-01-11 07:26:44 +01:00
Alug f8d1bf0811 Merge branch 'Saturn-Next' into directionallight 2025-01-11 07:26:37 +01:00
Alug a1f185b0f0 Merge pull request #148 from Indev450/checkposopti
Dont always call R_PointInSubsector if thing has not moved in P_CheckPosition
2025-01-11 01:37:07 +01:00
Alug 8981ae3117 Merge pull request #156 from Indev450/precipthinklist
Add a seperate thinkerlist for precipmobjs only
2025-01-11 01:36:23 +01:00
Alug 2a948ca4c2 move this 2025-01-10 22:46:52 +01:00
Alug 8ff0524bbc move this 2025-01-10 22:46:18 +01:00
Alug e749c9764c Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-10 22:31:52 +01:00
Alug d9f0c55fee "Invinciblity" 2025-01-10 22:31:46 +01:00
Alug 69a6adf0a8 Merge branch 'freecamstuffs' into Saturn-Testing 2025-01-10 22:28:47 +01:00
Alug ab064c90dd let "fovchange" work in software 2025-01-10 22:28:45 +01:00
Alug 50d2bf5d8d seperate game turn axis from cam turn axis
both are bound to the same value by default, so vanilla controls remain intact
theres no other good way to have gamepad controls for this sadly
2025-01-10 22:28:34 +01:00
Alug d39fd5bb5c strafe controls for speccam/freecam
TODO: seperate cam turning axis from gameplay turn axis for gamepads
2025-01-10 22:28:31 +01:00
Alug 817df662da slight cleanup r_draw8 2025-01-10 02:17:38 +01:00
Alug d093b461d6 clamp to length-1 2025-01-10 02:14:38 +01:00
Alug 5cc756f853 reinit minimap stuff when a wad is added while ingame 2025-01-10 02:12:13 +01:00
Alug 07c443598b fix column drawers clamping stuff 2025-01-10 02:11:52 +01:00
Alug 3c6116255b kill unarchivevaluedemo
just pass if we load from replay or not and do stuff accordingly
2025-01-09 21:25:08 +01:00
Alug 5689e3815a shouldnt this be uint? 2025-01-09 20:22:40 +01:00
Alug 9bf6a72621 make gamestate download show total gamestate size 2025-01-09 18:47:21 +01:00
Alug 2e02aa16bb Merge branch 'freecamstuffs' into Saturn-Testing 2025-01-09 17:27:38 +01:00
Alug 1a9865ebc4 this should also use unpaused rendertimefrac 2025-01-09 17:27:25 +01:00
Alug 8e7fddd6b0 use lööps for those to look a little better lel 2025-01-09 17:15:18 +01:00
Alug ac8f6455ff dont reset cam using f12 when only one player is ingame 2025-01-09 17:15:15 +01:00
Alug 3c268c8cbd slightly refactor chasecam stuff again 2025-01-09 17:15:12 +01:00
Alug a11227b15a fix postimg data types mismatch
also remove the "postimgflag_t" typedef since its useless
and use smoler type for everything we dont need much space lol
2025-01-08 18:34:24 +01:00
Alug 10b56e7b4f fix postimg data types mismatch
also remove the "postimgflag_t" typedef since its useless
and use smoler type for everything we dont need much space lol
2025-01-08 18:34:16 +01:00
Alug f52db71ec6 this is not needed anymore 2025-01-08 17:11:53 +01:00
indev 38b52b826a huh 2025-01-08 12:00:41 +03:00
Alug bc1f21961c smol cleanup localskin ranking shit 2025-01-08 06:29:28 +01:00
Alug 0e1f843f50 ; 2025-01-08 05:52:08 +01:00
Alug 2a5d1fb84a ; 2025-01-08 05:52:01 +01:00
Alug 3b0d0dcd0c add banandrag rumble lol 2025-01-08 05:51:17 +01:00
Alug f92cf3df4f add slight fadeout to spinout rumble 2025-01-08 05:51:15 +01:00
Alug 274c9904e6 forgor to delet this 2025-01-08 04:13:07 +01:00
Alug 44ee017dee forgor to delet this 2025-01-08 04:12:51 +01:00
Alug 1416650c9d reorder saturn hud menu a little
also remove uncapped hud from it, since why would you ever wanna turn it off?
2025-01-08 05:09:03 +01:00
Alug 4acf6d336b add colourized speedlines
smth i had laying around in lugstuff
2025-01-08 05:08:27 +01:00
Alug dd7a861280 Merge branch 'rankingsrefactor' into Saturn-Testing 2025-01-08 04:47:39 +01:00
Alug bbb4893857 throw this into a function
smth smth nesting
2025-01-08 04:47:25 +01:00
Alug 3054c2366e Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-08 04:10:13 +01:00
Alug 51e367a61d move saturn hud cvars to k_kart and fix driftgauge extra showing
if there is no patch for it
its kinda dumb, since technically would allow to not load all of em
but im lazy and dont wanna change possiblevalues around
2025-01-08 04:10:05 +01:00
Alug 165803c95c toggle for smol positionnum and posnum animation 2025-01-08 04:10:02 +01:00
Alug d01ed38895 fix "connect" command not saving to last server 2025-01-08 03:23:37 +01:00
Alug f9e9b423dd Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-08 01:50:31 +01:00
Alug cdfef0f884 oops forgor those 2025-01-08 01:50:26 +01:00
Alug ddc8e4a29e clean up gamepad led stuff 2025-01-08 01:47:05 +01:00
Alug f576f39bc6 Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-08 01:34:00 +01:00
Alug f74cd97c4b clean up this mess a little 2025-01-08 01:33:55 +01:00
Alug bb91d8e1e3 dont rumble in freecam + player fix 2025-01-08 01:33:49 +01:00
Alug ee8fd22f36 oops fix software lel 2025-01-08 01:33:46 +01:00
Alug c0d4599a35 TEST: revert sleep stuff for now
dedi may sometimes get stuck here somehow
2025-01-07 23:48:41 +01:00
Alug 24a7d4b82d Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-07 20:18:49 +01:00
Alug 5c5a5e200e fix fbo crap once again 2025-01-07 20:18:39 +01:00
Alug 864d747e3b check if subsector has sector before assigning 2025-01-07 19:49:54 +01:00
Alug d623820833 check if subsector has sector before assigning 2025-01-07 19:49:46 +01:00
Alug a9be6a54ff Merge branch 'freecamstuffs' into Saturn-Testing 2025-01-07 18:47:31 +01:00
Alug d41b6c185a fix freecam aim getting stuck and other issues
- gamepads now aim like they used to and at same speed as keyboard
- aim reset has been changed so it resets automatically, but also can be manually reset with centerview
- aiming is locked during cam reset
2025-01-07 18:47:26 +01:00
Alug 3b60cb2bcd replace common damage magic numbers with named macros
that stuff always confused me before lol
2025-01-07 16:31:16 +01:00
Alug fe3ff15539 readd check for banan
this time without mobjwasremoved
just check if banan exists
2025-01-07 16:31:13 +01:00
Alug f5018f628a Merge branch 'freecamstuffs' into Saturn-Testing 2025-01-07 16:31:09 +01:00
Alug 03e45f4590 check for cam subsector
since we can move it around and i added this to freecam mode, subsector may be null for reason so better be safe than sorry
2025-01-07 16:31:04 +01:00
indev ce31ceda65 If available, add map title into crash log 2025-01-07 14:52:58 +03:00
indev aa00419198 If available, add map title into crash log 2025-01-07 14:52:19 +03:00
Alug fd5575ace5 make this more complicated due to a "-" 2025-01-06 22:50:30 +01:00
Alug c8737bd43f make this more complicated due to a "-" 2025-01-06 22:50:24 +01:00
Alug 2e31e08522 check for 0 to avoid division by 0 2025-01-06 22:41:41 +01:00
Alug 1412805503 Merge branch 'freecamstuffs' into Saturn-Testing 2025-01-06 22:41:25 +01:00
Alug eff6b31ee8 change director toggling handling
- now not changable over console anymore, bind only!
- it doesent save anymore so its always disabled at game start
- moving while in spec state will disable director when active so stand still
- disable it in splitscreen completely
- only adjust view when toggling it on
2025-01-06 22:41:20 +01:00
Alug 03259aeca0 let postimg stuff also apply to freecam 2025-01-06 22:41:18 +01:00
Alug 812e269195 Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-06 20:36:50 +01:00
Alug dbb5c1482b add a little extra safety here ig
this crashed on levelload once so idk maybe player was null ig
2025-01-06 20:36:31 +01:00
Alug afa66d0418 double the slack for slep 2025-01-06 20:36:25 +01:00
Alug 7177b396e0 any of those may be NULL in MakePatch
no idea but this crap keeps crashing in some other place every single time i add a check somewhere else
2025-01-05 23:02:36 +01:00
Alug e796f7e81f thats not timedemo lel 2025-01-05 21:25:01 +01:00
Alug 006fde8fea thats not timedemo lel 2025-01-05 21:24:55 +01:00
Alug 8499ca358b turn off any active menus when using demo play commands 2025-01-05 21:24:12 +01:00
Alug 890779713a turn off any active menus when using demo play commands 2025-01-05 21:24:03 +01:00
Alug 63b8cc1104 disable pause vhs effect when in freecam mode 2025-01-05 20:37:58 +01:00
Alug c4c995a9a3 disable pause vhs effect when in freecam mode 2025-01-05 20:37:49 +01:00
Alug 511105beb3 Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-05 20:14:59 +01:00
Alug 718fe7e8ae slight slep optimization
https://git.do.srb2.org/STJr/SRB2/-/commit/1da55066d43ed6a0cb666999c20316bef463024b?merge_request_iid=2583
2025-01-05 20:14:54 +01:00
Alug 258447c17b disable director while in replay freecam 2025-01-05 19:02:08 +01:00
Alug 1d8be20962 disable director while in replay freecam 2025-01-05 19:02:01 +01:00
Alug a90c51ec0f no u may be used uninitialised 2025-01-05 18:54:08 +01:00
Alug 077076532f slight cleanup buildticcmd 2025-01-05 18:54:05 +01:00
Alug e1bf657a05 Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-05 18:53:40 +01:00
Alug 7ca2051f84 Adjust slack based on precision
https://git.do.srb2.org/STJr/SRB2/-/commit/d20552c49d9fd6a2075ebd7d46b0b133c69f1dbe?merge_request_iid=2583
2025-01-05 18:53:32 +01:00
Alug 8ff5cc7cbb --------- 2025-01-05 15:11:25 +01:00
Alug bca4af201d no u may be used uninitialised 2025-01-05 14:51:32 +01:00
Alug 9af243177f --------- 2025-01-05 15:11:18 +01:00
Alug ca3c2bf70a remove this again
seems like it basically doesent change anything
2025-01-05 15:04:20 +01:00
Alug ce5fc9715d slight cleanup buildticcmd 2025-01-05 15:04:09 +01:00
Alug 606a50047c put refreshdirmenu back here 2025-01-05 15:04:06 +01:00
Alug b58c0705fc Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-05 15:04:01 +01:00
Alug 92649a393d dont cast "infinity" to int lel 2025-01-05 01:11:57 +01:00
Alug 98db1a5757 Further improve sleep accuracy on UNIX systems
hanichad https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2583
2025-01-05 01:11:54 +01:00
Alug 841c226732 this somehow got lost lel 2025-01-05 01:11:42 +01:00
Alug 7e8c8f4bb7 dont cast "infinity" to int lel 2025-01-05 00:43:20 +01:00
Alug ebedca82f3 Further improve sleep accuracy on UNIX systems
hanichad https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2583
2025-01-05 00:32:39 +01:00
Alug e06b61e8d2 revert "Faster z position checks for mobjs without collision" 2025-01-04 22:17:24 +01:00
Alug e2e703540e Merge branch 'freecamstuffs' into Saturn-Testing 2025-01-04 22:17:22 +01:00
Alug e53c6bb4da reduce ternary hell a little lel 2025-01-04 21:54:53 +01:00
Alug 8fa3a73fb2 Merge branch 'freecamstuffs' into Saturn-Testing 2025-01-04 21:04:45 +01:00
Alug 5c8b318a93 make float and sink use accel and brake again but also keep rebindable controls
keeps intended behaviour since we now dont need to worry about player controls anymore
but keeps the rebindable buttons incase someone wants to do a crazy control setup for some reason
2025-01-04 21:04:04 +01:00
Alug 029907a87a Merge branch 'Saturn-Next' into freecamstuffs 2025-01-04 19:46:42 +01:00
Alug 56cff59438 Merge branch 'nospecmove' into Saturn-Testing 2025-01-04 19:41:38 +01:00
Alug 2f4a113685 more hAx: dont move player during freecam state besides hop and honk
useful if you wanna take pics and dont feel like driving away
2025-01-04 19:38:08 +01:00
Alug f512a08051 dont do this while not in replay
this is kinda awkward tbh, but its useful for replay stuff
2025-01-04 19:38:05 +01:00
Alug cb223d7ddf Merge branch 'nospecmove' into Saturn-Testing 2025-01-04 02:30:08 +01:00
Alug 96a4bf3464 Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-04 02:30:06 +01:00
Alug 338bcf0d2d forgor about lookback ig 2025-01-04 02:30:01 +01:00
Alug 8cb7396f33 check for consoleplayer since displayplayer is who youre watching 2025-01-04 02:29:57 +01:00
Alug b69bb85003 remove redundant stuff
can just set this all the time, its only used when menu is active anyways so it doesent matter if we set it
2025-01-04 02:29:23 +01:00
Alug 729a74a561 remove redundant stuff
can just set this all the time, its only used when menu is active anyways so it doesent matter if we set it
2025-01-03 19:45:46 +01:00
Alug 5f0d47ca88 Merge branch 'nospecmove' into Saturn-Testing 2025-01-03 19:44:59 +01:00
Alug f9b1071539 simplify this 2025-01-03 19:44:10 +01:00
Alug 7d47834e55 oops smol error 2025-01-03 19:44:03 +01:00
Alug 2e1120dc50 move postimg flags to camera struct
- also dont let water and heat be applied on top of each other since it does not look good (water postimg takes priority over heat)
- also save a little time in opengl splitscreen since it does not support heat or wöter effects
2025-01-03 19:43:59 +01:00
Alug 64a2fe1410 clean shit up even more + fix cam aiming reset
dont really care about which input anyways.
2025-01-03 19:43:45 +01:00
Alug caa09cbcfb try and clean up this mess
+ fix cam angle being wrong when you switch to freecam from viewing someone
2025-01-03 19:43:36 +01:00
Alug ba4329e623 add another local ticcmd builder so it can guess if we "moved" and put us into freecam state and shit 2025-01-03 19:43:32 +01:00
Alug 575e46c3db let playercmd lua hook run during "spectator" input crap lmao 2025-01-03 19:43:19 +01:00
Alug 45237c9298 fix unitialised use of controller stuff 2025-01-03 19:43:10 +01:00
Alug 7de32c74e6 move spectator hack after pause/desynch code
this should take priority over everything
2025-01-03 19:43:04 +01:00
Alug 01b942e1fc giga shizo spec synch "fix"
ok so, for whatever dumb reason, spectatormovement will desynch at random, even on localhost.
with this we just literally fucking ignore almost every button input locally and just wont move our spectator player at all.
but since we are indeed still runiing specatotr movement code, and this is localcmd shit, the server just thinks we dont want to move and thus is "synchsave".
sadly this does not fix desynchs from vanilla players
the only code we keep is for button inputs that do certain actions like "item" so we can still join from spec with it and other crap
2025-01-03 19:42:58 +01:00
Alug 3388d35fe0 fix encore mirroring not applyingg to freecam/democam 2025-01-03 16:41:01 +01:00
Alug 2f014bb505 apparently this is slower for everything but rendering 2025-01-03 15:56:46 +01:00
Alug f9f7090b63 save subsector checks for dedi 2025-01-03 15:56:04 +01:00
Alug 0bc95e4b5e speed up camera position checks 2025-01-03 15:55:52 +01:00
Alug 250b41612e Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-03 15:55:32 +01:00
Alug c5b70ccc4a do NOT repeatedly call M_Responder!!
"thread safety" or smth
also put stuff into two seperate functions, since i started hating nesting
2025-01-03 15:55:07 +01:00
Alug 8b94aded16 smol fix 2025-01-03 15:54:52 +01:00
Alug e105d8f51e apparently this is slower for everything but rendering 2025-01-03 15:54:44 +01:00
Alug 54ed725061 didnt mean to revert this one 2025-01-03 15:54:01 +01:00
Alug 5844330301 only ever touch this if player has a mobjs
angleturn is dumb in kart and rarely really is what we want
2025-01-03 01:14:15 +01:00
Alug d1c80dfd9b smol fix 2025-01-02 22:54:16 +01:00
Alug b2097e2f93 apparently this is slower for everything but rendering 2025-01-02 21:50:57 +01:00
Alug 7386a2f40f let windoze detect 64bit mingw in makefile
lets us use just "make" cmd without specifieng any other crap on mingw64
2025-01-02 19:53:59 +01:00
Alug 5a1ecb55b8 Merge branch 'freecamstuffs' into Saturn-Testing 2025-01-02 17:09:48 +01:00
Alug b05d7d09cf Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-02 17:09:45 +01:00
Alug 30dc0abc25 move camera noclip stuff into its own function
its not used in kart anyways and moving it makes crap more readable
2025-01-02 17:09:34 +01:00
Alug a7a6e9edfc move camera noclip stuff into its own function
its not used in kart anyways and moving it makes crap more readable
2025-01-02 17:09:13 +01:00
Alug 854cb7ee49 this doesent work for us 2025-01-02 05:21:40 +01:00
Alug f7ca8fb943 add speccam playerflag
the other thing was weird and dumb lol
2025-01-02 04:54:25 +01:00
Alug dc0423f97e Merge remote-tracking branch 'origin/Saturn-Testing' into Saturn-Testing 2025-01-02 03:28:26 +01:00
Alug af968f1868 add speccam playerflag
the other thing was weird and dumb lol
2025-01-02 03:28:21 +01:00
Alug 2cc73cc52a this may not be synchsafe 2025-01-02 01:50:37 +01:00
Alug 28109dfb39 save subsector checks for dedi 2025-01-02 01:39:10 +01:00
Alug 2912994e6b speed up camera position checks 2025-01-02 01:39:07 +01:00
Alug 6d6d5996d7 Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-02 01:39:03 +01:00
Alug 54fda32591 logic error lmao oops 2025-01-01 21:53:01 +01:00
Alug 5d44b44558 use FRACUNIT in rumbleticker + some changes
- brakedrift will now add to any rumble thats currently going on
- both hyu and invul now rumble less heavy on offroad
2025-01-01 21:34:14 +01:00
indev e321d759c0 Thats not defined or used anywhere, bad automerge maybe? 2025-01-01 20:01:54 +03:00
indev bb3a65f8ff Repurpose ST_DrawTextInput into M_DrawTextInputScroll, and move its definition into m_textinput.c. M_DrawTextInput is now a macro using M_DrawTextInputScroll 2025-01-01 19:59:25 +03:00
Alug 8da59dc288 slightly cleanup rumble and led ticker 2025-01-01 17:37:00 +01:00
Alug bd433e0776 Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Testing 2025-01-01 17:22:51 +01:00
Alug fc9644f448 Merge branch 'precipthinklist' into Saturn-Testing 2025-01-01 17:22:29 +01:00
Alug 1558970064 Merge branch 'freecamstuffs' into Saturn-Testing 2025-01-01 17:20:04 +01:00
Alug 991dd55049 Merge branch 'Saturn-Next' into Saturn-Testing 2025-01-01 17:19:43 +01:00
Alug 8f0c5fb508 always close any menus when using "connect" command 2025-01-01 17:19:32 +01:00
Alug 5e1d43b5af those will never be changed ever 2025-01-01 17:19:29 +01:00
Alug 487018f146 hack: only let freecam for spec move when youre actually able to move as spec
cause kart weird, and we cant remove the spec movement due to synch reasons
and letting the cam move instantly instead of waiting, may put you in a weird cam position
2025-01-01 05:37:52 +01:00
Alug 3ade8b09c5 move early return even earlier
so theres no need to constantly init scale and drawdist
2025-01-01 05:30:31 +01:00
Alug 3180221a42 dont iterate through precip blockmap if there is no precip 2025-01-01 05:30:22 +01:00
Alug 9c37a8472e move early return even earlier
so theres no need to constantly init scale and drawdist
2025-01-01 05:11:31 +01:00
Alug 136d9143e7 we dont really need to check for precipthinkers in the precip thinkerlist
also makes precip handling in P_NetUnArchiveThinkers a little safer
2025-01-01 05:11:28 +01:00
Alug 4aad4887fd dont iterate through precip blockmap if there is no precip 2025-01-01 05:11:25 +01:00
Alug dfee1cc490 Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-31 02:53:22 +01:00
Alug ffc7832ec7 attempt to optimize column drawers a little 2024-12-31 02:52:30 +01:00
Alug 3910e66905 dont try to chase after your spec mobj lel 2024-12-30 23:11:00 +01:00
Alug 6fcfb9cf36 readd this check lel 2024-12-30 22:21:38 +01:00
Alug 83d2ade699 seperate thinkerlist for precip
i sure hope i handled everything right lmao
2024-12-30 18:00:18 +01:00
Alug fef98e478d add extra driftgauge option before i forger about it again 2024-12-30 17:55:50 +01:00
Alug f7ba260717 just skip missing/broken fields in musiccredit handling
like vanilla kek
still will throw warnings but atleast will show stuff if theres anything left in the musicdef
2024-12-30 17:53:06 +01:00
Alug 82f9f2f73f delet all the hardware sound crap
psure it doesent even properly work at this point
2024-12-30 17:51:57 +01:00
Alug e649690f6a Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-30 17:34:50 +01:00
Alug 182500c2d2 fix potential Fix segfault when aborting HTTP download 2024-12-30 17:34:45 +01:00
Alug aca48d45b3 fix potential crash with perfstats
https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2576
2024-12-30 17:34:40 +01:00
Alug 783682251f Merge branch 'freecamstuffs' into Saturn-Testing 2024-12-30 11:34:45 +01:00
Alug b2823c81e4 fix jitter when toggling freecam off 2024-12-30 11:34:40 +01:00
Alug 7465e1ae4b kill splitscreen director again 2024-12-30 11:34:10 +01:00
Alug 743d1a0e86 Merge branch 'freecamstuffs' into Saturn-Testing 2024-12-30 11:31:42 +01:00
Alug 761df3f2cf hide director control stuff for others than player 1 2024-12-30 11:30:53 +01:00
Alug 6f3443232e Merge branch 'Saturn-Next' into freecamstuffs 2024-12-30 11:30:46 +01:00
Alug 588dac343e dont disable this.... if its disabled kek 2024-12-30 11:24:23 +01:00
Alug aa222b6861 slight cleanup director 2024-12-30 11:10:41 +01:00
Alug 6d01ec4c55 dont need this anymore 2024-12-29 19:46:44 +01:00
Alug f72c64d7d1 fix some potential issues with viewinterp
now unpaused disabled interp on netlag
also fixes screencoord stuff not being interpolated during pause
2024-12-29 19:46:41 +01:00
Alug 92a3e974b0 fix driftgauge showing with freecam while ingame 2024-12-29 19:46:35 +01:00
Alug 7d6cce5881 readd cam cmd stuff
cause it may break the cam in replays or smth a
2024-12-29 19:46:33 +01:00
Alug 17f6f1cd4c use V_STEELMAP for white skincolours instead
cause white on white be weird
2024-12-29 18:43:54 +01:00
Alug 4b856fba2a z 2024-12-29 18:43:49 +01:00
Alug 3a8e4e065e draw gametype in tabrankings during replay playback
replays already show the mapname in there so
2024-12-29 18:43:41 +01:00
Alug 43f9bd5239 make highlight color in scoreboard and tab ranking player coloured
also make it appear in splitscreen
similar to hostmod things
2024-12-29 18:43:31 +01:00
Alug 6f5a0b9a3f also add playernum var to tabrankings drawer 2024-12-29 18:43:16 +01:00
Alug ecf55e64ae more smol refactoring 2024-12-29 18:43:08 +01:00
Alug cd566ac9c0 refactor intermission standings drawer
abstract the data stuff too
2024-12-29 18:42:56 +01:00
Alug b3323b7c2d change error msg 2024-12-29 17:45:28 +01:00
Alug 70e64d9471 reset demo recording in those places 2024-12-29 17:43:21 +01:00
Alug cbc3f8e917 add warning for non allocated demobuffer 2024-12-29 17:39:02 +01:00
Alug 55dfdc723f fix demo playback 2024-12-29 17:24:45 +01:00
Alug 6101ded74a allocate some extra buffer for demobuffer
incase this might overflow that we dont write to unvalid memory
thx indev <3
2024-12-29 16:59:10 +01:00
Alug 0d49bbfa7a Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-29 17:45:33 +01:00
Alug f6d83c17bd fix demo playback 2024-12-29 17:24:38 +01:00
Alug ac90a0973d fix wrong cam default controls 2024-12-29 16:51:42 +01:00
Alug 27d6447a83 fix wrong cam default controls 2024-12-29 16:51:18 +01:00
Alug f195c61200 Merge branch 'splitscreendirector' into Saturn-Testing 2024-12-29 16:48:17 +01:00
Alug 20044fa6a7 Merge branch 'freecamstuffs' into splitscreendirector 2024-12-29 16:47:25 +01:00
Alug 26480882c8 remove the remainder or demo.freecam 2024-12-29 16:43:34 +01:00
Alug b23020435f replace all this crap with either stplyrnum or R_GetViewNumber 2024-12-29 16:43:09 +01:00
Alug 267e2be69b fix offbyone issue 2024-12-29 16:42:33 +01:00
Alug b9428360c0 Merge branch 'Saturn-Next' into splitscreendirector 2024-12-29 16:16:59 +01:00
Alug 2112be8ef7 Merge branch 'Saturn-Next' into freecamstuffs 2024-12-29 16:16:49 +01:00
Alug e5ee978eb2 Merge branch 'Saturn-Next' into delaynetxcommand 2024-12-29 16:16:33 +01:00
Alug 55fd31894b Merge branch 'Saturn-Next' into checkposopti 2024-12-29 16:15:23 +01:00
Alug 189d9adef5 Merge branch 'Saturn-Next' into fixdupeacks 2024-12-29 16:15:00 +01:00
Alug 44288a5865 Merge branch 'unglobsavep' into Saturn-Next 2024-12-29 16:04:21 +01:00
Alug 66f89fb4ad oops 2024-12-29 16:03:56 +01:00
Alug eceb671ea8 add missing include 2024-12-29 16:02:05 +01:00
Alug a15615a229 add missing include 2024-12-29 16:01:35 +01:00
Alug 8e10bcc739 add a bunch of extra checks into demo stuff
buffer may be NULL in some cases
should fix dedis crashing when replay recording is disabled
2024-12-29 15:59:10 +01:00
Alug 22e65cd5e7 fixup conflicts 2024-12-29 15:58:43 +01:00
Alug 72383520cb Merge branch 'Saturn-Next' into unglobsavep 2024-12-29 15:51:25 +01:00
Alug 38ef55b869 add a mipmap check here ig 2024-12-29 15:41:28 +01:00
Alug 55c7dd860c fix offbyone issue 2024-12-29 15:39:39 +01:00
Alug ecefd1d3ee Merge branch 'splitscreendirector' into Saturn-Testing 2024-12-29 16:35:38 +01:00
Alug 0cdd0ca583 Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-29 16:17:16 +01:00
Alug 31a0122cd1 add a bunch of extra checks into demo stuff
buffer may be NULL in some cases
should fix dedis crashing when replay recording is disabled
2024-12-29 15:43:04 +01:00
Alug 6777cd2a9c Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-29 15:42:58 +01:00
Alug 649373ff51 Merge branch 'freecamstuffs' into splitscreendirector 2024-12-29 06:41:40 +01:00
Alug ca09a5dd46 dont need to do this twice 2024-12-29 06:41:11 +01:00
Alug 11546cd906 fix centerview 2024-12-29 06:41:07 +01:00
Alug 4110130ca7 block freecam toggling when player is in spec 2024-12-29 06:41:04 +01:00
Alug 6b9900ad4e clean up cam stuff for good 2024-12-29 06:41:00 +01:00
Alug 97e6222176 make function to return button names
to use with new rebindable cam controls
2024-12-29 06:03:20 +01:00
Alug 3d39f50388 make function to return button names
to use with new rebindable cam controls
2024-12-29 06:03:10 +01:00
Alug eef56a7c82 make debugdirector show stuff for p1 atleast 2024-12-29 05:51:13 +01:00
Alug 8853666645 track views in directorinfo structs
should hopefully fix any potential remaining issues
2024-12-29 05:45:04 +01:00
Alug a379764076 fix director toggling + smol cleanup 2024-12-29 05:45:01 +01:00
Alug edd1cc6059 Merge branch 'freecamstuffs' into splitscreendirector 2024-12-29 05:44:53 +01:00
Alug f355b2269c toggle off freecam when f12ing 2024-12-29 05:42:31 +01:00
Alug 03280db377 missing inlucde 2024-12-28 18:52:57 +01:00
Alug 86aeff5547 cleanup K_DirectorIsAvailable 2024-12-28 18:25:23 +01:00
Alug b5b2062efa add K_DirectorIsAvailable 2024-12-28 18:25:05 +01:00
Alug b51731d675 cleanup director splitscreen stuff 2024-12-28 17:48:02 +01:00
Alug 229e8d9592 WIP splitscreen director lel 2024-12-28 17:47:58 +01:00
indev da9c19bba4 Update replayfreecam lua global to use camera.freecam for currently viewed player 2024-12-28 18:48:58 +03:00
Alug 3156851554 fix cam interp during pause again 2024-12-28 04:01:21 +01:00
Alug a19cb5f2bc fix speccam again 2024-12-28 04:01:18 +01:00
Alug 2639f94dff fix freecam not being steerable when not in spec
ugh this is godawful
its literally almost a complete copy of
2024-12-28 03:44:32 +01:00
Alug 2c769f8043 changable freecam speed 2024-12-28 01:46:20 +01:00
Alug 332f7db32f make freecam work in splitscreen
banish cameracmd shit
2024-12-28 01:46:17 +01:00
Alug 3381f6af3a set default controls for float and sink ig 2024-12-28 01:46:12 +01:00
Alug 45d33b951c add alternative cam float and sink buttons 2024-12-28 01:46:09 +01:00
Alug 1922b32799 add bindable freecam toggle 2024-12-28 01:46:06 +01:00
Alug 6bb72c363f fix freecam not being interpolated when ingame 2024-12-28 01:46:03 +01:00
Alug 378382f3ad use demo freecam for spec
its more versataile and lets you pass through walls and floors just like in replays
2024-12-28 01:45:59 +01:00
Alug 7e09493cf2 whoops this never did anything lol 2024-12-26 16:01:49 +01:00
Alug 5c6bd1a043 oops forgor 2024-12-26 15:38:43 +01:00
Alug dcdd5e8f2d Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-26 16:33:01 +01:00
Alug 126fce9119 1px 2024-12-26 01:08:12 +01:00
Alug a3b3f91f8d 1px 2024-12-26 01:08:01 +01:00
Alug 69568378ec Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-26 01:01:00 +01:00
Alug 0b5879ffb3 fix compile 2024-12-26 01:00:52 +01:00
Alug 0bd2c6220d drifgauge gfx using the extra 3 speedometer sticker
arsepain
+ smol cleanup colorhud
2024-12-26 01:00:27 +01:00
Alug a434ce2080 super smol optimizations 2024-12-26 00:57:19 +01:00
Alug 8776b36bb0 super smol optimizations 2024-12-26 00:56:50 +01:00
Alug 9bde946c55 add tweakmap support
https://git.do.srb2.org/KartKrew/RingRacers/-/commit/7fb44bdb0239a8012be73cb9ee384a9fdca9addb
2024-12-25 01:57:51 +01:00
Alug c74898b970 make those const 2024-12-23 18:09:53 +01:00
Alug f0f2314639 Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-23 17:46:20 +01:00
Alug c8193380e7 make some cam stuff behave exactly like vanilla again
no clue if this changes anything at all, but cam stuff be causing so many issues id rather just have it behave like it used to
2024-12-23 17:45:59 +01:00
Alug e38580c9c2 dont remember removing this in s_sound 2024-12-23 17:45:54 +01:00
indev edf38cef33 If player has mobj, use it to assign localangle in G_FixCamera 2024-12-23 12:41:50 +03:00
Alug a700ec32fd fixeur comptime stuff (thx indev <3) 2024-12-23 00:37:51 +01:00
Alug 7dcd5f41ec use P_MobjWasRemoved for HWR_DrawSprite 2024-12-22 21:19:19 +01:00
Alug c46ff7daff use P_MobjWasRemoved for HWR_DrawSprite 2024-12-22 21:19:08 +01:00
Alug d2ca916043 settable mobj lightlevel from lua 2024-12-22 20:58:23 +01:00
Alug 09e901b31b readd mobj lightlevel field so i dont have to edit frameflags 2024-12-22 20:58:20 +01:00
Alug 01208a858d settable mobj lightlevel from lua 2024-12-22 20:58:02 +01:00
Alug c379db831c readd mobj lightlevel field so i dont have to edit frameflags 2024-12-22 20:57:56 +01:00
Alug d478a8a8b4 just skip missing/broken fields in musiccredit handling
like vanilla kek
still will throw warnings but atleast will show stuff if theres anything left in the musicdef
2024-12-22 19:59:53 +01:00
Alug 4418653edb Merge pull request #147 from Indev450/refactorogl
Refactor OpenGL library handling
2024-12-22 19:22:12 +01:00
Alug 1d9bcaa786 Merge branch 'Saturn-Next' into refactorogl 2024-12-22 19:21:27 +01:00
Alug 8bd943eb71 Merge remote-tracking branch 'origin/Saturn-Next' into directionallight 2024-12-22 18:57:38 +01:00
Alug 39535e9bf8 this stuff somehow wasnt merged 2024-12-22 18:52:27 +01:00
Alug db90142c4b Merge branch 'checkposopti' into Saturn-Testing 2024-12-22 18:45:53 +01:00
Alug 63bd3374be Merge branch 'optimobjz' into Saturn-Testing 2024-12-22 18:45:48 +01:00
Alug 7a232c8f5d fix compile 2024-12-22 18:39:04 +01:00
Alug b24c59ce55 fix compile 2024-12-22 18:38:57 +01:00
Alug 34f9dd9ea2 fix compile 2024-12-22 18:38:45 +01:00
Alug 0290c738e1 fix compile 2024-12-22 18:38:39 +01:00
Alug 0acb8e6a63 fix compile 2024-12-22 18:38:31 +01:00
Alug 27bfd0078c fix compile 2024-12-22 18:38:17 +01:00
Alug a98ab3d823 Merge branch 'Saturn-Next' into checkposopti 2024-12-22 18:25:10 +01:00
Alug bbf4de4f5e Revert "add P_CheckPositionShadow just for shadow mobjs"
This reverts commit 7edce19c9c.
2024-12-22 18:25:03 +01:00
Alug 4d3fba2bd0 Merge branch 'Saturn-Next' into optimobjz 2024-12-22 18:24:29 +01:00
Alug 83cc7015bf Revert "add shadows to faster slope z checking"
This reverts commit 4aaa2c6fed.
2024-12-22 18:24:26 +01:00
Alug f20297b5dd Merge branch 'Saturn-Next' into delaynetxcommand 2024-12-22 18:24:17 +01:00
Alug b4521643b2 Merge branch 'Saturn-Next' into fixdupeacks 2024-12-22 18:24:08 +01:00
Alug dfe151ccb1 Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-22 18:23:57 +01:00
Alug 67a75730d0 Revert "massive cleanup unused code"
This reverts commit e35612a6f6.
2024-12-22 18:23:38 +01:00
Alug d12369f6f4 add some () 2024-12-22 01:47:14 +01:00
Alug 4a7ce87ac2 do the same for R_ProjectPrecipitationSprite 2024-12-22 01:44:33 +01:00
Alug d8b36ef0da dont put potential null mobj into interpolation stuff 2024-12-22 01:42:51 +01:00
Alug 1341ec80bf dont dereference potential null mobjs in software projectsprite 2024-12-22 01:40:52 +01:00
Alug 9882291828 compiler pls shut up 2024-12-22 01:32:05 +01:00
Alug aa4fa1e42e use P_MobjWasRemoved and null check for thing subsector in projectsprite 2024-12-22 01:32:01 +01:00
Alug 8a641d3e37 fix fade to menu again oops 2024-12-20 18:23:27 +01:00
Alug 317f5f8d48 fix no fbo compile 2024-12-20 18:23:25 +01:00
Alug 98f136e747 fix fade to menu again oops 2024-12-20 17:20:16 +01:00
Alug 94792fe571 fix no fbo compile 2024-12-20 17:19:12 +01:00
Alug 92c0ddd068 always reset those just in case 2024-12-20 11:35:30 +01:00
Alug 6a43f0a09d Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-20 11:34:30 +01:00
Alug 4f037896db oops this is lugstuff only lel 2024-12-20 11:27:49 +01:00
Alug 494a87feea idk just set to false here too 2024-12-20 11:19:18 +01:00
Alug 4a3af6bc8a whoops 2024-12-20 03:17:20 +01:00
Alug 0c7851bd26 try to clean up downsampling and resolution checking stuff
- global function that updates variables with current display resolution
-smol boolean function that quickly checks if the game res matches the desktop res
- i_downsample has been simplyfied a bit
2024-12-20 03:13:17 +01:00
Alug 5b46ae2eb9 better nvidia xwayland workaround handling
what in the world was i thinking????
2024-12-20 03:12:57 +01:00
Alug 2034eedbe4 add another early return 2024-12-20 01:21:09 +01:00
Alug fde4f64b83 simplify this crap and make compiler happy 2024-12-20 00:59:46 +01:00
Alug 404927c53c no 2024-12-20 00:59:22 +01:00
Alug e0796b0cf1 just query this once 2024-12-20 00:59:18 +01:00
Alug 8df8749a9c return false here 2024-12-20 00:58:41 +01:00
Alug 1c2fb14f45 makes no sense without screen tex 2024-12-20 00:58:35 +01:00
Alug 4a2354ab26 Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-19 22:42:41 +01:00
Alug 82f70ff75e fix compile due to missing am_map.h include 2024-12-19 22:42:22 +01:00
Alug 46b2d5fbcd fix compile without USE_FBO_OGL 2024-12-19 22:40:28 +01:00
Alug be8cd85bfe Merge branch 'delaynetxcommand' into Saturn-Testing 2024-12-19 20:56:42 +01:00
Alug 7c4eefe8ee Merge branch 'fixdupeacks' into Saturn-Testing 2024-12-19 20:56:37 +01:00
Alug 19d6e30889 Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-19 20:56:35 +01:00
Alug 23b2e35dbd use slightly diff maths for skydomevertex calc
from DSDA-Doom
maybe fixes some issues with certain skydomes?
2024-12-19 20:56:25 +01:00
Alug a576ddf0e4 oops 2024-12-19 20:43:05 +01:00
Alug df63b3ece0 add "listmapthings" and "listunusedsprites" commands
the former also shows duplicated mapthings
2024-12-19 20:34:10 +01:00
Alug 3174d8fb1c Fix segfault when sending excessively large netcmds
https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2568/diffs?commit_id=457b761d9301b1904c414a8e8ba908f74b9ab959
2024-12-18 19:40:36 +01:00
Alug bed0e65548 potential fix for clients locking up due to never receiving acks back
apparently, if the client doesent receive an ack back which may happen due to duplicate packets/bad net conditions, it may spam resend the packet until its netxcmd buffer is full and locks up
2024-12-16 22:01:32 +01:00
Alug 1357978596 init textcmdbuf to NULL
just in case
2024-12-16 21:58:51 +01:00
Alug c5765c20bc delay NetXCmd´s instead of dropping them when the buffer is full
credits and many thanks to Hanicef!
https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2568
2024-12-16 21:58:48 +01:00
Alug 174af34115 Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Testing 2024-12-16 17:09:40 +01:00
Alug 52cd614613 prevent potential crash if viewmobj was removed 2024-12-16 16:38:03 +01:00
Alug 5c3711bcc8 Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-16 15:49:01 +01:00
Alug db04046cb3 smol fix for gamma stuff
-dont apply gamma adjust when gamma is on default value
-fix saturation not being applied on console on OpenGL without paletterendering
2024-12-16 15:48:33 +01:00
Alug 5ec48f72e0 fix changing gamma absolutely trashing performance
not quite sure why it made stuff die so much but uhhh
instead i just check in the cube initialistion function instead and only let it build when needed to not change how the game looks with raised gamma values
2024-12-15 22:14:57 +01:00
Alug 31aef1d200 fix changing gamma absolutely trashing performance
not quite sure why it made stuff die so much but uhhh
instead i just check in the cube initialistion function instead and only let it build when needed to not change how the game looks with raised gamma values
2024-12-15 22:14:05 +01:00
Alug 4aaa2c6fed add shadows to faster slope z checking 2024-12-14 22:50:30 +01:00
Alug 5d3c84327d Merge branch 'Saturn-Next' into optimobjz 2024-12-14 22:50:24 +01:00
Alug 909307f5ce only check if polyobjcst are on the map 2024-12-14 22:50:11 +01:00
Alug 7c7582f09b forgor about cameracheckposition 2024-12-14 22:50:07 +01:00
Alug 6f6dff4897 only check for polyobjects in the blockmap if there even are polyobjects
this saves the trouble of iterating through the blockmap every single time P_CheckPosition is called if there are no polyobjects present on the map
2024-12-14 22:50:04 +01:00
Alug 8611e70ba3 smol calc optimization P_Checkposition 2024-12-14 22:50:00 +01:00
Alug 7edce19c9c add P_CheckPositionShadow just for shadow mobjs
its basically just R_GetShadowZ from the render based shadows from srb2 lmao
hope this is synchsafe
2024-12-14 22:49:57 +01:00
Alug de52b1663d Merge branch 'Saturn-Next' into checkposopti 2024-12-14 22:49:50 +01:00
Alug eb1feba304 only check if polyobjcst are on the map 2024-12-14 22:49:32 +01:00
Alug 9df6368558 forgor about cameracheckposition 2024-12-14 22:49:25 +01:00
Alug 0a6092b738 only check for polyobjects in the blockmap if there even are polyobjects
this saves the trouble of iterating through the blockmap every single time P_CheckPosition is called if there are no polyobjects present on the map
2024-12-14 22:49:21 +01:00
Alug 6b852822a5 smol calc optimization P_Checkposition 2024-12-14 22:49:17 +01:00
Alug b4cde98526 add P_CheckPositionShadow just for shadow mobjs
its basically just R_GetShadowZ from the render based shadows from srb2 lmao
hope this is synchsafe
2024-12-14 22:49:13 +01:00
Alug 5f0f1966a8 add shadows to faster slope z checking 2024-12-14 22:49:08 +01:00
Alug dbadee987c delet all the hardware sound crap
psure it doesent even properly work at this point
2024-12-14 22:49:03 +01:00
Alug 995943d84d Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-14 22:48:24 +01:00
Alug 7a1c6bd9e4 slight cleanup K_GetScreenCoords and related functions
mostly just reducing scope and adding const clarifyier
also use mobjwasremoved checks everywhere instead of just simple null checks for some safety
2024-12-14 21:20:03 +01:00
Alug d8fe3920b1 fix papersprite lightlevels again kek + remove shit that does nothing 2024-12-14 17:14:20 +01:00
Alug 75af036fcf seems like you CANNOT apply dispoffset to papersprites
well then
2024-12-14 16:53:34 +01:00
Alug accc9890df fix inverted papersprite roll
oopsie
2024-12-14 16:53:31 +01:00
Alug a920556feb fix papersprite directional light
uhhh idk??
also passes papersprite bool directly instead of rechecking every frame for it
2024-12-14 16:53:23 +01:00
Alug 351cb4a1ac Merge branch 'Saturn-Next' into directionallight 2024-12-14 16:53:20 +01:00
Alug 764a5f3e0a Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Testing 2024-12-12 23:15:12 +01:00
indev cb97973b1c Merge pull request #150 from utkumaden/Saturn
Fixed gr_glinfo crash when there are way too many extensions present.
2024-12-12 19:21:15 +03:00
themixedupstuff 331f09cdd9 Fixed gr_glinfo crash when there are way too many extensions present. 2024-12-12 19:17:04 +03:00
indev 939084d57b Avoid overflowing CONS_Printf's buffer by using vsnprintf 2024-12-12 18:47:35 +03:00
indev 1cbfc71fc6 Revert "Change gl_extension to use glGetStringi instead of glGetString"
This reverts commit 7b550200f0.

Not supported on opengl version before 3.0 unfortunately
2024-12-12 18:03:16 +03:00
indev 7b550200f0 Change gl_extension to use glGetStringi instead of glGetString 2024-12-12 17:52:36 +03:00
Alug d41a2adce7 Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Testing 2024-12-12 14:40:21 +01:00
indev 665a11fa2b Merge branch 'Saturn-Next' into refactorogl 2024-12-12 14:38:59 +03:00
indev 1a49b161cc Merge pull request #146 from utkumaden/Saturn
Add gr_glinfo.
2024-12-12 14:34:32 +03:00
Alug 521b53dc09 maybe fix fade stuff idk 2024-12-12 02:32:19 +01:00
Alug 2c94ae8bb4 seperate thinkerlist for precip
i sure hope i handled everything right lmao
2024-12-12 02:32:07 +01:00
Alug ebbedc558d Merge branch 'refactorogl' into Saturn-Testing 2024-12-12 02:32:01 +01:00
Alug 0065c3d610 Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-12 02:31:52 +01:00
Alug 99e4870a52 check for the flag first 2024-12-12 02:31:44 +01:00
Alug 13ad27bc90 remove some precip code dupe 2024-12-12 00:30:54 +01:00
Alug 7ae361cb7c better cv_lessprecip handling
idk what i was thinking lmao
2024-12-12 00:11:50 +01:00
Alug 0e1bfbb0b5 clean up hw_cache stuff + fix accidental wrong cast 2024-12-11 23:24:00 +01:00
Alug 3dec352245 smol cleanup GL_SetBlend
use early return since i likeit more
2024-12-11 22:14:20 +01:00
Alug 8e273a1f19 GL_UpdateTexture can be static 2024-12-11 22:14:17 +01:00
Alug 1ab20814e9 simplify GL_SetPalette
can just copy the whole struct
2024-12-11 14:39:38 +01:00
Alug 0325ba4c0a simplify GL_SetPalette
can just copy the whole struct
2024-12-11 14:39:24 +01:00
Alug b348bff7a8 Merge branch 'refactorogl' into Saturn-Testing 2024-12-11 14:23:57 +01:00
Alug 37649a0d3c more cleanup GL_UpdateTexture
also some optimizations
2024-12-11 14:23:51 +01:00
Alug f3d1bf1106 clean up GL_UpdateTexture
use switches and reduce code dupe
2024-12-11 14:23:48 +01:00
Alug 93311c628e Merge branch 'Saturn-Next' into refactorogl 2024-12-11 14:23:42 +01:00
Alug b5e43ed73b Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-11 03:11:38 +01:00
Alug f8dfc954a0 test "or" 2024-12-11 03:11:33 +01:00
Alug 7ac2ba90b1 cast this 2024-12-11 02:03:14 +01:00
Alug f869393da4 Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-11 02:03:08 +01:00
Alug dbe5f8a4ba clamp splitsprite heights aswell 2024-12-11 01:26:04 +01:00
Alug a05c38b1fe those should better be clamped oops 2024-12-11 01:25:55 +01:00
Alug 91b6143f15 clean up this stuff; make splitwall behave more like vanilla
changes some splitwall issues slightly but gives bit better performance in some cases
2024-12-11 01:25:52 +01:00
Alug 0eaedd4b5e "extra safety" 2024-12-11 01:25:42 +01:00
Alug 727a31fdb5 one line those 2024-12-10 21:18:20 +01:00
Alug 3b64263dc6 Unconditionally interpolate view
even if it may NOT change
but i get the feeling it may cause some issues
2024-12-10 21:18:17 +01:00
Alug 83b6a63f13 dont pass fwrapv to compiler flags
this technically changes behavior of some things, even if it MAY fix some undefined behaviour
2024-12-10 21:18:14 +01:00
Alug 6ccece4603 Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-09 23:20:13 +01:00
Alug f6f6600118 interp.subsector is unused
so dont need to assign it nor call pointinsubsector for nothing
2024-12-09 23:20:07 +01:00
themixedupstuff 04c0bf2f17 Fix compiler warning on implicit GLuint* to GLint* conversion. 2024-12-09 17:30:04 +03:00
Alug 4da9c5ac07 "P_CheckSightFast" for lua
should be faster than normal P_CheckSight
only to be used for things like nametags etc so nothing gameplaywise as it will desynch
2024-12-09 10:53:11 +01:00
Alug 97cae4de59 smol things 2024-12-09 10:53:08 +01:00
Alug 9d1bef9ab9 i love menus 2024-12-09 10:19:32 +01:00
Alug 4bd2ba4d13 show commit on main menu for now
dont feel like always changing version strings for testing builds so thisll do
2024-12-09 10:19:14 +01:00
Alug ab0a3cde78 i love menus 2024-12-09 10:18:27 +01:00
Alug 72f9e4485e change testing versionstring 2024-12-09 10:17:58 +01:00
Alug 87c536b698 this does not work on windoze builds
rev-parse seems to do the job tho?
2024-12-09 10:16:56 +01:00
Alug ac03bad282 Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-09 10:53:17 +01:00
Alug 9efdcc1f34 HWDEEZ 2024-12-08 19:07:00 +01:00
Alug f26a965ea9 Merge branch 'directionallight' into Saturn-Testing 2024-12-08 19:05:56 +01:00
Alug 5c7bd954a2 fix up! 2024-12-08 19:05:13 +01:00
Alug 184cb8ba19 Merge remote-tracking branch 'origin/jittest' into Saturn-Testing 2024-12-08 18:57:25 +01:00
Alug 1d324a2d94 Merge branch 'optimobjz' into Saturn-Testing 2024-12-08 18:57:21 +01:00
Alug eeeb3440c2 Merge branch 'refactorogl' into Saturn-Testing 2024-12-08 18:57:16 +01:00
Alug a1c965584e Merge branch 'checkposopti' into Saturn-Testing 2024-12-08 18:57:12 +01:00
Alug e5b4905a12 Merge branch 'Saturn-Next' into Saturn-Testing 2024-12-08 18:57:04 +01:00
Alug f64ba96962 Merge remote-tracking branch 'ghg/ljtest' into jittest 2024-12-08 18:53:30 +01:00
Alug 0eec77d8b3 a 2024-12-08 18:43:17 +01:00
Alug 7efbe2213a port over bluajit stuff 2024-12-08 18:41:02 +01:00
Alug ffa25d1690 actually use the flags lol 2024-12-08 16:02:24 +01:00
Alug 74088c1d26 use loop instead of memcpy for setpalette
idk last time this died with models for some reason kek
2024-12-08 15:43:46 +01:00
Alug b03e74c366 rename to "hw_gl" 2024-12-08 15:39:52 +01:00
Alug cd9ee7d139 smol cleanup 2024-12-08 15:31:41 +01:00
Alug 3080f2953d optimized checksight for nametags and camera
idk should this be exposed to lua too?
2024-12-08 15:26:40 +01:00
Alug f7c7dae3a5 smol cleanup p_sight 2024-12-08 15:14:04 +01:00
Alug 3f16f42adf forgor 2024-12-08 05:03:36 +01:00
Alug feeb2d0f1a use early return
no need to check for all this crap if we can use it anyways
2024-12-08 04:39:12 +01:00
Alug 4c680808c1 dont always call R_PointInSubsector if thing has not moved
R_PointInSubsector is quite expensive
needs alot of testing
2024-12-08 04:22:03 +01:00
Alug 13a5909c3f oop 2024-12-08 04:13:16 +01:00
Alug 40be4d25a5 menu oopsie 2024-12-08 04:07:05 +01:00
Alug d84f887be8 clear maplight on toggling
so you only have to wait until nextmap for effect to do smth instead of game restart
2024-12-08 04:07:03 +01:00
Alug 009d851b58 this is needed 2024-12-08 03:36:48 +01:00
Alug 6d5e6add9b Optimize Z Postion checks for collisionless mobjs
a bit of speedup
hopefully should be synchsafe
2024-12-08 03:35:42 +01:00
Alug 62f7915e97 Merge branch 'Saturn-Next' into optimobjz 2024-12-08 03:34:29 +01:00
Alug 7b2e763d07 inline those two
smol speedup
2024-12-08 03:34:19 +01:00
Alug bc29d77aff menu entry 2024-12-08 03:31:53 +01:00
Alug 8db2e646db oop 2024-12-08 03:28:44 +01:00
Alug 3b2e207b6b make random directionallight toggable 2024-12-08 03:27:45 +01:00
Alug f061d66a16 conflict fix 2024-12-08 03:24:58 +01:00
Alug 8c295e8d5f port rr´s directional light 2024-12-08 03:22:34 +01:00
Alug c1b771fdc8 fix make files 2024-12-08 03:16:13 +01:00
Alug e5b12ece35 change this 2024-12-08 03:15:14 +01:00
Alug 43c99f8851 delet this 2024-12-08 03:13:50 +01:00
Alug 7304988071 fix conflitc 2024-12-08 03:12:48 +01:00
Alug d0b0a7490a Merge branch 'Saturn-Next' into refactorogl 2024-12-08 03:06:26 +01:00
Alug de4bcec782 make those less chaotic 2024-12-08 01:34:16 +01:00
Alug 0e843c2a96 stuff 2024-12-08 01:33:53 +01:00
Alug 9abd34baa3 proper macros 2024-12-08 01:33:44 +01:00
Alug 4fca31049f no need to set all that stuff manually 2024-12-07 12:52:09 +01:00
Alug 13f6b62dc0 port updated skydome code from srb2
seems to actually fix some visual issues on certain maps with it
2024-12-07 12:38:53 +01:00
Alug 3a5b282b9b try less maths for projectionmatrix
from dsdadoom again lul
2024-12-07 12:33:13 +01:00
themixedupstuff d763456655 Add gr_glinfo. 2024-12-05 22:38:47 +03:00
themixedupstuff b23fa084f1 Add GL_VENDOR string to the list of global GL variables. 2024-12-05 21:54:31 +03:00
Alug 216acf083a bruh 2024-12-05 14:30:19 +01:00
Alug 686a9f7237 use long M_PI to fix some render issues 2024-12-05 14:30:16 +01:00
Alug 5a206822c5 little extra safety 2024-12-05 08:10:13 +01:00
Alug 9805b03533 reduce the scope of those
only this function needs those
2024-12-05 08:08:00 +01:00
Alug d519f9cf06 try fix keepmusic occasionally not working
idk but sometimes DoReborn broke it?
also this ensures keepmusic and skipintromus flags always get reset
2024-12-05 07:58:20 +01:00
Alug 6265d0e38e why does this need a variable?
it just gets assigned kartstuff[k_aizdriftstrat] anyways?
2024-12-04 14:23:06 +01:00
Alug 55d9d64910 clean up this mess 2024-12-04 14:23:03 +01:00
Alug e2a651e553 make those const 2024-12-04 14:23:00 +01:00
Alug e4343f0935 only ever call pointtoangle for sprites that really need it 2024-12-04 01:39:17 +01:00
Alug 68090a55e1 change this a little 2024-12-03 21:50:45 +01:00
Alug 00bdd684ed 1463 lmao change this to be readable
also raise to 40 secs
2024-12-03 20:52:02 +01:00
Alug f4e498e559 this may be used unitialised lul 2024-12-03 20:40:05 +01:00
Alug 39c33b1f59 Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Next 2024-12-03 20:39:54 +01:00
Alug 55acbb208e try to make demo data handling a bit safer
- Use Z_Malloc to allocate demobuffer
- Use Z_Free to free demobuffer
- Make functions for freeing and resseting demobuffer
- Always reset demobuffer when not saving
2024-12-03 20:39:46 +01:00
indev 208f96535e Add MENUCAPS to some menu options 2024-12-03 22:06:35 +03:00
Alug 64bda53a78 Merge pull request #144 from Indev450/mobjcache2
Cache and reuse removed mobjs when spawning mobjs - Take 2
2024-12-02 21:31:25 +01:00
Alug e016777331 Merge pull request #145 from Indev450/hooklibrefactor
Lua Hooklib refactor
2024-12-02 21:31:16 +01:00
Alug 508cab4a0d Merge pull request #142 from Indev450/fastpoinonside
Add R_PointOnSideFast and R_PointInSubsectorFast and use it to optimize some non synch critical things
2024-12-02 21:13:07 +01:00
Alug b779be3574 Merge branch 'Saturn-Next' into hooklibrefactor 2024-12-02 21:12:16 +01:00
Alug fddcebc2d2 Merge branch 'fastpoinonside' into mobjcache2 2024-12-02 21:11:18 +01:00
Alug 91c5dc3c19 Merge branch 'Saturn-Next' into fastpoinonside 2024-12-02 21:11:10 +01:00
Alug 9401eb1591 oops revert this just in case 2024-12-02 21:09:58 +01:00
Alug 521bb88cda gah 2024-12-02 20:58:01 +01:00
Alug c1765258b2 quickncasehash 2024-12-02 20:57:08 +01:00
Alug 6afcb06e08 forgor
- refactored musicdef handling
- other things
2024-12-02 20:56:21 +01:00
Alug 1ae5bb9d27 lugstuff merge
- Completely refactor player camera handling
- Refactor ALOT of gamepad code
- Refactor local cmds
- Refactor automap and add minimap generator ("minigen" command)
- Remove a bunch of unused netcode
- Remove ALOT of unused gametype code
- Remove alot of unused bot code
- Optimize some sectorspecial code slightly
- Remove a bunch of nights mode related stuff that was unused
- Bunch of smaller optimizations and code improvements
2024-12-02 20:49:53 +01:00
Alug 252cd5cde5 better fix for netgame join hoop crash
this actually works and makes em animate
apparently somehow on netjoin some hprev entries get mangled but are not null?
no clue why that happens since hoops arent even netsynched only their "spawnpoint" is
2024-12-01 22:14:24 +01:00
Alug 12558740a4 better fix for G_FixCamera
completely forgor in kart and srb2.1 cmd.angleturn needs to be bitshifted to accomidate localangle
using it again is better, since player mobj angle is not always suitable for localangle and may slightly mismatch where a player is steering
2024-12-01 10:29:06 +01:00
Alug e1fbe8d657 seems like player not always have mobjs
titledemo moment
2024-12-01 10:18:18 +01:00
Alug b29a3ecfba this only ever applies to ogl
no need in software lol
2024-11-30 23:39:18 +01:00
Alug bd3a5ac284 give those better names 2024-11-30 23:23:05 +01:00
Alug 7de8b2d881 save one R_PointToAngle call
very smol optimisation lul
2024-11-30 22:31:45 +01:00
Alug 3139dff6ba missed this 2024-11-30 22:04:56 +01:00
Alug c4211045f2 oops this gets directly called in one instance
also why do we keep checking for null mobj when P_MobjWasRemoved checks that anyways?
2024-11-30 21:59:56 +01:00
Alug 6633dfe1e2 smol cleanup 2024-11-30 21:54:55 +01:00
Alug 9e2a48cae1 whoops 2024-11-30 21:54:52 +01:00
Alug 43f8a0213a sloperoll already has "off" setting, delet spriteroll cvar since redundant 2024-11-30 21:54:48 +01:00
Alug 975978ca9c this is null anyways if disabled 2024-11-30 21:54:45 +01:00
Alug dad630f3eb delet this 2024-11-30 20:29:08 +01:00
Alug 11f8b974df forgor sliptide roll 2024-11-30 20:28:26 +01:00
Alug 00773a0c10 okay? shut up compiler 2024-11-30 20:09:12 +01:00
Alug 6f6066906e optimize sprite rotation / sprite drawing a bit
- make software and ogl use same variable names
- let papersprites also roll in ogl not just software
- throw pitchnroll calc into a function to reduce code dupe
- save some calcs when having sliptide roll disabled
- fix software not calculating camang when just player roll is enabled (did that ever work right before? oops)
- determine early if the sprite is supposed to rotate, and only if it really does, run the rotation stuff
2024-11-30 20:05:15 +01:00
Alug 7730b69ef4 delete A_RollAngle things
they cant be used, since theyre not synchsafe
and nothing uses those anyways
2024-11-30 20:05:13 +01:00
Alug e3084cc28e allow demo play commands while watching a demo again 2024-11-29 23:25:58 +01:00
Alug b784fc58d0 loading not sending
just to clarify
2024-11-29 22:25:13 +01:00
Alug 8baa972bb2 this is also redundant 2024-11-29 13:15:59 +01:00
Alug 3b2251017c use continue instead of huge if block 2024-11-29 12:14:28 +01:00
Alug f0e7dace72 Merge branch 'Saturn-Next' into mobjcache2 2024-11-29 11:34:03 +01:00
Alug 4a837d3339 Fix buffer overrun with players with no associated node
https://git.do.srb2.org/STJr/SRB2/-/merge_requests/810/diffs?commit_id=af9164f336a65634f6908e677b47773d88f583af
2024-11-29 10:41:00 +01:00
Alug a2aa43e7fc dont think we need to reset anything here
kick cmd gets send out which should clear stuff in theory
2024-11-29 10:40:09 +01:00
Alug 3c0899263f those are redundant 2024-11-29 10:14:47 +01:00
Alug 91bb601ecb why? 2024-11-29 10:14:43 +01:00
Alug 1bd0c5d9bf those dont need to be inlined tbh 2024-11-29 09:37:13 +01:00
Alug 8b76426825 remove dupes 2024-11-29 09:37:10 +01:00
Alug 85464921ba eh this looks better 2024-11-29 09:37:07 +01:00
indev 9b6034853f Simplify consistency check a bit 2024-11-28 22:24:51 +03:00
indev 0ab732c9b2 Only check nodes that are in game in SV_ResendingSavegameToAnyone 2024-11-28 22:03:29 +03:00
Alug 8662648ef5 init polyobject thinker->references to 0
otherwise they wont get removed alot of the time
2024-11-27 23:00:32 +01:00
Alug 51808b8ced init polyobject thinker->references to 0
otherwise they wont get removed alot of the time
2024-11-27 23:00:16 +01:00
indev 2a7e442544 Use textinput_t for addon search 2024-11-28 00:54:26 +03:00
Alug dbdd5b8b6e only apply palrender postprocess shader once 2024-11-27 22:34:48 +01:00
Alug b8483376c4 dont draw final screen texture twice if you use native res
no need to
saves some performance
2024-11-27 22:29:49 +01:00
Alug 70105ccefc make own screentex for vhs effect
idk if its really needed tbh, but also doesent hurt
2024-11-27 17:12:25 +01:00
Alug 3a9082a694 memset screentex to 0 in FlushScreenTextures 2024-11-27 17:10:56 +01:00
Alug 82c18be717 why do replay play commands only have netgame check???????
bad things will happen if theyre played ingame regardless of netgame or not
2024-11-27 00:36:29 +01:00
Alug 0d39c2a0f6 we dont even need to check this
this doesent do anything with papersprites so dont even call it kek
2024-11-26 22:30:38 +01:00
Alug 4240af23cf Merge remote-tracking branch 'origin/cleanspriteclip' into Saturn-Next 2024-11-26 22:25:00 +01:00
Alug 80697046d5 clean up spriteclip fix + fix papersprites being affected by it
its now its own function HWR_ApplyDispoffset
papersprites are now also unaffected by it, which caused some minor visual issues before (ex zfighting signposts)
also just check for papersprite once and put it into a bool so we dont have to recheck sprite frames and flags 10 times
2024-11-26 20:31:20 +01:00
Alug 765dd72b38 Merge branch 'Saturn-Next' into fastpoinonside 2024-11-26 19:31:59 +01:00
Alug 403b60240f check for titlescreen music 2024-11-26 19:25:59 +01:00
Alug f973e6cd72 init polyobj thinker cachable bool
otherwise shit will die lol
2024-11-26 19:18:38 +01:00
Alug 5aff1acea8 mobjcache with explicit "true" check
just in case smth throws a garbo value and is not actually a mobj thinker
2024-11-26 19:18:34 +01:00
Alug 9e07ca0007 make hud hooks clean up after themselves 2024-11-22 16:04:16 +01:00
Alug df97bef4b5 Refactor HUD hooks too 2024-11-22 00:40:05 +01:00
indev b402738428 Fix mobj hooks called for mobj type 0 being interpreted as regular hooks 2024-11-22 01:31:02 +03:00
Alug 2de9a6bb94 forgor to remove those 2024-11-21 22:08:50 +01:00
Alug fb0c88cf55 Fix -Warray-bounds warning in lua_hooklib.c 2024-11-21 20:34:09 +01:00
Alug 1f6096e3ff fix pre and post thinkframe perfstats pages 2024-11-21 20:34:06 +01:00
Alug a4e6b5d177 Fix HurtMsg inflictor mobj type discriminator
https://git.do.srb2.org/STJr/SRB2/-/merge_requests/1903
2024-11-21 20:34:03 +01:00
Alug 4477f5ab93 Fix MusicChange hook crashing when called 2024-11-21 20:34:01 +01:00
Alug 11992d2e08 MORE MACROS 2024-11-21 20:33:58 +01:00
Alug 802979b81d Refactor hook ref allocation 2024-11-21 20:33:55 +01:00
Alug 06d0f5b95b Automatically count hook values 2024-11-21 20:33:52 +01:00
Alug da06c84aa4 we dont have key event hooks 2024-11-21 20:33:49 +01:00
Alug ecae607b59 this is unused for now 2024-11-21 20:33:46 +01:00
Alug f26717954e change those to fit rest of style 2024-11-21 20:33:44 +01:00
Alug a4080980ec make intermissionthinker use LUA_HookVoid
comment out hookbool since unused
2024-11-21 20:33:41 +01:00
indev 3db21bf778 Fix warning regarding MusicChange hook 2024-11-21 20:33:38 +01:00
indev 66518ced75 Add Should- and Player- Spin/Explode/Squish, and ServerJoin hooks into new hook system 2024-11-21 20:33:36 +01:00
Alug 5598526f52 delet serverjoin stuff i forgor and add old should spin stuff 2024-11-21 20:33:32 +01:00
Alug 14ec6e0674 serverjoin hook 2024-11-21 20:33:29 +01:00
Alug 549112822a port srb2 hooklib refactor (WIP)
lol lmao
2024-11-21 20:33:06 +01:00
indev e1cb858d9a Players that get 'NO CONTEST' can save replays too now 2024-11-21 22:02:25 +03:00
Alug 1659c2e753 try to make shadows not so offset on slopes with rotation enabled
lmaos
2024-11-21 02:11:51 +01:00
Alug e2222f66a9 those should be SHORT i think? 2024-11-21 02:11:48 +01:00
Alug 8a15b5e640 last attempt at fixing those things 2024-11-20 23:44:35 +01:00
Alug f499b11113 add R_PointInSubsectorFast for non critical gameplay stuff like sounds and camera
and some parts of rendering
2024-11-20 21:27:29 +01:00
Alug bec632800d use it for R_IsPointInSubsector
this is fine since R_IsPointInSubsector is only used for precip spawn unless you disable noclipcam lol
2024-11-20 21:26:18 +01:00
Alug a14c2f59b8 rename to R_PointOnSideFast 2024-11-20 21:25:18 +01:00
Alug e66d215dd3 Fix integer overflows on very large numbers 2024-11-20 21:24:16 +01:00
Alug 809ae20558 use highly optmized (but slightly inaccurate) version of R_PointOnSide for rendering 2024-11-20 21:24:04 +01:00
Alug 7b26ecb5f5 fixed float to integer conversion problems
from dsda doom
should hopefully make this behave the same everywhere
2024-11-19 22:10:08 +01:00
Alug 0c2ccc56cd inline _GetZAt stuff
those are very small but frequently used, so cant hurt
2024-11-17 21:42:20 +01:00
Alug 525681b5a5 Merge remote-tracking branch 'origin/Saturn-Next' into Saturn-Next 2024-11-17 21:41:33 +01:00
Alug c9a3dfcac9 reset pingtable in SV_ResetServer
and use some memsets cause they look cooler
also use ClearAdminPlayers simply to make this consistent with the other stuff that resets adminplayers
2024-11-17 21:41:25 +01:00
Alug a05aab1c7b Merge pull request #141 from Indev450/interpfixes
Some interpolation related fixes
2024-11-17 21:25:42 +01:00
Alug 7dfc638305 make replay/time attack menu support lowercase if toggled, also levelselect addon names too 2024-11-17 14:41:49 +01:00
Alug 3585969285 why is that declared here?? 2024-11-17 13:30:37 +01:00
Alug 3361ebe3c5 make menucaps stuff global macro and also apply to downloader text 2024-11-17 13:03:32 +01:00
Alug ebfd7f3e4e try make this look less like crap lol 2024-11-17 13:03:18 +01:00
Alug be49bd167b dont do this for papersprites
fickle...
2024-11-15 19:59:54 +01:00
Alug 13e9e41890 Merge remote-tracking branch 'origin/refactorcamstuff' into Saturn-Testing 2024-11-15 19:55:44 +01:00
Alug e6eec622c8 Merge remote-tracking branch 'origin/interpfixes' into Saturn-Testing 2024-11-15 19:55:35 +01:00
Alug 501b8b7bf5 try recursion limit for _RenderBSPNode
its 112 seems like the best compromise, hope it doesent break maps i didnt test visually or smth
2024-11-15 19:55:23 +01:00
Alug 99d78d62fb gu 2024-11-15 19:54:40 +01:00
Alug 1d5758f5d2 inline those 2024-11-15 19:54:24 +01:00
Alug fad1916259 psure it should be like this? 2024-11-15 19:54:20 +01:00
Alug 1bff103e53 use memset here too 2024-11-15 19:54:13 +01:00
Alug 68013b96d6 use memsets here and clear pingdata too 2024-11-15 19:54:10 +01:00
Alug 0c687539fb Merge branch 'Saturn-Next' into Saturn-Testing 2024-11-15 19:54:02 +01:00
Alug e2c8a773be prevent some palrender startup crashes
thx srb2 apparently this can be null during init so add some extra safety
2024-11-12 16:23:08 +01:00
Alug 6816c6dd19 add some paranthesis here 2024-11-12 15:44:29 +01:00
Alug b9e26a7e2f Merge branch 'Saturn-Next' into interpfixes 2024-11-12 15:44:16 +01:00
indev 31d8fe4459 Fix game crashing when increasing number of viewpoints more than by one (again) (needs testing that it didn't break anything else) 2024-11-12 01:40:05 +03:00
Alug 478d809620 Merge branch 'Saturn-Next' into refactorcamstuff 2024-11-09 16:16:40 +01:00
Alug 52f1d727c0 Merge branch 'Saturn-Next' into interpfixes 2024-11-09 16:11:08 +01:00
indev 80a29dc5a1 Fix r_portal.c and r_portal.h missing from src/CMakeLists.txt 2024-11-08 11:52:03 +03:00
Alug 54cbfbe699 forgor ifdef here 2024-11-03 15:33:26 +01:00
Alug 05f454157f Merge pull request #138 from Indev450/Saturn-Next
Saturn v7.2
2024-11-03 16:24:00 +01:00
indev 5a7c481f69 Fix normal skin being unable to load if localskins limit is reached (thx Alug for pointing out <3) 2024-11-03 00:26:44 +03:00
indev 076e84ed24 Fix localskins being unable to load if normal skin limit is reached 2024-11-03 00:13:45 +03:00
Alug 22164031fe gu? 2024-11-02 01:05:06 +01:00
Alug cb50144624 Merge branch 'Saturn-Next' into Saturn-Testing 2024-11-02 01:04:22 +01:00
Alug acd9763b9d Merge branch 'refactorogl' into Saturn-Testing 2024-10-31 13:47:42 +01:00
indev 9f2167ac3c Fix mapmusname global in lua being renamed to (*mapmusname) 2024-10-30 20:34:53 +03:00
Alug e9cfff8165 Merge branch 'Saturn-Next' into Saturn-Testing 2024-10-25 03:28:50 +02:00
Alug 1153d477ee Revert "maybe fix mobj interp spawn bugs?"
This reverts commit 037f45df1e.
2024-10-22 15:52:37 +02:00
Alug d63b158966 Revert "fix ghost interpolation"
This reverts commit f23202545b.
2024-10-22 15:52:32 +02:00
Alug f23202545b fix ghost interpolation 2024-10-22 02:32:01 +02:00
Alug 037f45df1e maybe fix mobj interp spawn bugs?
idk maybe has some odd side effects?
2024-10-21 22:50:51 +02:00
Alug 0eeb6758f4 Merge branch 'Saturn-Next' into Saturn-Testing 2024-10-21 22:50:46 +02:00
indev 5279192102 Fix off-by-one error for using '?' as map name 2024-10-21 18:40:16 +03:00
Alug 0c8516d33a also check here ig? 2024-10-21 17:01:35 +02:00
Alug 651f9637fc prevent map command crash from maps with invalid or non existing mapinfo 2024-10-21 15:39:37 +02:00
Alug 36c5c9939b replace those two P_MobjWasRemoved with simple null check insteead
since those may actually segfault if null anyways
2024-10-21 06:23:23 +02:00
Alug 613e32194f Merge branch 'Saturn-Next' into Saturn-Testing 2024-10-21 06:14:36 +02:00
indev 9a1e96fb99 Add commit title in comprevision 2024-10-20 21:20:57 +03:00
Alug bdcbf12246 add small quickncasehash function 2024-10-20 19:59:26 +02:00
Alug 894b843ccb Merge branch 'clientkick' into Saturn-Testing 2024-10-20 19:57:07 +02:00
Alug 4a9d67521f attempt to fix automap + add minimap generator command "minigen" 2024-10-20 19:56:32 +02:00
Alug a353dceaa3 better M_Random implementation
https://git.do.srb2.org/STJr/SRB2/-/merge_requests/1780
2024-10-20 19:50:44 +02:00
Alug 802dd2608e dont draw fadescreen when minimap iss active 2024-10-20 19:44:52 +02:00
Alug ebc4bf4b45 move displayplayer assignment earlier 2024-10-20 19:43:29 +02:00
Alug 906828fadb remove useless code in S_StopChannel 2024-10-20 19:42:56 +02:00
Alug e35612a6f6 massive cleanup unused code
all team stuff, gametypes, bots, etc.
hopefully this wont cause any weird netsynch issues for some reason
2024-10-20 19:41:41 +02:00
Alug f4e0272db9 Start bustable FOF sounds at the correct height 2024-10-20 19:25:26 +02:00
Alug 5ecfc5e09d Use PU_LEVEL for texture caching 2024-10-20 19:24:01 +02:00
Alug 927b819bc8 if game crashes, attempt to save replay 2024-10-20 19:22:04 +02:00
Alug 857731e89f remove broken and unused netcode stuff
https://git.do.srb2.org/STJr/SRB2/-/merge_requests/2523
2024-10-20 19:20:32 +02:00
Alug 24fed58c81 Merge branch 'interpfixes' into Saturn-Testing 2024-10-20 19:19:29 +02:00
Alug 57cef86ca1 dont think this needs to be reset every frame 2024-10-20 19:19:14 +02:00
Alug 0f91e18fce Merge branch 'unglobsavep' into Saturn-Testing 2024-10-20 19:16:23 +02:00
Alug c01a0147f2 Merge branch 'remusicdef' into Saturn-Testing 2024-10-20 19:16:19 +02:00
Alug d695b6d51a Merge branch 'refactorgamepads' into Saturn-Testing 2024-10-20 19:16:12 +02:00
Alug 3d1e4a93fd Merge branch 'refactorcamstuff' into Saturn-Testing 2024-10-20 19:15:53 +02:00
Alug 6a5d36c57a Merge branch 'Saturn-Next' into remusicdef 2024-10-20 16:30:24 +02:00
Alug 86ea7dde40 Merge branch 'Saturn-Next' into unglobsavep 2024-10-20 16:27:26 +02:00
Alug 7f709aee53 Merge branch 'Saturn-Next' into refactorcamstuff 2024-10-20 16:26:08 +02:00
Alug 4df7bcd87f Merge branch 'Saturn-Next' into refactorgamepads 2024-10-20 16:25:26 +02:00
Alug 0be25bd362 Merge branch 'Saturn-Next' into Saturn 2024-10-20 14:56:56 +02:00
Alug bfd61893a1 forgor joyscale 2024-10-16 13:28:25 +02:00
Alug 72d374786f huge cleanup controller code
hope i didnt break anything here lel
2024-10-16 13:28:22 +02:00
Alug eb40eec4c1 clean up cvar register a bit 2024-10-16 12:57:41 +02:00
Alug 991f1b17dd spec cam needs mo angle and aiming
atleast now ik why it checks for consoleplayer Zzz...
2024-10-14 19:23:47 +02:00
Alug 9a9aa75684 forgor about shadows lol 2024-10-13 21:33:17 +02:00
Alug d1b023c8c8 whoops forgor 2024-10-13 23:25:38 +02:00
Alug 0d6faed3d5 lol 2024-10-13 23:13:22 +02:00
Alug b3750f78ff only do this in software renderer
doesent work even with pal rendering in ogl
2024-10-13 23:07:32 +02:00
Alug 82f96dd080 remove unused/nonunsable analog cvars 2024-10-13 22:44:50 +02:00
Alug d640ce06d7 fix cam stuff for good + huge cleanup 2024-10-13 22:44:47 +02:00
Alug b8fb74fef3 fix the cam loops 2024-10-13 22:44:43 +02:00
Alug ab4bbbff72 use arrays for all the cam cvars 2024-10-13 22:44:37 +02:00
Alug 4180949307 dont need this splitscreen check 2024-10-13 22:43:14 +02:00
Alug e68ff858f2 attempt to clean up cam shit even more 2024-10-13 22:43:08 +02:00
Alug b978645c28 Merge branch 'Saturn-Next' into clientkick 2024-10-13 00:05:28 +02:00
Alug 59a99f4c21 Merge branch 'Saturn-Next' into clientkick 2024-10-12 23:29:43 +02:00
indev cb94235ac1 If corrupted save received, leave netgame 2024-10-12 22:09:20 +02:00
Alug d0c50c49a7 Add few checks to prevent game crashing if netgame archive becomes corrupted
https://github.com/alufolie91/saturn-32p/commit/1e47728ea8c60a1f04130170ddfab9b02e1a7e4c#diff-0c6396d5a9ad45f461741cd44ffb2c0d3cf0eb2ec7b0500053005196fe53f1a6R1517
2024-10-12 22:09:18 +02:00
Alug 7f1217b2ab Attempt to fix a lua panic when unarchiveing extvars (print error to console instead. Not sure if it would be safe for game to read from save afterwards though)
https://github.com/alufolie91/saturn-32p/commit/a770ecdbd4afd56a9d8325eae47f0c69f71661ee#diff-0c6396d5a9ad45f461741cd44ffb2c0d3cf0eb2ec7b0500053005196fe53f1a6R1462
2024-10-12 22:09:15 +02:00
Alug 3b01393a71 Merge branch 'Saturn-Next' into unglobsavep 2024-10-12 22:08:49 +02:00
Alug ef763487a5 this doesent make much sense tbh 2024-10-06 18:51:43 +02:00
Alug 03f5ac87fa Merge branch 'Saturn-Next' into interpfixes 2024-10-06 18:51:20 +02:00
Alug b2cac97106 fix this 2024-10-06 14:53:25 +02:00
Alug c3ce75055a only do this in replays
otherwise shit will jitter during netlag
2024-10-06 14:30:28 +02:00
Alug 90d64c4e15 fix main menu interpolation
apparently in main menu, opening the menu pauses the game so rendertimefrac was FRACUNIT and didnt interpolate
2024-10-06 13:47:20 +02:00
Alug 595648a2b3 Interpolate view, even when paused
https://github.com/KartKrewDev/RingRacers/commit/3320faec8cebecb124882d38c7ec0ad37b79340a#diff-607b68058edc6124b3061267d902aabeddb6ba338c6483df0af8b1a7cf796a01R43
2024-10-06 13:47:17 +02:00
Alug 8e799ddd74 fix a interp bug where the jitter on tally increase would be for only one rendered frame, not one full tic. 2024-10-06 13:47:14 +02:00
Alug a754e9c08a HACK: reset interp values in case 412 teleporter without using P_Setorigin
since that function does some wonky stuff and idk if that would be synch safe
2024-10-06 13:47:11 +02:00
Alug 112c9398e7 add missing break 2024-10-06 13:47:08 +02:00
Alug ccd691548e more R_ResetViewInterpolation stuff 2024-10-06 13:47:05 +02:00
Alug afd7b85005 R_ResetViewInterpolation: wait an extra tic if R_UpdateViewInterpolation has not run yet, do not add extra time for subsequent calls 2024-10-06 13:47:02 +02:00
Alug f9e1cdb940 P_Ticker: update view interpolation at the start of a tic 2024-10-06 13:46:43 +02:00
Alug 63fe657c7d Do not set hu_stopped on interpolated frame 2024-10-06 13:46:31 +02:00
Alug bf67c6b1d0 remove code dupe and let S_LoadMusicDefs also load MUSCINFO def 2024-10-01 15:19:51 +02:00
Alug f1cf370680 make a funky macro 2024-10-01 15:19:46 +02:00
Alug affa23040b refactor musicdef stuff
well it fixed the hash find lmao
2024-10-01 15:19:42 +02:00
Alug a15cefc80f oops 2024-10-01 15:19:38 +02:00
Alug 5cf00d903b super smol optimization to S_FindMusicCredit 2024-10-01 15:19:25 +02:00
Alug 47a805ede7 Merge branch 'Saturn-Next' into clientkick 2024-09-26 18:18:53 +02:00
Alug 206d562f3f Kick clients that fail to catch up with server gamelogic
version from rr to accomidate kart netcode a bit better
2024-09-24 19:11:03 +02:00
Alug 63f649724e Merge branch 'Saturn-Next' into unglobsavep 2024-09-24 17:05:42 +02:00
Alug df10262ebb Revert "beta hud driftgauge"
This reverts commit 26e8c2ca2b.
2024-09-23 01:34:47 +02:00
Alug a87ac3e35e Revert "extra check"
This reverts commit 0bb1efcd50.
2024-09-23 01:34:41 +02:00
Alug b71d9d2e68 Merge branch 'Saturn-Next' into unglobsavep 2024-09-23 01:04:04 +02:00
Alug cc44a5785d lets not archive players as mobjs 2024-09-22 23:08:33 +02:00
Alug 172d2bf545 Merge branch 'Saturn-Next' into unglobsavep 2024-09-22 22:20:19 +02:00
Alug 7493b3d2ab Revert "clean up leveload a bit"
This reverts commit c14af4a136.
2024-09-22 22:10:57 +02:00
Alug 31370741f2 Merge branch 'Saturn-Next' into unglobsavep 2024-09-22 17:01:27 +02:00
Alug e187f73044 Merge branch 'Saturn-Next' into unglobsavep 2024-09-21 17:41:58 +02:00
Alug 3aa55ee9c3 dont need this 2024-09-16 18:12:52 +02:00
Alug 8cfc8a5492 "player" 2024-09-16 17:52:58 +02:00
Alug 3f1c8db362 some stuff i forgor 2024-09-16 17:33:31 +02:00
Alug 0d999d7a70 Revert "Contain end & size into savebuffer_t"
This reverts commit 1a810bc923.
2024-09-16 17:17:19 +02:00
Alug 8bc081d937 Use Zone memory functions for sending compressed saves 2024-09-16 13:47:46 +02:00
Alug 42eb8d1af5 Only save demo if demobuf.p is ready 2024-09-16 13:47:43 +02:00
Alug 1a810bc923 Contain end & size into savebuffer_t 2024-09-16 13:47:40 +02:00
Alug 065572ef64 more fixup 2024-09-16 12:56:19 +02:00
Alug e88702e10c fix demo checkspace 2024-09-16 12:56:16 +02:00
Alug ee2d934525 rest smol fixes 2024-09-16 12:42:39 +02:00
Alug 2a3a33226e fixup demo savebuf 2024-09-16 12:42:36 +02:00
Alug 539315710c clean up 2024-09-16 12:42:33 +02:00
Alug 191a6ca76f unglobalize savebuffer
needs some cleanup
2024-09-16 12:42:29 +02:00
585 changed files with 36602 additions and 197899 deletions

No files matched your search

+8 -7
View File
@@ -13,16 +13,17 @@ Win32_LIB_ASM_Release
*.dgb
*.debug
*.debug.txt
/bin/VC10/
/objs/VC10/
*.user
*.db
*.opendb
/.vs
/debian
/assets/debian
compile.sh
*.gz
.vscode/
out
build
/make
/bin
/build
/build/*
/CMakeUserPresets.json
/out
/objs/VC10
*.kate-swp
+1 -1
View File
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.5)
# DO NOT CHANGE THIS SRB2 STRING! Some variable names depend on this string.
# Version change is fine.
project(SRB2
+9
View File
@@ -28,6 +28,10 @@ exist.
Returns the values of the given HUD item's `xoffset`/`yoffset` cvars.
Available for any HUD item with offset cvars.
## patch = v.cachePatchRotated(name, rollangle)
Like v.cachePatch, it caches a new patch with the corresponding name. Unlike v.cachePatch, however,
a rollangle can be supplied to the function so that it returns a rotated patch instead.
## x, y, flags = v.getDrawInfo(item)
Returns the X, Y and flags where the given HUD item will be drawn for the current displayplayer.
@@ -152,6 +156,11 @@ Add Gamepad Rumble support for things.
To be used with Displayplayers.
Duration is in milliseconds and is optional to set, default value is 84ms.
## P_CheckSightFast(mo1, mo2)
Exactly same as P_CheckSight but uses cheaper algorithm, useful for things like nametags. Doesn't work exactly
like P_CheckSight so don't use it for anything gameplay-related.
# Other changes
## P_PlayRinglossSound(source, damager)
+8
View File
@@ -0,0 +1,8 @@
ifdef SILENT
MAKEFLAGS+=--no-print-directory
endif
all :
% ::
@$(MAKE) -C src $(MAKECMDGOALS)
+1 -1
View File
@@ -76,7 +76,7 @@ Crashlogs now contain alot more informations. and even more if your build has de
Also allows 64bit Windows builds to produce Crashlogs!
## MISC
- Bird's Camara Tilting feature is no longer turned on by default
- Bird's Camera Tilting feature is no longer turned on by default
- Bird's warning on the title screen has been removed
## Bugs
-5
View File
@@ -1726,11 +1726,6 @@ HW3SOUND for 3D hardware sound support
<Option compilerVar="CC" />
</Unit>
<Unit filename="src/r_draw.h" />
<Unit filename="src/r_draw16.c">
<Option compilerVar="CC" />
<Option compile="0" />
<Option link="0" />
</Unit>
<Unit filename="src/r_draw8.c">
<Option compilerVar="CC" />
<Option compile="0" />
-10
View File
@@ -773,16 +773,6 @@ Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit79]
FileName=src\r_draw16.c
Folder=R_Rend
Compile=0
CompileCpp=0
Link=0
Priority=1000
OverrideBuildCmd=0
BuildCmd=
[Unit80]
FileName=src\r_draw8.c
Folder=R_Rend
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-1
View File
@@ -1 +0,0 @@
/lsdlsrb2
-3
View File
@@ -1,3 +0,0 @@
/lsdlsrb2
/pnd
/*.mo
-1
View File
@@ -1 +0,0 @@
/lsdlsrb2
-1
View File
@@ -1 +0,0 @@
/lsdl2srb2kart
-4
View File
@@ -1,4 +0,0 @@
*.exe
*.mo
r_opengl.dll
*.bat
-4
View File
@@ -1,4 +0,0 @@
*.exe
*.mo
r_opengl.dll
*.bat
-3
View File
@@ -1,3 +0,0 @@
/srb2sdl.exe
/srb2win.exe
/r_opengl.dll
-4
View File
@@ -1,4 +0,0 @@
*.exe
*.mo
r_opengl.dll
*.bat
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
+32 -32
View File
@@ -1,32 +1,32 @@
@echo off
set BRA=Unknown
set REV=illegal
copy nul: /b +%1\comptime.c tmp.$$$ > nul
move tmp.$$$ %1\comptime.c > nul
if exist .git goto gitrev
if exist ..\.git goto gitrev
if exist .svn goto svnrev
goto filwri
:gitrev
set GIT=%2
if "%GIT%"=="" set GIT=git
for /f "usebackq" %%s in (`%GIT% rev-parse --abbrev-ref HEAD`) do @set BRA=%%s
for /f "usebackq" %%s in (`%GIT% rev-parse HEAD`) do @set REV=%%s
set REV=%REV:~0,8%
goto filwri
:svnrev
set BRA=Subversion
for /f "usebackq" %%s in (`svnversion .`) do @set REV=%%s
set REV=r%REV%
goto filwri
:filwri
echo // Do not edit! This file was autogenerated > %1\comptime.h
echo // by the %0 batch file >> %1\comptime.h
echo // >> %1\comptime.h
echo const char* compbranch = "%BRA%"; >> %1\comptime.h
echo const char* comprevision = "%REV%"; >> %1\comptime.h
@echo off
set BRA=Unknown
set REV=illegal
copy nul: /b +%1\comptime.c tmp.$$$ > nul
move tmp.$$$ %1\comptime.c > nul
if exist .git goto gitrev
if exist ..\.git goto gitrev
if exist .svn goto svnrev
goto filwri
:gitrev
set GIT=%2
if "%GIT%"=="" set GIT=git
for /f "usebackq" %%s in (`%GIT% rev-parse --abbrev-ref HEAD`) do @set BRA=%%s
for /f "usebackq" %%s in (`%GIT% rev-parse HEAD`) do @set REV=%%s
set REV=%REV:~0,8%
goto filwri
:svnrev
set BRA=Subversion
for /f "usebackq" %%s in (`svnversion .`) do @set REV=%%s
set REV=r%REV%
goto filwri
:filwri
echo // Do not edit! This file was autogenerated > %1\comptime.h
echo // by the %0 batch file >> %1\comptime.h
echo // >> %1\comptime.h
echo const char* compbranch = "%BRA%"; >> %1\comptime.h
echo const char* comprevision = "%REV%"; >> %1\comptime.h
+1 -1
View File
@@ -17,7 +17,7 @@ EOF
versiongit() {
gitbranch="$(git rev-parse --abbrev-ref HEAD)"
gitversion="$(git rev-parse HEAD | cut -c -8)"
gitversion="$(git show --pretty=format:'%h %s' -s HEAD | sed 's/"/\\"/g')"
version "$gitbranch" "$gitversion";
exit 0
}
+9 -8
View File
@@ -1,5 +1,5 @@
/* backtrace.h -- Public header file for stack backtrace library.
Copyright (C) 2012-2020 Free Software Foundation, Inc.
Copyright (C) 2012-2024 Free Software Foundation, Inc.
Written by Ian Lance Taylor, Google.
Redistribution and use in source and binary forms, with or without
@@ -54,13 +54,14 @@ struct backtrace_state;
invalid after this function returns.
As a special case, the ERRNUM argument will be passed as -1 if no
debug info can be found for the executable, but the function
requires debug info (e.g., backtrace_full, backtrace_pcinfo). The
MSG in this case will be something along the lines of "no debug
info". Similarly, ERRNUM will be passed as -1 if there is no
symbol table, but the function requires a symbol table (e.g.,
backtrace_syminfo). This may be used as a signal that some other
approach should be tried. */
debug info can be found for the executable, or if the debug info
exists but has an unsupported version, but the function requires
debug info (e.g., backtrace_full, backtrace_pcinfo). The MSG in
this case will be something along the lines of "no debug info".
Similarly, ERRNUM will be passed as -1 if there is no symbol table,
but the function requires a symbol table (e.g., backtrace_syminfo).
This may be used as a signal that some other approach should be
tried. */
typedef void (*backtrace_error_callback) (void *data, const char *msg,
int errnum);
Binary file not shown.
-11
View File
@@ -1,11 +0,0 @@
#All folders
SRB2.res
depend.dep
depend.ped
*.o
buildvm*
minilua*
lj_vm.S
#VC9 folder only
/VC9/Win32
/VC9/x64
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
-2
View File
@@ -1,2 +0,0 @@
# DON'T REMOVE
# This keeps the folder from disappearing
+2 -1
View File
@@ -1,2 +1,3 @@
/cscope.out
/srb2wii
*.json
*.idx
+19 -3
View File
@@ -129,6 +129,7 @@ set(SRB2_CORE_RENDER_SOURCES
r_fps.c
r_main.c
r_patch.c
r_patchrotation.c
r_plane.c
r_segs.c
r_sky.c
@@ -143,7 +144,8 @@ set(SRB2_CORE_RENDER_SOURCES
r_fps.h
r_local.h
r_main.h
r_patch
r_patch.h
r_patchrotation.h
r_plane.h
r_segs.h
r_sky.h
@@ -173,6 +175,7 @@ set(SRB2_CORE_GAME_SOURCES
p_user.c
k_director.c
k_kart.c
k_stats.c
i_time.c
p_local.h
@@ -187,6 +190,7 @@ set(SRB2_CORE_GAME_SOURCES
p_tick.h
k_director.h
k_kart.h
k_stats.h
)
if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
@@ -224,6 +228,14 @@ set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL
"Use statically linked OpenGL. NOT RECOMMENDED.")
set(SRB2_CONFIG_USE_FBO_OGL ON CACHE BOOL
"Enable OpenGL FBO Downsampling support.")
set(SRB2_CONFIG_DEDICATED OFF CACHE BOOL
"Build a dedicated server.")
if(${SRB2_CONFIG_DEDICATED})
set(SRB2_CONFIG_HAVE_GME NO)
set(SRB2_CONFIG_HAVE_OPENMPT NO)
set(SRB2_CONFIG_HWRENDER NO)
endif()
### use internal libraries?
if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only
@@ -487,7 +499,7 @@ if(${SRB2_CONFIG_HWRENDER})
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_drv.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_gl.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h
${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_portal.h
@@ -550,7 +562,11 @@ add_definitions(-DCMAKECONFIG)
# ${SRB2_BLUA_HEADERS}
#)
add_subdirectory(sdl)
if(${SRB2_CONFIG_DEDICATED})
add_subdirectory(dedicated)
else()
add_subdirectory(sdl)
endif()
if(NOT ${SRB2_SDL2_AVAILABLE} AND NOT ${SRB2_WIN32_AVAILABLE})
message(FATAL_ERROR "There are no targets available to build an SRB2Kart executable. :(")
+360 -842
View File
File diff suppressed because it is too large. Load diff
+13 -11
View File
@@ -12,6 +12,7 @@
# to avoid a false positive with the version detection...
SUPPORTED_GCC_VERSIONS:=\
151 150 15\
142 141 140 14\
132 131 130 13\
123 122 121 120 12\
@@ -78,6 +79,18 @@ ifeq (,$(filter GCC%,$(.VARIABLES)))
endif
endif
ifdef GCC151
GCC150=1
endif
ifdef GCC15
GCC150=1
endif
ifdef GCC150
GCC142=1
endif
ifdef GCC142
GCC141=1
endif
@@ -469,7 +482,6 @@ ifdef GCC81
WFLAGS+=-Wno-error=multistatement-macros
endif
#indicate platform and what interface use with
ifndef LINUX
ifndef FREEBSD
@@ -477,7 +489,6 @@ ifndef CYGWIN32
ifndef MINGW
ifndef MINGW64
ifndef SDL
ifndef DUMMY
$(error No interface or platform flag defined)
endif
endif
@@ -485,7 +496,6 @@ endif
endif
endif
endif
endif
#determine the interface directory (where you put all i_*.c)
i_net_o=$(OBJDIR)/i_net.o
@@ -510,11 +520,6 @@ UPX_OPTS+=-q
endif
#Interface Setup
ifdef DUMMY
INTERFACE=dummy
OBJDIR:=$(OBJDIR)/dummy
BIN:=$(BIN)/dummy
else
ifdef LINUX
SDL=1
ifdef LINUX64
@@ -561,7 +566,6 @@ endif
endif
endif
endif
endif
ifdef ARCHNAME
OBJDIR:=$(OBJDIR)/$(ARCHNAME)
@@ -576,7 +580,6 @@ ifdef SDL
OBJDIR:=$(OBJDIR)/SDL
endif
ifndef DUMMY
ifdef DEBUGMODE
OBJDIR:=$(OBJDIR)/Debug
BIN:=$(BIN)/Debug
@@ -584,4 +587,3 @@ else
OBJDIR:=$(OBJDIR)/Release
BIN:=$(BIN)/Release
endif
endif
+19
View File
@@ -0,0 +1,19 @@
makedir:=$(makedir)/Dedicated
sources+=$(call List,dedicated/Sourcefile)
opts+=-DDEDICATED
ifdef MINGW
libs+=-mconsole
endif
ifndef NOTHREADS
opts+=-DHAVE_THREADS
sources+=dedicated/i_threads.c
endif
NOOPENMPT=1
NOGME=1
NOHW=1
NOUPNP=1
+124
View File
@@ -0,0 +1,124 @@
#
# Detect the host system and compiler version.
#
# Previously featured:\
PANDORA\
DUMMY\
DJGPPDOS\
SOLARIS\
MACOSX\
all_systems:=\
LINUX64\
MINGW64\
MINGW\
UNIX\
LINUX\
FREEBSD\
HAIKU\
# check for user specified system
ifeq (,$(filter $(all_systems),$(.VARIABLES)))
ifeq ($(OS),Windows_NT) # all windows are Windows_NT...
ifeq ($(shell uname -s | grep -o MINGW64),MINGW64) # 64-bit MinGW
_m=Detected a Windows system,\
compiling for 64-bit MinGW SDL...)
$(call Print,$(_m))
MINGW64=1
else # 32-bit MinGW
_m=Detected a Windows system,\
compiling for 32-bit MinGW SDL...)
$(call Print,$(_m))
MINGW=1
endif
NOOBJDUMP=1
else # if you on the *nix
system:=$(shell uname -s)
ifeq ($(system),Linux)
new_system:=LINUX
else ifeq ($(system),Haiku)
new_system:=HAIKU
else
$(error \
Could not automatically detect your system,\
try specifying a system manually)
endif
ifeq ($(shell getconf LONG_BIT),64)
system+=64-bit
new_system:=$(new_system)64
endif
$(call Print,Detected $(system) ($(new_system))...)
$(new_system):=1
endif
endif
# This must have high to low order.
gcc_versions:=\
151 150 15\
142 141 140 14\
132 131 130 13\
123 122 121 120 12\
114 113 112 111 110 11\
105 104 103 102 101 100 10\
95 94 93 92 91 90\
85 84 83 82 81 80\
75 74 73 72 71 70\
64 63 62 61 60\
55 54 53 52 51 50\
49 48 47 46 45 44 43 42 41 40
latest_gcc_version:=15.1.1
# Automatically set version flag, but not if one was
# manually set. And don't bother if this is a clean only
# run.
ifeq (,$(call Wildvar,GCC% destructive))
# can't use $(CC) --version here since that uses argv[0] to display the name
# also gcc outputs the information to stderr, so I had to do 2>&1
# this program really doesn't like identifying itself
shellversion:=$(shell $(CC) -v 2>&1)
# Try to remove "-win32"
version:=$(subst -win32,.0,$(shellversion))
# check if this is in fact GCC
ifneq (,$(findstring gcc version,$(version)))
# in stark contrast to the name, gcc will give me a nicely formatted version number for free
shellversion:=$(shell $(CC) -dumpfullversion)
# Try to remove "-win32"
version:=$(subst -win32,.0,$(shellversion))
# Turn version into words of major, minor
v:=$(subst ., ,$(version))
# concat. major minor
v:=$(word 1,$(v))$(word 2,$(v))
# If this version is not in the list,
# default to the latest supported
ifeq (,$(filter $(v),$(gcc_versions)))
define line =
Your compiler version, GCC $(version), \
is not supported by the Makefile.
The Makefile will assume GCC $(latest_gcc_version).
endef
$(call Print,$(line))
GCC$(subst .,,$(latest_gcc_version)):=1
else
$(call Print,Detected GCC $(version) (GCC$(v)))
GCC$(v):=1
endif
endif
endif
+106
View File
@@ -0,0 +1,106 @@
#
# Makefile for feature flags.
#
passthru_opts+=\
NOHW NOMD5 NOPOSTPROCESSING\
MOBJCONSISTANCY PACKETDROP ZDEBUG\
HAVE_MINIUPNPC\
HAVE_DISCORDRPC DEVELOP\
NOBLUAJIT
# build with debugging information
ifdef DEBUGMODE
PACKETDROP=1
opts+=-DPARANOIA -DRANGECHECK
endif
ifndef NOHW
opts+=-DHWRENDER
ifndef NOSCREENFBO
opts+=-DUSE_FBO_OGL
endif
sources+=$(call List,hardware/Sourcefile)
endif
ifndef NOMD5
sources+=md5.c
endif
ifndef NONET
ifndef NOSATURNJOIN
opts+=-DDOSATURNJOIN
endif
ifndef NOSATURNPAK
opts+=-DDOSATURNPAK
endif
endif
ifndef NOZLIB
ifndef NOPNG
ifdef PNG_PKGCONFIG
$(eval $(call Use_pkg_config,PNG_PKGCONFIG))
else
PNG_CONFIG?=$(call Prefix,libpng-config)
$(eval $(call Configure,PNG,$(PNG_CONFIG) \
$(if $(PNG_STATIC),--static),,--ldflags))
endif
ifdef LINUX
opts+=-D_LARGEFILE64_SOURCE
endif
opts+=-DHAVE_PNG
sources+=apng.c
endif
endif
ifndef NOCURL
CURLCONFIG?=curl-config
$(eval $(call Configure,CURL,$(CURLCONFIG)))
opts+=-DHAVE_CURL
endif
ifdef HAVE_MINIUPNPC
MINIUPNPC_PKGCONFIG?=miniupnpc
$(eval $(call Use_pkg_config,MINIUPNPC))
HAVE_MINIUPNPC=1
opts+=-DHAVE_MINIUPNPC
endif
ifndef NOLIBBACKTRACE
$(eval $(call Propogate_flags,LIBBACKTRACE))
libs+=-lbacktrace
opts+=-DHAVE_LIBBACKTRACE
endif
#windoze hack
ifdef MINGW
ifndef NODISCORDRPC
HAVE_DISCORDRPC=1
endif
endif
ifdef HAVE_DISCORDRPC
$(eval $(call Propogate_flags,DISCORDRPC))
libs+=-ldiscord-rpc
opts+=-DUSE_STUN
sources+=discord.c stun.c
endif
# (Valgrind is a memory debugger.)
ifdef VALGRIND
VALGRIND_PKGCONFIG?=valgrind
VALGRIND_LDFLAGS=
$(eval $(call Use_pkg_config,VALGRIND))
ZDEBUG=1
opts+=-DHAVE_VALGRIND
endif
default_packages:=\
GME/libgme/LIBGME\
OPENMPT/libopenmpt/LIBOPENMPT\
ZLIB/zlib\
$(foreach p,$(default_packages),\
$(eval $(call Check_pkg_config,$(p))))
+71
View File
@@ -0,0 +1,71 @@
#
# Makefile options for Haiku
#
opts+=-DUNIXCOMMON -DLUA_USE_POSIX
ifndef DEDICATED
ifndef DUMMY
SDL?=1
DEDICATED?=0
endif
endif
NOEXECINFO=1
ifeq (${SDL},1)
EXENAME?=srb2haiku
else ifeq (${DEDICATED},1)
EXENAME?=srb2haikud
endif
ifndef NONET
libs+=-lnetwork
endif
define _set =
$(1)_CFLAGS?=$($(1)_opts)
$(1)_LDFLAGS?=$($(1)_libs)
endef
lib:=../libs/gme
LIBGME_opts:=-I$(lib)/include
LIBGME_libs:=-l:libgme.so.0
$(eval $(call _set,LIBGME))
lib:=../libs/libopenmpt
LIBOPENMPT_opts:=-I$(lib)/inc
LIBOPENMPT_libs:=-l:libopenmpt.so.0
$(eval $(call _set,LIBOPENMPT))
ifdef SDL
lib:=../libs/SDL2_mixer
mixer_opts:=-I$(lib)/include
mixer_libs:=-l:libSDL2_mixer-2.0.so.0
lib:=../libs/SDL2
SDL_opts:=-I$(lib)/include $(mixer_opts)
SDL_libs:=$(mixer_libs) -l:libSDL2-2.0.so.0
$(eval $(call _set,SDL))
endif
lib:=../libs/zlib
ZLIB_opts:=-I$(lib)
ZLIB_libs:=-l:libz.so.1
$(eval $(call _set,ZLIB))
ifndef PNG_CONFIG
PNG_opts:=
PNG_libs:=-l:libpng16.so.16
$(eval $(call _set,PNG))
endif
lib:=../libs/curl
CURL_opts:=-I$(lib)/include
CURL_libs:=-l:libcurl.so.4
$(eval $(call _set,CURL))
lib:=../libs/miniupnpc
MINIUPNPC_opts:=-I$(lib)/include
MINIUPNPC_libs:=-l:libminiupnpc.so.17
$(eval $(call _set,MINIUPNPC))
+47
View File
@@ -0,0 +1,47 @@
#
# Makefile options for unices (linux, bsd...)
#
opts+=-DUNIXCOMMON -DLUA_USE_POSIX
# Use -rdynamic so a backtrace log shows function names
# instead of addresses
libs+=-lm -rdynamic
ifndef NOHW
opts+=-I/usr/X11R6/include
libs+=-L/usr/X11R6/lib
endif
ifndef DEDICATED
SDL?=1
DEDICATED?=0
endif
ifeq (${SDL},1)
EXENAME?=lsdl2srb2kart
endif
ifeq (${DEDICATED},1)
EXENAME?=lsrb2kartd
endif
# In common usage.
ifdef LINUX
libs+=-lrt
passthru_opts+=NOTERMIOS
endif
# Tested by Steel, as of release 2.2.8.
ifdef FREEBSD
opts+=-I/usr/X11R6/include -DLINUX -DFREEBSD
libs+=-L/usr/X11R6/lib -lkvm -lexecinfo
endif
# FIXME: UNTESTED
#ifdef SOLARIS
#NOIPX=1
#opts+=-I/usr/local/include -I/opt/sfw/include \
# -DSOLARIS -DINADDR_NONE=INADDR_ANY -DBSD_COMP
#libs+=-L/opt/sfw/lib -lsocket -lnsl
#endif
+16
View File
@@ -0,0 +1,16 @@
#
# Warn about old build directories and offer to purge.
#
_old:=$(wildcard $(addprefix ../bin/,FreeBSD Linux \
Linux64 Mingw Mingw64 SDL dummy) ../objs ../dep)
ifdef _old
$(foreach v,$(_old),$(info $(abspath $(v))))
$(info )
$(info These directories are no longer\
required and should be removed.)
$(info You may remove them manually or\
by using 'make distclean')
$(error )
endif
+76
View File
@@ -0,0 +1,76 @@
#
# Platform specific options.
#
PKG_CONFIG?=pkg-config
ifdef WINDOWSHELL
rmrf=-2>NUL DEL /S /Q
mkdir=-2>NUL MD
cat=TYPE
else
rmrf=rm -rf
mkdir=mkdir -p
cat=cat
endif
ifdef LINUX64
LINUX=1
endif
ifdef MINGW64
MINGW=1
endif
ifdef LINUX
UNIX=1
ifdef LINUX64
NONX86=1
# LINUX64 does not imply X86_64=1;
# could mean ARM64 or Itanium
platform=linux/64
else
platform=linux
endif
else ifdef FREEBSD
UNIX=1
platform=freebsd
else ifdef HAIKU
# Give Haiku its own configuration, since it
# isn't actually UNIX.
include Makefile.d/haiku.mk
else ifdef SOLARIS # FIXME: UNTESTED
UNIX=1
platform=solaris
else ifdef CYGWIN32 # FIXME: UNTESTED
platform=cygwin
else ifdef MINGW
ifdef MINGW64
NONX86=1
NOASM=1
# MINGW64 should not necessarily imply X86_64=1,
# but we make that assumption elsewhere
# Once that changes, remove this
X86_64=1
platform=mingw/64
else
platform=mingw
endif
include Makefile.d/win32.mk
endif
ifdef platform
makedir:=$(makedir)/$(platform)
endif
ifdef UNIX
include Makefile.d/nix.mk
endif
ifeq ($(SDL), 1)
include Makefile.d/sdl.mk
else ifeq ($(DEDICATED), 1)
include Makefile.d/dedicated.mk
else
include Makefile.d/dummy.mk
endif
+71
View File
@@ -0,0 +1,71 @@
#
# Makefile options for SDL2 backend.
#
#
# SDL...., *looks at Alam*, THIS IS A MESS!
#
# ...a little bird flexes its muscles...
#
makedir:=$(makedir)/SDL
opts+=-DDIRECTFULLSCREEN -DHAVE_SDL
sources+=$(call List,sdl/Sourcefile)
NOUPNP=1
# FIXME: UNTESTED
#ifdef PANDORA
#include sdl/SRB2Pandora/Makefile.cfg
#endif #ifdef PANDORA
# FIXME: UNTESTED
#ifdef CYGWIN32
#include sdl/MakeCYG.cfg
#endif #ifdef CYGWIN32
ifndef NOHW
sources+=sdl/ogl_sdl.c
endif
ifdef NOMIXER
sources+=sdl/sdl_sound.c
else
opts+=-DHAVE_MIXER
sources+=sdl/mixer_sound.c
ifndef HAIKU # Haiku has a special import path
libs+=-lSDL2_mixer
endif
endif
ifndef NOTHREADS
opts+=-DHAVE_THREADS
sources+=sdl/i_threads.c
endif
ifdef SDL_PKGCONFIG
$(eval $(call Use_pkg_config,SDL))
else
SDL_CONFIG?=$(call Prefix,sdl2-config)
SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
SDL_LDFLAGS?=$(shell $(SDL_CONFIG) \
$(if $(STATIC),--static-libs,--libs))
$(eval $(call Propogate_flags,SDL))
endif
ifdef MINGW
ifndef NOSDLMAIN
SDLMAIN=1
endif
endif
ifdef SDLMAIN
opts+=-DSDLMAIN
else
ifdef MINGW
opts+=-Umain
libs+=-mconsole
endif
endif
+93
View File
@@ -0,0 +1,93 @@
#
# Utility macros for the rest of the Makefiles.
#
Ifnot=$(if $(1),$(3),$(2))
Ifndef=$(call Ifnot,$($(1)),$(2),$(3))
# Match and expand a list of variables by pattern.
Wildvar=$(foreach v,$(filter $(1),$(.VARIABLES)),$($(v)))
# Read a list of words from file and prepend each with the
# directory of the file.
_cat=$(shell $(cat) $(call Windows_path,$(1)))
List=$(addprefix $(dir $(1)),$(call _cat,$(1)))
# Convert path separators to backslash on Windows.
Windows_path=$(if $(WINDOWSHELL),$(subst /,\,$(1)),$(1))
define Propogate_flags =
opts+=$$($(1)_CFLAGS)
libs+=$$($(1)_LDFLAGS)
endef
# Set library's _CFLAGS and _LDFLAGS from some command.
# Automatically propogates the flags too.
# 1: variable prefix (e.g. CURL)
# 2: start of command (e.g. curl-config)
# --- optional ----
# 3: CFLAGS command arguments, default '--cflags'
# 4: LDFLAGS command arguments, default '--libs'
# 5: common command arguments at the end of command
define Configure =
$(1)_CFLAGS?=$$(shell $(2) $(or $(3),--cflags) $(5))
$(1)_LDFLAGS?=$$(shell $(2) $(or $(4),--libs) $(5))
$(call Propogate_flags,$(1))
endef
# Configure library with pkg-config. The package name is
# taken from a _PKGCONFIG variable.
# 1: variable prefix
#
# LIBGME_PKGCONFIG=libgme
# $(eval $(call Use_pkg_config,LIBGME))
define Use_pkg_config =
$(call Configure,$(1),$(PKG_CONFIG),,,$($(1)_PKGCONFIG))
endef
# Check disabling flag and configure package in one step
# according to delimited argument.
# (There is only one argument, but it split by slash.)
# 1/: short form library name (uppercase). This is
# prefixed with 'NO' and 'HAVE_'. E.g. NOGME, HAVE_GME
# /2: package name (e.g. libgme)
# /3: variable prefix
#
# The following example would check if NOGME is not
# defined before attempting to define LIBGME_CFLAGS and
# LIBGME_LDFLAGS as with Use_pkg_config.
#
# $(eval $(call Check_pkg_config,GME/libgme/LIBGME))
define Check_pkg_config =
_p:=$(subst /, ,$(1))
_v1:=$$(word 1,$$(_p))
_v2:=$$(or $$(word 3,$$(_p)),$$(_v1))
ifndef NO$$(_v1)
$$(_v2)_PKGCONFIG?=$$(word 2,$$(_p))
$$(eval $$(call Use_pkg_config,$$(_v2)))
opts+=-DHAVE_$$(_v1)
endif
endef
# $(call Prefix,gcc)
Prefix=$(if $(PREFIX),$(PREFIX)-)$(1)
Echo=
Echo_name=
Print=
ifndef SILENT
Echo=@echo $(1)
ifndef ECHO
ifndef NOECHOFILENAMES
Echo_name=$(call Echo,-- $(1) ...)
endif
endif
ifndef MAKE_RESTARTS
ifndef destructive
Print=$(info $(1))
endif
endif
endif
.=$(call Ifndef,ECHO,@)
+181
View File
@@ -0,0 +1,181 @@
#
# Flags to put a sock in GCC!
#
# See the versions list in detect.mk
# This will define all version flags going backward.
# Yes, it's magic.
define _predecessor =
ifdef GCC$(firstword $(1))
GCC$(lastword $(1)):=1
endif
endef
_n:=$(words $(gcc_versions))
$(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\
$(addprefix =,$(wordlist 2,$(_n),$(gcc_versions)))),\
$(and $(findstring =,$(v)),\
$(eval $(call _predecessor,$(subst =, ,$(v))))))
# aggregate returns seem to happen alot in c++ so just supress em lel
CXXFLAGS+= -Wno-aggregate-return
# -W -Wno-unused
ifdef GCC150
opts+=-std=gnu17
endif
WFLAGS:=-Wall -Wno-trigraphs
ifndef GCC295
#WFLAGS+=-Wno-packed
endif
ifndef RELAXWARNINGS
WFLAGS+=-W
#WFLAGS+=-Wno-sign-compare
ifndef GCC295
WFLAGS+=-Wno-div-by-zero
endif
#WFLAGS+=-Wsystem-headers
WFLAGS+=-Wfloat-equal
#WFLAGS+=-Wtraditional
WFLAGS+=-Wundef
ifndef GCC295
WFLAGS+=-Wendif-labels
endif
ifdef GCC41
WFLAGS+=-Wshadow
endif
#WFLAGS+=-Wlarger-than-%len%
WFLAGS+=-Wpointer-arith -Wbad-function-cast
ifdef GCC45
#WFLAGS+=-Wc++-compat
endif
WFLAGS+=-Wcast-qual
ifndef NOCASTALIGNWARN
WFLAGS+=-Wcast-align
endif
WFLAGS+=-Wwrite-strings
ifndef ERRORMODE
#WFLAGS+=-Wconversion
ifdef GCC43
#WFLAGS+=-Wno-sign-conversion
endif
endif
WFLAGS+=-Wsign-compare
ifdef GCC91
WFLAGS+=-Wno-error=address-of-packed-member
endif
ifdef GCC45
WFLAGS+=-Wlogical-op
endif
WFLAGS+=-Waggregate-return
ifdef HAIKU
ifdef GCC41
#WFLAGS+=-Wno-attributes
endif
endif
#WFLAGS+=-Wstrict-prototypes
ifdef GCC40
WFLAGS+=-Wold-style-definition
endif
WFLAGS+=-Wmissing-prototypes -Wmissing-declarations
ifdef GCC40
WFLAGS+=-Wmissing-field-initializers
endif
WFLAGS+=-Wmissing-noreturn
#WFLAGS+=-Wmissing-format-attribute
#WFLAGS+=-Wno-multichar
#WFLAGS+=-Wno-deprecated-declarations
#WFLAGS+=-Wpacked
#WFLAGS+=-Wpadded
#WFLAGS+=-Wredundant-decls
WFLAGS+=-Wnested-externs
#WFLAGS+=-Wunreachable-code
WFLAGS+=-Winline
ifdef DEBUGMODE
WFLAGS+=-Wno-error=inline
endif
ifdef GCC43
WFLAGS+=-funit-at-a-time
WFLAGS+=-Wlogical-op
endif
ifndef GCC295
WFLAGS+=-Wdisabled-optimization
endif
endif
WFLAGS+=-Wformat-y2k
ifdef GCC71
WFLAGS+=-Wno-error=format-overflow=2
endif
WFLAGS+=-Wformat-security
ifndef GCC29
#WFLAGS+=-Winit-self
endif
ifdef GCC46
WFLAGS+=-Wno-suggest-attribute=noreturn
endif
ifdef NOLDWARNING
LDFLAGS+=-Wl,--as-needed
endif
ifdef ERRORMODE
WFLAGS+=-Werror
endif
ifdef GCC43
#WFLAGS+=-Wno-error=clobbered
endif
ifdef GCC44
#WFLAGS+=-Wno-error=array-bounds
endif
ifdef GCC46
WFLAGS+=-Wno-error=suggest-attribute=noreturn
endif
ifdef GCC54
WFLAGS+=-Wno-logical-op -Wno-error=logical-op
endif
ifdef GCC61
WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare
endif
ifdef GCC71
WFLAGS+=-Wimplicit-fallthrough=4
endif
ifdef GCC81
WFLAGS+=-Wno-error=format-overflow
WFLAGS+=-Wno-format-overflow
WFLAGS+=-Wno-error=multistatement-macros
endif
ifdef NONX86
ifdef X86_64 # yeah that SEEMS contradictory
opts+=-march=nocona
endif
else
ifndef GCC29
opts+=-msse3 -mfpmath=sse
else
opts+=-mpentium
endif
endif
ifdef DEBUGMODE
ifdef GCC48
opts+=-Og
else
opts+=-O0
endif
endif
ifdef VALGRIND
ifdef GCC46
WFLAGS+=-Wno-error=unused-but-set-variable
WFLAGS+=-Wno-unused-but-set-variable
endif
endif
# Lua
ifdef GCC43
ifndef GCC44
WFLAGS+=-Wno-logical-op
endif
endif
+124
View File
@@ -0,0 +1,124 @@
#
# Mingw, if you don't know, that's Win32/Win64
#
ifndef MINGW64
EXENAME?=srb2kart-saturn_32bit.exe
else
EXENAME?=srb2kart-saturn_64bit.exe
endif
# disable dynamicbase if under msys2
ifdef MSYSTEM
libs+=-Wl,--disable-dynamicbase
endif
sources+=win32/Srb2win.rc
opts+=-DSTDC_HEADERS
libs+=-ladvapi32 -lkernel32 -lmsvcrt -luser32
ifndef DEDICATED
ifndef DUMMY
SDL?=1
endif
endif
ifndef NOHW
opts+=-DUSE_WGL_SWAP
endif
ifdef MINGW64
libs+=-lws2_32
else
#ifndef HAVE_IPV6
#libs+=-lwsock32
#else
libs+=-lws2_32
#endif
endif
ifndef MINGW64
libs+=-Wl,--large-address-aware
NOLIBBACKTRACE=1
endif
ifndef MINGW64
32=32
x86=x86
i686=i686
else
32=64
x86=x86_64
i686=x86_64
endif
mingw:=$(i686)-w64-mingw32
define _set =
$(1)_CFLAGS?=$($(1)_opts)
$(1)_LDFLAGS?=$($(1)_libs)
endef
lib:=../libs/gme
LIBGME_opts:=-I$(lib)/include
LIBGME_libs:=-L$(lib)/win$(32) -lgme
$(eval $(call _set,LIBGME))
lib:=../libs/libopenmpt
LIBOPENMPT_opts:=-I$(lib)/inc
LIBOPENMPT_libs:=-L$(lib)/lib/$(x86)/mingw -lopenmpt
$(eval $(call _set,LIBOPENMPT))
lib:=../libs/SDL2_mixer/$(mingw)
ifdef SDL
mixer_opts:=-I$(lib)/include/SDL2
mixer_libs:=-L$(lib)/lib
lib:=../libs/SDL2/$(mingw)
SDL_opts:=-I$(lib)/include/SDL2\
$(mixer_opts) -Dmain=SDL_main
SDL_libs:=-L$(lib)/lib $(mixer_libs)\
-lmingw32 -lSDL2main -lSDL2 -mwindows
$(eval $(call _set,SDL))
endif
ifdef MINGW64
lib:=../libs/libbacktrace
LIBBACKTRACE_opts:=-I$(lib)/include
LIBBACKTRACE_libs:=-L$(lib)/lib/x86_64 -lbacktrace
$(eval $(call _set,LIBBACKTRACE))
else
lib:=../libs/drmingw
opts+=-I$(lib)/include
libs+=-L$(lib)/lib/win32 -lmgwhelp -lexchndl
endif
lib:=../libs/zlib
ZLIB_opts:=-I$(lib)
ZLIB_libs:=-L$(lib)/win32 -l:libz$(32).a
$(eval $(call _set,ZLIB))
ifndef PNG_CONFIG
lib:=../libs/libpng-src
PNG_opts:=-I$(lib)
PNG_libs:=-L$(lib)/projects -lpng$(32)
$(eval $(call _set,PNG))
endif
lib:=../libs/curl
CURL_opts:=-I$(lib)/include
CURL_libs:=-L$(lib)/lib$(32) -lcurl
$(eval $(call _set,CURL))
ifndef MINGW64 # miniupnc is broken with MINGW64
lib:=../libs/miniupnpc
MINIUPNPC_opts:=-I$(lib)/include -DMINIUPNP_STATICLIB
MINIUPNPC_libs:=-L$(lib)/mingw$(32) -lminiupnpc -lws2_32 -liphlpapi
$(eval $(call _set,MINIUPNPC))
endif
lib:=../libs/discord-rpc/win$(32)-dynamic
DISCORDRPC_opts+=-I$(lib)/include
DISCORDRPC_libs+=-L$(lib)/lib -ldiscord-rpc
$(eval $(call _set,DISCORDRPC))
+97
View File
@@ -0,0 +1,97 @@
am_map.c
b_bot.c
command.c
console.c
d_clisrv.c
d_main.c
d_net.c
d_netcmd.c
d_netfil.c
d_protocol.c
dehacked.c
f_finale.c
f_wipe.c
filesrch.c
g_game.c
g_input.c
hu_stuff.c
i_tcp.c
i_time.c
info.c
lzf.c
m_aatree.c
m_anigif.c
m_argv.c
m_bbox.c
m_cheat.c
m_cond.c
m_fixed.c
m_menu.c
m_textinput.c
m_misc.c
m_perfstats.c
m_queue.c
m_random.c
mserv.c
http-mserv.c
qs22j.c
s_sound.c
screen.c
sounds.c
st_stuff.c
string.c
tables.c
v_video.c
w_wad.c
y_inter.c
z_zone.c
r_bsp.c
r_data.c
r_draw.c
r_fps.c
r_main.cpp
r_patch.c
r_patchrotation.c
r_plane.cpp
r_segs.cpp
r_skins.c
r_sky.c
r_splats.c
r_things.cpp
r_portal.c
p_ceilng.c
p_enemy.c
p_floor.c
p_inter.c
p_lights.c
p_map.c
p_maputl.c
p_mobj.c
p_polyobj.c
p_saveg.c
p_setup.c
p_sight.c
p_slopes.c
p_spec.c
p_telept.c
p_tick.c
p_user.c
k_director.c
k_kart.c
k_stats.c
lua_baselib.c
lua_blockmaplib.c
lua_consolelib.c
lua_hooklib.c
lua_hudlib.c
lua_hudlib_drawlist.c
lua_infolib.c
lua_maplib.c
lua_mathlib.c
lua_mobjlib.c
lua_playerlib.c
lua_script.c
lua_skinlib.c
lua_thinkerlib.c
lua_udatalib.c
lua_glib.c
+465 -121
View File
@@ -1,8 +1,10 @@
// SONIC ROBO BLAST 2
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2018 by Sonic Team Junior.
// Copyright (C) 2024 by Vivian "toastergrl" Grannell.
// Copyright (C) 2024 by Kart Krew.
// Copyright (C) 2020 by Sonic Team Junior.
// Copyright (C) 2000 by DooM Legacy Team.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
@@ -33,36 +35,31 @@ static const UINT8 GRAYSRANGE = 16;
static const UINT8 BROWNS = (3*16);
static const UINT8 YELLOWS = (7*16);
static const UINT8 GREENS = (10*16);
//static const UINT8 CYANS = (13*16);
static const UINT8 BLUES = (14*16);
static const UINT8 DBLACK = 31;
static const UINT8 DWHITE = 0;
static const UINT8 NOCLIMBREDS = 248;
static const UINT8 NOCLIMBREDRANGE = 8;
static const UINT8 NOCLIMBGRAYS = 204;
static const UINT8 NOCLIMBBROWNS = (2*16);
static const UINT8 NOCLIMBYELLOWS = (11*16);
// Automap colors
#define BACKGROUND DBLACK
#define WALLCOLORS (REDS + REDRANGE/2)
#define WALLRANGE (REDRANGE/2)
#define NOCLIMBWALLCOLORS (NOCLIMBREDS + NOCLIMBREDRANGE/2)
#define NOCLIMBWALLRANGE (NOCLIMBREDRANGE/2)
#define THOKWALLCOLORS REDS
#define THOKWALLRANGE REDRANGE
#define NOCLIMBTHOKWALLCOLORS NOCLIMBREDS
#define NOCLIMBTHOKWALLRANGE NOCLIMBREDRANGE
#define TSWALLCOLORS GRAYS
#define TSWALLRANGE GRAYSRANGE
#define NOCLIMBTSWALLCOLORS NOCLIMBGRAYS
#define TSWALLCOLORS DWHITE
#define TSFINISHLINE (GREENS + 2)
#define TSFOFINFO (BLUES + 4)
#define FDWALLCOLORS BROWNS
#define NOCLIMBFDWALLCOLORS NOCLIMBBROWNS
#define CDWALLCOLORS YELLOWS
#define NOCLIMBCDWALLCOLORS NOCLIMBYELLOWS
#define THINGCOLORS GREENS
#define GRIDCOLORS (GRAYS + GRAYSRANGE/2)
#define XHAIRCOLORS GRAYS
// Automap passes
#define PASS_SOLID 1
#define PASS_INTANGIBLE 2
#define PASS_FOF 4
// controls
#define AM_PANUPKEY KEY_UPARROW
#define AM_PANDOWNKEY KEY_DOWNARROW
@@ -110,11 +107,6 @@ typedef struct
mpoint_t a, b;
} mline_t;
typedef struct
{
fixed_t slp, islp;
} islope_t;
//
// The vector graphics for the automap.
// A line drawing of the player pointing right,
@@ -136,16 +128,14 @@ static const mline_t player_arrow[] = {
#undef R
#define NUMPLYRLINES (sizeof (player_arrow)/sizeof (mline_t))
#if 0
#define R (FRACUNIT)
static mline_t triangle_guy[] = {
{ { (fixed_t)-.867f*R, (fixed_t)-.5f*R }, { (fixed_t) .867f*R, (fixed_t)-.5f*R } },
{ { (fixed_t) .867f*R, (fixed_t)-.5f*R }, { (fixed_t) 0, (fixed_t) R } },
{ { (fixed_t) 0, (fixed_t) R }, { (fixed_t)-.867f*R, (fixed_t)-.5f*R } }
static const mline_t cross_mark[] =
{
{ { -R, 0 }, { R, 0} },
{ { 0, -R }, { 0, R } },
};
#undef R
#define NUMTRIANGLEGUYLINES (sizeof (triangle_guy)/sizeof (mline_t))
#endif
#define NUMCROSSMARKLINES (sizeof(cross_mark)/sizeof(mline_t))
#define R (FRACUNIT)
static const mline_t thintriangle_guy[] = {
@@ -162,10 +152,14 @@ static boolean draw_grid = false;
boolean automapactive = false;
boolean am_recalc = false; //added : 05-02-98 : true when screen size changes
static boolean am_stopped = true;
static boolean am_minigen = false;
static UINT8 *am_buf = NULL;
static INT32 f_x, f_y; // location of window on screen (always zero for both)
static INT32 f_w, f_h; // size of window on screen (always the screen width and height respectively)
static boolean m_keydown[4]; // which window panning keys are being pressed down?
static mpoint_t m_paninc; // how far the window pans each tic (map coords)
static fixed_t mtof_zoommul; // how far the window zooms in each tic (map coords)
static fixed_t ftom_zoommul; // how far the window zooms in each tic (fb coords)
@@ -203,14 +197,15 @@ static fixed_t scale_mtof = (fixed_t)INITSCALEMTOF;
// used by FTOM to scale from frame-buffer-to-map coords (=1/scale_mtof)
static fixed_t scale_ftom;
static player_t *plr; // the player represented by an arrow
static player_t *plr = NULL; // the player represented by an arrow
static INT32 followplayer = true; // specifies whether to follow the player around
static boolean followplayer = true; // specifies whether to follow the player around
// function for drawing lines, depends on rendermode
typedef void (*AMDRAWFLINEFUNC) (const fline_t *fl, INT32 color);
static AMDRAWFLINEFUNC AM_drawFline;
static void AM_drawPixel(INT32 xx, INT32 yy, INT32 cc);
static void AM_drawFline_soft(const fline_t *fl, INT32 color);
static void AM_activateNewScale(void)
@@ -242,7 +237,7 @@ static inline void AM_restoreScaleAndLoc(void)
m_x = old_m_x;
m_y = old_m_y;
}
else
else if (plr && plr->mo)
{
m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2;
m_y = (plr->mo->y >> FRACTOMAPBITS) - m_h/2;
@@ -270,9 +265,6 @@ static void AM_findMinMaxBoundaries(void)
max_w = minimapinfo.map_w << MAPBITS;
max_h = minimapinfo.map_h << MAPBITS;
max_w = (max_x >>= FRACTOMAPBITS) - (min_x >>= FRACTOMAPBITS);
max_h = (max_y >>= FRACTOMAPBITS) - (min_y >>= FRACTOMAPBITS);
a = FixedDiv(f_w<<FRACBITS, max_w);
b = FixedDiv(f_h<<FRACBITS, max_h);
@@ -326,7 +318,8 @@ static void AM_initVariables(void)
break;
plr = &players[pnum];
if (plr != NULL && plr->mo != NULL)
if (plr && plr->mo)
{
m_x = (plr->mo->x >> FRACTOMAPBITS) - m_w/2;
m_y = (plr->mo->y >> FRACTOMAPBITS) - m_h/2;
@@ -340,22 +333,23 @@ static void AM_initVariables(void)
old_m_h = m_h;
}
//
// Called when the screen size changes.
//
static void AM_FrameBufferInit(void)
{
f_x = f_y = 0;
f_w = vid.width;
f_h = vid.height;
am_buf = vid.screens[0];
}
//
// should be called at the start of every level
// right now, i figure it out myself
//
static void AM_LevelInit(void)
{
f_x = f_y = 0;
f_w = vid.width;
f_h = vid.height;
AM_drawFline = AM_drawFline_soft;
#ifdef HWRENDER
if (rendermode == render_opengl)
AM_drawFline = HWR_drawAMline;
#endif
AM_findMinMaxBoundaries();
scale_mtof = FixedDiv(min_scale_mtof*10, 7*FRACUNIT);
if (scale_mtof > max_scale_mtof)
@@ -377,7 +371,7 @@ void AM_Stop(void)
*
* \sa AM_Stop
*/
static inline void AM_Start(void)
void AM_Start(void)
{
static INT32 lastlevel = -1;
@@ -386,8 +380,12 @@ static inline void AM_Start(void)
am_stopped = false;
if (lastlevel != gamemap || am_recalc) // screen size changed
{
AM_LevelInit();
lastlevel = gamemap;
AM_FrameBufferInit();
if (lastlevel != gamemap)
{
AM_LevelInit();
lastlevel = gamemap;
}
am_recalc = false;
}
AM_initVariables();
@@ -413,6 +411,28 @@ static void AM_maxOutWindowScale(void)
AM_activateNewScale();
}
//
// set window panning
//
static void AM_setWindowPanning(void)
{
// up and down
if (m_keydown[2]) // pan up
m_paninc.y = FTOM(F_PANINC);
else if (m_keydown[3]) // pan down
m_paninc.y = -FTOM(F_PANINC);
else
m_paninc.y = 0;
// left and right
if (m_keydown[0]) // pan right
m_paninc.x = FTOM(F_PANINC);
else if (m_keydown[1]) // pan left
m_paninc.x = -FTOM(F_PANINC);
else
m_paninc.x = 0;
}
/** Responds to user inputs in automap mode.
*
* \param ev Event to possibly respond to.
@@ -445,35 +465,49 @@ boolean AM_Responder(event_t *ev)
{
case AM_PANRIGHTKEY: // pan right
if (!followplayer)
m_paninc.x = FTOM(F_PANINC);
{
m_keydown[0] = true;
AM_setWindowPanning();
}
else
rc = false;
break;
case AM_PANLEFTKEY: // pan left
if (!followplayer)
m_paninc.x = -FTOM(F_PANINC);
{
m_keydown[1] = true;
AM_setWindowPanning();
}
else
rc = false;
break;
case AM_PANUPKEY: // pan up
if (!followplayer)
m_paninc.y = FTOM(F_PANINC);
{
m_keydown[2] = true;
AM_setWindowPanning();
}
else
rc = false;
break;
case AM_PANDOWNKEY: // pan down
if (!followplayer)
m_paninc.y = -FTOM(F_PANINC);
{
m_keydown[3] = true;
AM_setWindowPanning();
}
else
rc = false;
break;
case AM_ZOOMOUTKEY: // zoom out
mtof_zoommul = M_ZOOMOUT;
ftom_zoommul = M_ZOOMIN;
AM_setWindowPanning();
break;
case AM_ZOOMINKEY: // zoom in
mtof_zoommul = M_ZOOMIN;
ftom_zoommul = M_ZOOMOUT;
AM_setWindowPanning();
break;
case AM_TOGGLEKEY:
AM_Stop();
@@ -487,6 +521,7 @@ boolean AM_Responder(event_t *ev)
}
else
AM_restoreScaleAndLoc();
AM_setWindowPanning();
break;
case AM_FOLLOWKEY:
followplayer = !followplayer;
@@ -506,14 +541,32 @@ boolean AM_Responder(event_t *ev)
switch (ev->data1)
{
case AM_PANRIGHTKEY:
if (!followplayer)
{
m_keydown[0] = false;
AM_setWindowPanning();
}
break;
case AM_PANLEFTKEY:
if (!followplayer)
m_paninc.x = 0;
{
m_keydown[1] = false;
AM_setWindowPanning();
}
break;
case AM_PANUPKEY:
if (!followplayer)
{
m_keydown[2] = false;
AM_setWindowPanning();
}
break;
case AM_PANDOWNKEY:
if (!followplayer)
m_paninc.y = 0;
{
m_keydown[3] = false;
AM_setWindowPanning();
}
break;
case AM_ZOOMOUTKEY:
case AM_ZOOMINKEY:
@@ -545,6 +598,9 @@ static inline void AM_changeWindowScale(void)
static inline void AM_doFollowPlayer(void)
{
if (!plr || !plr->mo)
return;
if (f_oldloc.x != plr->mo->x || f_oldloc.y != plr->mo->y)
{
m_x = FTOM(MTOF(plr->mo->x >> FRACTOMAPBITS)) - m_w/2;
@@ -714,6 +770,16 @@ static boolean AM_clipMline(const mline_t *ml, fline_t *fl)
}
#undef DOOUTCODE
//
// Draws a pixel.
//
static void AM_drawPixel(INT32 xx, INT32 yy, INT32 cc)
{
if (xx < 0 || yy < 0 || xx >= f_w || yy >= f_h)
return; // off the screen
am_buf[(yy*f_w) + xx] = cc;
}
//
// Classic Bresenham w/ whatever optimizations needed for speed
//
@@ -735,8 +801,6 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
}
#endif
#define PUTDOT(xx,yy,cc) V_DrawFill(xx,yy,1,1,cc|V_NOSCALESTART);
dx = fl->b.x - fl->a.x;
ax = 2 * (dx < 0 ? -dx : dx);
sx = dx < 0 ? -1 : 1;
@@ -753,7 +817,7 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
d = ay - ax/2;
for (;;)
{
PUTDOT(x, y, color)
AM_drawPixel(x, y, color);
if (x == fl->b.x)
return;
if (d >= 0)
@@ -770,7 +834,7 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
d = ax - ay/2;
for (;;)
{
PUTDOT(x, y, color)
AM_drawPixel(x, y, color);
if (y == fl->b.y)
return;
if (d >= 0)
@@ -782,8 +846,6 @@ static void AM_drawFline_soft(const fline_t *fl, INT32 color)
d += ax;
}
}
#undef PUTDOT
}
//
@@ -805,17 +867,18 @@ static void AM_drawGrid(INT32 color)
fixed_t x, y;
fixed_t start, end;
mline_t ml;
fixed_t gridsize = (MAPBLOCKUNITS<<MAPBITS);
// Figure out start of vertical gridlines
start = m_x;
if ((start - bmaporgx) % (MAPBLOCKUNITS<<FRACBITS))
start += (MAPBLOCKUNITS<<FRACBITS) - ((start - bmaporgx) % (MAPBLOCKUNITS<<FRACBITS));
if ((start - (bmaporgx>>FRACTOMAPBITS)) % gridsize)
start += gridsize - ((start - (bmaporgx>>FRACTOMAPBITS)) % gridsize);
end = m_x + m_w;
// draw vertical gridlines
ml.a.y = m_y;
ml.b.y = m_y + m_h;
for (x = start; x < end; x += (MAPBLOCKUNITS<<FRACBITS))
for (x = start; x < end; x += gridsize)
{
ml.a.x = x;
ml.b.x = x;
@@ -824,14 +887,14 @@ static void AM_drawGrid(INT32 color)
// Figure out start of horizontal gridlines
start = m_y;
if ((start - bmaporgy) % (MAPBLOCKUNITS<<FRACBITS))
start += (MAPBLOCKUNITS<<FRACBITS) - ((start - bmaporgy) % (MAPBLOCKUNITS<<FRACBITS));
if ((start - (bmaporgy>>FRACTOMAPBITS)) % gridsize)
start += gridsize - ((start - (bmaporgy>>FRACTOMAPBITS)) % gridsize);
end = m_y + m_h;
// draw horizontal gridlines
ml.a.x = m_x;
ml.b.x = m_x + m_w;
for (y = start; y < end; y += (MAPBLOCKUNITS<<FRACBITS))
for (y = start; y < end; y += gridsize)
{
ml.a.y = y;
ml.b.y = y;
@@ -839,14 +902,118 @@ static void AM_drawGrid(INT32 color)
}
}
static INT32 GetDamage(INT32 special)
{
switch (special)
{
case 1: // Damage (Generic)
return 1;
case 6: // Death Pit (Camera Tilt)
return 6;
case 7: // Death Pit (No Camera Tilt)
return 7;
case 8: // Instant Kill
return 8;
default:
return 0;
}
}
static INT32 GetOffroad(INT32 special)
{
switch (special)
{
case 2: // Offroad (Weak)
return 2;
case 3: // Offroad
return 3;
case 4: // Offroad (Strong)
return 4;
default:
return 0;
}
}
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
end1 = (P_GetZAt(slope, lines[i].v1->x, lines[i].v1->y, ((normalheight + FRACUNIT/2) >> FRACBITS)) + FRACUNIT/2) >> FRACBITS; \
end2 = (P_GetZAt(slope, lines[i].v2->x, lines[i].v2->y, ((normalheight + FRACUNIT/2) >> FRACBITS)) + FRACUNIT/2) >> FRACBITS;
static ffloor_t *AM_CompareFOFs(size_t i, ffloor_t *rover, ffloor_t *secondarystore)
{
ffloor_t *secondaryrover = NULL;
for (; rover; rover = rover->next)
{
fixed_t rovt1, rovt2;
fixed_t rovb1, rovb2;
if (!(rover->flags & FF_EXISTS))
continue;
if (!(rover->flags & FF_BLOCKPLAYER))
continue;
SLOPEPARAMS(*rover->t_slope, rovt1, rovt2, *rover->topheight)
SLOPEPARAMS(*rover->b_slope, rovb1, rovb2, *rover->bottomheight)
for (secondaryrover = secondarystore; secondaryrover; secondaryrover = secondaryrover->next)
{
fixed_t sect1, sect2;
fixed_t secb1, secb2;
if (!(secondaryrover->flags & FF_EXISTS))
continue;
if (!(secondaryrover->flags & FF_BLOCKPLAYER))
continue;
if (secondaryrover->secnum == rover->secnum)
break;
SLOPEPARAMS(*secondaryrover->t_slope, sect1, sect2, *secondaryrover->topheight)
SLOPEPARAMS(*secondaryrover->b_slope, secb1, secb2, *secondaryrover->bottomheight)
if (rovt1 != sect1)
continue;
if (rovt2 != sect2)
continue;
if (rovb1 != secb1)
continue;
if (rovb2 != secb2)
continue;
// this is fucking horrible
INT32 damage1, damage2;
INT32 offroad1, offroad2;
INT32 special1, special2;
special1 = GETSECSPECIAL(sectors[rover->secnum].special, 1);
special2 = GETSECSPECIAL(sectors[secondaryrover->secnum].special, 1);
damage1 = GetDamage(special1);
damage2 = GetDamage(special2);
offroad1 = GetOffroad(special1);
offroad2 = GetOffroad(special2);
if (damage1 != damage2
//|| sectors[rover->secnum].friction != sectors[secondaryrover->secnum].friction
|| offroad1 != offroad2)
continue;
break;
}
if (secondaryrover == NULL)
break;
}
return rover;
}
//
// Determines visible lines, draws them.
// This is LineDef based, not LineSeg based.
//
static inline void AM_drawWalls(void)
static void AM_drawWalls(UINT8 pass)
{
size_t i;
static mline_t l;
const fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale)>>FRACBITS;
fixed_t frontf1,frontf2, frontc1, frontc2; // front floor/ceiling ends
fixed_t backf1 = 0, backf2 = 0, backc1 = 0, backc2 = 0; // back floor ceiling ends
@@ -856,74 +1023,142 @@ static inline void AM_drawWalls(void)
l.a.y = lines[i].v1->y >> FRACTOMAPBITS;
l.b.x = lines[i].v2->x >> FRACTOMAPBITS;
l.b.y = lines[i].v2->y >> FRACTOMAPBITS;
#define SLOPEPARAMS(slope, end1, end2, normalheight) \
if (slope) { \
end1 = P_GetZAt(slope, lines[i].v1->x, lines[i].v1->y); \
end2 = P_GetZAt(slope, lines[i].v2->x, lines[i].v2->y); \
} else \
end1 = end2 = normalheight;
SLOPEPARAMS(lines[i].frontsector->f_slope, frontf1, frontf2, lines[i].frontsector->floorheight)
SLOPEPARAMS(lines[i].frontsector->c_slope, frontc1, frontc2, lines[i].frontsector->ceilingheight)
if (lines[i].backsector) {
SLOPEPARAMS(lines[i].backsector->f_slope, backf1, backf2, lines[i].backsector->floorheight)
SLOPEPARAMS(lines[i].backsector->c_slope, backc1, backc2, lines[i].backsector->ceilingheight)
}
#undef SLOPEPARAMS
if (!lines[i].backsector) // 1-sided
{
if (lines[i].flags & ML_NOCLIMB)
AM_drawMline(&l, NOCLIMBWALLCOLORS);
else
if (!(pass & PASS_SOLID))
;
else if (frontf1 != frontc1 || frontf2 != frontc2 || lines[i].frontsector->f_slope)
{
AM_drawMline(&l, TSWALLCOLORS);
}
else if (!am_minigen)
{
AM_drawMline(&l, WALLCOLORS);
}
continue;
}
else if ((backf1 == backc1 && backf2 == backc2) // Back is thok barrier
SLOPEPARAMS(lines[i].backsector->f_slope, backf1, backf2, lines[i].backsector->floorheight)
SLOPEPARAMS(lines[i].backsector->c_slope, backc1, backc2, lines[i].backsector->ceilingheight)
if ((backf1 == backc1 && backf2 == backc2) // Back is thok barrier
|| (frontf1 == frontc1 && frontf2 == frontc2)) // Front is thok barrier
{
if (backf1 == backc1 && backf2 == backc2
&& frontf1 == frontc1 && frontf2 == frontc2) // BOTH are thok barriers
{
if (lines[i].flags & ML_NOCLIMB)
AM_drawMline(&l, NOCLIMBTSWALLCOLORS);
else
AM_drawMline(&l, TSWALLCOLORS);
if (!am_minigen && (pass & PASS_INTANGIBLE))
{
AM_drawMline(&l, GRIDCOLORS);
}
}
else
else if (pass & PASS_SOLID)
{
if (lines[i].flags & ML_NOCLIMB)
AM_drawMline(&l, NOCLIMBTHOKWALLCOLORS);
else
AM_drawMline(&l, THOKWALLCOLORS);
AM_drawMline(&l, TSWALLCOLORS);
}
}
else
{
if (lines[i].flags & ML_NOCLIMB) {
if (backf1 != frontf1 || backf2 != frontf2) {
AM_drawMline(&l, NOCLIMBFDWALLCOLORS); // floor level change
}
else if (backc1 != frontc1 || backc2 != frontc2) {
AM_drawMline(&l, NOCLIMBCDWALLCOLORS); // ceiling level change
if (lines[i].flags & ML_IMPASSIBLE) // (ML_IMPASSABLE|ML_BLOCKPLAYERS)
{
if (pass & PASS_SOLID)
AM_drawMline(&l, TSWALLCOLORS); // Completely solid course boundary
}
else if ((lines[i].flags & ML_EFFECT4) // ML_MIDSOLID
&& sides[lines->sidenum[0]].midtexture)
{
if (pass & PASS_SOLID)
AM_drawMline(&l, TSWALLCOLORS); // solid midtexture, likely a course boundary
}
if ((backf1 != frontf1 && abs(backf1 - frontf1) > maxstep)
|| (backf2 != frontf2 && abs(backf2 - frontf2) > maxstep))
{
if (pass & PASS_SOLID)
AM_drawMline(&l, TSWALLCOLORS); // floor-wall, likely a course boundary
}
else if (GETSECSPECIAL(lines[i].frontsector->special, 4) == 10 || GETSECSPECIAL(lines[i].backsector->special, 4) == 10)
{
if (pass & PASS_SOLID)
AM_drawMline(&l, TSFINISHLINE); // finish line
}
else if (backf1 != frontf1 || backf2 != frontf2)
{
if (pass & PASS_INTANGIBLE)
AM_drawMline(&l, FDWALLCOLORS); // floorlevel change
}
else if (backc1 != frontc1 || backc2 != frontc2)
{
if (!(pass & PASS_INTANGIBLE))
;
else if (abs(backc1 - frontc1) < maxstep
|| abs(backc2 - frontc2) < maxstep)
{
AM_drawMline(&l, CDWALLCOLORS); // ceilinglevel change
}
else
AM_drawMline(&l, NOCLIMBTSWALLCOLORS);
{
AM_drawMline(&l, GRIDCOLORS); // ceiling-wall, not likely to be a course boundary but flagged up just in case
}
}
else
{
if (backf1 != frontf1 || backf2 != frontf2) {
AM_drawMline(&l, FDWALLCOLORS); // floor level change
ffloor_t *rover = NULL;
if (lines[i].frontsector->ffloors || lines[i].backsector->ffloors)
{
if (lines[i].backsector->ffloors == NULL)
{
// Check frontside for one solid
for (rover = lines[i].frontsector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS))
continue;
if (!(rover->flags & FF_BLOCKPLAYER))
continue;
break;
}
}
else if (lines[i].frontsector->ffloors == NULL)
{
// Check backside for one solid
for (rover = lines[i].backsector->ffloors; rover; rover = rover->next)
{
if (!(rover->flags & FF_EXISTS))
continue;
if (!(rover->flags & FF_BLOCKPLAYER))
continue;
break;
}
}
else
{
// Check to see if any secnums exist in one but not the other.
rover = AM_CompareFOFs(i, lines[i].frontsector->ffloors, lines[i].backsector->ffloors);
if (rover == NULL)
rover = AM_CompareFOFs(i, lines[i].backsector->ffloors, lines[i].frontsector->ffloors);
}
}
else if (backc1 != frontc1 || backc2 != frontc2) {
AM_drawMline(&l, CDWALLCOLORS); // ceiling level change
if (rover != NULL)
{
if (pass & PASS_FOF)
AM_drawMline(&l, TSFOFINFO); // a FOF is here but we don't know how to distinguish them yet
}
else if (!am_minigen)
{
if (pass & PASS_INTANGIBLE)
AM_drawMline(&l, GRIDCOLORS); // likely low-relevance line
}
else
AM_drawMline(&l, TSWALLCOLORS);
}
}
}
}
#undef SLOPEPARAMS
//
// Rotation in 2D.
// Used to rotate player arrow line character.
@@ -994,18 +1229,11 @@ static inline void AM_drawPlayers(void)
player_t *p;
INT32 color = GREENS;
if (!multiplayer)
{
AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, plr->mo->angle, DWHITE, plr->mo->x, plr->mo->y);
return;
}
// multiplayer (how??)
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator)
continue;
if (!players[i].mo)
continue;
@@ -1013,7 +1241,7 @@ static inline void AM_drawPlayers(void)
if (p->skincolor > 0)
color = R_GetTranslationColormap(TC_DEFAULT, p->skincolor, GTC_CACHE)[GREENS + 8];
AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 0, p->mo->angle, color, p->mo->x, p->mo->y);
AM_drawLineCharacter(player_arrow, NUMPLYRLINES, 16<<FRACBITS, p->mo->angle, color, p->mo->x, p->mo->y);
}
}
@@ -1027,19 +1255,65 @@ static inline void AM_drawThings(UINT8 colors)
t = sectors[i].thinglist;
while (t)
{
AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16<<FRACBITS, t->angle, colors, t->x, t->y);
if (!t->player)
AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16<<FRACBITS, t->angle, colors, t->x, t->y);
t = t->snext;
}
}
}
/** Draws the crosshair, actually just a dot in software mode.
static inline void AM_drawSpecialThingsOnly(UINT8 colors)
{
size_t i;
for (i = 0; i < numsectors; i++)
{
mobj_t *t = NULL;
// this is fucking horrible
const INT32 special = GETSECSPECIAL(sectors[i].special, 1);
if (GetDamage(special) != 0
//|| sectors[i].friction < ORIG_FRICTION
|| GetOffroad(special) != 0)
continue;
t = sectors[i].thinglist;
while (t)
{
if (t->type == MT_RANDOMITEM
|| t->type == MT_STARPOST
|| (t->flags & MF_SPRING))
AM_drawLineCharacter(thintriangle_guy, NUMTHINTRIANGLEGUYLINES, 16<<FRACBITS, t->angle, colors, t->x, t->y);
t = t->snext;
}
}
}
/** Draws the crosshair.
*
* \param color Color for the crosshair.
*/
static inline void AM_drawCrosshair(UINT8 color)
{
V_DrawFill(f_w/2 + f_x, f_h/2 + f_y, 1, 1, color|V_NOSCALESTART);
const fixed_t scale = 4<<FRACBITS;
size_t i;
fline_t fl;
for (i = 0; i < NUMCROSSMARKLINES; i++)
{
fl.a.x = FixedMul(cross_mark[i].a.x, scale) >> FRACBITS;
fl.a.y = FixedMul(cross_mark[i].a.y, scale) >> FRACBITS;
fl.b.x = FixedMul(cross_mark[i].b.x, scale) >> FRACBITS;
fl.b.y = FixedMul(cross_mark[i].b.y, scale) >> FRACBITS;
fl.a.x += f_x + (f_w / 2);
fl.a.y += f_y + (f_h / 2);
fl.b.x += f_x + (f_w / 2);
fl.b.y += f_y + (f_h / 2);
AM_drawFline(&fl, color);
}
}
/** Draws the automap.
@@ -1049,11 +1323,81 @@ void AM_Drawer(void)
if (!automapactive)
return;
AM_drawFline = AM_drawFline_soft;
#ifdef HWRENDER
if (rendermode == render_opengl)
AM_drawFline = HWR_drawAMline;
#endif
AM_clearFB(BACKGROUND);
if (draw_grid) AM_drawGrid(GRIDCOLORS);
AM_drawWalls();
AM_drawPlayers();
AM_drawWalls(PASS_FOF|PASS_INTANGIBLE|PASS_SOLID);
AM_drawThings(THINGCOLORS);
AM_drawPlayers();
AM_drawCrosshair(XHAIRCOLORS);
if (!followplayer) AM_drawCrosshair(XHAIRCOLORS);
}
minigen_t *AM_MinimapGenerate(INT32 mul)
{
static minigen_t ret = {0};
if (automapactive)
return NULL;
am_minigen = true;
AM_drawFline = AM_drawFline_soft; // yes, even in GL
//AM_FrameBufferInit();
f_x = f_y = 0;
ret.w = f_w = minimapinfo.minimap_w * mul;
ret.h = f_h = minimapinfo.minimap_h * mul;
am_buf = ret.buf = NULL;
//AM_LevelInit();
AM_findMinMaxBoundaries();
scale_mtof = min_scale_mtof - (min_scale_mtof/20);
scale_ftom = FixedDiv(FRACUNIT, scale_mtof);
//AM_initVariables();
f_oldloc.x = INT32_MAX;
m_paninc.x = m_paninc.y = 0;
ftom_zoommul = FRACUNIT;
mtof_zoommul = FRACUNIT;
m_w = FTOM(f_w);
m_h = FTOM(f_h);
//AM_changeWindowLoc();
m_x = min_x - FixedMul(m_w, FRACUNIT/40);
m_y = min_y - FixedMul(m_h, FRACUNIT/40);
m_x2 = m_x + m_w;
m_y2 = m_y + m_h;
// for saving & restoring
old_m_x = m_x;
old_m_y = m_y;
old_m_w = m_w;
old_m_h = m_h;
am_buf = ret.buf = malloc((f_w*f_h));
if (ret.buf == NULL)
return NULL;
//AM_clearFB(BACKGROUND);
memset(am_buf, 0xff, (f_w*f_h));
AM_drawSpecialThingsOnly(BACKGROUND);
AM_drawWalls(PASS_FOF);
AM_drawWalls(PASS_INTANGIBLE);
AM_drawWalls(PASS_SOLID);
am_buf = NULL;
am_recalc = true;
am_minigen = false;
return &ret;
}
+17 -8
View File
@@ -1,8 +1,10 @@
// SONIC ROBO BLAST 2
// SONIC ROBO BLAST 2 KART
//-----------------------------------------------------------------------------
// Copyright (C) 1993-1996 by id Software, Inc.
// Copyright (C) 1998-2000 by DooM Legacy Team.
// Copyright (C) 1999-2018 by Sonic Team Junior.
// Copyright (C) 2024 by Vivian "toastergrl" Grannell.
// Copyright (C) 2024 by Kart Krew.
// Copyright (C) 2020 by Sonic Team Junior.
// Copyright (C) 2000 by DooM Legacy Team.
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
@@ -26,11 +28,6 @@ typedef struct
fpoint_t a, b;
} fline_t;
// Used by ST StatusBar stuff.
#define AM_MSGHEADER (('a'<<24)+('m'<<16))
#define AM_MSGENTERED (AM_MSGHEADER | ('e'<<8))
#define AM_MSGEXITED (AM_MSGHEADER | ('x'<<8))
extern boolean am_recalc; // true if screen size changes
extern boolean automapactive; // In AutoMap mode?
@@ -43,7 +40,19 @@ void AM_Ticker(void);
// Called by main loop, instead of view drawer if automap is active.
void AM_Drawer(void);
// Enables the automap.
void AM_Start(void);
// Called to force the automap to quit if the level is completed while it is up.
void AM_Stop(void);
typedef struct
{
INT32 w, h;
UINT8 *buf;
} minigen_t;
// Minimap generation
minigen_t *AM_MinimapGenerate(INT32 mul);
#endif
-4
View File
@@ -184,8 +184,6 @@ void I_OutputMsg(const char *fmt, ...)
void I_StartupMouse(void){}
void I_StartupMouse2(void){}
void I_StartupKeyboard(void){}
INT32 I_GetKey(void)
@@ -242,8 +240,6 @@ void I_GetJoystickEvents(void){}
void I_GetJoystick2Events(void){}
void I_GetMouseEvents(void){}
char *I_GetEnv(const char *name)
{
LOGW("I_GetEnv() called?!");
-1
View File
@@ -46,7 +46,6 @@ INT32 VID_SetMode(INT32 modenum)
vid.modenum = 0;
vid.width = 320;
vid.height = 240;
vid.bpp = 1;
vid.buffer = android_surface;
return 0;
}
+2 -5
View File
@@ -36,7 +36,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm
return;
// Lua can handle it!
if (LUAh_BotAI(sonic, tails, cmd))
if (LUA_HookBotAI(sonic, tails, cmd))
return;
if (tails->player->pflags & (PF_MACESPIN|PF_ITEMHANG))
@@ -118,11 +118,8 @@ void B_BuildTiccmd(player_t *player, ticcmd_t *cmd)
return;
}
// Bot AI isn't programmed in analog.
//CV_SetValue(&cv_analog2, false);
// Let Lua scripts build ticcmds
if (LUAh_BotTiccmd(player, cmd))
if (LUA_HookTiccmd(player, cmd, HOOK(BotTiccmd)))
return;
// We don't have any main character AI, sorry. D:
-55
View File
@@ -1,55 +0,0 @@
ifdef UNIXCOMMON
LUA_CFLAGS+=-DLUA_USE_POSIX
endif
ifdef LINUX
LUA_CFLAGS+=-DLUA_USE_POSIX
endif
ifdef GCC43
ifndef GCC44
WFLAGS+=-Wno-logical-op
endif
endif
OBJS:=$(OBJS) \
$(OBJDIR)/lapi.o \
$(OBJDIR)/lbaselib.o \
$(OBJDIR)/ldo.o \
$(OBJDIR)/ldblib.o \
$(OBJDIR)/lfunc.o \
$(OBJDIR)/linit.o \
$(OBJDIR)/liolib.o \
$(OBJDIR)/llex.o \
$(OBJDIR)/lmem.o \
$(OBJDIR)/lobject.o \
$(OBJDIR)/lstate.o \
$(OBJDIR)/lstrlib.o \
$(OBJDIR)/ltablib.o \
$(OBJDIR)/lundump.o \
$(OBJDIR)/lzio.o \
$(OBJDIR)/lauxlib.o \
$(OBJDIR)/lcode.o \
$(OBJDIR)/ldebug.o \
$(OBJDIR)/ldump.o \
$(OBJDIR)/lgc.o \
$(OBJDIR)/lopcodes.o \
$(OBJDIR)/lparser.o \
$(OBJDIR)/lstring.o \
$(OBJDIR)/ltable.o \
$(OBJDIR)/ltm.o \
$(OBJDIR)/lvm.o \
$(OBJDIR)/lua_script.o \
$(OBJDIR)/lua_baselib.o \
$(OBJDIR)/lua_blockmaplib.o \
$(OBJDIR)/lua_mathlib.o \
$(OBJDIR)/lua_hooklib.o \
$(OBJDIR)/lua_consolelib.o \
$(OBJDIR)/lua_infolib.o \
$(OBJDIR)/lua_mobjlib.o \
$(OBJDIR)/lua_playerlib.o \
$(OBJDIR)/lua_skinlib.o \
$(OBJDIR)/lua_thinkerlib.o \
$(OBJDIR)/lua_maplib.o \
$(OBJDIR)/lua_hudlib.o \
$(OBJDIR)/lua_hudlib_drawlist.o \
$(OBJDIR)/lua_udatalib.o \
$(OBJDIR)/lua_glib.o
+26
View File
@@ -0,0 +1,26 @@
lapi.c
lauxlib.c
lbaselib.c
ldblib.c
lcode.c
ldebug.c
ldo.c
ldump.c
lfunc.c
lgc.c
linit.c
liolib.c
llex.c
lmem.c
lobject.c
lopcodes.c
lparser.c
lstate.c
lstring.c
lstrlib.c
ltable.c
ltablib.c
ltm.c
lundump.c
lvm.c
lzio.c
+70 -5
View File
@@ -17,14 +17,27 @@
#include "lauxlib.h"
#include "lualib.h"
#include "../i_system.h"
#include "../doomdef.h"
#include "../d_main.h"
#include "../m_misc.h"
#define IO_INPUT 1
#define IO_OUTPUT 2
#define FILELIMIT 1024*1024 // Size limit for reading/writing files
static const char *const fnames[] = {"input", "output"};
static const char *whitelist[] = { // Allow scripters to write files of these types to SRB2's folder
".txt",
".sav2",
".cfg",
".png",
".bmp"
};
static int pushresult (lua_State *L, int i, const char *filename) {
@@ -146,12 +159,59 @@ static int io_tostring (lua_State *L) {
return 1;
}
static int StartsWith(const char *a, const char *b) // this is wolfs being lazy yet again
{
if(strncmp(a, b, strlen(b)) == 0) return 1;
return 0;
}
static int io_open (lua_State *L) {
const char *filename = luaL_checkstring(L, 1);
const char *mode = luaL_optstring(L, 2, "r");
FILE **pf = newfile(L);
*pf = fopen(filename, mode);
return (*pf == NULL) ? pushresult(L, 0, filename) : 1;
FILE **pf;
const char *filename = luaL_checkstring(L, 1);
int pass = 0;
size_t i;
int length = strlen(filename);
char *splitter, *forward, *backward;
char *destFilename;
const char *mode = luaL_optstring(L, 2, "r");
for (i = 0; i < (sizeof (whitelist) / sizeof(const char *)); i++)
{
if (!stricmp(&filename[length - strlen(whitelist[i])], whitelist[i]))
{
pass = 1;
break;
}
}
if (strstr(filename, "..") || strchr(filename, ':') || StartsWith(filename, "\\")
|| StartsWith(filename, "/") || !pass)
{
luaL_error(L,"access denied to %s", filename);
return pushresult(L,0,filename);
}
destFilename = va("%s"PATHSEP"luafiles"PATHSEP"%s", srb2home, filename);
// Make directories as needed
splitter = destFilename;
forward = strchr(splitter, '/');
backward = strchr(splitter, '\\');
while ((splitter = (forward && backward) ? min(forward, backward) : (forward ?: backward)))
{
*splitter = 0;
I_mkdir(destFilename, 0755);
*splitter = '/';
splitter++;
forward = strchr(splitter, '/');
backward = strchr(splitter, '\\');
}
pf = newfile(L);
*pf = fopen(destFilename, mode);
return (*pf == NULL) ? pushresult(L, 0, filename) : 1;
}
@@ -394,6 +454,11 @@ static int g_write (lua_State *L, FILE *f, int arg) {
else {
size_t l;
const char *s = luaL_checklstring(L, arg, &l);
if (ftell(f) + l > FILELIMIT)
{
luaL_error(L,"write limit bypassed in file. Changes have been discarded.");
break;
}
status = status && (fwrite(s, sizeof(char), l, f) == l);
}
}
-9
View File
@@ -1,9 +0,0 @@
luajit
luajit.h
luajit_relver.txt
lj_bcdef.h
lj_ffdef.h
lj_libdef.h
lj_recdef.h
lj_folddef.h
lj_vm.[sS]
-406
View File
@@ -1,406 +0,0 @@
##############################################################################
# LuaJIT Makefile. Requires GNU Make.
#
# Please read doc/install.html before changing any variables!
#
# Suitable for POSIX platforms (Linux, *BSD, OSX etc.).
# Also works with MinGW and Cygwin on Windows.
# Please check msvcbuild.bat for building with MSVC on Windows.
#
# Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
##############################################################################
# this is a very dumbed down version of the LuaJIT makefile.
# to get the original makefile, visit
# https://github.com/GenericHeroGuy/bluajit
XCFLAGS=
XCFLAGS+= -DLUAJIT_DISABLE_FFI
#XCFLAGS+= -DLUAJIT_ENABLE_LUA52COMPAT
#XCFLAGS+= -DLUAJIT_DISABLE_JIT
#XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
#XCFLAGS+= -DLUAJIT_USE_VALGRIND
#XCFLAGS+= -DLUAJIT_USE_GDBJIT
#XCFLAGS+= -DLUA_USE_APICHECK
#XCFLAGS+= -DLUA_USE_ASSERT
XCFLAGS+= -DLUAJIT_DISABLE_BYTECODE
# load standard libraries in debug mode, so jit.dump etc works
ifndef DEBUGMODE
XCFLAGS+= -DLUAJIT_SRB2LIB -DLUAJIT_DISABLE_BUFFER
endif
# additional functions
#XCFLAGS+= -DLUAJIT_SRB2LIB_OS
XCFLAGS+= -DLUAJIT_SRB2LIB_DEBUG
XCFLAGS+= -DLUAJIT_SRB2LIB_IO
# don't touch these unless you wanna have a bad time
XCFLAGS+= -DLUAJIT_NUMMODE=2
XCFLAGS+= -DLUAJIT_INTONLY
# needed for the headers
OPTS+=-DLUAJIT_INTONLY
ifdef MINGW
TARGET_SYS= Windows
HOST_MSYS= mingw
endif
ifeq (Windows,$(findstring Windows,$(OS))$(MSYSTEM)$(TERM))
HOST_SYS= Windows
else
HOST_SYS:= $(shell uname -s)
ifneq (,$(findstring MINGW,$(HOST_SYS)))
HOST_SYS= Windows
HOST_MSYS= mingw
endif
ifneq (,$(findstring MSYS,$(HOST_SYS)))
HOST_SYS= Windows
HOST_MSYS= mingw
endif
ifneq (,$(findstring CYGWIN,$(HOST_SYS)))
HOST_SYS= Windows
HOST_MSYS= cygwin
endif
endif
ASOPTIONS= $(CCOPT) $(XCFLAGS) $(CFLAGS)
CCOPTIONS= $(ASOPTIONS)
HOST_CC= $(CC)
HOST_RM?= rm -f
HOST_XCFLAGS= -Ibluajit
HOST_XLIBS=
HOST_ACFLAGS= $(XCFLAGS) $(HOST_XCFLAGS) $(TARGET_ARCH)
TARGET_CC= $(CROSS)$(CC)
TARGET_LFSFLAGS= -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
TARGET_XCFLAGS= $(TARGET_LFSFLAGS) -U_FORTIFY_SOURCE
TARGET_XLIBS= -lm
TARGET_ACFLAGS= $(CCOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS)
TARGET_ASFLAGS= $(ASOPTIONS) $(TARGET_XCFLAGS) $(TARGET_FLAGS)
TARGET_ACFLAGS+= $(LUA_CFLAGS)
TARGET_TESTARCH:=$(shell $(TARGET_CC) $(TARGET_ACFLAGS) -E bluajit/lj_arch.h -dM)
ifneq (,$(findstring LJ_TARGET_X64 ,$(TARGET_TESTARCH)))
TARGET_LJARCH= x64
else
ifneq (,$(findstring LJ_TARGET_X86 ,$(TARGET_TESTARCH)))
TARGET_LJARCH= x86
else
ifneq (,$(findstring LJ_TARGET_ARM ,$(TARGET_TESTARCH)))
TARGET_LJARCH= arm
else
ifneq (,$(findstring LJ_TARGET_ARM64 ,$(TARGET_TESTARCH)))
ifneq (,$(findstring __AARCH64EB__ ,$(TARGET_TESTARCH)))
TARGET_ARCH= -D__AARCH64EB__=1
endif
TARGET_LJARCH= arm64
else
ifneq (,$(findstring LJ_TARGET_PPC ,$(TARGET_TESTARCH)))
ifneq (,$(findstring LJ_LE 1,$(TARGET_TESTARCH)))
TARGET_ARCH= -DLJ_ARCH_ENDIAN=LUAJIT_LE
else
TARGET_ARCH= -DLJ_ARCH_ENDIAN=LUAJIT_BE
endif
TARGET_LJARCH= ppc
else
ifneq (,$(findstring LJ_TARGET_MIPS ,$(TARGET_TESTARCH)))
ifneq (,$(findstring MIPSEL ,$(TARGET_TESTARCH)))
TARGET_ARCH= -D__MIPSEL__=1
endif
ifneq (,$(findstring LJ_TARGET_MIPS64 ,$(TARGET_TESTARCH)))
TARGET_LJARCH= mips64
else
TARGET_LJARCH= mips
endif
else
$(error Unsupported target architecture)
endif
endif
endif
endif
endif
endif
ifneq (,$(findstring LJ_TARGET_PS3 1,$(TARGET_TESTARCH)))
TARGET_SYS= PS3
TARGET_ARCH+= -D__CELLOS_LV2__
TARGET_XCFLAGS+= -DLUAJIT_USE_SYSMALLOC
TARGET_XLIBS+= -lpthread
endif
TARGET_ARCH+= $(patsubst %,-DLUAJIT_TARGET=LUAJIT_ARCH_%,$(TARGET_LJARCH))
ifneq (,$(PREFIX))
ifneq (/usr/local,$(PREFIX))
TARGET_XCFLAGS+= -DLUA_ROOT=\"$(PREFIX)\"
endif
endif
ifneq (,$(MULTILIB))
TARGET_XCFLAGS+= -DLUA_MULTILIB=\"$(MULTILIB)\"
endif
ifneq (,$(LMULTILIB))
TARGET_XCFLAGS+= -DLUA_LMULTILIB=\"$(LMULTILIB)\"
endif
ifneq (,$(INSTALL_LJLIBD))
TARGET_XCFLAGS+= -DLUA_LJDIR=\"$(INSTALL_LJLIBD)\"
endif
##############################################################################
# Target system detection.
##############################################################################
TARGET_SYS?= $(HOST_SYS)
ifeq (,$(shell $(TARGET_CC) -o /dev/null -c -x c /dev/null -fno-stack-protector 2>/dev/null || echo 1))
TARGET_XCFLAGS+= -fno-stack-protector
endif
ifeq (Darwin,$(TARGET_SYS))
ifeq (,$(MACOSX_DEPLOYMENT_TARGET))
$(error missing: export MACOSX_DEPLOYMENT_TARGET=XX.YY)
endif
TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL
else
ifeq (iOS,$(TARGET_SYS))
ifeq (arm64,$(TARGET_LJARCH))
TARGET_XCFLAGS+= -fno-omit-frame-pointer
endif
else
ifeq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH)))
# Find out whether the target toolchain always generates unwind tables.
TARGET_TESTUNWIND=$(shell exec 2>/dev/null; echo 'extern void b(void);int a(void){b();return 0;}' | $(TARGET_CC) -c -x c - -o tmpunwind.o && { grep -qa -e eh_frame -e __unwind_info tmpunwind.o || grep -qU -e eh_frame -e __unwind_info tmpunwind.o; } && echo E; rm -f tmpunwind.o)
ifneq (,$(findstring E,$(TARGET_TESTUNWIND)))
TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL
endif
endif
ifeq (Linux,$(TARGET_SYS))
TARGET_XLIBS+= -ldl
endif
ifeq (GNU/kFreeBSD,$(TARGET_SYS))
TARGET_XLIBS+= -ldl
endif
endif
endif
ifneq ($(HOST_SYS),$(TARGET_SYS))
ifeq (Windows,$(TARGET_SYS))
HOST_XCFLAGS+= -malign-double -DLUAJIT_OS=LUAJIT_OS_WINDOWS
else
ifeq (Linux,$(TARGET_SYS))
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_LINUX
else
ifeq (Darwin,$(TARGET_SYS))
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX
else
ifeq (iOS,$(TARGET_SYS))
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OSX -DTARGET_OS_IPHONE=1
else
HOST_XCFLAGS+= -DLUAJIT_OS=LUAJIT_OS_OTHER
endif
endif
endif
endif
endif
##############################################################################
# Files and pathnames.
##############################################################################
MINILUA_O= $(OBJDIR)/minilua.o
MINILUA_LIBS= -lm
MINILUA_T= $(OBJDIR)/minilua
MINILUA_X= $(MINILUA_T)
MINILUA_DEP=
HOST_LUA= $(MINILUA_X)
MINILUA_DEP= $(MINILUA_T)
DASM_DIR= bluajit/dynasm
DASM= $(HOST_LUA) $(DASM_DIR)/dynasm.lua
DASM_XFLAGS=
DASM_AFLAGS=
DASM_ARCH= $(TARGET_LJARCH)
ifneq (,$(findstring LJ_LE 1,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D ENDIAN_LE
else
DASM_AFLAGS+= -D ENDIAN_BE
endif
ifneq (,$(findstring LJ_ARCH_BITS 64,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D P64
endif
ifneq (,$(findstring LJ_HASJIT 1,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D JIT
endif
ifneq (,$(findstring LJ_HASFFI 1,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D FFI
endif
ifneq (,$(findstring LJ_DUALNUM 1,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D DUALNUM
endif
ifneq (,$(findstring LJ_INTONLY 1,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D INTONLY
endif
ifneq (,$(findstring LJ_ARCH_HASFPU 1,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D FPU
TARGET_ARCH+= -DLJ_ARCH_HASFPU=1
else
TARGET_ARCH+= -DLJ_ARCH_HASFPU=0
endif
ifeq (,$(findstring LJ_ABI_SOFTFP 1,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D HFABI
TARGET_ARCH+= -DLJ_ABI_SOFTFP=0
else
TARGET_ARCH+= -DLJ_ABI_SOFTFP=1
endif
ifneq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D NO_UNWIND
TARGET_ARCH+= -DLUAJIT_NO_UNWIND
endif
ifneq (,$(findstring LJ_ABI_PAUTH 1,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D PAUTH
TARGET_ARCH+= -DLJ_ABI_PAUTH=1
endif
DASM_AFLAGS+= -D VER=$(subst LJ_ARCH_VERSION_,,$(filter LJ_ARCH_VERSION_%,$(subst LJ_ARCH_VERSION ,LJ_ARCH_VERSION_,$(TARGET_TESTARCH))))
ifeq (Windows,$(TARGET_SYS))
DASM_AFLAGS+= -D WIN
endif
ifeq (x64,$(TARGET_LJARCH))
ifeq (,$(findstring LJ_FR2 1,$(TARGET_TESTARCH)))
DASM_ARCH= x86
endif
else
ifeq (arm,$(TARGET_LJARCH))
ifeq (iOS,$(TARGET_SYS))
DASM_AFLAGS+= -D IOS
endif
else
ifneq (,$(findstring LJ_TARGET_MIPSR6 ,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D MIPSR6
endif
ifeq (ppc,$(TARGET_LJARCH))
ifneq (,$(findstring LJ_ARCH_SQRT 1,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D SQRT
endif
ifneq (,$(findstring LJ_ARCH_ROUND 1,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D ROUND
endif
ifneq (,$(findstring LJ_ARCH_PPC32ON64 1,$(TARGET_TESTARCH)))
DASM_AFLAGS+= -D GPR64
endif
ifeq (PS3,$(TARGET_SYS))
DASM_AFLAGS+= -D PPE -D TOC
endif
endif
endif
endif
DASM_FLAGS= $(DASM_XFLAGS) $(DASM_AFLAGS)
DASM_DASC= bluajit/vm_$(DASM_ARCH).dasc
GIT= git
ifeq (Windows,$(HOST_SYS)$(HOST_MSYS))
GIT_RELVER= if exist ..\.git ( $(GIT) show -s --format=%%ct >bluajit/luajit_relver.txt ) else ( type ..\.relver >bluajit/luajit_relver.txt )
else
GIT_RELVER= [ -e ../.git ] && $(GIT) show -s --format=%ct >bluajit/luajit_relver.txt 2>/dev/null || cat ../.relver >bluajit/luajit_relver.txt 2>/dev/null || :
endif
GIT_DEP= $(wildcard ../.git/HEAD ../.git/refs/heads/*)
BUILDVM_O= $(OBJDIR)/buildvm.o $(OBJDIR)/buildvm_asm.o $(OBJDIR)/buildvm_peobj.o \
$(OBJDIR)/buildvm_lib.o $(OBJDIR)/buildvm_fold.o
BUILDVM_T= $(OBJDIR)/buildvm
BUILDVM_X= $(BUILDVM_T)
HOST_O= $(MINILUA_O) $(BUILDVM_O)
HOST_T= $(MINILUA_T) $(BUILDVM_T)
LJVM_S= $(OBJDIR)/lj_vm.S
LJVM_O= $(OBJDIR)/lj_vm.o
LJVM_BOUT= $(LJVM_S)
LJVM_MODE= elfasm
LJLIB_O= lib_base.o lib_string.o lib_table.o lib_io.o lib_jit.o
ifeq (,$(filter -DLUAJIT_SRB2LIB,$(XCFLAGS)))
LJLIB_O+= lib_math.o lib_bit.o lib_os.o lib_package.o lib_debug.o lib_ffi.o lib_buffer.o
else
ifneq (,$(filter -DLUAJIT_SRB2LIB_OS,$(XCFLAGS)))
LJLIB_O+= lib_os.o
endif
ifneq (,$(filter -DLUAJIT_SRB2LIB_DEBUG,$(XCFLAGS)))
LJLIB_O+= lib_debug.o
endif
endif
LJLIB_C= $(addprefix bluajit/,$(LJLIB_O:.o=.c))
LJCORE_O= lj_assert.o lj_gc.o lj_err.o lj_char.o lj_bc.o lj_obj.o lj_buf.o \
lj_str.o lj_tab.o lj_func.o lj_udata.o lj_meta.o lj_debug.o \
lj_prng.o lj_state.o lj_dispatch.o lj_vmevent.o lj_vmmath.o \
lj_strscan.o lj_strfmt.o lj_strfmt_num.o lj_serialize.o \
lj_api.o lj_profile.o \
lj_lex.o lj_parse.o lj_bcread.o lj_bcwrite.o lj_load.o \
lj_ir.o lj_opt_mem.o lj_opt_fold.o lj_opt_narrow.o \
lj_opt_dce.o lj_opt_loop.o lj_opt_split.o lj_opt_sink.o \
lj_mcode.o lj_snap.o lj_record.o lj_crecord.o lj_ffrecord.o \
lj_asm.o lj_trace.o lj_gdbjit.o \
lj_ctype.o lj_cdata.o lj_cconv.o lj_ccall.o lj_ccallback.o \
lj_carith.o lj_clib.o lj_cparse.o \
lj_lib.o lj_alloc.o lib_aux.o \
$(LJLIB_O) lib_init.o
LJCORE_O:= $(addprefix $(OBJDIR)/,$(LJCORE_O))
LJVMCORE_O= $(LJVM_O) $(LJCORE_O)
LIB_VMDEF= bluajit/jit/vmdef.lua
LIB_VMDEFP= $(LIB_VMDEF)
ALL_T= $(HOST_T)
ALL_HDRGEN:= lj_bcdef.h lj_ffdef.h lj_libdef.h lj_recdef.h lj_folddef.h \
host/buildvm_arch.h luajit.h
ALL_HDRGEN:= $(addprefix bluajit/,$(ALL_HDRGEN))
ALL_GEN= $(LJVM_S) $(ALL_HDRGEN) bluajit/luajit_relver.txt $(LIB_VMDEFP)
##############################################################################
# Build mode handling.
##############################################################################
ifeq (Windows,$(TARGET_SYS))
LJVM_MODE= peobj
LJVM_BOUT= $(LJVM_O)
endif
ifeq (Darwin,$(TARGET_SYS))
LJVM_MODE= machasm
endif
ifeq (iOS,$(TARGET_SYS))
LJVM_MODE= machasm
endif
ifeq (Windows,$(TARGET_SYS))
MINILUA_T= $(OBJDIR)/minilua.exe
BUILDVM_T= $(OBJDIR)/buildvm.exe
ifeq (,$(HOST_MSYS))
MINILUA_X= $(OBJDIR)\minilua
BUILDVM_X= $(OBJDIR)\buildvm
HOST_RM= del
endif
endif
OBJS:=$(OBJS) \
$(LJVMCORE_O) \
$(OBJDIR)/lua_script.o \
$(OBJDIR)/lua_baselib.o \
$(OBJDIR)/lua_blockmaplib.o \
$(OBJDIR)/lua_mathlib.o \
$(OBJDIR)/lua_hooklib.o \
$(OBJDIR)/lua_consolelib.o \
$(OBJDIR)/lua_infolib.o \
$(OBJDIR)/lua_mobjlib.o \
$(OBJDIR)/lua_playerlib.o \
$(OBJDIR)/lua_skinlib.o \
$(OBJDIR)/lua_thinkerlib.o \
$(OBJDIR)/lua_maplib.o \
$(OBJDIR)/lua_hudlib.o \
$(OBJDIR)/lua_hudlib_drawlist.o \
$(OBJDIR)/lua_udatalib.o \
$(OBJDIR)/lua_glib.o
-63
View File
@@ -1,63 +0,0 @@
Q= @
E= @true
#Q=
#E= @:
$(MINILUA_T): $(MINILUA_O)
$(E) "HOSTLINK $@"
$(HOST_CC) -o $@ $(MINILUA_O) $(MINILUA_LIBS)
bluajit/luajit.h: $(MINILUA_DEP) $(GIT_DEP) bluajit/luajit_rolling.h
$(E) "VERSION $@"
$(Q)$(GIT_RELVER)
$(Q)cd bluajit && ../$(HOST_LUA) host/genversion.lua
bluajit/host/buildvm_arch.h: $(DASM_DASC) $(MINILUA_DEP) bluajit/lj_arch.h bluajit/lua.h bluajit/luaconf.h
$(E) "DYNASM $@"
$(Q)$(DASM) $(DASM_FLAGS) -o $@ $(DASM_DASC)
$(OBJDIR)/buildvm.o: $(DASM_DIR)/dasm_*.h
$(BUILDVM_T): $(BUILDVM_O)
$(E) "HOSTLINK $@"
$(HOST_CC) -o $@ $(BUILDVM_O)
$(LJVM_BOUT): $(BUILDVM_T)
$(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m $(LJVM_MODE) -o $@
bluajit/lj_bcdef.h: $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m bcdef -o $@ $(LJLIB_C)
bluajit/lj_ffdef.h: $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m ffdef -o $@ $(LJLIB_C)
bluajit/lj_libdef.h: $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m libdef -o $@ $(LJLIB_C)
bluajit/lj_recdef.h: $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m recdef -o $@ $(LJLIB_C)
$(LIB_VMDEF): $(BUILDVM_T) $(LJLIB_C)
$(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m vmdef -o $(LIB_VMDEFP) $(LJLIB_C)
bluajit/lj_folddef.h: $(BUILDVM_T) bluajit/lj_opt_fold.c
$(E) "BUILDVM $@"
$(Q)$(BUILDVM_X) -m folddef -o $@ bluajit/lj_opt_fold.c
$(OBJDIR)/%.o: bluajit/%.c
$(E) "CC $@"
$(TARGET_CC) $(TARGET_ACFLAGS) -c -o $@ $<
$(OBJDIR)/%.o: $(OBJDIR)/lj_vm.S
$(E) "ASM $@"
$(TARGET_CC) $(TARGET_ASFLAGS) -c -o $@ $<
$(HOST_O): $(OBJDIR)/%.o: bluajit/host/%.c
$(E) "HOSTCC $@"
$(HOST_CC) $(HOST_ACFLAGS) -c -o $@ $<
-456
View File
@@ -1,456 +0,0 @@
/*
** DynASM ARM encoding engine.
** Copyright (C) 2005-2023 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice.
*/
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define DASM_ARCH "arm"
#ifndef DASM_EXTERN
#define DASM_EXTERN(a,b,c,d) 0
#endif
/* Action definitions. */
enum {
DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT,
/* The following actions need a buffer position. */
DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG,
/* The following actions also have an argument. */
DASM_REL_PC, DASM_LABEL_PC,
DASM_IMM, DASM_IMM12, DASM_IMM16, DASM_IMML8, DASM_IMML12, DASM_IMMV8,
DASM__MAX
};
/* Maximum number of section buffer positions for a single dasm_put() call. */
#define DASM_MAXSECPOS 25
/* DynASM encoder status codes. Action list offset or number are or'ed in. */
#define DASM_S_OK 0x00000000
#define DASM_S_NOMEM 0x01000000
#define DASM_S_PHASE 0x02000000
#define DASM_S_MATCH_SEC 0x03000000
#define DASM_S_RANGE_I 0x11000000
#define DASM_S_RANGE_SEC 0x12000000
#define DASM_S_RANGE_LG 0x13000000
#define DASM_S_RANGE_PC 0x14000000
#define DASM_S_RANGE_REL 0x15000000
#define DASM_S_UNDEF_LG 0x21000000
#define DASM_S_UNDEF_PC 0x22000000
/* Macros to convert positions (8 bit section + 24 bit index). */
#define DASM_POS2IDX(pos) ((pos)&0x00ffffff)
#define DASM_POS2BIAS(pos) ((pos)&0xff000000)
#define DASM_SEC2POS(sec) ((sec)<<24)
#define DASM_POS2SEC(pos) ((pos)>>24)
#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos))
/* Action list type. */
typedef const unsigned int *dasm_ActList;
/* Per-section structure. */
typedef struct dasm_Section {
int *rbuf; /* Biased buffer pointer (negative section bias). */
int *buf; /* True buffer pointer. */
size_t bsize; /* Buffer size in bytes. */
int pos; /* Biased buffer position. */
int epos; /* End of biased buffer position - max single put. */
int ofs; /* Byte offset into section. */
} dasm_Section;
/* Core structure holding the DynASM encoding state. */
struct dasm_State {
size_t psize; /* Allocated size of this structure. */
dasm_ActList actionlist; /* Current actionlist pointer. */
int *lglabels; /* Local/global chain/pos ptrs. */
size_t lgsize;
int *pclabels; /* PC label chains/pos ptrs. */
size_t pcsize;
void **globals; /* Array of globals. */
dasm_Section *section; /* Pointer to active section. */
size_t codesize; /* Total size of all code sections. */
int maxsection; /* 0 <= sectionidx < maxsection. */
int status; /* Status code. */
dasm_Section sections[1]; /* All sections. Alloc-extended. */
};
/* The size of the core structure depends on the max. number of sections. */
#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section))
/* Initialize DynASM state. */
void dasm_init(Dst_DECL, int maxsection)
{
dasm_State *D;
size_t psz = 0;
Dst_REF = NULL;
DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection));
D = Dst_REF;
D->psize = psz;
D->lglabels = NULL;
D->lgsize = 0;
D->pclabels = NULL;
D->pcsize = 0;
D->globals = NULL;
D->maxsection = maxsection;
memset((void *)D->sections, 0, maxsection * sizeof(dasm_Section));
}
/* Free DynASM state. */
void dasm_free(Dst_DECL)
{
dasm_State *D = Dst_REF;
int i;
for (i = 0; i < D->maxsection; i++)
if (D->sections[i].buf)
DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize);
if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize);
if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize);
DASM_M_FREE(Dst, D, D->psize);
}
/* Setup global label array. Must be called before dasm_setup(). */
void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl)
{
dasm_State *D = Dst_REF;
D->globals = gl;
DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int));
}
/* Grow PC label array. Can be called after dasm_setup(), too. */
void dasm_growpc(Dst_DECL, unsigned int maxpc)
{
dasm_State *D = Dst_REF;
size_t osz = D->pcsize;
DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int));
memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz);
}
/* Setup encoder. */
void dasm_setup(Dst_DECL, const void *actionlist)
{
dasm_State *D = Dst_REF;
int i;
D->actionlist = (dasm_ActList)actionlist;
D->status = DASM_S_OK;
D->section = &D->sections[0];
memset((void *)D->lglabels, 0, D->lgsize);
if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize);
for (i = 0; i < D->maxsection; i++) {
D->sections[i].pos = DASM_SEC2POS(i);
D->sections[i].rbuf = D->sections[i].buf - D->sections[i].pos;
D->sections[i].ofs = 0;
}
}
#ifdef DASM_CHECKS
#define CK(x, st) \
do { if (!(x)) { \
D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0)
#define CKPL(kind, st) \
do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \
D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0)
#else
#define CK(x, st) ((void)0)
#define CKPL(kind, st) ((void)0)
#endif
static int dasm_imm12(unsigned int n)
{
int i;
for (i = 0; i < 16; i++, n = (n << 2) | (n >> 30))
if (n <= 255) return (int)(n + (i << 8));
return -1;
}
/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */
void dasm_put(Dst_DECL, int start, ...)
{
va_list ap;
dasm_State *D = Dst_REF;
dasm_ActList p = D->actionlist + start;
dasm_Section *sec = D->section;
int pos = sec->pos, ofs = sec->ofs;
int *b;
if (pos >= sec->epos) {
DASM_M_GROW(Dst, int, sec->buf, sec->bsize,
sec->bsize + 2*DASM_MAXSECPOS*sizeof(int));
sec->rbuf = sec->buf - DASM_POS2BIAS(pos);
sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos);
}
b = sec->rbuf;
b[pos++] = start;
va_start(ap, start);
while (1) {
unsigned int ins = *p++;
unsigned int action = (ins >> 16);
if (action >= DASM__MAX) {
ofs += 4;
} else {
int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0;
switch (action) {
case DASM_STOP: goto stop;
case DASM_SECTION:
n = (ins & 255); CK(n < D->maxsection, RANGE_SEC);
D->section = &D->sections[n]; goto stop;
case DASM_ESC: p++; ofs += 4; break;
case DASM_REL_EXT: break;
case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break;
case DASM_REL_LG:
n = (ins & 2047) - 10; pl = D->lglabels + n;
/* Bkwd rel or global. */
if (n >= 0) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; }
pl += 10; n = *pl;
if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */
goto linkrel;
case DASM_REL_PC:
pl = D->pclabels + n; CKPL(pc, PC);
putrel:
n = *pl;
if (n < 0) { /* Label exists. Get label pos and store it. */
b[pos] = -n;
} else {
linkrel:
b[pos] = n; /* Else link to rel chain, anchored at label. */
*pl = pos;
}
pos++;
break;
case DASM_LABEL_LG:
pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel;
case DASM_LABEL_PC:
pl = D->pclabels + n; CKPL(pc, PC);
putlabel:
n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */
while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos;
}
*pl = -pos; /* Label exists now. */
b[pos++] = ofs; /* Store pass1 offset estimate. */
break;
case DASM_IMM:
case DASM_IMM16:
#ifdef DASM_CHECKS
CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I);
if ((ins & 0x8000))
CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I);
else
CK((n>>((ins>>5)&31)) == 0, RANGE_I);
#endif
b[pos++] = n;
break;
case DASM_IMMV8:
CK((n & 3) == 0, RANGE_I);
n >>= 2;
/* fallthrough */
case DASM_IMML8:
case DASM_IMML12:
CK(n >= 0 ? ((n>>((ins>>5)&31)) == 0) :
(((-n)>>((ins>>5)&31)) == 0), RANGE_I);
b[pos++] = n;
break;
case DASM_IMM12:
CK(dasm_imm12((unsigned int)n) != -1, RANGE_I);
b[pos++] = n;
break;
}
}
}
stop:
va_end(ap);
sec->pos = pos;
sec->ofs = ofs;
}
#undef CK
/* Pass 2: Link sections, shrink aligns, fix label offsets. */
int dasm_link(Dst_DECL, size_t *szp)
{
dasm_State *D = Dst_REF;
int secnum;
int ofs = 0;
#ifdef DASM_CHECKS
*szp = 0;
if (D->status != DASM_S_OK) return D->status;
{
int pc;
for (pc = 0; pc*sizeof(int) < D->pcsize; pc++)
if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc;
}
#endif
{ /* Handle globals not defined in this translation unit. */
int idx;
for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) {
int n = D->lglabels[idx];
/* Undefined label: Collapse rel chain and replace with marker (< 0). */
while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; }
}
}
/* Combine all code sections. No support for data sections (yet). */
for (secnum = 0; secnum < D->maxsection; secnum++) {
dasm_Section *sec = D->sections + secnum;
int *b = sec->rbuf;
int pos = DASM_SEC2POS(secnum);
int lastpos = sec->pos;
while (pos != lastpos) {
dasm_ActList p = D->actionlist + b[pos++];
while (1) {
unsigned int ins = *p++;
unsigned int action = (ins >> 16);
switch (action) {
case DASM_STOP: case DASM_SECTION: goto stop;
case DASM_ESC: p++; break;
case DASM_REL_EXT: break;
case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break;
case DASM_REL_LG: case DASM_REL_PC: pos++; break;
case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break;
case DASM_IMM: case DASM_IMM12: case DASM_IMM16:
case DASM_IMML8: case DASM_IMML12: case DASM_IMMV8: pos++; break;
}
}
stop: (void)0;
}
ofs += sec->ofs; /* Next section starts right after current section. */
}
D->codesize = ofs; /* Total size of all code sections */
*szp = ofs;
return DASM_S_OK;
}
#ifdef DASM_CHECKS
#define CK(x, st) \
do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0)
#else
#define CK(x, st) ((void)0)
#endif
/* Pass 3: Encode sections. */
int dasm_encode(Dst_DECL, void *buffer)
{
dasm_State *D = Dst_REF;
char *base = (char *)buffer;
unsigned int *cp = (unsigned int *)buffer;
int secnum;
/* Encode all code sections. No support for data sections (yet). */
for (secnum = 0; secnum < D->maxsection; secnum++) {
dasm_Section *sec = D->sections + secnum;
int *b = sec->buf;
int *endb = sec->rbuf + sec->pos;
while (b != endb) {
dasm_ActList p = D->actionlist + *b++;
while (1) {
unsigned int ins = *p++;
unsigned int action = (ins >> 16);
int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0;
switch (action) {
case DASM_STOP: case DASM_SECTION: goto stop;
case DASM_ESC: *cp++ = *p++; break;
case DASM_REL_EXT:
n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins&2047), !(ins&2048));
goto patchrel;
case DASM_ALIGN:
ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0xe1a00000;
break;
case DASM_REL_LG:
if (n < 0) {
n = (int)((ptrdiff_t)D->globals[-n-10] - (ptrdiff_t)cp - 4);
goto patchrel;
}
/* fallthrough */
case DASM_REL_PC:
CK(n >= 0, UNDEF_PC);
n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base) - 4;
patchrel:
if ((ins & 0x800) == 0) {
CK((n & 3) == 0 && ((n+0x02000000) >> 26) == 0, RANGE_REL);
cp[-1] |= ((n >> 2) & 0x00ffffff);
} else if ((ins & 0x1000)) {
CK((n & 3) == 0 && -256 <= n && n <= 256, RANGE_REL);
goto patchimml8;
} else if ((ins & 0x2000) == 0) {
CK((n & 3) == 0 && -4096 <= n && n <= 4096, RANGE_REL);
goto patchimml;
} else {
CK((n & 3) == 0 && -1020 <= n && n <= 1020, RANGE_REL);
n >>= 2;
goto patchimml;
}
break;
case DASM_LABEL_LG:
ins &= 2047; if (ins >= 20) D->globals[ins-20] = (void *)(base + n);
break;
case DASM_LABEL_PC: break;
case DASM_IMM:
cp[-1] |= ((n>>((ins>>10)&31)) & ((1<<((ins>>5)&31))-1)) << (ins&31);
break;
case DASM_IMM12:
cp[-1] |= dasm_imm12((unsigned int)n);
break;
case DASM_IMM16:
cp[-1] |= ((n & 0xf000) << 4) | (n & 0x0fff);
break;
case DASM_IMML8: patchimml8:
cp[-1] |= n >= 0 ? (0x00800000 | (n & 0x0f) | ((n & 0xf0) << 4)) :
((-n & 0x0f) | ((-n & 0xf0) << 4));
break;
case DASM_IMML12: case DASM_IMMV8: patchimml:
cp[-1] |= n >= 0 ? (0x00800000 | n) : (-n);
break;
default: *cp++ = ins; break;
}
}
stop: (void)0;
}
}
if (base + D->codesize != (char *)cp) /* Check for phase errors. */
return DASM_S_PHASE;
return DASM_S_OK;
}
#undef CK
/* Get PC label offset. */
int dasm_getpclabel(Dst_DECL, unsigned int pc)
{
dasm_State *D = Dst_REF;
if (pc*sizeof(int) < D->pcsize) {
int pos = D->pclabels[pc];
if (pos < 0) return *DASM_POS2PTR(D, -pos);
if (pos > 0) return -1; /* Undefined. */
}
return -2; /* Unused or out of range. */
}
#ifdef DASM_CHECKS
/* Optional sanity checker to call between isolated encoding steps. */
int dasm_checkstep(Dst_DECL, int secmatch)
{
dasm_State *D = Dst_REF;
if (D->status == DASM_S_OK) {
int i;
for (i = 1; i <= 9; i++) {
if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; }
D->lglabels[i] = 0;
}
}
if (D->status == DASM_S_OK && secmatch >= 0 &&
D->section != &D->sections[secmatch])
D->status = DASM_S_MATCH_SEC|(D->section-D->sections);
return D->status;
}
#endif
File diff suppressed because it is too large. Load diff
-558
View File
@@ -1,558 +0,0 @@
/*
** DynASM ARM64 encoding engine.
** Copyright (C) 2005-2023 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice.
*/
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define DASM_ARCH "arm64"
#ifndef DASM_EXTERN
#define DASM_EXTERN(a,b,c,d) 0
#endif
/* Action definitions. */
enum {
DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT,
/* The following actions need a buffer position. */
DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG,
/* The following actions also have an argument. */
DASM_REL_PC, DASM_LABEL_PC, DASM_REL_A,
DASM_IMM, DASM_IMM6, DASM_IMM12, DASM_IMM13W, DASM_IMM13X, DASM_IMML,
DASM_IMMV, DASM_VREG,
DASM__MAX
};
/* Maximum number of section buffer positions for a single dasm_put() call. */
#define DASM_MAXSECPOS 25
/* DynASM encoder status codes. Action list offset or number are or'ed in. */
#define DASM_S_OK 0x00000000
#define DASM_S_NOMEM 0x01000000
#define DASM_S_PHASE 0x02000000
#define DASM_S_MATCH_SEC 0x03000000
#define DASM_S_RANGE_I 0x11000000
#define DASM_S_RANGE_SEC 0x12000000
#define DASM_S_RANGE_LG 0x13000000
#define DASM_S_RANGE_PC 0x14000000
#define DASM_S_RANGE_REL 0x15000000
#define DASM_S_RANGE_VREG 0x16000000
#define DASM_S_UNDEF_LG 0x21000000
#define DASM_S_UNDEF_PC 0x22000000
/* Macros to convert positions (8 bit section + 24 bit index). */
#define DASM_POS2IDX(pos) ((pos)&0x00ffffff)
#define DASM_POS2BIAS(pos) ((pos)&0xff000000)
#define DASM_SEC2POS(sec) ((sec)<<24)
#define DASM_POS2SEC(pos) ((pos)>>24)
#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos))
/* Action list type. */
typedef const unsigned int *dasm_ActList;
/* Per-section structure. */
typedef struct dasm_Section {
int *rbuf; /* Biased buffer pointer (negative section bias). */
int *buf; /* True buffer pointer. */
size_t bsize; /* Buffer size in bytes. */
int pos; /* Biased buffer position. */
int epos; /* End of biased buffer position - max single put. */
int ofs; /* Byte offset into section. */
} dasm_Section;
/* Core structure holding the DynASM encoding state. */
struct dasm_State {
size_t psize; /* Allocated size of this structure. */
dasm_ActList actionlist; /* Current actionlist pointer. */
int *lglabels; /* Local/global chain/pos ptrs. */
size_t lgsize;
int *pclabels; /* PC label chains/pos ptrs. */
size_t pcsize;
void **globals; /* Array of globals. */
dasm_Section *section; /* Pointer to active section. */
size_t codesize; /* Total size of all code sections. */
int maxsection; /* 0 <= sectionidx < maxsection. */
int status; /* Status code. */
dasm_Section sections[1]; /* All sections. Alloc-extended. */
};
/* The size of the core structure depends on the max. number of sections. */
#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section))
/* Initialize DynASM state. */
void dasm_init(Dst_DECL, int maxsection)
{
dasm_State *D;
size_t psz = 0;
Dst_REF = NULL;
DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection));
D = Dst_REF;
D->psize = psz;
D->lglabels = NULL;
D->lgsize = 0;
D->pclabels = NULL;
D->pcsize = 0;
D->globals = NULL;
D->maxsection = maxsection;
memset((void *)D->sections, 0, maxsection * sizeof(dasm_Section));
}
/* Free DynASM state. */
void dasm_free(Dst_DECL)
{
dasm_State *D = Dst_REF;
int i;
for (i = 0; i < D->maxsection; i++)
if (D->sections[i].buf)
DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize);
if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize);
if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize);
DASM_M_FREE(Dst, D, D->psize);
}
/* Setup global label array. Must be called before dasm_setup(). */
void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl)
{
dasm_State *D = Dst_REF;
D->globals = gl;
DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int));
}
/* Grow PC label array. Can be called after dasm_setup(), too. */
void dasm_growpc(Dst_DECL, unsigned int maxpc)
{
dasm_State *D = Dst_REF;
size_t osz = D->pcsize;
DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int));
memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz);
}
/* Setup encoder. */
void dasm_setup(Dst_DECL, const void *actionlist)
{
dasm_State *D = Dst_REF;
int i;
D->actionlist = (dasm_ActList)actionlist;
D->status = DASM_S_OK;
D->section = &D->sections[0];
memset((void *)D->lglabels, 0, D->lgsize);
if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize);
for (i = 0; i < D->maxsection; i++) {
D->sections[i].pos = DASM_SEC2POS(i);
D->sections[i].rbuf = D->sections[i].buf - D->sections[i].pos;
D->sections[i].ofs = 0;
}
}
#ifdef DASM_CHECKS
#define CK(x, st) \
do { if (!(x)) { \
D->status = DASM_S_##st|(int)(p-D->actionlist-1); return; } } while (0)
#define CKPL(kind, st) \
do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \
D->status = DASM_S_RANGE_##st|(int)(p-D->actionlist-1); return; } } while (0)
#else
#define CK(x, st) ((void)0)
#define CKPL(kind, st) ((void)0)
#endif
static int dasm_imm12(unsigned int n)
{
if ((n >> 12) == 0)
return n;
else if ((n & 0xff000fff) == 0)
return (n >> 12) | 0x1000;
else
return -1;
}
static int dasm_ffs(unsigned long long x)
{
int n = -1;
while (x) { x >>= 1; n++; }
return n;
}
static int dasm_imm13(int lo, int hi)
{
int inv = 0, w = 64, s = 0xfff, xa, xb;
unsigned long long n = (((unsigned long long)hi) << 32) | (unsigned int)lo;
unsigned long long m = 1ULL, a, b, c;
if (n & 1) { n = ~n; inv = 1; }
a = n & (unsigned long long)-(long long)n;
b = (n+a)&(unsigned long long)-(long long)(n+a);
c = (n+a-b)&(unsigned long long)-(long long)(n+a-b);
xa = dasm_ffs(a); xb = dasm_ffs(b);
if (c) {
w = dasm_ffs(c) - xa;
if (w == 32) m = 0x0000000100000001UL;
else if (w == 16) m = 0x0001000100010001UL;
else if (w == 8) m = 0x0101010101010101UL;
else if (w == 4) m = 0x1111111111111111UL;
else if (w == 2) m = 0x5555555555555555UL;
else return -1;
s = (-2*w & 0x3f) - 1;
} else if (!a) {
return -1;
} else if (xb == -1) {
xb = 64;
}
if ((b-a) * m != n) return -1;
if (inv) {
return ((w - xb) << 6) | (s+w+xa-xb);
} else {
return ((w - xa) << 6) | (s+xb-xa);
}
return -1;
}
/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */
void dasm_put(Dst_DECL, int start, ...)
{
va_list ap;
dasm_State *D = Dst_REF;
dasm_ActList p = D->actionlist + start;
dasm_Section *sec = D->section;
int pos = sec->pos, ofs = sec->ofs;
int *b;
if (pos >= sec->epos) {
DASM_M_GROW(Dst, int, sec->buf, sec->bsize,
sec->bsize + 2*DASM_MAXSECPOS*sizeof(int));
sec->rbuf = sec->buf - DASM_POS2BIAS(pos);
sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos);
}
b = sec->rbuf;
b[pos++] = start;
va_start(ap, start);
while (1) {
unsigned int ins = *p++;
unsigned int action = (ins >> 16);
if (action >= DASM__MAX) {
ofs += 4;
} else {
int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0;
switch (action) {
case DASM_STOP: goto stop;
case DASM_SECTION:
n = (ins & 255); CK(n < D->maxsection, RANGE_SEC);
D->section = &D->sections[n]; goto stop;
case DASM_ESC: p++; ofs += 4; break;
case DASM_REL_EXT: if ((ins & 0x8000)) ofs += 8; break;
case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break;
case DASM_REL_LG:
n = (ins & 2047) - 10; pl = D->lglabels + n;
/* Bkwd rel or global. */
if (n >= 0) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; }
pl += 10; n = *pl;
if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */
goto linkrel;
case DASM_REL_PC:
pl = D->pclabels + n; CKPL(pc, PC);
putrel:
n = *pl;
if (n < 0) { /* Label exists. Get label pos and store it. */
b[pos] = -n;
} else {
linkrel:
b[pos] = n; /* Else link to rel chain, anchored at label. */
*pl = pos;
}
pos++;
if ((ins & 0x8000)) ofs += 8;
break;
case DASM_REL_A:
b[pos++] = n;
b[pos++] = va_arg(ap, int);
break;
case DASM_LABEL_LG:
pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel;
case DASM_LABEL_PC:
pl = D->pclabels + n; CKPL(pc, PC);
putlabel:
n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */
while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos;
}
*pl = -pos; /* Label exists now. */
b[pos++] = ofs; /* Store pass1 offset estimate. */
break;
case DASM_IMM:
CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I);
n >>= ((ins>>10)&31);
#ifdef DASM_CHECKS
if ((ins & 0x8000))
CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I);
else
CK((n>>((ins>>5)&31)) == 0, RANGE_I);
#endif
b[pos++] = n;
break;
case DASM_IMM6:
CK((n >> 6) == 0, RANGE_I);
b[pos++] = n;
break;
case DASM_IMM12:
CK(dasm_imm12((unsigned int)n) != -1, RANGE_I);
b[pos++] = n;
break;
case DASM_IMM13W:
CK(dasm_imm13(n, n) != -1, RANGE_I);
b[pos++] = n;
break;
case DASM_IMM13X: {
int m = va_arg(ap, int);
CK(dasm_imm13(n, m) != -1, RANGE_I);
b[pos++] = n;
b[pos++] = m;
break;
}
case DASM_IMML: {
#ifdef DASM_CHECKS
int scale = (ins & 3);
CK((!(n & ((1<<scale)-1)) && (unsigned int)(n>>scale) < 4096) ||
(unsigned int)(n+256) < 512, RANGE_I);
#endif
b[pos++] = n;
break;
}
case DASM_IMMV:
ofs += 4;
b[pos++] = n;
break;
case DASM_VREG:
CK(n < 32, RANGE_VREG);
b[pos++] = n;
break;
}
}
}
stop:
va_end(ap);
sec->pos = pos;
sec->ofs = ofs;
}
#undef CK
/* Pass 2: Link sections, shrink aligns, fix label offsets. */
int dasm_link(Dst_DECL, size_t *szp)
{
dasm_State *D = Dst_REF;
int secnum;
int ofs = 0;
#ifdef DASM_CHECKS
*szp = 0;
if (D->status != DASM_S_OK) return D->status;
{
int pc;
for (pc = 0; pc*sizeof(int) < D->pcsize; pc++)
if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc;
}
#endif
{ /* Handle globals not defined in this translation unit. */
int idx;
for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) {
int n = D->lglabels[idx];
/* Undefined label: Collapse rel chain and replace with marker (< 0). */
while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; }
}
}
/* Combine all code sections. No support for data sections (yet). */
for (secnum = 0; secnum < D->maxsection; secnum++) {
dasm_Section *sec = D->sections + secnum;
int *b = sec->rbuf;
int pos = DASM_SEC2POS(secnum);
int lastpos = sec->pos;
while (pos != lastpos) {
dasm_ActList p = D->actionlist + b[pos++];
while (1) {
unsigned int ins = *p++;
unsigned int action = (ins >> 16);
switch (action) {
case DASM_STOP: case DASM_SECTION: goto stop;
case DASM_ESC: p++; break;
case DASM_REL_EXT: break;
case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break;
case DASM_REL_LG: case DASM_REL_PC: pos++; break;
case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break;
case DASM_IMM: case DASM_IMM6: case DASM_IMM12: case DASM_IMM13W:
case DASM_IMML: case DASM_IMMV: case DASM_VREG: pos++; break;
case DASM_IMM13X: case DASM_REL_A: pos += 2; break;
}
}
stop: (void)0;
}
ofs += sec->ofs; /* Next section starts right after current section. */
}
D->codesize = ofs; /* Total size of all code sections */
*szp = ofs;
return DASM_S_OK;
}
#ifdef DASM_CHECKS
#define CK(x, st) \
do { if (!(x)) return DASM_S_##st|(int)(p-D->actionlist-1); } while (0)
#else
#define CK(x, st) ((void)0)
#endif
/* Pass 3: Encode sections. */
int dasm_encode(Dst_DECL, void *buffer)
{
dasm_State *D = Dst_REF;
char *base = (char *)buffer;
unsigned int *cp = (unsigned int *)buffer;
int secnum;
/* Encode all code sections. No support for data sections (yet). */
for (secnum = 0; secnum < D->maxsection; secnum++) {
dasm_Section *sec = D->sections + secnum;
int *b = sec->buf;
int *endb = sec->rbuf + sec->pos;
while (b != endb) {
dasm_ActList p = D->actionlist + *b++;
while (1) {
unsigned int ins = *p++;
unsigned int action = (ins >> 16);
int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0;
switch (action) {
case DASM_STOP: case DASM_SECTION: goto stop;
case DASM_ESC: *cp++ = *p++; break;
case DASM_REL_EXT:
n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins&2047), !(ins&2048));
goto patchrel;
case DASM_ALIGN:
ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0xd503201f;
break;
case DASM_REL_LG:
if (n < 0) {
ptrdiff_t na = (ptrdiff_t)D->globals[-n-10] - (ptrdiff_t)cp + 4;
n = (int)na;
CK((ptrdiff_t)n == na, RANGE_REL);
goto patchrel;
}
/* fallthrough */
case DASM_REL_PC:
CK(n >= 0, UNDEF_PC);
n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base) + 4;
patchrel:
if (!(ins & 0xf800)) { /* B, BL */
CK((n & 3) == 0 && ((n+0x08000000) >> 28) == 0, RANGE_REL);
cp[-1] |= ((n >> 2) & 0x03ffffff);
} else if ((ins & 0x800)) { /* B.cond, CBZ, CBNZ, LDR* literal */
CK((n & 3) == 0 && ((n+0x00100000) >> 21) == 0, RANGE_REL);
cp[-1] |= ((n << 3) & 0x00ffffe0);
} else if ((ins & 0x3000) == 0x2000) { /* ADR */
CK(((n+0x00100000) >> 21) == 0, RANGE_REL);
cp[-1] |= ((n << 3) & 0x00ffffe0) | ((n & 3) << 29);
} else if ((ins & 0x3000) == 0x3000) { /* ADRP */
cp[-1] |= ((n >> 9) & 0x00ffffe0) | (((n >> 12) & 3) << 29);
} else if ((ins & 0x1000)) { /* TBZ, TBNZ */
CK((n & 3) == 0 && ((n+0x00008000) >> 16) == 0, RANGE_REL);
cp[-1] |= ((n << 3) & 0x0007ffe0);
} else if ((ins & 0x8000)) { /* absolute */
cp[0] = (unsigned int)((ptrdiff_t)cp - 4 + n);
cp[1] = (unsigned int)(((ptrdiff_t)cp - 4 + n) >> 32);
cp += 2;
}
break;
case DASM_REL_A: {
ptrdiff_t na = (((ptrdiff_t)(*b++) << 32) | (unsigned int)n);
if ((ins & 0x3000) == 0x3000) { /* ADRP */
ins &= ~0x1000;
na = (na >> 12) - (((ptrdiff_t)cp - 4) >> 12);
} else {
na = na - (ptrdiff_t)cp + 4;
}
n = (int)na;
CK((ptrdiff_t)n == na, RANGE_REL);
goto patchrel;
}
case DASM_LABEL_LG:
ins &= 2047; if (ins >= 20) D->globals[ins-20] = (void *)(base + n);
break;
case DASM_LABEL_PC: break;
case DASM_IMM:
cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31);
break;
case DASM_IMM6:
cp[-1] |= ((n&31) << 19) | ((n&32) << 26);
break;
case DASM_IMM12:
cp[-1] |= (dasm_imm12((unsigned int)n) << 10);
break;
case DASM_IMM13W:
cp[-1] |= (dasm_imm13(n, n) << 10);
break;
case DASM_IMM13X:
cp[-1] |= (dasm_imm13(n, *b++) << 10);
break;
case DASM_IMML: {
int scale = (ins & 3);
cp[-1] |= (!(n & ((1<<scale)-1)) && (unsigned int)(n>>scale) < 4096) ?
((n << (10-scale)) | 0x01000000) : ((n & 511) << 12);
break;
}
case DASM_IMMV:
*cp++ = n;
break;
case DASM_VREG:
cp[-1] |= (n & 0x1f) << (ins & 0x1f);
break;
default: *cp++ = ins; break;
}
}
stop: (void)0;
}
}
if (base + D->codesize != (char *)cp) /* Check for phase errors. */
return DASM_S_PHASE;
return DASM_S_OK;
}
#undef CK
/* Get PC label offset. */
int dasm_getpclabel(Dst_DECL, unsigned int pc)
{
dasm_State *D = Dst_REF;
if (pc*sizeof(int) < D->pcsize) {
int pos = D->pclabels[pc];
if (pos < 0) return *DASM_POS2PTR(D, -pos);
if (pos > 0) return -1; /* Undefined. */
}
return -2; /* Unused or out of range. */
}
#ifdef DASM_CHECKS
/* Optional sanity checker to call between isolated encoding steps. */
int dasm_checkstep(Dst_DECL, int secmatch)
{
dasm_State *D = Dst_REF;
if (D->status == DASM_S_OK) {
int i;
for (i = 1; i <= 9; i++) {
if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; }
D->lglabels[i] = 0;
}
}
if (D->status == DASM_S_OK && secmatch >= 0 &&
D->section != &D->sections[secmatch])
D->status = DASM_S_MATCH_SEC|(int)(D->section-D->sections);
return D->status;
}
#endif
File diff suppressed because it is too large. Load diff
-419
View File
@@ -1,419 +0,0 @@
/*
** DynASM MIPS encoding engine.
** Copyright (C) 2005-2023 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice.
*/
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define DASM_ARCH "mips"
#ifndef DASM_EXTERN
#define DASM_EXTERN(a,b,c,d) 0
#endif
/* Action definitions. */
enum {
DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT,
/* The following actions need a buffer position. */
DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG,
/* The following actions also have an argument. */
DASM_REL_PC, DASM_LABEL_PC, DASM_IMM, DASM_IMMS,
DASM__MAX
};
/* Maximum number of section buffer positions for a single dasm_put() call. */
#define DASM_MAXSECPOS 25
/* DynASM encoder status codes. Action list offset or number are or'ed in. */
#define DASM_S_OK 0x00000000
#define DASM_S_NOMEM 0x01000000
#define DASM_S_PHASE 0x02000000
#define DASM_S_MATCH_SEC 0x03000000
#define DASM_S_RANGE_I 0x11000000
#define DASM_S_RANGE_SEC 0x12000000
#define DASM_S_RANGE_LG 0x13000000
#define DASM_S_RANGE_PC 0x14000000
#define DASM_S_RANGE_REL 0x15000000
#define DASM_S_UNDEF_LG 0x21000000
#define DASM_S_UNDEF_PC 0x22000000
/* Macros to convert positions (8 bit section + 24 bit index). */
#define DASM_POS2IDX(pos) ((pos)&0x00ffffff)
#define DASM_POS2BIAS(pos) ((pos)&0xff000000)
#define DASM_SEC2POS(sec) ((sec)<<24)
#define DASM_POS2SEC(pos) ((pos)>>24)
#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos))
/* Action list type. */
typedef const unsigned int *dasm_ActList;
/* Per-section structure. */
typedef struct dasm_Section {
int *rbuf; /* Biased buffer pointer (negative section bias). */
int *buf; /* True buffer pointer. */
size_t bsize; /* Buffer size in bytes. */
int pos; /* Biased buffer position. */
int epos; /* End of biased buffer position - max single put. */
int ofs; /* Byte offset into section. */
} dasm_Section;
/* Core structure holding the DynASM encoding state. */
struct dasm_State {
size_t psize; /* Allocated size of this structure. */
dasm_ActList actionlist; /* Current actionlist pointer. */
int *lglabels; /* Local/global chain/pos ptrs. */
size_t lgsize;
int *pclabels; /* PC label chains/pos ptrs. */
size_t pcsize;
void **globals; /* Array of globals. */
dasm_Section *section; /* Pointer to active section. */
size_t codesize; /* Total size of all code sections. */
int maxsection; /* 0 <= sectionidx < maxsection. */
int status; /* Status code. */
dasm_Section sections[1]; /* All sections. Alloc-extended. */
};
/* The size of the core structure depends on the max. number of sections. */
#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section))
/* Initialize DynASM state. */
void dasm_init(Dst_DECL, int maxsection)
{
dasm_State *D;
size_t psz = 0;
Dst_REF = NULL;
DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection));
D = Dst_REF;
D->psize = psz;
D->lglabels = NULL;
D->lgsize = 0;
D->pclabels = NULL;
D->pcsize = 0;
D->globals = NULL;
D->maxsection = maxsection;
memset((void *)D->sections, 0, maxsection * sizeof(dasm_Section));
}
/* Free DynASM state. */
void dasm_free(Dst_DECL)
{
dasm_State *D = Dst_REF;
int i;
for (i = 0; i < D->maxsection; i++)
if (D->sections[i].buf)
DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize);
if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize);
if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize);
DASM_M_FREE(Dst, D, D->psize);
}
/* Setup global label array. Must be called before dasm_setup(). */
void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl)
{
dasm_State *D = Dst_REF;
D->globals = gl;
DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int));
}
/* Grow PC label array. Can be called after dasm_setup(), too. */
void dasm_growpc(Dst_DECL, unsigned int maxpc)
{
dasm_State *D = Dst_REF;
size_t osz = D->pcsize;
DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int));
memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz);
}
/* Setup encoder. */
void dasm_setup(Dst_DECL, const void *actionlist)
{
dasm_State *D = Dst_REF;
int i;
D->actionlist = (dasm_ActList)actionlist;
D->status = DASM_S_OK;
D->section = &D->sections[0];
memset((void *)D->lglabels, 0, D->lgsize);
if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize);
for (i = 0; i < D->maxsection; i++) {
D->sections[i].pos = DASM_SEC2POS(i);
D->sections[i].rbuf = D->sections[i].buf - D->sections[i].pos;
D->sections[i].ofs = 0;
}
}
#ifdef DASM_CHECKS
#define CK(x, st) \
do { if (!(x)) { \
D->status = DASM_S_##st|(int)(p-D->actionlist-1); return; } } while (0)
#define CKPL(kind, st) \
do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \
D->status = DASM_S_RANGE_##st|(int)(p-D->actionlist-1); return; } } while (0)
#else
#define CK(x, st) ((void)0)
#define CKPL(kind, st) ((void)0)
#endif
/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */
void dasm_put(Dst_DECL, int start, ...)
{
va_list ap;
dasm_State *D = Dst_REF;
dasm_ActList p = D->actionlist + start;
dasm_Section *sec = D->section;
int pos = sec->pos, ofs = sec->ofs;
int *b;
if (pos >= sec->epos) {
DASM_M_GROW(Dst, int, sec->buf, sec->bsize,
sec->bsize + 2*DASM_MAXSECPOS*sizeof(int));
sec->rbuf = sec->buf - DASM_POS2BIAS(pos);
sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos);
}
b = sec->rbuf;
b[pos++] = start;
va_start(ap, start);
while (1) {
unsigned int ins = *p++;
unsigned int action = (ins >> 16) - 0xff00;
if (action >= DASM__MAX) {
ofs += 4;
} else {
int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0;
switch (action) {
case DASM_STOP: goto stop;
case DASM_SECTION:
n = (ins & 255); CK(n < D->maxsection, RANGE_SEC);
D->section = &D->sections[n]; goto stop;
case DASM_ESC: p++; ofs += 4; break;
case DASM_REL_EXT: break;
case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break;
case DASM_REL_LG:
n = (ins & 2047) - 10; pl = D->lglabels + n;
/* Bkwd rel or global. */
if (n >= 0) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; }
pl += 10; n = *pl;
if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */
goto linkrel;
case DASM_REL_PC:
pl = D->pclabels + n; CKPL(pc, PC);
putrel:
n = *pl;
if (n < 0) { /* Label exists. Get label pos and store it. */
b[pos] = -n;
} else {
linkrel:
b[pos] = n; /* Else link to rel chain, anchored at label. */
*pl = pos;
}
pos++;
break;
case DASM_LABEL_LG:
pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel;
case DASM_LABEL_PC:
pl = D->pclabels + n; CKPL(pc, PC);
putlabel:
n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */
while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos;
}
*pl = -pos; /* Label exists now. */
b[pos++] = ofs; /* Store pass1 offset estimate. */
break;
case DASM_IMM: case DASM_IMMS:
#ifdef DASM_CHECKS
CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I);
#endif
n >>= ((ins>>10)&31);
#ifdef DASM_CHECKS
if (ins & 0x8000)
CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I);
else
CK((n>>((ins>>5)&31)) == 0, RANGE_I);
#endif
b[pos++] = n;
break;
}
}
}
stop:
va_end(ap);
sec->pos = pos;
sec->ofs = ofs;
}
#undef CK
/* Pass 2: Link sections, shrink aligns, fix label offsets. */
int dasm_link(Dst_DECL, size_t *szp)
{
dasm_State *D = Dst_REF;
int secnum;
int ofs = 0;
#ifdef DASM_CHECKS
*szp = 0;
if (D->status != DASM_S_OK) return D->status;
{
int pc;
for (pc = 0; pc*sizeof(int) < D->pcsize; pc++)
if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc;
}
#endif
{ /* Handle globals not defined in this translation unit. */
int idx;
for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) {
int n = D->lglabels[idx];
/* Undefined label: Collapse rel chain and replace with marker (< 0). */
while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; }
}
}
/* Combine all code sections. No support for data sections (yet). */
for (secnum = 0; secnum < D->maxsection; secnum++) {
dasm_Section *sec = D->sections + secnum;
int *b = sec->rbuf;
int pos = DASM_SEC2POS(secnum);
int lastpos = sec->pos;
while (pos != lastpos) {
dasm_ActList p = D->actionlist + b[pos++];
while (1) {
unsigned int ins = *p++;
unsigned int action = (ins >> 16) - 0xff00;
switch (action) {
case DASM_STOP: case DASM_SECTION: goto stop;
case DASM_ESC: p++; break;
case DASM_REL_EXT: break;
case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break;
case DASM_REL_LG: case DASM_REL_PC: pos++; break;
case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break;
case DASM_IMM: case DASM_IMMS: pos++; break;
}
}
stop: (void)0;
}
ofs += sec->ofs; /* Next section starts right after current section. */
}
D->codesize = ofs; /* Total size of all code sections */
*szp = ofs;
return DASM_S_OK;
}
#ifdef DASM_CHECKS
#define CK(x, st) \
do { if (!(x)) return DASM_S_##st|(int)(p-D->actionlist-1); } while (0)
#else
#define CK(x, st) ((void)0)
#endif
/* Pass 3: Encode sections. */
int dasm_encode(Dst_DECL, void *buffer)
{
dasm_State *D = Dst_REF;
char *base = (char *)buffer;
unsigned int *cp = (unsigned int *)buffer;
int secnum;
/* Encode all code sections. No support for data sections (yet). */
for (secnum = 0; secnum < D->maxsection; secnum++) {
dasm_Section *sec = D->sections + secnum;
int *b = sec->buf;
int *endb = sec->rbuf + sec->pos;
while (b != endb) {
dasm_ActList p = D->actionlist + *b++;
while (1) {
unsigned int ins = *p++;
unsigned int action = (ins >> 16) - 0xff00;
int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0;
switch (action) {
case DASM_STOP: case DASM_SECTION: goto stop;
case DASM_ESC: *cp++ = *p++; break;
case DASM_REL_EXT:
n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins & 2047), 1);
goto patchrel;
case DASM_ALIGN:
ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000;
break;
case DASM_REL_LG:
if (n < 0) {
n = (int)((ptrdiff_t)D->globals[-n-10] - (ptrdiff_t)cp);
goto patchrel;
}
/* fallthrough */
case DASM_REL_PC:
CK(n >= 0, UNDEF_PC);
n = *DASM_POS2PTR(D, n);
if (ins & 2048)
n = (n + (int)(size_t)base) & 0x0fffffff;
else
n = n - (int)((char *)cp - base);
patchrel: {
unsigned int e = 16 + ((ins >> 12) & 15);
CK((n & 3) == 0 &&
((n + ((ins & 2048) ? 0 : (1<<(e+1)))) >> (e+2)) == 0, RANGE_REL);
cp[-1] |= ((n>>2) & ((1<<e)-1));
}
break;
case DASM_LABEL_LG:
ins &= 2047; if (ins >= 20) D->globals[ins-20] = (void *)(base + n);
break;
case DASM_LABEL_PC: break;
case DASM_IMMS:
cp[-1] |= ((n>>3) & 4); n &= 0x1f;
/* fallthrough */
case DASM_IMM:
cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31);
break;
default: *cp++ = ins; break;
}
}
stop: (void)0;
}
}
if (base + D->codesize != (char *)cp) /* Check for phase errors. */
return DASM_S_PHASE;
return DASM_S_OK;
}
#undef CK
/* Get PC label offset. */
int dasm_getpclabel(Dst_DECL, unsigned int pc)
{
dasm_State *D = Dst_REF;
if (pc*sizeof(int) < D->pcsize) {
int pos = D->pclabels[pc];
if (pos < 0) return *DASM_POS2PTR(D, -pos);
if (pos > 0) return -1; /* Undefined. */
}
return -2; /* Unused or out of range. */
}
#ifdef DASM_CHECKS
/* Optional sanity checker to call between isolated encoding steps. */
int dasm_checkstep(Dst_DECL, int secmatch)
{
dasm_State *D = Dst_REF;
if (D->status == DASM_S_OK) {
int i;
for (i = 1; i <= 9; i++) {
if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; }
D->lglabels[i] = 0;
}
}
if (D->status == DASM_S_OK && secmatch >= 0 &&
D->section != &D->sections[secmatch])
D->status = DASM_S_MATCH_SEC|(int)(D->section-D->sections);
return D->status;
}
#endif
File diff suppressed because it is too large. Load diff
-12
View File
@@ -1,12 +0,0 @@
------------------------------------------------------------------------------
-- DynASM MIPS64 module.
--
-- Copyright (C) 2005-2023 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------
-- This module just sets 64 bit mode for the combined MIPS/MIPS64 module.
-- All the interesting stuff is there.
------------------------------------------------------------------------------
mips64 = true -- Using a global is an ugly, but effective solution.
return require("dasm_mips")
-418
View File
@@ -1,418 +0,0 @@
/*
** DynASM PPC/PPC64 encoding engine.
** Copyright (C) 2005-2023 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice.
*/
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define DASM_ARCH "ppc"
#ifndef DASM_EXTERN
#define DASM_EXTERN(a,b,c,d) 0
#endif
/* Action definitions. */
enum {
DASM_STOP, DASM_SECTION, DASM_ESC, DASM_REL_EXT,
/* The following actions need a buffer position. */
DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG,
/* The following actions also have an argument. */
DASM_REL_PC, DASM_LABEL_PC, DASM_IMM, DASM_IMMSH,
DASM__MAX
};
/* Maximum number of section buffer positions for a single dasm_put() call. */
#define DASM_MAXSECPOS 25
/* DynASM encoder status codes. Action list offset or number are or'ed in. */
#define DASM_S_OK 0x00000000
#define DASM_S_NOMEM 0x01000000
#define DASM_S_PHASE 0x02000000
#define DASM_S_MATCH_SEC 0x03000000
#define DASM_S_RANGE_I 0x11000000
#define DASM_S_RANGE_SEC 0x12000000
#define DASM_S_RANGE_LG 0x13000000
#define DASM_S_RANGE_PC 0x14000000
#define DASM_S_RANGE_REL 0x15000000
#define DASM_S_UNDEF_LG 0x21000000
#define DASM_S_UNDEF_PC 0x22000000
/* Macros to convert positions (8 bit section + 24 bit index). */
#define DASM_POS2IDX(pos) ((pos)&0x00ffffff)
#define DASM_POS2BIAS(pos) ((pos)&0xff000000)
#define DASM_SEC2POS(sec) ((sec)<<24)
#define DASM_POS2SEC(pos) ((pos)>>24)
#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos))
/* Action list type. */
typedef const unsigned int *dasm_ActList;
/* Per-section structure. */
typedef struct dasm_Section {
int *rbuf; /* Biased buffer pointer (negative section bias). */
int *buf; /* True buffer pointer. */
size_t bsize; /* Buffer size in bytes. */
int pos; /* Biased buffer position. */
int epos; /* End of biased buffer position - max single put. */
int ofs; /* Byte offset into section. */
} dasm_Section;
/* Core structure holding the DynASM encoding state. */
struct dasm_State {
size_t psize; /* Allocated size of this structure. */
dasm_ActList actionlist; /* Current actionlist pointer. */
int *lglabels; /* Local/global chain/pos ptrs. */
size_t lgsize;
int *pclabels; /* PC label chains/pos ptrs. */
size_t pcsize;
void **globals; /* Array of globals. */
dasm_Section *section; /* Pointer to active section. */
size_t codesize; /* Total size of all code sections. */
int maxsection; /* 0 <= sectionidx < maxsection. */
int status; /* Status code. */
dasm_Section sections[1]; /* All sections. Alloc-extended. */
};
/* The size of the core structure depends on the max. number of sections. */
#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section))
/* Initialize DynASM state. */
void dasm_init(Dst_DECL, int maxsection)
{
dasm_State *D;
size_t psz = 0;
Dst_REF = NULL;
DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection));
D = Dst_REF;
D->psize = psz;
D->lglabels = NULL;
D->lgsize = 0;
D->pclabels = NULL;
D->pcsize = 0;
D->globals = NULL;
D->maxsection = maxsection;
memset((void *)D->sections, 0, maxsection * sizeof(dasm_Section));
}
/* Free DynASM state. */
void dasm_free(Dst_DECL)
{
dasm_State *D = Dst_REF;
int i;
for (i = 0; i < D->maxsection; i++)
if (D->sections[i].buf)
DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize);
if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize);
if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize);
DASM_M_FREE(Dst, D, D->psize);
}
/* Setup global label array. Must be called before dasm_setup(). */
void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl)
{
dasm_State *D = Dst_REF;
D->globals = gl;
DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int));
}
/* Grow PC label array. Can be called after dasm_setup(), too. */
void dasm_growpc(Dst_DECL, unsigned int maxpc)
{
dasm_State *D = Dst_REF;
size_t osz = D->pcsize;
DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int));
memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz);
}
/* Setup encoder. */
void dasm_setup(Dst_DECL, const void *actionlist)
{
dasm_State *D = Dst_REF;
int i;
D->actionlist = (dasm_ActList)actionlist;
D->status = DASM_S_OK;
D->section = &D->sections[0];
memset((void *)D->lglabels, 0, D->lgsize);
if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize);
for (i = 0; i < D->maxsection; i++) {
D->sections[i].pos = DASM_SEC2POS(i);
D->sections[i].rbuf = D->sections[i].buf - D->sections[i].pos;
D->sections[i].ofs = 0;
}
}
#ifdef DASM_CHECKS
#define CK(x, st) \
do { if (!(x)) { \
D->status = DASM_S_##st|(p-D->actionlist-1); return; } } while (0)
#define CKPL(kind, st) \
do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \
D->status = DASM_S_RANGE_##st|(p-D->actionlist-1); return; } } while (0)
#else
#define CK(x, st) ((void)0)
#define CKPL(kind, st) ((void)0)
#endif
/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */
void dasm_put(Dst_DECL, int start, ...)
{
va_list ap;
dasm_State *D = Dst_REF;
dasm_ActList p = D->actionlist + start;
dasm_Section *sec = D->section;
int pos = sec->pos, ofs = sec->ofs;
int *b;
if (pos >= sec->epos) {
DASM_M_GROW(Dst, int, sec->buf, sec->bsize,
sec->bsize + 2*DASM_MAXSECPOS*sizeof(int));
sec->rbuf = sec->buf - DASM_POS2BIAS(pos);
sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos);
}
b = sec->rbuf;
b[pos++] = start;
va_start(ap, start);
while (1) {
unsigned int ins = *p++;
unsigned int action = (ins >> 16);
if (action >= DASM__MAX) {
ofs += 4;
} else {
int *pl, n = action >= DASM_REL_PC ? va_arg(ap, int) : 0;
switch (action) {
case DASM_STOP: goto stop;
case DASM_SECTION:
n = (ins & 255); CK(n < D->maxsection, RANGE_SEC);
D->section = &D->sections[n]; goto stop;
case DASM_ESC: p++; ofs += 4; break;
case DASM_REL_EXT: break;
case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break;
case DASM_REL_LG:
n = (ins & 2047) - 10; pl = D->lglabels + n;
/* Bkwd rel or global. */
if (n >= 0) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; }
pl += 10; n = *pl;
if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */
goto linkrel;
case DASM_REL_PC:
pl = D->pclabels + n; CKPL(pc, PC);
putrel:
n = *pl;
if (n < 0) { /* Label exists. Get label pos and store it. */
b[pos] = -n;
} else {
linkrel:
b[pos] = n; /* Else link to rel chain, anchored at label. */
*pl = pos;
}
pos++;
break;
case DASM_LABEL_LG:
pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel;
case DASM_LABEL_PC:
pl = D->pclabels + n; CKPL(pc, PC);
putlabel:
n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */
while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos;
}
*pl = -pos; /* Label exists now. */
b[pos++] = ofs; /* Store pass1 offset estimate. */
break;
case DASM_IMM:
#ifdef DASM_CHECKS
CK((n & ((1<<((ins>>10)&31))-1)) == 0, RANGE_I);
#endif
n >>= ((ins>>10)&31);
#ifdef DASM_CHECKS
if (ins & 0x8000)
CK(((n + (1<<(((ins>>5)&31)-1)))>>((ins>>5)&31)) == 0, RANGE_I);
else
CK((n>>((ins>>5)&31)) == 0, RANGE_I);
#endif
b[pos++] = n;
break;
case DASM_IMMSH:
CK((n >> 6) == 0, RANGE_I);
b[pos++] = n;
break;
}
}
}
stop:
va_end(ap);
sec->pos = pos;
sec->ofs = ofs;
}
#undef CK
/* Pass 2: Link sections, shrink aligns, fix label offsets. */
int dasm_link(Dst_DECL, size_t *szp)
{
dasm_State *D = Dst_REF;
int secnum;
int ofs = 0;
#ifdef DASM_CHECKS
*szp = 0;
if (D->status != DASM_S_OK) return D->status;
{
int pc;
for (pc = 0; pc*sizeof(int) < D->pcsize; pc++)
if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc;
}
#endif
{ /* Handle globals not defined in this translation unit. */
int idx;
for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) {
int n = D->lglabels[idx];
/* Undefined label: Collapse rel chain and replace with marker (< 0). */
while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; }
}
}
/* Combine all code sections. No support for data sections (yet). */
for (secnum = 0; secnum < D->maxsection; secnum++) {
dasm_Section *sec = D->sections + secnum;
int *b = sec->rbuf;
int pos = DASM_SEC2POS(secnum);
int lastpos = sec->pos;
while (pos != lastpos) {
dasm_ActList p = D->actionlist + b[pos++];
while (1) {
unsigned int ins = *p++;
unsigned int action = (ins >> 16);
switch (action) {
case DASM_STOP: case DASM_SECTION: goto stop;
case DASM_ESC: p++; break;
case DASM_REL_EXT: break;
case DASM_ALIGN: ofs -= (b[pos++] + ofs) & (ins & 255); break;
case DASM_REL_LG: case DASM_REL_PC: pos++; break;
case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break;
case DASM_IMM: case DASM_IMMSH: pos++; break;
}
}
stop: (void)0;
}
ofs += sec->ofs; /* Next section starts right after current section. */
}
D->codesize = ofs; /* Total size of all code sections */
*szp = ofs;
return DASM_S_OK;
}
#ifdef DASM_CHECKS
#define CK(x, st) \
do { if (!(x)) return DASM_S_##st|(p-D->actionlist-1); } while (0)
#else
#define CK(x, st) ((void)0)
#endif
/* Pass 3: Encode sections. */
int dasm_encode(Dst_DECL, void *buffer)
{
dasm_State *D = Dst_REF;
char *base = (char *)buffer;
unsigned int *cp = (unsigned int *)buffer;
int secnum;
/* Encode all code sections. No support for data sections (yet). */
for (secnum = 0; secnum < D->maxsection; secnum++) {
dasm_Section *sec = D->sections + secnum;
int *b = sec->buf;
int *endb = sec->rbuf + sec->pos;
while (b != endb) {
dasm_ActList p = D->actionlist + *b++;
while (1) {
unsigned int ins = *p++;
unsigned int action = (ins >> 16);
int n = (action >= DASM_ALIGN && action < DASM__MAX) ? *b++ : 0;
switch (action) {
case DASM_STOP: case DASM_SECTION: goto stop;
case DASM_ESC: *cp++ = *p++; break;
case DASM_REL_EXT:
n = DASM_EXTERN(Dst, (unsigned char *)cp, (ins & 2047), 1) - 4;
goto patchrel;
case DASM_ALIGN:
ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0x60000000;
break;
case DASM_REL_LG:
if (n < 0) {
n = (int)((ptrdiff_t)D->globals[-n-10] - (ptrdiff_t)cp);
goto patchrel;
}
/* fallthrough */
case DASM_REL_PC:
CK(n >= 0, UNDEF_PC);
n = *DASM_POS2PTR(D, n) - (int)((char *)cp - base);
patchrel:
CK((n & 3) == 0 &&
(((n+4) + ((ins & 2048) ? 0x00008000 : 0x02000000)) >>
((ins & 2048) ? 16 : 26)) == 0, RANGE_REL);
cp[-1] |= ((n+4) & ((ins & 2048) ? 0x0000fffc: 0x03fffffc));
break;
case DASM_LABEL_LG:
ins &= 2047; if (ins >= 20) D->globals[ins-20] = (void *)(base + n);
break;
case DASM_LABEL_PC: break;
case DASM_IMM:
cp[-1] |= (n & ((1<<((ins>>5)&31))-1)) << (ins&31);
break;
case DASM_IMMSH:
cp[-1] |= (ins & 1) ? ((n&31)<<11)|((n&32)>>4) : ((n&31)<<6)|(n&32);
break;
default: *cp++ = ins; break;
}
}
stop: (void)0;
}
}
if (base + D->codesize != (char *)cp) /* Check for phase errors. */
return DASM_S_PHASE;
return DASM_S_OK;
}
#undef CK
/* Get PC label offset. */
int dasm_getpclabel(Dst_DECL, unsigned int pc)
{
dasm_State *D = Dst_REF;
if (pc*sizeof(int) < D->pcsize) {
int pos = D->pclabels[pc];
if (pos < 0) return *DASM_POS2PTR(D, -pos);
if (pos > 0) return -1; /* Undefined. */
}
return -2; /* Unused or out of range. */
}
#ifdef DASM_CHECKS
/* Optional sanity checker to call between isolated encoding steps. */
int dasm_checkstep(Dst_DECL, int secmatch)
{
dasm_State *D = Dst_REF;
if (D->status == DASM_S_OK) {
int i;
for (i = 1; i <= 9; i++) {
if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_LG|i; break; }
D->lglabels[i] = 0;
}
}
if (D->status == DASM_S_OK && secmatch >= 0 &&
D->section != &D->sections[secmatch])
D->status = DASM_S_MATCH_SEC|(D->section-D->sections);
return D->status;
}
#endif
File diff suppressed because it is too large. Load diff
-83
View File
@@ -1,83 +0,0 @@
/*
** DynASM encoding engine prototypes.
** Copyright (C) 2005-2023 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice.
*/
#ifndef _DASM_PROTO_H
#define _DASM_PROTO_H
#include <stddef.h>
#include <stdarg.h>
#define DASM_IDENT "DynASM 1.5.0"
#define DASM_VERSION 10500 /* 1.5.0 */
#ifndef Dst_DECL
#define Dst_DECL dasm_State **Dst
#endif
#ifndef Dst_REF
#define Dst_REF (*Dst)
#endif
#ifndef DASM_FDEF
#define DASM_FDEF extern
#endif
#ifndef DASM_M_GROW
#define DASM_M_GROW(ctx, t, p, sz, need) \
do { \
size_t _sz = (sz), _need = (need); \
if (_sz < _need) { \
if (_sz < 16) _sz = 16; \
while (_sz < _need) _sz += _sz; \
(p) = (t *)realloc((p), _sz); \
if ((p) == NULL) exit(1); \
(sz) = _sz; \
} \
} while(0)
#endif
#ifndef DASM_M_FREE
#define DASM_M_FREE(ctx, p, sz) free(p)
#endif
/* Internal DynASM encoder state. */
typedef struct dasm_State dasm_State;
/* Initialize and free DynASM state. */
DASM_FDEF void dasm_init(Dst_DECL, int maxsection);
DASM_FDEF void dasm_free(Dst_DECL);
/* Setup global array. Must be called before dasm_setup(). */
DASM_FDEF void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl);
/* Grow PC label array. Can be called after dasm_setup(), too. */
DASM_FDEF void dasm_growpc(Dst_DECL, unsigned int maxpc);
/* Setup encoder. */
DASM_FDEF void dasm_setup(Dst_DECL, const void *actionlist);
/* Feed encoder with actions. Calls are generated by pre-processor. */
DASM_FDEF void dasm_put(Dst_DECL, int start, ...);
/* Link sections and return the resulting size. */
DASM_FDEF int dasm_link(Dst_DECL, size_t *szp);
/* Encode sections into buffer. */
DASM_FDEF int dasm_encode(Dst_DECL, void *buffer);
/* Get PC label offset. */
DASM_FDEF int dasm_getpclabel(Dst_DECL, unsigned int pc);
#ifdef DASM_CHECKS
/* Optional sanity checker to call between isolated encoding steps. */
DASM_FDEF int dasm_checkstep(Dst_DECL, int secmatch);
#else
#define dasm_checkstep(a, b) 0
#endif
#endif /* _DASM_PROTO_H */
-12
View File
@@ -1,12 +0,0 @@
------------------------------------------------------------------------------
-- DynASM x64 module.
--
-- Copyright (C) 2005-2023 Mike Pall. All rights reserved.
-- See dynasm.lua for full copyright notice.
------------------------------------------------------------------------------
-- This module just sets 64 bit mode for the combined x86/x64 module.
-- All the interesting stuff is there.
------------------------------------------------------------------------------
x64 = true -- Using a global is an ugly, but effective solution.
return require("dasm_x86")
-523
View File
@@ -1,523 +0,0 @@
/*
** DynASM x86 encoding engine.
** Copyright (C) 2005-2023 Mike Pall. All rights reserved.
** Released under the MIT license. See dynasm.lua for full copyright notice.
*/
#include <stddef.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#define DASM_ARCH "x86"
#ifndef DASM_EXTERN
#define DASM_EXTERN(a,b,c,d) 0
#endif
/* Action definitions. DASM_STOP must be 255. */
enum {
DASM_DISP = 233,
DASM_IMM_S, DASM_IMM_B, DASM_IMM_W, DASM_IMM_D, DASM_IMM_WB, DASM_IMM_DB,
DASM_VREG, DASM_SPACE, DASM_SETLABEL, DASM_REL_A, DASM_REL_LG, DASM_REL_PC,
DASM_IMM_LG, DASM_IMM_PC, DASM_LABEL_LG, DASM_LABEL_PC, DASM_ALIGN,
DASM_EXTERN, DASM_ESC, DASM_MARK, DASM_SECTION, DASM_STOP
};
/* Maximum number of section buffer positions for a single dasm_put() call. */
#define DASM_MAXSECPOS 25
/* DynASM encoder status codes. Action list offset or number are or'ed in. */
#define DASM_S_OK 0x00000000
#define DASM_S_NOMEM 0x01000000
#define DASM_S_PHASE 0x02000000
#define DASM_S_MATCH_SEC 0x03000000
#define DASM_S_RANGE_I 0x11000000
#define DASM_S_RANGE_SEC 0x12000000
#define DASM_S_RANGE_LG 0x13000000
#define DASM_S_RANGE_PC 0x14000000
#define DASM_S_RANGE_VREG 0x15000000
#define DASM_S_UNDEF_L 0x21000000
#define DASM_S_UNDEF_PC 0x22000000
/* Macros to convert positions (8 bit section + 24 bit index). */
#define DASM_POS2IDX(pos) ((pos)&0x00ffffff)
#define DASM_POS2BIAS(pos) ((pos)&0xff000000)
#define DASM_SEC2POS(sec) ((sec)<<24)
#define DASM_POS2SEC(pos) ((pos)>>24)
#define DASM_POS2PTR(D, pos) (D->sections[DASM_POS2SEC(pos)].rbuf + (pos))
/* Action list type. */
typedef const unsigned char *dasm_ActList;
/* Per-section structure. */
typedef struct dasm_Section {
int *rbuf; /* Biased buffer pointer (negative section bias). */
int *buf; /* True buffer pointer. */
size_t bsize; /* Buffer size in bytes. */
int pos; /* Biased buffer position. */
int epos; /* End of biased buffer position - max single put. */
int ofs; /* Byte offset into section. */
} dasm_Section;
/* Core structure holding the DynASM encoding state. */
struct dasm_State {
size_t psize; /* Allocated size of this structure. */
dasm_ActList actionlist; /* Current actionlist pointer. */
int *lglabels; /* Local/global chain/pos ptrs. */
size_t lgsize;
int *pclabels; /* PC label chains/pos ptrs. */
size_t pcsize;
void **globals; /* Array of globals. */
dasm_Section *section; /* Pointer to active section. */
size_t codesize; /* Total size of all code sections. */
int maxsection; /* 0 <= sectionidx < maxsection. */
int status; /* Status code. */
dasm_Section sections[1]; /* All sections. Alloc-extended. */
};
/* The size of the core structure depends on the max. number of sections. */
#define DASM_PSZ(ms) (sizeof(dasm_State)+(ms-1)*sizeof(dasm_Section))
/* Initialize DynASM state. */
void dasm_init(Dst_DECL, int maxsection)
{
dasm_State *D;
size_t psz = 0;
Dst_REF = NULL;
DASM_M_GROW(Dst, struct dasm_State, Dst_REF, psz, DASM_PSZ(maxsection));
D = Dst_REF;
D->psize = psz;
D->lglabels = NULL;
D->lgsize = 0;
D->pclabels = NULL;
D->pcsize = 0;
D->globals = NULL;
D->maxsection = maxsection;
memset((void *)D->sections, 0, maxsection * sizeof(dasm_Section));
}
/* Free DynASM state. */
void dasm_free(Dst_DECL)
{
dasm_State *D = Dst_REF;
int i;
for (i = 0; i < D->maxsection; i++)
if (D->sections[i].buf)
DASM_M_FREE(Dst, D->sections[i].buf, D->sections[i].bsize);
if (D->pclabels) DASM_M_FREE(Dst, D->pclabels, D->pcsize);
if (D->lglabels) DASM_M_FREE(Dst, D->lglabels, D->lgsize);
DASM_M_FREE(Dst, D, D->psize);
}
/* Setup global label array. Must be called before dasm_setup(). */
void dasm_setupglobal(Dst_DECL, void **gl, unsigned int maxgl)
{
dasm_State *D = Dst_REF;
D->globals = gl;
DASM_M_GROW(Dst, int, D->lglabels, D->lgsize, (10+maxgl)*sizeof(int));
}
/* Grow PC label array. Can be called after dasm_setup(), too. */
void dasm_growpc(Dst_DECL, unsigned int maxpc)
{
dasm_State *D = Dst_REF;
size_t osz = D->pcsize;
DASM_M_GROW(Dst, int, D->pclabels, D->pcsize, maxpc*sizeof(int));
memset((void *)(((unsigned char *)D->pclabels)+osz), 0, D->pcsize-osz);
}
/* Setup encoder. */
void dasm_setup(Dst_DECL, const void *actionlist)
{
dasm_State *D = Dst_REF;
int i;
D->actionlist = (dasm_ActList)actionlist;
D->status = DASM_S_OK;
D->section = &D->sections[0];
memset((void *)D->lglabels, 0, D->lgsize);
if (D->pclabels) memset((void *)D->pclabels, 0, D->pcsize);
for (i = 0; i < D->maxsection; i++) {
D->sections[i].pos = DASM_SEC2POS(i);
D->sections[i].rbuf = D->sections[i].buf - D->sections[i].pos;
D->sections[i].ofs = 0;
}
}
#ifdef DASM_CHECKS
#define CK(x, st) \
do { if (!(x)) { \
D->status = DASM_S_##st|(int)(p-D->actionlist-1); return; } } while (0)
#define CKPL(kind, st) \
do { if ((size_t)((char *)pl-(char *)D->kind##labels) >= D->kind##size) { \
D->status=DASM_S_RANGE_##st|(int)(p-D->actionlist-1); return; } } while (0)
#else
#define CK(x, st) ((void)0)
#define CKPL(kind, st) ((void)0)
#endif
/* Pass 1: Store actions and args, link branches/labels, estimate offsets. */
void dasm_put(Dst_DECL, int start, ...)
{
va_list ap;
dasm_State *D = Dst_REF;
dasm_ActList p = D->actionlist + start;
dasm_Section *sec = D->section;
int pos = sec->pos, ofs = sec->ofs, mrm = -1;
int *b;
if (pos >= sec->epos) {
DASM_M_GROW(Dst, int, sec->buf, sec->bsize,
sec->bsize + 2*DASM_MAXSECPOS*sizeof(int));
sec->rbuf = sec->buf - DASM_POS2BIAS(pos);
sec->epos = (int)sec->bsize/sizeof(int) - DASM_MAXSECPOS+DASM_POS2BIAS(pos);
}
b = sec->rbuf;
b[pos++] = start;
va_start(ap, start);
while (1) {
int action = *p++;
if (action < DASM_DISP) {
ofs++;
} else if (action <= DASM_REL_A) {
int n = va_arg(ap, int);
b[pos++] = n;
switch (action) {
case DASM_DISP:
if (n == 0) { if (mrm < 0) mrm = p[-2]; if ((mrm&7) != 5) break; }
/* fallthrough */
case DASM_IMM_DB: if (((n+128)&-256) == 0) goto ob; /* fallthrough */
case DASM_REL_A: /* Assumes ptrdiff_t is int. !x64 */
case DASM_IMM_D: ofs += 4; break;
case DASM_IMM_S: CK(((n+128)&-256) == 0, RANGE_I); goto ob;
case DASM_IMM_B: CK((n&-256) == 0, RANGE_I); ob: ofs++; break;
case DASM_IMM_WB: if (((n+128)&-256) == 0) goto ob; /* fallthrough */
case DASM_IMM_W: CK((n&-65536) == 0, RANGE_I); ofs += 2; break;
case DASM_SPACE: p++; ofs += n; break;
case DASM_SETLABEL: b[pos-2] = -0x40000000; break; /* Neg. label ofs. */
case DASM_VREG: CK((n&-16) == 0 && (n != 4 || (*p>>5) != 2), RANGE_VREG);
if (*p < 0x40 && p[1] == DASM_DISP) mrm = n;
if (*p < 0x20 && (n&7) == 4) ofs++;
switch ((*p++ >> 3) & 3) {
case 3: n |= b[pos-3]; /* fallthrough */
case 2: n |= b[pos-2]; /* fallthrough */
case 1: if (n <= 7) { b[pos-1] |= 0x10; ofs--; }
}
continue;
}
mrm = -1;
} else {
int *pl, n;
switch (action) {
case DASM_REL_LG:
case DASM_IMM_LG:
n = *p++; pl = D->lglabels + n;
/* Bkwd rel or global. */
if (n <= 246) { CK(n>=10||*pl<0, RANGE_LG); CKPL(lg, LG); goto putrel; }
pl -= 246; n = *pl;
if (n < 0) n = 0; /* Start new chain for fwd rel if label exists. */
goto linkrel;
case DASM_REL_PC:
case DASM_IMM_PC: pl = D->pclabels + va_arg(ap, int); CKPL(pc, PC);
putrel:
n = *pl;
if (n < 0) { /* Label exists. Get label pos and store it. */
b[pos] = -n;
} else {
linkrel:
b[pos] = n; /* Else link to rel chain, anchored at label. */
*pl = pos;
}
pos++;
ofs += 4; /* Maximum offset needed. */
if (action == DASM_REL_LG || action == DASM_REL_PC) {
b[pos++] = ofs; /* Store pass1 offset estimate. */
} else if (sizeof(ptrdiff_t) == 8) {
ofs += 4;
}
break;
case DASM_LABEL_LG: pl = D->lglabels + *p++; CKPL(lg, LG); goto putlabel;
case DASM_LABEL_PC: pl = D->pclabels + va_arg(ap, int); CKPL(pc, PC);
putlabel:
n = *pl; /* n > 0: Collapse rel chain and replace with label pos. */
while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = pos; }
*pl = -pos; /* Label exists now. */
b[pos++] = ofs; /* Store pass1 offset estimate. */
break;
case DASM_ALIGN:
ofs += *p++; /* Maximum alignment needed (arg is 2**n-1). */
b[pos++] = ofs; /* Store pass1 offset estimate. */
break;
case DASM_EXTERN: p += 2; ofs += 4; break;
case DASM_ESC: p++; ofs++; break;
case DASM_MARK: mrm = p[-2]; break;
case DASM_SECTION:
n = *p; CK(n < D->maxsection, RANGE_SEC); D->section = &D->sections[n];
case DASM_STOP: goto stop;
}
}
}
stop:
va_end(ap);
sec->pos = pos;
sec->ofs = ofs;
}
#undef CK
/* Pass 2: Link sections, shrink branches/aligns, fix label offsets. */
int dasm_link(Dst_DECL, size_t *szp)
{
dasm_State *D = Dst_REF;
int secnum;
int ofs = 0;
#ifdef DASM_CHECKS
*szp = 0;
if (D->status != DASM_S_OK) return D->status;
{
int pc;
for (pc = 0; pc*sizeof(int) < D->pcsize; pc++)
if (D->pclabels[pc] > 0) return DASM_S_UNDEF_PC|pc;
}
#endif
{ /* Handle globals not defined in this translation unit. */
int idx;
for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) {
int n = D->lglabels[idx];
/* Undefined label: Collapse rel chain and replace with marker (< 0). */
while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; }
}
}
/* Combine all code sections. No support for data sections (yet). */
for (secnum = 0; secnum < D->maxsection; secnum++) {
dasm_Section *sec = D->sections + secnum;
int *b = sec->rbuf;
int pos = DASM_SEC2POS(secnum);
int lastpos = sec->pos;
while (pos != lastpos) {
dasm_ActList p = D->actionlist + b[pos++];
int op = 0;
while (1) {
int action = *p++;
switch (action) {
case DASM_REL_LG: p++;
/* fallthrough */
case DASM_REL_PC: {
int shrink = op == 0xe9 ? 3 : ((op&0xf0) == 0x80 ? 4 : 0);
if (shrink) { /* Shrinkable branch opcode? */
int lofs, lpos = b[pos];
if (lpos < 0) goto noshrink; /* Ext global? */
lofs = *DASM_POS2PTR(D, lpos);
if (lpos > pos) { /* Fwd label: add cumulative section offsets. */
int i;
for (i = secnum; i < DASM_POS2SEC(lpos); i++)
lofs += D->sections[i].ofs;
} else {
lofs -= ofs; /* Bkwd label: unfix offset. */
}
lofs -= b[pos+1]; /* Short branch ok? */
if (lofs >= -128-shrink && lofs <= 127) ofs -= shrink; /* Yes. */
else { noshrink: shrink = 0; } /* No, cannot shrink op. */
}
b[pos+1] = shrink;
pos += 2;
break;
}
/* fallthrough */
case DASM_SPACE: case DASM_IMM_LG: case DASM_VREG: p++;
/* fallthrough */
case DASM_DISP: case DASM_IMM_S: case DASM_IMM_B: case DASM_IMM_W:
case DASM_IMM_D: case DASM_IMM_WB: case DASM_IMM_DB:
case DASM_SETLABEL: case DASM_REL_A: case DASM_IMM_PC: pos++; break;
case DASM_LABEL_LG: p++;
/* fallthrough */
case DASM_LABEL_PC: b[pos++] += ofs; break; /* Fix label offset. */
case DASM_ALIGN: ofs -= (b[pos++]+ofs)&*p++; break; /* Adjust ofs. */
case DASM_EXTERN: p += 2; break;
case DASM_ESC: op = *p++; break;
case DASM_MARK: break;
case DASM_SECTION: case DASM_STOP: goto stop;
default: op = action; break;
}
}
stop: (void)0;
}
ofs += sec->ofs; /* Next section starts right after current section. */
}
D->codesize = ofs; /* Total size of all code sections */
*szp = ofs;
return DASM_S_OK;
}
#define dasmb(x) *cp++ = (unsigned char)(x)
#ifndef DASM_ALIGNED_WRITES
#define dasmw(x) \
do { *((unsigned short *)cp) = (unsigned short)(x); cp+=2; } while (0)
#define dasmd(x) \
do { *((unsigned int *)cp) = (unsigned int)(x); cp+=4; } while (0)
#define dasmq(x) \
do { *((unsigned long long *)cp) = (unsigned long long)(x); cp+=8; } while (0)
#else
#define dasmw(x) do { dasmb(x); dasmb((x)>>8); } while (0)
#define dasmd(x) do { dasmw(x); dasmw((x)>>16); } while (0)
#define dasmq(x) do { dasmd(x); dasmd((x)>>32); } while (0)
#endif
static unsigned char *dasma_(unsigned char *cp, ptrdiff_t x)
{
if (sizeof(ptrdiff_t) == 8)
dasmq((unsigned long long)x);
else
dasmd((unsigned int)x);
return cp;
}
#define dasma(x) (cp = dasma_(cp, (x)))
/* Pass 3: Encode sections. */
int dasm_encode(Dst_DECL, void *buffer)
{
dasm_State *D = Dst_REF;
unsigned char *base = (unsigned char *)buffer;
unsigned char *cp = base;
int secnum;
/* Encode all code sections. No support for data sections (yet). */
for (secnum = 0; secnum < D->maxsection; secnum++) {
dasm_Section *sec = D->sections + secnum;
int *b = sec->buf;
int *endb = sec->rbuf + sec->pos;
while (b != endb) {
dasm_ActList p = D->actionlist + *b++;
unsigned char *mark = NULL;
while (1) {
int action = *p++;
int n = (action >= DASM_DISP && action <= DASM_ALIGN) ? *b++ : 0;
switch (action) {
case DASM_DISP: if (!mark) mark = cp; {
unsigned char *mm = mark;
if (*p != DASM_IMM_DB && *p != DASM_IMM_WB) mark = NULL;
if (n == 0) { int mrm = mm[-1]&7; if (mrm == 4) mrm = mm[0]&7;
if (mrm != 5) { mm[-1] -= 0x80; break; } }
if (((n+128) & -256) != 0) goto wd; else mm[-1] -= 0x40;
}
/* fallthrough */
case DASM_IMM_S: case DASM_IMM_B: wb: dasmb(n); break;
case DASM_IMM_DB: if (((n+128)&-256) == 0) {
db: if (!mark) mark = cp; mark[-2] += 2; mark = NULL; goto wb;
} else mark = NULL;
/* fallthrough */
case DASM_IMM_D: wd: dasmd(n); break;
case DASM_IMM_WB: if (((n+128)&-256) == 0) goto db; else mark = NULL;
/* fallthrough */
case DASM_IMM_W: dasmw(n); break;
case DASM_VREG: {
int t = *p++;
unsigned char *ex = cp - (t&7);
if ((n & 8) && t < 0xa0) {
if (*ex & 0x80) ex[1] ^= 0x20 << (t>>6); else *ex ^= 1 << (t>>6);
n &= 7;
} else if (n & 0x10) {
if (*ex & 0x80) {
*ex = 0xc5; ex[1] = (ex[1] & 0x80) | ex[2]; ex += 2;
}
while (++ex < cp) ex[-1] = *ex;
if (mark) mark--;
cp--;
n &= 7;
}
if (t >= 0xc0) n <<= 4;
else if (t >= 0x40) n <<= 3;
else if (n == 4 && t < 0x20) { cp[-1] ^= n; *cp++ = 0x20; }
cp[-1] ^= n;
break;
}
case DASM_REL_LG: p++; if (n >= 0) goto rel_pc;
b++; n = (int)(ptrdiff_t)D->globals[-n-10];
/* fallthrough */
case DASM_REL_A: rel_a:
n -= (unsigned int)(ptrdiff_t)(cp+4); goto wd; /* !x64 */
case DASM_REL_PC: rel_pc: {
int shrink = *b++;
int *pb = DASM_POS2PTR(D, n); if (*pb < 0) { n = pb[1]; goto rel_a; }
n = *pb - ((int)(cp-base) + 4-shrink);
if (shrink == 0) goto wd;
if (shrink == 4) { cp--; cp[-1] = *cp-0x10; } else cp[-1] = 0xeb;
goto wb;
}
case DASM_IMM_LG:
p++;
if (n < 0) { dasma((ptrdiff_t)D->globals[-n-10]); break; }
/* fallthrough */
case DASM_IMM_PC: {
int *pb = DASM_POS2PTR(D, n);
dasma(*pb < 0 ? (ptrdiff_t)pb[1] : (*pb + (ptrdiff_t)base));
break;
}
case DASM_LABEL_LG: {
int idx = *p++;
if (idx >= 10)
D->globals[idx-10] = (void *)(base + (*p == DASM_SETLABEL ? *b : n));
break;
}
case DASM_LABEL_PC: case DASM_SETLABEL: break;
case DASM_SPACE: { int fill = *p++; while (n--) *cp++ = fill; break; }
case DASM_ALIGN:
n = *p++;
while (((cp-base) & n)) *cp++ = 0x90; /* nop */
break;
case DASM_EXTERN: n = DASM_EXTERN(Dst, cp, p[1], *p); p += 2; goto wd;
case DASM_MARK: mark = cp; break;
case DASM_ESC: action = *p++;
/* fallthrough */
default: *cp++ = action; break;
case DASM_SECTION: case DASM_STOP: goto stop;
}
}
stop: (void)0;
}
}
if (base + D->codesize != cp) /* Check for phase errors. */
return DASM_S_PHASE;
return DASM_S_OK;
}
/* Get PC label offset. */
int dasm_getpclabel(Dst_DECL, unsigned int pc)
{
dasm_State *D = Dst_REF;
if (pc*sizeof(int) < D->pcsize) {
int pos = D->pclabels[pc];
if (pos < 0) return *DASM_POS2PTR(D, -pos);
if (pos > 0) return -1; /* Undefined. */
}
return -2; /* Unused or out of range. */
}
#ifdef DASM_CHECKS
/* Optional sanity checker to call between isolated encoding steps. */
int dasm_checkstep(Dst_DECL, int secmatch)
{
dasm_State *D = Dst_REF;
if (D->status == DASM_S_OK) {
int i;
for (i = 1; i <= 9; i++) {
if (D->lglabels[i] > 0) { D->status = DASM_S_UNDEF_L|i; break; }
D->lglabels[i] = 0;
}
}
if (D->status == DASM_S_OK && secmatch >= 0 &&
D->section != &D->sections[secmatch])
D->status = DASM_S_MATCH_SEC|(int)(D->section-D->sections);
return D->status;
}
#endif
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
-3
View File
@@ -1,3 +0,0 @@
minilua
buildvm
buildvm_arch.h
-4
View File
@@ -1,4 +0,0 @@
The files in this directory are only used during the build process of LuaJIT.
For cross-compilation, they must be executed on the host, not on the target.
These files should NOT be installed!
-529
View File
@@ -1,529 +0,0 @@
/*
** LuaJIT VM builder.
** Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
**
** This is a tool to build the hand-tuned assembler code required for
** LuaJIT's bytecode interpreter. It supports a variety of output formats
** to feed different toolchains (see usage() below).
**
** This tool is not particularly optimized because it's only used while
** _building_ LuaJIT. There's no point in distributing or installing it.
** Only the object code generated by this tool is linked into LuaJIT.
**
** Caveat: some memory is not free'd, error handling is lazy.
** It's a one-shot tool -- any effort fixing this would be wasted.
*/
#include "buildvm.h"
#include "lj_obj.h"
#include "lj_gc.h"
#include "lj_bc.h"
#if LJ_HASJIT
#include "lj_ir.h"
#include "lj_ircall.h"
#endif
#include "lj_frame.h"
#include "lj_dispatch.h"
#if LJ_HASFFI
#include "lj_ctype.h"
#include "lj_ccall.h"
#endif
#include "luajit.h"
#if defined(_WIN32)
#include <fcntl.h>
#include <io.h>
#endif
/* ------------------------------------------------------------------------ */
/* DynASM glue definitions. */
#define Dst ctx
#define Dst_DECL BuildCtx *ctx
#define Dst_REF (ctx->D)
#define DASM_CHECKS 1
#include "../dynasm/dasm_proto.h"
/* Glue macros for DynASM. */
static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type);
#define DASM_EXTERN(ctx, addr, idx, type) \
collect_reloc(ctx, addr, idx, type)
/* ------------------------------------------------------------------------ */
/* Avoid trouble if cross-compiling for an x86 target. Speed doesn't matter. */
#define DASM_ALIGNED_WRITES 1
/* Embed architecture-specific DynASM encoder. */
#if LJ_TARGET_X86ORX64
#include "../dynasm/dasm_x86.h"
#elif LJ_TARGET_ARM
#include "../dynasm/dasm_arm.h"
#elif LJ_TARGET_ARM64
#include "../dynasm/dasm_arm64.h"
#elif LJ_TARGET_PPC
#include "../dynasm/dasm_ppc.h"
#elif LJ_TARGET_MIPS
#include "../dynasm/dasm_mips.h"
#else
#error "No support for this architecture (yet)"
#endif
/* Embed generated architecture-specific backend. */
#include "buildvm_arch.h"
/* ------------------------------------------------------------------------ */
void owrite(BuildCtx *ctx, const void *ptr, size_t sz)
{
if (fwrite(ptr, 1, sz, ctx->fp) != sz) {
fprintf(stderr, "Error: cannot write to output file: %s\n",
strerror(errno));
exit(1);
}
}
/* ------------------------------------------------------------------------ */
/* Emit code as raw bytes. Only used for DynASM debugging. */
static void emit_raw(BuildCtx *ctx)
{
owrite(ctx, ctx->code, ctx->codesz);
}
/* -- Build machine code -------------------------------------------------- */
static const char *sym_decorate(BuildCtx *ctx,
const char *prefix, const char *suffix)
{
char name[256];
char *p;
#if LJ_64
const char *symprefix = ctx->mode == BUILD_machasm ? "_" : "";
#elif LJ_TARGET_XBOX360
const char *symprefix = "";
#else
const char *symprefix = ctx->mode != BUILD_elfasm ? "_" : "";
#endif
sprintf(name, "%s%s%s", symprefix, prefix, suffix);
p = strchr(name, '@');
if (p) {
#if LJ_TARGET_X86ORX64
if (!LJ_64 && (ctx->mode == BUILD_coffasm || ctx->mode == BUILD_peobj))
name[0] = name[1] == 'R' ? '_' : '@'; /* Just for _RtlUnwind@16. */
else
*p = '\0';
#elif LJ_TARGET_PPC && !LJ_TARGET_CONSOLE
/* Keep @plt etc. */
#else
*p = '\0';
#endif
}
p = (char *)malloc(strlen(name)+1); /* MSVC doesn't like strdup. */
strcpy(p, name);
return p;
}
#define NRELOCSYM (sizeof(extnames)/sizeof(extnames[0])-1)
static int relocmap[NRELOCSYM];
/* Collect external relocations. */
static int collect_reloc(BuildCtx *ctx, uint8_t *addr, int idx, int type)
{
if (ctx->nreloc >= BUILD_MAX_RELOC) {
fprintf(stderr, "Error: too many relocations, increase BUILD_MAX_RELOC.\n");
exit(1);
}
if (relocmap[idx] < 0) {
relocmap[idx] = ctx->nrelocsym;
ctx->relocsym[ctx->nrelocsym] = sym_decorate(ctx, "", extnames[idx]);
ctx->nrelocsym++;
}
ctx->reloc[ctx->nreloc].ofs = (int32_t)(addr - ctx->code);
ctx->reloc[ctx->nreloc].sym = relocmap[idx];
ctx->reloc[ctx->nreloc].type = type;
ctx->nreloc++;
#if LJ_TARGET_XBOX360
return (int)(ctx->code - addr) + 4; /* Encode symbol offset of .text. */
#else
return 0; /* Encode symbol offset of 0. */
#endif
}
/* Naive insertion sort. Performance doesn't matter here. */
static void sym_insert(BuildCtx *ctx, int32_t ofs,
const char *prefix, const char *suffix)
{
ptrdiff_t i = ctx->nsym++;
while (i > 0) {
if (ctx->sym[i-1].ofs <= ofs)
break;
ctx->sym[i] = ctx->sym[i-1];
i--;
}
ctx->sym[i].ofs = ofs;
ctx->sym[i].name = sym_decorate(ctx, prefix, suffix);
}
/* Build the machine code. */
static int build_code(BuildCtx *ctx)
{
int status;
int i;
/* Initialize DynASM structures. */
ctx->nglob = GLOB__MAX;
ctx->glob = (void **)malloc(ctx->nglob*sizeof(void *));
memset(ctx->glob, 0, ctx->nglob*sizeof(void *));
ctx->nreloc = 0;
ctx->globnames = globnames;
ctx->extnames = extnames;
ctx->relocsym = (const char **)malloc(NRELOCSYM*sizeof(const char *));
ctx->nrelocsym = 0;
for (i = 0; i < (int)NRELOCSYM; i++) relocmap[i] = -1;
ctx->dasm_ident = DASM_IDENT;
ctx->dasm_arch = DASM_ARCH;
dasm_init(Dst, DASM_MAXSECTION);
dasm_setupglobal(Dst, ctx->glob, ctx->nglob);
dasm_setup(Dst, build_actionlist);
/* Call arch-specific backend to emit the code. */
ctx->npc = build_backend(ctx);
/* Finalize the code. */
(void)dasm_checkstep(Dst, -1);
if ((status = dasm_link(Dst, &ctx->codesz))) return status;
ctx->code = (uint8_t *)malloc(ctx->codesz);
if ((status = dasm_encode(Dst, (void *)ctx->code))) return status;
/* Allocate symbol table and bytecode offsets. */
ctx->beginsym = sym_decorate(ctx, "", LABEL_PREFIX "vm_asm_begin");
ctx->sym = (BuildSym *)malloc((ctx->npc+ctx->nglob+1)*sizeof(BuildSym));
ctx->nsym = 0;
ctx->bc_ofs = (int32_t *)malloc(ctx->npc*sizeof(int32_t));
/* Collect the opcodes (PC labels). */
for (i = 0; i < ctx->npc; i++) {
int32_t ofs = dasm_getpclabel(Dst, i);
if (ofs < 0) return 0x22000000|i;
ctx->bc_ofs[i] = ofs;
if ((LJ_HASJIT ||
!(i == BC_JFORI || i == BC_JFORL || i == BC_JITERL || i == BC_JLOOP ||
i == BC_IFORL || i == BC_IITERL || i == BC_ILOOP)) &&
(LJ_HASFFI || i != BC_KCDATA))
sym_insert(ctx, ofs, LABEL_PREFIX_BC, bc_names[i]);
}
/* Collect the globals (named labels). */
for (i = 0; i < ctx->nglob; i++) {
const char *gl = globnames[i];
int len = (int)strlen(gl);
if (!ctx->glob[i]) {
fprintf(stderr, "Error: undefined global %s\n", gl);
exit(2);
}
/* Skip the _Z symbols. */
if (!(len >= 2 && gl[len-2] == '_' && gl[len-1] == 'Z'))
sym_insert(ctx, (int32_t)((uint8_t *)(ctx->glob[i]) - ctx->code),
LABEL_PREFIX, globnames[i]);
}
/* Close the address range. */
sym_insert(ctx, (int32_t)ctx->codesz, "", "");
ctx->nsym--;
dasm_free(Dst);
return 0;
}
/* -- Generate VM enums --------------------------------------------------- */
const char *const bc_names[] = {
#define BCNAME(name, ma, mb, mc, mt) #name,
BCDEF(BCNAME)
#undef BCNAME
NULL
};
#if LJ_HASJIT
const char *const ir_names[] = {
#define IRNAME(name, m, m1, m2) #name,
IRDEF(IRNAME)
#undef IRNAME
NULL
};
const char *const irt_names[] = {
#define IRTNAME(name, size) #name,
IRTDEF(IRTNAME)
#undef IRTNAME
NULL
};
const char *const irfpm_names[] = {
#define FPMNAME(name) #name,
IRFPMDEF(FPMNAME)
#undef FPMNAME
NULL
};
const char *const irfield_names[] = {
#define FLNAME(name, ofs) #name,
IRFLDEF(FLNAME)
#undef FLNAME
NULL
};
const char *const ircall_names[] = {
#define IRCALLNAME(cond, name, nargs, kind, type, flags) #name,
IRCALLDEF(IRCALLNAME)
#undef IRCALLNAME
NULL
};
static const char *const trace_errors[] = {
#define TREDEF(name, msg) msg,
#include "lj_traceerr.h"
NULL
};
#endif
#if LJ_HASJIT
static const char *lower(char *buf, const char *s)
{
char *p = buf;
while (*s) {
*p++ = (*s >= 'A' && *s <= 'Z') ? *s+0x20 : *s;
s++;
}
*p = '\0';
return buf;
}
#endif
/* Emit C source code for bytecode-related definitions. */
static void emit_bcdef(BuildCtx *ctx)
{
int i;
fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n");
fprintf(ctx->fp, "LJ_DATADEF const uint16_t lj_bc_ofs[] = {\n");
for (i = 0; i < ctx->npc; i++) {
if (i != 0)
fprintf(ctx->fp, ",\n");
fprintf(ctx->fp, "%d", ctx->bc_ofs[i]);
}
}
/* Emit VM definitions as Lua code for debug modules. */
static void emit_vmdef(BuildCtx *ctx)
{
#if LJ_HASJIT
char buf[80];
#endif
int i;
fprintf(ctx->fp, "-- This is a generated file. DO NOT EDIT!\n\n");
fprintf(ctx->fp, "assert(require(\"jit\").version == \"%s\", \"LuaJIT core/library version mismatch\")\n\n", LUAJIT_VERSION);
fprintf(ctx->fp, "return {\n\n");
fprintf(ctx->fp, "bcnames = \"");
for (i = 0; bc_names[i]; i++) fprintf(ctx->fp, "%-6s", bc_names[i]);
fprintf(ctx->fp, "\",\n\n");
#if LJ_HASJIT
fprintf(ctx->fp, "irnames = \"");
for (i = 0; ir_names[i]; i++) fprintf(ctx->fp, "%-6s", ir_names[i]);
fprintf(ctx->fp, "\",\n\n");
fprintf(ctx->fp, "irfpm = { [0]=");
for (i = 0; irfpm_names[i]; i++)
fprintf(ctx->fp, "\"%s\", ", lower(buf, irfpm_names[i]));
fprintf(ctx->fp, "},\n\n");
fprintf(ctx->fp, "irfield = { [0]=");
for (i = 0; irfield_names[i]; i++) {
char *p;
lower(buf, irfield_names[i]);
p = strchr(buf, '_');
if (p) *p = '.';
fprintf(ctx->fp, "\"%s\", ", buf);
}
fprintf(ctx->fp, "},\n\n");
fprintf(ctx->fp, "ircall = {\n[0]=");
for (i = 0; ircall_names[i]; i++)
fprintf(ctx->fp, "\"%s\",\n", ircall_names[i]);
fprintf(ctx->fp, "},\n\n");
fprintf(ctx->fp, "traceerr = {\n[0]=");
for (i = 0; trace_errors[i]; i++)
fprintf(ctx->fp, "\"%s\",\n", trace_errors[i]);
fprintf(ctx->fp, "},\n\n");
#endif
}
/* -- Argument parsing ---------------------------------------------------- */
/* Build mode names. */
static const char *const modenames[] = {
#define BUILDNAME(name) #name,
BUILDDEF(BUILDNAME)
#undef BUILDNAME
NULL
};
/* Print usage information and exit. */
static void usage(void)
{
int i;
fprintf(stderr, LUAJIT_VERSION " VM builder.\n");
fprintf(stderr, LUAJIT_COPYRIGHT ", " LUAJIT_URL "\n");
fprintf(stderr, "Target architecture: " LJ_ARCH_NAME "\n\n");
fprintf(stderr, "Usage: buildvm -m mode [-o outfile] [infiles...]\n\n");
fprintf(stderr, "Available modes:\n");
for (i = 0; i < BUILD__MAX; i++)
fprintf(stderr, " %s\n", modenames[i]);
exit(1);
}
/* Parse the output mode name. */
static BuildMode parsemode(const char *mode)
{
int i;
for (i = 0; modenames[i]; i++)
if (!strcmp(mode, modenames[i]))
return (BuildMode)i;
usage();
return (BuildMode)-1;
}
/* Parse arguments. */
static void parseargs(BuildCtx *ctx, char **argv)
{
const char *a;
int i;
ctx->mode = (BuildMode)-1;
ctx->outname = "-";
for (i = 1; (a = argv[i]) != NULL; i++) {
if (a[0] != '-')
break;
switch (a[1]) {
case '-':
if (a[2]) goto err;
i++;
goto ok;
case '\0':
goto ok;
case 'm':
i++;
if (a[2] || argv[i] == NULL) goto err;
ctx->mode = parsemode(argv[i]);
break;
case 'o':
i++;
if (a[2] || argv[i] == NULL) goto err;
ctx->outname = argv[i];
break;
default: err:
usage();
break;
}
}
ok:
ctx->args = argv+i;
if (ctx->mode == (BuildMode)-1) goto err;
}
int main(int argc, char **argv)
{
BuildCtx ctx_;
BuildCtx *ctx = &ctx_;
int status, binmode;
if (sizeof(void *) != 4*LJ_32+8*LJ_64) {
fprintf(stderr,"Error: pointer size mismatch in cross-build.\n");
fprintf(stderr,"Try: make HOST_CC=\"gcc -m32\" CROSS=...\n\n");
return 1;
}
UNUSED(argc);
parseargs(ctx, argv);
if ((status = build_code(ctx))) {
fprintf(stderr,"Error: DASM error %08x\n", status);
return 1;
}
switch (ctx->mode) {
case BUILD_peobj:
case BUILD_raw:
binmode = 1;
break;
default:
binmode = 0;
break;
}
if (ctx->outname[0] == '-' && ctx->outname[1] == '\0') {
ctx->fp = stdout;
#if defined(_WIN32)
if (binmode)
_setmode(_fileno(stdout), _O_BINARY); /* Yuck. */
#endif
} else if (!(ctx->fp = fopen(ctx->outname, binmode ? "wb" : "w"))) {
fprintf(stderr, "Error: cannot open output file '%s': %s\n",
ctx->outname, strerror(errno));
exit(1);
}
switch (ctx->mode) {
case BUILD_elfasm:
case BUILD_coffasm:
case BUILD_machasm:
emit_asm(ctx);
emit_asm_debug(ctx);
break;
case BUILD_peobj:
emit_peobj(ctx);
break;
case BUILD_raw:
emit_raw(ctx);
break;
case BUILD_bcdef:
emit_bcdef(ctx);
emit_lib(ctx);
break;
case BUILD_vmdef:
emit_vmdef(ctx);
emit_lib(ctx);
fprintf(ctx->fp, "}\n\n");
break;
case BUILD_ffdef:
case BUILD_libdef:
case BUILD_recdef:
emit_lib(ctx);
break;
case BUILD_folddef:
emit_fold(ctx);
break;
default:
break;
}
fflush(ctx->fp);
if (ferror(ctx->fp)) {
fprintf(stderr, "Error: cannot write to output file: %s\n",
strerror(errno));
exit(1);
}
fclose(ctx->fp);
return 0;
}
-105
View File
@@ -1,105 +0,0 @@
/*
** LuaJIT VM builder.
** Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
*/
#ifndef _BUILDVM_H
#define _BUILDVM_H
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include "lj_def.h"
#include "lj_arch.h"
/* Hardcoded limits. Increase as needed. */
#define BUILD_MAX_RELOC 200 /* Max. number of relocations. */
#define BUILD_MAX_FOLD 4096 /* Max. number of fold rules. */
/* Prefix for scanned library definitions. */
#define LIBDEF_PREFIX "LJLIB_"
/* Prefix for scanned fold definitions. */
#define FOLDDEF_PREFIX "LJFOLD"
/* Prefixes for generated labels. */
#define LABEL_PREFIX "lj_"
#define LABEL_PREFIX_BC LABEL_PREFIX "BC_"
#define LABEL_PREFIX_FF LABEL_PREFIX "ff_"
#define LABEL_PREFIX_CF LABEL_PREFIX "cf_"
#define LABEL_PREFIX_FFH LABEL_PREFIX "ffh_"
#define LABEL_PREFIX_LIBCF LABEL_PREFIX "lib_cf_"
#define LABEL_PREFIX_LIBINIT LABEL_PREFIX "lib_init_"
/* Forward declaration. */
struct dasm_State;
/* Build modes. */
#define BUILDDEF(_) \
_(elfasm) _(coffasm) _(machasm) _(peobj) _(raw) \
_(bcdef) _(ffdef) _(libdef) _(recdef) _(vmdef) \
_(folddef)
typedef enum {
#define BUILDENUM(name) BUILD_##name,
BUILDDEF(BUILDENUM)
#undef BUILDENUM
BUILD__MAX
} BuildMode;
/* Code relocation. */
typedef struct BuildReloc {
int32_t ofs;
int sym;
int type;
} BuildReloc;
typedef struct BuildSym {
const char *name;
int32_t ofs;
} BuildSym;
/* Build context structure. */
typedef struct BuildCtx {
/* DynASM state pointer. Should be first member. */
struct dasm_State *D;
/* Parsed command line. */
BuildMode mode;
FILE *fp;
const char *outname;
char **args;
/* Code and symbols generated by DynASM. */
uint8_t *code;
size_t codesz;
int npc, nglob, nsym, nreloc, nrelocsym;
void **glob;
BuildSym *sym;
const char **relocsym;
int32_t *bc_ofs;
const char *beginsym;
/* Strings generated by DynASM. */
const char *const *globnames;
const char *const *extnames;
const char *dasm_ident;
const char *dasm_arch;
/* Relocations. */
BuildReloc reloc[BUILD_MAX_RELOC];
} BuildCtx;
extern void owrite(BuildCtx *ctx, const void *ptr, size_t sz);
extern void emit_asm(BuildCtx *ctx);
extern void emit_peobj(BuildCtx *ctx);
extern void emit_lib(BuildCtx *ctx);
extern void emit_fold(BuildCtx *ctx);
extern const char *const bc_names[];
extern const char *const ir_names[];
extern const char *const irt_names[];
extern const char *const irfpm_names[];
extern const char *const irfield_names[];
extern const char *const ircall_names[];
#endif
-355
View File
@@ -1,355 +0,0 @@
/*
** LuaJIT VM builder: Assembler source code emitter.
** Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
*/
#include "buildvm.h"
#include "lj_bc.h"
/* ------------------------------------------------------------------------ */
#if LJ_TARGET_X86ORX64
/* Emit bytes piecewise as assembler text. */
static void emit_asm_bytes(BuildCtx *ctx, uint8_t *p, int n)
{
int i;
for (i = 0; i < n; i++) {
if ((i & 15) == 0)
fprintf(ctx->fp, "\t.byte %d", p[i]);
else
fprintf(ctx->fp, ",%d", p[i]);
if ((i & 15) == 15) putc('\n', ctx->fp);
}
if ((n & 15) != 0) putc('\n', ctx->fp);
}
/* Emit relocation */
static void emit_asm_reloc(BuildCtx *ctx, int type, const char *sym)
{
switch (ctx->mode) {
case BUILD_elfasm:
if (type)
fprintf(ctx->fp, "\t.long %s-.-4\n", sym);
else
fprintf(ctx->fp, "\t.long %s\n", sym);
break;
case BUILD_coffasm:
fprintf(ctx->fp, "\t.def %s; .scl 3; .type 32; .endef\n", sym);
if (type)
fprintf(ctx->fp, "\t.long %s-.-4\n", sym);
else
fprintf(ctx->fp, "\t.long %s\n", sym);
break;
default: /* BUILD_machasm for relative relocations handled below. */
fprintf(ctx->fp, "\t.long %s\n", sym);
break;
}
}
static const char *const jccnames[] = {
"jo", "jno", "jb", "jnb", "jz", "jnz", "jbe", "ja",
"js", "jns", "jpe", "jpo", "jl", "jge", "jle", "jg"
};
/* Emit x86/x64 text relocations. */
static void emit_asm_reloc_text(BuildCtx *ctx, uint8_t *cp, int n,
const char *sym)
{
const char *opname = NULL;
if (--n < 0) goto err;
if (cp[n] == 0xe8) {
opname = "call";
} else if (cp[n] == 0xe9) {
opname = "jmp";
} else if (cp[n] >= 0x80 && cp[n] <= 0x8f && n > 0 && cp[n-1] == 0x0f) {
opname = jccnames[cp[n]-0x80];
n--;
} else {
err:
fprintf(stderr, "Error: unsupported opcode for %s symbol relocation.\n",
sym);
exit(1);
}
emit_asm_bytes(ctx, cp, n);
if (strncmp(sym+(*sym == '_'), LABEL_PREFIX, sizeof(LABEL_PREFIX)-1)) {
/* Various fixups for external symbols outside of our binary. */
if (ctx->mode == BUILD_elfasm) {
if (LJ_32)
fprintf(ctx->fp, "#if __PIC__\n\t%s lj_wrap_%s\n#else\n", opname, sym);
fprintf(ctx->fp, "\t%s %s@PLT\n", opname, sym);
if (LJ_32)
fprintf(ctx->fp, "#endif\n");
return;
} else if (LJ_32 && ctx->mode == BUILD_machasm) {
fprintf(ctx->fp, "\t%s L%s$stub\n", opname, sym);
return;
}
}
fprintf(ctx->fp, "\t%s %s\n", opname, sym);
}
#else
/* Emit words piecewise as assembler text. */
static void emit_asm_words(BuildCtx *ctx, uint8_t *p, int n)
{
int i;
for (i = 0; i < n; i += 4) {
uint32_t ins = *(uint32_t *)(p+i);
#if LJ_TARGET_ARM64 && LJ_BE
ins = lj_bswap(ins); /* ARM64 instructions are always little-endian. */
#endif
if ((i & 15) == 0)
fprintf(ctx->fp, "\t.long 0x%08x", ins);
else
fprintf(ctx->fp, ",0x%08x", ins);
if ((i & 15) == 12) putc('\n', ctx->fp);
}
if ((n & 15) != 0) putc('\n', ctx->fp);
}
/* Emit relocation as part of an instruction. */
static void emit_asm_wordreloc(BuildCtx *ctx, uint8_t *p, int n,
const char *sym)
{
uint32_t ins;
emit_asm_words(ctx, p, n-4);
ins = *(uint32_t *)(p+n-4);
#if LJ_TARGET_ARM
if ((ins & 0xff000000u) == 0xfa000000u) {
fprintf(ctx->fp, "\tblx %s\n", sym);
} else if ((ins & 0x0e000000u) == 0x0a000000u) {
fprintf(ctx->fp, "\t%s%.2s %s\n", (ins & 0x01000000u) ? "bl" : "b",
&"eqnecsccmiplvsvchilsgeltgtle"[2*(ins >> 28)], sym);
} else {
fprintf(stderr,
"Error: unsupported opcode %08x for %s symbol relocation.\n",
ins, sym);
exit(1);
}
#elif LJ_TARGET_ARM64
if ((ins >> 26) == 0x25u) {
fprintf(ctx->fp, "\tbl %s\n", sym);
} else {
fprintf(stderr,
"Error: unsupported opcode %08x for %s symbol relocation.\n",
ins, sym);
exit(1);
}
#elif LJ_TARGET_PPC
#if LJ_TARGET_PS3
#define TOCPREFIX "."
#else
#define TOCPREFIX ""
#endif
if ((ins >> 26) == 16) {
fprintf(ctx->fp, "\t%s %d, %d, " TOCPREFIX "%s\n",
(ins & 1) ? "bcl" : "bc", (ins >> 21) & 31, (ins >> 16) & 31, sym);
} else if ((ins >> 26) == 18) {
fprintf(ctx->fp, "\t%s " TOCPREFIX "%s\n", (ins & 1) ? "bl" : "b", sym);
} else {
fprintf(stderr,
"Error: unsupported opcode %08x for %s symbol relocation.\n",
ins, sym);
exit(1);
}
#elif LJ_TARGET_MIPS
fprintf(stderr,
"Error: unsupported opcode %08x for %s symbol relocation.\n",
ins, sym);
exit(1);
#else
#error "missing relocation support for this architecture"
#endif
}
#endif
#if LJ_TARGET_ARM
#define ELFASM_PX "%%"
#else
#define ELFASM_PX "@"
#endif
/* Emit an assembler label. */
static void emit_asm_label(BuildCtx *ctx, const char *name, int size, int isfunc)
{
switch (ctx->mode) {
case BUILD_elfasm:
#if LJ_TARGET_PS3
if (!strncmp(name, "lj_vm_", 6) &&
strcmp(name, ctx->beginsym) &&
!strstr(name, "hook")) {
fprintf(ctx->fp,
"\n\t.globl %s\n"
"\t.section \".opd\",\"aw\"\n"
"%s:\n"
"\t.long .%s,.TOC.@tocbase32\n"
"\t.size %s,8\n"
"\t.previous\n"
"\t.globl .%s\n"
"\t.hidden .%s\n"
"\t.type .%s, " ELFASM_PX "function\n"
"\t.size .%s, %d\n"
".%s:\n",
name, name, name, name, name, name, name, name, size, name);
break;
}
#endif
fprintf(ctx->fp,
"\n\t.globl %s\n"
"\t.hidden %s\n"
"\t.type %s, " ELFASM_PX "%s\n"
"\t.size %s, %d\n"
"%s:\n",
name, name, name, isfunc ? "function" : "object", name, size, name);
break;
case BUILD_coffasm:
fprintf(ctx->fp, "\n\t.globl %s\n", name);
if (isfunc)
fprintf(ctx->fp, "\t.def %s; .scl 3; .type 32; .endef\n", name);
fprintf(ctx->fp, "%s:\n", name);
break;
case BUILD_machasm:
fprintf(ctx->fp,
"\n\t.private_extern %s\n"
"\t.no_dead_strip %s\n"
"%s:\n", name, name, name);
break;
default:
break;
}
}
/* Emit alignment. */
static void emit_asm_align(BuildCtx *ctx, int bits)
{
switch (ctx->mode) {
case BUILD_elfasm:
case BUILD_coffasm:
fprintf(ctx->fp, "\t.p2align %d\n", bits);
break;
case BUILD_machasm:
fprintf(ctx->fp, "\t.align %d\n", bits);
break;
default:
break;
}
}
/* ------------------------------------------------------------------------ */
/* Emit assembler source code. */
void emit_asm(BuildCtx *ctx)
{
int i, rel;
fprintf(ctx->fp, "\t.file \"buildvm_%s.dasc\"\n", ctx->dasm_arch);
fprintf(ctx->fp, "\t.text\n");
#if LJ_TARGET_MIPS32 && !LJ_ABI_SOFTFP
fprintf(ctx->fp, "\t.module fp=32\n");
#endif
#if LJ_TARGET_MIPS
fprintf(ctx->fp, "\t.set nomips16\n\t.abicalls\n\t.set noreorder\n\t.set nomacro\n");
#endif
emit_asm_align(ctx, 4);
#if LJ_TARGET_PS3
emit_asm_label(ctx, ctx->beginsym, ctx->codesz, 0);
#else
emit_asm_label(ctx, ctx->beginsym, 0, 0);
#endif
if (ctx->mode != BUILD_machasm)
fprintf(ctx->fp, ".Lbegin:\n");
#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND
/* This should really be moved into buildvm_arm.dasc. */
#if LJ_ARCH_HASFPU
fprintf(ctx->fp,
".fnstart\n"
".save {r5, r6, r7, r8, r9, r10, r11, lr}\n"
".vsave {d8-d15}\n"
".save {r4}\n"
".pad #28\n");
#else
fprintf(ctx->fp,
".fnstart\n"
".save {r4, r5, r6, r7, r8, r9, r10, r11, lr}\n"
".pad #28\n");
#endif
#endif
for (i = rel = 0; i < ctx->nsym; i++) {
int32_t ofs = ctx->sym[i].ofs;
int32_t next = ctx->sym[i+1].ofs;
#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND && LJ_HASFFI
if (!strcmp(ctx->sym[i].name, "lj_vm_ffi_call"))
fprintf(ctx->fp,
".globl lj_err_unwind_arm\n"
".personality lj_err_unwind_arm\n"
".fnend\n"
".fnstart\n"
".save {r4, r5, r11, lr}\n"
".setfp r11, sp\n");
#endif
emit_asm_label(ctx, ctx->sym[i].name, next - ofs, 1);
while (rel < ctx->nreloc && ctx->reloc[rel].ofs <= next) {
BuildReloc *r = &ctx->reloc[rel];
int n = r->ofs - ofs;
#if LJ_TARGET_X86ORX64
if (r->type != 0 &&
(ctx->mode == BUILD_elfasm || ctx->mode == BUILD_machasm)) {
emit_asm_reloc_text(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]);
} else {
emit_asm_bytes(ctx, ctx->code+ofs, n);
emit_asm_reloc(ctx, r->type, ctx->relocsym[r->sym]);
}
ofs += n+4;
#else
emit_asm_wordreloc(ctx, ctx->code+ofs, n, ctx->relocsym[r->sym]);
ofs += n;
#endif
rel++;
}
#if LJ_TARGET_X86ORX64
emit_asm_bytes(ctx, ctx->code+ofs, next-ofs);
#else
emit_asm_words(ctx, ctx->code+ofs, next-ofs);
#endif
}
#if LJ_TARGET_ARM && defined(__GNUC__) && !LJ_NO_UNWIND
fprintf(ctx->fp,
#if !LJ_HASFFI
".globl lj_err_unwind_arm\n"
".personality lj_err_unwind_arm\n"
#endif
".fnend\n");
#endif
fprintf(ctx->fp, "\n");
switch (ctx->mode) {
case BUILD_elfasm:
#if !(LJ_TARGET_PS3 || LJ_TARGET_PSVITA)
fprintf(ctx->fp, "\t.section .note.GNU-stack,\"\"," ELFASM_PX "progbits\n");
#endif
#if LJ_TARGET_PPC && !LJ_TARGET_PS3 && !LJ_ABI_SOFTFP
/* Hard-float ABI. */
fprintf(ctx->fp, "\t.gnu_attribute 4, 1\n");
#endif
/* fallthrough */
case BUILD_coffasm:
fprintf(ctx->fp, "\t.ident \"%s\"\n", ctx->dasm_ident);
break;
case BUILD_machasm:
#if defined(__apple_build_version__) && __apple_build_version__ >= 15000000 && __apple_build_version__ < 15000300
/* Workaround for XCode 15.0 - 15.2. */
fprintf(ctx->fp, "\t.subsections_via_symbols\n");
#endif
fprintf(ctx->fp,
"\t.cstring\n"
"\t.ascii \"%s\\0\"\n", ctx->dasm_ident);
break;
default:
break;
}
fprintf(ctx->fp, "\n");
}
-236
View File
@@ -1,236 +0,0 @@
/*
** LuaJIT VM builder: IR folding hash table generator.
** Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
*/
#include "buildvm.h"
#include "lj_obj.h"
#if LJ_HASJIT
#include "lj_ir.h"
/* Context for the folding hash table generator. */
static int lineno;
static uint32_t funcidx;
static uint32_t foldkeys[BUILD_MAX_FOLD];
static uint32_t nkeys;
/* Try to fill the hash table with keys using the hash parameters. */
static int tryhash(uint32_t *htab, uint32_t sz, uint32_t r, int dorol)
{
uint32_t i;
if (dorol && ((r & 31) == 0 || (r>>5) == 0))
return 0; /* Avoid zero rotates. */
memset(htab, 0xff, (sz+1)*sizeof(uint32_t));
for (i = 0; i < nkeys; i++) {
uint32_t key = foldkeys[i];
uint32_t k = key & 0xffffff;
uint32_t h = (dorol ? lj_rol(lj_rol(k, r>>5) - k, r&31) :
(((k << (r>>5)) - k) << (r&31))) % sz;
if (htab[h] != 0xffffffff) { /* Collision on primary slot. */
if (htab[h+1] != 0xffffffff) { /* Collision on secondary slot. */
/* Try to move the colliding key, if possible. */
if (h < sz-1 && htab[h+2] == 0xffffffff) {
uint32_t k2 = htab[h+1] & 0xffffff;
uint32_t h2 = (dorol ? lj_rol(lj_rol(k2, r>>5) - k2, r&31) :
(((k2 << (r>>5)) - k2) << (r&31))) % sz;
if (h2 != h+1) return 0; /* Cannot resolve collision. */
htab[h+2] = htab[h+1]; /* Move colliding key to secondary slot. */
} else {
return 0; /* Collision. */
}
}
htab[h+1] = key;
} else {
htab[h] = key;
}
}
return 1; /* Success, all keys could be stored. */
}
/* Print the generated hash table. */
static void printhash(BuildCtx *ctx, uint32_t *htab, uint32_t sz)
{
uint32_t i;
fprintf(ctx->fp, "static const uint32_t fold_hash[%d] = {\n0x%08x",
sz+1, htab[0]);
for (i = 1; i < sz+1; i++)
fprintf(ctx->fp, ",\n0x%08x", htab[i]);
fprintf(ctx->fp, "\n};\n\n");
}
/* Exhaustive search for the shortest semi-perfect hash table. */
static void makehash(BuildCtx *ctx)
{
uint32_t htab[BUILD_MAX_FOLD*2+1];
uint32_t sz, r;
/* Search for the smallest hash table with an odd size. */
for (sz = (nkeys|1); sz < BUILD_MAX_FOLD*2; sz += 2) {
/* First try all shift hash combinations. */
for (r = 0; r < 32*32; r++) {
if (tryhash(htab, sz, r, 0)) {
printhash(ctx, htab, sz);
fprintf(ctx->fp,
"#define fold_hashkey(k)\t(((((k)<<%u)-(k))<<%u)%%%u)\n\n",
r>>5, r&31, sz);
return;
}
}
/* Then try all rotate hash combinations. */
for (r = 0; r < 32*32; r++) {
if (tryhash(htab, sz, r, 1)) {
printhash(ctx, htab, sz);
fprintf(ctx->fp,
"#define fold_hashkey(k)\t(lj_rol(lj_rol((k),%u)-(k),%u)%%%u)\n\n",
r>>5, r&31, sz);
return;
}
}
}
fprintf(stderr, "Error: search for perfect hash failed\n");
exit(1);
}
/* Parse one token of a fold rule. */
static uint32_t nexttoken(char **pp, int allowlit, int allowany)
{
char *p = *pp;
if (p) {
uint32_t i;
char *q = strchr(p, ' ');
if (q) *q++ = '\0';
*pp = q;
if (allowlit && !strncmp(p, "IRFPM_", 6)) {
for (i = 0; irfpm_names[i]; i++)
if (!strcmp(irfpm_names[i], p+6))
return i;
} else if (allowlit && !strncmp(p, "IRFL_", 5)) {
for (i = 0; irfield_names[i]; i++)
if (!strcmp(irfield_names[i], p+5))
return i;
} else if (allowlit && !strncmp(p, "IRCALL_", 7)) {
for (i = 0; ircall_names[i]; i++)
if (!strcmp(ircall_names[i], p+7))
return i;
} else if (allowlit && !strncmp(p, "IRCONV_", 7)) {
for (i = 0; irt_names[i]; i++) {
const char *r = strchr(p+7, '_');
if (r && !strncmp(irt_names[i], p+7, r-(p+7))) {
uint32_t j;
for (j = 0; irt_names[j]; j++)
if (!strcmp(irt_names[j], r+1))
return (i << 5) + j;
}
}
} else if (allowlit && *p >= '0' && *p <= '9') {
for (i = 0; *p >= '0' && *p <= '9'; p++)
i = i*10 + (*p - '0');
if (*p == '\0')
return i;
} else if (allowany && !strcmp("any", p)) {
return allowany;
} else {
for (i = 0; ir_names[i]; i++)
if (!strcmp(ir_names[i], p))
return i;
}
fprintf(stderr, "Error: bad fold definition token \"%s\" at line %d\n", p, lineno);
exit(1);
}
return 0;
}
/* Parse a fold rule. */
static void foldrule(char *p)
{
uint32_t op = nexttoken(&p, 0, 0);
uint32_t left = nexttoken(&p, 0, 0x7f);
uint32_t right = nexttoken(&p, 1, 0x3ff);
uint32_t key = (funcidx << 24) | (op << 17) | (left << 10) | right;
uint32_t i;
if (nkeys >= BUILD_MAX_FOLD) {
fprintf(stderr, "Error: too many fold rules, increase BUILD_MAX_FOLD.\n");
exit(1);
}
/* Simple insertion sort to detect duplicates. */
for (i = nkeys; i > 0; i--) {
if ((foldkeys[i-1]&0xffffff) < (key & 0xffffff))
break;
if ((foldkeys[i-1]&0xffffff) == (key & 0xffffff)) {
fprintf(stderr, "Error: duplicate fold definition at line %d\n", lineno);
exit(1);
}
foldkeys[i] = foldkeys[i-1];
}
foldkeys[i] = key;
nkeys++;
}
/* Emit C source code for IR folding hash table. */
void emit_fold(BuildCtx *ctx)
{
char buf[256]; /* We don't care about analyzing lines longer than that. */
const char *fname = ctx->args[0];
FILE *fp;
if (fname == NULL) {
fprintf(stderr, "Error: missing input filename\n");
exit(1);
}
if (fname[0] == '-' && fname[1] == '\0') {
fp = stdin;
} else {
fp = fopen(fname, "r");
if (!fp) {
fprintf(stderr, "Error: cannot open input file '%s': %s\n",
fname, strerror(errno));
exit(1);
}
}
fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n");
fprintf(ctx->fp, "static const FoldFunc fold_func[] = {\n");
lineno = 0;
funcidx = 0;
nkeys = 0;
while (fgets(buf, sizeof(buf), fp) != NULL) {
lineno++;
/* The prefix must be at the start of a line, otherwise it's ignored. */
if (!strncmp(buf, FOLDDEF_PREFIX, sizeof(FOLDDEF_PREFIX)-1)) {
char *p = buf+sizeof(FOLDDEF_PREFIX)-1;
char *q = strchr(p, ')');
if (p[0] == '(' && q) {
p++;
*q = '\0';
foldrule(p);
} else if ((p[0] == 'F' || p[0] == 'X') && p[1] == '(' && q) {
p += 2;
*q = '\0';
if (funcidx)
fprintf(ctx->fp, ",\n");
if (p[-2] == 'X')
fprintf(ctx->fp, " %s", p);
else
fprintf(ctx->fp, " fold_%s", p);
funcidx++;
} else {
buf[strlen(buf)-1] = '\0';
fprintf(stderr, "Error: unknown fold definition tag %s%s at line %d\n",
FOLDDEF_PREFIX, p, lineno);
exit(1);
}
}
}
fclose(fp);
fprintf(ctx->fp, "\n};\n\n");
makehash(ctx);
}
#else
void emit_fold(BuildCtx *ctx)
{
UNUSED(ctx);
}
#endif
-470
View File
@@ -1,470 +0,0 @@
/*
** LuaJIT VM builder: library definition compiler.
** Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
*/
#include "buildvm.h"
#include "lj_obj.h"
#include "lj_bc.h"
#include "lj_lib.h"
#include "buildvm_libbc.h"
/* Context for library definitions. */
static uint8_t obuf[8192];
static uint8_t *optr;
static char modname[80];
static size_t modnamelen;
static char funcname[80];
static int modstate, regfunc;
static int ffid, recffid, ffasmfunc;
enum {
REGFUNC_OK,
REGFUNC_NOREG,
REGFUNC_NOREGUV
};
static void libdef_name(const char *p, int kind)
{
size_t n = strlen(p);
if (kind != LIBINIT_STRING) {
if (n > modnamelen && p[modnamelen] == '_' &&
!strncmp(p, modname, modnamelen)) {
p += modnamelen+1;
n -= modnamelen+1;
}
}
if (n > LIBINIT_MAXSTR) {
fprintf(stderr, "Error: string too long: '%s'\n", p);
exit(1);
}
if (optr+1+n+2 > obuf+sizeof(obuf)) { /* +2 for caller. */
fprintf(stderr, "Error: output buffer overflow\n");
exit(1);
}
*optr++ = (uint8_t)(n | kind);
memcpy(optr, p, n);
optr += n;
}
static void libdef_endmodule(BuildCtx *ctx)
{
if (modstate != 0) {
char line[80];
const uint8_t *p;
int n;
if (modstate == 1)
fprintf(ctx->fp, " (lua_CFunction)0");
fprintf(ctx->fp, "\n};\n");
fprintf(ctx->fp, "static const uint8_t %s%s[] = {\n",
LABEL_PREFIX_LIBINIT, modname);
line[0] = '\0';
for (n = 0, p = obuf; p < optr; p++) {
n += sprintf(line+n, "%d,", *p);
if (n >= 75) {
fprintf(ctx->fp, "%s\n", line);
n = 0;
line[0] = '\0';
}
}
fprintf(ctx->fp, "%s%d\n};\n#endif\n\n", line, LIBINIT_END);
}
}
static void libdef_module(BuildCtx *ctx, char *p, int arg)
{
UNUSED(arg);
if (ctx->mode == BUILD_libdef) {
libdef_endmodule(ctx);
optr = obuf;
*optr++ = (uint8_t)ffid;
*optr++ = (uint8_t)ffasmfunc;
*optr++ = 0; /* Hash table size. */
modstate = 1;
fprintf(ctx->fp, "#ifdef %sMODULE_%s\n", LIBDEF_PREFIX, p);
fprintf(ctx->fp, "#undef %sMODULE_%s\n", LIBDEF_PREFIX, p);
fprintf(ctx->fp, "static const lua_CFunction %s%s[] = {\n",
LABEL_PREFIX_LIBCF, p);
}
modnamelen = strlen(p);
if (modnamelen > sizeof(modname)-1) {
fprintf(stderr, "Error: module name too long: '%s'\n", p);
exit(1);
}
strcpy(modname, p);
}
static int find_ffofs(BuildCtx *ctx, const char *name)
{
int i;
for (i = 0; i < ctx->nglob; i++) {
const char *gl = ctx->globnames[i];
if (gl[0] == 'f' && gl[1] == 'f' && gl[2] == '_' && !strcmp(gl+3, name)) {
return (int)((uint8_t *)ctx->glob[i] - ctx->code);
}
}
fprintf(stderr, "Error: undefined fast function %s%s\n",
LABEL_PREFIX_FF, name);
exit(1);
}
static void libdef_func(BuildCtx *ctx, char *p, int arg)
{
if (arg != LIBINIT_CF)
ffasmfunc++;
if (ctx->mode == BUILD_libdef) {
if (modstate == 0) {
fprintf(stderr, "Error: no module for function definition %s\n", p);
exit(1);
}
if (regfunc == REGFUNC_NOREG) {
if (optr+1 > obuf+sizeof(obuf)) {
fprintf(stderr, "Error: output buffer overflow\n");
exit(1);
}
*optr++ = LIBINIT_FFID;
} else {
if (arg != LIBINIT_ASM_) {
if (modstate != 1) fprintf(ctx->fp, ",\n");
modstate = 2;
fprintf(ctx->fp, " %s%s", arg ? LABEL_PREFIX_FFH : LABEL_PREFIX_CF, p);
}
if (regfunc != REGFUNC_NOREGUV) obuf[2]++; /* Bump hash table size. */
libdef_name(regfunc == REGFUNC_NOREGUV ? "" : p, arg);
}
} else if (ctx->mode == BUILD_ffdef) {
fprintf(ctx->fp, "FFDEF(%s)\n", p);
} else if (ctx->mode == BUILD_recdef) {
if (strlen(p) > sizeof(funcname)-1) {
fprintf(stderr, "Error: function name too long: '%s'\n", p);
exit(1);
}
strcpy(funcname, p);
} else if (ctx->mode == BUILD_vmdef) {
int i;
for (i = 1; p[i] && modname[i-1]; i++)
if (p[i] == '_') p[i] = '.';
fprintf(ctx->fp, "\"%s\",\n", p);
} else if (ctx->mode == BUILD_bcdef) {
if (arg != LIBINIT_CF)
fprintf(ctx->fp, ",\n%d", find_ffofs(ctx, p));
}
ffid++;
regfunc = REGFUNC_OK;
}
static uint8_t *libdef_uleb128(uint8_t *p, uint32_t *vv)
{
uint32_t v = *p++;
if (v >= 0x80) {
int sh = 0; v &= 0x7f;
do { v |= ((*p & 0x7f) << (sh += 7)); } while (*p++ >= 0x80);
}
*vv = v;
return p;
}
static void libdef_fixupbc(uint8_t *p)
{
uint32_t i, sizebc;
p += 4;
p = libdef_uleb128(p, &sizebc);
p = libdef_uleb128(p, &sizebc);
p = libdef_uleb128(p, &sizebc);
for (i = 0; i < sizebc; i++, p += 4) {
uint8_t op = p[libbc_endian ? 3 : 0];
uint8_t ra = p[libbc_endian ? 2 : 1];
uint8_t rc = p[libbc_endian ? 1 : 2];
uint8_t rb = p[libbc_endian ? 0 : 3];
if (!LJ_DUALNUM && op == BC_ISTYPE && rc == ~LJ_TNUMX+1) {
op = BC_ISNUM; rc++;
}
p[LJ_ENDIAN_SELECT(0, 3)] = op;
p[LJ_ENDIAN_SELECT(1, 2)] = ra;
p[LJ_ENDIAN_SELECT(2, 1)] = rc;
p[LJ_ENDIAN_SELECT(3, 0)] = rb;
}
}
static void libdef_lua(BuildCtx *ctx, char *p, int arg)
{
UNUSED(arg);
if (ctx->mode == BUILD_libdef) {
int i;
for (i = 0; libbc_map[i].name != NULL; i++) {
if (!strcmp(libbc_map[i].name, p)) {
int ofs = libbc_map[i].ofs;
int len = libbc_map[i+1].ofs - ofs;
obuf[2]++; /* Bump hash table size. */
*optr++ = LIBINIT_LUA;
libdef_name(p, 0);
memcpy(optr, libbc_code + ofs, len);
libdef_fixupbc(optr);
optr += len;
return;
}
}
fprintf(stderr, "Error: missing libbc definition for %s\n", p);
exit(1);
}
}
static uint32_t find_rec(char *name)
{
char *p = (char *)obuf;
uint32_t n;
for (n = 2; *p; n++) {
if (strcmp(p, name) == 0)
return n;
p += strlen(p)+1;
}
if (p+strlen(name)+1 >= (char *)obuf+sizeof(obuf)) {
fprintf(stderr, "Error: output buffer overflow\n");
exit(1);
}
strcpy(p, name);
return n;
}
static void libdef_rec(BuildCtx *ctx, char *p, int arg)
{
UNUSED(arg);
if (ctx->mode == BUILD_recdef) {
char *q;
uint32_t n;
for (; recffid+1 < ffid; recffid++)
fprintf(ctx->fp, ",\n0");
recffid = ffid;
if (*p == '.') p = funcname;
q = strchr(p, ' ');
if (q) *q++ = '\0';
n = find_rec(p);
if (q)
fprintf(ctx->fp, ",\n0x%02x00+(%s)", n, q);
else
fprintf(ctx->fp, ",\n0x%02x00", n);
}
}
static void memcpy_endian(void *dst, void *src, size_t n)
{
union { uint8_t b; uint32_t u; } host_endian;
host_endian.u = 1;
if (host_endian.b == LJ_ENDIAN_SELECT(1, 0)) {
memcpy(dst, src, n);
} else {
size_t i;
for (i = 0; i < n; i++)
((uint8_t *)dst)[i] = ((uint8_t *)src)[n-i-1];
}
}
static void libdef_push(BuildCtx *ctx, char *p, int arg)
{
UNUSED(arg);
if (ctx->mode == BUILD_libdef) {
int len = (int)strlen(p);
if (*p == '"') {
if (len > 1 && p[len-1] == '"') {
p[len-1] = '\0';
libdef_name(p+1, LIBINIT_STRING);
return;
}
} else if (*p >= '0' && *p <= '9') {
char *ep;
double d = strtod(p, &ep);
if (*ep == '\0') {
if (optr+1+sizeof(double) > obuf+sizeof(obuf)) {
fprintf(stderr, "Error: output buffer overflow\n");
exit(1);
}
*optr++ = LIBINIT_NUMBER;
memcpy_endian(optr, &d, sizeof(double));
optr += sizeof(double);
return;
}
} else if (!strcmp(p, "lastcl")) {
if (optr+1 > obuf+sizeof(obuf)) {
fprintf(stderr, "Error: output buffer overflow\n");
exit(1);
}
*optr++ = LIBINIT_LASTCL;
return;
} else if (len > 4 && !strncmp(p, "top-", 4)) {
if (optr+2 > obuf+sizeof(obuf)) {
fprintf(stderr, "Error: output buffer overflow\n");
exit(1);
}
*optr++ = LIBINIT_COPY;
*optr++ = (uint8_t)atoi(p+4);
return;
}
fprintf(stderr, "Error: bad value for %sPUSH(%s)\n", LIBDEF_PREFIX, p);
exit(1);
}
}
static void libdef_set(BuildCtx *ctx, char *p, int arg)
{
UNUSED(arg);
if (ctx->mode == BUILD_libdef) {
if (p[0] == '!' && p[1] == '\0') p[0] = '\0'; /* Set env. */
libdef_name(p, LIBINIT_STRING);
*optr++ = LIBINIT_SET;
obuf[2]++; /* Bump hash table size. */
}
}
static void libdef_regfunc(BuildCtx *ctx, char *p, int arg)
{
UNUSED(ctx); UNUSED(p);
regfunc = arg;
}
typedef void (*LibDefFunc)(BuildCtx *ctx, char *p, int arg);
typedef struct LibDefHandler {
const char *suffix;
const char *stop;
const LibDefFunc func;
const int arg;
} LibDefHandler;
static const LibDefHandler libdef_handlers[] = {
{ "MODULE_", " \t\r\n", libdef_module, 0 },
{ "CF(", ")", libdef_func, LIBINIT_CF },
{ "ASM(", ")", libdef_func, LIBINIT_ASM },
{ "ASM_(", ")", libdef_func, LIBINIT_ASM_ },
{ "LUA(", ")", libdef_lua, 0 },
{ "REC(", ")", libdef_rec, 0 },
{ "PUSH(", ")", libdef_push, 0 },
{ "SET(", ")", libdef_set, 0 },
{ "NOREGUV", NULL, libdef_regfunc, REGFUNC_NOREGUV },
{ "NOREG", NULL, libdef_regfunc, REGFUNC_NOREG },
{ NULL, NULL, (LibDefFunc)0, 0 }
};
/* Emit C source code for library function definitions. */
void emit_lib(BuildCtx *ctx)
{
const char *fname;
if (ctx->mode == BUILD_ffdef || ctx->mode == BUILD_libdef ||
ctx->mode == BUILD_recdef)
fprintf(ctx->fp, "/* This is a generated file. DO NOT EDIT! */\n\n");
else if (ctx->mode == BUILD_vmdef)
fprintf(ctx->fp, "ffnames = {\n[0]=\"Lua\",\n\"C\",\n");
if (ctx->mode == BUILD_recdef)
fprintf(ctx->fp, "static const uint16_t recff_idmap[] = {\n0,\n0x0100");
recffid = ffid = FF_C+1;
ffasmfunc = 0;
while ((fname = *ctx->args++)) {
char buf[256]; /* We don't care about analyzing lines longer than that. */
FILE *fp;
if (fname[0] == '-' && fname[1] == '\0') {
fp = stdin;
} else {
fp = fopen(fname, "r");
if (!fp) {
fprintf(stderr, "Error: cannot open input file '%s': %s\n",
fname, strerror(errno));
exit(1);
}
}
modstate = 0;
regfunc = REGFUNC_OK;
while (fgets(buf, sizeof(buf), fp) != NULL) {
char *p;
/* Simplistic pre-processor. Only handles top-level #if/#endif. */
if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') {
int ok = 1;
size_t len = strlen(buf);
if (buf[len-1] == '\n') {
buf[len-1] = 0;
if (buf[len-2] == '\r') {
buf[len-2] = 0;
}
}
if (!strcmp(buf, "#if LJ_52"))
ok = LJ_52;
else if (!strcmp(buf, "#if LJ_HASJIT"))
ok = LJ_HASJIT;
else if (!strcmp(buf, "#if LJ_HASFFI"))
ok = LJ_HASFFI;
else if (!strcmp(buf, "#if LJ_HASBUFFER"))
ok = LJ_HASBUFFER;
else if (!strcmp(buf, "#if !LJ_SRB2LIB"))
ok = !LJ_SRB2LIB;
else if (!strcmp(buf, "#if !LJ_SRB2LIB || (LJ_SRB2LIB && LJ_SRB2IO)"))
ok = !LJ_SRB2LIB || (LJ_SRB2LIB && LJ_SRB2IO); /* whacky! */
if (!ok) {
int lvl = 1;
while (fgets(buf, sizeof(buf), fp) != NULL) {
if (buf[0] == '#' && buf[1] == 'e' && buf[2] == 'n') {
if (--lvl == 0) break;
} else if (buf[0] == '#' && buf[1] == 'i' && buf[2] == 'f') {
lvl++;
}
}
continue;
}
}
for (p = buf; (p = strstr(p, LIBDEF_PREFIX)) != NULL; ) {
const LibDefHandler *ldh;
p += sizeof(LIBDEF_PREFIX)-1;
for (ldh = libdef_handlers; ldh->suffix != NULL; ldh++) {
size_t n, len = strlen(ldh->suffix);
if (!strncmp(p, ldh->suffix, len)) {
p += len;
n = ldh->stop ? strcspn(p, ldh->stop) : 0;
if (!p[n]) break;
p[n] = '\0';
ldh->func(ctx, p, ldh->arg);
p += n+1;
break;
}
}
if (ldh->suffix == NULL) {
buf[strlen(buf)-1] = '\0';
fprintf(stderr, "Error: unknown library definition tag %s%s\n",
LIBDEF_PREFIX, p);
exit(1);
}
}
}
fclose(fp);
if (ctx->mode == BUILD_libdef) {
libdef_endmodule(ctx);
}
}
if (ctx->mode == BUILD_ffdef) {
fprintf(ctx->fp, "\n#undef FFDEF\n\n");
fprintf(ctx->fp,
"#ifndef FF_NUM_ASMFUNC\n#define FF_NUM_ASMFUNC %d\n#endif\n\n",
ffasmfunc);
} else if (ctx->mode == BUILD_vmdef) {
fprintf(ctx->fp, "},\n\n");
} else if (ctx->mode == BUILD_bcdef) {
int i;
fprintf(ctx->fp, "\n};\n\n");
fprintf(ctx->fp, "LJ_DATADEF const uint16_t lj_bc_mode[] = {\n");
fprintf(ctx->fp, "BCDEF(BCMODE)\n");
for (i = ffasmfunc-1; i > 0; i--)
fprintf(ctx->fp, "BCMODE_FF,\n");
fprintf(ctx->fp, "BCMODE_FF\n};\n\n");
} else if (ctx->mode == BUILD_recdef) {
char *p = (char *)obuf;
fprintf(ctx->fp, "\n};\n\n");
fprintf(ctx->fp, "static const RecordFunc recff_func[] = {\n"
"recff_nyi,\n"
"recff_c");
while (*p) {
fprintf(ctx->fp, ",\nrecff_%s", p);
p += strlen(p)+1;
}
fprintf(ctx->fp, "\n};\n\n");
}
}
-81
View File
@@ -1,81 +0,0 @@
/* This is a generated file. DO NOT EDIT! */
static const int libbc_endian = 0;
static const uint8_t libbc_code[] = {
#if LJ_FR2
/* math.deg */ 0,1,2,0,0,1,2,BC_MULVN,1,0,0,BC_RET1,1,2,0,241,135,158,166,3,
220,203,178,130,4,
/* math.rad */ 0,1,2,0,0,1,2,BC_MULVN,1,0,0,BC_RET1,1,2,0,243,244,148,165,20,
198,190,199,252,3,
/* string.len */ 0,1,2,0,0,0,3,BC_ISTYPE,0,5,0,BC_LEN,1,0,0,BC_RET1,1,2,0,
/* table.foreachi */ 0,2,10,0,0,0,15,BC_ISTYPE,0,12,0,BC_ISTYPE,1,9,0,
BC_KSHORT,2,1,0,BC_LEN,3,0,0,BC_KSHORT,4,1,0,BC_FORI,2,8,128,BC_MOV,6,1,0,
BC_MOV,8,5,0,BC_TGETR,9,5,0,BC_CALL,6,3,2,BC_ISEQP,6,0,0,BC_JMP,7,1,128,
BC_RET1,6,2,0,BC_FORL,2,248,127,BC_RET0,0,1,0,
/* table.foreach */ 0,2,11,0,0,1,16,BC_ISTYPE,0,12,0,BC_ISTYPE,1,9,0,BC_KPRI,
2,0,0,BC_MOV,3,0,0,BC_KNUM,4,0,0,BC_JMP,5,7,128,BC_MOV,7,1,0,BC_MOV,9,5,0,
BC_MOV,10,6,0,BC_CALL,7,3,2,BC_ISEQP,7,0,0,BC_JMP,8,1,128,BC_RET1,7,2,0,
BC_ITERN,5,3,3,BC_ITERL,5,247,127,BC_RET0,0,1,0,1,255,255,249,255,15,
/* table.getn */ 0,1,2,0,0,0,3,BC_ISTYPE,0,12,0,BC_LEN,1,0,0,BC_RET1,1,2,0,
/* table.remove */ 0,2,10,0,0,2,30,BC_ISTYPE,0,12,0,BC_LEN,2,0,0,BC_ISNEP,1,0,
0,BC_JMP,3,7,128,BC_ISEQN,2,0,0,BC_JMP,3,23,128,BC_TGETR,3,2,0,BC_KPRI,4,0,0,
BC_TSETR,4,2,0,BC_RET1,3,2,0,BC_JMP,3,18,128,BC_ISTYPE,1,14,0,BC_KSHORT,3,1,0,
BC_ISGT,3,1,0,BC_JMP,3,14,128,BC_ISGT,1,2,0,BC_JMP,3,12,128,BC_TGETR,3,1,0,
BC_ADDVN,4,1,1,BC_MOV,5,2,0,BC_KSHORT,6,1,0,BC_FORI,4,4,128,BC_SUBVN,8,1,7,
BC_TGETR,9,7,0,BC_TSETR,9,8,0,BC_FORL,4,252,127,BC_KPRI,4,0,0,BC_TSETR,4,2,0,
BC_RET1,3,2,0,BC_RET0,0,1,0,0,2,
/* table.move */ 0,5,12,0,0,0,35,BC_ISTYPE,0,12,0,BC_ISTYPE,1,14,0,BC_ISTYPE,
2,14,0,BC_ISTYPE,3,14,0,BC_ISNEP,4,0,0,BC_JMP,5,1,128,BC_MOV,4,0,0,BC_ISTYPE,
4,12,0,BC_ISGT,1,2,0,BC_JMP,5,24,128,BC_SUBVV,5,1,3,BC_ISLT,2,3,0,BC_JMP,6,4,
128,BC_ISLE,3,1,0,BC_JMP,6,2,128,BC_ISEQV,4,0,0,BC_JMP,6,9,128,BC_MOV,6,1,0,
BC_MOV,7,2,0,BC_KSHORT,8,1,0,BC_FORI,6,4,128,BC_ADDVV,10,5,9,BC_TGETR,11,9,0,
BC_TSETR,11,10,4,BC_FORL,6,252,127,BC_JMP,6,8,128,BC_MOV,6,2,0,BC_MOV,7,1,0,
BC_KSHORT,8,255,255,BC_FORI,6,4,128,BC_ADDVV,10,5,9,BC_TGETR,11,9,0,BC_TSETR,
11,10,4,BC_FORL,6,252,127,BC_RET1,4,2,0,
#else
/* math.deg */ 0,1,2,0,0,1,2,BC_MULVN,1,0,0,BC_RET1,1,2,0,241,135,158,166,3,
220,203,178,130,4,
/* math.rad */ 0,1,2,0,0,1,2,BC_MULVN,1,0,0,BC_RET1,1,2,0,243,244,148,165,20,
198,190,199,252,3,
/* string.len */ 0,1,2,0,0,0,3,BC_ISTYPE,0,5,0,BC_LEN,1,0,0,BC_RET1,1,2,0,
/* table.foreachi */ 0,2,9,0,0,0,15,BC_ISTYPE,0,12,0,BC_ISTYPE,1,9,0,
BC_KSHORT,2,1,0,BC_LEN,3,0,0,BC_KSHORT,4,1,0,BC_FORI,2,8,128,BC_MOV,6,1,0,
BC_MOV,7,5,0,BC_TGETR,8,5,0,BC_CALL,6,3,2,BC_ISEQP,6,0,0,BC_JMP,7,1,128,
BC_RET1,6,2,0,BC_FORL,2,248,127,BC_RET0,0,1,0,
/* table.foreach */ 0,2,10,0,0,1,16,BC_ISTYPE,0,12,0,BC_ISTYPE,1,9,0,BC_KPRI,
2,0,0,BC_MOV,3,0,0,BC_KNUM,4,0,0,BC_JMP,5,7,128,BC_MOV,7,1,0,BC_MOV,8,5,0,
BC_MOV,9,6,0,BC_CALL,7,3,2,BC_ISEQP,7,0,0,BC_JMP,8,1,128,BC_RET1,7,2,0,
BC_ITERN,5,3,3,BC_ITERL,5,247,127,BC_RET0,0,1,0,1,255,255,249,255,15,
/* table.getn */ 0,1,2,0,0,0,3,BC_ISTYPE,0,12,0,BC_LEN,1,0,0,BC_RET1,1,2,0,
/* table.remove */ 0,2,10,0,0,2,30,BC_ISTYPE,0,12,0,BC_LEN,2,0,0,BC_ISNEP,1,0,
0,BC_JMP,3,7,128,BC_ISEQN,2,0,0,BC_JMP,3,23,128,BC_TGETR,3,2,0,BC_KPRI,4,0,0,
BC_TSETR,4,2,0,BC_RET1,3,2,0,BC_JMP,3,18,128,BC_ISTYPE,1,14,0,BC_KSHORT,3,1,0,
BC_ISGT,3,1,0,BC_JMP,3,14,128,BC_ISGT,1,2,0,BC_JMP,3,12,128,BC_TGETR,3,1,0,
BC_ADDVN,4,1,1,BC_MOV,5,2,0,BC_KSHORT,6,1,0,BC_FORI,4,4,128,BC_SUBVN,8,1,7,
BC_TGETR,9,7,0,BC_TSETR,9,8,0,BC_FORL,4,252,127,BC_KPRI,4,0,0,BC_TSETR,4,2,0,
BC_RET1,3,2,0,BC_RET0,0,1,0,0,2,
/* table.move */ 0,5,12,0,0,0,35,BC_ISTYPE,0,12,0,BC_ISTYPE,1,14,0,BC_ISTYPE,
2,14,0,BC_ISTYPE,3,14,0,BC_ISNEP,4,0,0,BC_JMP,5,1,128,BC_MOV,4,0,0,BC_ISTYPE,
4,12,0,BC_ISGT,1,2,0,BC_JMP,5,24,128,BC_SUBVV,5,1,3,BC_ISLT,2,3,0,BC_JMP,6,4,
128,BC_ISLE,3,1,0,BC_JMP,6,2,128,BC_ISEQV,4,0,0,BC_JMP,6,9,128,BC_MOV,6,1,0,
BC_MOV,7,2,0,BC_KSHORT,8,1,0,BC_FORI,6,4,128,BC_ADDVV,10,5,9,BC_TGETR,11,9,0,
BC_TSETR,11,10,4,BC_FORL,6,252,127,BC_JMP,6,8,128,BC_MOV,6,2,0,BC_MOV,7,1,0,
BC_KSHORT,8,255,255,BC_FORI,6,4,128,BC_ADDVV,10,5,9,BC_TGETR,11,9,0,BC_TSETR,
11,10,4,BC_FORL,6,252,127,BC_RET1,4,2,0,
#endif
0
};
static const struct { const char *name; int ofs; } libbc_map[] = {
{"math_deg",0},
{"math_rad",25},
{"string_len",50},
{"table_foreachi",69},
{"table_foreach",136},
{"table_getn",213},
{"table_remove",232},
{"table_move",361},
{NULL,508}
};
-473
View File
@@ -1,473 +0,0 @@
/*
** LuaJIT VM builder: PE object emitter.
** Copyright (C) 2005-2023 Mike Pall. See Copyright Notice in luajit.h
**
** Only used for building on Windows, since we cannot assume the presence
** of a suitable assembler. The host and target byte order must match.
*/
#include "buildvm.h"
#include "lj_bc.h"
#if LJ_TARGET_WINDOWS || LJ_TARGET_CYGWIN
/* Context for PE object emitter. */
static char *strtab;
static size_t strtabofs;
/* -- PE object definitions ----------------------------------------------- */
/* PE header. */
typedef struct PEheader {
uint16_t arch;
uint16_t nsects;
uint32_t time;
uint32_t symtabofs;
uint32_t nsyms;
uint16_t opthdrsz;
uint16_t flags;
} PEheader;
/* PE section. */
typedef struct PEsection {
char name[8];
uint32_t vsize;
uint32_t vaddr;
uint32_t size;
uint32_t ofs;
uint32_t relocofs;
uint32_t lineofs;
uint16_t nreloc;
uint16_t nline;
uint32_t flags;
} PEsection;
/* PE relocation. */
typedef struct PEreloc {
uint32_t vaddr;
uint32_t symidx;
uint16_t type;
} PEreloc;
/* Cannot use sizeof, because it pads up to the max. alignment. */
#define PEOBJ_RELOC_SIZE (4+4+2)
/* PE symbol table entry. */
typedef struct PEsym {
union {
char name[8];
uint32_t nameref[2];
} n;
uint32_t value;
int16_t sect;
uint16_t type;
uint8_t scl;
uint8_t naux;
} PEsym;
/* PE symbol table auxiliary entry for a section. */
typedef struct PEsymaux {
uint32_t size;
uint16_t nreloc;
uint16_t nline;
uint32_t cksum;
uint16_t assoc;
uint8_t comdatsel;
uint8_t unused[3];
} PEsymaux;
/* Cannot use sizeof, because it pads up to the max. alignment. */
#define PEOBJ_SYM_SIZE (8+4+2+2+1+1)
/* PE object CPU specific defines. */
#if LJ_TARGET_X86
#define PEOBJ_ARCH_TARGET 0x014c
#define PEOBJ_RELOC_REL32 0x14 /* MS: REL32, GNU: DISP32. */
#define PEOBJ_RELOC_DIR32 0x06
#define PEOBJ_RELOC_OFS 0
#define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */
#elif LJ_TARGET_X64
#define PEOBJ_ARCH_TARGET 0x8664
#define PEOBJ_RELOC_REL32 0x04 /* MS: REL32, GNU: DISP32. */
#define PEOBJ_RELOC_DIR32 0x02
#define PEOBJ_RELOC_ADDR32NB 0x03
#define PEOBJ_RELOC_OFS 0
#define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */
#define PEOBJ_PDATA_NRELOC 6
#define PEOBJ_XDATA_SIZE (8*2+4+6*2)
#elif LJ_TARGET_ARM64
#define PEOBJ_ARCH_TARGET 0xaa64
#define PEOBJ_RELOC_REL32 0x03 /* MS: BRANCH26. */
#define PEOBJ_RELOC_DIR32 0x01
#define PEOBJ_RELOC_ADDR32NB 0x02
#define PEOBJ_RELOC_OFS (-4)
#define PEOBJ_TEXT_FLAGS 0x60500020 /* 60=r+x, 50=align16, 20=code. */
#define PEOBJ_PDATA_NRELOC 4
#define PEOBJ_XDATA_SIZE (4+24+4 +4+8)
#endif
/* Section numbers (0-based). */
enum {
PEOBJ_SECT_ABS = -2,
PEOBJ_SECT_UNDEF = -1,
PEOBJ_SECT_TEXT,
#ifdef PEOBJ_PDATA_NRELOC
PEOBJ_SECT_PDATA,
PEOBJ_SECT_XDATA,
#elif LJ_TARGET_X86
PEOBJ_SECT_SXDATA,
#endif
PEOBJ_SECT_RDATA_Z,
PEOBJ_NSECTIONS
};
/* Symbol types. */
#define PEOBJ_TYPE_NULL 0
#define PEOBJ_TYPE_FUNC 0x20
/* Symbol storage class. */
#define PEOBJ_SCL_EXTERN 2
#define PEOBJ_SCL_STATIC 3
/* -- PE object emitter --------------------------------------------------- */
/* Emit PE object symbol. */
static void emit_peobj_sym(BuildCtx *ctx, const char *name, uint32_t value,
int sect, int type, int scl)
{
PEsym sym;
size_t len = strlen(name);
if (!strtab) { /* Pass 1: only calculate string table length. */
if (len > 8) strtabofs += len+1;
return;
}
if (len <= 8) {
memcpy(sym.n.name, name, len);
memset(sym.n.name+len, 0, 8-len);
} else {
sym.n.nameref[0] = 0;
sym.n.nameref[1] = (uint32_t)strtabofs;
memcpy(strtab + strtabofs, name, len);
strtab[strtabofs+len] = 0;
strtabofs += len+1;
}
sym.value = value;
sym.sect = (int16_t)(sect+1); /* 1-based section number. */
sym.type = (uint16_t)type;
sym.scl = (uint8_t)scl;
sym.naux = 0;
owrite(ctx, &sym, PEOBJ_SYM_SIZE);
}
/* Emit PE object section symbol. */
static void emit_peobj_sym_sect(BuildCtx *ctx, PEsection *pesect, int sect)
{
PEsym sym;
PEsymaux aux;
if (!strtab) return; /* Pass 1: no output. */
memcpy(sym.n.name, pesect[sect].name, 8);
sym.value = 0;
sym.sect = (int16_t)(sect+1); /* 1-based section number. */
sym.type = PEOBJ_TYPE_NULL;
sym.scl = PEOBJ_SCL_STATIC;
sym.naux = 1;
owrite(ctx, &sym, PEOBJ_SYM_SIZE);
memset(&aux, 0, sizeof(PEsymaux));
aux.size = pesect[sect].size;
aux.nreloc = pesect[sect].nreloc;
owrite(ctx, &aux, PEOBJ_SYM_SIZE);
}
/* Emit Windows PE object file. */
void emit_peobj(BuildCtx *ctx)
{
PEheader pehdr;
PEsection pesect[PEOBJ_NSECTIONS];
uint32_t sofs;
int i, nrsym;
union { uint8_t b; uint32_t u; } host_endian;
#ifdef PEOBJ_PDATA_NRELOC
uint32_t fcofs = (uint32_t)ctx->sym[ctx->nsym-1].ofs;
#endif
sofs = sizeof(PEheader) + PEOBJ_NSECTIONS*sizeof(PEsection);
/* Fill in PE sections. */
memset(&pesect, 0, PEOBJ_NSECTIONS*sizeof(PEsection));
memcpy(pesect[PEOBJ_SECT_TEXT].name, ".text", sizeof(".text")-1);
pesect[PEOBJ_SECT_TEXT].ofs = sofs;
sofs += (pesect[PEOBJ_SECT_TEXT].size = (uint32_t)ctx->codesz);
pesect[PEOBJ_SECT_TEXT].relocofs = sofs;
sofs += (pesect[PEOBJ_SECT_TEXT].nreloc = (uint16_t)ctx->nreloc) * PEOBJ_RELOC_SIZE;
/* Flags: 60 = read+execute, 50 = align16, 20 = code. */
pesect[PEOBJ_SECT_TEXT].flags = PEOBJ_TEXT_FLAGS;
#ifdef PEOBJ_PDATA_NRELOC
memcpy(pesect[PEOBJ_SECT_PDATA].name, ".pdata", sizeof(".pdata")-1);
pesect[PEOBJ_SECT_PDATA].ofs = sofs;
sofs += (pesect[PEOBJ_SECT_PDATA].size = PEOBJ_PDATA_NRELOC*4);
pesect[PEOBJ_SECT_PDATA].relocofs = sofs;
sofs += (pesect[PEOBJ_SECT_PDATA].nreloc = PEOBJ_PDATA_NRELOC) * PEOBJ_RELOC_SIZE;
/* Flags: 40 = read, 30 = align4, 40 = initialized data. */
pesect[PEOBJ_SECT_PDATA].flags = 0x40300040;
memcpy(pesect[PEOBJ_SECT_XDATA].name, ".xdata", sizeof(".xdata")-1);
pesect[PEOBJ_SECT_XDATA].ofs = sofs;
sofs += (pesect[PEOBJ_SECT_XDATA].size = PEOBJ_XDATA_SIZE); /* See below. */
pesect[PEOBJ_SECT_XDATA].relocofs = sofs;
sofs += (pesect[PEOBJ_SECT_XDATA].nreloc = 1) * PEOBJ_RELOC_SIZE;
/* Flags: 40 = read, 30 = align4, 40 = initialized data. */
pesect[PEOBJ_SECT_XDATA].flags = 0x40300040;
#elif LJ_TARGET_X86
memcpy(pesect[PEOBJ_SECT_SXDATA].name, ".sxdata", sizeof(".sxdata")-1);
pesect[PEOBJ_SECT_SXDATA].ofs = sofs;
sofs += (pesect[PEOBJ_SECT_SXDATA].size = 4);
pesect[PEOBJ_SECT_SXDATA].relocofs = sofs;
/* Flags: 40 = read, 30 = align4, 02 = lnk_info, 40 = initialized data. */
pesect[PEOBJ_SECT_SXDATA].flags = 0x40300240;
#endif
memcpy(pesect[PEOBJ_SECT_RDATA_Z].name, ".rdata$Z", sizeof(".rdata$Z")-1);
pesect[PEOBJ_SECT_RDATA_Z].ofs = sofs;
sofs += (pesect[PEOBJ_SECT_RDATA_Z].size = (uint32_t)strlen(ctx->dasm_ident)+1);
/* Flags: 40 = read, 30 = align4, 40 = initialized data. */
pesect[PEOBJ_SECT_RDATA_Z].flags = 0x40300040;
/* Fill in PE header. */
pehdr.arch = PEOBJ_ARCH_TARGET;
pehdr.nsects = PEOBJ_NSECTIONS;
pehdr.time = 0; /* Timestamp is optional. */
pehdr.symtabofs = sofs;
pehdr.opthdrsz = 0;
pehdr.flags = 0;
/* Compute the size of the symbol table:
** @feat.00 + nsections*2
** + asm_start + nsym
** + nrsym
*/
nrsym = ctx->nrelocsym;
pehdr.nsyms = 1+PEOBJ_NSECTIONS*2 + 1+ctx->nsym + nrsym;
#ifdef PEOBJ_PDATA_NRELOC
pehdr.nsyms += 1; /* Symbol for lj_err_unwind_win. */
#endif
/* Write PE object header and all sections. */
owrite(ctx, &pehdr, sizeof(PEheader));
owrite(ctx, &pesect, sizeof(PEsection)*PEOBJ_NSECTIONS);
/* Write .text section. */
host_endian.u = 1;
if (host_endian.b != LJ_ENDIAN_SELECT(1, 0)) {
fprintf(stderr, "Error: different byte order for host and target\n");
exit(1);
}
owrite(ctx, ctx->code, ctx->codesz);
for (i = 0; i < ctx->nreloc; i++) {
PEreloc reloc;
reloc.vaddr = (uint32_t)ctx->reloc[i].ofs + PEOBJ_RELOC_OFS;
reloc.symidx = 1+2+ctx->reloc[i].sym; /* Reloc syms are after .text sym. */
reloc.type = ctx->reloc[i].type ? PEOBJ_RELOC_REL32 : PEOBJ_RELOC_DIR32;
owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
}
#if LJ_TARGET_X64
{ /* Write .pdata section. */
uint32_t pdata[3]; /* Start of .text, end of .text and .xdata. */
PEreloc reloc;
pdata[0] = 0; pdata[1] = fcofs; pdata[2] = 0;
owrite(ctx, &pdata, sizeof(pdata));
pdata[0] = fcofs; pdata[1] = (uint32_t)ctx->codesz; pdata[2] = 20;
owrite(ctx, &pdata, sizeof(pdata));
reloc.vaddr = 0; reloc.symidx = 1+2+nrsym+2+2+1;
reloc.type = PEOBJ_RELOC_ADDR32NB;
owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
reloc.vaddr = 4; reloc.symidx = 1+2+nrsym+2+2+1;
reloc.type = PEOBJ_RELOC_ADDR32NB;
owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
reloc.vaddr = 8; reloc.symidx = 1+2+nrsym+2;
reloc.type = PEOBJ_RELOC_ADDR32NB;
owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
reloc.vaddr = 12; reloc.symidx = 1+2+nrsym+2+2+1;
reloc.type = PEOBJ_RELOC_ADDR32NB;
owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
reloc.vaddr = 16; reloc.symidx = 1+2+nrsym+2+2+1;
reloc.type = PEOBJ_RELOC_ADDR32NB;
owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
reloc.vaddr = 20; reloc.symidx = 1+2+nrsym+2;
reloc.type = PEOBJ_RELOC_ADDR32NB;
owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
}
{ /* Write .xdata section. */
uint16_t xdata[8+2+6];
PEreloc reloc;
xdata[0] = 0x01|0x08|0x10; /* Ver. 1, uhandler/ehandler, prolog size 0. */
xdata[1] = 0x0005; /* Number of unwind codes, no frame pointer. */
xdata[2] = 0x4200; /* Stack offset 4*8+8 = aword*5. */
xdata[3] = 0x3000; /* Push rbx. */
xdata[4] = 0x6000; /* Push rsi. */
xdata[5] = 0x7000; /* Push rdi. */
xdata[6] = 0x5000; /* Push rbp. */
xdata[7] = 0; /* Alignment. */
xdata[8] = xdata[9] = 0; /* Relocated address of exception handler. */
xdata[10] = 0x01; /* Ver. 1, no handler, prolog size 0. */
xdata[11] = 0x1504; /* Number of unwind codes, fp = rbp, fpofs = 16. */
xdata[12] = 0x0300; /* set_fpreg. */
xdata[13] = 0x0200; /* stack offset 0*8+8 = aword*1. */
xdata[14] = 0x3000; /* Push rbx. */
xdata[15] = 0x5000; /* Push rbp. */
owrite(ctx, &xdata, sizeof(xdata));
reloc.vaddr = 2*8; reloc.symidx = 1+2+nrsym+2+2;
reloc.type = PEOBJ_RELOC_ADDR32NB;
owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
}
#elif LJ_TARGET_ARM64
/* https://learn.microsoft.com/en-us/cpp/build/arm64-exception-handling */
{ /* Write .pdata section. */
uint32_t pdata[4];
PEreloc reloc;
pdata[0] = 0;
pdata[1] = 0;
pdata[2] = fcofs;
pdata[3] = 4+24+4;
owrite(ctx, &pdata, sizeof(pdata));
/* Start of .text and start of .xdata. */
reloc.vaddr = 0; reloc.symidx = 1+2+nrsym+2+2+1;
reloc.type = PEOBJ_RELOC_ADDR32NB;
owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
reloc.vaddr = 4; reloc.symidx = 1+2+nrsym+2;
reloc.type = PEOBJ_RELOC_ADDR32NB;
owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
/* Start of vm_ffi_call and start of second part of .xdata. */
reloc.vaddr = 8; reloc.symidx = 1+2+nrsym+2+2+1;
reloc.type = PEOBJ_RELOC_ADDR32NB;
owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
reloc.vaddr = 12; reloc.symidx = 1+2+nrsym+2;
reloc.type = PEOBJ_RELOC_ADDR32NB;
owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
}
{ /* Write .xdata section. */
uint32_t u32;
uint8_t *p, uwc[24];
PEreloc reloc;
#define CBE16(x) (*p = ((x) >> 8) & 0xff, p[1] = (x) & 0xff, p += 2)
#define CALLOC_S(s) (*p++ = ((s) >> 4)) /* s < 512 */
#define CSAVE_FPLR(o) (*p++ = 0x40 | ((o) >> 3)) /* o <= 504 */
#define CSAVE_REGP(r,o) CBE16(0xc800 | (((r) - 19) << 6) | ((o) >> 3))
#define CSAVE_REGS(r1,r2,o1) do { \
int r, o; for (r = r1, o = o1; r <= r2; r += 2, o -= 16) CSAVE_REGP(r, o); \
} while (0)
#define CSAVE_REGPX(r,o) CBE16(0xcc00 | (((r) - 19) << 6) | (~(o) >> 3))
#define CSAVE_FREGP(r,o) CBE16(0xd800 | (((r) - 8) << 6) | ((o) >> 3))
#define CSAVE_FREGS(r1,r2,o1) do { \
int r, o; for (r = r1, o = o1; r <= r2; r += 2, o -= 16) CSAVE_FREGP(r, o); \
} while (0)
#define CADD_FP(s) CBE16(0xe200 | ((s) >> 3)) /* s < 8*256 */
#define CODE_NOP 0xe3
#define CODE_END 0xe4
#define CEND_ALIGN do { \
*p++ = CODE_END; \
while ((p - uwc) & 3) *p++ = CODE_NOP; \
} while (0)
/* Unwind codes for .text section with handler. */
p = uwc;
CADD_FP(192); /* +2 */
CSAVE_REGS(19, 28, 176); /* +5*2 */
CSAVE_FREGS(8, 15, 96); /* +4*2 */
CSAVE_FPLR(192); /* +1 */
CALLOC_S(208); /* +1 */
CEND_ALIGN; /* +1 +1 -> 24 */
u32 = ((24u >> 2) << 27) | (1u << 20) | (fcofs >> 2);
owrite(ctx, &u32, 4);
owrite(ctx, &uwc, 24);
u32 = 0; /* Handler RVA to be relocated at 4 + 24. */
owrite(ctx, &u32, 4);
/* Unwind codes for vm_ffi_call without handler. */
p = uwc;
CADD_FP(16); /* +2 */
CSAVE_FPLR(16); /* +1 */
CSAVE_REGPX(19, -32); /* +2 */
CEND_ALIGN; /* +1 +2 -> 8 */
u32 = ((8u >> 2) << 27) | (((uint32_t)ctx->codesz - fcofs) >> 2);
owrite(ctx, &u32, 4);
owrite(ctx, &uwc, 8);
reloc.vaddr = 4 + 24; reloc.symidx = 1+2+nrsym+2+2;
reloc.type = PEOBJ_RELOC_ADDR32NB;
owrite(ctx, &reloc, PEOBJ_RELOC_SIZE);
}
#elif LJ_TARGET_X86
/* Write .sxdata section. */
for (i = 0; i < nrsym; i++) {
if (!strcmp(ctx->relocsym[i], "_lj_err_unwind_win")) {
uint32_t symidx = 1+2+i;
owrite(ctx, &symidx, 4);
break;
}
}
if (i == nrsym) {
fprintf(stderr, "Error: extern lj_err_unwind_win not used\n");
exit(1);
}
#endif
/* Write .rdata$Z section. */
owrite(ctx, ctx->dasm_ident, strlen(ctx->dasm_ident)+1);
/* Write symbol table. */
strtab = NULL; /* 1st pass: collect string sizes. */
for (;;) {
strtabofs = 4;
/* Mark as SafeSEH compliant. */
emit_peobj_sym(ctx, "@feat.00", 1,
PEOBJ_SECT_ABS, PEOBJ_TYPE_NULL, PEOBJ_SCL_STATIC);
emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_TEXT);
for (i = 0; i < nrsym; i++)
emit_peobj_sym(ctx, ctx->relocsym[i], 0,
PEOBJ_SECT_UNDEF, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN);
#ifdef PEOBJ_PDATA_NRELOC
emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_PDATA);
emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_XDATA);
emit_peobj_sym(ctx, "lj_err_unwind_win", 0,
PEOBJ_SECT_UNDEF, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN);
#elif LJ_TARGET_X86
emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_SXDATA);
#endif
emit_peobj_sym(ctx, ctx->beginsym, 0,
PEOBJ_SECT_TEXT, PEOBJ_TYPE_NULL, PEOBJ_SCL_EXTERN);
for (i = 0; i < ctx->nsym; i++)
emit_peobj_sym(ctx, ctx->sym[i].name, (uint32_t)ctx->sym[i].ofs,
PEOBJ_SECT_TEXT, PEOBJ_TYPE_FUNC, PEOBJ_SCL_EXTERN);
emit_peobj_sym_sect(ctx, pesect, PEOBJ_SECT_RDATA_Z);
if (strtab)
break;
/* 2nd pass: alloc strtab, write syms and copy strings. */
strtab = (char *)malloc(strtabofs);
*(uint32_t *)strtab = (uint32_t)strtabofs;
}
/* Write string table. */
owrite(ctx, strtab, strtabofs);
}
#else
void emit_peobj(BuildCtx *ctx)
{
UNUSED(ctx);
fprintf(stderr, "Error: no PE object support for this target\n");
exit(1);
}
#endif
-234
View File
@@ -1,234 +0,0 @@
----------------------------------------------------------------------------
-- Lua script to dump the bytecode of the library functions written in Lua.
-- The resulting 'buildvm_libbc.h' is used for the build process of LuaJIT.
----------------------------------------------------------------------------
-- Copyright (C) 2005-2023 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
local ffi = require("ffi")
local bit = require("bit")
local vmdef = require("jit.vmdef")
local bcnames = vmdef.bcnames
local format = string.format
local isbe = (string.byte(string.dump(function() end), 5) % 2 == 1)
local function usage(arg)
io.stderr:write("Usage: ", arg and arg[0] or "genlibbc",
" [-o buildvm_libbc.h] lib_*.c\n")
os.exit(1)
end
local function parse_arg(arg)
local outfile = "-"
if not (arg and arg[1]) then
usage(arg)
end
if arg[1] == "-o" then
outfile = arg[2]
if not outfile then usage(arg) end
table.remove(arg, 1)
table.remove(arg, 1)
end
return outfile
end
local function read_files(names)
local src = ""
for _,name in ipairs(names) do
local fp = assert(io.open(name))
src = src .. fp:read("*a")
fp:close()
end
return src
end
local function transform_lua(code)
local fixup = {}
local n = -30000
code = string.gsub(code, "CHECK_(%w*)%((.-)%)", function(tp, var)
n = n + 1
fixup[n] = { "CHECK", tp }
return format("%s=%d", var, n)
end)
code = string.gsub(code, "PAIRS%((.-)%)", function(var)
fixup.PAIRS = true
return format("nil, %s, 0x4dp80", var)
end)
return "return "..code, fixup
end
local function read_uleb128(p)
local v = p[0]; p = p + 1
if v >= 128 then
local sh = 7; v = v - 128
repeat
local r = p[0]
v = v + bit.lshift(bit.band(r, 127), sh)
sh = sh + 7
p = p + 1
until r < 128
end
return p, v
end
-- ORDER LJ_T
local name2itype = {
str = 5, func = 9, tab = 12, int = 14, num = 15
}
local BC, BCN = {}, {}
for i=0,#bcnames/6-1 do
local name = bcnames:sub(i*6+1, i*6+6):gsub(" ", "")
BC[name] = i
BCN[i] = name
end
local xop, xra = isbe and 3 or 0, isbe and 2 or 1
local xrc, xrb = isbe and 1 or 2, isbe and 0 or 3
local function fixup_dump(dump, fixup)
local buf = ffi.new("uint8_t[?]", #dump+1, dump)
local p = buf+5
local n, sizebc
p, n = read_uleb128(p)
local start = p
p = p + 4
p = read_uleb128(p)
p = read_uleb128(p)
p, sizebc = read_uleb128(p)
local startbc = tonumber(p - start)
local rawtab = {}
for i=0,sizebc-1 do
local op = p[xop]
if op == BC.KSHORT then
local rd = p[xrc] + 256*p[xrb]
rd = bit.arshift(bit.lshift(rd, 16), 16)
local f = fixup[rd]
if f then
if f[1] == "CHECK" then
local tp = f[2]
if tp == "tab" then rawtab[p[xra]] = true end
p[xop] = tp == "num" and BC.ISNUM or BC.ISTYPE
p[xrb] = 0
p[xrc] = name2itype[tp]
else
error("unhandled fixup type: "..f[1])
end
end
elseif op == BC.TGETV then
if rawtab[p[xrb]] then
p[xop] = BC.TGETR
end
elseif op == BC.TSETV then
if rawtab[p[xrb]] then
p[xop] = BC.TSETR
end
elseif op == BC.ITERC then
if fixup.PAIRS then
p[xop] = BC.ITERN
end
end
p = p + 4
end
local ndump = ffi.string(start, n)
-- Fixup hi-part of 0x4dp80 to LJ_KEYINDEX.
ndump = ndump:gsub("\x80\x80\xcd\xaa\x04", "\xff\xff\xf9\xff\x0f")
return { dump = ndump, startbc = startbc, sizebc = sizebc }
end
local function find_defs(src, mode)
local defs = {}
for name, code in string.gmatch(src, "LJLIB_LUA%(([^)]*)%)%s*/%*(.-)%*/") do
local tcode, fixup = transform_lua(code)
local func = assert(load(tcode, "", mode))
defs[name] = fixup_dump(string.dump(func, mode), fixup)
defs[#defs+1] = name
end
return defs
end
local function gen_header(defs32, defs64)
local t = {}
local function w(x) t[#t+1] = x end
w("/* This is a generated file. DO NOT EDIT! */\n\n")
w("static const int libbc_endian = ") w(isbe and 1 or 0) w(";\n\n")
for j,defs in ipairs{defs64, defs32} do
local s, sb = "", ""
for i,name in ipairs(defs) do
local d = defs[name]
s = s .. d.dump
sb = sb .. string.char(i) .. ("\0"):rep(d.startbc - 1)
.. (isbe and "\0\0\0\255" or "\255\0\0\0"):rep(d.sizebc)
.. ("\0"):rep(#d.dump - d.startbc - d.sizebc*4)
end
if j == 1 then
w("static const uint8_t libbc_code[] = {\n#if LJ_FR2\n")
else
w("\n#else\n")
end
local n = 0
for i=1,#s do
local x = string.byte(s, i)
local xb = string.byte(sb, i)
if xb == 255 then
local name = BCN[x]
local m = #name + 4
if n + m > 78 then n = 0; w("\n") end
n = n + m
w("BC_"); w(name)
else
local m = x < 10 and 2 or (x < 100 and 3 or 4)
if xb == 0 then
if n + m > 78 then n = 0; w("\n") end
else
local name = defs[xb]:gsub("_", ".")
if n ~= 0 then w("\n") end
w("/* "); w(name); w(" */ ")
n = #name + 7
end
n = n + m
w(x)
end
w(",")
end
end
w("\n#endif\n0\n};\n\n")
w("static const struct { const char *name; int ofs; } libbc_map[] = {\n")
local m32, m64 = 0, 0
for i,name in ipairs(defs32) do
assert(name == defs64[i])
w('{"'); w(name); w('",'); w(m32) w('},\n')
m32 = m32 + #defs32[name].dump
m64 = m64 + #defs64[name].dump
assert(m32 == m64)
end
w("{NULL,"); w(m32); w("}\n};\n\n")
return table.concat(t)
end
local function write_file(name, data)
if name == "-" then
assert(io.write(data))
assert(io.flush())
else
local fp = io.open(name)
if fp then
local old = fp:read("*a")
fp:close()
if data == old then return end
end
fp = assert(io.open(name, "w"))
assert(fp:write(data))
assert(fp:close())
end
end
local outfile = parse_arg(arg)
local src = read_files(arg)
local defs32 = find_defs(src, "Wdts")
local defs64 = find_defs(src, "Xdts")
local hdr = gen_header(defs32, defs64)
write_file(outfile, hdr)
-436
View File
@@ -1,436 +0,0 @@
----------------------------------------------------------------------------
-- Lua script to generate a customized, minified version of Lua.
-- The resulting 'minilua' is used for the build process of LuaJIT.
----------------------------------------------------------------------------
-- Copyright (C) 2005-2023 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
local sub, match, gsub = string.sub, string.match, string.gsub
local LUA_VERSION = "5.1.5"
local LUA_SOURCE
local function usage()
io.stderr:write("Usage: ", arg and arg[0] or "genminilua",
" lua-", LUA_VERSION, "-source-dir\n")
os.exit(1)
end
local function find_sources()
LUA_SOURCE = arg and arg[1]
if not LUA_SOURCE then usage() end
if sub(LUA_SOURCE, -1) ~= "/" then LUA_SOURCE = LUA_SOURCE.."/" end
local fp = io.open(LUA_SOURCE .. "lua.h")
if not fp then
LUA_SOURCE = LUA_SOURCE.."src/"
fp = io.open(LUA_SOURCE .. "lua.h")
if not fp then usage() end
end
local all = fp:read("*a")
fp:close()
if not match(all, 'LUA_RELEASE%s*"Lua '..LUA_VERSION..'"') then
io.stderr:write("Error: version mismatch\n")
usage()
end
end
local LUA_FILES = {
"lmem.c", "lobject.c", "ltm.c", "lfunc.c", "ldo.c", "lstring.c", "ltable.c",
"lgc.c", "lstate.c", "ldebug.c", "lzio.c", "lopcodes.c",
"llex.c", "lcode.c", "lparser.c", "lvm.c", "lapi.c", "lauxlib.c",
"lbaselib.c", "ltablib.c", "liolib.c", "loslib.c", "lstrlib.c", "linit.c",
}
local REMOVE_LIB = {}
gsub([[
collectgarbage dofile gcinfo getfenv getmetatable load print rawequal rawset
select tostring xpcall
foreach foreachi getn maxn setn
popen tmpfile seek setvbuf __tostring
clock date difftime execute getenv rename setlocale time tmpname
dump gfind len reverse
LUA_LOADLIBNAME LUA_MATHLIBNAME LUA_DBLIBNAME
]], "%S+", function(name)
REMOVE_LIB[name] = true
end)
local REMOVE_EXTINC = { ["<assert.h>"] = true, ["<locale.h>"] = true, }
local CUSTOM_MAIN = [[
typedef unsigned int UB;
static UB barg(lua_State *L,int idx){
union{lua_Number n;U64 b;}bn;
bn.n=lua_tonumber(L,idx)+6755399441055744.0;
if (bn.n==0.0&&!lua_isnumber(L,idx))luaL_typerror(L,idx,"number");
return(UB)bn.b;
}
#define BRET(b) lua_pushnumber(L,(lua_Number)(int)(b));return 1;
static int tobit(lua_State *L){
BRET(barg(L,1))}
static int bnot(lua_State *L){
BRET(~barg(L,1))}
static int band(lua_State *L){
int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b&=barg(L,i);BRET(b)}
static int bor(lua_State *L){
int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b|=barg(L,i);BRET(b)}
static int bxor(lua_State *L){
int i;UB b=barg(L,1);for(i=lua_gettop(L);i>1;i--)b^=barg(L,i);BRET(b)}
static int lshift(lua_State *L){
UB b=barg(L,1),n=barg(L,2)&31;BRET(b<<n)}
static int rshift(lua_State *L){
UB b=barg(L,1),n=barg(L,2)&31;BRET(b>>n)}
static int arshift(lua_State *L){
UB b=barg(L,1),n=barg(L,2)&31;BRET((int)b>>n)}
static int rol(lua_State *L){
UB b=barg(L,1),n=barg(L,2)&31;BRET((b<<n)|(b>>(32-n)))}
static int ror(lua_State *L){
UB b=barg(L,1),n=barg(L,2)&31;BRET((b>>n)|(b<<(32-n)))}
static int bswap(lua_State *L){
UB b=barg(L,1);b=(b>>24)|((b>>8)&0xff00)|((b&0xff00)<<8)|(b<<24);BRET(b)}
static int tohex(lua_State *L){
UB b=barg(L,1);
int n=lua_isnone(L,2)?8:(int)barg(L,2);
const char *hexdigits="0123456789abcdef";
char buf[8];
int i;
if(n<0){n=-n;hexdigits="0123456789ABCDEF";}
if(n>8)n=8;
for(i=(int)n;--i>=0;){buf[i]=hexdigits[b&15];b>>=4;}
lua_pushlstring(L,buf,(size_t)n);
return 1;
}
static const struct luaL_Reg bitlib[] = {
{"tobit",tobit},
{"bnot",bnot},
{"band",band},
{"bor",bor},
{"bxor",bxor},
{"lshift",lshift},
{"rshift",rshift},
{"arshift",arshift},
{"rol",rol},
{"ror",ror},
{"bswap",bswap},
{"tohex",tohex},
{NULL,NULL}
};
int main(int argc, char **argv){
lua_State *L = luaL_newstate();
int i;
luaL_openlibs(L);
luaL_register(L, "bit", bitlib);
if (argc < 2) return sizeof(void *);
lua_createtable(L, 0, 1);
lua_pushstring(L, argv[1]);
lua_rawseti(L, -2, 0);
lua_setglobal(L, "arg");
if (luaL_loadfile(L, argv[1]))
goto err;
for (i = 2; i < argc; i++)
lua_pushstring(L, argv[i]);
if (lua_pcall(L, argc - 2, 0, 0)) {
err:
fprintf(stderr, "Error: %s\n", lua_tostring(L, -1));
return 1;
}
lua_close(L);
return 0;
}
]]
local function read_sources()
local t = {}
for i, name in ipairs(LUA_FILES) do
local fp = assert(io.open(LUA_SOURCE..name, "r"))
t[i] = fp:read("*a")
assert(fp:close())
end
t[#t+1] = CUSTOM_MAIN
return table.concat(t)
end
local includes = {}
local function merge_includes(src)
return gsub(src, '#include%s*"([^"]*)"%s*\n', function(name)
if includes[name] then return "" end
includes[name] = true
local fp = assert(io.open(LUA_SOURCE..name, "r"))
local inc = fp:read("*a")
assert(fp:close())
inc = gsub(inc, "#ifndef%s+%w+_h\n#define%s+%w+_h\n", "")
inc = gsub(inc, "#endif%s*$", "")
return merge_includes(inc)
end)
end
local function get_license(src)
return match(src, "/%*+\n%* Copyright %(.-%*/\n")
end
local function fold_lines(src)
return gsub(src, "\\\n", " ")
end
local strings = {}
local function save_str(str)
local n = #strings+1
strings[n] = str
return "\1"..n.."\2"
end
local function save_strings(src)
src = gsub(src, '"[^"\n]*"', save_str)
return gsub(src, "'[^'\n]*'", save_str)
end
local function restore_strings(src)
return gsub(src, "\1(%d+)\2", function(numstr)
return strings[tonumber(numstr)]
end)
end
local function def_istrue(def)
return def == "INT_MAX > 2147483640L" or
def == "LUAI_BITSINT >= 32" or
def == "SIZE_Bx < LUAI_BITSINT-1" or
def == "cast" or
def == "defined(LUA_CORE)" or
def == "MINSTRTABSIZE" or
def == "LUA_MINBUFFER" or
def == "HARDSTACKTESTS" or
def == "UNUSED"
end
local head, defs = {[[
#ifdef _MSC_VER
typedef unsigned __int64 U64;
#else
typedef unsigned long long U64;
#endif
int _CRT_glob = 0;
]]}, {}
local function preprocess(src)
local t = { match(src, "^(.-)#") }
local lvl, on, oldon = 0, true, {}
for pp, def, txt in string.gmatch(src, "#(%w+) *([^\n]*)\n([^#]*)") do
if pp == "if" or pp == "ifdef" or pp == "ifndef" then
lvl = lvl + 1
oldon[lvl] = on
on = def_istrue(def)
elseif pp == "else" then
if oldon[lvl] then
if on == false then on = true else on = false end
end
elseif pp == "elif" then
if oldon[lvl] then
on = def_istrue(def)
end
elseif pp == "endif" then
on = oldon[lvl]
lvl = lvl - 1
elseif on then
if pp == "include" then
if not head[def] and not REMOVE_EXTINC[def] then
head[def] = true
head[#head+1] = "#include "..def.."\n"
end
elseif pp == "define" then
local k, sp, v = match(def, "([%w_]+)(%s*)(.*)")
if k and not (sp == "" and sub(v, 1, 1) == "(") then
defs[k] = gsub(v, "%a[%w_]*", function(tok)
return defs[tok] or tok
end)
else
t[#t+1] = "#define "..def.."\n"
end
elseif pp ~= "undef" then
error("unexpected directive: "..pp.." "..def)
end
end
if on then t[#t+1] = txt end
end
return gsub(table.concat(t), "%a[%w_]*", function(tok)
return defs[tok] or tok
end)
end
local function merge_header(src, license)
local hdr = string.format([[
/* This is a heavily customized and minimized copy of Lua %s. */
/* It's only used to build LuaJIT. It does NOT have all standard functions! */
]], LUA_VERSION)
return hdr..license..table.concat(head)..src
end
local function strip_unused1(src)
return gsub(src, '( {"?([%w_]+)"?,%s+%a[%w_]*},\n)', function(line, func)
return REMOVE_LIB[func] and "" or line
end)
end
local function strip_unused2(src)
return gsub(src, "Symbolic Execution.-}=", "")
end
local function strip_unused3(src)
src = gsub(src, "extern", "static")
src = gsub(src, "\nstatic([^\n]-)%(([^)]*)%)%(", "\nstatic%1 %2(")
src = gsub(src, "#define lua_assert[^\n]*\n", "")
src = gsub(src, "lua_assert%b();?", "")
src = gsub(src, "default:\n}", "default:;\n}")
src = gsub(src, "lua_lock%b();", "")
src = gsub(src, "lua_unlock%b();", "")
src = gsub(src, "luai_threadyield%b();", "")
src = gsub(src, "luai_userstateopen%b();", "{}")
src = gsub(src, "luai_userstate%w+%b();", "")
src = gsub(src, "%(%(c==.*luaY_parser%)", "luaY_parser")
src = gsub(src, "trydecpoint%(ls,seminfo%)",
"luaX_lexerror(ls,\"malformed number\",TK_NUMBER)")
src = gsub(src, "int c=luaZ_lookahead%b();", "")
src = gsub(src, "luaL_register%(L,[^,]*,co_funcs%);\nreturn 2;",
"return 1;")
src = gsub(src, "getfuncname%b():", "NULL:")
src = gsub(src, "getobjname%b():", "NULL:")
src = gsub(src, "if%([^\n]*hookmask[^\n]*%)\n[^\n]*\n", "")
src = gsub(src, "if%([^\n]*hookmask[^\n]*%)%b{}\n", "")
src = gsub(src, "if%([^\n]*hookmask[^\n]*&&\n[^\n]*%b{}\n", "")
src = gsub(src, "(twoto%b()%()", "%1(size_t)")
src = gsub(src, "i<sizenode", "i<(int)sizenode")
src = gsub(src, "cast%(unsigned int,key%-1%)", "cast(unsigned int,key)-1")
return gsub(src, "\n\n+", "\n")
end
local function strip_comments(src)
return gsub(src, "/%*.-%*/", " ")
end
local function strip_whitespace(src)
src = gsub(src, "^%s+", "")
src = gsub(src, "%s*\n%s*", "\n")
src = gsub(src, "[ \t]+", " ")
src = gsub(src, "(%W) ", "%1")
return gsub(src, " (%W)", "%1")
end
local function rename_tokens1(src)
src = gsub(src, "getline", "getline_")
src = gsub(src, "struct ([%w_]+)", "ZX%1")
return gsub(src, "union ([%w_]+)", "ZY%1")
end
local function rename_tokens2(src)
src = gsub(src, "ZX([%w_]+)", "struct %1")
return gsub(src, "ZY([%w_]+)", "union %1")
end
local function fix_bugs_and_warnings(src)
src = gsub(src, "(luaD_checkstack%(L,p%->maxstacksize)%)", "%1+p->numparams)")
src = gsub(src, "if%(sep==%-1%)(return'%[';)\nelse (luaX_lexerror%b();)", "if (sep!=-1)%2\n%1")
return gsub(src, "(default:{\nNode%*n=mainposition)", "/*fallthrough*/\n%1")
end
local function func_gather(src)
local nodes, list = {}, {}
local pos, len = 1, #src
while pos < len do
local d, w = match(src, "^(#define ([%w_]+)[^\n]*\n)", pos)
if d then
local n = #list+1
list[n] = d
nodes[w] = n
else
local s
d, w, s = match(src, "^(([%w_]+)[^\n]*([{;])\n)", pos)
if not d then
d, w, s = match(src, "^(([%w_]+)[^(]*%b()([{;])\n)", pos)
if not d then d = match(src, "^[^\n]*\n", pos) end
end
if s == "{" then
d = d..sub(match(src, "^%b{}[^;\n]*;?\n", pos+#d-2), 3)
if sub(d, -2) == "{\n" then
d = d..sub(match(src, "^%b{}[^;\n]*;?\n", pos+#d-2), 3)
end
end
local k, v = nil, d
if w == "typedef" then
if match(d, "^typedef enum") then
head[#head+1] = d
else
k = match(d, "([%w_]+);\n$")
if not k then k = match(d, "^.-%(.-([%w_]+)%)%(") end
end
elseif w == "enum" then
head[#head+1] = v
elseif w ~= nil then
k = match(d, "^[^\n]-([%w_]+)[(%[=]")
if k then
if w ~= "static" and k ~= "main" then v = "static "..d end
else
k = w
end
end
if w and k then
local o = nodes[k]
if o then nodes["*"..k] = o end
local n = #list+1
list[n] = v
nodes[k] = n
end
end
pos = pos + #d
end
return nodes, list
end
local function func_visit(nodes, list, used, n)
local i = nodes[n]
for m in string.gmatch(list[i], "[%w_]+") do
if nodes[m] then
local j = used[m]
if not j then
used[m] = i
func_visit(nodes, list, used, m)
elseif i < j then
used[m] = i
end
end
end
end
local function func_collect(src)
local nodes, list = func_gather(src)
local used = {}
func_visit(nodes, list, used, "main")
for n,i in pairs(nodes) do
local j = used[n]
if j and j < i then used["*"..n] = j end
end
for n,i in pairs(nodes) do
if not used[n] then list[i] = "" end
end
return table.concat(list)
end
find_sources()
local src = read_sources()
src = merge_includes(src)
local license = get_license(src)
src = fold_lines(src)
src = strip_unused1(src)
src = save_strings(src)
src = strip_unused2(src)
src = strip_comments(src)
src = preprocess(src)
src = strip_whitespace(src)
src = strip_unused3(src)
src = rename_tokens1(src)
src = func_collect(src)
src = rename_tokens2(src)
src = restore_strings(src)
src = fix_bugs_and_warnings(src)
src = merge_header(src, license)
io.write(src)
-45
View File
@@ -1,45 +0,0 @@
----------------------------------------------------------------------------
-- Lua script to embed the rolling release version in luajit.h.
----------------------------------------------------------------------------
-- Copyright (C) 2005-2023 Mike Pall. All rights reserved.
-- Released under the MIT license. See Copyright Notice in luajit.h
----------------------------------------------------------------------------
local arg = {...}
local FILE_ROLLING_H = arg[1] or "luajit_rolling.h"
local FILE_RELVER_TXT = arg[2] or "luajit_relver.txt"
local FILE_LUAJIT_H = arg[3] or "luajit.h"
local function file_read(file)
local fp = assert(io.open(file, "rb"), "run from the wrong directory")
local data = assert(fp:read("*a"))
fp:close()
return data
end
local function file_write_mod(file, data)
local fp = io.open(file, "rb")
if fp then
local odata = assert(fp:read("*a"))
fp:close()
if odata == data then return end
end
fp = assert(io.open(file, "wb"))
assert(fp:write(data))
assert(fp:close())
end
local text = file_read(FILE_ROLLING_H):gsub("#error.-\n", "")
local relver = file_read(FILE_RELVER_TXT):match("(%d+)")
if relver then
text = text:gsub("ROLLING", relver)
else
io.stderr:write([[
**** WARNING Cannot determine rolling release version from git log.
**** WARNING The 'git' command must be available during the build.
]])
file_write_mod(FILE_RELVER_TXT, "ROLLING\n") -- Fallback for install target.
end
file_write_mod(FILE_LUAJIT_H, text)
File diff suppressed because it is too large. Load diff
-1
View File
@@ -1 +0,0 @@
vmdef.lua
Loaded 100 of 585 files, more files were not shown because too many files have changed in this diff. Show more