X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2F16_vl.c;h=e30f7484b83eb8b01152803fc429fb80cf1e12f0;hb=a6dac9aacc0353763dc564afda8b57848afc3e0b;hp=53e45abd3aeea4eccc87938d4d6a8a0b4ad0bd6d;hpb=310f4da6ca5a87f9b69e8de7cbe4407703415f54;p=16.git diff --git a/src/lib/16_vl.c b/src/lib/16_vl.c index 53e45abd..e30f7484 100755 --- a/src/lib/16_vl.c +++ b/src/lib/16_vl.c @@ -213,8 +213,8 @@ modexNextPage(page_t *p) { page_t result; result.data = p->data + (p->pagesize); - result.dx = 0; - result.dy = 0; + result.dx = p->dx; // not used anymore we use page[0].dx + result.dy = p->dy; // not used anymore we use page[0].dy result.sw = p->sw; result.sh = p->sh; result.width = p->width; @@ -238,8 +238,8 @@ modexNextPageFlexibleSize(page_t *p, word x, word y) page_t result; result.data = p->data + (p->pagesize); /* compute the offset */ - result.dx = 0; - result.dy = 0; + result.dx = 0; // not used anymore we use page[0].dx + result.dy = 0; // not used anymore we use page[0].dy result.sw = x; result.sh = y; result.width = x; @@ -294,23 +294,25 @@ void modexHiganbanaPageSetup(video_t *video) video->r=1; //setup the buffersize - video->page[0].dy=video->page[0].dx= - video->page[1].dx=video->page[1].dy=16; + video->page[0].dx=video->page[1].dx=TILEWH; + video->page[0].dy=video->page[1].dy=TILEWH; + /* video->page[1].dx=video->page[1].dy=TILEWH; // 1 tile size buffer video->page[2].dx=video->page[2].dy= - video->page[3].dx=video->page[3].dy=0; + video->page[3].dx=video->page[3].dy=0; */// cache pages are buffer wwww } +// +// move page to appropriate part and show it +// void modexShowPage(page_t *page) { - word high_address; - word low_address; - word offset; + word high_address, low_address, offset; byte crtcOffset; /* calculate offset */ offset = (word) page->data; - offset += page->dy * (page->width >> 2 ); - offset += page->dx >> 2; + offset += page[0].dy * (page->width >> 2 ); + offset += page[0].dx >> 2; /* calculate crtcOffset according to virtual width */ crtcOffset = page->width >> 3; @@ -319,24 +321,121 @@ modexShowPage(page_t *page) { low_address = LOW_ADDRESS | (offset << 8); /* wait for appropriate timing and then program CRTC */ - //while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE)); +//+=+= while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE)); + outpw(CRTC_INDEX, high_address); + outpw(CRTC_INDEX, low_address); + outp(CRTC_INDEX, 0x13); + outp(CRTC_DATA, crtcOffset); + + /* wait for one retrace */ +//+=+= while (!(inp(INPUT_STATUS_1) & VRETRACE)); + + /* do PEL panning here */ + outp(AC_INDEX, 0x33); + outp(AC_INDEX, (page[0].dx & 0x03) << 1); +} + +// +// testing version of void modexShowPage() +// +void +modexShowPage_(page_t *page) +{ + word high_address, low_address, offset; + byte crtcOffset; + + /* calculate offset */ + offset = (word) page->data; + offset += page[0].dy * (page->width >> 2 ); + offset += page[0].dx >> 2; + + /* calculate crtcOffset according to virtual width */ + crtcOffset = page->sw >> 3; + + high_address = HIGH_ADDRESS | (offset & 0xff00); + low_address = LOW_ADDRESS | (offset << 8); + + /* wait for appropriate timing and then program CRTC */ +//+=+= while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE)); + outpw(CRTC_INDEX, high_address); + outpw(CRTC_INDEX, low_address); + outp(CRTC_INDEX, 0x13); + outp(CRTC_DATA, crtcOffset); + + /* wait for one retrace */ +//+=+= while (!(inp(INPUT_STATUS_1) & VRETRACE)); + + /* do PEL panning here */ + outp(AC_INDEX, 0x33); + outp(AC_INDEX, (page[0].dx & 0x03) << 1); +} + +//yet another variant +//args: page, vertical sync switch, screen resolution switch, page0 switch +void +VL_ShowPage(page_t *page, boolean vsync, boolean sr, boolean an) { + word high_address, low_address, offset; + byte crtcOffset; + + /* calculate offset */ + offset = (word) page->data; + switch(an) + { + case 1: + offset += page[0].dy * (page->width >> 2 ); + offset += page[0].dx >> 2; + break; + default: + case 0: + offset += page->dy * (page->width >> 2 ); + offset += page->dx >> 2; + break; + } + /* calculate crtcOffset according to virtual width */ + switch(sr) + { + case 1: + crtcOffset = page->sw >> 3; + break; + default: + case 0: + crtcOffset = page->width >> 3; + break; + } + + high_address = HIGH_ADDRESS | (offset & 0xff00); + low_address = LOW_ADDRESS | (offset << 8); + + /* wait for appropriate timing and then program CRTC */ + if(vsync) while ((inp(INPUT_STATUS_1) & DISPLAY_ENABLE)); outpw(CRTC_INDEX, high_address); outpw(CRTC_INDEX, low_address); outp(CRTC_INDEX, 0x13); outp(CRTC_DATA, crtcOffset); - /* wait for one retrace */ - //while (!(inp(INPUT_STATUS_1) & VRETRACE)); + /* wait for one retrace */ + if(vsync) while (!(inp(INPUT_STATUS_1) & VRETRACE)); /* do PEL panning here */ outp(AC_INDEX, 0x33); - outp(AC_INDEX, (page->dx & 0x03) << 1); + switch(an) + { + case 1: + outp(AC_INDEX, (page[0].dx & 0x03) << 1); + break; + default: + case 0: + outp(AC_INDEX, (page->dx & 0x03) << 1); + break; + } } +//============================================================================= + void modexPanPage(page_t *page, int dx, int dy) { - page->dx = dx; - page->dy = dy; + page[0].dx = dx; + page[0].dy = dy; } void @@ -626,6 +725,23 @@ modexLoadPalFile(byte *filename, byte **palette) { } +void VL_LoadPalFile(const char *filename, byte *palette) +{ + int fd; + + fd = open(filename,O_RDONLY|O_BINARY); + if (fd >= 0) { + word i; + + read(fd,palette,768); + close(fd); + + vga_palette_lseek(0); + for (i=0;i < 256;i++) vga_palette_write(palette[(i*3)+0]>>2,palette[(i*3)+1]>>2,palette[(i*3)+2]>>2); + } +} + + void modexSavePalFile(char *filename, byte *pal) { //unsigned int i;