1 // license:BSD-3-Clause
2 // copyright-holders:Phil Stroffolino, hap, R. Belmont
3 /***************************************************************************
4 
5     Namco System22 / System Super22 hardware
6 
7 ***************************************************************************/
8 
9 #ifndef MAME_INCLUDES_NAMCOS22_H
10 #define MAME_INCLUDES_NAMCOS22_H
11 
12 #pragma once
13 
14 #include "machine/eeprompar.h"
15 #include "machine/mb87078.h"
16 #include "machine/namcomcu.h"
17 #include "machine/timer.h"
18 #include "sound/c352.h"
19 #include "video/rgbutil.h"
20 #include "video/poly.h"
21 #include "emupal.h"
22 #include "screen.h"
23 #include "tilemap.h"
24 
25 enum
26 {
27 	NAMCOS22_AIR_COMBAT22,
28 	NAMCOS22_ALPINE_RACER,
29 	NAMCOS22_CYBER_COMMANDO,
30 	NAMCOS22_CYBER_CYCLES,
31 	NAMCOS22_PROP_CYCLE,
32 	NAMCOS22_RAVE_RACER,
33 	NAMCOS22_RIDGE_RACER,
34 	NAMCOS22_RIDGE_RACER2,
35 	NAMCOS22_TIME_CRISIS,
36 	NAMCOS22_VICTORY_LAP,
37 	NAMCOS22_ACE_DRIVER,
38 	NAMCOS22_ALPINE_RACER_2,
39 	NAMCOS22_ALPINE_SURFER,
40 	NAMCOS22_TOKYO_WARS,
41 	NAMCOS22_AQUA_JET,
42 	NAMCOS22_DIRT_DASH,
43 	NAMCOS22_ARMADILLO_RACING
44 };
45 
46 
47 struct namcos22_polyvertex
48 {
49 	float x, y, z;
50 	int u, v; /* 0..0xfff */
51 	int bri;  /* 0..0xff */
52 };
53 
54 enum namcos22_scenenode_type
55 {
56 	NAMCOS22_SCENENODE_NONLEAF,
57 	NAMCOS22_SCENENODE_QUAD,
58 	NAMCOS22_SCENENODE_SPRITE
59 };
60 
61 #define NAMCOS22_RADIX_BITS 4
62 #define NAMCOS22_RADIX_BUCKETS (1 << NAMCOS22_RADIX_BITS)
63 #define NAMCOS22_RADIX_MASK (NAMCOS22_RADIX_BUCKETS - 1)
64 
65 struct namcos22_scenenode
66 {
67 	namcos22_scenenode_type type;
68 	struct namcos22_scenenode *next;
69 	union
70 	{
71 		struct
72 		{
73 			struct namcos22_scenenode *next[NAMCOS22_RADIX_BUCKETS];
74 		} nonleaf;
75 
76 		struct
77 		{
78 			float vx, vy;
79 			float vu, vd, vl, vr;
80 			int texturebank;
81 			int color;
82 			int cmode;
83 			int flags;
84 			int cz_adjust;
85 			int direct;
86 			namcos22_polyvertex v[4];
87 		} quad;
88 
89 		struct
90 		{
91 			int tile, color;
92 			int prioverchar;
93 			int fade_enabled;
94 			int flipx, flipy;
95 			int linktype;
96 			int cols, rows;
97 			int xpos, ypos;
98 			int cx_min, cx_max;
99 			int cy_min, cy_max;
100 			int sizex, sizey;
101 			int translucency;
102 			int cz;
103 		} sprite;
104 	} data;
105 };
106 
107 
108 struct namcos22_object_data
109 {
110 	/* poly / sprites */
111 	rgbaint_t fogcolor;
112 	rgbaint_t fadecolor;
113 	rgbaint_t polycolor;
114 	const pen_t *pens;
115 	bitmap_rgb32 *destbase;
116 	bitmap_ind8 *primap;
117 	int bn;
118 	int flags;
119 	int prioverchar;
120 	int cmode;
121 	int fadefactor;
122 	int pfade_enabled;
123 	int fogfactor;
124 	int zfog_enabled;
125 	int cz_adjust;
126 	int cz_sdelta;
127 	const u8 *czram;
128 
129 	/* sprites */
130 	const u8 *source;
131 	int alpha;
132 	int line_modulo;
133 	int flipx;
134 	int flipy;
135 };
136 
137 
138 class namcos22_state;
139 
140 class namcos22_renderer : public poly_manager<float, namcos22_object_data, 4, 8000>
141 {
142 public:
143 	namcos22_renderer(namcos22_state &state);
144 
145 	void render_scene(screen_device &screen, bitmap_rgb32 &bitmap);
146 	struct namcos22_scenenode *new_scenenode(running_machine &machine, u32 zsort, namcos22_scenenode_type type);
147 
148 	void init();
149 
150 private:
151 	namcos22_state &m_state;
152 
153 	struct namcos22_scenenode m_scenenode_root;
154 	struct namcos22_scenenode *m_scenenode_cur;
155 
156 	float m_clipx;
157 	float m_clipy;
158 	rectangle m_cliprect;
159 
nthbyte(const u32 * src,int n)160 	inline u8 nthbyte(const u32 *src, int n) { return (src[n / 4] << ((n & 3) * 8)) >> 24; }
nthword(const u32 * src,int n)161 	inline u16 nthword(const u32 *src, int n) { return (src[n / 2] << ((n & 1) * 16)) >> 16; }
162 
163 	void render_scene_nodes(screen_device &screen, bitmap_rgb32 &bitmap, struct namcos22_scenenode *node);
164 	void render_sprite(screen_device &screen, bitmap_rgb32 &bitmap, struct namcos22_scenenode *node);
165 	void poly3d_drawquad(screen_device &screen, bitmap_rgb32 &bitmap, struct namcos22_scenenode *node);
166 	void poly3d_drawsprite(screen_device &screen, bitmap_rgb32 &dest_bmp, u32 code, u32 color, int flipx, int flipy, int sx, int sy, int scalex, int scaley, int cz_factor, int prioverchar, int fade_enabled, int alpha);
167 
168 	void free_scenenode(struct namcos22_scenenode *node);
169 	struct namcos22_scenenode *alloc_scenenode(running_machine &machine, struct namcos22_scenenode *node);
170 
171 	void renderscanline_uvi_full(int32_t scanline, const extent_t &extent, const namcos22_object_data &extra, int threadid);
172 	void renderscanline_sprite(int32_t scanline, const extent_t &extent, const namcos22_object_data &extra, int threadid);
173 };
174 
175 
176 enum namcos22_dsp_upload_state
177 {
178 	NAMCOS22_DSP_UPLOAD_READY,
179 	NAMCOS22_DSP_UPLOAD_DEST,
180 	NAMCOS22_DSP_UPLOAD_DATA
181 };
182 
183 #define NAMCOS22_MAX_LIT_SURFACES 0x80
184 #define NAMCOS22_MAX_RENDER_CMD_SEQ 0x1c
185 
186 class namcos22_state : public driver_device
187 {
188 public:
namcos22_state(const machine_config & mconfig,device_type type,const char * tag)189 	namcos22_state(const machine_config &mconfig, device_type type, const char *tag) :
190 		driver_device(mconfig, type, tag),
191 		m_palette(*this, "palette"),
192 		m_czram(*this, "czram"),
193 		m_spriteram(*this, "spriteram"),
194 		m_gfxdecode(*this, "gfxdecode"),
195 		m_maincpu(*this, "maincpu"),
196 		m_master(*this, "master"),
197 		m_slave(*this, "slave"),
198 		m_mcu(*this, "mcu"),
199 		m_iomcu(*this, "iomcu"),
200 		m_eeprom(*this, "eeprom"),
201 		m_mb87078(*this, "mb87078"),
202 		m_c352(*this, "c352"),
203 		m_shareram(*this, "shareram"),
204 		m_slave_extram(*this, "slaveextram"),
205 		m_master_extram(*this, "masterextram"),
206 		m_paletteram(*this, "paletteram"),
207 		m_cgram(*this, "cgram"),
208 		m_textram(*this, "textram"),
209 		m_polygonram(*this, "polygonram"),
210 		m_mixer(*this, "video_mixer"),
211 		m_gamma_proms(*this, "gamma_proms"),
212 		m_vics_data(*this, "vics_data"),
213 		m_vics_control(*this, "vics_control"),
214 		m_screen(*this, "screen"),
215 		m_adc_ports(*this, "ADC.%u", 0),
216 		m_inputs(*this, "INPUTS"),
217 		m_custom(*this, "CUSTOM.%u", 0),
218 		m_opt(*this, "OPT.%u", 0),
219 		m_mcu_out(*this, "mcuout%u", 0U),
220 		m_cpuled_out(*this, "cpuled%u", 0U)
221 	{ }
222 
223 	void cybrcomm(machine_config &config);
224 	void namcos22(machine_config &config);
225 
226 	void init_acedrvr();
227 	void init_raveracw();
228 	void init_ridger2j();
229 	void init_victlap();
230 	void init_cybrcomm();
231 	void init_ridgeraj();
232 
233 	// renderer
234 	int m_poly_translucency;
235 	u16 *m_texture_tilemap;
236 	std::unique_ptr<u8[]> m_texture_tileattr;
237 	u8 *m_texture_tiledata;
238 	std::unique_ptr<u8[]> m_texture_ayx_to_pixel;
239 	int m_is_ss22;
240 	int m_mixer_flags;
241 	int m_screen_fade_factor;
242 	int m_screen_fade_r;
243 	int m_screen_fade_g;
244 	int m_screen_fade_b;
245 	int m_poly_fade_enabled;
246 	int m_poly_fade_r;
247 	int m_poly_fade_g;
248 	int m_poly_fade_b;
249 	u32 m_fog_colormask;
250 	int m_fog_r;
251 	int m_fog_g;
252 	int m_fog_b;
253 	std::unique_ptr<u8[]> m_recalc_czram[4];
254 	int m_fog_r_per_cztype[4];
255 	int m_fog_g_per_cztype[4];
256 	int m_fog_b_per_cztype[4];
257 	u16 m_czattr[8];
258 
259 	required_device<palette_device> m_palette;
260 	optional_shared_ptr<u32> m_czram;
261 	optional_shared_ptr<u32> m_spriteram;
262 	required_device<gfxdecode_device> m_gfxdecode;
263 
264 protected:
265 	virtual void machine_reset() override;
266 	virtual void machine_start() override;
267 	virtual void video_start() override;
268 	virtual void device_post_load() override;
269 
270 	void namcos22_textram_w(offs_t offset, u32 data, u32 mem_mask = ~0);
271 	u16 namcos22_tilemapattr_r(offs_t offset);
272 	void namcos22_tilemapattr_w(offs_t offset, u16 data, u16 mem_mask = ~0);
273 	u32 namcos22_dspram_r(offs_t offset);
274 	void namcos22_dspram_w(offs_t offset, u32 data, u32 mem_mask = ~0);
275 	void namcos22_cgram_w(offs_t offset, u32 data, u32 mem_mask = ~0);
276 	void namcos22_paletteram_w(offs_t offset, u32 data, u32 mem_mask = ~0);
277 	void namcos22_dspram16_bank_w(offs_t offset, u16 data, u16 mem_mask = ~0);
278 	u16 namcos22_dspram16_r(offs_t offset);
279 	void namcos22_dspram16_w(offs_t offset, u16 data, u16 mem_mask = ~0);
280 	u16 pdp_status_r();
281 	u16 pdp_begin_r();
282 	u16 dsp_hold_signal_r();
283 	void dsp_hold_ack_w(u16 data);
284 	void dsp_xf_output_w(u16 data);
285 	void point_address_w(u16 data);
286 	void point_loword_iw(u16 data);
287 	void point_hiword_w(u16 data);
288 	u16 point_loword_r();
289 	u16 point_hiword_ir();
290 	void dsp_unk2_w(u16 data);
291 	u16 dsp_unk_port3_r();
292 	void upload_code_to_slave_dsp_w(u16 data);
293 	u16 dsp_unk8_r();
294 	u16 custom_ic_status_r();
295 	u16 dsp_upload_status_r();
296 	void slave_serial_io_w(u16 data);
297 	u16 master_serial_io_r();
298 	void dsp_unk_porta_w(u16 data);
299 	void dsp_led_w(u16 data);
300 	void dsp_unk8_w(u16 data);
301 	void master_render_device_w(u16 data);
302 	u16 dsp_slave_bioz_r();
303 	u16 dsp_slave_port3_r();
304 	u16 dsp_slave_port4_r();
305 	u16 dsp_slave_port5_r();
306 	u16 dsp_slave_port6_r();
307 	void dsp_slave_portc_w(u16 data);
308 	u16 dsp_slave_port8_r();
309 	u16 dsp_slave_portb_r();
310 	void dsp_slave_portb_w(u16 data);
311 	u16 namcos22_sci_r(offs_t offset);
312 	void namcos22_sci_w(offs_t offset, u16 data);
313 	u16 namcos22_shared_r(offs_t offset);
314 	void namcos22_shared_w(offs_t offset, u16 data, u16 mem_mask = ~0);
315 	u16 namcos22_keycus_r(offs_t offset);
316 	void namcos22_keycus_w(offs_t offset, u16 data, u16 mem_mask = ~0);
317 	u16 namcos22_portbit_r(offs_t offset);
318 	void namcos22_portbit_w(offs_t offset, u16 data);
319 	void namcos22_cpuleds_w(offs_t offset, u32 data, u32 mem_mask = ~0);
320 	u8 mcu_port4_s22_r();
321 	u8 iomcu_port4_s22_r();
322 	u16 mcuc74_speedup_r();
323 	void mcu_speedup_w(offs_t offset, u16 data, u16 mem_mask = ~0);
324 
nthbyte(const u32 * src,int n)325 	inline u8 nthbyte(const u32 *src, int n) { return (src[n / 4] << ((n & 3) * 8)) >> 24; }
nthword(const u32 * src,int n)326 	inline u16 nthword(const u32 *src, int n) { return (src[n / 2] << ((n & 1) * 16)) >> 16; }
327 
signed18(s32 val)328 	inline s32 signed18(s32 val) { return (val & 0x00020000) ? (s32)(val | 0xfffc0000) : val & 0x0001ffff; }
signed24(s32 val)329 	inline s32 signed24(s32 val) { return (val & 0x00800000) ? (s32)(val | 0xff000000) : val & 0x007fffff; }
330 
dspfixed_to_nativefloat(s16 val)331 	inline float dspfixed_to_nativefloat(s16 val) { return val / (float)0x7fff; }
332 	float dspfloat_to_nativefloat(u32 val);
333 
334 	void handle_driving_io();
335 	void handle_coinage(u16 flags);
336 	void handle_cybrcomm_io();
337 	void pdp_handle_commands(u16 offs);
pdp_polygonram_read(offs_t offs)338 	inline u32 pdp_polygonram_read(offs_t offs) { return m_polygonram[offs & 0x7fff]; }
pdp_polygonram_write(offs_t offs,u32 data)339 	inline void pdp_polygonram_write(offs_t offs, u32 data) { m_polygonram[offs & 0x7fff] = data; }
340 	void point_write(offs_t offs, u32 data);
341 	s32 pointram_read(offs_t offs);
point_read(offs_t offs)342 	inline s32 point_read(offs_t offs) { offs &= 0x00ffffff; return (offs < m_pointrom_size) ? m_pointrom[offs] : pointram_read(offs); }
343 	void master_enable(bool enable);
344 	void slave_enable(bool enable);
345 
346 	void syscon_irqlevel(offs_t offset, u8 data);
347 	void syscon_irqack(offs_t offset, u8 data);
348 	void syscon_dspcontrol(offs_t offset, u8 data);
349 	void syscon_mcucontrol(offs_t offset, u8 data);
350 	u8 syscon_r(offs_t offset);
351 	void ss22_syscon_w(offs_t offset, u8 data);
352 	void s22_syscon_w(offs_t offset, u8 data);
353 
354 	void posirq_update();
355 	emu_timer *m_posirq_timer;
356 	TIMER_CALLBACK_MEMBER(posirq_callback);
357 
358 	void matrix3d_multiply(float a[4][4], float b[4][4]);
359 	void matrix3d_identity(float m[4][4]);
360 	void matrix3d_apply_reflection(float m[4][4]);
361 	void transform_point(float *vx, float *vy, float *vz, float m[4][4]);
362 	void transform_normal(float *nx, float *ny, float *nz, float m[4][4]);
363 	void register_normals(int addr, float m[4][4]);
364 
365 	void blit_single_quad(u32 color, u32 addr, float m[4][4], int polyshift, int flags, int packetformat);
366 	void blit_quads(int addr, int len, float m[4][4]);
367 	void blit_polyobject(int code, float m[4][4]);
368 
369 	void slavesim_handle_bb0003(const s32 *src);
370 	void slavesim_handle_200002(const s32 *src, int code);
371 	void slavesim_handle_300000(const s32 *src);
372 	void slavesim_handle_233002(const s32 *src);
373 	void simulate_slavedsp();
374 
375 	virtual void init_tables();
376 	void update_mixer();
377 	void update_palette();
378 	void draw_direct_poly(const u16 *src);
379 	void draw_polygons();
380 	void draw_sprites();
381 	void draw_sprite_group(const u32 *src, const u32 *attr, int num_sprites, int deltax, int deltay, int y_lowres);
382 	void namcos22_mix_text_layer(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
383 
384 	void install_c74_speedup();
385 
386 	TILE_GET_INFO_MEMBER(get_text_tile_info);
387 	virtual void draw_text_layer(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
388 	u32 screen_update_namcos22(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
389 	INTERRUPT_GEN_MEMBER(namcos22_interrupt);
390 	INTERRUPT_GEN_MEMBER(dsp_vblank_irq);
391 	TIMER_DEVICE_CALLBACK_MEMBER(dsp_serial_pulse);
392 
393 	void iomcu_s22_program(address_map &map);
394 	void master_dsp_data(address_map &map);
395 	void master_dsp_io(address_map &map);
396 	void master_dsp_program(address_map &map);
397 	void mcu_s22_program(address_map &map);
398 	void namcos22_am(address_map &map);
399 	void slave_dsp_data(address_map &map);
400 	void slave_dsp_io(address_map &map);
401 	void slave_dsp_program(address_map &map);
402 
403 	required_device<cpu_device> m_maincpu;
404 	required_device<cpu_device> m_master;
405 	required_device<cpu_device> m_slave;
406 	required_device<m37710_cpu_device> m_mcu;
407 	optional_device<m37710_cpu_device> m_iomcu;
408 	required_device<eeprom_parallel_28xx_device> m_eeprom;
409 	optional_device<mb87078_device> m_mb87078;
410 	required_device<c352_device> m_c352;
411 	required_shared_ptr<u16> m_shareram;
412 	required_shared_ptr<u16> m_slave_extram;
413 	required_shared_ptr<u16> m_master_extram;
414 	required_shared_ptr<u32> m_paletteram;
415 	required_shared_ptr<u32> m_cgram;
416 	required_shared_ptr<u32> m_textram;
417 	required_shared_ptr<u32> m_polygonram;
418 	required_shared_ptr<u32> m_mixer;
419 	optional_region_ptr<u8> m_gamma_proms;
420 	optional_shared_ptr<u32> m_vics_data;
421 	optional_shared_ptr<u32> m_vics_control;
422 	required_device<screen_device> m_screen;
423 	optional_ioport_array<8> m_adc_ports;
424 	required_ioport m_inputs;
425 	optional_ioport_array<2> m_custom;
426 	optional_ioport_array<2> m_opt;
427 	output_finder<16> m_mcu_out;
428 	output_finder<8> m_cpuled_out;
429 
430 	u8 m_syscontrol[0x20];
431 	bool m_dsp_irq_enabled;
432 	emu_timer *m_ar_tb_interrupt[2];
433 	u16 m_dsp_master_bioz;
434 	std::unique_ptr<u32[]> m_pointram;
435 	int m_old_coin_state;
436 	u32 m_credits1;
437 	u32 m_credits2;
438 	u32 m_point_address;
439 	u32 m_point_data;
440 	u16 m_SerialDataSlaveToMasterNext;
441 	u16 m_SerialDataSlaveToMasterCurrent;
442 	int m_RenderBufSize;
443 	u16 m_RenderBufData[NAMCOS22_MAX_RENDER_CMD_SEQ];
444 	u16 m_portbits[2];
445 	int m_irq_state;
446 	int m_irq_enabled;
447 	namcos22_dsp_upload_state m_dsp_upload_state;
448 	int m_UploadDestIdx;
449 	u32 m_cpuled_data;
450 	u16 m_su_82;
451 	u16 m_keycus_id;
452 	u16 m_keycus_rng;
453 	int m_gametype;
454 	int m_cz_adjust;
455 	namcos22_renderer *m_poly;
456 	u16 m_dspram_bank;
457 	u16 m_dspram16_latch;
458 	bool m_slave_simulation_active;
459 	int m_absolute_priority;
460 	int m_objectshift;
461 	float m_viewmatrix[4][4];
462 	u8 m_reflection;
463 	bool m_cullflip;
464 	u8 m_LitSurfaceInfo[NAMCOS22_MAX_LIT_SURFACES];
465 	int m_SurfaceNormalFormat;
466 	unsigned m_LitSurfaceCount;
467 	unsigned m_LitSurfaceIndex;
468 	int m_pointrom_size;
469 	s32 *m_pointrom;
470 	std::unique_ptr<u8[]> m_dirtypal;
471 	std::unique_ptr<bitmap_ind16> m_mix_bitmap;
472 	tilemap_t *m_bgtilemap;
473 	u16 m_tilemapattr[8];
474 
475 	int m_spot_factor;
476 	int m_text_palbase;
477 	int m_bg_palbase;
478 
479 	float m_camera_zoom;
480 	float m_camera_vx;
481 	float m_camera_vy;
482 	float m_camera_vu;
483 	float m_camera_vd;
484 	float m_camera_vl;
485 	float m_camera_vr;
486 	float m_camera_lx; // unit vector for light direction
487 	float m_camera_ly; // "
488 	float m_camera_lz; // "
489 	int m_camera_ambient; // 0.0..1.0
490 	int m_camera_power;   // 0.0..1.0
491 
492 	bool m_skipped_this_frame;
493 	void render_frame_active();
494 	DECLARE_WRITE_LINE_MEMBER(screen_vblank);
495 	bool m_pdp_render_done;
496 	bool m_render_refresh;
497 	uint64_t m_pdp_frame;
498 	u16 m_pdp_base;
499 };
500 
501 class namcos22s_state : public namcos22_state
502 {
503 public:
namcos22s_state(const machine_config & mconfig,device_type type,const char * tag)504 	namcos22s_state(const machine_config &mconfig, device_type type, const char *tag) :
505 		namcos22_state(mconfig, type, tag),
506 		m_motor_timer(*this, "motor_timer"),
507 		m_pc_pedal_interrupt(*this, "pc_p_int")
508 	{ }
509 
510 	void namcos22s(machine_config &config);
511 	void propcycl(machine_config &config);
512 	void dirtdash(machine_config &config);
513 	void airco22b(machine_config &config);
514 	void cybrcycc(machine_config &config);
515 	void tokyowar(machine_config &config);
516 	void alpine(machine_config &config);
517 	void alpinesa(machine_config &config);
518 	void adillor(machine_config &config);
519 	void timecris(machine_config &config);
520 
521 	void init_aquajet();
522 	void init_adillor();
523 	void init_cybrcyc();
524 	void init_timecris();
525 	void init_tokyowar();
526 	void init_propcycl();
527 	void init_alpiner2();
528 	void init_dirtdash();
529 	void init_airco22();
530 	void init_alpiner();
531 	void init_alpinesa();
532 
533 	template <int N> DECLARE_READ_LINE_MEMBER(alpine_motor_r);
534 
535 protected:
536 	virtual void machine_start() override;
537 
538 	virtual void init_tables() override;
539 	virtual void draw_text_layer(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) override;
540 
541 private:
542 	DECLARE_MACHINE_START(adillor);
543 
544 	void install_130_speedup();
545 	void install_141_speedup();
546 
547 	void recalc_czram();
548 	void namcos22s_mix_text_layer(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int prival);
549 	u32 screen_update_namcos22s(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
550 
551 	void namcos22s_czattr_w(offs_t offset, u16 data, u16 mem_mask = ~0);
552 	u16 namcos22s_czattr_r(offs_t offset);
553 	void namcos22s_czram_w(offs_t offset, u32 data, u32 mem_mask = ~0);
554 	u32 namcos22s_czram_r(offs_t offset);
555 	u32 namcos22s_vics_control_r(offs_t offset);
556 	void namcos22s_vics_control_w(offs_t offset, u32 data, u32 mem_mask = ~0);
557 	u16 spotram_r(offs_t offset);
558 	void spotram_w(offs_t offset, u16 data, u16 mem_mask = ~0);
559 
560 	u32 alpinesa_prot_r();
561 	void alpinesa_prot_w(u32 data);
562 	u16 timecris_gun_r(offs_t offset);
563 	void mb87078_gain_changed(offs_t offset, u8 data);
564 	void namcos22s_chipselect_w(offs_t offset, u32 data, u32 mem_mask = ~0);
565 
566 	void mcu_port4_w(u8 data);
567 	u8 mcu_port4_r();
568 	void mcu_port5_w(u8 data);
569 	u8 mcu_port5_r();
570 	void mcu_port6_w(u8 data);
571 	u8 mcu_port6_r();
572 	template <int Channel> u16 mcu_adc_r();
573 	void alpine_mcu_port4_w(u8 data);
574 	u16 mcu130_speedup_r();
575 	u16 mcu141_speedup_r();
576 
577 	INTERRUPT_GEN_MEMBER(namcos22s_interrupt);
578 	TIMER_DEVICE_CALLBACK_MEMBER(mcu_irq);
579 	TIMER_DEVICE_CALLBACK_MEMBER(adillor_trackball_update);
580 	TIMER_CALLBACK_MEMBER(adillor_trackball_interrupt);
581 	TIMER_DEVICE_CALLBACK_MEMBER(propcycl_pedal_update);
582 	TIMER_DEVICE_CALLBACK_MEMBER(propcycl_pedal_interrupt);
583 	TIMER_DEVICE_CALLBACK_MEMBER(alpine_steplock_callback);
584 
585 	void alpinesa_am(address_map &map);
586 	void mcu_program(address_map &map);
587 	void namcos22s_am(address_map &map);
588 	void timecris_am(address_map &map);
589 
590 	optional_device<timer_device> m_motor_timer;
591 	optional_device<timer_device> m_pc_pedal_interrupt;
592 
593 	int m_spotram_enable;
594 	int m_spotram_address;
595 	std::unique_ptr<u16[]> m_spotram;
596 	std::unique_ptr<u16[]> m_banked_czram[4];
597 	u32 m_cz_was_written[4];
598 
599 	u32 m_alpinesa_protection;
600 	int m_motor_status;
601 	u8 m_mcu_iocontrol;
602 	u8 m_mcu_outdata;
603 	int m_chipselect;
604 };
605 
606 #endif // MAME_INCLUDES_NAMCOS22_H
607