|
|
| version 1.6, 2004/02/20 15:20:30 | version 1.21, 2005/05/20 13:59:47 |
|---|---|
| Line 2 | Line 2 |
| #include "cpucore.h" | #include "cpucore.h" |
| #include "pccore.h" | #include "pccore.h" |
| #include "iocore.h" | #include "iocore.h" |
| #include "gdc_sub.h" | |
| #include "bios.h" | #include "bios.h" |
| #include "biosmem.h" | #include "biosmem.h" |
| #include "vram.h" | #include "vram.h" |
| #include "lio.h" | #include "lio.h" |
| #include "lio.res" | |
| static _LIOWORK liowork; | |
| void lio_initialize(void) { | void lio_initialize(void) { |
| UINT i; | CopyMemory(mem + (LIO_SEGMENT << 4), liorom, sizeof(liorom)); |
| mem[0xf9900] = 0x11; | |
| for (i=0; i<0x11; i++) { | |
| mem[0xf9904 + i*4] = 0xa0 + i; | |
| SETBIOSMEM16(0xf9906 + i*4, 0x100 + i*2); | |
| SETBIOSMEM16(0xf9a00 + i*2, 0xcf90); | |
| } | |
| mem[0xf9944] = 0xce; | |
| } | } |
| void bios_lio(REG8 cmd) { | void bios_lio(REG8 cmd) { |
| LIOWORK lio; | _GLIO lio; |
| UINT8 ret; | |
| TRACEOUT(("lio command %.2x", cmd)); | |
| lio = &liowork; | // TRACEOUT(("lio command %.2x", cmd)); |
| MEMR_READS(CPU_DS, 0x0620, &lio.work, sizeof(lio.work)); | |
| lio.palmode = MEMR_READ8(CPU_DS, 0x0a08); | |
| lio.wait = 0; | |
| switch(cmd) { | switch(cmd) { |
| case 0x00: // a0: GINIT | case 0x00: // a0: GINIT |
| CPU_AH = lio_ginit(lio); | ret = lio_ginit(&lio); |
| break; | break; |
| case 0x01: // a1: GSCREEN | case 0x01: // a1: GSCREEN |
| CPU_AH = lio_gscreen(lio); | ret = lio_gscreen(&lio); |
| break; | break; |
| case 0x02: // a2: GVIEW | case 0x02: // a2: GVIEW |
| CPU_AH = lio_gview(lio); | ret = lio_gview(&lio); |
| break; | break; |
| case 0x03: // a3: GCOLOR1 | case 0x03: // a3: GCOLOR1 |
| CPU_AH = lio_gcolor1(lio); | ret = lio_gcolor1(&lio); |
| break; | break; |
| case 0x04: // a4: GCOLOR2 | case 0x04: // a4: GCOLOR2 |
| CPU_AH = lio_gcolor2(lio); | ret = lio_gcolor2(&lio); |
| break; | break; |
| case 0x05: // a5: GCLS | case 0x05: // a5: GCLS |
| CPU_AH = lio_gcls(lio); | ret = lio_gcls(&lio); |
| break; | break; |
| case 0x06: // a6: GPSET | case 0x06: // a6: GPSET |
| CPU_AH = lio_gpset(lio); | ret = lio_gpset(&lio); |
| break; | break; |
| case 0x07: // a7: GLINE | case 0x07: // a7: GLINE |
| CPU_AH = lio_gline(lio); | ret = lio_gline(&lio); |
| break; | break; |
| case 0x08: // a8: GCIRCLE | case 0x08: // a8: GCIRCLE |
| ret = lio_gcircle(&lio); | |
| break; | break; |
| case 0x09: // a9: GPAINT1 | // case 0x09: // a9: GPAINT1 |
| break; | // break; |
| case 0x0a: // aa: GPAINT2 | // case 0x0a: // aa: GPAINT2 |
| break; | // break; |
| case 0x0b: // ab: GGET | case 0x0b: // ab: GGET |
| ret = lio_gget(&lio); | |
| break; | break; |
| case 0x0c: // ac: GPUT1 | case 0x0c: // ac: GPUT1 |
| CPU_AH = lio_gput1(lio); | ret = lio_gput1(&lio); |
| break; | break; |
| case 0x0d: // ad: GPUT2 | case 0x0d: // ad: GPUT2 |
| CPU_AH = lio_gput2(lio); | ret = lio_gput2(&lio); |
| break; | break; |
| case 0x0e: // ae: GROLL | // case 0x0e: // ae: GROLL |
| break; | // break; |
| case 0x0f: // af: GPOINT2 | case 0x0f: // af: GPOINT2 |
| ret = lio_gpoint2(&lio); | |
| break; | break; |
| case 0x10: // ce: GCOPY | // case 0x10: // ce: GCOPY |
| // break; | |
| default: | |
| ret = LIO_SUCCESS; | |
| break; | break; |
| } | } |
| // TRACEOUT(("lio cmd-%d, %d", cmd, CPU_AH)); | CPU_AH = ret; |
| if (lio.wait) { | |
| gdcsub_setslavewait(lio.wait); | |
| } | |
| } | } |
| Line 101 void bios_lio(REG8 cmd) { | Line 104 void bios_lio(REG8 cmd) { |
| const UINT32 lioplaneadrs[4] = {VRAM_B, VRAM_R, VRAM_G, VRAM_E}; | const UINT32 lioplaneadrs[4] = {VRAM_B, VRAM_R, VRAM_G, VRAM_E}; |
| void lio_updaterange(LIOWORK lio) { | void lio_updatedraw(GLIO lio) { |
| lio->range.x1 = max(lio->gview.x1, 0); | UINT8 flag; |
| lio->range.y1 = max(lio->gview.y1, 0); | UINT8 colorbit; |
| lio->range.x2 = min(lio->gview.x2, 639); | SINT16 maxline; |
| lio->range.y2 = min(lio->gview.x2, (lio->scrn.lines - 1)); | SINT16 tmp; |
| flag = 0; | |
| colorbit = 3; | |
| maxline = 399; | |
| if (lio->palmode == 2) { | |
| flag |= LIODRAW_4BPP; | |
| colorbit = 4; | |
| } | |
| switch(lio->work.scrnmode) { | |
| case 0: | |
| if (lio->work.pos & 1) { | |
| flag |= LIODRAW_UPPER; | |
| } | |
| maxline = 199; | |
| break; | |
| case 1: | |
| flag |= lio->work.pos % colorbit; | |
| flag |= LIODRAW_MONO; | |
| if (lio->work.pos >= colorbit) { | |
| flag |= LIODRAW_UPPER; | |
| } | |
| maxline = 199; | |
| break; | |
| case 2: | |
| flag |= lio->work.pos % colorbit; | |
| flag |= LIODRAW_MONO; | |
| break; | |
| } | |
| lio->draw.flag = flag; | |
| lio->draw.palmax = 1 << colorbit; | |
| tmp = (SINT16)LOADINTELWORD(lio->work.viewx1); | |
| lio->draw.x1 = max(tmp, 0); | |
| tmp = (SINT16)LOADINTELWORD(lio->work.viewy1); | |
| lio->draw.y1 = max(tmp, 0); | |
| tmp = (SINT16)LOADINTELWORD(lio->work.viewx2); | |
| lio->draw.x2 = min(tmp, 639); | |
| tmp = (SINT16)LOADINTELWORD(lio->work.viewy2); | |
| lio->draw.y2 = min(tmp, maxline); | |
| if (!gdcs.access) { | |
| lio->draw.base = 0; | |
| lio->draw.bank = 0; | |
| lio->draw.sbit = 0x01; | |
| } | |
| else { | |
| lio->draw.base = VRAM_STEP; | |
| lio->draw.bank = 1; | |
| lio->draw.sbit = 0x02; | |
| } | |
| } | } |
| // ---- | // ---- |
| static const BYTE bit_l[8] = {0xff, 0x7f, 0x3f, 0x1f, 0x0f, 0x07, 0x03, 0x01}; | static void pixed8(const _GLIO *lio, UINT addr, REG8 bit, REG8 pal) { |
| static const BYTE bit_r[8] = {0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe}; | |
| static void pixed8(const _LIOWORK *lio, UINT32 vadrs, BYTE bit, REG8 pal) { | UINT8 *ptr; |
| if (lio->scrn.plane & 0x80) { | addr = LOW15(addr); |
| vramupdate[addr] |= lio->draw.sbit; | |
| ptr = mem + lio->draw.base + addr; | |
| if (!(lio->draw.flag & LIODRAW_MONO)) { | |
| if (pal & 1) { | if (pal & 1) { |
| mem[vadrs + VRAM_B] |= bit; | ptr[VRAM_B] |= bit; |
| } | } |
| else { | else { |
| mem[vadrs + VRAM_B] &= ~bit; | ptr[VRAM_B] &= ~bit; |
| } | } |
| if (pal & 2) { | if (pal & 2) { |
| mem[vadrs + VRAM_R] |= bit; | ptr[VRAM_R] |= bit; |
| } | } |
| else { | else { |
| mem[vadrs + VRAM_R] &= ~bit; | ptr[VRAM_R] &= ~bit; |
| } | } |
| if (pal & 4) { | if (pal & 4) { |
| mem[vadrs + VRAM_G] |= bit; | ptr[VRAM_G] |= bit; |
| } | } |
| else { | else { |
| mem[vadrs + VRAM_G] &= ~bit; | ptr[VRAM_G] &= ~bit; |
| } | |
| if (pal & 8) { | |
| mem[vadrs + VRAM_E] |= bit; | |
| } | } |
| else { | if (lio->draw.flag & LIODRAW_4BPP) { |
| mem[vadrs + VRAM_E] &= ~bit; | if (pal & 8) { |
| ptr[VRAM_E] |= bit; | |
| } | |
| else { | |
| ptr[VRAM_E] &= ~bit; | |
| } | |
| } | } |
| } | } |
| else { | else { |
| vadrs += lioplaneadrs[lio->scrn.plane & 3]; | ptr += lioplaneadrs[lio->draw.flag & LIODRAW_PMASK]; |
| if (pal) { | if (pal) { |
| mem[vadrs] |= bit; | *ptr |= bit; |
| } | } |
| else { | else { |
| mem[vadrs] &= ~bit; | *ptr &= ~bit; |
| } | } |
| } | } |
| } | } |
| void lio_pset(const _LIOWORK *lio, SINT16 x, SINT16 y, REG8 pal) { | void lio_pset(const _GLIO *lio, SINT16 x, SINT16 y, REG8 pal) { |
| UINT32 adrs; | UINT addr; |
| BYTE bit; | UINT8 bit; |
| if ((lio->range.x1 > x) || (lio->range.x2 < x) || | if ((lio->draw.x1 > x) || (lio->draw.x2 < x) || |
| (lio->range.y1 > y) || (lio->range.y2 < y)) { | (lio->draw.y1 > y) || (lio->draw.y2 < y)) { |
| return; | return; |
| } | } |
| adrs = (y * 80) + (x >> 3); | addr = (y * 80) + (x >> 3); |
| bit = 0x80 >> (x & 7); | bit = 0x80 >> (x & 7); |
| if (lio->scrn.top) { | if (lio->draw.flag & LIODRAW_UPPER) { |
| adrs += 16000; | addr += 16000; |
| } | |
| if (!lio->scrn.bank) { | |
| vramupdate[adrs] |= 1; | |
| gdcs.grphdisp |= 1; | |
| } | } |
| else { | gdcs.grphdisp |= lio->draw.sbit; |
| vramupdate[adrs] |= 2; | pixed8(lio, addr, bit, pal); |
| gdcs.grphdisp |= 2; | |
| adrs += VRAM_STEP; | |
| } | |
| pixed8(lio, adrs, bit, pal); | |
| } | } |
| void lio_line(const _LIOWORK *lio, SINT16 x1, SINT16 x2, SINT16 y, REG8 pal) { | #if 0 |
| void lio_line(const _GLIO *lio, SINT16 x1, SINT16 x2, SINT16 y, REG8 pal) { | |
| UINT adrs; | UINT addr; |
| UINT32 vadrs; | UINT8 bit, dbit; |
| BYTE bit, dbit, sbit; | |
| SINT16 width; | SINT16 width; |
| if ((lio->range.y1 > y) || (lio->range.y2 < y)) { | if ((lio->draw.y1 > y) || (lio->draw.y2 < y)) { |
| return; | return; |
| } | } |
| if (lio->range.x1 > x1) { | if (lio->draw.x1 > x1) { |
| x1 = lio->range.x1; | x1 = lio->draw.x1; |
| } | } |
| if (lio->range.x2 < x2) { | if (lio->draw.x2 < x2) { |
| x2 = lio->range.x2; | x2 = lio->draw.x2; |
| } | } |
| width = x2 - x1 + 1; | width = x2 - x1 + 1; |
| if (width <= 0) { | if (width <= 0) { |
| return; | return; |
| } | } |
| adrs = (y * 80) + (x1 >> 3); | addr = (y * 80) + (x1 >> 3); |
| bit = 0x80 >> (x1 & 7); | bit = 0x80 >> (x1 & 7); |
| if (lio->scrn.top) { | if (lio->draw.flag & LIODRAW_UPPER) { |
| adrs += 16000; | addr += 16000; |
| } | |
| if (!lio->scrn.bank) { | |
| vadrs = adrs; | |
| sbit = 1; | |
| gdcs.grphdisp |= 1; | |
| } | } |
| else { | gdcs.grphdisp |= lio->draw.sbit; |
| vadrs = adrs + VRAM_STEP; | |
| sbit = 2; | |
| gdcs.grphdisp |= 2; | |
| } | |
| dbit = 0; | dbit = 0; |
| while(bit && width--) { | while((bit) && (width)) { |
| dbit |= bit; | dbit |= bit; |
| bit >>= 1; | bit >>= 1; |
| width--; | |
| } | } |
| pixed8(lio, vadrs++, dbit, pal); | pixed8(lio, addr, dbit, pal); |
| vramupdate[adrs++] |= sbit; | addr++; |
| while(width >= 8) { | while(width >= 8) { |
| width -= 8; | width -= 8; |
| pixed8(lio, vadrs++, 0xff, pal); | pixed8(lio, addr, 0xff, pal); |
| vramupdate[adrs++] |= sbit; | addr++; |
| } | } |
| dbit = 0; | dbit = 0; |
| bit = 0x80; | bit = 0x80; |
| while(bit && width--) { | while((bit) && (width)) { |
| dbit |= bit; | dbit |= bit; |
| bit >>= 1; | bit >>= 1; |
| width--; | |
| } | } |
| if (dbit) { | if (dbit) { |
| pixed8(lio, vadrs, dbit, pal); | pixed8(lio, addr, dbit, pal); |
| vramupdate[adrs] |= sbit; | |
| } | } |
| } | } |
| #endif | |