diff --git a/.gitattributes b/.gitattributes index 375849c..1083949 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,23 +1,35 @@ core.autocrlf=false -**/* = linguist-vendored=false linguist-documentation=false linguist-detectable=false diff -/manual/**/* = linguist-detectable=true -/manual/plaintext/**/* = linguist-documentation=true *.c = linguist-language=C *.h = linguist-language=C +*.m = linguist-language=objc +*.mm = linguist-language=objc++ *.cc = linguist-language=C++ *.hh = linguist-language=C++ +*.hm = linguist-language=objc +*.hmm = linguist-language=objc++ *.def = linguist-language=C *.inc = linguist-language=C +*.inl = linguist-language=C *.struct = linguist-language=C *.tmpl = linguist-language=C++ *.cclass = linguist-language=C++ -*.c.m4 = lingust-language=m4 linguist-language=C -*.h.m4 = lingust-language=m4 linguist-language=C -*.cc.m4 = lingust-language=m4 linguist-language=C++ -*.hh.m4 = lingust-language=m4 linguist-language=C++ -*.def.m4 = lingust-language=m4 linguist-language=C -*.inc.m4 = lingust-language=m4 linguist-language=C -*.struct.m4 = lingust-language=m4 linguist-language=C -*.tmpl.m4 = lingust-language=m4 linguist-language=C++ -*.cclass.m4 = lingust-language=m4 linguist-language=C++ +*.as = linguist-language=AngelScript +*.m4 = linguist-language=m4 +*.c.m4 = linguist-language=m4 linguist-language=C +*.h.m4 = linguist-language=m4 linguist-language=C +*.m.m4 = linguist-language=m4 linguist-language=objc +*.mm.m4 = linguist-language=m4 linguist-language=objc++ +*.cc.m4 = linguist-language=m4 linguist-language=C++ +*.hh.m4 = linguist-language=m4 linguist-language=C++ +*.hm.m4 = linguist-language=m4 linguist-language=objc +*.hmm.m4 = linguist-language=m4 linguist-language=objc++ +*.def.m4 = linguist-language=m4 linguist-language=C +*.inc.m4 = linguist-language=m4 linguist-language=C +*.inl.m4 = linguist-language=m4 linguist-language=C +*.struct.m4 = linguist-language=m4 linguist-language=C +*.tmpl.m4 = linguist-language=m4 linguist-language=C++ +*.cclass.m4 = linguist-language=m4 linguist-language=C++ +*.as.m4 = linguist-language=m4 linguist-language=AngelScript +*.awk = linguist-language=awk +*.PL = linguist-language=perl diff --git a/README.md b/README.md index 88bb5be..5076080 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ IWannaFly (working title) ========================= -***___ +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/ -*note: as I've been learning, one of the things I've been teaching myself +~~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. + +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. when reporting bugs, please note if the bug concerns the engine, +or one of the games, and which part of the engine or game. + +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. +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 +- `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()`. + +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 -` + +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. + +--- + +\**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. +I will leave them as-is.* diff --git a/concepts.txt b/concepts.txt new file mode 100644 index 0000000..b9798ee --- /dev/null +++ b/concepts.txt @@ -0,0 +1,18 @@ +the event loop is implemented in Object styled C with some small C++ +subsystems. it is based on the dlfcn library. the loop is arranged as +a circular singly linked list, with each element capible of building +a stack of queued frames; after a frame is done executing, any queued +frames are shunted to be executed after it until the stack is empty; +this data layout resembles a wooden crown gear. the function pointer +is of type «int(f*)(unsigned argc,void *argv[])», and is called via +dlsym or, if specifyed to be avalible, dlfunc. + +this could be changed to an angelscript engine, where +dlfunc(«module»,«symbol») is replaced by +engine->GetModule(«module»)->GetFunctionByDecl(«symbol»). + +the commandline is implemented with angelscript. actions use underlying +C++ objects that define the capibilities of each race/species; each +command calls a method on the object for that species/class. the method +in question may do something expected, something unexpected, produce an +error message, or produce a silly message. diff --git a/conventions.md b/conventions.md index 7f9dd02..f465f74 100644 --- a/conventions.md +++ b/conventions.md @@ -9,3 +9,9 @@ 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/cyberpunk/fragments b/cyberpunk/fragments new file mode 100644 index 0000000..021795f --- /dev/null +++ b/cyberpunk/fragments @@ -0,0 +1,27 @@ +save your game guy - man, my life sucks! +I'm just a nobody from nowhere! +heck, if life was an RPG, I wouldn't even be +the protagonist; I'd be the guy standing in +the starting area that says "Don't forget to +save your game!" + +--- + +homeless man - hey, maaan! +here, take a tinfoil hat! +why? HAHAHAhahaha... + *grab* +...thEy'rE reAdin oUr thOUghtS... + + +(note: he's not as crazy as he seems...) + +--- + +your shadow - who am I? +I'm everything that you are not. +I'm everything that you've forgot. +I'm everything that you should be-- +don't you wish... that you were me⸮ + +--- \ No newline at end of file diff --git a/cyberpunk/open b/cyberpunk/open new file mode 100644 index 0000000..95b0cdd --- /dev/null +++ b/cyberpunk/open @@ -0,0 +1,9 @@ +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/doctypes.txt b/doctypes.txt new file mode 100644 index 0000000..5160906 --- /dev/null +++ b/doctypes.txt @@ -0,0 +1,10 @@ +*.man.* a Linux manpage +*.mdoc.* a NetBSD manpage + +*.m(an|doc).3iwf a manpage on the C api +*.m(an|doc).5iwf a manpage on file formats +*.m(an|doc).6iwf a game package's manpage +*.m(an|doc).6 the engine's manpage + +*.texinfo plugin technical documentation, + lore reference materials for players and devs diff --git a/questdialogs/ElfPaladin.txt b/fantasy/ElfPaladin.txt similarity index 98% rename from questdialogs/ElfPaladin.txt rename to fantasy/ElfPaladin.txt index e72eb87..00ac4ac 100644 --- a/questdialogs/ElfPaladin.txt +++ b/fantasy/ElfPaladin.txt @@ -36,7 +36,7 @@ delagate from - there have been certain supplies, including ampel food, but no soldiers. we will attempt a rendezous at the southern border. mayor - (ampel food?...) -delagate from - +delagate from (you are standing with them) - I can provide 4 soldiers: 3 archers and a paladin. valiant soldiers from our small village. entering siren - then you seem to be in need of a caster. diff --git a/fantasy/ascension.ro4 b/fantasy/ascension.ro4 new file mode 100644 index 0000000..ab4dbc4 --- /dev/null +++ b/fantasy/ascension.ro4 @@ -0,0 +1 @@ +CWgVv'w7G'v'G&WGW'GV7W⠐'G77G'WvG76V⠠⠠CW...۠Gr7GVƗGvWG'VƗfV'7rGG7W6wV'7vVw'F""⠠CGFWfVgV'FVV7WvwWFҠWwWFwG&'VVwGFVG'VG7rW'w'7GfV'vgV栐f''GGG67GFWGWFw7'VGV7 WV77VfGVv6W6wG7G6VFwV'VGV7VgV7 &'VvFVG'VGV7GV'6V77F7G'Gvw'fWGWƗ77W'VFFV7G'W6GrGvGVWFV'֗'GV6G FW6F&WGG7vwV'GVFVG⠠CvwV'7҆wGGWvG⠐w7V'76VwGVGV'Vr7766VGGGV6GWƗ֖vGFGGW7VV'G&Vv7fv'VGwV'GVFG&VƖGGVGW6wV7V7WG7GV'Vv⒠ \ No newline at end of file diff --git a/questdialogs/avianinn.txt b/fantasy/avianinn.txt similarity index 100% rename from questdialogs/avianinn.txt rename to fantasy/avianinn.txt diff --git a/fantasy/dissonance.txt b/fantasy/dissonance.txt new file mode 100644 index 0000000..3fd4c93 --- /dev/null +++ b/fantasy/dissonance.txt @@ -0,0 +1,8 @@ +[1] - I've never understood + why your people let their own endure so + much suffering. beyond this city, the + outlying fifes have great surplus of + land and food, yet here people starve. + is this invented concept of "money" so + important to them that they will let + people, children, die for it? \ No newline at end of file diff --git a/questdialogs/farlook/orkishhords.txt b/fantasy/farlook/orkishhords.txt similarity index 100% rename from questdialogs/farlook/orkishhords.txt rename to fantasy/farlook/orkishhords.txt diff --git a/fantasy/farlook/spoilercharacter1.ro4 b/fantasy/farlook/spoilercharacter1.ro4 new file mode 100644 index 0000000..0975524 --- /dev/null +++ b/fantasy/farlook/spoilercharacter1.ro4 @@ -0,0 +1 @@ +Gr7GVwGV6w6V7&W'FVWGVgV'fVwF7GvgVWfFF6⠖77VVV77G󠠠GVww7wV'vGV6GFVV'7'Vwv7ww77VVvW7'V7GVW7⠠GGW'7WG7Vr7GVVFV'r7FWvGV'W6rG'W6VV'V7VGWGV'gvVwVGV6GvW'F6VG'FW'FVWG⠠7Vr7FvGV'VW7G&V7VGvW6F \ No newline at end of file diff --git a/questdialogs/fragments.txt b/fantasy/fragments.txt similarity index 73% rename from questdialogs/fragments.txt rename to fantasy/fragments.txt index 7450618..edd55bc 100644 --- a/questdialogs/fragments.txt +++ b/fantasy/fragments.txt @@ -1,3 +1,7 @@ +� = refer to spoiler character table + +*** + gnome - I call it a computational engine. it uses thousands of small mechanical parts to store and manipulate data! and as a recent improvement, it is powered by... Electricity! @@ -9,20 +13,12 @@ gnome - I call it a computational engine. it uses thousands of small has been suspended... I know that you suredly must be busy, but could you perhaps fetch it for me? -*** - -sourcerer thug - oh, fiesty young street rat, eh? what are you going to do? - humans can't cast, so unless-- -mentor - *snrkt* -thug - ...what are you laughing at, hag? -mentor - oh, nothing. carry on. - *** *cold open* (redshirt) - GO TO HELL YOU MONSTERS!! -���[evil] - Oh, I've been to hell. I even brought +�[2] - Oh, I've been to hell. I even brought some of it back with me *chapter 2 titlecard* @@ -46,23 +42,21 @@ siren magic instructor - it is easy for us to draw and hold magic; take *** -���[0] - Stop. that's not necissarry. you are no longer drawing energy from + +�[0] - Stop. that's not necissarry. you are no longer drawing energy from a well, or diverting it from a river. you are the precipace of a waterfall, and if you cannot learn to stem the flow soon, you will - be eroded away by the current. - - once I am sure you arn't a bigger threat than ���[evil], if only - from your inexperiance, you may leave. + be eroded away by the current passing through you. here, I can keep + you alive until you learn to control it. *** +�[0] - You're not the first to seek these monsters. -���[0] - You're not the first to seek these monsters. - - you know wat they say about the one who fights them... + you know what they say about the one who fights them... *** -���[0] - REMEMBER... +??? (�[0]) - REMEMBER... *note: all required characters start getting this event halfway through chapter 2* @@ -90,3 +84,19 @@ extra 2 - well, "hyper-cosmic extradimensional currents induced by exposing potential differentials in persistant background fields of exotic quantum partical reservoirs" is a bit verbose. extra 1 - but it's percise! + +*** + +shady shopkeeper - ...offer void where prohibited, NULL when cast to a + pointer... +(programmer joke) + +*** + +guard #1 - THERE! THAT ONE! THERE'S A 100,000,000 COIN BOUNTY ON THEM! +guard #2 - That sum could feed my family for a week! +guard #1 - screw your family, the money is mine! + *the first guard stabs the second guard* +guard commander - advance your career on your own time; AFTER THEM! + +*** diff --git a/questdialogs/goaway.depra b/fantasy/goaway.depra similarity index 100% rename from questdialogs/goaway.depra rename to fantasy/goaway.depra diff --git a/fantasy/languagelore b/fantasy/languagelore new file mode 100644 index 0000000..b11e06b --- /dev/null +++ b/fantasy/languagelore @@ -0,0 +1,20 @@ +NOTE: words that the character cannot understand will be randomized between +⍰ and �, and will blink. +NOTE: this is not yet implemented + +the language of the sirens is vast and complex, combining vocalization of +the larnix and syrnix. few other species can understand it, and fewer still +can actually speak it. + +it has two written forms: a complex dictation form, and a ‶simplified″ +academic form. the dictation form is most commonly used, and records the +inflection of the words, as well as their dialectal pronunceation; there is +no standardized spelling. the academic form was invented to fix this, and +records generalized phonemes instead of exact sounds. the newer academic +form has gained universal acceptance in applications where the text is not +a proxy for a person's words, but presents it's own information; i.e. in a +novel, it has become standard practice to use the academic form for the +words of a dispassionate narrator, while continuing to use the dictation +form for dialouge spoken by characters. using the opposite form of writing +can be used artistically to invoke a response, although when done by +mistake it usually invokes mockery. diff --git a/fantasy/potential.txt b/fantasy/potential.txt new file mode 100644 index 0000000..2217e6f --- /dev/null +++ b/fantasy/potential.txt @@ -0,0 +1,19 @@ +thief, chapter 2, dream +======================= + +[0] - You're asking yourself the wrong question. + + In addition to psionics, humans can, in fact, cast basic spells; + several notable heros have done so. but doing so is _always_ fatal. + it is a matter of biology; the exotic energy causes too much damage + to a frail human body. + + not only have you cast several high level spells of particularly + complex construction, but because of your lack of training, you + have done so in such a way that would bring an experianced elvan + battlecaster to their knees in agony...and you are none the worse + for wear. + + why do you suppose that is? + +*wakes up* diff --git a/fantasy/spoilercharactertable.ro4 b/fantasy/spoilercharactertable.ro4 new file mode 100644 index 0000000..2e93006 --- /dev/null +++ b/fantasy/spoilercharactertable.ro4 @@ -0,0 +1 @@ +ETt%TE$tE$Td5T%4%4ET%5ӠGVV'6'6GV'7'VG6WFVFVWFV6FVF㣠wV'fWVGGw7wGVF'v7'7VFfGV'V֖Ɩ7fV'7FF67FV'GV7VgV7GV6'VGV'fGV'VVGVwV'V6V'GF'VV&V'&Vv'GƳgvWV6'6W7G6V7wGVgV'vV'VfV7G6VGV&G'VgVGGVf'Fv'VG667ƗFg6vGVGw67W7WƗ66VF&7v7W''VƠ'VG'6WV7G7&WGGVGW'Vf'VƖGFGV7VfVWFV6FVF㣠GVFWvGV'f7'VG'&VFV'w7&VVW'VG7VVGVWF7F7vW7V#VWFV6FVF㣠ffVFw77WvGFGGVFGVwV'G%UTETu%DVw7V7GVf'6V'WVf&7WGV'FV'f'GV"Fg6VVGf6gƖG"F7GV&6vfGV6VGF'66gV''F73VWFV6FVFFVVvGVf'GVVgV7GV'v''V7GVVFV'fGV'G7'vGG7G'vGFV7G&ƖVGVVgƖG67V'VwGƖ7GGVWF'7V'V7GV'V'VgVVFG&V6Gv7G'VvVGf'#w'GƗ7GVW7''gCVWFV6FVF㠐7V6f6v''VV'w7VgV'VƗF7ƖV7ճGVGwfGV֠gVgV'v7G'GVwGGVƖ֖GVV7GGGw6W''fg'wGGV'7GV'7S \ No newline at end of file diff --git a/questdialogs/trollsontheroad.c b/fantasy/trollsontheroad.c similarity index 100% rename from questdialogs/trollsontheroad.c rename to fantasy/trollsontheroad.c diff --git a/filetypes.txt b/filetypes.txt index e1b6cc8..4f31620 100644 --- a/filetypes.txt +++ b/filetypes.txt @@ -1,10 +1,13 @@ -.c regular C +.c C of some description .cc C++ +.m Objective C +.mm Objective C++ -.inc modular code snippet to be #include-ed - these files contain large amounts of data +.inc modularized code +.inl inline functions .h C or C++ header +.h_ C only header .struct C struct definitions .def C preprocessor macro file @@ -12,7 +15,11 @@ .cclass C++ class header .tmpl C++ template header +.hm Objective C header +.hmm Objective C++ header + .*.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. @@ -22,27 +29,14 @@ as a key-value store, using the current addresses as *arbitrary* keys. new addresses are generated upon reloading. -.bin an array of contiguous data; is read to and from an unsigned char - array of uint's of the same width. the address of the array - in memory is irrelevant. - chunk voxel data uses this format; they are 32*32*32 voxels - and use a 15-bit address. +.bin a page of data; is mmaped to an unsigned char array and backed by a + file. the address of the array in memory is irrelevant, the data is + accessed by [offset]. chunk voxel data uses this format; they are + 32^3 voxels and use 15 bits of address space. the combination of bin files and dat files should be useable to restore all relevant state data. -*.man.* a Linux manpage -*.mdoc.* a NetBSD manpage - -*.m(an|doc).3iwf a manpage on the api -*.m(an|doc).5iwf a manpage on file formats -*.m(an|doc).6 the engine's manpage -*.m(an|doc).6iwf a game package's manpage -*.m(an|doc).7 the engine's automata layout - -*.texinfo plugin technical documentation, - lore reference materials for players and devs - possible build scripts for the project, once it reaches the existential threshold: build.sh makefile CMakeLists.txt diff --git a/notepad.txt b/notepad.txt index fb8a097..214efed 100644 --- a/notepad.txt +++ b/notepad.txt @@ -3,18 +3,3 @@ requires that both games be in the same global chapter, that the game is saved in a "Designated Area", that 2 individuals are not duplicated, and that the subspell "Wormhole - Summon Party" is known by a member of the party to be merged into. - -*** - -spells are called as thunks based on a dispatch table taking argc/argv. - -*** - -save files are tar bz2 files. the file is extracted to tmpfs during -gameplay - -*** - -chunk buffer is 64 chunks in a fifo. the nearest chunks are always kept -in the front 27 slots; others are allowed to fall further and further -back until falling off the end, being synced to tmpfs, then unloaded. diff --git a/nybbleswap.c b/nybbleswap.c new file mode 100644 index 0000000..d9143c2 --- /dev/null +++ b/nybbleswap.c @@ -0,0 +1,18 @@ +/* a trivial 4-bit rotate cipher program, for hiding spoilers. + * inspired by the rot13 cipher commonly used for the same pourpose. + * + * WTFPL + */ + +#include +#include + +main () { + unsigned char ch; + for (int err = fgetc(stdin);err != EOF;err = fgetc(stdin)) { + ch = err; + ch = ch >> 4 | ch << 4; + fputc(ch,stdout); + } + return 0; + } diff --git a/questdialogs/endofthebeginning_rot13.depra b/questdialogs/endofthebeginning_rot13.depra deleted file mode 100644 index 9dfeb32..0000000 --- a/questdialogs/endofthebeginning_rot13.depra +++ /dev/null @@ -1,28 +0,0 @@ -char *lines0[] = { - "Jrypbzr...V unir orra rkcrpgvat lbh.", - "V nz Sngr, gur xrrcre bs onynapr.", - "Naq V arrq lbhe uryc." - } - -char *lines1[] = { - "Ynj, Punbf, Tbbq, naq Rivy...rnpu nybar pnaabg shapgvba jvgubhg vg'f bccbfvgr.", - "Ynj jvgubhg Punbf vf vaqvssrerg naq pehyr.", - "Punbf jvgubhg ynj vf nanepul.", - "Tbbq pnaabg fheivir jvgubhg fbzr nzbhag bs Rivy.", - "Rivy qrfgeblf vgfrys va gur nofrapr bs Tbbq.", - "Fheryl, lbh unir frra guvf va lbhe ybat geniryf..." - } - -char *lines2[] = { - "Na napvrag orvat bs Rivy evfrf va gur bhgre cynarf.", - "vg vf lbhe qrfgval gb rafher gung onynapr erznvaf va gur zhygvirefr..." - } - -char *lines3[] = { - "V pnaabg vagresrne va gur nssnvef bs gur pbfzbf nal zber guna V unir nyernql qbar;", - "vg vf sbeovqqra gb qb nf zhpu nf V unir nyernql. Lbh zhfg svaq lbhe bja cngu sebz urer.", - "V tenag lbh bar ynfg tvsg orsber lbh zhfg yrnir..." - } - -/*Ryrzragny jrncba vf tenagrq urer. -Ebbz orpbzrf vanpprffvoyr nsgre rirag cynlf.*/ diff --git a/questdialogs/greedyjudge.txt b/questdialogs/greedyjudge.txt deleted file mode 100644 index eb8b16f..0000000 --- a/questdialogs/greedyjudge.txt +++ /dev/null @@ -1,5 +0,0 @@ -Given the facts of the case, I have no choice but to issue -summary judgement. You are hereby found guilty of high crime of intent to -debase the currency by passing forign coin. you will be interrogeted for -one week as to the location of the mines of your people, after which you -will be (pinioned, drawn, and quartered. | hung, drawn, and quartered.) diff --git a/src/atomic_mutex.c b/src/atomic_mutex.c new file mode 100644 index 0000000..fc574cc --- /dev/null +++ b/src/atomic_mutex.c @@ -0,0 +1,45 @@ +#include "atomicmutex.h" + +IMPLICIT atomic_bool$$lock (volatile atomic_bool * adhoc) { + while (*adhoc) { + usleep(1); + }; + *adhoc = 1; + } + +IMPLICIT atomic_mutex$$lock (STRUCT atomic_mutex * adhoc) { + while (adhoc->writelock) { + usleep(1); + }; + adhoc->writelock = 1; + while (adhoc->readlock) { + usleep(1); + }; + return 0; + } + +IMPLICIT atomic_mutex$$unlock (STRUCT atomic_mutex * adhoc) { + adhoc->writelock = 0; + return 0; + } + +IMPLICIT atomic_mutex$$increment (STRUCT atomic_mutex * adhoc) { + while (adhock->writelock) { + usleep(1); + }; + adhoc->readlock++; + if (!(adhoc->writelock)) { + errno = EOVERFLOW; + return -1; + } + return 0; + } + +IMPLICIT atomic_mutex$$decrement (STRUCT atomic_mutex * adhoc) { + adhoc->writelock--; + if (!~(adhoc->writelock)) { + errno = EOVERFLOW; + return -1; + } + return 0; + } diff --git a/src/atomic_mutex.h b/src/atomic_mutex.h new file mode 100644 index 0000000..6eecb34 --- /dev/null +++ b/src/atomic_mutex.h @@ -0,0 +1,20 @@ +#ifndef __cplusplus +#include +#include +#include +#else +#include +#endif +#include +#include +#include "cppkeywords.def" + +struct atomic_mutex { + volatile atomic_bool writelock; + volatile atomic_uint readlock; + } + +IMPLICIT atomic_mutex$$lock (STRUCT atomic_mutex * adhoc); +IMPLICIT atomic_mutex$$unlock (STRUCT atomic_mutex * adhoc); +IMPLICIT atomic_mutex$$increment (STRUCT atomic_mutex * adhoc); +IMPLICIT atomic_mutex$$decrement (STRUCT atomic_mutex * adhoc); diff --git a/src/barrelroll.c b/src/barrelroll.c deleted file mode 100644 index d54a0a5..0000000 --- a/src/barrelroll.c +++ /dev/null @@ -1,45 +0,0 @@ -#ifdef __cplusplus -#error this is not a C++ file -#endif - -#include "barrelroll.h" - -void rol8 (uint8_t * self,unsigned n) { - n &= 7; - *self = (*self << n) | (*self >> (8 - n)); - } - -void rol16 (uint16_t * self,unsigned n) { - n &= 0xf; - *self = (*self << n) | (*self >> (16 - n)); - } - -void rol32 (uint32_t * self,unsigned n) { - n &= 0x1f; - *self = (*self << n) | (*self >> (32 - n)); - } - -void rol64 (uint64_t * self,unsigned n) { - n &= 077; - *self = (*self << n) | (*self >> (64 - n)); - } - -void ror8 (uint8_t * self,unsigned n) { - n &= 7; - *self = (*self >> n) | (*self << (8 - n)); - } - -void ror16 (uint16_t * self,unsigned n) { - n &= 0xf; - *self = (*self >> n) | (*self << (16 - n)); - } - -void ror32 (uint32_t * self,unsigned n) { - n &= 0x1f; - *self = (*self >> n) | (*self << (32 - n)); - } - -void ror64 (uint64_t * self,unsigned n) { - n &= 077; - *self = (*self >> n) | (*self << (64 - n)); - } diff --git a/src/barrelroll.h b/src/barrelroll.h deleted file mode 100644 index d581cc4..0000000 --- a/src/barrelroll.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef __GG4872_BARRELROLL_H__ -#define __GG4872_BARRELROLL_H__ - -#ifndef __cplusplus -#include -#include -#else -#include -extern "C" { -#endif - -extern void rol8 (uint8_t * self,unsigned n); -extern void rol16 (uint16_t * self,unsigned n); -extern void rol32 (uint32_t * self,unsigned n); -extern void rol64 (uint64_t * self,unsigned n); -extern void ror8 (uint8_t * self,unsigned n); -extern void ror16 (uint16_t * self,unsigned n); -extern void ror32 (uint32_t * self,unsigned n); -extern void ror64 (uint64_t * self,unsigned n); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/src/barrelroll.inl b/src/barrelroll.inl new file mode 100644 index 0000000..66ab544 --- /dev/null +++ b/src/barrelroll.inl @@ -0,0 +1,64 @@ +#ifdef __ROL8__ + +static inline void rol8 (uint8_t * adhoc,unsigned n) { + n &= 7; + *adhoc = (*adhoc << n) | (*adhoc >> (8 - n)); + } + +#endif +#ifdef __ROL16__ + +static inline void rol16 (uint16_t * adhoc,unsigned n) { + n &= 0x0f; + *adhoc = (*adhoc << n) | (*adhoc >> (16 - n)); + } + +#enddef +#ifdef __ROL32__ + +static inline void rol32 (uint32_t * adhoc,unsigned n) { + n &= 0x1f; + *adhoc = (*adhoc << n) | (*adhoc >> (32 - n)); + } + +#endif +#ifdef __ROL64__ + +static inline void rol64 (uint64_t * adhoc,unsigned n) { + n &= 0077; + *adhoc = (*adhoc << n) | (*adhoc >> (64 - n)); + } + +#endif +#ifdef __ROR8__ + +static inline void ror8 (uint8_t * adhoc,unsigned n) { + n &= 7; + *adhoc = (*adhoc >> n) | (*adhoc << (8 - n)); + } + +#endif +#ifdef __ROR16__ + +static inline void ror16 (uint16_t * adhoc,unsigned n) { + n &= 0x0f; + *adhoc = (*adhoc >> n) | (*adhoc << (16 - n)); + } + +#endif +#ifdef __ROR32__ + +static inline void ror32 (uint32_t * adhoc,unsigned n) { + n &= 0x1f; + *adhoc = (*adhoc >> n) | (*adhoc << (32 - n)); + } + +#endif +#ifdef __ROR64__ + +static inline void ror64 (uint64_t * adhoc,unsigned n) { + n &= 0077; + *adhoc = (*adhoc >> n) | (*adhoc << (64 - n)); + } + +#endif diff --git a/src/base1.def b/src/base1.def index ff92224..7f10784 100644 --- a/src/base1.def +++ b/src/base1.def @@ -1,7 +1,7 @@ #ifndef __GG4872_BASE1_DEF__ #define __GG4872_BASE1_DEF__ -#define invbase1(T,X) (((T) -1) << (X)) -#define base1(T,X) ~invertbase1(T,X) +#define invbase1(T,X) (((T) -1) << (((CHAR_BIT * sizeof(T)) - 1) & X)) +#define base1(T,X) ~invbase1(T,X) #endif diff --git a/src/binary16vector.c b/src/binary16vector.c new file mode 100644 index 0000000..d4ba68a --- /dev/null +++ b/src/binary16vector.c @@ -0,0 +1,4 @@ +#include "binary16vector.h" +vector2functions(half,f16) +vector3functions(half,f16) +vector4functions(half,f16) diff --git a/src/binary16vector.h b/src/binary16vector.h new file mode 100644 index 0000000..941d247 --- /dev/null +++ b/src/binary16vector.h @@ -0,0 +1,14 @@ +#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/bitconcat.c b/src/bitconcat.c index 27e8ef6..b9f49a1 100644 --- a/src/bitconcat.c +++ b/src/bitconcat.c @@ -5,13 +5,13 @@ #include "bitconcat.h" uint16_t bitconcat8(uint8_t h,uint8_t l) { - return (h << 8) | l; + return ((uint16_t)h << 8) | l; } uint32_t bitconcat16(uint16_t h,uint16_t l) { - return (h << 16) | l; + return ((uint32_t)h << 16) | l; } uint64_t bitconcat32(uint32_t h,uint32_t l) { - return (h << 32) | l; + return ((uint64_t)h << 32) | l; } diff --git a/src/bitpack.c b/src/bitpack.c index 3ca98fb..9414948 100644 --- a/src/bitpack.c +++ b/src/bitpack.c @@ -6,89 +6,69 @@ #include "base1.def" void pack_8 (uint8_t * here,uint8_t value,unsigned width,unsigned offset) { - uint8_t mask = base1(width); - value &= mask; + offset &= 7; + uint8_t mask = invbase1(width) << offset; value <<= offset; - mask <<=offset; - mask = ~mask; - *here &= mask; - *here |= value; + *here = (here & mask) | (value & ~mask); } uint8_t unpack_u8 (uint8_t * here,unsigned width,unsigned offset) { - uint8_t mask = base1(width) << offset; - uint8_t output = *here & mask; - return output >> offset; + uint8_t output = *here >> offset; + return output & base1(width); } int8_t unpack_s8 (uint8_t * here,unsigned width,unsigned offset) { - uint8_t mask = base1(width) << offset; - int8_t output = *here & mask; - return output >> offset; + uint8_t output = *here >> offset; + return output & base1(width); } -void pack_16 (uint16_t * here,uint16_t value,unsigned width,unsigned offset) { - uint8_t mask = base1(width); - value &= mask; +void pack_8 (uint16_t * here,uint16_t value,unsigned width,unsigned offset) { + offset &= 0x0F; + uint16_t mask = invbase1(width) << offset; value <<= offset; - mask <<=offset; - mask = ~mask; - *here &= mask; - *here |= value; + *here = (here & mask) | (value & ~mask); } uint16_t unpack_u16 (uint16_t * here,unsigned width,unsigned offset) { - uint8_t mask = base1(width) << offset; - uint8_t output = *here & mask; - return output >> offset; + uint16_t output = *here >> offset; + return output & base1(width); } int16_t unpack_s16 (uint16_t * here,unsigned width,unsigned offset) { - uint8_t mask = base1(width) << offset; - int8_t output = *here & mask; - return output >> offset; + uint16_t output = *here >> offset; + return output & base1(width); } void pack_32 (uint32_t * here,uint32_t value,unsigned width,unsigned offset) { - uint8_t mask = base1(width); - value &= mask; + offset &= 0x1F; + uint32_t mask = invbase1(width) << offset; value <<= offset; - mask <<=offset; - mask = ~mask; - *here &= mask; - *here |= value; + *here = (here & mask) | (value & ~mask); } uint32_t unpack_u32 (uint32_t * here,unsigned width,unsigned offset) { - uint8_t mask = base1(width) << offset; - uint8_t output = *here & mask; - return output >> offset; + uint32_t output = *here >> offset; + return output & base1(width); } -int32_t unpack_s32 (uint32_t * here,unsigned width,unsigned offset) { - uint8_t mask = base1(width) << offset; - int8_t output = *here & mask; - return output >> offset; +int32_t unpack_s32 (uint8_t * here,unsigned width,unsigned offset) { + uint32_t output = *here >> offset; + return output & base1(width); } void pack_64 (uint64_t * here,uint64_t value,unsigned width,unsigned offset) { - uint8_t mask = base1(width); - value &= mask; + offset &= 077; + uint64_t mask = invbase1(width) << offset; value <<= offset; - mask <<=offset; - mask = ~mask; - *here &= mask; - *here |= value; + *here = (here & mask) | (value & ~mask); } uint64_t unpack_u64 (uint64_t * here,unsigned width,unsigned offset) { - uint8_t mask = base1(width) << offset; - uint8_t output = *here & mask; - return output >> offset; + uint64_t output = *here >> offset; + return output & base1(width); } -int64_t unpack_s64 (uint64_t * here,unsigned width,unsigned offset) { - uint8_t mask = base1(width) << offset; - int8_t output = *here & mask; - return output >> offset; +int64_t unpack_s64 (uint8_t * here,unsigned width,unsigned offset) { + uint64_t output = *here >> offset; + return output & base1(width); } diff --git a/src/cppkeyword.def b/src/cppkeyword.def index fbf6ef4..6cc3cbc 100644 --- a/src/cppkeyword.def +++ b/src/cppkeyword.def @@ -12,6 +12,7 @@ #define UNIONTYPE(N,X) extern "C" union N X; #define IMPLICIT int; +#define ATOMIC(T) std::atomic #else @@ -24,5 +25,6 @@ #define UNIONTYPE(N,X) typedef union N X N; #define IMPLICIT +#define ATOMIC(T) _Atomic T #endif #endif diff --git a/src/dlfunc_shim.h b/src/dlfunc_shim.h new file mode 100644 index 0000000..2ec385c --- /dev/null +++ b/src/dlfunc_shim.h @@ -0,0 +1,5 @@ +#ifndef __GG4872_DLFUNC_SHIM_H__ +#define __GG4872_DLFUNC_SHIM_H__ +typedef void * dlfunc_t; +#define dlfunc(H,S) dlsym(H,S) +#endif diff --git a/src/getsafe.h b/src/getsafe.h index d1cd7ed..bede2dd 100644 --- a/src/getsafe.h +++ b/src/getsafe.h @@ -8,7 +8,6 @@ extern "C" { #endif extern char * getsafe (); -extern IMPLICIT cat (char * filename); #ifdef __cplusplus } diff --git a/src/TODO b/src/incomplete/TODO similarity index 90% rename from src/TODO rename to src/incomplete/TODO index 815b554..dc5506e 100644 --- a/src/TODO +++ b/src/incomplete/TODO @@ -21,4 +21,5 @@ Entity movement Manpages Spells Special Effects -Commandline flex interpreter +Angelscript Commandline +Angelscript Debugger diff --git a/src/incomplete/launchpad/flywheel.cclass b/src/incomplete/launchpad/flywheel.cclass new file mode 100644 index 0000000..616e9e1 --- /dev/null +++ b/src/incomplete/launchpad/flywheel.cclass @@ -0,0 +1,74 @@ +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 () { + if (data != NULL) { + ExecuteString(this->engine,data->call.c_str(),0,this->ctx); + return 0; + } else { + return -1; + }} + + IMPLICIT insert (std::string call,int times) { + iwf::flywheel::frame * nova = new iwf::flywheel::frame; + if (this->data == NULL) { + this->data = nova; + this->prev = nova; + } + nova->call = call; + nova->times = times; + return 0; + } + + IMPLICIT queue (std::string call,int times) { + iwf::flywheel::subframe * nova = new iwf::flywheel::frame; + nova->call = call; + nova->times = times; + this->data->down.push(nova); + return 0; + } + + IMPLICIT dequeue () { + iwf::flywheel::frame * nova = new iwf::flywheel::frame; + nova->call = this->data->down.top().call; + nova->times = this->data->down.top().times; + nova->down = this->data->down.top().down; + this->data->down.pop(); + return 0; + } + + IMPLICIT spin () { + if (this->data != NULL) { + while (this->data->down.size()) { + this->dequeue(); + } + if (this->data->times == 0) { + iwf::flywheel::frame * deadbeef = this->data; + this->data = this->data->next; + this->prev->next = this->data; + delete deadbeef; + } else { + if (this->data->times != -1) { + this->times -= 1; + } + this->prev = this->data; + this->data = this->data->next; + } + return 0; + }} + } diff --git a/src/incomplete/ncursesnoise.c b/src/incomplete/launchpad/ncursesnoise.c similarity index 100% rename from src/incomplete/ncursesnoise.c rename to src/incomplete/launchpad/ncursesnoise.c diff --git a/src/incomplete/launchpad/repl.cc b/src/incomplete/launchpad/repl.cc new file mode 100644 index 0000000..ab93047 --- /dev/null +++ b/src/incomplete/launchpad/repl.cc @@ -0,0 +1,16 @@ +extern volatile atomic_bool HALT; +extern volatile atomic_bool ERROR; + +iwf$$threads$$commandline (iwf::types::asrepl * state) { + std::string buffer; + for (int as_errno;!(HALT || ERROR);) { + getline(std::cin,buffer); + as_errno = ExecuteString(state->engine,buffer.c_str(),state->module,state->context); + assert (as_errno >= 0) { + HALT = 1; + ERROR = 1; + return -1; + } + } + return ERROR ? -1 : 0; + } diff --git a/src/incomplete/launchpad/scriptboot.cc b/src/incomplete/launchpad/scriptboot.cc new file mode 100644 index 0000000..8ee1d13 --- /dev/null +++ b/src/incomplete/launchpad/scriptboot.cc @@ -0,0 +1,19 @@ +int angelscript::r; + +asIScriptEngine * iwf::bootengine::new (unsigned argc,*void[] argv,std::string[] names,*iwf::strangemutex[] locks) { + asIScriptEngine * nova = asCreateScriptEngine(); assert (nova != NULL); + RegisterScriptArray(nova,true); + RegisterStdString(nova); + RegisterScriptDictionary(nova); + RegisterScriptFile(nova); + RegisterScriptFileSystem(nova); + RegisterScriptMath(nova); + RegisterScriptDateTime(nova); + RegisterExceptionRoutines(nova); + #include "astypes.def" + for (unsigned n;n < argc;n++) { + angelscript::r = nova->RegisterGlobalProperty(names[n].c_str(), &g_number); assert(angelscript::r >= 0); + } + + } + diff --git a/src/incomplete/launchpad/slurp.cc b/src/incomplete/launchpad/slurp.cc new file mode 100644 index 0000000..147db92 --- /dev/null +++ b/src/incomplete/launchpad/slurp.cc @@ -0,0 +1,89 @@ +std::vector slurplines (char * filename) { + std::ifstream input; + input.open(filename,std::ifstream::in); + std::vector output; + for (std::string tmp;!(input.eof());) { + getline(input,tmp); + output.push_back(tmp); + } + return output; + } + +std::vector slurplines (std::string filename) { + std::ifstream input; + input.open(filename,std::ifstream::in); + std::vector output; + for (std::string tmp;!(input.eof());) { + getline(input,tmp); + output.push_back(tmp); + } + return output; + } + +std::vector slurpstrings (char * filename) { + std::ifstream input; + input.open(filename,std::ifstream::in); + std::vector output; + for (std::string tmp;!(input.eof());) { + getline(input,tmp,0); + output.push_back(tmp); + } + return output; + } + +std::vector slurpstrings (std::string filename) { + std::ifstream input; + input.open(filename,std::ifstream::in); + std::vector output; + for (std::string tmp;!(input.eof());) { + getline(input,tmp,0); + output.push_back(tmp); + } + return output; + } + +std::vector slurprecord (char * filename) { + std::ifstream input; + input.open(filename,std::ifstream::in); + std::vector output; + for (std::string tmp;!(input.eof());) { + getline(input,tmp,036); + output.push_back(tmp); + } + return output; + } + +std::vector slurprecord (std::string filename) { + std::ifstream input; + input.open(filename,std::ifstream::in); + std::vector output; + for (std::string tmp;!(input.eof());) { + getline(input,tmp,036); + output.push_back(tmp); + } + return output; + } + +std::string slurpfile (char * filename) { + std::ifstream input; + input.open(filename,std::ifstream::in); + std::string output; + for (std::string tmp;!(input.eof());) { + getline(input,tmp); + output.append(tmp); + output.append("\n"); + } + return output; + } + +std::string slurpfile (std::string filename) { + std::ifstream input; + input.open(filename,std::ifstream::in); + std::string output; + for (std::string tmp;!(input.eof());) { + getline(input,tmp); + output.append(tmp); + output.append("\n"); + } + return output; + } diff --git a/src/unused/archive.c b/src/incomplete/mothballedORreference/archive.c similarity index 100% rename from src/unused/archive.c rename to src/incomplete/mothballedORreference/archive.c diff --git a/src/incomplete/mothballedORreference/argvlogic.h b/src/incomplete/mothballedORreference/argvlogic.h new file mode 100644 index 0000000..9b12a95 --- /dev/null +++ b/src/incomplete/mothballedORreference/argvlogic.h @@ -0,0 +1,8 @@ +bool argv_and (unsigned argc,bool argv[]); +bool argv_or (unsigned argc,bool argv[]); +bool argv_nand (unsigned argc,bool argv[]); +bool argv_nor (unsigned argc,bool argv[]); +bool argv_onehot (unsigned argc,bool argv[]); +bool argv_evenparity (unsigned argc,bool argv[]); +bool argv_oddparity (unsigned argc,bool argv[]); +bool argv_iff (unsigned argc,bool argv[]); \ No newline at end of file diff --git a/src/unused/bettersavefileio.c b/src/incomplete/mothballedORreference/bettersavefileio.c similarity index 100% rename from src/unused/bettersavefileio.c rename to src/incomplete/mothballedORreference/bettersavefileio.c diff --git a/src/unused/evheap.c b/src/incomplete/mothballedORreference/evheap.c similarity index 100% rename from src/unused/evheap.c rename to src/incomplete/mothballedORreference/evheap.c diff --git a/src/exists.tmpl b/src/incomplete/mothballedORreference/exists.tmpl similarity index 50% rename from src/exists.tmpl rename to src/incomplete/mothballedORreference/exists.tmpl index 6776348..ac334e6 100644 --- a/src/exists.tmpl +++ b/src/incomplete/mothballedORreference/exists.tmpl @@ -2,14 +2,14 @@ #if 1 template -bool exists(std::map * me,std::map::key_type query) { - return me->find(query) != me->end(); +bool exists(std::map * adhoc,std::map::key_type query) { + return (adhoc->find(query) != adhoc->end()); } #else template -bool exists(std::map * me,std::map::key_type query) { +bool exists(std::map * adhoc,std::map::key_type query) { try { - me->at(query); + adhoc->at(query); } catch (std::out_of_bounds) { return 0; } diff --git a/src/unused/extmodules.cc b/src/incomplete/mothballedORreference/extmodules.cc similarity index 100% rename from src/unused/extmodules.cc rename to src/incomplete/mothballedORreference/extmodules.cc diff --git a/src/incomplete/flywheel.cpseudo b/src/incomplete/mothballedORreference/flywheel.cpseudo similarity index 98% rename from src/incomplete/flywheel.cpseudo rename to src/incomplete/mothballedORreference/flywheel.cpseudo index 7ffb5dc..da05bdb 100644 --- a/src/incomplete/flywheel.cpseudo +++ b/src/incomplete/mothballedORreference/flywheel.cpseudo @@ -70,4 +70,4 @@ flywheelshunt (STRUCT flywheelindex * me) { free(deadbeef->cleanupsym); } if (deadbeef->dumpsym != NULL) { free(deadbeef->dumpsym); - } free(deadbeef);}}}} \ No newline at end of file + } free(deadbeef);}}}} diff --git a/src/incomplete/funstack.c b/src/incomplete/mothballedORreference/funstack.c similarity index 100% rename from src/incomplete/funstack.c rename to src/incomplete/mothballedORreference/funstack.c diff --git a/src/incomplete/mothballedORreference/globalvar.cc b/src/incomplete/mothballedORreference/globalvar.cc new file mode 100644 index 0000000..8ba8de9 --- /dev/null +++ b/src/incomplete/mothballedORreference/globalvar.cc @@ -0,0 +1,51 @@ +NEWSTRUCT globalvar { + size_t num; + size_t size; + void * ptr; + } + +#ifdef __cplusplus + +class iwf::globaltmp { + std::map> data; + void * alloc (std::string name,size_t num,size_t size) { + void * tmp = calloc(num,size); + this->data[name].push({num,size,tmp}); + return tmp; + } + void * alloc (char * cname,size_t num,size_t size) { + std::string name(cname); + return this->alloc(name,width,length); + } + void dealloc (std::string name) { + if (this->data.contains(name)) { + if (!(this->data[name].empty())) { + free(this->data[name].back().ptr); + this->data[name].pop_back(); + } + if (this->data[name].empty()) { + this->data.erase(name)); + } + }} + void dealloc (char * cname) { + std::string name; + this->dealloc(name); + } + } + +extern "C" { +#endif + + void * iwf$$globaltmp$$alloc (void * adhoc,char * name,size_t num,size_t size) { + iwf::globaltmp * objcast = adhoc; + return objcast->alloc(name,num,size); + } + + void * iwf$$globaltmp$$alloc (void * adhoc,char * name) { + iwf::globaltmp * objcast = adhoc; + return objcast->dealloc(name); + } + +#ifdef __cplusplus + } +#endif diff --git a/src/unused/heapio.c b/src/incomplete/mothballedORreference/heapio.c similarity index 100% rename from src/unused/heapio.c rename to src/incomplete/mothballedORreference/heapio.c diff --git a/src/unused/heapio2.c b/src/incomplete/mothballedORreference/heapio2.c similarity index 100% rename from src/unused/heapio2.c rename to src/incomplete/mothballedORreference/heapio2.c diff --git a/src/incomplete/lightning.psudoexpr b/src/incomplete/mothballedORreference/lightning.psudoexpr similarity index 100% rename from src/incomplete/lightning.psudoexpr rename to src/incomplete/mothballedORreference/lightning.psudoexpr diff --git a/src/incomplete/lighttree.c b/src/incomplete/mothballedORreference/lighttree.c similarity index 100% rename from src/incomplete/lighttree.c rename to src/incomplete/mothballedORreference/lighttree.c diff --git a/src/incomplete/mothballedORreference/magnetoception.txt b/src/incomplete/mothballedORreference/magnetoception.txt new file mode 100644 index 0000000..aa03c59 --- /dev/null +++ b/src/incomplete/mothballedORreference/magnetoception.txt @@ -0,0 +1,16 @@ +Magnetoception: +- initialize a discreet vector space with + south→north vectors of magnitude 0.5 + (or some other value 0.25 ≤ real ≤ 0.65) +- calculate a vector at each intergal point + on the main grid for each dipole, and mean + the value into the vector at that coordinate +- render each vector in red, and its negative + in light blue. + +B_r = 2M sin lat/r^3 +B_lat = -M cos lat/r^3 + + (non-dipole sources will be modeled as + dipoles. this is a game engine, not a + scientific calculator.) diff --git a/src/incomplete/main.c b/src/incomplete/mothballedORreference/main.c similarity index 100% rename from src/incomplete/main.c rename to src/incomplete/mothballedORreference/main.c diff --git a/src/incomplete/mothballedORreference/minifixed.c b/src/incomplete/mothballedORreference/minifixed.c new file mode 100644 index 0000000..4bdb943 --- /dev/null +++ b/src/incomplete/mothballedORreference/minifixed.c @@ -0,0 +1,17 @@ +//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 new file mode 100644 index 0000000..4fb5ba9 --- /dev/null +++ b/src/incomplete/mothballedORreference/minifixed.h @@ -0,0 +1,13 @@ +//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/oldtypes.h b/src/incomplete/mothballedORreference/oldtypes.h new file mode 100644 index 0000000..2101d29 --- /dev/null +++ b/src/incomplete/mothballedORreference/oldtypes.h @@ -0,0 +1,1331 @@ +/* this file has more history at branch "lastworking" + * I dragged it here soley as a reference while reimplementing + * the contents in C++. + */ + +/* uuid's are used to cache dynamiclly allocated memory into the savefile; + * think of them like shared pointers. + */ + +#ifndef IWANNAFLY_TYPES_H_REENTRANT +#define IWANNAFLY_TYPES_H_REENTRANT 1 + +/* note: if the compiler complains about mixing tightly packed and loosly packed fields, + * the tightly packed ones will be split off into a seperate type with "_bits" affixed to + * the name, which will be placed in a member "_bits" at the end of the struct. + * + * only structs that mix odd-sized members and subcontainer structs or true pointers will have this problem; + * technically, even true pointers can be size-allocated if you want to maintain seperate 32 and 64 bit sources, + * but I don't. debugging multiple builds from a single source will be difficult enough. + */ + +#define uint unsigned int +#define uchar unsigned char +#define ushort unsigned short +#define ulong unsigned long +#define ptrchar uint8_t +#define ptrshort uint16_t + +struct stringlistyp <% +(self) * prev; +(self) * next; +char * text; +%> +/* used to store a list of strings + * may be from a data object, or + * stored in a tsv + */ + +struct singlestringlistyp <% +(self) * next; +char * text; +%> + +struct filelinetyp <% +(self) * prev; +(self) * next; +uint16_t lineno; +char * text; +%> +// used by the line editor + +struct singlestringlistyp <% +(self) * next; +uint16_t lineno; +char * text; +%> + +struct chaptertyp { +unsigned c : 7; //chapter number +unsigned a : 9; //alignment type +} + +struct turntyp { +unsigned second : 6; //mod 60 +unsigned mm : 6; //mod 60 +unsigned hour : 5; //mod 24 +unsigned timezone : 5; +unsigned dayear : 9; //mod 360 +unsigned weekday : 3; //mod 7 +unsigned moonphase : 2; //rollover ; solar-lunar phase shift is deferred +unsigned daymonth : 5; //mod 30 +unsigned month : 4; //mod 12 +unsigned season : 2; //month % 4 + +} +/* years will start on the vernal equinox, for multiple reasons: + * - it adds to the exotic feel of the world + * - it makes more sense than some random day in the middle of winter + * ->it's easier to the program the equinoxes/solstices that way + */ + +struct sphere { +Vector3 center +float radius +} + +typedef uchar ucoord4[4]; +typedef uchar ucoord3[3]; +typedef uchar ucoord2[2]; +typedef char scoord4[4]; +typedef char scoord3[3]; +typedef char scoord2[2]; + +struct setcoord3 <% +struct setcoord3 * prev; +struct setcoord3 * next; +uchar x; +uchar y; +uchar z; +%> + +typedef char *strarry[] +typedef void *ptrarry[] + +struct lightyp <% +struct lightyp * prev; +struct lightyp * next; +ucoord2 x; +ucoord2 y; +ucoord2 z; +%> + +struct agetyp { + unsigned chrono : 16; + signed bio : 8; //entity dies on overflow + unsigned rem : 8; // bio's remainder after chrono; + } /* bio increments on the next modulo0 of + * the entity's current aging factor + * (href basentyp). exploiting the + * immediately apparent flaw of this + * behavior by frequently shapeshifting + * is allowed; but has it's own side + * effects. (href shiftstackobj) + */ + +struct nibbles { +unsigned lo : 4 +unsigned hi : 4 +} + +struct snibbles { +signed lo : 4 +signed hi : 4 +} + +struct racetyp { +intptr_t race : 8 +intptr_t table : 4 +unsigned meta : 4 + // 00,0,F is nul +} + +struct microvector { +unsigned x : 2 +unsigned y : 2 +unsigned z : 2 +unsigned w : 2 +} + +struct nanovector { +signed x : 2 +signed y : 2 +signed z : 2 +signed w : 2 +} + +typedef char *pluralwords[3]; + +#define MOVETOKEN_ICE 8 +#define MOVETOKEN_LAND 4 +#define MOVETOKEN_FLY 1 +#define MOVETOKEN_SWIM 2 + +struct selftyp { +unsigned az : 3 //yaw in eighth turns +unsigned phi : 3 //polar angle in eighth turns +unsigned movetoken : 4 +unsigned gravdir : 5 //changes the up vector, must be a valid octant +bool weightless : 1 +} + +struct beamtyp { +unsigned az : 3 //azimuth +unsigned phi : 3 //elevation in eighth turns. 07 is omnidirectional. +unsigned ang : 4 //total solid angle of spread in twelfths of a circle. +unsigned range : 6 +} +/* for all azimuths: + * + * 701 + * 6 2 + * 543 + * + * for all elevations: + * + * +1 + * 0 ?-2? + * -1 + */ + +struct diceodds: +unsigned num : 3 +unsigned side : 5 +unsigned tobeat : 8 + +struct planetyp { +bool shadow : 1 +unsigned rho : 2 +unsigned az : 3 +signed el : 2 +} + +/* if the poles of a sphere are unaccessible, it may be cylindrically + * projected; otherwise, it must be cube mapped + * + * rho 0 is the prime plane + * rho 1 are the elemental planes + * rho 2 are afterlives + * rho 3 can be used for areas that are meant to not show up on a map. + * (said map would be implemented with pipes) + * + * az elemental afterlife corrilation + * 0 water neutral good nurturer + * 1 ice chaotic good the ends justify the means + * 2 air chaotic neutral insert obscure fourswords reference here + * 3 electricity chaotic evil force lightning + * 4 fire neutral evil obviously + * 5 metal lawful evil greed + * 6 earth lawful neutral stubborn + * 7 trees lawful good knowladge + * + * az rotates by 45 degree steps and el by 90 degree steps. + * a nonzero el causes az to gimbal lock. + * also best not to think about where exactly -2 is pointing. + * + * el " " " + * +1 light true neutral enlightenment + * -1 darkness uncomitted meh, I'll think of one later + * -2 entropy oathbreakers abandon all hope ye who enter here + * + * errors related to this section may generate one of 2 errors: + * "fell off the edge of the world", N1=±lat,N2=±lon + * "froze to death on pluto", N1=+az,N2=±el + * + * a room stack exists that keeps a number of rooms loaded + * if a room is not on the stack, it is loaded from the save file and + * pushed to the stack. this may cause the stack to intentionally drop + * the room at the bottom to prevent eating too much ram. if the file + * does not yet exist, the room is generated according to a dispatch table + * in a shared object. if the function and file are both NULL and the + * room is being entered, a lost in space death is called. if only the + * function is NULL, the file is executed in perl. if only the file is + * NULL, no shared objects are loaded before the function is called. + * + * a swap array keeps track of gating between the 23 major planes, + * saving the player's position, but not keeping the room loaded. + */ + +struct placetyp { +(self) *prev +(self) *next +uuid_t uuid +char* name +ucoord4 globpos +planetyp plane +Vector2 latlon +ucoord3 pos +} + +typedef float trackaligntyp[2] +typedef float trackalignplayertyp[3] +/* alignments satisfy the equasion { x^2 + y^2 ≤ 1000^2 } + * neutral is the area satisfying { x^2 + y^2 ≤ 100^2 } + * other alignments are deternmined by lines extending at the following + * azimuths: 30, 60, 120, 150, -150, -120, -60, -30 (use atan2) + * corner cases round twords a cardinal direction + * + * actions, quests, and being polymorphed into + * certain monsters can alter your alignment + * [0] is {+good,-evil}, [1] is {+lawful,-chaotic} + * + * for players, proactivness/passivity is also + * tracked + */ + +struct ray_vfx_typ { +(self) * prev +(self) * next +Ray this +Color color +} + +struct multiclasstyp: +(self) *prev +(self) *next +bool notnull : 1 +unsigned role : 2 +unsigned class : 3 +unsigned mastery : 2 + +struct classtyp { +bool notnull : 1 +unsigned role : 2 +unsigned class : 3 +unsigned mastery : 2 +} + +struct baseclasstyp { +struct paffectyp bonus +uchar spd +char airspd +uchar air +struct conlangtyp lang +cantriptyp spell[2] +bool mindless : 1 +bool shadow : 1 +bool incoporeal : 1 +bool immortal : 1 +unsigned lde : 3 //grants +unsigned alignment : 9 //requires +unsigned element : 8 //grants +} + +struct the8stats: //8* 5D6 +stren : u5 +psy : u5 +dex : u5 +con : u5 +fort : u5 +intl : u5 +wis : u5 +bluff : u5 +struct movelimit { +float spd +float airspd +float watspd +uchar lung +uchar wing +} + +struct movecount { +float spd //added to move each turn +float airspd /* if this is negative, then it's value is immediately + * subtracted from move whenever flying is attempted. + * otherwise, added to fly each turn + */ +float watspd //ditto but added to swim +float move //value is capped at 2*spd +float fly /* carries the extra moves that can be used in the air; + * they are used first when applicable + */ +float swim //ditto but used in water +ucoord3 skillgain /* [0] = ground, [1] = water, [2] = air. + * when these overflow, a skill level is + * gained if applicable. + */ +ucoord2 lung //number of turns that you can go without air. +ucoord2 wing //number of turns left before you fall +} + +struct conlangtype: +unsigned id : 5 +bool r : 1 +bool w : 1 +bool x : 1 + +struct xtraplayertyp { +uuid_t partyid; //the folder in the savefile to save to +chaptertyp chapter; +uint64_t kills; +uchar elecollect[8]; +uchar questcollect[3]; +bagitemptr * bag; +walletyp wallet; +turntyp date; +uint64_t turn; +uint16_t roomturn; +} + +/* note: everything related to players and entitys is + * copied into the struct, because it might be changed. + * the base entities and base classes are only templates. + * + * whenever you "rest" in-game, all entities are re-verified; + * meaning that all effect registers are recalculated. this + * has the side effect of removing any non-item based buffs + * and debuffs. this should be one of the only times that + * a baseclasstyp or basentyp are referenced; the others + * being adding a class, looseing a class, advancing in a class, + * polymorphing, polylocking, by the renderer, + * and when spawning a new entity. + * + * some stats are spread out accross multiple fields in the structure; + * most effects have one field for permenant and one field for temporary + * versions of the effect. a handful of alteration spells have a third + * register, with the polymorph stack, for timed spells, since the + * other temporary slot has no timer. + * + * nearly all fields of the player struct are created by COMBINING the + * basentyp and baseclasstyp chosen at the creation of the savefile. + * the remainder are based on backstory and user input. + */ + +walletyp { +unsigned whole : 25 +unsigned cent : 7 +} + +struct playertyp: +playertyp * prev +playertyp * next +char * name +uuid_t root //the uuid for this player's story; should they die, everything with this uuid as a parent is garbage collected +classtyp class[3] +uchar element +agetyp age +struct shiftstackobj race +ucoord3 pos +selftyp etc +struct movecount move +paffectyp paffect //permenant +effectyp effect //from equipment +trackalignplayertyp align +uint16_t hp +uint16_t mp +uint32_t xp +uchar lvl +Vector2 hunger +langlistele *lang_ptr +spellistele *spell_ptr +cantriplistele *cant_ptr +helditemtyp helm //any item +helditemtyp shield //shld +helditemtyp bow //weapon +helditemtyp armor //armor +helditemtyp cape //armor +helditemtyp amul //baub +unsigned n_arms : 4 +unsigned n_legs : 4 +armtyp * arms +legtyp * legs + +struct armtyp { +struct armtyp * next +helditemtyp weap[2] +helditemtyp ring[2] +helditemtyp wrist[2] +helditemtyp gloves +helditemtyp cannon +} + +struct legtyp { +legtyp * next +helditemtyp boots +helditemtyp greev +} + +enum equipenum = {ENUM_WEAP_LEFT,ENUM_WEAP_RIGHT,ENUM_SHIELD_ENUM_BOW,ENUM_ARMOR,ENUM_CAPE,ENUM_HELM, +ENUM_GLOVES,ENUM_CANNON,ENUM_BOOTS,ENUM_GREEV,ENUM_AMUL,ENUM_RING_LEFT,ENUM_RING_RIGHT,ENUM_WRIST_LEFT, +ENUM_WRIST_RIGHT} + +struct basentyp: +aggrotyp aggro //here, shiftable denotes a monster's aggro state is locked. also gives the value that patience is set to when a monster calms down, the value that cooldown is set to when it is angered, and the default AI. +paffectyp base +struct movelimit move +unsigned n_arms : 4 +unsigned n_legs : 4 +uchar hplvl +uchar mplvl +uchar xplvl +struct conlangtyp lang[2] +spelltyp spell[4] +Mesh * shape +Texture2D * texture +signed size : 2 +bool mindless : 1 +bool shadow : 1 +bool incoporeal : 1 +unsigned age_rate : 8 +unsigned element : 8 +unsigned lde : 3 +float hunger +/* entitys of size 1 or -2 cannot use armor. + * entitys of larger size automaticly win grapples. + * entitys of 2 sizes smaller can be picked up and thrown. + * entitys of size 1 can instakill entitys of size -2. squish. + * size 1: dragon, size 0: human, size -1: dwarf, size -2: pixie + */ + +struct aggrotyp: +bool unhinged : 1 +unsigned patience : 3 +unsigned ai_type : 4 +unsigned anger : 8 + +struct enttyp: +(self) *prev +(self) *next +npctyp * depth +agetyp age +classtyp class +uchar element +aggrotyp aggro +struct shiftstackobj race +ucoord3 pos +selftyp etc +struct movecount move +paffectyp paffect +effectyp effect +uint16_t hp +uint16_t mp +uint32_t xp +uchar lvl +float wallet +spellistele *spell_ptr +cantriplistele *cant_ptr +helditemtyp loot +helditemtyp helm +helditemtyp shield +helditemtyp bow +helditemtyp armor +helditemtyp cape +helditemtyp amul +unsigned n_arms : 4 +unsigned n_legs : 4 +armtyp * arms +legtyp * legs + +struct npctyp { +(self) *prev +(self) *next +ucoord3 * path +char * describe +uchar lang +char **lines[9]; //accessor: (lines[n])[m] +} +/* npc data is controlled by events, and is stored by room or in + * global space. more complex actors, such as shopkeepers, + * should be events. + */ + + +struct spawntyp: +npctyp * depth +classtyp class +uchar element +aggrotyp aggro +struct shiftstackobj race +paffectyp paffect +effectyp effect +helditemtyp loot +helditemtyp helm +helditemtyp shield +helditemtyp bow +helditemtyp armor +helditemtyp cape +helditemtyp amul +unsigned n_arms : 4 +unsigned n_legs : 4 +armtyp * arms +legtyp * legs + +struct helditemtyp { +masteritemptr itemid; +uuid_t uuid; //the null uuid for no extended metadata +extendedmetadata * data; //the null pointer for no extended metadata +} + +struct bagitemtyp: +(self) *prev +(self) *next +masteritemptr itemid; +extendedmetadata * data; + +struct langlistele { +(self) * prev +(self) * next +struct conlangtyp data +} + +struct spellistele { +(self) * prev +(self) * next +spelltyp this +} + +struct cantriplistele { +(self) * prev +(self) * next +cantriptyp this +} + +/*replace +struct subobjtyp: +intptr_t itemid : 8 +bool cursed : 1 +bool oxide : 1 +bool burned : 1 +signed bonus : 5 +intptr_t metadata : 8 //secondary _8bitPtr for legendary objects +*/ + +struct magictyp: +bool fire : 1 +bool air : 1 +bool water : 1 +bool earth : 1 +unsigned lde : 3 +bool planer : 1 + +struct shiftstackobj { +bool topdeck : 1; //does every shift change base[0]? +bool lycan : 1; //is base[1] valid? +bool swap : 1 //base[swap] +signed depth : 5; //on overflow, the stack is freed an topdeck is set +struct racetyp base[2]; +struct shiftstackele * poly; //unless this is NULL, this overrides base[] +struct shiftertyp alters; +} + +struct shiftstackele { +struct shiftstackele * prev; +unsigned polytimer : 8; //time remaining in the current polymorph. +intptr_t race : 8; +intptr_t table : 4; +unsigned meta : 4; +}/* polymorphing to the same form twice causes your active base form to change. + * some ways of aquireing multi-form abilities may place restrictions on what your second form may be. + */ + +struct altertimertyp { + signed n : 5; //permenant on overflow + bool q : 1; + char : 0; + unsigned t : 8; + } + +struct altertimerwtyp { + signed n : 5; //permenant on overflow + bool q : 1; + unsigned w_typ : 2; + bool w_sgn : 1; + unsigned t : 7; + } + +struct shiftertyp { +struct altertimertyp gills; //using an alteration spell, including intrensics from polymorph spells, 10 times will make them permenent. +struct altertimertyp lungs; //these counters can be reset by rest or spells +struct altertimerwtyp wings; +struct altertimertyp tail; +struct altertimertyp claws; +struct altertimertyp fangs; +struct altertimertyp talons; +}/* non-player, non-follower entitys do not have this field, + * and any polymorph or alteration is permenent. this may be + * changed in future if memory footprint allows. + */ + +struct cantriptyp { +funcptr spell; +diceodds odds; +uchar prof; +char cost_typ : 2 //0 = at will, 1 = gold, -1 = mp, -2 = hp +unsigned cost_amnt : 6 +} + +struct spelltyp { +basespelltyp * spell; +diceodds odds; +uchar prof; +char cost_typ : 2 //0 = at will, 1 = gold, -1 = mp, -2 = hp +unsigned cost_amnt : 6 +} + +typedef int (*funcptr)(); +typedef int (*funcptr_1arg)(intptr_t); +typedef int (*funcptr_2arg)(intptr_t,intptr_t); +typedef int (*funcptr_3arg)(intptr_t,intptr_t,intptr_t); +typedef int (*funcptr_4arg)(intptr_t,intptr_t,intptr_t,intptr_t); +typedef int (*funcptr_multi)(uint,intptr_t*); +typedef int (*eventcleanup)(eventdatastack_ele,bool); + +struct trampolinestackele { +struct trampolinestackele * prev; +funcptr exec; +} + +struct passiveffectlistele { +struct passiveffectlistele * prev; +struct passiveffectlistele * next; +funcptr whenthis; +funcptr dothis; +funcptr undothis; +intptr_t statedata; +} + +struct basespelltyp: +unsigned lvl : 6 +char : 0 +magictyp type +potiontyp effect +missiletyp delivery + +struct missiletyp { +bool vamp : 1 +unsigned damage : 7 +signed recoil : 8 +float range; +float spread; +float splash; +} + +struct baseweaptyp: +bool fire : 1 +bool air : 1 +bool water : 1 +bool earth : 1 +bool entro : 1 +bool light : 1 +bool dark : 1 +bool fireproof : 1 +bool waterproof : 1 +bool elecproof : 1 +bool iceproof : 1 +bool warded : 1 +bool illum : 1 +unsigned skill : 3 +unsigned damage : 8 + +legendtyp: +paffectyp magic +symtableref base +symtableref spell +legendflagtyp flags + +legendflagtyp: +bool fire : 1 +bool air : 1 +bool water : 1 +bool earth : 1 +bool entro : 1 +bool light : 1 +bool dark : 1 +bool fireproof : 1 +bool waterproof : 1 +bool elecproof : 1 +bool iceproof : 1 +bool warded : 1 +bool unbreak : 1 +bool infinate : 1 +bool spelled : 1 +bool vamp : 1 +bool drain : 1 +bool interest : 1 +bool useless : 1 +unsigned powermag : 5 + +struct basearmortyp: +effectyp effect +uchar def +uchar spdef +uchar extfort + +struct baseshldtyp: +bool fireproof : 1 +bool waterproof : 1 +bool elecproof : 1 +bool iceproof : 1 +bool reflect : 1 +bool entro : 1 +bool light : 1 +bool dark : 1 +effectyp effect +unsigned def : 8 +unsigned spdef : 8 + +struct bodytyp { +bool gills : 1; //affects breathing underwater +bool wings : 1; //affects flying +bool tail : 1; //affects unarmed attacks, swimming, flying +bool claws : 1; //affects unarmed attacks, writing +bool hoof : 1; //affects walking, swimming, unarmed attacks +bool talon : 1; //affects walking, swimming, unarmed attacks +bool fangs : 1; //affects unarmed attacks +bool legs : 1; //affects walking, swimming, unarmed attacks +bool arms : 1; //affects walking, swimming, unarmed attacks, writing +bool nolungs : 1; //affects breathing above water +bool noswim : 1; //affects swimming +bool nofly : 1; +bool atktail : 1; //affects unarmed attacks, swimming, flying +bool atkwing : 1; //affects unarmed attacks, swimming, flying +bool bite : 1; +bool breath : 1; +bool engulf : 1; +bool permwings : 1; +bool wingsign : 1; +unsigned wingtype : 2; +char : 0; +} + +struct stattyp { +unsigned dizzy : 3; +unsigned psn : 4; +unsigned prlz : 4; +unsigned frz : 4; +unsigned brn : 4; +signed stone : 8; //inverse one's complement; 0x00 is inactive (-0), 0xFF is dead (+0). overflows can be used to extend time to live +signed slime : 8; //inverse one's complement +unsigned slp : 8; +unsigned invis : 6; +unsigned blind : 8; +signed eaten : 7; //inverse one's complement +} + +struct elixtyp: +dizzy : 1 +psn : 1 +prlz : 1 +frz : 1 +brn : 1 +stone : 1 +slp : 1 +invis : 1 + +struct cursetyp: +stattyp type +uchar polytimer +intptr_t poly : 8 + +struct resistyp: +bool fireproof : 1 +bool waterproof : 1 +bool elecproof : 1 +bool iceproof : 1 +bool stoneproof : 1 +bool polyproof : 1 +bool sleepproof : 1 +bool poisonproof : 1 + +struct sensetyp: +bool trouble : 1 +bool invis : 1 +bool infra : 1 +bool blind : 1 +bool good : 1 +bool evil : 1 +bool law : 1 +bool chaos : 1 + +struct effectyp: +the8stats eight +bodytyp shape +stattyp stat +resistyp resist +sensetyp sense +skilltyp skill +char atk +char spatk +char def +char spdef + +struct paffectyp: +the8stats eight +bodytyp shape +elixtyp ails_ya +resistyp resist +sensetyp sense +skilltyp skill +venomtyp venom +char atk +char spatk +char def +char spdef + +struct potiontyp: +bodytyp shape +elixtyp ails_ya +cursetyp curse +resistyp resist +sensetyp sense +uint16_t hp +uint16_t mp +diceodds odds + +struct skilltyp { +unsigned sword : 4; //+skill to sword-type weapon attack +unsigned knife : 4; //+skill to knife-type weapon attack +unsigned stave : 4; //+skill to stave-type weapon attack +unsigned spear : 4; //+skill to spear-type weapon attack +unsigned whip : 4; //+skill to whip-type weapon range (unused range added to attack) +unsigned club : 4; //+skill to club-type weapon attack +unsigned bow : 4; //+(2 * skill) to bow-type weapon range +unsigned throw : 4; //+(2 * skill) to javalin-type weapon range +unsigned monk : 4; //+(2*skill) to unarmed attack, unlocks more modes of attack. +unsigned shield : 4; //skill in (damage-defense)+abs(damage-defense) chance of blocking +unsigned locks : 4; //1 in 2^(lock.level - (skill)) chance of picking +unsigned caster : 6; //-(skill-1)/4 to casting cost, +(skill-1)/4 to spatk and spdef, unlocks spells, 0 is non-caster +bool swim : 1; //may be lost by polymorphing to a form with different locomotion. +bool walk : 1; //may be lost by polymorphing to a form with different locomotion. +unsigned fly : 2; //0 = never had wings, 1 = slow falling, 2 = cannot gain altitude, 3 = free flight. lvl1 learned by falling +bool sink : 1; //overrides any swim or fly skills +bool magnetic : 1; +} +/* damage = MAX( incoming-defense , 0 ) + * + * polyshock = base.hplvl - ((poly.hplvl * (util__roll(1,20,1) / 20)) * util__roll(1,3,0)) + * ⎧if n < -HPMAX : Instakill (deathmessage: miscalculated a crucial equivilant-exchange parameter,hath choose...poorly) + * ⎪if n = -HPMAX : Stoning + * ⎨if -HPMAX < n < 0 : abs(n) Damage (deathmessage: could not withstand the cost of transmutation) + * ⎪if n = 0 : stun for 1D16 (standardmessage: your mind reels from the transformation...) + * ⎩if n > 0 : success + * + * writing = + * succeed if 4D6 < dex if !talons, break pen on fail if 1D20 < stren + * succeed if 6D6 < dex if talons, break pen on fail if coinflip + * talons can engrave without tools + */ + +readtyp: +unsigned locale : 6 +bool multiuse : 1 +bool scroll : 1 +unsigned subject : 2 //0 = cooking, 1 = weapons, 2 = language, 3 = spellcraft +unsigned uses : 6 +void* contents + +wandtyp: +unsigned matter : 4 +unsigned uses : 4 +intptr_t bound : 8 + +baubtype : +signed type : 2 //0=ring, 1=bracelet, -1=amulet, -2=tiara +unsigned matter : 3 +unsigned color : 3 +paffectyp enchnt + +struct roomneighbors { +ucoord4 north +ucoord4 south +ucoord4 east +ucoord4 west +ucoord4 up +ucoord4 down +uint16_t northsub +uint16_t southsub +uint16_t eastsub +uint16_t westsub +uint16_t upsub +uint16_t downsub +} + +struct chunktyp { +char * tiledata[CHUNK][CHUNK][CHUNK] +shadowmask * seen +shadowmask * light +shadowmask * collimap //entity collision mask +} + +#define roomsizeindex(T,Z,Y,X) (\ +(Z + Y + X) < (T->size.w + T->size.z + 1) ?\ +(\ +(Z * (T->size.w + T->size.y + 1)) +\ +(Y * (T->size.w + T->size.x + 1)) +\ +X) :\ +raise(SIGSEGV)\) + +struct roomtyp: +ucoord4 globpos +struct planetyp plane +Vector3 latlon //reported as the latitude, longitude, and elevation of the current room. NaN may be helpful. +intptr_t area : 16 //the name of the area from a table of names +intptr_t hightiles : 8 //dispatch table key +struct chunktyp * chunks +struct microvector size //field w is added to all fields, other fields bias +1 +encontyp * encon_ptr +enttyp * ent_ptr +eventtyp * ev_ptr +mapobjtyp * obj_ptr +ray_vfx_typ * ray_ptr +lightyp * light_ptr +setcoord3 * path_ptr +ucoord2 downstair +ucoord2 upstair +ucoord3 home +char filltile +bool visited : 1 +unsigned meta : 7 +bool upstair : 1 +bool downstair : 1 +bool show_north : 1 +bool show_south : 1 +bool show_east : 1 +bool show_west : 1 +bool show_up : 1 +bool show_down : 1 +struct roomneighbors neighborhood +/* if invalid coords are given for a warp (typically {$FF,$FF}), + * then the player is dumped at the location indicated by home. + * + * if the player has invalid coords, then the error string "fell out of terminal",N1=x,N2=y is generated. + */ + +/* the world of the game will be referred to using two different grids of + * discreet coordinates. the primary grid is the cell space, which is + * interleaved octohedrally with the boundry space, such that if a given + * diminsion in cell space has n points, the same dimension in boundry + * space has n+1 points. the cell space referes to the cells that are + * displayed (the "cells"), while the boundry space referes to their + * boundries. exact boundry space coordinates are not expected to be used; + * only planes and polytopes are meaningful in boundry space. + * + * some notable uses of boundry space are in describing the emulated + * cull plane of the "camera", and as the boundries of a given room. + */ + +typedef uint32_t shadowmask[CHUNK][CHUNK] +typedef tilemeta tileset[128] + +struct tilemeta { +bool ladder : 1 +bool solid : 1 +bool liquid : 1 +bool conductive : 1 +bool burns : 1 +bool hypotherm : 1 +bool sharp : 1 +bool entropy : 1 + +bool shiney : 1 +bool slip : 1 +signed speed : 2 + +bool freezes : 1 +bool melts : 1 +bool petrif : 1 + +bool dig : 1 +bool fence : 1 + +intptr_t freeze : 8 +intptr_t melt : 8 +intptr_t stone : 8 +unsigned density + +bool blink : 1 +unsigned color : 6 + +Mesh * shape +Texture2D * texture +} +/* tiles can be effected by stuff happening around them. + * + * if a tile is flammable, a fire is summoned when fire magic + * enters the space or 1d6 chance if there is fire within 1 taxicab of it. + * + * if a tile is conductive, then electricity is summoned for the instant + * that electrical magic strikes it, and propagates through contiguous tiles. + * + * if a tile can freeze, it's _8BITPTR is changed to the number indicated by ice. + * when ice magic intersects it. + * + * if a tile can melt, it's _8bitPtr is changed to the number indicated by melt + * when fire or electrical magic intersect it. + * + * if a tile can be petrified, it is changed to the tile indicated by stone. + * + * if a tile can be dug, using a ↧digging tool on it will remove it + * digging something triggers updates which cause gravity to affect gases (!liquid,!solid), + * liquids(+liquid,!solid), and granulars(+liquid,+solid), wherin less dense + * tiles will swap with more dense ones. this effect travels outwards, to the edge of the room, + * but will not be applied to the border tiles. in the default set, water has a density of 10, snow + * has a density of -1, and air has a density of -100. + */ + +mapobjflags: +bool hidden : 1 +bool moves : 1 +bool rclass : 1 +unsigned class : 4 +unsigned alignment : 9 + +struct mapobjtyp: +(self) *prev +(self) *next +uuid_t uuid +ucoord3 pos +masteritemptr itemid; +extendedmetadata * data; +mapobjflags flags + +struct signtyp { +Mesh * shape +Texture2D * texture +conlangtyp lang +char* lines +char* gibber +} + +struct chestyp: +heldobjtyp *bag_ptr +cursetyp curse +locktype locked + +struct doortyp { +bool open : 1 +unsigned hp : 7 +locktype lock : 8 + +struct locktype { +unsigned level : 4; +bool locked : 1; +unsigned pins : 7; +trapflag flags; +} +/* lockpicking requires the player to enter + * 0 and + in the correct order to turn the + * tumblers. in addition to making the correct + * guess, one must make a skill check: + * 1 in 2^(lock.level - (skill/2)) chance + * + * lockpicking will play an ascending chromatic + * scale on a loop, starting on C3 and ending + * at G3, on synthbass (triangle wave) + */ + +struct encontyp { +(self) *prev +(self) *next +uuid_t uuid +uchar tobeat //of 10D20 +spawntyp spawn + +struct masteritemptr { +intptr_t id : 16; +unsigned meta : 8; +unsigned n : 8; +} + +struct extendedmetadata { +char * name; +void * data; +} + +struct masteritemlistentry { +objid type +void * data +} + +typedef struct masteritemlistentry *(*(*(*(const * masteritemlist)[16])[16])[16])[16]; +//array of 16 pointers to arrays of 16 pointers to arrays of 16 pointers to arrays of 16 pointers to string-like arrays + +struct toolsublistyp { +struct toolsublistyp * prev; //the previous tools block +struct toolsublistyp * next; //the next tools block +uint16_t first; +uint16_t last; +unsigned n; +funcptr * funcs; +} + +/*to be replaced +struct miscitembasetyp: +bool key : 1 +bool pick : 1 +bool dig : 1 +bool music : 1 +bool light : 1 +bool book : 1 +bool spark : 1 +bool quest : 1 +bool fireproof : 1 +bool waterproof : 1 +bool elecproof : 1 +bool iceproof : 1 +bool stoneproof : 1 +bool arrow : 1 +bool poisoned : 1 +bool unbreak : 1 +unsigned uses : 8 +intptr_t metadata : 8 +*/ + +struct eventdatastack_uuidptr { +uuid_t uuid; +void * ptr; +} + +struct eventdatastack_top { +struct eventdatastack_top * prev; +struct eventdatastack_top * next; +struct eventdatastack_sub * this; +struct eventdatastacl_uuidptr * up; //what events depend on this one +uuid_t uuid; +unsigned cleanup[2]; //keys to a dispatch table +} + +struct eventdatastack_sub { +(self)* prev; +(self)* next; +uuid_t uuid; +void * data; +size_t length; +} + +union hitboxuni { +BoundingBox square +struct sphere +Vector3 geom +Ray ray +} + +struct hitboxtyp { +union hitboxuni +uchar type +} + +struct eventtyp: +(self) *prev +(self) *next +ucoord3 pos +uuid_t uuid +unsigned hours : 24 +int (*dothis)(intptr_t,intptr_t,intptr_t,intptr_t) +bool interact : 1 +bool look : 1 +unsigned duration : 15 +unsigned remduration : 15 +Mesh * shape +Texture2D * texture + +struct triggertyp { +triggerenum key : 4 +unsigned value : 4 +} + +struct qglobev { //queued global event. can be modifications to distant rooms, or stuff like cutscenes. +(self) *prev; +(self) *next; +uuid_t parent; +ucoord4 globpos; +funcptr dothis; +bool pres; //whether to act as soon as the room is on the stack, or if the player must be present +} + +struct traptyp: +Mesh * shape +Texture2D * texture +uint16_t duration +magictyp element +stattyp stat +cursetyp curse +diceodds odds +trapflags flags +sensetyp sense +int16_t hp +int16_t mp + +struct trapflags: +bool fireproof : 1 +bool waterproof : 1 +bool elecproof : 1 +bool iceproof : 1 +bool tamperproof : 1 +bool stoneproof : 1 +bool warded : 1 +unsigned attack_alignments : 9 +bool multiuse : 1 +bool magic : 1 //whether the trap is a mechanism or a rune +unsigned color : 6 + +struct subwarptyp { +bool perm : 1 +bool blink : 1 +unsigned color : 6 +ucoord3 pos +ucoord3 dest +int16_t duration //negative are uses, positive are turns +} + +struct warptyp: +bool perm : 1 +bool blink : 1 +unsigned color : 6 +ucoord4 glob_loc +ucoord3 pos +ucoord4 glob_dest +ucoord3 dest +int16_t duration + +struct gemstonetyp: +unsigned color : 5 +unsigned cut : 3 +unsigned quality : 8 + +/* to be replaced +struct meattyp: +struct racetyp race +uchar sellby +uchar amount + +struct foodtyp: +intptr_t itemid : 8 +intptr_t metadata : 8 +unsigned sellby : 8 +unsigned amount : 8 + +foodbasetyp: +effectyp effect +diceodds odds +uchar keepsfor //0 means non-perishable +uchar hp +uchar nutri +*/ + +/* rework be a type enum for unified object table +enum objid: +WEAPON_FLAG : contains subobjtyp calling baseweaptyp +LEGEND_FLAG : contains subobjtyp calling baseweaptyp +POTION_FLAG : contains potiontyp +READ_FLAG : contains readtyp +FOOD_FLAG : contains subobjtyp containing foodtyp +MEAT_FLAG : contains subobjtyp containing meattyp +ARMOR_FLAG : contains subobjtyp calling basearmortyp +SHLD_FLAG : contains subobjtyp calling baseshldtyp +BAUB_FLAG : contains subobjtyp calling baubtyp +CONLANG_FLAG : contains conlangtyp +MISC_FLAG : contains ptrchar or ptrshort +GEM_FLAG : contains gemstonetyp +TRAP_FLAG : contains traptyp +WARP_FLAG : contains warptyp +SUBWARP_FLAG : contains subwarptyp +CHEST_FLAG : contains chestyp +DOOR_FLAG : contains doortyp +LOCK_FLAG : contains locktyp (gates are this) +MONEY_FLAG : contains float +SPAWN_FLAG : contains spawntyp +SIGN_FLAG : contains signtyp +*/ + +#endif diff --git a/src/plugin.cc b/src/incomplete/mothballedORreference/plugin.cc similarity index 66% rename from src/plugin.cc rename to src/incomplete/mothballedORreference/plugin.cc index 37a4a31..e2e7baa 100644 --- a/src/plugin.cc +++ b/src/incomplete/mothballedORreference/plugin.cc @@ -2,30 +2,33 @@ #include #include "CONFIG.DEF" +#include "atomic_mutex.h" -extern "C" typedef int (*subroutine)(size_t,void*); +#ifndef __IWF_HAS_DLFUNC__ +#include "dlfunc_shim.inl" +#endif class iwf::plugintable { std::map data; - iwf::strangemutex mutex; + atomic_mutex mutex; public: bool loadplugin (std::string key,void * handle) { - this->mutex.lockw(); + atomic_mutex$$lock(this->mutex); if (exists(&PLUGIN_TABLE,key) { dlclose(PLUGIN_TABLE[key]); } this->data[key] = handle; - this->mutex.unlockw(); + atomic_mutex$$unlock(this->mutex); return 1; } bool cloadplugin (char * name,void * handle) { std::string key = name; - this->mutex.lockw(); + atomic_mutex$$lock(this->mutex); if (exists(&PLUGIN_TABLE,key) { dlclose(PLUGIN_TABLE[key]); } this->data[key] = handle; - this->mutex.unlockw(); + atomic_mutex$$unlock(this->mutex); return 1; } bool loadpluginfile (char * path) { @@ -35,7 +38,7 @@ class iwf::plugintable { return false; } else if (path[0] == '/') { handle = dlopen(path,RTLD_NOW | RTLD_PRIVATE); - } else if (path[0] < ' ') { + } else if (path[0] < 034) { fprintf(stderr,"refusing to load plugin: %s is not a valid filename",path); return false; } else { @@ -51,31 +54,35 @@ class iwf::plugintable { std::string key = basename(path); return this->loadplugin(key,handle); } - subroutine getsub (std::string key,char * symbol) { - this->mutex.lockr(); + dlfunc_t getf (std::string key,char * symbol) { + atomic_mutex$$increment(this->mutex); void * handle; try { handle = PLUGIN_TABLE.at(key); } catch (std::out_of_range) { + atomic_mutex$$decrement(this->mutex); fprintf(stderr,"cannot find :%s;%s",module,symbol); return NULL; } - subroutine symptr = dlsym(handle,symbol); + atomic_mutex$$decrement(this->mutex); + dlfunc_t symptr = dlfunc(handle,symbol); if (symptr == NULL) { fprintf(stderr,"%s\n",dlerror()); return NULL; } return symptr; } - void * getvar (std::string key,char * symbol) { - this->mutex.lockr(); + void * getsym (std::string key,char * symbol) { + atomic_mutex$$increment(this->mutex); void * handle; try { handle = PLUGIN_TABLE.at(key); } catch (std::out_of_range) { + atomic_mutex$$decrement(this->mutex); fprintf(stderr,"cannot find :%s;%s",module,symbol); return NULL; } + atomic_mutex$$decrement(this->mutex); void * symptr = dlsym(handle,symbol); if (symptr == NULL) { fprintf(stderr,"%s\n",dlerror()); @@ -87,41 +94,29 @@ class iwf::plugintable { extern "C" { -void * iwf__plugintable__new () { +void * iwf$$plugintable$$new () { return new iwf::plugintable; } -void iwf__plugintable__del (void * deadbeef) { +void iwf$$plugintable$$del (void * deadbeef) { delete deadbeef; } -IMPLICIT iwf__plugintable__load (void * self,char * name,void * handle) { +IMPLICIT iwf$$plugintable$$load (void * self,char * name,void * handle) { return -!( ((iwf::plugintable*)self)->cloadplugin(name,handle) ); } -IMPLICIT iwf__plugintable__loadfile (void * self,char * name) { +IMPLICIT iwf$$plugintable$$loadfile (void * self,char * name) { return -!( ((iwf::plugintable*)self)->loadplugin(name) ); } -subroutine iwf__plugintable__getsub (void * self,char * name,char * symbol) { +dlfunc_t iwf$$plugintable$$getf (void * self,char * name,char * symbol) { std::string key = name; - return ((iwf::plugintable*)self)->getsub(key,symbol); + return ((iwf::plugintable*)self)->getf(key,symbol); } -void * iwf__plugintable__getvar (void * self,char * name,char * symbol) { +void * iwf$$plugintable$$getsym (void * self,char * name,char * symbol) { std::string key = name; return ((iwf::plugintable*)self)->getsub(key,symbol); } - -struct dlsub_t { - char * module; - char * symbol; - subroutine loaded_at; - } - -struct dlvar_t { - char * module; - char * symbol; - void * loaded_at; - } } diff --git a/src/plugin.cclass b/src/incomplete/mothballedORreference/plugin.cclass similarity index 75% rename from src/plugin.cclass rename to src/incomplete/mothballedORreference/plugin.cclass index 09a3c42..4b449d6 100644 --- a/src/plugin.cclass +++ b/src/incomplete/mothballedORreference/plugin.cclass @@ -9,6 +9,6 @@ extern class iwf::plugintable { bool loadplugin (std::string key,void * handle); bool cloadplugin (char * name,void * handle); bool loadpluginfile (char * path); - subroutine getsub (std::string key,char * symbol); - void * getsub (std::string key,char * symbol); + dlfunc_t getf (std::string key,char * symbol); + void * getsym (std::string key,char * symbol); } diff --git a/src/incomplete/mothballedORreference/plugin.h b/src/incomplete/mothballedORreference/plugin.h new file mode 100644 index 0000000..e1148a6 --- /dev/null +++ b/src/incomplete/mothballedORreference/plugin.h @@ -0,0 +1,41 @@ +#ifndef __cplusplus +#include +#include +#else +#include +#endif + +#include "cppkeyword.def" + +#ifndef __IWF_HAS_DLFUNC__ +#include "dlfunc_shim.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +extern void * iwf$$plugintable$$new (); +extern void iwf$$plugintable$$del (void * deadbeef); +extern IMPLICIT iwf$$plugintable$$load (void * self,char * name,void * handle); +extern IMPLICIT iwf$$plugintable$$loadfile (void * self,char * name); +extern dlfunc_t iwf$$plugintable$$getf (void * self,char * name,char * symbol); +extern void * iwf$$plugintable$$getsym (void * self,char * name,char * symbol); + +struct iwf$$types$$dlfunc_fastref { + char * module; + char * symbol; + dlfunc_t loaded_at; + } + +struct iwf$$types$$dlsym_fastref { + char * module; + char * symbol; + void * loaded_at; + } + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/unused/pure_c_shared_mutex.c b/src/incomplete/mothballedORreference/pure_c_shared_mutex.c similarity index 100% rename from src/unused/pure_c_shared_mutex.c rename to src/incomplete/mothballedORreference/pure_c_shared_mutex.c diff --git a/src/incomplete/renderstack.c b/src/incomplete/mothballedORreference/renderstack.c similarity index 100% rename from src/incomplete/renderstack.c rename to src/incomplete/mothballedORreference/renderstack.c diff --git a/src/incomplete/savefileio.cc b/src/incomplete/mothballedORreference/savefileio.cc similarity index 100% rename from src/incomplete/savefileio.cc rename to src/incomplete/mothballedORreference/savefileio.cc diff --git a/src/unused/scalar.c b/src/incomplete/mothballedORreference/scalar.c similarity index 100% rename from src/unused/scalar.c rename to src/incomplete/mothballedORreference/scalar.c diff --git a/src/incomplete/strangemutex.cc b/src/incomplete/mothballedORreference/strangemutex.cc similarity index 100% rename from src/incomplete/strangemutex.cc rename to src/incomplete/mothballedORreference/strangemutex.cc diff --git a/src/unused/templates/README.md b/src/incomplete/mothballedORreference/templates/README.md similarity index 100% rename from src/unused/templates/README.md rename to src/incomplete/mothballedORreference/templates/README.md diff --git a/src/unused/templates/cuckootree.c b/src/incomplete/mothballedORreference/templates/cuckootree.c similarity index 100% rename from src/unused/templates/cuckootree.c rename to src/incomplete/mothballedORreference/templates/cuckootree.c diff --git a/src/unused/templates/evheap.c b/src/incomplete/mothballedORreference/templates/evheap.c similarity index 100% rename from src/unused/templates/evheap.c rename to src/incomplete/mothballedORreference/templates/evheap.c diff --git a/src/incomplete/texturetree.c b/src/incomplete/mothballedORreference/texturetree.c similarity index 100% rename from src/incomplete/texturetree.c rename to src/incomplete/mothballedORreference/texturetree.c diff --git a/src/incomplete/tmp.cnode b/src/incomplete/mothballedORreference/tmp.cnode similarity index 100% rename from src/incomplete/tmp.cnode rename to src/incomplete/mothballedORreference/tmp.cnode diff --git a/src/uuidtypes.def b/src/incomplete/mothballedORreference/uuidtypes.def similarity index 100% rename from src/uuidtypes.def rename to src/incomplete/mothballedORreference/uuidtypes.def diff --git a/src/unused/wrapper___std___shared_mutex.cc b/src/incomplete/mothballedORreference/wrapper___std___shared_mutex.cc similarity index 100% rename from src/unused/wrapper___std___shared_mutex.cc rename to src/incomplete/mothballedORreference/wrapper___std___shared_mutex.cc diff --git a/src/incomplete/sandbox/as_moduleglue.cc b/src/incomplete/sandbox/as_moduleglue.cc new file mode 100644 index 0000000..c57b0d8 --- /dev/null +++ b/src/incomplete/sandbox/as_moduleglue.cc @@ -0,0 +1,117 @@ +extern asIScriptEngine * ASENGINE; +extern asIScriptContext * ASLOADERCTX; +extern volatile atomic_bool * ASLOADERMUTEX; +extern std::map LOADED_ASMODULES; +extern std::map LOADED_DLOBJECTS; +extern std::map> DEPENDANCIES; + +iwf::runtime::asloadmodule (std::string name) { + int errno_as; + asIScriptModule nova = ASENGINE->GetModule(name.c_str()); + if (nova == NULL) { + nova = ASENGINE->GetModule(name.c_str(),asGM_ALWAYS_CREATE); + std::string path; + if (name[0] > ' ') { + fprintf(stderr,"not a valid module name: %s\n",name); + return -1; + } else if (name[0] == '/') { + path = name; + } else { + path = CONFIG_DEFAULT_ASMODULE_PATH; + path.append(name); + } + std::string code = slurpfile(path); + errno_as = nova.AddScriptSection(name.c_str(),code.c_str(),code.length()); + assert (errno_as >= 0); + errno_as = nova.Build(); + assert (errno_as >= 0); + errno_as = nova.BindAllImportedFunctions(); + assert (errno_as >= 0); + } + asIScriptFunction * loader = nova.GetFunctionByDecl("INIT"); + atomic_bool$$lock(ASLOADERMUTEX) + ASLOADERCTX->Prepare(loader); + ASLOADERCTX->Execute(); + *ASLOADERMUTEX = 0; + LOADED_ASMODULES[name]++; + return 0; + } + +void iwf::runtime::asunloadmodule (std::string name) { + LOADED_ASMODULES[name]--; + if (!(LOADED_ASMODULES[name])) { + asIScriptFunction * unloader = ASENGINE->GetModule(name.c_str)->GetFunctionByDecl("HIDE"); + atomic_bool$$lock(ASLOADERMUTEX) + ASLOADERCTX->Prepare(unloader) + ASLOADERCTX->Execute(); + *ASLOADERMUTEX = 0; + }} + +iwf::runtime::cloadmodule (std::string name) { + dlerror(); + std::string path; + if (name[0] > ' ') { + fprintf(stderr,"not a valid module name: %s\n",name); + return -1; + } else if (name[0] == '/') { + path = name; + } else { + path = CONFIG_DEFAULT_LIB_PATH; + path.append(name); + } + void * tmp = dlopen(path.c_str(),DL_NOW); + char * err = dlerror(); + if (err != NULL) { + fputs(err,stderr); + exit(1); + } + LOADED_DLOBJECTS[name] = tmp; + } + +void iwf$$dependancymanager$$add (void * adhoc,std::string nova) { + DEPENDANCIES[X].insert(Y); + } + +void iwf$$dependacnymanager$$drop (void * adhoc,std::string dead) { + try { + DEPENDANCIES[adhoc].find(dead).erase(); + } catch (std::out_of_bounds) { + }} + +void iwf$$dependancymanager$$load (void * adhoc,std::string basepath) { + { + std::string cpath = basepath; + cpath.append("c_depends") + std::vector tmp = slurpstrings(cpath); + while (tmp.size() > 0) { + DEPENDANCIES[adhoc].first.insert(tmp.back()); + iwf::runtime::cloadmodule(tmp.back()); + tmp.pop_back(); + }} + { + std::string aspath = basepath; + aspath.append("as_depends") + std::vector tmp = slurpstrings(aspath); + while (tmp.size() > 0) { + DEPENDANCIES[adhoc].second.insert(tmp.back()); + iwf::runtime::asloadmodule(tmp.back()); + tmp.pop_back(); + }}} + +void iwf$$dependancymanager$$save (void * adhoc,std::string path) { + path.append("depends"); + std.string backuppath = path; + backuppath.append(".old"); + fclose(fopen(backuppath.c_str(),"w")); + std::fstream backup; + backup.open(backuppath,std::ios_base::out); + backup << slurpfile(path); + fclose(fopen(path.c_str(),"w")); + std::fstream output; + output.open(path,std::ios_base::in); + for (std::set::iterator i = + DEPENDANCIES[adhoc].begin();i != DEPENDANCIES[adhoc].end();i++) { + output << *i + << "\n"; + } + } diff --git a/src/incomplete/build.sh b/src/incomplete/sandbox/build.sh similarity index 100% rename from src/incomplete/build.sh rename to src/incomplete/sandbox/build.sh diff --git a/src/incomplete/sandbox/commandline.hh b/src/incomplete/sandbox/commandline.hh new file mode 100644 index 0000000..10a61cc --- /dev/null +++ b/src/incomplete/sandbox/commandline.hh @@ -0,0 +1,46 @@ +typedef int (*subroutine)(std::vector); +typedef int (*assignfptr)(void*); +typedef int (*alterfptr)(void*); +typedef int (*accessfptr)(void); + +struct IWFType { + accessfptr accessor; + assignfptr assignment; + alterfptr toggle; + assignfptr add; + assignfptr subtract; + alterfptr increment; + alterfptr decrement; + }; + +struct IWFVariable { + IWFType * type; + void * data; + }; + +struct IWFRecord { + std::map links; + std::map fields; + }; + +struct IWFInterface; + +struct IWFInstance { + std::map * type; + std::map objfields; + std::map fields; + }; + +struct IWFInterface { + std::map methods; + std::map objproperties; + std::map properties; + }; + +struct IWFNamespace { + std::map subdir; + std::map databases; + std::map functions; + std::map objects; + std::map variables; + }; diff --git a/src/incomplete/sandbox/commandlinesyntax.txt b/src/incomplete/sandbox/commandlinesyntax.txt new file mode 100644 index 0000000..8a9f688 --- /dev/null +++ b/src/incomplete/sandbox/commandlinesyntax.txt @@ -0,0 +1,12 @@ +foo(bar,qux,zot) ... call a function + +foo=bar ... assign a value to a variable +!foo ... toggle a flag +foo+=bar ... add a value to a variable +foo-=bar ... subtract a value from a variable +foo++ ... increment a variable +foo-- ... decrement a variable + +foo/bar ... subdirectory bar in foo +foo[bar] ... access a field +foo{bar=baz,qux=zot} ... alter fields diff --git a/src/incomplete/iwf__graphics3d.cc b/src/incomplete/sandbox/iwf__graphics3d.cc similarity index 100% rename from src/incomplete/iwf__graphics3d.cc rename to src/incomplete/sandbox/iwf__graphics3d.cc diff --git a/src/incomplete/iwf__voxels__minichunk.cc b/src/incomplete/sandbox/iwf__voxels__minichunk.cc similarity index 100% rename from src/incomplete/iwf__voxels__minichunk.cc rename to src/incomplete/sandbox/iwf__voxels__minichunk.cc diff --git a/src/incomplete/sandbox/iwf_joystick.c b/src/incomplete/sandbox/iwf_joystick.c new file mode 100644 index 0000000..94c746e --- /dev/null +++ b/src/incomplete/sandbox/iwf_joystick.c @@ -0,0 +1,125 @@ +#define JS0 _IOR('j',0,struct js_event); + +#include + +extern volatile ATOMIC(bool) HALT; +extern volatile ATOMIC(bool) ERROR; +extern volatile ATOMIC(bool) CHANGE_JSDEV; + +std::vector iwf::joystick::buttons; +std::vector iwf::joystick::axes; + +#define MAPPED_BUTTONS_MAX 8 +#define MAPPED_AXES_MAX 11 + +unsigned char iwf$$iosettings$$buttonmap[MAPPED_BUTTONS_MAX]; +unsigned char iwf$$iosettings$$axismap[MAPPED_AXES_MAX]; +unsigned char iwf$$iosettings$$sensitivity; + +extern "C" { + +iwf$$joystickio (void * dummy) { + for (;!(HALT || ERROR);) { + if ((jsdev = open(iwf::iosettings::jsdevpath.c_str(),O_RDONLY | O_NONBLOCK)) < 0) { + HALT = 1; + ERROR = 1; + return 1; + } + { + unsigned char axes; + ioctrl(jsdev,JSIOCGAXES,&axes); + iwf::irq::axes.reserve(axes); + }{ + unsigned char buttons; + ioctrl(jsdev,JSIOCGBUTTONS,&buttons); + iwf::irq::axes.reserve(buttons); + } + js_event js; + while (!CHANGE_JSDEV) { + read(jsdev,&js,sizeof(struct js_event)); + switch (js.type) { + case JS_EVENT_BUTTON : + if ((js.number + 1) > iwf::irq::buttons.capacity()) { + iwf::irq::buttons.reserve(js.number + 1); + } + iwf::irq::buttons[js.number] = js.value; + break; + case JS_EVENT_AXIS : + if ((js.number + 1) > iwf::irq::axis.capacity()) { + iwf::irq::axis.reserve(js.number + 1); + } + iwf::irq::axis[js.number] = js.value & invbase1(int16_t,iwf$$iosettings$$sensitivity); + if (iwf::irq::axis[js.number] && iwf$$iosettings$$sensitivity) { + js.value | base1(iwf$$iosettings$$sensitivity); + }; + break; + default : break; + } + close(jsdev); + } + }} + +bool iwf$$joystick$$getbutton (unsigned char index) { + if (index < MAPPED_BUTTONS_MAX) { + return iwf::joystick::buttons[iwf$$iosettings$$buttonmap[index]]; + } else { + errno = EINVAL; + return 0; + }} + +int16_t iwf$$joystick$$getaxis (unsigned char index) { + if (index < MAPPED_AXES_MAX) { + return iwf::joystick::axes[iwf$$iosettings$$axismap[index]]; + } else { + errno = EINVAL; + return 0; + }} + +#define REMAP_X0 0 +#define REMAP_Y0 1 +#define REMAP_LT 2 +#define REMAP_X1 3 +#define REMAP_Y1 4 +#define REMAP_RT 5 +#define REMAP_XPAD 6 +#define REMAP_YPAD 7 + +#define REMAP_A 0 +#define REMAP_B 1 +#define REMAP_X 2 +#define REMAP_Y 3 +#define REMAP_LB 4 +#define REMAP_RB 5 +#define REMAP_BACK 6 +#define REMAP_START 7 +#define REMAP_BIGX 8 +#define REMAP_LSTICK 9 +#define REMAP_RSTICK 10 + +extern volatile ATOMIC(uint8_t) iwf$$settings$$desense; + +iwf$$buttonmap$$assign ( + + + + read(joystick,&event1,sizeof(event1)); + if (event1.type == 0x02) + { + values[event1.number] = event1.value; + } + } + while (*JSAXISFLAG == 0) + { + sleep(0); + } + *JSAXISFLAG = -1; + (*JSAXISBUFF)[0] = values[0]; + (*JSAXISBUFF)[1] = values[1]; + (*JSAXISBUFF)[2] = values[2]; + (*JSAXISBUFF)[3] = values[3]; + (*JSAXISBUFF)[4] = values[4]; + (*JSAXISBUFF)[5] = values[5]; + (*JSAXISBUFF)[6] = values[6]; + (*JSAXISBUFF)[7] = values[7]; + *JSAXISFLAG = 0; + } diff --git a/src/incomplete/keyswitch.inc b/src/incomplete/sandbox/keyswitch.inc similarity index 100% rename from src/incomplete/keyswitch.inc rename to src/incomplete/sandbox/keyswitch.inc diff --git a/src/incomplete/sandbox/main.cc b/src/incomplete/sandbox/main.cc new file mode 100644 index 0000000..2be7faf --- /dev/null +++ b/src/incomplete/sandbox/main.cc @@ -0,0 +1,16 @@ +#define macro_pthread_create(X,Y,Z) pthread_t X; pthread_create(&X,NULL,Y,Z) + +//init curses + +//init angelscript + +int main (int argc,char *argv[]) { + macro_pthread_create(iwf$$threadhandles$$joystick,iwf$$joystickio,NULL); + //asynchronous button minithreads + macro_pthread_create(iwf$$threadhandles$$commandline,iwf$$threads$$commandline,/*???*/); + //movement + //irrlicht thread + //load game file + //load room + //load chunk + //becomes event loop diff --git a/src/incomplete/memdump.pseudoc b/src/incomplete/sandbox/memdump.pseudoc similarity index 100% rename from src/incomplete/memdump.pseudoc rename to src/incomplete/sandbox/memdump.pseudoc diff --git a/src/incomplete/seedcrypt.cc b/src/incomplete/sandbox/seedcrypt.cc similarity index 100% rename from src/incomplete/seedcrypt.cc rename to src/incomplete/sandbox/seedcrypt.cc diff --git a/src/incomplete/seedcrypt.h b/src/incomplete/sandbox/seedcrypt.h similarity index 65% rename from src/incomplete/seedcrypt.h rename to src/incomplete/sandbox/seedcrypt.h index 99ac4f7..c9d5dab 100644 --- a/src/incomplete/seedcrypt.h +++ b/src/incomplete/sandbox/seedcrypt.h @@ -3,6 +3,6 @@ #include #include #include -#include "uuidtypes.def" -typedef UUID_TYPE MD4_t[MD4_DIGEST_LENGTH]; +#include "util.def" +typedef BYTE MD4_t[MD4_DIGEST_LENGTH]; #endif diff --git a/src/incomplete/seedcrypt.hlib b/src/incomplete/sandbox/seedcrypt.hlib similarity index 100% rename from src/incomplete/seedcrypt.hlib rename to src/incomplete/sandbox/seedcrypt.hlib diff --git a/questdialogs/more_history_at_cc8f5b5a9027acf6c5a6e2a7b0d877cb83ff5928 b/src/incomplete/sandbox/split.cc similarity index 100% rename from questdialogs/more_history_at_cc8f5b5a9027acf6c5a6e2a7b0d877cb83ff5928 rename to src/incomplete/sandbox/split.cc diff --git a/src/incomplete/sandbox/startup.cc b/src/incomplete/sandbox/startup.cc new file mode 100644 index 0000000..384ee9a --- /dev/null +++ b/src/incomplete/sandbox/startup.cc @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/src/incomplete/sandbox/types.h b/src/incomplete/sandbox/types.h new file mode 100644 index 0000000..8e10de7 --- /dev/null +++ b/src/incomplete/sandbox/types.h @@ -0,0 +1,36 @@ +#ifndef IWF_TYPES_H +#define IWF_TYPES_H + +#include +#include + +struct encontyp; +struct enttyp; +struct eventtyp; +struct mapobjtyp; +struct ray_vfx_typ; + +typedef struct iwf$$datatypes$$plane_bf { + bool shadow : 1; + unsigned rho : 2; + unsigned az : 3; + signed el : 2; + } planetype; + +struct iwf$$datatypes$$chunk_t { + Vector2u16 chunkpos; + Vector2u16 filename; + iwf$$datatypes$$chunk_bf plane; + Vector3 latlon; //the reported latitude, longitude, and elevation of the chunk + intptr_t area : 16; //key to a table of area names + intptr_t tiles : 8; //key to a table of alternate tilesets + uint8_t tiles[4096]; //16x16x16 cube, X=0x00F,Y=0x0F0,Z=0xF00 + struct encontyp * encon_ptr; + struct /*enttyp*/ kdtree * ent_ptr; + struct /*mapitemtyp*/ kdtree * mitem_ptr; + struct /*npctyp*/ kdtree * npc_ptr; + struct /*char **/ kdtree * npc_ptr; + struct /*ray_vfx_typ*/ kdtree * ray_ptr; + struct /*ray_vfx_typ*/ kdtree * light_ptr; + struct /*evtriggertyp*/ kdtree * ev_ptr; + } diff --git a/src/incomplete/types.h b/src/incomplete/types.h deleted file mode 100644 index 98e1ac0..0000000 --- a/src/incomplete/types.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef IWF_TYPES_H -#define IWF_TYPES_H -/* this code is liscensed under the GPL, version 2.0 or at your option, - * under the same terms of Perl, version 5.24, or under a later version - * of the GPL or the terms of Perl; - * - * concepts and ideas used herein shall not be included under the - * the terms of the license IFF they are in the public domain - * or equivilantly classified as common knowlage; such knowlage - * is not be mine to lend liscense to. - */ - -/* many of these types can be thought of as associative arrays with a fixed - * set of keys, and their relation be visualized in the usual manner of - * pointers and arrays in C and Pascal. - * - * the level of abstraction starts signifigantly lower than most modern - * programming (with some blackbox exceptions, such as std::string), and - * then builds a well-defined, consistant higher level API from a sturdy - * lowlevel foundation. - */ - -#include -#include - -#define _FH_ int - -typedef uint8_t ucoord2[2]; -typedef uint8_t ucoord3[3]; -typedef uint8_t ucoord4[4]; - -typedef int8_t scoord2[2]; -typedef int8_t scoord3[3]; -typedef int8_t scoord4[4]; - -typedef uint16_t ucoord2w[2]; -typedef uint16_t ucoord3w[3]; -typedef uint16_t ucoord4w[4]; - -typedef int16_t scoord2w[2]; -typedef int16_t scoord3w[3]; -typedef int16_t scoord4w[4]; - -struct encontyp; -struct enttyp; -struct eventtyp; -struct mapobjtyp; -struct ray_vfx_typ; - -struct planetyp { - bool shadow : 1; - unsigned rho : 2; - unsigned az : 3; - signed el : 2; - } - -struct chunktyp <: - ucoord2w chunkpos; - ucoord2w filename; - struct planetyp plane; - Vector3 latlon; //the reported latitude, longitude, and elevation of the chunk - intptr_t area : 16; //key to a table of area names - intptr_t tiles : 8; //key to a table of alternate tilesets - uint8_t tiles[64][64][64]; - struct encontyp * encon_ptr; - struct /*enttyp*/ kdtree * ent_ptr; - struct /*mapitemtyp*/ kdtree * mitem_ptr; - struct /*npctyp*/ kdtree * npc_ptr; - struct /*char **/ kdtree * npc_ptr; - struct /*ray_vfx_typ*/ kdtree * ray_ptr; - struct /*ray_vfx_typ*/ kdtree * light_ptr; - struct /*evtriggertyp*/ kdtree * ev_ptr; - :> - -#endif diff --git a/src/listf.cc b/src/listf.cc new file mode 100644 index 0000000..65840ec --- /dev/null +++ b/src/listf.cc @@ -0,0 +1,59 @@ +#include +#include +#include + +NEWSTRUCT iwf$$listf_t { + int datac; + STRUCT dirent * datav; + } + +iwf$$listf_t iwf::listf (std::string path) { + iwf$$listf_t output; + std::vector buffer; + DIR * pwd = opendir(path.c_str()); + errno = 0; + dirent tmp; + for (dirent tmp;;) { + tmp = readdir(pwd); + { + int err = errno; + if (tmp == NULL) { + errno = err; + return output; + }} + output.push_back(buffer); + } + output.datac = buffer.size(); + output.datav = calloc(output.datac,sizeof(dirent)); + memcpy(output.datav,buffer.data(),output.datac * sizeof(dirent)); + return output; + } + +iwf::listf_t iwf::listf (char * path) { + iwf$$listf_t output; + std::vector buffer; + DIR * pwd = opendir(path.c_str()); + errno = 0; + dirent tmp; + for (dirent tmp;;) { + tmp = readdir(pwd); + { + int err = errno; + if (tmp == NULL) { + errno = err; + return output; + }} + output.push_back(buffer); + } + output.datac = buffer.size(); + output.datav = calloc(output.datac,sizeof(dirent)); + memcpy(output.datav,buffer.data(),output.datac * sizeof(dirent)); + return output; + } + +extern "C" iwf$$listf_t * iwf$$listf (char * path) { + iwf::listf_t tmp = iwf::listf(path); + dirent * output = calloc(tmp.size() + 1,sizeof(dirent)); + memcpy(output,tmp.data(),tmp.size() * sizeof(dirent)); + return output; + } diff --git a/src/listf.h b/src/listf.h new file mode 100644 index 0000000..ceb4d7f --- /dev/null +++ b/src/listf.h @@ -0,0 +1,34 @@ +#ifndef __GG4872_LISTF_H__ +#define __GG4872_LISTF_H__ + +#ifndef __cplusplus +#include +#include +#else +#include +#endif + +#include +#include "cppkeyword.def" + +NEWSTRUCT iwf$$listf_t { + int datac; + STRUCT dirent * datav; + } + +#ifdef __cplusplus +#include +#include + +extern iwf$$listf_t iwf::listf (std::string path); +extern iwf$$listf_t iwf::listf (char * path); + +extern "C" { +#endif + +extern iwf$$listf_t iwf$$listf (char * path); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/CONFIG.DEF b/src/ongoing/CONFIG.DEF similarity index 84% rename from src/CONFIG.DEF rename to src/ongoing/CONFIG.DEF index 67d695c..22be17d 100644 --- a/src/CONFIG.DEF +++ b/src/ongoing/CONFIG.DEF @@ -5,6 +5,9 @@ //the path to the libraries #define CONFIG_DEFAULT_LIB_PATH "/usr/local/lib/games/IWannaFly" +//the path to the game's angelscript modules +#define CONFIG_DEFAULT_ASMODULE_PATH "/usr/local/share/lib/games/IWannaFly" + //the path to the dialog files; both .hex and .txt #define CONFIG_DIALOG_PATH "/usr/local/lib/games/IWannaFly" diff --git a/src/ongoing/globals.inc b/src/ongoing/globals.inc new file mode 100644 index 0000000..85eb79d --- /dev/null +++ b/src/ongoing/globals.inc @@ -0,0 +1,19 @@ +asIScriptEngine ASENGINE; + +std::map LOADED_MODULES; + +std::map> DEPENDANCIES; + +volatile ATOMIC(bool) HALT; +//everywhere + +volatile ATOMIC(bool) ERROR; +//everywhere + +volatile ATOMIC(bool) CHANGE_JSDEV; +//iwf$$joystickio + +std::string iwf::iosettings::jsdevpath; +//iwf$$joystickio + +uint8_t diff --git a/src/plugin.h b/src/plugin.h deleted file mode 100644 index 4d57afb..0000000 --- a/src/plugin.h +++ /dev/null @@ -1,39 +0,0 @@ -#ifndef __cplusplus -#include -#include -#else -#include -#endif - -#include "cppkeyword.def" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef int (*subroutine)(size_t,void*); - -extern void * iwf__plugintable__new (); -extern void iwf__plugintable__del (void * deadbeef); -extern IMPLICIT iwf__plugintable__load (void * self,char * name,void * handle); -extern IMPLICIT iwf__plugintable__loadfile (void * self,char * name); -extern subroutine iwf__plugintable__getsub (void * self,char * name,char * symbol); -extern void * iwf__plugintable__getvar (void * self,char * name,char * symbol); - -struct dlsub_t { - char * module; - char * symbol; - subroutine loaded_at; - } - -struct dlvar_t { - char * module; - char * symbol; - void * loaded_at; - } - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/src/random.c b/src/random.c index bd71713..498269e 100644 --- a/src/random.c +++ b/src/random.c @@ -19,16 +19,16 @@ int coin_flip_nickel () { } unsigned roll (unsigned number,unsigned sides,bool off) { - unsigned acc; + unsigned register acc; for (unsigned n;n < number;n++) { acc += (rand() % sides) + off; } return acc; } -signed short roll_bonus (unsigned number) { +signed roll_bonus (unsigned number) { number = (2 * number) + 1; - signed short acc; + signed register acc; for (unsigned n;n < number;n++) { acc += (rand() % 3) - 1; } diff --git a/src/random.h b/src/random.h index f057399..a347748 100644 --- a/src/random.h +++ b/src/random.h @@ -13,7 +13,7 @@ extern "C" { extern int coin_flip_nickel(); extern unsigned roll(unsigned number,unsigned sides,_Bool off); -extern signed short roll_bonus(unsigned number); +extern signed roll_bonus(unsigned number); extern char randchar(); #ifdef __cplusplus diff --git a/src/structops.c b/src/structops.c index 7822961..8a53f39 100644 --- a/src/structops.c +++ b/src/structops.c @@ -5,55 +5,55 @@ #include "structops.h" void meminvert (void * acc,size_t size) { - uint8_t * q = acc; + byteptr q = acc; for (int n = 0;n < size;n++) { q[n] = ~(q[n]); } } void memandset (void * lval,void * rval,size_t size) { - uint8_t * x = lval; - uint8_t * y = rval; + byteptr x = lval; + byteptr y = rval; for (int n = 0;n < size;n++) { x[n] &= y[n]; } } void memorset (void * lval,void * rval,size_t size) { - uint8_t * x = lval; - uint8_t * y = rval; + byteptr x = lval; + byteptr y = rval; for (int n = 0;n < size;n++) { x[n] |= y[n]; } } void memnandset (void * lval,void * rval,size_t size) { - uint8_t * x = lval; - uint8_t * y = rval; + byteptr x = lval; + byteptr y = rval; for (int n = 0;n < size;n++) { x[n] = ~(x[n] & y[n]); } } void memnorset (void * lval,void * rval,size_t size) { - uint8_t * x = lval; - uint8_t * y = rval; + byteptr x = lval; + byteptr y = rval; for (int n = 0;n < size;n++) { x[n] = ~(x[n] | y[n]); } } void memxorset (void * lval,void * rval,size_t size) { - uint8_t * x = lval; - uint8_t * y = rval; + byteptr x = lval; + byteptr y = rval; for (int n = 0;n < size;n++) { x[n] ^= y[n]; } } void memxnorset (void * lval,void * rval,size_t size) { - uint8_t * x = lval; - uint8_t * y = rval; + byteptr x = lval; + byteptr y = rval; for (int n = 0;n < size;n++) { x[n] = ~(x[n] ^ y[n]); } @@ -66,8 +66,8 @@ void memxnorset (void * lval,void * rval,size_t size) { #define memge(X,Y,Z) (memcmp(X,Y,Z) >= 0) void memswap(void * x,void * y,size_t size) { - uint8_t * xx = x; - uint8_t * yy = y; + byteptr xx = x; + byteptr yy = y; uint8_t tmp; for (int n,n < size_t,n++) { tmp = 0; diff --git a/src/structops.h b/src/structops.h index 27be421..8c47c62 100644 --- a/src/structops.h +++ b/src/structops.h @@ -8,6 +8,11 @@ #else #include #include +#endif + +#include "util.def" + +#ifdef __cplusplus extern "C" { #endif diff --git a/src/unused/lfsh.c b/src/unused/lfsh.c deleted file mode 100644 index e69de29..0000000 diff --git a/src/using.hh b/src/using.hh new file mode 100644 index 0000000..a681ce1 --- /dev/null +++ b/src/using.hh @@ -0,0 +1,11 @@ +#ifndef __GG4872_USING__ +#define __GG4872_USING__ + +#include +using half_float::half; + +#include +using boost::logic::tribool; + +#endif + diff --git a/src/util.def b/src/util.def index d6374cf..29c8697 100644 --- a/src/util.def +++ b/src/util.def @@ -3,6 +3,7 @@ #define FILENO int #define BYTE unsigned char +#define addoffset(T,X,Y) (T)(((BYTE*) (X)) + (Y)) #define tosignbit(X) (X < 0 ? 1 : 0) #define signbit(X) (X ? -1 : 1) @@ -13,13 +14,7 @@ #define sgnf(X) cmpf(X,0) #define sgnfd(X) cmpfd(X,0) -//choose the one that runs fastest on your machine. -//define istrue(X) ((X) ? 1 : 0) #define istrue(X) ((X) || 0) -//define istrue(X) ((X) && 1) -//define istrue(X) ((X) != 0) -//define istrue(X) (!!(X)) - #define iff(X,Y) (istrue(X) == istrue(Y)) #define logicxor(X,Y) (istrue(X) != istrue(Y)) diff --git a/src/vectors.c b/src/vectors.c new file mode 100644 index 0000000..15d4038 --- /dev/null +++ b/src/vectors.c @@ -0,0 +1,126 @@ +#include "vectors.h" + +vector2functions(char8_t,s8) +vector2functions(uchar8_t,u8) +vector2functions(char16_t,s16) +vector2functions(uchar16_t,u16) +vector2functions(char32_t,s32) +vector2functions(uchar32_t,u32) +vector2functions(char64_t,s64) +vector2functions(uchar64_t,u64) +vector2functions(int,i) +vector2functions(float,f) +vector2functions(double,NIL) + +vector3functions(char8_t,s8) +vector3functions(uchar8_t,u8) +vector3functions(char16_t,s16) +vector3functions(uchar16_t,u16) +vector3functions(char32_t,s32) +vector3functions(uchar32_t,u32) +vector3functions(char64_t,s64) +vector3functions(uchar64_t,u64) +vector3functions(int,i) +vector3functions(float,f) +vector3functions(double,NIL) + +vector4functions(char8_t,s8) +vector4functions(uchar8_t,u8) +vector4functions(char16_t,s16) +vector4functions(uchar16_t,u16) +vector4functions(char32_t,s32) +vector4functions(uchar32_t,u32) +vector4functions(char64_t,s64) +vector4functions(uchar64_t,u64) +vector4functions(int,i) +vector4functions(float,f) +vector4functions(double,NIL) + +vector2functions(unsigned,uNybble) +vector2functions(signed,sNybble) +vector4functions(unsigned,uNybble) +vector4functions(signed,sNybble) + +float SphereCoord2f$$at (SphereCoord2f * input,int n) { + switch (n) { + case 0 : return input->az; + case 1 : return input->el; + default : errno = EINVAL; return -1; + }} + +IMPLICIT SphereCoord2f$$setall (SphereCoord2f * input,float azimuth,float elevation) { + input->az = azimuth; + input->el = elevation; + } + +double SphereCoord2$$at (SphereCoord2 * input,int n) { + switch (n) { + case 0 : return input.az; + case 1 : return input.el; + default : errno = EINVAL; return -1; + }} + +IMPLICIT SphereCoord2$$setall (SphereCoord2 * input,double azimuth,double elevation) { + input->az = azimuth; + input->el = elevation; + } + +float SphereCoord3f$$at (SphereCoord3f * input,int n) { + switch (n) { + case 0 : return input->az; + case 1 : return input->el; + case 3 : return input->rho; + default : errno = EINVAL; return -1; + }} + +IMPLICIT SphereCoord3f$$setall (SphereCoord2f * input,float azimuth,float elevation,float range) { + input->az = azimuth; + input->el = elevation; + input->rho = range; + } + +double SphereCoord3$$at (SphereCoord3 * input,int n) { + switch (n) { + case 0 : return input->az; + case 1 : return input->el; + case 2 : return input->rho; + default : errno = EINVAL; return -1; + }} + +IMPLICIT SphereCoord3$$setall (SphereCoord3 * input,double azimuth,double elevation,double range) { + input->az = azimuth; + input->el = elevation; + input->rho = range; + } + +IMPLICIT LowColor$$setall (LowColor * input,unsigned red,unsigned green,unsigned blue) { + input->r = red; + input->g = green; + input->b = blue; + } + +IMPLICIT HighColor$$setall (HighColor * input,unsigned red,unsigned green,unsigned blue,_Bool alpha) { + input->r = red; + input->g = green; + input->b = blue; + } + +IMPLICIT HighColorA$$setall (HighColorA * input,unsigned red,unsigned green,unsigned blue,_Bool alpha) { + input->r = red; + input->g = green; + input->b = blue; + input->a = alpha; + } + +IMPLICIT TrueColor$$setall (TrueColor * input,unsigned red,unsigned green,unsigned blue) { + input->r = red; + input->g = green; + input->b = blue; + } + +IMPLICIT TrueColorA$$setall (TrueColorA * input,unsigned red,unsigned green,unsigned blue,unsigned alpha) { + input->r = red; + input->g = green; + input->b = blue; + input->a = alpha; + } diff --git a/src/vectors.c.m4 b/src/vectors.c.m4 index 804f33d..f19647d 100644 --- a/src/vectors.c.m4 +++ b/src/vectors.c.m4 @@ -1,20 +1,20 @@ m4_changequote(`,´) m4_define(`vector2functions´,` -$1 Vector2$2__at (Vector2$2 * input,int n) { +$1 Vector2$2`$$´at (Vector2$2 * input,int n) { switch (n) { case 0 : return input->x; case 1 : return input->y; default : errno = EINVAL; return -1; }} -IMPLICIT Vector2$2__setall (Vector2$2 * input,$1 xx,$1 yy) { +IMPLICIT Vector2$2`$$´setall (Vector2$2 * input,$1 xx,$1 yy) { input->x = xx; input->y = yy; }´) m4_define(`vector3functions´,` -$1 Vector3$2__at (Vector3$2 * input,int n) { +$1 Vector3$2`$$´at (Vector3$2 * input,int n) { switch (n) { case 0 : return input->x; case 1 : return input->y; @@ -22,14 +22,14 @@ $1 Vector3$2__at (Vector3$2 * input,int n) { default : errno = EINVAL; return -1; }} -IMPLICIT Vector3$2__setall (Vector3$2 * input,$1 xx,$1 yy,$1 zz) { +IMPLICIT Vector3$2`$$´setall (Vector3$2 * input,$1 xx,$1 yy,$1 zz) { input->x = xx; input->y = yy; input->z = zz; }´) m4_define(`vector4functions´,` -$1 Vector4$2__at (Vector4$2 * input,int n) { +$1 Vector4$2`$$´at (Vector4$2 * input,int n) { switch (n) { case 0 : return input->x; case 1 : return input->y; @@ -38,139 +38,9 @@ $1 Vector4$2__at (Vector4$2 * input,int n) { default : errno = EINVAL; return -1; }} -IMPLICIT Vector3$2__setall (Vector3$2 * input,$1 xx,$1 yy,$1 zz,$1 ww) { +IMPLICIT Vector4$2__setall (Vector4$2 * input,$1 xx,$1 yy,$1 zz,$1 ww) { input->x = xx; input->y = yy; input->z = zz; input->w = ww; }´) - -#include -#include -#include "cppkeyword.h" -#include "vectors.h" - -vector2functions(char8_t,s8) -vector2functions(uchar8_t,u8) -vector2functions(char16_t,s16) -vector2functions(uchar16_t,u16) -vector2functions(char32_t,s32) -vector2functions(uchar32_t,u32) -vector2functions(char64_t,s64) -vector2functions(uchar64_t,u64) -vector2functions(int,i) -vector2functions(float,f) -vector2functions(double,NIL) - -vector3functions(char8_t,s8) -vector3functions(uchar8_t,u8) -vector3functions(char16_t,s16) -vector3functions(uchar16_t,u16) -vector3functions(char32_t,s32) -vector3functions(uchar32_t,u32) -vector3functions(char64_t,s64) -vector3functions(uchar64_t,u64) -vector3functions(int,i) -vector3functions(float,f) -vector3functions(double,NIL) - -vector4functions(char8_t,s8) -vector4functions(uchar8_t,u8) -vector4functions(char16_t,s16) -vector4functions(uchar16_t,u16) -vector4functions(char32_t,s32) -vector4functions(uchar32_t,u32) -vector4functions(char64_t,s64) -vector4functions(uchar64_t,u64) -vector4functions(int,i) -vector4functions(float,f) -vector4functions(double,NIL) - -vector2functions(unsigned,uNybble) -vector2functions(signed,sNybble) -vector4functions(unsigned,uNybble) -vector4functions(signed,sNybble) - -float SphereCoord2f__at (SphereCoord2f * input,int n) { - switch (n) { - case 0 : return input->az; - case 1 : return input->el; - default : errno = EINVAL; return -1; - }} - -IMPLICIT SphereCoord2f__setall (SphereCoord2f * input,float azimuth,float elevation) { - input->az = azimuth; - input->el = elevation; - } - -double SphereCoord2__at (SphereCoord2 * input,int n) { - switch (n) { - case 0 : return input.az; - case 1 : return input.el; - default : errno = EINVAL; return -1; - }} - -IMPLICIT SphereCoord2__setall (SphereCoord2 * input,double azimuth,double elevation) { - input->az = azimuth; - input->el = elevation; - } - -float SphereCoord3f__at (SphereCoord3f * input,int n) { - switch (n) { - case 0 : return input->az; - case 1 : return input->el; - case 3 : return input->rho; - default : errno = EINVAL; return -1; - }} - -IMPLICIT SphereCoord3f__setall (SphereCoord2f * input,float azimuth,float elevation,float range) { - input->az = azimuth; - input->el = elevation; - input->rho = range; - } - -double SphereCoord3__at (SphereCoord3 * input,int n) { - switch (n) { - case 0 : return input->az; - case 1 : return input->el; - case 2 : return input->rho; - default : errno = EINVAL; return -1; - }} - -IMPLICIT SphereCoord3__setall (SphereCoord3 * input,double azimuth,double elevation,double range) { - input->az = azimuth; - input->el = elevation; - input->rho = range; - } - -IMPLICIT LowColor__setall (LowColor * input,unsigned red,unsigned green,unsigned blue) { - input->r = red; - input->g = green; - input->b = blue; - } - -IMPLICIT HighColor__setall (HighColor * input,unsigned red,unsigned green,unsigned blue,_Bool alpha) { - input->r = red; - input->g = green; - input->b = blue; - } - -IMPLICIT HighColorA__setall (HighColorA * input,unsigned red,unsigned green,unsigned blue,_Bool alpha) { - input->r = red; - input->g = green; - input->b = blue; - input->a = alpha; - } - -IMPLICIT TrueColor__setall (TrueColor * input,unsigned red,unsigned green,unsigned blue) { - input->r = red; - input->g = green; - input->b = blue; - } - -IMPLICIT TrueColorA__setall (TrueColorA * input,unsigned red,unsigned green,unsigned blue,unsigned alpha) { - input->r = red; - input->g = green; - input->b = blue; - input->a = alpha; - } diff --git a/src/vectors.h b/src/vectors.h new file mode 100644 index 0000000..7a6cd02 --- /dev/null +++ b/src/vectors.h @@ -0,0 +1,130 @@ +#ifndef __GG4872_VECTOR_H__ +#define __GG4872_VECTOR_H__ + +#ifndef __cplusplus +#include +#include +#else +#include +extern "C" { +#endif + +#include "cppkeyword.h" + +makevector2(char8_t,s8) +makevector2(uchar8_t,u8) +makevector2(char16_t,s16) +makevector2(uchar16_t,u16) +makevector2(char32_t,s32) +makevector2(uchar32_t,u32) +makevector2(char64_t,s64) +makevector2(uchar64_t,u64) +makevector2(int,i) +makevector2(float,f) +makevector2(double,NIL) + +makevector3(char8_t,s8) +makevector3(uchar8_t,u8) +makevector3(char16_t,s16) +makevector3(uchar16_t,u16) +makevector3(char32_t,s32) +makevector3(uchar32_t,u32) +makevector3(char64_t,s64) +makevector3(uchar64_t,u64) +makevector3(int,i) +makevector3(float,f) +makevector3(double,NIL) + +makevector4(char8_t,s8) +makevector4(uchar8_t,u8) +makevector4(char16_t,s16) +makevector4(uchar16_t,u16) +makevector4(char32_t,s32) +makevector4(uchar32_t,u32) +makevector4(char64_t,s64) +makevector4(uchar64_t,u64) +makevector4(int,i) +makevector4(float,f) +makevector4(double,NIL) + +STRUCTTYPE(Vector2sNybble,{signed y : 4;signed x : 4;}) +STRUCTTYPE(Vector2uNybble,{unsigned y : 4;unsigned x : 4;}) +STRUCTTYPE(Vector4sNybble,{signed w : 4;signed z : 4;signed y : 4;signed x : 4;}) +STRUCTTYPE(Vector4uNybble,{unsigned w : 4;unsigned z : 4;unsigned y : 4;unsigned x : 4;}) +Vector2sNybble LiteralVector2sNybble(signed x,signed y) {return (Vector2sNybble){y,x};} +Vector2uNybble LiteralVector2uNybble(unsigned x,unsigned y) {return (Vector2uNybble){y,x};} +Vector4sNybble LiteralVector4sNybble(signed x,signed y,signed z,signed w) {return (Vector4sNybble){w,z,y,x};} +Vector4uNybble LiteralVector4uNybble(unsigned x,unsigned y,unsigned z,unsigned w) {return (Vector4uNybble){w,z,y,x};} + +STRUCTTYPE(SphereCoord2f,{float az;float el;}) +STRUCTTYPE(SphereCoord2,{double az;double el;}) +STRUCTTYPE(SphereCoord3f,{float az;float el;float rho;}) +STRUCTTYPE(SphereCoord3,{double az;double el;double rho;}) + +STRUCTTYPE(LowColor,{unsigned r : 3;unsigned g : 3;unsigned b : 2;}) +STRUCTTYPE(HighColor,{unsigned r : 5;unsigned g : 6;unsigned b : 5}) +STRUCTTYPE(HighColorA,{unsigned r : 5;unsigned g : 5;unsigned b : 5;_Bool a : 1}) +STRUCTTYPE(TrueColor,{uint8_t r;uint8_t g;uint8_t b}) +STRUCTTYPE(TrueColorA,{uint8_t r;uint8_t g;uint8_t b;uint8_t a}) + +vector2linkage(char8_t,s8) +vector2linkage(uchar8_t,u8) +vector2linkage(char16_t,s16) +vector2linkage(uchar16_t,u16) +vector2linkage(char32_t,s32) +vector2linkage(uchar32_t,u32) +vector2linkage(char64_t,s64) +vector2linkage(uchar64_t,u64) +vector2linkage(int,i) +vector2linkage(float,f) +vector2linkage(double,NIL) + +vector3linkage(char8_t,s8) +vector3linkage(uchar8_t,u8) +vector3linkage(char16_t,s16) +vector3linkage(uchar16_t,u16) +vector3linkage(char32_t,s32) +vector3linkage(uchar32_t,u32) +vector3linkage(char64_t,s64) +vector3linkage(uchar64_t,u64) +vector3linkage(int,i) +vector3linkage(float,f) +vector3linkage(double,NIL) + +vector4linkage(char8_t,s8) +vector4linkage(uchar8_t,u8) +vector4linkage(char16_t,s16) +vector4linkage(uchar16_t,u16) +vector4linkage(char32_t,s32) +vector4linkage(uchar32_t,u32) +vector4linkage(char64_t,s64) +vector4linkage(uchar64_t,u64) +vector4linkage(int,i) +vector4linkage(float,f) +vector4linkage(double,NIL) + +vector2linkage(unsigned,uNybble) +vector2linkage(signed,sNybble) +vector4linkage(unsigned,uNybble) +vector4linkage(signed,sNybble) + +float SphereCoord2f__at (SphereCoord2f * input,int n); +IMPLICIT SphereCoord2f__setall (SphereCoord2f * input,float az,float el); +double SphereCoord2__at (SphereCoord2 * input,int n); +IMPLICIT SphereCoord2__setall (SphereCoord2 * input,double az,double el); + +float SphereCoord3f__at (SphereCoord3f * input,int n); +IMPLICIT SphereCoord3f__setall (SphereCoord3f * input,float az,float el,float rho); +double SphereCoord3__at (SphereCoord3 * input,int n); +IMPLICIT SphereCoord3__setall (SphereCoord3 * input,double az,double el); + +IMPLICIT LowColor__setall (unsigned red,unsigned green,unsigned blue); +IMPLICIT HighColor__setall (unsigned red,unsigned green,unsigned blue); +IMPLICIT HighColorA__setall (unsigned red,unsigned green,unsigned blue,_Bool alpha); +IMPLICIT TrueColor__setall (unsigned red,unsigned green,unsigned blue); +IMPLICIT TrueColorA__setall (unsigned red,unsigned green,unsigned blue,unsigned alpha); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/src/vectors.h.m4 b/src/vectors.h.m4 index a752f8a..ef54cb7 100644 --- a/src/vectors.h.m4 +++ b/src/vectors.h.m4 @@ -15,132 +15,3 @@ IMPLICIT Vector3$2__setall (Vector3$2 input,$1 xx,$1 yy,$1 zz);´) m4_define(`vector4linkage´,` $1 Vector4$2__at (Vector4$2 input,int n); IMPLICIT Vector4$2__setall (Vector4$2 input,$1 xx,$1 yy,$1 zz,$1 ww);´) - -#ifndef __GG4872_VECTOR_H__ -#define __GG4872_VECTOR_H__ - -#ifndef __cplusplus -#include -#include -#else -#include -extern "C" { -#endif - -makevector2(char8_t,s8) -makevector2(uchar8_t,u8) -makevector2(char16_t,s16) -makevector2(uchar16_t,u16) -makevector2(char32_t,s32) -makevector2(uchar32_t,u32) -makevector2(char64_t,s64) -makevector2(uchar64_t,u64) -makevector2(int,i) -makevector2(float,f) -makevector2(double,NIL) - -makevector3(char8_t,s8) -makevector3(uchar8_t,u8) -makevector3(char16_t,s16) -makevector3(uchar16_t,u16) -makevector3(char32_t,s32) -makevector3(uchar32_t,u32) -makevector3(char64_t,s64) -makevector3(uchar64_t,u64) -makevector3(int,i) -makevector3(float,f) -makevector3(double,NIL) - -makevector4(char8_t,s8) -makevector4(uchar8_t,u8) -makevector4(char16_t,s16) -makevector4(uchar16_t,u16) -makevector4(char32_t,s32) -makevector4(uchar32_t,u32) -makevector4(char64_t,s64) -makevector4(uchar64_t,u64) -makevector4(int,i) -makevector4(float,f) -makevector4(double,NIL) - -STRUCTTYPE(Vector2sNybble,{signed y : 4;signed x : 4;}) -STRUCTTYPE(Vector2uNybble,{unsigned y : 4;unsigned x : 4;}) -STRUCTTYPE(Vector4sNybble,{signed w : 4;signed z : 4;signed y : 4;signed x : 4;}) -STRUCTTYPE(Vector4uNybble,{unsigned w : 4;unsigned z : 4;unsigned y : 4;unsigned x : 4;}) -Vector2sNybble LiteralVector2sNybble(signed x,signed y) {return (Vector2sNybble){y,x};} -Vector2uNybble LiteralVector2uNybble(unsigned x,unsigned y) {return (Vector2uNybble){y,x};} -Vector4sNybble LiteralVector4sNybble(signed x,signed y,signed z,signed w) {return (Vector4sNybble){w,z,y,x};} -Vector4uNybble LiteralVector4uNybble(unsigned x,unsigned y,unsigned z,unsigned w) {return (Vector4uNybble){w,z,y,x};} - -STRUCTTYPE(SphereCoord2f,{float az;float el;}) -STRUCTTYPE(SphereCoord2,{double az;double el;}) -STRUCTTYPE(SphereCoord3f,{float az;float el;float rho;}) -STRUCTTYPE(SphereCoord3,{double az;double el;double rho;}) - -STRUCTTYPE(LowColor,{unsigned r : 3;unsigned g : 3;unsigned b : 2;}) -STRUCTTYPE(HighColor,{unsigned r : 5;unsigned g : 6;unsigned b : 5}) -STRUCTTYPE(HighColorA,{unsigned r : 5;unsigned g : 5;unsigned b : 5;_Bool a : 1}) -STRUCTTYPE(TrueColor,{uint8_t r;uint8_t g;uint8_t b}) -STRUCTTYPE(TrueColorA,{uint8_t r;uint8_t g;uint8_t b;uint8_t a}) - -vector2linkage(char8_t,s8) -vector2linkage(uchar8_t,u8) -vector2linkage(char16_t,s16) -vector2linkage(uchar16_t,u16) -vector2linkage(char32_t,s32) -vector2linkage(uchar32_t,u32) -vector2linkage(char64_t,s64) -vector2linkage(uchar64_t,u64) -vector2linkage(int,i) -vector2linkage(float,f) -vector2linkage(double,NIL) - -vector3linkage(char8_t,s8) -vector3linkage(uchar8_t,u8) -vector3linkage(char16_t,s16) -vector3linkage(uchar16_t,u16) -vector3linkage(char32_t,s32) -vector3linkage(uchar32_t,u32) -vector3linkage(char64_t,s64) -vector3linkage(uchar64_t,u64) -vector3linkage(int,i) -vector3linkage(float,f) -vector3linkage(double,NIL) - -vector4linkage(char8_t,s8) -vector4linkage(uchar8_t,u8) -vector4linkage(char16_t,s16) -vector4linkage(uchar16_t,u16) -vector4linkage(char32_t,s32) -vector4linkage(uchar32_t,u32) -vector4linkage(char64_t,s64) -vector4linkage(uchar64_t,u64) -vector4linkage(int,i) -vector4linkage(float,f) -vector4linkage(double,NIL) - -vector2linkage(unsigned,uNybble) -vector2linkage(signed,sNybble) -vector4linkage(unsigned,uNybble) -vector4linkage(signed,sNybble) - -float SphereCoord2f__at (SphereCoord2f * input,int n); -IMPLICIT SphereCoord2f__setall (SphereCoord2f * input,float az,float el); -double SphereCoord2__at (SphereCoord2 * input,int n); -IMPLICIT SphereCoord2__setall (SphereCoord2 * input,double az,double el); - -float SphereCoord3f__at (SphereCoord3f * input,int n); -IMPLICIT SphereCoord3f__setall (SphereCoord3f * input,float az,float el,float rho); -double SphereCoord3__at (SphereCoord3 * input,int n); -IMPLICIT SphereCoord3__setall (SphereCoord3 * input,double az,double el); - -IMPLICIT LowColor__setall (unsigned red,unsigned green,unsigned blue); -IMPLICIT HighColor__setall (unsigned red,unsigned green,unsigned blue); -IMPLICIT HighColorA__setall (unsigned red,unsigned green,unsigned blue,_Bool alpha); -IMPLICIT TrueColor__setall (unsigned red,unsigned green,unsigned blue); -IMPLICIT TrueColorA__setall (unsigned red,unsigned green,unsigned blue,unsigned alpha); - -#ifdef __cplusplus -} -#endif -#endif