]> 4ch.mooo.com Git - 16.git/blobdiff - src/lib/modex16.c
I DID IT PLANAR BUFFERING IS RENDERED! IT JUST NEEDS POLISHING~
[16.git] / src / lib / modex16.c
index 19ab89c711592f593524195ef7957539fe1c3d0d..8a0015bd5e2b06f9a1d7ec22551bf4d4e658ed8a 100755 (executable)
@@ -499,6 +499,7 @@ oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite)
        }\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
@@ -508,19 +509,18 @@ modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp) {
 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 far *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
-       //code is a bit slow here\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
@@ -555,7 +555,6 @@ modexDrawBmpRegion(page_t *page, int x, int y,
                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
@@ -577,17 +576,163 @@ modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) {
 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
+       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 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