Previous 15994 Revisions Next

r14591 Thursday 23rd February, 2012 at 15:49:54 UTC by Michael Zapf
ti99: Horizon Ramdisk expansion card added (Michael Zapf)
[src/mess]mess.mak
[src/mess/machine/ti99]horizon.c* horizon.h* peribox.c

src/mess/machine/ti99/peribox.c
r14590r14591
192192#include "ti_rs232.h"
193193#include "spchsyn.h"
194194#include "memex.h"
195#include "horizon.h"
195196
196197#include "formats/ti99_dsk.h"
197198
r14590r14591
379380   SLOT_INTERFACE("hsgpl", TI99_HSGPL)
380381   SLOT_INTERFACE("tirs232", TI99_RS232)
381382   SLOT_INTERFACE("speech", TI99_SPEECH)
383   SLOT_INTERFACE("horizon", TI99_HORIZON)
382384SLOT_INTERFACE_END
383385
384386SLOT_INTERFACE_START( peribox_slot6 )
r14590r14591
435437   SLOT_INTERFACE("pcode", TI99_P_CODE)
436438   SLOT_INTERFACE("tirs232", TI99_RS232)
437439   SLOT_INTERFACE("speech", TI99_SPEECH)
440   SLOT_INTERFACE("horizon", TI99_HORIZON)
438441SLOT_INTERFACE_END
439442
440443MACHINE_CONFIG_FRAGMENT( peribox_gen_device )
r14590r14591
468471   SLOT_INTERFACE("pcode", TI99_P_CODE)
469472   SLOT_INTERFACE("tirs232", TI99_RS232)
470473   SLOT_INTERFACE("speech", TI99_SPEECH)
474   SLOT_INTERFACE("horizon", TI99_HORIZON)
471475SLOT_INTERFACE_END
472476
473477SLOT_INTERFACE_START( peribox_ev_slot )
src/mess/machine/ti99/horizon.c
r0r14591
1/****************************************************************************
2 
3    Horizon Ramdisk
4 
5    This emulation realizes the latest development, the HRD 4000, which could
6    host up to 16 MiB of SRAM. Real cards rarely had more than 1.5 MiB since
7    the SRAM used on the card is rather expensive.
8 
9    The SRAM is buffered with a battery pack. Also, there is an option for
10    an additional 32 KiB of unbuffered memory.
11 
12    The driver (ROS) of the ramdisk is stored in another buffered 8 KiB SRAM.
13 
14    The Horizon RAMdisk comes with a disk containing the ROS and a configuration
15    program (CFG). The latest version is ROS 8.14.
16 
17    Technical details:
18 
19    In the tradition (Horizon) mode, memory is organized as 2 KiB pages. The
20    pages are selected via CRU bits and visible in the address area 5800 - 5fff.
21    The area 4000-57ff is occupied by the ROS. As with all peripheral cards,
22    the 4000-5fff area requires a CRU bit to be set (usually bit 0 of this
23    card's CRU base).
24 
25    Next releases of the HRD included new modes. The RAMBO (RAM Block operator)
26    mode gathers four pages to a single 8 KiB page that is visible in the
27    area 6000-7fff (cartridge space). Note that due to a possible design glitch,
28    each RAMBO page n covers Horizon pages 4n, 4n+2, 4n+1, 4n+3 in this sequence.
29    We emulate this by swapping two CRU lines.
30 
31    The RAMDisk may be split in two separate drives, which is called the
32    Phoenix extension. This is particularly important for use in the Geneve.
33    As a bootable drive, the RAMdisk must not
34    exceed 256 KiB; consequently, the RAM area is split, and one part realizes
35    the boot drive while the other is still available for data. Also, there
36    is a mechanism for selecting the parts of the card: The TI setting allows
37    to select two CRU addresses, one for each part. In the Geneve mode, only
38    one CRU address is used (1400 or 1600), and the part is selected by the
39    fact that one disk uses CRU bits higher than 8, while the other uses the
40    bits lower than 8.
41 
42    The card is able to handle 128K*8 and 512K*8 SRAM chips, allowing a total
43    of 16 MiB memory space. Unfortunately, a bug causes the configuration
44    program to crash when used with more than 2 MiB. Although the card was
45    quite popular, this bug was not found because most cards were sold with
46    less than 2 MiB onboard.
47 
48    Michael Zapf
49    February 2012
50 
51*****************************************************************************/
52 
53#include "horizon.h"
54 
55#define RAMREGION "ram"
56#define NVRAMREGION "nvram"
57#define ROSREGION "ros"
58 
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
61 
62#define VERBOSE 1
63#define LOG logerror
64 
65horizon_ramdisk_device::horizon_ramdisk_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
66: ti_expansion_card_device(mconfig, TI99_HORIZON, "Horizon 4000 Ramdisk", tag, owner, clock) ,device_nvram_interface(mconfig, *this)
67{
68   m_shortname = "ti99_horizon";
69}
70 
71//-------------------------------------------------
72//  nvram_default - called to initialize NVRAM to
73//  its default state
74//-------------------------------------------------
75 
76void horizon_ramdisk_device::nvram_default()
77{
78   memset(m_nvram, 0, BUFFRAM_SIZE);
79}
80 
81//-------------------------------------------------
82//  nvram_read - called to read NVRAM from the
83//  .nv file
84//-------------------------------------------------
85 
86void horizon_ramdisk_device::nvram_read(emu_file &file)
87{
88   file.read(m_nvram, BUFFRAM_SIZE);
89}
90 
91//-------------------------------------------------
92//  nvram_write - called to write NVRAM to the
93//  .nv file
94//-------------------------------------------------
95 
96void horizon_ramdisk_device::nvram_write(emu_file &file)
97{
98   file.write(m_nvram, BUFFRAM_SIZE);
99}
100 
101READ8Z_MEMBER(horizon_ramdisk_device::readz)
102{
103   // 32K expansion
104   if (m_32k_installed)
105   {
106      switch((offset & 0xe000)>>13)
107      {
108      case 1:    // 2000-3fff
109         *value = m_ram[offset & 0x1fff];
110         return;
111      case 5:   // a000-bfff
112         *value = m_ram[(offset & 0x1fff) | 0x2000];
113         return;
114      case 6:   // c000-dfff
115         *value = m_ram[(offset & 0x1fff) | 0x4000];
116         return;
117      case 7:   // e000-ffff
118         *value = m_ram[(offset & 0x1fff) | 0x6000];
119         return;
120      default:
121         break;
122      }
123   }
124 
125   if (m_killswitch) return;
126 
127   // I think RAMBO mode does not need the card to be selected
128   if (!m_selected && !m_rambo_mode) return;
129 
130   if (!m_rambo_mode)
131   {
132      if ((offset & m_select_mask) == m_select_value)
133      {
134         if ((offset & 0x1800) == 0x1800)
135         {
136            // NVRAM page of size 2 KiB
137            *value = m_nvram[(m_page << 11)|(offset & 0x07ff)];
138            if (VERBOSE>5) LOG("horizon: offset=%04x, page=%04x -> %02x\n", offset&0xffff,  m_page, *value);
139         }
140         else
141         {
142            // ROS
143            *value = m_ros[offset & 0x1fff];
144            if (VERBOSE>5) LOG("horizon: offset=%04x -> %02x\n", offset&0xffff,  *value);
145         }
146      }
147   }
148   else
149   {
150      if ((offset & m_select_mask)==m_select_value)
151      {
152         *value = m_ros[offset & 0x1fff];
153         if (VERBOSE>5) LOG("horizon: offset=%04x (Rambo) -> %02x\n", offset&0xffff,  *value);
154      }
155      if ((offset & m_select_mask)==m_select6_value)
156      {
157         // In RAMBO mode the page numbers are multiples of 4
158         // (encompassing 4 Horizon pages)
159         // We clear away the rightmost two bits
160         *value = m_nvram[((m_page&0xfffc)<<11) | (offset & 0x1fff)];
161         if (VERBOSE>5) LOG("horizon: offset=%04x, page=%04x (Rambo) -> %02x\n", offset&0xffff,  m_page, *value);
162      }
163   }
164}
165 
166WRITE8_MEMBER(horizon_ramdisk_device::write)
167{
168   // 32K expansion
169   if (m_32k_installed)
170   {
171      switch((offset & 0xe000)>>13)
172      {
173      case 1:    // 2000-3fff
174         m_ram[offset & 0x1fff] = data;
175         return;
176      case 5:   // a000-bfff
177         m_ram[(offset & 0x1fff) | 0x2000] = data;
178         return;
179      case 6:   // c000-dfff
180         m_ram[(offset & 0x1fff) | 0x4000] = data;
181         return;
182      case 7:   // e000-ffff
183         m_ram[(offset & 0x1fff) | 0x6000] = data;
184         return;
185      default:
186         break;
187      }
188   }
189 
190   if (m_killswitch) return;
191 
192   // I think RAMBO mode does not need the card to be selected
193   if (!m_selected && !m_rambo_mode) return;
194 
195   if (!m_rambo_mode)
196   {
197      if ((offset & m_select_mask) == m_select_value)
198      {
199         if ((offset & 0x1800) == 0x1800)
200         {
201            // NVRAM page of size 2 KiB
202            m_nvram[(m_page << 11)|(offset & 0x07ff)] = data;
203            if (VERBOSE>5) LOG("horizon: offset=%04x, page=%04x <- %02x\n", offset&0xffff,  m_page, data);
204         }
205         else
206         {
207            // ROS
208            m_ros[offset & 0x1fff] = data;
209            if (VERBOSE>5) LOG("horizon: offset=%04x <- %02x\n", offset&0xffff,  data);
210         }
211      }
212   }
213   else
214   {
215      if ((offset & m_select_mask)==m_select_value)
216      {
217         m_ros[offset & 0x1fff] = data;
218         if (VERBOSE>5) LOG("horizon: offset=%04x (Rambo) <- %02x\n", offset&0xffff,  data);
219      }
220      if ((offset & m_select_mask)==m_select6_value)
221      {
222         // In RAMBO mode the page numbers are multiples of 4
223         // (encompassing 4 Horizon pages)
224         // We clear away the rightmost two bits
225         m_nvram[((m_page&0xfffc)<<11) | (offset & 0x1fff)] = data;
226         if (VERBOSE>5) LOG("horizon: offset=%04x, page=%04x (Rambo) <- %02x\n", offset&0xffff,  m_page, data);
227      }
228   }
229}
230 
231void horizon_ramdisk_device::crureadz(offs_t offset, UINT8 *value)
232{
233   // There is no CRU read operation for the Horizon.
234   return;
235}
236 
237void horizon_ramdisk_device::setbit(int& page, int pattern, bool set)
238{
239   if (set)
240   {
241      page |= pattern;
242   }
243   else
244   {
245      page &= ~pattern;
246   }
247}
248 
249void horizon_ramdisk_device::cruwrite(offs_t offset, UINT8 data)
250{
251   if (((offset & 0xff00)==m_cru_horizon)||((offset & 0xff00)==m_cru_phoenix))
252   {
253      int bit = (offset >> 1) & 0x0f;
254      if (VERBOSE>5) LOG("horizon: CRU write bit %d <- %d\n", bit, data);
255      switch (bit)
256      {
257      case 0:
258         m_selected = (data!=0);
259         if (VERBOSE>4) LOG("horizon: Activate ROS = %d\n", m_selected);
260         break;
261      case 1:
262         // Swap the lines so that the access with RAMBO is consistent
263         if (!m_rambo_mode) setbit(m_page, 0x0002, data!=0);
264         break;
265      case 2:
266         // Swap the lines so that the access with RAMBO is consistent
267         if (!m_rambo_mode) setbit(m_page, 0x0001, data!=0);
268         break;
269      case 3:
270         setbit(m_page, 0x0004, data!=0);
271         break;
272      case 4:
273         setbit(m_page, 0x0008, data!=0);
274         break;
275      case 5:
276         setbit(m_page, 0x0010, data!=0);
277         break;
278      case 6:
279         setbit(m_page, 0x0020, data!=0);
280         break;
281      case 7:
282         setbit(m_page, 0x0040, data!=0);
283         break;
284      case 8:
285         setbit(m_page, 0x0080, data!=0);
286         break;
287      case 9:
288         setbit(m_page, 0x0100, data!=0);
289         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;
306      case 14:
307         break;
308      case 15:
309         if (m_use_rambo)
310         {
311            m_rambo_mode = (data != 0);
312            if (VERBOSE>4) LOG("horizon: RAMBO = %d\n", m_rambo_mode);
313         }
314         break;
315      }
316 
317      if (m_split_mode)
318      {
319         if (m_timode)
320         {
321            // 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));
324         }
325         else
326         {
327            // In Geneve mode, switch between both RAMdisks by
328            // using the bit number of the last CRU access
329            // setbit(m_page, 0x0800, (bit>7));
330            setbit(m_page, 0x0200, (bit>7));
331         }
332      }
333   }
334}
335 
336void horizon_ramdisk_device::device_start(void)
337{
338   m_nvram = subregion(NVRAMREGION)->base();
339   m_ram = subregion(RAMREGION)->base();
340   m_ros = m_nvram + BUFFRAM_SIZE-8192;
341   m_cru_horizon = 0;
342   m_cru_phoenix = 0;
343}
344 
345void horizon_ramdisk_device::device_reset(void)
346{
347   if (m_genmod)
348   {
349      m_select_mask = 0x1fe000;
350      m_select_value = 0x174000;
351      m_select6_value = 0x176000;
352      m_select_all = 0x170000;
353   }
354   else
355   {
356      m_select_mask = 0x7e000;
357      m_select_value = 0x74000;
358      m_select6_value = 0x76000;
359      m_select_all = 0x70000;
360   }
361 
362   m_cru_horizon = input_port_read(*this, "CRUHOR");
363   m_cru_phoenix = input_port_read(*this, "CRUPHOE");
364 
365   m_32k_installed = (input_port_read(*this, "HORIZON32")!=0);
366 
367   m_split_mode = (input_port_read(*this, "HORIZONDUAL")!=0);
368   m_timode = (input_port_read(*this, "HORIZONDUAL")==1);
369 
370   m_rambo_mode = false;
371   m_killswitch = (input_port_read(*this, "HORIZONACT")!=0);
372 
373   m_use_rambo = (input_port_read(*this, "RAMBO")!=0);
374 
375   m_page = 0;
376}
377 
378INPUT_CHANGED_MEMBER( horizon_ramdisk_device::ks_changed )
379{
380   if (VERBOSE>5) LOG("horizon: killswitch changed %d\n", newval);
381   m_killswitch = (newval!=0);
382}
383 
384/*
385    Input ports for the Horizon
386*/
387INPUT_PORTS_START( horizon )
388   PORT_START( "CRUHOR" )
389   PORT_DIPNAME( 0x1f00, 0x1200, "Horizon CRU base" )
390      PORT_DIPSETTING(    0x0000, DEF_STR( Off ) )
391      PORT_DIPSETTING(    0x1000, "1000" )
392      PORT_DIPSETTING(    0x1200, "1200" )
393      PORT_DIPSETTING(    0x1400, "1400" )
394      PORT_DIPSETTING(    0x1500, "1500" )
395      PORT_DIPSETTING(    0x1600, "1600" )
396      PORT_DIPSETTING(    0x1700, "1700" )
397 
398   PORT_START( "CRUPHOE" )
399   PORT_DIPNAME( 0x1f00, 0x0000, "Phoenix CRU base" )
400      PORT_DIPSETTING(    0x0000, DEF_STR( Off ) )
401      PORT_DIPSETTING(    0x1400, "1400" )
402      PORT_DIPSETTING(    0x1600, "1600" )
403 
404   PORT_START( "HORIZONDUAL" )
405   PORT_DIPNAME( 0x03, 0x00, "Horizon ramdisk split" )
406      PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
407      PORT_DIPSETTING(    0x01, "TI mode" )
408      PORT_DIPSETTING(    0x02, "Geneve mode" )
409 
410   PORT_START( "HORIZONACT" )
411   PORT_DIPNAME( 0x01, 0x00, "Horizon killswitch" ) PORT_CHANGED_MEMBER(DEVICE_SELF, horizon_ramdisk_device, ks_changed, 1)
412      PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
413      PORT_DIPSETTING(    0x01, DEF_STR( On ) )
414 
415   PORT_START( "HORIZON32" )
416   PORT_CONFNAME( 0x01, 0x00, "Horizon 32 KiB upgrade" )
417      PORT_CONFSETTING( 0x00, DEF_STR( Off ))
418      PORT_CONFSETTING( 0x01, DEF_STR( On ))
419 
420   PORT_START( "RAMBO" )
421   PORT_CONFNAME( 0x01, 0x01, "Horizon RAMBO" )
422      PORT_CONFSETTING( 0x00, DEF_STR( Off ))
423      PORT_CONFSETTING( 0x01, DEF_STR( On ))
424INPUT_PORTS_END
425 
426ROM_START( horizon )
427   ROM_REGION(BUFFRAM_SIZE, NVRAMREGION, 0)
428   ROM_FILL(0x0000, BUFFRAM_SIZE, 0x00)
429   ROM_REGION(0x8000, RAMREGION, 0)
430   ROM_FILL(0x0000, 0x8000, 0x00)
431ROM_END
432 
433const rom_entry *horizon_ramdisk_device::device_rom_region() const
434{
435   return ROM_NAME( horizon );
436}
437 
438ioport_constructor horizon_ramdisk_device::device_input_ports() const
439{
440   return INPUT_PORTS_NAME(horizon);
441}
442 
443const device_type TI99_HORIZON = &device_creator<horizon_ramdisk_device>;
444 
src/mess/machine/ti99/horizon.h
r0r14591
1/****************************************************************************
2 
3    Horizon Ramdisk
4    See horizon.c for documentation
5 
6    Michael Zapf
7 
8    February 2012
9 
10*****************************************************************************/
11 
12#ifndef __HORIZON__
13#define __HORIZON__
14 
15#include "emu.h"
16#include "peribox.h"
17#include "ti99defs.h"
18 
19extern const device_type TI99_HORIZON;
20 
21class horizon_ramdisk_device : public ti_expansion_card_device, public device_nvram_interface
22{
23public:
24   horizon_ramdisk_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
25   DECLARE_READ8Z_MEMBER(readz);
26   DECLARE_WRITE8_MEMBER(write);
27 
28   void crureadz(offs_t offset, UINT8 *value);
29   void cruwrite(offs_t offset, UINT8 value);
30 
31   DECLARE_INPUT_CHANGED_MEMBER( ks_changed );
32 
33protected:
34   void device_start();
35   void device_reset();
36 
37   const rom_entry *device_rom_region() const;
38   ioport_constructor device_input_ports() const;
39 
40   void nvram_default();
41   void nvram_read(emu_file &file);
42   void nvram_write(emu_file &file);
43 
44private:
45   void   setbit(int& page, int pattern, bool set);
46 
47   UINT8*   m_ram;
48   UINT8*   m_nvram;
49   UINT8*   m_ros;
50 
51   int      m_select6_value;
52   int      m_select_all;
53 
54   int    m_page;
55 
56   int      m_cru_horizon;
57   int      m_cru_phoenix;
58   bool   m_timode;
59   bool   m_32k_installed;
60   bool   m_split_mode;
61   bool   m_rambo_mode;
62   bool   m_killswitch;
63   bool   m_use_rambo;
64};
65 
66#endif
src/mess/mess.mak
r14590r14591
16761676   $(MESS_MACHINE)/ti99/mapper8.o   \
16771677   $(MESS_MACHINE)/ti99/genboard.o   \
16781678   $(MESS_MACHINE)/ti99/memex.o   \
1679   $(MESS_MACHINE)/ti99/horizon.o   \
16791680   $(MESS_MACHINE)/strata.o   \
16801681   $(MESS_MACHINE)/990_dk.o   \
16811682   $(MESS_DRIVERS)/ti990_4.o   \

Previous 15994 Revisions Next


© 1998-2018 The MESS Team