2 modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp) {
\r
3 /* draw the region (the entire freakin bitmap) */
\r
4 modexDrawBmpRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);
\r
8 modexDrawBmpRegion(page_t *page, int x, int y,
\r
9 int rx, int ry, int rw, int rh, bitmap_t *bmp) {
\r
10 word poffset = (word) page->data + y*(page->width/4) + x/4;
\r
11 byte *data = bmp->data;//+bmp->offset;
\r
12 word bmpOffset = (word) data + ry * bmp->width + rx;
\r
15 byte plane = 1 << ((byte) x & 0x03);
\r
16 word scanCount = width/4 + (width%4 ? 1 :0);
\r
17 word nextPageRow = page->width/4 - scanCount;
\r
18 word nextBmpRow = (word) bmp->width - width;
\r
20 byte planeCounter = 4;
\r
23 MOV AX, SCREEN_SEG ; go to the VGA memory
\r
26 MOV DX, SC_INDEX ; point at the map mask register
\r
31 MOV DX, SC_DATA ; select the current plane
\r
35 ;-- begin plane painting
\r
36 MOV AX, height ; start the row counter
\r
37 MOV rowCounter, AX ;
\r
38 MOV DI, poffset ; go to the first pixel
\r
39 MOV SI, bmpOffset ; go to the bmp pixel
\r
41 MOV CX, width ; count the columns
\r
43 MOVSB ; copy the pixel
\r
44 SUB CX, 3 ; we skip the next 3
\r
45 ADD SI, 3 ; skip the bmp pixels
\r
46 LOOP SCAN_LOOP ; finish the scan
\r
49 ADD DI, AX ; go to the next row on screen
\r
51 ADD SI, AX ; go to the next row on bmp
\r
54 JNZ ROW_LOOP ; do all the rows
\r
55 ;-- end plane painting
\r
56 MOV AL, plane ; advance to the next plane
\r
58 AND AL, 0x0f ; mask the plane properly
\r
59 MOV plane, AL ; store the plane
\r
61 INC bmpOffset ; start bmp at the right spot
\r
64 JNZ PLANE_LOOP ; do all 4 planes
\r
69 modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) {
\r
70 /* draw the whole sprite */
\r
71 modexDrawSpriteRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp);
\r
75 modexDrawSpriteRegion(page_t *page, int x, int y,
\r
76 int rx, int ry, int rw, int rh, bitmap_t *bmp) {
\r
77 word poffset = (word)page->data + y*(page->width/4) + x/4;
\r
78 byte *data = bmp->data;//+bmp->offset;
\r
79 word bmpOffset = (word) data + ry * bmp->width + rx;
\r
82 byte plane = 1 << ((byte) x & 0x03);
\r
83 word scanCount = width/4 + (width%4 ? 1 :0);
\r
84 word nextPageRow = page->width/4 - scanCount;
\r
85 word nextBmpRow = (word) bmp->width - width;
\r
87 byte planeCounter = 4;
\r
90 MOV AX, SCREEN_SEG ; go to the VGA memory
\r
93 MOV DX, SC_INDEX ; point at the map mask register
\r
98 MOV DX, SC_DATA ; select the current plane
\r
102 ;-- begin plane painting
\r
103 MOV AX, height ; start the row counter
\r
104 MOV rowCounter, AX ;
\r
105 MOV DI, poffset ; go to the first pixel
\r
106 MOV SI, bmpOffset ; go to the bmp pixel
\r
108 MOV CX, width ; count the columns
\r
113 JNE DRAW_PIXEL ; draw non-zero pixels
\r
115 INC DI ; skip the transparent pixel
\r
119 MOVSB ; copy the pixel
\r
121 SUB CX, 3 ; we skip the next 3
\r
122 ADD SI, 3 ; skip the bmp pixels
\r
123 LOOP SCAN_LOOP ; finish the scan
\r
125 MOV AX, nextPageRow
\r
126 ADD DI, AX ; go to the next row on screen
\r
128 ADD SI, AX ; go to the next row on bmp
\r
131 JNZ ROW_LOOP ; do all the rows
\r
132 ;-- end plane painting
\r
134 MOV AL, plane ; advance to the next plane
\r
136 AND AL, 0x0f ; mask the plane properly
\r
137 MOV plane, AL ; store the plane
\r
139 INC bmpOffset ; start bmp at the right spot
\r
142 JNZ PLANE_LOOP ; do all 4 planes
\r