57
51
#include "sound/2203intf.h"
58
52
#include "sound/okim6295.h"
59
53
#include "includes/sshangha.h"
54
#include "video/decospr.h"
55
#include "video/deco16ic.h"
61
57
#define SSHANGHA_HACK 0
63
static UINT16 *sshangha_prot_data;
65
static UINT16 *sshangha_sound_shared_ram;
67
61
/******************************************************************************/
69
63
static WRITE16_HANDLER( sshangha_protection16_w )
71
COMBINE_DATA(&sshangha_prot_data[offset]);
65
sshangha_state *state = space->machine().driver_data<sshangha_state>();
66
COMBINE_DATA(&state->m_prot_data[offset]);
73
logerror("CPU #0 PC %06x: warning - write unmapped control address %06x %04x\n",cpu_get_pc(space->cpu),offset<<1,data);
68
logerror("CPU #0 PC %06x: warning - write unmapped control address %06x %04x\n",cpu_get_pc(&space->device()),offset<<1,data);
76
71
/* Protection/IO chip 146 */
77
72
static READ16_HANDLER( sshangha_protection16_r )
74
sshangha_state *state = space->machine().driver_data<sshangha_state>();
82
return input_port_read(space->machine, "INPUTS");
78
return input_port_read(space->machine(), "INPUTS");
84
return input_port_read(space->machine, "SYSTEM");
80
return input_port_read(space->machine(), "SYSTEM");
86
return input_port_read(space->machine, "DSW");
82
return input_port_read(space->machine(), "DSW");
91
logerror("CPU #0 PC %06x: warning - read unmapped control address %06x\n",cpu_get_pc(space->cpu),offset<<1);
92
return sshangha_prot_data[offset];
87
logerror("CPU #0 PC %06x: warning - read unmapped control address %06x\n",cpu_get_pc(&space->device()),offset<<1);
88
return state->m_prot_data[offset];
95
91
static READ16_HANDLER( sshanghb_protection16_r )
93
sshangha_state *state = space->machine().driver_data<sshangha_state>();
100
return input_port_read(space->machine, "INPUTS");
97
return input_port_read(space->machine(), "INPUTS");
102
return input_port_read(space->machine, "SYSTEM");
99
return input_port_read(space->machine(), "SYSTEM");
104
return input_port_read(space->machine, "DSW");
101
return input_port_read(space->machine(), "DSW");
107
return sshangha_prot_data[offset];
104
return state->m_prot_data[offset];
110
107
/* Probably returns 0xffff when sprite DMA is complete, the game waits on it */
118
115
static MACHINE_RESET( sshangha )
120
address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
121
/* Such thing is needed as there is no code to turn the screen
122
to normal orientation when the game is reset.
123
I'm using the value that forces the screen to be in normal
124
orientation when entering the "test mode"
125
(check the game code from 0x0006b8 to 0x0006f0).
126
I can't tell however if this is accurate or not. */
127
sshangha_control_0_w(space, 0, 0x10, 0x00ff);
130
119
/******************************************************************************/
132
static ADDRESS_MAP_START( sshangha_map, ADDRESS_SPACE_PROGRAM, 16 )
121
INLINE void set_color_888(running_machine &machine, pen_t color, int rshift, int gshift, int bshift, UINT32 data)
123
palette_set_color_rgb(machine, color, (data >> rshift) & 0xff, (data >> gshift) & 0xff, (data >> bshift) & 0xff);
127
WRITE16_HANDLER( paletteram16_xbgr_word_be_sprites2_w )
129
sshangha_state *state = space->machine().driver_data<sshangha_state>();
130
COMBINE_DATA(&state->m_sprite_paletteram2[offset]);
131
set_color_888(space->machine(), (offset/2)+0x100, 0, 8, 16, state->m_sprite_paletteram2[(offset) | 1] | (state->m_sprite_paletteram2[(offset) & ~1] << 16) );
134
WRITE16_HANDLER( paletteram16_xbgr_word_be_sprites_w )
136
// hack??? we have to call this otherwise the sprite colours for some selected tiles are wrong (most noticable on the 2nd level of quest mode)
137
// however if we simply mirror the memory both ways the how to play screen ends up with bad colours
138
// we use the 2nd copy of palette ram for low priority tiles only..
139
// is this related to the bootleg only, or does the original have this issue too?
140
// maybe related to sprite DMA on the original, or the apparent lack of a 2nd sprite controller on the bootleg.
141
paletteram16_xbgr_word_be_sprites2_w(space,offset,data,mem_mask);
143
sshangha_state *state = space->machine().driver_data<sshangha_state>();
144
COMBINE_DATA(&state->m_sprite_paletteram[offset]);
145
set_color_888(space->machine(), (offset/2)+0x000, 0, 8, 16, state->m_sprite_paletteram[(offset) | 1] | (state->m_sprite_paletteram[(offset) & ~1] << 16) );
148
WRITE16_HANDLER( paletteram16_xbgr_word_be_tilelow_w )
150
sshangha_state *state = space->machine().driver_data<sshangha_state>();
151
COMBINE_DATA(&state->m_tile_paletteram1[offset]);
152
set_color_888(space->machine(), (offset/2)+0x200, 0, 8, 16, state->m_tile_paletteram1[(offset) | 1] | (state->m_tile_paletteram1[(offset) & ~1] << 16) );
155
WRITE16_HANDLER( paletteram16_xbgr_word_be_tilehigh_w )
157
sshangha_state *state = space->machine().driver_data<sshangha_state>();
158
COMBINE_DATA(&state->m_tile_paletteram2[offset]);
159
set_color_888(space->machine(), (offset/2)+0x300, 0, 8, 16, state->m_tile_paletteram2[(offset) | 1] | (state->m_tile_paletteram2[(offset) & ~1] << 16) );
162
static ADDRESS_MAP_START( sshangha_map, AS_PROGRAM, 16 )
133
163
AM_RANGE(0x000000, 0x03ffff) AM_ROM
134
AM_RANGE(0x100000, 0x10000f) AM_RAM AM_BASE(&sshangha_sound_shared_ram)
164
AM_RANGE(0x100000, 0x10000f) AM_RAM AM_BASE_MEMBER(sshangha_state, m_sound_shared_ram)
136
AM_RANGE(0x200000, 0x201fff) AM_RAM_WRITE(sshangha_pf1_data_w) AM_BASE(&sshangha_pf1_data)
137
AM_RANGE(0x202000, 0x203fff) AM_RAM_WRITE(sshangha_pf2_data_w) AM_BASE(&sshangha_pf2_data)
138
AM_RANGE(0x204000, 0x2047ff) AM_RAM AM_BASE(&sshangha_pf1_rowscroll)
139
AM_RANGE(0x206000, 0x2067ff) AM_RAM AM_BASE(&sshangha_pf2_rowscroll)
166
AM_RANGE(0x200000, 0x201fff) AM_DEVREADWRITE("tilegen1", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
167
AM_RANGE(0x202000, 0x203fff) AM_DEVREADWRITE("tilegen1", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
168
AM_RANGE(0x204000, 0x2047ff) AM_RAM AM_BASE_MEMBER(sshangha_state, m_pf1_rowscroll)
169
AM_RANGE(0x206000, 0x2067ff) AM_RAM AM_BASE_MEMBER(sshangha_state, m_pf2_rowscroll)
140
170
AM_RANGE(0x206800, 0x207fff) AM_RAM
141
AM_RANGE(0x300000, 0x30000f) AM_WRITE(sshangha_control_0_w)
171
AM_RANGE(0x300000, 0x30000f) AM_DEVWRITE("tilegen1", deco16ic_pf_control_w)
142
172
AM_RANGE(0x320000, 0x320001) AM_WRITE(sshangha_video_w)
143
173
AM_RANGE(0x320002, 0x320005) AM_WRITENOP
144
174
AM_RANGE(0x320006, 0x320007) AM_READNOP //irq ack
149
179
AM_RANGE(0x360000, 0x360fff) AM_RAM AM_BASE_GENERIC(spriteram2)
150
180
AM_RANGE(0x370000, 0x370001) AM_READ(deco_71_r)
151
181
AM_RANGE(0x370000, 0x370007) AM_WRITENOP
152
AM_RANGE(0x380000, 0x383fff) AM_RAM_WRITE(paletteram16_xbgr_word_be_w) AM_BASE_GENERIC(paletteram)
153
AM_RANGE(0x3c0000, 0x3c0fff) AM_RAM /* Sprite ram buffer on bootleg only?? */
183
AM_RANGE(0x380000, 0x3803ff) AM_RAM_WRITE(paletteram16_xbgr_word_be_sprites_w) AM_BASE_MEMBER(sshangha_state, m_sprite_paletteram)
184
AM_RANGE(0x380400, 0x3807ff) AM_RAM_WRITE(paletteram16_xbgr_word_be_tilehigh_w) AM_BASE_MEMBER(sshangha_state, m_tile_paletteram2)
185
AM_RANGE(0x380800, 0x380bff) AM_RAM_WRITE(paletteram16_xbgr_word_be_sprites2_w) AM_BASE_MEMBER(sshangha_state, m_sprite_paletteram2)
186
AM_RANGE(0x380c00, 0x380fff) AM_RAM_WRITE(paletteram16_xbgr_word_be_tilelow_w) AM_BASE_MEMBER(sshangha_state, m_tile_paletteram1)
187
AM_RANGE(0x381000, 0x383fff) AM_RAM // unused palette area
154
189
AM_RANGE(0xfec000, 0xff3fff) AM_RAM
155
AM_RANGE(0xff4000, 0xff47ff) AM_READWRITE(sshangha_protection16_r,sshangha_protection16_w) AM_BASE(&sshangha_prot_data)
190
AM_RANGE(0xff4000, 0xff47ff) AM_READWRITE(sshangha_protection16_r,sshangha_protection16_w) AM_BASE_MEMBER(sshangha_state, m_prot_data)
158
static ADDRESS_MAP_START( sshanghb_map, ADDRESS_SPACE_PROGRAM, 16 )
193
static ADDRESS_MAP_START( sshanghb_map, AS_PROGRAM, 16 )
159
194
AM_RANGE(0x000000, 0x03ffff) AM_ROM
160
195
AM_RANGE(0x084000, 0x0847ff) AM_READ(sshanghb_protection16_r)
161
AM_RANGE(0x101000, 0x10100f) AM_RAM AM_BASE(&sshangha_sound_shared_ram) /* the bootleg writes here */
196
AM_RANGE(0x101000, 0x10100f) AM_RAM AM_BASE_MEMBER(sshangha_state, m_sound_shared_ram) /* the bootleg writes here */
163
AM_RANGE(0x200000, 0x201fff) AM_RAM_WRITE(sshangha_pf1_data_w) AM_BASE(&sshangha_pf1_data)
164
AM_RANGE(0x202000, 0x203fff) AM_RAM_WRITE(sshangha_pf2_data_w) AM_BASE(&sshangha_pf2_data)
165
AM_RANGE(0x204000, 0x2047ff) AM_RAM AM_BASE(&sshangha_pf1_rowscroll)
166
AM_RANGE(0x206000, 0x2067ff) AM_RAM AM_BASE(&sshangha_pf2_rowscroll)
198
AM_RANGE(0x200000, 0x201fff) AM_DEVREADWRITE("tilegen1", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
199
AM_RANGE(0x202000, 0x203fff) AM_DEVREADWRITE("tilegen1", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
200
AM_RANGE(0x204000, 0x2047ff) AM_RAM AM_BASE_MEMBER(sshangha_state, m_pf1_rowscroll)
201
AM_RANGE(0x206000, 0x2067ff) AM_RAM AM_BASE_MEMBER(sshangha_state, m_pf2_rowscroll)
167
202
AM_RANGE(0x206800, 0x207fff) AM_RAM
168
AM_RANGE(0x300000, 0x30000f) AM_WRITE(sshangha_control_0_w)
203
AM_RANGE(0x300000, 0x30000f) AM_DEVWRITE("tilegen1", deco16ic_pf_control_w)
169
204
AM_RANGE(0x320000, 0x320001) AM_WRITE(sshangha_video_w)
170
205
AM_RANGE(0x320002, 0x320005) AM_WRITENOP
171
206
AM_RANGE(0x320006, 0x320007) AM_READNOP //irq ack
173
AM_RANGE(0x340000, 0x340fff) AM_RAM AM_BASE_GENERIC(spriteram)
174
AM_RANGE(0x350000, 0x350001) AM_READ(deco_71_r)
175
AM_RANGE(0x350000, 0x350007) AM_WRITENOP
176
AM_RANGE(0x360000, 0x360fff) AM_RAM AM_BASE_GENERIC(spriteram2)
177
AM_RANGE(0x370000, 0x370001) AM_READ(deco_71_r)
178
AM_RANGE(0x370000, 0x370007) AM_WRITENOP
179
AM_RANGE(0x380000, 0x383fff) AM_RAM_WRITE(paletteram16_xbgr_word_be_w) AM_BASE_GENERIC(paletteram)
180
AM_RANGE(0x3c0000, 0x3c0fff) AM_RAM /* Sprite ram buffer on bootleg only?? */
208
AM_RANGE(0x340000, 0x340fff) AM_RAM // original spriteram
210
AM_RANGE(0x380000, 0x3803ff) AM_RAM_WRITE(paletteram16_xbgr_word_be_sprites_w) AM_BASE_MEMBER(sshangha_state, m_sprite_paletteram)
211
AM_RANGE(0x380400, 0x3807ff) AM_RAM_WRITE(paletteram16_xbgr_word_be_tilehigh_w) AM_BASE_MEMBER(sshangha_state, m_tile_paletteram2)
212
AM_RANGE(0x380800, 0x380bff) AM_RAM_WRITE(paletteram16_xbgr_word_be_sprites2_w) AM_BASE_MEMBER(sshangha_state, m_sprite_paletteram2)
213
AM_RANGE(0x380c00, 0x380fff) AM_RAM_WRITE(paletteram16_xbgr_word_be_tilelow_w) AM_BASE_MEMBER(sshangha_state, m_tile_paletteram1)
214
AM_RANGE(0x381000, 0x383fff) AM_RAM // unused palette area
216
AM_RANGE(0x3c0000, 0x3c0fff) AM_RAM AM_BASE_GENERIC(spriteram) // bootleg spriteram
181
217
AM_RANGE(0xfec000, 0xff3fff) AM_RAM
182
218
AM_RANGE(0xff4000, 0xff47ff) AM_RAM
189
225
static READ8_HANDLER(sshangha_sound_shared_r)
191
return sshangha_sound_shared_ram[offset] & 0xff;
227
sshangha_state *state = space->machine().driver_data<sshangha_state>();
228
return state->m_sound_shared_ram[offset] & 0xff;
194
231
static WRITE8_HANDLER(sshangha_sound_shared_w)
196
sshangha_sound_shared_ram[offset] = data & 0xff;
233
sshangha_state *state = space->machine().driver_data<sshangha_state>();
234
state->m_sound_shared_ram[offset] = data & 0xff;
199
237
/* Note: there's rom data after 0x8000 but the game never seem to call a rom bank, left-over? */
200
static ADDRESS_MAP_START( sshangha_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
238
static ADDRESS_MAP_START( sshangha_sound_map, AS_PROGRAM, 8 )
201
239
AM_RANGE(0x0000, 0x7fff) AM_ROM
202
240
AM_RANGE(0xc000, 0xc001) AM_DEVREADWRITE("ymsnd", ym2203_r,ym2203_w)
203
241
AM_RANGE(0xc200, 0xc201) AM_DEVREADWRITE_MODERN("oki", okim6295_device, read, write)
322
360
static GFXDECODE_START( sshangha )
323
GFXDECODE_ENTRY( "gfx1", 0, charlayout, 256, 64 ) /* Characters 8x8 */
324
GFXDECODE_ENTRY( "gfx1", 0, tilelayout, 256, 64 ) /* Tiles 16x16 */
325
GFXDECODE_ENTRY( "gfx2", 0, tilelayout, 0, 32 ) /* Sprites 16x16 */
361
GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0x200, 64 ) /* Characters 8x8 */
362
GFXDECODE_ENTRY( "gfx1", 0, tilelayout, 0x200, 64 ) /* Tiles 16x16 */
363
GFXDECODE_ENTRY( "gfx2", 0, tilelayout, 0, 64 ) /* Sprites 16x16 */
328
366
/******************************************************************************/
330
368
static void irqhandler(device_t *device, int state)
332
cputag_set_input_line(device->machine, "audiocpu", 0, state);
370
cputag_set_input_line(device->machine(), "audiocpu", 0, state);
335
373
static const ym2203_interface ym2203_config =
352
409
MCFG_CPU_ADD("audiocpu", Z80, 16000000/4)
353
410
MCFG_CPU_PROGRAM_MAP(sshangha_sound_map)
355
MCFG_QUANTUM_TIME(HZ(6000))
412
MCFG_QUANTUM_TIME(attotime::from_hz(6000))
357
414
MCFG_MACHINE_RESET(sshangha) /* init machine */
360
/*MCFG_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)*/
362
416
MCFG_SCREEN_ADD("screen", RASTER)
363
417
MCFG_SCREEN_REFRESH_RATE(60)
364
418
MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
365
MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
419
MCFG_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
366
420
MCFG_SCREEN_SIZE(40*8, 32*8)
367
421
MCFG_SCREEN_VISIBLE_AREA(0*8, 40*8-1, 1*8, 31*8-1)
422
MCFG_SCREEN_UPDATE(sshangha)
369
424
MCFG_GFXDECODE(sshangha)
370
MCFG_PALETTE_LENGTH(4096)
425
MCFG_PALETTE_LENGTH(0x4000)
427
MCFG_DECO16IC_ADD("tilegen1", sshangha_deco16ic_tilegen1_intf)
429
MCFG_DEVICE_ADD("spritegen1", decospr_, 0)
430
decospr_device_config::set_gfx_region(device, 2);
432
MCFG_DEVICE_ADD("spritegen2", decospr_, 0)
433
decospr_device_config::set_gfx_region(device, 2);
372
436
MCFG_VIDEO_START(sshangha)
373
MCFG_VIDEO_UPDATE(sshangha)
375
438
/* sound hardware */
376
439
MCFG_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker") /* sure it's stereo? */