42
42
#include "includes/aquarium.h"
45
static READ16_HANDLER( aquarium_coins_r )
45
READ16_MEMBER(aquarium_state::aquarium_coins_r)
47
aquarium_state *state = space->machine().driver_data<aquarium_state>();
50
data = (input_port_read(space->machine(), "SYSTEM") & 0x7fff);
51
data |= state->m_aquarium_snd_ack;
52
state->m_aquarium_snd_ack = 0;
49
data = (ioport("SYSTEM")->read() & 0x7fff);
50
data |= m_aquarium_snd_ack;
51
m_aquarium_snd_ack = 0;
57
static WRITE8_HANDLER( aquarium_snd_ack_w )
56
WRITE8_MEMBER(aquarium_state::aquarium_snd_ack_w)
59
aquarium_state *state = space->machine().driver_data<aquarium_state>();
60
state->m_aquarium_snd_ack = 0x8000;
58
m_aquarium_snd_ack = 0x8000;
63
static WRITE16_HANDLER( aquarium_sound_w )
61
WRITE16_MEMBER(aquarium_state::aquarium_sound_w)
65
63
// popmessage("sound write %04x",data);
66
aquarium_state *state = space->machine().driver_data<aquarium_state>();
68
soundlatch_w(space, 1, data & 0xff);
69
device_set_input_line(state->m_audiocpu, INPUT_LINE_NMI, PULSE_LINE );
65
soundlatch_byte_w(space, 1, data & 0xff);
66
device_set_input_line(m_audiocpu, INPUT_LINE_NMI, PULSE_LINE );
72
static WRITE8_HANDLER( aquarium_z80_bank_w )
69
WRITE8_MEMBER(aquarium_state::aquarium_z80_bank_w)
74
memory_set_bank(space->machine(), "bank1", data & 0x07);
71
membank("bank1")->set_entry(data & 0x07);
77
74
static UINT8 aquarium_snd_bitswap( UINT8 scrambled_data )
93
static READ8_HANDLER( aquarium_oki_r )
95
okim6295_device *oki = space->machine().device<okim6295_device>("oki");
96
return aquarium_snd_bitswap(oki->read(*space, offset));
99
static WRITE8_HANDLER( aquarium_oki_w )
101
logerror("%s:Writing %04x to the OKI M6295\n", space->machine().describe_context(), aquarium_snd_bitswap(data));
102
okim6295_device *oki = space->machine().device<okim6295_device>("oki");
103
oki->write(*space, offset, (aquarium_snd_bitswap(data)));
109
static ADDRESS_MAP_START( main_map, AS_PROGRAM, 16 )
90
READ8_MEMBER(aquarium_state::aquarium_oki_r)
92
okim6295_device *oki = machine().device<okim6295_device>("oki");
93
return aquarium_snd_bitswap(oki->read(space, offset));
96
WRITE8_MEMBER(aquarium_state::aquarium_oki_w)
98
logerror("%s:Writing %04x to the OKI M6295\n", machine().describe_context(), aquarium_snd_bitswap(data));
99
okim6295_device *oki = machine().device<okim6295_device>("oki");
100
oki->write(space, offset, (aquarium_snd_bitswap(data)));
106
static ADDRESS_MAP_START( main_map, AS_PROGRAM, 16, aquarium_state )
110
107
AM_RANGE(0x000000, 0x07ffff) AM_ROM
111
AM_RANGE(0xc00000, 0xc00fff) AM_RAM_WRITE(aquarium_mid_videoram_w) AM_BASE_MEMBER(aquarium_state, m_mid_videoram)
112
AM_RANGE(0xc01000, 0xc01fff) AM_RAM_WRITE(aquarium_bak_videoram_w) AM_BASE_MEMBER(aquarium_state, m_bak_videoram)
113
AM_RANGE(0xc02000, 0xc03fff) AM_RAM_WRITE(aquarium_txt_videoram_w) AM_BASE_MEMBER(aquarium_state, m_txt_videoram)
114
AM_RANGE(0xc80000, 0xc81fff) AM_RAM AM_BASE_SIZE_MEMBER(aquarium_state, m_spriteram, m_spriteram_size)
115
AM_RANGE(0xd00000, 0xd00fff) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBRGBx_word_w) AM_BASE_GENERIC(paletteram)
116
AM_RANGE(0xd80014, 0xd8001f) AM_WRITEONLY AM_BASE_MEMBER(aquarium_state, m_scroll)
108
AM_RANGE(0xc00000, 0xc00fff) AM_RAM_WRITE(aquarium_mid_videoram_w) AM_SHARE("mid_videoram")
109
AM_RANGE(0xc01000, 0xc01fff) AM_RAM_WRITE(aquarium_bak_videoram_w) AM_SHARE("bak_videoram")
110
AM_RANGE(0xc02000, 0xc03fff) AM_RAM_WRITE(aquarium_txt_videoram_w) AM_SHARE("txt_videoram")
111
AM_RANGE(0xc80000, 0xc81fff) AM_RAM AM_SHARE("spriteram")
112
AM_RANGE(0xd00000, 0xd00fff) AM_RAM_WRITE(paletteram_RRRRGGGGBBBBRGBx_word_w) AM_SHARE("paletteram")
113
AM_RANGE(0xd80014, 0xd8001f) AM_WRITEONLY AM_SHARE("scroll")
117
114
AM_RANGE(0xd80068, 0xd80069) AM_WRITENOP /* probably not used */
118
115
AM_RANGE(0xd80080, 0xd80081) AM_READ_PORT("DSW")
119
116
AM_RANGE(0xd80082, 0xd80083) AM_READNOP /* stored but not read back ? check code at 0x01f440 */
124
121
AM_RANGE(0xff0000, 0xffffff) AM_RAM
127
static ADDRESS_MAP_START( snd_map, AS_PROGRAM, 8 )
124
static ADDRESS_MAP_START( snd_map, AS_PROGRAM, 8, aquarium_state )
128
125
AM_RANGE(0x0000, 0x3fff) AM_ROM
129
126
AM_RANGE(0x7800, 0x7fff) AM_RAM
130
127
AM_RANGE(0x8000, 0xffff) AM_ROMBANK("bank1")
133
static ADDRESS_MAP_START( snd_portmap, AS_IO, 8 )
130
static ADDRESS_MAP_START( snd_portmap, AS_IO, 8, aquarium_state )
134
131
ADDRESS_MAP_GLOBAL_MASK(0xff)
135
AM_RANGE(0x00, 0x01) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
132
AM_RANGE(0x00, 0x01) AM_DEVREADWRITE_LEGACY("ymsnd", ym2151_r, ym2151_w)
136
133
AM_RANGE(0x02, 0x02) AM_READWRITE(aquarium_oki_r, aquarium_oki_w)
137
AM_RANGE(0x04, 0x04) AM_READ(soundlatch_r)
134
AM_RANGE(0x04, 0x04) AM_READ(soundlatch_byte_r)
138
135
AM_RANGE(0x06, 0x06) AM_WRITE(aquarium_snd_ack_w)
139
136
AM_RANGE(0x08, 0x08) AM_WRITE(aquarium_z80_bank_w)
243
240
static DRIVER_INIT( aquarium )
245
UINT8 *Z80 = machine.region("audiocpu")->base();
242
UINT8 *Z80 = machine.root_device().memregion("audiocpu")->base();
247
244
/* The BG tiles are 5bpp, this rearranges the data from
248
245
the roms containing the 1bpp data so we can decode it
250
UINT8 *DAT2 = machine.region("gfx1")->base() + 0x080000;
251
UINT8 *DAT = machine.region("user1")->base();
247
UINT8 *DAT2 = machine.root_device().memregion("gfx1")->base() + 0x080000;
248
UINT8 *DAT = machine.root_device().memregion("user1")->base();
252
249
int len = 0x0200000;
254
251
for (len = 0; len < 0x020000; len++)
281
278
/* configure and set up the sound bank */
282
memory_configure_bank(machine, "bank1", 0, 7, &Z80[0x18000], 0x8000);
283
memory_set_bank(machine, "bank1", 1);
279
machine.root_device().membank("bank1")->configure_entries(0, 7, &Z80[0x18000], 0x8000);
280
machine.root_device().membank("bank1")->set_entry(1);