Previous 15994 Revisions Next

r4186 Friday 23rd January, 2009 at 14:37:37 UTC by Dirk Best
[A7800] More cleanups
[src/mess/machine]a7800.c

src/mess/machine/a7800.c
r4185r4186
2121***************************************************************************/
2222
2323#include "driver.h"
24#include "includes/a7800.h"
2425#include "cpu/m6502/m6502.h"
2526#include "sound/tiasound.h"
26#include "hash.h"
27#include "image.h"
2827#include "machine/6532riot.h"
2928#include "sound/pokey.h"
3029#include "sound/tiaintf.h"
30#include "hash.h"
3131
32#include "includes/a7800.h"
3332
3433int a7800_lines;
3534int a7800_ispal;
r4185r4186
4847static UINT8 *ROM;
4948
5049
51/****** RIOT ****************************************/
50/***************************************************************************
51    6532 RIOT
52***************************************************************************/
5253
53/* TODO: Convert the definitions into a syntax accepting input_port_read */
54
55static UINT8 riot_input_port_0_r(const device_config *device, UINT8 olddata)
54static UINT8 riot_joystick_r(const device_config *device, UINT8 olddata)
5655{
57   return input_port_0_r(cpu_get_address_space(device->machine->cpu[0],ADDRESS_SPACE_PROGRAM), 0);
56   return input_port_read(device->machine, "joysticks");
5857}
5958
60static UINT8 riot_input_port_3_r(const device_config *device, UINT8 olddata)
59static UINT8 riot_console_button_r(const device_config *device, UINT8 olddata)
6160{
62   return input_port_3_r(cpu_get_address_space(device->machine->cpu[0],ADDRESS_SPACE_PROGRAM), 0);
61   return input_port_read(device->machine, "console_buttons");
6362}
6463
6564const riot6532_interface r6532_interface =
6665{
67   riot_input_port_0_r,
68   riot_input_port_3_r,
66   riot_joystick_r,
67   riot_console_button_r,
6968   NULL,
7069   NULL
7170};
7271
7372
74/* -----------------------------------------------------------------------
75 * Driver/Machine Init
76 * ----------------------------------------------------------------------- */
73/***************************************************************************
74    DRIVER INIT
75***************************************************************************/
7776
7877static void a7800_driver_init(running_machine *machine, int ispal, int lines)
7978{
r4185r4186
9796}
9897
9998
100
10199DRIVER_INIT( a7800_ntsc )
102100{
103101   a7800_driver_init(machine, FALSE, 262);
104102}
105103
106104
107
108105DRIVER_INIT( a7800_pal )
109106{
110107   a7800_driver_init(machine, TRUE, 312);
111108}
112109
113110
114
115111MACHINE_RESET( a7800 )
116112{
117113   UINT8 *memory;
r4185r4186
137133}
138134
139135
136/***************************************************************************
137    CARTRIDGE HANDLING
138***************************************************************************/
140139
141/* ----------------------------------------------------------------------- */
142
143140#define MBANK_TYPE_ATARI 0x0000
144141#define MBANK_TYPE_ACTIVISION 0x0100
145142#define MBANK_TYPE_ABSOLUTE 0x0200
r4185r4186
185182}
186183
187184
188
189185static int a7800_verify_cart(char header[128])
190186{
191187   const char* tag = "ATARI7800";
r4185r4186
200196   return IMAGE_VERIFY_PASS;
201197}
202198
199
203200DEVICE_START( a7800_cart )
204201{
205202   UINT8   *memory;
r4185r4186
220217   a7800_stick_type = 1;
221218}
222219
220
223221DEVICE_IMAGE_LOAD( a7800_cart )
224222{
225223   long len,start;
r4185r4186
332330}
333331
334332
335/******  TIA  *****************************************/
336
337 READ8_HANDLER( a7800_TIA_r )
338{
339   switch(offset)
340   {
341      case 0x08:
342           return((input_port_read(space->machine, "buttons") & 0x02) << 6);
343      case 0x09:
344           return((input_port_read(space->machine, "buttons") & 0x08) << 4);
345      case 0x0A:
346           return((input_port_read(space->machine, "buttons") & 0x01) << 7);
347      case 0x0B:
348           return((input_port_read(space->machine, "buttons") & 0x04) << 5);
349      case 0x0c:
350         if((input_port_read(space->machine, "buttons") & 0x08) ||(input_port_read(space->machine, "buttons") & 0x02))
351            return 0x00;
352         else
353            return 0x80;
354      case 0x0d:
355         if((input_port_read(space->machine, "buttons") & 0x01) ||(input_port_read(space->machine, "buttons") & 0x04))
356            return 0x00;
357         else
358            return 0x80;
359      default:
360         logerror("undefined TIA read %x\n",offset);
361
362   }
363   return 0xFF;
364}
365
366WRITE8_HANDLER( a7800_TIA_w )
367{
368   switch(offset) {
369   case 0x01:
370      if(data & 0x01)
371      {
372         maria_flag=1;
373      }
374      if(!a7800_ctrl_lock)
375      {
376         a7800_ctrl_lock = data & 0x01;
377         a7800_ctrl_reg = data;
378
379         if (data & 0x04)
380            memcpy( ROM + 0xC000, a7800_cart_bkup, 0x4000 );
381         else
382            memcpy( ROM + 0xC000, a7800_bios_bkup, 0x4000 );
383      }
384      break;
385   }
386   tia_sound_w(space, offset,data);
387   ROM[offset] = data;
388}
389
390
391
392/****** RAM Mirroring ******************************/
393
394333WRITE8_HANDLER( a7800_RAM0_w )
395334{
396335   ROM[0x2040 + offset] = data;
397336   ROM[0x40 + offset] = data;
398337}
399338
339
400340WRITE8_HANDLER( a7800_cart_w )
401341{
402342   UINT8 *memory = memory_region(space->machine, "main");
r4185r4186
458398}
459399
460400
401/***************************************************************************
402    TIA
403***************************************************************************/
404
405READ8_HANDLER( a7800_TIA_r )
406{
407   switch(offset)
408   {
409      case 0x08:
410           return((input_port_read(space->machine, "buttons") & 0x02) << 6);
411      case 0x09:
412           return((input_port_read(space->machine, "buttons") & 0x08) << 4);
413      case 0x0A:
414           return((input_port_read(space->machine, "buttons") & 0x01) << 7);
415      case 0x0B:
416           return((input_port_read(space->machine, "buttons") & 0x04) << 5);
417      case 0x0c:
418         if((input_port_read(space->machine, "buttons") & 0x08) ||(input_port_read(space->machine, "buttons") & 0x02))
419            return 0x00;
420         else
421            return 0x80;
422      case 0x0d:
423         if((input_port_read(space->machine, "buttons") & 0x01) ||(input_port_read(space->machine, "buttons") & 0x04))
424            return 0x00;
425         else
426            return 0x80;
427      default:
428         logerror("undefined TIA read %x\n",offset);
429
430   }
431   return 0xFF;
432}
433
434
435WRITE8_HANDLER( a7800_TIA_w )
436{
437   switch(offset) {
438   case 0x01:
439      if(data & 0x01)
440      {
441         maria_flag=1;
442      }
443      if(!a7800_ctrl_lock)
444      {
445         a7800_ctrl_lock = data & 0x01;
446         a7800_ctrl_reg = data;
447
448         if (data & 0x04)
449            memcpy( ROM + 0xC000, a7800_cart_bkup, 0x4000 );
450         else
451            memcpy( ROM + 0xC000, a7800_bios_bkup, 0x4000 );
452      }
453      break;
454   }
455   tia_sound_w(space, offset,data);
456   ROM[offset] = data;
457}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team