|
|
| version 1.2, 2003/10/21 11:22:05 | version 1.7, 2004/02/20 16:20:41 |
|---|---|
| Line 1 | Line 1 |
| #include "compiler.h" | #include "compiler.h" |
| #include "i286.h" | #include "cpucore.h" |
| #include "memory.h" | |
| #include "pccore.h" | #include "pccore.h" |
| #include "iocore.h" | #include "iocore.h" |
| #include "bios.h" | #include "bios.h" |
| Line 9 | Line 8 |
| #include "lio.h" | #include "lio.h" |
| LIO_TABLE lio; | static _LIOWORK liowork; |
| void lio_init(void) { | void lio_initialize(void) { |
| UINT i; | UINT i; |
| mem[0xf9900] = 0x11; | mem[0xf9900] = 0x11; |
| for (i=0; i<0x11; i++) { | for (i=0; i<0x11; i++) { |
| mem[0xf9904 + i*4] = 0xa0 + i; | mem[0xf9904 + i*4] = 0xa0 + i; |
| SETBIOSMEM16(0xf9906 + i*4, 0x100 + i*2); | mem[0xf9905 + i*4] = 0x00; |
| SETBIOSMEM16(0xf9a00 + i*2, 0xcf90); | SETBIOSMEM16(0xf9906 + i*4, 0x100 + i*4); |
| SETBIOSMEM32(0xf9a00 + i*4, 0xcf90fb90); | |
| } | } |
| mem[0xf9944] = 0xce; | mem[0xf9944] = 0xce; |
| ZeroMemory(&lio, sizeof(lio)); | |
| } | } |
| void bios_lio(BYTE cmd) { | void bios_lio(REG8 cmd) { |
| UINT i; | LIOWORK lio; |
| // TRACE_("lio", cmd); | TRACEOUT(("lio command %.2x", cmd)); |
| lio = &liowork; | |
| lio->wait = 500; | |
| switch(cmd) { | switch(cmd) { |
| case 0x00: // a0: GINIT | case 0x00: // a0: GINIT |
| // GDCバッファを空に | CPU_AH = lio_ginit(lio); |
| if (gdc.s.cnt) { | |
| gdc_work(GDCWORK_SLAVE); | |
| } | |
| gdc_forceready(&gdc.s); | |
| ZeroMemory(&gdc.s.para[GDC_SCROLL], 8); | |
| gdc.mode1 |= 0x10; | |
| gdc.s.para[GDC_CSRFORM] = 1; | |
| screenupdate |= 2; | |
| gdcs.access = gdcs.disp = 0; | |
| vramop.operate &= VOP_ACCESSMASK; | |
| i286_vram_dispatch(vramop.operate); | |
| iocore_out8(0x006a, 0); | |
| gdcs.grphdisp |= GDCSCRN_ENABLE; | |
| gdc_paletteinit(); | |
| lio.scrn.top = 0; | |
| lio.scrn.lines = 200; | |
| lio.scrn.bank = 0; | |
| lio.scrn.plane = 0x80; | |
| lio.gcolor1.palmax = 8; | |
| lio.gcolor1.bgcolor = 0; | |
| lio.gcolor1.bdcolor = 0; | |
| lio.gcolor1.fgcolor = 7; | |
| lio.gcolor1.palmode = 0; | |
| lio.gview.x1 = 0; | |
| lio.gview.y1 = 0; | |
| lio.gview.x2 = 639; | |
| lio.gview.y2 = 399; | |
| lio_makeviewmask(); | |
| for (i=0; i<8; i++) { | |
| lio.degcol[i] = i; | |
| } | |
| I286_AH = 0; | |
| break; | break; |
| case 0x01: // a1: GSCREEN | case 0x01: // a1: GSCREEN |
| I286_AH = lio_gscreen(); | CPU_AH = lio_gscreen(lio); |
| break; | break; |
| case 0x02: // a2: GVIEW | case 0x02: // a2: GVIEW |
| I286_AH = lio_gview(); | CPU_AH = lio_gview(lio); |
| break; | break; |
| case 0x03: // a3: GCOLOR1 | case 0x03: // a3: GCOLOR1 |
| I286_AH = lio_gcolor1(); | CPU_AH = lio_gcolor1(lio); |
| break; | break; |
| case 0x04: // a4: GCOLOR2 | case 0x04: // a4: GCOLOR2 |
| I286_AH = lio_gcolor2(); | CPU_AH = lio_gcolor2(lio); |
| break; | break; |
| case 0x05: // a5: GCLS | case 0x05: // a5: GCLS |
| I286_AH = lio_gcls(); | CPU_AH = lio_gcls(lio); |
| break; | break; |
| case 0x06: // a6: GPSET | case 0x06: // a6: GPSET |
| I286_AH = lio_gpset(); | CPU_AH = lio_gpset(lio); |
| break; | break; |
| case 0x07: // a7: GLINE | case 0x07: // a7: GLINE |
| I286_AH = lio_gline(); | CPU_AH = lio_gline(lio); |
| break; | break; |
| case 0x08: // a8: GCIRCLE | case 0x08: // a8: GCIRCLE |
| Line 115 void bios_lio(BYTE cmd) { | Line 79 void bios_lio(BYTE cmd) { |
| break; | break; |
| case 0x0c: // ac: GPUT1 | case 0x0c: // ac: GPUT1 |
| I286_AH = lio_gput1(); | CPU_AH = lio_gput1(lio); |
| break; | break; |
| case 0x0d: // ad: GPUT2 | case 0x0d: // ad: GPUT2 |
| CPU_AH = lio_gput2(lio); | |
| break; | break; |
| case 0x0e: // ae: GROLL | case 0x0e: // ae: GROLL |
| Line 130 void bios_lio(BYTE cmd) { | Line 95 void bios_lio(BYTE cmd) { |
| case 0x10: // ce: GCOPY | case 0x10: // ce: GCOPY |
| break; | break; |
| } | } |
| // TRACEOUT(("lio cmd-%d, %d", cmd, I286_AH)); | gdcsub_setslavewait(lio->wait); |
| TRACEOUT(("lio wait = %d", lio->wait)); | |
| } | |
| // ---- | |
| const UINT32 lioplaneadrs[4] = {VRAM_B, VRAM_R, VRAM_G, VRAM_E}; | |
| void lio_updaterange(LIOWORK lio) { | |
| lio->range.x1 = max(lio->gview.x1, 0); | |
| lio->range.y1 = max(lio->gview.y1, 0); | |
| lio->range.x2 = min(lio->gview.x2, 639); | |
| lio->range.y2 = min(lio->gview.x2, (lio->scrn.lines - 1)); | |
| } | } |
| // ---- | // ---- |
| static const UINT32 planeadrs[4] = {0xa8000, 0xb0000, 0xb8000, 0xe0000}; | |
| static const BYTE bit_l[8] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01}; | static const BYTE bit_l[8] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01}; |
| static const BYTE bit_r[8] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe}; | static const BYTE bit_r[8] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe}; |
| static void pixed8(UINT32 vadrs, BYTE bit, BYTE pal) { | static void pixed8(const _LIOWORK *lio, UINT32 vadrs, BYTE bit, REG8 pal) { |
| if (lio.scrn.plane & 0x80) { | if (lio->scrn.plane & 0x80) { |
| if (pal & 1) { | if (pal & 1) { |
| mem[vadrs+0xa8000] |= bit; | mem[vadrs + VRAM_B] |= bit; |
| } | } |
| else { | else { |
| mem[vadrs+0xa8000] &= ~bit; | mem[vadrs + VRAM_B] &= ~bit; |
| } | } |
| if (pal & 2) { | if (pal & 2) { |
| mem[vadrs+0xb0000] |= bit; | mem[vadrs + VRAM_R] |= bit; |
| } | } |
| else { | else { |
| mem[vadrs+0xb0000] &= ~bit; | mem[vadrs + VRAM_R] &= ~bit; |
| } | } |
| if (pal & 4) { | if (pal & 4) { |
| mem[vadrs+0xb8000] |= bit; | mem[vadrs + VRAM_G] |= bit; |
| } | } |
| else { | else { |
| mem[vadrs+0xb8000] &= ~bit; | mem[vadrs + VRAM_G] &= ~bit; |
| } | } |
| if (pal & 8) { | if (pal & 8) { |
| mem[vadrs+0xe0000] |= bit; | mem[vadrs + VRAM_E] |= bit; |
| } | } |
| else { | else { |
| mem[vadrs+0xe0000] &= ~bit; | mem[vadrs + VRAM_E] &= ~bit; |
| } | } |
| } | } |
| else { | else { |
| vadrs += planeadrs[lio.scrn.plane & 3]; | vadrs += lioplaneadrs[lio->scrn.plane & 3]; |
| if (pal) { | if (pal) { |
| mem[vadrs] |= bit; | mem[vadrs] |= bit; |
| } | } |
| Line 179 static void pixed8(UINT32 vadrs, BYTE bi | Line 157 static void pixed8(UINT32 vadrs, BYTE bi |
| } | } |
| } | } |
| void lio_pset(SINT16 x, SINT16 y, BYTE pal) { | void lio_pset(const _LIOWORK *lio, SINT16 x, SINT16 y, REG8 pal) { |
| UINT32 adrs; | UINT32 adrs; |
| BYTE bit; | BYTE bit; |
| if ((lio.x1 > x) || (lio.x2 < x) || (lio.y1 > y) || (lio.y2 < y)) { | if ((lio->range.x1 > x) || (lio->range.x2 < x) || |
| (lio->range.y1 > y) || (lio->range.y2 < y)) { | |
| return; | return; |
| } | } |
| adrs = (y * 80) + (x >> 3); | adrs = (y * 80) + (x >> 3); |
| bit = 0x80 >> (x & 7); | bit = 0x80 >> (x & 7); |
| if (lio.scrn.top) { | if (lio->scrn.top) { |
| adrs += 16000; | adrs += 16000; |
| } | } |
| if (!lio.scrn.bank) { | if (!lio->scrn.bank) { |
| vramupdate[adrs] |= 1; | vramupdate[adrs] |= 1; |
| gdcs.grphdisp |= 1; | gdcs.grphdisp |= 1; |
| } | } |
| else { | else { |
| vramupdate[adrs] |= 2; | vramupdate[adrs] |= 2; |
| gdcs.grphdisp |= 2; | gdcs.grphdisp |= 2; |
| adrs += 0x200000; | adrs += VRAM_STEP; |
| } | } |
| pixed8(adrs, bit, pal); | pixed8(lio, adrs, bit, pal); |
| } | } |
| void lio_line(SINT16 x1, SINT16 x2, SINT16 y, BYTE pal) { | void lio_line(const _LIOWORK *lio, SINT16 x1, SINT16 x2, SINT16 y, REG8 pal) { |
| UINT adrs; | UINT adrs; |
| UINT32 vadrs; | UINT32 vadrs; |
| BYTE bit, dbit, sbit; | BYTE bit, dbit, sbit; |
| SINT16 width; | SINT16 width; |
| if ((lio.y1 > y) || (lio.y2 < y)) { | if ((lio->range.y1 > y) || (lio->range.y2 < y)) { |
| return; | return; |
| } | } |
| if (lio.x1 > x1) { | if (lio->range.x1 > x1) { |
| x1 = lio.x1; | x1 = lio->range.x1; |
| } | } |
| if (lio.x2 < x2) { | if (lio->range.x2 < x2) { |
| x2 = lio.x2; | x2 = lio->range.x2; |
| } | } |
| width = x2 - x1 + 1; | width = x2 - x1 + 1; |
| if (width <= 0) { | if (width <= 0) { |
| Line 226 void lio_line(SINT16 x1, SINT16 x2, SINT | Line 205 void lio_line(SINT16 x1, SINT16 x2, SINT |
| } | } |
| adrs = (y * 80) + (x1 >> 3); | adrs = (y * 80) + (x1 >> 3); |
| bit = 0x80 >> (x1 & 7); | bit = 0x80 >> (x1 & 7); |
| if (lio.scrn.top) { | if (lio->scrn.top) { |
| adrs += 16000; | adrs += 16000; |
| } | } |
| if (!lio.scrn.bank) { | if (!lio->scrn.bank) { |
| vadrs = adrs; | vadrs = adrs; |
| sbit = 1; | sbit = 1; |
| gdcs.grphdisp |= 1; | gdcs.grphdisp |= 1; |
| } | } |
| else { | else { |
| vadrs = adrs + 0x200000; | vadrs = adrs + VRAM_STEP; |
| sbit = 2; | sbit = 2; |
| gdcs.grphdisp |= 2; | gdcs.grphdisp |= 2; |
| } | } |
| Line 245 void lio_line(SINT16 x1, SINT16 x2, SINT | Line 224 void lio_line(SINT16 x1, SINT16 x2, SINT |
| dbit |= bit; | dbit |= bit; |
| bit >>= 1; | bit >>= 1; |
| } | } |
| pixed8(vadrs++, dbit, pal); | pixed8(lio, vadrs++, dbit, pal); |
| vramupdate[adrs++] |= sbit; | vramupdate[adrs++] |= sbit; |
| while(width >= 8) { | while(width >= 8) { |
| width -= 8; | width -= 8; |
| pixed8(vadrs++, 0xff, pal); | pixed8(lio, vadrs++, 0xff, pal); |
| vramupdate[adrs++] |= sbit; | vramupdate[adrs++] |= sbit; |
| } | } |
| dbit = 0; | dbit = 0; |
| Line 259 void lio_line(SINT16 x1, SINT16 x2, SINT | Line 238 void lio_line(SINT16 x1, SINT16 x2, SINT |
| bit >>= 1; | bit >>= 1; |
| } | } |
| if (dbit) { | if (dbit) { |
| pixed8(vadrs, dbit, pal); | pixed8(lio, vadrs, dbit, pal); |
| vramupdate[adrs] |= sbit; | vramupdate[adrs] |= sbit; |
| } | } |
| } | } |