X-Git-Url: http://4ch.mooo.com/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fmodex16.c;h=5db7bf481849910a90551b4725f801c7600daa38;hb=d31b48962de4f4384cca54f92db59ccc0bb06fbc;hp=bada2e67972d951ea48fdacbe96bbda4b969b5b8;hpb=c1d3221afb5fe541d8c886ff66198329c153e48e;p=16.git diff --git a/src/lib/modex16.c b/src/lib/modex16.c index bada2e67..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,8 +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; - vga_state.vga_stride=0x58; - cm.offset=0x2c; + 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; @@ -130,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; @@ -876,8 +883,10 @@ byte modexgetPixel(page_t *page, int x, int y) 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; @@ -888,36 +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/*for mode X planar use*/, y/*redunant, remove*/, t, col, bgcol, addrq); - addrq += 2; /* move 8 pixels over (2 x 4 planar pixels per byte) */ - //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) */ } } @@ -1026,7 +1022,7 @@ void modexcls(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 @@ -1035,7 +1031,7 @@ modexWaitBorder() { while(!(inp(INPUT_STATUS_1) & 8)) { // spin } -}*/ +} void bios_cls() { VGA_ALPHA_PTR ap;