Diff for /xmil/io/crtc.c between versions 1.13 and 1.17

version 1.13, 2004/08/14 12:16:17 version 1.17, 2004/08/17 14:46:37
Line 3 Line 3
 #include        "z80core.h"  #include        "z80core.h"
 #include        "pccore.h"  #include        "pccore.h"
 #include        "iocore.h"  #include        "iocore.h"
   #include        "nevent.h"
 #include        "vram.h"  #include        "vram.h"
 #include        "palettes.h"  #include        "palettes.h"
 #include        "makescrn.h"  #include        "makescrn.h"
   
   
   static const UINT8 defrgbp[4] = {0xaa, 0xcc, 0xf0, 0x00};
   static const UINT8 defreg[18] = {
                                   0x37, 0x28, 0x2d, 0x34,
                                   0x1f, 0x02, 0x19, 0x1c,
                                   0x00, 0x07, 0x00, 0x00,
                                   0x00, 0x00, 0x00, 0x00,
                                   0x00, 0x00};
   
   #if defined(SUPPORT_TURBOZ)
 static const UINT8 defpaltext[8] = {  static const UINT8 defpaltext[8] = {
                                 0x00, 0x03, 0x0c, 0x0f, 0x30, 0x33, 0x3c, 0x3f};                                  0x00, 0x03, 0x0c, 0x0f, 0x30, 0x33, 0x3c, 0x3f};
   
