Previous 15994 Revisions Next

r10322 Sunday 6th February, 2011 at 20:45:25 UTC by Fabio Priuli
[A800] cart handling clean up, part II:
* added preliminary handling for various mappers to a400 & a800
(it works if you load by softlist, but it should work also if you load
by fullpath a cart which has a correct CART header)
* added the a800 softlist to XL/XE systems too (only plain 8K & 16K
carts are allowed to be loaded: other types will require more work
on the memory map of these computers)
[src/mess/drivers]atari.c
[src/mess/machine]ataricrt.c

src/mess/machine/ataricrt.c
r10321r10322
1010#include "ataridev.h"
1111#include "machine/ram.h"
1212
13#define LEFT_CARTSLOT_MOUNTED  1
14#define RIGHT_CARTSLOT_MOUNTED 2
15
16/* PCB */
17enum
18{
19    A800_UNKNOWN = 0,
20   A800_4K, A800_8K, A800_12K, A800_16K,
21   A800_RIGHT_4K, A800_RIGHT_8K,
22   OSS_034M, OSS_M091, PHOENIX_8K, XEGS_32K,
23   BBSB, DIAMOND_64K, WILLIAMS_64K, EXPRESS_64,
24   SPARTADOS_X
25};
26
1327static int a800_cart_loaded = 0;
14static int a800_cart_is_16k = 0;
1528static int atari = 0;
29static int a800_cart_type = A800_UNKNOWN;
1630
17#define LEFT_CARTSLOT_MOUNTED  1
18#define RIGHT_CARTSLOT_MOUNTED 2
19
2031/*************************************
2132 *
2233 *  Generic code
r10321r10322
4051   {
4152      memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0x9fff, 0, 0, "8000");
4253      memory_set_bankptr(machine, "8000", machine->region("rslot")->base());
43      memory_nop_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0x9fff, 0, 0);
54      memory_unmap_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0x9fff, 0, 0);
4455   }
45   else
56   else if (a800_cart_type != BBSB)
4657   {
4758      ram_top = MIN(ram_get_size(machine->device(RAM_TAG)), 0xa000) - 1;
4859      if (ram_top > 0x8000)
r10321r10322
5566   // take care of 0xa000-0xbfff: is there anything in the left slot?
5667   if (cart_mounted & LEFT_CARTSLOT_MOUNTED)
5768   {
69      // FIXME: this is an hack to keep XL working until we clean up its memory map as well!
5870      if (atari == ATARI_800XL)
5971      {
60         // FIXME: this is an hack to keep XL working until we clean up its memory map as well!
61         if (a800_cart_is_16k)
72         if (a800_cart_type == A800_16K)
6273         {
6374            memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0x9fff, 0, 0, "8000");
6475            memory_set_bankptr(machine, "8000", machine->region("lslot")->base());
65            memory_nop_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0x9fff, 0, 0);
76            memory_unmap_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0x9fff, 0, 0);
6677
6778            memcpy(machine->region("maincpu")->base() + 0x10000, machine->region("lslot")->base() + 0x2000, 0x2000);
6879         }
80         else if (a800_cart_type == A800_8K)
81            memcpy(machine->region("maincpu")->base() + 0x10000, machine->region("lslot")->base(), 0x2000);
6982         else
70            memcpy(machine->region("maincpu")->base() + 0x10000, machine->region("lslot")->base(), 0x2000);
83            fatalerror("This type of cart is not supported yet in this driver. Please use a400 or a800.\n");
7184      }
72      else if (a800_cart_is_16k)
85      else if (a800_cart_type == A800_16K)
7386      {
7487         memory_set_bankptr(machine, "8000", machine->region("lslot")->base());
7588         memory_set_bankptr(machine, "a000", machine->region("lslot")->base() + 0x2000);
76         memory_nop_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0);
89         memory_unmap_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0);
7790      }
91      else if (a800_cart_type == BBSB)
92      {
93         // this requires separate banking in 0x8000 & 0x9000!
94         memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0x8fff, 0, 0, "8000");
95         memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x9000, 0x9fff, 0, 0, "9000");
96         memory_set_bankptr(machine, "8000", machine->region("lslot")->base() + 0x0000);   
97         memory_set_bankptr(machine, "9000", machine->region("lslot")->base() + 0x4000);   
98         memory_set_bankptr(machine, "a000", machine->region("lslot")->base() + 0x8000);
99         memory_unmap_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa000, 0xbfff, 0, 0);
100      }
101      else if (a800_cart_type == OSS_034M)
102      {
103         // this requires separate banking in 0xa000 & 0xb000!
104         memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa000, 0xafff, 0, 0, "a000");
105         memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xb000, 0xbfff, 0, 0, "b000");
106         memory_set_bankptr(machine, "b000", machine->region("lslot")->base() + 0x3000);
107         memory_unmap_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa000, 0xbfff, 0, 0);
108      }
109      else if (a800_cart_type == OSS_M091)
110      {
111         // this requires separate banking in 0xa000 & 0xb000!
112         memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa000, 0xafff, 0, 0, "a000");
113         memory_install_read_bank(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xb000, 0xbfff, 0, 0, "b000");
114         memory_set_bankptr(machine, "b000", machine->region("lslot")->base());
115         memory_unmap_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa000, 0xbfff, 0, 0);
116      }
117      else if (a800_cart_type == XEGS_32K)
118      {
119         memory_set_bankptr(machine, "8000", machine->region("lslot")->base());
120         memory_set_bankptr(machine, "a000", machine->region("lslot")->base() + 0x6000);
121         memory_unmap_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0xbfff, 0, 0);
122      }
78123      else
79124      {
80125         memory_set_bankptr(machine, "a000", machine->region("lslot")->base());
81         memory_nop_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa000, 0xbfff, 0, 0);
126         memory_unmap_write(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xa000, 0xbfff, 0, 0);
82127      }
83128   }
84129}
r10321r10322
123168   ms_atari_machine_start(machine, ATARI_800, TRUE);
124169}
125170
171static WRITE8_HANDLER( x32_bank_w )
172{
173   //   printf("written %x\n", data);
174   int bank = data & 0x03;
175   memory_set_bankptr(space->machine, "8000", space->machine->region("lslot")->base() + bank * 0x2000);
176}
126177
127/* PCB */
128enum
178static WRITE8_HANDLER( w64_bank_w )
129179{
130    A800_UNKNOWN = 0,
131   A800_4K, A800_8K, A800_12K, A800_16K,
132   A800_RIGHT_4K, A800_RIGHT_8K,
133   OSS_034M, OSS_M091, PHOENIX_8K, XEGS_32K,
134   BBSB, DIAMOND_64K, WILLIAMS_64K, EXPRESS_64,
135   SPARTADOS_X
136};
180//   printf("write to %x\n", offset);
137181
182   if (offset < 8)
183      memory_set_bankptr(space->machine, "a000", space->machine->region("lslot")->base() + offset * 0x2000);   
184   else
185      memory_set_bankptr(space->machine, "a000", space->machine->region("maincpu")->base());   
186   // FIXME: writes to 0x8-0xf should disable the cart
187}
188
189// this covers Express 64, Diamond 64 and SpartaDOS (same bankswitch, but at different addresses)
190static WRITE8_HANDLER( ex64_bank_w )
191{
192//   printf("write to %x\n", offset);
193
194   if (offset < 8)
195      memory_set_bankptr(space->machine, "a000", space->machine->region("lslot")->base() + (7 - offset) * 0x2000);   
196   else
197      memory_set_bankptr(space->machine, "a000", space->machine->region("maincpu")->base());   
198   // FIXME: writes to 0x8-0xf should disable the cart
199}
200
201static WRITE8_HANDLER( bbsb_bankl_w )
202{
203//   printf("write to %x\n", 0x8000 + offset);
204   if (offset >= 0xff6 && offset <= 0xff9)
205      memory_set_bankptr(space->machine, "8000", space->machine->region("lslot")->base() + 0x0000 + (offset - 0xff6) * 0x1000);   
206}
207
208static WRITE8_HANDLER( bbsb_bankh_w )
209{
210//   printf("write to %x\n", 0x9000 + offset);
211   if (offset >= 0xff6 && offset <= 0xff9)
212      memory_set_bankptr(space->machine, "9000", space->machine->region("lslot")->base() + 0x4000 + (offset - 0xff6) * 0x1000);   
213}
214
215static WRITE8_HANDLER( oss_034m_w )
216{
217   switch (offset & 0x0f)
218   {
219      case 0:
220      case 1:
221         memory_set_bankptr(space->machine, "a000", space->machine->region("lslot")->base());   
222         memory_set_bankptr(space->machine, "b000", space->machine->region("lslot")->base() + 0x3000);
223         break;
224      case 2:
225      case 6:
226         // docs says this should put 0xff in the 0xa000 bank -> let's point to the end of the cart
227         memory_set_bankptr(space->machine, "a000", space->machine->region("lslot")->base() + 0x4000);   
228         memory_set_bankptr(space->machine, "b000", space->machine->region("lslot")->base() + 0x3000);
229         break;
230      case 3:
231      case 7:
232         memory_set_bankptr(space->machine, "a000", space->machine->region("lslot")->base() + 0x1000);   
233         memory_set_bankptr(space->machine, "b000", space->machine->region("lslot")->base() + 0x3000);
234         break;
235      case 4:
236      case 5:
237         memory_set_bankptr(space->machine, "a000", space->machine->region("lslot")->base() + 0x2000);   
238         memory_set_bankptr(space->machine, "b000", space->machine->region("lslot")->base() + 0x3000);
239         break;
240      default:
241         memory_set_bankptr(space->machine, "a000", space->machine->region("maincpu")->base() + 0xa000);   
242         memory_set_bankptr(space->machine, "b000", space->machine->region("maincpu")->base() + 0xb000);
243         break;
244   }
245}
246
247static WRITE8_HANDLER( oss_m091_w )
248{
249   switch (offset & 0x09)
250   {
251      case 0:
252         memory_set_bankptr(space->machine, "a000", space->machine->region("lslot")->base() + 0x1000);   
253         memory_set_bankptr(space->machine, "b000", space->machine->region("lslot")->base());
254         break;
255      case 1:
256         memory_set_bankptr(space->machine, "a000", space->machine->region("lslot")->base() + 0x3000);   
257         memory_set_bankptr(space->machine, "b000", space->machine->region("lslot")->base());
258         break;
259      case 8:
260         memory_set_bankptr(space->machine, "a000", space->machine->region("maincpu")->base() + 0xa000);   
261         memory_set_bankptr(space->machine, "b000", space->machine->region("maincpu")->base() + 0xb000);
262         break;
263      case 9:
264         memory_set_bankptr(space->machine, "a000", space->machine->region("lslot")->base() + 0x2000);   
265         memory_set_bankptr(space->machine, "b000", space->machine->region("lslot")->base());
266         break;
267   }
268}
269
270#if 0
271static int bbsb_bankl = 0;
272static int bbsb_bankh = 0;
273
274static WRITE8_HANDLER( bbsb_bankl_w )
275{
276   bbsb_bankl = offset; // 0,1,2,3
277}
278
279static WRITE8_HANDLER( bbsb_bankh_w )
280{
281   bbsb_bankh = offset; // 4,5,6,7
282}
283
284static READ8_HANDLER( bbsb_bankl_r )
285{
286   // return data from the selected bank (0,1,2,3)
287   UINT8 *mem = space->machine->region("lslot")->base();
288   return &mem[0x0000 + bbsb_bankl * 0x1000];
289}
290
291static READ8_HANDLER( bbsb_bankh_r )
292{
293   // return data from the selected bank (4,5,6,7)
294   UINT8 *mem = space->machine->region("lslot")->base();
295   return &mem[0x4000 + bbsb_bankh * 0x1000];
296}
297#endif
298
138299typedef struct _a800_pcb  a800_pcb;
139300struct _a800_pcb
140301{
r10321r10322
146307// WARNING: most of these are still unsupported by the driver
147308static const a800_pcb pcb_list[] =
148309{
149   {"standard 4k", A800_4K},
310   {"standard 4k", A800_8K},
150311   {"standard 8k", A800_8K},
151   {"standard 12k", A800_12K},
312   {"standard 12k", A800_16K},
152313   {"standard 16k", A800_16K},
153314   {"right slot 4k", A800_RIGHT_4K},
154315   {"right slot 8k", A800_RIGHT_8K},
r10321r10322
189350      case A800_8K:
190351      case A800_16K:
191352      case A800_RIGHT_8K:
353      case PHOENIX_8K:   // as normal 8k cart, but it can be disabled by writing to 0xd500-0xdfff
354         break;
355      case XEGS_32K:
356         memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd500, 0xd5ff, 0, 0, x32_bank_w);
357         break;
192358      case OSS_034M:
359         memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd500, 0xd5ff, 0, 0, oss_034m_w);
360         break;
193361      case OSS_M091:
194      case PHOENIX_8K:
195      case XEGS_32K:
362         memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd500, 0xd5ff, 0, 0, oss_m091_w);
363         break;
196364      case BBSB:
365         memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0x8fff, 0, 0, bbsb_bankl_w);
366         memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x9000, 0x9fff, 0, 0, bbsb_bankh_w);
367         break;
368      case WILLIAMS_64K:
369         memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd500, 0xd50f, 0, 0, w64_bank_w);
370         break;
197371      case DIAMOND_64K:
198      case WILLIAMS_64K:
372         memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd5d0, 0xd5df, 0, 0, ex64_bank_w);
373         break;
199374      case EXPRESS_64:
375         memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd570, 0xd57f, 0, 0, ex64_bank_w);
376         break;
200377      case SPARTADOS_X:
378         memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xd5e0, 0xd5ef, 0, 0, ex64_bank_w);
379         break;
201380      default:
202381         break;
203382   }
r10321r10322
290469         else
291470            type = A800_8K;
292471      }
293     
294      if ((strcmp(image.device().tag(),"cart2") == 0) && (type != A800_RIGHT_8K))
295         fatalerror("You cannot load this image '%s' in the right slot", image.filename());
296472   }
297473   else
298474   {
r10321r10322
314490            break;
315491      }
316492   }
493   
494   if ((strcmp(image.device().tag(),"cart2") == 0) && (type != A800_RIGHT_8K))
495      fatalerror("You cannot load this image '%s' in the right slot", image.filename());
496
317497   return type;
318498}
319499
320500DEVICE_IMAGE_LOAD( a800_cart )
321501{
322   int cart_type;
323502   UINT32 size, start = 0;
324503
325504   a800_cart_loaded = a800_cart_loaded & ~LEFT_CARTSLOT_MOUNTED;
326   a800_cart_is_16k = 0;
327   cart_type = a800_check_cart_type(image);
505   a800_cart_type = a800_check_cart_type(image);
328506
329   a800_setup_mappers(image.device().machine, cart_type);
507   a800_setup_mappers(image.device().machine, a800_cart_type);
330508
331509   if (image.software_entry() == NULL)
332510   {
r10321r10322
346524   }   
347525
348526   a800_cart_loaded |= (size > 0x0000) ? 1 : 0;
349   a800_cart_is_16k = (size > 0x2000) ? 1 : 0;
350527
351   logerror("%s loaded left cartridge '%s' size %s\n", image.device().machine->gamedrv->name, image.filename(), (a800_cart_is_16k) ? "16K":"8K");
528   logerror("%s loaded left cartridge '%s' size %dK\n", image.device().machine->gamedrv->name, image.filename(), size/1024);
352529   return IMAGE_INIT_PASS;
353530}
354531
355532DEVICE_IMAGE_LOAD( a800_cart_right )
356533{
357   int cart_type;
358534   UINT32 size, start = 0;
359535   
360536   a800_cart_loaded = a800_cart_loaded & ~RIGHT_CARTSLOT_MOUNTED;
361   cart_type = a800_check_cart_type(image);
537   a800_cart_type = a800_check_cart_type(image);
362538   
363   a800_setup_mappers(image.device().machine, cart_type);
539   a800_setup_mappers(image.device().machine, a800_cart_type);
364540   
365541   if (image.software_entry() == NULL)
366542   {
r10321r10322
387563
388564DEVICE_IMAGE_UNLOAD( a800_cart )
389565{
390   a800_cart_is_16k = 0;
391566   a800_cart_loaded = a800_cart_loaded & ~LEFT_CARTSLOT_MOUNTED;
567   a800_cart_type = A800_UNKNOWN;
392568   a800_setbank(image.device().machine, a800_cart_loaded);
393569}
394570
395571DEVICE_IMAGE_UNLOAD( a800_cart_right )
396572{
397573   a800_cart_loaded = a800_cart_loaded & ~RIGHT_CARTSLOT_MOUNTED;
574   a800_cart_type = A800_UNKNOWN;
398575   a800_setbank(image.device().machine, a800_cart_loaded);
399576}
400577
src/mess/drivers/atari.c
r10321r10322
11701170
11711171   MCFG_FRAGMENT_ADD(a400_cartslot)
11721172
1173   /* software lists */
1174   MCFG_SOFTWARE_LIST_ADD("cart_list","a800")
1175
11731176   /* internal ram */
11741177   MCFG_RAM_MODIFY(RAM_TAG)
11751178   MCFG_RAM_DEFAULT_SIZE("16K")
r10321r10322
11911194   MCFG_SCREEN_SIZE(HWIDTH*8, TOTAL_LINES_60HZ)
11921195
11931196   MCFG_FRAGMENT_ADD(a400_cartslot)
1197
1198   /* software lists */
1199   MCFG_SOFTWARE_LIST_ADD("cart_list","a800")
11941200MACHINE_CONFIG_END
11951201
11961202static MACHINE_CONFIG_DERIVED( a800xlpal, a800xl )
r10321r10322
12211227   MCFG_PIA6821_MODIFY( "pia", xegs_pia_interface )
12221228
12231229   MCFG_DEVICE_REMOVE("cart1")
1230   MCFG_DEVICE_REMOVE("cart_list")
12241231
12251232   MCFG_CARTSLOT_ADD("cart1")
12261233   MCFG_CARTSLOT_EXTENSION_LIST("rom,bin")

Previous 15994 Revisions Next


© 1998-2018 The MESS Team