misc drivers: Moved functions into driver class, cleanups (nw)

This commit is contained in:
Ivan Vangelista 2014-10-04 06:25:00 +00:00
parent 69dbd9e223
commit ac8a857d1c
16 changed files with 93 additions and 87 deletions

View File

@ -65,7 +65,7 @@ bool compare_mbus(UINT16* rom)
return true;
}
void find_mbus(sc4_state *state, UINT16* rom)
void sc4_state::find_mbus(UINT16* rom)
{
for (int i=0;i<(0x100000-0x40)/2;i++)
{
@ -74,7 +74,7 @@ void find_mbus(sc4_state *state, UINT16* rom)
if (found==true)
{
printf("x found at %08x\n", i*2);
state->m_chk41addr = i*2;
m_chk41addr = i*2;
}
}
}
@ -144,7 +144,7 @@ DRIVER_INIT_MEMBER(sc4_state,sc4mbus)
{
DRIVER_INIT_CALL(sc4);
UINT16 *rom = (UINT16 *)memregion("maincpu")->base();
find_mbus(this, rom);
find_mbus(rom);
}

View File

@ -141,6 +141,7 @@ public:
virtual void machine_reset();
virtual void video_start();
UINT32 screen_update_bmcbowl(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void init_stats(const UINT8 *table, int table_len, int address);
};
@ -285,11 +286,10 @@ static const UINT8 bmc_nv3[]=
};
static void init_stats(bmcbowl_state *state, const UINT8 *table, int table_len, int address)
void bmcbowl_state::init_stats(const UINT8 *table, int table_len, int address)
{
int i;
for (i=0; i<table_len; i++)
state->m_stats_ram[address+2*i]=table[i];
for (int i = 0; i < table_len; i++)
m_stats_ram[address+2*i]=table[i];
}
#endif
@ -299,9 +299,9 @@ void bmcbowl_state::machine_reset()
for (int i = 0; i < m_stats_ram.bytes(); i++)
m_stats_ram[i] = 0xff;
init_stats(this,bmc_nv1,ARRAY_LENGTH(bmc_nv1),0);
init_stats(this,bmc_nv2,ARRAY_LENGTH(bmc_nv2),0x3b0);
init_stats(this,bmc_nv3,ARRAY_LENGTH(bmc_nv3),0xfe2);
init_stats(bmc_nv1,ARRAY_LENGTH(bmc_nv1),0);
init_stats(bmc_nv2,ARRAY_LENGTH(bmc_nv2),0x3b0);
init_stats(bmc_nv3,ARRAY_LENGTH(bmc_nv3),0xfe2);
#endif
}

View File

