Previous 199869 Revisions Next

r32027 Tuesday 9th September, 2014 at 18:03:05 UTC by Fabio Priuli
antic.c: converted to be a device. [Fabio Priuli]
[src/mame/drivers]bartop52.c maxaflex.c
[src/mame/includes]atari.h
[src/mame/machine]atari.c
[src/mame/video]antic.c antic.h atari.c
[src/mess/drivers]atari400.c

trunk/src/mame/machine/atari.c
r32026r32027
99***************************************************************************/
1010
1111#include "emu.h"
12#include "cpu/m6502/m6502.h"
1312#include "includes/atari.h"
1413#include "sound/pokey.h"
15#include "sound/dac.h"
1614
1715#define VERBOSE_POKEY   1
1816#define VERBOSE_SERIAL  1
trunk/src/mame/includes/atari.h
r32026r32027
2424   atari_common_state(const machine_config &mconfig, device_type type, const char *tag)
2525      : driver_device(mconfig, type, tag),
2626      m_gtia(*this, "gtia"),
27      tv_artifacts(0) { }
27      m_antic(*this, "antic")
28      { }
2829
29   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
30
3130   virtual void video_start();
32   UINT32 screen_update_atari(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
3331
3432   TIMER_DEVICE_CALLBACK_MEMBER( a400_interrupt );
3533   TIMER_DEVICE_CALLBACK_MEMBER( a800_interrupt );
r32026r32027
3836
3937   DECLARE_PALETTE_INIT(atari);
4038
41   DECLARE_READ8_MEMBER ( atari_antic_r );
42   DECLARE_WRITE8_MEMBER ( atari_antic_w );
43
4439   POKEY_INTERRUPT_CB_MEMBER(interrupt_cb);
4540   POKEY_KEYBOARD_CB_MEMBER(a5200_keypads);
4641   POKEY_KEYBOARD_CB_MEMBER(a800_keyboard);
4742
4843private:
49   static const device_timer_id TIMER_CYCLE_STEAL = 0;
50   static const device_timer_id TIMER_ISSUE_DLI = 1;
51   static const device_timer_id TIMER_LINE_REND = 2;
52   static const device_timer_id TIMER_LINE_DONE = 3;
53
5444   required_device<gtia_device> m_gtia;
55   UINT32 tv_artifacts;
56   void prio_init();
57   void cclk_init();
58   void artifacts_gfx(UINT8 *src, UINT8 *dst, int width);
59   void artifacts_txt(UINT8 * src, UINT8 * dst, int width);
60   void antic_linerefresh();
61   int cycle();
62   void after(int cycles, timer_expired_delegate function);
63   TIMER_CALLBACK_MEMBER( antic_issue_dli );
64   TIMER_CALLBACK_MEMBER( antic_line_done );
65   TIMER_CALLBACK_MEMBER( antic_steal_cycles );
66   TIMER_CALLBACK_MEMBER( antic_scanline_render );
67   inline void LMS(int new_cmd);
68   void antic_scanline_dma(int param);
69   void generic_atari_interrupt(int button_count);
70   
71   int m_antic_render1, m_antic_render2, m_antic_render3;
45   required_device<antic_device> m_antic;
7246};
7347
74/* video */
75
76#define CYCLES_PER_LINE 114     /* total number of cpu cycles per scanline (incl. hblank) */
77#define CYCLES_REFRESH  9       /* number of cycles lost for ANTICs RAM refresh using DMA */
78#define CYCLES_HSTART   32      /* where does the ANTIC DMA fetch start */
79#define CYCLES_DLI_NMI  7       /* number of cycles until the CPU recognizes a DLI */
80#define CYCLES_HSYNC    104     /* where does the HSYNC position of a scanline start */
81
82#define VBL_END         8       /* vblank ends in this scanline */
83#define VDATA_START     11      /* video display begins in this scanline */
84#define VDATA_END       244     /* video display ends in this scanline */
85#define VBL_START       248     /* vblank starts in this scanline */
86
87/* total number of lines per frame (incl. vblank) */
88#define TOTAL_LINES_60HZ 262
89#define TOTAL_LINES_50HZ 312
90
91/* frame rates */
92#define FRAME_RATE_50HZ (double)1789790/114/TOTAL_LINES_50HZ
93#define FRAME_RATE_60HZ (double)1789790/114/TOTAL_LINES_60HZ
94
95
9648#endif /* ATARI_H */
trunk/src/mame/video/atari.c
r32026r32027
88
99#include "emu.h"
1010#include "includes/atari.h"
11#include "video/gtia.h"
1211
1312#define VERBOSE 0
1413
r32026r32027
1615
1716
1817/************************************************************************
19 * atari_vh_start
18 * video_start
2019 * Initialize the ATARI800 video emulation
2120 ************************************************************************/
2221
r32026r32027
2423{
2524   palette_device *m_palette = machine().first_screen()->palette();
2625
27   m_antic_render1 = 0;
28   m_antic_render2 = 0;
29   m_antic_render3 = 0;
30
3126   for (int i = 0; i < 256; i++)
3227      m_gtia->set_color_lookup(i, (m_palette->pen(0) << 8) + m_palette->pen(0));
33   
34   antic_vstart(machine());
3528}
3629
3730
38/*****************************************************************************
31/**************************************************************
3932 *
40 *  Generic Atari Interrupt Dispatcher
41 *  This is called once per scanline and handles:
42 *  vertical blank interrupt
43 *  ANTIC DMA to possibly access the next display list command
33 * Interrupts
4434 *
45 *****************************************************************************/
35 **************************************************************/
4636
47void atari_common_state::generic_atari_interrupt(int button_count)
48{
49   LOG(("ANTIC #%3d @cycle #%d scanline interrupt\n", antic.scanline, cycle()));
50
51   if( antic.scanline < VBL_START )
52   {
53      antic_scanline_dma(0);
54      return;
55   }
56
57   if( antic.scanline == VBL_START )
58   {
59      /* specify buttons relevant to this Atari variant */
60      m_gtia->button_interrupt(button_count, machine().root_device().ioport("djoy_b")->read_safe(0));
61
62      /* do nothing new for the rest of the frame */
63      antic.modelines = machine().first_screen()->height() - VBL_START;
64      m_antic_render1 = 0;
65      m_antic_render2 = 0;
66      m_antic_render3 = 0;
67     
68      /* if the CPU want's to be interrupted at vertical blank... */
69      if( antic.w.nmien & VBL_NMI )
70      {
71         LOG(("           cause VBL NMI\n"));
72         /* set the VBL NMI status bit */
73         antic.r.nmist |= VBL_NMI;
74         machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
75      }
76   }
77
78   /* refresh the display (translate color clocks to pixels) */
79   antic_linerefresh();
80}
81
82
83
8437TIMER_DEVICE_CALLBACK_MEMBER( atari_common_state::a400_interrupt )
8538{
86   generic_atari_interrupt(4);
39   m_antic->generic_interrupt(4);
8740}
8841
8942TIMER_DEVICE_CALLBACK_MEMBER( atari_common_state::a800_interrupt )
9043{
91   generic_atari_interrupt(4);
44   m_antic->generic_interrupt(4);
9245}
9346
9447TIMER_DEVICE_CALLBACK_MEMBER( atari_common_state::a800xl_interrupt )
9548{
96   generic_atari_interrupt(2);
49   m_antic->generic_interrupt(2);
9750}
9851
9952TIMER_DEVICE_CALLBACK_MEMBER( atari_common_state::a5200_interrupt )
10053{
101   generic_atari_interrupt(4);
54   m_antic->generic_interrupt(4);
10255}
10356
10457/**************************************************************
trunk/src/mame/video/antic.c
r32026r32027
66    Juergen Buchmueller, June 1998
77******************************************************************************/
88
9#include "emu.h"
109#include "antic.h"
11#include "includes/atari.h"
12#include "cpu/m6502/m6502.h"
1310
1411#ifdef MAME_DEBUG
1512#define VERBOSE 1
r32026r32027
1916
2017#define LOG(x)  do { if (VERBOSE) logerror x; } while (0)
2118
19// devices
20const device_type ATARI_ANTIC = &device_creator<antic_device>;
21
22//-------------------------------------------------
23//  upd7220_device - constructor
24//-------------------------------------------------
25
26antic_device::antic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
27            device_t(mconfig, ATARI_ANTIC, "Atari ANTIC", tag, owner, clock, "antic", __FILE__),
28            m_gtia_tag(NULL)
29{
30}
31
32
33//-------------------------------------------------
34//  device_start - device-specific startup
35//-------------------------------------------------
36
37void antic_device::device_start()
38{
39   m_gtia = machine().device<gtia_device>(m_gtia_tag);
40   assert(m_gtia);
41
42   /* save states */
43   save_pointer(NAME((UINT8 *) &m_r), sizeof(m_r));
44   save_pointer(NAME((UINT8 *) &m_w), sizeof(m_w));
45   
46   m_bitmap = auto_bitmap_ind16_alloc(machine(), machine().first_screen()->width(), machine().first_screen()->height());
47   
48   m_cclk_expand = auto_alloc_array(machine(), UINT32, 21 * 256);
49   
50   m_pf_21       = &m_cclk_expand[ 0 * 256];
51   m_pf_x10b     = &m_cclk_expand[ 1 * 256];
52   m_pf_3210b2   = &m_cclk_expand[ 3 * 256];
53   m_pf_210b4    = &m_cclk_expand[11 * 256];
54   m_pf_210b2    = &m_cclk_expand[15 * 256];
55   m_pf_1b       = &m_cclk_expand[17 * 256];
56   m_pf_gtia1    = &m_cclk_expand[18 * 256];
57   m_pf_gtia2    = &m_cclk_expand[19 * 256];
58   m_pf_gtia3    = &m_cclk_expand[20 * 256];
59   
60   m_used_colors = auto_alloc_array(machine(), UINT8, 21 * 256);
61   
62   memset(m_used_colors, 0, 21 * 256 * sizeof(UINT8));
63   
64   m_uc_21       = &m_used_colors[ 0 * 256];
65   m_uc_x10b     = &m_used_colors[ 1 * 256];
66   m_uc_3210b2   = &m_used_colors[ 3 * 256];
67   m_uc_210b4    = &m_used_colors[11 * 256];
68   m_uc_210b2    = &m_used_colors[15 * 256];
69   m_uc_1b       = &m_used_colors[17 * 256];
70   m_uc_g1       = &m_used_colors[18 * 256];
71   m_uc_g2       = &m_used_colors[19 * 256];
72   m_uc_g3       = &m_used_colors[20 * 256];
73   
74   LOG(("atari cclk_init\n"));
75   cclk_init();
76   
77   for (int i = 0; i < 64; i++)
78      m_prio_table[i] = auto_alloc_array(machine(), UINT8, 8*256);
79   
80   LOG(("atari prio_init\n"));
81   prio_init();
82   
83   for (int i = 0; i < machine().first_screen()->height(); i++)
84      m_video[i] = auto_alloc_clear(machine(), VIDEO);
85}
86
87
88//-------------------------------------------------
89//  device_reset - device-specific reset
90//-------------------------------------------------
91
92void antic_device::device_reset()
93{
94   /* reset the ANTIC read / write registers */
95   memset(&m_r, 0, sizeof(m_r));
96   memset(&m_w, 0, sizeof(m_w));
97   m_r.antic00 = 0xff;
98   m_r.antic01 = 0xff;
99   m_r.antic02 = 0xff;
100   m_r.antic03 = 0xff;
101   m_r.antic04 = 0xff;
102   m_r.antic05 = 0xff;
103   m_r.antic06 = 0xff;
104   m_r.antic07 = 0xff;
105   m_r.antic08 = 0xff;
106   m_r.antic09 = 0xff;
107   m_r.antic0a = 0xff;
108   m_r.penh    = 0x00;
109   m_r.penv    = 0x00;
110   m_r.antic0e = 0xff;
111   m_r.nmist   = 0x1f;
112   
113   m_render1 = 0;
114   m_render2 = 0;
115   m_render3 = 0;
116   m_tv_artifacts = 0;
117}
118
119
22120/*************************************************************************
23121 * The priority tables tell which playfield, player or missile colors
24122 * have precedence about the others, depending on the contents of the
r32026r32027
77175 * luminance of the modes foreground (ie. colpf1).
78176 * Any combination of players/missiles (256) is checked for the highest
79177 * priority player or missile and the resulting color is stored into
80 * antic.prio_table. The second part (20-3F) contains the resulting
178 * m_prio_table. The second part (20-3F) contains the resulting
81179 * color values for the EOR mode, which is derived from the *visible*
82180 * player/missile colors calculated for the first part (00-1F).
83181 * The priorities of combining priority bits (which games use!) are:
r32026r32027
409507 * prio_init
410508 * Initialize player/missile priority lookup tables
411509 ************************************************************************/
412void prio_init()
510void antic_device::prio_init()
413511{
414512   int i, j, pm, p, c;
415513   const UINT8 * prio;
r32026r32027
430528               if (((prio[p] & pm) == prio[p]) && (prio[p+1]))
431529                  c = prio[p+1];
432530            }
433            antic.prio_table[i][(j << 8) + pm] = c;
531            m_prio_table[i][(j << 8) + pm] = c;
434532            if( (c==PL0 || c==P000 || c==P001 || c==P010 || c==P011) &&
435533               (pm & (P0+P1))==(P0+P1))
436534               c = EOR;
437535            if( (c==PL2 || c==P200 || c==P201 || c==P210 || c==P211) &&
438536               (pm & (P2+P3))==(P2+P3))
439537               c = EOR;
440            antic.prio_table[32 + i][(j << 8) + pm] = c;
538            m_prio_table[32 + i][(j << 8) + pm] = c;
441539         }
442540      }
443541   }
r32026r32027
447545 * cclk_init
448546 * Initialize "color clock" lookup tables
449547 ************************************************************************/
450static void cclk_init()
548void antic_device::cclk_init()
451549{
452550   static const UINT8 _pf_21[4] =   {T00,T01,T10,T11};
453551   static const UINT8 _pf_1b[4] =   {G00,G01,G10,G11};
r32026r32027
460558   for( i = 0; i < 256; i++ )
461559   {
462560      /****** text mode (2,3) **********/
463      dst = (UINT8 *)&antic.pf_21[0x000+i];
561      dst = (UINT8 *)&m_pf_21[0x000+i];
464562      *dst++ = _pf_21[(i>>6)&3];
465563      *dst++ = _pf_21[(i>>4)&3];
466564      *dst++ = _pf_21[(i>>2)&3];
467565      *dst++ = _pf_21[(i>>0)&3];
468566     
469567      /****** 4 color text (4,5) with pf2, D, E **********/
470      dst = (UINT8 *)&antic.pf_x10b[0x000+i];
568      dst = (UINT8 *)&m_pf_x10b[0x000+i];
471569      *dst++ = _pf_210b[(i>>6)&3];
472570      *dst++ = _pf_210b[(i>>4)&3];
473571      *dst++ = _pf_210b[(i>>2)&3];
474572      *dst++ = _pf_210b[(i>>0)&3];
475      dst = (UINT8 *)&antic.pf_x10b[0x100+i];
573      dst = (UINT8 *)&m_pf_x10b[0x100+i];
476574      *dst++ = _pf_310b[(i>>6)&3];
477575      *dst++ = _pf_310b[(i>>4)&3];
478576      *dst++ = _pf_310b[(i>>2)&3];
479577      *dst++ = _pf_310b[(i>>0)&3];
480578     
481579      /****** pf0 color text (6,7), 9, B, C **********/
482      dst = (UINT8 *)&antic.pf_3210b2[0x000+i*2];
580      dst = (UINT8 *)&m_pf_3210b2[0x000+i*2];
483581      *dst++ = (i&0x80)?PF0:PBK;
484582      *dst++ = (i&0x40)?PF0:PBK;
485583      *dst++ = (i&0x20)?PF0:PBK;
r32026r32027
490588      *dst++ = (i&0x01)?PF0:PBK;
491589     
492590      /****** pf1 color text (6,7), 9, B, C **********/
493      dst = (UINT8 *)&antic.pf_3210b2[0x200+i*2];
591      dst = (UINT8 *)&m_pf_3210b2[0x200+i*2];
494592      *dst++ = (i&0x80)?PF1:PBK;
495593      *dst++ = (i&0x40)?PF1:PBK;
496594      *dst++ = (i&0x20)?PF1:PBK;
r32026r32027
501599      *dst++ = (i&0x01)?PF1:PBK;
502600     
503601      /****** pf2 color text (6,7), 9, B, C **********/
504      dst = (UINT8 *)&antic.pf_3210b2[0x400+i*2];
602      dst = (UINT8 *)&m_pf_3210b2[0x400+i*2];
505603      *dst++ = (i&0x80)?PF2:PBK;
506604      *dst++ = (i&0x40)?PF2:PBK;
507605      *dst++ = (i&0x20)?PF2:PBK;
r32026r32027
512610      *dst++ = (i&0x01)?PF2:PBK;
513611     
514612      /****** pf3 color text (6,7), 9, B, C **********/
515      dst = (UINT8 *)&antic.pf_3210b2[0x600+i*2];
613      dst = (UINT8 *)&m_pf_3210b2[0x600+i*2];
516614      *dst++ = (i&0x80)?PF3:PBK;
517615      *dst++ = (i&0x40)?PF3:PBK;
518616      *dst++ = (i&0x20)?PF3:PBK;
r32026r32027
523621      *dst++ = (i&0x01)?PF3:PBK;
524622     
525623      /****** 4 color graphics 4 cclks (8) **********/
526      dst = (UINT8 *)&antic.pf_210b4[i*4];
624      dst = (UINT8 *)&m_pf_210b4[i*4];
527625      *dst++ = _pf_210b[(i>>6)&3];
528626      *dst++ = _pf_210b[(i>>6)&3];
529627      *dst++ = _pf_210b[(i>>6)&3];
r32026r32027
542640      *dst++ = _pf_210b[(i>>0)&3];
543641     
544642      /****** 4 color graphics 2 cclks (A) **********/
545      dst = (UINT8 *)&antic.pf_210b2[i*2];
643      dst = (UINT8 *)&m_pf_210b2[i*2];
546644      *dst++ = _pf_210b[(i>>6)&3];
547645      *dst++ = _pf_210b[(i>>6)&3];
548646      *dst++ = _pf_210b[(i>>4)&3];
r32026r32027
553651      *dst++ = _pf_210b[(i>>0)&3];
554652     
555653      /****** high resolution graphics (F) **********/
556      dst = (UINT8 *)&antic.pf_1b[i];
654      dst = (UINT8 *)&m_pf_1b[i];
557655      *dst++ = _pf_1b[(i>>6)&3];
558656      *dst++ = _pf_1b[(i>>4)&3];
559657      *dst++ = _pf_1b[(i>>2)&3];
560658      *dst++ = _pf_1b[(i>>0)&3];
561659     
562660      /****** gtia mode 1 **********/
563      dst = (UINT8 *)&antic.pf_gtia1[i];
661      dst = (UINT8 *)&m_pf_gtia1[i];
564662      *dst++ = GT1+((i>>4)&15);
565663      *dst++ = GT1+((i>>4)&15);
566664      *dst++ = GT1+(i&15);
567665      *dst++ = GT1+(i&15);
568666     
569667      /****** gtia mode 2 **********/
570      dst = (UINT8 *)&antic.pf_gtia2[i];
668      dst = (UINT8 *)&m_pf_gtia2[i];
571669      *dst++ = GT2+((i>>4)&15);
572670      *dst++ = GT2+((i>>4)&15);
573671      *dst++ = GT2+(i&15);
574672      *dst++ = GT2+(i&15);
575673     
576674      /****** gtia mode 3 **********/
577      dst = (UINT8 *)&antic.pf_gtia3[i];
675      dst = (UINT8 *)&m_pf_gtia3[i];
578676      *dst++ = GT3+((i>>4)&15);
579677      *dst++ = GT3+((i>>4)&15);
580678      *dst++ = GT3+(i&15);
r32026r32027
586684   for( i = 0; i < 256; i++ )
587685   {
588686      /* used colors in text modes 2,3 */
589      antic.uc_21[i] = (i) ? PF2 | PF1 : PF2;
687      m_uc_21[i] = (i) ? PF2 | PF1 : PF2;
590688     
591689      /* used colors in text modes 4,5 and graphics modes D,E */
592690      switch( i & 0x03 )
593691      {
594         case 0x01: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break;
595         case 0x02: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break;
596         case 0x03: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break;
692         case 0x01: m_uc_x10b[0x000+i] |= PF0; m_uc_x10b[0x100+i] |= PF0; break;
693         case 0x02: m_uc_x10b[0x000+i] |= PF1; m_uc_x10b[0x100+i] |= PF1; break;
694         case 0x03: m_uc_x10b[0x000+i] |= PF2; m_uc_x10b[0x100+i] |= PF3; break;
597695      }
598696      switch( i & 0x0c )
599697      {
600         case 0x04: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break;
601         case 0x08: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break;
602         case 0x0c: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break;
698         case 0x04: m_uc_x10b[0x000+i] |= PF0; m_uc_x10b[0x100+i] |= PF0; break;
699         case 0x08: m_uc_x10b[0x000+i] |= PF1; m_uc_x10b[0x100+i] |= PF1; break;
700         case 0x0c: m_uc_x10b[0x000+i] |= PF2; m_uc_x10b[0x100+i] |= PF3; break;
603701      }
604702      switch( i & 0x30 )
605703      {
606         case 0x10: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break;
607         case 0x20: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break;
608         case 0x30: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break;
704         case 0x10: m_uc_x10b[0x000+i] |= PF0; m_uc_x10b[0x100+i] |= PF0; break;
705         case 0x20: m_uc_x10b[0x000+i] |= PF1; m_uc_x10b[0x100+i] |= PF1; break;
706         case 0x30: m_uc_x10b[0x000+i] |= PF2; m_uc_x10b[0x100+i] |= PF3; break;
609707      }
610708      switch( i & 0xc0 )
611709      {
612         case 0x40: antic.uc_x10b[0x000+i] |= PF0; antic.uc_x10b[0x100+i] |= PF0; break;
613         case 0x80: antic.uc_x10b[0x000+i] |= PF1; antic.uc_x10b[0x100+i] |= PF1; break;
614         case 0xc0: antic.uc_x10b[0x000+i] |= PF2; antic.uc_x10b[0x100+i] |= PF3; break;
710         case 0x40: m_uc_x10b[0x000+i] |= PF0; m_uc_x10b[0x100+i] |= PF0; break;
711         case 0x80: m_uc_x10b[0x000+i] |= PF1; m_uc_x10b[0x100+i] |= PF1; break;
712         case 0xc0: m_uc_x10b[0x000+i] |= PF2; m_uc_x10b[0x100+i] |= PF3; break;
615713      }
616714     
617715      /* used colors in text modes 6,7 and graphics modes 9,B,C */
618716      if( i )
619717      {
620         antic.uc_3210b2[0x000+i*2] |= PF0;
621         antic.uc_3210b2[0x200+i*2] |= PF1;
622         antic.uc_3210b2[0x400+i*2] |= PF2;
623         antic.uc_3210b2[0x600+i*2] |= PF3;
718         m_uc_3210b2[0x000+i*2] |= PF0;
719         m_uc_3210b2[0x200+i*2] |= PF1;
720         m_uc_3210b2[0x400+i*2] |= PF2;
721         m_uc_3210b2[0x600+i*2] |= PF3;
624722      }
625723     
626724      /* used colors in graphics mode 8 */
627725      switch( i & 0x03 )
628726      {
629         case 0x01: antic.uc_210b4[i*4] |= PF0; break;
630         case 0x02: antic.uc_210b4[i*4] |= PF1; break;
631         case 0x03: antic.uc_210b4[i*4] |= PF2; break;
727         case 0x01: m_uc_210b4[i*4] |= PF0; break;
728         case 0x02: m_uc_210b4[i*4] |= PF1; break;
729         case 0x03: m_uc_210b4[i*4] |= PF2; break;
632730      }
633731      switch( i & 0x0c )
634732      {
635         case 0x04: antic.uc_210b4[i*4] |= PF0; break;
636         case 0x08: antic.uc_210b4[i*4] |= PF1; break;
637         case 0x0c: antic.uc_210b4[i*4] |= PF2; break;
733         case 0x04: m_uc_210b4[i*4] |= PF0; break;
734         case 0x08: m_uc_210b4[i*4] |= PF1; break;
735         case 0x0c: m_uc_210b4[i*4] |= PF2; break;
638736      }
639737      switch( i & 0x30 )
640738      {
641         case 0x10: antic.uc_210b4[i*4] |= PF0; break;
642         case 0x20: antic.uc_210b4[i*4] |= PF1; break;
643         case 0x30: antic.uc_210b4[i*4] |= PF2; break;
739         case 0x10: m_uc_210b4[i*4] |= PF0; break;
740         case 0x20: m_uc_210b4[i*4] |= PF1; break;
741         case 0x30: m_uc_210b4[i*4] |= PF2; break;
644742      }
645743      switch( i & 0xc0 )
646744      {
647         case 0x40: antic.uc_210b4[i*4] |= PF0; break;
648         case 0x80: antic.uc_210b4[i*4] |= PF1; break;
649         case 0xc0: antic.uc_210b4[i*4] |= PF2; break;
745         case 0x40: m_uc_210b4[i*4] |= PF0; break;
746         case 0x80: m_uc_210b4[i*4] |= PF1; break;
747         case 0xc0: m_uc_210b4[i*4] |= PF2; break;
650748      }
651749     
652750      /* used colors in graphics mode A */
653751      switch( i & 0x03 )
654752      {
655         case 0x01: antic.uc_210b2[i*2] |= PF0; break;
656         case 0x02: antic.uc_210b2[i*2] |= PF1; break;
657         case 0x03: antic.uc_210b2[i*2] |= PF2; break;
753         case 0x01: m_uc_210b2[i*2] |= PF0; break;
754         case 0x02: m_uc_210b2[i*2] |= PF1; break;
755         case 0x03: m_uc_210b2[i*2] |= PF2; break;
658756      }
659757      switch( i & 0x0c )
660758      {
661         case 0x04: antic.uc_210b2[i*2] |= PF0; break;
662         case 0x08: antic.uc_210b2[i*2] |= PF1; break;
663         case 0x0c: antic.uc_210b2[i*2] |= PF2; break;
759         case 0x04: m_uc_210b2[i*2] |= PF0; break;
760         case 0x08: m_uc_210b2[i*2] |= PF1; break;
761         case 0x0c: m_uc_210b2[i*2] |= PF2; break;
664762      }
665763      switch( i & 0x30 )
666764      {
667         case 0x10: antic.uc_210b2[i*2] |= PF0; break;
668         case 0x20: antic.uc_210b2[i*2] |= PF1; break;
669         case 0x30: antic.uc_210b2[i*2] |= PF2; break;
765         case 0x10: m_uc_210b2[i*2] |= PF0; break;
766         case 0x20: m_uc_210b2[i*2] |= PF1; break;
767         case 0x30: m_uc_210b2[i*2] |= PF2; break;
670768      }
671769      switch( i & 0xc0 )
672770      {
673         case 0x40: antic.uc_210b2[i*2] |= PF0; break;
674         case 0x80: antic.uc_210b2[i*2] |= PF1; break;
675         case 0xc0: antic.uc_210b2[i*2] |= PF2; break;
771         case 0x40: m_uc_210b2[i*2] |= PF0; break;
772         case 0x80: m_uc_210b2[i*2] |= PF1; break;
773         case 0xc0: m_uc_210b2[i*2] |= PF2; break;
676774      }
677775     
678776      /* used colors in graphics mode F */
679777      if( i )
680         antic.uc_1b[i] |= PF1;
778         m_uc_1b[i] |= PF1;
681779     
682780      /* used colors in GTIA graphics modes */
683781      /* GTIA 1 is 16 different luminances with hue of colbk */
684      antic.uc_g1[i] = 0x00;
782      m_uc_g1[i] = 0x00;
685783      /* GTIA 2 is all 9 colors (8..15 is colbk) */
686784      switch( i & 0x0f )
687785      {
688         case 0x00: antic.uc_g2[i] = 0x10; break;
689         case 0x01: antic.uc_g2[i] = 0x20; break;
690         case 0x02: antic.uc_g2[i] = 0x40; break;
691         case 0x03: antic.uc_g2[i] = 0x80; break;
692         case 0x04: antic.uc_g2[i] = 0x01; break;
693         case 0x05: antic.uc_g2[i] = 0x02; break;
694         case 0x06: antic.uc_g2[i] = 0x04; break;
695         case 0x07: antic.uc_g2[i] = 0x08; break;
696         default:   antic.uc_g2[i] = 0x00;
786         case 0x00: m_uc_g2[i] = 0x10; break;
787         case 0x01: m_uc_g2[i] = 0x20; break;
788         case 0x02: m_uc_g2[i] = 0x40; break;
789         case 0x03: m_uc_g2[i] = 0x80; break;
790         case 0x04: m_uc_g2[i] = 0x01; break;
791         case 0x05: m_uc_g2[i] = 0x02; break;
792         case 0x06: m_uc_g2[i] = 0x04; break;
793         case 0x07: m_uc_g2[i] = 0x08; break;
794         default:   m_uc_g2[i] = 0x00;
697795      }
698796     
699797      /* GTIA 3 is 16 different hues with luminance of colbk */
700      antic.uc_g3[i] = 0x00;
798      m_uc_g3[i] = 0x00;
701799   }
702800}
703801
704802
705803
706ANTIC antic;
707
708void antic_start(running_machine &machine)
709{   
710   /* save states */
711   machine.save().save_pointer(NAME((UINT8 *) &antic.r), sizeof(antic.r));
712   machine.save().save_pointer(NAME((UINT8 *) &antic.w), sizeof(antic.w));
713}
714
715void antic_vstart(running_machine &machine)
716{   
717   LOG(("atari antic_vh_start\n"));
718   memset(&antic, 0, sizeof(antic));
719   
720   antic.bitmap = auto_bitmap_ind16_alloc(machine, machine.first_screen()->width(), machine.first_screen()->height());
721   
722   antic.cclk_expand = auto_alloc_array(machine, UINT32, 21 * 256);
723   
724   antic.pf_21       = &antic.cclk_expand[ 0 * 256];
725   antic.pf_x10b     = &antic.cclk_expand[ 1 * 256];
726   antic.pf_3210b2   = &antic.cclk_expand[ 3 * 256];
727   antic.pf_210b4    = &antic.cclk_expand[11 * 256];
728   antic.pf_210b2    = &antic.cclk_expand[15 * 256];
729   antic.pf_1b       = &antic.cclk_expand[17 * 256];
730   antic.pf_gtia1    = &antic.cclk_expand[18 * 256];
731   antic.pf_gtia2    = &antic.cclk_expand[19 * 256];
732   antic.pf_gtia3    = &antic.cclk_expand[20 * 256];
733   
734   antic.used_colors = auto_alloc_array(machine, UINT8, 21 * 256);
735   
736   memset(antic.used_colors, 0, 21 * 256 * sizeof(UINT8));
737   
738   antic.uc_21       = &antic.used_colors[ 0 * 256];
739   antic.uc_x10b     = &antic.used_colors[ 1 * 256];
740   antic.uc_3210b2   = &antic.used_colors[ 3 * 256];
741   antic.uc_210b4    = &antic.used_colors[11 * 256];
742   antic.uc_210b2    = &antic.used_colors[15 * 256];
743   antic.uc_1b       = &antic.used_colors[17 * 256];
744   antic.uc_g1       = &antic.used_colors[18 * 256];
745   antic.uc_g2       = &antic.used_colors[19 * 256];
746   antic.uc_g3       = &antic.used_colors[20 * 256];
747   
748   LOG(("atari cclk_init\n"));
749   cclk_init();
750   
751   for (int i = 0; i < 64; i++)
752      antic.prio_table[i] = auto_alloc_array(machine, UINT8, 8*256);
753   
754   LOG(("atari prio_init\n"));
755   prio_init();
756   
757   for (int i = 0; i < machine.first_screen()->height(); i++)
758      antic.video[i] = auto_alloc_clear(machine, VIDEO);
759}
760
761804/**************************************************************
762805 *
763 * Reset ANTIC
764 *
765 **************************************************************/
766
767void antic_reset(void)
768{
769   /* reset the ANTIC read / write registers */
770   memset(&antic.r, 0, sizeof(antic.r));
771   memset(&antic.w, 0, sizeof(antic.w));
772   antic.r.antic00 = 0xff;
773   antic.r.antic01 = 0xff;
774   antic.r.antic02 = 0xff;
775   antic.r.antic03 = 0xff;
776   antic.r.antic04 = 0xff;
777   antic.r.antic05 = 0xff;
778   antic.r.antic06 = 0xff;
779   antic.r.antic07 = 0xff;
780   antic.r.antic08 = 0xff;
781   antic.r.antic09 = 0xff;
782   antic.r.antic0a = 0xff;
783   antic.r.penh    = 0x00;
784   antic.r.penv    = 0x00;
785   antic.r.antic0e = 0xff;
786   antic.r.nmist   = 0x1f;
787}
788
789/**************************************************************
790 *
791806 * Read ANTIC hardware registers
792807 *
793808 **************************************************************/
794READ8_MEMBER ( atari_common_state::atari_antic_r )
809READ8_MEMBER ( antic_device::read )
795810{
796811   UINT8 data = 0xff;
797812
798813   switch (offset & 15)
799814   {
800815   case  0: /* nothing */
801      data = antic.r.antic00;
816      data = m_r.antic00;
802817      break;
803818   case  1: /* nothing */
804      data = antic.r.antic01;
819      data = m_r.antic01;
805820      break;
806821   case  2: /* nothing */
807      data = antic.r.antic02;
822      data = m_r.antic02;
808823      break;
809824   case  3: /* nothing */
810      data = antic.r.antic03;
825      data = m_r.antic03;
811826      break;
812827   case  4: /* nothing */
813      data = antic.r.antic04;
828      data = m_r.antic04;
814829      break;
815830   case  5: /* nothing */
816      data = antic.r.antic05;
831      data = m_r.antic05;
817832      break;
818833   case  6: /* nothing */
819      data = antic.r.antic06;
834      data = m_r.antic06;
820835      break;
821836   case  7: /* nothing */
822      data = antic.r.antic07;
837      data = m_r.antic07;
823838      break;
824839   case  8: /* nothing */
825      data = antic.r.antic08;
840      data = m_r.antic08;
826841      break;
827842   case  9: /* nothing */
828      data = antic.r.antic09;
843      data = m_r.antic09;
829844      break;
830845   case 10: /* WSYNC read */
831846      space.machine().device("maincpu")->execute().spin_until_trigger(TRIGGER_HSYNC);
832      antic.w.wsync = 1;
833      data = antic.r.antic0a;
847      m_w.wsync = 1;
848      data = m_r.antic0a;
834849      break;
835850   case 11: /* vert counter (scanline / 2) */
836      data = antic.r.vcount = antic.scanline >> 1;
851      data = m_r.vcount = m_scanline >> 1;
837852      break;
838853   case 12: /* light pen horz pos */
839      data = antic.r.penh;
854      data = m_r.penh;
840855      break;
841856   case 13: /* light pen vert pos */
842      data = antic.r.penv;
857      data = m_r.penv;
843858      break;
844859   case 14: /* NMI enable */
845      data = antic.r.antic0e;
860      data = m_r.antic0e;
846861      break;
847862   case 15: /* NMI status */
848      data = antic.r.nmist;
863      data = m_r.nmist;
849864      break;
850865   }
851866   return data;
r32026r32027
857872 *
858873 **************************************************************/
859874
860WRITE8_MEMBER ( atari_common_state::atari_antic_w )
875WRITE8_MEMBER ( antic_device::write )
861876{
862877   int temp;
863878
864879   switch (offset & 15)
865880   {
866881   case  0:
867      if( data == antic.w.dmactl )
882      if( data == m_w.dmactl )
868883         break;
869884      LOG(("ANTIC 00 write DMACTL $%02X\n", data));
870      antic.w.dmactl = data;
885      m_w.dmactl = data;
871886      switch (data & 3)
872887      {
873         case 0: antic.pfwidth =  0; break;
874         case 1: antic.pfwidth = 32; break;
875         case 2: antic.pfwidth = 40; break;
876         case 3: antic.pfwidth = 48; break;
888         case 0: m_pfwidth =  0; break;
889         case 1: m_pfwidth = 32; break;
890         case 2: m_pfwidth = 40; break;
891         case 3: m_pfwidth = 48; break;
877892      }
878893      break;
879894   case  1:
880      if( data == antic.w.chactl )
895      if( data == m_w.chactl )
881896         break;
882897      LOG(("ANTIC 01 write CHACTL $%02X\n", data));
883      antic.w.chactl = data;
884      antic.chand = (data & 1) ? 0x00 : 0xff;
885      antic.chxor = (data & 2) ? 0xff : 0x00;
898      m_w.chactl = data;
899      m_chand = (data & 1) ? 0x00 : 0xff;
900      m_chxor = (data & 2) ? 0xff : 0x00;
886901      break;
887902   case  2:
888903      LOG(("ANTIC 02 write DLISTL $%02X\n", data));
889      antic.w.dlistl = data;
890      temp = (antic.w.dlisth << 8) + antic.w.dlistl;
891      antic.dpage = temp & DPAGE;
892      antic.doffs = temp & DOFFS;
904      m_w.dlistl = data;
905      temp = (m_w.dlisth << 8) + m_w.dlistl;
906      m_dpage = temp & DPAGE;
907      m_doffs = temp & DOFFS;
893908      break;
894909   case  3:
895910      LOG(("ANTIC 03 write DLISTH $%02X\n", data));
896      antic.w.dlisth = data;
897      temp = (antic.w.dlisth << 8) + antic.w.dlistl;
898      antic.dpage = temp & DPAGE;
899      antic.doffs = temp & DOFFS;
911      m_w.dlisth = data;
912      temp = (m_w.dlisth << 8) + m_w.dlistl;
913      m_dpage = temp & DPAGE;
914      m_doffs = temp & DOFFS;
900915      break;
901916   case  4:
902      if( data == antic.w.hscrol )
917      if( data == m_w.hscrol )
903918         break;
904919      LOG(("ANTIC 04 write HSCROL $%02X\n", data));
905      antic.w.hscrol = data & 15;
920      m_w.hscrol = data & 15;
906921      break;
907922   case  5:
908      if( data == antic.w.vscrol )
923      if( data == m_w.vscrol )
909924         break;
910925      LOG(("ANTIC 05 write VSCROL $%02X\n", data));
911      antic.w.vscrol = data & 15;
926      m_w.vscrol = data & 15;
912927      break;
913928   case  6:
914      if( data == antic.w.pmbasl )
929      if( data == m_w.pmbasl )
915930         break;
916931      LOG(("ANTIC 06 write PMBASL $%02X\n", data));
917      /* antic.w.pmbasl = data; */
932      /* m_w.pmbasl = data; */
918933      break;
919934   case  7:
920      if( data == antic.w.pmbash )
935      if( data == m_w.pmbash )
921936         break;
922937      LOG(("ANTIC 07 write PMBASH $%02X\n", data));
923      antic.w.pmbash = data;
924      antic.pmbase_s = (data & 0xfc) << 8;
925      antic.pmbase_d = (data & 0xf8) << 8;
938      m_w.pmbash = data;
939      m_pmbase_s = (data & 0xfc) << 8;
940      m_pmbase_d = (data & 0xf8) << 8;
926941      break;
927942   case  8:
928      if( data == antic.w.chbasl )
943      if( data == m_w.chbasl )
929944         break;
930945      LOG(("ANTIC 08 write CHBASL $%02X\n", data));
931      /* antic.w.chbasl = data; */
946      /* m_w.chbasl = data; */
932947      break;
933948   case  9:
934      if( data == antic.w.chbash )
949      if( data == m_w.chbash )
935950         break;
936951      LOG(("ANTIC 09 write CHBASH $%02X\n", data));
937      antic.w.chbash = data;
952      m_w.chbash = data;
938953      break;
939954   case 10: /* WSYNC write */
940955      LOG(("ANTIC 0A write WSYNC  $%02X\n", data));
941956      space.machine().device("maincpu")->execute().spin_until_trigger(TRIGGER_HSYNC);
942      antic.w.wsync = 1;
957      m_w.wsync = 1;
943958      break;
944959   case 11:
945      if( data == antic.w.antic0b )
960      if( data == m_w.antic0b )
946961         break;
947962      LOG(("ANTIC 0B write ?????? $%02X\n", data));
948      antic.w.antic0b = data;
963      m_w.antic0b = data;
949964      break;
950965   case 12:
951      if( data == antic.w.antic0c )
966      if( data == m_w.antic0c )
952967         break;
953968      LOG(("ANTIC 0C write ?????? $%02X\n", data));
954      antic.w.antic0c = data;
969      m_w.antic0c = data;
955970      break;
956971   case 13:
957      if( data == antic.w.antic0d )
972      if( data == m_w.antic0d )
958973         break;
959974      LOG(("ANTIC 0D write ?????? $%02X\n", data));
960      antic.w.antic0d = data;
975      m_w.antic0d = data;
961976      break;
962977   case 14:
963      if( data == antic.w.nmien )
978      if( data == m_w.nmien )
964979         break;
965980      LOG(("ANTIC 0E write NMIEN  $%02X\n", data));
966      antic.w.nmien  = data;
981      m_w.nmien  = data;
967982      break;
968983   case 15:
969984      LOG(("ANTIC 0F write NMIRES $%02X\n", data));
970      antic.r.nmist = 0x1f;
971      antic.w.nmires = data;
985      m_r.nmist = 0x1f;
986      m_w.nmires = data;
972987      break;
973988   }
974989}
r32026r32027
976991/*************  ANTIC mode 00: *********************************
977992 * generate 1-8 empty scanlines
978993 ***************************************************************/
979static inline void antic_mode_0_xx(address_space &space, VIDEO *video)
994inline void antic_device::mode_0(address_space &space, VIDEO *video)
980995{
981996   PREPARE();
982997   memset(dst, PBK, HWIDTH*4);
r32026r32027
9911006/*************  ANTIC mode 02: *********************************
9921007 * character mode 8x8:2 (32/40/48 byte per line)
9931008 ***************************************************************/
994#define MODE2(s) COPY4(dst, antic.pf_21[video->data[s]])
1009#define MODE2(s) COPY4(dst, m_pf_21[video->data[s]])
9951010
996static inline void antic_mode_2(address_space &space, VIDEO *video, int bytes, int erase)
1011inline void antic_device::mode_2(address_space &space, VIDEO *video, int bytes, int erase)
9971012{
9981013   PREPARE_TXT2(space, bytes);
9991014   ERASE(erase);
r32026r32027
10051020/*************  ANTIC mode 03: *********************************
10061021 * character mode 8x10:2 (32/40/48 byte per line)
10071022 ***************************************************************/
1008#define MODE3(s) COPY4(dst, antic.pf_21[video->data[s]])
1023#define MODE3(s) COPY4(dst, m_pf_21[video->data[s]])
10091024
1010static inline void antic_mode_3(address_space &space, VIDEO *video, int bytes, int erase)
1025inline void antic_device::mode_3(address_space &space, VIDEO *video, int bytes, int erase)
10111026{
10121027   PREPARE_TXT3(space, bytes);
10131028   ERASE(erase);
r32026r32027
10191034/*************  ANTIC mode 04: *********************************
10201035 * character mode 8x8:4 multi color (32/40/48 byte per line)
10211036 ***************************************************************/
1022#define MODE4(s) COPY4(dst, antic.pf_x10b[video->data[s]])
1037#define MODE4(s) COPY4(dst, m_pf_x10b[video->data[s]])
10231038
1024static inline void antic_mode_4(address_space &space, VIDEO *video, int bytes, int erase)
1039inline void antic_device::mode_4(address_space &space, VIDEO *video, int bytes, int erase)
10251040{
10261041   PREPARE_TXT45(space, bytes, 0);
10271042   ERASE(erase);
r32026r32027
10331048/*************  ANTIC mode 05: *********************************
10341049 * character mode 8x16:4 multi color (32/40/48 byte per line)
10351050 ***************************************************************/
1036#define MODE5(s) COPY4(dst, antic.pf_x10b[video->data[s]])
1051#define MODE5(s) COPY4(dst, m_pf_x10b[video->data[s]])
10371052
1038static inline void antic_mode_5(address_space &space, VIDEO *video, int bytes, int erase)
1053inline void antic_device::mode_5(address_space &space, VIDEO *video, int bytes, int erase)
10391054{
10401055   PREPARE_TXT45(space, bytes, 1);
10411056   ERASE(erase);
r32026r32027
10471062/*************  ANTIC mode 06: *********************************
10481063 * character mode 16x8:5 single color (16/20/24 byte per line)
10491064 ***************************************************************/
1050#define MODE6(s) COPY8(dst, antic.pf_3210b2[video->data[s]], antic.pf_3210b2[video->data[s]+1])
1065#define MODE6(s) COPY8(dst, m_pf_3210b2[video->data[s]], m_pf_3210b2[video->data[s]+1])
10511066
1052static inline void antic_mode_6(address_space &space, VIDEO *video, int bytes, int erase)
1067inline void antic_device::mode_6(address_space &space, VIDEO *video, int bytes, int erase)
10531068{
10541069   PREPARE_TXT67(space, bytes, 0);
10551070   ERASE(erase);
r32026r32027
10611076/*************  ANTIC mode 07: *********************************
10621077 * character mode 16x16:5 single color (16/20/24 byte per line)
10631078 ***************************************************************/
1064#define MODE7(s) COPY8(dst, antic.pf_3210b2[video->data[s]], antic.pf_3210b2[video->data[s]+1])
1079#define MODE7(s) COPY8(dst, m_pf_3210b2[video->data[s]], m_pf_3210b2[video->data[s]+1])
10651080
1066static inline void antic_mode_7(address_space &space, VIDEO *video, int bytes, int erase)
1081inline void antic_device::mode_7(address_space &space, VIDEO *video, int bytes, int erase)
10671082{
10681083   PREPARE_TXT67(space, bytes, 1);
10691084   ERASE(erase);
r32026r32027
10751090/*************  ANTIC mode 08: *********************************
10761091 * graphics mode 8x8:4 (8/10/12 byte per line)
10771092 ***************************************************************/
1078#define MODE8(s) COPY16(dst, antic.pf_210b4[video->data[s]],antic.pf_210b4[video->data[s]+1],antic.pf_210b4[video->data[s]+2],antic.pf_210b4[video->data[s]+3])
1093#define MODE8(s) COPY16(dst, m_pf_210b4[video->data[s]],m_pf_210b4[video->data[s]+1],m_pf_210b4[video->data[s]+2],m_pf_210b4[video->data[s]+3])
10791094
1080static inline void antic_mode_8(address_space &space, VIDEO *video, int bytes, int erase)
1095inline void antic_device::mode_8(address_space &space, VIDEO *video, int bytes, int erase)
10811096{
10821097   PREPARE_GFX8(space, bytes);
10831098   ERASE(erase);
r32026r32027
10891104/*************  ANTIC mode 09: *********************************
10901105 * graphics mode 4x4:2 (8/10/12 byte per line)
10911106 ***************************************************************/
1092#define MODE9(s) COPY8(dst, antic.pf_3210b2[video->data[s]], antic.pf_3210b2[video->data[s]+1])
1107#define MODE9(s) COPY8(dst, m_pf_3210b2[video->data[s]], m_pf_3210b2[video->data[s]+1])
10931108
1094static inline void antic_mode_9(address_space &space, VIDEO *video, int bytes, int erase)
1109inline void antic_device::mode_9(address_space &space, VIDEO *video, int bytes, int erase)
10951110{
10961111   PREPARE_GFX9BC(space, bytes);
10971112   ERASE(erase);
r32026r32027
11031118/*************  ANTIC mode 0A: *********************************
11041119 * graphics mode 4x4:4 (16/20/24 byte per line)
11051120 ***************************************************************/
1106#define MODEA(s) COPY8(dst, antic.pf_210b2[video->data[s]], antic.pf_210b2[video->data[s]+1])
1121#define MODEA(s) COPY8(dst, m_pf_210b2[video->data[s]], m_pf_210b2[video->data[s]+1])
11071122
1108static inline void antic_mode_a(address_space &space, VIDEO *video, int bytes, int erase)
1123inline void antic_device::mode_a(address_space &space, VIDEO *video, int bytes, int erase)
11091124{
11101125   PREPARE_GFXA(space, bytes);
11111126   ERASE(erase);
r32026r32027
11171132/*************  ANTIC mode 0B: *********************************
11181133 * graphics mode 2x2:2 (16/20/24 byte per line)
11191134 ***************************************************************/
1120#define MODEB(s) COPY8(dst, antic.pf_3210b2[video->data[s]], antic.pf_3210b2[video->data[s]+1])
1135#define MODEB(s) COPY8(dst, m_pf_3210b2[video->data[s]], m_pf_3210b2[video->data[s]+1])
11211136
1122static inline void antic_mode_b(address_space &space, VIDEO *video, int bytes, int erase)
1137inline void antic_device::mode_b(address_space &space, VIDEO *video, int bytes, int erase)
11231138{
11241139   PREPARE_GFX9BC(space, bytes);
11251140   ERASE(erase);
r32026r32027
11311146/*************  ANTIC mode 0C: *********************************
11321147 * graphics mode 2x1:2 (16/20/24 byte per line)
11331148 ***************************************************************/
1134#define MODEC(s) COPY8(dst, antic.pf_3210b2[video->data[s]], antic.pf_3210b2[video->data[s]+1])
1149#define MODEC(s) COPY8(dst, m_pf_3210b2[video->data[s]], m_pf_3210b2[video->data[s]+1])
11351150
1136static inline void antic_mode_c(address_space &space, VIDEO *video, int bytes, int erase)
1151inline void antic_device::mode_c(address_space &space, VIDEO *video, int bytes, int erase)
11371152{
11381153   PREPARE_GFX9BC(space, bytes);
11391154   ERASE(erase);
r32026r32027
11451160/*************  ANTIC mode 0D: *********************************
11461161 * graphics mode 2x2:4 (32/40/48 byte per line)
11471162 ***************************************************************/
1148#define MODED(s) COPY4(dst, antic.pf_x10b[video->data[s]])
1163#define MODED(s) COPY4(dst, m_pf_x10b[video->data[s]])
11491164
1150static inline void antic_mode_d(address_space &space, VIDEO *video, int bytes, int erase)
1165inline void antic_device::mode_d(address_space &space, VIDEO *video, int bytes, int erase)
11511166{
11521167   PREPARE_GFXDE(space, bytes);
11531168   ERASE(erase);
r32026r32027
11591174/*************  ANTIC mode 0E: *********************************
11601175 * graphics mode 2x1:4 (32/40/48 byte per line)
11611176 ***************************************************************/
1162#define MODEE(s) COPY4(dst, antic.pf_x10b[video->data[s]])
1177#define MODEE(s) COPY4(dst, m_pf_x10b[video->data[s]])
11631178
1164static inline void antic_mode_e(address_space &space, VIDEO *video, int bytes, int erase)
1179inline void antic_device::mode_e(address_space &space, VIDEO *video, int bytes, int erase)
11651180{
11661181   PREPARE_GFXDE(space, bytes);
11671182   ERASE(erase);
r32026r32027
11731188/*************  ANTIC mode 0F: *********************************
11741189 * graphics mode 1x1:2 (32/40/48 byte per line)
11751190 ***************************************************************/
1176#define MODEF(s) COPY4(dst, antic.pf_1b[video->data[s]])
1191#define MODEF(s) COPY4(dst, m_pf_1b[video->data[s]])
11771192
1178static inline void antic_mode_f(address_space &space, VIDEO *video, int bytes, int erase)
1193inline void antic_device::mode_f(address_space &space, VIDEO *video, int bytes, int erase)
11791194{
11801195   PREPARE_GFXF(space, bytes);
11811196   ERASE(erase);
r32026r32027
11871202/*************  ANTIC mode 0F : GTIA mode 1 ********************
11881203 * graphics mode 8x1:16 (32/40/48 byte per line)
11891204 ***************************************************************/
1190#define GTIA1(s) COPY4(dst, antic.pf_gtia1[video->data[s]])
1205#define GTIA1(s) COPY4(dst, m_pf_gtia1[video->data[s]])
11911206
1192static inline void antic_mode_gtia1(address_space &space, VIDEO *video, int bytes, int erase)
1207inline void antic_device::mode_gtia1(address_space &space, VIDEO *video, int bytes, int erase)
11931208{
11941209   PREPARE_GFXG1(space, bytes);
11951210   ERASE(erase);
r32026r32027
12011216/*************  ANTIC mode 0F : GTIA mode 2 ********************
12021217 * graphics mode 8x1:16 (32/40/48 byte per line)
12031218 ***************************************************************/
1204#define GTIA2(s) COPY4(dst, antic.pf_gtia2[video->data[s]])
1219#define GTIA2(s) COPY4(dst, m_pf_gtia2[video->data[s]])
12051220
1206static inline void antic_mode_gtia2(address_space &space, VIDEO *video, int bytes, int erase)
1221inline void antic_device::mode_gtia2(address_space &space, VIDEO *video, int bytes, int erase)
12071222{
12081223   PREPARE_GFXG2(space, bytes);
12091224   ERASE(erase);
r32026r32027
12151230/*************  ANTIC mode 0F : GTIA mode 3 ********************
12161231 * graphics mode 8x1:16 (32/40/48 byte per line)
12171232 ***************************************************************/
1218#define GTIA3(s) COPY4(dst, antic.pf_gtia3[video->data[s]])
1233#define GTIA3(s) COPY4(dst, m_pf_gtia3[video->data[s]])
12191234
1220static inline void antic_mode_gtia3(address_space &space, VIDEO *video, int bytes, int erase)
1235inline void antic_device::mode_gtia3(address_space &space, VIDEO *video, int bytes, int erase)
12211236{
12221237   PREPARE_GFXG3(space, bytes);
12231238   ERASE(erase);
r32026r32027
12291244
12301245/*************  ANTIC render ********************/
12311246
1232void antic_render(address_space &space, int param1, int param2, int param3)
1247void antic_device::render(address_space &space, int param1, int param2, int param3)
12331248{
1234   VIDEO *video = antic.video[antic.scanline];
1249   VIDEO *video = m_video[m_scanline];
12351250   int add_bytes = 0, erase = 0;
12361251   
12371252   if (param3 == 0 || param2 <= 1)
12381253   {
1239      antic_mode_0_xx(space, video);
1254      mode_0(space, video);
12401255      return;
12411256   }
12421257   
r32026r32027
12621277   switch (param2)
12631278   {
12641279      case 0x02:
1265         antic_mode_2(space, video, add_bytes, erase);
1280         mode_2(space, video, add_bytes, erase);
12661281         return;
12671282      case 0x03:
1268         antic_mode_3(space, video, add_bytes, erase);
1283         mode_3(space, video, add_bytes, erase);
12691284         return;
12701285      case 0x04:
1271         antic_mode_4(space, video, add_bytes, erase);
1286         mode_4(space, video, add_bytes, erase);
12721287         return;
12731288      case 0x05:
1274         antic_mode_5(space, video, add_bytes, erase);
1289         mode_5(space, video, add_bytes, erase);
12751290         return;
12761291      case 0x06:
1277         antic_mode_6(space, video, add_bytes >> 1, erase);
1292         mode_6(space, video, add_bytes >> 1, erase);
12781293         return;
12791294      case 0x07:
1280         antic_mode_7(space, video, add_bytes >> 1, erase);
1295         mode_7(space, video, add_bytes >> 1, erase);
12811296         return;
12821297      case 0x08:
1283         antic_mode_8(space, video, add_bytes >> 2, erase);
1298         mode_8(space, video, add_bytes >> 2, erase);
12841299         return;
12851300      case 0x09:
1286         antic_mode_9(space, video, add_bytes >> 1, erase);
1301         mode_9(space, video, add_bytes >> 1, erase);
12871302         return;
12881303      case 0x0a:
1289         antic_mode_a(space, video, add_bytes >> 1, erase);
1304         mode_a(space, video, add_bytes >> 1, erase);
12901305         return;
12911306      case 0x0b:
1292         antic_mode_b(space, video, add_bytes >> 1, erase);
1307         mode_b(space, video, add_bytes >> 1, erase);
12931308         return;
12941309      case 0x0c:
1295         antic_mode_c(space, video, add_bytes >> 1, erase);
1310         mode_c(space, video, add_bytes >> 1, erase);
12961311         return;
12971312      case 0x0d:
1298         antic_mode_d(space, video, add_bytes, erase);
1313         mode_d(space, video, add_bytes, erase);
12991314         return;
13001315      case 0x0e:
1301         antic_mode_e(space, video, add_bytes, erase);
1316         mode_e(space, video, add_bytes, erase);
13021317         return;
13031318      case 0x0f:
1304         antic_mode_f(space, video, add_bytes, erase);
1319         mode_f(space, video, add_bytes, erase);
13051320         return;
13061321      case 0x10:
1307         antic_mode_gtia1(space, video, add_bytes, erase);
1322         mode_gtia1(space, video, add_bytes, erase);
13081323         return;
13091324      case 0x11:
1310         antic_mode_gtia2(space, video, add_bytes, erase);
1325         mode_gtia2(space, video, add_bytes, erase);
13111326         return;
13121327      case 0x12:
1313         antic_mode_gtia3(space, video, add_bytes, erase);
1328         mode_gtia3(space, video, add_bytes, erase);
13141329         return;
13151330      default:
13161331         return;
r32026r32027
13181333}
13191334
13201335
1321
13221336/************************************************************************
13231337 * atari_vh_screenrefresh
13241338 * Refresh screen bitmap.
13251339 * Note: Actual drawing is done scanline wise during atari_interrupt
13261340 ************************************************************************/
1327UINT32 atari_common_state::screen_update_atari(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
1341UINT32 antic_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
13281342{
13291343   UINT32 new_tv_artifacts = screen.ioport("artifacts")->read_safe(0);
1330   copybitmap(bitmap, *antic.bitmap, 0, 0, 0, 0, cliprect);
1344   copybitmap(bitmap, *m_bitmap, 0, 0, 0, 0, cliprect);
13311345   
1332   if (tv_artifacts != new_tv_artifacts)
1333      tv_artifacts = new_tv_artifacts;
1346   if (m_tv_artifacts != new_tv_artifacts)
1347      m_tv_artifacts = new_tv_artifacts;
13341348   
13351349   return 0;
13361350}
13371351
1338void atari_common_state::artifacts_gfx(UINT8 *src, UINT8 *dst, int width)
1352void antic_device::artifacts_gfx(UINT8 *src, UINT8 *dst, int width)
13391353{
13401354   UINT8 n, bits = 0;
13411355   UINT8 b = m_gtia->get_w_colbk() & 0xf0;
r32026r32027
14091423   }
14101424}
14111425
1412void atari_common_state::artifacts_txt(UINT8 * src, UINT8 * dst, int width)
1426void antic_device::artifacts_txt(UINT8 * src, UINT8 * dst, int width)
14131427{
14141428   UINT8 n, bits = 0;
14151429   UINT8 b = m_gtia->get_w_colpf2() & 0xf0;
r32026r32027
14841498}
14851499
14861500
1487void atari_common_state::antic_linerefresh()
1501void antic_device::linerefresh()
14881502{
14891503   int x, y;
14901504   UINT8 *src;
r32026r32027
14931507   UINT16 *color_lookup = m_gtia->get_color_lookup();
14941508   
14951509   /* increment the scanline */
1496   if( ++antic.scanline == machine().first_screen()->height() )
1510   if( ++m_scanline == machine().first_screen()->height() )
14971511   {
14981512      /* and return to the top if the frame was complete */
1499      antic.scanline = 0;
1500      antic.modelines = 0;
1513      m_scanline = 0;
1514      m_modelines = 0;
15011515      /* count frames gone since last write to hitclr */
15021516      m_gtia->count_hitclr_frames();
15031517   }
15041518   
1505   if( antic.scanline < MIN_Y || antic.scanline > MAX_Y )
1519   if( m_scanline < MIN_Y || m_scanline > MAX_Y )
15061520      return;
15071521   
1508   y = antic.scanline - MIN_Y;
1509   src = &antic.cclock[PMOFFSET - antic.hscrol_old + 12];
1522   y = m_scanline - MIN_Y;
1523   src = &m_cclock[PMOFFSET - m_hscrol_old + 12];
15101524   dst = scanline;
15111525   
1512   if( tv_artifacts )
1526   if( m_tv_artifacts )
15131527   {
1514      if( (antic.cmd & 0x0f) == 2 || (antic.cmd & 0x0f) == 3 )
1528      if( (m_cmd & 0x0f) == 2 || (m_cmd & 0x0f) == 3 )
15151529      {
15161530         artifacts_txt(src, (UINT8*)(dst + 3), HCHARS);
15171531         return;
15181532      }
15191533      else
1520         if( (antic.cmd & 0x0f) == 15 )
1534         if( (m_cmd & 0x0f) == 15 )
15211535         {
15221536            artifacts_gfx(src, (UINT8*)(dst + 3), HCHARS);
15231537            return;
r32026r32027
15261540   dst[0] = color_lookup[PBK] | color_lookup[PBK] << 16;
15271541   dst[1] = color_lookup[PBK] | color_lookup[PBK] << 16;
15281542   dst[2] = color_lookup[PBK] | color_lookup[PBK] << 16;
1529   if ( (antic.cmd & ANTIC_HSCR) == 0  || (antic.pfwidth == 48) || (antic.pfwidth == 32))
1543   if ( (m_cmd & ANTIC_HSCR) == 0  || (m_pfwidth == 48) || (m_pfwidth == 32))
15301544   {
15311545      /* no hscroll */
15321546      dst[3] = color_lookup[src[BYTE_XOR_LE(0)]] | color_lookup[src[BYTE_XOR_LE(1)]] << 16;
r32026r32027
15441558   {
15451559      /* if hscroll is enabled, more data are fetched by ANTIC, but it still renders playfield
15461560       of width defined by pfwidth. */
1547      switch( antic.pfwidth )
1561      switch( m_pfwidth )
15481562      {
15491563         case 0:
15501564         {
r32026r32027
15901604   dst[2] = color_lookup[PBK] | color_lookup[PBK] << 16;
15911605   dst[3] = color_lookup[PBK] | color_lookup[PBK] << 16;
15921606   
1593   draw_scanline8(*antic.bitmap, 12, y, MIN(antic.bitmap->width() - 12, sizeof(scanline)), (const UINT8 *) scanline, NULL);
1607   draw_scanline8(*m_bitmap, 12, y, MIN(m_bitmap->width() - 12, sizeof(scanline)), (const UINT8 *) scanline, NULL);
15941608}
15951609
15961610
15971611#define ANTIC_TIME_FROM_CYCLES(cycles)   \
15981612(attotime)(machine().first_screen()->scan_period() * (cycles) / CYCLES_PER_LINE)
15991613
1600void atari_common_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
1614void antic_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
16011615{
16021616   switch (id)
16031617   {
16041618      case TIMER_CYCLE_STEAL:
1605         antic_steal_cycles(ptr, param);
1619         steal_cycles(ptr, param);
16061620         break;
16071621      case TIMER_ISSUE_DLI:
1608         antic_issue_dli(ptr, param);
1622         issue_dli(ptr, param);
16091623         break;
16101624      case TIMER_LINE_REND:
1611         antic_scanline_render(ptr, param);
1625         scanline_render(ptr, param);
16121626         break;
16131627      case TIMER_LINE_DONE:
1614         antic_line_done(ptr, param);
1628         line_done(ptr, param);
16151629         break;
16161630   }
16171631}
16181632
1619int atari_common_state::cycle()
1633int antic_device::cycle()
16201634{
16211635   return machine().first_screen()->hpos() * CYCLES_PER_LINE / machine().first_screen()->width();
16221636}
16231637
1624TIMER_CALLBACK_MEMBER( atari_common_state::antic_issue_dli )
1638TIMER_CALLBACK_MEMBER( antic_device::issue_dli )
16251639{
1626   if( antic.w.nmien & DLI_NMI )
1640   if( m_w.nmien & DLI_NMI )
16271641   {
16281642      LOG(("           @cycle #%3d issue DLI\n", cycle()));
1629      antic.r.nmist |= DLI_NMI;
1643      m_r.nmist |= DLI_NMI;
16301644      machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
16311645   }
16321646   else
r32026r32027
16411655 *  Antic Line Done
16421656 *
16431657 *****************************************************************************/
1644TIMER_CALLBACK_MEMBER( atari_common_state::antic_line_done )
1658TIMER_CALLBACK_MEMBER( antic_device::line_done )
16451659{
1646   LOG(("           @cycle #%3d antic_line_done\n", cycle()));
1647   if( antic.w.wsync )
1660   LOG(("           @cycle #%3d line_done\n", cycle()));
1661   if( m_w.wsync )
16481662   {
16491663      LOG(("           @cycle #%3d release WSYNC\n", cycle()));
16501664      /* release the CPU if it was actually waiting for HSYNC */
16511665      machine().scheduler().trigger(TRIGGER_HSYNC);
16521666      /* and turn off the 'wait for hsync' flag */
1653      antic.w.wsync = 0;
1667      m_w.wsync = 0;
16541668   }
16551669   LOG(("           @cycle #%3d release CPU\n", cycle()));
16561670   /* release the CPU (held for emulating cycles stolen by ANTIC DMA) */
16571671   machine().scheduler().trigger(TRIGGER_STEAL);
16581672   
16591673   /* refresh the display (translate color clocks to pixels) */
1660   antic_linerefresh();
1674   linerefresh();
16611675}
16621676
16631677/*****************************************************************************
r32026r32027
16691683 *  TRIGGER_HSYNC if WSYNC (D01A) was accessed
16701684 *
16711685 *****************************************************************************/
1672TIMER_CALLBACK_MEMBER( atari_common_state::antic_steal_cycles )
1686TIMER_CALLBACK_MEMBER( antic_device::steal_cycles )
16731687{
1674   LOG(("           @cycle #%3d steal %d cycles\n", cycle(), antic.steal_cycles));
1675   timer_set(ANTIC_TIME_FROM_CYCLES(antic.steal_cycles), TIMER_LINE_DONE);
1676   antic.steal_cycles = 0;
1688   LOG(("           @cycle #%3d steal %d cycles\n", cycle(), m_steal_cycles));
1689   timer_set(ANTIC_TIME_FROM_CYCLES(m_steal_cycles), TIMER_LINE_DONE);
1690   m_steal_cycles = 0;
16771691   machine().device("maincpu")->execute().spin_until_trigger(TRIGGER_STEAL);
16781692}
16791693
r32026r32027
16861700 *  of the GTIA if enabled (DMA_PLAYER or DMA_MISSILE)
16871701 *
16881702 *****************************************************************************/
1689TIMER_CALLBACK_MEMBER( atari_common_state::antic_scanline_render )
1703TIMER_CALLBACK_MEMBER( antic_device::scanline_render )
16901704{
16911705   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
16921706   
1693   LOG(("           @cycle #%3d render mode $%X lines to go #%d\n", cycle(), (antic.cmd & 0x0f), antic.modelines));
1707   LOG(("           @cycle #%3d render mode $%X lines to go #%d\n", cycle(), (m_cmd & 0x0f), m_modelines));
16941708   
1695   antic_render(space, m_antic_render1, m_antic_render2, m_antic_render3);
1709   render(space, m_render1, m_render2, m_render3);
16961710   
16971711   /* if player/missile graphics is enabled */
1698   if( antic.scanline < 256 && (antic.w.dmactl & (DMA_PLAYER|DMA_MISSILE)) )
1712   if( m_scanline < 256 && (m_w.dmactl & (DMA_PLAYER|DMA_MISSILE)) )
16991713   {
17001714      /* new player/missile graphics data for every scanline ? */
1701      if( antic.w.dmactl & DMA_PM_DBLLINE )
1715      if( m_w.dmactl & DMA_PM_DBLLINE )
17021716      {
17031717         /* transport missile data to GTIA ? */
1704         if( antic.w.dmactl & DMA_MISSILE )
1718         if( m_w.dmactl & DMA_MISSILE )
17051719         {
1706            antic.steal_cycles += 1;
1720            m_steal_cycles += 1;
17071721            m_gtia->write(space, 0x11, RDPMGFXD(space, 3*256));
17081722         }
17091723         /* transport player data to GTIA ? */
1710         if( antic.w.dmactl & DMA_PLAYER )
1724         if( m_w.dmactl & DMA_PLAYER )
17111725         {
1712            antic.steal_cycles += 4;
1726            m_steal_cycles += 4;
17131727            m_gtia->write(space, 0x0d, RDPMGFXD(space, 4*256));
17141728            m_gtia->write(space, 0x0e, RDPMGFXD(space, 5*256));
17151729            m_gtia->write(space, 0x0f, RDPMGFXD(space, 6*256));
r32026r32027
17191733      else
17201734      {
17211735         /* transport missile data to GTIA ? */
1722         if( antic.w.dmactl & DMA_MISSILE )
1736         if( m_w.dmactl & DMA_MISSILE )
17231737         {
1724            if( (antic.scanline & 1) == 0 )      /* even line ? */
1725               antic.steal_cycles += 1;
1738            if( (m_scanline & 1) == 0 )      /* even line ? */
1739               m_steal_cycles += 1;
17261740            m_gtia->write(space, 0x11, RDPMGFXS(space, 3*128));
17271741         }
17281742         /* transport player data to GTIA ? */
1729         if( antic.w.dmactl & DMA_PLAYER )
1743         if( m_w.dmactl & DMA_PLAYER )
17301744         {
1731            if( (antic.scanline & 1) == 0 )      /* even line ? */
1732               antic.steal_cycles += 4;
1745            if( (m_scanline & 1) == 0 )      /* even line ? */
1746               m_steal_cycles += 4;
17331747            m_gtia->write(space, 0x0d, RDPMGFXS(space, 4*128));
17341748            m_gtia->write(space, 0x0e, RDPMGFXS(space, 5*128));
17351749            m_gtia->write(space, 0x0f, RDPMGFXS(space, 6*128));
r32026r32027
17381752      }
17391753   }
17401754   
1741   if (antic.scanline >= VBL_END && antic.scanline < 256)
1742      m_gtia->render((UINT8 *)antic.pmbits + PMOFFSET, (UINT8 *)antic.cclock + PMOFFSET - antic.hscrol_old, (UINT8 *)antic.prio_table[m_gtia->get_w_prior() & 0x3f], (UINT8 *)&antic.pmbits);
1755   if (m_scanline >= VBL_END && m_scanline < 256)
1756      m_gtia->render((UINT8 *)m_pmbits + PMOFFSET, (UINT8 *)m_cclock + PMOFFSET - m_hscrol_old, (UINT8 *)m_prio_table[m_gtia->get_w_prior() & 0x3f], (UINT8 *)&m_pmbits);
17431757   
1744   antic.steal_cycles += CYCLES_REFRESH;
1745   LOG(("           run CPU for %d cycles\n", CYCLES_HSYNC - CYCLES_HSTART - antic.steal_cycles));
1746   timer_set(ANTIC_TIME_FROM_CYCLES(CYCLES_HSYNC - CYCLES_HSTART - antic.steal_cycles), TIMER_CYCLE_STEAL);
1758   m_steal_cycles += CYCLES_REFRESH;
1759   LOG(("           run CPU for %d cycles\n", CYCLES_HSYNC - CYCLES_HSTART - m_steal_cycles));
1760   timer_set(ANTIC_TIME_FROM_CYCLES(CYCLES_HSYNC - CYCLES_HSTART - m_steal_cycles), TIMER_CYCLE_STEAL);
17471761}
17481762
17491763
17501764
1751void atari_common_state::LMS(int new_cmd)
1765void antic_device::LMS(int new_cmd)
17521766{
17531767   /**************************************************************
17541768    * If the LMS bit (load memory scan) of the current display
r32026r32027
17601774   {
17611775      address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
17621776      int addr = RDANTIC(space);
1763      antic.doffs = (antic.doffs + 1) & DOFFS;
1777      m_doffs = (m_doffs + 1) & DOFFS;
17641778      addr += 256 * RDANTIC(space);
1765      antic.doffs = (antic.doffs + 1) & DOFFS;
1766      antic.vpage = addr & VPAGE;
1767      antic.voffs = addr & VOFFS;
1779      m_doffs = (m_doffs + 1) & DOFFS;
1780      m_vpage = addr & VPAGE;
1781      m_voffs = addr & VOFFS;
17681782      LOG(("           LMS $%04x\n", addr));
17691783      /* steal two more clock cycles from the cpu */
1770      antic.steal_cycles += 2;
1784      m_steal_cycles += 2;
17711785   }
17721786}
17731787
r32026r32027
17811795 *  if so, read a new command and set up the renderer function
17821796 *
17831797 *****************************************************************************/
1784void atari_common_state::antic_scanline_dma(int param)
1798void antic_device::scanline_dma(int param)
17851799{
17861800   address_space &space = machine().device("maincpu")->memory().space(AS_PROGRAM);
17871801   LOG(("           @cycle #%3d DMA fetch\n", cycle()));
1788   if (antic.scanline == VBL_END)
1789      antic.r.nmist &= ~VBL_NMI;
1790   if( antic.w.dmactl & DMA_ANTIC )
1802   if (m_scanline == VBL_END)
1803      m_r.nmist &= ~VBL_NMI;
1804   if( m_w.dmactl & DMA_ANTIC )
17911805   {
1792      if( antic.scanline >= VBL_END && antic.scanline < VBL_START )
1806      if( m_scanline >= VBL_END && m_scanline < VBL_START )
17931807      {
1794         if( antic.modelines <= 0 )
1808         if( m_modelines <= 0 )
17951809         {
1796            m_antic_render1 = 0;
1797            m_antic_render3 = antic.w.dmactl & 3;
1810            m_render1 = 0;
1811            m_render3 = m_w.dmactl & 3;
17981812            UINT8 vscrol_subtract = 0;
17991813            UINT8 new_cmd;
18001814           
18011815            new_cmd = RDANTIC(space);
1802            antic.doffs = (antic.doffs + 1) & DOFFS;
1816            m_doffs = (m_doffs + 1) & DOFFS;
18031817            /* steal at one clock cycle from the CPU for fetching the command */
1804            antic.steal_cycles += 1;
1818            m_steal_cycles += 1;
18051819            LOG(("           ANTIC CMD $%02x\n", new_cmd));
18061820            /* command 1 .. 15 ? */
18071821            if (new_cmd & ANTIC_MODE)
18081822            {
1809               antic.w.chbasl = 0;
1823               m_w.chbasl = 0;
18101824               /* vertical scroll mode changed ? */
1811               if( (antic.cmd ^ new_cmd) & ANTIC_VSCR )
1825               if( (m_cmd ^ new_cmd) & ANTIC_VSCR )
18121826               {
18131827                  /* vertical scroll activate now ? */
18141828                  if( new_cmd & ANTIC_VSCR )
18151829                  {
1816                     antic.vscrol_old =
1830                     m_vscrol_old =
18171831                     vscrol_subtract =
1818                     antic.w.chbasl = antic.w.vscrol;
1832                     m_w.chbasl = m_w.vscrol;
18191833                  }
18201834                  else
18211835                  {
1822                     vscrol_subtract = ~antic.vscrol_old;
1836                     vscrol_subtract = ~m_vscrol_old;
18231837                  }
18241838               }
18251839               /* does this command have horizontal scroll enabled ? */
18261840               if( new_cmd & ANTIC_HSCR )
18271841               {
1828                  m_antic_render1 = 1;
1829                  antic.hscrol_old = antic.w.hscrol;
1842                  m_render1 = 1;
1843                  m_hscrol_old = m_w.hscrol;
18301844               }
18311845               else
18321846               {
1833                  antic.hscrol_old = 0;
1847                  m_hscrol_old = 0;
18341848               }
18351849            }
18361850            /* Set the ANTIC mode renderer function */
1837            m_antic_render2 = new_cmd & ANTIC_MODE;
1851            m_render2 = new_cmd & ANTIC_MODE;
18381852           
18391853            switch( new_cmd & ANTIC_MODE )
18401854            {
18411855               case 0x00:
18421856                  /* generate 1 .. 8 empty lines */
1843                  antic.modelines = ((new_cmd >> 4) & 7) + 1;
1857                  m_modelines = ((new_cmd >> 4) & 7) + 1;
18441858                  /* did the last ANTIC command have vertical scroll enabled ? */
1845                  if( antic.cmd & ANTIC_VSCR )
1859                  if( m_cmd & ANTIC_VSCR )
18461860                  {
18471861                     /* yes, generate vscrol_old additional empty lines */
1848                     antic.modelines += antic.vscrol_old;
1862                     m_modelines += m_vscrol_old;
18491863                  }
18501864                  /* leave only bit 7 (DLI) set in ANTIC command */
18511865                  new_cmd &= ANTIC_DLI;
r32026r32027
18621876                  if( new_cmd & ANTIC_LMS )
18631877                  {
18641878                     int addr = RDANTIC(space);
1865                     antic.doffs = (antic.doffs + 1) & DOFFS;
1879                     m_doffs = (m_doffs + 1) & DOFFS;
18661880                     addr += 256 * RDANTIC(space);
1867                     antic.dpage = addr & DPAGE;
1868                     antic.doffs = addr & DOFFS;
1881                     m_dpage = addr & DPAGE;
1882                     m_doffs = addr & DOFFS;
18691883                     /* produce empty scanlines until vblank start */
1870                     antic.modelines = VBL_START + 1 - antic.scanline;
1871                     if( antic.modelines < 0 )
1872                        antic.modelines = machine().first_screen()->height() - antic.scanline;
1873                     LOG(("           JVB $%04x\n", antic.dpage|antic.doffs));
1884                     m_modelines = VBL_START + 1 - m_scanline;
1885                     if( m_modelines < 0 )
1886                        m_modelines = machine().first_screen()->height() - m_scanline;
1887                     LOG(("           JVB $%04x\n", m_dpage|m_doffs));
18741888                  }
18751889                  else
18761890                  {
18771891                     int addr = RDANTIC(space);
1878                     antic.doffs = (antic.doffs + 1) & DOFFS;
1892                     m_doffs = (m_doffs + 1) & DOFFS;
18791893                     addr += 256 * RDANTIC(space);
1880                     antic.dpage = addr & DPAGE;
1881                     antic.doffs = addr & DOFFS;
1894                     m_dpage = addr & DPAGE;
1895                     m_doffs = addr & DOFFS;
18821896                     /* produce a single empty scanline */
1883                     antic.modelines = 1;
1884                     LOG(("           JMP $%04x\n", antic.dpage|antic.doffs));
1897                     m_modelines = 1;
1898                     LOG(("           JMP $%04x\n", m_dpage|m_doffs));
18851899                  }
18861900                  break;
18871901               case 0x02:
18881902                  LMS(new_cmd);
1889                  antic.chbase = (antic.w.chbash & 0xfc) << 8;
1890                  antic.modelines = 8 - (vscrol_subtract & 7);
1891                  if( antic.w.chactl & 4 )    /* decrement chbasl? */
1892                     antic.w.chbasl = antic.modelines - 1;
1903                  m_chbase = (m_w.chbash & 0xfc) << 8;
1904                  m_modelines = 8 - (vscrol_subtract & 7);
1905                  if( m_w.chactl & 4 )    /* decrement chbasl? */
1906                     m_w.chbasl = m_modelines - 1;
18931907                  break;
18941908               case 0x03:
18951909                  LMS(new_cmd);
1896                  antic.chbase = (antic.w.chbash & 0xfc) << 8;
1897                  antic.modelines = 10 - (vscrol_subtract & 9);
1898                  if( antic.w.chactl & 4 )    /* decrement chbasl? */
1899                     antic.w.chbasl = antic.modelines - 1;
1910                  m_chbase = (m_w.chbash & 0xfc) << 8;
1911                  m_modelines = 10 - (vscrol_subtract & 9);
1912                  if( m_w.chactl & 4 )    /* decrement chbasl? */
1913                     m_w.chbasl = m_modelines - 1;
19001914                  break;
19011915               case 0x04:
19021916                  LMS(new_cmd);
1903                  antic.chbase = (antic.w.chbash & 0xfc) << 8;
1904                  antic.modelines = 8 - (vscrol_subtract & 7);
1905                  if( antic.w.chactl & 4 )    /* decrement chbasl? */
1906                     antic.w.chbasl = antic.modelines - 1;
1917                  m_chbase = (m_w.chbash & 0xfc) << 8;
1918                  m_modelines = 8 - (vscrol_subtract & 7);
1919                  if( m_w.chactl & 4 )    /* decrement chbasl? */
1920                     m_w.chbasl = m_modelines - 1;
19071921                  break;
19081922               case 0x05:
19091923                  LMS(new_cmd);
1910                  antic.chbase = (antic.w.chbash & 0xfc) << 8;
1911                  antic.modelines = 16 - (vscrol_subtract & 15);
1912                  if( antic.w.chactl & 4 )    /* decrement chbasl? */
1913                     antic.w.chbasl = antic.modelines - 1;
1924                  m_chbase = (m_w.chbash & 0xfc) << 8;
1925                  m_modelines = 16 - (vscrol_subtract & 15);
1926                  if( m_w.chactl & 4 )    /* decrement chbasl? */
1927                     m_w.chbasl = m_modelines - 1;
19141928                  break;
19151929               case 0x06:
19161930                  LMS(new_cmd);
1917                  antic.chbase = (antic.w.chbash & 0xfe) << 8;
1918                  antic.modelines = 8 - (vscrol_subtract & 7);
1919                  if( antic.w.chactl & 4 )    /* decrement chbasl? */
1920                     antic.w.chbasl = antic.modelines - 1;
1931                  m_chbase = (m_w.chbash & 0xfe) << 8;
1932                  m_modelines = 8 - (vscrol_subtract & 7);
1933                  if( m_w.chactl & 4 )    /* decrement chbasl? */
1934                     m_w.chbasl = m_modelines - 1;
19211935                  break;
19221936               case 0x07:
19231937                  LMS(new_cmd);
1924                  antic.chbase = (antic.w.chbash & 0xfe) << 8;
1925                  antic.modelines = 16 - (vscrol_subtract & 15);
1926                  if( antic.w.chactl & 4 )    /* decrement chbasl? */
1927                     antic.w.chbasl = antic.modelines - 1;
1938                  m_chbase = (m_w.chbash & 0xfe) << 8;
1939                  m_modelines = 16 - (vscrol_subtract & 15);
1940                  if( m_w.chactl & 4 )    /* decrement chbasl? */
1941                     m_w.chbasl = m_modelines - 1;
19281942                  break;
19291943               case 0x08:
19301944                  LMS(new_cmd);
1931                  antic.modelines = 8 - (vscrol_subtract & 7);
1945                  m_modelines = 8 - (vscrol_subtract & 7);
19321946                  break;
19331947               case 0x09:
19341948                  LMS(new_cmd);
1935                  antic.modelines = 4 - (vscrol_subtract & 3);
1949                  m_modelines = 4 - (vscrol_subtract & 3);
19361950                  break;
19371951               case 0x0a:
19381952                  LMS(new_cmd);
1939                  antic.modelines = 4 - (vscrol_subtract & 3);
1953                  m_modelines = 4 - (vscrol_subtract & 3);
19401954                  break;
19411955               case 0x0b:
19421956                  LMS(new_cmd);
1943                  antic.modelines = 2 - (vscrol_subtract & 1);
1957                  m_modelines = 2 - (vscrol_subtract & 1);
19441958                  break;
19451959               case 0x0c:
19461960                  LMS(new_cmd);
1947                  antic.modelines = 1;
1961                  m_modelines = 1;
19481962                  break;
19491963               case 0x0d:
19501964                  LMS(new_cmd);
1951                  antic.modelines = 2 - (vscrol_subtract & 1);
1965                  m_modelines = 2 - (vscrol_subtract & 1);
19521966                  break;
19531967               case 0x0e:
19541968                  LMS(new_cmd);
1955                  antic.modelines = 1;
1969                  m_modelines = 1;
19561970                  break;
19571971               case 0x0f:
19581972                  LMS(new_cmd);
r32026r32027
19611975                  switch (m_gtia->get_w_prior() >> 6)
19621976               {
19631977                  case 0: break;
1964                  case 1: m_antic_render2 = 16;  break;
1965                  case 2: m_antic_render2 = 17;  break;
1966                  case 3: m_antic_render2 = 18;  break;
1978                  case 1: m_render2 = 16;  break;
1979                  case 2: m_render2 = 17;  break;
1980                  case 3: m_render2 = 18;  break;
19671981               }
1968                  antic.modelines = 1;
1982                  m_modelines = 1;
19691983                  break;
19701984            }
19711985            /* set new (current) antic command */
1972            antic.cmd = new_cmd;
1986            m_cmd = new_cmd;
19731987         }
19741988      }
19751989      else
19761990      {
19771991         LOG(("           out of visible range\n"));
1978         antic.cmd = 0x00;
1979         m_antic_render1 = 0;
1980         m_antic_render2 = 0;
1981         m_antic_render3 = 0;
1992         m_cmd = 0x00;
1993         m_render1 = 0;
1994         m_render2 = 0;
1995         m_render3 = 0;
19821996      }
19831997   }
19841998   else
19851999   {
19862000      LOG(("           DMA is off\n"));
1987      antic.cmd = 0x00;
1988      m_antic_render1 = 0;
1989      m_antic_render2 = 0;
1990      m_antic_render3 = 0;
2001      m_cmd = 0x00;
2002      m_render1 = 0;
2003      m_render2 = 0;
2004      m_render3 = 0;
19912005   }
19922006   
1993   antic.r.nmist &= ~DLI_NMI;
1994   if (antic.modelines == 1 && (antic.cmd & antic.w.nmien & DLI_NMI))
2007   m_r.nmist &= ~DLI_NMI;
2008   if (m_modelines == 1 && (m_cmd & m_w.nmien & DLI_NMI))
19952009      timer_set(ANTIC_TIME_FROM_CYCLES(CYCLES_DLI_NMI), TIMER_ISSUE_DLI);
19962010   
19972011   timer_set(ANTIC_TIME_FROM_CYCLES(CYCLES_HSTART), TIMER_LINE_REND);
19982012}
2013
2014/*****************************************************************************
2015 *
2016 *  Generic Atari Interrupt Dispatcher
2017 *  This is called once per scanline and handles:
2018 *  vertical blank interrupt
2019 *  ANTIC DMA to possibly access the next display list command
2020 *
2021 *****************************************************************************/
2022
2023void antic_device::generic_interrupt(int button_count)
2024{
2025   LOG(("ANTIC #%3d @cycle #%d scanline interrupt\n", m_scanline, cycle()));
2026   
2027   if( m_scanline < VBL_START )
2028   {
2029      scanline_dma(0);
2030      return;
2031   }
2032   
2033   if( m_scanline == VBL_START )
2034   {
2035      /* specify buttons relevant to this Atari variant */
2036      m_gtia->button_interrupt(button_count, machine().root_device().ioport("djoy_b")->read_safe(0));
2037     
2038      /* do nothing new for the rest of the frame */
2039      m_modelines = machine().first_screen()->height() - VBL_START;
2040      m_render1 = 0;
2041      m_render2 = 0;
2042      m_render3 = 0;
2043     
2044      /* if the CPU want's to be interrupted at vertical blank... */
2045      if( m_w.nmien & VBL_NMI )
2046      {
2047         LOG(("           cause VBL NMI\n"));
2048         /* set the VBL NMI status bit */
2049         m_r.nmist |= VBL_NMI;
2050         machine().device("maincpu")->execute().set_input_line(INPUT_LINE_NMI, PULSE_LINE);
2051      }
2052   }
2053   
2054   /* refresh the display (translate color clocks to pixels) */
2055   linerefresh();
2056}
2057
trunk/src/mame/video/antic.h
r32026r32027
1212#define __ANTIC_H__
1313
1414#include "emu.h"
15#include "video/gtia.h"
1516
17
18#define CYCLES_PER_LINE 114     /* total number of cpu cycles per scanline (incl. hblank) */
19#define CYCLES_REFRESH  9       /* number of cycles lost for ANTICs RAM refresh using DMA */
20#define CYCLES_HSTART   32      /* where does the ANTIC DMA fetch start */
21#define CYCLES_DLI_NMI  7       /* number of cycles until the CPU recognizes a DLI */
22#define CYCLES_HSYNC    104     /* where does the HSYNC position of a scanline start */
23
24#define VBL_END         8       /* vblank ends in this scanline */
25#define VDATA_START     11      /* video display begins in this scanline */
26#define VDATA_END       244     /* video display ends in this scanline */
27#define VBL_START       248     /* vblank starts in this scanline */
28
29/* total number of lines per frame (incl. vblank) */
30#define TOTAL_LINES_60HZ 262
31#define TOTAL_LINES_50HZ 312
32
33/* frame rates */
34#define FRAME_RATE_50HZ (double)1789790/114/TOTAL_LINES_50HZ
35#define FRAME_RATE_60HZ (double)1789790/114/TOTAL_LINES_60HZ
36
1637#define HWIDTH          48      /* total characters per line */
1738#define HCHARS          44      /* visible characters per line */
1839#define VHEIGHT         32
r32026r32027
122143#define COPY8(dst,s1,s2) *dst++ = s1; *dst++ = s2
123144#define COPY16(dst,s1,s2,s3,s4) *dst++ = s1; *dst++ = s2; *dst++ = s3; *dst++ = s4
124145
125struct ANTIC_R {
126   UINT8   antic00;    /* 00 nothing */
127   UINT8   antic01;    /* 01 nothing */
128   UINT8   antic02;    /* 02 nothing */
129   UINT8   antic03;    /* 03 nothing */
130   UINT8   antic04;    /* 04 nothing */
131   UINT8   antic05;    /* 05 nothing */
132   UINT8   antic06;    /* 06 nothing */
133   UINT8   antic07;    /* 07 nothing */
134   UINT8   antic08;    /* 08 nothing */
135   UINT8   antic09;    /* 09 nothing */
136   UINT8   antic0a;    /* 0a nothing */
137   UINT8   vcount;     /* 0b vertical (scanline) counter */
138   UINT8   penh;       /* 0c light pen horizontal pos */
139   UINT8   penv;       /* 0d light pen vertical pos */
140   UINT8   antic0e;    /* 0e nothing */
141   UINT8   nmist;      /* 0f NMI status */
142};  /* read registers */
146#define RDANTIC(space)      space.read_byte(m_dpage+m_doffs)
147#define RDVIDEO(space,o)    space.read_byte(m_vpage+((m_voffs+(o))&VOFFS))
148#define RDCHGEN(space,o)    space.read_byte(m_chbase+(o))
149#define RDPMGFXS(space,o)   space.read_byte(m_pmbase_s+(o)+(m_scanline>>1))
150#define RDPMGFXD(space,o)   space.read_byte(m_pmbase_d+(o)+m_scanline)
143151
144struct ANTIC_W {
145   UINT8   dmactl;     /* 00 write DMA control */
146   UINT8   chactl;     /* 01 write character control */
147   UINT8   dlistl;     /* 02 display list low */
148   UINT8   dlisth;     /* 03 display list high */
149   UINT8   hscrol;     /* 04 horz scroll */
150   UINT8   vscrol;     /* 05 vert scroll */
151   UINT8   pmbasl;     /* 06 player/missile base addr low */
152   UINT8   pmbash;     /* 07 player/missile base addr high */
153   UINT8   chbasl;     /* 08 character generator base addr low */
154   UINT8   chbash;     /* 09 character generator base addr high */
155   UINT8   wsync;      /* 0a wait for hsync */
156   UINT8   antic0b;    /* 0b nothing */
157   UINT8   antic0c;    /* 0c nothing */
158   UINT8   antic0d;    /* 0d nothing */
159   UINT8   nmien;      /* 0e NMI enable */
160   UINT8   nmires;     /* 0f NMI reset */
161};  /* write registers */
162
163/* per scanline buffer for video data (and optimization variables) */
164struct VIDEO {
165   UINT32  cmd;                /* antic command for this scanline */
166   UINT16  data[HWIDTH];       /* graphics data buffer (text through chargen) */
167};
168
169typedef void (*atari_renderer_func)(address_space &space, VIDEO *video);
170
171struct ANTIC {
172   atari_renderer_func renderer;   /* current renderer */
173   UINT32  cmd;                /* currently executed display list command */
174   UINT32  steal_cycles;       /* steal how many cpu cycles for this line ? */
175   UINT32  vscrol_old;         /* old vscrol value */
176   UINT32  hscrol_old;         /* old hscrol value */
177   INT32   modelines;          /* number of lines for current ANTIC mode */
178   UINT32  chbase;             /* character mode source base */
179   UINT32  chand;              /* character and mask (chactl) */
180   UINT32  chxor;              /* character xor mask (chactl) */
181   UINT32  scanline;           /* current scan line */
182   UINT32  pfwidth;            /* playfield width */
183   UINT32  dpage;              /* display list address page */
184   UINT32  doffs;              /* display list offset into page */
185   UINT32  vpage;              /* video data source page */
186   UINT32  voffs;              /* video data offset into page */
187   UINT32  pmbase_s;           /* p/m graphics single line source base */
188   UINT32  pmbase_d;           /* p/m graphics double line source base */
189   ANTIC_R r;                  /* ANTIC read registers */
190   ANTIC_W w;                  /* ANTIC write registers */
191   UINT8   cclock[256+32];     /* color clock buffer filled by ANTIC */
192   UINT8   pmbits[256+32];     /* player missile buffer filled by GTIA */
193   UINT8   *prio_table[64];    /* player/missile priority tables */
194   VIDEO   *video[312];        /* video buffer */
195   UINT32  *cclk_expand;       /* shared buffer for the following: */
196   UINT32  *pf_21;             /* 1cclk 2 color txt 2,3 */
197   UINT32  *pf_x10b;           /* 1cclk 4 color txt 4,5, gfx D,E */
198   UINT32  *pf_3210b2;         /* 1cclk 5 color txt 6,7, gfx 9,B,C */
199   UINT32  *pf_210b4;          /* 4cclk 4 color gfx 8 */
200   UINT32  *pf_210b2;          /* 2cclk 4 color gfx A */
201   UINT32  *pf_1b;             /* 1cclk hires gfx F */
202   UINT32  *pf_gtia1;          /* 1cclk gtia mode 1 */
203   UINT32  *pf_gtia2;          /* 1cclk gtia mode 2 */
204   UINT32  *pf_gtia3;          /* 1cclk gtia mode 3 */
205   UINT8   *used_colors;       /* shared buffer for the following: */
206   UINT8   *uc_21;             /* used colors for txt (2,3) */
207   UINT8   *uc_x10b;           /* used colors for txt 4,5, gfx D,E */
208   UINT8   *uc_3210b2;         /* used colors for txt 6,7, gfx 9,B,C */
209   UINT8   *uc_210b4;          /* used colors for gfx 8 */
210   UINT8   *uc_210b2;          /* used colors for gfx A */
211   UINT8   *uc_1b;             /* used colors for gfx F */
212   UINT8   *uc_g1;             /* used colors for gfx GTIA 1 */
213   UINT8   *uc_g2;             /* used colors for gfx GTIA 2 */
214   UINT8   *uc_g3;             /* used colors for gfx GTIA 3 */
215   bitmap_ind16 *bitmap;
216};
217
218#define RDANTIC(space)      space.read_byte(antic.dpage+antic.doffs)
219#define RDVIDEO(space,o)    space.read_byte(antic.vpage+((antic.voffs+(o))&VOFFS))
220#define RDCHGEN(space,o)    space.read_byte(antic.chbase+(o))
221#define RDPMGFXS(space,o)   space.read_byte(antic.pmbase_s+(o)+(antic.scanline>>1))
222#define RDPMGFXD(space,o)   space.read_byte(antic.pmbase_d+(o)+antic.scanline)
223
224152#define PREPARE()                                               \
225   UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET]
153   UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET]
226154
227155#define PREPARE_TXT2(space,width)                               \
228   UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET];            \
156   UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET];            \
229157   for (int i = 0; i < width; i++)                             \
230158   {                                                           \
231159      UINT16 ch = RDVIDEO(space,i) << 3;                      \
232160      if (ch & 0x400)                                         \
233161      {                                                       \
234         ch = RDCHGEN(space,(ch & 0x3f8) + antic.w.chbasl);  \
235         ch = (ch ^ antic.chxor) & antic.chand;              \
162         ch = RDCHGEN(space,(ch & 0x3f8) + m_w.chbasl);  \
163         ch = (ch ^ m_chxor) & m_chand;              \
236164      }                                                       \
237165      else                                                    \
238166      {                                                       \
239         ch = RDCHGEN(space,ch + antic.w.chbasl);            \
167         ch = RDCHGEN(space,ch + m_w.chbasl);            \
240168      }                                                       \
241169      video->data[i] = ch;                                    \
242170   }
243171
244172#define PREPARE_TXT3(space,width)                               \
245   UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET];            \
173   UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET];            \
246174   for (int i = 0; i < width; i++)                             \
247175   {                                                           \
248176      UINT16 ch = RDVIDEO(space,i) << 3;                      \
r32026r32027
251179         ch &= 0x3f8;                                        \
252180         if ((ch & 0x300) == 0x300)                          \
253181         {                                                   \
254            if (antic.w.chbasl < 2) /* first two lines empty */ \
182            if (m_w.chbasl < 2) /* first two lines empty */ \
255183               ch = 0x00;                                  \
256184            else /* lines 2..7 are standard, 8&9 are 0&1 */ \
257               ch = RDCHGEN(space,ch + (antic.w.chbasl & 7));\
185               ch = RDCHGEN(space,ch + (m_w.chbasl & 7));\
258186         }                                                   \
259187         else                                                \
260188         {                                                   \
261            if (antic.w.chbasl > 7) /* last two lines empty */  \
189            if (m_w.chbasl > 7) /* last two lines empty */  \
262190               ch = 0x00;                                  \
263191            else /* lines 0..7 are standard */              \
264               ch = RDCHGEN(space,ch + antic.w.chbasl);    \
192               ch = RDCHGEN(space,ch + m_w.chbasl);    \
265193         }                                                   \
266         ch = (ch ^ antic.chxor) & antic.chand;              \
194         ch = (ch ^ m_chxor) & m_chand;              \
267195      }                                                       \
268196      else                                                    \
269197      {                                                       \
270198         if ((ch & 0x300) == 0x300)                          \
271199         {                                                   \
272            if (antic.w.chbasl < 2) /* first two lines empty */ \
200            if (m_w.chbasl < 2) /* first two lines empty */ \
273201               ch = 0x00;                                  \
274202            else /* lines 2..7 are standard, 8&9 are 0&1 */ \
275               ch = RDCHGEN(space,ch + (antic.w.chbasl & 7));\
203               ch = RDCHGEN(space,ch + (m_w.chbasl & 7));\
276204         }                                                   \
277205         else                                                \
278206         {                                                   \
279            if (antic.w.chbasl > 7) /* last two lines empty */  \
207            if (m_w.chbasl > 7) /* last two lines empty */  \
280208               ch = 0x00;                                  \
281209            else /* lines 0..7 are standard */              \
282               ch = RDCHGEN(space,ch + antic.w.chbasl);    \
210               ch = RDCHGEN(space,ch + m_w.chbasl);    \
283211         }                                                   \
284212      }                                                       \
285213      video->data[i] = ch;                                    \
286214   }
287215
288216#define PREPARE_TXT45(space,width,shift)                        \
289   UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET];            \
217   UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET];            \
290218   for (int i = 0; i < width; i++)                             \
291219   {                                                           \
292220      UINT16 ch = RDVIDEO(space,i) << 3;                      \
293      ch = ((ch>>2)&0x100)|RDCHGEN(space,(ch&0x3f8)+(antic.w.chbasl>>shift)); \
221      ch = ((ch>>2)&0x100)|RDCHGEN(space,(ch&0x3f8)+(m_w.chbasl>>shift)); \
294222      video->data[i] = ch;                                    \
295223   }
296224
297225
298226#define PREPARE_TXT67(space,width,shift)                        \
299   UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET];            \
227   UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET];            \
300228   for (int i = 0; i < width; i++)                             \
301229   {                                                           \
302230      UINT16 ch = RDVIDEO(space,i) << 3;                      \
303      ch = (ch&0x600)|(RDCHGEN(space,(ch&0x1f8)+(antic.w.chbasl>>shift))<<1); \
231      ch = (ch&0x600)|(RDCHGEN(space,(ch&0x1f8)+(m_w.chbasl>>shift))<<1); \
304232      video->data[i] = ch;                                    \
305233   }
306234
307235#define PREPARE_GFX8(space,width)                               \
308   UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET];            \
236   UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET];            \
309237   for (int i = 0; i < width; i++)                             \
310238      video->data[i] = RDVIDEO(space,i) << 2
311239
312240#define PREPARE_GFX9BC(space,width)                             \
313   UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET];            \
241   UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET];            \
314242   for (int i = 0; i < width; i++)                             \
315243      video->data[i] = RDVIDEO(space,i) << 1
316244
317245#define PREPARE_GFXA(space,width)                               \
318   UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET];            \
246   UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET];            \
319247   for (int i = 0; i < width; i++)                             \
320248      video->data[i] = RDVIDEO(space,i) << 1
321249
322250#define PREPARE_GFXDE(space,width)                              \
323   UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET];            \
251   UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET];            \
324252   for (int i = 0; i < width; i++)                             \
325253      video->data[i] = RDVIDEO(space,i)
326254
327255#define PREPARE_GFXF(space,width)                               \
328   UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET];            \
256   UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET];            \
329257   for (int i = 0; i < width; i++)                             \
330258      video->data[i] = RDVIDEO(space,i)
331259
332260#define PREPARE_GFXG1(space,width)                              \
333   UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET];            \
261   UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET];            \
334262   for (int i = 0; i < width; i++)                             \
335263      video->data[i] = RDVIDEO(space,i)
336264
337265#define PREPARE_GFXG2(space,width)                              \
338   UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET];            \
266   UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET];            \
339267   for (int i = 0; i < width; i++)                             \
340268      video->data[i] = RDVIDEO(space,i)
341269
342270#define PREPARE_GFXG3(space,width)                              \
343   UINT32 *dst = (UINT32 *)&antic.cclock[PMOFFSET];            \
271   UINT32 *dst = (UINT32 *)&m_cclock[PMOFFSET];            \
344272   for (int i = 0; i < width; i++)                             \
345273      video->data[i] = RDVIDEO(space,i)
346274
r32026r32027
348276 * common end of a single antic/gtia mode emulation function
349277 ******************************************************************/
350278#define POST()                                                  \
351   --antic.modelines
279   --m_modelines
352280
353281#define POST_GFX(width)                                         \
354   antic.steal_cycles += width;                                \
355   if (--antic.modelines == 0)                                 \
356      antic.voffs = (antic.voffs + width) & VOFFS
282   m_steal_cycles += width;                                \
283   if (--m_modelines == 0)                                 \
284      m_voffs = (m_voffs + width) & VOFFS
357285
358286#define POST_TXT(width)                                         \
359   antic.steal_cycles += width;                                \
360   if (--antic.modelines == 0)                                 \
361      antic.voffs = (antic.voffs + width) & VOFFS;            \
362   else if (antic.w.chactl & 4)                                \
363      antic.w.chbasl--;                                       \
287   m_steal_cycles += width;                                \
288   if (--m_modelines == 0)                                 \
289      m_voffs = (m_voffs + width) & VOFFS;            \
290   else if (m_w.chactl & 4)                                \
291      m_w.chbasl--;                                       \
364292   else                                                        \
365      antic.w.chbasl++
293      m_w.chbasl++
366294
367295/* erase a number of color clocks to background color PBK */
368296#define ERASE(size)                     \
r32026r32027
387315   }                              \
388316
389317
390void antic_start(running_machine &machine);
391void antic_vstart(running_machine &machine);
392void antic_reset(void);
393void antic_render(address_space &space, int param1, int param2, int param3);
394318
319struct ANTIC_R {
320   UINT8   antic00;    /* 00 nothing */
321   UINT8   antic01;    /* 01 nothing */
322   UINT8   antic02;    /* 02 nothing */
323   UINT8   antic03;    /* 03 nothing */
324   UINT8   antic04;    /* 04 nothing */
325   UINT8   antic05;    /* 05 nothing */
326   UINT8   antic06;    /* 06 nothing */
327   UINT8   antic07;    /* 07 nothing */
328   UINT8   antic08;    /* 08 nothing */
329   UINT8   antic09;    /* 09 nothing */
330   UINT8   antic0a;    /* 0a nothing */
331   UINT8   vcount;     /* 0b vertical (scanline) counter */
332   UINT8   penh;       /* 0c light pen horizontal pos */
333   UINT8   penv;       /* 0d light pen vertical pos */
334   UINT8   antic0e;    /* 0e nothing */
335   UINT8   nmist;      /* 0f NMI status */
336};  /* read registers */
395337
396extern ANTIC antic;
338struct ANTIC_W {
339   UINT8   dmactl;     /* 00 write DMA control */
340   UINT8   chactl;     /* 01 write character control */
341   UINT8   dlistl;     /* 02 display list low */
342   UINT8   dlisth;     /* 03 display list high */
343   UINT8   hscrol;     /* 04 horz scroll */
344   UINT8   vscrol;     /* 05 vert scroll */
345   UINT8   pmbasl;     /* 06 player/missile base addr low */
346   UINT8   pmbash;     /* 07 player/missile base addr high */
347   UINT8   chbasl;     /* 08 character generator base addr low */
348   UINT8   chbash;     /* 09 character generator base addr high */
349   UINT8   wsync;      /* 0a wait for hsync */
350   UINT8   antic0b;    /* 0b nothing */
351   UINT8   antic0c;    /* 0c nothing */
352   UINT8   antic0d;    /* 0d nothing */
353   UINT8   nmien;      /* 0e NMI enable */
354   UINT8   nmires;     /* 0f NMI reset */
355};  /* write registers */
397356
357/* per scanline buffer for video data (and optimization variables) */
358struct VIDEO {
359   UINT32  cmd;                /* antic command for this scanline */
360   UINT16  data[HWIDTH];       /* graphics data buffer (text through chargen) */
361};
362
363
364class antic_device :  public device_t
365{
366public:
367   // construction/destruction
368   antic_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
369
370   // device-level overrides
371   virtual void device_start();
372   virtual void device_reset();
373   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
374
375   static void set_gtia_tag(device_t &device, const char *tag) { downcast<antic_device &>(device).m_gtia_tag = tag; }
376
377   DECLARE_READ8_MEMBER( read );
378   DECLARE_WRITE8_MEMBER( write );
379
380   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
381   void generic_interrupt(int button_count);
382   
383private:
384   static const device_timer_id TIMER_CYCLE_STEAL = 0;
385   static const device_timer_id TIMER_ISSUE_DLI = 1;
386   static const device_timer_id TIMER_LINE_REND = 2;
387   static const device_timer_id TIMER_LINE_DONE = 3;
388
389   const char *m_gtia_tag;
390   gtia_device  *m_gtia;
391
392   UINT32 m_tv_artifacts;
393   int m_render1, m_render2, m_render3;
394
395   inline void mode_0(address_space &space, VIDEO *video);
396   inline void mode_2(address_space &space, VIDEO *video, int bytes, int erase);
397   inline void mode_3(address_space &space, VIDEO *video, int bytes, int erase);
398   inline void mode_4(address_space &space, VIDEO *video, int bytes, int erase);
399   inline void mode_5(address_space &space, VIDEO *video, int bytes, int erase);
400   inline void mode_6(address_space &space, VIDEO *video, int bytes, int erase);
401   inline void mode_7(address_space &space, VIDEO *video, int bytes, int erase);
402   inline void mode_8(address_space &space, VIDEO *video, int bytes, int erase);
403   inline void mode_9(address_space &space, VIDEO *video, int bytes, int erase);
404   inline void mode_a(address_space &space, VIDEO *video, int bytes, int erase);
405   inline void mode_b(address_space &space, VIDEO *video, int bytes, int erase);
406   inline void mode_c(address_space &space, VIDEO *video, int bytes, int erase);
407   inline void mode_d(address_space &space, VIDEO *video, int bytes, int erase);
408   inline void mode_e(address_space &space, VIDEO *video, int bytes, int erase);
409   inline void mode_f(address_space &space, VIDEO *video, int bytes, int erase);
410   inline void mode_gtia1(address_space &space, VIDEO *video, int bytes, int erase);
411   inline void mode_gtia2(address_space &space, VIDEO *video, int bytes, int erase);
412   inline void mode_gtia3(address_space &space, VIDEO *video, int bytes, int erase);
413
414   UINT32  m_cmd;                /* currently executed display list command */
415   UINT32  m_steal_cycles;       /* steal how many cpu cycles for this line ? */
416   UINT32  m_vscrol_old;         /* old vscrol value */
417   UINT32  m_hscrol_old;         /* old hscrol value */
418   INT32   m_modelines;          /* number of lines for current ANTIC mode */
419   UINT32  m_chbase;             /* character mode source base */
420   UINT32  m_chand;              /* character and mask (chactl) */
421   UINT32  m_chxor;              /* character xor mask (chactl) */
422   UINT32  m_scanline;           /* current scan line */
423   UINT32  m_pfwidth;            /* playfield width */
424   UINT32  m_dpage;              /* display list address page */
425   UINT32  m_doffs;              /* display list offset into page */
426   UINT32  m_vpage;              /* video data source page */
427   UINT32  m_voffs;              /* video data offset into page */
428   UINT32  m_pmbase_s;           /* p/m graphics single line source base */
429   UINT32  m_pmbase_d;           /* p/m graphics double line source base */
430   ANTIC_R m_r;                  /* ANTIC read registers */
431   ANTIC_W m_w;                  /* ANTIC write registers */
432   UINT8   m_cclock[256+32];     /* color clock buffer filled by ANTIC */
433   UINT8   m_pmbits[256+32];     /* player missile buffer filled by GTIA */
434   UINT8   *m_prio_table[64];    /* player/missile priority tables */
435   VIDEO   *m_video[312];        /* video buffer */
436   UINT32  *m_cclk_expand;       /* shared buffer for the following: */
437   UINT32  *m_pf_21;             /* 1cclk 2 color txt 2,3 */
438   UINT32  *m_pf_x10b;           /* 1cclk 4 color txt 4,5, gfx D,E */
439   UINT32  *m_pf_3210b2;         /* 1cclk 5 color txt 6,7, gfx 9,B,C */
440   UINT32  *m_pf_210b4;          /* 4cclk 4 color gfx 8 */
441   UINT32  *m_pf_210b2;          /* 2cclk 4 color gfx A */
442   UINT32  *m_pf_1b;             /* 1cclk hires gfx F */
443   UINT32  *m_pf_gtia1;          /* 1cclk gtia mode 1 */
444   UINT32  *m_pf_gtia2;          /* 1cclk gtia mode 2 */
445   UINT32  *m_pf_gtia3;          /* 1cclk gtia mode 3 */
446   UINT8   *m_used_colors;       /* shared buffer for the following: */
447   UINT8   *m_uc_21;             /* used colors for txt (2,3) */
448   UINT8   *m_uc_x10b;           /* used colors for txt 4,5, gfx D,E */
449   UINT8   *m_uc_3210b2;         /* used colors for txt 6,7, gfx 9,B,C */
450   UINT8   *m_uc_210b4;          /* used colors for gfx 8 */
451   UINT8   *m_uc_210b2;          /* used colors for gfx A */
452   UINT8   *m_uc_1b;             /* used colors for gfx F */
453   UINT8   *m_uc_g1;             /* used colors for gfx GTIA 1 */
454   UINT8   *m_uc_g2;             /* used colors for gfx GTIA 2 */
455   UINT8   *m_uc_g3;             /* used colors for gfx GTIA 3 */
456   bitmap_ind16 *m_bitmap;
457   
458   void prio_init();
459   void cclk_init();
460
461   void artifacts_gfx(UINT8 *src, UINT8 *dst, int width);
462   void artifacts_txt(UINT8 *src, UINT8 *dst, int width);
463
464   void linerefresh();
465   int cycle();
466
467   TIMER_CALLBACK_MEMBER( issue_dli );
468   TIMER_CALLBACK_MEMBER( line_done );
469   TIMER_CALLBACK_MEMBER( steal_cycles );
470   TIMER_CALLBACK_MEMBER( scanline_render );
471
472   void render(address_space &space, int param1, int param2, int param3);
473
474   inline void LMS(int new_cmd);
475   void scanline_dma(int param);
476};
477
478
479// device type definition
480extern const device_type ATARI_ANTIC;
481
482
483
484#define MCFG_ANTIC_GTIA(_tag) \
485   antic_device::set_gtia_tag(*device, _tag);
486
487
398488#endif /* __GTIA_H__ */
trunk/src/mame/drivers/maxaflex.c
r32026r32027
6565   WRITE_LINE_MEMBER(pia_cb2_w) { }  // This is used by Floppy drive on Atari 8bits Home Computers
6666   TIMER_DEVICE_CALLBACK_MEMBER(mcu_timer_proc);
6767   int atari_input_disabled();
68   virtual void machine_start();
6968   virtual void machine_reset();
7069   required_device<cpu_device> m_maincpu;
7170   required_device<cpu_device> m_mcu;
r32026r32027
289288   AM_RANGE(0xd100, 0xd1ff) AM_NOP
290289   AM_RANGE(0xd200, 0xd2ff) AM_DEVREADWRITE("pokey", pokey_device, read, write)
291290   AM_RANGE(0xd300, 0xd3ff) AM_DEVREADWRITE("pia", pia6821_device, read_alt, write_alt)
292   AM_RANGE(0xd400, 0xd4ff) AM_READWRITE(atari_antic_r, atari_antic_w)
291   AM_RANGE(0xd400, 0xd4ff) AM_DEVREADWRITE("antic", antic_device, read, write)
293292   AM_RANGE(0xd500, 0xd7ff) AM_NOP
294293   AM_RANGE(0xd800, 0xffff) AM_ROM /* OS */
295294ADDRESS_MAP_END
r32026r32027
385384}
386385
387386
388void maxaflex_state::machine_start()
389{
390   /* ANTIC */
391   antic_start(machine());
392}
393
394387void maxaflex_state::machine_reset()
395388{
396389   pokey_device *pokey = machine().device<pokey_device>("pokey");
397390   pokey->write(15,0);
398   antic_reset();
399391
400392   // Supervisor board reset
401393   m_portA_in = m_portA_out = m_ddrA = 0;
r32026r32027
426418   MCFG_DEVICE_ADD("gtia", ATARI_GTIA, 0)
427419   MCFG_GTIA_READ_CB(IOPORT("console"))
428420
421   MCFG_DEVICE_ADD("antic", ATARI_ANTIC, 0)
422   MCFG_ANTIC_GTIA("gtia")
423
429424   MCFG_DEVICE_ADD("pia", PIA6821, 0)
430425   MCFG_PIA_READPA_HANDLER(READ8(maxaflex_state, pia_pa_r))
431426   MCFG_PIA_READPB_HANDLER(READ8(maxaflex_state, pia_pb_r))
r32026r32027
440435   MCFG_SCREEN_VISIBLE_AREA(MIN_X, MAX_X, MIN_Y, MAX_Y)
441436   MCFG_SCREEN_REFRESH_RATE(FRAME_RATE_60HZ)
442437   MCFG_SCREEN_SIZE(HWIDTH*8, TOTAL_LINES_60HZ)
443   MCFG_SCREEN_UPDATE_DRIVER(atari_common_state, screen_update_atari)
438   MCFG_SCREEN_UPDATE_DEVICE("antic", antic_device, screen_update)
444439   MCFG_SCREEN_PALETTE("palette")
445440
446441   MCFG_PALETTE_ADD("palette", 256)
trunk/src/mame/drivers/bartop52.c
r32026r32027
3030      : atari_common_state(mconfig, type, tag),
3131      m_maincpu(*this, "maincpu") { }
3232
33   virtual void machine_start();
3433   virtual void machine_reset();
3534   required_device<cpu_device> m_maincpu;
3635};
r32026r32027
4039   AM_RANGE(0x0000, 0x3fff) AM_RAM
4140   AM_RANGE(0x4000, 0xbfff) AM_ROM
4241   AM_RANGE(0xc000, 0xc0ff) AM_DEVREADWRITE("gtia", gtia_device, read, write)
43   AM_RANGE(0xd400, 0xd5ff) AM_READWRITE(atari_antic_r, atari_antic_w)
42   AM_RANGE(0xd400, 0xd5ff) AM_DEVREADWRITE("antic", antic_device, read, write)
4443   AM_RANGE(0xe800, 0xe8ff) AM_DEVREADWRITE("pokey", pokey_device, read, write)
4544   AM_RANGE(0xf800, 0xffff) AM_ROM
4645ADDRESS_MAP_END
r32026r32027
102101INPUT_PORTS_END
103102
104103
105void bartop52_state::machine_start()
106{
107   /* ANTIC */
108   antic_start(machine());
109}
110
111104void bartop52_state::machine_reset()
112105{
113106   pokey_device *pokey = machine().device<pokey_device>("pokey");
114107   pokey->write(15,0);
115   antic_reset();
116108}
117109
118110
r32026r32027
124116
125117   MCFG_DEVICE_ADD("gtia", ATARI_GTIA, 0)
126118
119   MCFG_DEVICE_ADD("antic", ATARI_ANTIC, 0)
120   MCFG_ANTIC_GTIA("gtia")
121
127122   /* video hardware */
128123   MCFG_SCREEN_ADD("screen", RASTER)
129124   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1))
130125   MCFG_SCREEN_VISIBLE_AREA(MIN_X, MAX_X, MIN_Y, MAX_Y)
131126   MCFG_SCREEN_REFRESH_RATE(FRAME_RATE_60HZ)
132127   MCFG_SCREEN_SIZE(HWIDTH*8, TOTAL_LINES_60HZ)
133   MCFG_SCREEN_UPDATE_DRIVER(atari_common_state, screen_update_atari)
128   MCFG_SCREEN_UPDATE_DEVICE("antic", antic_device, screen_update)
134129   MCFG_SCREEN_PALETTE("palette")
135130
136131   MCFG_PALETTE_ADD("palette", 256)
trunk/src/mess/drivers/atari400.c
r32026r32027
263263
264264   DECLARE_MACHINE_RESET(a400);
265265
266   DECLARE_WRITE8_MEMBER(gtia_write);
266   DECLARE_WRITE8_MEMBER(gtia_cb);
267267
268268   DECLARE_WRITE8_MEMBER(a600xl_pia_pb_w);
269269   DECLARE_WRITE8_MEMBER(a800xl_pia_pb_w);
r32026r32027
304304   
305305   void setup_ram(int bank,UINT32 size);
306306   void setup_cart(a800_cart_slot_device *slot);
307
308   // start helper (until GTIA & ANTIC are device-fied)
309   void common_start();
310   void a5200_start();
311307};
312308
313309
r32026r32027
535531   AM_RANGE(0xd100, 0xd1ff) AM_NOP
536532   AM_RANGE(0xd200, 0xd2ff) AM_DEVREADWRITE("pokey", pokey_device, read, write)
537533   AM_RANGE(0xd300, 0xd3ff) AM_DEVREADWRITE("pia", pia6821_device, read_alt, write_alt)
538   AM_RANGE(0xd400, 0xd4ff) AM_READWRITE(atari_antic_r, atari_antic_w)
534   AM_RANGE(0xd400, 0xd4ff) AM_DEVREADWRITE("antic", antic_device, read, write)
539535   AM_RANGE(0xd500, 0xd7ff) AM_NOP
540536   AM_RANGE(0xd800, 0xffff) AM_ROM
541537ADDRESS_MAP_END
r32026r32027
550546   AM_RANGE(0xd100, 0xd1ff) AM_NOP
551547   AM_RANGE(0xd200, 0xd2ff) AM_DEVREADWRITE("pokey", pokey_device, read, write)
552548   AM_RANGE(0xd300, 0xd3ff) AM_DEVREADWRITE("pia", pia6821_device, read_alt, write_alt)
553   AM_RANGE(0xd400, 0xd4ff) AM_READWRITE(atari_antic_r, atari_antic_w)
549   AM_RANGE(0xd400, 0xd4ff) AM_DEVREADWRITE("antic", antic_device, read, write)
554550   AM_RANGE(0xd500, 0xd7ff) AM_NOP
555551   AM_RANGE(0xd800, 0xffff) AM_ROM // OS
556552ADDRESS_MAP_END
r32026r32027
562558   AM_RANGE(0xd100, 0xd1ff) AM_NOP
563559   AM_RANGE(0xd200, 0xd2ff) AM_DEVREADWRITE("pokey", pokey_device, read, write)
564560   AM_RANGE(0xd300, 0xd3ff) AM_DEVREADWRITE("pia", pia6821_device, read_alt, write_alt)
565   AM_RANGE(0xd400, 0xd4ff) AM_READWRITE(atari_antic_r, atari_antic_w)
561   AM_RANGE(0xd400, 0xd4ff) AM_DEVREADWRITE("antic", antic_device, read, write)
566562   AM_RANGE(0xd500, 0xd7ff) AM_NOP
567563   AM_RANGE(0xd800, 0xffff) AM_READWRITE(a800xl_high_r, a800xl_high_w)
568564ADDRESS_MAP_END
r32026r32027
574570   AM_RANGE(0xd100, 0xd1ff) AM_NOP
575571   AM_RANGE(0xd200, 0xd2ff) AM_DEVREADWRITE("pokey", pokey_device, read, write)
576572   AM_RANGE(0xd300, 0xd3ff) AM_DEVREADWRITE("pia", pia6821_device, read_alt, write_alt)
577   AM_RANGE(0xd400, 0xd4ff) AM_READWRITE(atari_antic_r, atari_antic_w)
573   AM_RANGE(0xd400, 0xd4ff) AM_DEVREADWRITE("antic", antic_device, read, write)
578574   AM_RANGE(0xd500, 0xd7ff) AM_NOP
579575   AM_RANGE(0xd800, 0xffff) AM_READWRITE(a800xl_high_r, a800xl_high_w)
580576ADDRESS_MAP_END
r32026r32027
586582   AM_RANGE(0xd100, 0xd1ff) AM_NOP
587583   AM_RANGE(0xd200, 0xd2ff) AM_DEVREADWRITE("pokey", pokey_device, read, write)
588584   AM_RANGE(0xd300, 0xd3ff) AM_DEVREADWRITE("pia", pia6821_device, read_alt, write_alt)
589   AM_RANGE(0xd400, 0xd4ff) AM_READWRITE(atari_antic_r, atari_antic_w)
585   AM_RANGE(0xd400, 0xd4ff) AM_DEVREADWRITE("antic", antic_device, read, write)
590586   AM_RANGE(0xd500, 0xd7ff) AM_NOP
591587   AM_RANGE(0xd800, 0xffff) AM_READWRITE(a800xl_high_r, a800xl_high_w)
592588ADDRESS_MAP_END
r32026r32027
598594   AM_RANGE(0xd100, 0xd1ff) AM_NOP
599595   AM_RANGE(0xd200, 0xd2ff) AM_DEVREADWRITE("pokey", pokey_device, read, write)
600596   AM_RANGE(0xd300, 0xd3ff) AM_DEVREADWRITE("pia", pia6821_device, read_alt, write_alt)
601   AM_RANGE(0xd400, 0xd4ff) AM_READWRITE(atari_antic_r, atari_antic_w)
597   AM_RANGE(0xd400, 0xd4ff) AM_DEVREADWRITE("antic", antic_device, read, write)
602598   AM_RANGE(0xd500, 0xd7ff) AM_NOP
603599   AM_RANGE(0xd800, 0xffff) AM_READWRITE(a800xl_high_r, a800xl_high_w)
604600ADDRESS_MAP_END
r32026r32027
608604   AM_RANGE(0x0000, 0x3fff) AM_RAM
609605   AM_RANGE(0x4000, 0xbfff) AM_NOP // ROM installed at machine start
610606   AM_RANGE(0xc000, 0xcfff) AM_DEVREADWRITE("gtia", gtia_device, read, write)
611   AM_RANGE(0xd400, 0xdfff) AM_READWRITE(atari_antic_r, atari_antic_w)
607   AM_RANGE(0xd400, 0xdfff) AM_DEVREADWRITE("antic", antic_device, read, write)
612608   // 0xe000-0xe7ff - Expansion?
613609   AM_RANGE(0xe800, 0xefff) AM_DEVREADWRITE("pokey", pokey_device, read, write)
614610   AM_RANGE(0xf000, 0xffff) AM_ROM
r32026r32027
19311927}
19321928
19331929
1934void a400_state::common_start()
1935{   
1936   /* ANTIC */
1937   antic_start(machine());
1938}
1939
1940void a400_state::a5200_start()
1941{
1942   /* ANTIC */
1943   antic_start(machine());
1944}
1945
19461930MACHINE_RESET_MEMBER( a400_state, a400 )
19471931{
19481932   pokey_device *pokey = machine().device<pokey_device>("pokey");
19491933   pokey->write(15,0);
1950   antic_reset();
19511934}
19521935
19531936
19541937MACHINE_START_MEMBER( a400_state, a400 )
19551938{
1956   common_start();
19571939   setup_ram(0, m_ram->size());
19581940   setup_ram(1, m_ram->size());
19591941   setup_ram(2, m_ram->size());
r32026r32027
19661948
19671949MACHINE_START_MEMBER( a400_state, a800 )
19681950{
1969   common_start();
19701951   setup_ram(0, m_ram->size());
19711952   setup_ram(1, m_ram->size());
19721953   setup_ram(2, m_ram->size());
r32026r32027
19811962{
19821963   m_mmu = 0xfd;
19831964   m_ext_bank = 0x03;   // only used by a130xe
1984   common_start();
19851965   setup_cart(m_cartslot);
19861966
19871967   save_item(NAME(m_cart_disabled));
r32026r32027
19931973
19941974MACHINE_START_MEMBER( a400_state, a5200 )
19951975{
1996   a5200_start();
19971976   setup_cart(m_cartslot);
19981977
19991978   save_item(NAME(m_cart_disabled));
r32026r32027
20071986 *
20081987 **************************************************************/
20091988
2010WRITE8_MEMBER(a400_state::gtia_write)
1989WRITE8_MEMBER(a400_state::gtia_cb)
20111990{
20121991   dac_device *dac = machine().device<dac_device>("dac");
20131992   if (data & 0x08)
r32026r32027
20622041   MCFG_SCREEN_ADD("screen", RASTER)
20632042   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1))
20642043   MCFG_SCREEN_VISIBLE_AREA(MIN_X, MAX_X, MIN_Y, MAX_Y)
2065   MCFG_SCREEN_UPDATE_DRIVER(atari_common_state, screen_update_atari)
2044   MCFG_SCREEN_UPDATE_DEVICE("antic", antic_device, screen_update)
20662045   MCFG_SCREEN_PALETTE("palette")
20672046
20682047   MCFG_PALETTE_ADD("palette", sizeof(atari_palette) / 3)
r32026r32027
21022081
21032082   MCFG_DEVICE_ADD("gtia", ATARI_GTIA, 0)
21042083   MCFG_GTIA_READ_CB(IOPORT("console"))
2105   MCFG_GTIA_WRITE_CB(WRITE8(a400_state, gtia_write))
2084   MCFG_GTIA_WRITE_CB(WRITE8(a400_state, gtia_cb))
21062085
2086   MCFG_DEVICE_ADD("antic", ATARI_ANTIC, 0)
2087   MCFG_ANTIC_GTIA("gtia")
2088
21072089   /* devices */
21082090   MCFG_DEVICE_ADD("fdc", ATARI_FDC, 0)
21092091
r32026r32027
22902272
22912273   MCFG_DEVICE_ADD("gtia", ATARI_GTIA, 0)
22922274
2275   MCFG_DEVICE_ADD("antic", ATARI_ANTIC, 0)
2276   MCFG_ANTIC_GTIA("gtia")
2277
22932278   MCFG_DEVICE_MODIFY("pia")
22942279   MCFG_PIA_READPA_HANDLER(NULL) // FIXME: is there anything connected here
22952280   MCFG_PIA_READPB_HANDLER(NULL) // FIXME: is there anything connected here

Previous 199869 Revisions Next


© 1997-2024 The MAME Team