From: sparky4 Date: Tue, 3 Nov 2015 18:59:17 +0000 (-0600) Subject: pbuf???? X-Git-Url: http://4ch.mooo.com/gitweb/?a=commitdiff_plain;h=74929b07c8b45a20eb5079444f4df21c9898e605;p=16.git pbuf???? --- diff --git a/16.exe b/16.exe index 4033c177..2cfa243e 100755 Binary files a/16.exe and b/16.exe differ diff --git a/exmmtest.exe b/exmmtest.exe index b8d0240f..494d15e6 100755 Binary files a/exmmtest.exe and b/exmmtest.exe differ diff --git a/maptest.exe b/maptest.exe index d26b9e7e..392d02c7 100755 Binary files a/maptest.exe and b/maptest.exe differ diff --git a/pcxtest.exe b/pcxtest.exe index 48540911..02beb338 100755 Binary files a/pcxtest.exe and b/pcxtest.exe differ diff --git a/pcxtest2.exe b/pcxtest2.exe index 0201569b..1bee8f18 100755 Binary files a/pcxtest2.exe and b/pcxtest2.exe differ diff --git a/planrpcx.exe b/planrpcx.exe index d8301b34..7276d5bc 100755 Binary files a/planrpcx.exe and b/planrpcx.exe differ diff --git a/scroll.exe b/scroll.exe index f7ce4bec..a8c8ab9f 100755 Binary files a/scroll.exe and b/scroll.exe differ diff --git a/src/lib/16_head.h b/src/lib/16_head.h index 941069c2..5db7e3f4 100755 --- a/src/lib/16_head.h +++ b/src/lib/16_head.h @@ -172,16 +172,6 @@ typedef void __based(__self) * memptr; typedef void _seg * memptr; #endif -#define AARED "\x1b[41;31m" -#define AABLUE "\x1b[44;34m" -#define AAGREEN "\x1b[42;32m" -#define AAYELLOW "\x1b[43;33m" -#define AAGREY "\x1b[47;37m" -#define AABLACK "\x1b[40;30m" -#define AAWHITE "\x1b[47;37m" -#define AAMAGENTA "\x1b[45;35m" -#define AARESET "\x1b[0m" - /* local function */ void wait(clock_t wait); diff --git a/src/lib/16_in.h b/src/lib/16_in.h index d910f3ec..2157fa3a 100755 --- a/src/lib/16_in.h +++ b/src/lib/16_in.h @@ -223,8 +223,9 @@ typedef struct word d; //direction!! wwww word q; //loop variable word speed; //player speed! +//0000 planar_buf_t huge *data; //supposively the sprite sheet data // planar_buf_t data; //supposively the sprite sheet data -// bitmap_t data; //supposively the sprite sheet data +////0000---- bitmap_t data; //supposively the sprite sheet data sword hp; //hitpoints of the player int persist_aniframe; /* gonna be increased to 1 before being used, so 0 is ok for default */ CursorInfo info; diff --git a/src/lib/bitmap.h b/src/lib/bitmap.h index 95c6782c..4b31c4b4 100755 --- a/src/lib/bitmap.h +++ b/src/lib/bitmap.h @@ -28,6 +28,8 @@ #include "src/lib/types.h" #include "src/lib/16_head.h" +#define PALSIZE 768 + typedef struct { byte huge *data; word width; diff --git a/src/lib/mapread.c b/src/lib/mapread.c index 205bf39a..9bfdf6c9 100755 --- a/src/lib/mapread.c +++ b/src/lib/mapread.c @@ -74,7 +74,7 @@ word dump(const char *js, jsmntok_t *t, size_t count, word indent, char *js_sv, //map->tiles->data = malloc(sizeof(bitmap_t)); //fix this to be far~ bp = bitmapLoadPcx("data/ed.pcx"); - map->tiles->btdata = &bp; + map->tiles->data = planar_buf_from_bitmap0(&bp); //map->tiles->data->data = malloc((16/**2*/)*16); //map->tiles->data->width = (16/**2*/); //map->tiles->data->height= 16; diff --git a/src/lib/mapread.h b/src/lib/mapread.h index b2bf0fd4..3f9e3ac6 100755 --- a/src/lib/mapread.h +++ b/src/lib/mapread.h @@ -16,8 +16,9 @@ //#define DEBUG_JS typedef struct { - bitmap_t huge *btdata; - planar_buf_t huge *data; +//---- bitmap_t huge *btdata; + //planar_buf_t huge *data; + planar_buf_t data; word tileHeight; word tileWidth; unsigned int rows; diff --git a/src/lib/planar.c b/src/lib/planar.c index 5541217f..4eda4515 100755 --- a/src/lib/planar.c +++ b/src/lib/planar.c @@ -30,10 +30,11 @@ be destroyed with the planar_buf_free function when no longer needed. */ -planar_buf_t * +planar_buf_t huge * planar_buf_from_bitmap(bitmap_t *b) { planar_buf_t *p; int plane, bi, pi, x, y; + word q; /* allocate the buffer */ p = planar_buf_alloc(b->width, b->height); @@ -59,12 +60,18 @@ planar_buf_from_bitmap(bitmap_t *b) { if(plane) pi++; } + p->palette = modexNewPal(); + for(;qpalette[q]=b->palette[q]; + } + return p; } /* allocates a planar buffer with specified dimensions */ -planar_buf_t * +planar_buf_t huge * planar_buf_alloc(word width, word height) { planar_buf_t *p; int i; @@ -97,3 +104,41 @@ planar_buf_free(planar_buf_t *p) { /* free the structure */ free(p); } + +/* non pointer version */ +planar_buf_t planar_buf_from_bitmap0(bitmap_t *b) { + planar_buf_t p; + int plane, bi, pi, x, y; + word q=0; + + /* allocate the buffer */ + p = *planar_buf_alloc(b->width, b->height); + + /* copy the bitmap data into the planar format */ + bi=0; + pi=0; + for(y=0; y < b->height; y++) { + /* start on the first plane */ + plane=0; + for(x=0; x < b->width; x++) { + /* copy to each plane */ + p.plane[plane++][pi]=b->data[bi++]; + + /* handle the completion of 4 planes. */ + if(plane==4) { + plane=0; + pi++; + } + } + + /* correct for images not divisible by 4 */ + if(plane) pi++; + } + p.palette = modexNewPal(); + for(;qpalette[q]; + } + + return p; +} diff --git a/src/lib/planar.h b/src/lib/planar.h index af8c5bf4..4cd7365b 100755 --- a/src/lib/planar.h +++ b/src/lib/planar.h @@ -31,11 +31,14 @@ #include "src/lib/16_mm.h" #include "src/lib/16_hc.h" +extern byte *modexNewPal(); + typedef struct { byte huge *plane[4]; /* 4 planes of image data */ word width; /* width of the image (spread across 4 planes) */ word height; /* height of the image (spread across 4 planes) */ word pwidth; /* the number of bytes in each plane */ + byte *palette; } planar_buf_t; /* creates a planar buffer from the bitmap data. @@ -43,11 +46,15 @@ typedef struct { be destroyed with the planar_buf_free function when no longer needed. */ -planar_buf_t *planar_buf_from_bitmap(bitmap_t *b); +planar_buf_t huge *planar_buf_from_bitmap(bitmap_t *b); /* allocates a planar buffer with specified dimensions */ -planar_buf_t *planar_buf_alloc(word width, word height); +planar_buf_t huge *planar_buf_alloc(word width, word height); /* deallocates a planar buffer */ void planar_buf_free(planar_buf_t *p); + +/* non pointer version~ */ +planar_buf_t planar_buf_from_bitmap0(bitmap_t *b); + #endif diff --git a/src/lib/scroll16.c b/src/lib/scroll16.c index 347062bd..7dd610f7 100755 --- a/src/lib/scroll16.c +++ b/src/lib/scroll16.c @@ -60,7 +60,7 @@ void walk(map_view_t *pip, player_t *player, word pn) { modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x-4, player[pn].y-TILEWH, player[pn].x-4, player[pn].y-TILEWH, 24, 32); #ifdef SPRITE - PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 24, 32, &player[pn].data); + PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 24, 32, PLAYERBMPDATA); #else modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 14); #endif @@ -101,7 +101,7 @@ void walk(map_view_t *pip, player_t *player, word pn) { modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x-4, player[pn].y-TILEWH, player[pn].x-4, player[pn].y-TILEWH, 24, 32); #ifdef SPRITE - PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 96, 24, 32, &player[pn].data); + PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 96, 24, 32, PLAYERBMPDATA); #else modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 10); #endif @@ -142,7 +142,7 @@ void walk(map_view_t *pip, player_t *player, word pn) { modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x-4, player[pn].y-TILEWH, player[pn].x-4, player[pn].y-TILEWH, 24, 32); #ifdef SPRITE - PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 64, 24, 32, &player[pn].data); + PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATA); #else modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 9); #endif @@ -183,7 +183,7 @@ void walk(map_view_t *pip, player_t *player, word pn) { modexCopyPageRegion(pip[1].page, pip[0].page, player[pn].x-4, player[pn].y-TILEWH, player[pn].x-4, player[pn].y-TILEWH, 24, 32); #ifdef SPRITE - PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 0, 24, 32, &player[pn].data); + PBUFSFUN(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 0, 24, 32, PLAYERBMPDATA); #else modexClearRegion(pip[1].page, player[pn].x-4, player[pn].y-TILEWH, 24, 32, 12); #endif @@ -478,8 +478,8 @@ mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y) } else { - rx = (((i-1) % ((t->btdata->width)/t->tileWidth)) * t->tileWidth); - ry = (((i-1) / ((t->btdata->height)/t->tileHeight)) * t->tileHeight); + rx = (((i-1) % ((t->data.width)/t->tileWidth)) * t->tileWidth); + ry = (((i-1) / ((t->data.height)/t->tileHeight)) * t->tileHeight); ////0000printf("i=%d\n", i); switch(t->debug_text) { @@ -488,7 +488,7 @@ mapDrawTile(tiles_t *t, word i, page_t *page, word x, word y) modexClearRegion(page, x, y, t->tileWidth, t->tileHeight, ((t->debug_data[i])+1)*2); //cannot print number value du to it being slow as bakapee #else - PBUFBFUN(page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->data)); + PBUFBFUN(page, x, y, rx, ry, t->tileWidth, t->tileHeight, &(t->data)); //modexDrawBmpRegion(page, x, y, rx, ry, t->tileWidth, t->tileHeight, (t->btdata)); #endif break; @@ -618,53 +618,53 @@ void shinku(map_view_t *pip, global_game_variables_t *gv) } } -void near animatePlayer(map_view_t *pip, player_t *player, word playnum, sword scrollswitch) +void near animatePlayer(map_view_t *pip, player_t *player, word pn, sword scrollswitch) { - sword x = player[playnum].x; - sword y = player[playnum].y; + sword x = player[pn].x; + sword y = player[pn].y; #ifdef SPRITE word dire=32; //direction #else word dire=8; //direction #endif sword qq; //scroll offset - word ls = player[playnum].persist_aniframe; + word ls = player[pn].persist_aniframe; if(scrollswitch==0) qq = 0; - else qq = ((player[playnum].q)*(player[playnum].speed)); + else qq = ((player[pn].q)*(player[pn].speed)); x-=4; y-=TILEWH; - switch (player[playnum].d) + switch (player[pn].d) { case 0: //up - dire*=player[playnum].d; + dire*=player[pn].d; y-=qq; break; case 3: // right - dire*=(player[playnum].d-2); + dire*=(player[pn].d-2); x+=qq; break; case 2: break; case 4: //down - dire*=(player[playnum].d-2); + dire*=(player[pn].d-2); y+=qq; break; case 1: //left - dire*=(player[playnum].d+2); + dire*=(player[pn].d+2); x-=qq; break; } #ifdef SPRITE -#define FRAME1 PBUFSFUN(pip[1].page, x, y, 48, dire, 24, 32, &player[playnum].data); -#define FRAME2 PBUFSFUN(pip[1].page, x, y, 24, dire, 24, 32, &player[playnum].data); -#define FRAME3 PBUFSFUN(pip[1].page, x, y, 0, dire, 24, 32, &player[playnum].data); -#define FRAME4 PBUFSFUN(pip[1].page, x, y, 24, dire, 24, 32, &player[playnum].data); +#define FRAME1 PBUFSFUN(pip[1].page, x, y, 48, dire, 24, 32, PLAYERBMPDATA); +#define FRAME2 PBUFSFUN(pip[1].page, x, y, 24, dire, 24, 32, PLAYERBMPDATA); +#define FRAME3 PBUFSFUN(pip[1].page, x, y, 0, dire, 24, 32, PLAYERBMPDATA); +#define FRAME4 PBUFSFUN(pip[1].page, x, y, 24, dire, 24, 32, PLAYERBMPDATA); #else #define FRAME1 modexClearRegion(pip[1].page, x, y, 24, 32, 2+dire); #define FRAME2 modexClearRegion(pip[1].page, x, y, 24, 32, 1+dire); diff --git a/src/lib/scroll16.h b/src/lib/scroll16.h index 94d3cf82..93936157 100755 --- a/src/lib/scroll16.h +++ b/src/lib/scroll16.h @@ -34,10 +34,11 @@ #include "src/lib/wcpu/wcpu.h" //#define SPRITE -//#define TILERENDER +#define TILERENDER -#define PBUFSFUN modexDrawSpritePBufRegion -#define PBUFBFUN modexDrawBmpPBufRegion +#define PBUFSFUN modexDrawSpritePBufRegion +#define PBUFBFUN modexDrawBmpPBufRegion +#define PLAYERBMPDATA &player[pn].data typedef struct { map_t *map; diff --git a/src/lib/typdefst.h b/src/lib/typdefst.h index b7dc2fa9..3f53cd7f 100755 --- a/src/lib/typdefst.h +++ b/src/lib/typdefst.h @@ -25,6 +25,17 @@ #include "src/lib/types.h" + +#define AARED "\x1b[41;31m" +#define AABLUE "\x1b[44;34m" +#define AAGREEN "\x1b[42;32m" +#define AAYELLOW "\x1b[43;33m" +#define AAGREY "\x1b[47;37m" +#define AABLACK "\x1b[40;30m" +#define AAWHITE "\x1b[47;37m" +#define AAMAGENTA "\x1b[45;35m" +#define AARESET "\x1b[0m" + /* * typedefs of the game variables! */ diff --git a/src/scroll.c b/src/scroll.c index eb600195..ecfa6725 100755 --- a/src/scroll.c +++ b/src/scroll.c @@ -36,6 +36,8 @@ player_t player[MaxPlayers]; map_view_t mv[3]; map_view_t *bg, *spri, *mask;//, *tmp; bitmap_t p; +word pn=0; +static planar_buf_t pp; float t; sword bakapee; @@ -57,15 +59,14 @@ sword bakapee; void main(int argc, char *argv[]) { - byte *mesg=malloc(sizeof(dword)); - if(argv[1]) bakapee = atoi(argv[1]); else bakapee = 1; player[0].persist_aniframe=0; player[0].speed=4; + //player[0].data = &pp; printf("starting timer\n"); start_timer(&gvar); @@ -87,7 +88,7 @@ void main(int argc, char *argv[]) /* draw the tiles */ #ifdef MODEX ptr = map.data; - mappalptr = map.tiles->btdata->palette; + //mappalptr = map.tiles->btdata->palette; /* data */ p = bitmapLoadPcx("data/ptmp.pcx"); // load sprite @@ -95,6 +96,9 @@ void main(int argc, char *argv[]) /* create the planar buffer */ ////++++ (player[0].data) = *planar_buf_from_bitmap(&p); + printf("load pee!!\n"); + pp = planar_buf_from_bitmap0(&p); + printf("done!\n"); #endif /* input! */ @@ -186,14 +190,15 @@ void main(int argc, char *argv[]) npc0.q=1; npc0.d=0; modexDrawSpriteRegion(spri->page, npc0.x-4, npc0.y-TILEWH, 24, 64, 24, 32, &npctmp);*/ -IN_Ack(); + modexCopyPageRegion(mv[1].page, mv[0].page, 0, 0, 0, 0, mv[0].page->width, mv[0].page->height); #ifndef SPRITE modexClearRegion(mv[1].page, player[0].x-4, player[0].y-TILEWH, 24, 32, 15); #else - PBUFSFUN(spri->page, player[0].x-4, player[0].y-TILEWH, 24, 64, 24, 32, &player[0].data); + //PBUFSFUN(spri->page, player[0].x-4, player[0].y-TILEWH, 24, 64, 24, 32, PLAYERBMPDATA); + PBUFSFUN(spri->page, player[0].x-4, player[0].y-TILEWH, 24, 64, 24, 32, &pp); #endif -IN_Ack(); + modexShowPage(spri->page); //modexClearRegion(mv[2].page, 0, 0, mv[2].page->width, mv[2].page->height, 1); #ifdef MODEX diff --git a/test.exe b/test.exe index c9ba9e3b..f33b73c5 100755 Binary files a/test.exe and b/test.exe differ diff --git a/test2.exe b/test2.exe index eafa2c55..950104fa 100755 Binary files a/test2.exe and b/test2.exe differ