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
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
/* 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
{
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
{
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
{
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
{
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
}
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)
{
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;
}
}
-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);
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;
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);
/* 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
/* 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! */
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