44
43
VIDEO_START( hexion )
46
bg_tilemap[0] = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,8,8,64,32);
47
bg_tilemap[1] = tilemap_create(machine, get_tile_info1,tilemap_scan_rows, 8,8,64,32);
49
tilemap_set_transparent_pen(bg_tilemap[0],0);
50
tilemap_set_scrollx(bg_tilemap[1],0,-4);
51
tilemap_set_scrolly(bg_tilemap[1],0,4);
53
vram[0] = machine->region("maincpu")->base() + 0x30000;
54
vram[1] = vram[0] + 0x2000;
55
unkram = vram[1] + 0x2000;
45
hexion_state *state = machine.driver_data<hexion_state>();
46
state->m_bg_tilemap[0] = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,8,8,64,32);
47
state->m_bg_tilemap[1] = tilemap_create(machine, get_tile_info1,tilemap_scan_rows, 8,8,64,32);
49
tilemap_set_transparent_pen(state->m_bg_tilemap[0],0);
50
tilemap_set_scrollx(state->m_bg_tilemap[1],0,-4);
51
tilemap_set_scrolly(state->m_bg_tilemap[1],0,4);
53
state->m_vram[0] = machine.region("maincpu")->base() + 0x30000;
54
state->m_vram[1] = state->m_vram[0] + 0x2000;
55
state->m_unkram = state->m_vram[1] + 0x2000;
66
66
WRITE8_HANDLER( hexion_bankswitch_w )
68
UINT8 *rom = space->machine->region("maincpu")->base() + 0x10000;
68
hexion_state *state = space->machine().driver_data<hexion_state>();
69
UINT8 *rom = space->machine().region("maincpu")->base() + 0x10000;
70
71
/* bits 0-3 select ROM bank */
71
memory_set_bankptr(space->machine, "bank1",rom + 0x2000 * (data & 0x0f));
72
memory_set_bankptr(space->machine(), "bank1",rom + 0x2000 * (data & 0x0f));
73
74
/* does bit 6 trigger the 052591? */
76
int bank = unkram[0]&1;
77
memset(vram[bank],unkram[1],0x2000);
78
tilemap_mark_all_tiles_dirty(bg_tilemap[bank]);
77
int bank = state->m_unkram[0]&1;
78
memset(state->m_vram[bank],state->m_unkram[1],0x2000);
79
tilemap_mark_all_tiles_dirty(state->m_bg_tilemap[bank]);
80
81
/* bit 7 = PMC-BK */
81
pmcbank = (data & 0x80) >> 7;
82
state->m_pmcbank = (data & 0x80) >> 7;
83
84
/* other bits unknown */
85
86
popmessage("bankswitch %02x",data&0xf0);
87
//logerror("%04x: bankswitch_w %02x\n",cpu_get_pc(space->cpu),data);
88
//logerror("%04x: bankswitch_w %02x\n",cpu_get_pc(&space->device()),data);
90
91
READ8_HANDLER( hexion_bankedram_r )
92
if (gfxrom_select && offset < 0x1000)
94
return space->machine->region("gfx1")->base()[((gfxrom_select & 0x7f) << 12) + offset];
96
else if (bankctrl == 0)
98
return vram[rambank][offset];
100
else if (bankctrl == 2 && offset < 0x800)
102
return unkram[offset];
93
hexion_state *state = space->machine().driver_data<hexion_state>();
94
if (state->m_gfxrom_select && offset < 0x1000)
96
return space->machine().region("gfx1")->base()[((state->m_gfxrom_select & 0x7f) << 12) + offset];
98
else if (state->m_bankctrl == 0)
100
return state->m_vram[state->m_rambank][offset];
102
else if (state->m_bankctrl == 2 && offset < 0x800)
104
return state->m_unkram[offset];
106
//logerror("%04x: bankedram_r offset %04x, bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,bankctrl);
108
//logerror("%04x: bankedram_r offset %04x, bankctrl = %02x\n",cpu_get_pc(&space->device()),offset,state->m_bankctrl);
111
113
WRITE8_HANDLER( hexion_bankedram_w )
113
if (bankctrl == 3 && offset == 0 && (data & 0xfe) == 0)
115
//logerror("%04x: bankedram_w offset %04x, data %02x, bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,data,bankctrl);
118
else if (bankctrl == 0)
122
//logerror("%04x: bankedram_w offset %04x, data %02x, bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,data,bankctrl);
123
vram[rambank][offset] = data;
124
tilemap_mark_tile_dirty(bg_tilemap[rambank],offset/4);
127
logerror("%04x pmc internal ram %04x = %02x\n",cpu_get_pc(space->cpu),offset,data);
129
else if (bankctrl == 2 && offset < 0x800)
133
//logerror("%04x: unkram_w offset %04x, data %02x, bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,data,bankctrl);
134
unkram[offset] = data;
137
logerror("%04x pmc internal ram %04x = %02x\n",cpu_get_pc(space->cpu),offset,data);
115
hexion_state *state = space->machine().driver_data<hexion_state>();
116
if (state->m_bankctrl == 3 && offset == 0 && (data & 0xfe) == 0)
118
//logerror("%04x: bankedram_w offset %04x, data %02x, bankctrl = %02x\n",cpu_get_pc(&space->device()),offset,data,state->m_bankctrl);
119
state->m_rambank = data & 1;
121
else if (state->m_bankctrl == 0)
123
if (state->m_pmcbank)
125
//logerror("%04x: bankedram_w offset %04x, data %02x, bankctrl = %02x\n",cpu_get_pc(&space->device()),offset,data,state->m_bankctrl);
126
state->m_vram[state->m_rambank][offset] = data;
127
tilemap_mark_tile_dirty(state->m_bg_tilemap[state->m_rambank],offset/4);
130
logerror("%04x pmc internal ram %04x = %02x\n",cpu_get_pc(&space->device()),offset,data);
132
else if (state->m_bankctrl == 2 && offset < 0x800)
134
if (state->m_pmcbank)
136
//logerror("%04x: unkram_w offset %04x, data %02x, bankctrl = %02x\n",cpu_get_pc(&space->device()),offset,data,state->m_bankctrl);
137
state->m_unkram[offset] = data;
140
logerror("%04x pmc internal ram %04x = %02x\n",cpu_get_pc(&space->device()),offset,data);
140
logerror("%04x: bankedram_w offset %04x, data %02x, bankctrl = %02x\n",cpu_get_pc(space->cpu),offset,data,bankctrl);
143
logerror("%04x: bankedram_w offset %04x, data %02x, bankctrl = %02x\n",cpu_get_pc(&space->device()),offset,data,state->m_bankctrl);
143
146
WRITE8_HANDLER( hexion_bankctrl_w )
145
//logerror("%04x: bankctrl_w %02x\n",cpu_get_pc(space->cpu),data);
148
hexion_state *state = space->machine().driver_data<hexion_state>();
149
//logerror("%04x: bankctrl_w %02x\n",cpu_get_pc(&space->device()),data);
150
state->m_bankctrl = data;
149
153
WRITE8_HANDLER( hexion_gfxrom_select_w )
151
//logerror("%04x: gfxrom_select_w %02x\n",cpu_get_pc(space->cpu),data);
152
gfxrom_select = data;
155
hexion_state *state = space->machine().driver_data<hexion_state>();
156
//logerror("%04x: gfxrom_select_w %02x\n",cpu_get_pc(&space->device()),data);
157
state->m_gfxrom_select = data;