--- np2/bios/bios18.c 2004/03/04 15:20:13 1.30 +++ np2/bios/bios18.c 2007/11/11 12:46:06 1.44 @@ -8,27 +8,25 @@ #include "font.h" -static int sti_waiting = 0; - typedef struct { - BYTE GBON_PTN; - BYTE GBBCC; - BYTE GBDOTU; - BYTE GBDSP; - BYTE GBCPC[4]; - BYTE GBSX1[2]; - BYTE GBSY1[2]; - BYTE GBLNG1[2]; - BYTE GBWDPA[2]; - BYTE GBRBUF[2][3]; - BYTE GBSX2[2]; - BYTE GBSY2[2]; - BYTE GBMDOT[2]; - BYTE GBCIR[2]; - BYTE GBLNG2[2]; - BYTE GBMDOTI[8]; - BYTE GBDTYP; - BYTE GBFILL; + UINT8 GBON_PTN; + UINT8 GBBCC; + UINT8 GBDOTU; + UINT8 GBDSP; + UINT8 GBCPC[4]; + UINT8 GBSX1[2]; + UINT8 GBSY1[2]; + UINT8 GBLNG1[2]; + UINT8 GBWDPA[2]; + UINT8 GBRBUF[2][3]; + UINT8 GBSX2[2]; + UINT8 GBSY2[2]; + UINT8 GBMDOT[2]; + UINT8 GBCIR[2]; + UINT8 GBLNG2[2]; + UINT8 GBMDOTI[8]; + UINT8 GBDTYP; + UINT8 GBFILL; } UCWTBL; typedef struct { @@ -41,10 +39,10 @@ typedef struct { static const UINT8 modenum[4] = {3, 1, 0, 2}; static const CRTDATA crtdata[7] = { - {0x07, 0x00, 0x07, 0x08}, // 200-20 - {0x09, 0x1f, 0x08, 0x08}, // 200-25 - {0x0f, 0x00, 0x0f, 0x10}, // 400-20 - {0x13, 0x1e, 0x11, 0x10}, // 400-25 + {0x09, 0x1f, 0x08, 0x08}, // 200-20 + {0x07, 0x00, 0x07, 0x08}, // 200-25 + {0x13, 0x1e, 0x11, 0x10}, // 400-20 + {0x0f, 0x00, 0x0f, 0x10}, // 400-25 {0x17, 0x1c, 0x13, 0x10}, // 480-20 {0x12, 0x1f, 0x11, 0x10}, // 480-25 {0x0f, 0x00, 0x0f, 0x10}}; // 480-30 @@ -114,8 +112,8 @@ const CRTDATA *crt; gdc.mode1 |= 0x08; crt += 2; } - if (mode & 0x01) { - crt += 1; // 20行 + if (!(mode & 0x01)) { + crt += 1; // 25行 } if (mode & 0x02) { gdc.mode1 |= 0x04; // 40桁 @@ -135,9 +133,17 @@ const CRTDATA *crt; bios0x18_10(0); } +void bios0x18_0c(void) { + + if (!(gdcs.textdisp & GDCSCRN_ENABLE)) { + gdcs.textdisp |= GDCSCRN_ENABLE; + pcstat.screenupdate |= 2; + } +} + static void bios0x18_0f(UINT seg, UINT off, REG8 num, REG8 cnt) { - BYTE *p; + UINT8 *p; UINT raster; UINT t; @@ -167,17 +173,17 @@ static void bios0x18_0f(UINT seg, UINT o #endif while((cnt--) && (p < (gdc.m.para + GDC_SCROLL + 0x10))) { - t = i286_memword_read(seg, off); + t = MEMR_READ16(seg, off); t >>= 1; STOREINTELWORD(p, t); - t = i286_memword_read(seg, off + 2); + t = MEMR_READ16(seg, off + 2); t *= raster; STOREINTELWORD(p + 2, t); off += 4; p += 4; } gdcs.textdisp |= GDCSCRN_ALLDRAW2; - screenupdate |= 2; + pcstat.screenupdate |= 2; } void bios0x18_10(REG8 curdel) { @@ -201,34 +207,34 @@ void bios0x18_10(REG8 curdel) { REG16 bios0x18_14(REG16 seg, REG16 off, REG16 code) { UINT16 size; -const BYTE *p; - BYTE buf[32]; +const UINT8 *p; + UINT8 buf[32]; UINT i; switch(code >> 8) { case 0x00: // 8x8 size = 0x0101; - i286_memword_write(seg, off, 0x0101); + MEMR_WRITE16(seg, off, 0x0101); p = fontrom + 0x82000 + ((code & 0xff) << 4); - i286_memstr_write(seg, off + 2, p, 8); + MEMR_WRITES(seg, off + 2, p, 8); break; - case 0x28: // 8x16 KANJI - case 0x29: +// case 0x28: + case 0x29: // 8x16 KANJI case 0x2a: case 0x2b: size = 0x0102; - i286_memword_write(seg, off, 0x0102); + MEMR_WRITE16(seg, off, 0x0102); p = fontrom; p += (code & 0x7f) << 12; p += (((code >> 8) - 0x20) & 0x7f) << 4; - i286_memstr_write(seg, off + 2, p, 16); + MEMR_WRITES(seg, off + 2, p, 16); break; case 0x80: // 8x16 ANK size = 0x0102; p = fontrom + 0x80000 + ((code & 0xff) << 4); - i286_memstr_write(seg, off + 2, p, 16); + MEMR_WRITES(seg, off + 2, p, 16); break; default: @@ -240,21 +246,21 @@ const BYTE *p; buf[i*2+0] = *p; buf[i*2+1] = *(p+0x800); } - i286_memstr_write(seg, off + 2, buf, 32); + MEMR_WRITES(seg, off + 2, buf, 32); break; } - i286_memword_write(seg, off, size); + MEMR_WRITE16(seg, off, size); return(size); } static void bios0x18_1a(REG16 seg, REG16 off, REG16 code) { - BYTE *p; - BYTE buf[32]; + UINT8 *p; + UINT8 buf[32]; UINT i; if (((code >> 8) & 0x7e) == 0x76) { - i286_memstr_read(seg, off + 2, buf, 32); + MEMR_READS(seg, off + 2, buf, 32); p = fontrom; p += (code & 0x7f) << 12; p += (((code >> 8) - 0x20) & 0x7f) << 4; @@ -348,7 +354,7 @@ const CRTDATA *p; } CopyMemory(gdc.m.para + GDC_SYNC, gdcmastersync[master], 8); - ZeroMemory(gdc.m.para + GDC_SCROLL, 8); + ZeroMemory(gdc.m.para + GDC_SCROLL, 4); gdc.m.para[GDC_PITCH] = 80; p = crtdata + crt; @@ -363,11 +369,12 @@ const CRTDATA *p; crtc.reg.sdr = 0; CopyMemory(gdc.s.para + GDC_SYNC, gdcslavesync[slave], 8); - ZeroMemory(gdc.s.para + GDC_SCROLL, 8); + ZeroMemory(gdc.s.para + GDC_SCROLL, 4); if (slave & 1) { gdc.s.para[GDC_PITCH] = 80; gdc.clock |= 3; mem[MEMB_PRXDUPD] |= 0x04; + gdc.s.para[GDC_SCROLL+3] = 0x40; } else { gdc.s.para[GDC_PITCH] = 40; @@ -390,7 +397,7 @@ const CRTDATA *p; gdcs.textdisp &= ~GDCSCRN_ENABLE; gdcs.textdisp |= GDCSCRN_EXT | GDCSCRN_ALLDRAW2; gdcs.grphdisp |= GDCSCRN_EXT | GDCSCRN_ALLDRAW2; - screenupdate |= 2; + pcstat.screenupdate |= 2; mem[0x597] &= ~3; mem[0x597] |= (scrn >> 4) & 3; @@ -435,7 +442,7 @@ void bios0x18_40(void) { gdc_forceready(GDCWORK_SLAVE); if (!(gdcs.grphdisp & GDCSCRN_ENABLE)) { gdcs.grphdisp |= GDCSCRN_ENABLE; - screenupdate |= 2; + pcstat.screenupdate |= 2; } mem[MEMB_PRXCRT] |= 0x80; } @@ -445,7 +452,7 @@ void bios0x18_41(void) { gdc_forceready(GDCWORK_SLAVE); if (gdcs.grphdisp & GDCSCRN_ENABLE) { gdcs.grphdisp &= ~(GDCSCRN_ENABLE); - screenupdate |= 2; + pcstat.screenupdate |= 2; } mem[MEMB_PRXCRT] &= 0x7f; } @@ -468,11 +475,11 @@ void bios0x18_42(REG8 mode) { scrn = bios0x18_31bh(); if ((mem[MEMB_CRT_BIOS] & 0x80) && (((scrn & 0x30) == 0x30) || (crtmode == 3))) { - bios0x18_30(rate, (crtmode << 4) + 1); + bios0x18_30(rate, (REG8)((crtmode << 4) + 1)); } else { #endif - ZeroMemory(gdc.s.para + GDC_SCROLL, 8); + ZeroMemory(gdc.s.para + GDC_SCROLL, 4); if (crtmode == 2) { // ALL crtmode = 2; if ((mem[MEMB_PRXDUPD] & 0x24) == 0x20) { @@ -503,6 +510,9 @@ void bios0x18_42(REG8 mode) { gdc.s.para[GDC_SCROLL+1] = (200*40) >> 8; } } + if (mem[MEMB_PRXDUPD] & 4) { + gdc.s.para[GDC_SCROLL+3] = 0x40; + } if ((crtmode == 2) || (!(mem[MEMB_PRXCRT] & 0x40))) { gdc.mode1 &= ~(0x10); gdc.s.para[GDC_CSRFORM] = 0; @@ -520,20 +530,21 @@ void bios0x18_42(REG8 mode) { gdcs.disp = (mode >> 4) & 1; } if (!(mode & 0x20)) { - gdc.mode1 &= ~0x04; + gdc.mode2 &= ~0x04; } else { gdc.mode2 |= 0x04; } + gdcs.mode2 = gdc.mode2; gdcs.grphdisp |= GDCSCRN_ALLDRAW2; - screenupdate |= 2; + pcstat.screenupdate |= 2; } static void setbiosgdc(UINT32 csrw, const GDCVECT *vect, UINT8 ope) { - gdc.s.para[GDC_CSRW + 0] = (BYTE)csrw; - gdc.s.para[GDC_CSRW + 1] = (BYTE)(csrw >> 8); - gdc.s.para[GDC_CSRW + 2] = (BYTE)(csrw >> 16); + gdc.s.para[GDC_CSRW + 0] = (UINT8)csrw; + gdc.s.para[GDC_CSRW + 1] = (UINT8)(csrw >> 8); + gdc.s.para[GDC_CSRW + 2] = (UINT8)(csrw >> 16); gdc.s.para[GDC_VECTW] = vect->ope; gdc_vectreset(&gdc.s); @@ -561,7 +572,7 @@ static void bios0x18_47(void) { SINT16 dy; gdc_forceready(GDCWORK_SLAVE); - i286_memstr_read(CPU_DS, CPU_BX, &ucw, sizeof(ucw)); + MEMR_READS(CPU_DS, CPU_BX, &ucw, sizeof(ucw)); GBSX1 = LOADINTELWORD(ucw.GBSX1); GBSY1 = LOADINTELWORD(ucw.GBSY1); GBSX2 = LOADINTELWORD(ucw.GBSX2); @@ -620,7 +631,8 @@ static void bios0x18_47(void) { vect.ope = 0x20 + (ucw.GBDSP & 7); vect.DC[0] = ucw.GBLNG1[0]; vect.DC[1] = ucw.GBLNG1[1]; - data = LOADINTELWORD(ucw.GBLNG2) - 1; +// data = LOADINTELWORD(ucw.GBLNG2) - 1; + data = LOADINTELWORD(ucw.GBCIR) - 1; STOREINTELWORD(vect.D, data); data >>= 1; STOREINTELWORD(vect.D2, data); @@ -662,7 +674,7 @@ static void bios0x18_49(void) { UCWTBL ucw; UINT i; - BYTE pat[8]; + UINT8 pat[8]; UINT16 tmp; GDCVECT vect; UINT16 GBSX1; @@ -672,7 +684,7 @@ static void bios0x18_49(void) { gdc_forceready(GDCWORK_SLAVE); - i286_memstr_read(CPU_DS, CPU_BX, &ucw, sizeof(ucw)); + MEMR_READS(CPU_DS, CPU_BX, &ucw, sizeof(ucw)); for (i=0; i<8; i++) { mem[MEMW_PRXGLS + i] = ucw.GBMDOTI[i]; pat[i] = GDCPATREVERSE(ucw.GBMDOTI[i]); @@ -756,21 +768,10 @@ void bios0x18(void) { #if 0 TRACEOUT(("int18 AX=%.4x %.4x:%.4x", CPU_AX, - i286_memword_read(CPU_SS, CPU_SP+2), - i286_memword_read(CPU_SS, CPU_SP))); + MEMR_READ16(CPU_SS, CPU_SP+2), + MEMR_READ16(CPU_SS, CPU_SP))); #endif - sti_waiting ^= 1; - if (sti_waiting) { // 割込み許可の遊び - CPU_STI; - if (PICEXISTINTR) { - CPU_IP--; - nevent_forceexit(); - return; - } - } - sti_waiting = 0; - switch(CPU_AH) { case 0x00: // キー・データの読みだし if (mem[MEMB_KB_COUNT]) { @@ -803,7 +804,7 @@ void bios0x18(void) { break; case 0x04: // キー入力状態のセンス - CPU_AH = mem[0x00052a + (CPU_AL & 0x0f)]; + CPU_AH = mem[MEMX_KB_KY_STS + (CPU_AL & 0x0f)]; break; case 0x05: // キー入力センス @@ -825,16 +826,13 @@ void bios0x18(void) { break; case 0x0c: // テキスト画面の表示開始 - if (!(gdcs.textdisp & GDCSCRN_ENABLE)) { - gdcs.textdisp |= GDCSCRN_ENABLE; - screenupdate |= 2; - } + bios0x18_0c(); break; case 0x0d: // テキスト画面の表示終了 if (gdcs.textdisp & GDCSCRN_ENABLE) { gdcs.textdisp &= ~(GDCSCRN_ENABLE); - screenupdate |= 2; + pcstat.screenupdate |= 2; } break; @@ -851,7 +849,7 @@ void bios0x18(void) { SETBIOSMEM16(MEMW_CRT_W_RASTER, tmp.w); STOREINTELWORD(gdc.m.para + GDC_SCROLL + 2, tmp.w); gdcs.textdisp |= GDCSCRN_ALLDRAW2; -// screenupdate |= 2; +// pcstat.screenupdate |= 2; break; case 0x0f: // 複数の表示領域の設定 @@ -940,12 +938,10 @@ void bios0x18(void) { if (tmp.r8 == 0x05) { CPU_AL = 0; CPU_BH = 0; - TRACEOUT(("success")); } else { CPU_AL = 1; CPU_BH = 1; - TRACEOUT(("failure")); } } break; @@ -970,8 +966,7 @@ void bios0x18(void) { break; case 0x43: // パレットの設定 - i286_memstr_read(CPU_DS, CPU_BX + offsetof(UCWTBL, GBCPC), - tmp.col, 4); + MEMR_READS(CPU_DS, CPU_BX + offsetof(UCWTBL, GBCPC), tmp.col, 4); for (i=0; i<4; i++) { gdc_setdegitalpal(6 - (i*2), (REG8)(tmp.col[i] >> 4)); gdc_setdegitalpal(7 - (i*2), (REG8)(tmp.col[i] & 15)); @@ -980,7 +975,7 @@ void bios0x18(void) { case 0x44: // ボーダカラーの設定 // if (!(mem[MEMB_PRXCRT] & 0x40)) { -// color = i286_membyte_read(CPU_DS, CPU_BX + 1); +// color = MEMR_READ8(CPU_DS, CPU_BX + 1); // } break;