Line 20  static const UINT16 defpalgrph[64] = { Line 30  static const UINT16 defpalgrph[64] = {
                                 0x505, 0x50f, 0x5a5, 0x5af, 0xf05, 0xf0f, 0xfa5, 0xfaf,                                  0x505, 0x50f, 0x5a5, 0x5af, 0xf05, 0xf0f, 0xfa5, 0xfaf,
                                 0x550, 0x55a, 0x5f0, 0x5fa, 0xf50, 0xf5a, 0xff0, 0xffa,                                  0x550, 0x55a, 0x5f0, 0x5fa, 0xf50, 0xf5a, 0xff0, 0xffa,
                                 0x555, 0x55f, 0x5f5, 0x5ff, 0xf55, 0xf5f, 0xff5, 0xfff};                                  0x555, 0x55f, 0x5f5, 0x5ff, 0xf55, 0xf5f, 0xff5, 0xfff};
   #endif
   
 static const UINT8 defrgbp[4] = {0xaa, 0xcc, 0xf0, 0x00};  
 static const UINT8 defreg[18] = {  
                                 0x37, 0x28, 0x2d, 0x34,  
                                 0x1f, 0x02, 0x19, 0x1c,  
                                 0x00, 0x07, 0x00, 0x00,  
                                 0x00, 0x00, 0x00, 0x00,  
                                 0x00, 0x00};  
   
 typedef struct {  typedef struct {
         UINT32  clock;          UINT32  clock;
Line 92  static void crtc_timingupdate(void) { Line 96  static void crtc_timingupdate(void) {
         UINT32  fontclock;          UINT32  fontclock;
         UINT    yl;          UINT    yl;
   
           // とりあえず…ね
           crtc.e.rasterdisp8 = (crtc.e.rasterclock8 * 40) / 56;
   
         fontclock = (crtc.s.reg[CRTCREG_CHRCY] & 0x1f) + 1;          fontclock = (crtc.s.reg[CRTCREG_CHRCY] & 0x1f) + 1;
         fontclock = (fontclock * crtc.e.rasterclock8) >> 8;          fontclock = (fontclock * crtc.e.rasterclock8) >> 8;
   
Line 109  static void crtc_timingupdate(void) { Line 116  static void crtc_timingupdate(void) {
   
 static void crtc_bankupdate(void) {  static void crtc_bankupdate(void) {
   
   #if defined(SUPPORT_TURBOZ)
         UINT    updatemask;          UINT    updatemask;
         UINT8   dispmode;          UINT8   dispmode;
         UINT8   pal_bank;          UINT8   pal_bank;
         UINT8   pal_disp;          UINT8   pal_disp;
   #endif
   
         if (crtc.s.SCRN_BITS & 0x10) {          if (crtc.s.SCRN_BITS & 0x10) {
                 crtc.e.gram = gram + GRAM_BANK1;                  crtc.e.gram = gram + GRAM_BANK1;
Line 122  static void crtc_bankupdate(void) { Line 131  static void crtc_bankupdate(void) {
                 crtc.e.gram = gram + GRAM_BANK0;                  crtc.e.gram = gram + GRAM_BANK0;
                 crtc.e.updatebit = UPDATE_VRAM0;                  crtc.e.updatebit = UPDATE_VRAM0;
         }          }
         dispmode = (crtc.s.SCRN_BITS & SCRN_DISPVRAM)?SCRN_BANK1:SCRN_BANK0;  
         pal_bank = pal_disp = PAL_NORMAL;  
   
   #if !defined(SUPPORT_TURBOZ)
           crtc.e.updatemask = (crtc.s.SCRN_BITS & SCRN_TEXTYx2)?0x3ff:0x7ff;
           crtc.e.dispmode =
                                           (crtc.s.SCRN_BITS & SCRN_DISPVRAM)?SCRN_BANK1:SCRN_BANK0;
   #else
           dispmode = (crtc.s.SCRN_BITS & SCRN_DISPVRAM)?SCRN_BANK1:SCRN_BANK0;
           pal_bank = PAL_NORMAL;
           pal_disp = PAL_NORMAL;
         if ((!(crtc.s.EXTPALMODE & 0x80)) || (crtc.s.SCRN_BITS & SCRN_UNDERLINE)) {          if ((!(crtc.s.EXTPALMODE & 0x80)) || (crtc.s.SCRN_BITS & SCRN_UNDERLINE)) {
                 updatemask = 0x7ff;                  updatemask = 0x7ff;
                 if ((crtc.s.SCRN_BITS & SCRN_24KHZ) && (!crtc.s.width40)) {                  if ((crtc.s.SCRN_BITS & SCRN_24KHZ) && (!crtc.s.width40)) {
                         pal_bank = pal_disp = PAL_HIGHRESO;                          pal_bank = PAL_HIGHRESO;
                           pal_disp = PAL_HIGHRESO;
                 }                  }
                 if (crtc.s.SCRN_BITS & SCRN_TEXTYx2) {                  if (crtc.s.SCRN_BITS & SCRN_TEXTYx2) {
                         updatemask = 0x3ff;                          updatemask = 0x3ff;
Line 229  static void crtc_bankupdate(void) { Line 245  static void crtc_bankupdate(void) {
         crtc.e.dispmode = dispmode;          crtc.e.dispmode = dispmode;
         crtc.e.pal_bank = pal_bank;          crtc.e.pal_bank = pal_bank;
         crtc.e.pal_disp = pal_disp;          crtc.e.pal_disp = pal_disp;
   #endif
 }  }
   
   
   
 // ---- CRTC  // ---- CRTC
   
 void IOOUTCALL crtc_o(UINT port, REG8 value) {  void IOOUTCALL crtc_o(UINT port, REG8 value) {
Line 289  void IOOUTCALL ply_o(UINT port, REG8 val Line 305  void IOOUTCALL ply_o(UINT port, REG8 val
         if (crtc.s.rgbp[CRTC_PLY] != value) {          if (crtc.s.rgbp[CRTC_PLY] != value) {
                 crtc.s.rgbp[CRTC_PLY] = value;                  crtc.s.rgbp[CRTC_PLY] = value;
                 makescrn.palandply = 1;                  makescrn.palandply = 1;
   #if defined(SUPPORT_PALEVENT)
                   if ((!corestat.vsync) && (palevent.events < SUPPORT_PALEVENT)) {
                           PAL1EVENT *e = palevent.event + palevent.events;
                           palevent.events++;
                           e->rgbp = CRTC_PLY;
                           e->value = value;
                           e->clock = nevent_getwork(NEVENT_FRAMES);
                   }
   #endif
         }          }
         (void)port;          (void)port;
 }  }
   
 REG8 IOINPCALL ply_i(UINT port) {  
   
         (void)port;  
         return(crtc.s.rgbp[CRTC_PLY]);  
 }  
   
   
 // ---- パレット  // ---- パレット
   
 void IOOUTCALL palette_o(UINT port, REG8 value) {  void IOOUTCALL palette_o(UINT port, REG8 value) {
   
         REG8    sft;  
         UINT    num;          UINT    num;
   #if defined(SUPPORT_TURBOZ)
           REG8    sft;
         UINT    pal;          UINT    pal;
   #endif
   
   #if defined(SUPPORT_TURBOZ)
         crtc.s.lastpal = (value & 0xf0);          crtc.s.lastpal = (value & 0xf0);
         if (crtc.s.EXTPALMODE & 0x80) {          if (!(crtc.s.EXTPALMODE & 0x80)) {
   #endif
                   num = (port >> 8) & 3;
                   if (crtc.s.rgbp[num] != value) {
                           crtc.s.rgbp[num] = value;
                           makescrn.palandply = 1;
   #if defined(SUPPORT_PALEVENT)
                           if ((!corestat.vsync) && (palevent.events < SUPPORT_PALEVENT)) {
                                   PAL1EVENT *e = palevent.event + palevent.events;
                                   palevent.events++;
                                   e->rgbp = (UINT8)num;
                                   e->value = value;
                                   e->clock = nevent_getwork(NEVENT_FRAMES);
                           }
   #endif
                   }
   #if defined(SUPPORT_TURBOZ)
           }
           else {
                 if ((crtc.s.EXTGRPHPAL & 0x88) != 0x80) {                  if ((crtc.s.EXTGRPHPAL & 0x88) != 0x80) {
                         return;                          return;
                 }                  }
Line 345  void IOOUTCALL palette_o(UINT port, REG8 Line 385  void IOOUTCALL palette_o(UINT port, REG8
                         pal_setgrph(crtc.e.pal_bank, (REG8)num);                          pal_setgrph(crtc.e.pal_bank, (REG8)num);
                 }                  }
         }          }
         else {  #endif
                 num = (port >> 8) & 3;  }
                 if (crtc.s.rgbp[num] != value) {  
                         crtc.s.rgbp[num] = value;  void IOOUTCALL blackctrl_o(UINT port, REG8 value) {
                         makescrn.palandply = 1;  
           if (crtc.s.rgbp[CRTC_BLACK] != value) {
                   crtc.s.rgbp[CRTC_BLACK] = value;
                   makescrn.palandply = 1;
   #if defined(SUPPORT_PALEVENT)
                   if ((!corestat.vsync) && (palevent.events < SUPPORT_PALEVENT)) {
                           PAL1EVENT *e = palevent.event + palevent.events;
                           palevent.events++;
                           e->rgbp = CRTC_BLACK;
                           e->value = value;
                           e->clock = nevent_getwork(NEVENT_FRAMES);
                 }                  }
   #endif
         }          }
           (void)port;
   }
   
   REG8 IOINPCALL blackctrl_i(UINT port) {
   
           (void)port;
           return(crtc.s.rgbp[CRTC_BLACK]);
   }
   
   
   // ---- turboZ
   
   #if defined(SUPPORT_TURBOZ)
   REG8 IOINPCALL ply_i(UINT port) {
   
           (void)port;
           return(crtc.s.rgbp[CRTC_PLY]);
 }  }
   
 REG8 IOINPCALL palette_i(UINT port) {  REG8 IOINPCALL palette_i(UINT port) {
Line 392  REG8 IOINPCALL palette_i(UINT port) { Line 460  REG8 IOINPCALL palette_i(UINT port) {
 }  }
   
   
 // ---- turboZ  
   
 void IOOUTCALL extpal_o(UINT port, REG8 value) {  void IOOUTCALL extpal_o(UINT port, REG8 value) {
   
         crtc.s.EXTPALMODE = value;          crtc.s.EXTPALMODE = value;
Line 455  REG8 IOINPCALL exttextdisp_i(UINT port)  Line 521  REG8 IOINPCALL exttextdisp_i(UINT port) 
         (void)port;          (void)port;
         return(0xff);          return(0xff);
 }  }
   #endif
 void IOOUTCALL blackctrl_o(UINT port, REG8 value) {  
   
         crtc.s.BLACKPAL = value;  
         makescrn.palandply = 1;  
         (void)port;  
 }  
   
 REG8 IOINPCALL blackctrl_i(UINT port) {  
   
         (void)port;  
         return(crtc.s.BLACKPAL);  
 }  
   
   
 // ----  // ----
Line 490  void crtc_setwidth(REG8 width40) { Line 544  void crtc_setwidth(REG8 width40) {
   
 // ----  // ----
   
   #if defined(SUPPORT_TURBOZ)
 static void resetpal(void) {  static void resetpal(void) {
   
         CopyMemory(crtc.p.text, defpaltext, sizeof(defpaltext));          CopyMemory(crtc.p.text, defpaltext, sizeof(defpaltext));
         CopyMemory(crtc.p.grph[0], defpalgrph, sizeof(defpalgrph));          CopyMemory(crtc.p.grph[0], defpalgrph, sizeof(defpalgrph));
         CopyMemory(crtc.p.grph[1], defpalgrph, sizeof(defpalgrph));          CopyMemory(crtc.p.grph[1], defpalgrph, sizeof(defpalgrph));
 }  }
   #endif
   
   #if defined(SUPPORT_TURBOZ)
 void crtc_initialize(void) {  void crtc_initialize(void) {
   
         UINT    p;          UINT    p;
Line 506  void crtc_initialize(void) { Line 563  void crtc_initialize(void) {
                 crtc.p.grph4096[p] = p;                  crtc.p.grph4096[p] = p;
         }          }
 }  }
   #endif
   
 void crtc_reset(void) {  void crtc_reset(void) {
   
Line 513  void crtc_reset(void) { Line 571  void crtc_reset(void) {
         CopyMemory(crtc.s.rgbp, defrgbp, 4);          CopyMemory(crtc.s.rgbp, defrgbp, 4);
         CopyMemory(crtc.s.reg, defreg, 18);          CopyMemory(crtc.s.reg, defreg, 18);
         crtc.s.width40 = 1;          crtc.s.width40 = 1;
   #if defined(SUPPORT_TURBOZ)
         if (pccore.ROM_TYPE < 3) {          if (pccore.ROM_TYPE < 3) {
                 resetpal();                  resetpal();
         }          }
   #endif
 //      IPLが勝手に切り替える筈である  //      IPLが勝手に切り替える筈である
 //      if ((pccore.ROM_TYPE >= 2) && (!(pccore.DIP_SW & 1))) {  //      if ((pccore.ROM_TYPE >= 2) && (!(pccore.DIP_SW & 1))) {
 //              crtc.s.SCRN_BITS = SCRN_200LINE;  //              crtc.s.SCRN_BITS = SCRN_200LINE;

Removed from v.1.13  
changed lines
  Added in v.1.17


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