+\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