X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fmodex16.c;h=5db7bf481849910a90551b4725f801c7600daa38;hb=d31b48962de4f4384cca54f92db59ccc0bb06fbc;hp=fcec8d38002ff996c245cc25f783a9b4dce5e261;hpb=46de466195384487cfd2ce33da7d277a25c4cdef;p=16.git diff --git a/src/lib/modex16.c b/src/lib/modex16.c index fcec8d38..5db7bf48 100755 --- a/src/lib/modex16.c +++ b/src/lib/modex16.c @@ -80,7 +80,6 @@ vgaGetMode() void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv) { word i; - dword far*ptr=(dword far*)vga_state.vga_graphics_ram;//VGA; /* used for faster screen clearing */ struct vga_mode_params cm; int CRTParmCount; @@ -94,9 +93,15 @@ void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv) case 1: //CRTParmCount = sizeof(ModeX_320x240regs) / sizeof(ModeX_320x240regs[0]); /* width and height */ - gv->video.page[0].sw=vga_state.vga_width = 320; // VGA lib currently does not update this - gv->video.page[0].sh=vga_state.vga_height = 240; // VGA lib currently does not update this - + gv->video.page[0].sw = vga_state.vga_width = 320; // VGA lib currently does not update this + gv->video.page[0].sh = vga_state.vga_height = 240; // VGA lib currently does not update this + /* virtual width and height. match screen, at first */ + gv->video.page[0].height = gv->video.page[0].sh; + gv->video.page[0].width = gv->video.page[0].sw; + + // mode X BYTE mode + cm.word_mode = 0; + cm.dword_mode = 0; // 320x240 mode 60Hz cm.horizontal_total=0x5f + 5; /* CRTC[0] -5 */ cm.horizontal_display_end=0x4f + 1; /* CRTC[1] -1 */ @@ -115,6 +120,7 @@ void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv) cm.clock_select = 0; /* misc register = 0xE3 25MHz */ cm.vsync_neg = 1; cm.hsync_neg = 1; + cm.offset = (vga_state.vga_width / (4 * 2)); // 320 wide (40 x 4 pixel groups x 2) break; case 2: // TODO: 160x120 according to ModeX_160x120regs return; @@ -128,15 +134,18 @@ void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv) return; } + vga_state.vga_stride = cm.offset * 2; vga_write_crtc_mode(&cm,0); /* clear video memory */ switch (cmem) { - case 1: - /* clear video memory */ - vga_write_sequencer(2/*map mask register*/,0xf/*all 4 planes*/); - for(i=0; i<0x8000; i++) ptr[i] = 0x0000; + case 1: { + /* clear video memory */ + dword far*ptr=(dword far*)vga_state.vga_graphics_ram;//VGA; /* used for faster screen clearing */ + vga_write_sequencer(2/*map mask register*/,0xf/*all 4 planes*/); + for(i = 0;i < 0x4000; i++) ptr[i] = 0x0000; // 0x4000 x dword = 64KB + } break; } gv->video.page[0].tilesw = gv->video.page[0].sw/TILEWH; @@ -636,7 +645,7 @@ printf("\nqqqqqqqq\n\n"); pp = q; //printf("1(*i)=%02d\n", (*i)/3); //printf("1z=%02d\n", z/3); - chkcolor(bmp, &q, &a, &aa, &z, i); + modexchkcolor(bmp, &q, &a, &aa, &z, i); //printf("2(*i)=%02d\n", (*i)/3); //printf("2z=%02d\n", z/3); aq=0; @@ -753,7 +762,7 @@ modexPalOverscan(byte *p, word 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*/) +void modexchkcolor(bitmap_t *bmp, word *q, word *a, word *aa, word *z, word *i/*, word *offset*/) { byte *pal; word zz=0; @@ -871,23 +880,13 @@ byte modexgetPixel(page_t *page, int x, int y) } -void modexhlin(page_t *page, word xl, word xh, word y, word color) -{ - word x; - word yy=0; - - for(x=0;x=page[0].sw-1){ x=0; yy+=4; } - modexClearRegion(page, x+xl, y+yy, 4, 4, color); - } - //modexputPixel(page, x+xl, y, color); -} - -void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str, boolean q) +void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, const byte *str) { word s, o, w; + word x_draw = x; word addr = (word) romFontsData.l; + word addrq = (page->width/4) * y + (x / 4) + ((word)page->data); + word addrr = addrq; byte c; s=romFonts[t].seg; @@ -898,35 +897,23 @@ void modexprint(page_t *page, word x, word y, word t, word col, word bgcol, cons for(; *str != '\0'; str++) { c = (*str); - if((c=='\n'/* || c=="\ -"*/) || romFontsData.chw ->=page->width) + if(c=='\n') { - romFontsData.chw=0; - y+=romFonts[t].charSize; + x = x_draw; + romFontsData.chw = 0; + addrq += (page->width / 4) * 8; + addrr = addrq; + y += 8; continue; } - //load the letter 'A' - __asm { - MOV DI, addr - MOV SI, o - MOV ES, s - SUB AH, AH - MOV AL, c ; the letter - MOV CX, w - MUL CX - ADD SI, AX ;the address of charcter - L1: MOV AX, ES:SI - MOV DS:DI, AX - INC SI - INC DI - DEC CX - JNZ L1 - } -//TODO: OPTIMIZE THIS!!!! - modexDrawCharPBuf(page, x, y, t, col, bgcol, q); - //if(!q) getch(); + // load the character into romFontsData.l + // no need for inline assembly! + // NTS: It might even be faster to just let the modexDrawChar point directly at ROM font than to copy per char! --J.C. + _fmemcpy(romFontsData.l,MK_FP(s,o+(w*c))/*ROM font location*/,w/*char size*/); + modexDrawChar(page, x_draw/*for mode X planar use*/, t, col, bgcol, addrr); + x_draw += 8; /* track X for edge of screen */ + addrr += 2; /* move 8 pixels over (2 x 4 planar pixels per byte) */ } } @@ -1006,7 +993,7 @@ void modexprintbig(page_t *page, word x, word y, word t, word col, word bgcol, c } /* palette dump on display! */ -void pdump(page_t *pee) +void modexpdump(page_t *pee) { int mult=(QUADWH); int palq=(mult)*TILEWH; @@ -1026,7 +1013,7 @@ void pdump(page_t *pee) // the Virtual screen. // // // ///////////////////////////////////////////////////////////////////////////// -void cls(page_t *page, byte color, byte *Where) +void modexcls(page_t *page, byte color, byte *Where) { //modexClearRegion(page, 0, 0, page->width, page->height, color); /* set map mask to all 4 planes */ @@ -1035,7 +1022,7 @@ void cls(page_t *page, byte color, byte *Where) _fmemset(Where, color, page->width*(page->height)/4); } -/*void +void modexWaitBorder() { while(inp(INPUT_STATUS_1) & 8) { // spin @@ -1044,4 +1031,31 @@ modexWaitBorder() { while(!(inp(INPUT_STATUS_1) & 8)) { // spin } -}*/ +} + +void bios_cls() { + VGA_ALPHA_PTR ap; + VGA_RAM_PTR rp; + unsigned char m; + + m = int10_getmode(); + if ((rp=vga_state.vga_graphics_ram) != NULL && !(m <= 3 || m == 7)) { + unsigned int i,im; + + im = (FP_SEG(vga_state.vga_graphics_ram_fence) - FP_SEG(vga_state.vga_graphics_ram)); + if (im > 0xFFE) im = 0xFFE; + im <<= 4; + for (i=0;i < im;i++) vga_state.vga_graphics_ram[i] = 0; + } + else if ((ap=vga_state.vga_alpha_ram) != NULL) { + unsigned int i,im; + + im = (FP_SEG(vga_state.vga_alpha_ram_fence) - FP_SEG(vga_state.vga_alpha_ram)); + if (im > 0x7FE) im = 0x7FE; + im <<= 4 - 1; /* because ptr is type uint16_t */ + for (i=0;i < im;i++) vga_state.vga_alpha_ram[i] = 0x0720; + } + else { + printf("WARNING: bios cls no ptr\n"); + } +}