Previous 199869 Revisions Next

r29346 Sunday 6th April, 2014 at 00:33:09 UTC by Michael Zapf
(MESS) Fixed several bugs in HSGPL. [Michael Zapf]
[src/emu/bus/ti99_peb]hsgpl.c hsgpl.h

trunk/src/emu/bus/ti99_peb/hsgpl.c
r29345r29346
8989    48 - 55     >9858   >9C58
9090    56 - 63     >985C   >9C5C
9191
92    Note: Writing only works for areas set up as RAM.  To write to the
93        FEEPROMs, you must used the algorithm specified by their respective
94        manufacturer.
92    Notes:
93    1. The bank numbering of the modules is not exactly the GROM bank numbering.
94       The first 16 banks are numbered as expected, but bank 16 is DSR bank 0-7,
95       bank 23 is DSR bank 56-63, bank 24 is ROM6000 of module bank 0, bank 31 is
96       ROM6000 of module bank 25, and finally bank 32 and 33 and the GRAM banks,
97       and bank 48 and 49 are the RAM banks.
98       Only accesses to the GROM/GRAM addresses will change the module bank.
9599
100    2. Writing only works for areas set up as RAM.  To write to the
101       FEEPROMs, you must used the algorithm specified by their respective
102       manufacturer.
103
96104    CRDENA: This flag is used to turn on and off the HSGPL. It is used in
97105    particular at start-up when the DSR detects a cartridge in the
98106    cartridge slot. In that case the memory locations 6000-7fff must be
r29345r29346
102110    active.
103111    The technical specifications are not clear enough at this point.
104112
105    FIXME: Re-flashing the at29040 chips is only possible when the DSR Flashrom
106    U9 is deleted before. The file must be removed from the nvram directory.
107    May also be a bug of the loader program DSRLDR3.
108    (Detail: The DSRLDR program fails to flash part 3/8 of the flash rom.)
109
110113    Raphael Nabet, 2003.
111114
112115    Michael Zapf
r29345r29346
120123#define CRU_BASE 0x1B00
121124#define SUPERCART_BASE 0x0800
122125
123#define VERBOSE 1
124#define LOG logerror
126#define TRACE_PORT 0
127#define TRACE_DSR 0
128#define TRACE_BANKING 0
129#define TRACE_CRU 0
130#define TRACE_READ 0
131#define TRACE_WRITE 0
132#define TRACE_IGNORE 0
125133
126134#define RAMSIZE         0x020000
127135#define GRAMSIZE        0x020000
r29345r29346
154162   {
155163      if (data != 0)
156164      {
157         if (VERBOSE>2) LOG("hsgpl: Supercart cru setting %04x\n", offset);
165         if (TRACE_CRU) logerror("%s: Supercart cru setting %04x\n", tag(), offset);
158166         m_current_bank = (offset-0x0802)>>2;
159167      }
160168      return;
r29345r29346
168176      {
169177      case 0:
170178         m_dsr_enabled = (data != 0);
171         if (VERBOSE>5) LOG("hsgpl: Set dsr_enabled=%x\n", data);
179         if (TRACE_CRU) logerror("%s: Set dsr_enabled=%x\n", tag(), data);
172180         break;
173181      case 1:
174182         m_gram_enabled = (data != 0);
175         if (VERBOSE>5) LOG("hsgpl: Set gram_enabled=%x\n", data);
183         if (TRACE_CRU) logerror("%s: Set gram_enabled=%x\n", tag(), data);
176184         break;
177185      case 2:
178         m_bank_enabled = (data != 0);
179         if (VERBOSE>5) LOG("hsgpl: Set bank_enabled=%x\n", data);
186         m_bank_inhibit = (data != 0);
187         if (TRACE_CRU) logerror("%s: Set bank_inhibit=%x\n", tag(), data);
180188         break;
181189      case 3:
182190      case 4:
r29345r29346
188196            m_dsr_page |= (1 << (bit-3));
189197         else
190198            m_dsr_page &= ~(1 << (bit-3));
191         if (VERBOSE>5) LOG("hsgpl: Set dsr_page=%d\n", m_dsr_page);
199         if (TRACE_CRU) logerror("%s: Set dsr_page=%d\n", tag(), m_dsr_page);
192200         break;
193201      case 9:
194202         m_card_enabled = data;
195         if (VERBOSE>5) LOG("hsgpl: Set card_enabled=%x\n", data);
203         if (TRACE_CRU) logerror("%s: Set card_enabled=%x\n", tag(), data);
196204         break;
197205      case 10:
198206         m_write_enabled = data;
199         if (VERBOSE>5) LOG("hsgpl: Set write_enabled=%x\n", data);
207         if (TRACE_CRU) logerror("%s: Set write_enabled=%x\n", tag(), data);
200208         break;
201209      case 11:
202210         m_supercart_enabled = data;
203211         // CHECK: Do we have to reset the bank?
204         if (VERBOSE>5) LOG("hsgpl: Set supercart_enabled=%x\n", data);
212         if (TRACE_CRU) logerror("%s: Set supercart_enabled=%x\n", tag(), data);
205213         break;
206214      case 12:
207215         m_led_on = data;
208         if (VERBOSE>5) LOG("hsgpl: Set led_on=%x\n", data);
216         if (TRACE_CRU) logerror("%s: Set led_on=%x\n", tag(), data);
209217         break;
210218      case 13:
211219         break;
212220      case 14:
213221         m_mbx_enabled = data;
214         if (VERBOSE>5) LOG("hsgpl: Set mbx_enabled=%x\n", data);
222         if (TRACE_CRU) logerror("%s: Set mbx_enabled=%x\n", tag(), data);
215223         break;
216224      case 15:
217225         m_ram_enabled = data;
218         if (VERBOSE>5) LOG("hsgpl: Set ram_enabled=%x\n", data);
226         if (TRACE_CRU) logerror("%s: Set ram_enabled=%x\n", tag(), data);
219227         break;
220228      }
221229   }
r29345r29346
268276   if (m_dsr_enabled)
269277   {
270278      *value = m_dsr_eeprom->read(space, (offset & 0x1fff) | (m_dsr_page<<13), mem_mask);
271      if (VERBOSE>7) LOG("hsgpl: read dsr %04x[%02x] -> %02x\n", offset, m_dsr_page, *value);
279      if (TRACE_READ) logerror("%s: read dsr %04x[%02x] -> %02x\n", tag(), offset, m_dsr_page, *value);
272280   }
273281}
274282
r29345r29346
279287{
280288   if (!m_card_enabled || m_flash_mode)
281289   {
282      if (VERBOSE>6) LOG("hsgpl cart read ignored (enable=%02x)\n", m_card_enabled);
290      if (TRACE_IGNORE) logerror("%s: cartridge space read ignored (enable=%d, flash_mode=%d)\n", tag(), m_card_enabled, m_flash_mode);
283291      return;
284292   }
285293
286   if ((m_current_grom_port < 2) && (m_ram_enabled))
294   if (m_module_bank < 16)
287295   {
288      *value = m_ram6_memory[(offset & 0x1fff) | (m_current_bank<<13) | (m_current_grom_port<<15)];
289      if (VERBOSE>7) LOG("hsgpl cart ram read %04x -> %02x\n", offset, *value);
290      return;
291   }
292
293   if (m_current_grom_port < 16)
294   {
295296      *value = m_rom6_eeprom->read(space, (offset & 0x1fff) | (m_current_bank<<13) | (m_current_grom_port<<15), mem_mask);
296      if (VERBOSE>7) LOG("hsgpl cart read %04x -> %02x\n", offset, *value);
297      if (TRACE_READ) logerror("%s: cartridge space read %04x -> %02x\n", tag(), offset, *value);
297298   }
298299   else
299300   {
300      if (m_current_grom_port==32 || m_current_grom_port==33)
301      if (m_module_bank==16 || m_module_bank==17)
301302      {
302         *value = m_ram6_memory[(offset & 0x1fff) | (m_current_bank<<13) | ((m_current_grom_port-32)<<15)];
303         *value = m_ram6_memory[(offset & 0x1fff) | (m_current_bank<<13) | ((m_module_bank & 0x000f)<<15)];
303304      }
304305      else
305306      {
306         if (VERBOSE>1) LOG("unknown 0x6000 port\n");
307         logerror("%s: unknown 0x6000 port\n", tag());
307308      }
308309   }
309310}
r29345r29346
316317*/
317318void snug_high_speed_gpl_device::grom_readz(address_space& space, offs_t offset, UINT8* value, UINT8 mem_mask)
318319{
319   int port;
320320   if (space.debugger_access()) return;
321321
322322   //activedevice_adjust_icount(-4);
323323
324324   // 1001 10bb bbbb bba0
325   port = m_current_grom_port = (offset & 0x3fc) >> 2;
325   int port = (offset & 0x3fc) >> 2;
326326
327327   if (offset & 2)
328328   {   // Read GPL address. This must be available even when the rest
r29345r29346
342342   }
343343   else
344344   {   /* read GPL data */
345      bool bNew = (port != m_current_grom_port);
346      m_current_grom_port = port;
347
345348      // It is not clear what effect a CRDENA=0 really has.
346349      // At least GROMs 0-2 must remain visible, or the console will lock up.
347350      if (m_card_enabled || m_grom_address < 0x6000)
r29345r29346
349352         if ((port < 2) && (m_gram_enabled))
350353         {
351354            *value = m_gram_memory[m_grom_address | (port<<16)];
355            m_module_bank = port + 16;
356            if (TRACE_PORT) if (bNew) logerror("%s: GRAM read access at %04x (GRMENA=1) - switch to bank %d\n", tag(), offset & 0xffff, m_module_bank);
352357         }
353358         else
354359         {
r29345r29346
357362               if (!m_flash_mode)
358363               {
359364                  *value = m_grom_a_eeprom->read(space, m_grom_address | (port<<16), mem_mask);
365                  m_module_bank = port;
366                  if (TRACE_PORT) if (bNew) logerror("%s: GROM read access at %04x - switch to bank %d\n", tag(), offset & 0xffff, m_module_bank);
360367               }
361368            }
362369            else
r29345r29346
364371               if (port < 16)
365372               {
366373                  *value = m_grom_b_eeprom->read(space, m_grom_address | ((port-8)<<16), mem_mask);
374                  m_module_bank = port;
375                  if (TRACE_PORT) if (bNew) logerror("%s: GROM read access at %04x - switch to bank %d\n", tag(), offset & 0xffff, m_module_bank);
367376               }
368377               else
369378               {
r29345r29346
372381                     // 9840-985c
373382                     // DSR banks 0-63 (8 KiB per bank, 8 banks per port)
374383                     *value = m_dsr_eeprom->read(space, m_grom_address | ((port-16)<<16), mem_mask);
384                     // Don't change the module port
385                     if (TRACE_DSR) if (bNew) logerror("%s: read access to DSR bank %d-%d (%04x)\n", tag(), (port-16)<<3, ((port-16)<<3)+7, offset);
375386                  }
376387                  else
377388                  {
r29345r29346
381392                        // Each ROM6 is available as 4 (sub)banks (switchable via 6000, 6002, 6004, 6006)
382393                        // Accordingly, each port has two complete sets
383394                        *value = m_rom6_eeprom->read(space, m_grom_address | ((port-24)<<16), mem_mask);
395                        if (TRACE_PORT) if (bNew) logerror("%s: ROM6 read access for module bank %d-%d (%04x)\n", tag(), (port-24)<<1, ((port-24)<<1)+1, offset & 0xffff);
384396                     }
385397                     else
386398                     {
r29345r29346
388400                        if (port==32 || port==33)
389401                        {
390402                           *value = m_gram_memory[m_grom_address | ((port-32)<<16)];
403                           m_module_bank = port - 16;
404                           if (TRACE_PORT) if (bNew) logerror("%s: GRAM read access at %04x  - switch to bank %d\n", tag(), offset & 0xffff, m_module_bank);
391405                        }
392406                        else
393407                        {
r29345r29346
395409                           {
396410//                                      *value = m_ram6_memory[m_grom_address];
397411                              *value = m_ram6_memory[m_grom_address | ((port-48)<<16)];
412                              if (TRACE_PORT) if (bNew) logerror("%s: RAM read access at %04x\n", tag(), offset & 0xffff);
398413                           }
399414                           else
400415                           {
401                              if (VERBOSE>2) LOG("hsgpl: Attempt to read from undefined port 0x%0x; ignored.\n", port);
416                              logerror("%s: Attempt to read from undefined port 0x%0x; ignored.\n", tag(), port);
402417                           }
403418                        }
404419                     }
r29345r29346
421436{
422437   if (!m_card_enabled || m_flash_mode)
423438   {
424      if (VERBOSE>2) LOG("hsgpl cart write ignored: card_enabled=%02x\n", m_card_enabled);
439      if (TRACE_IGNORE) logerror("%s: write ignored: card_enabled=%d, flash_mode=%d\n", tag(), m_card_enabled, m_flash_mode);
425440      return;
426441   }
427442
428   if (VERBOSE>7) LOG("hsgpl cart write %04x -> %02x\n", offset, data);
443   if (TRACE_WRITE) logerror("%s: cartridge space write %04x <- %02x\n", tag(), offset, data);
429444
430   if (m_bank_enabled)
445   if (!m_bank_inhibit && (m_module_bank < 16))
431446   {
432      m_current_bank = (offset>>1) & 3;
433      if (VERBOSE>7) LOG("hsgpl cart select bank %02x\n", m_current_bank);
447      if ((offset & 1) == 0)
448      {
449         if ((offset & 0x9ff0)!=0) logerror("%s: unplausible ROM6 write: %04x <- %02x\n", tag(), offset, data);
450         m_current_bank = (offset>>1) & 3;
451         if (TRACE_BANKING) logerror("%s: select bank %d\n", tag(), m_current_bank);
452      }
434453      return;     /* right??? */
435454   }
436455
437456   if ((m_mbx_enabled) && (offset==0x6ffe))
438457   {   /* MBX: mapper at 0x6ffe */
439458      m_current_bank = data & 0x03;
459      if (TRACE_BANKING) logerror("%s: select bank MBX %d\n", tag(), m_current_bank);
440460      return;
441461   }
442462
r29345r29346
445465   // not implemented
446466   if ((m_write_enabled) || ((m_mbx_enabled) && ((offset & 0xfc00)==0x6c00)))
447467   {
448      if ((m_current_grom_port < 2) && (m_ram_enabled))
468      if ((m_module_bank < 2) && (m_ram_enabled))
449469      {
450         m_ram6_memory[(offset & 0x1fff) | (m_current_bank<<13) | (m_current_grom_port<<15) ] = data;
470         m_ram6_memory[(offset & 0x1fff) | (m_current_bank<<13) | (m_module_bank<<15) ] = data;
451471      }
452472      else
453473      {   // keep in mind that these lines are also reached for port < 2
454474         // and !ram_enabled
455         if (m_current_grom_port < 16)
475         if (m_module_bank < 16)
456476         {
477            logerror("%s: invalid write %04x <- %02x\n", tag(), offset, data);
457478         // feeprom is normally written to using GPL ports, and I don't know
458479         // writing through >6000 page is enabled
459480/*
r29345r29346
463484         }
464485         else
465486         {
466            if (m_current_grom_port==32 || m_current_grom_port==33)
487            if (m_module_bank==16 || m_module_bank==17)
467488            {
468               m_ram6_memory[(offset & 0x1fff) | (m_current_bank<<13) | ((m_current_grom_port-32)<<15)] = data;
489               m_ram6_memory[(offset & 0x1fff) | (m_current_bank<<13) | ((m_module_bank-16)<<15)] = data;
469490            }
470491            else
471492            {
472               if (VERBOSE>1) LOG("unknown 0x6000 port\n");
493               logerror("%s: unknown 0x6000 port\n", tag());
473494            }
474495         }
475496      }
r29345r29346
481502*/
482503void snug_high_speed_gpl_device::grom_write(address_space& space, offs_t offset, UINT8 data, UINT8 mem_mask)
483504{
484   int port;
485505   if (space.debugger_access()) return;
486506
487507   //activedevice_adjust_icount(-4);
488508
489509   // 1001 11bb bbbb bba0
490   port = m_current_grom_port = (offset & 0x3fc) >> 2;
510   int port = (offset & 0x3fc) >> 2;
491511
492512   if (offset & 2)
493513   {   // Write GPL address. This must be available even when the rest
r29345r29346
507527   }
508528   else
509529   {
530      bool bNew = (port != m_current_grom_port);
531      m_current_grom_port = port;
510532      // It is not clear what effect a CRDENA=0 really has.
511533      // At least GROMs 0-2 must remain visible, or the console will lock up.
512534      if (m_card_enabled || m_grom_address < 0x6000)
r29345r29346
517539            if ((port < 2) && (m_gram_enabled))
518540            {
519541               m_gram_memory[m_grom_address | (port<<16)] = data;
542               m_module_bank = port + 16;
543               if (TRACE_PORT) if (bNew) logerror("%s: GRAM write access at %04x (GRMENA=1) - switch to bank %d\n", tag(), offset & 0xffff, port);
520544            }
521545            else
522546            {
523547               if (port < 8)
524548               {
525549                  m_grom_a_eeprom->write(space, m_grom_address | (port<<16), data, mem_mask);
550                  m_module_bank = port;
551                  if (TRACE_PORT) if (bNew) logerror("%s: GROM write access at %04x - switch to bank %d\n", tag(), offset & 0xffff, port);
526552               }
527553               else
528554               {
529555                  if (port < 16)
530556                  {
531557                     m_grom_b_eeprom->write(space, m_grom_address | ((port-8)<<16), data, mem_mask);
558                     m_module_bank = port;
559                     if (TRACE_PORT) if (bNew) logerror("%s: GROM write access at %04x - switch to bank %d\n", tag(), offset & 0xffff, port);
532560                  }
533561                  else
534562                  {
535563                     if (port < 24)
536564                     {
537565                        m_dsr_eeprom->write(space, m_grom_address | ((port-16)<<16), data, mem_mask);
566                        if (TRACE_DSR) if (bNew) logerror("%s: write access to DSR bank %d-%d (%04x)\n", tag(), (port-16)<<3, ((port-16)<<3)+7, offset);
538567                     }
539568                     else
540569                     {
541570                        if (port < 32)
542571                        {
543572                           m_rom6_eeprom->write(space, m_grom_address | ((port-24)<<16), data, mem_mask);
573                           if (TRACE_PORT) if (bNew) logerror("%s: ROM6 write access for module bank %d-%d (%04x)\n", tag(), (port-24)<<1, ((port-24)<<1)+1,offset & 0xffff);
544574                        }
545575                        else
546576                        {
547577                           if (port==32 || port==33)
548578                           {
549579                              m_gram_memory[m_grom_address | ((port-32)<<16)] = data;
580                              m_module_bank = port - 16;
581                              if (TRACE_PORT) if (bNew) logerror("%s: GRAM write access at %04x - switch to bank %d\n", tag(), offset & 0xffff, m_module_bank);
550582                           }
551583                           else
552584                           {
r29345r29346
554586                              {
555587//                                          m_ram6_memory[m_grom_address] = data;
556588                                 m_ram6_memory[m_grom_address | ((port-48)<<16)] = data;
589                                 if (TRACE_PORT) if (bNew) logerror("%s: RAM write access at %04x\n", tag(), offset & 0xffff);
557590                              }
558591                              else
559592                              {
560                                 if (VERBOSE>1) LOG("hsgpl: Attempt to write to undefined port; ignored.\n");
593                                 logerror("%s: Attempt to write to undefined port; ignored.\n", tag());
561594                              }
562595                           }
563596                        }
r29345r29346
583616
584617void snug_high_speed_gpl_device::device_reset()
585618{
586   if (VERBOSE>5) LOG("hsgpl: reset\n");
619   logerror("%s: reset\n", tag());
587620   m_dsr_enabled = false;
588621   m_gram_enabled = false;
589   m_bank_enabled = true;  // important, assumed to be enabled by default (won't start up otherwise!)
622   m_bank_inhibit = false;
590623   m_dsr_page = 0;
591624   m_card_enabled = true;  // important, assumed to be enabled by default
592625   m_write_enabled = false;
r29345r29346
602635   m_waddr_LSB = false;
603636   m_raddr_LSB = false;
604637   m_grom_address = 0;
638   m_module_bank = 0;
605639}
606640
607641void snug_high_speed_gpl_device::device_config_complete(void)
trunk/src/emu/bus/ti99_peb/hsgpl.h
r29345r29346
5959
6060   bool            m_dsr_enabled;
6161   bool            m_gram_enabled;
62   bool            m_bank_enabled;
62   bool            m_bank_inhibit;
6363   int             m_dsr_page;
6464   bool            m_card_enabled;
6565   bool            m_write_enabled;
r29345r29346
7272   int             m_current_grom_port;
7373   int             m_current_bank;
7474
75   int             m_module_bank;
76
7577   // GROM emulation
7678   bool            m_waddr_LSB;
7779   bool            m_raddr_LSB;

Previous 199869 Revisions Next


© 1997-2024 The MAME Team