X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fmodex16.c;h=cb5102c8077c32d55f79c065f1bcb896cc386dbb;hb=73a484ef8bbdbcb82bde5580b77001e7c54265f8;hp=eaf9966c805f047ddb35804d6967d2161d086277;hpb=bba7fa83186d755c585791acec1db6c6d58164db;p=16.git diff --git a/src/lib/modex16.c b/src/lib/modex16.c index eaf9966c..cb5102c8 100755 --- a/src/lib/modex16.c +++ b/src/lib/modex16.c @@ -83,6 +83,7 @@ modexEnter() { 0xea10, /* v sync start */ 0xac11, /* v sync end and protect cr0-cr7 */ 0xdf12, /* vertical displayed */ +// 0x2013, /* offset/logical width */ 0x0014, /* turn off dword mode */ 0xe715, /* v blank start */ 0x0616, /* v blank end */ @@ -139,7 +140,9 @@ modexDefaultPage() { page.dy = 0; page.width = SCREEN_WIDTH; page.height = SCREEN_HEIGHT; - page.id = 0; + page.tw = page.width/TILEWH; + page.th = page.height/TILEWH; + page.id = 0; return page; } @@ -151,30 +154,35 @@ page_t modexNextPage(page_t *p) { page_t result; - result.data = p->data + (p->width/4)*p->height; /* compute the offset */ + result.data = p->data + (p->width/4)*p->height; result.dx = 0; result.dy = 0; result.width = p->width; result.height = p->height; - result.id = p->id+1; + result.tw = p->width/TILEWH; + result.th = p->height/TILEWH; + result.id = p->id+1; - return result; + return result; +// return modexNextPageFlexibleSize(&p, p->width, p->height); } //next page with defined dimentions~ page_t -modexNextPage0(page_t *p, word x, word y) +modexNextPageFlexibleSize(page_t *p, word x, word y) { - page_t result; - - result.data = p->data + (p->width/4)*p->height; /* compute the offset */ - result.dx = 0; - result.dy = 0; - result.width = x; - result.height = y; - result.id = p->id+1; - - return result; + page_t result; + + result.data = p->data + (p->width/4)*p->height; /* compute the offset */ + result.dx = 0; + result.dy = 0; + result.width = x; + result.height = y; + result.tw = p->width/TILEWH; + result.th = p->height/TILEWH; + result.id = p->id+1; + + return result; } @@ -399,6 +407,72 @@ modexDrawBmpRegion(page_t *page, int x, int y, } } +void +modex_sparky4_DrawBmpRegion(page_t *page, int x, int y, + int rx, int ry, int rw, int rh, bitmap_t *bmp) { + word poffset = (word) page->data + y*(page->width/4) + x/4; + byte far *data = bmp->data;//+bmp->offset; + word bmpOffset = (word) data + ry * bmp->width + rx; + word width = rw; + word height = rh; + byte plane = 1 << ((byte) x & 0x03); + word scanCount = width/4 + (width%4 ? 1 :0); + word nextPageRow = page->width/4 - scanCount; + word nextBmpRow = (word) bmp->width - width; + word rowCounter; + byte planeCounter = 4; + +/* printf("bmp->data=%Fp\n",bmp->data); + printf("*bmp->data=%Fp\n",*(bmp->data)); + printf("&bmp->data=%Fp\n",&(bmp->data));*/ + + //code is a bit slow here + __asm { + MOV AX, SCREEN_SEG ; go to the VGA memory + MOV ES, AX + + MOV DX, SC_INDEX ; point at the map mask register + MOV AL, MAP_MASK ; + OUT DX, AL ; + + PLANE_LOOP: + MOV DX, SC_DATA ; select the current plane + MOV AL, plane ; + OUT DX, AL ; + + ;-- begin plane painting + MOV AX, height ; start the row counter + MOV rowCounter, AX ; + MOV DI, poffset ; go to the first pixel + MOV SI, bmpOffset ; go to the bmp pixel + ROW_LOOP: + MOV CX, width ; count the columns + SCAN_LOOP: + MOVSB ; copy the pixel + SUB CX, 3 ; we skip the next 3 + ADD SI, 3 ; skip the bmp pixels + LOOP SCAN_LOOP ; finish the scan + + MOV AX, nextPageRow + ADD DI, AX ; go to the next row on screen + MOV AX, nextBmpRow + ADD SI, AX ; go to the next row on bmp + + DEC rowCounter + JNZ ROW_LOOP ; do all the rows + ;-- end plane painting + + MOV AL, plane ; advance to the next plane + SHL AL, 1 ; + AND AL, 0x0f ; mask the plane properly + MOV plane, AL ; store the plane + + INC bmpOffset ; start bmp at the right spot + + DEC planeCounter + JNZ PLANE_LOOP ; do all 4 planes + } +} void modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp) {