Previous 15994 Revisions Next

r9653 Wednesday 24th November, 2010 at 11:44:14 UTC by Curt Coder
[ADVISION] Refactored to define ADDRESS_MAP_MODERN.
[docs]messnew.txt
[src/mess/drivers]advision.c
[src/mess/includes]advision.h
[src/mess/machine]advision.c
[src/mess/video]advision.c

src/mess/machine/advision.c
r9652r9653
2525
2626/* Machine Initialization */
2727
28MACHINE_START( advision )
28void advision_state::machine_start()
2929{
30   advision_state *state = machine->driver_data<advision_state>();
3130   /* configure EA banking */
3231   memory_configure_bank(machine, "bank1", 0, 1, memory_region(machine, "bios"), 0);
3332   memory_configure_bank(machine, "bank1", 1, 1, memory_region(machine, I8048_TAG), 0);
34   memory_install_readwrite_bank(cputag_get_address_space(machine, I8048_TAG, ADDRESS_SPACE_PROGRAM), 0x0000, 0x03ff, 0, 0, "bank1");
33   memory_install_readwrite_bank(cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM), 0x0000, 0x03ff, 0, 0, "bank1");
3534   memory_set_bank(machine, "bank1", 0);
3635
3736   /* allocate external RAM */
38   state->extram = auto_alloc_array(machine, UINT8, 0x400);
37   m_ext_ram = auto_alloc_array(machine, UINT8, 0x400);
3938}
4039
41MACHINE_RESET( advision )
40void advision_state::machine_reset()
4241{
43   advision_state *state = machine->driver_data<advision_state>();
44
4542   /* enable internal ROM */
46   cputag_set_input_line(machine, I8048_TAG, MCS48_INPUT_EA, CLEAR_LINE);
43   cpu_set_input_line(m_maincpu, MCS48_INPUT_EA, CLEAR_LINE);
4744   memory_set_bank(machine, "bank1", 0);
4845
4946   /* reset sound CPU */
50   cputag_set_input_line(machine, COP411_TAG, INPUT_LINE_RESET, ASSERT_LINE);
47   cpu_set_input_line(m_soundcpu, INPUT_LINE_RESET, ASSERT_LINE);
5148
52   state->rambank = 0x300;
53   state->frame_start = 0;
54   state->video_enable = 0;
55   state->sound_cmd = 0;
49   m_rambank = 0x300;
50   m_frame_start = 0;
51   m_video_enable = 0;
52   m_sound_cmd = 0;
5653}
5754
5855/* Bank Switching */
5956
60WRITE8_HANDLER( advision_bankswitch_w )
57WRITE8_MEMBER( advision_state::bankswitch_w )
6158{
62   advision_state *state = space->machine->driver_data<advision_state>();
63
6459   int ea = BIT(data, 2);
6560
66   cputag_set_input_line(space->machine, I8048_TAG, MCS48_INPUT_EA, ea ? ASSERT_LINE : CLEAR_LINE);
61   cpu_set_input_line(m_maincpu, MCS48_INPUT_EA, ea ? ASSERT_LINE : CLEAR_LINE);
6762
68   memory_set_bank(space->machine, "bank1", ea);
63   memory_set_bank(machine, "bank1", ea);
6964
70   state->rambank = (data & 0x03) << 8;
65   m_rambank = (data & 0x03) << 8;
7166}
7267
7368/* External RAM */
7469
75READ8_HANDLER( advision_extram_r )
70READ8_MEMBER( advision_state::ext_ram_r )
7671{
77   advision_state *state = space->machine->driver_data<advision_state>();
72   UINT8 data = m_ext_ram[m_rambank + offset];
7873
79   UINT8 data = state->extram[state->rambank + offset];
80
81   if (!state->video_enable)
74   if (!m_video_enable)
8275   {
8376      /* the video hardware interprets reads as writes */
84      advision_vh_write(space->machine, data);
77      vh_write(data);
8578   }
8679
87   if (state->video_bank == 0x06)
80   if (m_video_bank == 0x06)
8881   {
89      cputag_set_input_line(space->machine, COP411_TAG, INPUT_LINE_RESET, (data & 0x01) ? CLEAR_LINE : ASSERT_LINE);
82      cpu_set_input_line(m_soundcpu, INPUT_LINE_RESET, (data & 0x01) ? CLEAR_LINE : ASSERT_LINE);
9083   }
9184
9285   return data;
9386}
9487
95WRITE8_HANDLER( advision_extram_w )
88WRITE8_MEMBER( advision_state::ext_ram_w )
9689{
97   advision_state *state = space->machine->driver_data<advision_state>();
98
99   state->extram[state->rambank + offset] = data;
90   m_ext_ram[m_rambank + offset] = data;
10091}
10192
10293/* Sound */
10394
104READ8_HANDLER( advision_sound_cmd_r )
95READ8_MEMBER( advision_state::sound_cmd_r )
10596{
106   advision_state *state = space->machine->driver_data<advision_state>();
107
108   return state->sound_cmd;
97   return m_sound_cmd;
10998}
11099
111static void update_dac(running_machine *machine)
100void advision_state::update_dac()
112101{
113   running_device *dac_device = machine->device("dac");
114   advision_state *state = machine->driver_data<advision_state>();
115
116   if (state->sound_g == 0 && state->sound_d == 0)
117      dac_data_w(dac_device, 0xff);
118   else if (state->sound_g == 1 && state->sound_d == 1)
119      dac_data_w(dac_device, 0x80);
102   if (m_sound_g == 0 && m_sound_d == 0)
103      dac_data_w(m_dac, 0xff);
104   else if (m_sound_g == 1 && m_sound_d == 1)
105      dac_data_w(m_dac, 0x80);
120106   else
121      dac_data_w(dac_device, 0x00);
107      dac_data_w(m_dac, 0x00);
122108}
123109
124WRITE8_HANDLER( advision_sound_g_w )
110WRITE8_MEMBER( advision_state::sound_g_w )
125111{
126   advision_state *state = space->machine->driver_data<advision_state>();
127   state->sound_g = data & 0x01;
128   update_dac(space->machine);
112   m_sound_g = data & 0x01;
113
114   update_dac();
129115}
130116
131
132WRITE8_HANDLER( advision_sound_d_w )
117WRITE8_MEMBER( advision_state::sound_d_w )
133118{
134   advision_state *state = space->machine->driver_data<advision_state>();
135   state->sound_d = data & 0x01;
136   update_dac(space->machine);
119   m_sound_d = data & 0x01;
120   
121   update_dac();
137122}
138123
139124/* Video */
140125
141WRITE8_HANDLER( advision_av_control_w )
126WRITE8_MEMBER( advision_state::av_control_w )
142127{
143   advision_state *state = space->machine->driver_data<advision_state>();
128   m_sound_cmd = data >> 4;
144129
145   state->sound_cmd = data >> 4;
146
147   if ((state->video_enable == 0x00) && (data & 0x10))
130   if ((m_video_enable == 0x00) && (data & 0x10))
148131   {
149      advision_vh_update(space->machine, state->video_hpos);
132      vh_update(m_video_hpos);
150133
151      state->video_hpos++;
134      m_video_hpos++;
152135
153      if (state->video_hpos > 255)
136      if (m_video_hpos > 255)
154137      {
155         state->video_hpos = 0;
138         m_video_hpos = 0;
156139         logerror("HPOS OVERFLOW\n");
157140      }
158141   }
159142
160   state->video_enable = data & 0x10;
161   state->video_bank = (data & 0xe0) >> 5;
143   m_video_enable = data & 0x10;
144   m_video_bank = (data & 0xe0) >> 5;
162145}
163146
164READ8_HANDLER( advision_vsync_r )
147READ8_MEMBER( advision_state::vsync_r )
165148{
166   advision_state *state = space->machine->driver_data<advision_state>();
167
168   if (state->frame_start)
149   if (m_frame_start)
169150   {
170      state->frame_start = 0;
151      m_frame_start = 0;
171152
172153      return 0;
173154   }
r9652r9653
179160
180161/* Input */
181162
182READ8_HANDLER( advision_controller_r )
163READ8_MEMBER( advision_state::controller_r )
183164{
184165   // Get joystick switches
185   UINT8 in = input_port_read(space->machine, "joystick");
166   UINT8 in = input_port_read(machine, "joystick");
186167   UINT8 data = in | 0x0f;
187168
188169   // Get buttons
src/mess/video/advision.c
r9652r9653
1717  Start the video hardware emulation.
1818
1919***************************************************************************/
20VIDEO_START( advision )
21{
22   advision_state *state = machine->driver_data<advision_state>();
2320
24   state->video_hpos = 0;
25   state->display = auto_alloc_array(machine, UINT8, 8 * 8 * 256);
26   memset(state->display, 0, 8 * 8 * 256);
21void advision_state::video_start()
22{
23   m_video_hpos = 0;
24   m_display = auto_alloc_array(machine, UINT8, 8 * 8 * 256);
25   memset(m_display, 0, 8 * 8 * 256);
2726}
2827
2928/***************************************************************************
r9652r9653
4948
5049***************************************************************************/
5150
52void advision_vh_write(running_machine *machine, int data)
51void advision_state::vh_write(int data)
5352{
54   advision_state *state = machine->driver_data<advision_state>();
55
56   if (state->video_bank >= 1 && state->video_bank <=5)
53   if (m_video_bank >= 1 && m_video_bank <=5)
5754   {
58      state->led_latch[state->video_bank] = data;
55      m_led_latch[m_video_bank] = data;
5956   }
6057}
6158
62void advision_vh_update(running_machine *machine, int x)
59void advision_state::vh_update(int x)
6360{
64   advision_state *state = machine->driver_data<advision_state>();
65
66   UINT8 *dst = &state->display[x];
61   UINT8 *dst = &m_display[x];
6762   int y;
6863
6964   for( y = 0; y < 8; y++ )
7065   {
71      UINT8 data = state->led_latch[7-y];
66      UINT8 data = m_led_latch[7-y];
7267
7368      if( (data & 0x80) == 0 ) dst[0 * 256] = 8;
7469      if( (data & 0x40) == 0 ) dst[1 * 256] = 8;
r9652r9653
7974      if( (data & 0x02) == 0 ) dst[6 * 256] = 8;
8075      if( (data & 0x01) == 0 ) dst[7 * 256] = 8;
8176
82      state->led_latch[7-y] = 0xff;
77      m_led_latch[7-y] = 0xff;
8378
8479      dst += 8 * 256;
8580   }
r9652r9653
9287
9388***************************************************************************/
9489
95VIDEO_UPDATE( advision )
90bool advision_state::video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
9691{
97   advision_state *state = screen->machine->driver_data<advision_state>();
98
9992   int x, y;
10093
101   static int framecount = 0;
102
103   if( (framecount++ % 4) == 0 )
94   if( (m_frame_count++ % 4) == 0 )
10495   {
105      state->frame_start = 1;
106      state->video_hpos = 0;
96      m_frame_start = 1;
97      m_video_hpos = 0;
10798   }
10899
109100   for (x = 0; x < 150; x++)
110101   {
111      UINT8 *led = &state->display[x];
102      UINT8 *led = &m_display[x];
112103
113104      for( y = 0; y < 128; y+=2 )
114105      {
115106         if( *led > 0 )
116            *BITMAP_ADDR16(bitmap, 30 + y, 85 + x) = --(*led);
107            *BITMAP_ADDR16(&bitmap, 30 + y, 85 + x) = --(*led);
117108         else
118            *BITMAP_ADDR16(bitmap, 30 + y, 85 + x) = 0;
109            *BITMAP_ADDR16(&bitmap, 30 + y, 85 + x) = 0;
119110
120111         led += 256;
121112      }
122113   }
123114   return 0;
124115}
125
126
src/mess/includes/advision.h
r9652r9653
1515{
1616public:
1717   advision_state(running_machine &machine, const driver_device_config_base &config)
18      : driver_device(machine, config) { }
18      : driver_device(machine, config),
19        m_maincpu(*this, I8048_TAG),
20        m_soundcpu(*this, COP411_TAG),
21        m_dac(*this, "dac")
22   { }
1923
20   /* external RAM state */
21   UINT8 *extram;
22   int rambank;
24   required_device<cpu_device> m_maincpu;
25   required_device<cpu_device> m_soundcpu;
26   required_device<running_device> m_dac;
2327
24   /* video state */
25   int frame_start;
26   int video_enable;
27   int video_bank;
28   int video_hpos;
29   UINT8 led_latch[8];
30   UINT8 *display;
28   virtual void machine_start();
29   virtual void machine_reset();
3130
32   /* sound state */
33   int sound_cmd;
34   int sound_d;
35   int sound_g;
36};
31   virtual void video_start();
32   virtual bool video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
3733
38/*----------- defined in machine/advision.c -----------*/
34   void update_dac();
35   void vh_write(int data);
36   void vh_update(int x);
3937
40MACHINE_START( advision );
41MACHINE_RESET( advision );
42READ8_HANDLER( advision_extram_r );
43WRITE8_HANDLER( advision_extram_w );
38   DECLARE_READ8_MEMBER( ext_ram_r );
39   DECLARE_WRITE8_MEMBER( ext_ram_w );
40   DECLARE_READ8_MEMBER( controller_r );
41   DECLARE_WRITE8_MEMBER( bankswitch_w );
42   DECLARE_WRITE8_MEMBER( av_control_w );
43   DECLARE_READ8_MEMBER( vsync_r );
44   DECLARE_READ8_MEMBER( sound_cmd_r );
45   DECLARE_WRITE8_MEMBER( sound_g_w );
46   DECLARE_WRITE8_MEMBER( sound_d_w );
4447
45/* Port P1 */
46READ8_HANDLER( advision_controller_r );
47WRITE8_HANDLER( advision_bankswitch_w );
48   /* external RAM state */
49   UINT8 *m_ext_ram;
50   int m_rambank;
4851
49/* Port P2 */
50WRITE8_HANDLER( advision_av_control_w );
52   /* video state */
53   int m_frame_count;
54   int m_frame_start;
55   int m_video_enable;
56   int m_video_bank;
57   int m_video_hpos;
58   UINT8 m_led_latch[8];
59   UINT8 *m_display;
5160
52READ8_HANDLER( advision_vsync_r );
53READ8_HANDLER( advision_sound_cmd_r );
54WRITE8_HANDLER( advision_sound_g_w );
55WRITE8_HANDLER( advision_sound_d_w );
61   /* sound state */
62   int m_sound_cmd;
63   int m_sound_d;
64   int m_sound_g;
65};
5666
5767/*----------- defined in video/advision.c -----------*/
5868
59VIDEO_START( advision );
60VIDEO_UPDATE( advision );
6169PALETTE_INIT( advision );
62void advision_vh_write(running_machine *machine, int data);
63void advision_vh_update(running_machine *machine, int data);
6470
6571#endif
src/mess/drivers/advision.c
r9652r9653
1616
1717*/
1818
19#define ADDRESS_MAP_MODERN
20
1921#include "emu.h"
2022#include "includes/advision.h"
2123#include "cpu/mcs48/mcs48.h"
r9652r9653
2527
2628/* Memory Maps */
2729
28static ADDRESS_MAP_START( program_map, ADDRESS_SPACE_PROGRAM, 8 )
30static ADDRESS_MAP_START( program_map, ADDRESS_SPACE_PROGRAM, 8, advision_state )
2931   AM_RANGE(0x0000, 0x03ff) AM_ROMBANK("bank1")
3032   AM_RANGE(0x0400, 0x0fff) AM_ROM
3133ADDRESS_MAP_END
3234
33static ADDRESS_MAP_START( io_map, ADDRESS_SPACE_IO, 8 )
34   AM_RANGE(0x00, 0xff) AM_READWRITE(advision_extram_r, advision_extram_w)
35   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READWRITE(advision_controller_r, advision_bankswitch_w)
36   AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(advision_av_control_w)
37   AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(advision_vsync_r)
35static ADDRESS_MAP_START( io_map, ADDRESS_SPACE_IO, 8, advision_state )
36   AM_RANGE(0x00, 0xff) AM_READWRITE(ext_ram_r, ext_ram_w)
37   AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_READWRITE(controller_r, bankswitch_w)
38   AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(av_control_w)
39   AM_RANGE(MCS48_PORT_T1, MCS48_PORT_T1) AM_READ(vsync_r)
3840ADDRESS_MAP_END
3941
40static ADDRESS_MAP_START( sound_io_map, ADDRESS_SPACE_IO, 8 )
41   AM_RANGE(COP400_PORT_L, COP400_PORT_L) AM_READ(advision_sound_cmd_r)
42   AM_RANGE(COP400_PORT_G, COP400_PORT_G) AM_WRITE(advision_sound_g_w)
43   AM_RANGE(COP400_PORT_D, COP400_PORT_D) AM_WRITE(advision_sound_d_w)
42static ADDRESS_MAP_START( sound_io_map, ADDRESS_SPACE_IO, 8, advision_state )
43   AM_RANGE(COP400_PORT_L, COP400_PORT_L) AM_READ(sound_cmd_r)
44   AM_RANGE(COP400_PORT_G, COP400_PORT_G) AM_WRITE(sound_g_w)
45   AM_RANGE(COP400_PORT_D, COP400_PORT_D) AM_WRITE(sound_d_w)
4446   AM_RANGE(COP400_PORT_SIO, COP400_PORT_SIO) AM_NOP
4547   AM_RANGE(COP400_PORT_SK, COP400_PORT_SK) AM_NOP
4648ADDRESS_MAP_END
r9652r9653
101103};
102104
103105static MACHINE_CONFIG_START( advision, advision_state )
104
105106   /* basic machine hardware */
106107   MDRV_CPU_ADD(I8048_TAG, I8048, XTAL_11MHz)
107108   MDRV_CPU_PROGRAM_MAP(program_map)
r9652r9653
111112   MDRV_CPU_CONFIG(advision_cop411_interface)
112113   MDRV_CPU_IO_MAP(sound_io_map)
113114
114   MDRV_MACHINE_START(advision)
115   MDRV_MACHINE_RESET(advision)
116
117115    /* video hardware */
118116   MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
119117   MDRV_SCREEN_REFRESH_RATE(4*15)
r9652r9653
124122   MDRV_PALETTE_LENGTH(8)
125123   MDRV_PALETTE_INIT(advision)
126124
127   MDRV_VIDEO_START(advision)
128   MDRV_VIDEO_UPDATE(advision)
129
130125   /* sound hardware */
131126   MDRV_SPEAKER_STANDARD_MONO("mono")
132127
docs/messnew.txt
r9652r9653
2525
2626System Driver Changes:
2727----------------------
28- [ABC80] Refactored driver to define ADDRESS_MAP_MODERN. [Curt Coder]
29
3028- [ABC80] Added graphics PROMs. [Ola Andersson]
3129
3230- [ABC80] Refactored video to work like real hardware. [Curt Coder]
3331
3432- [ABC800C] Added Color version ROMs. [Ola Andersson]
3533
36- [AMU880] Refactored driver to define ADDRESS_MAP_MODERN, and fixed
37  keyboard. [Curt Coder]
34- [AMU880] Fixed keyboard. [Curt Coder]
3835
3936- [C64] Added known good dumps softlist for cartridges. Not hooked up
4037  to driver code yet. [Curt Coder]
4138
4239- [CHANNELF/LYNX/SPECIAL/SVISION/WSWAN] Tokenized audio state.  [Atari Ace]
4340
44- [MM1M6] Refactored driver to define ADDRESS_MAP_MODERN. [Curt Coder]
45
46- [SG1000] Refactored driver to define ADDRESS_MAP_MODERN. [Curt Coder]
47
4841- [SMS] Improved Light Phaser emulation and converted it to use timers
4942  that control when the beam will reach the aim area, to run the function
5043  that checks if the pixel displayed is bright enough to activate the
r9652r9653
5851  selecting the Segascope views from the Video Options menu). The option
5952  is turned off by default, being inaccurate [Enik Land, Fabio Priuli]
6053
61- [TANDY2K] Refactored driver to define ADDRESS_MAP_MODERN. [Curt Coder]
6254
63- [V1050] Refactored driver to define ADDRESS_MAP_MODERN. [Curt Coder]
6455
65- [VICTOR9K] Refactored driver to define ADDRESS_MAP_MODERN. [Curt Coder]
66
67- [VIDBRAIN] Refactored driver to define ADDRESS_MAP_MODERN. [Curt Coder]
68
69- [XEROX820] Refactored driver to define ADDRESS_MAP_MODERN. [Curt Coder]
70
71- [XOR100] Refactored driver to define ADDRESS_MAP_MODERN. [Curt Coder]
72
73
74
7556Imgtool Changes:
7657----------------
7758(none)
r9652r9653
9879- Static/const changes, and added driver_device state to many drivers.
9980  [Atari Ace]
10081
82- Refactored the following drivers to define ADDRESS_MAP_MODERN:
83  abc80, advision, amu880, mm1m6, sg1000, tandy2k, v1050, victor9k,
84  vidbrain, xerox820, xor100. [Curt Coder]
10185
10286
87
103880.140
10489
10590New System Drivers Supported:

Previous 15994 Revisions Next


© 1998-2018 The MESS Team