diff --git a/.gitattributes b/.gitattributes index 882dd2d..4ff6623 100644 --- a/.gitattributes +++ b/.gitattributes @@ -7,8 +7,13 @@ core.autocrlf=false *.c = linguist-language=C *.h = linguist-language=C +*.ch = linguist-language=C *.cc = linguist-language=C++ *.hh = linguist-language=C++ +*.cchh = linguist-language=C++ +*.C = linguist-language=C++ +*.H = linguist-language=C++ +*.CH = linguist-language=C++ *.m = linguist-language=Objective-C *.mm = linguist-language=Objective-C++ *.xs = linguist-language=XS diff --git a/README.md b/README.md index 65ae608..69a7df3 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,8 @@ Doc Recommends: NEWS (and Olds) --------------- +Mixed line endings are intentional. + As of 28/10/2019, major changes to some of the oldest portions of the outline are underway. these changes need to be propogated through the entire project, and will result in major inconsistancies until finished. diff --git a/src/NotesOnCompiling b/src/NotesOnCompiling deleted file mode 100644 index 95187af..0000000 --- a/src/NotesOnCompiling +++ /dev/null @@ -1,18 +0,0 @@ -NOTE: NOT READY FOR COMPILATION - -a .ch file is a code header file, and containes code that must -be in the same translation unit as the .c file they are used in. -these files contain volatile functions. each .ch file should -correspond to a single blackbox-like abstraction layer. - -efforts will be made to move to using the linker rather than the -proprocessor to combine files, however various sources indicate -that this would be a pessimization in most of my use cases. - -files that do not require access to a global variable will -use the linker; files that do will use preprocessor transclusion -via a .ch file. the paradigm of existing functions needs to -be changed to switch from calling globals explicitly to passing -them at invocation as development continues. - -all details are subject to change, based on compiler tinkering. diff --git a/src/baserender.messy b/src/baserender.messy index d8728aa..066af6e 100644 --- a/src/baserender.messy +++ b/src/baserender.messy @@ -2,7 +2,20 @@ enttyp__normalrender (int yzindex,int cullplane) { struct enttyp * next_ent_ptr = ROOM->ent_ptr; while (next_ent_ptr != NULL) { if (raycast__visabledefault(next_ent_ptr->pos,cullplane) { - basentyp * basentity = &(montable[next_ent_ptr->race[0]->table][next_ent_ptr->race[0]->race]); + basentyp * basentity = (next_ent_ptr->race->poly == NULL) ? + montable[ + next_ent_ptr->race->base[ + next_ent_ptr->race->swap + ]->table + ][ + next_ent_ptr->race[ + next_ent_ptr->race->swap + ]->race + ] : montable[ + next_ent_ptr->race->poly->table + ][ + next_ent_ptr->race->poly->race + ]; baseclasstyp * baseclass = next_ent_ptr->class.notnull ? &(classtable[next_ent_ptr->class.role][next_ent_ptr->class.class][next_ent_ptr->class.mastery]) : NULL; char16_t this_sprite; attr_t this_attr; diff --git a/src/class_cleric.csv b/src/class_cleric.csv deleted file mode 100644 index 5bff498..0000000 --- a/src/class_cleric.csv +++ /dev/null @@ -1 +0,0 @@ -"healer","cleric","priest","druid","alchemist","scholar","white mage","seer" diff --git a/src/class_fighter.csv b/src/class_fighter.csv deleted file mode 100644 index 4cf32c8..0000000 --- a/src/class_fighter.csv +++ /dev/null @@ -1 +0,0 @@ -"fighter","knight","paladin","valkyrie","viking","samuri","ranger","monk" diff --git a/src/class_magic_user.csv b/src/class_magic_user.csv deleted file mode 100644 index a429067..0000000 --- a/src/class_magic_user.csv +++ /dev/null @@ -1 +0,0 @@ -"magic-user","wizard","illusionist","enchanter","black mage","red mage","psion","necromancer" diff --git a/src/class_rogue.csv b/src/class_rogue.csv deleted file mode 100644 index 32a1137..0000000 --- a/src/class_rogue.csv +++ /dev/null @@ -1 +0,0 @@ -"changeling","rogue","thief","pirate","ninja","assasin","tourist","ronan" diff --git a/src/gemstones.csv b/src/gemstones.csv deleted file mode 100644 index 6efdce7..0000000 --- a/src/gemstones.csv +++ /dev/null @@ -1 +0,0 @@ -"jet","sapphire","emerald","turquoise","ruby","amythest","heliodor","diamond" diff --git a/src/legend.csv b/src/legend.csv deleted file mode 100644 index cf60227..0000000 --- a/src/legend.csv +++ /dev/null @@ -1,24 +0,0 @@ -"truthseeker", -"sword of justice", -"excalibur", -"thunderbolt", -"sickle of chaos", -"stormbringer", -"devilfork", -"staff of tyrants", -"deathscyth", -"sunray", -"nightedge", -"staff of merlin", -"flame's edge", -"tesla's mace", -"stormgale", -"frostpike", -"trident of the seas", -"staff of the forest", -"quake hammer", -"bow of fire", -"bow of ice", -"bow of darkness", -"bow of void", -"bow of dawn" diff --git a/src/main.c b/src/main.c index d121bf7..1126e99 100644 --- a/src/main.c +++ b/src/main.c @@ -1,40 +1,27 @@ #error NOT READY FOR INITIAL COMPILATION -/* at the moment, this file is a scratchpad for outlining functions. - * as development progresses, these outlines will be replaced with - * tested and working equivilants. - * to preserve the file history, this file will eventually become main.c - * dummy.h will provide externs and macros for linkage. - * - * the bulk of it's contents, however, will be moved. - * - * comments may be deleted, may be moved into documentation, or may stay with what they describe - * - * work process: +/* work process: * outline pseudocode top-down, using blackboxes as neccisary * write real code bottom-up * - * optimized for memory footprint. speed is not a concern at the moment. - * C++ was found unsuitable for the majority of the program, however - * Perl is seeming more and more of an extravagance; a C/C++ hybrid - * may be called upon to replace it. + * Once the engine's first principles are fully implemented, + * the second stage of my development process will begin, which + * consists of making the first chunk of code compile and work; + * afterwards, development will continue in the more common + * poke-build-test method. * - * the idioms and formatting I am using throughout the project are based on the way my mind works - * rather than a specific programming paradigm; I am borrowing from several. + * I have been laboring under some false assumptions about memory + * management, and as a result, the program is optimized strangely, + * for memory footprint and swappiness. speed has not been a concern. * - * the program also uses various memory management paradigms, - * including linked lists, stacks, queues, and page swapping. + * C++ was found unsuitable for the majority of the program, however + * Perl is seeming more and more of an extravagance; a C/C++ hybrid, + * using std::string, may be called upon to replace it. * - * example: loading a room's file is swapping it into memory. - * once it is loaded, the pointer is placed on the top of - * the stack of loaded rooms, and the stack's depth counter - * is increased. when the counter reaches the limit, the - * stalest room is dropped. when warping, the room stack - * is checked before an attempt is made to load another - * room; when a room is recalled, it is moved to the top - * of the stack, therefore (less stale) rooms are able to be - * fetched faster than (more stale) rooms. + * the idioms and formatting I am using throughout the project are + * based on the way my mind works rather than a specific programming + * paradigm; I am, however, borrowing from several. * - * additional indirection layers are used in an attempt to + * indirection layers are used in an attempt to * prevent larger data structures from being duplicated * * most function calls provide an (obfuscation|abstraction) layer, @@ -49,17 +36,17 @@ * in the documentation and comments, * an "unbounded" array refers to * a [0] array that resembles a - * nul-terminated string literal. - * they are used for fixed data where + * nul-terminated string. + * they are used for semi-const data where * linked lists would be bloaty, but the * size of the array is not consistent. * * both explicit and implicit int declarations are used. - * functions declared return either zero (ok) or - * nonzero (error) rather than a proper intergal value. - * this is akin to certain C library functions, and inverse - * to a perl sub or a function returning bool - * for the same pourpouse. + * functions declared /*implicit*/ return either zero (ok) or + * nonzero (error), which is usually negative, rather than a + * proper intergal value. this is akin to certain C library + * functions, and inverse to a perl sub or a function returning + * bool for the same purpouse. * functions that return pointers return NULL on error; * functions returning "unbounded" arrays that cannot simply return NULL * return an equivilant to the empty string on error. @@ -150,7 +137,8 @@ * if such requirements arise, they will be considered a severe flaw and work * will focus on fixing them as soon as possible. * - * commands are implemented by a Perl::Safe read,exec loop + * commands are implemented by a Perl::Safe read,exec loop for now; + * this may be changed later * * This program is divided into 3 layers: * @@ -250,9 +238,10 @@ #include #include #include +//#include +//#include //#include //#include -//#include //#include //#include //#include @@ -282,8 +271,11 @@ #endif /**local libraries**/ +#include "util.h" #include "macro.h" #include "constants.h" +#include "types.h" +#include "objects.h" mvaddch16(int x,int y,char16_t raw,attr_t attrs) { const wchar_t wch = raw; @@ -460,42 +452,46 @@ return lines; */ /**GLOBALS**/ -playertyp PLAYER -roomstackholder ROOMSTACK -#define ROOM ROOMSTACK.swapin +//further tests necissary before committing to mmap +playertyp PLAYER; //may be mmapped +roomstackholder * ROOMSTACK; //may be anonymously mmapped +#define ROOM ROOMSTACK->swapin #define ROOM_NOT_NULL(X,Y) ((ROOM != NULL) ? X : Y) -#define WORLD ROOM_NOT_NULL( ROOM->latlon , (latlontyp){0,0,0,0,0,0} ) +#define WORLD ROOM_NOT_NULL( ROOM->latlon , (latlontyp){0,0,0,0,0,0} ) +//WORLD is a relic of an earlier design, and is not intended to be part of the API #define CEILING ROOM_NOT_NULL( ROOM->ceiling , MAX_Z ) #define OLDCEILING (CEILING + 1) -planestackholder PLANESTACK -uint64_t TURN -nibbles TIMER -char ALARM = -1 -turntyp DATE -uchar ROOMTURN -uchar ELECOLLECT[8] //elemental collectibles -uchar QUESTCOLLECT[3] //light/dark/entropy collectibles -uint64_t KILLS -char* SAVEPATH +/* several different variations on how to calculate/store CEILING have been used, + * and the one chosen was "off-by-one" from the original (last index vs length) + */ +struct xtraplayertyp PLAYERMETA //may be mmapped +#define KILLS PLAYERMETA->kills +#define CHAPTER PLAYERMETA->chapter +#define ELECOLLECT(N) PLAYERMETA->elecollect[N] +#define QUESTCOLLECT(N) PLAYERMETA->questcollect[N] +char* SAVEPATH //unsaved; but needed to save +//all linked lists are player-specific followtyp *FOLLOW_ptr //followers/minions followtyp *PURS_ptr //pursuers, i.e. paid assasins, ninjas, the reaper... eventtyp *EVNT_ptr //FOO_ptr refers to the doubly linked list's head. the tail is FOO_ptr->prev. FOO_ptr->prev->next is always NULL. placetyp *PLACE_ptr stringlistyp *HINT_ptr -eventdatastack_ele *EVSTACK_ptr +eventdatastack_ele *EVSTACK_ptr //B L A R G qglobobj * GLOBOBJ_ptr qglobev * GLOBEV_ptr -chaptertyp CHAPTER -bitfield globools -#define NEW globools.a -#define FIRST globools.b -#define DAY globools.c -#define NIGHT globools.d -#define MORN globools.w -#define NOON globools.x -#define EVE globools.y -#define MIDNIT globools.z -cameratyp CAMERA +struct odds_n_ends * GLOBOOLS //shared; may be mmapped +#define TURN GLOBOOLS->turn +#define DATE GLOBOOLS->date +#define ROOMTURN GLOBOOLS->roomturn +#define CAMERA GLOBOOLS->camera +#define NEW GLOBOOLS->new +#define FIRST GLOBOOLS->first +#define DAY GLOBOOLS->day +#define NIGHT GLOBOOLS->night +#define MORN GLOBOOLS->morn +#define NOON GLOBOOLS->noon +#define EVE GLOBOOLS->eve +#define MIDNIT GLOBOOLS->midnit /*end GLOBALS*/ bool ticktock() { @@ -552,7 +548,7 @@ baseshldtyp* shldtable[256] baubtyp* baubtable[256] char* legendstabs[24] = { -#include "legend.csv" +#include "legend.carray" }; legendtyp* legendtable[24]; @@ -562,25 +558,25 @@ char* psystabs[8] = {"detect alignment","charm","psychic lock","sleep","mind bla uchar id //switch case for each psionic ability -char (*classnametable[8])[4] = { +char (*classnametable[2])[8][4] = { { -#include "class_rogue.csv" +#include "class_rogue.carray" },{ -#include "class_fighter.csv" +#include "class_fighter.carray" },{ -#include "class_magic_user.csv" +#include "class_magic_user.carray" },{ -#include "class_cleric.csv" +#include "class_cleric.carray" }} struct baseclasstyp classtable[4][8][4]; -char (*monstabs[256])[16] = { -#include "monster0.csv" +char (*monstabs[2])[256][16] = { +#include "monster0.carray" },{ -#include "monster1.csv" +#include "monster1.carray" },{ -#include "monster2.csv" +#include "monster2.carray" }} basentyp (*montable[256])[16] = { @@ -594,7 +590,7 @@ basentyp (*montable[256])[16] = { */ /* MONSTERS BY LETTER - * & : horned devil, balrog, jubilix, + * & : horned devil, balrog, jubilix, kerr, * @ : human, elf, half elf, drow, seaelf, siren, * A : angel, astral, ætherial, celestial, archon, half celestial, * a : newt, salamander, frog, @@ -609,7 +605,7 @@ basentyp (*montable[256])[16] = { * F : panther, lion, tiger, manticore, cat, lynx, bobcat, * f : turkey, rooster, chicken, peacock, duck, goose, swan, gull, dodo, * G : ghost, banshee, revenent, barrow wight, - * g : gremlin, gargoyle, winged gargoyle, + * g : gremlin, gargoyle, winged gargoyle, goblin, * H : giant, cyclops, * h : dwarf, gnome, hobbit, * I : /giant (ant|roach|scarab|wasp|scorpion|spider)/ @@ -628,7 +624,7 @@ basentyp (*montable[256])[16] = { * o : ostrich, emu, moa, * P : dolphin, narwhal, orca, beluga, * p : penguin, puffin, auk, albatross, - * Q : fiend, drider, erinys, kerr, harpy, tiefling, + * Q : fiend, drider, erinys, tiefling, * q : quasit, imp, homunculus, * R : eagle, falcon, owl, kite, vulture, phoenix, raven, rook, crow, * r : mouse, rat, dire rat, raccoon, badger, opossum, platypus, groundhog, @@ -638,7 +634,7 @@ basentyp (*montable[256])[16] = { * t : troll, * U : umber hulk, * u : unicorn, pegasus, griphon, hippogriph, - * V : vampire, mind flayer, medusa, tengu, + * V : vampire, mind flayer, medusa, tengu, harpy, * v : bat, * W : wyrm, great wyrm, hydra, * w : purple worm, nightcrawler, @@ -653,7 +649,7 @@ basentyp (*montable[256])[16] = { * × : lizard, geko, skink, * ÷ : lobster, crab, shrimp, * £ : justice. (strictly-lawful neutral) - * ¥ : [spoiler] + * ⊜ : [spoiler] * ¶ : da fuzz. (lawful neutral) * Ω : [spoiler] * ⑄ : retribution. (chaotic neutral) @@ -792,8 +788,8 @@ set_collision_map (roomtyp * this,char x,char y,char z,bool q) { } } -char* gemcolors[8] = { -#include "gemstones.csv" +char* gemcolors[2][8] = { +#include "gemstones.carray" } //stoning has no effect /* cut varys by color: * diamond = {uncut,cushion-cut,princess-cut,perfect-cut} @@ -831,17 +827,17 @@ an UNDERLINE is a shadow note: unicode symbols are (mostly) used be their appearence, not by their meaning ) is a sword or dagger. ⍏ are polearms. ! is a staff. ⇞ is a club or mace. ℓ is a whip. ␋ is a flail. ( is a bow. ⇤ is an arrow. ⇲ is a writing instrument. ⟦ is armor. [ is clothing. ] is a shield. ⟧ are cannons or greeves. ☜☝☞☟ is a gauntlet. % is meat. ± is food (don't shoot it). $ is gold. ¢ is copper. -⌘ is a misc item. ↧ is a digging tool. ⌥ is a key or lockpick. ♫ is a lyre. ƒ is a violin. ♪ is a lute. +⌘ is a misc item. ↧ is a digging tool. ⌥ is a key or lockpick. ♫ is a lyre. ƒ is a violin. ♪ is a lute. ≣ is a staircase or ladder. ¿ are potions (fragile). ∫ is a scroll. ⊒ is a book. ∩ is a tablet. ° is a ring. º is a bracelet. ª is an amulet. ¬ is a crown. -¡ is a wand. ♮ ⇫ ⇪ is a ladder. ⋎ is a fountain or gyser. ⍾ is a bell. ⎋ is a clockface. ♠ ♣ ‡ are trees. ⋏ is fire. ♜ is a pedestal. -≋ is deep liquid's surface. ∬ is a waterfall. ≈ is a shallow liquid's surface, or a deep liquid below surface. ~ (centered) is a puddle. ≣ is a staircase. +¡ is a wand. ⋎ is a fountain or gyser. ⍾ is a bell. ⎋ is a clockface. ♠ ♣ ‡ are trees. ⋏ is fire. ♜ is a pedestal. +≋ is deep liquid's surface. ∬ is a waterfall. ≈ is a shallow liquid's surface, or a deep liquid below surface. ~ (centered) is a puddle. ⌁ is electricity. * is ice. ⎈ spider web. ⌬ beehive. ↥ are spikes. ⎙ ⍝ ⎍ ∎ ⎅ are tombstones or signs. ␥ is glass. -• is a boulder. . is a rock. ⑆ is a rockslide. ◇ is a gemstone. ◊ is a giant magic crystal. ? is somone wearing a cowled cloak. +• is a boulder. . is a rock. # ♯ is a rockslide. ◇ is a gemstone. ◊ is a giant magic crystal. ? is somone wearing a cowled cloak. ∪ is a sink. ⏍ is a chest. ↯ is the thunderbolt. ∅ is a spacetime anomaly (do not touch). ⍍ ⍔ are level stairs. ⇡ ⇣ ← ↑ → ↓ ↖ ↗ ↘ ↙ are flying projectiles, or facing direction. ⇐ ⇑ ⇒ ⇓ ⇖ ⇗ ⇘ ⇙ are ballistae. ✪ is a rune. ː ˑ are traps. -# █ ▓ ▒ ░ ▞ ▚ ⣿ (etc) are thick walls or floor. ☁ ≎ are clouds. ☈ is a thundercloud (keep your head out of them). ⁂ is fog. +█ ▓ ▒ ░ ▞ ▚ ⣿ (etc) are thick walls or floor. ☁ ≎ are clouds. ☈ is a thundercloud (keep your head out of them). ⁂ is fog. ^ ␣ are holes. , is a plant. ; is a grain or sunflower (impassable). ⌸ is a door. ⍯ is a locked door. ⎕ is an open door. -box drawings are low walls or columns. ¦ ⑉ are iron bars. / \ " are sunbeams. = is a gate. ≠ is a locked gate. : is an open gate +box drawings are low walls or columns. ¦ Ⅲ are iron bars. / \ " are sunbeams. = is a gate. ≠ is a locked gate. : is an open gate ⍽ is mud. ≃ ≊ is stagnent water (unbreathable). ☯ is a reflecting pool. ⍬ is a mirror. ♄ is an antimagic field. a prompt at launch uses user responce to choose between using ~ or ∼ for centered tilde. diff --git a/src/monster0.csv b/src/monster0.csv deleted file mode 100644 index a587c3c..0000000 --- a/src/monster0.csv +++ /dev/null @@ -1,2 +0,0 @@ -"human", "elf", "dwarf", "gnome", "hobbit", "half elf", "drow", "siren", "half orc", "half dragon", /*half celestial*/, "tiefling", "half air elemental", "half water elemental", "half earth elemental", "half fire elemental", -"merfolk", "seaelf", "satyr", "fairy", "pixie", "naiad", "naga", "dryad", "orc", "kobald", "centaur", "sphinx", "half electric elemental", "half ice elemental", "half nature elemental", "half metal elemental", diff --git a/src/monster1.csv b/src/monster1.csv deleted file mode 100644 index cce7af4..0000000 --- a/src/monster1.csv +++ /dev/null @@ -1 +0,0 @@ -"grue", "newt", diff --git a/src/monster2.csv b/src/monster2.csv deleted file mode 100644 index 7626d39..0000000 --- a/src/monster2.csv +++ /dev/null @@ -1 +0,0 @@ -"rook", "raven", "jackdaw", diff --git a/src/objects.messy b/src/objects.messy index f6c3a89..5eaf107 100644 --- a/src/objects.messy +++ b/src/objects.messy @@ -128,6 +128,19 @@ roomstackobj__makecurrent(roomstackobj * this,latlontyp query) { roomstackobj__neighbor_reset(); return 0;} +roomstackobj__scroll(roomstackobj * this,playertyp * you,char dir) { + switch (dir & 07) : + case ROOM_EAST : roomstackobj__makecurrent(this,this->swapin->neighborhood.east);you->pos[0] = MAX_X - 1;return 0; + case ROOM_WEST : roomstackobj__makecurrent(this,this->swapin->neighborhood.west);you->pos[0] = 0;return 0; + case ROOM_NORTH : roomstackobj__makecurrent(this,this->swapin->neighborhood.north);you->pos[1] = MAX_Y - 1;return 0; + case ROOM_SOUTH : roomstackobj__makecurrent(this,this->swapin->neighborhood.south);you->pos[1] = 0;return 0; + case ROOM_UP : roomstackobj__makecurrent(this,this->swapin->neighborhood.up);you->pos[2] = 0;return 0; + case ROOM_UPSTAIR : roomstackobj__makecurrent(this,this->swapin->neighborhood.up);you->pos[0] = this->swapin->downstair[0];you->pos[1] = this->swapin->downstair[1];you->pos[2] = 0;return 0; + case ROOM_DOWN : roomstackobj__makecurrent(this,this->swapin->neighborhood.down);you->pos[2] = this->ceiling;return 0; + case ROOM_DOWNSTAIR : roomstackobj__makecurrent(this,this->swapin->neighborhood.down);you->pos[0] = this->swapin->upstair[0];you->pos[1] = this->swapin->upstair[1];you->pos[2] = this->swapin->ceiling;return 0; + default : return -1; + } + roomstackobj__neighbor_reset (struct roomstack * this) { for (int n = 0;n < 6;n++) { for (int i = 0,i < n,i++) { @@ -291,33 +304,81 @@ roomtyp * smrtloadroom (struct latlontyp query) { } } -/* planetyp getplanetyp(latlontyp) - */ +/**getplanetyp**/ +struct planetyp getplanetyp(struct latlontyp input) { + struct planetype output; + output.rho = input.rho; + output.az = input.az; + output.el = input.el; + return output; + } -/* blitlineobj__load_room(blit_lineobj*,char,char*) ...load a bank of lines from a room - * blitlineobj__load_plane(blit_lineobj*,char,char*) ...load a bank of lines from a plane - * blitlineobj__load(blit_lineobj*,char,char*) ...load a bank of lines from the global library - * blitobj__pallette_load_room(blitobj*,char,char*) ...load a pallette from a room - * blitobj__pallette_load_plane(blitobj*,char,char*) ...load a pallette from a plane - * blitobj__pallette_load(blitobj*,char,char*) ...load a pallette from the global library - * blitobj__img_load_room(blitobj*,char*) ...load an imageset from a room - * blitobj__img_load_plane(blitobj*,char*) ...load an imageset from a plane - * blitobj__img_load(blitobj*,char*) ...load an imageset from the global library - * blitobj__sprite_load_room(blitobj*,char*) ...load a spriteset from a room - * blitobj__sprite_load_plane(blitobj*,char*) ...load a spriteset from a plane - * blitobj__sprite_load(blitobj*,char*) ...load a spriteset from the global library +/**shiftstackobj** + * shiftstackobj__push(racetyp) + * shiftstackobj__popif() + * shiftstackobj__pop() + * shiftstackobj__destroy() + * shiftstackobj__base_swap() + * shiftstackobj__alter_set(char,altertimertyp) + * shiftstackobj__alter_wset(altertimerwtyp) + * playertyp__shiftstacksync() */ -struct blitobj { - char *lines[8][32]; // ans file - _8bitPtr *img[4][8][8]; // hex file - struct blitele * head; - struct blitele * tail; +shiftstackobj__push (struct shiftstackobj * this,struct racetyp data,uchar timer) { + if (!(this->topdeck) { + this->depth++; + if (depth < 0) { + this->topdeck = 1; + this->swap = 0; + this->lycan = 0; + this->base[0] = data; + this->base[1] = (struct racetyp){0,0,0}; + shiftstackobj__destroy(this); + this->depth = 0; + return this->depth; + } + else if ( + (this->poly.race == data.race) + && + (this->poly.table == data.table) + && + (this->poly.meta == data.meta) + ) { + this->base[this->swap] = data; + shiftstackobj__destroy(this); + this->depth = 0; + return this->depth; + } + else { + struct shiftstackele * tmp = malloc(sizeof(struct shiftstackele)); + tmp->prev = this->poly; + tmp->polytimer = timer; + tmp->race = data.race; + tmp->table = data.table; + tmp->meta = data.meta; + this->poly = tmp; + return this->depth; + } + return -1; + } + else { + this->base[0] = data; + return 0; + } } -blitele { - blitele * prev; - blitele * next; - int p[6]; - uchar s[16]; +void shiftstackobj__pop (struct shiftstackobj * this) { + struct shiftstackobj * deadbeef = this->poly; + if ((this->poly != NULL) && (this->poly->prev != NULL)) { + this->poly = this->poly->prev; + free(deadbeef); + } } + +/**blit functions**/ + +dialouge(coord3 * pos,coord3 * meta,struct strarry * lines,struct chgat_args_typ * attrs,struct attrcolortyp default) + +spriteblit(coord3 * pos,coord2 * meta,struct strarry * lines,struct chgat_args_typ * attrs,struct attrcolortyp default,ucoord3 origin) + + diff --git a/src/roomscroll.ch b/src/roomscroll.ch deleted file mode 100644 index 6c6f482..0000000 --- a/src/roomscroll.ch +++ /dev/null @@ -1,12 +0,0 @@ -roomscroll(char dir) { -switch (dir & 07) : - case ROOM_EAST : roomstackobj__makecurrent(ROOMSTACK,ROOM->neighborhood.east);PLAYER->pos[0] = MAX_X - 1;break; - case ROOM_WEST : roomstackobj__makecurrent(ROOMSTACK,ROOM->neighborhood.west);PLAYER->pos[0] = 0;break; - case ROOM_NORTH : roomstackobj__makecurrent(ROOMSTACK,ROOM->neighborhood.north);PLAYER->pos[1] = MAX_Y - 1;break; - case ROOM_SOUTH : roomstackobj__makecurrent(ROOMSTACK,ROOM->neighborhood.south);PLAYER->pos[1] = 0;break; - case ROOM_UP : roomstackobj__makecurrent(ROOMSTACK,ROOM->neighborhood.up);PLAYER->pos[2] = 0;break; - case ROOM_UPSTAIR : roomstackobj__makecurrent(ROOMSTACK,ROOM->neighborhood.up);PLAYER->pos[0] = ROOM->downstair[0];PLAYER->pos[1] = ROOM->downstair[1];PLAYER->pos[2] = 0;break; - case ROOM_DOWN : roomstackobj__makecurrent(ROOMSTACK,ROOM->neighborhood.down);PLAYER->pos[2] = CEILING;break; - case ROOM_DOWNSTAIR : roomstackobj__makecurrent(ROOMSTACK,ROOM->neighborhood.down);PLAYER->pos[0] = ROOM->upstair[0];PLAYER->pos[1] = ROOM->upstair[1];PLAYER->pos[2] = CEILING;break; - default : break; -} diff --git a/src/types.h b/src/types.h index d39952e..0eb20d1 100644 --- a/src/types.h +++ b/src/types.h @@ -1,8 +1,9 @@ +#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 "_bitfield" affixed to - * the name, which will be placed in a consistantly-named member at the end of the struct. - * - * possible names: 1."β" 2."_b" + * the tightly packed ones will be split off into a seperate type with "_bits" affixed to + * the name, which will be placed in a consistantly-named member "_bits" at the end of the struct. */ #define uint unsigned int @@ -11,6 +12,21 @@ #define ulong unsigned long #define 8BITPTR uint8_t +struct odds_n_ends { +uint64_t turn; +turntype date; +uchar roomturn; +cameratyp camera; +bool new : 1; +bool first : 1; +bool day : 1; +bool night : 1; +bool morn : 1; +bool noon : 1; +bool eve : 1; +bool midnit : 1; +} + struct stringlistyp { (self) *prev (self) *next @@ -40,15 +56,16 @@ ushort lineno char * text } +/*depracated struct blitimgcolor { - struct attr_t attr[6] - uchar fgcolor[4] - uchar bgcolor[4] + struct attr_t attr[6]; + uchar fgcolor[4]; + uchar bgcolor[4]; char ** img[16]; } - /* [0] [1] [2] [3] fgcolor - * 0 [0] [1] [2] attr - * [0] 0 [0] [1] [2] [3] img + ?* [0] [1] [2] [3] fgcolor + * 0x0000 [0] [1] [2] attr + * [0] 0x0000 [0] [1] [2] [3] img * [1] [3] [4] [5] [6] [7] * [2] [4] [8] [9] [10] [11] * [3] [5] [12] [13] [14] [15] @@ -71,53 +88,81 @@ struct drawvector { * ( char16_t unichar, struct attrcolortyp attrcolor, uchar az ¿, float dist?, ushort uslp) */ +/* not implemented yet +struct glyphtyp { +unsigned typ; +int attrs; +void *glyph; +} +?* cast void to (OR flags) : + * + * 0x80 : char16_t instead of char + * 0x70 : elements are nul terminated strings of whatevers + * 0xn0 : for 1 ≤ n ≤ 6, elements are fixed sized arrays of n whatevers + * + * 0x00 : toplevel is not an array + * 0x01 : [10] = {up,north,ne,left,se,south,sw,right,nw,down} + * 0x02 : [2] = {left,right} + * 0x03 : [2] = {north,south} + * 0x04 : [4] = {north,left,south,right} + * 0x06 : [6] = {up,north,left,south,right,down} + * 0x07 : [8] = {north,ne,left,se,south,sw,right,nw} + */ + struct chaptertyp { unsigned c : 7; //chapter number unsigned a : 9; //alignment type } struct turntyp: -uchar sec : 6 -uchar min : 6 -uchar hour : 5 -uchar day : 5 -uchar weekday : 3 -uchar month : 4 -ushort year : 11 - -typedef uchar ucoord3[3] -typedef uchar ucoord2[2] -typedef char scoord3[3] -typedef char scoord2[2] +uchar sec : 6; +uchar min : 6; +uchar hour : 5; +uchar day : 5; +uchar weekday : 3; +uchar month : 4; +ushort year : 11; + +typedef uchar ucoord3[3]; +typedef uchar ucoord2[2]; +typedef char scoord3[3]; +typedef char scoord2[2]; //sentinal for an array of coord3 is {0,0,-1} +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 -unsigned x : 7 -unsigned y : 5 -unsigned z : 4 -unsigned xx : 7 -unsigned yy : 5 -unsigned zz : 4 +unsigned x : 7; +unsigned y : 5; +unsigned z : 4; +unsigned xx : 7; +unsigned yy : 5; +unsigned zz : 4; } struct agetyp { -unsigned chrono : 16 -signed bio : 8 //entity dies on overflow -unsigned rem : 8 /* bio remainder after chrono; - * bio increments on the next - * modulo_0 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 shiftertyp) - */ -} + unsigned chrono : 16; + signed bio : 8; //entity dies on overflow + unsigned rem : 8; /* bio remainder after chrono; + } * bio increments on the next modulo_0 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 mapcoord3: unsigned x : 7 @@ -208,6 +253,18 @@ bool behind : 1 //EQUATOR/2 degrees are added to azimuth * next packet. set to 0 to send immidiately. */ +/* typedef short sprite[16] + * typedef sprite *voxel[5] ?/ top, bottom, sides, front, back. if front or back == NULL, side is substituted. + * typedef sprite vwing[2] ?/ front and back only + * + * for future use by a vector graphics library, for 3d rendering by algorithem + * in non-isogonal modes, single-point perspective is used; points are calculated by adverageing the boundries of a voxel box's perpendicular sides. + * perpindicular side sizes are calculated by altering the camera's distance and focal length + * + * these types provide an abstraction layer for an xlib- or xcb-like frontend, + * uses a 17*17 point vector grid, distorted according to the perspective, to draw squares for each 1-bit in the sprite array. + */ + //some specific use cases require spheres. these are simply numeric types. struct diceodds: @@ -236,12 +293,12 @@ signed el : 2 * 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 is WIP) + * (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 princess stealing + * 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 @@ -367,14 +424,19 @@ bool r : 1 bool w : 1 bool x : 1 //can be spoken +struct xtraplayertyp { +chaptertyp chapter; +uint64_t kills; +uchar elecollect[8]; +uchar questcollect[3]; +} + struct playertyp: char * name classtyp class[3] uchar element agetyp age -struct racetyp baserace[2] -struct racetyp polyrace -shiftertyp polycounter +struct shiftstackobj race ucoord3 pos polar facing vector3 velo @@ -466,7 +528,7 @@ agetyp age classtyp class uchar element aggrotyp aggro -struct racetyp race[2] +struct shiftstackobj race ucoord3 pos polar facing vector3 velo @@ -509,9 +571,7 @@ agetyp age classtyp class uchar element aggrotyp aggro -struct racetyp baserace[2] -struct racetyp polyrace -shiftertyp polycounter +struct shiftstackobj race ucoord3 pos polar facing vector3 velo @@ -542,7 +602,7 @@ npctyp * depth classtyp class uchar element aggrotyp aggro -struct racetyp race +struct shiftstackobj race paffectyp paffect effectyp effect oneobjtyp loot @@ -595,24 +655,53 @@ bool earth : 1 unsigned lde : 3 bool planer : 1 -struct shiftertyp { -unsigned polytimer : 8 //time remaining in the current polymorph. if non-zero, polyrace is used instead of baserace. -unsigned polydepth : 4 //polymorphing more than 10 times without returning to your base form first change your base form to the 15th one -unsigned polycount : 4 //repeating the same polymorph 10 times will make it permenant -unsigned altertimer : 8 //time remaining in the current alteration. -unsigned gills : 4 //using an alteration spell, including intrensics from polymorph spells, 10 times will make them permenent. -unsigned lungs : 4 //these counters can be reset by rest or spells -unsigned wings : 4 -unsigned tail : 4 -unsigned claws : 4 -unsigned fangs : 4 -unsigned talons : 4 -bodytyp alterations //keeps track of changes. if a change becomes permenent, it is moved to paffect. +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; } -/* 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 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 spelltyp: intptr_t itemid : 8 @@ -1293,3 +1382,4 @@ MONEY_FLAG : contains moneytyp SPAWN_FLAG : contains spawntyp SIGN_FLAG : contains signtyp +#endif diff --git a/src/util.h b/src/util.h index 1a880fd..f960431 100644 --- a/src/util.h +++ b/src/util.h @@ -27,3 +27,4 @@ extern int sgnf(float n); extern double maxfd(double a,double b); extern double minfd(double a,double b); extern int sgnfd(float n); +#endif diff --git a/src/wingrender.messy b/src/wingrender.messy index ece1a60..7d52d0f 100644 --- a/src/wingrender.messy +++ b/src/wingrender.messy @@ -44,9 +44,30 @@ else {\ enttyp__wingrender(enttyp * this,basentyp * basentity,baseclasstyp * baseclass,int yzindex,int cullplane,attr_t attrs) { char16_t this_sprite[2]; - if PREDICATE(this,effect) SWITCH_BODY(this,effect) + if (this->race->alters->wings->t) { + if (this->race->alters->wings->q) { + if (this->race->alters->wings->w_sgn) { + switch this->race->alters->wings->w_typ : + case 0 : this_sprite[0] = '>'; this_sprite[1] = '<'; break; + case 1 : this_sprite[0] = 0x2265; this_sprite[1] = 0x2264; break; + case 2 : this_sprite[0] = 0x226B; this_sprite[1] = 0x226A; break; + case 3 : this_sprite[0] = 0x2277; this_sprite[1] = 0x2276; break; + default : this_sprite[0] = 0xFFFD; this_sprite[1] = 0xFFFD; break; + } + else { + switch this->race->alters->wings->w_typ : + case 0 : this_sprite[0] = '<'; this_sprite[1] = '>'; break; + case 1 : this_sprite[0] = 0x2264; this_sprite[1] = 0x2265; break; + case 2 : this_sprite[0] = 0x226A; this_sprite[1] = 0x226B; break; + case 3 : this_sprite[0] = 0x2276; this_sprite[1] = 0x2277; break; + default : this_sprite[0] = 0xFFFD; this_sprite[1] = 0xFFFD; break; + } + } + else {return 0;} + } + else if PREDICATE(this,effect) SWITCH_BODY(this,effect) else if PREDICATE(this,paffect) SWITCH_BODY(this,paffect) - esle if PREDICATE(baseclass,bonus) SWITCH_BODY(baseclass,bonus) + else if PREDICATE(baseclass,bonus) SWITCH_BODY(baseclass,bonus) else if PREDICATE(basentity,base) SWITCH_BODY(basentity,base) else {return 0;} if (