From 62e514036d73a377dcbc7c8fb1e35807a972179a Mon Sep 17 00:00:00 2001 From: sparky4 Date: Fri, 27 Jan 2017 08:48:48 -0600 Subject: [PATCH] going to work on bg draw today! --- 16/glist.c | 343 +++++++++++++++++++++++++++++++++++++++++++++ DEBUG.16W | 210 --------------------------- HEAP.16W | 69 --------- MMDUMP.16W | Bin 2550 -> 0 bytes src/0.c | 2 +- src/lib/16_sprit.c | 20 ++- src/lib/16_tdef.h | 43 ++++-- src/lib/16_vl.c | 42 +++--- src/lib/bakapee.c | 6 +- src/lib/doslib | 2 +- src/lib/scroll16.c | 34 ++--- src/lib/scroll16.h | 27 ---- 12 files changed, 434 insertions(+), 364 deletions(-) create mode 100755 16/glist.c delete mode 100755 DEBUG.16W delete mode 100755 HEAP.16W delete mode 100755 MMDUMP.16W diff --git a/16/glist.c b/16/glist.c new file mode 100755 index 00000000..a29e5009 --- /dev/null +++ b/16/glist.c @@ -0,0 +1,343 @@ +/**************************************************** + * William Crenshaw + * 10/27/2014 + * GList.cc + * + * Generic list program + ****************************************************/ + +#include +using namespace std; + +const int MAX_SIZE = 35; + +template +class List +{ + private: + // list node definition + struct Node + { + T data; + Node *link; + }; + + Node *head; // the head of the list + Node *tail; // the tail of the list + Node *curr; // the current position in the list + int num_items; // the number of items in the list + + public: + // constructor + // remember that an empty list has a "size" of -1 and its "position" is at -1 + List() + { + head = NULL; + tail = NULL; + curr = NULL; + num_items = 0; + } + + // copy constructor + // clones the list l and sets the last element as the current + List(const List& l) + { + *this = l; + } + + // copy constructor + // clones the list l and sets the last element as the current + void operator=(const List& l) + { + head = NULL; + tail = NULL; + curr = NULL; + num_items = 0; + + Node *n = l.head; + + while(n != NULL) + { + InsertAfter(n->data); + n = n->link; + } + } + + // navigates to the beginning of the list + void First() + { + curr = head; + } + + // navigates to the end of the list + // the end of the list is at the last valid item in the list + void Last() + { + curr = tail; + } + + // navigates to the specified element (0-index) + // this should not be possible for an empty list + // this should not be possible for invalid positions + void SetPos(int pos) + { + if(!IsEmpty() && pos >= 0 && pos < GetSize()) + { + curr = head; + while(pos > 0) + { + curr = curr->link; + pos--; + } + } + } + + // navigates to the previous element + // this should not be possible for an empty list + // there should be no wrap-around + void Prev() + { + if(curr != head) + { + Node *n = head; + + while(n->link != curr) + n = n->link; + + curr = n; + } + } + + // navigates to the next element + // this should not be possible for an empty list + // there should be no wrap-around + void Next() + { + if(!IsEmpty() && curr != tail) + curr = curr->link; + } + + // returns the location of the current element (or -1) + int GetPos() + { + if(IsEmpty()) + return -1; + + int pos = 0; + Node *n = head; + + while(n != curr) + { + n = n->link; + pos++; + } + + return pos; + } + + // returns the value of the current element (or -1) + T GetValue() + { + if(!IsEmpty()) + return curr->data; + + return -1; + } + + // returns the size of the list + // size does not imply capacity + int GetSize() + { + return num_items; + } + + // inserts an item before the current element + // the new element becomes the current + // this should not be possible for a full list + void InsertBefore(T data) + { + if(!IsFull()) + { + if(IsEmpty()) + InsertAfter(data); + else + { + Node* n = new Node; + n->data = data; + n->link = NULL; + + if(curr == head) + { + n->link = head; + head = n; + curr = n; + num_items++; + } + else + { + Prev(); + InsertAfter(data); + } + } + } + } + + // inserts an item after the current element + // the new element becomes the current + // this should not be possible for a full list + void InsertAfter(T data) + { + if(!IsFull()) + { + Node* n = new Node; + n->data = data; + n->link = NULL; + + if(IsEmpty()) + { + head = n; + tail = n; + } + else + { + if(curr == tail) + { + curr->link = n; + tail = n; + } + else + { + n->link = curr->link; + curr->link = n; + } + } + + curr = n; + num_items++; + } + } + + // removes the current element (collapsing the list) + // this should not be possible for an empty list + void Remove() + { + if(!IsEmpty()) + { + if(num_items == 1) + { + head = NULL; + tail = NULL; + curr = NULL; + } + else + { + if(curr == head) + { + head = head->link; + curr = head; + } + else if(curr == tail) + { + Prev(); + tail = curr; + tail->link = NULL; + } + else + { + Prev(); + curr->link = curr->link->link; + Next(); + } + } + + num_items--; + } + } + + // replaces the value of the current element with the specified value + // this should not be possible for an empty list + void Replace(int data) + { + if(!IsEmpty()) + curr->data = data; + } + + // returns if the list is empty + bool IsEmpty() + { + return (num_items == 0); + } + + // returns if the list is full + bool IsFull() + { + return (num_items == MAX_SIZE); + } + + // returns the concatenation of two lists + // l should not be modified + // l should be concatenated to the end of *this + // the returned list should not exceed MAX_SIZE elements + // the last element of the new list is the current + List operator+(const List& l) const + { + List newList = *this; + + Node *n = l.head; + + while(n != NULL) + { + newList.InsertAfter(n->data); + n = n->link; + } + + return newList; + } + + // returns if two lists are equal (by value) + bool operator==(const List& l) const + { + if(num_items != l.num_items) + return false; + + Node *n = head; + Node *p = l.head; + + while(n != NULL) + { + if(n->data != p->data) + return false; + + n = n->link; + p = p->link; + } + + return true; + } + + // returns if two lists are not equal (by value) + bool operator!=(const List& l) const + { + return !(*this == l); + } + + // returns a string representation of the entire list (e.g., 1 2 3 4 5) + // the string "NULL" should be returned for an empty list + friend ostream& operator<<(ostream& out, const List &l) + { + if(l.num_items == 0) + out << "NULL"; + else + { + Node* n = l.head; + + while(n != NULL) + { + out << n->data;// << " "; + n = n->link; + } + } + + return out; + } +}; diff --git a/DEBUG.16W b/DEBUG.16W deleted file mode 100755 index 927f74dc..00000000 --- a/DEBUG.16W +++ /dev/null @@ -1,210 +0,0 @@ -Seg:0 Size:9973 Owner:0x0 -+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++0000 -Seg:27ba Size:36 Owner:0x0 -+ -Seg:27de Size:256 Owner:0x1984 -++++ -Seg:28de Size:256 Owner:0x1776 -++++ -Seg:29de Size:256 Owner:0x1778 -+++++ -Seg:2ade Size:256 Owner:0x177a -++++ -Seg:2bde Size:256 Owner:0x177c -++++ -Seg:2cde Size:256 Owner:0x177e -++++ -Seg:2dde Size:256 Owner:0x1780 -++++ -Seg:2ede Size:256 Owner:0x1782 -+++++ -Seg:2fde Size:256 Owner:0x1784 -++++ -Seg:30de Size:256 Owner:0x1786 -++++ -Seg:31de Size:256 Owner:0x1788 -++++ -Seg:32de Size:256 Owner:0x178a -++++ -Seg:33de Size:256 Owner:0x178c -+++++ -Seg:34de Size:256 Owner:0x178e -++++ -Seg:35de Size:256 Owner:0x1790 -++++ -Seg:36de Size:256 Owner:0x1792 -++++ -Seg:37de Size:256 Owner:0x1794 -++++ -Seg:38de Size:256 Owner:0x1796 -+++++ -Seg:39de Size:256 Owner:0x1798 -++++ -Seg:3ade Size:256 Owner:0x179a -++++ -Seg:3bde Size:256 Owner:0x179c -++++ -Seg:3cde Size:256 Owner:0x179e -++++ -Seg:3dde Size:256 Owner:0x17a0 -+++++ -Seg:3ede Size:256 Owner:0x17a2 -++++ -Seg:3fde Size:256 Owner:0x17a4 -++++ -Seg:40de Size:256 Owner:0x17a6 -++++ -Seg:41de Size:256 Owner:0x17a8 -++++ -Seg:42de Size:256 Owner:0x17aa -+++++ -Seg:43de Size:256 Owner:0x17ac -++++ -Seg:44de Size:256 Owner:0x17ae -++++ -Seg:45de Size:256 Owner:0x17b0 -++++ -Seg:46de Size:256 Owner:0x17b2 -++++ -Seg:47de Size:256 Owner:0x17b4 -+++++ -Seg:48de Size:256 Owner:0x17b6 -++++ -Seg:49de Size:256 Owner:0x17b8 -++++ -Seg:4ade Size:256 Owner:0x17ba -++++ -Seg:4bde Size:256 Owner:0x17bc -++++ -Seg:4cde Size:256 Owner:0x17be -+++++ -Seg:4dde Size:256 Owner:0x17c0 -++++ -Seg:4ede Size:256 Owner:0x17c2 -++++ -Seg:4fde Size:256 Owner:0x17c4 -++++ -Seg:50de Size:256 Owner:0x17c6 -++++ -Seg:51de Size:256 Owner:0x17c8 -+++++ -Seg:52de Size:256 Owner:0x17ca -++++ -Seg:53de Size:256 Owner:0x17cc -++++ -Seg:54de Size:256 Owner:0x17ce -++++ -Seg:55de Size:256 Owner:0x17d0 -++++ -Seg:56de Size:256 Owner:0x17d2 -+++++ -Seg:57de Size:256 Owner:0x17d4 -++++ -Seg:58de Size:256 Owner:0x17d6 -++++ -Seg:59de Size:256 Owner:0x17d8 -++++ -Seg:5ade Size:256 Owner:0x17da -++++ -Seg:5bde Size:256 Owner:0x17dc -+++++ -Seg:5cde Size:256 Owner:0x17de -++++ -Seg:5dde Size:256 Owner:0x17e0 -++++ -Seg:5ede Size:256 Owner:0x17e2 -++++ -Seg:5fde Size:256 Owner:0x17e4 -++++ -Seg:60de Size:256 Owner:0x17e6 -+++++ -Seg:61de Size:256 Owner:0x17e8 -++++ -Seg:62de Size:256 Owner:0x17ea -++++ -Seg:63de Size:256 Owner:0x17ec -++++ -Seg:64de Size:256 Owner:0x17ee -++++ -Seg:65de Size:256 Owner:0x17f0 -+++++ -Seg:66de Size:256 Owner:0x17f2 -++++ -Seg:67de Size:256 Owner:0x17f4 -++++ -Seg:68de Size:256 Owner:0x17f6 -++++ -Seg:69de Size:256 Owner:0x17f8 -++++ -Seg:6ade Size:256 Owner:0x17fa -+++++ -Seg:6bde Size:256 Owner:0x17fc -++++ -Seg:6cde Size:256 Owner:0x17fe -++++ -Seg:6dde Size:256 Owner:0x1800 -++++ -Seg:6ede Size:256 Owner:0x1802 -++++ -Seg:6fde Size:256 Owner:0x1804 -+++++ -Seg:70de Size:256 Owner:0x1806 -++++ -Seg:71de Size:256 Owner:0x1808 -++++ -Seg:72de Size:256 Owner:0x180a -++++ -Seg:73de Size:256 Owner:0x180c -++++ -Seg:74de Size:256 Owner:0x180e -+++++ -Seg:75de Size:256 Owner:0x1810 -++++ -Seg:76de Size:256 Owner:0x1812 -++++ -Seg:77de Size:256 Owner:0x1814 -++++ -Seg:78de Size:256 Owner:0x1816 -++++ -Seg:79de Size:256 Owner:0x1818 -+++++ -Seg:7ade Size:256 Owner:0x181a -++++ -Seg:7bde Size:256 Owner:0x181c -++++ -Seg:7cde Size:256 Owner:0x181e -++++ -Seg:7dde Size:256 Owner:0x1820 -++++ -Seg:7ede Size:256 Owner:0x1822 -+++++ -Seg:7fde Size:256 Owner:0x1824 -++++ -Seg:80de Size:256 Owner:0x1826 -++++ -Seg:81de Size:256 Owner:0x1828 -++++ -Seg:82de Size:256 Owner:0x182a -++++ -Seg:83de Size:256 Owner:0x182c -+++++ -Seg:84de Size:256 Owner:0x182e -++++ -Seg:85de Size:256 Owner:0x1830 -++++ -Seg:86de Size:256 Owner:0x1832 -++++ -Seg:87de Size:256 Owner:0x1834 -++++ -Seg:88de Size:256 Owner:0x1836 -+++++ -Seg:89de Size:256 Owner:0x1838 -++++ -Seg:8ade Size:256 Owner:0x183a -++++ -Seg:8bde Size:256 Owner:0x183c -++++ -Seg:8cde Size:401 Owner:0xef0c -++++++ -Seg:b7de Size:18465 Owner:0x0 -++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ \ No newline at end of file diff --git a/HEAP.16W b/HEAP.16W deleted file mode 100755 index 21a34df4..00000000 --- a/HEAP.16W +++ /dev/null @@ -1,69 +0,0 @@ - - == default == - - FREE block at 27dc0016 of size 68 - USED block at 27dc005a of size 50 - USED block at 27dc008c of size 50 - USED block at 27dc00be of size 50 - USED block at 27dc00f0 of size 50 - USED block at 27dc0122 of size 50 - USED block at 27dc0154 of size 50 - USED block at 27dc0186 of size 50 - USED block at 27dc01b8 of size 50 - USED block at 27dc01ea of size 50 - USED block at 27dc021c of size 50 - USED block at 27dc024e of size 50 - USED block at 27dc0280 of size 50 - FREE block at 27dc02b2 of size 14 - USED block at 27dc02c0 of size 20 - USED block at 27dc02d4 of size 136 - FREE block at 27dc035c of size 7328 -OK - end of heap - - == near == - - USED block at 17dbefa6 of size 12 - USED block at 17dbefb2 of size 330 - USED block at 17dbf0fc of size 52 - USED block at 17dbf130 of size 20 - USED block at 17dbf144 of size 20 - USED block at 17dbf158 of size 20 - USED block at 17dbf16c of size 20 - USED block at 17dbf180 of size 20 - USED block at 17dbf194 of size 3688 -OK - end of heap - - == far == - - USED block at 27dc0016 of size 68 - USED block at 27dc005a of size 50 - USED block at 27dc008c of size 50 - USED block at 27dc00be of size 50 - USED block at 27dc00f0 of size 50 - USED block at 27dc0122 of size 50 - USED block at 27dc0154 of size 50 - USED block at 27dc0186 of size 50 - USED block at 27dc01b8 of size 50 - USED block at 27dc01ea of size 50 - USED block at 27dc021c of size 50 - USED block at 27dc024e of size 50 - USED block at 27dc0280 of size 50 - USED block at 27dc02b2 of size 14 - USED block at 27dc02c0 of size 20 - USED block at 27dc02d4 of size 136 - USED block at 27dc035c of size 7328 -OK - end of heap - -Memory Type Total Used Free ----------------- -------- -------- -------- -Default 8166 756 7410 -Near 4182 494 3688 -Far 8166 756 7410 ----------------- -------- -------- -------- -coreleft = 3686 -farcoreleft = 35502 -GetFreeSize = 31836 -GetNearFreeSize = 3688 -GetFarFreeSize = 31836 -memavl = 3686 -stackavail = 31557 diff --git a/MMDUMP.16W b/MMDUMP.16W deleted file mode 100755 index 9793e6efc84b96e3e263ef6c7c1b31724f44bec7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2550 zcmZ|RyGaE=5Qb4>!5(g?fv^v`cUG_mTi9m}wqeI=qJfIYN$*qsh_aXmT_;njB4zCP$N_%hBcN za&$Sm99@nsN0(#BG2|F>3^|4zLyjTGkYma*<(P6zIi?&_jw#2KW681PSaK{mmK;lt zCC8Fu%dzFya%?%a99xbp$Cl&BapX9196630M~)-Mfg=(ek>H2~MKH$Z}*kvK(2CEJv23$Wi1dauhj=97T>IN0Fn-QRS#|R5_{~RgMZri|^yl|2Nz| MKcD#g`8V#q04i7c-T(jq diff --git a/src/0.c b/src/0.c index a79f455c..2d55bcdf 100755 --- a/src/0.c +++ b/src/0.c @@ -31,7 +31,7 @@ int main(int argc,char **argv) boolean anim=1,noanim=0,zerostoppause=1; bakapee1=malloc(64); - bakapee2=malloc(1024); + bakapee2=malloc(64); if (argc < 2) { //fprintf(stderr,"drawvrl \n palette file optional\n"); diff --git a/src/lib/16_sprit.c b/src/lib/16_sprit.c index 8cac6595..d9ecad99 100755 --- a/src/lib/16_sprit.c +++ b/src/lib/16_sprit.c @@ -99,18 +99,29 @@ void print_anim_ids(struct sprite *spri) void animate_spri(entity_t *enti, video_t *video) { #define INC_PER_FRAME if(enti->q&1) enti->persist_aniframe++; if(enti->persist_aniframe>4) enti->persist_aniframe = 1; - const unsigned int offscreen_ofs = video->page[0].pagesize+video->page[1].pagesize;//(vga_state.vga_stride * vga_state.vga_height); - const unsigned int pattern_ofs = 0x10000UL - (uint16_t)video->page[2].data;//(vga_state.vga_stride * vga_state.vga_height); + const unsigned int offscreen_ofs = video->page[0].pagesize+video->page[1].pagesize;//(vga_state.vga_stride * vga_state.vga_height); + const unsigned int pattern_ofs = 0x10000UL - (uint16_t)video->page[2].data;//(vga_state.vga_stride * vga_state.vga_height); + unsigned int copy_ofs = offscreen_ofs; + unsigned int display_ofs = 0x0000; unsigned int i,o,o2; int j; int x,y,rx,ry,w,h; - VGA_RAM_PTR omemptr; + VGA_RAM_PTR omemptr = (VGA_RAM_PTR)video->page[0].data;// save original mem ptr + x=enti->spri->x; + y=enti->spri->y; // Depending on delay, update indices //#define FRAME1 modexDrawSpriteRegion(pip[(pip->video->p)].page, x, y, 48, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR); //#define FRAME2 modexDrawSpriteRegion(pip[(pip->video->p)].page, x, y, 24, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR); stand //#define FRAME3 modexDrawSpriteRegion(pip[(pip->video->p)].page, x, y, 0, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR); //#define FRAME4 modexDrawSpriteRegion(pip[(pip->video->p)].page, x, y, 24, player[pn].enti.dire, 24, 32, PLAYERBMPDATAPTR); stand + + /* copy active display (0) to offscreen buffer (0x4000) */ + vga_state.vga_draw_stride_limit = vga_state.vga_draw_stride = vga_state.vga_stride; + vga_setup_wm1_block_copy(); + vga_wm1_mem_block_copy(copy_ofs, display_ofs, vga_state.vga_stride * vga_state.vga_height); + vga_restore_rm0wm0(); + switch(enti->spri->delay) { // Delay = 0 means that sprite should loop. Nothing to change here @@ -138,9 +149,6 @@ void animate_spri(entity_t *enti, video_t *video) // Events go here - omemptr = (VGA_RAM_PTR)video->page[0].data;// save original mem ptr - x=enti->spri->x; - y=enti->spri->y; // Draw sprite j = get_vrl_by_id(enti->spri->spritesheet, enti->spri->curr_spri_id, enti->spri->sprite_vrl_cont); diff --git a/src/lib/16_tdef.h b/src/lib/16_tdef.h index 004b5d1c..206598c4 100755 --- a/src/lib/16_tdef.h +++ b/src/lib/16_tdef.h @@ -99,25 +99,18 @@ typedef struct{ sword tilemidposscreeny; /* middle tile y position */ /* needed for scroll system to work accordingly */ sword tileplayerposscreenx; /* player position on screen */ /* needed for scroll and map system to work accordingly */ sword tileplayerposscreeny; /* player position on screen */ /* needed for scroll and map system to work accordingly */ -} ti_t; +} tileinfo_t; typedef struct { nibble/*word*/ id; /* the Identification number of the page~ For layering~ */ byte far* data; /* the data for the page */ + tileinfo_t ti; word dx; /* col we are viewing on virtual screen (on page[0]) */ /* off screen buffer on the left size */ word dy; /* row we are viewing on virtual screen (on page[0]) */ /* off screen buffer on the top size */ word sw; /* screen width */ /* resolution */ word sh; /* screen heigth */ /* resolution */ - word tw; /* screen width in tiles */ - word th; /* screen height in tiles */ word width; /* virtual width of the page */ word height; /* virtual height of the page */ - word tilesw; /* virtual screen width in tiles */ - word tilesh; /* virtual screen height in tiles */ - sword tilemidposscreenx; /* middle tile x position */ /* needed for scroll system to work accordingly */ - sword tilemidposscreeny; /* middle tile y position */ /* needed for scroll system to work accordingly */ - sword tileplayerposscreenx; /* player position on screen */ /* needed for scroll and map system to work accordingly */ - sword tileplayerposscreeny; /* player position on screen */ /* needed for scroll and map system to work accordingly */ word stridew; /* width/4 */ /* VGA */ word pagesize; /* page size */ word pi; /* increment page by this much to preserve location */ @@ -126,7 +119,7 @@ typedef struct { sword delta; // How much should we shift the page for smooth scrolling } page_t; -//new structs +//newer structs typedef struct { int x; //entity exact position on the viewable map @@ -285,6 +278,36 @@ typedef struct byte grneeded[NUMCHUNKS]; } video_t; +//from scroll16 +//========================================================================== +typedef struct +{ + map_t *map; + page_t *page; + int tx,ty; //appears to be the top left tile position on the viewable screen map + word dxThresh,dyThresh; //Threshold for physical tile switch + video_t *video; //pointer to game variables of the video + nibble __near *p; // pointer to video's render page num + nibble __near *sp; // pointer to video's show page num + int dx, dy; // draw row and col var +//newer vars! + int delta, d; +} map_view_t; +/* Map is presumed to: + * 1. Have all the required layers and tilesets within itself + * 2. Have a 'fence' around accessible blocks to simplify boundary logic + * 3. Have a persistent map and tile size among the layers + * Map view is presumed to: + * 1. Calculate, store and update a panning info, which includes, but not limited to: + * combined layer information, actual map representation (reflecting real state of the game), + * pixel shift for smooth tile scrolling. + * 2. Provide ways to draw a visible part of map. For simplicity with smooth scrolling, + * additional row/column is always drawn at the each side of the map. This implies that 'fence' + * should have a sprite too. Map is drawn left-to-right, top-to-bottom. + */ + +//========================================================================== + //from 16_mm //========================================================================== diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 59ce49aa..31a76ce6 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -162,12 +162,12 @@ void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv) break; } -// gv->video.page[0].tw = gv->video.page[0].sw/TILEWH; -// gv->video.page[0].th = gv->video.page[0].sh/TILEWH; +// gv->video.page[0].ti.tw = gv->video.page[0].sw/TILEWH; +// gv->video.page[0].ti.th = gv->video.page[0].sh/TILEWH; //TODO MAKE FLEXIBLE~ -// gv->video.page[0].tilemidposscreenx = gv->video.page[0].tilesw; -// gv->video.page[0].tilemidposscreeny = (gv->video.page[0].tilesh/2)+1; +// gv->video.page[0].ti.tilemidposscreenx = gv->video.page[0].ti.tilesw; +// gv->video.page[0].ti.tilemidposscreeny = (gv->video.page[0].ti.tilesh/2)+1; } void @@ -191,12 +191,12 @@ modexDefaultPage(page_t *p) page.sh = p->sh; page.width = p->sw+TILEWHD; page.height = p->sh+TILEWHD; - page.tw = page.sw/TILEWH; - page.th = page.sh/TILEWH; - page.tilesw=page.width/TILEWH; - page.tilesh=page.height/TILEWH; - page.tilemidposscreenx = page.tw/2; - page.tilemidposscreeny = (page.th/2)+1; + page.ti.tw = page.sw/TILEWH; + page.ti.th = page.sh/TILEWH; + page.ti.tilesw=page.width/TILEWH; + page.ti.tilesh=page.height/TILEWH; + page.ti.tilemidposscreenx = page.ti.tw/2; + page.ti.tilemidposscreeny = (page.ti.th/2)+1; page.stridew=page.width/4; page.pagesize = (word)(page.stridew)*page.height; page.pi=page.width*4; @@ -219,10 +219,10 @@ modexNextPage(page_t *p) { result.sh = p->sh; result.width = p->width; result.height = p->height; - result.tw = p->tw; - result.th = p->th; - result.tilesw = p->tilesw; - result.tilesh = p->tilesh; + result.ti.tw = p->ti.tw; + result.ti.th = p->ti.th; + result.ti.tilesw = p->ti.tilesw; + result.ti.tilesh = p->ti.tilesh; result.stridew=p->stridew; result.pagesize = p->pagesize; result.pi=result.width*4; @@ -244,10 +244,10 @@ modexNextPageFlexibleSize(page_t *p, word x, word y) result.sh = y; result.width = x; result.height = y; - result.tw = result.sw/TILEWH; - result.th = result.sh/TILEWH; - result.tilesw=result.width/TILEWH; - result.tilesh=result.height/TILEWH; + result.ti.tw = result.sw/TILEWH; + result.ti.th = result.sh/TILEWH; + result.ti.tilesw=result.width/TILEWH; + result.ti.tilesh=result.height/TILEWH; result.id = p->id+1; result.stridew=result.width/4;//p->sw/4; result.pagesize = (word)(result.stridew)*result.height; @@ -1256,7 +1256,7 @@ void modexcls(page_t *page, byte color, byte *Where) /* set map mask to all 4 planes */ outpw(SC_INDEX, 0xff02); //_fmemset(VGA, color, 16000); - _fmemset(Where, color, page->width*(page->height)/4); + _fmemset(Where, color, page->stridew*page->height); } // @@ -1330,8 +1330,8 @@ void VL_PrintmodexmemInfo(video_t *v) // printf("========================================\n"); printf("VL_PrintmodexmemInfo:\n"); // printf("========================================\n"); - printf(" Virtual Screen: %dx", v->page[0].width); printf("%d ", v->page[0].height); printf("Tile: %dx", v->page[0].tilesw); printf("%d", v->page[0].tilesh); printf("=((Virtual Screen)/16)\n"); - printf(" Screen: %dx", v->page[0].sw); printf("%d ", v->page[0].sh); printf("Tile: %dx", v->page[0].tw); printf("%d", v->page[0].th); printf("=((Screen)/16)\n"); + printf(" Virtual Screen: %dx", v->page[0].width); printf("%d ", v->page[0].height); printf("Tile: %dx", v->page[0].ti.tilesw); printf("%d", v->page[0].ti.tilesh); printf("=((Virtual Screen)/16)\n"); + printf(" Screen: %dx", v->page[0].sw); printf("%d ", v->page[0].sh); printf("Tile: %dx", v->page[0].ti.tw); printf("%d", v->page[0].ti.th); printf("=((Screen)/16)\n"); printf(" Free Video Memory: %u\n", v->vmem_remain); printf(" page"); diff --git a/src/lib/bakapee.c b/src/lib/bakapee.c index 917784f5..0b2c6d04 100755 --- a/src/lib/bakapee.c +++ b/src/lib/bakapee.c @@ -280,8 +280,10 @@ void ding(page_t *page, bakapee_t *pee, word q) colortest(page, pee); break; case 6: - pee->coor = rand()%256; - modexcls(page, pee->coor, VGA); +// pee->coor = rand()%256; +// modexcls(page, pee->coor, VGA); + colorz(page, pee); + modexprint(page, page->sw/2, page->sh/2, 1, 47, 0, "bakapi"); break; case 7: if(pee->coor <= pee->hgq) diff --git a/src/lib/doslib b/src/lib/doslib index 82810640..e6fba71d 160000 --- a/src/lib/doslib +++ b/src/lib/doslib @@ -1 +1 @@ -Subproject commit 82810640576d089bbc4b382b3318a41679ff2817 +Subproject commit e6fba71d59fad9b5e5bce6115f38dfb61c299a32 diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index d6d7875e..4ad596f0 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -36,7 +36,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) break; //right movement case 3: - if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->tilemidposscreenx && + if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->ti.tw < pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->ti.tilemidposscreenx && !(pip[0].map->data[(player[pn].enti.tx)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx+1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection! { player[pn].walktype=2; @@ -73,7 +73,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) break; //left movement case 1: - if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->tilemidposscreenx && + if(pip[0].tx > 0 && pip[0].tx+pip[0].page->ti.tw <= pip[0].map->width && player[pn].enti.tx == pip[0].tx+pip[0].page->ti.tilemidposscreenx && !(pip[0].map->data[(player[pn].enti.tx-2)+(pip[0].map->width*(player[pn].enti.ty-1))] == 0))//!(player[pn].enti.tx-1 == TRIGGX && player[pn].enti.ty == TRIGGY)) //collision detection! { player[pn].walktype=2; @@ -110,7 +110,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) break; //down movement case 4: - if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->tilemidposscreeny && + if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->ti.th < pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->ti.tilemidposscreeny && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty+1 == TRIGGY)) //collision detection! { player[pn].walktype=2; @@ -147,7 +147,7 @@ void ZC_walk(map_view_t *pip, player_t *player, word pn) break; //up movement case 0: - if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->tilemidposscreeny && + if(pip[0].ty > 0 && pip[0].ty+pip[0].page->ti.th <= pip[0].map->height && player[pn].enti.ty == pip[0].ty+pip[0].page->ti.tilemidposscreeny && !(pip[0].map->data[(player[pn].enti.tx-1)+(pip[0].map->width*(player[pn].enti.ty-2))] == 0))//!(player[pn].enti.tx == TRIGGX && player[pn].enti.ty-1 == TRIGGY)) //collision detection! { player[pn].walktype=2; @@ -194,7 +194,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn) { //right movement case 3: - if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->tw < pip[0].page->tilesw) + if(pip[0].tx >= 0 && pip[0].tx+pip[0].page->ti.tw < pip[0].page->ti.tilesw) { if(player[pn].enti.q<=player[pn].enti.spt) { @@ -207,7 +207,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn) //left movement case 1: - if(pip[0].tx > 0 && pip[0].tx+pip[0].page->tw <= pip[0].page->tilesw) + if(pip[0].tx > 0 && pip[0].tx+pip[0].page->ti.tw <= pip[0].page->ti.tilesw) { if(player[pn].enti.q<=player[pn].enti.spt) { @@ -220,7 +220,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn) //down movement case 4: - if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->th < pip[0].page->tilesh) + if(pip[0].ty >= 0 && pip[0].ty+pip[0].page->ti.th < pip[0].page->ti.tilesh) { if(player[pn].enti.q<=player[pn].enti.spt) { @@ -233,7 +233,7 @@ void ZC_panPageManual(map_view_t *pip, player_t *player, word pn) //up movement case 0: - if(pip[0].ty > 0 && pip[0].ty+pip[0].page->th <= pip[0].page->tilesh) + if(pip[0].ty > 0 && pip[0].ty+pip[0].page->ti.th <= pip[0].page->ti.tilesh) { if(player[pn].enti.q<=player[pn].enti.spt) { @@ -436,10 +436,10 @@ void near mapScrollRight(map_view_t *mv, player_t *player, word id, word plid) if(player[plid].enti.q==4) #endif if(id==0) - mapDrawCol(&mv[0], mv[0].tx + mv[0].page->tw, mv[0].ty-1, x, player, DRAWCOLNUM); + mapDrawCol(&mv[0], mv[0].tx + mv[0].page->ti.tw, mv[0].ty-1, x, player, DRAWCOLNUM); // else // if(!pageflipflop && !pageploop) -// modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->th+2)); +// modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->ti.th+2)); mv[0].video->r=1; } @@ -473,7 +473,7 @@ void near mapScrollLeft(map_view_t *mv, player_t *player, word id, word plid) mapDrawCol(&mv[0], mv[0].tx - 1, mv[0].ty-1, x, player, DRAWCOLNUM); // else // if(!pageflipflop && !pageploop) -// modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->th+2)); +// modexCopyPageRegion(mv[id].page, mv[0].page, x, 0, x, 0, mv[id].map->tiles->tileWidth, mv[id].map->tiles->tileHeight*(mv[0].page->ti.th+2)); mv[0].video->r=1; } @@ -507,7 +507,7 @@ void near mapScrollUp(map_view_t *mv, player_t *player, word id, word plid) mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty-1, y, player, DRAWCOLNUM); // else // if(!pageflipflop && !pageploop) -// modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->tw+2), mv[id].map->tiles->tileHeight); +// modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->ti.tw+2), mv[id].map->tiles->tileHeight); mv[0].video->r=1; } @@ -538,10 +538,10 @@ void near mapScrollDown(map_view_t *mv, player_t *player, word id, word plid) if(player[plid].enti.q==4) #endif if(id==0) - mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->th, y, player, DRAWCOLNUM); + mapDrawRow(&mv[0], mv[0].tx - 1, mv[0].ty+mv[0].page->ti.th, y, player, DRAWCOLNUM); // else // if(!pageflipflop && !pageploop) -// modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->tw+2), mv[id].map->tiles->tileHeight); +// modexCopyPageRegion(mv[id].page, mv[0].page, 0, y, 0, y, mv[id].map->tiles->tileWidth*(mv[0].page->ti.tw+2), mv[id].map->tiles->tileHeight); mv[0].video->r=1; } @@ -620,8 +620,8 @@ void near ScrollDown(map_view_t *mv, player_t *player, word id, word plid) //default player position on the viewable map void playerXYpos(int x, int y, player_t *player, map_view_t *pip, nibble pn) { - player[pn].enti.tx = x + pip[0].tx + pip[0].page->tilemidposscreenx; - player[pn].enti.ty = y + pip[0].ty + pip[0].page->tilemidposscreeny; + player[pn].enti.tx = x + pip[0].tx + pip[0].page->ti.tilemidposscreenx; + player[pn].enti.ty = y + pip[0].ty + pip[0].page->ti.tilemidposscreeny; } //=========================================================================== @@ -1129,7 +1129,7 @@ boolean ZC_walk2(entity_t *enti, map_view_t *map_v) void player_walk(player_t *player, map_view_t *map_v){ int dx=16, dy=16; - if(ZC_walk2(&(player->enti), map_v) && boundary_check(map_v->tx, map_v->ty, dx, dy, map_v->map->width - 2*map_v->page->tilesw, map_v->map->height - 2*map_v->page->tilesh)) + if(ZC_walk2(&(player->enti), map_v) && boundary_check(map_v->tx, map_v->ty, dx, dy, map_v->map->width - 2*map_v->page->ti.tilesw, map_v->map->height - 2*map_v->page->ti.tilesh)) { mapScroll(map_v, player); // (Un)load stuff? diff --git a/src/lib/scroll16.h b/src/lib/scroll16.h index fdfd58a2..dc81f873 100755 --- a/src/lib/scroll16.h +++ b/src/lib/scroll16.h @@ -61,33 +61,6 @@ //#define DRAWCOLNUM player[plid].enti.q //#define DRAWROLNUM player[plid].enti.q -typedef struct { - map_t *map; - page_t *page; - int tx; //appears to be the top left tile position on the viewable screen map - int ty; //appears to be the top left tile position on the viewable screen map - word dxThresh; //Threshold for physical tile switch - word dyThresh; //Threshold for physical tile switch - video_t *video; //pointer to game variables of the video - nibble __near *p; // pointer to video's render page num - nibble __near *sp; // pointer to video's show page num - int dx, dy; // draw row and col var -//newer vars! - int delta, d; -} map_view_t; -/* Map is presumed to: - * 1. Have all the required layers and tilesets within itself - * 2. Have a 'fence' around accessible blocks to simplify boundary logic - * 3. Have a persistent map and tile size among the layers - * Map view is presumed to: - * 1. Calculate, store and update a panning info, which includes, but not limited to: - * combined layer information, actual map representation (reflecting real state of the game), - * pixel shift for smooth tile scrolling. - * 2. Provide ways to draw a visible part of map. For simplicity with smooth scrolling, - * additional row/column is always drawn at the each side of the map. This implies that 'fence' - * should have a sprite too. Map is drawn left-to-right, top-to-bottom. - */ - //for null map! #define MAPW 40 #define MAPH 30 -- 2.39.2