Previous 15994 Revisions Next

r14617 Friday 24th February, 2012 at 18:48:47 UTC by Michael Zapf
ti99: Horizon Ramdisk gets configurable size (nw)
[src/mess/machine/ti99]horizon.c horizon.h

src/mess/machine/ti99/horizon.c
r14616r14617
4343    of 16 MiB memory space. Unfortunately, a bug causes the configuration
4444    program to crash when used with more than 2 MiB. Although the card was
4545    quite popular, this bug was not found because most cards were sold with
46    less than 2 MiB onboard.
46    less than 2 MiB onboard. As the community is still alive we can hope for
47    a fix for this problem; so we make the size configurable.
4748 
4849    Michael Zapf
4950    February 2012
r14616r14617
5657#define NVRAMREGION "nvram"
5758#define ROSREGION "ros"
5859 
59// Paged RAM is 2 MiB; behind we add the 8 KiB for the buffered RAM for the ROS
60#define BUFFRAM_SIZE 2097152+8192
60// Paged RAM is max 16 MiB; behind we add the 8 KiB for the buffered RAM for the ROS
61#define MAXRAM_SIZE 16777216+8192
6162 
6263#define VERBOSE 1
6364#define LOG logerror
r14616r14617
7374//  its default state
7475//-------------------------------------------------
7576 
77int horizon_ramdisk_device::get_size()
78{
79   int size = 8192 + 2097152*(1 << input_port_read(*this, "HORIZONSIZE"));
80   if (VERBOSE>2) LOG("horizon: size = %d\n", size);
81   return size;
82}
83 
7684void horizon_ramdisk_device::nvram_default()
7785{
78   memset(m_nvram, 0, BUFFRAM_SIZE);
86   memset(m_nvram, 0, get_size());
7987}
8088 
8189//-------------------------------------------------
r14616r14617
8593 
8694void horizon_ramdisk_device::nvram_read(emu_file &file)
8795{
88   file.read(m_nvram, BUFFRAM_SIZE);
96   int size = get_size();
97   int readsize = file.read(m_nvram, size);
98   // If we increased the size, fill the remaining parts with 0
99   if (readsize < size)
100   {
101      memset(m_nvram + readsize, 0, size-readsize);
102   }
89103}
90104 
91105//-------------------------------------------------
r14616r14617
95109 
96110void horizon_ramdisk_device::nvram_write(emu_file &file)
97111{
98   file.write(m_nvram, BUFFRAM_SIZE);
112   int size = get_size();
113   file.write(m_nvram, size);
99114}
100115 
101116READ8Z_MEMBER(horizon_ramdisk_device::readz)
r14616r14617
248263 
249264void horizon_ramdisk_device::cruwrite(offs_t offset, UINT8 data)
250265{
266   int size = input_port_read(*this, "HORIZONSIZE");
267   int split_bit = size + 10;
268   int splitpagebit = 0x0200 << size;
269 
251270   if (((offset & 0xff00)==m_cru_horizon)||((offset & 0xff00)==m_cru_phoenix))
252271   {
253272      int bit = (offset >> 1) & 0x0f;
r14616r14617
267286         if (!m_rambo_mode) setbit(m_page, 0x0001, data!=0);
268287         break;
269288      case 3:
270         setbit(m_page, 0x0004, data!=0);
271         break;
272289      case 4:
273         setbit(m_page, 0x0008, data!=0);
274         break;
275290      case 5:
276         setbit(m_page, 0x0010, data!=0);
277         break;
278291      case 6:
279         setbit(m_page, 0x0020, data!=0);
280         break;
281292      case 7:
282         setbit(m_page, 0x0040, data!=0);
283         break;
284293      case 8:
285         setbit(m_page, 0x0080, data!=0);
286         break;
287294      case 9:
288         setbit(m_page, 0x0100, data!=0);
295         setbit(m_page, 0x0001 << (bit-1), data!=0);
289296         break;
290      case 10:
291         // Remove "if" for 512K SRAMs
292         if (!m_split_mode) setbit(m_page, 0x0200, data!=0);
293         break;
294      case 11:
295         // We nee to limit this to 2 MiB because of a formatting too bug!
296         // setbit(m_page, 0x0400, data!=0);
297         break;
298      case 12:
299         // Uncomment for 512k SRAMs
300         //if (!m_split_mode) setbit(m_page, 0x0800, data!=0);
301         break;
302      case 13:
303         // Uncomment for 512k SRAMs
304         //setbit(m_page, 0x1000, data!=0);
305         break;
306297      case 14:
307298         break;
308299      case 15:
r14616r14617
312303            if (VERBOSE>4) LOG("horizon: RAMBO = %d\n", m_rambo_mode);
313304         }
314305         break;
306 
307      default:   // bits 10-13
308         if (bit != split_bit || !m_split_mode)
309         {
310            if (bit <= split_bit) setbit(m_page, 0x0200<<(bit-10), data!=0);
311         }
312         break;
315313      }
316314 
317315      if (m_split_mode)
r14616r14617
319317         if (m_timode)
320318         {
321319            // In TI mode, switch between both RAMDisks using the CRU address
322            //setbit(m_page, 0x0800, ((offset & 0xff00)==m_cru_phoenix));
323            setbit(m_page, 0x0200, ((offset & 0xff00)==m_cru_phoenix));
320            setbit(m_page, splitpagebit, ((offset & 0xff00)==m_cru_phoenix));
324321         }
325322         else
326323         {
327324            // In Geneve mode, switch between both RAMdisks by
328325            // using the bit number of the last CRU access
329            // setbit(m_page, 0x0800, (bit>7));
330            setbit(m_page, 0x0200, (bit>7));
326            setbit(m_page, splitpagebit, (bit>7));
331327         }
332328      }
333329   }
r14616r14617
337333{
338334   m_nvram = subregion(NVRAMREGION)->base();
339335   m_ram = subregion(RAMREGION)->base();
340   m_ros = m_nvram + BUFFRAM_SIZE-8192;
336   m_ros = m_nvram + MAXRAM_SIZE - 8192;
341337   m_cru_horizon = 0;
342338   m_cru_phoenix = 0;
343339}
r14616r14617
359355      m_select_all = 0x70000;
360356   }
361357 
358   m_ros = m_nvram + get_size()-8192;
362359   m_cru_horizon = input_port_read(*this, "CRUHOR");
363360   m_cru_phoenix = input_port_read(*this, "CRUPHOE");
364361 
r14616r14617
421418   PORT_CONFNAME( 0x01, 0x01, "Horizon RAMBO" )
422419      PORT_CONFSETTING( 0x00, DEF_STR( Off ))
423420      PORT_CONFSETTING( 0x01, DEF_STR( On ))
421 
422   PORT_START( "HORIZONSIZE" )
423   PORT_CONFNAME( 0x03, 0x00, "Horizon size" )
424      PORT_CONFSETTING( 0x00, "2 MiB")
425      PORT_CONFSETTING( 0x01, "4 MiB")
426      PORT_CONFSETTING( 0x03, "16 MiB")
427 
424428INPUT_PORTS_END
425429 
426430ROM_START( horizon )
427   ROM_REGION(BUFFRAM_SIZE, NVRAMREGION, 0)
428   ROM_FILL(0x0000, BUFFRAM_SIZE, 0x00)
431   ROM_REGION(MAXRAM_SIZE, NVRAMREGION, 0)
432   ROM_FILL(0x0000, MAXRAM_SIZE, 0x00)
429433   ROM_REGION(0x8000, RAMREGION, 0)
430434   ROM_FILL(0x0000, 0x8000, 0x00)
431435ROM_END
src/mess/machine/ti99/horizon.h
r14616r14617
4343 
4444private:
4545   void   setbit(int& page, int pattern, bool set);
46
46   int    get_size();
4747   UINT8*   m_ram;
4848   UINT8*   m_nvram;
4949   UINT8*   m_ros;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team