]> 4ch.mooo.com Git - 16.git/commitdiff
pbuf????
authorsparky4 <sparky4@cock.li>
Tue, 3 Nov 2015 18:59:17 +0000 (12:59 -0600)
committersparky4 <sparky4@cock.li>
Tue, 3 Nov 2015 18:59:17 +0000 (12:59 -0600)
20 files changed:
16.exe
exmmtest.exe
maptest.exe
pcxtest.exe
pcxtest2.exe
planrpcx.exe
scroll.exe
src/lib/16_head.h
src/lib/16_in.h
src/lib/bitmap.h
src/lib/mapread.c
src/lib/mapread.h
src/lib/planar.c
src/lib/planar.h
src/lib/scroll16.c
src/lib/scroll16.h
src/lib/typdefst.h
src/scroll.c
test.exe
test2.exe

diff --git a/16.exe b/16.exe
index 4033c177a0651373c1b484038bc483eebf5d5c40..2cfa243e60d361cd18c1f3515bc1274704c5ca2c 100755 (executable)
Binary files a/16.exe and b/16.exe differ
index b8d0240f68b300300c2dc10528fcd4697aec76e0..494d15e69319cb2aed2cc43acee8457bd7985b94 100755 (executable)
Binary files a/exmmtest.exe and b/exmmtest.exe differ
index d26b9e7ef7b226ef7ca96987cb2aa438ca15dfac..392d02c71dc0dcab0ea049b741def80b7093b526 100755 (executable)
Binary files a/maptest.exe and b/maptest.exe differ
index 48540911ea9f27681614c0025fc90ce7d585c67b..02beb338302055775a4ccf853224ec0dfa2f1b36 100755 (executable)
Binary files a/pcxtest.exe and b/pcxtest.exe differ
index 0201569b5c92a189d0f5028e85b2e2be8e6f0da6..1bee8f188660fe05c833d6ef1d76ff2bf750a020 100755 (executable)
Binary files a/pcxtest2.exe and b/pcxtest2.exe differ
index d8301b34e9f7c02ff167e3444675279e0d637865..7276d5bc5fbb735e9472b01e95daeceeca68d8f7 100755 (executable)
Binary files a/planrpcx.exe and b/planrpcx.exe differ
index f7ce4bec268b0cb6c65e4ba60e39863f316d3487..a8c8ab9f4718d993aeca5194cec9fb9bd3322e09 100755 (executable)
Binary files a/scroll.exe and b/scroll.exe differ
index 941069c2732b9816c40a48a270bd9a8dcc3f08d1..5db7e3f4e2619a414da03aefc76d9fa1cecae647 100755 (executable)
@@ -172,16 +172,6 @@ typedef void __based(__self) * memptr;
 typedef void _seg * memptr;\r
 #endif\r
 \r
-#define AARED          "\x1b[41;31m"\r
-#define AABLUE         "\x1b[44;34m"\r
-#define AAGREEN        "\x1b[42;32m"\r
-#define AAYELLOW       "\x1b[43;33m"\r
-#define AAGREY         "\x1b[47;37m"\r
-#define AABLACK        "\x1b[40;30m"\r
-#define AAWHITE                "\x1b[47;37m"\r
-#define AAMAGENTA      "\x1b[45;35m"\r
-#define AARESET        "\x1b[0m"\r
-\r
 /* local function */\r
 void wait(clock_t wait);\r
 \r
index d910f3ecfcbb8fea5ed5500d373f7a3d338f8805..2157fa3a974cd899a2acabf153246a797f8843ee 100755 (executable)
@@ -223,8 +223,9 @@ typedef     struct
        word d; //direction!! wwww\r
        word q; //loop variable\r
        word speed;             //player speed!\r
+//0000 planar_buf_t huge *data; //supposively the sprite sheet data\r
 //     planar_buf_t data; //supposively the sprite sheet data\r
-//     bitmap_t data; //supposively the sprite sheet data\r
+////0000----   bitmap_t data; //supposively the sprite sheet data\r
        sword hp; //hitpoints of the player\r
        int persist_aniframe;    /* gonna be increased to 1 before being used, so 0 is ok for default */\r
        CursorInfo      info;\r
index 95c6782c71de508264d72b776156428848334b69..4b31c4b481f6d15fdd960f4dff17214dba2f01c0 100755 (executable)
@@ -28,6 +28,8 @@
 #include "src/lib/types.h"\r
 #include "src/lib/16_head.h"\r
 \r
