1 // license:BSD-3-Clause
2 // copyright-holders:Aaron Giles
3 /*************************************************************************
4 
5     Jaleco Exerion
6 
7 *************************************************************************/
8 #ifndef MAME_INCLUDES_EXERION_H
9 #define MAME_INCLUDES_EXERION_H
10 
11 #pragma once
12 
13 #include "emupal.h"
14 #include "screen.h"
15 
16 
17 #define EXERION_MASTER_CLOCK      (XTAL(19'968'000))   /* verified on pcb */
18 #define EXERION_CPU_CLOCK         (EXERION_MASTER_CLOCK / 6)
19 #define EXERION_AY8910_CLOCK      (EXERION_CPU_CLOCK / 2)
20 #define EXERION_PIXEL_CLOCK       (EXERION_MASTER_CLOCK / 3)
21 #define EXERION_HCOUNT_START      (0x58)
22 #define EXERION_HTOTAL            (512-EXERION_HCOUNT_START)
23 #define EXERION_HBEND             (12*8)    /* ?? */
24 #define EXERION_HBSTART           (52*8)    /* ?? */
25 #define EXERION_VTOTAL            (256)
26 #define EXERION_VBEND             (16)
27 #define EXERION_VBSTART           (240)
28 
29 
30 class exerion_state : public driver_device
31 {
32 public:
exerion_state(const machine_config & mconfig,device_type type,const char * tag)33 	exerion_state(const machine_config &mconfig, device_type type, const char *tag) :
34 		driver_device(mconfig, type, tag),
35 		m_main_ram(*this, "main_ram"),
36 		m_videoram(*this, "videoram"),
37 		m_spriteram(*this, "spriteram"),
38 		m_maincpu(*this, "maincpu"),
39 		m_gfxdecode(*this, "gfxdecode"),
40 		m_screen(*this, "screen"),
41 		m_palette(*this, "palette")
42 	{ }
43 
44 	void exerion(machine_config &config);
45 	void irion(machine_config &config);
46 
47 	void init_exerion();
48 	void init_exerionb();
49 	void init_irion();
50 
51 	DECLARE_CUSTOM_INPUT_MEMBER(exerion_controls_r);
52 	DECLARE_INPUT_CHANGED_MEMBER(coin_inserted);
53 
54 private:
55 	/* memory pointers */
56 	required_shared_ptr<uint8_t> m_main_ram;
57 	required_shared_ptr<uint8_t> m_videoram;
58 	required_shared_ptr<uint8_t> m_spriteram;
59 
60 	/* video-related */
61 	uint8_t    m_cocktail_flip;
62 	uint8_t    m_char_palette;
63 	uint8_t    m_sprite_palette;
64 	uint8_t    m_char_bank;
65 	std::unique_ptr<uint16_t[]>  m_background_gfx[4];
66 	uint8_t    *m_background_mixer;
67 	uint8_t    m_background_latches[13];
68 
69 	/* protection? */
70 	uint8_t m_porta;
71 	uint8_t m_portb;
72 
73 	/* devices */
74 	required_device<cpu_device> m_maincpu;
75 	required_device<gfxdecode_device> m_gfxdecode;
76 	required_device<screen_device> m_screen;
77 	required_device<palette_device> m_palette;
78 
79 	uint8_t exerion_protection_r(offs_t offset);
80 	void exerion_videoreg_w(uint8_t data);
81 	void exerion_video_latch_w(offs_t offset, uint8_t data);
82 	uint8_t exerion_video_timing_r();
83 	uint8_t exerion_porta_r();
84 	void exerion_portb_w(uint8_t data);
85 	virtual void machine_start() override;
86 	virtual void machine_reset() override;
87 	virtual void video_start() override;
88 	void exerion_palette(palette_device &palette) const;
89 	uint32_t screen_update_exerion(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
90 	void draw_background( bitmap_ind16 &bitmap, const rectangle &cliprect);
91 	void main_map(address_map &map);
92 	void sub_map(address_map &map);
93 };
94 
95 #endif // MAME_INCLUDES_EXERION_H
96