|
|
| version 1.7, 2004/08/12 13:32:52 | version 1.14, 2004/08/18 08:08:13 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #include "scrnmng.h" | #include "scrnmng.h" |
| #include "sysmng.h" | |
| #include "pccore.h" | #include "pccore.h" |
| #include "iocore.h" | #include "iocore.h" |
| #include "vram.h" | #include "vram.h" |
| Line 9 | Line 10 |
| #include "makesub.h" | #include "makesub.h" |
| MAKESCRN makescrn; | MAKESCRN makescrn; |
| BYTE scrnallflash; | UINT8 scrnallflash; |
| static BYTE lastdisp = 0; | UINT drawtime = 0; |
| static BYTE blinktime = 1; | |
| UINT drawtime = 0; | |
| static void fillupdatetmp(void) { | static void fillupdatetmp(void) { |
| Line 29 static void fillupdatetmp(void) { | Line 28 static void fillupdatetmp(void) { |
| } | } |
| } | } |
| #if 1 | |
| static void flashupdatetmp(void) { | static void flashupdatetmp(void) { |
| UINT posl; | UINT posl; |
| Line 45 static void flashupdatetmp(void) { | Line 43 static void flashupdatetmp(void) { |
| if (!makescrn.vramsize) { | if (!makescrn.vramsize) { |
| return; | return; |
| } | } |
| posl = crtc.s.TXT_TOP; | posl = crtc.e.pos; |
| y = crtc.s.TXT_YL; | y = crtc.e.yl; |
| do { | do { |
| for (x=0; x<crtc.s.TXT_XL; x++) { | for (x=0; x<crtc.s.reg[CRTCREG_HDISP]; x++) { |
| if (!(tram[TRAM_ATR + LOW11(posl + x)] & TRAMATR_Yx2)) { | if (!(tram[TRAM_ATR + LOW11(posl + x)] & TRAMATR_Yx2)) { |
| break; | break; |
| } | } |
| } | } |
| y2 = (x < crtc.s.TXT_XL)?FALSE:TRUE; | y2 = (x < crtc.s.reg[CRTCREG_HDISP])?FALSE:TRUE; |
| udtbase = (x < crtc.s.TXT_XL)?0x0000:0x0404; | udtbase = (x < crtc.s.reg[CRTCREG_HDISP])?0x0000:0x0404; |
| r = (crtc.s.TXT_XL + 1) >> 1; | r = (crtc.s.reg[CRTCREG_HDISP] + 1) >> 1; |
| do { | do { |
| posr = LOW11(posl + 1); | posr = LOW11(posl + 1); |
| atr = (tram[TRAM_ATR + posl] << 8) | tram[TRAM_ATR + posr]; | atr = (tram[TRAM_ATR + posl] << 8) | tram[TRAM_ATR + posr]; |
| Line 90 static void flashupdatetmp(void) { | Line 88 static void flashupdatetmp(void) { |
| } | } |
| posl = LOW11(posl + 2); | posl = LOW11(posl + 2); |
| } while(--r); | } while(--r); |
| if (crtc.s.TXT_XL & 1) { | if (crtc.s.reg[CRTCREG_HDISP] & 1) { |
| posl = LOW11(posl - 1); | posl = LOW11(posl - 1); |
| } | } |
| } while(--y); | } while(--y); |
| } | } |
| #else | |
| static LABEL void flashupdatetmp(void) { | |
| __asm { | |
| push ebx | |
| push esi | |
| push edi | |
| movzx esi, crtc.s.TXT_TOP | |
| xor dl, dl | |
| // まず行すべてが縦倍角か調べる | |
| check_tateflag: mov edi, esi | |
| movzx ecx, crtc.s.TXT_XL | |
| tateflaglp_s: and edi, (TRAM_MAX - 1) | |
| test tram[TRAM_ATR + edi], X1ATR_Yx2 | |
| je tatex1 | |
| inc edi | |
| loop tateflaglp_s | |
| // すべて縦倍角 だったら | |
| movzx ecx, crtc.s.TXT_XL | |
| shr cl, 1 | |
| tatex2loop_s: and esi, (TRAM_MAX - 1) | |
| mov ax, (UPDATE_TVRAM or 04h) * 0101h // 縦倍角 | |
| mov bx, word ptr (tram[TRAM_ATR + esi]) | |
| test bl, X1ATR_Xx2 | |
| je tatex2_norleft | |
| // 倍角フラグが立ってる | |
| or ax, 08h + 12h * 256 // 左4倍角 + 右縦倍角は確定 | |
| test bh, X1ATR_Xx2 | |
| je tatex2_pcg | |
| or ah, 8 // 右側も倍角ビットが立ってた | |
| jmp tatex2_pcg | |
| tatex2_norleft: test bh, X1ATR_Xx2 // 4倍角でない場合 | |
| je tatex2_pcg | |
| or ah, 8 // 右側のみ倍角だった | |
| tatex2_pcg: mov bx, word ptr (updatetmp[esi]) | |
| and bx, UPDATE_TVRAM * 0101h | |
| or ax, bx // UPDATEフラグを加える | |
| cmp word ptr (updatetmp[esi]), ax | |
| je tatex2noupdate | |
| or ax, UPDATE_TVRAM * 0101h | |
| mov word ptr (updatetmp[esi]), ax | |
| tatex2noupdate: add esi, 2 | |
| loop tatex2loop_s | |
| jmp nextlinecheck | |
| tatex1: movzx ecx, crtc.s.TXT_XL | |
| shr cl, 1 | |
| xor dh, dh | |
| tatex1loop_s: and esi, (TRAM_MAX - 1) | |
| xor ax, ax | |
| mov bx, word ptr (tram[TRAM_ATR + esi]) | |
| or dh, dh // 縦ノーマルは既にあったか? | |
| jne tatex1_tate_e | |
| test bl, X1ATR_Yx2 | |
| je tatex1_tate0 | |
| mov al, UPDATE_TVRAM or 1 // 左潰れ縦倍角 | |
| test bh, X1ATR_Yx2 | |
| je tatex1_tate0 | |
| mov ah, UPDATE_TVRAM or 1 // 右潰れ縦倍角 | |
| jmp tatex1_tate_e | |
| tatex1_tate0: inc dh // 縦ノーマルの出現 | |
| tatex1_tate_e: | |
| test bl, X1ATR_Xx2 | |
| je tatex1_norleft | |
| // 倍角フラグが立ってる | |
| or ax, 08h + (12h * 256) // 左横倍角 は確定 | |
| test bh, X1ATR_Xx2 | |
| je tatex1_pcg | |
| or ah, 8 // 右側も倍角ビットが立ってた | |
| jmp tatex1_pcg | |
| tatex1_norleft: test bh, X1ATR_Xx2 // 倍角でない場合 | |
| je tatex1_pcg | |
| or ah, 8 // 右側のみ倍角だった | |
| tatex1_pcg: mov bx, word ptr (updatetmp[esi]) | |
| and bx, UPDATE_TVRAM * 0101h | |
| or ax, bx | |
| cmp word ptr (updatetmp[esi]), ax | |
| je tatex1noupdate | |
| or ax, UPDATE_TVRAM * 0101h | |
| mov word ptr (updatetmp[esi]), ax | |
| tatex1noupdate: add esi, 2 | |
| loop tatex1loop_s | |
| nextlinecheck: inc dl | |
| cmp dl, crtc.s.TXT_YL | |
| jb check_tateflag | |
| pop edi | |
| pop esi | |
| pop ebx | |
| ret | |
| } | |
| } | |
| #endif | |
| static BRESULT updateblink(void) { | static BRESULT updateblink(void) { |
| Line 202 static BRESULT updateblink(void) { | Line 100 static BRESULT updateblink(void) { |
| REG8 update; | REG8 update; |
| UINT r; | UINT r; |
| if (blinktime) { | if (makescrn.blinktime) { |
| blinktime--; | makescrn.blinktime--; |
| return(FALSE); | return(FALSE); |
| } | } |
| else { | else { |
| blinktime = 30 - 1; | makescrn.blinktime = 30 - 1; |
| pos = makescrn.vramtop; | pos = makescrn.vramtop; |
| makescrn.blinktest ^= 0x10; | makescrn.blinktest ^= 0x10; |
| update = 0; | update = 0; |
| Line 233 static BRESULT updateblink(void) { | Line 131 static BRESULT updateblink(void) { |
| // ---- | // ---- |
| typedef void (*MAKEFN)(void); | |
| static void width_dummy(void) { } | |
| static const UINT8 screendraw[] = { | |
| MAKESCRN_320x200S, MAKESCRN_320x400, | |
| MAKESCRN_320x200S, MAKESCRN_320x400, | |
| MAKESCRN_320x200S, MAKESCRN_320x400, | |
| MAKESCRN_320x200S, MAKESCRN_320x200H, | |
| MAKESCRN_320x200S, MAKESCRN_320x400, | |
| MAKESCRN_320x200S, MAKESCRN_320x400, | |
| MAKESCRN_320x200S, MAKESCRN_320x200H, | |
| MAKESCRN_320x200S, MAKESCRN_320x200H, | |
| #if defined(SUPPORT_TURBOZ) | |
| MAKESCRN_320x200H, MAKESCRN_320x200H, | |
| MAKESCRN_320x200H, MAKESCRN_320x200H, | |
| MAKESCRN_320x200H, MAKESCRN_320x200H, | |
| MAKESCRN_320x200H, MAKESCRN_320x200H, | |
| MAKESCRN_320x200H, MAKESCRN_320x200H, | |
| MAKESCRN_320x200H, MAKESCRN_320x200H, | |
| MAKESCRN_320x200H, MAKESCRN_320x200H, | |
| MAKESCRN_320x200H, MAKESCRN_320x200H, | |
| #endif | |
| }; | |
| static const MAKEFN screenmake[] = { | |
| width80x25_200l, width80x25_400h, | |
| width80x25_200l, width80x25_200h, | |
| width80x12_200l, width80x12_400h, | |
| width80x12_200l, width80x12_200h, | |
| width80x20l, width80x20h, | |
| width80x20l, width80x20h, | |
| width80x10l, width80x10h, | |
| width80x10l, width80x10h, | |
| #if defined(SUPPORT_TURBOZ) | |
| width_dummy, width_dummy, | |
| width_dummy, width_dummy, | |
| width_dummy, width_dummy, | |
| width_dummy, width_dummy, | |
| width_dummy, width_dummy, | |
| width_dummy, width_dummy, | |
| width_dummy, width_dummy, | |
| width_dummy, width_dummy, | |
| #endif | |
| }; | |
| static void changemodes(void) { | static void changemodes(void) { |
| lastdisp = crtc.e.dispmode; | REG8 dispmode; |
| if (!(lastdisp & SCRN_BANK1)) { | |
| dispmode = crtc.e.dispmode; | |
| makescrn.dispmode = dispmode; | |
| makescrn.drawmode = screendraw[dispmode & DISPMODE_MASKMODE]; | |
| if (dispmode & DISPMODE_WIDTH80) { | |
| makescrn.drawmode |= 1; | |
| } | |
| sysmng_scrnwidth((dispmode & DISPMODE_WIDTH80) == 0); | |
| if (!(dispmode & DISPMODE_BANK1)) { | |
| makescrn.disp1 = gram + GRAM_BANK0; | makescrn.disp1 = gram + GRAM_BANK0; |
| makescrn.disp2 = gram + GRAM_BANK1; | makescrn.disp2 = gram + GRAM_BANK1; |
| makescrn.dispflag = UPDATE_TRAM | UPDATE_VRAM0; | makescrn.dispflag = UPDATE_TRAM + UPDATE_VRAM0; |
| } | } |
| else { | else { |
| makescrn.disp1 = gram + GRAM_BANK1; | makescrn.disp1 = gram + GRAM_BANK1; |
| makescrn.disp2 = gram + GRAM_BANK0; | makescrn.disp2 = gram + GRAM_BANK0; |
| makescrn.dispflag = UPDATE_TRAM | UPDATE_VRAM1; | makescrn.dispflag = UPDATE_TRAM + UPDATE_VRAM1; |
| } | } |
| scrnallflash = 1; | scrnallflash = 1; |
| makescrn.palandply = 1; | makescrn.palandply = 1; |
| Line 256 static void changecrtc(void) { | Line 216 static void changecrtc(void) { |
| UINT scrnymax; | UINT scrnymax; |
| UINT textxl; | UINT textxl; |
| UINT surfcx; | UINT surfcx; |
| REG8 widthmode; | |
| UINT fontcy; | UINT fontcy; |
| UINT underlines; | UINT underlines; |
| REG8 y2; | REG8 y2; |
| UINT charcy; | UINT charcy; |
| UINT surfcy; | UINT surfcy; |
| UINT surfsy; | |
| UINT x; | UINT x; |
| UINT y; | UINT y; |
| UINT8 *p; | UINT8 *p; |
| makescrn.vramtop = LOW11(crtc.s.TXT_TOP); | makescrn.vramtop = crtc.e.pos; |
| scrnxmax = (crtc.s.TXT_XL <= 40)?40:80; | scrnxmax = (makescrn.dispmode & DISPMODE_WIDTH80)?80:40; |
| scrnymax = 200; | scrnymax = 200; |
| if (crtc.s.TXT_XL <= 40) { | |
| if (lastdisp & SCRN_DRAW4096) { | |
| widthmode = SCRNWIDTHMODE_4096; | |
| } | |
| else { | |
| widthmode = SCRNWIDTHMODE_WIDTH40; | |
| } | |
| } | |
| else { | |
| widthmode = SCRNWIDTHMODE_WIDTH80; | |
| } | |
| scrndraw_changewidth(widthmode); | |
| textxl = crtc.s.TXT_XL; | textxl = crtc.s.reg[CRTCREG_HDISP]; |
| surfcx = min(scrnxmax, textxl); | surfcx = min(scrnxmax, textxl); |
| fontcy = crtc.e.fonty; | fontcy = crtc.e.fonty; |
| underlines = (crtc.s.SCRN_BITS & SCRN_UNDERLINE)?2:0; | underlines = (makescrn.dispmode & DISPMODE_UNDERLINE)?2:0; |
| if (fontcy > underlines) { | if (fontcy > underlines) { |
| fontcy -= underlines; | fontcy -= underlines; |
| } | } |
| else { | else { |
| fontcy = 0; | fontcy = 0; |
| } | } |
| y2 = (crtc.s.SCRN_BITS & SCRN_TEXTYx2)?1:0; | y2 = (makescrn.dispmode & DISPMODE_TEXTYx2)?1:0; |
| fontcy >>= y2; | fontcy >>= y2; |
| #if 0 | #if 0 |
| if (((dispmode & SCRN64_MASK) != SCRN64_INVALID) && (fontcy > 8)) { | if (((dispmode & SCRN64_MASK) != SCRN64_INVALID) && (fontcy > 8)) { |
| Line 312 static void changecrtc(void) { | Line 260 static void changecrtc(void) { |
| makescrn.charcy = charcy; | makescrn.charcy = charcy; |
| charcy <<= y2; | charcy <<= y2; |
| surfcy = scrnymax / charcy; | surfcy = scrnymax / charcy; |
| if (surfcy > crtc.s.TXT_YL) { | if (surfcy > crtc.e.yl) { |
| surfcy = crtc.s.TXT_YL; | surfcy = crtc.e.yl; |
| } | } |
| surfsy = charcy * surfcy * 2; | |
| x = min(scrnxmax, makescrn.surfcx); | x = min(scrnxmax, makescrn.surfcx); |
| if (surfcx < x) { // 小さくなった | if (surfcx < x) { // 小さくなった |
| x = (x - surfcx) * 8; | x = (x - surfcx) * 8; |
| p = screenmap + (surfcx * 8); | p = screenmap + (surfcx * 8); |
| y = surfcy * 2; | y = surfsy; |
| while(y) { | while(y) { |
| y--; | y--; |
| ZeroMemory(p, x); | ZeroMemory(p, x); |
| p += SURFACE_WIDTH; | p += SURFACE_WIDTH; |
| } | } |
| } | } |
| if (surfcy < makescrn.surfcy) { | if (surfsy < makescrn.surfsy) { |
| ZeroMemory(screenmap + (SURFACE_WIDTH * surfcy * 2), | ZeroMemory(screenmap + (SURFACE_WIDTH * surfsy), |
| SURFACE_WIDTH * (makescrn.surfcy - surfcy) * 2); | SURFACE_WIDTH * (makescrn.surfsy - surfsy)); |
| } | } |
| makescrn.surfcx = surfcx; | makescrn.surfcx = surfcx; |
| makescrn.surfrx = textxl - surfcx; | makescrn.surfrx = textxl - surfcx; |
| makescrn.surfcy = surfcy; | makescrn.surfcy = surfcy; |
| makescrn.surfsy = surfsy; | |
| makescrn.surfstep = (SURFACE_WIDTH * charcy * 2) - (surfcx * 8); | makescrn.surfstep = (SURFACE_WIDTH * charcy * 2) - (surfcx * 8); |
| makescrn.vramsize = min(0x800, surfcy * textxl); | makescrn.vramsize = min(0x800, surfcy * textxl); |
| // scrnmng_setheight(0, charcy * surfcy * 2); | // scrnmng_setheight(0, charcy * surfcy * 2); |
| } | } |
| // ------------------------------------------------------------------------- | |
| typedef void (*DRAWFN)(void); | |
| static const DRAWFN screendraw[8] = { | |
| width80x25_200l, width80x25_400h, | |
| width80x25_200l, width80x25_200h, | |
| width80x12_200l, width80x12_400h, | |
| width80x12_200l, width80x12_200h}; | |
| static const DRAWFN screendraw2[8] = { | |
| width80x20l, width80x20h, | |
| width80x20l, width80x20h, | |
| width80x10l, width80x10h, | |
| width80x10l, width80x10h}; | |
| void scrnupdate(void) { | void scrnupdate(void) { |
| BRESULT ddrawflash; | BRESULT ddrawflash; |
| Line 367 void scrnupdate(void) { | Line 299 void scrnupdate(void) { |
| } | } |
| corestat.drawframe = 0; | corestat.drawframe = 0; |
| ddrawflash = FALSE; | ddrawflash = makescrn.nextdraw; |
| allflash = FALSE; | allflash = FALSE; |
| if (lastdisp != crtc.e.dispmode) { | if (makescrn.dispmode != crtc.e.dispmode) { |
| changemodes(); | changemodes(); |
| } | } |
| if (scrnallflash) { | if (scrnallflash) { |
| scrnallflash = 0; | scrnallflash = 0; |
| fillupdatetmp(); | fillupdatetmp(); |
| changecrtc(); | changecrtc(); |
| ddrawflash = TRUE; | |
| allflash = TRUE; | allflash = TRUE; |
| makescrn.scrnflash = 1; | makescrn.scrnflash = 1; |
| } | } |
| Line 386 void scrnupdate(void) { | Line 319 void scrnupdate(void) { |
| if (makescrn.palandply) { | if (makescrn.palandply) { |
| makescrn.palandply = 0; | makescrn.palandply = 0; |
| pal_update(); | pal_update(); |
| ddrawflash = 1; | ddrawflash = TRUE; |
| } | } |
| if (makescrn.existblink) { | if (makescrn.existblink) { |
| makescrn.scrnflash |= updateblink(); | makescrn.scrnflash |= updateblink(); |
| Line 396 void scrnupdate(void) { | Line 329 void scrnupdate(void) { |
| makescrn.scrnflash = 0; | makescrn.scrnflash = 0; |
| if (makescrn.vramsize) { | if (makescrn.vramsize) { |
| makescrn.fontycnt = 0; | makescrn.fontycnt = 0; |
| screenmake[makescrn.dispmode & DISPMODE_MASKMODE](); | |
| #if 0 | |
| switch(lastdisp & SCRN64_MASK) { | switch(lastdisp & SCRN64_MASK) { |
| case SCRN64_320x200: | case SCRN64_320x200: |
| // width40x25_64s(); | // width40x25_64s(); |
| Line 440 void scrnupdate(void) { | Line 375 void scrnupdate(void) { |
| // case SCRN64_INVALID: | // case SCRN64_INVALID: |
| default: | default: |
| if (!(crtc.s.SCRN_BITS & SCRN_UNDERLINE)) { | if (!(crtc.s.SCRN_BITS & SCRN_UNDERLINE)) { |
| screendraw[crtc.s.SCRN_BITS & 7](); | screenmake[(crtc.s.SCRN_BITS & 7) + 0](); |
| } | } |
| else { | else { |
| screendraw2[crtc.s.SCRN_BITS & 7](); | screenmake[(crtc.s.SCRN_BITS & 7) + 8](); |
| } | } |
| break; | break; |
| } | } |
| ddrawflash = 1; | #endif |
| ddrawflash = TRUE; | |
| } | } |
| } | } |
| if (ddrawflash) { | if (ddrawflash) { |
| ddrawflash = 0; | makescrn.nextdraw = scrndraw_draw(allflash); |
| scrndraw_draw(allflash); | |
| drawtime++; | drawtime++; |
| } | } |
| } | } |
| Line 466 void makescrn_initialize(void) { | Line 401 void makescrn_initialize(void) { |
| void makescrn_reset(void) { | void makescrn_reset(void) { |
| fillupdatetmp(); | |
| changemodes(); | changemodes(); |
| changecrtc(); | changecrtc(); |
| flashupdatetmp(); | |
| } | } |