+#define     PALSIZE            768\r
+\r
 typedef struct {\r
        byte huge *data;\r
        word width;\r
index 205bf39a6ca32163ce9c483d6e58d9038973fa8f..9bfdf6c966f60bf850fd3116bc73ec6467ec7e27 100755 (executable)
@@ -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;
index b2bf0fd42bedbcc12a484008b5bdd72ccd13225c..3f9e3ac64c07d9071f721e4bf607ab578285c2ce 100755 (executable)
@@ -16,8 +16,9 @@
 //#define DEBUG_JS\r
 \r
 typedef struct {\r
-       bitmap_t huge *btdata;\r
-       planar_buf_t huge *data;\r
+//---- bitmap_t huge *btdata;\r
+       //planar_buf_t huge *data;\r
+       planar_buf_t data;\r
        word tileHeight;\r
        word tileWidth;\r
        unsigned int rows;\r
index 5541217fe4fa2ac2cc76f74caaf67dbd2b4e5a5c..4eda45155878659bbaf5ed57309013eb37fe6a09 100755 (executable)
    be destroyed with the planar_buf_free function when no longer\r
    needed.\r
  */\r
-planar_buf_t *\r
+planar_buf_t huge *\r
 planar_buf_from_bitmap(bitmap_t *b) {\r
        planar_buf_t *p;\r
        int plane, bi, pi, x, y;\r
+       word q;\r
 \r
        /* allocate the buffer */\r
        p = planar_buf_alloc(b->width, b->height);\r
@@ -59,12 +60,18 @@ planar_buf_from_bitmap(bitmap_t *b) {
        if(plane) pi++;\r
        }\r
 \r
+       p->palette = modexNewPal();\r
+       for(;q<PALSIZE;q++)\r
+       {\r
+               p->palette[q]=b->palette[q];\r
+       }\r
+\r
        return p;\r
 }\r
 \r
 \r
 /* allocates a planar buffer with specified dimensions */\r
-planar_buf_t *\r
+planar_buf_t huge *\r
 planar_buf_alloc(word width, word height) {\r
        planar_buf_t *p;\r
        int i;\r
@@ -97,3 +104,41 @@ planar_buf_free(planar_buf_t *p) {
        /* free the structure */\r
        free(p);\r
 }\r
+\r
+/*     non pointer version     */\r
+planar_buf_t planar_buf_from_bitmap0(bitmap_t *b) {\r
+       planar_buf_t p;\r
+       int plane, bi, pi, x, y;\r
+       word q=0;\r
+\r
+       /* allocate the buffer */\r
+       p = *planar_buf_alloc(b->width, b->height);\r
+\r
+       /* copy the bitmap data into the planar format */\r
+       bi=0;\r
+       pi=0;\r
+       for(y=0; y < b->height; y++) {\r
+       /* start on the first plane */\r
+       plane=0;\r
+       for(x=0; x < b->width; x++) {\r
+               /* copy to each plane */\r
+               p.plane[plane++][pi]=b->data[bi++];\r
+\r
+               /* handle the completion of 4 planes. */\r
+               if(plane==4) {\r
+                       plane=0;\r
+                       pi++;\r
+               }\r
+       }\r
+\r
+       /* correct for images not divisible by 4 */\r
+       if(plane) pi++;\r
+       }\r
+       p.palette = modexNewPal();\r
+       for(;q<PALSIZE;q++)\r
+       {\r
+               p.palette[q]=b->palette[q];\r
+       }\r
+\r
+       return p;\r
+}\r
index af8c5bf427e9a4bbbaea84c1719bfce9de755075..4cd7365b36d48245d9b1f0df3f2c9875c73198e1 100755 (executable)
 #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
index 347062bdf75cc058c768b6fd7cfbcd6c2f562b13..7dd610f772586167c56d823935415e4266940fff 100755 (executable)
@@ -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);
index 94d3cf828c649082277731cb4f2743ac2dae8cd3..939361575e602a69993e4c3fd77680076b702cba 100755 (executable)
 #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;
index b7dc2fa9a7a3ae89462434b47b216b761cc7203a..3f53cd7f7b437334f2c28ce6787f604fa58d33df 100755 (executable)
 \r
 #include "src/lib/types.h"\r
 \r
+\r
+#define AARED          "\x1b[41;31m"\r
+#define AABLUE         "\x1b[44;34m"\r
+#define AAGREEN        "\x1b[42;32m"\r
+#define AAYELLOW       "\x1b[43;33m"\r
+#define AAGREY         "\x1b[47;37m"\r
+#define AABLACK        "\x1b[40;30m"\r
+#define AAWHITE                "\x1b[47;37m"\r
+#define AAMAGENTA      "\x1b[45;35m"\r
+#define AARESET        "\x1b[0m"\r
+\r
 /*\r
  * typedefs of the game variables!\r
  */\r
index eb60019526cd06876b0f75fce37269891a5efd18..ecfa672543d9814e9073ccbe0330a7b0a5283baf 100755 (executable)
@@ -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
index c9ba9e3b95dea00538e0dd9ecac4db7046a1cc66..f33b73c5e483d369fdffaf702b39e08f0dd86feb 100755 (executable)
Binary files a/test.exe and b/test.exe differ
index eafa2c55012e5041cc97cbfe385c2dfeac183337..950104fa66a0fbd2a0b1eb5741a31b30b8dd80a6 100755 (executable)
Binary files a/test2.exe and b/test2.exe differ