@ -291,52 +291,50 @@ static int amerdart_trackball_dec(int data)
return data;
}
static int amerdart_trackball_direction(address_space &space, int num, int data)
int coolpool_state::amerdart_trackball_direction(int num, int data)
{
coolpool_state *state = space.machine().driver_data<coolpool_state>();
UINT16 result_x = (data & 0x0c) >> 2;
UINT16 result_y = (data & 0x03) >> 0;
if ((state->m_dx[num] == 0) && (state->m_dy[num] < 0)) { /* Up */
state->m_oldy[num]--;
if ((m_dx[num] == 0) && (m_dy[num] < 0)) { /* Up */
m_oldy[num]--;
result_x = amerdart_trackball_inc(result_x);
result_y = amerdart_trackball_inc(result_y);
}
if ((state->m_dx[num] == 0) && (state->m_dy[num] > 0)) { /* Down */
state->m_oldy[num]++;
if ((m_dx[num] == 0) && (m_dy[num] > 0)) { /* Down */
m_oldy[num]++;
result_x = amerdart_trackball_dec(result_x);
result_y = amerdart_trackball_dec(result_y);
}
if ((state->m_dx[num] < 0) && (state->m_dy[num] == 0)) { /* Left */
state->m_oldx[num]--;
if ((m_dx[num] < 0) && (m_dy[num] == 0)) { /* Left */
m_oldx[num]--;
result_x = amerdart_trackball_inc(result_x);
result_y = amerdart_trackball_dec(result_y);
}
if ((state->m_dx[num] > 0) && (state->m_dy[num] == 0)) { /* Right */
state->m_oldx[num]++;
if ((m_dx[num] > 0) && (m_dy[num] == 0)) { /* Right */
m_oldx[num]++;
result_x = amerdart_trackball_dec(result_x);
result_y = amerdart_trackball_inc(result_y);
}
if ((state->m_dx[num] < 0) && (state->m_dy[num] < 0)) { /* Left & Up */
state->m_oldx[num]--;
state->m_oldy[num]--;
if ((m_dx[num] < 0) && (m_dy[num] < 0)) { /* Left & Up */
m_oldx[num]--;
m_oldy[num]--;
result_x = amerdart_trackball_inc(result_x);
}
if ((state->m_dx[num] < 0) && (state->m_dy[num] > 0)) { /* Left & Down */
state->m_oldx[num]--;
state->m_oldy[num]++;
if ((m_dx[num] < 0) && (m_dy[num] > 0)) { /* Left & Down */
m_oldx[num]--;
m_oldy[num]++;
result_y = amerdart_trackball_dec(result_y);
}
if ((state->m_dx[num] > 0) && (state->m_dy[num] < 0)) { /* Right & Up */
state->m_oldx[num]++;
state->m_oldy[num]--;
if ((m_dx[num] > 0) && (m_dy[num] < 0)) { /* Right & Up */
m_oldx[num]++;
m_oldy[num]--;
result_y = amerdart_trackball_inc(result_y);
}
if ((state->m_dx[num] > 0) && (state->m_dy[num] > 0)) { /* Right & Down */
state->m_oldx[num]++;
state->m_oldy[num]++;
if ((m_dx[num] > 0) && (m_dy[num] > 0)) { /* Right & Down */
m_oldx[num]++;
m_oldy[num]++;
result_x = amerdart_trackball_dec(result_x);
}
@ -398,10 +396,10 @@ READ16_MEMBER(coolpool_state::amerdart_trackball_r)
m_dy[2] = (INT8)(m_newy[2] - m_oldy[2]);
/* Determine Trackball 1 direction state */
m_result = (m_result & 0xf0ff) | (amerdart_trackball_direction(space, 1, ((m_result >> 8) & 0xf)) << 8);
m_result = (m_result & 0xf0ff) | (amerdart_trackball_direction(1, ((m_result >> 8) & 0xf)) << 8);
/* Determine Trackball 2 direction state */
m_result = (m_result & 0x0fff) | (amerdart_trackball_direction(space, 2, ((m_result >> 12) & 0xf)) << 12);
m_result = (m_result & 0x0fff) | (amerdart_trackball_direction(2, ((m_result >> 12) & 0xf)) << 12);
// logerror("%08X:read port 6 (X=%02X Y=%02X oldX=%02X oldY=%02X oldRes=%04X Res=%04X)\n", space.device().safe_pc(), m_newx, m_newy, m_oldx, m_oldy, m_lastresult, m_result);

View File

@ -95,43 +95,42 @@ READ16_MEMBER(exterm_state::exterm_host_data_r)
*
*************************************/
static UINT16 exterm_trackball_port_r(address_space &space, int which, UINT16 mem_mask)
UINT16 exterm_state::exterm_trackball_port_r(int which, UINT16 mem_mask)
{
exterm_state *state = space.machine().driver_data<exterm_state>();
UINT16 port;
/* Read the fake input port */
UINT8 trackball_pos = state->ioport(which ? "DIAL1" : "DIAL0")->read();
UINT8 trackball_pos = ioport(which ? "DIAL1" : "DIAL0")->read();
/* Calculate the change from the last position. */
UINT8 trackball_diff = state->m_trackball_old[which] - trackball_pos;
UINT8 trackball_diff = m_trackball_old[which] - trackball_pos;
/* Store the new position for the next comparision. */
state->m_trackball_old[which] = trackball_pos;
m_trackball_old[which] = trackball_pos;
/* Move the sign bit to the high bit of the 6-bit trackball count. */
if (trackball_diff & 0x80)
trackball_diff |= 0x20;
/* Keep adding the changes. The counters will be reset later by a hardware write. */
state->m_aimpos[which] = (state->m_aimpos[which] + trackball_diff) & 0x3f;
m_aimpos[which] = (m_aimpos[which] + trackball_diff) & 0x3f;
/* Combine it with the standard input bits */
port = state->ioport(which ? "P2" : "P1")->read();
port = ioport(which ? "P2" : "P1")->read();
return (port & 0xc0ff) | (state->m_aimpos[which] << 8);
return (port & 0xc0ff) | (m_aimpos[which] << 8);
}
READ16_MEMBER(exterm_state::exterm_input_port_0_r)
{
return exterm_trackball_port_r(space, 0, mem_mask);
return exterm_trackball_port_r(0, mem_mask);
}
READ16_MEMBER(exterm_state::exterm_input_port_1_r)
{
return exterm_trackball_port_r(space, 1, mem_mask);
return exterm_trackball_port_r(1, mem_mask);
}

View File

@ -120,7 +120,7 @@ public:
UINT32 screen_update_famibox(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
TIMER_CALLBACK_MEMBER(famicombox_attract_timer_callback);
TIMER_CALLBACK_MEMBER(famicombox_gameplay_timer_callback);
void set_mirroring(famibox_state *state, int mirroring);
void set_mirroring(int mirroring);
void famicombox_bankswitch(UINT8 bank);
void famicombox_reset();
void ppu_irq(int *ppu_regs);
@ -133,7 +133,7 @@ public:
*******************************************************/
#if 0
void famibox_state::set_mirroring(famibox_state *state, int mirroring)
void famibox_state::set_mirroring(int mirroring)
{
switch(mirroring)
{

View File

@ -160,6 +160,7 @@ public:
virtual void machine_start();
virtual void machine_reset();
DECLARE_PALETTE_INIT(vega);
void draw_tilemap(screen_device& screen, bitmap_ind16& bitmap, const rectangle& cliprect);
UINT32 screen_update_vega(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
};
@ -489,13 +490,13 @@ PALETTE_INIT_MEMBER(vega_state, vega)
}
static void draw_tilemap(vega_state *state, screen_device& screen, bitmap_ind16& bitmap, const rectangle& cliprect)
void vega_state::draw_tilemap(screen_device& screen, bitmap_ind16& bitmap, const rectangle& cliprect)
{
{
UINT8 *map_lookup = state->memregion("tilemaps")->base();
UINT8 *map_lookup = memregion("tilemaps")->base();
int offset_y=state->m_tilemap_offset_y;
int offset_x=state->m_tilemap_offset_x;
int offset_y=m_tilemap_offset_y;
int offset_x=m_tilemap_offset_x;
//logerror("%d %d\n",offset_x, offset_y);
@ -507,7 +508,7 @@ static void draw_tilemap(vega_state *state, screen_device& screen, bitmap_ind16&
int y0=yy*32;
int id=map_lookup[((yy+xx*8)+ ((state->m_tilemap_flags&2)?0x400:0) + (state->m_tilemap_top<<6 ) ) &0x7ff];
int id=map_lookup[((yy+xx*8)+ ((m_tilemap_flags&2)?0x400:0) + (m_tilemap_top<<6 ) ) &0x7ff];
int flip=BIT(id,5);
@ -528,7 +529,7 @@ static void draw_tilemap(vega_state *state, screen_device& screen, bitmap_ind16&
{
//for(int x=0;x<4;++x)
{
state->m_gfxdecode->gfx(1)->transpen(bitmap,cliprect, num, 0, 1,flip?1:0, x*4+x0-offset_x, (flip?(3-y):y)*8+y0-offset_y, 0);
m_gfxdecode->gfx(1)->transpen(bitmap,cliprect, num, 0, 1,flip?1:0, x*4+x0-offset_x, (flip?(3-y):y)*8+y0-offset_y, 0);
++num;
}
}
@ -550,7 +551,7 @@ UINT32 vega_state::screen_update_vega(screen_device &screen, bitmap_ind16 &bitma
bitmap.fill(0, cliprect);
draw_tilemap(this, screen, bitmap, cliprect);
draw_tilemap(screen, bitmap, cliprect);
{

View File

@ -91,15 +91,19 @@ class warpspeed_state : public driver_device
public:
warpspeed_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_videoram(*this, "videoram"),
m_workram(*this, "workram"),
m_maincpu(*this, "maincpu"),
m_gfxdecode(*this, "gfxdecode") { }
m_gfxdecode(*this, "gfxdecode"),
m_videoram(*this, "videoram"),
m_workram(*this, "workram") { }
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
required_shared_ptr<UINT8> m_videoram;
required_shared_ptr<UINT8> m_workram;
tilemap_t *m_text_tilemap;
tilemap_t *m_starfield_tilemap;
required_shared_ptr<UINT8> m_workram;
UINT8 m_regs[0x28];
DECLARE_WRITE8_MEMBER(warpspeed_hardware_w);
DECLARE_WRITE8_MEMBER(warpspeed_vidram_w);
@ -109,8 +113,7 @@ public:
virtual void video_start();
DECLARE_PALETTE_INIT(warpspeed);
UINT32 screen_update_warpspeed(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
required_device<cpu_device> m_maincpu;
required_device<gfxdecode_device> m_gfxdecode;
void draw_circles(bitmap_ind16 &bitmap);
};
WRITE8_MEMBER(warpspeed_state::warpspeed_hardware_w)
@ -192,29 +195,29 @@ static void warpspeed_draw_circle(bitmap_ind16 &bitmap, INT16 cx, INT16 cy, UINT
}
}
static void warpspeed_draw_circles(bitmap_ind16 &bitmap, warpspeed_state *state)
void warpspeed_state::draw_circles(bitmap_ind16 &bitmap)
{
for (int i = 0; i < 4; i++)
{
UINT16 radius = state->m_regs[i*8] + state->m_regs[i*8 + 1]*256;
UINT16 radius = m_regs[i*8] + m_regs[i*8 + 1]*256;
radius = 0xffff - radius;
radius = sqrt((float)radius);
INT16 midx = state->m_regs[i*8 + 2] + state->m_regs[i*8 + 3]*256;
INT16 midx = m_regs[i*8 + 2] + m_regs[i*8 + 3]*256;
midx -= 0xe70;
INT16 midy = state->m_regs[i*8 + 4] + state->m_regs[i*8 + 5]*256;
INT16 midy = m_regs[i*8 + 4] + m_regs[i*8 + 5]*256;
midy -= 0xe70;
if ( radius == 0 || radius == 0xffff )
{
continue;
}
warpspeed_draw_circle(bitmap, midx + 128 + 16, midy + 128 + 16, radius, (state->m_regs[i*8 + 6] & 0x07) + 2);
warpspeed_draw_circle(bitmap, midx + 128 + 16, midy + 128 + 16, radius, (m_regs[i*8 + 6] & 0x07) + 2);
}
}
UINT32 warpspeed_state::screen_update_warpspeed(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
m_starfield_tilemap->draw(screen, bitmap, cliprect, 0, 0);
warpspeed_draw_circles(bitmap, this);
draw_circles(bitmap);
m_text_tilemap->draw(screen, bitmap, cliprect, 0, 0);
return 0;
}

View File

@ -585,6 +585,8 @@ public:
void bfm_sc4_68307_portb_w(address_space &space, bool dedicated, UINT16 data, UINT16 line_mask);
UINT8 bfm_sc4_68307_porta_r(address_space &space, bool dedicated, UINT8 line_mask);
UINT16 bfm_sc4_68307_portb_r(address_space &space, bool dedicated, UINT16 line_mask);
void find_mbus(UINT16* rom);
protected:

View File

@ -94,7 +94,7 @@ public:
TIMER_DEVICE_CALLBACK_MEMBER(bigrun_scanline);
TIMER_DEVICE_CALLBACK_MEMBER(scudhamm_scanline);
TIMER_DEVICE_CALLBACK_MEMBER(armchamp2_scanline);
void prepare_shadows(cischeat_state *state);
void prepare_shadows();
inline void scrollram_w(address_space &space, offs_t offset, UINT16 data, UINT16 mem_mask, int which);
void create_tilemaps();
void cischeat_draw_road(bitmap_ind16 &bitmap, const rectangle &cliprect, int road_num, int priority1, int priority2, int transparency);

View File

@ -76,4 +76,5 @@ public:
TIMER_DEVICE_CALLBACK_MEMBER(nvram_write_timeout);
TIMER_DEVICE_CALLBACK_MEMBER(amerdart_audio_int_gen);
void register_state_save();
int amerdart_trackball_direction(int num, int data);
};

View File

@ -11,14 +11,23 @@ class exterm_state : public driver_device
public:
exterm_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag),
m_master_videoram(*this, "master_videoram"),
m_slave_videoram(*this, "slave_videoram"),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_audioslave(*this, "audioslave"),
m_slave(*this, "slave"),
m_dac(*this, "dac") { }
m_dac(*this, "dac"),
m_master_videoram(*this, "master_videoram"),
m_slave_videoram(*this, "slave_videoram") { }
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<cpu_device> m_audioslave;
required_device<tms34010_device> m_slave;
required_device<dac_device> m_dac;
required_shared_ptr<UINT16> m_master_videoram;
required_shared_ptr<UINT16> m_slave_videoram;
UINT8 m_aimpos[2];
UINT8 m_trackball_old[2];
UINT8 m_master_sound_latch;
@ -26,8 +35,7 @@ public:
UINT8 m_sound_control;
UINT8 m_dac_value[2];
UINT16 m_last;
required_shared_ptr<UINT16> m_master_videoram;
required_shared_ptr<UINT16> m_slave_videoram;
DECLARE_WRITE16_MEMBER(exterm_host_data_w);
DECLARE_READ16_MEMBER(exterm_host_data_r);
DECLARE_READ16_MEMBER(exterm_input_port_0_r);
@ -49,9 +57,5 @@ public:
TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg_master);
TMS340X0_TO_SHIFTREG_CB_MEMBER(to_shiftreg_slave);
TMS340X0_FROM_SHIFTREG_CB_MEMBER(from_shiftreg_slave);
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<cpu_device> m_audioslave;
required_device<tms34010_device> m_slave;
required_device<dac_device> m_dac;
UINT16 exterm_trackball_port_r(int which, UINT16 mem_mask);
};

View File

@ -83,6 +83,9 @@ public:
INTERRUPT_GEN_MEMBER(grchamp_cpu1_interrupt);
TIMER_CALLBACK_MEMBER(main_to_sub_comm_sync_w);
void draw_objects(int y, UINT8 *objdata);
int collision_check(bitmap_ind16 &bitmap, int which );
void draw_fog(bitmap_ind16 &bitmap, const rectangle &cliprect, int fog);
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect);
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<cpu_device> m_subcpu;

View File

@ -32,7 +32,6 @@ public:
m_palette(*this, "palette") { }
/* memory pointers */
UINT8 * m_ram;
dynamic_array<UINT8> m_paletteram;
/* video-related */

View File

@ -209,10 +209,6 @@ void gaelco_serial_device::device_start()
/* validate arguments */
assert(strlen(tag()) < 20);
/* clear out CIA structure, and copy the interface */
//memset(state, 0, sizeof(*state));
//m_device = device;
m_irq_handler.resolve_safe();
m_sync_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(gaelco_serial_device::link_cb), this));

View File

@ -111,7 +111,7 @@ Note: if MAME_DEBUG is defined, pressing Z or X with:
***************************************************************************/
void cischeat_state::prepare_shadows(cischeat_state *state)
void cischeat_state::prepare_shadows()
{
int i;
for (i = 0;i < 16;i++)
@ -246,7 +246,7 @@ VIDEO_START_MEMBER(cischeat_state,cischeat)
m_bits_per_color_code = 5;
prepare_shadows(this);
prepare_shadows();
}
/**************************************************************************

View File

@ -107,7 +107,7 @@ void grchamp_state::video_start()
}
#if 0
int grchamp_state::collision_check(grchamp_state *state, bitmap_ind16 &bitmap, int which )
int grchamp_state::collision_check(bitmap_ind16 &bitmap, int which )
{
int bgcolor = m_palette->pen(0);
int sprite_transp = m_palette->pen(0x24);
@ -157,7 +157,7 @@ int grchamp_state::collision_check(grchamp_state *state, bitmap_ind16 &bitmap, i
return result?(1<<which):0;
}
void grchamp_state::draw_fog(grchamp_state *state, bitmap_ind16 &bitmap, const rectangle &cliprect, int fog)
void grchamp_state::draw_fog(bitmap_ind16 &bitmap, const rectangle &cliprect, int fog)
{
int x,y,offs;
@ -174,7 +174,7 @@ void grchamp_state::draw_fog(grchamp_state *state, bitmap_ind16 &bitmap, const r
}
}
void grchamp_state::draw_sprites(grchamp_state *state, bitmap_ind16 &bitmap, const rectangle &cliprect)
void grchamp_state::draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect)
{
gfx_element *gfx = m_gfxdecode->gfx(5);
int bank = (m_cpu0_out[0] & 0x20) ? 0x40 : 0x00;