1 // license:BSD-3-Clause
2 // copyright-holders:Nicola Salmoria
3 #ifndef MAME_INCLUDES_AEROFGT_H
4 #define MAME_INCLUDES_AEROFGT_H
5 
6 #pragma once
7 
8 #include "machine/gen_latch.h"
9 #include "video/vsystem_spr.h"
10 #include "video/vsystem_spr2.h"
11 #include "sound/okim6295.h"
12 #include "sound/upd7759.h"
13 #include "emupal.h"
14 #include "tilemap.h"
15 
16 class aerofgt_state : public driver_device
17 {
18 public:
aerofgt_state(const machine_config & mconfig,device_type type,const char * tag)19 	aerofgt_state(const machine_config &mconfig, device_type type, const char *tag)
20 		: driver_device(mconfig, type, tag)
21 		, m_vram(*this, "vram.%u", 0)
22 		, m_rasterram(*this, "rasterram")
23 		, m_bitmapram(*this, "bitmapram")
24 		, m_sprlookupram(*this, "sprlookupram%u", 1)
25 		, m_spriteram(*this, "spriteram")
26 		, m_tx_tilemap_ram(*this, "tx_tilemap_ram")
27 		, m_maincpu(*this, "maincpu")
28 		, m_audiocpu(*this, "audiocpu")
29 		, m_oki(*this, "oki")
30 		, m_upd7759(*this, "upd")
31 		, m_gfxdecode(*this, "gfxdecode")
32 		, m_palette(*this, "palette")
33 		, m_spr(*this, "vsystem_spr")
34 		, m_spr_old(*this, "vsystem_spr_old%u", 1)
35 		, m_soundlatch(*this, "soundlatch")
36 		, m_sprlookuprom(*this, "sprlookuprom")
37 		, m_soundbank(*this, "soundbank")
38 		, m_okibank(*this, "okibank")
39 	{ }
40 
41 	/* memory pointers */
42 	optional_shared_ptr_array<uint16_t, 2> m_vram;
43 	optional_shared_ptr<uint16_t> m_rasterram;
44 	optional_shared_ptr<uint16_t> m_bitmapram;
45 	optional_shared_ptr_array<uint16_t, 2> m_sprlookupram;
46 	required_shared_ptr<uint16_t> m_spriteram;
47 	optional_shared_ptr<uint16_t> m_tx_tilemap_ram;
48 
49 	/* devices referenced above */
50 	required_device<cpu_device> m_maincpu;
51 	optional_device<cpu_device> m_audiocpu;
52 	optional_device<okim6295_device> m_oki;
53 	optional_device<upd7759_device> m_upd7759; // karatblzbl
54 	required_device<gfxdecode_device> m_gfxdecode;
55 	required_device<palette_device> m_palette;
56 	optional_device<vsystem_spr_device> m_spr; // only the aerofgt parent uses this chip
57 	optional_device_array<vsystem_spr2_device, 2> m_spr_old; // every other (non-bootleg) uses this or a pair of them..
58 	optional_device<generic_latch_8_device> m_soundlatch;
59 
60 	optional_region_ptr<uint16_t> m_sprlookuprom;
61 	optional_memory_bank m_soundbank;
62 	optional_memory_bank m_okibank;
63 
64 	/* video-related */
65 	tilemap_t   *m_tilemap[2];
66 	uint8_t     m_gfxbank[8];
67 	uint16_t    m_bank[4];
68 	uint16_t    m_scrollx[2];
69 	uint16_t    m_scrolly[2];
70 	bool        m_flip_screen;
71 	uint16_t    m_wbbc97_bitmap_enable;
72 	int       m_charpalettebank;
73 	int       m_spritepalettebank;
74 	int       m_sprite_gfx;
75 	int       m_spikes91_lookup;
76 	uint32_t aerofgt_tile_callback( uint32_t code );
77 
78 	uint32_t aerofgt_old_tile_callback( uint32_t code );
79 	uint32_t aerofgt_ol2_tile_callback( uint32_t code );
80 	uint32_t spinbrk_tile_callback( uint32_t code );
81 
82 	/* handlers */
83 	void karatblzbl_soundlatch_w(uint8_t data);
84 	uint8_t pending_command_r();
85 	void aerofgt_sh_bankswitch_w(uint8_t data);
86 	void spinlbrk_sh_bankswitch_w(uint8_t data);
87 	void aerfboot_okim6295_banking_w(uint8_t data);
88 	template<int Layer> void vram_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
89 	void pspikes_gfxbank_w(uint8_t data);
90 	void pspikesb_gfxbank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
91 	void spikes91_lookup_w(uint16_t data);
92 	void karatblz_gfxbank_w(uint8_t data);
93 	void spinlbrk_gfxbank_w(uint8_t data);
94 	void kickball_gfxbank_w(uint8_t data);
95 	void turbofrc_gfxbank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
96 	void aerofgt_gfxbank_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
97 	template<int Layer> void scrollx_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
98 	template<int Layer> void scrolly_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
99 	void pspikes_palette_bank_w(uint8_t data);
100 	void spinlbrk_flip_screen_w(uint8_t data);
101 	void turbofrc_flip_screen_w(uint8_t data);
102 	void wbbc97_bitmap_enable_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
103 	void pspikesb_oki_banking_w(uint16_t data);
104 	void aerfboo2_okim6295_banking_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0);
105 	void karatblzbl_d7759_write_port_0_w(uint8_t data);
106 	void karatblzbl_d7759_reset_w(uint8_t data);
107 	TILE_GET_INFO_MEMBER(get_pspikes_tile_info);
108 	template<int Layer> TILE_GET_INFO_MEMBER(karatblz_tile_info);
109 	template<int Layer> TILE_GET_INFO_MEMBER(spinlbrk_tile_info);
110 	template<int Layer> TILE_GET_INFO_MEMBER(get_tile_info);
111 	DECLARE_MACHINE_START(aerofgt);
112 	DECLARE_MACHINE_START(spinlbrk);
113 	DECLARE_MACHINE_RESET(aerofgt);
114 	DECLARE_VIDEO_START(pspikes);
115 	DECLARE_MACHINE_START(common);
116 	DECLARE_MACHINE_RESET(common);
117 	DECLARE_VIDEO_START(karatblz);
118 	DECLARE_VIDEO_START(spinlbrk);
119 	DECLARE_VIDEO_START(turbofrc);
120 	DECLARE_VIDEO_START(wbbc97);
121 	void init_banked_oki();
122 	void init_kickball();
123 	uint32_t screen_update_pspikes(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
124 	uint32_t screen_update_spikes91(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
125 	uint32_t screen_update_pspikesb(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
126 	uint32_t screen_update_karatblz(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
127 	uint32_t screen_update_spinlbrk(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
128 	uint32_t screen_update_turbofrc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
129 	uint32_t screen_update_aerofgt(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
130 	uint32_t screen_update_aerfboot(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
131 	uint32_t screen_update_aerfboo2(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
132 	uint32_t screen_update_wbbc97(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
133 	void aerofgt_register_state_globals(  );
134 	void setbank( int layer, int num, int bank );
135 	void aerfboo2_draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int chip, int chip_disabled_pri );
136 	void pspikesb_draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect );
137 	void spikes91_draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect );
138 	void aerfboot_draw_sprites( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect );
139 	void wbbc97_draw_bitmap( bitmap_rgb32 &bitmap );
140 	void spinlbrk(machine_config &config);
141 	void aerofgt(machine_config &config);
142 	void karatblz(machine_config &config);
143 	void pspikesb(machine_config &config);
144 	void aerfboo2(machine_config &config);
145 	void pspikes(machine_config &config);
146 	void wbbc97(machine_config &config);
147 	void aerfboot(machine_config &config);
148 	void pspikesc(machine_config &config);
149 	void karatblzbl(machine_config &config);
150 	void spikes91(machine_config &config);
151 	void aerofgtb(machine_config &config);
152 	void turbofrc(machine_config &config);
153 	void kickball(machine_config &config);
154 	void aerfboo2_map(address_map &map);
155 	void aerfboot_map(address_map &map);
156 	void aerfboot_sound_map(address_map &map);
157 	void aerofgt_map(address_map &map);
158 	void aerofgt_sound_portmap(address_map &map);
159 	void aerofgtb_map(address_map &map);
160 	void karatblz_map(address_map &map);
161 	void karatblzbl_map(address_map &map);
162 	void karatblzbl_sound_map(address_map &map);
163 	void karatblzbl_sound_portmap(address_map &map);
164 	void kickball_map(address_map &map);
165 	void kickball_sound_map(address_map &map);
166 	void kickball_sound_portmap(address_map &map);
167 	void oki_map(address_map &map);
168 	void pspikes_map(address_map &map);
169 	void pspikesb_map(address_map &map);
170 	void pspikesc_map(address_map &map);
171 	void sound_map(address_map &map);
172 	void spikes91_map(address_map &map);
173 	void spikes91_sound_map(address_map &map);
174 	void spinlbrk_map(address_map &map);
175 	void spinlbrk_sound_portmap(address_map &map);
176 	void turbofrc_map(address_map &map);
177 	void turbofrc_sound_portmap(address_map &map);
178 	void wbbc97_map(address_map &map);
179 	void wbbc97_sound_map(address_map &map);
180 };
181 
182 #endif // MAME_INCLUDES_AEROFGT_H
183