Previous 15994 Revisions Next

r8082 Wednesday 19th May, 2010 at 09:03:19 UTC by Fabio Priuli
Several WIPs:

* Improved TI-89, TI-92 and TI-92+ emulation [Sandro Ronco]
* Updated TI99 to use TMC0285 voice synthesis processor instead of TMS5220 [Michael Zapf]
* Added partially working support for Sufami Turbo carts in SNES
* Added skeleton support for BS-X Satellaview carts in SNES (nothing loads yet and most hardware is not emulated)
* Fixed a couple of details in snes.xml
[docs]messnew.txt
[hash]snes.xml
[src/mame/includes]snes.h
[src/mame/machine]snes.c snes7110.c snesbsx.c*
[src/mess]mess.mak messdriv.c
[src/mess/drivers]geneve.c snes.c ti89.c ti99_4p.c ti99_4x.c ti99_8.c
[src/mess/machine]geneve.c snescart.c snescart.h ti99_4x.c

hash/snes.xml
r8081r8082
55775577   </software>
55785578
55795579   <software name="columns">
5580      <!-- Serial:  - Release Date: -->
5580      <!-- Serial:  - Release Date: 1999-08-01 -->
55815581      <description>Columns (Jpn, NP)</description>
5582      <year>19??</year>
5583      <publisher>&lt;unknown&gt;</publisher>
5582      <year>1999</year>
5583      <publisher>Media Factory</publisher>
55845584      <part name="cart" interface="snes_cart">
55855585         <dataarea name="rom" size="524288">
55865586            <rom name="columns (japan) (np).sfc" size="524288" crc="005c77f5" sha1="cc1259497606ba73617d5a277b23cb5dc5e6fd27" offset="000000" />
r8081r8082
2525625256   </software>
2525725257
2525825258   <software name="ringkake">
25259      <!-- Serial:  - Release Date: 1988-06-01 -->
25259      <!-- Serial:  - Release Date: 1998-06-01 -->
2526025260      <description>Ring ni Kakero (Jpn, NP)</description>
2526125261      <year>1998</year>
2526225262      <publisher>NCS</publisher>
src/mame/machine/snes7110.c
r8081r8082
121121typedef struct
122122{
123123   running_machine *machine;
124
124   
125125   UINT32 decomp_mode;
126126   UINT32 decomp_offset;
127127
r8081r8082
138138
139139   UINT32 morton16[2][256];
140140   UINT32 morton32[4][256];
141   
142   UINT32 rom_size;
141143} SPC7110Decomp;
142144
143static SPC7110Decomp* SPC7110Decomp_ctor(running_machine *machine);
145static SPC7110Decomp* SPC7110Decomp_ctor(running_machine *machine, UINT32 size);
144146static void SPC7110Decomp_reset(SPC7110Decomp *thisptr);
145147static void SPC7110Decomp_init(SPC7110Decomp *thisptr, running_machine *machine, UINT32 mode, UINT32 offset, UINT32 index);
146148static UINT8 SPC7110Decomp_read(SPC7110Decomp *thisptr);
r8081r8082
156158static UINT32 SPC7110Decomp_morton_2x8(SPC7110Decomp *thisptr, UINT32 data);
157159static UINT32 SPC7110Decomp_morton_4x8(SPC7110Decomp *thisptr, UINT32 data);
158160
159static SPC7110Decomp* SPC7110Decomp_ctor(running_machine *machine)
161static SPC7110Decomp* SPC7110Decomp_ctor(running_machine *machine, UINT32 size)
160162{
161163   UINT32 i;
162164   SPC7110Decomp* newclass = (SPC7110Decomp*)auto_alloc_array(machine, UINT8, sizeof(SPC7110Decomp));
r8081r8082
183185      #undef map
184186   }
185187
188   newclass->rom_size = size;
189
186190   return newclass;
187191}
188192
r8081r8082
271275static UINT8 SPC7110Decomp_dataread(SPC7110Decomp *thisptr)
272276{
273277   UINT8 *ROM = memory_region(thisptr->machine, "cart");
274   UINT32 size = snes_rom_size - 0x100000;
278   UINT32 size = thisptr->rom_size - 0x100000;
275279   while(thisptr->decomp_offset >= size)
276280   {
277281      thisptr->decomp_offset -= size;
r8081r8082
863867   UINT64 rtc_offset;
864868
865869   UINT8 rtc_ram[16];   // 0-12 secs, min, hrs, etc.; 13-14-15 control registers
870   
871   UINT32 size;
866872} _snes_spc7110_t;
867873
868874static _snes_spc7110_t snes_spc7110;
869875
870876static void spc7110_init(running_machine* machine)
871877{
878   snes_state *state = (snes_state *)machine->driver_data;
879
872880   snes_spc7110.r4801 = 0x00;
873881   snes_spc7110.r4802 = 0x00;
874882   snes_spc7110.r4803 = 0x00;
r8081r8082
921929   snes_spc7110.r4840 = 0x00;
922930   snes_spc7110.r4841 = 0x00;
923931   snes_spc7110.r4842 = 0x00;
924
925   snes_spc7110.decomp = SPC7110Decomp_ctor(machine);
932   
933   snes_spc7110.size = state->cart_size;   
934   
935   snes_spc7110.decomp = SPC7110Decomp_ctor(machine, snes_spc7110.size);
926936}
927937
928938static void spc7110rtc_init(running_machine* machine)
r8081r8082
940950
941951static UINT32 spc7110_datarom_addr(UINT32 addr)
942952{
943   UINT32 size = snes_rom_size - 0x100000;
953   UINT32 size = snes_spc7110.size - 0x100000;
944954   while(addr >= size)
945955   {
946956      addr -= size;
src/mame/machine/snesbsx.c
r0r8082
1/***************************************************************************
2
3  snesbsx.c
4
5  File to handle emulation of the SNES "BS-X Satellaview".
6
7  Based on byuu's research.
8 
9  TODO: basically everything. The hardware can dynamically remap where
10  the memory handlers read/write (this will probably require some more
11  rethinking of the way we use snes_ram), see bsx_update_memory_map
12
13***************************************************************************/
14
15
16enum
17{
18   SNES_BSX_CARTROM = 0,
19   SNES_BSX_PRAM,
20   SNES_BSX_FLASH
21};
22
23
24struct _snes_bsx_state
25{
26   // base regs
27   // we don't emulate the base unit yet
28
29   // cart regs
30    UINT8 cart_regs[16];
31
32   // flash regs
33    UINT32 command;
34    UINT8 write_old;
35    UINT8 write_new;
36   
37    int flash_enable;
38    int read_enable;
39    int write_enable;
40   
41   UINT8 *pram;
42   int ram_source;
43};
44
45static struct _snes_bsx_state  bsx_state;
46
47
48static void bsx_update_memory_map(void)
49{
50   bsx_state.ram_source = BIT(bsx_state.cart_regs[0x01], 7) ? SNES_BSX_PRAM : SNES_BSX_FLASH;
51//   UINT8 *RAM = (bsx_state.cart_regs[0x01] & 0x80) == 0x00 ? memory_region(space->machine, "flash") : bsx_state.pram;
52   
53   logerror("BSX: updated memory map, current RAM: %d", bsx_state.ram_source);
54   if (!BIT(bsx_state.cart_regs[0x02], 7))
55   {
56      //LoROM mapping
57      // 0x00-0x7d:0x8000-0xfff -> RAM (either flash or pram)
58      // 0x80-0xff:0x8000-0xfff -> RAM
59   }
60   else
61   {
62      //HiROM mapping
63      // 0x00-0x3f:0x8000-0xfff -> RAM - 'shadowed'
64      // 0x40-0x7d:0x0000-0xfff -> RAM
65      // 0x80-0xbf:0x8000-0xfff -> RAM - 'shadowed'
66      // 0xc0-0xff:0x0000-0xfff -> RAM
67   }
68   
69   if (BIT(bsx_state.cart_regs[0x03], 7))
70   {
71      // 0x60-0x6f:0x0000-0xffff -> PRAM
72   }
73
74   if (!BIT(bsx_state.cart_regs[0x05], 7))
75   {
76      // 0x40-0x4f:0x0000-0xffff -> PRAM
77   }
78   
79   if (!BIT(bsx_state.cart_regs[0x06], 7))
80   {
81      // 0x50-0x5f:0x0000-0xffff -> PRAM
82   }
83   
84   if (BIT(bsx_state.cart_regs[0x07], 7))
85   {
86      // 0x00-0x1f:0x8000-0xffff -> CART
87   }
88   
89   if (BIT(bsx_state.cart_regs[0x08], 7))
90   {
91      // 0x80-0x9f:0x8000-0xffff -> CART
92   }
93   
94   // 0x20-0x3f:0x6000-0x7fff -> PRAM
95   // 0x70-0x77:0x0000-0xffff -> PRAM
96}
97
98static READ8_HANDLER( bsx_read )
99{
100   if ((offset & 0xf0ffff) == 0x005000)
101   { 
102      //$[00-0f]:5000 MMIO
103      UINT8 n = (offset >> 16) & 0x0f;
104      return bsx_state.cart_regs[n];
105   }
106   
107   if ((offset & 0xf8f000) == 0x105000)
108   { 
109      //$[10-17]:[5000-5fff] SRAM
110      return bsx_state.pram[((offset >> 16) & 7) * 0x1000 + (offset & 0xfff)];
111   }
112   
113   return 0x00;
114}
115
116
117static WRITE8_HANDLER( bsx_write )
118{
119   if ((offset & 0xf0ffff) == 0x005000)
120   { 
121      //$[00-0f]:5000 MMIO
122      UINT8 n = (offset >> 16) & 0x0f;
123      bsx_state.cart_regs[n] = data;
124      if ((n == 0x0e) && (data & 0x80))
125         bsx_update_memory_map();
126   }
127   
128   if ((offset & 0xf8f000) == 0x105000)
129   { 
130      //$[10-17]:[5000-5fff] SRAM
131      bsx_state.pram[((offset >> 16) & 7) * 0x1000 + (offset & 0xfff)] = data;
132   }
133}
134
135static void bsx_init( running_machine *machine )
136{
137   
138   memset(bsx_state.cart_regs, 0, ARRAY_LENGTH(bsx_state.cart_regs));
139   
140   bsx_state.cart_regs[0x07] = 0x80;
141   bsx_state.cart_regs[0x08] = 0x80;
142   
143   bsx_state.pram = auto_alloc_array(machine, UINT8, 0x80000);
144   
145   bsx_update_memory_map();
146   // saves
147}
148
149#ifdef UNUSED_FUNCTION
150static READ8_HANDLER( bsx_flash_read )
151{
152   UINT8 *FLASH = memory_region(space->machine, "flash");
153
154   if (offset == 0x0002)
155   {
156      if (bsx_state.flash_enable)
157         return 0x80;
158   }
159   
160   if (offset == 0x5555)
161   {
162      if (bsx_state.flash_enable)
163         return 0x80;
164   }
165   
166   if (bsx_state.read_enable && offset >= 0xff00 && offset <= 0xff13)
167   {
168      //read flash cartridge vendor information
169      switch(offset - 0xff00)
170      {
171         case 0x00: return 0x4d;
172         case 0x01: return 0x00;
173         case 0x02: return 0x50;
174         case 0x03: return 0x00;
175         case 0x04: return 0x00;
176         case 0x05: return 0x00;
177         case 0x06: return 0x2a;  //0x2a = 8mbit, 0x2b = 16mbit (not known to exist, though BIOS recognizes ID)
178         case 0x07: return 0x00;
179         default:   return 0x00;
180      }
181   }
182   
183   return FLASH[offset];
184}
185
186static WRITE8_HANDLER( bsx_flash_write )
187{
188   if ((offset & 0xff0000) == 0)
189   {
190      bsx_state.write_old = bsx_state.write_new;
191      bsx_state.write_new = data;
192     
193      if (bsx_state.write_enable && bsx_state.write_old == bsx_state.write_new)
194      {
195//         currently we have the flashcart loaded in a rom_region -> we cannot write yet
196      }
197   }
198   else
199   {
200      if (bsx_state.write_enable)
201      {
202         //         currently we have the flashcart loaded in a rom_region -> we cannot write yet
203      }
204   }
205   
206   if (offset == 0x0000)
207   {
208      bsx_state.command <<= 8;
209      bsx_state.command |= data;
210     
211      if ((bsx_state.command & 0xffff) == 0x38d0)
212      {
213         bsx_state.flash_enable = 1;
214         bsx_state.read_enable  = 1;
215      }
216   }
217   
218   if (offset == 0x2aaa)
219   {
220      bsx_state.command <<= 8;
221      bsx_state.command |= data;
222   }
223   
224   if (offset == 0x5555)
225   {
226      bsx_state.command <<= 8;
227      bsx_state.command |= data;
228     
229      if ((bsx_state.command & 0xffffff) == 0xaa5570)
230      {
231         bsx_state.write_enable = 0;
232      }
233     
234      if ((bsx_state.command & 0xffffff) == 0xaa55a0)
235      {
236         bsx_state.write_old = 0x00;
237         bsx_state.write_new = 0x00;
238         bsx_state.flash_enable = 1;
239         bsx_state.write_enable = 1;
240      }
241     
242      if ((bsx_state.command & 0xffffff) == 0xaa55f0)
243      {
244         bsx_state.flash_enable = 0;
245         bsx_state.read_enable  = 0;
246         bsx_state.write_enable = 0;
247      }
248   }
249}
250
251#endif
252
src/mame/machine/snes.c
r8081r8082
2626/* -- Globals -- */
2727UINT8  *snes_ram = NULL;      /* 65816 ram */
2828
29UINT8 snes_has_addon_chip;
30UINT32 snes_rom_size;
31
3229static void snes_dma(const address_space *space, UINT8 channels);
3330static void snes_hdma_init(const address_space *space);
3431static void snes_hdma(const address_space *space);
r8081r8082
4946#include "machine/snessdd1.c"
5047#include "machine/snes7110.c"
5148#include "machine/snesst10.c"
49#include "machine/snesbsx.c"
5250
5351/*************************************
5452
r8081r8082
435433      return spc_port_out(state->spc700, offset & 0x3);
436434   }
437435
438   if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
436   if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
439437   {
440438      if (offset >= 0x3000 && offset < 0x3300)
441439      {
442440         return superfx_mmio_read(state->superfx, offset);
443441      }
444442   }
445   else if (snes_has_addon_chip == HAS_RTC)
443   else if (state->has_addon_chip == HAS_RTC)
446444   {
447445      if (offset == 0x2800 || offset == 0x2801)
448446      {
449447         return srtc_read(space, offset);
450448      }
451449   }
452   else if (snes_has_addon_chip == HAS_SDD1)
450   else if (state->has_addon_chip == HAS_SDD1)
453451   {
454452      if (offset >= 0x4800 && offset < 0x4808)
455453      {
r8081r8082
460458         offset += 0x4300;
461459      }
462460   }
463   else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
461   else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)
464462   {
465      UINT16 limit = (snes_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
463      UINT16 limit = (state->has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
466464      if (offset >= 0x4800 && offset <= limit)
467465      {
468466         return spc7110_mmio_read(space, offset);
r8081r8082
578576      return;
579577   }
580578
581   if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
579   if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
582580   {
583581      if (offset >= 0x3000 && offset < 0x3300)
584582      {
r8081r8082
586584         return;
587585      }
588586   }
589   else if (snes_has_addon_chip == HAS_RTC)
587   else if (state->has_addon_chip == HAS_RTC)
590588   {
591589      if (offset == 0x2800 || offset == 0x2801)
592590      {
r8081r8082
594592         return;
595593      }
596594   }
597   else if (snes_has_addon_chip == HAS_SDD1)
595   else if (state->has_addon_chip == HAS_SDD1)
598596   {
599597      if ((offset >= 0x4300 && offset < 0x4380) ||
600598         (offset >= 0x4800 && offset < 0x4808))
r8081r8082
607605         offset += 0x4300;
608606      }
609607   }
610   else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
608   else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)
611609   {
612      UINT16 limit = (snes_has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
610      UINT16 limit = (state->has_addon_chip == HAS_SPC7110_RTC) ? 0x4842 : 0x483f;
613611      if (offset >= 0x4800 && offset <= limit)
614612      {
615613         spc7110_mmio_write(space->machine, (UINT32)offset, data);
r8081r8082
918916   if (address < 0x2000)                                 /* Mirror of Low RAM */
919917      value = memory_read_byte(space, 0x7e0000 + address);
920918   else if (address < 0x6000)                              /* I/O */
921      value = snes_r_io(space, address);
919   {
920      if (state->cart[0].mode == SNES_MODE_BSX && address >= 0x5000)
921         value = bsx_read(space, offset);
922      else
923         value = snes_r_io(space, address);
924   }
922925   else if (address < 0x8000)
923926   {
924      if (snes_has_addon_chip == HAS_SUPERFX && state->superfx !=NULL)
927      if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
925928      {
926929         if (superfx_access_ram(state->superfx))
927930            value = snes_ram[0xf00000 + (offset & 0x1fff)];   // here it should be 0xe00000 but there are mirroring issues
928931         else
929932            value = snes_open_bus_r(space, 0);
930933      }
931      else if (snes_has_addon_chip == HAS_OBC1)
934      else if (state->has_addon_chip == HAS_OBC1)
932935         value = obc1_read(space, offset);
933      else if ((snes_cart.mode == SNES_MODE_21) && (snes_has_addon_chip == HAS_DSP1) && (offset < 0x100000))
936      else if ((state->cart[0].mode == SNES_MODE_21) && (state->has_addon_chip == HAS_DSP1) && (offset < 0x100000))
934937         value = (address < 0x7000) ? dsp1_get_dr() : dsp1_get_sr();
935      else if (snes_has_addon_chip == HAS_CX4)
938      else if (state->has_addon_chip == HAS_CX4)
936939         value = CX4_read(address - 0x6000);
937      else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
940      else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)
938941      {
939942         if (offset < 0x10000)
940943            value = snes_ram[0x306000 + (offset & 0x1fff)];
r8081r8082
945948         value = snes_open_bus_r(space, 0);                        /* Reserved */
946949      }
947950   }
948   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
951   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
949952      value = (address < 0xc000) ? dsp1_get_dr() : dsp1_get_sr();
950   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
953   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
951954      value = (address < 0xc000) ? dsp2_dr_read() : dsp2_sr_read();
952   else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
955   else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
953956      value = dsp3_read(address);
954957   else
955958      value = snes_ram[offset];
r8081r8082
970973   if (address < 0x2000)                                 /* Mirror of Low RAM */
971974      value = memory_read_byte(space, 0x7e0000 + address);
972975   else if (address < 0x6000)                              /* I/O */
973      value = snes_r_io(space, address);
976   {
977      if (state->cart[0].mode == SNES_MODE_BSX && address >= 0x5000)
978         value = bsx_read(space, 0x300000 + offset);
979      else
980         value = snes_r_io(space, address);
981   }
974982   else if (address < 0x8000)                              /* SRAM for mode_21, Reserved othewise */
975983   {
976      if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
984      if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
977985      {
978986         if (superfx_access_ram(state->superfx))
979987            value = snes_ram[0xf00000 + (offset & 0x1fff)];   // here it should be 0xe00000 but there are mirroring issues
980988         else
981989            value = snes_open_bus_r(space, 0);
982990      }
983      else if (snes_has_addon_chip == HAS_OBC1)
991      else if (state->has_addon_chip == HAS_OBC1)
984992         value = obc1_read (space, offset);
985      else if (snes_has_addon_chip == HAS_CX4)
993      else if (state->has_addon_chip == HAS_CX4)
986994         value = CX4_read(address - 0x6000);
987      else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
995      else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)
988996      {
989997         if (offset < 0x10000)
990998            value = snes_ram[0x306000 + (offset & 0x1fff)];
991999      }
992      else if ((snes_cart.mode == SNES_MODE_21) && (snes_cart.sram > 0))
1000      else if ((state->cart[0].mode == SNES_MODE_21) && (state->cart[0].sram > 0))
9931001      {
994         int mask = (snes_cart.sram - 1) | 0xff0000;   /* Limit SRAM size to what's actually present */
1002         int mask = (state->cart[0].sram - 1) | 0xff0000;   /* Limit SRAM size to what's actually present */
9951003         value = snes_ram[0x300000 + (offset & mask)];
9961004      }
9971005      else
r8081r8082
10011009      }
10021010   }
10031011   /* some dsp1 games use these banks 0x30 to 0x3f at address 0x8000 */
1004   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1))
1012   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1))
10051013      value = (address < 0xc000) ? dsp1_get_dr() : dsp1_get_sr();
1006   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2))
1014   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2))
10071015      value = (address < 0xc000) ? dsp2_dr_read() : dsp2_sr_read();
1008   else if (snes_has_addon_chip == HAS_DSP3)
1016   else if (state->has_addon_chip == HAS_DSP3)
10091017      value = dsp3_read(address);
1010   else if (snes_has_addon_chip == HAS_DSP4)
1018   else if (state->has_addon_chip == HAS_DSP4)
10111019      value = (address < 0xc000) ? dsp4_read() : 0x80;
10121020   else
10131021      value = snes_ram[0x300000 + offset];
r8081r8082
10251033   UINT8 value = 0xff;
10261034   UINT16 address = offset & 0xffff;
10271035
1028   if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
1036   if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
10291037   {
10301038      if (superfx_access_rom(state->superfx))
10311039         value = snes_ram[0x400000 + offset];
r8081r8082
10381046         return sfx_data[offset & 0x0f];
10391047      }
10401048   }
1041   else if ((snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC))
1049   else if ((state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC))
10421050   {
10431051      if (offset >= 0x100000 && offset < 0x110000)
10441052         value = spc7110_mmio_read(space, 0x4800);
10451053   }
1046   else if ((snes_cart.mode & 5) && !(snes_has_addon_chip == HAS_SUPERFX))   /* Mode 20 & 22 */
1054   else if ((state->cart[0].mode & 5) && !(state->has_addon_chip == HAS_SUPERFX))   /* Mode 20 & 22 */
10471055   {
1048      if ((address < 0x8000) && (snes_cart.mode == SNES_MODE_20))
1056      if ((address < 0x8000) && (state->cart[0].mode == SNES_MODE_20))
10491057         value = snes_open_bus_r(space, 0);                     /* Reserved */
10501058      else
10511059         value = snes_ram[0x400000 + offset];
r8081r8082
10661074   UINT8 value = 0xff;
10671075   UINT16 address = offset & 0xffff;
10681076
1069   if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
1077   if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
10701078   {
10711079      if (superfx_access_ram(state->superfx))
10721080         value = snes_ram[0xe00000 + offset];
10731081      else
10741082         value = snes_open_bus_r(space, 0);
10751083   }
1076   else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x80000 && address < 0x1000)
1084   else if (state->has_addon_chip == HAS_ST010 && offset >= 0x80000 && address < 0x1000)
10771085      value = st010_read(address);
1078   else if (snes_cart.mode & 5)                     /* Mode 20 & 22 */
1086   else if (state->cart[0].mode & 5)                     /* Mode 20 & 22 */
10791087   {
10801088      if (address >= 0x8000)
10811089         value = snes_ram[0x600000 + offset];
10821090      /* some other dsp1 games use these banks 0x60 to 0x6f at address 0x0000 */
1083      else if (snes_has_addon_chip == HAS_DSP1)
1091      else if (state->has_addon_chip == HAS_DSP1)
10841092         value = (address >= 0x4000) ? dsp1_get_sr() : dsp1_get_dr();
10851093      else
10861094      {
r8081r8082
10881096         value = snes_open_bus_r(space, 0);                     /* Reserved */
10891097      }
10901098   }
1091   else if (snes_cart.mode & 0x0a)               /* Mode 21 & 25 */
1099   else if (state->cart[0].mode & 0x0a)               /* Mode 21 & 25 */
10921100      value = snes_ram[0x600000 + offset];
10931101
10941102   if(!space->debugger_access)
r8081r8082
11041112   UINT8 value;
11051113   UINT16 address = offset & 0xffff;
11061114
1107   if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
1115   if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
11081116   {
11091117      if (superfx_access_ram(state->superfx))
11101118         value = snes_ram[0xf00000 + offset];
11111119      else
11121120         value = snes_open_bus_r(space, 0);
11131121   }
1114   else if ((snes_cart.mode & 5) && (address < 0x8000))      /* Mode 20 & 22 */
1122   else if ((state->cart[0].mode & 5) && (address < 0x8000))      /* Mode 20 & 22 */
11151123   {
1116      if (snes_cart.sram > 0)
1124      if (state->cart[0].sram > 0)
11171125      {
1118         int mask = (snes_cart.sram - 1) | 0xff0000;   /* Limit SRAM size to what's actually present */
1126         int mask = (state->cart[0].sram - 1) | 0xff0000;   /* Limit SRAM size to what's actually present */
11191127         value = snes_ram[0x700000 + (offset & mask)];
11201128      }
11211129      else
r8081r8082
11361144/* 0x800000 - 0xbfffff */
11371145READ8_HANDLER( snes_r_bank6 )
11381146{
1147   snes_state *state = (snes_state *)space->machine->driver_data;
11391148   UINT8 value = 0;
11401149   UINT16 address = offset & 0xffff;
11411150
1142   if (snes_has_addon_chip == HAS_SUPERFX)
1151   if (state->has_addon_chip == HAS_SUPERFX)
11431152      value = memory_read_byte(space, offset);
11441153   else if (address < 0x8000)
11451154   {
1146      if (snes_cart.mode != SNES_MODE_25)
1155      if (state->cart[0].mode != SNES_MODE_25)
11471156         value = memory_read_byte(space, offset);
1148      else if ((snes_has_addon_chip == HAS_CX4) && (address >= 0x6000))
1157      else if ((state->has_addon_chip == HAS_CX4) && (address >= 0x6000))
11491158         value = CX4_read(address - 0x6000);
11501159      else                     /* Mode 25 has SRAM not mirrored from lower banks */
11511160      {
11521161         if (address < 0x6000)
11531162            value = memory_read_byte(space, offset);
1154         else if ((offset >= 0x300000) && (snes_cart.sram > 0))
1163         else if ((offset >= 0x300000) && (state->cart[0].sram > 0))
11551164         {
1156            int mask = (snes_cart.sram - 1) | 0xff0000;   /* Limit SRAM size to what's actually present */
1165            int mask = (state->cart[0].sram - 1) | 0xff0000;   /* Limit SRAM size to what's actually present */
11571166            value = snes_ram[0x800000 + (offset & mask)];
11581167         }
11591168         else                  /* Area 0x6000-0x8000 with offset < 0x300000 is reserved */
r8081r8082
11631172         }
11641173      }
11651174   }
1166   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
1175   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
11671176      value = (address < 0xc000) ? dsp1_get_dr() : dsp1_get_sr();
1168   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
1177   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
11691178      value = (address < 0xc000) ? dsp2_dr_read() : dsp2_sr_read();
1170   else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
1179   else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
11711180      value = dsp3_read(address);
1172   else if ((snes_has_addon_chip == HAS_DSP4) && (offset >= 0x300000))
1181   else if ((state->has_addon_chip == HAS_DSP4) && (offset >= 0x300000))
11731182      value = (address < 0xc000) ? dsp4_read() : 0x80;
11741183   else
11751184      value = snes_ram[0x800000 + offset];
r8081r8082
11871196   UINT8 value = 0;
11881197   UINT16 address = offset & 0xffff;
11891198
1190   if (snes_has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
1199   if (state->has_addon_chip == HAS_SUPERFX && state->superfx != NULL)
11911200   {
11921201      if (offset < 0x200000)   // ROM
11931202      {
r8081r8082
12111220            value = snes_open_bus_r(space, 0);
12121221      }
12131222   }
1214   else if ((snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC) && offset >= 0x100000)
1223   else if ((state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC) && offset >= 0x100000)
12151224      value = spc7110_bank7_read(space, offset);
1216   else if (snes_has_addon_chip == HAS_SDD1)
1225   else if (state->has_addon_chip == HAS_SDD1)
12171226      value = sdd1_read(space->machine, offset);
1218   else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x280000 && offset < 0x300000 && address < 0x1000)
1227   else if (state->has_addon_chip == HAS_ST010 && offset >= 0x280000 && offset < 0x300000 && address < 0x1000)
12191228      value = st010_read(address);
1220   else if ((snes_cart.mode & 5) && !(snes_has_addon_chip == HAS_SUPERFX))      /* Mode 20 & 22 */
1229   else if ((state->cart[0].mode & 5) && !(state->has_addon_chip == HAS_SUPERFX))      /* Mode 20 & 22 */
12211230   {
12221231      if (address < 0x8000)
12231232         value = memory_read_byte(space, 0x400000 + offset);
r8081r8082
12371246/* 0x000000 - 0x2fffff */
12381247WRITE8_HANDLER( snes_w_bank1 )
12391248{
1249   snes_state *state = (snes_state *)space->machine->driver_data;
12401250   UINT16 address = offset & 0xffff;
12411251
12421252   if (address < 0x2000)                     /* Mirror of Low RAM */
12431253      memory_write_byte(space, 0x7e0000 + address, data);
12441254   else if (address < 0x6000)                  /* I/O */
1245      snes_w_io(space, address, data);
1255   {
1256      if (state->cart[0].mode == SNES_MODE_BSX && address >= 0x5000)
1257         bsx_write(space, offset, data);
1258      else
1259         snes_w_io(space, address, data);
1260   }
12461261   else if (address < 0x8000)
12471262   {
1248      if (snes_has_addon_chip == HAS_SUPERFX)
1263      if (state->has_addon_chip == HAS_SUPERFX)
12491264         snes_ram[0xf00000 + (offset & 0x1fff)] = data;   // here it should be 0xe00000 but there are mirroring issues
1250      else if (snes_has_addon_chip == HAS_OBC1)
1265      else if (state->has_addon_chip == HAS_OBC1)
12511266         obc1_write(space, offset, data);
1252      else if ((snes_cart.mode == SNES_MODE_21) && (snes_has_addon_chip == HAS_DSP1) && (offset < 0x100000))
1267      else if ((state->cart[0].mode == SNES_MODE_21) && (state->has_addon_chip == HAS_DSP1) && (offset < 0x100000))
12531268         dsp1_set_dr(data);
1254      else if (snes_has_addon_chip == HAS_CX4)
1269      else if (state->has_addon_chip == HAS_CX4)
12551270         CX4_write(space->machine, address - 0x6000, data);
1256      else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
1271      else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)
12571272      {
12581273         if (offset < 0x10000)
12591274            snes_ram[0x306000 + (offset & 0x1fff)] = data;
r8081r8082
12611276      else
12621277         logerror("snes_w_bank1: Attempt to write to reserved address: %x = %02x\n", offset, data);
12631278   }
1264   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
1279   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
12651280      dsp1_set_dr(data);
1266   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
1281   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
12671282   {
12681283      if (address < 0xc000)
12691284         dsp2_dr_write(data);
12701285      else
12711286         dsp2_sr_write(data);
12721287   }
1273   else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
1288   else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
12741289      dsp3_write(address, data);
12751290   else
12761291      logerror( "(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset );
r8081r8082
12821297/* 0x300000 - 0x3fffff */
12831298WRITE8_HANDLER( snes_w_bank2 )
12841299{
1300   snes_state *state = (snes_state *)space->machine->driver_data;
12851301   UINT16 address = offset & 0xffff;
12861302
12871303   if (address < 0x2000)                     /* Mirror of Low RAM */
12881304      memory_write_byte(space, 0x7e0000 + address, data);
12891305   else if (address < 0x6000)                  /* I/O */
1290      snes_w_io(space, address, data);
1306   {
1307      if (state->cart[0].mode == SNES_MODE_BSX && address >= 0x5000)
1308         bsx_write(space, 0x300000 + offset, data);
1309      else
1310         snes_w_io(space, address, data);
1311   }
12911312   else if (address < 0x8000)                  /* SRAM for mode_21, Reserved othewise */
12921313   {
1293      if (snes_has_addon_chip == HAS_SUPERFX)
1314      if (state->has_addon_chip == HAS_SUPERFX)
12941315         snes_ram[0xf00000 + (offset & 0x1fff)] = data;   // here it should be 0xe00000 but there are mirroring issues
1295      else if (snes_has_addon_chip == HAS_OBC1)
1316      else if (state->has_addon_chip == HAS_OBC1)
12961317         obc1_write(space, offset, data);
1297      else if (snes_has_addon_chip == HAS_CX4)
1318      else if (state->has_addon_chip == HAS_CX4)
12981319         CX4_write(space->machine, address - 0x6000, data);
1299      else if (snes_has_addon_chip == HAS_SPC7110 || snes_has_addon_chip == HAS_SPC7110_RTC)
1320      else if (state->has_addon_chip == HAS_SPC7110 || state->has_addon_chip == HAS_SPC7110_RTC)
13001321      {
13011322         if (offset < 0x10000)
13021323            snes_ram[0x306000 + (offset & 0x1fff)] = data;
13031324      }
1304      else if ((snes_cart.mode == SNES_MODE_21) && (snes_cart.sram > 0))
1325      else if ((state->cart[0].mode == SNES_MODE_21) && (state->cart[0].sram > 0))
13051326      {
1306         int mask = (snes_cart.sram - 1) | 0xff0000;   /* Limit SRAM size to what's actually present */
1327         int mask = (state->cart[0].sram - 1) | 0xff0000;   /* Limit SRAM size to what's actually present */
13071328         snes_ram[0x300000 + (offset & mask)] = data;
13081329      }
13091330      else
13101331         logerror("snes_w_bank2: Attempt to write to reserved address: %X = %02x\n", offset + 0x300000, data);
13111332   }
13121333   /* some dsp1 games use these banks 0x30 to 0x3f at address 0x8000 */
1313   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1))
1334   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1))
13141335      dsp1_set_dr(data);
1315   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2))
1336   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2))
13161337   {
13171338      if (address < 0xc000)
13181339         dsp2_dr_write(data);
13191340      else
13201341         dsp2_sr_write(data);
13211342   }
1322   else if (snes_has_addon_chip == HAS_DSP3)
1343   else if (state->has_addon_chip == HAS_DSP3)
13231344      dsp3_write(address, data);
1324   else if ((snes_has_addon_chip == HAS_DSP4) && (address < 0xc000))
1345   else if ((state->has_addon_chip == HAS_DSP4) && (address < 0xc000))
13251346      dsp4_write(data);
13261347   else
13271348      logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x300000);
r8081r8082
13331354/* 0x600000 - 0x6fffff */
13341355WRITE8_HANDLER( snes_w_bank4 )
13351356{
1357   snes_state *state = (snes_state *)space->machine->driver_data;
13361358   UINT16 address = offset & 0xffff;
13371359
1338   if (snes_has_addon_chip == HAS_SUPERFX)
1360   if (state->has_addon_chip == HAS_SUPERFX)
13391361      snes_ram[0xe00000 + offset] = data;
1340   else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x80000 && address < 0x1000)
1362   else if (state->has_addon_chip == HAS_ST010 && offset >= 0x80000 && address < 0x1000)
13411363      st010_write(address, data);
1342   else if (snes_cart.mode & 5)               /* Mode 20 & 22 */
1364   else if (state->cart[0].mode & 5)               /* Mode 20 & 22 */
13431365   {
13441366      if (address >= 0x8000)
13451367         logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x600000);
1346      else if (snes_has_addon_chip == HAS_DSP1)
1368      else if (state->has_addon_chip == HAS_DSP1)
13471369         dsp1_set_dr(data);
13481370      else
13491371         logerror("snes_w_bank4: Attempt to write to reserved address: %X = %02x\n", offset + 0x600000, data);
13501372   }
1351   else if (snes_cart.mode & 0x0a)
1373   else if (state->cart[0].mode & 0x0a)
13521374      logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x600000);
13531375
13541376   if(!space->debugger_access)
r8081r8082
13581380/* 0x700000 - 0x7dffff */
13591381WRITE8_HANDLER( snes_w_bank5 )
13601382{
1383   snes_state *state = (snes_state *)space->machine->driver_data;
13611384   UINT16 address = offset & 0xffff;
13621385
1363   if (snes_has_addon_chip == HAS_SUPERFX)
1386   if (state->has_addon_chip == HAS_SUPERFX)
13641387      snes_ram[0xf00000 + offset] = data;
1365   else if ((snes_cart.mode & 5) && (address < 0x8000))         /* Mode 20 & 22 */
1388   else if ((state->cart[0].mode & 5) && (address < 0x8000))         /* Mode 20 & 22 */
13661389   {
1367      if (snes_cart.sram > 0)
1390      if (state->cart[0].sram > 0)
13681391      {
1369         int mask = (snes_cart.sram - 1) | 0xff0000;   /* Limit SRAM size to what's actually present */
1392         int mask = (state->cart[0].sram - 1) | 0xff0000;   /* Limit SRAM size to what's actually present */
13701393         snes_ram[0x700000 + (offset & mask)] = data;
13711394      }
13721395      else
13731396         logerror("snes_w_bank5: Attempt to write to reserved address: %X = %02x\n", offset + 0x700000, data);
13741397   }
1375   else if (snes_cart.mode & 0x0a)
1398   else if (state->cart[0].mode & 0x0a)
13761399      logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x700000);
13771400
13781401   if(!space->debugger_access)
r8081r8082
13831406/* 0x800000 - 0xbfffff */
13841407WRITE8_HANDLER( snes_w_bank6 )
13851408{
1409   snes_state *state = (snes_state *)space->machine->driver_data;
13861410   UINT16 address = offset & 0xffff;
13871411
1388   if (snes_has_addon_chip == HAS_SUPERFX)
1412   if (state->has_addon_chip == HAS_SUPERFX)
13891413      memory_write_byte(space, offset, data);
13901414   else if (address < 0x8000)
13911415   {
1392      if ((snes_has_addon_chip == HAS_CX4) && (address >= 0x6000))
1416      if ((state->has_addon_chip == HAS_CX4) && (address >= 0x6000))
13931417         CX4_write(space->machine, address - 0x6000, data);
1394      else if (snes_cart.mode != SNES_MODE_25)
1418      else if (state->cart[0].mode != SNES_MODE_25)
13951419         memory_write_byte(space, offset, data);
13961420      else   /* Mode 25 has SRAM not mirrored from lower banks */
13971421      {
13981422         if (address < 0x6000)
13991423            memory_write_byte(space, offset, data);
1400         else if ((offset >= 0x300000) && (snes_cart.sram > 0))
1424         else if ((offset >= 0x300000) && (state->cart[0].sram > 0))
14011425         {
1402            int mask = (snes_cart.sram - 1) | 0xff0000;   /* Limit SRAM size to what's actually present */
1426            int mask = (state->cart[0].sram - 1) | 0xff0000;   /* Limit SRAM size to what's actually present */
14031427            snes_ram[0x800000 + (offset & mask)] = data;
14041428         }
14051429         else   /* Area in 0x6000-0x8000 && offset < 0x300000 is Reserved! */
14061430            logerror("snes_w_bank6: Attempt to write to reserved address: %X = %02x\n", offset + 0x800000, data);
14071431      }
14081432   }
1409   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
1433   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP1) && (offset >= 0x200000))
14101434      dsp1_set_dr(data);
1411   else if ((snes_cart.mode == SNES_MODE_20) && (snes_has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
1435   else if ((state->cart[0].mode == SNES_MODE_20) && (state->has_addon_chip == HAS_DSP2) && (offset >= 0x200000))
14121436   {
14131437      if (address < 0xc000)
14141438         dsp2_dr_write(data);
14151439      else
14161440         dsp2_sr_write(data);
14171441   }
1418   else if ((snes_has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
1442   else if ((state->has_addon_chip == HAS_DSP3) && (offset >= 0x200000))
14191443      dsp3_write(address, data);
1420   else if ((snes_has_addon_chip == HAS_DSP4) && (offset >= 0x300000) && (address < 0xc000))
1444   else if ((state->has_addon_chip == HAS_DSP4) && (offset >= 0x300000) && (address < 0xc000))
14211445      dsp4_write(data);
14221446   else
14231447      logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0x800000);
r8081r8082
14301454/* 0xc00000 - 0xffffff */
14311455WRITE8_HANDLER( snes_w_bank7 )
14321456{
1457   snes_state *state = (snes_state *)space->machine->driver_data;
14331458   UINT16 address = offset & 0xffff;
14341459
1435   if (snes_has_addon_chip == HAS_SUPERFX)
1460   if (state->has_addon_chip == HAS_SUPERFX)
14361461   {
14371462      if (offset >= 0x200000)
14381463      {
r8081r8082
14421467      else
14431468         logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0xc00000);
14441469   }
1445   else if (snes_has_addon_chip == HAS_ST010 && offset >= 0x280000 && offset < 0x300000 && address < 0x1000)
1470   else if (state->has_addon_chip == HAS_ST010 && offset >= 0x280000 && offset < 0x300000 && address < 0x1000)
14461471      st010_write(address, data);
1447   else if (snes_cart.mode & 5)            /* Mode 20 & 22 */
1472   else if (state->cart[0].mode & 5)            /* Mode 20 & 22 */
14481473   {
14491474      if (address < 0x8000)
14501475      {
r8081r8082
14581483      else
14591484         logerror("(PC=%06x) snes_w_bank7: Attempt to write to ROM address: %X = %02x\n",cpu_get_pc(space->cpu),offset + 0xc00000, data);
14601485   }
1461   else if (snes_cart.mode & 0x0a)
1486   else if (state->cart[0].mode & 0x0a)
14621487      logerror("(PC=%06x) Attempt to write to ROM address: %X\n",cpu_get_pc(space->cpu),offset + 0xc00000);
14631488
14641489   if(!space->debugger_access)
r8081r8082
16061631   snes_ram[WRIO] = 0xff;
16071632   snes_ram[VMAIN] = 0x80;
16081633
1609   switch (snes_has_addon_chip)
1634   switch (state->has_addon_chip)
16101635   {
16111636      case HAS_DSP1:
16121637         dsp1_init(machine);
r8081r8082
16831708   snes_ram[WRDIVL] = 0xff;
16841709   snes_ram[WRDIVH] = 0xff;
16851710
1686   switch (snes_has_addon_chip)
1711   switch (state->has_addon_chip)
16871712   {
16881713      case HAS_SDD1:
16891714         sdd1_init(machine);
r8081r8082
16991724         break;
17001725   }
17011726
1727   if (state->cart[0].mode == SNES_MODE_BSX)
1728      bsx_init(machine);
1729
17021730   snes_init_timers(machine);
17031731
17041732   for (i = 0; i < 6; i++)
r8081r8082
18071835/* for mame we use an init, maybe we will need more for the different games */
18081836DRIVER_INIT( snes )
18091837{
1838   snes_state *state = (snes_state *)machine->driver_data;
18101839   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
18111840   UINT16 total_blocks, read_blocks;
18121841   UINT8 *rom;
r8081r8082
18151844   snes_ram = auto_alloc_array_clear(machine, UINT8, 0x1400000);
18161845
18171846   /* all NSS games seem to use MODE 20 */
1818   snes_cart.mode = SNES_MODE_20;
1819   snes_cart.sram_max = 0x40000;
1820   snes_has_addon_chip = HAS_NONE;
1847   state->cart[0].mode = SNES_MODE_20;
1848   state->cart[0].sram_max = 0x40000;
1849   state->has_addon_chip = HAS_NONE;
18211850
18221851   /* Find the number of blocks in this ROM */
18231852   total_blocks = (memory_region_length(machine, "user3") / 0x8000);
r8081r8082
18611890   }
18621891
18631892   /* Find the amount of sram */
1864   snes_cart.sram = snes_r_bank1(space, 0x00ffd8);
1865   if (snes_cart.sram > 0)
1893   state->cart[0].sram = snes_r_bank1(space, 0x00ffd8);
1894   if (state->cart[0].sram > 0)
18661895   {
1867      snes_cart.sram = (1024 << snes_cart.sram);
1868      if (snes_cart.sram > snes_cart.sram_max)
1869         snes_cart.sram = snes_cart.sram_max;
1896      state->cart[0].sram = (1024 << state->cart[0].sram);
1897      if (state->cart[0].sram > state->cart[0].sram_max)
1898         state->cart[0].sram = state->cart[0].sram_max;
18701899   }
18711900}
18721901
18731902DRIVER_INIT( snes_hirom )
18741903{
1904   snes_state *state = (snes_state *)machine->driver_data;
18751905   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
18761906   UINT16 total_blocks, read_blocks;
18771907   UINT8  *rom;
r8081r8082
18801910   snes_ram = auto_alloc_array(machine, UINT8, 0x1400000);
18811911   memset(snes_ram, 0, 0x1400000);
18821912
1883   snes_cart.mode = SNES_MODE_21;
1884   snes_cart.sram_max = 0x40000;
1885   snes_has_addon_chip = HAS_NONE;
1913   state->cart[0].mode = SNES_MODE_21;
1914   state->cart[0].sram_max = 0x40000;
1915   state->has_addon_chip = HAS_NONE;
18861916
18871917   /* Find the number of blocks in this ROM */
18881918   total_blocks = (memory_region_length(machine, "user3") / 0x10000);
r8081r8082
19201950   }
19211951
19221952   /* Find the amount of sram */
1923   snes_cart.sram = snes_r_bank1(space, 0x00ffd8);
1924   if (snes_cart.sram > 0)
1953   state->cart[0].sram = snes_r_bank1(space, 0x00ffd8);
1954   if (state->cart[0].sram > 0)
19251955   {
1926      snes_cart.sram = (1024 << snes_cart.sram);
1927      if (snes_cart.sram > snes_cart.sram_max)
1928         snes_cart.sram = snes_cart.sram_max;
1956      state->cart[0].sram = (1024 << state->cart[0].sram);
1957      if (state->cart[0].sram > state->cart[0].sram_max)
1958         state->cart[0].sram = state->cart[0].sram_max;
19291959   }
19301960}
19311961
src/mame/includes/snes.h
r8081r8082
4343#define SNES_VTOTAL_PAL       312      /* Maximum number of lines for PAL systems */
4444#define SNES_HTOTAL           341      /* Maximum number pixels per line (incl. hblank) */
4545#define SNES_DMA_BASE         0x4300   /* Base DMA register address */
46#define SNES_MODE_20          0x1      /* Lo-ROM cart */
47#define SNES_MODE_21          0x2      /* Hi-ROM cart */
48#define SNES_MODE_22          0x4      /* Extended Lo-ROM cart - SDD-1 */
49#define SNES_MODE_25          0x8      /* Extended Hi-ROM cart */
46#define SNES_MODE_20          0x01      /* Lo-ROM cart */
47#define SNES_MODE_21          0x02      /* Hi-ROM cart */
48#define SNES_MODE_22          0x04      /* Extended Lo-ROM cart - SDD-1 */
49#define SNES_MODE_25          0x08      /* Extended Hi-ROM cart */
50#define SNES_MODE_BSX         0x10
51#define SNES_MODE_BSLO        0x20
52#define SNES_MODE_BSHI        0x40
53#define SNES_MODE_ST          0x80
5054#define SNES_NTSC             0x00
5155#define SNES_PAL              0x10
5256#define SNES_VRAM_SIZE        0x20000   /* 128kb of video ram */
r8081r8082
354358#define DSP_FIR_C6      0x6F
355359#define DSP_FIR_C7      0x7F
356360
361struct snes_cart_info
362{
363   UINT8  mode;      /* ROM memory mode */
364   UINT32 sram;      /* Amount of sram in cart */
365   UINT32 sram_max;   /* Maximum amount sram in cart (based on ROM mode) */
366   int    small_sram;
367   int    slot_in_use;   /* this is needed by Sufami Turbo slots (to check if SRAM has to be saved) */
368};
369
357370struct snes_joypad
358371{
359372   UINT16 buttons;
r8081r8082
437450   snes_io_read          io_read;
438451   snes_oldjoy_read      oldjoy1_read, oldjoy2_read;
439452
453   /* cart related */
454   UINT8 has_addon_chip;
455   UINT32 cart_size;
456   snes_cart_info cart[2];   // the second one is used by MESS for Sufami Turbo and, eventually, BS-X
457
440458   /* devices */
441459   running_device *maincpu;
442460   running_device *soundcpu;
r8081r8082
523541
524542WRITE_LINE_DEVICE_HANDLER( snes_extern_irq_w );
525543
526extern UINT8 snes_has_addon_chip;
527extern UINT32 snes_rom_size;
528544
529545extern void snes_latch_counters(running_machine *machine);
530546
r8081r8082
638654   UINT8 stat77_flags;
639655};
640656
641struct snes_cart_info
642{
643   UINT8  mode;      /* ROM memory mode */
644   UINT32 sram;      /* Amount of sram in cart */
645   UINT32 sram_max;   /* Maximum amount sram in cart (based on ROM mode) */
646   int    small_sram;
647};
648
649657extern struct snes_cart_info snes_cart;
650658
651659/*----------- defined in video/snes.c -----------*/
src/mess/messdriv.c
r8081r8082
6464   DRIVER( gbpocket )  /* Nintendo Game Boy Pocket Handheld    */
6565   DRIVER( gblight )   /* Nintendo Game Boy Light Handheld  */
6666   DRIVER( gbcolor )   /* Nintendo Game Boy Color Handheld  */
67   DRIVER( snes )     /* Nintendo Super Nintendo NTSC    */
68   DRIVER( snessfx )   /* Nintendo Super Nintendo NTSC, SuperFX    */
67   DRIVER( snes )      /* Nintendo Super Nintendo NTSC    */
6968   DRIVER( snespal )   /* Nintendo Super Nintendo PAL    */
70   DRIVER( snespsfx )   /* Nintendo Super Nintendo PAL, SuperFX  */
69   DRIVER( snessfx )   /* Nintendo Super Nintendo NTSC w/SuperFX CPU*/
70   DRIVER( snespsfx )   /* Nintendo Super Nintendo PAL w/SuperFX CPU */
71   DRIVER( snesst )   /* Nintendo Super Nintendo NTSC w/Sufami Turbo base cart */
72   DRIVER( snesbsx )   /* Nintendo Super Nintendo NTSC w/BS-X compatible cart  */
7173   DRIVER( sfcbox )   /* Nintendo Super Famicom Box      */
7274   DRIVER( n64 )      /* Nintendo N64   */
7375   DRIVER( pokemini )  /* Nintendo Pokemon Mini    */
src/mess/machine/geneve.c
r8081r8082
300300{
301301   cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-8);      /* this is just a minimum, it can be more */
302302
303   return tms5220_status_r(devtag_get_device(space->machine, "tms5220"), offset);
303   return tms5220_status_r(devtag_get_device(space->machine, "tmc0285"), offset);
304304}
305305
306306#if 0
307307
308308static void speech_kludge_callback(int dummy)
309309{
310   if (! tms5220_readyq_r(devtag_get_device(space->machine, "tms5220")))
310   if (! tms5220_readyq_r(devtag_get_device(space->machine, "tmc0285")))
311311   {
312312      /* Weirdly enough, we are always seeing some problems even though
313313        everything is working fine. */
r8081r8082
333333    there are 15 bytes in FIFO.  It should be 16.  Of course, if it were the
334334    case, we would need to store the value on the bus, which would be more
335335    complex. */
336   if (! tms5220_readyq_r(devtag_get_device(space->machine, "tms5220")))
336   if (! tms5220_readyq_r(devtag_get_device(space->machine, "tmc0285")))
337337   {
338      attotime time_to_ready = double_to_attotime(tms5220_time_to_ready(devtag_get_device(space->machine, "tms5220")));
338      attotime time_to_ready = double_to_attotime(tms5220_time_to_ready(devtag_get_device(space->machine, "tmc0285")));
339339      int cycles_to_ready = cputag_attotime_to_clocks(space->machine, "maincpu", time_to_ready);
340340
341341      logerror("time to ready: %f -> %d\n", attotime_to_double(time_to_ready), (int) cycles_to_ready);
r8081r8082
345345   }
346346#endif
347347
348   tms5220_data_w(devtag_get_device(space->machine, "tms5220"), offset, data);
348   tms5220_data_w(devtag_get_device(space->machine, "tmc0285"), offset, data);
349349}
350350
351351READ8_HANDLER ( geneve_r )
src/mess/machine/snescart.c
r8081r8082
1111#include "devices/cartslot.h"
1212#include "snescart.h"
1313
14
1514#define SNES_CART_DEBUG 0
1615
1716/****** Strings for Cart Header Logging ******/
r8081r8082
123122/* Loads the battery backed RAM into the appropriate memory area */
124123static void snes_load_sram(running_machine *machine)
125124{
125   snes_state *state = (snes_state *)machine->driver_data;
126126   UINT8 ii;
127127   UINT8 *battery_ram, *ptr;
128128
129   battery_ram = (UINT8*)malloc(snes_cart.sram_max);
129   battery_ram = (UINT8*)malloc(state->cart[0].sram_max);
130130   ptr = battery_ram;
131   image_battery_load(devtag_get_device(machine, "cart"), battery_ram, snes_cart.sram_max, 0xff);
131   image_battery_load(devtag_get_device(machine, "cart"), battery_ram, state->cart[0].sram_max, 0xff);
132132
133   if (snes_cart.mode == SNES_MODE_20)
133   if (state->cart[0].mode == SNES_MODE_20)
134134   {
135      UINT32 size = snes_cart.small_sram ? 0x8000 : 0x10000;
135      UINT32 size = state->cart[0].small_sram ? 0x8000 : 0x10000;
136136
137137      /* There could be some larger image needing banks 0x70 to 0x7f at address 0x8000 for ROM
138138         * mirroring. These should be treated separately or data would be overwritten by SRAM */
r8081r8082
145145         ptr += size;
146146      }
147147   }
148   else if (snes_cart.mode == SNES_MODE_21)
148   else if (state->cart[0].mode == SNES_MODE_21)
149149   {
150150      for (ii = 0; ii < 16; ii++)
151151      {
r8081r8082
156156         ptr += 0x2000;
157157      }
158158   }
159   else if (snes_cart.mode == SNES_MODE_25)
159   else if (state->cart[0].mode == SNES_MODE_25)
160160   {
161161      for (ii = 0; ii < 16; ii++)
162162      {
r8081r8082
171171/* Saves the battery backed RAM from the appropriate memory area */
172172static void snes_save_sram(running_machine *machine)
173173{
174   snes_state *state = (snes_state *)machine->driver_data;
174175   UINT8 ii;
175176   UINT8 *battery_ram, *ptr;
176177
177   battery_ram = (UINT8*)malloc(snes_cart.sram_max);
178   battery_ram = (UINT8*)malloc(state->cart[0].sram_max);
178179   ptr = battery_ram;
179180
180   if (snes_cart.mode == SNES_MODE_20)
181   if (state->cart[0].mode == SNES_MODE_20)
181182   {
182      UINT32 size = snes_cart.small_sram ? 0x8000 : 0x10000;
183      UINT32 size = state->cart[0].small_sram ? 0x8000 : 0x10000;
183184
184185      for (ii = 0; ii < 16; ii++)
185186      {
r8081r8082
187188         ptr += size;
188189      }
189190   }
190   else if (snes_cart.mode == SNES_MODE_21)
191   else if (state->cart[0].mode == SNES_MODE_21)
191192   {
192193      for (ii = 0; ii < 16; ii++)
193194      {
r8081r8082
195196         ptr += 0x2000;
196197      }
197198   }
198   else if (snes_cart.mode == SNES_MODE_25)
199   else if (state->cart[0].mode == SNES_MODE_25)
199200   {
200201      for (ii = 0; ii < 16; ii++)
201202      {
r8081r8082
204205      }
205206   }
206207
207   image_battery_save(devtag_get_device(machine, "cart"), battery_ram, snes_cart.sram_max);
208   image_battery_save(devtag_get_device(machine, "cart"), battery_ram, state->cart[0].sram_max);
208209
209210   free(battery_ram);
210211}
211212
212213static void snes_machine_stop(running_machine *machine)
213214{
215   snes_state *state = (snes_state *)machine->driver_data;
216
214217   /* Save SRAM */
215   if (snes_cart.sram > 0)
218   if (state->cart[0].sram > 0)
216219      snes_save_sram(machine);
217220}
218221
219222MACHINE_START( snes_mess )
220223{
221   snes_ram = memory_region(machine, "maincpu");
222224   add_exit_callback(machine, snes_machine_stop);
223225   MACHINE_START_CALL(snes);
224226}
225227
226228
229static void sufami_load_sram(running_machine *machine, const char *cart_tag)
230{
231   UINT8 ii;
232   UINT8 *battery_ram, *ptr;
233   int st_sram_offset = 0;
234   
235   battery_ram = (UINT8*)malloc(0x20000);
236   ptr = battery_ram;
237   image_battery_load(devtag_get_device(machine, cart_tag), battery_ram, 0x20000, 0);
238   
239   if (strcmp(cart_tag, "slot_a") == 0)
240      st_sram_offset = 0x608000;
241   
242   if (strcmp(cart_tag, "slot_b") == 0)
243      st_sram_offset = 0x708000;
244   
245   /* Cart RAM is at 0x60-0x63:0x8000-0xffff (+0x10 for slot2) */
246   for (ii = 0; ii < 4; ii++)
247   {
248      /* loading */
249      memcpy(&snes_ram[st_sram_offset + (ii * 0x010000)], ptr + (ii * 0x8000), 0x8000);
250      /* mirroring */
251      memcpy(&snes_ram[0x800000 + st_sram_offset + (ii * 0x010000)], &snes_ram[st_sram_offset + (ii * 0x010000)], 0x8000);
252   }
253   
254   free(battery_ram);
255}
256
257static void sufami_machine_stop(running_machine *machine)
258{
259   snes_state *state = (snes_state *)machine->driver_data;
260   UINT8 ii;
261   UINT8 *battery_ram, *ptr;
262   
263   battery_ram = (UINT8*)malloc(0x20000);
264   ptr = battery_ram;
265   
266   if (state->cart[0].slot_in_use)
267   {
268      for (ii = 0; ii < 4; ii++)
269      {
270         memmove(ptr + ii * 0x8000, &snes_ram[0x608000 + (ii * 0x010000)], 0x8000);
271      }
272      image_battery_save(devtag_get_device(machine, "slot_a"), battery_ram, 0x20000);
273   }
274
275   if (state->cart[1].slot_in_use)
276   {
277      for (ii = 0; ii < 4; ii++)
278      {
279         memmove(ptr + ii * 0x8000, &snes_ram[0x708000 + (ii * 0x010000)], 0x8000);
280      }
281      image_battery_save(devtag_get_device(machine, "slot_b"), battery_ram, 0x20000);
282   }
283   
284   free(battery_ram);
285}
286
287MACHINE_START( snesst )
288{
289   add_exit_callback(machine, sufami_machine_stop);
290   MACHINE_START_CALL(snes);
291}
292
293
227294/***************************************************************************
228295
229296  Cart handling
r8081r8082
339406   return score;
340407}
341408
342
343static DEVICE_IMAGE_LOAD( snes_cart )
409/* Here we add a couple of cart utilities, to avoid duplicating the code in each DEVICE_IMAGE_LOAD */
410static UINT32 snes_skip_header( running_device *image, UINT32 snes_rom_size )
344411{
345   int i, supported_type = 1;
346   running_machine *machine = image->machine;
347   const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM );
348   int total_blocks, read_blocks;
349   UINT32 offset;
350412   UINT8 header[512];
351   UINT8 *temp_buffer = auto_alloc_array(machine, UINT8, 0x410000);
352   UINT8 valid_mode20, valid_mode21, valid_mode25;
353   unsigned char *ROM;
354
355   snes_ram = memory_region(machine, "maincpu");
356   memset(snes_ram, 0, 0x1000000);
357
358   if (image_software_entry(image) == NULL)
359      snes_rom_size = image_length(image);
360   else
361      snes_rom_size = image_get_software_region_length(image, "rom");
362
413   UINT32 offset = 512;
414   
363415   /* Check for a header (512 bytes) */
364   offset = 512;
365416   if (image_software_entry(image) == NULL)
366417      image_fread(image, header, 512);
367418   else
368419      memcpy(header, image_get_software_region(image, "rom"), 512);
369
420   
370421   if ((header[8] == 0xaa) && (header[9] == 0xbb) && (header[10] == 0x04))
371422   {
372423      /* Found an SWC identifier */
373      logerror("Found header(SWC) - Skipped\n");
424      logerror("Found header (SWC) - Skipped\n");
374425   }
375426   else if ((header[0] | (header[1] << 8)) == (((snes_rom_size - 512) / 1024) / 8))
376427   {
377428      /* Some headers have the rom size at the start, if this matches with the actual rom size, we probably have a header */
378      logerror("Found header(size) - Skipped\n");
429      logerror("Found header (size) - Skipped\n");
379430   }
380431   else if ((snes_rom_size % 0x8000) == 512)
381432   {
382433      /* As a last check we'll see if there's exactly 512 bytes extra to this image. */
383      logerror("Found header(extra) - Skipped\n");
434      logerror("Found header (extra) - Skipped\n");
384435   }
385436   else
386437   {
387438      /* No header found so go back to the start of the file */
388439      logerror("No header found.\n");
389440      offset = 0;
441   }
442   
443   return offset;
444}
390445
391      if (image_software_entry(image) == NULL)
392         image_fseek(image, offset, SEEK_SET);
446
447/* This determines if a cart is in Mode 20, 21, 22 or 25; sets state->cart[0].mode and
448 state->cart[0].sram accordingly; and returns the offset of the internal header (needed to
449 detect BSX and ST carts) */
450static UINT32 snes_find_hilo_mode( running_device *image, UINT8 *buffer, UINT32 offset, int cartid )
451{
452   snes_state *state = (snes_state *)image->machine->driver_data;
453   UINT8 valid_mode20, valid_mode21, valid_mode25;
454   UINT32 retvalue;
455
456   /* Now to determine if this is a lo-ROM, a hi-ROM or an extended lo/hi-ROM */
457   valid_mode20 = snes_validate_infoblock(buffer, 0x007fc0);
458   valid_mode21 = snes_validate_infoblock(buffer, 0x00ffc0);
459   valid_mode25 = snes_validate_infoblock(buffer, 0x40ffc0);
460   
461   /* Images larger than 32mbits are likely ExHiRom */
462   if (valid_mode25)
463      valid_mode25 += 4;
464   
465   if ((valid_mode20 >= valid_mode21) && (valid_mode20 >= valid_mode25))
466   {
467      if ((buffer[0x007fd5] == 0x32) || ((state->cart_size - offset) > 0x401000))
468         state->cart[cartid].mode = SNES_MODE_22;   // ExLoRom
469      else
470         state->cart[cartid].mode = SNES_MODE_20;   // LoRom
471     
472      retvalue = 0x007fc0;
473     
474      /* a few games require 512k, however we store twice as much to be sure to cover the various mirrors */
475      state->cart[cartid].sram_max = 0x100000;
393476   }
477   else if (valid_mode21 >= valid_mode25)
478   {
479      state->cart[cartid].mode = SNES_MODE_21;   // HiRom
480      retvalue = 0x00ffc0;
481      state->cart[cartid].sram_max = 0x20000;
482   }
483   else
484   {
485      state->cart[cartid].mode = SNES_MODE_25;   // ExHiRom
486      retvalue = 0x40ffc0;
487      state->cart[cartid].sram_max = 0x20000;
488   }
394489
490   logerror( "\t HiROM/LoROM id: %s (LoROM: %d , HiROM: %d, ExHiROM: %d)\n",
491          (state->cart[cartid].mode == SNES_MODE_20) ? "LoROM" :
492          (state->cart[cartid].mode == SNES_MODE_21) ? "HiROM" :
493          (state->cart[cartid].mode == SNES_MODE_22) ? "ExLoROM" :
494          (state->cart[cartid].mode == SNES_MODE_25) ? "ExHiROM" : "Other (BSX or ST)",
495          valid_mode20, valid_mode21, valid_mode25);
496   
497   return retvalue;
498}
499
500static int snes_find_addon_chip( running_machine *machine )
501{
502   snes_state *state = (snes_state *)machine->driver_data;
503   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
504   int supported_type = 1;
505
506   /* Info mostly taken from http://snesemu.black-ship.net/misc/-from%20nsrt.edgeemu.com-chipinfo.htm */
507   switch (snes_r_bank1(space, 0x00ffd6))
508   {
509      case 0x00:
510      case 0x01:
511      case 0x02:
512         state->has_addon_chip = HAS_NONE;
513         break;
514         
515      case 0x03:
516         if (snes_r_bank1(space, 0x00ffd5) == 0x30)
517            state->has_addon_chip = HAS_DSP4;
518         else
519            state->has_addon_chip = HAS_DSP1;
520         break;
521         
522      case 0x04:
523         state->has_addon_chip = HAS_DSP1;
524         break;
525         
526      case 0x05:
527         if (snes_r_bank1(space, 0x00ffd5) == 0x20)
528            state->has_addon_chip = HAS_DSP2;
529         /* DSP-3 is hard to detect. We exploit the fact that the only game has been manufactured by Bandai */
530         else if ((snes_r_bank1(space, 0x00ffd5) == 0x30) && (snes_r_bank1(space, 0x00ffda) == 0xb2))
531            state->has_addon_chip = HAS_DSP3;
532         else
533            state->has_addon_chip = HAS_DSP1;
534         break;
535         
536      case 0x13:   // Mario Chip 1
537      case 0x14:   // GSU-x
538      case 0x15:   // GSU-x
539      case 0x1a:   // GSU-1 (21 MHz at start)
540         if (snes_r_bank1(space, 0x00ffd5) == 0x20)
541            state->has_addon_chip = HAS_SUPERFX;
542         break;
543         
544      case 0x25:
545         state->has_addon_chip = HAS_OBC1;
546         break;
547         
548      case 0x32:   // needed by a Sample game (according to ZSNES)
549      case 0x34:
550      case 0x35:
551         if (snes_r_bank1(space, 0x00ffd5) == 0x23)
552         {
553            state->has_addon_chip = HAS_SA1;
554            supported_type = 0;
555            printf("This is a SA-1 type game, currently unsupported by the driver");
556         }
557         break;
558         
559      case 0x43:
560      case 0x45:
561         if (snes_r_bank1(space, 0x00ffd5) == 0x32)
562         {
563            state->has_addon_chip = HAS_SDD1;
564         }
565         break;
566         
567      case 0x55:
568         if (snes_r_bank1(space, 0x00ffd5) == 0x35)
569         {
570            state->has_addon_chip = HAS_RTC;
571         }
572         break;
573         
574      case 0xe3:
575         state->has_addon_chip = HAS_Z80GB;
576         supported_type = 0;
577         break;
578         
579      case 0xf3:
580         state->has_addon_chip = HAS_CX4;
581         break;
582         
583      case 0xf5:
584         if (snes_r_bank1(space, 0x00ffd5) == 0x30)
585         {
586            state->has_addon_chip = HAS_ST018;
587            supported_type = 0;
588         }
589         else if (snes_r_bank1(space, 0x00ffd5) == 0x3a)
590         {
591            state->has_addon_chip = HAS_SPC7110;
592         }
593         break;
594         
595      case 0xf6:
596         /* These Seta ST-01X chips have both 0x30 at 0x00ffd5,
597          they only differ for the 'size' at 0x00ffd7 */
598         if (snes_r_bank1(space, 0x00ffd7) < 0x0a)
599         {
600            state->has_addon_chip = HAS_ST011;
601            supported_type = 0;
602         }
603         else
604         {
605            state->has_addon_chip = HAS_ST010;
606         }
607         break;
608         
609      case 0xf9:
610         if (snes_r_bank1(space, 0x00ffd5) == 0x3a)
611         {
612            state->has_addon_chip = HAS_SPC7110_RTC;
613            supported_type = 0;
614         }
615         break;
616         
617      default:
618         state->has_addon_chip = HAS_UNK;
619         supported_type = 0;
620         break;
621   }
622   
623   return supported_type;
624}
625
626static void snes_cart_log_info( running_machine *machine, int total_blocks, int supported )
627{
628   snes_state *state = (snes_state *)machine->driver_data;
629   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
630   char title[21], rom_id[4], company_id[2];
631   int i, company, has_ram = 0, has_sram = 0;
632   
633   /* Company */
634   for (i = 0; i < 2; i++)
635      company_id[i] = snes_r_bank1(space, 0x00ffb0 + i);
636   company = (char_to_int_conv(company_id[0]) << 4) + char_to_int_conv(company_id[1]);
637   if (company == 0)
638      company = snes_r_bank1(space, 0x00ffda);
639   
640   /* ROM ID */
641   for( i = 0; i < 4; i++ )
642      rom_id[i] = snes_r_bank1(space, 0x00ffb2 + i);
643   
644   /* Title */
645   for( i = 0; i < 21; i++ )
646      title[i] = snes_r_bank1(space, 0x00ffc0 + i);
647   
648   /* RAM */
649   if (((snes_r_bank1(space, 0x00ffd6) & 0xf) == 1) ||
650      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 2) ||
651      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 4) ||
652      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 5))
653      has_ram = 1;
654   
655   /* SRAM */
656   if (((snes_r_bank1(space, 0x00ffd6) & 0xf) == 2) ||
657      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 5) ||
658      ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 6))
659      has_sram = 1;
660   
661   logerror( "ROM DETAILS\n" );
662   logerror( "===========\n\n" );
663   logerror( "\tTotal blocks:  %d (%dmb)\n", total_blocks, total_blocks / (state->cart[0].mode & 5 ? 32 : 16) );
664   logerror( "\tROM bank size: %s \n",
665          (state->cart[0].mode == SNES_MODE_20) ? "LoROM" :
666          (state->cart[0].mode == SNES_MODE_21) ? "HiROM" :
667          (state->cart[0].mode == SNES_MODE_22) ? "ExLoROM" :
668          (state->cart[0].mode == SNES_MODE_25) ? "ExHiROM" : "Other (BSX or ST)" );
669   logerror( "\tCompany:       %s [%.2s]\n", companies[company], company_id );
670   logerror( "\tROM ID:        %.4s\n\n", rom_id );
671   
672   logerror( "HEADER DETAILS\n" );
673   logerror( "==============\n\n" );
674   logerror( "\tName:          %.21s\n", title );
675   logerror( "\tSpeed:         %s [%d]\n", ((snes_r_bank1(space, 0x00ffd5) & 0xf0)) ? "FastROM" : "SlowROM", (snes_r_bank1(space, 0x00ffd5) & 0xf0) >> 4 );
676   logerror( "\tBank size:     %s [%d]\n", (snes_r_bank1(space, 0x00ffd5) & 0xf) ? "HiROM" : "LoROM", snes_r_bank1(space, 0x00ffd5) & 0xf );
677   
678   logerror( "\tType:          %s", types[state->has_addon_chip]);
679   if (has_ram)
680      logerror( ", RAM");
681   if (has_sram)
682      logerror( ", SRAM");
683   logerror( " [%d]\n", snes_r_bank1(space, 0x00ffd6) );
684   
685   logerror( "\tSize:          %d megabits [%d]\n", 1 << (snes_r_bank1(space, 0x00ffd7) - 7), snes_r_bank1(space, 0x00ffd7) );
686   logerror( "\tSRAM:          %d kilobits [%d]\n", state->cart[0].sram * 8, snes_ram[0xffd8] );
687   logerror( "\tCountry:       %s [%d]\n", countries[snes_r_bank1(space, 0x00ffd9)], snes_r_bank1(space, 0x00ffd9) );
688   logerror( "\tLicense:       %s [%X]\n", companies[snes_r_bank1(space, 0x00ffda)], snes_r_bank1(space, 0x00ffda) );
689   logerror( "\tVersion:       1.%d\n", snes_r_bank1(space, 0x00ffdb) );
690   logerror( "\tInv Checksum:  %X %X\n", snes_r_bank1(space, 0x00ffdd), snes_r_bank1(space, 0x00ffdc) );
691   logerror( "\tChecksum:      %X %X\n", snes_r_bank1(space, 0x00ffdf), snes_r_bank1(space, 0x00ffde) );
692   logerror( "\tNMI Address:   %2X%2Xh\n", snes_r_bank1(space, 0x00fffb), snes_r_bank1(space, 0x00fffa) );
693   logerror( "\tStart Address: %2X%2Xh\n\n", snes_r_bank1(space, 0x00fffd), snes_r_bank1(space, 0x00fffc) );
694   
695   logerror( "\tMode: %d\n", state->cart[0].mode);
696   
697   if (!supported)
698      logerror("WARNING: This cart type \"%s\" is not supported yet!\n", types[state->has_addon_chip]);
699}
700
701static DEVICE_IMAGE_LOAD( snes_cart )
702{
703   int supported_type = 1, i, j;
704   running_machine *machine = image->machine;
705   snes_state *state = (snes_state *)machine->driver_data;
706   const address_space *space = cputag_get_address_space( machine, "maincpu", ADDRESS_SPACE_PROGRAM );
707   int total_blocks, read_blocks, has_bsx_slot = 0, st_bios = 0;
708   UINT32 offset, int_header_offs;
709   UINT8 *temp_buffer = auto_alloc_array(machine, UINT8, 0x410000);
710   UINT8 *ROM;
711
712   if (image_software_entry(image) == NULL)
713      state->cart_size = image_length(image);
714   else
715      state->cart_size = image_get_software_region_length(image, "rom");
716
717   /* Check for a header (512 bytes), and skip it if found */
718   offset = snes_skip_header(image, state->cart_size);
719   
720   if (image_software_entry(image) == NULL)
721      image_fseek(image, offset, SEEK_SET);
722   
395723   /* We need to take a sample to test what mode we need to be in (the sample has to be quite large to cope with large carts in ExHiRom) */
396724   if (image_software_entry(image) == NULL)
397725   {
r8081r8082
403731      memcpy(temp_buffer, image_get_software_region(image, "rom") + offset, 0x40ffff);
404732   }
405733
406   /* Now to determine if this is a lo-ROM, a hi-ROM or an extended lo/hi-ROM */
407   valid_mode20 = snes_validate_infoblock(temp_buffer, 0x007fc0);
408   valid_mode21 = snes_validate_infoblock(temp_buffer, 0x00ffc0);
409   valid_mode25 = snes_validate_infoblock(temp_buffer, 0x40ffc0);
734   /* First, look if the cart is HiROM or LoROM (and set snes_cart accordingly) */
735   int_header_offs = snes_find_hilo_mode(image, temp_buffer, offset, 0);
410736
411   /* Images larger than 32mbits are likely ExHiRom */
412   if (valid_mode25)
413      valid_mode25 += 4;
414
415   if ((valid_mode20 >= valid_mode21) && (valid_mode20 >= valid_mode25))
737   /* Then, detect BS-X carts */
738   // Detect presence of BS-X Flash Cart
739   if ((temp_buffer[int_header_offs + 0x13] == 0x00 || temp_buffer[int_header_offs + 0x13] == 0xff) &&
740         temp_buffer[int_header_offs + 0x14] == 0x00)
416741   {
417      if ((temp_buffer[0x007fd5] == 0x32) || ((snes_rom_size - offset) > 0x401000))
418         snes_cart.mode = SNES_MODE_22;   // ExLoRom
419      else
420         snes_cart.mode = SNES_MODE_20;   // LoRom
421
422      /* a few games require 512k, however we store twice as much to be sure to cover the various mirrors */
423      snes_cart.sram_max = 0x100000;
742      UINT8 n15 = temp_buffer[int_header_offs + 0x15];
743      if (n15 == 0x00 || n15 == 0x80 || n15 == 0x84 || n15 == 0x9c || n15 == 0xbc || n15 == 0xfc)
744      {
745         if (temp_buffer[int_header_offs + 0x1a] == 0x33 || temp_buffer[int_header_offs + 0x1a] == 0xff)
746         {
747            // BS-X Flash Cart
748            state->cart[0].mode = SNES_MODE_BSX;
749         }
750      }
424751   }
425   else if (valid_mode21 >= valid_mode25)
752   
753   // Detect presence of BS-X flash cartridge connector
754   if ((temp_buffer[int_header_offs - 14] == 'Z') && (temp_buffer[int_header_offs - 11] == 'J'))
426755   {
427      snes_cart.mode = SNES_MODE_21;   // HiRom
428      snes_cart.sram_max = 0x20000;
756      UINT8 n13 = temp_buffer[int_header_offs - 13];
757      if ((n13 >= 'A' && n13 <= 'Z') || (n13 >= '0' && n13 <= '9'))
758      {
759         if (temp_buffer[int_header_offs + 0x1a] == 0x33 ||
760            (temp_buffer[int_header_offs - 10] == 0x00 && temp_buffer[int_header_offs - 4] == 0x00))
761         {
762            has_bsx_slot = 1;
763         }
764      }
429765   }
430   else
766   
767   // If there is a BS-X connector, detect if it is the Base Cart or a compatible slotted cart
768   if (has_bsx_slot)
431769   {
432      snes_cart.mode = SNES_MODE_25;   // ExHiRom
433      snes_cart.sram_max = 0x20000;
770      if (!memcmp(temp_buffer + int_header_offs, "Satellaview BS-X     ", 21))
771      {
772         //BS-X Base Cart
773         state->cart[0].mode = SNES_MODE_BSX;
774         // handle RAM
775      }
776      else
777      {
778         state->cart[0].mode = (int_header_offs ==0x007fc0) ? SNES_MODE_BSLO : SNES_MODE_BSHI;
779         // handle RAM?
780      }
434781   }
435782
436   if (SNES_CART_DEBUG) printf("mode %d\n", snes_cart.mode);
437
438   /* Loading data */
783   /* Then, detect Sufami Turbo carts */
784   if (!memcmp(temp_buffer, "BANDAI SFC-ADX", 14))
785   {
786      state->cart[0].mode = SNES_MODE_ST;
787      if (!memcmp(temp_buffer + 16, "SFC-ADX BACKUP", 14))
788         st_bios = 1;
789   }
790   
791   if (SNES_CART_DEBUG) printf("mode %d\n", state->cart[0].mode);
792   
793   /* Finally, load data */
439794   ROM = memory_region(image->machine, "cart");
440795
441796   if (image_software_entry(image) == NULL)
442      image_fread(image, ROM, snes_rom_size - offset);
797      image_fread(image, ROM, state->cart_size - offset);
443798   else
444      memcpy(ROM, image_get_software_region(image, "rom") + offset, snes_rom_size - offset);
799      memcpy(ROM, image_get_software_region(image, "rom") + offset, state->cart_size - offset);
445800
446   if (SNES_CART_DEBUG) printf("size %08X\n", snes_rom_size - offset);
801   if (SNES_CART_DEBUG) printf("size %08X\n", state->cart_size - offset);
447802
448   /* FIXME: Insert crc check here */
803   /* FIXME: Insert crc check here? */
449804
450805   /* How many blocks of data are available to be loaded? */
451   total_blocks = ((snes_rom_size - offset) / (snes_cart.mode & 0x05 ? 0x8000 : 0x10000));
806   total_blocks = ((state->cart_size - offset) / (state->cart[0].mode & 0xa5 ? 0x8000 : 0x10000));
452807   read_blocks = 0;
453808
454809   if (SNES_CART_DEBUG) printf("blocks %d\n", total_blocks);
r8081r8082
464819     * This is likely what happens in the real SNES as well, because the unit cannot be aware of the exact
465820     * size of data in the cart (procedure confirmed by byuu)
466821     */
467   switch (snes_cart.mode)
822   switch (state->cart[0].mode)
468823   {
469824      case SNES_MODE_21:
470825      /* HiROM carts load data in banks 0xc0 to 0xff. Each bank is fully mirrored in banks 0x40 to 0x7f
r8081r8082
594949         }
595950         break;
596951
952      case SNES_MODE_ST:
953         if (!st_bios)
954         {
955            printf("This is a Sufami Turbo data cart and cannot be loaded for snes/snespal in MESS.\n");
956            printf("Please use snesst driver to load it, instead.\n");
957            return INIT_FAIL;
958         }
959         else
960         {
961            // The Base ST cart consists of 8 * 0x8000 block which have to be loaded (and mirrored)
962            // at 0x00-0x1f:0x8000-0xffff and 0x80-0x9f:0x8000-0xffff
963            for (i = 0; i < 8; i++)
964            {
965               /* Loading data */
966               memcpy(&snes_ram[0x008000 + i * 0x10000], &ROM[0x000000 + i * 0x8000], 0x8000);
967               /* Mirroring */
968               memcpy(&snes_ram[0x808000 + i * 0x10000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000);
969               
970               /* Additional mirrors (to fill snes_ram up to 0x1fffff) */
971               for (j = 1; j < 4; j++)
972               {
973                  memcpy(&snes_ram[0x008000 + i * 0x10000 + j * 0x80000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000);
974                  memcpy(&snes_ram[0x808000 + i * 0x10000 + j * 0x80000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000);
975               }
976            }
977         }
978         break;
979
980      case SNES_MODE_BSX:
981      case SNES_MODE_BSLO:
982      case SNES_MODE_BSHI:
983         /* not handled yet */
984         printf("This is a BS-X Satellaview image: MESS does not support these yet, sorry.\n");
985#if 0
986         // shall we force incompatibility of flash carts without a base unit?
987         if (!has_bsx_slot)
988         {
989            printf("This is a BS-X flash cart and cannot be loaded in snes/snespal.\n");
990//            printf("Please use snesbsx driver to load it, instead.\n");
991            return INIT_FAIL;
992         }
993#endif
994         break;
995         
597996      default:
598997      case SNES_MODE_20:
599998      /* LoROM carts load data in banks 0x00 to 0x7f at address 0x8000 (actually up to 0x7d, because 0x7e and
r8081r8082
6481047         break;
6491048   }
6501049
651   /* Find the type of cart and detect special chips */
652   /* Info mostly taken from http://snesemu.black-ship.net/misc/-from%20nsrt.edgeemu.com-chipinfo.htm */
653   switch (snes_r_bank1(space, 0x00ffd6))
654   {
655         case 0x00:
656         case 0x01:
657         case 0x02:
658            snes_has_addon_chip = HAS_NONE;
659            break;
1050   /* Detect special chips */
1051   supported_type = snes_find_addon_chip(machine);
6601052
661         case 0x03:
662            if (snes_r_bank1(space, 0x00ffd5) == 0x30)
663               snes_has_addon_chip = HAS_DSP4;
664            else
665               snes_has_addon_chip = HAS_DSP1;
666            break;
1053   /* Find the amount of cart ram (even if we call it sram...) */
1054   if ((state->has_addon_chip != HAS_SUPERFX))
1055      state->cart[0].sram = snes_r_bank1(space, 0x00ffd8);
1056   else
1057      state->cart[0].sram = (snes_r_bank1(space, 0x00ffbd) & 0x07);
6671058
668         case 0x04:
669            snes_has_addon_chip = HAS_DSP1;
670            break;
1059   if (state->cart[0].sram > 0)
1060   {
1061      state->cart[0].sram = (1024 << state->cart[0].sram);
1062      if (state->cart[0].sram > state->cart[0].sram_max)
1063         state->cart[0].sram = state->cart[0].sram_max;
1064   }
6711065
672         case 0x05:
673            if (snes_r_bank1(space, 0x00ffd5) == 0x20)
674               snes_has_addon_chip = HAS_DSP2;
675            /* DSP-3 is hard to detect. We exploit the fact that the only game has been manufactured by Bandai */
676            else if ((snes_r_bank1(space, 0x00ffd5) == 0x30) && (snes_r_bank1(space, 0x00ffda) == 0xb2))
677               snes_has_addon_chip = HAS_DSP3;
678            else
679               snes_has_addon_chip = HAS_DSP1;
680            break;
1066   /* adjust size for very large carts */
1067   if (state->cart[0].mode == SNES_MODE_20 && ((state->cart_size - offset) > 0x200000 || state->cart[0].sram > (32 * 1024)))
1068      state->cart[0].small_sram = 1;
1069   else
1070      state->cart[0].small_sram = 0;
6811071
682         case 0x13:   // Mario Chip 1
683         case 0x14:   // GSU-x
684         case 0x15:   // GSU-x
685         case 0x1a:   // GSU-1 (21 MHz at start)
686            if (snes_r_bank1(space, 0x00ffd5) == 0x20)
687               snes_has_addon_chip = HAS_SUPERFX;
688            break;
1072   /* Log snes_cart information */
1073   snes_cart_log_info(machine, total_blocks, supported_type);
6891074
690         case 0x25:
691            snes_has_addon_chip = HAS_OBC1;
692            break;
1075   /* Load SRAM */
1076   snes_load_sram(machine);
6931077
694         case 0x32:   // needed by a Sample game (according to ZSNES)
695         case 0x34:
696         case 0x35:
697            if (snes_r_bank1(space, 0x00ffd5) == 0x23)
698            {
699               snes_has_addon_chip = HAS_SA1;
700               supported_type = 0;
701               fatalerror("This is a SA-1 type game, currently unsupported by the driver");
702            }
703            break;
1078   /* All done */
1079   return INIT_PASS;
1080}
7041081
705         case 0x43:
706         case 0x45:
707            if (snes_r_bank1(space, 0x00ffd5) == 0x32)
708            {
709               snes_has_addon_chip = HAS_SDD1;
710            }
711            break;
1082static DEVICE_IMAGE_LOAD( sufami_cart )
1083{
1084   running_machine *machine = image->machine;
1085   snes_state *state = (snes_state *)machine->driver_data;
1086   int total_blocks, read_blocks;
1087   int st_bios = 0, slot_id;
1088   UINT32 offset, st_data_offset = 0;
1089   UINT8 *temp_buffer = auto_alloc_array(machine, UINT8, 0x410000);
1090   UINT8 *ROM;
7121091
713         case 0x55:
714            if (snes_r_bank1(space, 0x00ffd5) == 0x35)
715            {
716               snes_has_addon_chip = HAS_RTC;
717               supported_type = 0;
718            }
719            break;
1092   snes_ram = memory_region(machine, "maincpu");
7201093
721         case 0xe3:
722            snes_has_addon_chip = HAS_Z80GB;
723            supported_type = 0;
724            break;
1094   if (strcmp(image->tag(), "slot_a") == 0)
1095   {
1096      st_data_offset = 0x200000;
1097      slot_id = 0;
1098   }
7251099
726         case 0xf3:
727            snes_has_addon_chip = HAS_CX4;
728            break;
729
730         case 0xf5:
731            if (snes_r_bank1(space, 0x00ffd5) == 0x30)
732            {
733               snes_has_addon_chip = HAS_ST018;
734               supported_type = 0;
735            }
736            else if (snes_r_bank1(space, 0x00ffd5) == 0x3a)
737            {
738               snes_has_addon_chip = HAS_SPC7110;
739            }
740            break;
741
742         case 0xf6:
743            /* These Seta ST-01X chips have both 0x30 at 0x00ffd5,
744                they only differ for the 'size' at 0x00ffd7 */
745            if (snes_r_bank1(space, 0x00ffd7) < 0x0a)
746            {
747               snes_has_addon_chip = HAS_ST011;
748               supported_type = 0;
749            }
750            else
751            {
752               snes_has_addon_chip = HAS_ST010;
753            }
754            break;
755
756         case 0xf9:
757            if (snes_r_bank1(space, 0x00ffd5) == 0x3a)
758            {
759               snes_has_addon_chip = HAS_SPC7110_RTC;
760               supported_type = 0;
761            }
762            break;
763
764         default:
765            snes_has_addon_chip = HAS_UNK;
766            supported_type = 0;
767            break;
1100   if (strcmp(image->tag(), "slot_b") == 0)
1101   {
1102      st_data_offset = 0x400000;
1103      slot_id = 1;
7681104   }
7691105
770   /* Find the amount of cart ram (even if we call it sram...) */
771   if ((snes_has_addon_chip != HAS_SUPERFX))
772      snes_cart.sram = snes_r_bank1(space, 0x00ffd8);
1106   if (image_software_entry(image) == NULL)
1107      state->cart_size = image_length(image);
7731108   else
774      snes_cart.sram = (snes_r_bank1(space, 0x00ffbd) & 0x07);
775
776   if (snes_cart.sram > 0)
1109      state->cart_size = image_get_software_region_length(image, "rom");
1110   
1111   /* Check for a header (512 bytes), and skip it if found */
1112   offset = snes_skip_header(image, state->cart_size);
1113   
1114   if (image_software_entry(image) == NULL)
1115      image_fseek(image, offset, SEEK_SET);
1116   
1117   /* We need to take a sample to test what mode we need to be in (the sample has to be quite large to cope with large carts in ExHiRom) */
1118   if (image_software_entry(image) == NULL)
7771119   {
778      snes_cart.sram = (1024 << snes_cart.sram);
779      if (snes_cart.sram > snes_cart.sram_max)
780         snes_cart.sram = snes_cart.sram_max;
1120      image_fread(image, temp_buffer, 0x40ffff);
1121      image_fseek(image, offset, SEEK_SET);   /* Rewind */
7811122   }
1123   else
1124   {
1125      memcpy(temp_buffer, image_get_software_region(image, "rom") + offset, 0x40ffff);
1126   }
1127   
1128   /* Detect Sufami Turbo carts */
1129   if (!memcmp(temp_buffer, "BANDAI SFC-ADX", 14))
1130   {
1131      state->cart[slot_id].mode = SNES_MODE_ST;
1132      if (!memcmp(temp_buffer + 16, "SFC-ADX BACKUP", 14))
1133         st_bios = 1;
1134   }
1135   else
1136   {
1137      printf("This is not a Sufami Turbo data pack.\n");
1138      printf("This image cannot be loaded in snesst (Use snes or snespal drivers, instead).\n");
1139      return INIT_FAIL;
1140   }
1141   
1142   if (st_bios == 1)
1143   {
1144      printf("This is the Sufami Turbo BIOS and not a Sufami Turbo data pack.\n");
1145      printf("This image cannot be loaded in snesst.\n");
1146      return INIT_FAIL;
1147   }
7821148
783   /* adjust size for very large carts */
784   if (snes_cart.mode == SNES_MODE_20 && ((snes_rom_size - offset) > 0x200000 || snes_cart.sram > (32 * 1024)))
785      snes_cart.small_sram = 1;
1149   /* Loading data */
1150   ROM = memory_region(image->machine, image->tag());
1151   
1152   if (image_software_entry(image) == NULL)
1153      image_fread(image, ROM, state->cart_size - offset);
7861154   else
787      snes_cart.small_sram = 0;
1155      memcpy(ROM, image_get_software_region(image, "rom") + offset, state->cart_size - offset);
7881156
1157   if (SNES_CART_DEBUG)
1158      printf("size %08X\n", state->cart_size - offset);
1159   
1160   /* FIXME: Insert crc check here? */
1161   
1162   /* How many blocks of data are available to be loaded? */
1163   total_blocks = (state->cart_size - offset) / 0x8000;
1164   read_blocks = 0;
1165   
1166   if (SNES_CART_DEBUG)
1167      printf("blocks %d\n", total_blocks);
1168   
1169   // actually load the cart
1170   while (read_blocks < 32 && read_blocks < total_blocks)
1171   {
1172      /* Loading data */
1173      // CART (either A or B)
1174      memcpy(&snes_ram[0x008000 + st_data_offset + read_blocks * 0x10000], &ROM[0x000000 + read_blocks * 0x8000], 0x8000);
1175      /* Mirroring */
1176      memcpy(&snes_ram[0x808000 + st_data_offset + read_blocks * 0x10000], &snes_ram[0x8000 + st_data_offset + (read_blocks * 0x10000)], 0x8000);
1177     
1178      read_blocks++;
1179   }
7891180
790   /* Log snes_cart information */
1181   /* Filling banks up to 0x1f and their mirrors */
1182   while (read_blocks % 32)
7911183   {
792      char title[21], rom_id[4], company_id[2];
793      int company, has_ram = 0, has_sram = 0;
1184      int j = 0, repeat_blocks;
1185      while ((read_blocks % (32 >> j)) && j < 5)
1186         j++;
1187      repeat_blocks = read_blocks % (32 >> (j - 1));
1188     
1189      memcpy(&snes_ram[st_data_offset + read_blocks * 0x10000], &snes_ram[st_data_offset + (read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
1190      memcpy(&snes_ram[0x800000 + st_data_offset + read_blocks * 0x10000], &snes_ram[st_data_offset + (read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
1191      read_blocks += repeat_blocks;
1192   }
7941193
795      /* Company */
796      for( i = 0; i < 2; i++ )
797         company_id[i] = snes_r_bank1(space, 0x00ffb0 + i);
798      company = (char_to_int_conv(company_id[0]) << 4) + char_to_int_conv(company_id[1]);
799      if (company == 0)
800         company = snes_r_bank1(space, 0x00ffda);
1194   sufami_load_sram(machine, image->tag());
8011195
802      /* ROM ID */
803      for( i = 0; i < 4; i++ )
804         rom_id[i] = snes_r_bank1(space, 0x00ffb2 + i);
1196   state->cart[slot_id].slot_in_use = 1;   // aknowledge the cart in this slot, for saving sram at exit
8051197
806      /* Title */
807      for( i = 0; i < 21; i++ )
808         title[i] = snes_r_bank1(space, 0x00ffc0 + i);
1198   auto_free(image->machine, temp_buffer);
1199   
1200   return INIT_PASS;
1201}
8091202
810      /* RAM */
811      if (((snes_r_bank1(space, 0x00ffd6) & 0xf) == 1) ||
812            ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 2) ||
813            ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 4) ||
814            ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 5))
815         has_ram = 1;
1203static DEVICE_IMAGE_LOAD( bsx_cart )
1204{
1205   running_machine *machine = image->machine;
1206   snes_state *state = (snes_state *)machine->driver_data;
1207   int total_blocks, read_blocks;
1208   int has_bsx_slot = 0;
1209   UINT32 offset, int_header_offs;
1210   UINT8 *temp_buffer = auto_alloc_array(machine, UINT8, 0x410000);
1211   UINT8 *ROM;
1212   
1213   if (image_software_entry(image) == NULL)
1214      state->cart_size = image_length(image);
1215   else
1216      state->cart_size = image_get_software_region_length(image, "rom");
1217   
1218   /* Check for a header (512 bytes), and skip it if found */
1219   offset = snes_skip_header(image, state->cart_size);
1220   
1221   if (image_software_entry(image) == NULL)
1222      image_fseek(image, offset, SEEK_SET);
1223   
1224   /* We need to take a sample to test what mode we need to be in (the sample has to be quite large to cope with large carts in ExHiRom) */
1225   if (image_software_entry(image) == NULL)
1226   {
1227      image_fread(image, temp_buffer, 0x40ffff);
1228      image_fseek(image, offset, SEEK_SET);   /* Rewind */
1229   }
1230   else
1231   {
1232      memcpy(temp_buffer, image_get_software_region(image, "rom") + offset, 0x40ffff);
1233   }
1234   
1235   /* First, look if the cart is HiROM or LoROM (and set snes_cart accordingly) */
1236   int_header_offs = snes_find_hilo_mode(image, temp_buffer, offset, 0);
1237   
1238   // Detect presence of BS-X flash cartridge connector
1239   if ((temp_buffer[int_header_offs - 14] == 'Z') && (temp_buffer[int_header_offs - 11] == 'J'))
1240   {
1241      UINT8 n13 = temp_buffer[int_header_offs - 13];
1242      if ((n13 >= 'A' && n13 <= 'Z') || (n13 >= '0' && n13 <= '9'))
1243      {
1244         if (temp_buffer[int_header_offs + 0x1a] == 0x33 ||
1245            (temp_buffer[int_header_offs - 10] == 0x00 && temp_buffer[int_header_offs - 4] == 0x00))
1246         {
1247            has_bsx_slot = 1;
1248         }
1249      }
1250   }
1251   
1252   // If there is a BS-X connector, detect if it is the Base Cart or a compatible slotted cart
1253   if (has_bsx_slot)
1254   {
1255      if (!memcmp(temp_buffer + int_header_offs, "Satellaview BS-X     ", 21))
1256      {
1257         //BS-X Base Cart
1258         state->cart[0].mode = SNES_MODE_BSX;
1259         // handle RAM
1260      }
1261      else
1262      {
1263         state->cart[0].mode = (int_header_offs ==0x007fc0) ? SNES_MODE_BSLO : SNES_MODE_BSHI;
1264         // handle RAM?
1265      }
1266   }
1267   else
1268   {
1269      printf("This is not a BS-X compatible cart.\n");
1270      printf("This image cannot be loaded in the first cartslot of snesbsx.\n");
1271      return INIT_FAIL;
1272   }
1273   
1274   /* Loading data */
1275   ROM = memory_region(image->machine, "cart");
1276   
1277   if (image_software_entry(image) == NULL)
1278      image_fread(image, ROM, state->cart_size - offset);
1279   else
1280      memcpy(ROM, image_get_software_region(image, "rom") + offset, state->cart_size - offset);
1281   
1282//   if (SNES_CART_DEBUG)
1283      printf("size %08X\n", state->cart_size - offset);
1284   
1285   /* FIXME: Insert crc check here? */
1286   
1287   /* How many blocks of data are available to be loaded? */
1288   total_blocks = (state->cart_size - offset) / 0x8000;
1289   read_blocks = 0;
1290   
1291//   if (SNES_CART_DEBUG)
1292      printf("blocks %d\n", total_blocks);
1293   
1294   // actually load the cart
1295   while (read_blocks < 64 && read_blocks < total_blocks)
1296   {
1297      /* Loading data */
1298      memcpy(&snes_ram[0x008000 + read_blocks * 0x10000], &ROM[0x000000 + read_blocks * 0x8000], 0x8000);
1299      /* Mirroring */
1300      memcpy(&snes_ram[0x808000 + read_blocks * 0x10000], &snes_ram[0x8000 + (read_blocks * 0x10000)], 0x8000);
1301     
1302      read_blocks++;
1303   }
1304   
1305   /* Filling banks up to 0x3f and their mirrors */
1306   while (read_blocks % 64)
1307   {
1308      int j = 0, repeat_blocks;
1309      while ((read_blocks % (64 >> j)) && j < 6)
1310         j++;
1311      repeat_blocks = read_blocks % (64 >> (j - 1));
1312     
1313      memcpy(&snes_ram[read_blocks * 0x10000], &snes_ram[(read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
1314      memcpy(&snes_ram[0x800000 + read_blocks * 0x10000], &snes_ram[(read_blocks - repeat_blocks) * 0x10000], repeat_blocks * 0x10000);
1315      read_blocks += repeat_blocks;
1316   }
8161317
817      /* SRAM */
818      if (((snes_r_bank1(space, 0x00ffd6) & 0xf) == 2) ||
819            ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 5) ||
820            ((snes_r_bank1(space, 0x00ffd6) & 0xf) == 6))
821         has_sram = 1;
1318   return INIT_PASS;
1319}
8221320
823      logerror( "ROM DETAILS\n" );
824      logerror( "===========\n\n" );
825      logerror( "\tTotal blocks:  %d (%dmb)\n", total_blocks, total_blocks / (snes_cart.mode & 5 ? 32 : 16) );
826      logerror( "\tROM bank size: %s (LoROM: %d , HiROM: %d, ExHiROM: %d)\n",
827                        (snes_cart.mode == SNES_MODE_20) ? "LoROM" :
828                        (snes_cart.mode == SNES_MODE_21) ? "HiROM" :
829                        (snes_cart.mode == SNES_MODE_22) ? "ExLoROM" : "ExHiROM",
830                              valid_mode20, valid_mode21, valid_mode25);
831      logerror( "\tCompany:       %s [%.2s]\n", companies[company], company_id );
832      logerror( "\tROM ID:        %.4s\n\n", rom_id );
1321static DEVICE_IMAGE_LOAD( bsx2slot_cart )
1322{
1323   running_machine *machine = image->machine;
1324   snes_state *state = (snes_state *)machine->driver_data;
1325   UINT32 offset, int_header_offs;
1326   UINT8 *temp_buffer = auto_alloc_array(machine, UINT8, 0x410000);
1327   UINT8 *ROM;
1328   
1329   if (image_software_entry(image) == NULL)
1330      state->cart_size = image_length(image);
1331   else
1332      state->cart_size = image_get_software_region_length(image, "rom");
1333   
1334   /* Check for a header (512 bytes), and skip it if found */
1335   offset = snes_skip_header(image, state->cart_size);
1336   
1337   if (image_software_entry(image) == NULL)
1338      image_fseek(image, offset, SEEK_SET);
1339   
1340   /* We need to take a sample to test what mode we need to be in (the sample has to be quite large to cope with large carts in ExHiRom) */
1341   if (image_software_entry(image) == NULL)
1342   {
1343      image_fread(image, temp_buffer, 0x40ffff);
1344      image_fseek(image, offset, SEEK_SET);   /* Rewind */
1345   }
1346   else
1347   {
1348      memcpy(temp_buffer, image_get_software_region(image, "rom") + offset, 0x40ffff);
1349   }
1350   
1351   /* First, look if the cart is HiROM or LoROM (and set snes_cart accordingly) */
1352   int_header_offs = snes_find_hilo_mode(image, temp_buffer, offset, 1);
1353   
1354   // Detect presence of BS-X Flash Cart
1355   if ((temp_buffer[int_header_offs + 0x13] == 0x00 || temp_buffer[int_header_offs + 0x13] == 0xff) &&
1356      temp_buffer[int_header_offs + 0x14] == 0x00)
1357   {
1358      UINT8 n15 = temp_buffer[int_header_offs + 0x15];
1359      if (n15 == 0x00 || n15 == 0x80 || n15 == 0x84 || n15 == 0x9c || n15 == 0xbc || n15 == 0xfc)
1360      {
1361         if (temp_buffer[int_header_offs + 0x1a] == 0x33 || temp_buffer[int_header_offs + 0x1a] == 0xff)
1362         {
1363            // BS-X Flash Cart
1364            state->cart[1].mode = SNES_MODE_BSX;
1365         }
1366      }
1367   }
8331368
834      logerror( "HEADER DETAILS\n" );
835      logerror( "==============\n\n" );
836      logerror( "\tName:          %.21s\n", title );
837      logerror( "\tSpeed:         %s [%d]\n", ((snes_r_bank1(space, 0x00ffd5) & 0xf0)) ? "FastROM" : "SlowROM", (snes_r_bank1(space, 0x00ffd5) & 0xf0) >> 4 );
838      logerror( "\tBank size:     %s [%d]\n", (snes_r_bank1(space, 0x00ffd5) & 0xf) ? "HiROM" : "LoROM", snes_r_bank1(space, 0x00ffd5) & 0xf );
839
840      logerror( "\tType:          %s", types[snes_has_addon_chip]);
841      if (has_ram)
842         logerror( ", RAM");
843      if (has_sram)
844         logerror( ", SRAM");
845      logerror( " [%d]\n", snes_r_bank1(space, 0x00ffd6) );
846
847      logerror( "\tSize:          %d megabits [%d]\n", 1 << (snes_r_bank1(space, 0x00ffd7) - 7), snes_r_bank1(space, 0x00ffd7) );
848      logerror( "\tSRAM:          %d kilobits [%d]\n", snes_cart.sram * 8, snes_ram[0xffd8] );
849      logerror( "\tCountry:       %s [%d]\n", countries[snes_r_bank1(space, 0x00ffd9)], snes_r_bank1(space, 0x00ffd9) );
850      logerror( "\tLicense:       %s [%X]\n", companies[snes_r_bank1(space, 0x00ffda)], snes_r_bank1(space, 0x00ffda) );
851      logerror( "\tVersion:       1.%d\n", snes_r_bank1(space, 0x00ffdb) );
852      logerror( "\tInv Checksum:  %X %X\n", snes_r_bank1(space, 0x00ffdd), snes_r_bank1(space, 0x00ffdc) );
853      logerror( "\tChecksum:      %X %X\n", snes_r_bank1(space, 0x00ffdf), snes_r_bank1(space, 0x00ffde) );
854      logerror( "\tNMI Address:   %2X%2Xh\n", snes_r_bank1(space, 0x00fffb), snes_r_bank1(space, 0x00fffa) );
855      logerror( "\tStart Address: %2X%2Xh\n\n", snes_r_bank1(space, 0x00fffd), snes_r_bank1(space, 0x00fffc) );
856
857      logerror( "\tMode: %d\n", snes_cart.mode);
858
859      if (!supported_type)
860         logerror("WARNING: This cart type \"%s\" is not supported yet!\n", types[snes_has_addon_chip]);
1369   if (state->cart[1].mode != SNES_MODE_BSX)
1370   {
1371      printf("This is not a BS-X flash cart.\n");
1372      printf("This image cannot be loaded in the second cartslot of snesbsx.\n");
1373      return INIT_FAIL;
8611374   }
862
863   /* Load SRAM */
864   snes_load_sram(space->machine);
865
866   /* All done */
1375   
1376   /* Loading data */
1377   ROM = memory_region(image->machine, "flash");
1378   
1379   if (image_software_entry(image) == NULL)
1380      image_fread(image, ROM, state->cart_size - offset);
1381   else
1382      memcpy(ROM, image_get_software_region(image, "rom") + offset, state->cart_size - offset);
1383   
1384   // actually load the cart
8671385   return INIT_PASS;
8681386}
8691387
8701388MACHINE_DRIVER_START( snes_cartslot )
8711389   MDRV_CARTSLOT_ADD("cart")
872   MDRV_CARTSLOT_EXTENSION_LIST("smc,sfc,fig,swc")
1390   MDRV_CARTSLOT_EXTENSION_LIST("sfc,smc,fig,swc,bin")
8731391   MDRV_CARTSLOT_NOT_MANDATORY
8741392   MDRV_CARTSLOT_INTERFACE("snes_cart")
8751393   MDRV_CARTSLOT_LOAD(snes_cart)
8761394   MDRV_SOFTWARE_LIST_ADD("snes")
8771395MACHINE_DRIVER_END
1396
1397// This (hackily) emulates a SNES unit with a Sufami Turbo Unit cart inserted:
1398// hence, the user can mount two data cart in the two slots available on the ST Unit
1399MACHINE_DRIVER_START( sufami_cartslot )
1400   MDRV_CARTSLOT_ADD("slot_a")
1401   MDRV_CARTSLOT_EXTENSION_LIST("st,sfc")
1402   MDRV_CARTSLOT_NOT_MANDATORY
1403   MDRV_CARTSLOT_INTERFACE("sufami_cart")
1404   MDRV_CARTSLOT_LOAD(sufami_cart)
1405
1406   MDRV_CARTSLOT_ADD("slot_b")
1407   MDRV_CARTSLOT_EXTENSION_LIST("st,sfc")
1408   MDRV_CARTSLOT_NOT_MANDATORY
1409   MDRV_CARTSLOT_INTERFACE("sufami_cart")
1410   MDRV_CARTSLOT_LOAD(sufami_cart)
1411
1412//   MDRV_SOFTWARE_LIST_ADD("snes")
1413MACHINE_DRIVER_END
1414
1415// This (hackily) emulates a SNES unit where you want to load a BS-X compatible cart:
1416// hence, the user can mount a SNES cart in the first slot (either a BS-X BIOS cart, or a
1417// BS-X compatible one, e.g. Same Game), and there is a second slot for the 8M data pack
1418// (in a real SNES this would have been inserted in the smaller slot on the cart itself)
1419MACHINE_DRIVER_START( bsx_cartslot )
1420   MDRV_CARTSLOT_ADD("cart")
1421   MDRV_CARTSLOT_EXTENSION_LIST("sfc,smc,fig,swc,bin")
1422   MDRV_CARTSLOT_NOT_MANDATORY
1423   MDRV_CARTSLOT_INTERFACE("snes_cart")
1424   MDRV_CARTSLOT_LOAD(bsx_cart)
1425
1426   MDRV_CARTSLOT_ADD("slot2")
1427   MDRV_CARTSLOT_EXTENSION_LIST("bs,sfc")
1428   MDRV_CARTSLOT_NOT_MANDATORY
1429   MDRV_CARTSLOT_INTERFACE("bsx_cart")
1430   MDRV_CARTSLOT_LOAD(bsx2slot_cart)
1431
1432//   MDRV_SOFTWARE_LIST_ADD("snes")
1433MACHINE_DRIVER_END
1434
1435DRIVER_INIT( snes_mess )
1436{
1437   snes_ram = memory_region(machine, "maincpu");
1438   memset(snes_ram, 0, 0x1000000);
1439}
1440
1441DRIVER_INIT( snesst )
1442{
1443   snes_state *state = (snes_state *)machine->driver_data;
1444   UINT8 *STBIOS = memory_region(machine, "sufami");
1445   int i, j;
1446
1447   state->cart[0].slot_in_use = 0;
1448   state->cart[1].slot_in_use = 0;
1449
1450   DRIVER_INIT_CALL(snes_mess);
1451
1452   // the Base ST cart consists of 8 * 0x8000 block which have to be loaded (and mirrored)
1453   // at 0x00-0x1f:0x8000-0xffff and 0x80-0x9f:0x8000-0xffff
1454   for (i = 0; i < 8; i++)
1455   {
1456      /* Loading data */
1457      memcpy(&snes_ram[0x008000 + i * 0x10000], &STBIOS[0x000000 + i * 0x8000], 0x8000);
1458      /* Mirroring */
1459      memcpy(&snes_ram[0x808000 + i * 0x10000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000);
1460     
1461      /* Additional mirrors (to fill snes_ram up to 0x1fffff) */
1462      for (j = 1; j < 4; j++)
1463      {
1464         memcpy(&snes_ram[0x008000 + i * 0x10000 + j * 0x80000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000);
1465         memcpy(&snes_ram[0x808000 + i * 0x10000 + j * 0x80000], &snes_ram[0x8000 + (i * 0x10000)], 0x8000);
1466      }
1467   }
1468   
1469}
src/mess/machine/snescart.h
r8081r8082
99#include "devices/cartslot.h"
1010
1111MACHINE_START( snes_mess );
12MACHINE_START( snesst );
1213
14DRIVER_INIT( snes_mess );
15DRIVER_INIT( snesst );
16
1317MACHINE_DRIVER_EXTERN( snes_cartslot );
18MACHINE_DRIVER_EXTERN( sufami_cartslot );
19MACHINE_DRIVER_EXTERN( bsx_cartslot );
1420
1521#endif /* _SNESCART_H */
1622
src/mess/machine/ti99_4x.c
r8081r8082
884884{
885885   cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-(18+3));      /* this is just a minimum, it can be more */
886886
887   return ((int) tms5220_status_r(devtag_get_device(space->machine, "tms5220"), offset)) << 8;
887   return ((int) tms5220_status_r(devtag_get_device(space->machine, "tmc0285"), offset)) << 8;
888888}
889889
890890#if 0
r8081r8082
915915    there are 15 bytes in FIFO.  It should be 16.  Of course, if it were the
916916    case, we would need to store the value on the bus, which would be more
917917    complex. */
918   if (! tms5220_readyq_r(devtag_get_device(space->machine, "tms5220")))
918   if (! tms5220_readyq_r(devtag_get_device(space->machine, "tmc0285")))
919919   {
920      attotime time_to_ready = double_to_attotime(tms5220_time_to_ready(devtag_get_device(space->machine, "tms5220")));
920      attotime time_to_ready = double_to_attotime(tms5220_time_to_ready(devtag_get_device(space->machine, "tmc0285")));
921921      int cycles_to_ready = cputag_attotime_to_clocks(space->machine, "maincpu", time_to_ready);
922922
923923      logerror("time to ready: %f -> %d\n", attotime_to_double(time_to_ready), (int) cycles_to_ready);
r8081r8082
927927   }
928928   #endif
929929
930   tms5220_data_w(devtag_get_device(space->machine, "tms5220"), offset, (data >> 8) & 0xff);
930   tms5220_data_w(devtag_get_device(space->machine, "tmc0285"), offset, (data >> 8) & 0xff);
931931}
932932
933933static UINT8 GROM_dataread(offs_t offset)
r8081r8082
12621262            if (! (offset & 1))
12631263            {
12641264               cpu_adjust_icount(devtag_get_device(space->machine, "maincpu"),-16*4);      /* this is just a minimum, it can be more */
1265               reply = tms5220_status_r(devtag_get_device(space->machine, "tms5220"), 0);
1265               reply = tms5220_status_r(devtag_get_device(space->machine, "tmc0285"), 0);
12661266            }
12671267            break;
12681268
r8081r8082
14281428                    there are 15 bytes in FIFO.  It should be 16.  Of course, if it were the
14291429                    case, we would need to store the value on the bus, which would be more
14301430                    complex. */
1431               if (! tms5220_readyq_r(devtag_get_device(space->machine, "tms5220")))
1431               if (! tms5220_readyq_r(devtag_get_device(space->machine, "tmc0285")))
14321432               {
1433                  attotime time_to_ready = double_to_attotime(tms5220_time_to_ready(devtag_get_device(space->machine, "tms5220")));
1433                  attotime time_to_ready = double_to_attotime(tms5220_time_to_ready(devtag_get_device(space->machine, "tmc0285")));
14341434                  double d = cputag_attotime_to_clocks(space->machine, "maincpu", time_to_ready);
14351435                  int cycles_to_ready = ((int) (d + 3)) & ~3;
14361436
r8081r8082
14411441                  timer_set(space->machine, attotime_zero, NULL, 0, /*speech_kludge_callback*/NULL);
14421442               }
14431443
1444               tms5220_data_w(devtag_get_device(space->machine, "tms5220"), offset, data);
1444               tms5220_data_w(devtag_get_device(space->machine, "tmc0285"), offset, data);
14451445            }
14461446            break;
14471447
src/mess/mess.mak
r8081r8082
16801680            $(MAMESRC)/machine/snesrtc.c \
16811681            $(MAMESRC)/machine/snessdd1.c \
16821682            $(MAMESRC)/machine/snesst10.c \
1683            $(MAMESRC)/machine/snes7110.c
1683            $(MAMESRC)/machine/snes7110.c \
1684            $(MAMESRC)/machine/snesbsx.c
16841685
16851686$(MESS_VIDEO)/gba.o:      $(MESSSRC)/video/gbamode0.c \
16861687            $(MESSSRC)/video/gbamode1.c \
src/mess/drivers/ti99_8.c
r8081r8082
183183#include "devices/ti99cart.h"
184184#include "machine/rtc65271.h"
185185#include "formats/ti99_dsk.h"
186#include "devices/ti99_hd.h"
186187
187
188188/*
189189    Memory map - see description above
190190*/
191191
192192static ADDRESS_MAP_START(ti99_8_memmap, ADDRESS_SPACE_PROGRAM, 8)
193        /* There is a mapper device involved, so we need to handle
194           the range mapping in a bit more complicated way. */
195        AM_RANGE(0x0000, 0xffff) AM_READWRITE(ti99_8_r, ti99_8_w)
196
193   /* There is a mapper device involved, so we need to handle the range mapping in a bit more complicated way. */
194   AM_RANGE(0x0000, 0xffff) AM_READWRITE(ti99_8_r, ti99_8_w)
197195ADDRESS_MAP_END
198196
199197
r8081r8082
203201
204202static ADDRESS_MAP_START(ti99_8_cru_map, ADDRESS_SPACE_IO, 8)
205203//  AM_RANGE(0x0000, 0x00ff) AM_DEVREAD("tms9901", tms9901_cru_r)
206        AM_RANGE(0x0000, 0x007f) AM_DEVREAD("tms9901", tms9901_cru_r)
207        AM_RANGE(0x0080, 0x00ff) AM_DEVREAD("ti99_multicart", ti99_multicart_cru_r)     /* SuperSpace cartridge */
208        AM_RANGE(0x0100, 0x02ff) AM_READ(ti99_8_peb_cru_r)
204   AM_RANGE(0x0000, 0x007f) AM_DEVREAD("tms9901", tms9901_cru_r)
205   AM_RANGE(0x0080, 0x00ff) AM_DEVREAD("ti99_multicart", ti99_multicart_cru_r)     /* SuperSpace cartridge */
206   AM_RANGE(0x0100, 0x02ff) AM_READ(ti99_8_peb_cru_r)
209207
210208//      AM_RANGE(0x0000, 0x07ff) AM_DEVWRITE("tms9901", tms9901_cru_w)
211        AM_RANGE(0x0000, 0x03ff) AM_DEVWRITE("tms9901", tms9901_cru_w)
212        AM_RANGE(0x0400, 0x07ff) AM_DEVWRITE("ti99_multicart", ti99_multicart_cru_w)    /* SuperSpace cartridge */
213        AM_RANGE(0x0800, 0x17ff) AM_WRITE(ti99_8_peb_cru_w)
209   AM_RANGE(0x0000, 0x03ff) AM_DEVWRITE("tms9901", tms9901_cru_w)
210   AM_RANGE(0x0400, 0x07ff) AM_DEVWRITE("ti99_multicart", ti99_multicart_cru_w)    /* SuperSpace cartridge */
211   AM_RANGE(0x0800, 0x17ff) AM_WRITE(ti99_8_peb_cru_w)
214212
215213ADDRESS_MAP_END
216214
r8081r8082
258256      PORT_CONFSETTING(    0x01, "Mechatronics Mouse" )
259257
260258   PORT_START( "CARTSLOT" )
261   PORT_CONFNAME( 0x07, 0x00, "Cartridge slot" )
262      PORT_CONFSETTING(    0x00, "Auto" )
263      PORT_CONFSETTING(    0x01, "Slot 1" )
264      PORT_CONFSETTING(    0x02, "Slot 2" )
265      PORT_CONFSETTING(    0x03, "Slot 3" )
266      PORT_CONFSETTING(    0x04, "Slot 4" )
259   PORT_DIPNAME( 0x07, 0x00, "Cartridge slot" )
260      PORT_DIPSETTING(    0x00, "Auto" )
261      PORT_DIPSETTING(    0x01, "Slot 1" )
262      PORT_DIPSETTING(    0x02, "Slot 2" )
263      PORT_DIPSETTING(    0x03, "Slot 3" )
264      PORT_DIPSETTING(    0x04, "Slot 4" )
267265//      PORT_CONFSETTING(    0x05, "GRAM Kracker" )
268266
269267   PORT_START( "HFDCDIP" )
r8081r8082
486484
487485static MACHINE_START(ti99_8_60hz)
488486{
489    ti99_common_init(machine, &tms9118_interface);
487   ti99_common_init(machine, &tms9118_interface);
490488}
491489
492490static const TMS9928a_interface tms9129_interface =
r8081r8082
499497
500498static MACHINE_START(ti99_8_50hz)
501499{
502    ti99_common_init(machine, &tms9129_interface);
500   ti99_common_init(machine, &tms9129_interface);
503501}
504502
505503static const struct tms9995reset_param ti99_8_processor_config =
506504{
507   1,            /* enable automatic wait state generation */
508               /* (in January 83 99/8 schematics sheet 9: the delay logic
509                    seems to keep READY low for one cycle when RESET* is
510                    asserted, but the timings are completely wrong this way) */
511   0,            /* no IDLE callback */
512   1            /* MP9537 mask */
505   1,   /* enable automatic wait state generation */
506      /* (in January 83 99/8 schematics sheet 9: the delay logic */
507      /* seems to keep READY low for one cycle when RESET* is */
508      /* asserted, but the timings are completely wrong this way) */
509   0,   /* no IDLE callback */
510   1   /* MP9537 mask */
513511};
514512
515513static const mm58274c_interface floppy_mm58274c_interface =
r8081r8082
561559
562560   /* devices */
563561   MDRV_IDE_CONTROLLER_ADD( "ide", ti99_ide_interrupt )
564
565//  MDRV_IMPORT_FROM( smc92x4_hd )
566
567   MDRV_IDE_HARDDISK_ADD( "ide_harddisk" )
568562   MDRV_RTC65271_ADD("ide_rtc", ti99_clk_interrupt_callback)
569563
570564   MDRV_CASSETTE_ADD( "cassette", default_cassette_config )
r8081r8082
576570   MDRV_TMS9901_ADD("tms9901", tms9901reset_param_ti99_8)
577571
578572   MDRV_WD179X_ADD("wd179x", ti99_wd17xx_interface )
573   MDRV_SMC92X4_ADD("smc92x4", ti99_smc92x4_interface )
579574
580575   MDRV_FLOPPY_4_DRIVES_ADD(ti99_8_floppy_config)
576   MDRV_MFMHD_3_DRIVES_ADD()
581577
582578   MDRV_TI99_CARTRIDGE_ADD("ti99_multicart")
583579   MDRV_SMARTMEDIA_ADD("smartmedia")
r8081r8082
617613   /* devices */
618614   MDRV_IDE_CONTROLLER_ADD( "ide", ti99_ide_interrupt )   /* FIXME */
619615
620//  MDRV_IMPORT_FROM( smc92x4_hd )
621
622616   MDRV_IDE_HARDDISK_ADD( "ide_harddisk" )
623617   MDRV_RTC65271_ADD("ide_rtc", ti99_clk_interrupt_callback)
624618
r8081r8082
631625   MDRV_TMS9901_ADD("tms9901", tms9901reset_param_ti99_8)
632626
633627   MDRV_WD179X_ADD("wd179x", ti99_wd17xx_interface )
628   MDRV_SMC92X4_ADD("smc92x4", ti99_smc92x4_interface )
634629   MDRV_FLOPPY_4_DRIVES_ADD(ti99_8_floppy_config)
630   MDRV_MFMHD_3_DRIVES_ADD()
635631
636632   MDRV_TI99_CARTRIDGE_ADD("ti99_multicart")
637633   MDRV_SMARTMEDIA_ADD("smartmedia")
r8081r8082
639635MACHINE_DRIVER_END
640636
641637/*
642  ROM loading
638    ROM loading
643639*/
644640ROM_START(ti99_8)
645641   /*CPU memory space*/
src/mess/drivers/geneve.c
r8081r8082
520520   MDRV_SPEAKER_STANDARD_MONO("mono")
521521   MDRV_SOUND_ADD("sn76496", SN76496, 3579545)   /* 3.579545 MHz */
522522   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
523   MDRV_SOUND_ADD("tms5220", TMS5220, 680000L)
523   MDRV_SOUND_ADD("tmc0285", TMC0285, 680000L)
524524   MDRV_SOUND_CONFIG(geneve_tms5220interface)
525525   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
526526
r8081r8082
570570   ROM_LOAD_OPTIONAL("hfdc.bin", offset_hfdc_dsr, 0x4000, CRC(66fbe0ed) SHA1(11df2ecef51de6f543e4eaf8b2529d3e65d0bd59)) /* HFDC disk DSR ROM */
571571   ROM_LOAD_OPTIONAL("rs232.bin", offset_rs232_dsr, 0x1000, CRC(eab382fb) SHA1(ee609a18a21f1a3ddab334e8798d5f2a0fcefa91)) /* TI rs232 DSR ROM */
572572
573   /*TMS5220 ROM space*/
573   /*TMC0285 ROM space*/
574574   ROM_REGION(0x8000, region_speech_rom, 0)
575575   ROM_LOAD_OPTIONAL("spchrom.bin", 0x0000, 0x8000, CRC(58b155f7) SHA1(382292295c00dff348d7e17c5ce4da12a1d87763)) /* system speech ROM */
576576ROM_END
r8081r8082
590590   ROM_LOAD_OPTIONAL("hfdc.bin", offset_hfdc_dsr, 0x4000, CRC(66fbe0ed) SHA1(11df2ecef51de6f543e4eaf8b2529d3e65d0bd59)) /* HFDC disk DSR ROM */
591591   ROM_LOAD_OPTIONAL("rs232.bin", offset_rs232_dsr, 0x1000, CRC(eab382fb) SHA1(ee609a18a21f1a3ddab334e8798d5f2a0fcefa91)) /* TI rs232 DSR ROM */
592592
593   /*TMS5220 ROM space*/
593   /*TMC0285 ROM space*/
594594   ROM_REGION(0x8000, region_speech_rom, 0)
595595   ROM_LOAD_OPTIONAL("spchrom.bin", 0x0000, 0x8000, CRC(58b155f7) SHA1(382292295c00dff348d7e17c5ce4da12a1d87763)) /* system speech ROM */
596596ROM_END
src/mess/drivers/snes.c
r8081r8082
686686   state->oldjoy2_read = snes_oldjoy2_read;
687687}
688688
689static MACHINE_DRIVER_START( snes )
689static MACHINE_DRIVER_START( snes_base )
690690
691691   /* driver data */
692692   MDRV_DRIVER_DATA(snes_state)
r8081r8082
718718   MDRV_SOUND_ADD("spc700", SNES, 0)
719719   MDRV_SOUND_ROUTE(0, "lspeaker", 1.00)
720720   MDRV_SOUND_ROUTE(1, "rspeaker", 1.00)
721MACHINE_DRIVER_END
721722
723static MACHINE_DRIVER_START( snes )
724   MDRV_IMPORT_FROM(snes_base)
725
722726   MDRV_IMPORT_FROM(snes_cartslot)
723727MACHINE_DRIVER_END
724728
r8081r8082
751755   MDRV_CPU_CONFIG(snes_superfx_config)
752756MACHINE_DRIVER_END
753757
758static MACHINE_DRIVER_START( snesst )
759   MDRV_IMPORT_FROM(snes_base)
760
761   MDRV_MACHINE_START(snesst)
762
763   MDRV_IMPORT_FROM(sufami_cartslot)
764MACHINE_DRIVER_END
765
766static MACHINE_DRIVER_START( snesbsx )
767   MDRV_IMPORT_FROM(snes_base)
768
769   MDRV_IMPORT_FROM(bsx_cartslot)
770MACHINE_DRIVER_END
771
772
754773/*************************************
755774 *
756775 *  ROM definition(s)
r8081r8082
825844   ROM_REGION( MAX_SNES_CART_SIZE, "cart", ROMREGION_ERASE00 )
826845ROM_END
827846
847ROM_START( snesst )
848   ROM_REGION( 0x1000000, "maincpu", ROMREGION_ERASE00 )
849
850   ROM_REGION( 0x100, "user5", 0 )      /* IPL ROM */
851   ROM_LOAD( "spc700.rom", 0, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) )   /* boot rom */
852
853   ROM_REGION( 0x1000, "addons", ROMREGION_ERASE00 )      /* add-on chip ROMs (DSP, SFX, etc) */
854
855   ROM_REGION( 0x40000, "sufami", 0 )      /* add-on chip ROMs (DSP, SFX, etc) */
856   ROM_LOAD( "shvc-qh-0.bin", 0,   0x40000, CRC(9b4ca911) SHA1(ef86ea192eed03d5c413fdbbfd46043be1d7a127) )
857
858   ROM_REGION( MAX_SNES_CART_SIZE, "slot_a", ROMREGION_ERASE00 )
859   ROM_REGION( MAX_SNES_CART_SIZE, "slot_b", ROMREGION_ERASE00 )
860ROM_END
861
862ROM_START( snesbsx )
863   ROM_REGION( 0x1000000, "maincpu", ROMREGION_ERASE00 )
864
865   ROM_REGION( 0x100, "user5", 0 )      /* IPL ROM */
866   ROM_LOAD( "spc700.rom", 0, 0x40, CRC(44bb3a40) SHA1(97e352553e94242ae823547cd853eecda55c20f0) )   /* boot rom */
867
868   ROM_REGION( 0x1000, "addons", 0 )      /* add-on chip ROMs (DSP, SFX, etc) */
869   ROM_LOAD( "dsp1data.bin", 0x000000, 0x000800, CRC(4b02d66d) SHA1(1534f4403d2a0f68ba6e35186fe7595d33de34b1) )
870   ROM_LOAD( "dsp3data.bin", 0x000800, 0x000800, CRC(4a1c5453) SHA1(2f69c652109938cde21df5eb89890bf090256dbb) )
871
872   ROM_REGION( MAX_SNES_CART_SIZE, "cart", ROMREGION_ERASE00 )
873   ROM_REGION( MAX_SNES_CART_SIZE, "flash", ROMREGION_ERASE00 )
874ROM_END
875
876
877
828878/*************************************
829879 *
830880 *  Game driver(s)
831881 *
832882 *************************************/
833883
834/*    YEAR  NAME      PARENT  COMPAT  MACHINE   INPUT  INIT  COMPANY     FULLNAME                                      FLAGS */
835CONS( 1989, snes,     0,      0,      snes,     snes,  0,    "Nintendo", "Super Nintendo Entertainment System / Super Famicom (NTSC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
836CONS( 1989, snessfx,  snes,   0,      snessfx,  snes,  0,    "Nintendo", "Super Nintendo Entertainment System / Super Famicom (NTSC, w/SuperFX)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
837CONS( 1991, snespal,  snes,   0,      snespal,  snes,  0,    "Nintendo", "Super Nintendo Entertainment System (PAL)",  GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
838CONS( 1991, snespsfx, snes,   0,      snespsfx, snes,  0,    "Nintendo", "Super Nintendo Entertainment System (PAL, w/SuperFX)",  GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
839CONS( 199?, sfcbox,   snes,   0,      snes,     snes,  0,    "Nintendo", "Super Famicom Box (NTSC)", GAME_NOT_WORKING )
884/*    YEAR  NAME      PARENT  COMPAT  MACHINE   INPUT  INIT          COMPANY     FULLNAME                                      FLAGS */
885CONS( 1989, snes,     0,      0,      snes,     snes,  snes_mess,    "Nintendo", "Super Nintendo Entertainment System / Super Famicom (NTSC)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
886CONS( 1991, snespal,  snes,   0,      snespal,  snes,  snes_mess,    "Nintendo", "Super Nintendo Entertainment System (PAL)",  GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
887CONS( 199?, sfcbox,   snes,   0,      snes,     snes,  snes_mess,    "Nintendo", "Super Famicom Box (NTSC)", GAME_NOT_WORKING )
888
889// FIXME: the "hacked" drivers below, currently needed due to limitations in the core device design, should eventually be removed
890
891// These would require CPU to be added/removed depending on the cart which is loaded
892CONS( 1989, snessfx,  snes,   0,      snessfx,  snes,  snes_mess,    "Nintendo", "Super Nintendo Entertainment System / Super Famicom (NTSC, w/SuperFX)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
893CONS( 1991, snespsfx, snes,   0,      snespsfx, snes,  snes_mess,    "Nintendo", "Super Nintendo Entertainment System (PAL, w/SuperFX)",  GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
894//CONS( 1989, snessa1,  snes,   0,      snessa1,  snes,  snes_mess,    "Nintendo", "Super Nintendo Entertainment System / Super Famicom (NTSC, w/SA-1)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
895//CONS( 1991, snespsa1, snes,   0,      snespsa1, snes,  snes_mess,    "Nintendo", "Super Nintendo Entertainment System (PAL, w/SA-1)",  GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
896
897// These would require cartslot to be added/removed depending on the cart which is loaded
898CONS( 1989, snesst,   snes,   0,      snesst,  snes,  snesst,       "Nintendo", "Super Nintendo Entertainment System / Super Famicom (NTSC, w/Sufami Turbo)", GAME_NOT_WORKING )
899CONS( 1989, snesbsx,  snes,   0,      snesbsx, snes,  snes_mess,    "Nintendo", "Super Nintendo Entertainment System / Super Famicom (NTSC, w/BS-X Satellaview slotted cart)",  GAME_NOT_WORKING )
src/mess/drivers/ti89.c
r8081r8082
11/***************************************************************************
22
3    TI-89
3    TI-89, TI-92 and TI-92 plus driver by Sandro Ronco
44
5    12/05/2009 Skeleton driver.
5    NVRAM works only if the calculator is turned off (2nd + ON) before closing of MESS
66
7   TODO:
8    -Link
9    -HW 3 I/O port
10    -RTC
11    -LCD contrast
712****************************************************************************/
813
914#include "emu.h"
1015#include "cpu/m68000/m68000.h"
16#include "includes/ti89.h"
1117
18static UINT8 ti_68k_keypad_r (running_machine *machine);
19
20class t68k_state
21{
22public:
23   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, t68k_state(machine)); }
24
25   t68k_state(running_machine &machine) { }
26
27   /* HW specifications */
28   UINT8 hw_version;
29   UINT8 mem_type;
30   UINT32 initial_pc;
31   UINT16 *ram;
32   UINT32 ram_size;
33
34   /* keyboard */
35   UINT16 kb_mask;
36   UINT8 on_key;
37
38   /* LCD */
39   UINT8 lcd_on;
40   UINT32 lcd_base;
41   UINT8 lcd_width;
42   UINT8 lcd_height;
43   UINT8 lcd_contrast;
44
45   /* Flash */
46   UINT8 flash_protect;
47   UINT8 flash_state;
48   UINT8 flash_wait;
49   UINT8 flash_ready;
50
51   /* I/O */
52   UINT16 io_hw1[0x10];
53   UINT16 io_hw2[0x80];
54
55   /* Timer */
56   UINT8 timer_on;
57   UINT8 timer_val;
58   UINT16 timer_mask;
59};
60
61
62static UINT8 ti_68k_keypad_r (running_machine *machine)
63{
64   t68k_state *state = (t68k_state *)machine->driver_data;
65   UINT8 port, bit, data = 0xff;
66   static const char *const bitnames[] = {"BIT0", "BIT1", "BIT2", "BIT3", "BIT4", "BIT5", "BIT6", "BIT7"};
67
68   for (bit = 0; bit < 10; bit++)
69      if (~state->kb_mask & (0x01 << bit))
70         for (port = 0; port < 8; port++)
71            data ^= input_port_read(machine, bitnames[port]) & (0x01 << bit) ? 0x01 << port : 0x00;
72   return data;
73}
74
75
76WRITE16_HANDLER ( ti68k_io_w )
77{
78   t68k_state *state = (t68k_state *)space->machine->driver_data;
79
80   switch(offset & 0x0f)
81   {
82      case 0x00:
83         state->lcd_contrast=(state->lcd_contrast & 0xfe) | BIT(data, 5);
84         break;
85      case 0x02:
86         if (!(data & 0x10) && data != state->io_hw1[offset])
87            cputag_suspend(space->machine, "maincpu", SUSPEND_REASON_DISABLE, 1);
88         break;
89      case 0x08:
90            state->lcd_base = data << 3;
91         break;
92      case 0x09:
93            state->lcd_width = (0x40 - ((data >> 8) & 0xff)) * 0x10;
94            state->lcd_height = 0x100 - (data & 0xff);
95         break;
96      case 0x0a:
97         state->timer_on = BIT(data ,1);
98         switch((data >> 4) & 0x03)
99         {
100            case 0:      state->timer_mask = 0x0000;   break;
101            case 1:      state->timer_mask = 0x000f;   break;
102            case 2:      state->timer_mask = 0x007f;   break;
103            case 3:      state->timer_mask = 0x1fff;   break;
104         }
105         break;
106      case 0x0b:
107         state->timer_val = data & 0xff;
108      case 0x0c:
109         state->kb_mask = data & 0x03ff;
110         break;
111      case 0x0e:
112         state->lcd_on = (((data >> 8) & 0x3c) == 0x3c) ? 0 : 1;
113         state->lcd_contrast = (state->lcd_contrast & 0x01) | ((data & 0x0f) << 1);
114         break;
115      default: break;
116   }
117   state->io_hw1[offset & 0x0f] = data;
118}
119
120
121READ16_HANDLER ( ti68k_io_r )
122{
123   t68k_state *state = (t68k_state *)space->machine->driver_data;
124   UINT16 data;
125
126   switch (offset & 0x0f)
127   {
128      case 0x00:
129         data = 0x0400 | ((state->lcd_contrast & 1) << 13);
130         break;
131      case 0x0b:
132         data = state->timer_val;
133         break;
134      case 0x0d:
135         data = ((!state->on_key) << 9) | ti_68k_keypad_r(space->machine);
136         break;
137      default:
138         data= state->io_hw1[offset & 0x0f];
139   }
140   return data;
141}
142
143
144WRITE16_HANDLER ( ti68k_io2_w )
145{
146   t68k_state *state = (t68k_state *)space->machine->driver_data;
147   switch(offset & 0x7f)
148   {
149      case 0x0b:
150         state->lcd_base = 0x4c00 + 0x1000 * (data & 0x03);
151         break;
152      case 0x0e:
153         state->lcd_on = (data & 0x02) ? 1 : 0;
154         break;
155      default: break;
156   }
157   state->io_hw2[offset & 0x7f] = data;
158}
159
160
161READ16_HANDLER ( ti68k_io2_r )
162{
163   t68k_state *state = (t68k_state *)space->machine->driver_data;
164   UINT16 data;
165
166   switch (offset & 0x7f)
167   {
168      default:
169         data= state->io_hw2[offset & 0x7f];
170   }
171   return data;
172}
173
174
175WRITE16_HANDLER ( flash_w )
176{
177   t68k_state *state = (t68k_state *)space->machine->driver_data;
178   UINT16 *flash_base = (UINT16 *)memory_region(space->machine, "maincpu");
179
180   /* verification if it is flash memory */
181   if (state->mem_type != FLASH)
182      return;
183
184   if (state->flash_ready)
185   {
186      flash_base[offset] &= data;
187      state->flash_ready = 0;
188      state->flash_wait = 1;
189   }
190   else if (data == 0x5050)
191      state->flash_state = 0x50;
192   else if (data == 0x1010)
193   {
194      state->flash_ready = 1;
195      state->flash_state = 0x50;
196   }
197   else if (data == 0x2020 && state->flash_state == 0x50)
198      state->flash_state = 0x20;
199   else if (data == 0xd0d0 && state->flash_state == 0x20)
200   {
201      state->flash_state = 0xd0;
202      state->flash_wait = 1;
203      memset(&flash_base[offset & 0xff0000], 0xff, 64 * 1024);
204   }
205   else if (data == 0xffff && state->flash_state == 0x50)
206   {
207      state->flash_ready = 0;
208      state->flash_wait = 0;
209   }
210   else if (data == 0x9090)
211      state->flash_state = 0x90;
212}
213
214
215READ16_HANDLER ( rom_r )
216{
217   t68k_state *state = (t68k_state *)space->machine->driver_data;
218   UINT16 *rom_base = (UINT16 *)memory_region(space->machine, "maincpu");
219
220   if (state->mem_type == FLASH)
221   {
222      if (state->flash_state == 0x90 )
223         switch(offset & 0xffff)
224         {
225            case 0:
226               return 0x8900;
227            case 2:
228               return 0xb500;
229            default:
230               return 0xffff;
231         }
232      else if (state->flash_wait)
233         return 0xffff;
234      else
235         return rom_base[offset];
236   }
237   else
238      return rom_base[offset];
239}
240
241
242static TIMER_CALLBACK( ti68k_timer_callback )
243 {
244   t68k_state *state = (t68k_state *)machine->driver_data;
245   static UINT64 timer;
246
247   timer++;
248
249   if (state->timer_on)
250   {
251      if (!(timer & state->timer_mask) && BIT(state->io_hw1[0x0a], 3))
252      {
253         if (state->timer_val)
254            state->timer_val++;
255         else
256            state->timer_val = (state->io_hw1[0x0b]) & 0xff;
257      }
258
259      if (!BIT(state->io_hw1[0x0a], 7) && ((state->hw_version == HW1) || (!BIT(state->io_hw1[0x0f], 2) && !BIT(state->io_hw1[0x0f], 1))))
260      {
261         if (!(timer & 0x003f))
262            cputag_set_input_line(machine, "maincpu", M68K_IRQ_1, HOLD_LINE);
263
264         if (!(timer & 0x3fff) && !BIT(state->io_hw1[0x0a], 3))
265            cputag_set_input_line(machine, "maincpu", M68K_IRQ_3, HOLD_LINE);
266
267         if (!(timer & state->timer_mask) && BIT(state->io_hw1[0x0a], 3) && state->timer_val == 0)
268            cputag_set_input_line(machine, "maincpu", M68K_IRQ_5, HOLD_LINE);
269      }
270   }
271
272   if (ti_68k_keypad_r(machine) != 0xff)
273      cputag_set_input_line(machine, "maincpu", M68K_IRQ_2, HOLD_LINE);
274}
275
276
277static ADDRESS_MAP_START(ti92_mem, ADDRESS_SPACE_PROGRAM, 16 )
278   ADDRESS_MAP_UNMAP_HIGH
279   AM_RANGE(0x000000, 0x0fffff) AM_RAM AM_BASE_SIZE_MEMBER(t68k_state, ram, ram_size)
280   AM_RANGE(0x200000, 0x5fffff) AM_UNMAP   // ROM
281   AM_RANGE(0x600000, 0x6fffff) AM_READWRITE(ti68k_io_r, ti68k_io_w)
282ADDRESS_MAP_END
283
284
12285static ADDRESS_MAP_START(ti89_mem, ADDRESS_SPACE_PROGRAM, 16 )
13286   ADDRESS_MAP_UNMAP_HIGH
14   AM_RANGE(0x000000, 0x1fffff) AM_ROM
15   AM_RANGE(0x200000, 0x2fffff) AM_RAM
287   AM_RANGE(0x000000, 0x0fffff) AM_RAM AM_BASE_SIZE_MEMBER(t68k_state, ram, ram_size)
288   AM_RANGE(0x200000, 0x3fffff) AM_READWRITE(rom_r, flash_w)
289   AM_RANGE(0x400000, 0x5fffff) AM_NOP
290   AM_RANGE(0x600000, 0x6fffff) AM_READWRITE(ti68k_io_r, ti68k_io_w)
291   AM_RANGE(0x700000, 0x7fffff) AM_READWRITE(ti68k_io2_r, ti68k_io2_w)
16292ADDRESS_MAP_END
17293
18/* Input ports */
19static INPUT_PORTS_START( ti89 )
294
295static ADDRESS_MAP_START(ti92p_mem, ADDRESS_SPACE_PROGRAM, 16 )
296   ADDRESS_MAP_UNMAP_HIGH
297   AM_RANGE(0x000000, 0x0fffff) AM_RAM AM_BASE_SIZE_MEMBER(t68k_state, ram, ram_size)
298   AM_RANGE(0x200000, 0x3fffff) AM_NOP
299   AM_RANGE(0x400000, 0x5fffff) AM_READWRITE(rom_r, flash_w)
300   AM_RANGE(0x600000, 0x6fffff) AM_READWRITE(ti68k_io_r, ti68k_io_w)
301   AM_RANGE(0x700000, 0x7fffff) AM_READWRITE(ti68k_io2_r, ti68k_io2_w)
302ADDRESS_MAP_END
303
304
305static INPUT_CHANGED( ti68k_on_key )
306{
307   t68k_state *state = (t68k_state *)field->port->machine->driver_data;
308
309   state->on_key = newval;
310
311   if (state->on_key)
312   {
313      if (cputag_is_suspended(field->port->machine, "maincpu", SUSPEND_REASON_DISABLE))
314         cputag_resume(field->port->machine, "maincpu", SUSPEND_REASON_DISABLE);
315
316      cputag_set_input_line(field->port->machine, "maincpu", M68K_IRQ_6, HOLD_LINE);
317   }
318}
319
320
321/* Input ports for TI-89 and TI-89 Titanium*/
322static INPUT_PORTS_START (ti8x)
323   PORT_START("BIT0")   /* bit 0 */
324      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Up") PORT_CODE(KEYCODE_UP)
325      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ENTER  (ENTRY)") PORT_CODE(KEYCODE_ENTER)
326      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(-)") PORT_CODE(KEYCODE_M)
327      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(".") PORT_CODE(KEYCODE_STOP)
328      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0)
329      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("APPS") PORT_CODE(KEYCODE_F11)
330      PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC)
331   PORT_START("BIT1")   /* bit 1 */
332      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Left") PORT_CODE(KEYCODE_LEFT)
333      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("+") PORT_CODE(KEYCODE_BACKSLASH)
334      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3)
335      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2)
336      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1)
337      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("STORE") PORT_CODE(KEYCODE_TAB)
338      PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ON") PORT_CODE(KEYCODE_F10) PORT_CHANGED(ti68k_on_key, 0)
339   PORT_START("BIT2")   /* bit 2 */
340      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Down") PORT_CODE(KEYCODE_DOWN)
341      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_MINUS)
342      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6)
343      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5)
344      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4)
345      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("EE") PORT_CODE(KEYCODE_E)
346   PORT_START("BIT3")   /* bit 3 */
347      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Right") PORT_CODE(KEYCODE_RIGHT)
348      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("*") PORT_CODE(KEYCODE_L)
349      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9)
350      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8)
351      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7)
352      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("|") PORT_CODE(KEYCODE_COLON)
353   PORT_START("BIT4")   /* bit 4 */
354      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2nd") PORT_CODE(KEYCODE_LALT)
355      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("/") PORT_CODE(KEYCODE_SLASH)
356      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA)
357      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(")") PORT_CODE(KEYCODE_CLOSEBRACE)
358      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(") PORT_CODE(KEYCODE_OPENBRACE)
359      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("=") PORT_CODE(KEYCODE_EQUALS)
360   PORT_START("BIT5")   /* bit 5 */
361      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT)
362      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("^") PORT_CODE(KEYCODE_P)
363      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T)
364      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z)
365      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y)
366      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X)
367   PORT_START("BIT6")   /* bit 6 */
368      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("3nd") PORT_CODE(KEYCODE_LCONTROL)
369      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CLEAR") PORT_CODE(KEYCODE_DEL)
370      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("<--") PORT_CODE(KEYCODE_BACKSPACE)
371      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CATALOG") PORT_CODE(KEYCODE_F8)
372      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Mode") PORT_CODE(KEYCODE_F12)
373      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("HOME") PORT_CODE(KEYCODE_HOME)
374   PORT_START("BIT7")   /* bit 7 */
375      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ALPHA") PORT_CODE(KEYCODE_CAPSLOCK)
376      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5)
377      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4)
378      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3)
379      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2)
380      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1)
20381INPUT_PORTS_END
21382
383/* Input ports for TI-92 and TI92 Plus*/
384static INPUT_PORTS_START (ti9x)
385   PORT_START("BIT0")   /* bit 0 */
386      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2nd") PORT_CODE(KEYCODE_LALT)
387      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_UNUSED
388      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_UNUSED
389      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("STORE") PORT_CODE(KEYCODE_TAB)
390      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE)
391      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("/") PORT_CODE(KEYCODE_SLASH)
392      PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("^") PORT_CODE(KEYCODE_COLON)
393      PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("=") PORT_CODE(KEYCODE_EQUALS)
394      PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("<--") PORT_CODE(KEYCODE_BACKSPACE)
395      PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("-") PORT_CODE(KEYCODE_MINUS)
396   PORT_START("BIT1")   /* bit 1 */
397      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("3nd") PORT_CODE(KEYCODE_LCONTROL)
398      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z)
399      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X)
400      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C)
401      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V)
402      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B)
403      PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N)
404      PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M)
405      PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("o") PORT_CODE(KEYCODE_BACKSLASH)
406      PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER_PAD)
407   PORT_START("BIT2")   /* bit 2 */
408      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT)
409      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S)
410      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D)
411      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F)
412      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G)
413      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H)
414      PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J)
415      PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K)
416      PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L)
417      PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A)
418   PORT_START("BIT3")   /* bit 3 */
419      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Clock") PORT_CODE(KEYCODE_F11)
420      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W)
421      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E)
422      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R)
423      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T)
424      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y)
425      PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U)
426      PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I)
427      PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O)
428      PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q)
429   PORT_START("BIT4")   /* bit 4 */
430      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Left") PORT_CODE(KEYCODE_LEFT)
431      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F8") PORT_CODE(KEYCODE_F8)
432      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F3") PORT_CODE(KEYCODE_F3)
433      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F7") PORT_CODE(KEYCODE_F7)
434      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F2") PORT_CODE(KEYCODE_F2)
435      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F6") PORT_CODE(KEYCODE_F6)
436      PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F1") PORT_CODE(KEYCODE_F1)
437      PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F5") PORT_CODE(KEYCODE_F5)
438      PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("+") PORT_CODE(KEYCODE_PLUS_PAD)
439      PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("F4") PORT_CODE(KEYCODE_F4)
440   PORT_START("BIT5")   /* bit 5 */
441      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Up") PORT_CODE(KEYCODE_UP)
442      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1)
443      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4)
444      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7)
445      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(") PORT_CODE(KEYCODE_OPENBRACE)
446      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("SIN") PORT_CODE(KEYCODE_PGUP)
447      PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("LN") PORT_CODE(KEYCODE_PGDN)
448      PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("CLEAR") PORT_CODE(KEYCODE_DEL)
449      PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("MODE") PORT_CODE(KEYCODE_F12)
450      PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0)
451   PORT_START("BIT6")   /* bit 6 */
452      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Right") PORT_CODE(KEYCODE_RIGHT)
453      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2)
454      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5)
455      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8)
456      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(")") PORT_CODE(KEYCODE_CLOSEBRACE)
457      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("COS") PORT_CODE(KEYCODE_END)
458      PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER)
459      PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("APPS") PORT_CODE(KEYCODE_HOME)
460      PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ESC") PORT_CODE(KEYCODE_ESC)
461      PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(".") PORT_CODE(KEYCODE_STOP)
462   PORT_START("BIT7")   /* bit 7 */
463      PORT_BIT(0x0001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Down") PORT_CODE(KEYCODE_DOWN)
464      PORT_BIT(0x0002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3)
465      PORT_BIT(0x0004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6)
466      PORT_BIT(0x0008, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9)
467      PORT_BIT(0x0010, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA)
468      PORT_BIT(0x0020, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("TAN") PORT_CODE(KEYCODE_INSERT)
469      PORT_BIT(0x0040, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P)
470      PORT_BIT(0x0080, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("*") PORT_CODE(KEYCODE_ASTERISK)
471      PORT_BIT(0x0100, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("ON") PORT_CODE(KEYCODE_F10) PORT_CHANGED(ti68k_on_key, 0)
472      PORT_BIT(0x0200, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("(-)") PORT_CODE(KEYCODE_MINUS_PAD)
473INPUT_PORTS_END
22474
23static MACHINE_RESET(ti89)
475
476NVRAM_HANDLER( ti68k )
24477{
478   t68k_state *state = (t68k_state *)machine->driver_data;
479   UINT16 *rom = (UINT16 *)memory_region(machine, "maincpu");
480
481   if (read_or_write)
482   {
483      mame_fwrite(file, state->ram, state->ram_size);
484
485      /* if the memory is flash saves the content */
486      if (state->mem_type == FLASH)
487         mame_fwrite(file, rom, 0x200000);
488   }
489   else
490   {
491      if (file)
492      {
493         mame_fread(file, state->ram, state->ram_size);
494         if (state->mem_type == FLASH)
495            mame_fread(file, rom, 0x200000);
496      }
497      else
498         memset(state->ram, 0, sizeof(state->ram));
499   }
25500}
26501
27static VIDEO_START( ti89 )
502
503static MACHINE_RESET(ti68k)
28504{
505   t68k_state *state = (t68k_state *)machine->driver_data;
506   cpu_set_reg(devtag_get_device(machine, "maincpu"), M68K_PC, state->initial_pc);
507
508   state->kb_mask = 0xff;
509   state->on_key = 0;
510   state->lcd_base = 0;
511   state->lcd_width = 0;
512   state->lcd_height = 0;
513   state->lcd_on = 0;
514   state->lcd_contrast = 0;
515   state->flash_protect = 0;
516   state->flash_state = 0;
517   state->flash_wait = 0;
518   state->flash_ready = 0;
519   memset(state->io_hw1, 0, sizeof(state->io_hw1));
520   memset(state->io_hw2, 0, sizeof(state->io_hw2));
521   state->timer_on = 0;
522   state->timer_mask = 0xf;
523   state->timer_val = 0;
29524}
30525
31static VIDEO_UPDATE( ti89 )
526/* video */
527
528static VIDEO_START( ti68k )
32529{
33    return 0;
530
34531}
35532
533static VIDEO_UPDATE( ti68k )
534{
535   /* preliminary implementation, doesn't use the contrast value */
536   t68k_state *state = (t68k_state *)screen->machine->driver_data;
537   const address_space *space = cputag_get_address_space(screen->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
538   UINT8 width = video_screen_get_width(screen);
539   UINT8 height = video_screen_get_height(screen);
540   UINT8 x, y, b;
541
542   if (!state->lcd_on || !state->lcd_base)
543      bitmap_fill(bitmap, NULL, 1);
544   else
545      for (y = 0; y < height; y++)
546         for (x = 0; x < width / 8; x++)
547         {
548            UINT8 s_byte= memory_read_byte(space, state->lcd_base + y * (width/8) + x);
549            for (b = 0; b<8; b++)
550               *BITMAP_ADDR16(bitmap, y, x * 8 + (7 - b)) = (BIT(s_byte, b) > 0) ? 0 : 1;
551         }
552
553   return 0;
554}
555
556
557MACHINE_START( ti68k )
558{
559   t68k_state *state = (t68k_state *)machine->driver_data;
560   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
561   UINT16 *rom = (UINT16 *)memory_region(space->machine, "maincpu");
562   int i;
563
564   state->mem_type= (rom[0x32] & 0x0f) ? EPROM : FLASH;
565
566   if (state->mem_type == FLASH)
567   {
568      UINT32 base = ((((rom[0x82]) << 16) | rom[0x83]) & 0xffff)>>1;
569
570      if (rom[base] >= 8)
571         state->hw_version = ((rom[base + 0x0b]) << 16) | rom[base + 0x0c];
572
573      if (!state->hw_version)
574         state->hw_version = HW1;
575
576      for (i = 0x9000; i < 0x100000; i++)
577         if (rom[i] == 0xcccc && rom[i + 1] == 0xcccc)
578            break;
579
580      state->initial_pc = ((rom[i + 4]) << 16) | rom[i + 5];
581   }
582   else
583   {
584      state->hw_version = HW1;
585      state->initial_pc = ((rom[2]) << 16) | rom[3];
586
587      memory_unmap_read(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x200000, 0x5fffff, 0, 0);
588
589      if (state->initial_pc > 0x400000)
590         memory_install_read16_handler( cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x400000, 0x5fffff, 0, 0, rom_r );
591      else
592         memory_install_read16_handler( cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x200000, 0x3fffff, 0, 0, rom_r );
593
594   }
595
596   timer_pulse(machine, ATTOTIME_IN_HZ(1<<14), NULL, 0, ti68k_timer_callback);
597}
598
599
36600static MACHINE_DRIVER_START( ti89 )
601
602   MDRV_DRIVER_DATA(t68k_state)
603
37604    /* basic machine hardware */
38605    MDRV_CPU_ADD("maincpu",M68000, XTAL_10MHz)
39606    MDRV_CPU_PROGRAM_MAP(ti89_mem)
40607
41    MDRV_MACHINE_RESET(ti89)
608    MDRV_MACHINE_RESET(ti68k)
42609
43610    /* video hardware */
44611    MDRV_SCREEN_ADD("screen", RASTER)
45612    MDRV_SCREEN_REFRESH_RATE(50)
46613    MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
47614    MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
48    MDRV_SCREEN_SIZE(640, 480)
49    MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
615    MDRV_SCREEN_SIZE(240, 128)
616    MDRV_SCREEN_VISIBLE_AREA(0, 160-1, 0, 100-1)
50617    MDRV_PALETTE_LENGTH(2)
618   MDRV_DEFAULT_LAYOUT(layout_lcd)
51619    MDRV_PALETTE_INIT(black_and_white)
52620
53    MDRV_VIDEO_START(ti89)
54    MDRV_VIDEO_UPDATE(ti89)
621    MDRV_VIDEO_START(ti68k)
622    MDRV_VIDEO_UPDATE(ti68k)
623
624   MDRV_MACHINE_START( ti68k )
625
626   MDRV_NVRAM_HANDLER(ti68k)
627
55628MACHINE_DRIVER_END
56629
630
631static MACHINE_DRIVER_START( ti92 )
632
633   MDRV_IMPORT_FROM( ti89 )
634
635    MDRV_CPU_MODIFY("maincpu")
636    MDRV_CPU_PROGRAM_MAP(ti92_mem)
637
638    /* video hardware */
639    MDRV_SCREEN_MODIFY("screen")
640    MDRV_SCREEN_VISIBLE_AREA(0, 240-1, 0, 128-1)
641
642
643MACHINE_DRIVER_END
644
645
646static MACHINE_DRIVER_START( ti92p )
647
648   MDRV_IMPORT_FROM( ti89 )
649
650    MDRV_CPU_REPLACE("maincpu",M68000, XTAL_12MHz)
651    MDRV_CPU_PROGRAM_MAP(ti92p_mem)
652
653    /* video hardware */
654    MDRV_SCREEN_MODIFY("screen")
655    MDRV_SCREEN_VISIBLE_AREA(0, 240-1, 0, 128-1)
656
657MACHINE_DRIVER_END
658
659
57660/* ROM definition */
58661ROM_START( ti89 )
59662  ROM_REGION( 0x200000, "maincpu", ROMREGION_ERASEFF )
60663  ROM_SYSTEM_BIOS( 0, "v100", "V 1.00 - HW1" )
61664  ROMX_LOAD( "ti89v100.rom",   0x000000, 0x200000, CRC(264b34ad) SHA1(c87586a7e9b6d49fbe908fbb6f3c0038f3498573), ROM_BIOS(1))
62  ROM_SYSTEM_BIOS( 1, "v100", "V 1.00 [a] - HW1" )
665  ROM_SYSTEM_BIOS( 1, "v100a", "V 1.00 [a] - HW1" )
63666  ROMX_LOAD( "ti89v100a.rom",  0x000000, 0x200000, CRC(95199934) SHA1(b8e3cdeb4705b0c7e0a15ab6c6f62bcde14a3a55), ROM_BIOS(2))
64  ROM_SYSTEM_BIOS( 2, "v100", "V 1.00 [m] - HW1" )
667  ROM_SYSTEM_BIOS( 2, "v100m", "V 1.00 [m] - HW1" )
65668  ROMX_LOAD( "ti89v100m.rom",  0x000000, 0x200000, CRC(b9059e06) SHA1(b33a7c2935eb9f73b210bcf6e7c7f32d1548a9d5), ROM_BIOS(3))
66  ROM_SYSTEM_BIOS( 3, "v100", "V 1.00 [m2] - HW1" )
669  ROM_SYSTEM_BIOS( 3, "v100m2", "V 1.00 [m2] - HW1" )
67670  ROMX_LOAD( "ti89v100m2.rom", 0x000000, 0x200000, CRC(cdd69d34) SHA1(1686362b0997bb9597f39b443490d4d8d85b56cc), ROM_BIOS(4))
68671  ROM_SYSTEM_BIOS( 4, "v105", "V 1.05 - HW1" )
69672  ROMX_LOAD( "ti89v105.rom",   0x000000, 0x200000, CRC(3bc0b474) SHA1(46fe0cd511eb81d53dc12cc4bdacec8a5bba5171), ROM_BIOS(5))
r8081r8082
92695ROM_END
93696
94697ROM_START( ti92 )
95  ROM_REGION( 0x300000, "maincpu", ROMREGION_ERASEFF )
96  // Internal ROM
97  ROM_LOAD( "ti92v111.rom",   0x000000, 0x100000, CRC(67878d52) SHA1(c0fdf162961922a76f286c93fd9b861ce20f23a3))
98  // External ROM
99  ROM_SYSTEM_BIOS( 0, "v13", "V 1.3" )
100  ROMX_LOAD( "ti92v13e.rom",  0x100000, 0x100000, CRC(316c8196) SHA1(82c8cd484c6aebe36f814a2023d2afad6d87f840), ROM_BIOS(1))
101  ROM_SYSTEM_BIOS( 1, "v14", "V 1.4" )
102  ROMX_LOAD( "ti92v14e.rom",  0x100000, 0x100000, CRC(239e9405) SHA1(df2f1ab17d490fda43a02f5851b5a15052361b28), ROM_BIOS(2))
103  ROM_SYSTEM_BIOS( 2, "v17", "V 1.7" )
104  ROMX_LOAD( "ti92v17e.rom",  0x100000, 0x100000, CRC(83e27cc5) SHA1(aec5a6a6157ff94a4e665fa3fe747bacb6688cd4), ROM_BIOS(3))
105  ROM_SYSTEM_BIOS( 3, "v111", "V 1.11" )
106  ROMX_LOAD( "ti92v111e.rom", 0x100000, 0x100000, CRC(4a343833) SHA1(ab4eaacc8c83a861c8d37df5c10e532d0d580460), ROM_BIOS(4))
107  ROM_SYSTEM_BIOS( 4, "v112", "V 1.12" )
108  ROMX_LOAD( "ti92v112e.rom", 0x100000, 0x100000, CRC(9a6947a0) SHA1(8bb0538ca98711e9ad46c56e4dfd609d4699be30), ROM_BIOS(5))
109  ROM_SYSTEM_BIOS( 5, "v21", "V 2.1" )
110  ROMX_LOAD( "ti92v21e.rom",  0x100000, 0x200000, CRC(5afb5863) SHA1(bf7b260d37d1502cc4b08dea5e1d55b523f27925), ROM_BIOS(6))
698  ROM_REGION( 0x200000, "maincpu", ROMREGION_ERASEFF )
699  ROM_SYSTEM_BIOS( 0, "v111", "V 1.11" )
700  ROMX_LOAD( "ti92v111.rom",  0x000000, 0x100000, CRC(67878d52) SHA1(c0fdf162961922a76f286c93fd9b861ce20f23a3), ROM_BIOS(1))
701  ROM_SYSTEM_BIOS( 1, "v13", "V 1.3" )
702  ROMX_LOAD( "ti92v13e.rom",  0x000000, 0x100000, CRC(316c8196) SHA1(82c8cd484c6aebe36f814a2023d2afad6d87f840), ROM_BIOS(2))
703  ROM_SYSTEM_BIOS( 2, "v14", "V 1.4" )
704  ROMX_LOAD( "ti92v14e.rom",  0x000000, 0x100000, CRC(239e9405) SHA1(df2f1ab17d490fda43a02f5851b5a15052361b28), ROM_BIOS(3))
705  ROM_SYSTEM_BIOS( 3, "v17", "V 1.7" )
706  ROMX_LOAD( "ti92v17e.rom",  0x000000, 0x100000, CRC(83e27cc5) SHA1(aec5a6a6157ff94a4e665fa3fe747bacb6688cd4), ROM_BIOS(4))
707  ROM_SYSTEM_BIOS( 4, "v111", "V 1.11" )
708  ROMX_LOAD( "ti92v111e.rom", 0x000000, 0x100000, CRC(4a343833) SHA1(ab4eaacc8c83a861c8d37df5c10e532d0d580460), ROM_BIOS(5))
709  ROM_SYSTEM_BIOS( 5, "v112", "V 1.12" )
710  ROMX_LOAD( "ti92v112e.rom", 0x000000, 0x100000, CRC(9a6947a0) SHA1(8bb0538ca98711e9ad46c56e4dfd609d4699be30), ROM_BIOS(6))
711  ROM_SYSTEM_BIOS( 6, "v21", "V 2.1" )
712  ROMX_LOAD( "ti92v21e.rom",  0x000000, 0x200000, CRC(5afb5863) SHA1(bf7b260d37d1502cc4b08dea5e1d55b523f27925), ROM_BIOS(7))
111713
112714ROM_END
113715
r8081r8082
140742/* Driver */
141743
142744/*    YEAR  NAME    PARENT  COMPAT   MACHINE    INPUT    INIT    COMPANY   FULLNAME       FLAGS */
143COMP( 1998, ti89,  0,       0,      ti89,   ti89,    0,       "Texas Instruments",   "TI-89",       GAME_NOT_WORKING | GAME_NO_SOUND)
144COMP( 1995, ti92,  0,       0,      ti89,   ti89,    0,       "Texas Instruments",   "TI-92",       GAME_NOT_WORKING | GAME_NO_SOUND)
145COMP( 1999, ti92p, 0,       0,      ti89,   ti89,    0,       "Texas Instruments",   "TI-92 Plus", GAME_NOT_WORKING | GAME_NO_SOUND)
146
745COMP( 1998, ti89,  0,       0,      ti89,   ti8x,    0,       "Texas Instruments",   "TI-89",       GAME_NO_SOUND)
746COMP( 1995, ti92,  0,       0,      ti92,   ti9x,    0,       "Texas Instruments",   "TI-92",       GAME_NO_SOUND)
747COMP( 1999, ti92p, 0,       0,      ti92p,   ti9x,    0,       "Texas Instruments",   "TI-92 Plus",    GAME_NO_SOUND)
src/mess/drivers/ti99_4p.c
r8081r8082
168168   /* 4 ports for keyboard and joystick */
169169   PORT_START("KEY0")   /* col 0 */
170170      PORT_BIT(0x0088, IP_ACTIVE_LOW, IPT_UNUSED)
171      /* The original control key is located on the left, but we accept the
172        right control key as well */
171      /* The original control key is located on the left, but we accept the right control key as well */
173172      PORT_BIT(0x0040, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CTRL") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL)
174173      /* TI99/4a has a second shift key which maps the same */
175174      PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
176      /* The original control key is located on the right, but we accept the
177        left function key as well */
175      /* The original control key is located on the right, but we accept the left function key as well */
178176      PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("FCTN") PORT_CODE(KEYCODE_RALT) PORT_CODE(KEYCODE_LALT) PORT_CHAR(UCHAR_SHIFT_2)
179177      PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("ENTER") PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
180178      PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("(SPACE)") PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
r8081r8082
262260};
263261
264262/*
265    we use a DAC to emulate "audio gate", even thought
263    We use a DAC to emulate "audio gate", even though
266264    a) there was no DAC in an actual TI99
267265    b) this is a 2-level output (whereas a DAC provides a 256-level output...)
268266*/
r8081r8082
278276   FLOPPY_OPTIONS_NAME(ti99),
279277   DO_NOT_KEEP_GEOMETRY
280278};
279
281280/*
282    machine description.
281    Machine description.
283282*/
284283static MACHINE_DRIVER_START(ti99_4p_60hz)
285284   /* basic machine hardware */
r8081r8082
313312//  MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20)
314313   MDRV_SOUND_ADD("sn76496", SN76496, 3579545)   /* 3.579545 MHz */
315314   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
316   MDRV_SOUND_ADD("tms5220", TMS5220, 680000L)
315   MDRV_SOUND_ADD("tmc0285", TMC0285, 680000L)
317316   MDRV_SOUND_CONFIG(ti99_4p_tms5220interface)
318317   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
319318
r8081r8082
359358   /* HSGPL memory space */
360359   ROM_REGION(region_hsgpl_len, region_hsgpl, ROMREGION_ERASEFF)
361360
362   /*TMS5220 ROM space*/
361   /*TMC0285 ROM space*/
363362   ROM_REGION(0x8000, region_speech_rom, 0)
364363   ROM_LOAD_OPTIONAL("spchrom.bin", 0x0000, 0x8000, CRC(58b155f7) SHA1(382292295c00dff348d7e17c5ce4da12a1d87763)) /* system speech ROM */
365364ROM_END
src/mess/drivers/ti99_4x.c
r8081r8082
88/*
99    TI99/4 info:
1010
11Similar to TI99/4a, except for the following:
11    Similar to TI99/4a, except for the following:
1212    * tms9918/9928 has no bitmap mode
1313    * smaller, 40-key keyboard
1414    * many small differences in the contents of system ROMs
1515
16Historical notes: TI made several last minute design changes.
16    Historical notes: TI made several last minute design changes.
1717    * TI99/4 prototypes had an extra port for an I/R joystick and keypad interface.
1818    * early TI99/4 prototypes were designed for a tms9985, not a tms9900.
1919*/
r8081r8082
4747#include "devices/ti99_hd.h"
4848
4949/*
50    memory map
50    Memory map
5151*/
5252
5353static ADDRESS_MAP_START(memmap, ADDRESS_SPACE_PROGRAM, 16)
r8081r8082
9090*/
9191
9292static ADDRESS_MAP_START(cru_map, ADDRESS_SPACE_IO, 8)
93        AM_RANGE(0x0000, 0x007f) AM_DEVREAD("tms9901", tms9901_cru_r)
94        AM_RANGE(0x0080, 0x00ff) AM_DEVREAD("ti99_multicart", ti99_multicart_cru_r)   /* SuperSpace */
95        AM_RANGE(0x0100, 0x01ff) AM_READ(ti99_4x_peb_cru_r)
93   AM_RANGE(0x0000, 0x007f) AM_DEVREAD("tms9901", tms9901_cru_r)
94   AM_RANGE(0x0080, 0x00ff) AM_DEVREAD("ti99_multicart", ti99_multicart_cru_r)   /* SuperSpace */
95   AM_RANGE(0x0100, 0x01ff) AM_READ(ti99_4x_peb_cru_r)
9696
9797   AM_RANGE(0x0000, 0x03ff) AM_DEVWRITE("tms9901", tms9901_cru_w)
98        AM_RANGE(0x0400, 0x07ff) AM_DEVWRITE("ti99_multicart", ti99_multicart_cru_w)   /* SuperSpace */
99        AM_RANGE(0x0800, 0x0fff) AM_WRITE(ti99_4x_peb_cru_w)
98   AM_RANGE(0x0400, 0x07ff) AM_DEVWRITE("ti99_multicart", ti99_multicart_cru_w)   /* SuperSpace */
99   AM_RANGE(0x0800, 0x0fff) AM_WRITE(ti99_4x_peb_cru_w)
100100ADDRESS_MAP_END
101101
102102/*
r8081r8082
157157      PORT_CONFSETTING(    0x01, "Mechatronics Mouse" )
158158
159159   PORT_START( "CARTSLOT" )
160   PORT_CONFNAME( 0x07, 0x00, "Cartridge slot" )
161      PORT_CONFSETTING(    0x00, "Auto" )
162      PORT_CONFSETTING(    0x01, "Slot 1" )
163      PORT_CONFSETTING(    0x02, "Slot 2" )
164      PORT_CONFSETTING(    0x03, "Slot 3" )
165      PORT_CONFSETTING(    0x04, "Slot 4" )
166//      PORT_CONFSETTING(    0x05, "GRAM Kracker" )
160   PORT_DIPNAME( 0x07, 0x00, "Cartridge slot" )
161      PORT_DIPSETTING(    0x00, "Auto" )
162      PORT_DIPSETTING(    0x01, "Slot 1" )
163      PORT_DIPSETTING(    0x02, "Slot 2" )
164      PORT_DIPSETTING(    0x03, "Slot 3" )
165      PORT_DIPSETTING(    0x04, "Slot 4" )
166//      PORT_DIPSETTING(    0x05, "GRAM Kracker" )
167167
168168   PORT_START( "HFDCDIP" )
169169   PORT_DIPNAME( 0xff, 0x55, "HFDC drive config" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 )
r8081r8082
192192   /* 4 ports for keyboard and joystick */
193193   PORT_START("KEY0")   /* col 0 */
194194      PORT_BIT(0x0088, IP_ACTIVE_LOW, IPT_UNUSED)
195      /* The original control key is located on the left, but we accept the
196        right control key as well */
195      /* The original control key is located on the left, but we accept the right control key as well */
197196      PORT_BIT(0x0040, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("CTRL")      PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL)
198197      /* TI99/4a has a second shift key which maps the same */
199198      PORT_BIT(0x0020, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
200      /* The original function key is located on the right, but we accept the
201        left alt key as well */
199      /* The original function key is located on the right, but we accept the left alt key as well */
202200      PORT_BIT(0x0010, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("FCTN")      PORT_CODE(KEYCODE_RALT) PORT_CODE(KEYCODE_LALT) PORT_CHAR(UCHAR_SHIFT_2)
203201      PORT_BIT(0x0004, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_ENTER) PORT_CHAR(13)
204202      PORT_BIT(0x0002, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_SPACE) PORT_CHAR(' ')
r8081r8082
333331      PORT_CONFSETTING(    0x04, DEF_STR( On ) )
334332
335333   PORT_START( "CARTSLOT" )
336   PORT_CONFNAME( 0x07, 0x00, "Cartridge slot" )
337      PORT_CONFSETTING(    0x00, "Auto" )
338      PORT_CONFSETTING(    0x01, "Slot 1" )
339      PORT_CONFSETTING(    0x02, "Slot 2" )
340      PORT_CONFSETTING(    0x03, "Slot 3" )
341      PORT_CONFSETTING(    0x04, "Slot 4" )
342//      PORT_CONFSETTING(    0x05, "GRAM Kracker" )
334   PORT_DIPNAME( 0x07, 0x00, "Cartridge slot" )
335      PORT_DIPSETTING(    0x00, "Auto" )
336      PORT_DIPSETTING(    0x01, "Slot 1" )
337      PORT_DIPSETTING(    0x02, "Slot 2" )
338      PORT_DIPSETTING(    0x03, "Slot 3" )
339      PORT_DIPSETTING(    0x04, "Slot 4" )
340//      PORT_DIPSETTING(    0x05, "GRAM Kracker" )
343341
344342   PORT_START( "HFDCDIP" )
345343   PORT_DIPNAME( 0xff, 0x55, "HFDC drive config" ) PORT_CONDITION( "DISKCTRL", 0x07, PORTCOND_EQUALS, 0x03 )
r8081r8082
642640
643641
644642/*
645    TMS0285 speech synthesizer
643    TMS5220 speech synthesizer
644    Note that in the real hardware, the predecessor TMC0285 was used.
646645*/
647646static const tms5220_interface ti99_4x_tms5220interface =
648647{
r8081r8082
697696   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.20)
698697   MDRV_SOUND_ADD("sn76496", SN94624, 3579545/8)   /* 3.579545 MHz */
699698   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
700   MDRV_SOUND_ADD("tms5220", TMS5220, 680000L)
699   MDRV_SOUND_ADD("tmc0285", TMC0285, 680000L)
701700   MDRV_SOUND_CONFIG(ti99_4x_tms5220interface)
702701   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
703702
r8081r8082
749748   MDRV_SPEAKER_STANDARD_MONO("mono")
750749   MDRV_SOUND_ADD("sn76496", SN94624, 3579545/8)   /* 3.579545 MHz */
751750   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
752   MDRV_SOUND_ADD("tms5220", TMS5220, 680000L)
751   MDRV_SOUND_ADD("tmc0285", TMC0285, 680000L)
753752   MDRV_SOUND_CONFIG(ti99_4x_tms5220interface)
754753   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
755754   MDRV_SOUND_WAVE_ADD("wave.1", "cassette1")
r8081r8082
803802   MDRV_SPEAKER_STANDARD_MONO("mono")
804803   MDRV_SOUND_ADD("sn76496", SN94624, 3579545/8)   /* 3.579545 MHz SN94624N */
805804   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
806   MDRV_SOUND_ADD("tms5220", TMS5220, 680000L)
805   MDRV_SOUND_ADD("tmc0285", TMC0285, 680000L)
807806   MDRV_SOUND_CONFIG(ti99_4x_tms5220interface)
808807   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
809808   MDRV_SOUND_WAVE_ADD("wave.1", "cassette1")
r8081r8082
859858   MDRV_SPEAKER_STANDARD_MONO("mono")
860859   MDRV_SOUND_ADD("sn76496", SN94624, 3579545/8)   /* 3.579545 MHz */
861860   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
862   MDRV_SOUND_ADD("tms5220", TMS5220, 680000L)
861   MDRV_SOUND_ADD("tmc0285", TMC0285, 680000L)
863862   MDRV_SOUND_CONFIG(ti99_4x_tms5220interface)
864863   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
865864   MDRV_SOUND_WAVE_ADD("wave.1", "cassette1")
r8081r8082
922921   MDRV_SPEAKER_STANDARD_MONO("mono")
923922   MDRV_SOUND_ADD("sn76496", SN94624, 3579545/8)   /* 3.579545 MHz */
924923   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.75)
925   MDRV_SOUND_ADD("tms5220", TMS5220, 680000L)
924   MDRV_SOUND_ADD("tmc0285", TMC0285, 680000L)
926925   MDRV_SOUND_CONFIG(ti99_4x_tms5220interface)
927926   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
928927   MDRV_SOUND_WAVE_ADD("wave.1", "cassette1")
r8081r8082
956955
957956/*
958957    ROM loading
959
960958    Note that we use the same ROMset for 50Hz and 60Hz versions.
961959*/
962960
docs/messnew.txt
r8081r8082
88
99Systems Promoted from GAME_NOT_WORKING:
1010---------------------------------------
11(none)
11- TI-89, TI-92, TI-92+ [Sandro Ronco]
1212
1313
1414
r8081r8082
132132- [SNES] Fixed rom mapping: now Tokimeki Memorial and Wizardry Gaiden work fine.
133133  [Fabio Priuli]
134134
135- [SNES] Added preliminary support for Sufami Turbo (2 slots): you can use
136  the 'snesst' driver which emulates a SNES with Sufami Turbo cart inserted,
137  and use -cart1 and -cart2 slots to mount the ST carts. Notice that some
138  games and some linking functionalities are not working yet. [Fabio Priuli]
139
135140- [SUPERGB] Added cart SRAM saving (bug #1949).  [Fabio Priuli]
136141
137142- [SX64] Added 1541 FLASH! BIOS. [Guru, Curt Coder]
r8081r8082
151156
152157- [TI99] Replaced DIP switches by Configuration switches.  [Michael Zapf]
153158
159- [TI99] Updated to use TMC0285 voice synthesis processor instead of TMS5220. 
160  [Michael Zapf]
161
154162- [VBOY] Added .hsi file with hashes from GoodVBoy V3.1415 [Cowering]
155163
156164- [VIC20] Fixed quick-loading from the commandline (bug #1935). [Robbbert]

Previous 15994 Revisions Next


© 1998-2018 The MESS Team