X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fmodex16.c;h=9b47253eef860da180d8901354ac96b6b90377b1;hb=1cc75f46d15728fed75f53a2243c9ad4c8234511;hp=90005d7ecb0d125fcb96b7627a82c7707bb14483;hpb=88540434895cd9c79e8b2c35dda149adad428462;p=16.git diff --git a/src/lib/modex16.c b/src/lib/modex16.c index 90005d7e..9b47253e 100755 --- a/src/lib/modex16.c +++ b/src/lib/modex16.c @@ -97,16 +97,11 @@ modexEnter(sword vq, global_game_variables_t *gv) switch(vq) { - case 0: + case 1: CRTParmCount = sizeof(ModeX_320x240regs) / sizeof(ModeX_320x240regs[0]); /* width and height */ - gv->video.page->sw=320; - gv->video.page->sh=240; - gv->video.page->tilesw = gv->video.page->sw/TILEWH; - gv->video.page->tilesh = gv->video.page->sh/TILEWH; - //TODO MAKE FLEXIBLE~ - gv->video.page->tilemidposscreenx = 10; - gv->video.page->tilemidposscreeny = 8; + gv->video.page[0].sw=320; + gv->video.page[0].sh=240; /* send the CRTParms */ for(i=0; ivideo.page[0].sw=120; + gv->video.page[0].sh=160; + + /* send the CRTParms */ + for(i=0; ivideo.page[0].sw=320; + gv->video.page[0].sh=200; + + /* send the CRTParms */ + for(i=0; ivideo.page[0].sw=192; + gv->video.page[0].sh=144; /* send the CRTParms */ for(i=0; ivideo.page[0].sw=256; + gv->video.page[0].sh=192; + + /* send the CRTParms */ + for(i=0; ivideo.page[0].tilesw = gv->video.page[0].sw/TILEWH; + gv->video.page[0].tilesh = gv->video.page[0].sh/TILEWH; + //TODO MAKE FLEXIBLE~ + gv->video.page[0].tilemidposscreenx = gv->video.page[0].tilesw; + gv->video.page[0].tilemidposscreeny = (gv->video.page[0].tilesh/2)+1; + #define PAGE_SIZE (word)(gv->video.page[0].sw/4 * gv->video.page[0].sh) } void @@ -169,24 +222,32 @@ modexsetBaseXMode(page_t *page) /* reprogram the CRT controller */ outp(CRTC_INDEX, 0x11); /* VSync End reg contains register write prot */ - temp = inp(CRTC_DATA) & 0x7F; - outp(CRTC_INDEX, 0x11); -// outp(CRTC_DATA, 0x7f); /* get current write protect on varios regs */ - outp(CRTC_DATA, temp); /* get current write protect on varios regs */ +// temp = inp(CRTC_DATA) & 0x7F; +// outp(CRTC_INDEX, 0x11); + outp(CRTC_DATA, 0x7f); /* get current write protect on varios regs */ +// outp(CRTC_DATA, temp); /* get current write protect on varios regs */ } page_t -modexDefaultPage() { +modexDefaultPage(page_t *p) +{ page_t page; /* default page values */ page.data = VGA; page.dx = 0; page.dy = 0; - page.width = SCREEN_WIDTH; - page.height = SCREEN_HEIGHT; - page.tw = page.width/TILEWH; - page.th = page.height/TILEWH; + page.sw = p->sw; + page.sh = p->sh; + page.width = p->sw; + page.height = p->sh; + page.tw = page.sw/TILEWH; + page.th = page.sh/TILEWH; + page.tilemidposscreenx = page.tw/2; + page.tilemidposscreeny = (page.th/2)+1; + page.tilesw=p->tilesw; + page.tilesh=p->tilesh; + //pageSize = p->sw*p->sh; page.id = 0; return page; @@ -333,35 +394,98 @@ modexClearRegion(page_t *page, int x, int y, int w, int h, byte color) { } } - -void -oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite) +//TODO! +//void +//modexDrawBmpRegion (page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp) +void modexDrawPBufRegion (page_t *page, int x, int y, int rx, int ry, int rw, int rh, planar_buf_t *p, boolean sprite) { - byte plane; - word px, py; - word offset; - - /* TODO Make this fast. It's SLOOOOOOW */ + int plane; + int px, py, i; +// byte near *buff; + px=x; + py=y; +// buff = _nmalloc(p->pwidth+1); + // TODO Make this fast. It's SLOOOOOOW +// for(plane=0; plane < 4; plane++) { +// i=0; +// modexSelectPlane(PLANE(plane+x)); +// for(px = plane; px < p->width; px+=4) { +// offset=px; +// for(py=0; pyheight/2; py++) { +// //SELECT_ALL_PLANES(); +// if(!sprite || p->plane[offset]) +// page->data = &(p->plane[offset][i++]); +// offset+=p->width; +// offset++; +// } +// } +// } for(plane=0; plane < 4; plane++) { + i=(rx/4)+((rx/4)*ry); modexSelectPlane(PLANE(plane+x)); - for(px = plane; px < bmp->width; px+=4) { - offset=px; - for(py=0; pyheight; py++) { - if(!sprite || bmp->data[offset]) - page[PAGE_OFFSET(x+px, y+py)] = bmp->data[offset]; - offset+=bmp->width; - } + for(; y < py+p->height; y++) { + //for(px=0; px < p->width; px++) { + //printf("%02X ", (int) p->plane[plane][i++]); +// _fmemcpy(buff, &(p->plane[plane][i+=p->pwidth]), p->pwidth); +// printf("buff %u==%s\n", y, *buff); +// _fmemcpy(page->data + (((page->width/4) * (y+page->dy)) + ((x+page->dx) / 4)), buff, p->pwidth); + _fmemcpy(page->data + (((page->width/4) * (y+page->dy)) + ((x+page->dx) / 4)), &(p->plane[plane][i+=p->pwidth]), p->pwidth); + //} } + x=px; + y=py; } +// _nfree(buff); } +/*void +DrawPBuf(page_t *page, int x, int y, planar_buf_t *p, boolean sprite) +{ + int plane; + int px, py, i; +// byte near *buff; + px=x; + py=y; +// buff = _nmalloc(p->pwidth+1); + // TODO Make this fast. It's SLOOOOOOW +// for(plane=0; plane < 4; plane++) { +// i=0; +// modexSelectPlane(PLANE(plane+x)); +// for(px = plane; px < p->width; px+=4) { +// offset=px; +// for(py=0; pyheight/2; py++) { +// //SELECT_ALL_PLANES(); +// if(!sprite || p->plane[offset]) +// page->data = &(p->plane[offset][i++]); +// offset+=p->width; +// offset++; +// } +// } +// } + for(plane=0; plane < 4; plane++) { + i=0; + modexSelectPlane(PLANE(plane+x)); + for(; y < py+p->height; y++) { + //for(px=0; px < p->width; px++) { + //printf("%02X ", (int) p->plane[plane][i++]); +// _fmemcpy(buff, &(p->plane[plane][i+=p->pwidth]), p->pwidth); +// printf("buff %u==%s\n", y, *buff); +// _fmemcpy(page->data + (((page->width/4) * (y+page->dy)) + ((x+page->dx) / 4)), buff, p->pwidth); + _fmemcpy(page->data + (((page->width/4) * (y+page->dy)) + ((x+page->dx) / 4)), &(p->plane[plane][i+=p->pwidth]), p->pwidth); + //} + } + x=px; + y=py; + } +// _nfree(buff); +}*/ + void -CDrawBmp(byte far* vgamem, page_t* page, int x, int y, bitmap_t *bmp, byte sprite) +oldDrawBmp(byte far* page, int x, int y, bitmap_t *bmp, byte sprite) { byte plane; word px, py; - word offset=0; - + word offset; /* TODO Make this fast. It's SLOOOOOOW */ for(plane=0; plane < 4; plane++) { @@ -370,8 +494,7 @@ CDrawBmp(byte far* vgamem, page_t* page, int x, int y, bitmap_t *bmp, byte sprit offset=px; for(py=0; pyheight; py++) { if(!sprite || bmp->data[offset]) - //modexputPixel(page, x+px, y+py, bmp->data[offset]); - vgamem[PAGE_OFFSET(x+px, y+py)] = bmp->data[offset]; + page[PAGE_OFFSET(x+px, y+py)] = bmp->data[offset]; offset+=bmp->width; } } @@ -384,7 +507,6 @@ modexDrawBmp(page_t *page, int x, int y, bitmap_t *bmp) { modexDrawBmpRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp); } - void modexDrawBmpRegion(page_t *page, int x, int y, int rx, int ry, int rw, int rh, bitmap_t *bmp) { @@ -453,10 +575,27 @@ 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; +modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp) { + /* TODO - adapt from test code */ + int plane; + for(plane=0; plane < 4; plane++) + { + //fack + } +} + + +void +modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) { + /* draw the whole sprite */ + modexDrawSpriteRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp); +} + +/*void +modexDrawSpriteRegion(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 *data = bmp->data;//+bmp->offset; word bmpOffset = (word) data + ry * bmp->width + rx; word width = rw; word height = rh; @@ -467,11 +606,6 @@ modex_sparky4_DrawBmpRegion(page_t *page, int x, int y, 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 @@ -493,7 +627,17 @@ modex_sparky4_DrawBmpRegion(page_t *page, int x, int y, ROW_LOOP: MOV CX, width ; count the columns SCAN_LOOP: + LODSB + DEC SI + CMP AL, 0 + JNE DRAW_PIXEL ; draw non-zero pixels + + INC DI ; skip the transparent pixel + ADD SI, 1 + JMP NEXT_PIXEL + DRAW_PIXEL: MOVSB ; copy the pixel + NEXT_PIXEL: SUB CX, 3 ; we skip the next 3 ADD SI, 3 ; skip the bmp pixels LOOP SCAN_LOOP ; finish the scan @@ -517,30 +661,13 @@ modex_sparky4_DrawBmpRegion(page_t *page, int x, int y, DEC planeCounter JNZ PLANE_LOOP ; do all 4 planes } -} - -void -modexDrawPlanarBuf(page_t *page, int x, int y, planar_buf_t *bmp) { - /* TODO - adapt from test code */ - int plane; - for(plane=0; plane < 4; plane++) - { - //fack - } -} - - -void -modexDrawSprite(page_t *page, int x, int y, bitmap_t *bmp) { - /* draw the whole sprite */ - modexDrawSpriteRegion(page, x, y, 0, 0, bmp->width, bmp->height, bmp); -} +}//backup!*/ void modexDrawSpriteRegion(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 *data = bmp->data;//+bmp->offset; + byte huge *data = bmp->data;//+bmp->offset; word bmpOffset = (word) data + ry * bmp->width + rx; word width = rw; word height = rh; @@ -608,7 +735,6 @@ modexDrawSpriteRegion(page_t *page, int x, int y, } } - /* copy a region of video memory from one page to another. * It assumes that the left edge of the tile is the same on both * regions and the memory areas do not overlap. @@ -1024,6 +1150,14 @@ modexPalUpdate0(byte *p) } } +void +modexPalOverscan(byte *p, word col) +{ + modexWaitBorder(); + outp(PAL_WRITE_REG, 0); /* start at the beginning of palette */ + outp(PAL_DATA_REG, col); +} + //color checker~ //i want to make another vesion that checks the palette when the palette is being appened~ void chkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/) @@ -1151,7 +1285,7 @@ void modexhlin(page_t *page, word xl, word xh, word y, word color) for(x=0;x=SCREEN_WIDTH-1){ x=0; yy+=4; } + if(x+4>=page[0].sw-1){ x=0; yy+=4; } modexClearRegion(page, x+xl, y+yy, 4, 4, color); } //modexputPixel(page, x+xl, y, color); @@ -1164,6 +1298,7 @@ void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, cons word addr = (word) l; word chw=0; byte c; + //byte near *bakapee; switch(t) { @@ -1216,9 +1351,14 @@ void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, cons DEC CX JNZ L1 } - + //bakapee = _nmalloc(sizeof(byte)*8); +//TODO: OPTIMIZE THIS!!!! for(i=0; idata + (((page->width/4) * (y+page->dy+i)) + ((x+page->dx+chw) / 4)), bakapee, 8);*/ j=1<<8; xp=0; while(j) @@ -1230,6 +1370,7 @@ void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, cons } chw += xp; } + //_nfree(bakapee); } void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str)