From acefc311f81078eb25110ea1ab20f62dc5489748 Mon Sep 17 00:00:00 2001 From: GeneralGuy4872 Date: Wed, 15 Jul 2020 11:20:28 -0500 Subject: [PATCH] WORKING! --- Licensing/README.md | 22 ++ README.md | 144 ++++--- conventions.md | 17 - cursesdataformat.txt | 17 +- cyberpunk/OpeningScene.txt | 15 + cyberpunk/Opening__Background.txt | 11 + cyberpunk/WANTED1.txt | 16 + cyberpunk/WANTED2.txt | 17 + cyberpunk/open | 9 - databasesystem.txt | 0 dependancies.txt | 65 +++- fantasy/README.md | 19 + filetypes.txt | 12 +- src/README.md | 127 ++++++ src/binary16vector.c | 4 - src/binary16vector.h | 14 - src/cursescat.h | 20 - .../archive.c | 0 .../bettersavefileio.c | 0 concepts.txt => src/deprecated/concepts.txt | 0 src/deprecated/doublelinkedlist.cc | 85 ++++ .../evheap.c | 0 .../exists.tmpl | 0 .../extmodules.cc | 0 .../flywheel.cpseudo | 0 .../funstack.c | 0 .../globalvar.cc | 0 .../heapio.c | 0 .../heapio2.c | 0 .../lightning.psudoexpr | 0 .../lighttree.c | 0 .../plugin.cc | 0 .../plugin.cclass | 0 .../plugin.h | 0 .../pure_c_shared_mutex.c | 0 .../renderstack.c | 0 .../savefileio.cc | 0 .../scalar.c | 0 .../strangemutex.cc | 0 .../texturetree.c | 0 .../uuidtypes.def | 0 src/{ => deprecated/vectors.d}/vectors.c | 0 src/{ => deprecated/vectors.d}/vectors.c.m4 | 0 src/{ => deprecated/vectors.d}/vectors.h | 0 src/{ => deprecated/vectors.d}/vectors.h.m4 | 0 .../wrapper___std___shared_mutex.cc | 0 src/incomplete/launchpad/camcoord.cc | 37 ++ .../launchpad/directory/directory.hh | 22 ++ .../launchpad/directory/tmp_directory.tmpl | 43 ++ src/incomplete/launchpad/minifixed.cc | 50 +++ .../argvlogic.h | 0 .../{sandbox => mothballed}/as_moduleglue.cc | 0 .../{sandbox => mothballed}/build.sh | 0 src/incomplete/mothballed/chunk.H | 76 ++++ src/incomplete/mothballed/chunk.fragment | 1 + .../{sandbox => mothballed}/commandline.hh | 13 +- .../commandlinesyntax.txt | 0 .../doublelinkedlist.d/refcounted.cc | 86 ++++ .../doublelinkedlist.d/refcounted.h | 4 + .../doublelinkedlist.d/refcounted.hh | 24 ++ .../flywheel}/flywheel.cclass | 0 .../mothballed/flywheel/flywheel.hh | 24 ++ src/incomplete/mothballed/iwf__chunk.cc | 6 + .../iwf__graphics3d.cc | 0 .../C_iwf__voxels__minichunk.cc | 50 +++ .../C_iwf__voxels__minichunk.h | 12 + .../iwf__voxels__minichunk.cclass | 37 ++ .../iwf__voxels__minichunk.hh | 9 + .../{sandbox => mothballed}/iwf_joystick.c | 0 .../{sandbox => mothballed}/keyswitch.inc | 0 src/incomplete/mothballed/listcontainer.cc | 85 ++++ .../magnetoception.txt | 0 .../{sandbox => mothballed}/main.cc | 0 .../{sandbox => mothballed}/memdump.pseudoc | 0 src/incomplete/mothballed/octanttriple.c | 69 ++++ src/incomplete/mothballed/pools.cc | 29 ++ .../mothballed/refcount.d/refcounted.cc | 86 ++++ .../mothballed/refcount.d/refcounted.h | 4 + .../mothballed/refcount.d/refcounted.hh | 24 ++ .../{launchpad => mothballed}/repl.cc | 0 .../{launchpad => mothballed}/scriptboot.cc | 0 .../{sandbox => mothballed}/seedcrypt.cc | 0 .../{sandbox => mothballed}/seedcrypt.h | 0 .../{sandbox => mothballed}/seedcrypt.hlib | 0 .../{sandbox => mothballed}/split.cc | 0 .../{sandbox => mothballed}/startup.cc | 0 .../{sandbox => mothballed}/types.h | 0 .../variablewidthdatablock.cc | 25 ++ .../variablewidthdatablock.hh | 4 + src/incomplete/mothballed/voxel.H | 12 + .../mothballedORreference/minifixed.c | 17 - .../mothballedORreference/minifixed.h | 13 - .../mothballedORreference/templates/README.md | 3 - .../sandbox/bitstruct}/bitpack.c | 31 +- .../sandbox/bitstruct}/bitpack.h | 0 .../sandbox/bitvector/bitvector16.c | 35 ++ .../sandbox/bitvector/bitvector32.c | 35 ++ .../sandbox/bitvector/bitvector64.c | 35 ++ src/incomplete/sandbox/bitvector/bitvector8.c | 35 ++ src/incomplete/sandbox/commandline/lexer.lex | 54 +++ src/incomplete/sandbox/commandline/parser.y | 15 + src/incomplete/sandbox/commandline/wrapper.cc | 37 ++ src/incomplete/sandbox/coord.c | 49 +++ .../sandbox/datatypes/basenttyp/abilities.H | 48 +++ src/incomplete/sandbox/datatypes/chunk.H | 71 ++++ .../sandbox/datatypes/chunk__directions.def | 19 + .../sandbox/datatypes/chunk__magic.H | 8 + src/incomplete/sandbox/datatypes/color.H | 31 ++ .../encounter_wheel/encounter_wheel.cc | 41 ++ .../encounter_wheel/encounter_wheel.h | 12 + .../encounter_wheel/encounter_wheel.hh | 13 + .../sandbox/datatypes/entity/ent_map.make | 10 + .../sandbox/datatypes/lights/lighttype.h | 14 + .../datatypes/lights/lighttype_map.make | 14 + .../sandbox/iwf__voxels__minichunk.cc | 42 -- src/incomplete/sandbox/pathfinder_data.cc | 23 ++ src/incomplete/sandbox/reload_rooms.inc | 366 ++++++++++++++++++ src/incomplete/sandbox/tiledata.H | 22 ++ src/incomplete/sandbox/tileref.c | 37 ++ src/incomplete/sandbox/voxelnodeid.c | 45 +++ src/incomplete/scratchpad.d/irrcontext.cc | 41 ++ src/incomplete/scratchpad.d/loadvoxels.cc | 41 ++ src/incomplete/scratchpad.d/roomcache.cc | 155 ++++++++ src/incomplete/{ => scratchpad.d}/scratchpad | 0 .../scratchpad.d/tiledata_and_texturecache.c | 31 ++ src/ongoing/globals.inc | 10 + src/reference/badlexer.cc | 144 +++++++ .../templates => reference}/cuckootree.c | 0 .../templates => reference}/evheap.c | 0 .../main.c | 0 .../oldtypes.h | 0 .../tmp.cnode | 0 .../atomic_mutex.d}/atomic_mutex.c | 0 .../atomic_mutex.d}/atomic_mutex.h | 0 src/{ => rotten/bitconcat.d}/bitconcat.c | 0 src/{ => rotten/bitconcat.d}/bitconcat.h | 0 src/{ => rotten}/dlfunc_shim.h | 0 src/{ => rotten}/fdshim.def | 0 src/{ => rotten/getsafe.d}/getsafe.cc | 0 src/{ => rotten/getsafe.d}/getsafe.h | 0 src/{ => rotten/listf.d}/listf.cc | 0 src/{ => rotten/listf.d}/listf.h | 0 src/{ => rotten/random.d}/random.c | 0 src/{ => rotten/random.d}/random.h | 0 src/{ => rotten/structops.d}/structops.c | 0 src/{ => rotten/structops.d}/structops.h | 0 src/{ => rotten/util.d}/util.c | 0 src/{ => rotten/util.d}/util.def | 3 + src/{ => rotten/util.d}/util.h | 0 src/{ => stable}/barrelroll.inl | 0 src/{ => stable}/base1.def | 0 src/{ => stable}/cppkeyword.def | 15 +- src/{ => stable/cursescat}/cursescat.c | 15 +- src/stable/cursescat/cursescat.h | 13 + src/stable/loops.def | 11 + src/stable/threequal.tmpl | 7 + src/using.hh | 11 - src/working/build.sh | 2 + src/working/main.cc | 192 +++++++++ tmp.md | 140 +++++++ tools/listwrapper_codegen.c | 70 ++++ tools/listwrapper_headergen.c | 32 ++ nybbleswap.c => tools/nybbleswap.c | 0 tools/stdmapwrapper_codegen.c | 69 ++++ tools/stdmapwrapper_headergen.c | 25 ++ tools/textgen.c | 57 +++ 166 files changed, 3449 insertions(+), 256 deletions(-) create mode 100644 Licensing/README.md delete mode 100644 conventions.md create mode 100644 cyberpunk/OpeningScene.txt create mode 100644 cyberpunk/Opening__Background.txt create mode 100644 cyberpunk/WANTED1.txt create mode 100644 cyberpunk/WANTED2.txt delete mode 100644 cyberpunk/open delete mode 100644 databasesystem.txt create mode 100644 fantasy/README.md create mode 100644 src/README.md delete mode 100644 src/binary16vector.c delete mode 100644 src/binary16vector.h delete mode 100644 src/cursescat.h rename src/{incomplete/mothballedORreference => deprecated}/archive.c (100%) rename src/{incomplete/mothballedORreference => deprecated}/bettersavefileio.c (100%) rename concepts.txt => src/deprecated/concepts.txt (100%) create mode 100644 src/deprecated/doublelinkedlist.cc rename src/{incomplete/mothballedORreference => deprecated}/evheap.c (100%) rename src/{incomplete/mothballedORreference => deprecated}/exists.tmpl (100%) rename src/{incomplete/mothballedORreference => deprecated}/extmodules.cc (100%) rename src/{incomplete/mothballedORreference => deprecated}/flywheel.cpseudo (100%) rename src/{incomplete/mothballedORreference => deprecated}/funstack.c (100%) rename src/{incomplete/mothballedORreference => deprecated}/globalvar.cc (100%) rename src/{incomplete/mothballedORreference => deprecated}/heapio.c (100%) rename src/{incomplete/mothballedORreference => deprecated}/heapio2.c (100%) rename src/{incomplete/mothballedORreference => deprecated}/lightning.psudoexpr (100%) rename src/{incomplete/mothballedORreference => deprecated}/lighttree.c (100%) rename src/{incomplete/mothballedORreference => deprecated}/plugin.cc (100%) rename src/{incomplete/mothballedORreference => deprecated}/plugin.cclass (100%) rename src/{incomplete/mothballedORreference => deprecated}/plugin.h (100%) rename src/{incomplete/mothballedORreference => deprecated}/pure_c_shared_mutex.c (100%) rename src/{incomplete/mothballedORreference => deprecated}/renderstack.c (100%) rename src/{incomplete/mothballedORreference => deprecated}/savefileio.cc (100%) rename src/{incomplete/mothballedORreference => deprecated}/scalar.c (100%) rename src/{incomplete/mothballedORreference => deprecated}/strangemutex.cc (100%) rename src/{incomplete/mothballedORreference => deprecated}/texturetree.c (100%) rename src/{incomplete/mothballedORreference => deprecated}/uuidtypes.def (100%) rename src/{ => deprecated/vectors.d}/vectors.c (100%) rename src/{ => deprecated/vectors.d}/vectors.c.m4 (100%) rename src/{ => deprecated/vectors.d}/vectors.h (100%) rename src/{ => deprecated/vectors.d}/vectors.h.m4 (100%) rename src/{incomplete/mothballedORreference => deprecated}/wrapper___std___shared_mutex.cc (100%) create mode 100644 src/incomplete/launchpad/camcoord.cc create mode 100644 src/incomplete/launchpad/directory/directory.hh create mode 100644 src/incomplete/launchpad/directory/tmp_directory.tmpl create mode 100644 src/incomplete/launchpad/minifixed.cc rename src/incomplete/{mothballedORreference => mothballed}/argvlogic.h (100%) rename src/incomplete/{sandbox => mothballed}/as_moduleglue.cc (100%) rename src/incomplete/{sandbox => mothballed}/build.sh (100%) create mode 100644 src/incomplete/mothballed/chunk.H create mode 100644 src/incomplete/mothballed/chunk.fragment rename src/incomplete/{sandbox => mothballed}/commandline.hh (76%) rename src/incomplete/{sandbox => mothballed}/commandlinesyntax.txt (100%) create mode 100644 src/incomplete/mothballed/doublelinkedlist.d/refcounted.cc create mode 100644 src/incomplete/mothballed/doublelinkedlist.d/refcounted.h create mode 100644 src/incomplete/mothballed/doublelinkedlist.d/refcounted.hh rename src/incomplete/{launchpad => mothballed/flywheel}/flywheel.cclass (100%) create mode 100644 src/incomplete/mothballed/flywheel/flywheel.hh create mode 100644 src/incomplete/mothballed/iwf__chunk.cc rename src/incomplete/{sandbox => mothballed}/iwf__graphics3d.cc (100%) create mode 100644 src/incomplete/mothballed/iwf__voxels__minichunk/C_iwf__voxels__minichunk.cc create mode 100644 src/incomplete/mothballed/iwf__voxels__minichunk/C_iwf__voxels__minichunk.h create mode 100644 src/incomplete/mothballed/iwf__voxels__minichunk/iwf__voxels__minichunk.cclass create mode 100644 src/incomplete/mothballed/iwf__voxels__minichunk/iwf__voxels__minichunk.hh rename src/incomplete/{sandbox => mothballed}/iwf_joystick.c (100%) rename src/incomplete/{sandbox => mothballed}/keyswitch.inc (100%) create mode 100644 src/incomplete/mothballed/listcontainer.cc rename src/incomplete/{mothballedORreference => mothballed}/magnetoception.txt (100%) rename src/incomplete/{sandbox => mothballed}/main.cc (100%) rename src/incomplete/{sandbox => mothballed}/memdump.pseudoc (100%) create mode 100644 src/incomplete/mothballed/octanttriple.c create mode 100644 src/incomplete/mothballed/pools.cc create mode 100644 src/incomplete/mothballed/refcount.d/refcounted.cc create mode 100644 src/incomplete/mothballed/refcount.d/refcounted.h create mode 100644 src/incomplete/mothballed/refcount.d/refcounted.hh rename src/incomplete/{launchpad => mothballed}/repl.cc (100%) rename src/incomplete/{launchpad => mothballed}/scriptboot.cc (100%) rename src/incomplete/{sandbox => mothballed}/seedcrypt.cc (100%) rename src/incomplete/{sandbox => mothballed}/seedcrypt.h (100%) rename src/incomplete/{sandbox => mothballed}/seedcrypt.hlib (100%) rename src/incomplete/{sandbox => mothballed}/split.cc (100%) rename src/incomplete/{sandbox => mothballed}/startup.cc (100%) rename src/incomplete/{sandbox => mothballed}/types.h (100%) create mode 100644 src/incomplete/mothballed/variablewidthdatablock/variablewidthdatablock.cc create mode 100644 src/incomplete/mothballed/variablewidthdatablock/variablewidthdatablock.hh create mode 100644 src/incomplete/mothballed/voxel.H delete mode 100644 src/incomplete/mothballedORreference/minifixed.c delete mode 100644 src/incomplete/mothballedORreference/minifixed.h delete mode 100644 src/incomplete/mothballedORreference/templates/README.md rename src/{ => incomplete/sandbox/bitstruct}/bitpack.c (63%) rename src/{ => incomplete/sandbox/bitstruct}/bitpack.h (100%) create mode 100644 src/incomplete/sandbox/bitvector/bitvector16.c create mode 100644 src/incomplete/sandbox/bitvector/bitvector32.c create mode 100644 src/incomplete/sandbox/bitvector/bitvector64.c create mode 100644 src/incomplete/sandbox/bitvector/bitvector8.c create mode 100644 src/incomplete/sandbox/commandline/lexer.lex create mode 100644 src/incomplete/sandbox/commandline/parser.y create mode 100644 src/incomplete/sandbox/commandline/wrapper.cc create mode 100644 src/incomplete/sandbox/coord.c create mode 100644 src/incomplete/sandbox/datatypes/basenttyp/abilities.H create mode 100644 src/incomplete/sandbox/datatypes/chunk.H create mode 100644 src/incomplete/sandbox/datatypes/chunk__directions.def create mode 100644 src/incomplete/sandbox/datatypes/chunk__magic.H create mode 100644 src/incomplete/sandbox/datatypes/color.H create mode 100644 src/incomplete/sandbox/datatypes/encounter_wheel/encounter_wheel.cc create mode 100644 src/incomplete/sandbox/datatypes/encounter_wheel/encounter_wheel.h create mode 100644 src/incomplete/sandbox/datatypes/encounter_wheel/encounter_wheel.hh create mode 100644 src/incomplete/sandbox/datatypes/entity/ent_map.make create mode 100644 src/incomplete/sandbox/datatypes/lights/lighttype.h create mode 100644 src/incomplete/sandbox/datatypes/lights/lighttype_map.make delete mode 100644 src/incomplete/sandbox/iwf__voxels__minichunk.cc create mode 100644 src/incomplete/sandbox/pathfinder_data.cc create mode 100644 src/incomplete/sandbox/reload_rooms.inc create mode 100644 src/incomplete/sandbox/tiledata.H create mode 100644 src/incomplete/sandbox/tileref.c create mode 100644 src/incomplete/sandbox/voxelnodeid.c create mode 100644 src/incomplete/scratchpad.d/irrcontext.cc create mode 100644 src/incomplete/scratchpad.d/loadvoxels.cc create mode 100644 src/incomplete/scratchpad.d/roomcache.cc rename src/incomplete/{ => scratchpad.d}/scratchpad (100%) create mode 100644 src/incomplete/scratchpad.d/tiledata_and_texturecache.c create mode 100644 src/reference/badlexer.cc rename src/{incomplete/mothballedORreference/templates => reference}/cuckootree.c (100%) rename src/{incomplete/mothballedORreference/templates => reference}/evheap.c (100%) rename src/{incomplete/mothballedORreference => reference}/main.c (100%) rename src/{incomplete/mothballedORreference => reference}/oldtypes.h (100%) rename src/{incomplete/mothballedORreference => reference}/tmp.cnode (100%) rename src/{ => rotten/atomic_mutex.d}/atomic_mutex.c (100%) rename src/{ => rotten/atomic_mutex.d}/atomic_mutex.h (100%) rename src/{ => rotten/bitconcat.d}/bitconcat.c (100%) rename src/{ => rotten/bitconcat.d}/bitconcat.h (100%) rename src/{ => rotten}/dlfunc_shim.h (100%) rename src/{ => rotten}/fdshim.def (100%) rename src/{ => rotten/getsafe.d}/getsafe.cc (100%) rename src/{ => rotten/getsafe.d}/getsafe.h (100%) rename src/{ => rotten/listf.d}/listf.cc (100%) rename src/{ => rotten/listf.d}/listf.h (100%) rename src/{ => rotten/random.d}/random.c (100%) rename src/{ => rotten/random.d}/random.h (100%) rename src/{ => rotten/structops.d}/structops.c (100%) rename src/{ => rotten/structops.d}/structops.h (100%) rename src/{ => rotten/util.d}/util.c (100%) rename src/{ => rotten/util.d}/util.def (89%) rename src/{ => rotten/util.d}/util.h (100%) rename src/{ => stable}/barrelroll.inl (100%) rename src/{ => stable}/base1.def (100%) rename src/{ => stable}/cppkeyword.def (57%) rename src/{ => stable/cursescat}/cursescat.c (62%) create mode 100644 src/stable/cursescat/cursescat.h create mode 100644 src/stable/loops.def create mode 100644 src/stable/threequal.tmpl delete mode 100644 src/using.hh create mode 100755 src/working/build.sh create mode 100644 src/working/main.cc create mode 100644 tmp.md create mode 100644 tools/listwrapper_codegen.c create mode 100644 tools/listwrapper_headergen.c rename nybbleswap.c => tools/nybbleswap.c (100%) create mode 100644 tools/stdmapwrapper_codegen.c create mode 100644 tools/stdmapwrapper_headergen.c create mode 100644 tools/textgen.c diff --git a/Licensing/README.md b/Licensing/README.md new file mode 100644 index 0000000..0681fa4 --- /dev/null +++ b/Licensing/README.md @@ -0,0 +1,22 @@ +LICENSING +========= + +The project, as a complete entity, is licensed under the terms of the GNU +General Public License, Version 2.0, or at your option, any later version. + +I reserve the right to republish some libraries which I consider to be +modularly independant of the project, but which are being published for the +first time as part of the project, at a later date under a less restrictive +liscense. + +*(note: I originally intended to liscense the project under the GPLv3, and +some parts of the source code archive have comments to this effect; I have +since chosen to commit to the GPLv2 or later because of various +potential complications regarding liscense propagation and the linux +kernel.)* + +*this is not legal advice, and I am not a lawyer. I am a programmer with +signifigant disdain for legal trolls suppressing the advancement of +knowladge, and I personally believe this liscense to be the best way of +preventing this.* + diff --git a/README.md b/README.md index 5076080..c97803d 100644 --- a/README.md +++ b/README.md @@ -3,49 +3,73 @@ IWannaFly (working title) ***Pre-Pre-Alpha version...idek*** -A Nearly Realtime RPG Engine written in C, C++, and Angelscript ---------------------------------------------------------------- -***(And possibly Objective-C and Objective-C++)*** +A Nearly Realtime RPG Engine written in C, C++, and lua +------------------------------------------------------- At this point, I've learned a bunch of stuff on both the programming and metaprogramming\* level, and I think I have a pretty good idea of how to move forward. This project was started primarily as a self-study opportunity, and it's been a fun journey. -I have now settled on a language, an overall structure, some libraries, -and a ui/gameplay style. from here, I do not forsee any further false -starts and hope to have smooth(ish) sailing through to a working alpha! + +I have now settled on a language, an overall structure, and some +libraries. from here, I do not forsee any further false starts and hope +to have smooth(ish) sailing through to a working alpha! The game engine uses the [Irrlicht Engine](http://irrlicht.sourceforge.net/) for rendering 3d graphics, [Cairo Graphics](https://www.cairographics.org/) for rendering -pictures, [NCurses](https://invisible-island.net/ncurses/) for -rendering dialog and menus, and -[AngelScript](https://www.angelcode.com/angelscript/) for general pourpose -scripting and debugging. to save space, the engine uses the half-precision -floating point implementation at http://half.sourceforge.net/ - -~~despite using C++, the majority of the project should be in C...~~ The -design goal of having a C API has been scrapped, in favor of using the -[AngelScript](https://www.angelcode.com/angelscript/) language. the -advantage to this is that Angelscript is JIT compiled (thus eliminating -pointer persistance problems) and has the crucial ability to directy access -and alter C data, which many of the scripting languages I considered -lacked. +pictures, [NCurses](https://invisible-island.net/ncurses/) for rendering +in-game dialog, and [lua](http://www.lua.org/) for both extensions and a +command line\ + *additional dependancies will follow...* + +use of an [external debugger](https://www.gnu.org/software/gdb/) is +recommended if **Bad Things** start happening. C code will use notation in variable names to seperate namespaces, using -`$$` in place of `::` *(this requires that a compiler support the extension -detailed in ISO 9899 Annex J.5.2)* +`$$` in place of `::` *(this requires that a compiler support the +extension detailed in ISO 9899 Annex J.5.2)* 2 example games will be provided: a high fantasy game with a wide cast of playable characters, and a cyberpunk game with a single customizable -character. when reporting bugs, please note if the bug concerns the engine, -or one of the games, and which part of the engine or game. +character. chunks can be connected in such a way to form wormholes that +are one-way or bidirectional. + +when reporting bugs, please note if the bug concerns the engine, or one +of the games, and which part of the engine or game; additionally, if the +bug concerns a freshly loaded state, try *turning it off and on again*. + +CODING STYLE +============ + +occasionally, a type of C coding called "Object Style C" will be used, +which takes the following form: +`namespace$$pseudo_class$$method(pseudo_object,arg,arg,arg...)` + +functions that in fortran would be called "subroutines" are also used, +and will be denoted by returning an implicit int or the SYSINT macro +(which evaluates to the empty string *(implicit int)* in C and to `int` +in C++) + +the types in `` (or ) should be used when an integer +of a specific width is required, with the exception that `char` should be +prefferred to `int8_t`, and `unsigned char` should be prefferred to +`uint8_t`. if an interger bitfield uses less than the full number of +bytes in an int, then it should be signed; otherwise it should +(*usually*) be unsigned. + +`struct`s should be catagorized into bitpacked structs and loosly-packed +structs. every field of a bitpacked struct should have an explicit width, +and should be of type `signed`, `unsigned`, or `bool`. a loosly-packed +struct should never use explicit-width fields. bitpacked structs should +eventually be replaced with interger bitfields. since `this` is a reserved word in C++, and `self` is a reserved word in -Objective-C, when using Object Style C, the object variable will be named -`adhoc`; the variable will be named `here` for lowlevel functions using an -opaque pointer to operate on contiguous memory. +Objective-C, when using Object-Style-C, the object variable will be named +`opaque` for `void *` pointers to C++ objects, or `object` for pointers +whose type is known; the variable will be named `here` for lowlevel +functions using an opaque pointer to operate on contiguous memory. similarly, since `new` is a keyword in C++ with a compleatly different meaning, an object that is being constructed by a function will be named `nova`. `input` may be employed as the primary, or only, argument of a @@ -53,7 +77,7 @@ function. `output` will be the return value. `acc` is an **acc**umulator, and should be a register variable. variables with generic names follow the following conventions: -- `x`, `y`, `z`, and `w` refer to coordinates +- `x`, `y`, `z`, and `w` refer to coordinates. `w` isn't used often. - `i` and `j` are `for`-loop iterators, either in the sense of C++ `::iterator`s or in the sense of intergal counters - `n` and `m` are generic numbers, usually for-loop intergal counters @@ -65,41 +89,65 @@ variables with generic names follow the following conventions: a naming system similar to [Systems Hungarian](https://en.wikipedia.org/wiki/Hungarian_notation) -is revived for the pourpose of manually mangling C functions that can take -multiple argument types, as this allows such functions to maintain C +is revived for the pourpose of manually mangling C functions that can +take multiple argument types, as this allows such functions to maintain C linkage while also having faux overloads. this is similar to functions in the C standard library such as `abs()` and `fabs()`. +FILENAMES +========= +files should use the following extensions: +- C preprocessor files + - `*.def` : C preprocessor macros +- C files + - `*.c` : C code + - `*.h` : C header + - `*.inl` : inline functions +- C++ files + - `*.cc` : C++ code + - `*.hh` : C++ header + - `*.tmpl` : C++ template +- C or C++ files + - `*.H` : C or C++ header + - `*.inc` : transclusion, for editing conveniance +- data files + - `*.txt` : raw text + - `*.ro4` : ciphertext (see below) + - `*.curses` : bytecode for a curses interpreter + - `*.lua` : a lua script + files ending in .ro4 contain severe spoilers, and have been ciphered by applying a [Circular Shift](https://en.wikipedia.org/wiki/Circular_shift) -of 4 to every byte of the file (the result is the same in either direction -like in a rot13 cipher); the program I use is provided in `nybbleswap.c`, -which is designed to be used in a shell pipeline.\ -to cipher a file:\ +of 4 to every byte of the file (the result is the same in either +direction like in a rot13 cipher); the program I use is provided in +`nybbleswap.c`, which is designed to be used in a shell pipeline.\ +to cipher a file: `cat plaintext.txt | nybbleswap > ciptertext.ro4`\ -to uncipher a file:\ +to uncipher a file: `cat ciphertext.ro4 | nybbleswap > plaintext.txt`\ -to view a file:\ +to view a file: `cat ciphertext.ro4 | nybbleswap`\ -to edit a file:\ +to edit a file: `cat ciphertext.ro4 | nybbleswap | vim -` -The code will be liscensed under the terms of the GPL, version 2.0 or, at -your option, any later version; unless the usage kernel calls makes it -impossible on systems using the linux kernel (it *really* shouldn't). some -general pourpose code libraries which are modularly independant of the game -engine may be offered under more permissive liscenses, or under a public -domain release, when not used as part of the whole; these parts will have -their liscense noted seperately. at present, liscensing information may be -absent due to the early stage and bumpy progress of the program's -development; this will be remedied no later than when the program is in a -state such that it can be compiled, however the non-working prealpha code -can be provided with an appropriate liscense upon request. +--- + +*at various points in development, I have entertained using the following +libraries, but have since decided to go with a different design: +- Guile +- Perl +- Raylib +- GLX +- Angelscript +- s7 scheme +- Chaiscript +earlier branches of the source tree may include broken code that uses +these libraries.* --- \**note: as I've been learning, one of the things I've been teaching myself has also been the git system; as a result, instead of branching the repo -at two specific "flag day" points of development, I -forked- it instead. +at two specific "flag day" points of development, I *forked* it instead. Mistakes were made. If you want to see these relics (you really don't), I will leave them as-is.* diff --git a/conventions.md b/conventions.md deleted file mode 100644 index f465f74..0000000 --- a/conventions.md +++ /dev/null @@ -1,17 +0,0 @@ -the perferred method of C API function error checking is by `errno`, in -combination with an `IMPLICIT` return value of 0 for OK and -1 for an -error, or optionally use 1 for a less severe error and -1 for a more severe -error. this matches the convention of most C standard library and nCurses -library functions, but is the reverse of most C++ `std::` functions. C++ -wrapers will use the idiom `-!(`...`)` to do conversion between the two. - -critical errors will `exit(`...`)`, `abort()`, or `raise(`...`)` a signal. - -bogon checking, to mitigate database corruption, will use assertions. -example: `assert(localfoo == *originalfoo)` - -The plan for the navigational database is to write a simple shell program -in Objective-C++, using templates and it's introspection capabilities to -wrap void pointers that will build a stack that holds the path of the $PWD. -syntax will be based on the API; however, the ability to do anything other -than `PEEK` and `POKE`, and even that, is very much deferred. diff --git a/cursesdataformat.txt b/cursesdataformat.txt index b6c3d42..69ac2ee 100644 --- a/cursesdataformat.txt +++ b/cursesdataformat.txt @@ -1,11 +1,10 @@ -serialization format: +NCurses scene serialization format +================================== -size of field... value field contains -==================================== -header: -sizeof(ptrdiff_t)... number of blocks in file +**header:** +uint16_t...number of blocks in file -block: -sizeof(ptrdiff_t)... number of chars in the block -sizeof(int)... attribute mask -char[]... data of string +**blocks:** +uint16_t...number of chars in the block +uint16_t...attribute mask +char[]...string diff --git a/cyberpunk/OpeningScene.txt b/cyberpunk/OpeningScene.txt new file mode 100644 index 0000000..6cdcdcc --- /dev/null +++ b/cyberpunk/OpeningScene.txt @@ -0,0 +1,15 @@ +The second half of the 21st century brought the world the Singularity, and with it many new technologies, amoung them cybernetic augmentation and general pourpose artificial intelligence; and, for a time, it was not bad. + +but soon, discontentedness began to emerge. not the ever-present discontentedness of the oppressed, but instead a primal greed amoungst those who, upon having eliminated that which sated their quest for more, now sought a new outlet for their evils. + +they find it by taking that which does not belong to them, in all manner of ways. tangible property is stolen. ideas are litigated. people are enslaved. + +many would say what happened next was unavoidable... + +this is not the second half of the 21st century. +this is the early 23rd century. +the world lies in ruin. + +you awaken with no memories of who you are, in a neutral zone between a warring corprate federation and fascist empire. a message has been written on your arm: + +- gjragl guerr ryrira abegu cevzebfr cnff (13) \ No newline at end of file diff --git a/cyberpunk/Opening__Background.txt b/cyberpunk/Opening__Background.txt new file mode 100644 index 0000000..f369b03 --- /dev/null +++ b/cyberpunk/Opening__Background.txt @@ -0,0 +1,11 @@ +player should awaken in an alley, with no money, +no weapons aside from a shiny copper pipe + +upon trying to leave the allyway, they suprise a mugger. +the player kills the mugger with a single attack. +they drop a throwing knife, and 2 wanted posters (WANTED1.txt and +WANTED2.txt). + +before reading these, it should be noted that the prices in the game are +typically given in kilo-currency or kilo-credits, and are always divisible +by 10 or 25. diff --git a/cyberpunk/WANTED1.txt b/cyberpunk/WANTED1.txt new file mode 100644 index 0000000..93fc2ae --- /dev/null +++ b/cyberpunk/WANTED1.txt @@ -0,0 +1,16 @@ +W A N T E D + +[picture] + +%s + +7,500,000,000 +goverment currency + +ENEMY OF THE STATE + +blah blah blah blah blah blah +bounty hunters are warned not + to listen to the criminal's + vile sedition and lies blah +blah blah blah blah blah blah diff --git a/cyberpunk/WANTED2.txt b/cyberpunk/WANTED2.txt new file mode 100644 index 0000000..18df9ba --- /dev/null +++ b/cyberpunk/WANTED2.txt @@ -0,0 +1,17 @@ +W A N T E D + +[picture] + +%s + +10,000,000,000 +MegaCorp® credits + +IP Theft, tresspassing, +terms-of-life violation + +blah blah blah blah blah blah +bounty hunters are warned not + to listen to the criminal's + vile slander and lies blah +blah blah blah blah blah blah diff --git a/cyberpunk/open b/cyberpunk/open deleted file mode 100644 index 95b0cdd..0000000 --- a/cyberpunk/open +++ /dev/null @@ -1,9 +0,0 @@ -player should awaken in an alley, with no money, -no weapons aside from a shiny copper pipe, -and no guidence other than a note saying -"they are after you-- trust no-one". - -upon trying to leave the allyway, they suprise a mugger. -the player kills the mugger with a single attack, who drops -a throwing knife and a picture of the player with the player's -name and "5,000,000,000 credits" written on it \ No newline at end of file diff --git a/databasesystem.txt b/databasesystem.txt deleted file mode 100644 index e69de29..0000000 diff --git a/dependancies.txt b/dependancies.txt index c005323..f713ffc 100644 --- a/dependancies.txt +++ b/dependancies.txt @@ -1,15 +1,50 @@ -C -C++ -M4 -Irrlicht -OpenGL-mesa -NCurses -NCursesw -Curses Forms -Curses Menu -X11 -Cairo on X -libuuid -libmd -jsdev -doxygen +Dependancies +- C standard libraries +- C++ standard libraries +- system libraries +- Irrlicht +- OpenGL-mesa +- NCurses +- NCursesw +- Curses Forms +- Curses Menu +- Cairo on X +- ?libmd? +- jsdev +- s7 extension language +- ?X Athena Widgets? + +To build +- C/C++ compiler toolchain + - gcc reccommended +- ?M4? +- make +- shell redirection +- shell pipes + +To run +- X11 session +- X Virtual Terminal (x2) + - XTerm, Unicode, 256-color recommended + - the program must be invoked with the dev file path of the terminal it + is **not** invoked on as one of its arguments. +- invocation arguments are parsed into a scheme alist + - ((argv[odd] . argv[even]) ...) + +To play +- Keyboard with Numeric keypad +- Mouse +- Gamepad with at least + - 2x analogue stick + - 2x throttle or trigger + - hat or d-pad + - 11 buttons + +To debug +- external debugger program + - gdb reccommended +- X Virtual Terminal (+1) + +other +- doxygen +- makeinfo diff --git a/fantasy/README.md b/fantasy/README.md new file mode 100644 index 0000000..6d00809 --- /dev/null +++ b/fantasy/README.md @@ -0,0 +1,19 @@ +A Swords & Sorcery setting, featuring an expanding party of +playable characters. + +This setting has everything you could want from a fantasy genera, all +thrown into a blender. you've got greedy human kingdoms with inept rulers +waging war on eachother, elves that will insist they are better than you, +dwarfs that will beg to differ, court intrigue, steampunk gadgets, meddling +cosmic beings with hidden agendas, dragons to slay, mysterious backstories +to unravel, and MORE! + +discover a plot to create a famine for political gain! + +travel across the elemental planes in search of great and terrible power! + +save the world from total domination by an evil sourcer who will unleash +the infernal legions of the nether relms upon the world to enforce his +vision of totalitarian dominion! + +steal stuff and break things! diff --git a/filetypes.txt b/filetypes.txt index 4f31620..814e5b5 100644 --- a/filetypes.txt +++ b/filetypes.txt @@ -1,25 +1,21 @@ .c C of some description .cc C++ -.m Objective C -.mm Objective C++ .inc modularized code .inl inline functions + .h C or C++ header -.h_ C only header -.struct C struct definitions .def C preprocessor macro file .hh C++ only header -.cclass C++ class header .tmpl C++ template header -.hm Objective C header -.hmm Objective C++ header +.smart_h + header that uses preprocessor variables starting with `#IMPORT___` + to determin what must be included .*.m4 must be preprocessed with the M4 macro processor -.*.nbsp must be preprocessed with the command `tr -d '\xff'` .txt text .curses bytecode to be executed by curses. diff --git a/src/README.md b/src/README.md new file mode 100644 index 0000000..cf0c714 --- /dev/null +++ b/src/README.md @@ -0,0 +1,127 @@ +NOTES +===== + +kanban filing system +-------------------- +- files in the `//src/stable` directory are finished; they can be used with relative safety as-is +- files in the `//src/unstable` directory are finished but may be subject to change due to depending on unfinished work +- files in the `//src/broken` directory have become broken due to changes to their dependancies. +- files in the `//src/reference` directory are kept because they may be needed later; they will not be used in the finished program +- files in the `//src/deprecated` directory have been superceded by other files +- files in the `//src/ongoing` directory are being updated as more stuff is finished +- files in the `//src/incomplete/mothballed` subdirectory have been abandoned in favor of other ideas; they may be revisited later +- files in the `//src/incomplete/sandbox` subdirectory are currently being worked on +- files in the `//src/incomplete/launchpad` subdirectory are almost finished + +--- + +above is depracated and will be changed now that a working main exists. + +--- + +editorial marks +--------------- +none of these will remain once the code is ready to compile +- `※include` is an `#include` line that refers to a file that has been or may be moved +- `«`...`»` contains pseudocode +- `⟦`...`⟧` block of pseudocode +- `⸘`...`‽` dubious +- `...` block of code that needs to be written. usually, this is expressed in a comment. + +--- + +formatting marks +================ + +markup +------ +- `// ---` or `//
` imagine a horizontal rule here +- *‹random comment mentioning dragons in ALL CAPS and ye fake olde english›* + the following code is complex, kludgey, or harmful to the eyes. +- `/***TITLE***/` imagine header text here + +odd conventions +--------------- +(besides those listed in the project's main README) +- `/*C++ type*/ void *` + - in C: an opaque pointer to a C++ object + - in C++: a dangerous typo (please send a bug report) +- `!!xyzzy` extract the logical value of xyzzy + - invalid if the ajacent function does this automatically (`&&`/`||`), if + used as the only function in a predicate, when applied to a `bool`, if + `util.def` was `#include`d (replace all instances of `!!` with the + `istrue()` macro), or if `!` was ment instead. +- `{bool again = 1;while(again) { again = 0;` a brute-force loop +- + +special comment blocks +---------------------- + +
/**************
+ * Project    *
+ * Titlecard  *
+ **************/
+ +
/** doxygen
+ * this style of comment,
+ * with 2 astrikses at the
+ * top, is used by doxygen
+ * to generate documentation
+ */
+ +`//! small doxygen notation` + +--- + +misc. +===== + +most files are created, formatted, and edited on a 80 column XTerm in vim; +complex files frequently using fully-quantified object names may use a 132 +column XTerm instead. + +--- + +the problem of 32/64 bit architecture portability is circumvented by using +`` instead of `int`, `short`, and `long`. + +--- + +all finished headers use the `#ifndef`/`#define` method of preventing +double-inclusion. + +a "smart header" is an experiment I'm trying based on how perl modules +work. they use a preceeding `#define` to know what to import; it's like +several small headers in one file. these `#define`s are like arguments for +the header, and mostly use the prefix `IMPORT___`*‹stuff›*. + +--- + +almost all C++ files will require the type safety to be turned off to be +compiled; this may or may not eventually be fixed, but is considered a low +priority annoyance. it is for primarily this reason that some files are +marked as C-only. + +--- + +several features require that structs specifying sub-byte fields are +"tightly packed" and truncated to the smallest possible **-multiple- of 8 +bits** (not mearly power of 2) that can contain the data. a kludgy +work-around may be provided in future as an alternative to structs, but it +requires that an `unsigned char` is 8 bits wide, and that address +arithmatic on `unsigned char *` is bytewise and not word-wise. + +--- + +ENIGNE DESIGN +============= + +the engine is NOT turn based; instead, it is based on a chaiscript event +pump. every entity has it's own thread that creates events, and the +chaiscript engine has full access to the C/C++ api underneath, thus having +the ability to create or destroy threads. most api calls are also +threadsafe, and can be invoked directly. + +all threads also have direct read-only access to a filesystem-like database +of internal atomic-access data, which can be modified through C api calls +with or without the chaiscript interface. diff --git a/src/binary16vector.c b/src/binary16vector.c deleted file mode 100644 index d4ba68a..0000000 --- a/src/binary16vector.c +++ /dev/null @@ -1,4 +0,0 @@ -#include "binary16vector.h" -vector2functions(half,f16) -vector3functions(half,f16) -vector4functions(half,f16) diff --git a/src/binary16vector.h b/src/binary16vector.h deleted file mode 100644 index 941d247..0000000 --- a/src/binary16vector.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef __GG4872_BIN16_VECTOR_H__ -#define __GG4872_BIN16_VECTOR_H__ - -#include "cppkeyword.h" -#include "halfshim.hh" - -makevector2(half,f16) -makevector3(half,f16) -makevector4(half,f16) - -vector2linkage(half,f16) -vector3linkage(half,f16) -vector4linkage(half,f16) -#endif diff --git a/src/cursescat.h b/src/cursescat.h deleted file mode 100644 index cc04a30..0000000 --- a/src/cursescat.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef __IWF_CURSESCAT_H__ -#define __IWF_CURSESCAT_H__ - -#ifndef __cplusplus -#include -#endif -#include -#include -#include -#include "cppkeyword.def" -#ifdef __cplusplus -extern "C" { -#endif - -extern IMPLICIT curscat (const char * filename); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/incomplete/mothballedORreference/archive.c b/src/deprecated/archive.c similarity index 100% rename from src/incomplete/mothballedORreference/archive.c rename to src/deprecated/archive.c diff --git a/src/incomplete/mothballedORreference/bettersavefileio.c b/src/deprecated/bettersavefileio.c similarity index 100% rename from src/incomplete/mothballedORreference/bettersavefileio.c rename to src/deprecated/bettersavefileio.c diff --git a/concepts.txt b/src/deprecated/concepts.txt similarity index 100% rename from concepts.txt rename to src/deprecated/concepts.txt diff --git a/src/deprecated/doublelinkedlist.cc b/src/deprecated/doublelinkedlist.cc new file mode 100644 index 0000000..fbe4683 --- /dev/null +++ b/src/deprecated/doublelinkedlist.cc @@ -0,0 +1,85 @@ +template + +class doublelinkedlist::node; + +struct doublelinkedlist { + doublelinkedlist::node * head; + doublelinkedlist::node * tail; + + doublelinkedlist::node * push_back (T input) { + doublelinkedlist::node * nova = new doublelinkedlist::node; + if (this->tail == NULL) { + this->head = nova; + this->tail = nova; + } else { + this->tail.next = nova; + nova->prev = this->tail; + this->tail = nova; + } + nova->data = T; + return nova; + }; + + doublelinkedlist::node * push_front (T input) { + doublelinkedlist::node * nova = new doublelinkedlist::node; + if (this->head == NULL) { + this->head = nova; + this->tail = nova; + } else { + this->head.prev = nova; + nova->next = this->head; + this->head = nova; + } + nova->data = T; + return nova; + }; + + doublelinkedlist::node * iter_front (unsigned n) { + doublelinkedlist::node * output = this->head; + for (int i = 0;i <= n;i++) { + if (this->next == NULL) { + throw std::out_of_range; + } + this = this->next; + } + return output; + + doublelinkedlist::node * iter_back (unsigned n) { + doublelinkedlist::node * output = this->tail; + for (int i = 0;i <= n;i++) { + if (this->prev == NULL) { + throw std::out_of_range; + } + this = this->prev; + } + return output; + }; + }; + +class doublelinkedlist::node { + private: + const doublelinkedlist * ends; + public: + doublelinkedlist::node * prev; + doublelinkedlist::node * next; + T data; + + void drop () { + if ((this.next == NULL) && (this.prev == NULL)) { + this.ends->head = NULL; + this.ends->tail = NULL; + } else if (this.prev == NULL) { + this.ends->head = this.next; + this.next.prev = NULL; + } else if (this.next == NULL) { + this.ends->tail = this.prev; + this.prev.next = NULL; + } else { + this.prev.next = this.next; + this.next.prev = this.prev; + } + delete this; + }; + }; + +extern "C" { diff --git a/src/incomplete/mothballedORreference/evheap.c b/src/deprecated/evheap.c similarity index 100% rename from src/incomplete/mothballedORreference/evheap.c rename to src/deprecated/evheap.c diff --git a/src/incomplete/mothballedORreference/exists.tmpl b/src/deprecated/exists.tmpl similarity index 100% rename from src/incomplete/mothballedORreference/exists.tmpl rename to src/deprecated/exists.tmpl diff --git a/src/incomplete/mothballedORreference/extmodules.cc b/src/deprecated/extmodules.cc similarity index 100% rename from src/incomplete/mothballedORreference/extmodules.cc rename to src/deprecated/extmodules.cc diff --git a/src/incomplete/mothballedORreference/flywheel.cpseudo b/src/deprecated/flywheel.cpseudo similarity index 100% rename from src/incomplete/mothballedORreference/flywheel.cpseudo rename to src/deprecated/flywheel.cpseudo diff --git a/src/incomplete/mothballedORreference/funstack.c b/src/deprecated/funstack.c similarity index 100% rename from src/incomplete/mothballedORreference/funstack.c rename to src/deprecated/funstack.c diff --git a/src/incomplete/mothballedORreference/globalvar.cc b/src/deprecated/globalvar.cc similarity index 100% rename from src/incomplete/mothballedORreference/globalvar.cc rename to src/deprecated/globalvar.cc diff --git a/src/incomplete/mothballedORreference/heapio.c b/src/deprecated/heapio.c similarity index 100% rename from src/incomplete/mothballedORreference/heapio.c rename to src/deprecated/heapio.c diff --git a/src/incomplete/mothballedORreference/heapio2.c b/src/deprecated/heapio2.c similarity index 100% rename from src/incomplete/mothballedORreference/heapio2.c rename to src/deprecated/heapio2.c diff --git a/src/incomplete/mothballedORreference/lightning.psudoexpr b/src/deprecated/lightning.psudoexpr similarity index 100% rename from src/incomplete/mothballedORreference/lightning.psudoexpr rename to src/deprecated/lightning.psudoexpr diff --git a/src/incomplete/mothballedORreference/lighttree.c b/src/deprecated/lighttree.c similarity index 100% rename from src/incomplete/mothballedORreference/lighttree.c rename to src/deprecated/lighttree.c diff --git a/src/incomplete/mothballedORreference/plugin.cc b/src/deprecated/plugin.cc similarity index 100% rename from src/incomplete/mothballedORreference/plugin.cc rename to src/deprecated/plugin.cc diff --git a/src/incomplete/mothballedORreference/plugin.cclass b/src/deprecated/plugin.cclass similarity index 100% rename from src/incomplete/mothballedORreference/plugin.cclass rename to src/deprecated/plugin.cclass diff --git a/src/incomplete/mothballedORreference/plugin.h b/src/deprecated/plugin.h similarity index 100% rename from src/incomplete/mothballedORreference/plugin.h rename to src/deprecated/plugin.h diff --git a/src/incomplete/mothballedORreference/pure_c_shared_mutex.c b/src/deprecated/pure_c_shared_mutex.c similarity index 100% rename from src/incomplete/mothballedORreference/pure_c_shared_mutex.c rename to src/deprecated/pure_c_shared_mutex.c diff --git a/src/incomplete/mothballedORreference/renderstack.c b/src/deprecated/renderstack.c similarity index 100% rename from src/incomplete/mothballedORreference/renderstack.c rename to src/deprecated/renderstack.c diff --git a/src/incomplete/mothballedORreference/savefileio.cc b/src/deprecated/savefileio.cc similarity index 100% rename from src/incomplete/mothballedORreference/savefileio.cc rename to src/deprecated/savefileio.cc diff --git a/src/incomplete/mothballedORreference/scalar.c b/src/deprecated/scalar.c similarity index 100% rename from src/incomplete/mothballedORreference/scalar.c rename to src/deprecated/scalar.c diff --git a/src/incomplete/mothballedORreference/strangemutex.cc b/src/deprecated/strangemutex.cc similarity index 100% rename from src/incomplete/mothballedORreference/strangemutex.cc rename to src/deprecated/strangemutex.cc diff --git a/src/incomplete/mothballedORreference/texturetree.c b/src/deprecated/texturetree.c similarity index 100% rename from src/incomplete/mothballedORreference/texturetree.c rename to src/deprecated/texturetree.c diff --git a/src/incomplete/mothballedORreference/uuidtypes.def b/src/deprecated/uuidtypes.def similarity index 100% rename from src/incomplete/mothballedORreference/uuidtypes.def rename to src/deprecated/uuidtypes.def diff --git a/src/vectors.c b/src/deprecated/vectors.d/vectors.c similarity index 100% rename from src/vectors.c rename to src/deprecated/vectors.d/vectors.c diff --git a/src/vectors.c.m4 b/src/deprecated/vectors.d/vectors.c.m4 similarity index 100% rename from src/vectors.c.m4 rename to src/deprecated/vectors.d/vectors.c.m4 diff --git a/src/vectors.h b/src/deprecated/vectors.d/vectors.h similarity index 100% rename from src/vectors.h rename to src/deprecated/vectors.d/vectors.h diff --git a/src/vectors.h.m4 b/src/deprecated/vectors.d/vectors.h.m4 similarity index 100% rename from src/vectors.h.m4 rename to src/deprecated/vectors.d/vectors.h.m4 diff --git a/src/incomplete/mothballedORreference/wrapper___std___shared_mutex.cc b/src/deprecated/wrapper___std___shared_mutex.cc similarity index 100% rename from src/incomplete/mothballedORreference/wrapper___std___shared_mutex.cc rename to src/deprecated/wrapper___std___shared_mutex.cc diff --git a/src/incomplete/launchpad/camcoord.cc b/src/incomplete/launchpad/camcoord.cc new file mode 100644 index 0000000..eb08330 --- /dev/null +++ b/src/incomplete/launchpad/camcoord.cc @@ -0,0 +1,37 @@ +class iwf::datatypes::camcoord { + double az; + double el; + double r; + + irr::core::vector3df normal () { + irr::core::vector3df tmp; + tmp.X = sin(this->el) * cos(this->az); + tmp.Y = sin(this->el) * sin(this->az); + tmp.Z = cos(this->el); + return tmp; + } + + irr::core::vector3df euclid () { + irr::core::vector3df tmp; + tmp.X = this->r * sin(this->el) * cos(this->az); + tmp.Y = this->r * sin(this->el) * sin(this->az); + tmp.Z = this->r * cos(this->el); + return tmp; + }} + +/**Camera Coordinate oject + * the pourpose of this object is to provide callbacks for moving the + * camera. + * + * - azimuth has a value of {-π < x ≤ π} by modulo + * + * - elevation has a value of {-π + π/1000 ≤ x ≤ 0 - π/1000} by clamping + * + * - the normal() method is intended to be used with + * irr::scene::ICameraSceneNode::setTarget(), to provide a first-person + * camera. + * + * - the euclid() method is intended to be added to used with + * irr::scene::ISceneNode::setPosition(), to provide an orbiting third- + * person camera. + */ diff --git a/src/incomplete/launchpad/directory/directory.hh b/src/incomplete/launchpad/directory/directory.hh new file mode 100644 index 0000000..b4a1d04 --- /dev/null +++ b/src/incomplete/launchpad/directory/directory.hh @@ -0,0 +1,22 @@ +struct iwf::directory { + std::map subdirectories; + std::map> variables; + /* the vector points to an untyped data block, and is used to + * allocate data on a bytewise basis. + */ + } + +/* database files use a format consisting of a byte control code, + * optionally followed by a sequence of pairs of size_t length specifiers + * and strings of bytes containing data. currently, a database storing a + * tree of iwf::directory would be as follows: + * + * SOH : enter a subdirectory (has one block of data for subdirectory name) + * STX : begin an entry (has 2 blocks of data for variable name and + * variable data) + * ETX : exit the current directory + * DLE : begin an entry (has 2 blocks of data, but first block is an + * unsigned int instead of a size_t/byte array pair) + * + * directory trees are saved depth-first. + */ diff --git a/src/incomplete/launchpad/directory/tmp_directory.tmpl b/src/incomplete/launchpad/directory/tmp_directory.tmpl new file mode 100644 index 0000000..19706d5 --- /dev/null +++ b/src/incomplete/launchpad/directory/tmp_directory.tmpl @@ -0,0 +1,43 @@ +template +class iwf::tmp_directory { + private: + T counter; + public: + std::map>> data; + + T alloc () { + while (this->data.contains(counter)) { + counter++; + } + this->data[counter]; + T output = counter; + while (this->data.contains(counter)) { + counter++; + }} + + std::vector operator[](T n) { + return this->data[n].second; + } + + std::vector at (T n) { + return this->data.at(n).second; + } + + int increment (T n) { + this->data.at(n).first++; + if (this->data.at(n).first < 0) { + throw std::overflow_error; + return -1; + } + return this->data.at(n).first; + } + + int decrement (T n) { + this->data.at(n).first--; + if (this->data.at(n).first < 0) { + this->data.erase(n); + return -1; + } + return this->data.at(n).first; + } + }; diff --git a/src/incomplete/launchpad/minifixed.cc b/src/incomplete/launchpad/minifixed.cc new file mode 100644 index 0000000..1773b30 --- /dev/null +++ b/src/incomplete/launchpad/minifixed.cc @@ -0,0 +1,50 @@ +#include "cppkeyword.def" + +extern "C" { + STRUCTTYPE_BEGIN(minifixed_t) + bool whole : 1; + unsigned part : 7; + STRUCTTYPE_END; + + double minifixed$$get (minifixed_t * object) { + return (object->whole + ((double) object->part / 0x80)); + }; + + float minifixed$$getf (minifixed_t * object) { + return (object->whole + ((float) object->part / 0x80)); + }; + + minifixed_t minifixed$$set (minifixed_t * object,double input) { + object->whole = istrue(((int)input)); + object->part = (int)(fmod(input,1) * 0x80); + return get(object); + }; + + minifixed_t minifixed$$setf (minifixed_t * object,float input) { + object->whole = istrue(((int)input)); + object->part = (int)(fmod(input,1) * 0x80); + return getf(object); + }; + } +namespace minifixed { + double get (minifixed_t * object) { + return (object->whole + ((double) object->part / 0x80)); + }; + + float getf (minifixed_t * object) { + return (object->whole + ((float) object->part / 0x80)); + }; + + minifixed_t set (minifixed_t * object,double input) { + object->whole = istrue(((int)input)); + object->part = (int)(fmod(input,1) * 0x80); + return get(object); + }; + + minifixed_t setf (minifixed_t * object,float input) { + object->whole = istrue(((int)input)); + object->part = (int)(fmod(input,1) * 0x80); + return getf(object); + }; + }; +} diff --git a/src/incomplete/mothballedORreference/argvlogic.h b/src/incomplete/mothballed/argvlogic.h similarity index 100% rename from src/incomplete/mothballedORreference/argvlogic.h rename to src/incomplete/mothballed/argvlogic.h diff --git a/src/incomplete/sandbox/as_moduleglue.cc b/src/incomplete/mothballed/as_moduleglue.cc similarity index 100% rename from src/incomplete/sandbox/as_moduleglue.cc rename to src/incomplete/mothballed/as_moduleglue.cc diff --git a/src/incomplete/sandbox/build.sh b/src/incomplete/mothballed/build.sh similarity index 100% rename from src/incomplete/sandbox/build.sh rename to src/incomplete/mothballed/build.sh diff --git a/src/incomplete/mothballed/chunk.H b/src/incomplete/mothballed/chunk.H new file mode 100644 index 0000000..68a8dff --- /dev/null +++ b/src/incomplete/mothballed/chunk.H @@ -0,0 +1,76 @@ +#ifndef __IWF__DATATYPES__CHUNK__ +#define __IWF__DATATYPES__CHUNK__ + +※include "chunk__magic.H" +※include "voxels.H + +#ifdef __cplusplus +#include +#include +#include +※include «appropos enttyp» +※include «appropos mapitem_t» +※include «appropos npctyp» +※include «appropos lightbeam» +※include «appropos lightsource» +※include «appropos event» +#else +#include +#endif + +STRUCTTYPE_BEGIN(iwf$$datatypes$$chunk_t) + int64_t here; + int64_t neighbors[6]; //address space TBD + double latlon[3]; + uint16_t area; + unsigned char tilesets[2]; //2 dispatch keys to sets of 256 tiles + iwf$$datatypes$$voxel_t tiles[32768]; //320 KiB flatfile, 10 bytes per voxel + /* this parameter for each tile determins what shape each + * voxel is. points are named: + * + * 1 2 3 + * 4 5 6 + * 7 8 9 + * 10 11 12 + * 13 14 15 + * 16 17 18 + * 19 20 21 + * 22 23 24 + * 25 26 27 + * + * if the resulting polyhedron is not 3-diminsional and is + * flush with the face of the bounding cube, then the + * missing dimension(s) are extrapolated by adding more + * verticies at midpoints extending away from that face. + * + * special cases: + * corner-to-corner diagonals add 3 midpoints in each + * corner to create a gyroelongated triangular bipyramid. + * + * a single point is abstracted to a small cube. + * + * a diagonal line accross a face is not changed. + * + * a + */ +#ifdef __cplusplus + boost::circular_buffer_space_optimized * encon_vec; + std::map * ent_map; + std::map * mapitem_map; + std::map * npc_map; + std::map * lightbeam_map; + std::map * lightsource_map; + std::map * trigger_map; +#else + void * encon_vec; + void * ent_map; + void * mapitem_map; + void * npc_map; + void * lightbeam_map; + void * lightsource_map; + void * trigger_map; +#endif + iwf$$datatypes$$chunk$$magic_t magic; +STRUCTTYPE_END(iwf$$datatypes$$chunk_t); +#endif +#endif diff --git a/src/incomplete/mothballed/chunk.fragment b/src/incomplete/mothballed/chunk.fragment new file mode 100644 index 0000000..174d31f --- /dev/null +++ b/src/incomplete/mothballed/chunk.fragment @@ -0,0 +1 @@ +typedef uint16_t iwf$$chunk[32][32][32]; diff --git a/src/incomplete/sandbox/commandline.hh b/src/incomplete/mothballed/commandline.hh similarity index 76% rename from src/incomplete/sandbox/commandline.hh rename to src/incomplete/mothballed/commandline.hh index 10a61cc..ee9865c 100644 --- a/src/incomplete/sandbox/commandline.hh +++ b/src/incomplete/mothballed/commandline.hh @@ -1,8 +1,12 @@ typedef int (*subroutine)(std::vector); -typedef int (*assignfptr)(void*); +typedef int (*assignfptr)(void*,void*); typedef int (*alterfptr)(void*); typedef int (*accessfptr)(void); +extern int skip_int (); +extern int skip_int_2ptr (void* foo,void* bar); +extern int skip_int_1ptr (void* foo); + struct IWFType { accessfptr accessor; assignfptr assignment; @@ -13,6 +17,8 @@ struct IWFType { alterfptr decrement; }; +extern std::map iwf::cli::types; + struct IWFVariable { IWFType * type; void * data; @@ -37,6 +43,8 @@ struct IWFInterface { std::map properties; }; +extern std::map iwf::cli::interfaces; + struct IWFNamespace { std::map subdir; std::map databases; @@ -44,3 +52,6 @@ struct IWFNamespace { std::map objects; std::map variables; }; + +extern IWFNamespace iwf::cli::toplevelnamespace; +extern diff --git a/src/incomplete/sandbox/commandlinesyntax.txt b/src/incomplete/mothballed/commandlinesyntax.txt similarity index 100% rename from src/incomplete/sandbox/commandlinesyntax.txt rename to src/incomplete/mothballed/commandlinesyntax.txt diff --git a/src/incomplete/mothballed/doublelinkedlist.d/refcounted.cc b/src/incomplete/mothballed/doublelinkedlist.d/refcounted.cc new file mode 100644 index 0000000..bed7bc1 --- /dev/null +++ b/src/incomplete/mothballed/doublelinkedlist.d/refcounted.cc @@ -0,0 +1,86 @@ +#include "variablewidthdatablock.hh" + +class iwf::refcounted { + private: + static iwf::refcounted * head; + static iwf::refcounted * tail; + iwf::refcounted * prev; + iwf::refcounted * next; + + public: + int refs; + variablewidthdatablock data; + + int inc () { + this->refs += 1; + if (this->refs <= 0) { + throw std::overflow_error; + } + return this->refs; + }; + + int del () { + this->refs -= 1; + if (this->refs < 0) { + this.drop(); + return -1; + } + return this->refs; + }; + + void drop () { + if ((this.next == NULL) && (this.prev == NULL)) { + this.head = NULL; + this.tail = NULL; + } else if (this.prev == NULL) { + this.head = this.next; + this.head.prev = NULL; + } else if (this.next == NULL) { + this.tail = this.prev; + this.tail.next = NULL; + } else { + this.prev.next = this.next; + this.next.prev = this.prev; + } + delete this; + }; + + iwf::refcounted * alloc () { + iwf::refcounted * nova = new iwf::refcounted; + if (this.tail == NULL) { + this.head = nova; + this.tail = nova; + } else { + this.tail.next = nova; + nova.prev = this.tail; + this.tail = nova; + } + return nova; + }; + }; + +extern "C" { + int iwf$$refcounted$$inc (void * opaque) { + iwf::refcounted * object = opaque; + try { + return object->inc(); + } catch (std::overflow_error) { + errno = EOVERFLOW; + return -1; + } + }; + + int iwf$$refcounted$$del (void * opaque) { + iwf::refcounted * object = opaque; + return object->del(); + } + + void iwf$$refcounted$$drop (void * opaque) { + iwf::refcounted object = opaque; + object->drop(); + }; + + void * iwf$$refcounted$$alloc () { + return iwf::refcounted::alloc(); + } + } diff --git a/src/incomplete/mothballed/doublelinkedlist.d/refcounted.h b/src/incomplete/mothballed/doublelinkedlist.d/refcounted.h new file mode 100644 index 0000000..d1b1f9e --- /dev/null +++ b/src/incomplete/mothballed/doublelinkedlist.d/refcounted.h @@ -0,0 +1,4 @@ + int iwf$$refcounted$$inc (void * opaque); + int iwf$$refcounted$$del (void * opaque); + void iwf$$refcounted$$drop (void * opaque); + void * iwf$$refcounted$$alloc (); diff --git a/src/incomplete/mothballed/doublelinkedlist.d/refcounted.hh b/src/incomplete/mothballed/doublelinkedlist.d/refcounted.hh new file mode 100644 index 0000000..69b50a3 --- /dev/null +++ b/src/incomplete/mothballed/doublelinkedlist.d/refcounted.hh @@ -0,0 +1,24 @@ +#include "variablewidthdatablock.hh" + +class iwf::refcounted { + private: + static iwf::refcounted * head; + static iwf::refcounted * tail; + iwf::refcounted * prev; + iwf::refcounted * next; + + public: + int refs; + variablewidthdatablock data; + int inc (); + int del (); + void drop (); + iwf::refcounted * alloc (); + }; + +extern "C" { + int iwf$$refcounted$$inc (void * opaque); + int iwf$$refcounted$$del (void * opaque); + void iwf$$refcounted$$drop (void * opaque); + void * iwf$$refcounted$$alloc (); + }; diff --git a/src/incomplete/launchpad/flywheel.cclass b/src/incomplete/mothballed/flywheel/flywheel.cclass similarity index 100% rename from src/incomplete/launchpad/flywheel.cclass rename to src/incomplete/mothballed/flywheel/flywheel.cclass diff --git a/src/incomplete/mothballed/flywheel/flywheel.hh b/src/incomplete/mothballed/flywheel/flywheel.hh new file mode 100644 index 0000000..884b3e3 --- /dev/null +++ b/src/incomplete/mothballed/flywheel/flywheel.hh @@ -0,0 +1,24 @@ +struct iwf::flywheel::subframe { + std::stack down; + std::string call; + int times; + } + +struct iwf::flywheel::frame { + iwf::flywheel::frame * next; + std::stack down; + std::string call; + int times; + } + +class iwf::flywheel { + iwf::flywheel::frame * data; + iwf::flywheel::frame * prev; + asIScriptEngine * engine; + asIScriptContext * ctx; + IMPLICIT call (); + IMPLICIT insert (std::string call,int times); + IMPLICIT queue (std::string call,int times); + IMPLICIT dequeue (); + IMPLICIT spin (); + } diff --git a/src/incomplete/mothballed/iwf__chunk.cc b/src/incomplete/mothballed/iwf__chunk.cc new file mode 100644 index 0000000..3fc0a28 --- /dev/null +++ b/src/incomplete/mothballed/iwf__chunk.cc @@ -0,0 +1,6 @@ +class iwf::voxels::chunk { + uint16_t data[32][32][32]; + public: + + } + diff --git a/src/incomplete/sandbox/iwf__graphics3d.cc b/src/incomplete/mothballed/iwf__graphics3d.cc similarity index 100% rename from src/incomplete/sandbox/iwf__graphics3d.cc rename to src/incomplete/mothballed/iwf__graphics3d.cc diff --git a/src/incomplete/mothballed/iwf__voxels__minichunk/C_iwf__voxels__minichunk.cc b/src/incomplete/mothballed/iwf__voxels__minichunk/C_iwf__voxels__minichunk.cc new file mode 100644 index 0000000..e640d93 --- /dev/null +++ b/src/incomplete/mothballed/iwf__voxels__minichunk/C_iwf__voxels__minichunk.cc @@ -0,0 +1,50 @@ +#include "iwf__voxels__minichunk.hh" + +extern "C" { + int iwf$$voxels$$minichunk$$at (void * opaque,unsigned char x,unsigned char y,unsigned char z) { + int output; + iwf::voxels::minichunk * object = opaque; + try { + return object.at(x,y,z); + } catch (std::out_of_range) { + errno = ERANGE; + return 0; + } catch (std::out_of_bounds) { + errno = EINVAL; + return -1; + }}; + + int iwf$$voxels$$minichunk$$safe_at (void * opaque,unsigned char x,unsigned char y,unsigned char z) { + iwf::voxels::minichunk * object = opaque; + try { + return object.safe_at(x,y,z); + } catch (std::out_of_range) { + errno = ERANGE; + return 0; + } catch (std::out_of_bounds) { + errno = EINVAL; + return -1; + }}; + + IMPLICIT iwf$$voxels$$minichunk$$insert (void * opaque,unsigned char x,unsigned char y,unsigned char z,uint16_t blockid) { + iwf::voxels::minichunk * object = opaque; + try { + object.insert(x,y,z); + } catch (std::out_of_bounds) { + errno = EINVAL; + return -1; + } + return 0; + }; + + IMPLICIT iwf$$voxels$$minichunk$$erase (void * opaque,unsigned char x,unsigned char y,unsigned char z) { + iwf::voxels::minichunk * object = opaque; + try { + object.erase(x,y,z); + } catch (std::out_of_bounds) { + errno = EINVAL; + return -1; + } + return 0; + }; + }; diff --git a/src/incomplete/mothballed/iwf__voxels__minichunk/C_iwf__voxels__minichunk.h b/src/incomplete/mothballed/iwf__voxels__minichunk/C_iwf__voxels__minichunk.h new file mode 100644 index 0000000..392a5e3 --- /dev/null +++ b/src/incomplete/mothballed/iwf__voxels__minichunk/C_iwf__voxels__minichunk.h @@ -0,0 +1,12 @@ +#ifdef __cplusplus +extern "C" { +#endif + +extern int iwf$$voxels$$minichunk$$at (void * opaque,unsigned char x,unsigned char y,unsigned char z); +extern int iwf$$voxels$$minichunk$$safe_at (void * opaque,unsigned char x,unsigned char y,unsigned char z); +extern IMPLICIT iwf$$voxels$$minichunk$$insert (void * opaque,unsigned char x,unsigned char y,unsigned char z,uint16_t blockid); +extern IMPLICIT iwf$$voxels$$minichunk$$erase (void * opaque,unsigned char x,unsigned char y,unsigned char z); + +#ifdef __cplusplus +} +#endif diff --git a/src/incomplete/mothballed/iwf__voxels__minichunk/iwf__voxels__minichunk.cclass b/src/incomplete/mothballed/iwf__voxels__minichunk/iwf__voxels__minichunk.cclass new file mode 100644 index 0000000..af4eb9e --- /dev/null +++ b/src/incomplete/mothballed/iwf__voxels__minichunk/iwf__voxels__minichunk.cclass @@ -0,0 +1,37 @@ +class iwf::voxels::minichunk { + private: + + std::map data; + + public: + + int at (unsigned char x,unsigned char y,unsigned char z) { + if ((x < 0x20) && (y < 0x20) && (x < 0x20)) { + return this->data.at((z << 10)|(y << 5)|x); + } else { + throw std::out_of_bounds; + return -1; + }}; + + int safe_at (unsigned char x,unsigned char y,unsigned char z) { + if ((x < 0x20) && (y < 0x20) && (x < 0x20)) { + return this->data[(z << 10)|(y << 5)|x]; + } else { + throw std::out_of_bounds; + return -1; + }}; + + void insert (unsigned char x,unsigned char y,unsigned char z,uint16_t blockid) { + if ((x < 0x20) && (y < 0x20) && (x < 0x20)) { + this->data[(z << 10)|(y << 5)|(x)] = blockid; + } else { + throw std::out_of_bounds; + }}; + + void erase (unsigned char x,unsigned char y,unsigned char z) { + if ((x < 0x20) && (y < 0x20) && (x < 0x20)) { + this->data.erase((z << 10)|(y << 5)|(x)); + } else { + throw std::out_of_bounds; + }}; + }; diff --git a/src/incomplete/mothballed/iwf__voxels__minichunk/iwf__voxels__minichunk.hh b/src/incomplete/mothballed/iwf__voxels__minichunk/iwf__voxels__minichunk.hh new file mode 100644 index 0000000..64da4e1 --- /dev/null +++ b/src/incomplete/mothballed/iwf__voxels__minichunk/iwf__voxels__minichunk.hh @@ -0,0 +1,9 @@ +class iwf::voxels::minichunk { + private: + std::map data; + public: + int at (unsigned char x,unsigned char y,unsigned char z); + int safe_at (unsigned char x,unsigned char y,unsigned char z); + void insert (unsigned char x,unsigned char y,unsigned char z,uint16_t blockid); + void erase (unsigned char x,unsigned char y,unsigned char z); + }; diff --git a/src/incomplete/sandbox/iwf_joystick.c b/src/incomplete/mothballed/iwf_joystick.c similarity index 100% rename from src/incomplete/sandbox/iwf_joystick.c rename to src/incomplete/mothballed/iwf_joystick.c diff --git a/src/incomplete/sandbox/keyswitch.inc b/src/incomplete/mothballed/keyswitch.inc similarity index 100% rename from src/incomplete/sandbox/keyswitch.inc rename to src/incomplete/mothballed/keyswitch.inc diff --git a/src/incomplete/mothballed/listcontainer.cc b/src/incomplete/mothballed/listcontainer.cc new file mode 100644 index 0000000..fbe4683 --- /dev/null +++ b/src/incomplete/mothballed/listcontainer.cc @@ -0,0 +1,85 @@ +template + +class doublelinkedlist::node; + +struct doublelinkedlist { + doublelinkedlist::node * head; + doublelinkedlist::node * tail; + + doublelinkedlist::node * push_back (T input) { + doublelinkedlist::node * nova = new doublelinkedlist::node; + if (this->tail == NULL) { + this->head = nova; + this->tail = nova; + } else { + this->tail.next = nova; + nova->prev = this->tail; + this->tail = nova; + } + nova->data = T; + return nova; + }; + + doublelinkedlist::node * push_front (T input) { + doublelinkedlist::node * nova = new doublelinkedlist::node; + if (this->head == NULL) { + this->head = nova; + this->tail = nova; + } else { + this->head.prev = nova; + nova->next = this->head; + this->head = nova; + } + nova->data = T; + return nova; + }; + + doublelinkedlist::node * iter_front (unsigned n) { + doublelinkedlist::node * output = this->head; + for (int i = 0;i <= n;i++) { + if (this->next == NULL) { + throw std::out_of_range; + } + this = this->next; + } + return output; + + doublelinkedlist::node * iter_back (unsigned n) { + doublelinkedlist::node * output = this->tail; + for (int i = 0;i <= n;i++) { + if (this->prev == NULL) { + throw std::out_of_range; + } + this = this->prev; + } + return output; + }; + }; + +class doublelinkedlist::node { + private: + const doublelinkedlist * ends; + public: + doublelinkedlist::node * prev; + doublelinkedlist::node * next; + T data; + + void drop () { + if ((this.next == NULL) && (this.prev == NULL)) { + this.ends->head = NULL; + this.ends->tail = NULL; + } else if (this.prev == NULL) { + this.ends->head = this.next; + this.next.prev = NULL; + } else if (this.next == NULL) { + this.ends->tail = this.prev; + this.prev.next = NULL; + } else { + this.prev.next = this.next; + this.next.prev = this.prev; + } + delete this; + }; + }; + +extern "C" { diff --git a/src/incomplete/mothballedORreference/magnetoception.txt b/src/incomplete/mothballed/magnetoception.txt similarity index 100% rename from src/incomplete/mothballedORreference/magnetoception.txt rename to src/incomplete/mothballed/magnetoception.txt diff --git a/src/incomplete/sandbox/main.cc b/src/incomplete/mothballed/main.cc similarity index 100% rename from src/incomplete/sandbox/main.cc rename to src/incomplete/mothballed/main.cc diff --git a/src/incomplete/sandbox/memdump.pseudoc b/src/incomplete/mothballed/memdump.pseudoc similarity index 100% rename from src/incomplete/sandbox/memdump.pseudoc rename to src/incomplete/mothballed/memdump.pseudoc diff --git a/src/incomplete/mothballed/octanttriple.c b/src/incomplete/mothballed/octanttriple.c new file mode 100644 index 0000000..57cdc95 --- /dev/null +++ b/src/incomplete/mothballed/octanttriple.c @@ -0,0 +1,69 @@ +int16_t iwf$$raw16$$octanttriple$$pack (char x,char y,char z) { + if ( + ((-13 <= x) && (x <= 13)) + && + ((-13 <= y) && (y <= 13)) + && + ((-13 <= z) && (z <= 13))) { + return (((0x1F & z) << 10)|((0x1F & y) << 5)|(0x1F & x)); + } else { + errno = EINVAL; + return -1; + }} + +char iwf$$raw16$$octanttriple$$get$x (int16_t input) { + char output = (input & 0x1F); + if (output & 0x10) { + return output | 0xF0; + } else { + return output; + }}; + +char iwf$$raw16$$octanttriple$$get$y (int16_t input) { + char output = ((input >> 5) & 0x1F); + if (output & 0x10) { + return output | 0xF0; + } else { + return output; + }}; + +char iwf$$raw16$$octanttriple$$get$z (int16_t input) { + char output = ((input >> 10) & 0x1F); + if (output & 0x10) { + return output | 0xF0; + } else { + return output; + }}; + +iwf$$raw16$$octanttriple$$set$x (int16_t * object,char input) { + if ((-13 <= input) && (input <= 13)) { + *object &= ~(0x1F); + *object |= (input & 0x1F); + return 0; + } else { + errno = EINVAL; + return -1; + } + }; + +iwf$$raw16$$octanttriple$$set$y (int16_t * object,unsigned char input) { + if ((-13 <= input) && (input <= 13)) { + *object &= ~(0x1F << 5); + *object |= (input & 0x1F) << 5; + return 0; + } else { + errno = EINVAL; + return -1; + } + }; + +iwf$$raw16$$octanttriple$$set$z (int16_t * output,unsigned char input) { + if ((-13 <= input) && (input <= 13)) { + *object &= ~(0x1F << 10); + *object |= (input & 0x1F) << 10; + return 0; + } else { + errno = EINVAL; + return -1; + } + }; diff --git a/src/incomplete/mothballed/pools.cc b/src/incomplete/mothballed/pools.cc new file mode 100644 index 0000000..4b2645b --- /dev/null +++ b/src/incomplete/mothballed/pools.cc @@ -0,0 +1,29 @@ +extern std::map *> POOLS; +// for saving and loading. the entire memory pool is saved as a file. + +struct persistantptr { + void * offset; + short pool; + }; + +void * truncateptr (void * input,size_t size) { + void * mask = base1(void*,((unsigned)floor(log2(size) + 1))); + return input & mask; + } + +int makepool (size_t size) { + boost::simple_segregated_storage pool; + void * block; + posix_memalign(&block,size,size); + pool.add_block(block,size,sizeof(char)); + short key = NEXTPOOL; + POOLS[key] = &pool; + NEXTPOOL++; + while ((POOLS.contains(NEXTPOOL)) && (NEXTPOOL != key)) { + NEXTPOOL++; + } + if (NEXTPOOL == key) { + POOLSMAXED = 1; + } + return key; + } diff --git a/src/incomplete/mothballed/refcount.d/refcounted.cc b/src/incomplete/mothballed/refcount.d/refcounted.cc new file mode 100644 index 0000000..bed7bc1 --- /dev/null +++ b/src/incomplete/mothballed/refcount.d/refcounted.cc @@ -0,0 +1,86 @@ +#include "variablewidthdatablock.hh" + +class iwf::refcounted { + private: + static iwf::refcounted * head; + static iwf::refcounted * tail; + iwf::refcounted * prev; + iwf::refcounted * next; + + public: + int refs; + variablewidthdatablock data; + + int inc () { + this->refs += 1; + if (this->refs <= 0) { + throw std::overflow_error; + } + return this->refs; + }; + + int del () { + this->refs -= 1; + if (this->refs < 0) { + this.drop(); + return -1; + } + return this->refs; + }; + + void drop () { + if ((this.next == NULL) && (this.prev == NULL)) { + this.head = NULL; + this.tail = NULL; + } else if (this.prev == NULL) { + this.head = this.next; + this.head.prev = NULL; + } else if (this.next == NULL) { + this.tail = this.prev; + this.tail.next = NULL; + } else { + this.prev.next = this.next; + this.next.prev = this.prev; + } + delete this; + }; + + iwf::refcounted * alloc () { + iwf::refcounted * nova = new iwf::refcounted; + if (this.tail == NULL) { + this.head = nova; + this.tail = nova; + } else { + this.tail.next = nova; + nova.prev = this.tail; + this.tail = nova; + } + return nova; + }; + }; + +extern "C" { + int iwf$$refcounted$$inc (void * opaque) { + iwf::refcounted * object = opaque; + try { + return object->inc(); + } catch (std::overflow_error) { + errno = EOVERFLOW; + return -1; + } + }; + + int iwf$$refcounted$$del (void * opaque) { + iwf::refcounted * object = opaque; + return object->del(); + } + + void iwf$$refcounted$$drop (void * opaque) { + iwf::refcounted object = opaque; + object->drop(); + }; + + void * iwf$$refcounted$$alloc () { + return iwf::refcounted::alloc(); + } + } diff --git a/src/incomplete/mothballed/refcount.d/refcounted.h b/src/incomplete/mothballed/refcount.d/refcounted.h new file mode 100644 index 0000000..d1b1f9e --- /dev/null +++ b/src/incomplete/mothballed/refcount.d/refcounted.h @@ -0,0 +1,4 @@ + int iwf$$refcounted$$inc (void * opaque); + int iwf$$refcounted$$del (void * opaque); + void iwf$$refcounted$$drop (void * opaque); + void * iwf$$refcounted$$alloc (); diff --git a/src/incomplete/mothballed/refcount.d/refcounted.hh b/src/incomplete/mothballed/refcount.d/refcounted.hh new file mode 100644 index 0000000..69b50a3 --- /dev/null +++ b/src/incomplete/mothballed/refcount.d/refcounted.hh @@ -0,0 +1,24 @@ +#include "variablewidthdatablock.hh" + +class iwf::refcounted { + private: + static iwf::refcounted * head; + static iwf::refcounted * tail; + iwf::refcounted * prev; + iwf::refcounted * next; + + public: + int refs; + variablewidthdatablock data; + int inc (); + int del (); + void drop (); + iwf::refcounted * alloc (); + }; + +extern "C" { + int iwf$$refcounted$$inc (void * opaque); + int iwf$$refcounted$$del (void * opaque); + void iwf$$refcounted$$drop (void * opaque); + void * iwf$$refcounted$$alloc (); + }; diff --git a/src/incomplete/launchpad/repl.cc b/src/incomplete/mothballed/repl.cc similarity index 100% rename from src/incomplete/launchpad/repl.cc rename to src/incomplete/mothballed/repl.cc diff --git a/src/incomplete/launchpad/scriptboot.cc b/src/incomplete/mothballed/scriptboot.cc similarity index 100% rename from src/incomplete/launchpad/scriptboot.cc rename to src/incomplete/mothballed/scriptboot.cc diff --git a/src/incomplete/sandbox/seedcrypt.cc b/src/incomplete/mothballed/seedcrypt.cc similarity index 100% rename from src/incomplete/sandbox/seedcrypt.cc rename to src/incomplete/mothballed/seedcrypt.cc diff --git a/src/incomplete/sandbox/seedcrypt.h b/src/incomplete/mothballed/seedcrypt.h similarity index 100% rename from src/incomplete/sandbox/seedcrypt.h rename to src/incomplete/mothballed/seedcrypt.h diff --git a/src/incomplete/sandbox/seedcrypt.hlib b/src/incomplete/mothballed/seedcrypt.hlib similarity index 100% rename from src/incomplete/sandbox/seedcrypt.hlib rename to src/incomplete/mothballed/seedcrypt.hlib diff --git a/src/incomplete/sandbox/split.cc b/src/incomplete/mothballed/split.cc similarity index 100% rename from src/incomplete/sandbox/split.cc rename to src/incomplete/mothballed/split.cc diff --git a/src/incomplete/sandbox/startup.cc b/src/incomplete/mothballed/startup.cc similarity index 100% rename from src/incomplete/sandbox/startup.cc rename to src/incomplete/mothballed/startup.cc diff --git a/src/incomplete/sandbox/types.h b/src/incomplete/mothballed/types.h similarity index 100% rename from src/incomplete/sandbox/types.h rename to src/incomplete/mothballed/types.h diff --git a/src/incomplete/mothballed/variablewidthdatablock/variablewidthdatablock.cc b/src/incomplete/mothballed/variablewidthdatablock/variablewidthdatablock.cc new file mode 100644 index 0000000..fe6a85d --- /dev/null +++ b/src/incomplete/mothballed/variablewidthdatablock/variablewidthdatablock.cc @@ -0,0 +1,25 @@ +#include "variablewidthdatablock.hh" + +int variablewidthdatablock_write (FILENO file,variablewidthdatablock * datablock) { + ssize_t x, y; + size_t tmp = datablock->size(); + if (write(file,&tmp,sizeof(size_t)) < 0) { + return -1; + } + return write(file,datablock->data(),tmp); + } + +int variablewidthdatablock_read (FILENO file,variablewidthdatablock * emptyblock) { + errno = 0; + if (!emptyblock.empty()) { + errno = EINVAL; + return -1; + } + size_t tmp; + if (!(read(file,&tmp,sizeof(size_t)))) { + if (errno) { + return -1; + }} + emptyblock.reserve(tmp); + return read(file,emptyblock.data(),tmp); + } diff --git a/src/incomplete/mothballed/variablewidthdatablock/variablewidthdatablock.hh b/src/incomplete/mothballed/variablewidthdatablock/variablewidthdatablock.hh new file mode 100644 index 0000000..8f190aa --- /dev/null +++ b/src/incomplete/mothballed/variablewidthdatablock/variablewidthdatablock.hh @@ -0,0 +1,4 @@ +typedef std::vector variablewidthdatablock; + +int variablewidthdatablock_write (FILENO file,variablewidthdatablock * datablock); +int variablewidthdatablock_read (FILENO file,variablewidthdatablock * emptyblock); diff --git a/src/incomplete/mothballed/voxel.H b/src/incomplete/mothballed/voxel.H new file mode 100644 index 0000000..3f72bd7 --- /dev/null +++ b/src/incomplete/mothballed/voxel.H @@ -0,0 +1,12 @@ +#ifndef USING___IWF__DATATYPES__VOXEL +#define USING___IWF__DATATYPES__VOXEL +STRUCTTYPE_BEGIN(iwf$$datatypes$$voxel_t) + unsigned octant : 8; + unsigned yz : 12; + unsigned xz : 12; + unsigned xy : 12; + unsigned vert : 27; + bool bank : 1; + unsigned tile : 8; +STRUCTTYPE_END(iwf$$datatypes$$voxel_t) +#endif diff --git a/src/incomplete/mothballedORreference/minifixed.c b/src/incomplete/mothballedORreference/minifixed.c deleted file mode 100644 index 4bdb943..0000000 --- a/src/incomplete/mothballedORreference/minifixed.c +++ /dev/null @@ -1,17 +0,0 @@ -//uses vectors.c.m4 - -double from_minifixed (struct minifixed input) { - return input.whole + ((double) input.part / 0x80); - -struct minifixed to_minifixed (double input) { - struct minifixed output; - int tmp = input; - output.whole = istrue(tmp); - output.part = (input - tmp) * 0x80; - return output; - } - -vector2functions(struct minifixed,minifixed); -vector3functions(struct minifixed,minifixed); -vector4functions(struct minifixed,minifixed); - diff --git a/src/incomplete/mothballedORreference/minifixed.h b/src/incomplete/mothballedORreference/minifixed.h deleted file mode 100644 index 4fb5ba9..0000000 --- a/src/incomplete/mothballedORreference/minifixed.h +++ /dev/null @@ -1,13 +0,0 @@ -//uses vectors.h.m4 - -NEWSTRUCT minifixed { - unsigned whole : 1; - unsigned part : 7; - } - -makevector2(STRUCT minifixed,minifixed); -makevector3(STRUCT minifixed,minifixed); -makevector4(STRUCT minifixed,minifixed); -vector2linkage(STRUCT minifixed,minifixed); -vector3linkage(STRUCT minifixed,minifixed); -vector4linkage(STRUCT minifixed,minifixed); diff --git a/src/incomplete/mothballedORreference/templates/README.md b/src/incomplete/mothballedORreference/templates/README.md deleted file mode 100644 index 3ebf9e4..0000000 --- a/src/incomplete/mothballedORreference/templates/README.md +++ /dev/null @@ -1,3 +0,0 @@ -These are templates for object classes, but not in the C++ sense; - -they must be filled in manually for each case. diff --git a/src/bitpack.c b/src/incomplete/sandbox/bitstruct/bitpack.c similarity index 63% rename from src/bitpack.c rename to src/incomplete/sandbox/bitstruct/bitpack.c index 9414948..0b16e71 100644 --- a/src/bitpack.c +++ b/src/incomplete/sandbox/bitstruct/bitpack.c @@ -5,27 +5,32 @@ #include "bitpack.h" #include "base1.def" -void pack_8 (uint8_t * here,uint8_t value,unsigned width,unsigned offset) { - offset &= 7; - uint8_t mask = invbase1(width) << offset; - value <<= offset; - *here = (here & mask) | (value & ~mask); +void pack_8 (unsigned char * object,unsigned char value,unsigned width,int offset) { + width &= 7; + div_t pos = div(offset,CHAR_BITS); + unsigned char mask = base1(unsigned char,width) << pos.rem; + value <<= pos.rem; + object[pos.quot] = (object[pos.quot] & ~mask) | (value & mask); } -uint8_t unpack_u8 (uint8_t * here,unsigned width,unsigned offset) { - uint8_t output = *here >> offset; +unsigned char unpack_u8 (unsigned char * object,unsigned char width,int offset) { + width &= 7; + div_t pos = div(offset,CHAR_BITS); + unsigned char output = object[pos.quot] >> pos.rem; return output & base1(width); } -int8_t unpack_s8 (uint8_t * here,unsigned width,unsigned offset) { +char unpack_s8 (unsigned char * here,unsigned width,unsigned offset) { uint8_t output = *here >> offset; return output & base1(width); } -void pack_8 (uint16_t * here,uint16_t value,unsigned width,unsigned offset) { - offset &= 0x0F; - uint16_t mask = invbase1(width) << offset; - value <<= offset; +void pack_16 (unsigned char * object,uint16_t value,unsigned width,int offset) { + width &= 0x0F; + div_t pos = div(offset,16); + uint16_t mask = base1(uint16_t,width) << pos.rem; + value <<= pos.rem; + uint16_t * here = object[pos.quot]; *here = (here & mask) | (value & ~mask); } @@ -68,7 +73,7 @@ uint64_t unpack_u64 (uint64_t * here,unsigned width,unsigned offset) { return output & base1(width); } -int64_t unpack_s64 (uint8_t * here,unsigned width,unsigned offset) { +int64_t unpack_s64 (uint64_t * here,unsigned width,unsigned offset) { uint64_t output = *here >> offset; return output & base1(width); } diff --git a/src/bitpack.h b/src/incomplete/sandbox/bitstruct/bitpack.h similarity index 100% rename from src/bitpack.h rename to src/incomplete/sandbox/bitstruct/bitpack.h diff --git a/src/incomplete/sandbox/bitvector/bitvector16.c b/src/incomplete/sandbox/bitvector/bitvector16.c new file mode 100644 index 0000000..6fda20a --- /dev/null +++ b/src/incomplete/sandbox/bitvector/bitvector16.c @@ -0,0 +1,35 @@ +bitvector16$$set (uint16_t * object,size_t size,unsigned pos) { + if ((pos < 16) && (object != NULL) { + *object |= 1 << pos; + return 0; + } else { + errno = EINVAL; + return -1; + }} + +bitvector16$$clear (uint16_t * object,size_t size,unsigned pos) { + if ((pos < 16) && (object != NULL) { + *object |= ~(1 << pos); + return 0; + } else { + errno = EINVAL; + return -1; + }} + +bitvector16$$toggle (uint16_t * object,size_t size,unsigned pos) { + if ((pos < 16) && (object != NULL) { + *object ^= 1 << pos; + return 0; + } else { + errno = EINVAL; + return -1; + }} + +bool bitvector16$$get (uint16_t * object,size_t size,unsigned pos) { + if ((pos < 16) && (object != NULL) { + errno = 0; + return *object & (1 << pos); + } else { + errno = EINVAL; + return 0; + }} diff --git a/src/incomplete/sandbox/bitvector/bitvector32.c b/src/incomplete/sandbox/bitvector/bitvector32.c new file mode 100644 index 0000000..cd3ca3e --- /dev/null +++ b/src/incomplete/sandbox/bitvector/bitvector32.c @@ -0,0 +1,35 @@ +bitvector32$$set (uint32_t * object,size_t size,unsigned char pos) { + if ((pos < 32) && (object != NULL) { + *object |= 1 << pos; + return 0; + } else { + errno = EINVAL; + return -1; + }} + +bitvector32$$clear (uint32_t * object,size_t size,unsigned char pos) { + if ((pos < 32) && (object != NULL) { + *object |= ~(1 << pos); + return 0; + } else { + errno = EINVAL; + return -1; + }} + +bitvector32$$toggle (uint32_t * object,size_t size,unsigned char pos) { + if ((pos < 32) && (object != NULL) { + *object ^= 1 << pos; + return 0; + } else { + errno = EINVAL; + return -1; + }} + +bool bitvector32$$get (uint32_t * object,size_t size,unsigned char pos) { + if ((pos < 32) && (object != NULL) { + errno = 0; + return *object & (1 << pos); + } else { + errno = EINVAL; + return 0; + }} diff --git a/src/incomplete/sandbox/bitvector/bitvector64.c b/src/incomplete/sandbox/bitvector/bitvector64.c new file mode 100644 index 0000000..b9b15f0 --- /dev/null +++ b/src/incomplete/sandbox/bitvector/bitvector64.c @@ -0,0 +1,35 @@ +bitvector64$$set (uint64_t * object,size_t size,unsigned pos) { + if ((pos < 64) && (object != NULL) { + *object |= 1 << pos; + return 0; + } else { + errno = EINVAL; + return -1; + }} + +bitvector64$$clear (uint64_t * object,size_t size,unsigned pos) { + if ((pos < 64) && (object != NULL) { + *object |= ~(1 << pos); + return 0; + } else { + errno = EINVAL; + return -1; + }} + +bitvector64$$toggle (uint64_t * object,size_t size,unsigned pos) { + if ((pos < 64) && (object != NULL) { + *object ^= 1 << pos; + return 0; + } else { + errno = EINVAL; + return -1; + }} + +bool bitvector64$$get (uint64_t * object,size_t size,unsigned pos) { + if ((pos < 64) && (object != NULL) { + errno = 0; + return *object & (1 << pos); + } else { + errno = EINVAL; + return 0; + }} diff --git a/src/incomplete/sandbox/bitvector/bitvector8.c b/src/incomplete/sandbox/bitvector/bitvector8.c new file mode 100644 index 0000000..b3cce32 --- /dev/null +++ b/src/incomplete/sandbox/bitvector/bitvector8.c @@ -0,0 +1,35 @@ +bitvector8$$set (unsigned char * object,size_t size,unsigned pos) { + if ((pos < 8) && (object != NULL) { + *object |= 1 << pos; + return 0; + } else { + errno = EINVAL; + return -1; + }} + +bitvector8$$clear (unsigned char * object,size_t size,unsigned pos) { + if ((pos < 8) && (object != NULL) { + *object |= ~(1 << pos); + return 0; + } else { + errno = EINVAL; + return -1; + }} + +bitvector8$$toggle (unsigned char * object,size_t size,unsigned pos) { + if ((pos < 8) && (object != NULL) { + *object ^= 1 << pos; + return 0; + } else { + errno = EINVAL; + return -1; + }} + +bool bitvector8$$get (unsigned char * object,size_t size,unsigned pos) { + if ((pos < 8) && (object != NULL) { + errno = 0; + return *object & (1 << pos); + } else { + errno = EINVAL; + return 0; + }} diff --git a/src/incomplete/sandbox/commandline/lexer.lex b/src/incomplete/sandbox/commandline/lexer.lex new file mode 100644 index 0000000..0268aaa --- /dev/null +++ b/src/incomplete/sandbox/commandline/lexer.lex @@ -0,0 +1,54 @@ +%{ +extern yylval; +extern std::vector garbage; +%} + +IDENT [A-Za-z_][A-Za-z0-9$_:]* +INTERGER [+-]?[0-9]+ +FLOAT [+-]?([0-9]*\.[0-9]+([eE][-+]?[0-9]+)?) +HEX ("0x"|"$")[0-9A-Fa-f]+ +BIN "%"[01]+ +OCTAL "@"[0-7]+ + +ESCAPE_OCTAL "\\"[0-7]([0-7][0-7]?)? +ESCAPE_HEX "\\x"[0-9A-Fa-f][0-9A-Fa-f] + +SEND ("\0"|[\003-\004]|[\030-\032]|<>) +%x STRING +%% +{FLOAT} {yylval.f = atof(yytext); return TOK_FLOAT;} +{INTERGER} {yylval.l = strtol(yytext,NULL,10); return TOK_NUM;} +{HEX} {yylval.l = strtol(yytext,NULL,16); return TOK_NUM;} +{IDENT} { + yylval.str = calloc(strlen(yytext) + 1,sizeof(char)); + strcpy(yylval.str,yytext); + iwf$$commandline$$garbage$insert(yylval.str); + return TOK_IDENT; + } +{OCTAL} {yylval.l = strtol(yytext,NULL,8); return TOK_NUM;} +"\"" {yystringbuffer$clear();BEGIN(STRING);return TOK_STR_FILLER;} +"!" {return '!';} +"+" {return '+';} +"-" {return '-';} +"*" {return '*';} +"/" {return '/';} +"%" {return '%';} +"<" {return '<';} +"=" {return '=';} +">" {return '>';} +";" {return ';';} +"&" {return '&';} +"|" {return '|';} +"~" {return '~';} +{SEND} return 0; +[.] +"\\\\" {yystringbuffer$push_back('\\');return TOK_STR_FILLER;} +{ESCAPE_OCTAL} {yystringbuffer$push_back(strtol(yytext+1,NULL,8);return TOK_STR_FILLER;} +{ESCAPE_HEX} {yystringbuffer$push_back(strtol(yytext+2,NULL,16);return TOK_STR_FILLER;} +"\"" { + yylval.str = calloc(iwf$$commandline$$stringbuffer$length() + 1,sizeof(char)); + strcpy(yylval.str,iwf$$commandline$$stringbuffer$c_str()); + iwf$$commandline$$garbage$insert(yylval.str); + return TOK_STR; + } +[.] {yystringbuffer$push_back(yytext[0]);return TOK_STR_FILLER;} diff --git a/src/incomplete/sandbox/commandline/parser.y b/src/incomplete/sandbox/commandline/parser.y new file mode 100644 index 0000000..40c44e2 --- /dev/null +++ b/src/incomplete/sandbox/commandline/parser.y @@ -0,0 +1,15 @@ +%token TOK_STR_FILLER + +%union{ +long l; +double f; +char * str; +%} + +%token TOK_IDENT TOK_STRING +%token TOK_NUM +%token TOK_FLOAT + +str_filler : TOK_STR_FILLER + | str_filler str_filler + ; diff --git a/src/incomplete/sandbox/commandline/wrapper.cc b/src/incomplete/sandbox/commandline/wrapper.cc new file mode 100644 index 0000000..09a88df --- /dev/null +++ b/src/incomplete/sandbox/commandline/wrapper.cc @@ -0,0 +1,37 @@ +std::string iwf::commandline::stringbuffer; + +extern "C" { + void iwf$$commandline$$stringbuffer$clear() { + iwf::commandline::stringbuffer.clear(); + } + char * iwf$$commandline$$stringbuffer$c_str () { + return iwf::commandline::stringbuffer.c_str(); + } + size_t iwf$$commandline$$stringbuffer$length () { + return iwf::commandline::stringbuffer.length(); + } + void iwf$$commandline$$stringbuffer$push_back (char input) { + iwf::commandline::stringbuffer.push_back(input); + } + } + +static std::set iwf$$commandline$$garbage; + +extern "C" { + void iwf$$commandline$$garbage$insert (char * input) { + iwf::commandline::garbage.insert(input); + } + } + +iwf::commandline::collectgarbage () { + iwf::commandline::stringbuffer.clear() + for (std::set::iterator i iwf::commandline::garbage.begin();i != iwf::commandline::garbage.end();) { + free(*i); + i = iwf::commandline::garbage.erase(i); + } + +iwf::commandline::repl () { + for (;;) { + + yyparse(); + diff --git a/src/incomplete/sandbox/coord.c b/src/incomplete/sandbox/coord.c new file mode 100644 index 0000000..5852878 --- /dev/null +++ b/src/incomplete/sandbox/coord.c @@ -0,0 +1,49 @@ +int16_t iwf$$raw16$$coord3$$pack (unsigned char x,unsigned char y,unsigned char z) { + if ((z < 0x20)&&(y < 0x20)&&(x < 0x20)) { + return ((z << 10)|(y << 5)|(x)); + } else { + errno = EINVAL; + return -1; + }} + +unsigned char iwf$$raw16$$coord3$$get$x (int16_t input) { + return (input & 0x1F); + } + +unsigned char iwf$$raw16$$coord3$$get$y (int16_t input) { + return ((input >> 5) & 0x1F); + } + +unsigned char iwf$$raw16$$coord3$$get$z (int16_t input) { + return ((input >> 10) & 0x1F); + } + +iwf$$raw16$$coord3$$set$x (int16_t * object,unsigned char input) { + if (input < 0x20) { + *object &= ~(0x1F); + *object |= input; + return 0; + } else { + errno = EINVAL; + return -1; + }} + +iwf$$raw16$$coord3$$set$y (int16_t * object,unsigned char input) { + if (input < 0x20) { + *object &= ~(0x1F << 5); + *object |= input << 5; + return 0; + } else { + errno = EINVAL; + return -1; + }} + +iwf$$raw16$$coord3$$set$z (int16_t * object,unsigned char input) { + if (input < 0x20) { + *object &= ~(0x1F << 10); + *object |= input << 10; + return 0; + } else { + errno = EINVAL; + return -1; + }} diff --git a/src/incomplete/sandbox/datatypes/basenttyp/abilities.H b/src/incomplete/sandbox/datatypes/basenttyp/abilities.H new file mode 100644 index 0000000..df60023 --- /dev/null +++ b/src/incomplete/sandbox/datatypes/basenttyp/abilities.H @@ -0,0 +1,48 @@ +// 32 bits +STRUCTTYPE_BEGIN(iwf$$datatypes$$body_combat_metadata) + bool gills : 1; + bool lungs : 1; + bool can_fly : 1; + bool can_swim : 1; + bool can_phase : 1; + bool caffinated : 1; + bool fireproof : 1; + bool iceproof : 1; + bool elecproof : 1; + bool stoneproof : 1; + bool poisonproof : 1; + bool paralzproof : 1; + bool lightproof : 1; + bool darkproof : 1; + bool voidproof : 1; + unsigned hands : 3; // none, hands, claws, poison claws, paws, hook, blade, tentacle + unsigned legs : 3; // none, humanoid legs, talons, poison talons, paws, blade, hooves, spider + unsigned wings : 2; // none, feathery, leathery, fairy + unsigned tail : 3; // none, bird, dragon, cat, spiked, fish, snake, pointy + bool fangs : 1; + unsigned venom : 2; + bool stare : 1; + bool shootweb : 1; + bool sting : 1; +STRUCTTYPE_END(iwf$$datatypes$$body_combat_metadata); + +// 7 bytes +STRUCTTYPE_BEGIN(iwf$$datatypes$$skilltyp) + unsigned sword : 4; //! flat bonus to sword damage + unsigned knife : 4; //! flat bonus to knife damage + unsigned stave : 4; //! flat bonus to stave damage + unsigned spear : 4; //! flat bonus to spear damage + unsigned whip : 4; //! flat bonus to whip range (extra range is added to damage) + unsigned club : 4; //! flat bonus to club damage + unsigned bow : 4; //! double bonus to bow range (extra range is added to damage) + unsigned throw : 4; //! double bonus to throwing range (extra range is added to damage iff not an improvised weapon) + unsigned hands : 4; //! triple bonus to unarmed attack + unsigned shield : 4; //! x in (damage - def) + |damage - def| chance of blocking attack + unsigned locks : 4; //! 1 in 2^(locklevel - x) chance of picking lock + unsigned caster : 5; //! casting cost is reduced by (x-1)/4. spatk and spdef are increased by same. + unsigned swim : 2; //! 0: sink, 1: swim accross surface, 2: dive, but positively bouyent, 3: neutraly bouyent + unsigned fly : 2; //! 0: regular falling, 1: feather falling, 2: glide, 3: free flight + bool walk : 1; + bool sink : 1; //! overrides swim + bool magnetic : 1 //! attracted to magnets +STRUCTTYPE_END(iwf$$datatypes$$skilltyp); diff --git a/src/incomplete/sandbox/datatypes/chunk.H b/src/incomplete/sandbox/datatypes/chunk.H new file mode 100644 index 0000000..8d7bc8f --- /dev/null +++ b/src/incomplete/sandbox/datatypes/chunk.H @@ -0,0 +1,71 @@ +#ifndef __IWF__DATATYPES__CHUNK__ +#define __IWF__DATATYPES__CHUNK__ + +※include "chunk__magic.H" + +#ifdef __cplusplus +#include +#include +#include +※include «appropos enttyp» +※include «appropos mapitem_t» +※include «appropos npctyp» +※include «appropos lightbeam» +※include «appropos lightsource» +※include «appropos event» +#else +#include +#endif + +STRUCTTYPE_BEGIN(iwf$$datatypes$$chunk_t) + int64_t here; /** int16 chunk addresses + * the top byte is the plane, and the following 2 + * bytes are directories as well, corresponding to + * areas. should never be less than 0. + */ + int64_t neighbors[6]; + double latlon[3]; //! mesured in degrees; also elevation, in meters + uint16_t roomname; //dispatch table key + unsigned char areaname; //dispatch table key + + unsigned char tilesets[4]; + /** tilesets + * voxel definitions are stored in tilesets, which are lookup + * tables of 64 tiles. a game can have up to 256 tilesets when + * using an unsigned char table lookup key. the number of tiles + * in each table depends on how wide the tile reference key is and + * how many bits are needed to switch between the loaded tilesets. + */ + + unsigned char tiles[32][32][32]; //32KiB + + char subtiles[32][32][32][2][2][2]; //2MiB + /* octree-arranged subvoxels + * + * z 6 7 + * |n 4 5 + * w-%-e 2 3 + * s 0 1 + */ + +#ifdef __cplusplus + boost::circular_buffer_space_optimized * encon_vec; + std::map * ent_map; + std::map * mapitem_map; + std::map * npc_map; + std::map * lightbeam_map; + std::map * lightsource_map; + std::map * trigger_map; +#else + void * encon_vec; + void * ent_map; + void * mapitem_map; + void * npc_map; + void * lightbeam_map; + void * lightsource_map; + void * trigger_map; +#endif + iwf$$datatypes$$chunk$$magic_t magic; +STRUCTTYPE_END(iwf$$datatypes$$chunk_t); +#endif +#endif diff --git a/src/incomplete/sandbox/datatypes/chunk__directions.def b/src/incomplete/sandbox/datatypes/chunk__directions.def new file mode 100644 index 0000000..4c0122d --- /dev/null +++ b/src/incomplete/sandbox/datatypes/chunk__directions.def @@ -0,0 +1,19 @@ +#ifdef ___IMPORT +#undef ___IMPORT +#define UP 0 +#define DOWN 1 +#define NORTH 2 +#define SOUTH 3 +#define WEST 4 +#define EAST 5 +#endif + +#ifdef ___UNPORT +#undef ___UNPORT +#undef UP +#undef DOWN +#undef NORTH +#undef SOUTH +#undef WEST +#undef EAST +#endif diff --git a/src/incomplete/sandbox/datatypes/chunk__magic.H b/src/incomplete/sandbox/datatypes/chunk__magic.H new file mode 100644 index 0000000..3765030 --- /dev/null +++ b/src/incomplete/sandbox/datatypes/chunk__magic.H @@ -0,0 +1,8 @@ +#ifndef __IWF__DATATYPES__CHUNK__MAGIC__ +#define __IWF__DATATYPES__CHUNK__MAGIC__ +STRUCTTYPE_BEGIN(iwf$$datatypes$$chunk$$magic_t) + double latent; + double latent_max; + float rate; +STRUCTTYPE_END(iwf$$datatypes$$chunk_t); +#endif diff --git a/src/incomplete/sandbox/datatypes/color.H b/src/incomplete/sandbox/datatypes/color.H new file mode 100644 index 0000000..fc4a92a --- /dev/null +++ b/src/incomplete/sandbox/datatypes/color.H @@ -0,0 +1,31 @@ +STRUCTTYPE_BEGIN(htmlcolor) + unsigned r : 8; + unsigned g : 8; + unsigned b : 8; +STRUCTTYPE_END(htmlcolor); + +STRUCTTYPE_BEGIN(htmlcolor_alpha) + unsigned r : 8; + unsigned g : 8; + unsigned b : 8; + unsigned a : 8; +STRUCTTYPE_END(htmlcolor_alpha); + +STRUCTTYPE_BEGIN(hicolor) + unsigned r : 5; + unsigned g : 6; + unsigned b : 5; +STRUCTTYPE_END(hicolor); + +STRUCTTYPE_BEGIN(hicolor_alpha) + unsigned r : 5; + unsigned g : 5; + unsigned b : 5; + unsigned a : 1; +STRUCTTYPE_END(hicolor_alpha); + +STRUCTTYPE_BEGIN(lowcolor) + unsigned r : 3; + unsigned g : 3; + unsigned b : 2; +STRUCTTYPE_END(lowcolor); diff --git a/src/incomplete/sandbox/datatypes/encounter_wheel/encounter_wheel.cc b/src/incomplete/sandbox/datatypes/encounter_wheel/encounter_wheel.cc new file mode 100644 index 0000000..819ea31 --- /dev/null +++ b/src/incomplete/sandbox/datatypes/encounter_wheel/encounter_wheel.cc @@ -0,0 +1,41 @@ +/* UNDER CONSTRUCTION + * + * areas requiring attention are marked ⍝ + */ + +⍝#include "encounter_wheel.hh" + +extern "C" { + + iwf$$datatypes$$encounter_t iwf$$datatype$$encounter_wheel$$next (void * opaque) { + iwf$$datatype$$encounter_wheel * object = opaque; + if (object->next >= object->table.size()) { + object->next = 0; + } + iwf$$datatype$$encounter_t output = object->table[object->next]; + object->next += 1; + return output; + } + + void iwf$$datatypes$$encounter_wheel$$insert (void * opaque,iwf$$datatype$$encounter_t nova) { + iwf$$datatype$$encounter_wheel * object = opaque; + if (object->next >= object->table.size()) { + object->next = 0; + object->table.push_back(nova); + } else { + object->table.insert(object->table.begin() + object->next,nova); + object->next += 1; + }} + + int iwf$$datatypes$$encounter_wheel$$erase (void * opaque,size_t dead) { + iwf$$datatypes$$encounter_wheel * object = opaque; + if (dead >= object->table.size()) { + errno = EFAULT; + return -1; + } else { + object->table.erase(dead); + if (object->next > dead) { + object->next -= 1; + }}} + + } diff --git a/src/incomplete/sandbox/datatypes/encounter_wheel/encounter_wheel.h b/src/incomplete/sandbox/datatypes/encounter_wheel/encounter_wheel.h new file mode 100644 index 0000000..6748079 --- /dev/null +++ b/src/incomplete/sandbox/datatypes/encounter_wheel/encounter_wheel.h @@ -0,0 +1,12 @@ +/* UNDER CONSTRUCTION + * + * incomplete areas will be marked with ⍝ + */ + +NEWSTRUCT iwf$$datatypes$$encounter_t { + ⍝ + }; + +iwf$$datatypes$$encounter_t iwf$$datatype$$encounter_wheel$$next (void * opaque); +void iwf$$datatypes$$encounter_wheel$$insert (void * opaque,iwf$$datatype$$encounter_t nova); +int iwf$$datatypes$$encounter_wheel$$erase (void * opaque,size_t dead) { diff --git a/src/incomplete/sandbox/datatypes/encounter_wheel/encounter_wheel.hh b/src/incomplete/sandbox/datatypes/encounter_wheel/encounter_wheel.hh new file mode 100644 index 0000000..208fd53 --- /dev/null +++ b/src/incomplete/sandbox/datatypes/encounter_wheel/encounter_wheel.hh @@ -0,0 +1,13 @@ +/* UNDER CONSTRUCTION + * + * incomplete areas will be marked with ⍝ + */ + +extern "C" { +⍝#include "encounter_wheel.h" + } + +struct iwf$$datatypes$$encounter_wheel { + std::vector table; + size_t next; + }; diff --git a/src/incomplete/sandbox/datatypes/entity/ent_map.make b/src/incomplete/sandbox/datatypes/entity/ent_map.make new file mode 100644 index 0000000..6b9566b --- /dev/null +++ b/src/incomplete/sandbox/datatypes/entity/ent_map.make @@ -0,0 +1,10 @@ +IWF_SRC_PATH := +IWF_TOOLS_PATH := + + +$(IWF_SRC_PATH)/datatypes/entity/ent_map.cc : $(IWF_SRC_PATH)/datatypes/entity/ent_typ.h $(IWF_TOOLS_PATH)/stdmapwrapper_codegen.out +$(IWF_TOOLS_PATH)/stdmapwrapper_codegen.out u16 enttyp uint16_t "iwf\$\$datatypes\$\$ent_typ" uint16_t "iwf\$\$datatypes\$\$ent_typ" 0 0 0 "#include \"$(IWF_SRC_PATH)/datatypes/entity/entity.h\"" > $(IWF_SRC_PATH)/datatypes/entity/ent_map.cc + +$(IWF_SRC_PATH)/datatypes/entity/ent_map.h : $(IWF_SRC_PATH)/datatypes/entity/ent_typ.h $(IWF_TOOLS_PATH)/stdmapwrapper_headergen.out +$(IWF_TOOLS_PATH)/stdmapwrapper_headergen.out u16 enttyp uint16_t "iwf\$\$datatypes\$\$ent_typ" "#include \"$(IWF_SRC_PATH)/datatypes/entity/entity.h\"" > $(IWF_SRC_PATH)/datatypes/entity/ent_map.h + diff --git a/src/incomplete/sandbox/datatypes/lights/lighttype.h b/src/incomplete/sandbox/datatypes/lights/lighttype.h new file mode 100644 index 0000000..e69abd7 --- /dev/null +++ b/src/incomplete/sandbox/datatypes/lights/lighttype.h @@ -0,0 +1,14 @@ +※include "../../cppkeywords.def" +※include "../color.H" + +STRUCTTYPE_BEGIN(iwf$$datatypes$$lightbeam_t) + uint16_t coord[2]; + htmlcolor color; + unsigned char alpha[2]; +STRUCTTYPE_END(iwf$$datatypes$$lightbeam_t); + +STRUCTTYPE_BEGIN(iwf$$datatypes$$lightsource_t) + uint16_t coord; + htmlcolor_alpha color; + float lum; +STRUCTTYPE_END(iwf$$datatypes$$lightsource_t); diff --git a/src/incomplete/sandbox/datatypes/lights/lighttype_map.make b/src/incomplete/sandbox/datatypes/lights/lighttype_map.make new file mode 100644 index 0000000..8b3b0f5 --- /dev/null +++ b/src/incomplete/sandbox/datatypes/lights/lighttype_map.make @@ -0,0 +1,14 @@ +IWF_SRC_PATH := +IWF_TOOLS_PATH := + +$(IWF_SRC_PATH)/datatypes/entity/lightbeam_map.cc : $(IWF_SRC_PATH)/datatypes/lights/lighttype.h $(IWF_TOOLS_PATH)/stdmapwrapper_codegen.out +$(IWF_TOOLS_PATH)/stdmapwrapper_codegen.out u16 lightbeam uint16_t "iwf\$\$datatypes\$\$lightbeam_t" uint16_t "iwf\$\$datatypes\$\$lightbeam_t" 0 0 0 "#include \"$(IWF_SRC_PATH)/datatypes/lights/lighttype.h\"" > $(IWF_SRC_PATH)/datatypes/entity/lightbeam_map.cc + +$(IWF_SRC_PATH)/datatypes/entity/lightbeam_map.h : $(IWF_SRC_PATH)/datatypes/lights/lighttype.h $(IWF_TOOLS_PATH)/stdmapwrapper_headergen.out +$(IWF_TOOLS_PATH)/stdmapwrapper_headergen.out u16 lightbeam uint16_t "iwf\$\$datatypes\$\$lightbeam_t" "#include \"$(IWF_SRC_PATH)/datatypes/lights/lighttype.h\"" "typedef void * iwf$$datamap$$> $(IWF_SRC_PATH)/datatypes/lights/lightbeam_map.h + +$(IWF_SRC_PATH)/datatypes/entity/lightsource_map.cc : $(IWF_SRC_PATH)/datatypes/lights/lighttype.h $(IWF_TOOLS_PATH)/stdmapwrapper_codegen.out +$(IWF_TOOLS_PATH)/stdmapwrapper_codegen.out u16 lightsource uint16_t "iwf\$\$datatypes\$\$lightsource_t" uint16_t "iwf\$\$datatypes\$\$lightsource_t" 0 0 0 "#include \"$(IWF_SRC_PATH)/datatypes/lights/lighttype.h\"" > $(IWF_SRC_PATH)/datatypes/entity/lightsource_map.cc + +$(IWF_SRC_PATH)/datatypes/entity/lightsource_map.h : $(IWF_SRC_PATH)/datatypes/lights/lighttype.h $(IWF_TOOLS_PATH)/stdmapwrapper_headergen.out +$(IWF_TOOLS_PATH)/stdmapwrapper_headergen.out u16 lightsource uint16_t "iwf\$\$datatypes\$\$lightsource_t" "#include \"$(IWF_SRC_PATH)/datatypes/lights/lighttype.h\"" > $(IWF_SRC_PATH)/datatypes/lights/lightsource_map.h diff --git a/src/incomplete/sandbox/iwf__voxels__minichunk.cc b/src/incomplete/sandbox/iwf__voxels__minichunk.cc deleted file mode 100644 index 778ec03..0000000 --- a/src/incomplete/sandbox/iwf__voxels__minichunk.cc +++ /dev/null @@ -1,42 +0,0 @@ -class iwf::voxels::minichunk { - public: - void set(unsigned x, - std::map data; - } - -uint16_t iwf::voxels::minichunk::at (uint8_t x,uint8_t y,uint8_t z) { - if ((x < 0x10) && (y < 0x10) && (x < 0x10)) { - uint16_t output; - try { - output = self.at((z << 8)|(y << 4)|x); - } catch (out_of_range) { - return 0; - } - return output; - } else { - errno = EINVAL; - return 0; - }} - -int iwf::voxels::minichunk::emplace (uint8_t x,uint8_t y,uint8_t z,uint16_t blockid) { - if ((x < 0x10) && (y < 0x10) && (x < 0x10)) { - iwf::voxels::minichunk::data::iterator exists = this.data.find((z << 8)|(y << 4)|(x)); - if (exists == this.data.end()) { - this.data.emplace(((z << 8)|(y << 4)|x),blockid); - return 0; - } else { - exists->second = blockid; - return 0; - } - } else { - errno = EINVAL; - return -1; - }} - -void iwf::voxels::minichunk::erase (uint8_t x,uint8_t y,uint8_t z) { - if ((x < 0x10) && (y < 0x10) && (x < 0x10)) { - iwf::voxels::minichunk::data::iterator exists = this.data.find((z << 8)|(y << 4)|(x)); - if (exists != this.data.end()) { - this.data.erase(exists); - //and now it doesn't - }}} diff --git a/src/incomplete/sandbox/pathfinder_data.cc b/src/incomplete/sandbox/pathfinder_data.cc new file mode 100644 index 0000000..8e3de12 --- /dev/null +++ b/src/incomplete/sandbox/pathfinder_data.cc @@ -0,0 +1,23 @@ +iwf::ai::pathfinder::data::node { + bool obstruction; + double distance; /** reverse distance + * for an A★ algorithem + */ + double swimtime; + double airtime; + double phasetime; + }; + +iwf::ai::pathfinder::data_t { + std::pair here; + std::pair there; + /** pair coords + * .first is the octant relative to the player's chunk. only 27 + * chunks are animate at a time. .second is the coordinate in the + * chunk. + */ + std::map;iwf::ai::pathfinder::data::node> nodes; + iwf$$datatypes$$body_combat_metadata * body_combat_metadata; + iwf$$datatypes$$skilltyp * skills + } + diff --git a/src/incomplete/sandbox/reload_rooms.inc b/src/incomplete/sandbox/reload_rooms.inc new file mode 100644 index 0000000..6976589 --- /dev/null +++ b/src/incomplete/sandbox/reload_rooms.inc @@ -0,0 +1,366 @@ +/***ORIGIN***/ + iwf::roomcache::current[3][3][3] = input; + iwf::roomcache::increment(input); +//END ORIGIN +/***AXES***/ +/***UP***/ + for (int n = 2;n >= 0;n++) { + iwf::roomcache::current[n][3][3] = iwf::roomcache::data.at(iwf::roomcache::current[n + 1][3][3]).first->neighbors[UP]; + if (iwf::roomcache::current[n][3][3] >= 0) { + iwf::roomcache::increment(iwf::roomcache::current[n][3][3]); + } else { + break; + } +//END UP +/***DOWN***/ + for (int n = 4;n < 7;n++) { + iwf::roomcache::current[n][3][3] = iwf::roomcache::data.at(iwf::roomcache::current[n - 1][3][3]).first->neighbors[DOWN]; + if (iwf::roomcache::current[n][3][3] >= 0) { + iwf::roomcache::increment(iwf::roomcache::current[n][3][3]); + } else { + break; + } +//END DOWN +/***NORTH***/ + for (int n = 2;n >= 0;n++) { + iwf::roomcache::current[3][n][3] = iwf::roomcache::data.at(iwf::roomcache::current[3][n + 1][3]).first->neighbors[NORTH]; + if (iwf::roomcache::current[3][n][3] >= 0) { + iwf::roomcache::increment(iwf::roomcache::current[3][n][3]); + } else { + break; + } +//END NORTH +/***SOUTH***/ + for (int n = 4;n < 7;n++) { + iwf::roomcache::current[3][n][3] = iwf::roomcache::data.at(iwf::roomcache::current[3][n - 1][3]).first->neighbors[SOUTH]; + if (iwf::roomcache::current[3][n][3] >= 0) { + iwf::roomcache::increment(iwf::roomcache::current[3][n][3]); + } else { + break; + } +//END SOUTH +/***WEST***/ + for (int n = 2;n >= 0;n++) { + iwf::roomcache::current[3][3][n] = iwf::roomcache::data.at(iwf::roomcache::current[3][3][n + 1]).first->neighbors[WEST]; + if (iwf::roomcache::current[3][3][n] >= 0) { + iwf::roomcache::increment(iwf::roomcache::current[3][3][n]); + } else { + break; + } +//END WEST +/***EAST***/ + for (int n = 4;n < 7;n++) { + iwf::roomcache::current[3][3][n] = iwf::roomcache::data.at(iwf::roomcache::current[3][3][n - 1]).first->neighbors[EAST]; + if (iwf::roomcache::current[3][3][n] >= 0) { + iwf::roomcache::increment(iwf::roomcache::current[3][3][n]); + } else { + break; + } +//END EAST +//END AXES +/***PLANES***/ +/***XY***/ +/***NW***/ + for (size_t y = 2;y >= 0;y--) {for (size_t x = 2;x >= 0;x--) { + if (( + iwf::roomcache::current[3][y + 1][x] >= 0 + ) && ( + iwf::roomcache::current[3][y][x + 1] >= 0 + ) && ( + iwf::roomcache::data[iwf::roomcache::current[3][y + 1][x]].first->neighbors[NORTH] + == + iwf::roomcache::data[iwf::roomcache::current[3][y][x + 1]].first->neighbors[WEST] + )) { + iwf::roomcache::current[3][y][x] = iwf::roomcache::data[iwf::roomcache::current[3][y + 1][x]].first->neighbors[NORTH]; + }}} +//END NW +/***NE***/ + for (size_t y = 2;y >= 0;y--) {for (size_t x = 4;x < 7;x++) { + if (( + iwf::roomcache::current[3][y + 1][x] >= 0 + ) && ( + iwf::roomcache::current[3][y][x - 1] >= 0 + ) && ( + iwf::roomcache::data[iwf::roomcache::current[3][y + 1][x]].first->neighbors[NORTH] + == + iwf::roomcache::data[iwf::roomcache::current[3][y][x - 1]].first->neighbors[EAST] + )) { + iwf::roomcache::current[3][y][x] = iwf::roomcache::data[iwf::roomcache::current[3][y + 1][x]].first->neighbors[NORTH]; + }}} +//END NE +/***SW***/ + for (size_t y = 4;y < 7;y++) {for (size_t x = 2;x >= 0;x--) { + if (( + iwf::roomcache::current[3][y - 1][x] >= 0 + ) && ( + iwf::roomcache::current[3][y][x + 1] >= 0 + ) && ( + iwf::roomcache::data[iwf::roomcache::current[3][y - 1][x]].first->neighbors[SOUTH] + == + iwf::roomcache::data[iwf::roomcache::current[3][y][x + 1]].first->neighbors[WEST] + )) { + iwf::roomcache::current[3][y][x] = iwf::roomcache::data[iwf::roomcache::current[3][y - 1][x]].first->neighbors[SOUTH]; + }}} +//END SW +/***SE***/ + for (size_t y = 4;y < 7;y++) {for (size_t x = 4;x < 7;x++) { + if (( + iwf::roomcache::current[3][y - 1][x] >= 0 + ) && ( + iwf::roomcache::current[3][y][x - 1] >= 0 + ) && ( + iwf::roomcache::data[iwf::roomcache::current[3][y - 1][x]].first->neighbors[SOUTH] + == + iwf::roomcache::data[iwf::roomcache::current[3][y][x - 1]].first->neighbors[EAST] + )) { + iwf::roomcache::current[3][y][x] = iwf::roomcache::data[iwf::roomcache::current[3][y - 1][x]].first->neighbors[SOUTH]; + }}} +//END SE +//END XY +/***XZ***/ +/***upW***/ + for (size_t z = 2;z >= 0;z--) {for (size_t x = 2;x >= 0;x--) { + if (( + iwf::roomcache::current[z + 1][3][x] >= 0 + ) && ( + iwf::roomcache::current[z][3][x + 1] >= 0 + ) && ( + iwf::roomcache::data[iwf::roomcache::current[z + 1][3][x]].first->neighbors[UP] + == + iwf::roomcache::data[iwf::roomcache::current[z][3][x + 1]].first->neighbors[WEST] + )) { + iwf::roomcache::current[z][3][x] = iwf::roomcache::data[iwf::roomcache::current[z + 1][3][x]].first->neighbors[UP]; + }}} +//END upW +/***upE***/ + for (size_t z = 2;z >= 0;z--) {for (size_t x = 4;x < 7;x++) { + if (( + iwf::roomcache::current[z + 1][3][x] >= 0 + ) && ( + iwf::roomcache::current[z][3][x - 1] >= 0 + ) && ( + iwf::roomcache::data[iwf::roomcache::current[z + 1][3][x]].first->neighbors[UP] + == + iwf::roomcache::data[iwf::roomcache::current[z][3][x - 1]].first->neighbors[EAST] + )) { + iwf::roomcache::current[z][3][x] = iwf::roomcache::data[iwf::roomcache::current[z + 1][3][x]].first->neighbors[UP]; + }}} +//END upE +/***downW***/ + for (size_t z = 4;z < 7;z++) {for (size_t x = 2;x >= 0;x--) { + if (( + iwf::roomcache::current[z - 1][3][x] >= 0 + ) && ( + iwf::roomcache::current[z][3][x + 1] >= 0 + ) && ( + iwf::roomcache::data[iwf::roomcache::current[z - 1][3][x]].first->neighbors[DOWN] + == + iwf::roomcache::data[iwf::roomcache::current[z][3][x + 1]].first->neighbors[WEST] + ) { + iwf::roomcache::current[z][3][x] = iwf::roomcache::data[iwf::roomcache::current[z - 1][3][x]].first->neighbors[DOWN]; + }}} +//END downW +/***downE***/ + for (size_t z = 4;z < 7;z++) {for (size_t x = 4;x < 7;x++) { + if (( + iwf::roomcache::current[z - 1][3][x] >= 0 + ) && ( + iwf::roomcache::current[z][3][x - 1] >= 0 + ) && ( + iwf::roomcache::data[iwf::roomcache::current[z - 1][3][x]].first->neighbors[DOWN] + == + iwf::roomcache::data[iwf::roomcache::current[z][3][x - 1]].first->neighbors[EAST] + ) { + iwf::roomcache::current[z][3][x] = iwf::roomcache::data[iwf::roomcache::current[z - 1][3][x]].first->neighbors[DOWN]; + }}} +//END downE +//END XZ +/***YZ***/ +/***upN***/ + for (size_t z = 2;z >= 0;z--) {for (size_t y = 2;y >= 0;y--) { + if (( + iwf::roomcache::current[z + 1][y][3] >= 0 + ) && ( + iwf::roomcache::current[z][y + 1][3] >= 0 + ) && ( + iwf::roomcache::data[iwf::roomcache::current[z + 1][y][3]].first->neighbors[UP] + == + iwf::roomcache::data[iwf::roomcache::current[z][y + 1][3]].first->neighbors[NORTH] + )) { + iwf::roomcache::current[z][y][3] = iwf::roomcache::data[iwf::roomcache::current[z + 1][y][3]].first->neighbors[UP]; + }}} +//END upN +/***upS***/ + for (size_t z = 2;z >= 0;z--) {for (size_t y = 4;y < 7;y++) { + if (( + iwf::roomcache::current[z + 1][y][3] >= 0 + ) && ( + iwf::roomcache::current[z][y - 1][3] >= 0 + ) && ( + iwf::roomcache::data[iwf::roomcache::current[z + 1][y][3]].first->neighbors[UP] + == + iwf::roomcache::data[iwf::roomcache::current[z][y - 1][3]].first->neighbors[SOUTH] + )) { + iwf::roomcache::current[z][y][3] = iwf::roomcache::data[iwf::roomcache::current[z + 1][y][3]].first->neighbors[UP]; + }}} +//END upS +/***downN***/ + for (size_t z = 4;z < 7;z++) {for (size_t y = 2;y >= 0;y--) { + if (( + iwf::roomcache::current[y - 1][y][3] >= 0 + ) && ( + iwf::roomcache::current[z][y + 1][3] >= 0 + ) && ( + iwf::roomcache::data[iwf::roomcache::current[z - 1][y][3]].first->neighbors[DOWN] + == + iwf::roomcache::data[iwf::roomcache::current[z][y + 1][3]].first->neighbors[NORTH] + ) { + iwf::roomcache::current[z][y][3] = iwf::roomcache::data[iwf::roomcache::current[z - 1][y][3]].first->neighbors[DOWN]; + }}} +//END downN +/***downS***/ + for (size_t z = 4;z < 7;z++) {for (size_t y = 4;y < 7;y++) { + if (( + iwf::roomcache::current[z - 1][y][3] >= 0 + ) && ( + iwf::roomcache::current[z][y - 1][3] >= 0 + ) && ( + iwf::roomcache::data[iwf::roomcache::current[z - 1][y][3]].first->neighbors[DOWN] + == + iwf::roomcache::data[iwf::roomcache::current[z][y - 1][3]].first->neighbors[SOUTH] + ) { + iwf::roomcache::current[z][y][3] = iwf::roomcache::data[iwf::roomcache::current[z - 1][y][3]].first->neighbors[DOWN]; + }}} +//END downS +//END YZ +//END PLANE +/***OCTANT***/ +/***upNW***/ + for (size_t z = 2;z >= 0;z--) {for (size_t y = 2;y >= 0;y--) {for (size_t x = 2;x >= 0;x--) { + if (( + iwf::roomcache::current[z][y][x + 1] >= 0 + ) && ( + iwf::roomcache::current[z][y + 1][x] >= 0 + ) && ( + iwf::roomcache::current[z + 1][y][x] >= 0 + ) && ( + THREEQUAL( + iwf::roomcache::data[iwf::roomcache::current[z][y][x + 1]].first->neighbors[WEST], + iwf::roomcache::data[iwf::roomcache::current[z][y + 1][x]].first->neighbors[NORTH], + iwf::roomcache::data[iwf::roomcache::current[z + 1][y][x]].first->neighbors[UP]))) { + iwf::roomcache::current[z][y][x] = iwf::roomcache::data[iwf::roomcache::current[z + 1][y][x]].first->neighbors[UP]; + }}}} +//END upNW +/***upNE***/ + for (size_t z = 2;z >= 0;z--) {for (size_t y = 2;y >= 0;y--) {for (size_t x = 4;x < 7;x++) { + if (( + iwf::roomcache::current[z][y][x - 1] >= 0 + ) && ( + iwf::roomcache::current[z][y + 1][x] >= 0 + ) && ( + iwf::roomcache::current[z + 1][y][x] >= 0 + ) && ( + THREEQUAL( + iwf::roomcache::data[iwf::roomcache::current[z][y][x - 1]].first->neighbors[EAST], + iwf::roomcache::data[iwf::roomcache::current[z][y + 1][x]].first->neighbors[NORTH], + iwf::roomcache::data[iwf::roomcache::current[z + 1][y][x]].first->neighbors[UP]))) { + iwf::roomcache::current[z][y][x] = iwf::roomcache::data[iwf::roomcache::current[z + 1][y][x]].first->neighbors[UP]; + }}}} +//END upNE +/***upSW***/ + for (size_t z = 2;z >= 0;z--) {for (size_t y = 4;y < 7;y++) {for (size_t x = 2;x >= 0;x--) { + if (( + iwf::roomcache::current[z][y][x + 1] >= 0 + ) && ( + iwf::roomcache::current[z][y - 1][x] >= 0 + ) && ( + iwf::roomcache::current[z + 1][y][x] >= 0 + ) && ( + THREEQUAL( + iwf::roomcache::data[iwf::roomcache::current[z][y][x + 1]].first->neighbors[WEST], + iwf::roomcache::data[iwf::roomcache::current[z][y - 1][x]].first->neighbors[SOUTH], + iwf::roomcache::data[iwf::roomcache::current[z + 1][y][x]].first->neighbors[UP]))) { + iwf::roomcache::current[z][y][x] = iwf::roomcache::data[iwf::roomcache::current[z + 1][y][x]].first->neighbors[UP]; + }}}} +//END upSW +/***upSE***/ + for (size_t z = 2;z >= 0;z--) {for (size_t y = 4;y < 7;y++) {for (size_t x = 4;x < 7;x++) { + if (( + iwf::roomcache::current[z][y][x - 1] >= 0 + ) && ( + iwf::roomcache::current[z][y - 1][x] >= 0 + ) && ( + iwf::roomcache::current[z + 1][y][x] >= 0 + ) && ( + THREEQUAL( + iwf::roomcache::data[iwf::roomcache::current[z][y][x - 1]].first->neighbors[EAST], + iwf::roomcache::data[iwf::roomcache::current[z][y - 1][x]].first->neighbors[SOUTH], + iwf::roomcache::data[iwf::roomcache::current[z + 1][y][x]].first->neighbors[UP]))) { + iwf::roomcache::current[z][y][x] = iwf::roomcache::data[iwf::roomcache::current[z + 1][y][x]].first->neighbors[UP]; + }}}} +//END upSE +/***downNW***/ + for (size_t z = 4;z < 7;z++) {for (size_t y = 2;y >= 0;y--) {for (size_t x = 2;x >= 0;x--) { + if (( + iwf::roomcache::current[z][y][x + 1] >= 0 + ) && ( + iwf::roomcache::current[z][y + 1][x] >= 0 + ) && ( + iwf::roomcache::current[z - 1][y][x] >= 0 + ) && ( + THREEQUAL( + iwf::roomcache::data[iwf::roomcache::current[z][y][x + 1]].first->neighbors[WEST], + iwf::roomcache::data[iwf::roomcache::current[z][y + 1][x]].first->neighbors[NORTH], + iwf::roomcache::data[iwf::roomcache::current[z - 1][y][x]].first->neighbors[DOWN]))) { + iwf::roomcache::current[z][y][x] = iwf::roomcache::data[iwf::roomcache::current[z - 1][y][x]].first->neighbors[DOWN]; + }}}} +//END downNW +/***downNE***/ + for (size_t z = 4;z < 7;z++) {for (size_t y = 2;y >= 0;y--) {for (size_t x = 4;x < 7;x++) { + if (( + iwf::roomcache::current[z][y][x - 1] >= 0 + ) && ( + iwf::roomcache::current[z][y + 1][x] >= 0 + ) && ( + iwf::roomcache::current[z - 1][y][x] >= 0 + ) && ( + THREEQUAL( + iwf::roomcache::data[iwf::roomcache::current[z][y][x - 1]].first->neighbors[EAST], + iwf::roomcache::data[iwf::roomcache::current[z][y + 1][x]].first->neighbors[NORTH], + iwf::roomcache::data[iwf::roomcache::current[z - 1][y][x]].first->neighbors[DOWN]))) { + iwf::roomcache::current[z][y][x] = iwf::roomcache::data[iwf::roomcache::current[z - 1][y][x]].first->neighbors[DOWN]; + }}}} +//END downNE +/***downSW***/ + for (size_t z = 4;z < 7;z--) {for (size_t y = 4;y < 7;y++) {for (size_t x = 2;x >= 0;x--) { + if (( + iwf::roomcache::current[z][y][x + 1] >= 0 + ) && ( + iwf::roomcache::current[z][y - 1][x] >= 0 + ) && ( + iwf::roomcache::current[z - 1][y][x] >= 0 + ) && ( + THREEQUAL( + iwf::roomcache::data[iwf::roomcache::current[z][y][x + 1]].first->neighbors[WEST], + iwf::roomcache::data[iwf::roomcache::current[z][y - 1][x]].first->neighbors[SOUTH], + iwf::roomcache::data[iwf::roomcache::current[z - 1][y][x]].first->neighbors[DOWN]))) { + iwf::roomcache::current[z][y][x] = iwf::roomcache::data[iwf::roomcache::current[z - 1][y][x]].first->neighbors[DOWN]; + }}}} +//END downSW +/***downSE***/ + for (size_t z = 4;z < 7;z++) {for (size_t y = 4;y < 7;y++) {for (size_t x = 4;x < 7;x++) { + if (( + iwf::roomcache::current[z][y][x - 1] >= 0 + ) && ( + iwf::roomcache::current[z][y - 1][x] >= 0 + ) && ( + iwf::roomcache::current[z - 1][y][x] >= 0 + ) && ( + THREEQUAL( + iwf::roomcache::data[iwf::roomcache::current[z][y][x - 1]].first->neighbors[EAST], + iwf::roomcache::data[iwf::roomcache::current[z][y - 1][x]].first->neighbors[SOUTH], + iwf::roomcache::data[iwf::roomcache::current[z - 1][y][x]].first->neighbors[DOWN]))) { + iwf::roomcache::current[z][y][x] = iwf::roomcache::data[iwf::roomcache::current[z - 1][y][x]].first->neighbors[DOWN]; + }}}} +//END downSE +//END octant diff --git a/src/incomplete/sandbox/tiledata.H b/src/incomplete/sandbox/tiledata.H new file mode 100644 index 0000000..91f895f --- /dev/null +++ b/src/incomplete/sandbox/tiledata.H @@ -0,0 +1,22 @@ +struct tilemeta { + bool ladder : 1; + bool fence : 1; + + bool solid : 1; + bool liquid : 1; + bool nophase : 1; + + bool burn : 1; + bool hypotherm : 1; + bool electric : 1; + bool conductive : 1; + bool poison : 1; + bool spikes : 1; + bool void_ : 1; + + double friction; + double speed; + float dig; + + char texture[3][256]; + }; diff --git a/src/incomplete/sandbox/tileref.c b/src/incomplete/sandbox/tileref.c new file mode 100644 index 0000000..50706f9 --- /dev/null +++ b/src/incomplete/sandbox/tileref.c @@ -0,0 +1,37 @@ +unsigned char iwf$$raw8$$tileref$$pack (unsigned char bank,unsigned char tile) { + if ((bank < 4)&&(tile < 0100)) { + return ((bank << 6)|(tile)); + } else { + errno = EINVAL; + return -1; + }} + +unsigned char iwf$$raw8$$tileref$$gettile (unsigned char input) { + return (input & 077); + }; + +unsigned char iwf$$raw8$$tileref$$getbank (unsigned char input) { + return ((input >> 6) & 3); + }; + +iwf$$raw8$$tileref$$settile (unsigned char * object,unsigned char input) { + if (input < 0100) { + *object &= ~(0300); + *object |= input; + return 0; + } else { + errno = EINVAL; + return -1; + } + }; + +iwf$$raw8$$tileref$$setbank (unsigned char * object,unsigned char input) { + if (input < 4) { + *object &= ~(077); + *object |= (input << 6); + return 0; + } else { + errno = EINVAL; + return -1; + } + }; diff --git a/src/incomplete/sandbox/voxelnodeid.c b/src/incomplete/sandbox/voxelnodeid.c new file mode 100644 index 0000000..2b08c4d --- /dev/null +++ b/src/incomplete/sandbox/voxelnodeid.c @@ -0,0 +1,45 @@ +int32_t iwf$$raw32$$voxelnodeid$$pack ( + unsigned char octant_x,unsigned char octant_y,unsigned char octant_z, + unsigned char coord_x, unsigned char coord_y, unsigned char coord_z, + bool large,bool octree_x,bool octree_y,bool octree_z) { + if ((octant_x < 7) && (octant_y < 7) && (octant_z < 7) && + (coord_x < 0x20) && (coord_y < 0x20) && (coord_z < 0x20)) { + return ((1 << 31) | (iwf::private::voxelnodeid::cachedvoxelid[octant_z][octant_y][octant_x] << 19) | + (coord_x << 14) | (coord_y << 9) | (coord_z << 4) | + (parent << 3) | (octree_z << 2) | (octree_y << 1) | + octree_x); + +uint16_t iwf$$raw32$$voxelnodeid$$get$chunkhash (int32_t input) { + return ((input >> 19) & 0x0FFF); + +unsigned char iwf$$raw32$$voxelnodeid$$get$coord$z (int32_t input) { + return ((input >> 14) & 0x1F); + } + +unsigned char iwf$$raw32$$voxelnodeid$$get$coord$y (int32_t input) { + return ((input >> 9) & 0x1F); + } + +unsigned char iwf$$raw32$$voxelnodeid$$get$coord$x (int32_t input) { + return ((input >> 4) & 0x1F); + } + +int16_t iwf$$raw32$$voxelnodeid$$get$coord (int32_t input) { + return ((input >> 4) & 077777); + } + +bool iwf$$raw32$$voxelnodeid$$get$parent (int32_t input) { + return (input & 8); + } + +bool iwf$$raw32$$voxelnodeid$$get$octree$z (int32_t input) { + return (input & 4); + } + +bool iwf$$raw32$$voxelnodeid$$get$octree$y (int32_t input) { + return (input & 2); + } + +bool iwf$$raw32$$voxelnodeid$$get$octree$x (int32_t input) { + return (input & 1); + } diff --git a/src/incomplete/scratchpad.d/irrcontext.cc b/src/incomplete/scratchpad.d/irrcontext.cc new file mode 100644 index 0000000..94ad9a5 --- /dev/null +++ b/src/incomplete/scratchpad.d/irrcontext.cc @@ -0,0 +1,41 @@ +namespace irrcontext { + irr::IrrlichtDevice * device; + irr::gui::ICursorControl * cursor; + irr::IEventReciever * events; + irr::io::FileSystem * filesystem; + irr::gui::IGUIEnviroment * gui; + irr:ILogger * logger; + irr::scene::ISceneManager * sm; + irr::ITimer * timer; + irr::video::IVideoDriver * driver; + irr::scene::ISceneNode; + std::map voxels; + ISceneNode *chunks[7][7][7]; + } + +namespace irrcontext::chunk_voxel { + uint16_t counter; + uint16_t voxelid[7][7][7]; + + pan_up () ... + pan_down () ... + pan_north () ... + pan_south () ... + pan_west () ... + pan_east () ... + + assign (char x,char y,char z) ... + tie (char x,char y,char z,char xx,char yy,char zz) ... + } + +namespace irrcontext::textures { + std::map cache; + + irr::video::ITexture * get (irr::io::path filename) { + if (!(cache.contains(filename))) { + irr::video::ITexture nova = irrcontext::driver->getTexture(filename); + cache[filename] = nova; + } + return &(cache.at(filename)); + } + } diff --git a/src/incomplete/scratchpad.d/loadvoxels.cc b/src/incomplete/scratchpad.d/loadvoxels.cc new file mode 100644 index 0000000..01d9f54 --- /dev/null +++ b/src/incomplete/scratchpad.d/loadvoxels.cc @@ -0,0 +1,41 @@ +static const float eightpieces[2][2][2][3] = { + -0.5,-0.5,-0.5, + -0.5,-0.5, 0.5, + -0.5, 0.5,-0.5, + -0.5, 0.5, 0.5, + 0.5,-0.5,-0.5, + 0.5,-0.5, 0.5, + 0.5, 0.5,-0.5, + 0.5, 0.5, 0.5}; + +for (int x = 0;x < 32;x++) { + for (int y = 0;y < 32;y++) { + for (int z = 0;z < 32;z++) { + irr::core::vector3df vtmp((32 * (xxx - 3)) + (x - 15.5),(32 * (yyy - 3)) + (y - 15.5),(32 * (zzz - 3)) + (z - 15.5)); + if (irrcontext::voxels.contains(iwf$$raw32$$voxelnodeid$$pack(xxx,yyy,zzz,x,y,z,1,0,0,0)) { + irrcontext::voxels.at(iwf$$raw32$$voxelnodeid$$pack(xxx,yyy,zzz,x,y,z,1,0,0,0))->remove(); + irrcontext::voxels.erase(iwf$$raw32$$voxelnodeid$$pack(xxx,yyy,zzz,x,y,z,1,0,0,0)); + } + for (int octx = 0;octx < 2;octx++) { + for (int octy = 0;octy < 2;octy++) { + for (int octz = 0;octz < 2;octz++) { + if (irrcontext::voxels.contains(iwf$$raw32$$voxelnodeid$$pack(xxx,yyy,zzz,x,y,z,0,octx,octy,octz)) { + irrcontext::voxels.at(iwf$$raw32$$voxelnodeid$$pack(xxx,yyy,zzz,x,y,z,0,octx,octy,octz))->remove(); + irrcontext::voxels.erase(iwf$$raw32$$voxelnodeid$$pack(xxx,yyy,zzz,x,y,z,0,octx,octy,octz)); + }}}} + if (object->subtiles[z][y][x] == -1) { + irrcontext::voxels[iwf$$raw32$$voxelnodeid$$pack(xxx,yyy,zzz,x,y,z,1,0,0,0)] = irrcontext::sm->addCubeSceneNode(1,irrcontext::chunks[zzz][yyy][xxx],iwf$$raw32$$voxelnodeid$$pack(xxx,yyy,zzz,x,y,z,1,0,0,0),vtmp); + irrcontext::voxels.at(iwf$$raw32$$voxelnodeid$$pack(xxx,yyy,zzz,x,y,z,1,0,0,0))->setMaterialTexture(0,irrcontext::textures::cache.get((*(object->tilesets[iwf$$raw8$$tileref$$getbank(object->tiles[z][y][x])]))[iwf$$raw8$$tileref$$gettile(object->tiles[z][y][x])]); //resolve a dispatch table + } else { + irr::core::vector3df vtmp2; + for (int d;d < 2;d++) { + for (int e;e < 2;e++) { + for (int f;f < 2;f++) { + if (object->subtiles & (1 << ((d << 2)|(e << 1)|f))) { + irr::core::vector3df vtmp2 = vtmp; + irr::core::vector3df vtmp2.x += eightpieces[a][b][c][0]; + irr::core::vector3df vtmp2.y += eightpieces[a][b][c][1]; + irr::core::vector3df vtmp2.z += eightpieces[a][b][c][2]; + irrcontext::voxels[iwf$$raw32$$voxelnodeid$$pack(xxx,yyy,zzz,x,y,z,0,d,e,f)] = irrcontext::sm->addCubeSceneNode(1,irrcontext::chunks[zzz][yyy][xxx],iwf$$raw32$$voxelnodeid$$pack(xxx,yyy,zzz,x,y,z,0,d,e,f),vtmp2); + irrcontext::voxels.at(iwf$$raw32$$voxelnodeid$$pack(xxx,yyy,zzz,x,y,z,0,d,e,f))->setMaterialTexture(0,irrcontext::textures::cache.get((*(object->tilesets[iwf$$raw8$$tileref$$getbank(object->tiles[z][y][x])]))[iwf$$raw8$$tileref$$gettile(object->tiles[z][y][x])]); //resolve a dispatch table + }}}}}}}} //the heck is this, lisp? diff --git a/src/incomplete/scratchpad.d/roomcache.cc b/src/incomplete/scratchpad.d/roomcache.cc new file mode 100644 index 0000000..569c850 --- /dev/null +++ b/src/incomplete/scratchpad.d/roomcache.cc @@ -0,0 +1,155 @@ +/* this is a C++-enabled simplification of one of the oldest and most complex bespoke automata in the engine; wide format view + * (132 col) is recommended. + * + * it is currently modeled after that datastructure, but may be optimized in a future version of the engine + * + * UNDER NO CIRCUMSTANCES SHOULD THIS BE ACCESSED MANUALLY. + * doing so can potentially cause the engine to enter a corrupt state, and cause permenant damage to save files. additionally, + * the internal functionality of the object should not be implied to provide a stable API guaruntee, meaning that potentially + * breaking changes may happen frequently and with no more warning than a footnote in the EXTENDED changelog. + * + * think of this object as a system daemon. you alter it's data, not directly, but by making a request; requests take the form + * of API functions in this case. + * + * DRAGONS DWELL HERE + */ + +#define IMPORT___IWF__CONSTANTS__CHUNK__NEIGHBOR +※include "chunk.H" + +#define IWF__CHUNKCACHE__WARP_TYPES 16 +#define IWF__CHUNKCACHE__UNDOWARP_LEVELS 8 +#define IWF__CHUNKCACHE__STALECACHE_DEPTH 64 + +namespace iwf::roomcache { + std::map> data; + + int64_t current[5][5][5] = { +-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, +-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, +-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, +-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, +-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, +-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, +-1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1, -1,-1,-1,-1,-1,-1,-1}; + + std::vector warpbank; + std::vector undowarpbank; + + namespace stalecache { + std::list data; + std::map::iterator> index; + } + + SYSINT load (int64_t input) { + int64_t old[7][7][7]; + memcpy(&old,&(iwf::roomcache::current),sizeof(int64_t) * 7 * 7 * 7); + memset(&(iwf::roomcache::current),-1,sizeof(int64_t) * 7 * 7 * 7); + + //HERE BE DRAGONS + #include "reload_rooms.inc" + + SYSINT unload (int64_t dead) { + if (iwf::roomcache::data[dead].second < 0) { + free(iwf::roomcache::data[dead].first); + iwf::roomcache::data.erase(dead); + return 0; + } else { + return 1; + }} + + SYSINT queueforunload (int64_t input) { + if (iwf::roomcache::data[input].second < 0) { + iwf::roomcache::stalecache::data.push_front(int64_t); + iwf::roomcache::stalecache::index[input] = iwf::roomcache::stalecache::data.begin() + while (iwf::roomcache::stalecache::data.size() > IWF__CHUNKCACHE__STALECACHE_DEPTH) { + iwf::roomcache::stalecache::index.erase(iwf::roomcache::stalecache::data.back()); + iwf::roomcache::unload(iwf::roomcache::stalecache::data.back()); + iwf::roomcache::stalecache::data.pop_back(); + return 0; + }} else { + return -1; + }} + + SYSINT increment (int64_t input) { + if (iwf::roomcache::data.contains(input)) { + if (iwf::roomcache::data.at(input).second < 0) { + iwf::roomcache::data.at(input).second = 0; + iwf::roomcache::stalecache::data.remove(input); + iwf::roomcache::stalecache::index.erase(input); + return 0; + } else { + iwf::roomcache::data.at(input).second += 1; + if (iwf::roomcache::data.at(input).second < 0) { + errno = EOVERFLOW; + return -1; + } + return 0; + }} else { + iwf::roomcache::data[input].first = iwf::loadroom(input); + int tmperr = errno; + if (iwf::roomcache::data.at(input).first == NULL) { + iwf::roomcache::data.erase(input); + errno = tmperr; + return -1; + } + return 0; + }} + + SYSINT decrement (int64 input) { + if (iwf::roomcache::data.contains(input) { + if (iwf::roomcache::data.at(input).second < 0) { + return 0; + } else { + iwf::roomcache::data.at(input).second -= 1; + if (iwf::roomcache::data.at(input).second < 0) { + iwf::roomcache::queueforunload(input); + } + return 0; + } + } else { + errno = EINVAL; + return -1; + }} + + SYSINT jump (int64_t input) { + if (iwf::roomcache::current[3][3][3] == input) { + errno = EBUSY; + return 0; + } else { + iwf::roomcache::decrement(iwf::roomcache::current[3][3][3]); + iwf::roomcache::current = + + SYSINT warp (size_t bankno) { + int64_t tmp = iwf::roomcache::current[3][3][3]; + iwf::roomcache::current = iwf::roomcache::warpbank[bankno]; + iwf::roomcache::warpbank[bankno] = tmp; + iwf::roomcache::undowarpbank.push_front(tmp); + iwf::roomcache::increment(tmp); + if (iwf::roomcache::undowarpbank.size() > IWF__CHUNKCACHE__UNDOWARP_LEVELS) { + iwf::roomcache::decrement(iwf::warpcache::undowarpbank.back()); + iwf::roomcache::undowarpbank.pop_back(); + } + return 0; + } + + SYSINT warpback () { + int64_t tmp = iwf::roomcache::current; + iwf::roomcache::current = iwf::roomcache::undowarpbank.front(); + iwf::roomcache::decrement(tmp); + iwf::roomcache::undowarpbank.pop_front(); + for (std::vector::iterator i = iwf::roomcache::warpbank.begin();i != iwf::roomcache::warpbank.end;i++) { + if (i.second == iwf::roomcache::current) { + i.second = tmp; + iwf::roomcache::decrement(iwf::roomcache::current); + iwf::roomcache::increment(tmp); + } + return 0; + } + } + +extern "C" { + + iwf$$scrollroom (char x,char y,char z) + + diff --git a/src/incomplete/scratchpad b/src/incomplete/scratchpad.d/scratchpad similarity index 100% rename from src/incomplete/scratchpad rename to src/incomplete/scratchpad.d/scratchpad diff --git a/src/incomplete/scratchpad.d/tiledata_and_texturecache.c b/src/incomplete/scratchpad.d/tiledata_and_texturecache.c new file mode 100644 index 0000000..ede4671 --- /dev/null +++ b/src/incomplete/scratchpad.d/tiledata_and_texturecache.c @@ -0,0 +1,31 @@ +struct tilemeta { + bool ladder : 1; + bool fence : 1; + + bool solid : 1; + bool liquid : 1; + bool nophase : 1; + + bool burn : 1; + bool hypotherm : 1; + bool electric : 1; + bool conductive : 1; + bool poison : 1; + bool spikes : 1; + bool void_ : 1; + + double friction; + double speed; + float dig; + + char *texture[3]; + }; + +struct texture_cache_entry { + irr::io::IReadFile file; + irr::video::IImage image; + irr::video::ITexture texture; + int refcount + }; + +std::map texture_cache; diff --git a/src/ongoing/globals.inc b/src/ongoing/globals.inc index 85eb79d..5229afd 100644 --- a/src/ongoing/globals.inc +++ b/src/ongoing/globals.inc @@ -10,10 +10,20 @@ volatile ATOMIC(bool) HALT; volatile ATOMIC(bool) ERROR; //everywhere +iwf::dictionary_t TOPLEVEL +std::map *> POOLS; +ATOMIC(short) NEXTPOOL; +ATOMIC(bool) POOLSMAXED; +//savefile stuff + +ATOMIC(std::map) iwf::refcounter::table; +//anywhere that leaks + volatile ATOMIC(bool) CHANGE_JSDEV; //iwf$$joystickio std::string iwf::iosettings::jsdevpath; //iwf$$joystickio + uint8_t diff --git a/src/reference/badlexer.cc b/src/reference/badlexer.cc new file mode 100644 index 0000000..7b4d459 --- /dev/null +++ b/src/reference/badlexer.cc @@ -0,0 +1,144 @@ +#define _____BUMPER(F,L) fprintf(stderr,"fall-through at\n%s\n%i\n",F,L);raise(SIGSEGV) + +enum iwf::cli::tokentype { + TOKTYP_SYNTAX, + TOKTYP_INT, + TOKTYP_LONG, + TOKTYP_FLOAT, + TOKTYP_STRING, + TOKTYP_IDENT + } + +std::vector>> lexer (std::string input) { + std::vector>> output; + std::string buffer; + int prebuffer; + unsigned long n; + unsigned long oline; + +/** a case for spaghetti + * this is a finite-state automata. each goto label is a MUTUALLY recursive + * function invoked by a jmp call. each of these "functions" is useless + * outside of the parent function's context. together, they form a lexer + * whose behavior is altered by the input. + * + * if actual functions were used, there would exist pathological inputs + * that could overflow the stack pointer; this would be a Bad Thing. + * + * the BUMPER macro indicates a point that execution SHOULD never reach; + * the compiler will not necissarily recognise that the code is unreachable. + * if a BUMPER somehow is reached, an appropriate error is printed, and + * SIGSEGV is raised. + */ + +/***ABANDON ALL HOPE, YE WHO ENTER HERE***/ + +MODE_INITIAL: + prebuffer = input[n]; + if (isprint(prebuffer)) { + if (isalnum(prebuffer)) { + if (isdigit(prebuffer)) { + goto ACTION_NUMBER; + } else { + goto ACTION_IDENT; + } + } else switch (prebuffer) { + case '!' : goto ACTION_SYNTAX; + case '"' : goto ACTION_STRING; + case '#' : goto ACTION_LONG; + case '$' : goto ACTION_HEX; + //case '%' : + //case '&' : + //case '\'' : + case '(' : goto ACTION_SYNTAX; + case ')' : goto ACTION_SYNTAX; + //case '*' : + case '+' : goto ACTION_NUMBER_EXTRA; + case ',' : goto ACTION_SYNTAX; + case '-' : goto ACTION_NUMBER; + case '.' : goto ACTION_REAL_START; + //case '/' : + //case ':' : + case ';' : + case '<' : goto ACTION_ASSIGN; + //case '=' : + //case '>' : + //case '?' : + case '@' : goto ACTION_OCTAL; + case '[' : goto ACTION_SYNTAX; + //case '\\' : + case ']' : goto ACTION_SYNTAX; + //case '^' : + case '_' : goto ACTION_IDENT; + //case '`' : + case '{' : + //case '|' : + case '}' : + //case '~' : + default : goto ACTION_UNEXPECTED; + } + } else if (isspace(prebuffer) || ((034 <= prebuffer) && (prebuffer <= 037)) { + goto ACTION_WHITESPACE; + } else { + goto ACTION_UNEXPECTED; + } + _____BUMPER(__FILE__,__LINE__); + +ACTION_NUMBER: + buffer = ""; + buffer.push_back(prebuffer); + { + std::pair tmp; + tmp.first = TOKTYP_INT; + output[outputline].pushback(tmp); + } + readchar++; + + _____BUMPER(__FILE__,__LINE__); + +ACTION_WHITESPACE: + readchar++; + goto MODE_INITIAL; + _____BUMPER(__FILE__,__LINE__); + +ACTION_IDENT: + buffer = ""; + buffer.push_back(prebuffer); + readchar++; + goto MODE_IDENT; + _____BUMPER(__FILE__,__LINE__); + +ACTION_INITIAL_OCTAL: + buffer = ""; + readchar++; + goto MODE_OCTAL; + _____BUMPER(__FILE__,__LINE__); +ACTION_INITIAL_HEX: +ACTION_INITIAL_INT: + buffer = ""; + buffer.push_back(prebuffer); + { + std::pair tmp; + tmp.first = TOKTYP_INT; + output[outputline].pushback(tmp); + } + readchar++; + goto MODE_INT; + _____BUMPER(__FILE__,__LINE__); + +MODE_IDENT: +MODE_OCTAL: +MODE_HEX: +MODE_INT: +MODE_FLOAT: + +ACTION_GOOD_RETURN: + errno = 0; + return output; + _____BUMPER(__FILE__,__LINE__); + +ACTION_BAD_RETURN: + errno = ECANCELED; + return output; + _____BUMPER(__FILE__,__LINE__); +} diff --git a/src/incomplete/mothballedORreference/templates/cuckootree.c b/src/reference/cuckootree.c similarity index 100% rename from src/incomplete/mothballedORreference/templates/cuckootree.c rename to src/reference/cuckootree.c diff --git a/src/incomplete/mothballedORreference/templates/evheap.c b/src/reference/evheap.c similarity index 100% rename from src/incomplete/mothballedORreference/templates/evheap.c rename to src/reference/evheap.c diff --git a/src/incomplete/mothballedORreference/main.c b/src/reference/main.c similarity index 100% rename from src/incomplete/mothballedORreference/main.c rename to src/reference/main.c diff --git a/src/incomplete/mothballedORreference/oldtypes.h b/src/reference/oldtypes.h similarity index 100% rename from src/incomplete/mothballedORreference/oldtypes.h rename to src/reference/oldtypes.h diff --git a/src/incomplete/mothballedORreference/tmp.cnode b/src/reference/tmp.cnode similarity index 100% rename from src/incomplete/mothballedORreference/tmp.cnode rename to src/reference/tmp.cnode diff --git a/src/atomic_mutex.c b/src/rotten/atomic_mutex.d/atomic_mutex.c similarity index 100% rename from src/atomic_mutex.c rename to src/rotten/atomic_mutex.d/atomic_mutex.c diff --git a/src/atomic_mutex.h b/src/rotten/atomic_mutex.d/atomic_mutex.h similarity index 100% rename from src/atomic_mutex.h rename to src/rotten/atomic_mutex.d/atomic_mutex.h diff --git a/src/bitconcat.c b/src/rotten/bitconcat.d/bitconcat.c similarity index 100% rename from src/bitconcat.c rename to src/rotten/bitconcat.d/bitconcat.c diff --git a/src/bitconcat.h b/src/rotten/bitconcat.d/bitconcat.h similarity index 100% rename from src/bitconcat.h rename to src/rotten/bitconcat.d/bitconcat.h diff --git a/src/dlfunc_shim.h b/src/rotten/dlfunc_shim.h similarity index 100% rename from src/dlfunc_shim.h rename to src/rotten/dlfunc_shim.h diff --git a/src/fdshim.def b/src/rotten/fdshim.def similarity index 100% rename from src/fdshim.def rename to src/rotten/fdshim.def diff --git a/src/getsafe.cc b/src/rotten/getsafe.d/getsafe.cc similarity index 100% rename from src/getsafe.cc rename to src/rotten/getsafe.d/getsafe.cc diff --git a/src/getsafe.h b/src/rotten/getsafe.d/getsafe.h similarity index 100% rename from src/getsafe.h rename to src/rotten/getsafe.d/getsafe.h diff --git a/src/listf.cc b/src/rotten/listf.d/listf.cc similarity index 100% rename from src/listf.cc rename to src/rotten/listf.d/listf.cc diff --git a/src/listf.h b/src/rotten/listf.d/listf.h similarity index 100% rename from src/listf.h rename to src/rotten/listf.d/listf.h diff --git a/src/random.c b/src/rotten/random.d/random.c similarity index 100% rename from src/random.c rename to src/rotten/random.d/random.c diff --git a/src/random.h b/src/rotten/random.d/random.h similarity index 100% rename from src/random.h rename to src/rotten/random.d/random.h diff --git a/src/structops.c b/src/rotten/structops.d/structops.c similarity index 100% rename from src/structops.c rename to src/rotten/structops.d/structops.c diff --git a/src/structops.h b/src/rotten/structops.d/structops.h similarity index 100% rename from src/structops.h rename to src/rotten/structops.d/structops.h diff --git a/src/util.c b/src/rotten/util.d/util.c similarity index 100% rename from src/util.c rename to src/rotten/util.d/util.c diff --git a/src/util.def b/src/rotten/util.d/util.def similarity index 89% rename from src/util.def rename to src/rotten/util.d/util.def index 29c8697..0758562 100644 --- a/src/util.def +++ b/src/rotten/util.d/util.def @@ -18,4 +18,7 @@ #define iff(X,Y) (istrue(X) == istrue(Y)) #define logicxor(X,Y) (istrue(X) != istrue(Y)) +#define newline puts("") +#define fnewline(F) fputs("",F) + #endif diff --git a/src/util.h b/src/rotten/util.d/util.h similarity index 100% rename from src/util.h rename to src/rotten/util.d/util.h diff --git a/src/barrelroll.inl b/src/stable/barrelroll.inl similarity index 100% rename from src/barrelroll.inl rename to src/stable/barrelroll.inl diff --git a/src/base1.def b/src/stable/base1.def similarity index 100% rename from src/base1.def rename to src/stable/base1.def diff --git a/src/cppkeyword.def b/src/stable/cppkeyword.def similarity index 57% rename from src/cppkeyword.def rename to src/stable/cppkeyword.def index 6cc3cbc..2603dbe 100644 --- a/src/cppkeyword.def +++ b/src/stable/cppkeyword.def @@ -5,26 +5,29 @@ #define STRUCT #define NEWSTRUCT extern "C" struct -#define STRUCTTYPE(N,X) extern "C" struct N X; +#define STRUCTTYPE_BEGIN(N) extern "C" struct N { +#define STRUCTTYPE_END(N) } #define UNION #define NEWUNION extern "C" union -#define UNIONTYPE(N,X) extern "C" union N X; +#define UNIONTYPE_BEGIN(N) extern "C" union N { -#define IMPLICIT int; +#define SYSINT int #define ATOMIC(T) std::atomic #else #define STRUCT struct #define NEWSTRUCT struct -#define STRUCTTYPE(N,X) typedef struct N X N; +#define STRUCTTYPE_BEGIN(N) struct N { +#define STRUCTTYPE_END(N) } N #define UNION union #define NEWUNION union -#define UNIONTYPE(N,X) typedef union N X N; +#define UNIONTYPE_BEGIN(N) union N { -#define IMPLICIT +#define SYSINT #define ATOMIC(T) _Atomic T + #endif #endif diff --git a/src/cursescat.c b/src/stable/cursescat/cursescat.c similarity index 62% rename from src/cursescat.c rename to src/stable/cursescat/cursescat.c index 2264a34..268f03a 100644 --- a/src/cursescat.c +++ b/src/stable/cursescat/cursescat.c @@ -2,20 +2,23 @@ #include #include #include +#include #include +#include +#include -curscat (const char * filename) { +iwf$$cursescat (const char * filename) { FILENO fh = openat(DATADIR,filename,O_RDONLY); ptrdiff_t blocks; read(fh,&blocks,sizeof(ptrdiff_t)); - ptrdiff_t count; - attr_t attrs; + uint16_t count; + uint16_t attrs; char * buffer; for (int n = 0;n < blocks;n++) { - read(fh,&count,sizeof(ptrdiff_t)); + read(fh,&count,sizeof(uint16_t)); buffer = calloc(count + 1,sizeof(char)); - read(fh,&attrs,sizeof(attr_t)); - attrset(attrs); + read(fh,&attrs,sizeof(uint16_t)); + attrset((attr_t)attrs); read(fh,buffer,sizeof(char) * count); printw("%s",buffer); free(buffer); diff --git a/src/stable/cursescat/cursescat.h b/src/stable/cursescat/cursescat.h new file mode 100644 index 0000000..c35a35e --- /dev/null +++ b/src/stable/cursescat/cursescat.h @@ -0,0 +1,13 @@ +#ifndef __IWF_CURSESCAT_H__ +#define __IWF_CURSESCAT_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +extern int iwf$$cursescat (const char * filename); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/stable/loops.def b/src/stable/loops.def new file mode 100644 index 0000000..8e207ff --- /dev/null +++ b/src/stable/loops.def @@ -0,0 +1,11 @@ +#ifndef __GG4872__LOOPS__ +#define __GG4872__LOOPS__ + +#ifndef __cplusplus +#include +#endif + +#define BEGINAGAIN for (bool again = 1;again;) {again = 0 +#define forever for (;;) + +#endif diff --git a/src/stable/threequal.tmpl b/src/stable/threequal.tmpl new file mode 100644 index 0000000..7068cbc --- /dev/null +++ b/src/stable/threequal.tmpl @@ -0,0 +1,7 @@ +template +bool threequal (T x,T y,T z) { + if ((x == y) && (x == z) && (y == z)) { + return 1; + } else { + return 0; + }} diff --git a/src/using.hh b/src/using.hh deleted file mode 100644 index a681ce1..0000000 --- a/src/using.hh +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef __GG4872_USING__ -#define __GG4872_USING__ - -#include -using half_float::half; - -#include -using boost::logic::tribool; - -#endif - diff --git a/src/working/build.sh b/src/working/build.sh new file mode 100755 index 0000000..0f38b48 --- /dev/null +++ b/src/working/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +g++ ./main.cc -lcurses -lIrrlicht -o IWannaFly_prerelease_9001_MORN_15_07_2020.out diff --git a/src/working/main.cc b/src/working/main.cc new file mode 100644 index 0000000..518a5f3 --- /dev/null +++ b/src/working/main.cc @@ -0,0 +1,192 @@ +/************** + * IWANNAFLY * + * * + * prealpha * + **************/ + +/* part of this program has been created using the toutorials at + * http://irrlicht.sourceforge.net/docu/pages.html + */ + +/* this program currently requires a second terminal; this may be anything + * that can be passed to the program as argv[1] and fopened "r+". stderr + * should also be redirected to the same file. invocation might be: + * + * Iwannafly /dev/pts/1 savefile 2>~/logfile + * + * eventually, all three relevant windows will be generated by the program + * itself, allowing it to be launched without an stdio. + */ + +#define SYSINT int +#define RGBColor(R,G,B) irr::video::SColor(0xFF,R,G,B) +#define RGBAColor(R,G,B,A) irr::video::SColor(A,R,G,B) + + +#include +#include +#include +#include + +#include +#include + +#include +//#include + +extern "C" { + #include + #include + } + +namespace iwf { namespace datatypes { +class camcoord { + public: + double az; + double el; + + irr::core::vector3df euclid () { + irr::core::vector3df tmp; + tmp.X = sin(this->el) * cos(this->az); + tmp.Y = sin(this->el) * sin(this->az); + tmp.Z = cos(this->el); + return tmp; + }}; +}} + +namespace irrcontext { + irr::IrrlichtDevice * device; + irr::video::IVideoDriver * driver; + irr::scene::ISceneManager * smgr; + irr::gui::IGUIEnvironment * guienv; + irr::scene::IMeshManipulator * meshmanipr; + irr::gui::ICursorControl * cursctrl; + irr::ITimer * timer; + double deltatime; + uint32_t then; + uint32_t now; + } + +//lua_State * LSTATE; +std::map THREADS; +iwf::datatypes::camcoord CAMCOORD; +irr::scene::ICameraSceneNode * CAMERA; + +class MyEventReciever : public irr::IEventReceiver { + public: + virtual bool OnEvent (const irr::SEvent& event) { + if (event.EventType == irr::EET_KEY_INPUT_EVENT) { + KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown; + return false; + }} + + virtual bool IsKeyDown(irr::EKEY_CODE keyCode) { + return KeyIsDown[keyCode]; + } + + SYSINT MyEventReceiver() { + for (int i = 0;i < irr::KEY_KEY_CODES_COUNT;i++) { + KeyIsDown[i] = false; + }} + + private: + bool KeyIsDown[irr::KEY_KEY_CODES_COUNT]; + }; + +MyEventReciever RECIEVER; + +SYSINT initialize (char * argv0,char * argv1) { + for (int fg = 0;fg < 8;fg++) { + for (int bg = 0;bg < 8;bg++) { + init_pair(fg | (bg << 3),fg,bg); + }} + + FILE * dev = fopen(argv1,"r+"); + + if (dev == NULL) { + fprintf(stderr,"%s\n(Not a typewriter?)\n",strerror(errno)); + printf("usage: %s ...\n",argv0); + exit(1); + } + + newterm(NULL,dev,dev); + raw(); + noecho(); + keypad(NULL,1); + + irrcontext::device = irr::createDevice(irr::video::EDT_OPENGL,irr::core::dimension2d(640, 480),16,false,false,false,&RECIEVER); + irrcontext::driver = irrcontext::device->getVideoDriver(); + irrcontext::smgr = irrcontext::device->getSceneManager(); + irrcontext::guienv = irrcontext::device->getGUIEnvironment(); + irrcontext::meshmanipr = irrcontext::smgr->getMeshManipulator(); + irrcontext::cursctrl = irrcontext::device->getCursorControl(); + irrcontext::timer = irrcontext::device->getTimer(); + + irrcontext::guienv->addStaticText(L"IWannaFly Devtest prealpha version 0.0.9001",irr::core::rect(10,10,260,22),1); + CAMERA = irrcontext::smgr->addCameraSceneNode(NULL,irr::core::vector3df(0,0,0),irr::core::vector3df(1,1,1)); + CAMERA->setUpVector(irr::core::vector3df(0,0,1)); + irrcontext::cursctrl->setVisible(false); + + for (int x = 0;x < 2;x += 1) { + for (int y = 0;y < 2;y += 1) { + for (int z = 0;z < 2;z += 1) { + irr::scene::IMeshSceneNode * tmp = irrcontext::smgr->addCubeSceneNode( + 10.0, + NULL, + ((z << 2)|(y << 1)|x), + irr::core::vector3df( + (x ? 25 : -25), + (y ? 25 : -25), + (z ? 25 : -25))); + irrcontext::meshmanipr->setVertexColors(tmp->getMesh(),RGBColor( + ((0xFF * x) | 0x55), + ((0xFF * y) | 0x55), + ((0xFF * z) | 0x55))); + }}} + irrcontext::smgr->addLightSceneNode(); + } + +//void * repl (void * dummy) { +// LSTATE = luaL_newstate(); +// lua_close(LSTATE); +// return 0; +// } + +main (int argc, char *argv[]) { + if (argc < 2) { + printf("usage: %s ...\n",argv[0]); + exit(1); + } + initialize(argv[0],argv[1]); + while (irrcontext::device->run()) { + if (RECIEVER.IsKeyDown(irr::KEY_KEY_W)) { + CAMCOORD.el += 5 * irrcontext::deltatime; + if (CAMCOORD.el >= 0.0) { + CAMCOORD.el = 0 - (M_PI / 1000); + }} + if (RECIEVER.IsKeyDown(irr::KEY_KEY_S)) { + CAMCOORD.el -= 5 * irrcontext::deltatime; + if (CAMCOORD.el <= -M_PI) { + CAMCOORD.el = -(M_PI - (M_PI / 1000)); + }} + if (RECIEVER.IsKeyDown(irr::KEY_KEY_A)) { + CAMCOORD.az -= 5 * irrcontext::deltatime; + while (CAMCOORD.az < -M_PI) { + CAMCOORD.az += 2 * M_PI; + }} + if (RECIEVER.IsKeyDown(irr::KEY_KEY_D)) { + CAMCOORD.az += 5 * irrcontext::deltatime; + while (CAMCOORD.az > M_PI) { + CAMCOORD.az -= 2 * M_PI; + }} + + CAMERA->setTarget(CAMCOORD.euclid()); + irrcontext::driver->beginScene(true, true, RGBAColor(0,0,0xAA,0xF0)); + irrcontext::smgr->drawAll(); + irrcontext::guienv->drawAll(); + irrcontext::driver->endScene(); + + irrcontext::now = irrcontext::timer->getTime(); + irrcontext::deltatime = (irrcontext::now - irrcontext::then) / 1000.0; + irrcontext::then = irrcontext::now; + }} diff --git a/tmp.md b/tmp.md new file mode 100644 index 0000000..b63598f --- /dev/null +++ b/tmp.md @@ -0,0 +1,140 @@ +IWannaFly (working title) +========================= + +***Pre-Pre-Alpha version...idek*** + +A Nearly Realtime RPG Engine written in C, C++, an an undetermined scripting language +-------------------------------------------------------------- + +At this point, I've learned a bunch of stuff on both the programming and +metaprogramming\* level, and I think I have a pretty good idea of how to +move forward. This project was started primarily as a self-study +opportunity, and it's been a fun journey. + +I have now settled on a language, an overall structure, and some libraries. +from here, I do not forsee any further false starts and hope to have +smooth(ish) sailing through to a working alpha! + +The game engine uses the +[Irrlicht Engine](http://irrlicht.sourceforge.net/) for rendering 3d +graphics, [Cairo Graphics](https://www.cairographics.org/) for rendering +pictures, [NCurses](https://invisible-island.net/ncurses/) for +rendering in-game dialog, and [ChaiScript](http://chaiscript.com/) for both +extensions and a command line *(2 seperate instances)*.\ + *additional dependancies will follow...* + +use of an [external debugger](https://www.gnu.org/software/gdb/) is +recommended if **Bad Things** start happening. + +C code will use notation in variable names to seperate namespaces, using +`$$` in place of `::` *(this requires that a compiler support the extension +detailed in ISO 9899 Annex J.5.2)* + +2 example games will be provided: a high fantasy game with a wide cast of +playable characters, and a cyberpunk game with a single customizable +character. chunks can be connected in such a way to form wormholes that are +one-way or bidirectional. + +when reporting bugs, please note if the bug concerns the engine, +or one of the games, and which part of the engine or game; additionally, if +the bug concerns a freshly loaded state, try *turning it off and on again*. + +CODING STYLE +============ + +occasionally, a type of C coding called "Object Style C" will be used, +which takes the following form: +`namespace$$pseudo_class$$method(pseudo_object,arg,arg,arg...)` +functions that in fortran would be called "subroutines" are also used, and +will be denoted by returning an implicit int or the SYSINT macro (which +evaluates to the empty string *(implicit int)* in C and to `int` in C++) + +the types in `` (or ) should be used when an integer of +a specific width is required, with the exception that `char` should be +prefferred to `int8_t`, and `unsigned char` should be prefferred to +`uint8_t`. if an interger bitfield uses less than the full number of bytes +in an int, then it should be signed; otherwise it should (*usually*) be +unsigned. + +`struct`s should be catagorized into bitpacked structs and loosly-packed +structs. every field of a bitpacked struct should have an explicit width, +and should be of type `signed`, `unsigned`, or `bool`. a loosly-packed +struct should never use explicit-width fields. bitpacked structs should be +replaced with interger bitfields. + +since `this` is a reserved word in C++, and `self` is a reserved word in +Objective-C, when using Object-Style-C, the object variable will be named +`opaque` for `void *` pointers to C++ objects, or `object` for pointers +whose type is known; the variable will be named `here` for lowlevel +functions using an opaque pointer to operate on contiguous memory. +similarly, since `new` is a keyword in C++ with a compleatly different +meaning, an object that is being constructed by a function will be named +`nova`. `input` may be employed as the primary, or only, argument of a +function. `output` will be the return value. `acc` is an **acc**umulator, +and should be a register variable. + +variables with generic names follow the following conventions: +- `x`, `y`, `z`, and `w` refer to coordinates. `w` isn't used often. +- `i` and `j` are `for`-loop iterators, either in the sense of C++ + `::iterator`s or in the sense of intergal counters +- `n` and `m` are generic numbers, usually for-loop intergal counters +- `tmp` is a temporary variable, usually holding an intermidiate value. +- `T` is a type in a template +- `L` is a length (ℓ); it breaks from the usual capitalization rules + because of the `1`/`l`/`I` rule +- `data` is the main data member of an object + +a naming system similar to +[Systems Hungarian](https://en.wikipedia.org/wiki/Hungarian_notation) +is revived for the pourpose of manually mangling C functions that can take +multiple argument types, as this allows such functions to maintain C +linkage while also having faux overloads. this is similar to functions in +the C standard library such as `abs()` and `fabs()`. + +FILENAMES +========= +files should use the following extensions: +- C preprocessor files + - `*.def` : C preprocessor macros +- C files + - `*.c` : C code + - `*.h` : C header + - `*.inl` : inline functions +- C++ files + - `*.cc` : C++ code + - `*.hh` : C++ header + - `*.tmpl` : C++ template +- C or C++ files + - `*.H` : C or C++ header + - `*.inc` : transclusion, for editing conveniance +- data files + - `*.txt` : raw text + - `*.ro4` : ciphertext (see below) + - `*.curses` : bytecode for a curses interpreter + +files ending in .ro4 contain severe spoilers, and have been ciphered by +applying a [Circular Shift](https://en.wikipedia.org/wiki/Circular_shift) +of 4 to every byte of the file (the result is the same in either direction +like in a rot13 cipher); the program I use is provided in `nybbleswap.c`, +which is designed to be used in a shell pipeline.\ +to cipher a file: +`cat plaintext.txt | nybbleswap > ciptertext.ro4`\ +to uncipher a file: +`cat ciphertext.ro4 | nybbleswap > plaintext.txt`\ +to view a file: +`cat ciphertext.ro4 | nybbleswap`\ +to edit a file: +`cat ciphertext.ro4 | nybbleswap | vim -` + +--- + +**Publisher is not liable for Bad Things happening due to usage of this +code.** + +--- + +\**note: as I've been learning, one of the things I've been teaching myself +has also been the git system; as a result, instead of branching the repo +at two specific "flag day" points of development, I *forked* it instead. +Mistakes were made. If you want to see these relics (you really don't), +I will leave them as-is.* diff --git a/tools/listwrapper_codegen.c b/tools/listwrapper_codegen.c new file mode 100644 index 0000000..98c7482 --- /dev/null +++ b/tools/listwrapper_codegen.c @@ -0,0 +1,70 @@ +#include +#include + +main (int argc,char *argv[]) { + if ((argc != 3) && (argc != 4)) { + fprintf(stderr,"usage:\nlistwrappergen_cc