1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
|
// license:BSD-3-Clause
// copyright-holders:Pierpaolo Prazzoli, Bryan McPhail
/*************************************************************************
SNK/Alpha 68000 based games
*************************************************************************/
#ifndef MAME_INCLUDES_ALPHA68K_H
#define MAME_INCLUDES_ALPHA68K_H
#pragma once
#include "cpu/m68000/m68000.h"
#include "cpu/mcs48/mcs48.h"
#include "cpu/z80/z80.h"
#include "sound/ay8910.h"
#include "sound/dac.h"
#include "sound/ymopn.h"
#include "sound/ymopl.h"
#include "machine/74259.h"
#include "machine/gen_latch.h"
#include "video/snk68_spr.h"
#include "video/alpha68k_palette.h"
#include "emupal.h"
#include "screen.h"
#include "tilemap.h"
#include "speaker.h"
class alpha68k_state : public driver_device
{
public:
alpha68k_state(const machine_config &mconfig, device_type type, const char *tag) :
driver_device(mconfig, type, tag),
m_maincpu(*this, "maincpu"),
m_audiocpu(*this, "audiocpu"),
m_gfxdecode(*this, "gfxdecode"),
m_screen(*this, "screen"),
m_outlatch(*this, "outlatch"),
m_soundlatch(*this, "soundlatch"),
m_shared_ram(*this, "shared_ram"),
m_spriteram(*this, "spriteram"),
m_videoram(*this, "videoram"),
m_in(*this, "IN%u", 0U),
m_audiobank(*this, "audiobank")
{ }
protected:
/* devices */
required_device<cpu_device> m_maincpu;
required_device<cpu_device> m_audiocpu;
required_device<gfxdecode_device> m_gfxdecode;
required_device<screen_device> m_screen;
optional_device<ls259_device> m_outlatch;
required_device<generic_latch_8_device> m_soundlatch;
/* memory pointers */
optional_shared_ptr<u16> m_shared_ram;
required_shared_ptr<u16> m_spriteram;
optional_shared_ptr<u16> m_videoram;
optional_ioport_array<7> m_in;
optional_memory_bank m_audiobank;
int m_flipscreen = 0;
// MCU sims
void alpha_microcontroller_w(offs_t offset, u16 data, u16 mem_mask);
int m_invert_controls = 0;
int m_microcontroller_id = 0;
unsigned m_game_id = 0U; // see below
unsigned m_deposits1 = 0U;
unsigned m_deposits2 = 0U;
unsigned m_credits = 0U;
unsigned m_coinvalue = 0U;
int m_coin_id = 0;
unsigned m_microcontroller_data = 0U;
unsigned m_trigstate = 0U;
int m_latch = 0;
void set_screen_raw_params(machine_config &config);
DECLARE_MACHINE_START(common);
DECLARE_MACHINE_RESET(common);
};
class alpha68k_II_state : public alpha68k_state
{
public:
alpha68k_II_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_state(mconfig, type, tag)
, m_sprites(*this, "sprites")
, m_palette(*this, "palette")
{}
void alpha68k_II(machine_config &config);
void btlfieldb(machine_config &config);
void init_skysoldr();
void init_timesold();
void init_timesold1();
void init_btlfield();
void init_btlfieldb();
protected:
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
required_device<snk68_spr_device> m_sprites;
required_device<alpha68k_palette_device> m_palette;
void base_config(machine_config &config);
DECLARE_VIDEO_START(alpha68k);
void video_config(machine_config &config, u16 num_pens);
void tile_callback(int &tile, int& fx, int& fy, int& region);
void tile_callback_noflipx(int &tile, int& fx, int& fy, int& region);
void tile_callback_noflipy(int &tile, int& fx, int& fy, int& region);
INTERRUPT_GEN_MEMBER(sound_nmi);
void sound_bank_w(u8 data);
void flipscreen_w(int flip);
void porta_w(u8 data);
u8 m_sound_nmi_mask = 0U;
u8 m_sound_pa_latch = 0U;
DECLARE_MACHINE_START(alpha68k_II);
DECLARE_MACHINE_RESET(alpha68k_II);
void video_bank_w(u8 data);
void alpha68k_II_map(address_map &map);
void sound_map(address_map &map);
void sound_portmap(address_map &map);
u16 alpha_II_trigger_r(offs_t offset);
/* video-related */
tilemap_t *m_fix_tilemap = nullptr;
int m_bank_base = 0;
void outlatch_w(offs_t offset, u8 data = 0);
u16 control_1_r();
u16 control_2_r();
u16 control_3_r();
u16 control_4_r();
void videoram_w(offs_t offset, u16 data);
DECLARE_WRITE_LINE_MEMBER(video_control2_w);
DECLARE_WRITE_LINE_MEMBER(video_control3_w);
private:
TILE_GET_INFO_MEMBER(get_tile_info);
};
class goldmedal_II_state : public alpha68k_II_state
{
public:
goldmedal_II_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_II_state(mconfig, type, tag)
{}
void init_goldmedl();
void goldmedal(machine_config &config);
};
class alpha68k_III_state : public alpha68k_II_state
{
public:
alpha68k_III_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_II_state(mconfig, type, tag)
{}
void alpha68k_III(machine_config &config);
protected:
DECLARE_MACHINE_START(alpha68k_V);
DECLARE_MACHINE_RESET(alpha68k_V);
void alpha68k_III_map(address_map &map);
void alpha68k_V_map(address_map &map);
u16 alpha_V_trigger_r(offs_t offset);
};
class goldmedal_III_state : public alpha68k_III_state
{
public:
goldmedal_III_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_III_state(mconfig, type, tag)
{}
void init_goldmedla();
void goldmedal(machine_config &config);
};
class alpha68k_V_state : public alpha68k_III_state
{
public:
alpha68k_V_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_III_state(mconfig, type, tag)
{}
void init_skyadvnt();
void init_skyadvntu();
void init_sbasebal();
void init_sbasebalj();
void init_gangwarsu();
void init_gangwars();
void alpha68k_V(machine_config &config);
};
class skyadventure_state : public alpha68k_V_state
{
public:
skyadventure_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_V_state(mconfig, type, tag)
{}
void skyadventure(machine_config &config);
};
class gangwars_state : public alpha68k_V_state
{
public:
gangwars_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_V_state(mconfig, type, tag)
{}
void gangwars(machine_config &config);
};
/*
* Base class for HWs with 4bpp PROMs for colors
*/
class alpha68k_prom_state : public alpha68k_state
{
public:
alpha68k_prom_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_state(mconfig, type, tag),
m_palette(*this, "palette"),
m_color_proms(*this, "color_proms")
{}
protected:
void palette_init(palette_device &palette) const;
required_device<palette_device> m_palette;
optional_region_ptr<u8> m_color_proms;
};
/*
*
* Alpha68k N games
*
*/
class alpha68k_N_state : public alpha68k_prom_state
{
public:
alpha68k_N_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_prom_state(mconfig, type, tag)
{}
protected:
void main_map(address_map &map);
void base_config(machine_config &config);
void video_config(machine_config &config, u8 tile_transchar, u8 tile_bankshift, bool is_super_stingray);
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d);
u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
u16 kyros_alpha_trigger_r(offs_t offset);
void sound_map(address_map &map);
void sound_iomap(address_map &map);
private:
u16 m_tile_transchar = 0U;
int m_tile_bankshift = 0;
bool m_is_super_stingray = false;
};
class sstingray_state : public alpha68k_N_state
{
public:
sstingray_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_N_state(mconfig, type, tag)
, m_alpha8511(*this, "alpha8511")
{}
void init_sstingry();
void sstingry(machine_config &config);
private:
u8 alpha8511_command_r(offs_t offset);
void alpha8511_command_w(offs_t offset, u8 data);
TIMER_CALLBACK_MEMBER(alpha8511_sync);
u8 alpha8511_bus_r();
void alpha8511_bus_w(u8 data);
u8 alpha8511_address_r();
u8 alpha8511_rw_r();
void alpha8511_control_w(u8 data);
void main_map(address_map &map);
void sound_map(address_map &map);
required_device<mcs48_cpu_device> m_alpha8511;
u8 m_alpha8511_address = 0U;
u8 m_alpha8511_control = 0U;
bool m_alpha8511_read_mode = 0;
emu_timer *m_alpha8511_sync_timer = 0;
};
class kyros_state : public alpha68k_N_state
{
public:
kyros_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_N_state(mconfig, type, tag)
{}
void kyros(machine_config &config);
void init_kyros();
};
class jongbou_state : public alpha68k_N_state
{
public:
jongbou_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_N_state(mconfig, type, tag)
{}
void jongbou(machine_config &config);
void init_jongbou();
void init_jongbou2();
private:
void main_map(address_map &map);
void sound_map(address_map &map);
void sound_iomap(address_map &map);
u16 dial_inputs_r();
};
/*
*
* Alpha68k I games
*
*/
class alpha68k_I_state : public alpha68k_prom_state
{
public:
alpha68k_I_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_prom_state(mconfig, type, tag)
{}
protected:
void base_config(machine_config &config);
void video_config(machine_config &config, int yshift);
void draw_sprites(bitmap_ind16 &bitmap, const rectangle &cliprect, int c, int d);
u32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
int m_yshift = 0;
};
class paddlemania_state : public alpha68k_I_state
{
public:
paddlemania_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_I_state(mconfig, type, tag)
{}
void paddlema(machine_config &config);
void init_paddlema();
private:
void main_map(address_map &map);
void sound_map(address_map &map);
};
class thenextspace_state : public alpha68k_I_state
{
public:
thenextspace_state(const machine_config &mconfig, device_type type, const char *tag)
: alpha68k_I_state(mconfig, type, tag)
{}
void tnextspc(machine_config &config);
void init_tnextspc();
private:
void main_map(address_map &map);
void sound_map(address_map &map);
void sound_iomap(address_map &map);
void tnextspc_coin_counters_w(offs_t offset, u16 data);
void tnextspc_unknown_w(offs_t offset, u16 data);
void tnextspc_soundlatch_w(u8 data);
u16 sound_cpu_r();
};
/* game_id - used to deal with a few game specific situations */
enum
{
ALPHA68K_BTLFIELDB = 1, // used in alpha_II_trigger_r
ALPHA68K_JONGBOU, // used in kyros_alpha_trigger_r & kyros_draw_sprites
ALPHA68K_KYROS // used in kyros_draw_sprites
};
#define ALPHA68K_PLAYER_INPUT_LSB( player, button3, start, active ) \
PORT_BIT( 0x0001, active, IPT_JOYSTICK_UP ) PORT_PLAYER(player) \
PORT_BIT( 0x0002, active, IPT_JOYSTICK_DOWN ) PORT_PLAYER(player) \
PORT_BIT( 0x0004, active, IPT_JOYSTICK_LEFT ) PORT_PLAYER(player) \
PORT_BIT( 0x0008, active, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(player) \
PORT_BIT( 0x0010, active, IPT_BUTTON1 ) PORT_PLAYER(player) \
PORT_BIT( 0x0020, active, IPT_BUTTON2 ) PORT_PLAYER(player) \
PORT_BIT( 0x0040, active, button3 ) PORT_PLAYER(player) \
PORT_BIT( 0x0080, active, start )
#define ALPHA68K_PLAYER_INPUT_MSB( player, button3, start, active ) \
PORT_BIT( 0x0100, active, IPT_JOYSTICK_UP ) PORT_PLAYER(player) \
PORT_BIT( 0x0200, active, IPT_JOYSTICK_DOWN ) PORT_PLAYER(player) \
PORT_BIT( 0x0400, active, IPT_JOYSTICK_LEFT ) PORT_PLAYER(player) \
PORT_BIT( 0x0800, active, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(player) \
PORT_BIT( 0x1000, active, IPT_BUTTON1 ) PORT_PLAYER(player) \
PORT_BIT( 0x2000, active, IPT_BUTTON2 ) PORT_PLAYER(player) \
PORT_BIT( 0x4000, active, button3 ) PORT_PLAYER(player) \
PORT_BIT( 0x8000, active, start )
#define ALPHA68K_MCU \
PORT_START("IN2") /* Coin input to microcontroller */\
PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )\
PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
#endif // MAME_INCLUDES_ALPHA68K_H
|