JSMNLIB=$(SRCLIB)jsmn$(DIRSEP)
NYANLIB=$(SRCLIB)nyan$(DIRSEP)
#EXMMLIB=$(SRCLIB)exmm$(DIRSEP)
+MODEXLIB=$(SRCLIB)modex16$(DIRSEP)
VGMSNDLIB=$(SRCLIB)vgmsnd$(DIRSEP)
DOSLIB=$(SRCLIB)doslib$(DIRSEP)
WCPULIB=$(SRCLIB)wcpu$(DIRSEP)
16LIBOBJS = 16_in.$(OBJ) 16_mm.$(OBJ) wcpu.$(OBJ) 16_head.$(OBJ) 16_ca.$(OBJ) kitten.$(OBJ) 16_hc.$(OBJ) timer.$(OBJ)
#
#3812intf.$(OBJ)
-GFXLIBOBJS = modex16.$(OBJ) bitmap.$(OBJ) planar.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ)
+GFXLIBOBJS = modex16.$(OBJ) bitmap.$(OBJ) planar.$(OBJ) 16text.$(OBJ) bakapee.$(OBJ) scroll16.$(OBJ) 16render.$(OBJ)
TESTEXEC = exmmtest.exe test.exe pcxtest.exe pcxtest2.exe test2.exe palettec.exe maptest.exe fmemtest.exe fonttest.exe fontgfx.exe scroll.exe vgmtest.exe inputest.exe palettel.exe planrpcx.exe
# tsthimem.exe
bakapee.$(OBJ): $(SRCLIB)bakapee.h $(SRCLIB)bakapee.c
wcl $(FLAGS) -c $(SRCLIB)bakapee.c
+16render.$(OBJ): $(MODEXLIB)16render.h $(MODEXLIB)16render.c
+ wcl $(FLAGS) -c $(MODEXLIB)16render.c
+
bitmap.$(OBJ): $(SRCLIB)bitmap.h $(SRCLIB)bitmap.c
wcl $(FLAGS) -c $(SRCLIB)bitmap.c
}\r
}\r
\r
-//TODO! ADD CLIPPING!!\r
-//memory management needs to be added\r
-//void\r
-//modexDrawBmpRegion (page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp)\r
-void modexDrawPBufRegion (page_t *page, int x, int y, int rx, int ry, int rw, int rh, planar_buf_t *p, boolean sprite)\r
-{\r
- sword plane;\r
- int i;\r
- const int px=x;//-page->dx;\r
- const int py=y;//-page->dy;\r
- #define PEEE ((rw)/4)-rx\r
- //-(rx/4)\r
- #define PEEEE ((p->pwidth)*(ry))\r
- //y=py;\r
- //x=px;\r
- //printf("%d,%d p(%d,%d) r(%d,%d) rwh(%d,%d)\n", x, y, px, py, rx, ry, rw, rh);\r
- for(plane=0; plane < 4; plane++) {\r
- i=PEEE+PEEEE;\r
- //printf("PEEE=%d ", PEEE);\r
- //printf("PEEEE=%d ", PEEEE);\r
- //printf("i=%d\n", i);\r
- modexSelectPlane(PLANE(plane+x));\r
- for(; y < py+rh; y++) {\r
- //for(px=0; px < p->width; px++) {\r
- //printf("%02X ", (int) p->plane[plane][i++]);\r
-// _fmemcpy(buff, &(p->plane[plane][i+=p->pwidth]), p->pwidth);\r
-// printf("buff %u==%s\n", y, *buff);\r
- _fmemcpy(page->data + (((page->width/4) * y) + (x / 4)), &(p->plane[plane][i+=p->pwidth]), (rw/4));\r
- //}\r
- //if(plane==3) IN_Ack();\r
- }\r
- /*printf("y%d=%d ", plane, y);\r
- if(plane==3) printf("y%d=%d\n", plane, y);*/\r
- x=px;\r
- y=py;\r
- }\r
-}\r
-\r
-\r
-/*temp*/\r
-void\r
-modexDrawPBuf(page_t *page, int x, int y, planar_buf_t *p, boolean sprite)\r
-{\r
- int plane;\r
- int i;\r
-// byte near *buff;\r
- const int px=x+page->dx;\r
- const int py=y+page->dy;\r
- x=px;\r
- y=py;\r
-// buff = _nmalloc(p->pwidth+1);\r
- // TODO Make this fast. It's SLOOOOOOW\r
-// for(plane=0; plane < 4; plane++) {\r
-// i=0;\r
-// modexSelectPlane(PLANE(plane+x));\r
-// for(px = plane; px < p->width; px+=4) {\r
-// offset=px;\r
-// for(py=0; py<p->height/2; py++) {\r
-// //SELECT_ALL_PLANES();\r
-// if(!sprite || p->plane[offset])\r
-// page->data = &(p->plane[offset][i++]);\r
-// offset+=p->width;\r
-// offset++;\r
-// }\r
-// }\r
-// }\r
- for(plane=0; plane < 4; plane++) {\r
- i=0;\r
- modexSelectPlane(PLANE(plane+x));\r
- for(; y < py+p->height; y++) {\r
- //for(px=0; px < p->width; px++) {\r
- //printf("%02X ", (int) p->plane[plane][i++]);\r
-// _fmemcpy(buff, &(p->plane[plane][i+=p->pwidth]), p->pwidth);\r
-// printf("buff %u==%s\n", y, *buff);\r
-// _fmemcpy(page->data + (((page->width/4) * (y+page->dy)) + ((x+page->dx) / 4)), buff, p->pwidth);\r
- _fmemcpy(page->data + (((page->width/4) * y) + (x / 4)), &(p->plane[plane][i+=p->pwidth]), p->pwidth);\r
- //}\r
- }\r
- x=px;\r
- y=py;\r
- }\r
-// _nfree(buff);\r
-}\r
-\r
-void\r
-oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite)\r
-{\r
- byte plane;\r
- word px, py;\r
- word offset;\r
-\r
- /* TODO Make this fast. It's SLOOOOOOW */\r
- for(plane=0; plane < 4; plane++) {\r
- modexSelectPlane(PLANE(plane+x));\r
- for(px = plane; px < bmp->width; px+=4) {\r
- offset=px;\r
- for(py=0; py<bmp->height; py++) {\r
- if(!sprite || bmp->data[offset])\r
- page[PAGE_OFFSET(x+px, y+py)] = bmp->data[offset];\r
- offset+=bmp->width;\r
- }\r
- }\r
- }\r
-}\r
-\r
-//* normal versions *//\r
-void\r
-modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp) {\r
- /* draw the region (the entire freakin bitmap) */\r
- modexDrawBmpRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
-}\r
-\r
-void\r
-modexDrawBmpRegion(page_t *page, int x, int y,\r
- int rx, int ry, int rw, int rh, bitmap_t *bmp) {\r
- word poffset = (word) page->data + y*(page->width/4) + x/4;\r
- byte *data = bmp->data;//+bmp->offset;\r
- word bmpOffset = (word) data + ry * bmp->width + rx;\r
- word width = rw;\r
- word height = rh;\r
- byte plane = 1 << ((byte) x & 0x03);\r
- word scanCount = width/4 + (width%4 ? 1 :0);\r
- word nextPageRow = page->width/4 - scanCount;\r
- word nextBmpRow = (word) bmp->width - width;\r
- word rowCounter;\r
- byte planeCounter = 4;\r
-\r
- __asm {\r
- MOV AX, SCREEN_SEG ; go to the VGA memory\r
- MOV ES, AX\r
-\r
- MOV DX, SC_INDEX ; point at the map mask register\r
- MOV AL, MAP_MASK ;\r
- OUT DX, AL ;\r
-\r
- PLANE_LOOP:\r
- MOV DX, SC_DATA ; select the current plane\r
- MOV AL, plane ;\r
- OUT DX, AL ;\r
-\r
- ;-- begin plane painting\r
- MOV AX, height ; start the row counter\r
- MOV rowCounter, AX ;\r
- MOV DI, poffset ; go to the first pixel\r
- MOV SI, bmpOffset ; go to the bmp pixel\r
- ROW_LOOP:\r
- MOV CX, width ; count the columns\r
- SCAN_LOOP:\r
- MOVSB ; copy the pixel\r
- SUB CX, 3 ; we skip the next 3\r
- ADD SI, 3 ; skip the bmp pixels\r
- LOOP SCAN_LOOP ; finish the scan\r
-\r
- MOV AX, nextPageRow\r
- ADD DI, AX ; go to the next row on screen\r
- MOV AX, nextBmpRow\r
- ADD SI, AX ; go to the next row on bmp\r
-\r
- DEC rowCounter\r
- JNZ ROW_LOOP ; do all the rows\r
- ;-- end plane painting\r
- MOV AL, plane ; advance to the next plane\r
- SHL AL, 1 ;\r
- AND AL, 0x0f ; mask the plane properly\r
- MOV plane, AL ; store the plane\r
-\r
- INC bmpOffset ; start bmp at the right spot\r
-\r
- DEC planeCounter\r
- JNZ PLANE_LOOP ; do all 4 planes\r
- }\r
-}\r
-\r
-void\r
-modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) {\r
- /* draw the whole sprite */\r
- modexDrawSpriteRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
-}\r
-\r
-void\r
-modexDrawSpriteRegion(page_t *page, int x, int y,\r
- int rx, int ry, int rw, int rh, bitmap_t *bmp) {\r
- word poffset = (word)page->data + y*(page->width/4) + x/4;\r
- byte *data = bmp->data;//+bmp->offset;\r
- word bmpOffset = (word) data + ry * bmp->width + rx;\r
- word width = rw;\r
- word height = rh;\r
- byte plane = 1 << ((byte) x & 0x03);\r
- word scanCount = width/4 + (width%4 ? 1 :0);\r
- word nextPageRow = page->width/4 - scanCount;\r
- word nextBmpRow = (word) bmp->width - width;\r
- word rowCounter;\r
- byte planeCounter = 4;\r
-\r
- __asm {\r
- MOV AX, SCREEN_SEG ; go to the VGA memory\r
- MOV ES, AX\r
-\r
- MOV DX, SC_INDEX ; point at the map mask register\r
- MOV AL, MAP_MASK ;\r
- OUT DX, AL ;\r
-\r
- PLANE_LOOP:\r
- MOV DX, SC_DATA ; select the current plane\r
- MOV AL, plane ;\r
- OUT DX, AL ;\r
-\r
- ;-- begin plane painting\r
- MOV AX, height ; start the row counter\r
- MOV rowCounter, AX ;\r
- MOV DI, poffset ; go to the first pixel\r
- MOV SI, bmpOffset ; go to the bmp pixel\r
- ROW_LOOP:\r
- MOV CX, width ; count the columns\r
- SCAN_LOOP:\r
- LODSB\r
- DEC SI\r
- CMP AL, 0\r
- JNE DRAW_PIXEL ; draw non-zero pixels\r
-\r
- INC DI ; skip the transparent pixel\r
- ADD SI, 1\r
- JMP NEXT_PIXEL\r
- DRAW_PIXEL:\r
- MOVSB ; copy the pixel\r
- NEXT_PIXEL:\r
- SUB CX, 3 ; we skip the next 3\r
- ADD SI, 3 ; skip the bmp pixels\r
- LOOP SCAN_LOOP ; finish the scan\r
-\r
- MOV AX, nextPageRow\r
- ADD DI, AX ; go to the next row on screen\r
- MOV AX, nextBmpRow\r
- ADD SI, AX ; go to the next row on bmp\r
-\r
- DEC rowCounter\r
- JNZ ROW_LOOP ; do all the rows\r
- ;-- end plane painting\r
-\r
- MOV AL, plane ; advance to the next plane\r
- SHL AL, 1 ;\r
- AND AL, 0x0f ; mask the plane properly\r
- MOV plane, AL ; store the plane\r
-\r
- INC bmpOffset ; start bmp at the right spot\r
-\r
- DEC planeCounter\r
- JNZ PLANE_LOOP ; do all 4 planes\r
- }\r
-}\r
-\r
-//* planar buffer versions *//\r
-void\r
-modexDrawBmpPBuf(page_t *page, int x, int y, planar_buf_t *bmp) {\r
- /* draw the region (the entire freakin bitmap) */\r
- modexDrawBmpPBufRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
-}\r
-\r
-void\r
-modexDrawBmpPBufRegion(page_t *page, int x, int y,\r
- int rx, int ry, int rw, int rh, planar_buf_t *bmp) {\r
- word poffset = (word) page->data + y*(page->width/4) + x/4;\r
- byte *data = *bmp->plane;//+bmp->offset;\r
- word bmpOffset = (word) data + ry * bmp->width + rx;\r
- word width = rw/4;\r
- word height = rh/4;\r
- byte plane = 1 << ((byte) x & 0x03);\r
- word scanCount = width/4 + (width%4 ? 1 :0);\r
- word nextPageRow = page->width/4 - scanCount;\r
- word nextBmpRow = (word) bmp->width - width;\r
- word rowCounter;\r
- byte planeCounter = 4;\r
-\r
- __asm {\r
- MOV AX, SCREEN_SEG ; go to the VGA memory\r
- MOV ES, AX\r
-\r
- MOV DX, SC_INDEX ; point at the map mask register\r
- MOV AL, MAP_MASK ;\r
- OUT DX, AL ;\r
-\r
- PLANE_LOOP:\r
- MOV DX, SC_DATA ; select the current plane\r
- MOV AL, plane ;\r
- OUT DX, AL ;\r
-\r
- ;-- begin plane painting\r
- MOV AX, height ; start the row counter\r
- MOV rowCounter, AX ;\r
- MOV DI, poffset ; go to the first pixel\r
- MOV SI, bmpOffset ; go to the bmp pixel\r
- ROW_LOOP:\r
- MOV CX, width ; count the columns\r
- SCAN_LOOP:\r
- MOVSB ; copy the pixel\r
- SUB CX, 3 ; we skip the next 3\r
- ADD SI, 3 ; skip the bmp pixels\r
- LOOP SCAN_LOOP ; finish the scan\r
-\r
- MOV AX, nextPageRow\r
- ADD DI, AX ; go to the next row on screen\r
- MOV AX, nextBmpRow\r
- ADD SI, AX ; go to the next row on bmp\r
-\r
- DEC rowCounter\r
- JNZ ROW_LOOP ; do all the rows\r
- ;-- end plane painting\r
- MOV AL, plane ; advance to the next plane\r
- SHL AL, 1 ;\r
- AND AL, 0x0f ; mask the plane properly\r
- MOV plane, AL ; store the plane\r
-\r
- INC bmpOffset ; start bmp at the right spot\r
-\r
- DEC planeCounter\r
- JNZ PLANE_LOOP ; do all 4 planes\r
- }\r
-}\r
-\r
-void\r
-modexDrawSpritePBuf(page_t *page, int x, int y, planar_buf_t *bmp) {\r
- /* draw the whole sprite */\r
- modexDrawSpritePBufRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
-}\r
-\r
-void\r
-modexDrawSpritePBufRegion(page_t *page, int x, int y,\r
- int rx, int ry, int rw, int rh, planar_buf_t *bmp) {\r
- word poffset = (word)page->data + y*(page->width/4) + x/4;\r
- byte *data = *bmp->plane;//+bmp->offset;\r
- word bmpOffset = (word) data + ry * bmp->width + rx;\r
- word width = rw/4;\r
- word height = rh/4;\r
- byte plane = 1 << ((byte) x & 0x03);\r
- word scanCount = width/4 + (width%4 ? 1 :0);\r
- word nextPageRow = page->width/4 - scanCount;\r
- word nextBmpRow = (word) bmp->width - width;\r
- word rowCounter;\r
- byte planeCounter = 4;\r
-\r
- __asm {\r
- MOV AX, SCREEN_SEG ; go to the VGA memory\r
- MOV ES, AX\r
-\r
- MOV DX, SC_INDEX ; point at the map mask register\r
- MOV AL, MAP_MASK ;\r
- OUT DX, AL ;\r
-\r
- PLANE_LOOP:\r
- MOV DX, SC_DATA ; select the current plane\r
- MOV AL, plane ;\r
- OUT DX, AL ;\r
-\r
- ;-- begin plane painting\r
- MOV AX, height ; start the row counter\r
- MOV rowCounter, AX ;\r
- MOV DI, poffset ; go to the first pixel\r
- MOV SI, bmpOffset ; go to the bmp pixel\r
- ROW_LOOP:\r
- MOV CX, width ; count the columns\r
- SCAN_LOOP:\r
- LODSB\r
- DEC SI\r
- CMP AL, 0\r
- JNE DRAW_PIXEL ; draw non-zero pixels\r
-\r
- INC DI ; skip the transparent pixel\r
- ADD SI, 1\r
- JMP NEXT_PIXEL\r
- DRAW_PIXEL:\r
- MOVSB ; copy the pixel\r
- NEXT_PIXEL:\r
- SUB CX, 3 ; we skip the next 3\r
- ADD SI, 3 ; skip the bmp pixels\r
- LOOP SCAN_LOOP ; finish the scan\r
-\r
- MOV AX, nextPageRow\r
- ADD DI, AX ; go to the next row on screen\r
- MOV AX, nextBmpRow\r
- ADD SI, AX ; go to the next row on bmp\r
-\r
- DEC rowCounter\r
- JNZ ROW_LOOP ; do all the rows\r
- ;-- end plane painting\r
-\r
- MOV AL, plane ; advance to the next plane\r
- SHL AL, 1 ;\r
- AND AL, 0x0f ; mask the plane properly\r
- MOV plane, AL ; store the plane\r
-\r
- INC bmpOffset ; start bmp at the right spot\r
-\r
- DEC planeCounter\r
- JNZ PLANE_LOOP ; do all 4 planes\r
- }\r
-}\r
+/* moved to src/lib/modex16/16render.c */\r
\r
/* copy a region of video memory from one page to another.\r
* It assumes that the left edge of the tile is the same on both\r
#include "src/lib/planar.h"
#include "src/lib/16_head.h"
#include "src/lib/16text.h"
+#include "src/lib/modex16/16render.h"
#include "src/lib/modex16/320x240.h"
#include "src/lib/modex16/320x200.h"
#include "src/lib/modex16/256x192.h"
void modexPanPage(page_t *page, int dx, int dy);
void modexSelectPlane(byte plane);
void modexClearRegion(page_t *page, int x, int y, int w, int h, byte color);
-void modexDrawPBufRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, planar_buf_t *p, boolean sprite);
-void modexDrawPBuf(page_t *page, int x, int y, planar_buf_t *p, boolean sprite); /*temp*/
-void oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite);
-void modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp);
-void modexDrawBmpRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);
-void modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp);
-void modexDrawSpriteRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);
-void modexDrawBmpPBuf(page_t *page, int x, int y, planar_buf_t *bmp); /*pbuf version*/
-void modexDrawBmpPBufRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, planar_buf_t *bmp);
-void modexDrawSpritePBuf(page_t *page, int x, int y, planar_buf_t *bmp);
-void modexDrawSpritePBufRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, planar_buf_t *bmp);
+/* moved to src/lib/modex16/16render.c */
void modexCopyPageRegion(page_t *dest, page_t *src, word sx, word sy, word dx, word dy, word width, word height);
/* Palette fade and flash effects */
--- /dev/null
+/* Project 16 Source Code~\r
+ * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669\r
+ *\r
+ * This file is part of Project 16.\r
+ *\r
+ * Project 16 is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Project 16 is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>, or\r
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
+ * Fifth Floor, Boston, MA 02110-1301 USA.\r
+ *\r
+ */\r
+/*\r
+ * Render data code~\r
+ */\r
+\r
+#include "src/lib/modex16/16render.h"\r
+\r
+//TODO! ADD CLIPPING!!\r
+//memory management needs to be added\r
+//void\r
+//modexDrawBmpRegion (page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp)\r
+void modexDrawPBufRegion (page_t *page, int x, int y, int rx, int ry, int rw, int rh, planar_buf_t *p, boolean sprite)\r
+{\r
+ sword plane;\r
+ int i;\r
+ const int px=x;//-page->dx;\r
+ const int py=y;//-page->dy;\r
+ #define PEEE ((rw)/4)-rx\r
+ //-(rx/4)\r
+ #define PEEEE ((p->pwidth)*(ry))\r
+ //y=py;\r
+ //x=px;\r
+ //printf("%d,%d p(%d,%d) r(%d,%d) rwh(%d,%d)\n", x, y, px, py, rx, ry, rw, rh);\r
+ for(plane=0; plane < 4; plane++) {\r
+ i=PEEE+PEEEE;\r
+ //printf("PEEE=%d ", PEEE);\r
+ //printf("PEEEE=%d ", PEEEE);\r
+ //printf("i=%d\n", i);\r
+ modexSelectPlane(PLANE(plane+x));\r
+ for(; y < py+rh; y++) {\r
+ //for(px=0; px < p->width; px++) {\r
+ //printf("%02X ", (int) p->plane[plane][i++]);\r
+// _fmemcpy(buff, &(p->plane[plane][i+=p->pwidth]), p->pwidth);\r
+// printf("buff %u==%s\n", y, *buff);\r
+ _fmemcpy(page->data + (((page->width/4) * y) + (x / 4)), &(p->plane[plane][i+=p->pwidth]), (rw/4));\r
+ //}\r
+ //if(plane==3) IN_Ack();\r
+ }\r
+ /*printf("y%d=%d ", plane, y);\r
+ if(plane==3) printf("y%d=%d\n", plane, y);*/\r
+ x=px;\r
+ y=py;\r
+ }\r
+}\r
+\r
+\r
+/*temp*/\r
+void\r
+modexDrawPBuf(page_t *page, int x, int y, planar_buf_t *p, boolean sprite)\r
+{\r
+ int plane;\r
+ int i;\r
+// byte near *buff;\r
+ const int px=x+page->dx;\r
+ const int py=y+page->dy;\r
+ x=px;\r
+ y=py;\r
+// buff = _nmalloc(p->pwidth+1);\r
+ // TODO Make this fast. It's SLOOOOOOW\r
+// for(plane=0; plane < 4; plane++) {\r
+// i=0;\r
+// modexSelectPlane(PLANE(plane+x));\r
+// for(px = plane; px < p->width; px+=4) {\r
+// offset=px;\r
+// for(py=0; py<p->height/2; py++) {\r
+// //SELECT_ALL_PLANES();\r
+// if(!sprite || p->plane[offset])\r
+// page->data = &(p->plane[offset][i++]);\r
+// offset+=p->width;\r
+// offset++;\r
+// }\r
+// }\r
+// }\r
+ for(plane=0; plane < 4; plane++) {\r
+ i=0;\r
+ modexSelectPlane(PLANE(plane+x));\r
+ for(; y < py+p->height; y++) {\r
+ //for(px=0; px < p->width; px++) {\r
+ //printf("%02X ", (int) p->plane[plane][i++]);\r
+// _fmemcpy(buff, &(p->plane[plane][i+=p->pwidth]), p->pwidth);\r
+// printf("buff %u==%s\n", y, *buff);\r
+// _fmemcpy(page->data + (((page->width/4) * (y+page->dy)) + ((x+page->dx) / 4)), buff, p->pwidth);\r
+ _fmemcpy(page->data + (((page->width/4) * y) + (x / 4)), &(p->plane[plane][i+=p->pwidth]), p->pwidth);\r
+ //}\r
+ }\r
+ x=px;\r
+ y=py;\r
+ }\r
+// _nfree(buff);\r
+}\r
+\r
+void\r
+oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite)\r
+{\r
+ byte plane;\r
+ word px, py;\r
+ word offset;\r
+\r
+ /* TODO Make this fast. It's SLOOOOOOW */\r
+ for(plane=0; plane < 4; plane++) {\r
+ modexSelectPlane(PLANE(plane+x));\r
+ for(px = plane; px < bmp->width; px+=4) {\r
+ offset=px;\r
+ for(py=0; py<bmp->height; py++) {\r
+ if(!sprite || bmp->data[offset])\r
+ page[PAGE_OFFSET(x+px, y+py)] = bmp->data[offset];\r
+ offset+=bmp->width;\r
+ }\r
+ }\r
+ }\r
+}\r
+\r
+//* normal versions *//\r
+void\r
+modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp) {\r
+ /* draw the region (the entire freakin bitmap) */\r
+ modexDrawBmpRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
+}\r
+\r
+void\r
+modexDrawBmpRegion(page_t *page, int x, int y,\r
+ int rx, int ry, int rw, int rh, bitmap_t *bmp) {\r
+ word poffset = (word) page->data + y*(page->width/4) + x/4;\r
+ byte *data = bmp->data;//+bmp->offset;\r
+ word bmpOffset = (word) data + ry * bmp->width + rx;\r
+ word width = rw;\r
+ word height = rh;\r
+ byte plane = 1 << ((byte) x & 0x03);\r
+ word scanCount = width/4 + (width%4 ? 1 :0);\r
+ word nextPageRow = page->width/4 - scanCount;\r
+ word nextBmpRow = (word) bmp->width - width;\r
+ word rowCounter;\r
+ byte planeCounter = 4;\r
+\r
+ __asm {\r
+ MOV AX, SCREEN_SEG ; go to the VGA memory\r
+ MOV ES, AX\r
+\r
+ MOV DX, SC_INDEX ; point at the map mask register\r
+ MOV AL, MAP_MASK ;\r
+ OUT DX, AL ;\r
+\r
+ PLANE_LOOP:\r
+ MOV DX, SC_DATA ; select the current plane\r
+ MOV AL, plane ;\r
+ OUT DX, AL ;\r
+\r
+ ;-- begin plane painting\r
+ MOV AX, height ; start the row counter\r
+ MOV rowCounter, AX ;\r
+ MOV DI, poffset ; go to the first pixel\r
+ MOV SI, bmpOffset ; go to the bmp pixel\r
+ ROW_LOOP:\r
+ MOV CX, width ; count the columns\r
+ SCAN_LOOP:\r
+ MOVSB ; copy the pixel\r
+ SUB CX, 3 ; we skip the next 3\r
+ ADD SI, 3 ; skip the bmp pixels\r
+ LOOP SCAN_LOOP ; finish the scan\r
+\r
+ MOV AX, nextPageRow\r
+ ADD DI, AX ; go to the next row on screen\r
+ MOV AX, nextBmpRow\r
+ ADD SI, AX ; go to the next row on bmp\r
+\r
+ DEC rowCounter\r
+ JNZ ROW_LOOP ; do all the rows\r
+ ;-- end plane painting\r
+ MOV AL, plane ; advance to the next plane\r
+ SHL AL, 1 ;\r
+ AND AL, 0x0f ; mask the plane properly\r
+ MOV plane, AL ; store the plane\r
+\r
+ INC bmpOffset ; start bmp at the right spot\r
+\r
+ DEC planeCounter\r
+ JNZ PLANE_LOOP ; do all 4 planes\r
+ }\r
+}\r
+\r
+void\r
+modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) {\r
+ /* draw the whole sprite */\r
+ modexDrawSpriteRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
+}\r
+\r
+void\r
+modexDrawSpriteRegion(page_t *page, int x, int y,\r
+ int rx, int ry, int rw, int rh, bitmap_t *bmp) {\r
+ word poffset = (word)page->data + y*(page->width/4) + x/4;\r
+ byte *data = bmp->data;//+bmp->offset;\r
+ word bmpOffset = (word) data + ry * bmp->width + rx;\r
+ word width = rw;\r
+ word height = rh;\r
+ byte plane = 1 << ((byte) x & 0x03);\r
+ word scanCount = width/4 + (width%4 ? 1 :0);\r
+ word nextPageRow = page->width/4 - scanCount;\r
+ word nextBmpRow = (word) bmp->width - width;\r
+ word rowCounter;\r
+ byte planeCounter = 4;\r
+\r
+ __asm {\r
+ MOV AX, SCREEN_SEG ; go to the VGA memory\r
+ MOV ES, AX\r
+\r
+ MOV DX, SC_INDEX ; point at the map mask register\r
+ MOV AL, MAP_MASK ;\r
+ OUT DX, AL ;\r
+\r
+ PLANE_LOOP:\r
+ MOV DX, SC_DATA ; select the current plane\r
+ MOV AL, plane ;\r
+ OUT DX, AL ;\r
+\r
+ ;-- begin plane painting\r
+ MOV AX, height ; start the row counter\r
+ MOV rowCounter, AX ;\r
+ MOV DI, poffset ; go to the first pixel\r
+ MOV SI, bmpOffset ; go to the bmp pixel\r
+ ROW_LOOP:\r
+ MOV CX, width ; count the columns\r
+ SCAN_LOOP:\r
+ LODSB\r
+ DEC SI\r
+ CMP AL, 0\r
+ JNE DRAW_PIXEL ; draw non-zero pixels\r
+\r
+ INC DI ; skip the transparent pixel\r
+ ADD SI, 1\r
+ JMP NEXT_PIXEL\r
+ DRAW_PIXEL:\r
+ MOVSB ; copy the pixel\r
+ NEXT_PIXEL:\r
+ SUB CX, 3 ; we skip the next 3\r
+ ADD SI, 3 ; skip the bmp pixels\r
+ LOOP SCAN_LOOP ; finish the scan\r
+\r
+ MOV AX, nextPageRow\r
+ ADD DI, AX ; go to the next row on screen\r
+ MOV AX, nextBmpRow\r
+ ADD SI, AX ; go to the next row on bmp\r
+\r
+ DEC rowCounter\r
+ JNZ ROW_LOOP ; do all the rows\r
+ ;-- end plane painting\r
+\r
+ MOV AL, plane ; advance to the next plane\r
+ SHL AL, 1 ;\r
+ AND AL, 0x0f ; mask the plane properly\r
+ MOV plane, AL ; store the plane\r
+\r
+ INC bmpOffset ; start bmp at the right spot\r
+\r
+ DEC planeCounter\r
+ JNZ PLANE_LOOP ; do all 4 planes\r
+ }\r
+}\r
+\r
+//* planar buffer versions *//\r
+void\r
+modexDrawBmpPBuf(page_t *page, int x, int y, planar_buf_t *bmp) {\r
+ /* draw the region (the entire freakin bitmap) */\r
+ modexDrawBmpPBufRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
+}\r
+\r
+void\r
+modexDrawBmpPBufRegion(page_t *page, int x, int y,\r
+ int rx, int ry, int rw, int rh, planar_buf_t *bmp) {\r
+ word poffset = (word) page->data + y*(page->width/4) + x/4;\r
+ byte *data = *bmp->plane;//+bmp->offset;\r
+ word bmpOffset = (word) data + ry * bmp->width + rx;\r
+ word width = rw/4;\r
+ word height = rh/4;\r
+ byte plane = 1 << ((byte) x & 0x03);\r
+ word scanCount = width/4 + (width%4 ? 1 :0);\r
+ word nextPageRow = page->width/4 - scanCount;\r
+ word nextBmpRow = (word) bmp->width - width;\r
+ word rowCounter;\r
+ byte planeCounter = 4;\r
+\r
+ __asm {\r
+ MOV AX, SCREEN_SEG ; go to the VGA memory\r
+ MOV ES, AX\r
+\r
+ MOV DX, SC_INDEX ; point at the map mask register\r
+ MOV AL, MAP_MASK ;\r
+ OUT DX, AL ;\r
+\r
+ PLANE_LOOP:\r
+ MOV DX, SC_DATA ; select the current plane\r
+ MOV AL, plane ;\r
+ OUT DX, AL ;\r
+\r
+ ;-- begin plane painting\r
+ MOV AX, height ; start the row counter\r
+ MOV rowCounter, AX ;\r
+ MOV DI, poffset ; go to the first pixel\r
+ MOV SI, bmpOffset ; go to the bmp pixel\r
+ ROW_LOOP:\r
+ MOV CX, width ; count the columns\r
+ SCAN_LOOP:\r
+ MOVSB ; copy the pixel\r
+ SUB CX, 3 ; we skip the next 3\r
+ ADD SI, 3 ; skip the bmp pixels\r
+ LOOP SCAN_LOOP ; finish the scan\r
+\r
+ MOV AX, nextPageRow\r
+ ADD DI, AX ; go to the next row on screen\r
+ MOV AX, nextBmpRow\r
+ ADD SI, AX ; go to the next row on bmp\r
+\r
+ DEC rowCounter\r
+ JNZ ROW_LOOP ; do all the rows\r
+ ;-- end plane painting\r
+ MOV AL, plane ; advance to the next plane\r
+ SHL AL, 1 ;\r
+ AND AL, 0x0f ; mask the plane properly\r
+ MOV plane, AL ; store the plane\r
+\r
+ INC bmpOffset ; start bmp at the right spot\r
+\r
+ DEC planeCounter\r
+ JNZ PLANE_LOOP ; do all 4 planes\r
+ }\r
+}\r
+\r
+void\r
+modexDrawSpritePBuf(page_t *page, int x, int y, planar_buf_t *bmp) {\r
+ /* draw the whole sprite */\r
+ modexDrawSpritePBufRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
+}\r
+\r
+void\r
+modexDrawSpritePBufRegion(page_t *page, int x, int y,\r
+ int rx, int ry, int rw, int rh, planar_buf_t *bmp) {\r
+ word poffset = (word)page->data + y*(page->width/4) + x/4;\r
+ byte *data = *bmp->plane;//+bmp->offset;\r
+ word bmpOffset = (word) data + ry * bmp->width + rx;\r
+ word width = rw/4;\r
+ word height = rh/4;\r
+ byte plane = 1 << ((byte) x & 0x03);\r
+ word scanCount = width/4 + (width%4 ? 1 :0);\r
+ word nextPageRow = page->width/4 - scanCount;\r
+ word nextBmpRow = (word) bmp->width - width;\r
+ word rowCounter;\r
+ byte planeCounter = 4;\r
+\r
+ __asm {\r
+ MOV AX, SCREEN_SEG ; go to the VGA memory\r
+ MOV ES, AX\r
+\r
+ MOV DX, SC_INDEX ; point at the map mask register\r
+ MOV AL, MAP_MASK ;\r
+ OUT DX, AL ;\r
+\r
+ PLANE_LOOP:\r
+ MOV DX, SC_DATA ; select the current plane\r
+ MOV AL, plane ;\r
+ OUT DX, AL ;\r
+\r
+ ;-- begin plane painting\r
+ MOV AX, height ; start the row counter\r
+ MOV rowCounter, AX ;\r
+ MOV DI, poffset ; go to the first pixel\r
+ MOV SI, bmpOffset ; go to the bmp pixel\r
+ ROW_LOOP:\r
+ MOV CX, width ; count the columns\r
+ SCAN_LOOP:\r
+ LODSB\r
+ DEC SI\r
+ CMP AL, 0\r
+ JNE DRAW_PIXEL ; draw non-zero pixels\r
+\r
+ INC DI ; skip the transparent pixel\r
+ ADD SI, 1\r
+ JMP NEXT_PIXEL\r
+ DRAW_PIXEL:\r
+ MOVSB ; copy the pixel\r
+ NEXT_PIXEL:\r
+ SUB CX, 3 ; we skip the next 3\r
+ ADD SI, 3 ; skip the bmp pixels\r
+ LOOP SCAN_LOOP ; finish the scan\r
+\r
+ MOV AX, nextPageRow\r
+ ADD DI, AX ; go to the next row on screen\r
+ MOV AX, nextBmpRow\r
+ ADD SI, AX ; go to the next row on bmp\r
+\r
+ DEC rowCounter\r
+ JNZ ROW_LOOP ; do all the rows\r
+ ;-- end plane painting\r
+\r
+ MOV AL, plane ; advance to the next plane\r
+ SHL AL, 1 ;\r
+ AND AL, 0x0f ; mask the plane properly\r
+ MOV plane, AL ; store the plane\r
+\r
+ INC bmpOffset ; start bmp at the right spot\r
+\r
+ DEC planeCounter\r
+ JNZ PLANE_LOOP ; do all 4 planes\r
+ }\r
+}\r
--- /dev/null
+/* Project 16 Source Code~\r
+ * Copyright (C) 2012-2015 sparky4 & pngwen & andrius4669\r
+ *\r
+ * This file is part of Project 16.\r
+ *\r
+ * Project 16 is free software; you can redistribute it and/or modify\r
+ * it under the terms of the GNU General Public License as published by\r
+ * the Free Software Foundation; either version 3 of the License, or\r
+ * (at your option) any later version.\r
+ *\r
+ * Project 16 is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program. If not, see <http://www.gnu.org/licenses/>, or\r
+ * write to the Free Software Foundation, Inc., 51 Franklin Street,\r
+ * Fifth Floor, Boston, MA 02110-1301 USA.\r
+ *\r
+ */\r
+\r
+#ifndef __RENDER_H__\r
+#define __RENDER_H__\r
+\r
+#include "src/lib/modex16.h"\r
+\r
+void modexDrawPBufRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, planar_buf_t *p, boolean sprite);\r
+void modexDrawPBuf(page_t *page, int x, int y, planar_buf_t *p, boolean sprite); /*temp*/\r
+void oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite);\r
+void modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp);\r
+void modexDrawBmpRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);\r
+void modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp);\r
+void modexDrawSpriteRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp);\r
+void modexDrawBmpPBuf(page_t *page, int x, int y, planar_buf_t *bmp); /*pbuf version*/\r
+void modexDrawBmpPBufRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, planar_buf_t *bmp);\r
+void modexDrawSpritePBuf(page_t *page, int x, int y, planar_buf_t *bmp);\r
+void modexDrawSpritePBufRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, planar_buf_t *bmp);\r
+\r
+#endif\r
+++ /dev/null
-void\r
-modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp) {\r
- /* draw the region (the entire freakin bitmap) */\r
- modexDrawBmpRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
-}\r
-\r
-void\r
-modexDrawBmpRegion(page_t *page, int x, int y,\r
- int rx, int ry, int rw, int rh, bitmap_t *bmp) {\r
- word poffset = (word) page->data + y*(page->width/4) + x/4;\r
- byte *data = bmp->data;//+bmp->offset;\r
- word bmpOffset = (word) data + ry * bmp->width + rx;\r
- word width = rw;\r
- word height = rh;\r
- byte plane = 1 << ((byte) x & 0x03);\r
- word scanCount = width/4 + (width%4 ? 1 :0);\r
- word nextPageRow = page->width/4 - scanCount;\r
- word nextBmpRow = (word) bmp->width - width;\r
- word rowCounter;\r
- byte planeCounter = 4;\r
-\r
- __asm {\r
- MOV AX, SCREEN_SEG ; go to the VGA memory\r
- MOV ES, AX\r
-\r
- MOV DX, SC_INDEX ; point at the map mask register\r
- MOV AL, MAP_MASK ;\r
- OUT DX, AL ;\r
-\r
- PLANE_LOOP:\r
- MOV DX, SC_DATA ; select the current plane\r
- MOV AL, plane ;\r
- OUT DX, AL ;\r
-\r
- ;-- begin plane painting\r
- MOV AX, height ; start the row counter\r
- MOV rowCounter, AX ;\r
- MOV DI, poffset ; go to the first pixel\r
- MOV SI, bmpOffset ; go to the bmp pixel\r
- ROW_LOOP:\r
- MOV CX, width ; count the columns\r
- SCAN_LOOP:\r
- MOVSB ; copy the pixel\r
- SUB CX, 3 ; we skip the next 3\r
- ADD SI, 3 ; skip the bmp pixels\r
- LOOP SCAN_LOOP ; finish the scan\r
-\r
- MOV AX, nextPageRow\r
- ADD DI, AX ; go to the next row on screen\r
- MOV AX, nextBmpRow\r
- ADD SI, AX ; go to the next row on bmp\r
-\r
- DEC rowCounter\r
- JNZ ROW_LOOP ; do all the rows\r
- ;-- end plane painting\r
- MOV AL, plane ; advance to the next plane\r
- SHL AL, 1 ;\r
- AND AL, 0x0f ; mask the plane properly\r
- MOV plane, AL ; store the plane\r
-\r
- INC bmpOffset ; start bmp at the right spot\r
-\r
- DEC planeCounter\r
- JNZ PLANE_LOOP ; do all 4 planes\r
- }\r
-}\r
-\r
-void\r
-modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) {\r
- /* draw the whole sprite */\r
- modexDrawSpriteRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
-}\r
-\r
-void\r
-modexDrawSpriteRegion(page_t *page, int x, int y,\r
- int rx, int ry, int rw, int rh, bitmap_t *bmp) {\r
- word poffset = (word)page->data + y*(page->width/4) + x/4;\r
- byte *data = bmp->data;//+bmp->offset;\r
- word bmpOffset = (word) data + ry * bmp->width + rx;\r
- word width = rw;\r
- word height = rh;\r
- byte plane = 1 << ((byte) x & 0x03);\r
- word scanCount = width/4 + (width%4 ? 1 :0);\r
- word nextPageRow = page->width/4 - scanCount;\r
- word nextBmpRow = (word) bmp->width - width;\r
- word rowCounter;\r
- byte planeCounter = 4;\r
-\r
- __asm {\r
- MOV AX, SCREEN_SEG ; go to the VGA memory\r
- MOV ES, AX\r
-\r
- MOV DX, SC_INDEX ; point at the map mask register\r
- MOV AL, MAP_MASK ;\r
- OUT DX, AL ;\r
-\r
- PLANE_LOOP:\r
- MOV DX, SC_DATA ; select the current plane\r
- MOV AL, plane ;\r
- OUT DX, AL ;\r
-\r
- ;-- begin plane painting\r
- MOV AX, height ; start the row counter\r
- MOV rowCounter, AX ;\r
- MOV DI, poffset ; go to the first pixel\r
- MOV SI, bmpOffset ; go to the bmp pixel\r
- ROW_LOOP:\r
- MOV CX, width ; count the columns\r
- SCAN_LOOP:\r
- LODSB\r
- DEC SI\r
- CMP AL, 0\r
- JNE DRAW_PIXEL ; draw non-zero pixels\r
-\r
- INC DI ; skip the transparent pixel\r
- ADD SI, 1\r
- JMP NEXT_PIXEL\r
- DRAW_PIXEL:\r
- MOVSB ; copy the pixel\r
- NEXT_PIXEL:\r
- SUB CX, 3 ; we skip the next 3\r
- ADD SI, 3 ; skip the bmp pixels\r
- LOOP SCAN_LOOP ; finish the scan\r
-\r
- MOV AX, nextPageRow\r
- ADD DI, AX ; go to the next row on screen\r
- MOV AX, nextBmpRow\r
- ADD SI, AX ; go to the next row on bmp\r
-\r
- DEC rowCounter\r
- JNZ ROW_LOOP ; do all the rows\r
- ;-- end plane painting\r
-\r
- MOV AL, plane ; advance to the next plane\r
- SHL AL, 1 ;\r
- AND AL, 0x0f ; mask the plane properly\r
- MOV plane, AL ; store the plane\r
-\r
- INC bmpOffset ; start bmp at the right spot\r
-\r
- DEC planeCounter\r
- JNZ PLANE_LOOP ; do all 4 planes\r
- }\r
-}\r
+++ /dev/null
-void\r
-modexDrawBmpPBuf(page_t *page, int x, int y, planar_buf_t *bmp) {\r
- /* draw the region (the entire freakin bitmap) */\r
- modexDrawBmpPBufRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
-}\r
-\r
-void\r
-modexDrawBmpPBufRegion(page_t *page, int x, int y,\r
- int rx, int ry, int rw, int rh, planar_buf_t *bmp) {\r
- word poffset = (word) page->data + y*(page->width/4) + x/4;\r
- byte huge *data = *bmp->plane;//+bmp->offset;\r
- word bmpOffset = (word) data + ry * bmp->width + rx;\r
- word width = rw/4;\r
- word height = rh/4;\r
- byte plane = 1 << ((byte) x & 0x03);\r
- word scanCount = width/4 + (width%4 ? 1 :0);\r
- word nextPageRow = page->width/4 - scanCount;\r
- word nextBmpRow = (word) bmp->width - width;\r
- word rowCounter;\r
- byte planeCounter = 4;\r
-\r
- __asm {\r
- MOV AX, SCREEN_SEG ; go to the VGA memory\r
- MOV ES, AX\r
-\r
- MOV DX, SC_INDEX ; point at the map mask register\r
- MOV AL, MAP_MASK ;\r
- OUT DX, AL ;\r
-\r
- PLANE_LOOP:\r
- MOV DX, SC_DATA ; select the current plane\r
- MOV AL, plane ;\r
- OUT DX, AL ;\r
-\r
- ;-- begin plane painting\r
- MOV AX, height ; start the row counter\r
- MOV rowCounter, AX ;\r
- MOV DI, poffset ; go to the first pixel\r
- MOV SI, bmpOffset ; go to the bmp pixel\r
- ROW_LOOP:\r
- MOV CX, width ; count the columns\r
- SCAN_LOOP:\r
- MOVSB ; copy the pixel\r
- SUB CX, 3 ; we skip the next 3\r
- ADD SI, 3 ; skip the bmp pixels\r
- LOOP SCAN_LOOP ; finish the scan\r
-\r
- MOV AX, nextPageRow\r
- ADD DI, AX ; go to the next row on screen\r
- MOV AX, nextBmpRow\r
- ADD SI, AX ; go to the next row on bmp\r
-\r
- DEC rowCounter\r
- JNZ ROW_LOOP ; do all the rows\r
- ;-- end plane painting\r
- MOV AL, plane ; advance to the next plane\r
- SHL AL, 1 ;\r
- AND AL, 0x0f ; mask the plane properly\r
- MOV plane, AL ; store the plane\r
-\r
- INC bmpOffset ; start bmp at the right spot\r
-\r
- DEC planeCounter\r
- JNZ PLANE_LOOP ; do all 4 planes\r
- }\r
-}\r
-\r
-void\r
-modexDrawSpritePBuf(page_t *page, int x, int y, planar_buf_t *bmp) {\r
- /* draw the whole sprite */\r
- modexDrawSpritePBufRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);\r
-}\r
-\r
-void\r
-modexDrawSpritePBufRegion(page_t *page, int x, int y,\r
- int rx, int ry, int rw, int rh, planar_buf_t *bmp) {\r
- word poffset = (word)page->data + y*(page->width/4) + x/4;\r
- byte huge *data = *bmp->plane;//+bmp->offset;\r
- word bmpOffset = (word) data + ry * bmp->width + rx;\r
- word width = rw/4;\r
- word height = rh/4;\r
- byte plane = 1 << ((byte) x & 0x03);\r
- word scanCount = width/4 + (width%4 ? 1 :0);\r
- word nextPageRow = page->width/4 - scanCount;\r
- word nextBmpRow = (word) bmp->width - width;\r
- word rowCounter;\r
- byte planeCounter = 4;\r
-\r
- __asm {\r
- MOV AX, SCREEN_SEG ; go to the VGA memory\r
- MOV ES, AX\r
-\r
- MOV DX, SC_INDEX ; point at the map mask register\r
- MOV AL, MAP_MASK ;\r
- OUT DX, AL ;\r
-\r
- PLANE_LOOP:\r
- MOV DX, SC_DATA ; select the current plane\r
- MOV AL, plane ;\r
- OUT DX, AL ;\r
-\r
- ;-- begin plane painting\r
- MOV AX, height ; start the row counter\r
- MOV rowCounter, AX ;\r
- MOV DI, poffset ; go to the first pixel\r
- MOV SI, bmpOffset ; go to the bmp pixel\r
- ROW_LOOP:\r
- MOV CX, width ; count the columns\r
- SCAN_LOOP:\r
- LODSB\r
- DEC SI\r
- CMP AL, 0\r
- JNE DRAW_PIXEL ; draw non-zero pixels\r
-\r
- INC DI ; skip the transparent pixel\r
- ADD SI, 1\r
- JMP NEXT_PIXEL\r
- DRAW_PIXEL:\r
- MOVSB ; copy the pixel\r
- NEXT_PIXEL:\r
- SUB CX, 3 ; we skip the next 3\r
- ADD SI, 3 ; skip the bmp pixels\r
- LOOP SCAN_LOOP ; finish the scan\r
-\r
- MOV AX, nextPageRow\r
- ADD DI, AX ; go to the next row on screen\r
- MOV AX, nextBmpRow\r
- ADD SI, AX ; go to the next row on bmp\r
-\r
- DEC rowCounter\r
- JNZ ROW_LOOP ; do all the rows\r
- ;-- end plane painting\r
-\r
- MOV AL, plane ; advance to the next plane\r
- SHL AL, 1 ;\r
- AND AL, 0x0f ; mask the plane properly\r
- MOV plane, AL ; store the plane\r
-\r
- INC bmpOffset ; start bmp at the right spot\r
-\r
- DEC planeCounter\r
- JNZ PLANE_LOOP ; do all 4 planes\r
- }\r
-}\r