Diff for /np2/lio/gscreen.c between versions 1.5 and 1.8

version 1.5, 2004/02/20 08:32:23 version 1.8, 2004/02/21 04:48:35
Line 2 Line 2
 #include        "cpucore.h"  #include        "cpucore.h"
 #include        "pccore.h"  #include        "pccore.h"
 #include        "iocore.h"  #include        "iocore.h"
   #include        "bios.h"
 #include        "biosmem.h"  #include        "biosmem.h"
 #include        "lio.h"  #include        "lio.h"
   #include        "vram.h"
   
   
 static void lio_makescreen(void) {  
   
         UINT16  pos;  typedef struct {
           BYTE    mode;
         // GDCバッファを空に          BYTE    sw;
         if (gdc.s.cnt) {          BYTE    act;
                 gdc_work(GDCWORK_SLAVE);          BYTE    disp;
         }  } GSCREEN;
         gdc_forceready(&gdc.s);  
   typedef struct {
         ZeroMemory(&gdc.s.para[GDC_SCROLL], 8);          BYTE    x1[2];
         if (lio.scrn.lines == 200) {          BYTE    y1[2];
                 gdc.mode1 |= 0x10;          BYTE    x2[2];
                 gdc.s.para[GDC_CSRFORM] = 1;          BYTE    y2[2];
                 pos = lio.scrn.top >> 1;          BYTE    vdraw_bg;
                 STOREINTELWORD(gdc.s.para + GDC_SCROLL + 0, pos);          BYTE    vdraw_ln;
         }  } GVIEW;
         else {  
                 gdc.mode1 &= ~0x10;  typedef struct {
                 gdc.s.para[GDC_CSRFORM] = 0;          BYTE    dummy;
         }          BYTE    bgcolor;
         gdcs.grphdisp |= GDCSCRN_ALLDRAW2;          BYTE    bdcolor;
         gdcs.disp = lio.scrn.disp & 1;          BYTE    fgcolor;
         screenupdate |= 2;          BYTE    palmode;
         iocore_out8(0x00a6, lio.scrn.bank);  } GCOLOR1;
   
   typedef struct {
           BYTE    pal;
           BYTE    color1;
           BYTE    color2;
   } GCOLOR2;
   
   
   // ---- INIT
   
   REG8 lio_ginit(LIOWORK lio) {
   
           UINT    i;
   
           vramop.operate &= VOP_ACCESSMASK;
           i286_vram_dispatch(vramop.operate);
           bios0x18_42(0x80);
           bios0x18_40();
           iocore_out8(0x006a, 0);
           gdc_paletteinit();
   
           lio->mem.scrnmode = 0;
           lio->mem.pos = 0;
           lio->mem.plane = 1;
           lio->mem.bgcolor = 0;
           lio->mem.fgcolor = 7;
           for (i=0; i<8; i++) {
                   lio->mem.color[i] = (UINT8)i;
           }
           STOREINTELWORD(lio->mem.viewx1, 0);
           STOREINTELWORD(lio->mem.viewy1, 0);
           STOREINTELWORD(lio->mem.viewx2, 639);
           STOREINTELWORD(lio->mem.viewy2, 399);
           lio->palmode = 0;
           return(LIO_SUCCESS);
 }  }
   
 BYTE lio_gscreen(void) {  
   
         LIOGSCREEN      data;  // ---- SCREEN
         LIO_SCRN        scrn;  
         BOOL            screenmodechange = FALSE;  
         BYTE            bit;  
         int                     disp;  
   
         i286_memstr_read(CPU_DS, CPU_BX, &data, sizeof(data));  
         if (data.mode == 0xff) {  
                 data.mode = lio.gscreen.mode;  
         }  
         if (data.mode > 4) {  
                 goto gscreen_err5;  
         }  
         else if ((data.mode >= 2) && (!(mem[MEMB_PRXCRT] & 0x40))) {  
                 goto gscreen_err5;  
         }  
   
         if (data.mode != lio.gscreen.mode) {  REG8 lio_gscreen(LIOWORK lio) {
                 screenmodechange = TRUE;  
           GSCREEN dat;
           UINT    colorbit;
           UINT8   scrnmode;
           UINT8   mono;
           UINT8   act;
           UINT8   pos;
           UINT8   disp;
           UINT8   plane;
           UINT8   planemax;
           UINT8   mode;
   
           if (lio->palmode != 2) {
                   colorbit = 3;
         }          }
         if (data.sw == 0xff) {          else {
                 data.sw = lio.gscreen.mode;                  colorbit = 4;
         }          }
         if (data.act == 0xff) {          i286_memstr_read(CPU_DS, CPU_BX, &dat, sizeof(dat));
                 if (screenmodechange) {          scrnmode = dat.mode;
                         data.act = 0;          if (scrnmode == 0xff) {
                 }                  scrnmode = lio->mem.scrnmode;
                 else {          }
                         data.act = lio.gscreen.act;          else {
                   if ((dat.mode >= 2) && (!(mem[MEMB_PRXCRT] & 0x40))) {
                           goto gscreen_err5;
                 }                  }
         }          }
         if (data.disp == 0xff) {          if (scrnmode >= 4) {
                 if (screenmodechange) {                  goto gscreen_err5;
                         data.disp = 1;          }
           if (dat.sw != 0xff) {
                   if (!(dat.sw & 2)) {
                           bios0x18_40();
                 }                  }
                 else {                  else {
                         data.disp = lio.gscreen.disp;                          bios0x18_41();
                 }                  }
         }          }
   
         if (data.mode >= 0x04) {          mono = ((scrnmode + 1) >> 1) & 1;
                 return(5);          act = dat.act;
           if (act == 0xff) {
                   if (scrnmode != lio->mem.scrnmode) {
                           lio->mem.pos = 0;
                           lio->mem.access = 0;
                   }
         }          }
         if (data.sw >= 0x04) {          else {
                 return(5);                  switch(scrnmode) {
                           case 0:
                                   pos = act & 1;
                                   act >>= 1;
                                   break;
   
                           case 1:
                                   pos = act % (colorbit * 2);
                                   act = act / (colorbit * 2);
                                   break;
   
                           case 2:
                                   pos = act % colorbit;
                                   act = act / colorbit;
                                   break;
   
                           case 3:
                           default:
                                   pos = 0;
                                   break;
                   }
                   if (act >= 2) {
                           goto gscreen_err5;
                   }
                   lio->mem.pos = pos;
                   lio->mem.access = act;
         }          }
         if (lio.gcolor1.palmode != 2) {          disp = dat.disp;
                 bit = 3;          if (disp == 0xff) {
                   if (scrnmode != lio->mem.scrnmode) {
                           lio->mem.plane = 1;
                           lio->mem.disp = 0;
                   }
         }          }
         else {          else {
                 bit = 4;                  plane = disp & ((2 << colorbit) - 1);
                   disp >>= (colorbit + 1);
                   if (disp >= 2) {
                           goto gscreen_err5;
                   }
                   lio->mem.disp = disp;
                   planemax = 1;
                   if (mono) {
                           planemax <<= colorbit;
                   }
                   if (!(scrnmode & 2)) {
                           planemax <<= 1;
                   }
                   if ((plane > planemax) &&
                           (plane != (1 << colorbit))) {
                           goto gscreen_err5;
                   }
                   lio->mem.plane = plane;
                   lio->mem.disp = disp;
         }          }
         switch(data.mode) {  
           lio->mem.scrnmode = scrnmode;
           switch(scrnmode) {
                 case 0:                  case 0:
                         if (data.act >= 4) {                          mode = (pos)?0x40:0x80;
                                 return(5);  
                         }  
                         scrn.top = (data.act & 1) * 16000;  
                         scrn.lines = 200;  
                         scrn.bank = data.act >> 1;  
                         scrn.plane = 0x80;  
                         scrn.disp = (data.disp >> (bit + 1)) & 1;  
                         if (data.disp & ((1 << bit) - 1)) {  
                                 scrn.dbit = (1 << bit) - 1;  
                                 if ((data.disp & ((1 << (bit + 1)) - 1)) >= 3) {  
                                         return(5);  
                                 }  
                         }  
                         else {  
                                 scrn.dbit = 0;  
                         }  
                         break;                          break;
   
                 case 1:                  case 1:
                         disp = data.act / bit;                          mode = (pos >= colorbit)?0x60:0xa0;
                         if (disp >= 4) {  
                                 return(5);  
                         }  
                         scrn.top = (disp & 1) * 16000;  
                         scrn.lines = 200;  
                         scrn.bank = disp >> 1;  
                         scrn.plane = data.act % bit;  
                         scrn.disp = (data.disp >> (bit + 1)) & 1;  
                         scrn.dbit = data.disp & ((1 << bit) - 1);  
                         break;                          break;
   
                 case 2:                  case 2:
                         disp = data.act / bit;                          mode = 0xe0;
                         if (disp >= 2) {  
                                 return(5);  
                         }  
                         scrn.top = 0;  
                         scrn.lines = 400;  
                         scrn.bank = disp;  
                         scrn.plane = data.act % bit;  
                         scrn.disp = (data.disp >> (bit + 1)) & 1;  
                         scrn.dbit = data.disp & ((1 << bit) - 1);  
                         if ((scrn.dbit) && (data.disp & (1 << bit))) {  
                                 return(5);  
                         }  
                         break;                          break;
   
                 case 3:                  case 3:
                         if (data.act >= 2) {                  default:
                                 return(5);                          mode = 0xc0;
                           break;
           }
           mode |= disp << 4;
           TRACEOUT(("bios1842 - %.2x", mode));
           bios0x18_42(mode);
           iocore_out8(0x00a6, lio->mem.access);
           return(LIO_SUCCESS);
   
   gscreen_err5:
           TRACEOUT(("screen error! %d %d %d %d",
                                                                   dat.mode, dat.sw, dat.act, dat.disp));
           return(LIO_ILLEGALFUNC);
   }
   
   
   // ---- VIEW
   
   REG8 lio_gview(LIOWORK lio) {
   
           GVIEW   dat;
           int             x1;
           int             y1;
           int             x2;
           int             y2;
   
           i286_memstr_read(CPU_DS, CPU_BX, &dat, sizeof(dat));
           x1 = (SINT16)LOADINTELWORD(dat.x1);
           y1 = (SINT16)LOADINTELWORD(dat.y1);
           x2 = (SINT16)LOADINTELWORD(dat.x2);
           y2 = (SINT16)LOADINTELWORD(dat.y2);
           if ((x1 >= x2) || (y1 >= y2)) {
                   return(LIO_ILLEGALFUNC);
           }
           STOREINTELWORD(lio->mem.viewx1, (UINT16)x1);
           STOREINTELWORD(lio->mem.viewy1, (UINT16)y1);
           STOREINTELWORD(lio->mem.viewx2, (UINT16)x2);
           STOREINTELWORD(lio->mem.viewy2, (UINT16)y2);
           return(LIO_SUCCESS);
   }
   
   
   // ---- COLOR1
   
   REG8 lio_gcolor1(LIOWORK lio) {
   
           GCOLOR1 dat;
   
           i286_memstr_read(CPU_DS, CPU_BX, &dat, sizeof(dat));
           if (dat.bgcolor != 0xff) {
                   lio->mem.bgcolor = dat.bgcolor;
           }
           if (dat.fgcolor == 0xff) {
                   lio->mem.fgcolor = dat.fgcolor;
           }
           if (dat.palmode != 0xff) {
                   if (!(mem[MEMB_PRXCRT] & 1)) {                          // 8color lio
                           dat.palmode = 0;
                   }
                   else {
                           if (!(mem[MEMB_PRXCRT] & 4)) {                  // have e-plane?
                                   goto gcolor1_err5;
                         }                          }
                         scrn.top = 0;                          if (!dat.palmode) {
                         scrn.lines = 400;                                  iocore_out8(0x006a, 0);
                         scrn.bank = data.act;  
                         scrn.plane = 0x80;  
                         scrn.disp = (data.disp >> (bit + 1)) & 1;  
                         if (data.disp & ((1 << bit) - 1)) {  
                                 scrn.dbit = (1 << bit) - 1;  
                                 if ((data.disp & ((1 << (bit + 1)) - 1)) >= 2) {  
                                         return(5);  
                                 }  
                         }                          }
                         else {                          else {
                                 scrn.dbit = 0;                                  iocore_out8(0x006a, 1);
                         }                          }
                         break;                  }
                   lio->palmode = dat.palmode;
         }          }
         lio.scrn = scrn;  
         lio_makeviewmask();  
         lio_makescreen();  
         return(LIO_SUCCESS);          return(LIO_SUCCESS);
   
 gscreen_err5:  gcolor1_err5:
           return(LIO_ILLEGALFUNC);
   }
   
   
   // ---- COLOR2
   
   REG8 lio_gcolor2(LIOWORK lio) {
   
           GCOLOR2 dat;
   
           i286_memstr_read(CPU_DS, CPU_BX, &dat, sizeof(dat));
           if (dat.pal >= ((lio->palmode == 2)?16:8)) {
                   goto gcolor2_err5;
           }
           if (!lio->palmode) {
                   dat.color1 &= 7;
                   lio->mem.color[dat.pal] = dat.color1;
                   gdc_setdegitalpal(dat.pal, dat.color1);
           }
           else {
                   gdc_setanalogpal(dat.pal, offsetof(RGB32, p.b),
                                                                                                   (UINT8)(dat.color1 & 0x0f));
                   gdc_setanalogpal(dat.pal, offsetof(RGB32, p.r),
                                                                                                   (UINT8)(dat.color1 >> 4));
                   gdc_setanalogpal(dat.pal, offsetof(RGB32, p.g),
                                                                                                   (UINT8)(dat.color2 & 0x0f));
           }
           return(LIO_SUCCESS);
   
   gcolor2_err5:
         return(LIO_ILLEGALFUNC);          return(LIO_ILLEGALFUNC);
 }  }
   

Removed from v.1.5  
changed lines
  Added in v.1.8


RetroPC.NET-CVS <cvs@retropc.net>