X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fmodex16.c;h=5db7bf481849910a90551b4725f801c7600daa38;hb=d31b48962de4f4384cca54f92db59ccc0bb06fbc;hp=cb4c53123337f7fffa4e57b33c392c25571483d5;hpb=8e9c24c25f7496303be4d3e8e3c6aac38a652e99;p=16.git diff --git a/src/lib/modex16.c b/src/lib/modex16.c index cb4c5312..5db7bf48 100755 --- a/src/lib/modex16.c +++ b/src/lib/modex16.c @@ -62,11 +62,7 @@ void VGAmodeX(sword vq, boolean cmem, global_game_variables_t *gv) static void vgaSetMode(byte mode) { - union REGS regs; - - regs.h.ah = SET_MODE; - regs.h.al = mode; - int86(VIDEO_INT, ®s, ®s); + int10_setmode(mode); } //--------------------------------------------------- @@ -74,109 +70,81 @@ vgaSetMode(byte mode) // Use the bios to get the current video mode // -long +byte/*FIXME: why long? "long" is 32-bit datatype, VGA modes are 8-bit numbers. */ vgaGetMode() { - union REGS rg; - - rg.h.ah = 0x0f; - int86(VIDEO_INT, &rg, &rg); - - return rg.h.al; + return int10_getmode(); } /* -========================= Entry Points ==========================- */ void modexEnter(sword vq, boolean cmem, global_game_variables_t *gv) { word i; - dword far*ptr=(dword far*)VGA; /* used for faster screen clearing */ + struct vga_mode_params cm; int CRTParmCount; - /* common mode X initiation stuff~ */ - modexsetBaseXMode(gv->video.page); - vga_enable_256color_modex(); // VGA mode X + + vgaSetMode(VGA_256_COLOR_MODE); + vga_enable_256color_modex(); update_state_from_vga(); + vga_read_crtc_mode(&cm); switch(vq) { 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 - - /* send the CRTParms */ - /*for(i=0; ivideo.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.vertical_total = 525; + cm.horizontal_total=0x5f + 5; /* CRTC[0] -5 */ + cm.horizontal_display_end=0x4f + 1; /* CRTC[1] -1 */ + cm.horizontal_blank_start=0x50 + 1; /* CRTC[2] */ + cm.horizontal_blank_end=0x82 + 1; /* CRTC[3] bit 0-4 & CRTC[5] bit 7 */ + cm.horizontal_start_retrace=0x54;/* CRTC[4] */ + cm.horizontal_end_retrace=0x80; /* CRTC[5] bit 0-4 */ + //cm.horizontal_start_delay_after_total=0x3e; /* CRTC[3] bit 5-6 */ + //cm.horizontal_start_delay_after_retrace=0x41; /* CRTC[5] bit 5-6 */ + cm.vertical_total = 0x20D + 2; cm.vertical_start_retrace = 0x1EA; cm.vertical_end_retrace = 0x1EC; cm.vertical_display_end = 480; - cm.vertical_blank_start = 489; - cm.vertical_blank_end = 517; - - vga_write_crtc_mode(&cm,0); - } - break; - case 2: - CRTParmCount = sizeof(ModeX_160x120regs) / sizeof(ModeX_160x120regs[0]); - /* width and height */ - gv->video.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; isw; @@ -617,7 +554,8 @@ modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset) static word a[PAL_SIZE]; //palette array of change values! word z=0, aq=0, aa=0, pp=0; - modexWaitBorder(); + //modexWaitBorder(); + vga_wait_for_vsync(); if((*i)==0) { memset(a, -1, sizeof(a)); @@ -667,7 +605,8 @@ modexPalUpdate(bitmap_t *bmp, word *i, word qp, word aqoffset) //if(qp>0) printf("qp=%d\n", qp); //if(qp>0) printf(" (*i)=%d\n", (*i)/3); } - modexWaitBorder(); /* waits one retrace -- less flicker */ + //modexWaitBorder(); /* waits one retrace -- less flicker */ + vga_wait_for_vsync(); if((*i)>=PAL_SIZE/2 && w==0) { for(; (*i)=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; @@ -963,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) */ } } @@ -1071,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; @@ -1091,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 */ @@ -1103,10 +1025,37 @@ void cls(page_t *page, byte color, byte *Where) void modexWaitBorder() { while(inp(INPUT_STATUS_1) & 8) { - /* spin */ + // spin } while(!(inp(INPUT_STATUS_1) & 8)) { - /* spin */ + // 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"); + } +}