Previous 199869 Revisions Next

r19987 Tuesday 1st January, 2013 at 15:10:46 UTC by Nathan Woods
[COCO3] GIME cleanups; identify memory banks on device start (nw)
[src/mess/video]gime.c gime.h

trunk/src/mess/video/gime.c
r19986r19987
119119
120120void gime_base_device::device_start(void)
121121{
122   /* get the config */
122   // get the config
123123   const gime_interface *config = (const gime_interface *) static_config();
124124   assert(config);
125125
126   /* find the RAM device - make sure that it is started */
126   // find the RAM device - make sure that it is started
127127   m_ram = machine().device<ram_device>(config->m_ram_tag);
128128   if (!m_ram->started())
129129      throw device_missing_dependencies();
130130
131   /* find the CART device - make sure that it is started */
131   // find the CART device - make sure that it is started
132132   m_cart_device = machine().device<cococart_slot_device>(config->m_ext_tag);
133133   if (!m_cart_device->started())
134134      throw device_missing_dependencies();
135135
136   /* find the CPU device - make sure that it is started */
136   // find the CPU device - make sure that it is started
137137   m_cpu = machine().device<cpu_device>(config->m_maincpu_tag);
138138   if (!m_cpu->started())
139139      throw device_missing_dependencies();
140140
141   /* inherited device_start - need to do this after checking dependencies */
141   // inherited device_start - need to do this after checking dependencies
142142   super::device_start();
143143
144   /* initialize variables */
144   // initialize variables
145145   memset(m_scanlines, 0, sizeof(m_scanlines));
146146   m_interrupt_value = 0x00;
147147   m_irq = 0x00;
148148   m_firq = 0x00;
149149
150   /* allocate timer */
150   // allocate timer
151151   m_gime_clock_timer = timer_alloc(TIMER_GIME_CLOCK);
152152
153   /* resolve callbacks */
153   // setup banks
154   assert(ARRAY_LENGTH(m_read_banks) == ARRAY_LENGTH(m_write_banks));
155   for (int i = 0; i < ARRAY_LENGTH(m_read_banks); i++)
156   {
157      char buffer[8];
158      snprintf(buffer, ARRAY_LENGTH(buffer), "rbank%d", i);
159      m_read_banks[i] = machine().root_device().membank(buffer);
160      snprintf(buffer, ARRAY_LENGTH(buffer), "wbank%d", i);
161      m_write_banks[i] = machine().root_device().membank(buffer);
162   }
163
164   // resolve callbacks
154165   m_res_out_hsync_func.resolve(config->m_out_hsync_func, *this);
155166   m_res_out_fsync_func.resolve(config->m_out_fsync_func, *this);
156167   m_res_out_irq_func.resolve(config->m_out_irq_func, *this);
157168   m_res_out_firq_func.resolve(config->m_out_firq_func, *this);
158169   m_res_in_floating_bus_func.resolve(config->m_in_floating_bus_func, *this);
159170
160   /* set up ROM/RAM pointers */
171   // set up ROM/RAM pointers
161172   m_rom = machine().root_device().memregion(config->m_maincpu_tag)->base();
162173   m_cart_rom = m_cart_device->get_cart_base();
163174
164   /* populate palettes */
175   // populate palettes
165176   for (int color = 0; color < 64; color++)
166177   {
167178      m_composite_palette[color] = get_composite_color(color);
r19986r19987
169180      m_rgb_palette[color] = get_rgb_color(color);
170181   }
171182
172   /* set up save states */
183   // set up save states
173184   save_pointer(NAME(m_gime_registers), ARRAY_LENGTH(m_gime_registers));
174185   save_pointer(NAME(m_mmu), ARRAY_LENGTH(m_mmu));
175186   save_item(NAME(m_sam_state));
r19986r19987
523534
524535void gime_base_device::update_memory(int bank)
525536{
526   static const char *rbanks[] = { "rbank0", "rbank1", "rbank2", "rbank3", "rbank4", "rbank5", "rbank6", "rbank7", "rbank8" };
527   static const char *wbanks[] = { "wbank0", "wbank1", "wbank2", "wbank3", "wbank4", "wbank5", "wbank6", "wbank7", "wbank8" };
537   // choose bank
538   assert((bank >= 0) && (bank < ARRAY_LENGTH(m_read_banks)) && (bank < ARRAY_LENGTH(m_write_banks)));
539   memory_bank *read_bank = m_read_banks[bank];
540   memory_bank *write_bank = m_write_banks[bank];
528541
529   /* look up the bank tags */
530   assert((bank >= 0) && (bank < ARRAY_LENGTH(rbanks)) && (bank < ARRAY_LENGTH(wbanks)));
531   const char *rbank = rbanks[bank];
532   const char *wbank = wbanks[bank];
533
534   /* bank 8 is really $FE00-$FEFF; it is weird so adjust for it */
542   // bank 8 is really $FE00-$FEFF; it is weird so adjust for it
535543   offs_t offset;
536544   bool force_ram;
537545   bool enable_mmu = (m_gime_registers[0] & 0x40) ? true : false;
r19986r19987
548556      force_ram = false;
549557   }
550558
551   /* is the MMU enabled at $FF90? */
559   // is the MMU enabled at $FF90?
552560   int block;
553561   if (enable_mmu)
554562   {
555      /* check TR register at $FF91 */
563      // check TR register at $FF91
556564      bank += (m_gime_registers[1] & 0x01) ? 8 : 0;
557565
558      /* perform the MMU lookup */
566      // perform the MMU lookup
559567      block = m_mmu[bank];
560568
561      /* also check $FF9B - relevant for the 2-8 MB upgrade */
569      // also check $FF9B - relevant for the 2-8 MB upgrade
562570      block |= ((UINT32) ((m_gime_registers[11] >> 4) & 0x03)) << 8;
563571   }
564572   else
565573   {
566      /* the MMU is not enabled */
574      // the MMU is not enabled
567575      block = bank + 56;
568576   }
569577
570   /* are we actually in ROM? */
578   // are we actually in ROM?
571579   UINT8 *memory;
572580   bool is_read_only;
573581   if (((block & 0x3F) >= 0x3C) && !(m_sam_state & SAM_STATE_TY) && !force_ram)
574582   {
575      /* we're in ROM */
583      // we're in ROM
576584      static const UINT8 rom_map[4][4] =
577585      {
578586         { 0, 1, 6, 7 },
r19986r19987
581589         { 4, 5, 6, 7 }
582590      };
583591
584      /* look up the block in the ROM map */
592      // look up the block in the ROM map
585593      block = rom_map[m_gime_registers[0] & 3][(block & 0x3F) - 0x3C];
586594
587      /* are we in onboard ROM or cart ROM? */
595      // are we in onboard ROM or cart ROM?
588596      UINT8 *rom_ptr = (block & 4) ? m_cart_rom : m_rom;
589      /* TODO: make this unmapped */
597      // TODO: make this unmapped
590598      if (rom_ptr==NULL) rom_ptr = m_rom;
591      /* perform the look up */
599      // perform the look up
592600      memory = &rom_ptr[(block & 3) * 0x2000];
593601      is_read_only = true;
594602   }
595603   else
596604   {
597      /* we're in RAM */
605      // we're in RAM
598606      memory = memory_pointer(block * 0x2000);
599607      is_read_only = false;
600608   }
601609
602   /* compensate for offset */
610   // compensate for offset
603611   memory += offset;
604612
605   /* set the banks */
606   machine().root_device().membank(rbank)->set_base(memory);
607   machine().root_device().membank(wbank)->set_base(is_read_only ? m_dummy_bank : memory);
613   // set the banks
614   read_bank->set_base(memory);
615   write_bank->set_base(is_read_only ? m_dummy_bank : memory);
608616}
609617
610618
trunk/src/mess/video/gime.h
r19986r19987
155155   static const UINT8 hires_font[128][12];
156156
157157   // callbacks
158   devcb_resolved_write_line m_res_out_irq_func;
159   devcb_resolved_write_line m_res_out_firq_func;
160   devcb_resolved_read8 m_res_in_floating_bus_func;
158   devcb_resolved_write_line   m_res_out_irq_func;
159   devcb_resolved_write_line   m_res_out_firq_func;
160   devcb_resolved_read8      m_res_in_floating_bus_func;
161161
162162   // device state
163   UINT8 m_gime_registers[16];
164   UINT8 m_mmu[16];
165   UINT8 m_ff22_value;
166   UINT8 m_interrupt_value;
167   UINT8 m_irq;
168   UINT8 m_firq;
169   UINT16 m_timer_value;
170   bool m_is_blinking;
163   UINT8                  m_gime_registers[16];
164   UINT8                  m_mmu[16];
165   UINT8                  m_ff22_value;
166   UINT8                  m_interrupt_value;
167   UINT8                  m_irq;
168   UINT8                  m_firq;
169   UINT16                  m_timer_value;
170   bool                  m_is_blinking;
171171
172172   // video state
173   bool m_legacy_video;
174   UINT32 m_video_position;
175   UINT8 m_line_in_row;
176   scanline_record m_scanlines[25+192+26];
177   bool m_displayed_rgb;
173   bool                  m_legacy_video;
174   UINT32                  m_video_position;
175   UINT8                  m_line_in_row;
176   scanline_record            m_scanlines[25+192+26];
177   bool                  m_displayed_rgb;
178178
179179   // palette state
180   UINT8 m_palette_rotated[1024][16];
181   UINT16 m_palette_rotated_position;
182   bool m_palette_rotated_position_used;
180   UINT8                  m_palette_rotated[1024][16];
181   UINT16                  m_palette_rotated_position;
182   bool                  m_palette_rotated_position_used;
183183
184184   // incidentals
185   ram_device *m_ram;
186   emu_timer *m_gime_clock_timer;
187   cococart_slot_device *m_cart_device;
188   UINT8 *m_rom;
189   UINT8 *m_cart_rom;
190   pixel_t m_composite_palette[64];
191   pixel_t m_composite_bw_palette[64];
192   pixel_t m_rgb_palette[64];
193   UINT8 m_dummy_bank[0x2000];
185   ram_device *            m_ram;
186   emu_timer *               m_gime_clock_timer;
187   cococart_slot_device *      m_cart_device;
188   memory_bank *            m_read_banks[9];
189   memory_bank *            m_write_banks[9];
190   UINT8 *                  m_rom;
191   UINT8 *                  m_cart_rom;
192   pixel_t                  m_composite_palette[64];
193   pixel_t                  m_composite_bw_palette[64];
194   pixel_t                  m_rgb_palette[64];
195   UINT8                  m_dummy_bank[0x2000];
194196
195197   // timer constants
196198   static const device_timer_id TIMER_FRAME = 0;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team