1 // license:BSD-3-Clause 2 // copyright-holders:Luca Elia 3 #ifndef MAME_INCLUDES_SUNA8_H 4 #define MAME_INCLUDES_SUNA8_H 5 6 #pragma once 7 8 #include "machine/gen_latch.h" 9 #include "machine/timer.h" 10 #include "sound/samples.h" 11 #include "emupal.h" 12 #include "screen.h" 13 #include "tilemap.h" 14 15 #define TILEMAPS 0 16 17 class suna8_state : public driver_device 18 { 19 public: suna8_state(const machine_config & mconfig,device_type type,const char * tag)20 suna8_state(const machine_config &mconfig, device_type type, const char *tag) : 21 driver_device(mconfig, type, tag), 22 m_maincpu(*this,"maincpu"), 23 m_hardhead_ip(*this, "hardhead_ip"), 24 m_spriteram(*this, "spriteram"), 25 m_wram(*this, "wram"), 26 m_banked_paletteram(*this, "paletteram"), 27 m_audiocpu(*this, "audiocpu"), 28 m_samples(*this, "samples"), 29 m_gfxdecode(*this, "gfxdecode"), 30 m_screen(*this, "screen"), 31 m_palette(*this, "palette"), 32 m_soundlatch(*this, "soundlatch"), 33 m_soundlatch2(*this, "soundlatch2"), 34 m_bank0d(*this, "bank0d"), 35 m_bank1(*this, "bank1"), 36 m_bank1d(*this, "bank1d"), 37 m_prot_opcode_toggle(0), 38 m_remap_sound(0), 39 m_leds(*this, "led%u", 0U) 40 { } 41 42 void brickzn(machine_config &config); 43 void starfigh(machine_config &config); 44 void sparkman(machine_config &config); 45 void hardhea2b(machine_config &config); 46 void brickzn11(machine_config &config); 47 void hardhead(machine_config &config); 48 void hardhea2(machine_config &config); 49 void rranger(machine_config &config); 50 51 void init_brickzn_common(); 52 void init_brickznv5(); 53 void init_brickznv4(); 54 void init_starfigh(); 55 void init_hardhea2(); 56 void init_hardhea2b(); 57 void init_hardhedb(); 58 void init_sparkman(); 59 void init_brickzn(); 60 void init_brickzn11(); 61 void init_hardhead(); 62 void init_suna8(); 63 64 private: 65 enum GFXBANK_TYPE_T 66 { 67 GFXBANK_TYPE_SPARKMAN, 68 GFXBANK_TYPE_BRICKZN, 69 GFXBANK_TYPE_STARFIGH 70 } m_gfxbank_type; 71 72 uint8_t hardhead_protection_r(offs_t offset); 73 void hardhead_protection_w(offs_t offset, uint8_t data); 74 uint8_t hardhead_ip_r(); 75 void hardhead_bankswitch_w(uint8_t data); 76 void hardhead_flipscreen_w(uint8_t data); 77 void rranger_bankswitch_w(uint8_t data); 78 uint8_t rranger_soundstatus_r(); 79 void sranger_prot_w(uint8_t data); 80 81 // brickzn 82 uint8_t brickzn_cheats_r(); 83 void brickzn_leds_w(uint8_t data); 84 void brickzn_palbank_w(uint8_t data); 85 void brickzn_sprbank_w(uint8_t data); 86 void brickzn_rombank_w(uint8_t data); 87 void brickzn_banked_paletteram_w(offs_t offset, uint8_t data); 88 // brickzn (newer sets) 89 void brickzn_prot2_w(uint8_t data); 90 void brickzn_multi_w(uint8_t data); 91 void brickzn_enab_palram_w(uint8_t data); 92 void brickzn_disab_palram_w(uint8_t data); 93 94 // hardhea2 95 void hardhea2_nmi_w(uint8_t data); 96 void hardhea2_flipscreen_w(uint8_t data); 97 void hardhea2_leds_w(uint8_t data); 98 void hardhea2_spritebank_w(uint8_t data); 99 void hardhea2_rombank_w(uint8_t data); 100 void hardhea2_spritebank_0_w(uint8_t data); 101 void hardhea2_spritebank_1_w(uint8_t data); 102 void hardhea2_rambank_0_w(uint8_t data); 103 void hardhea2_rambank_1_w(uint8_t data); 104 105 // starfigh 106 void starfigh_rombank_latch_w(offs_t offset, uint8_t data); 107 void starfigh_spritebank_latch_w(uint8_t data); 108 void starfigh_sound_latch_w(uint8_t data); 109 void starfigh_spritebank_w(uint8_t data); 110 uint8_t starfigh_cheats_r(); 111 void starfigh_leds_w(uint8_t data); 112 113 // sparkman 114 void sparkman_rombank_latch_w(offs_t offset, uint8_t data); 115 void sparkman_rombank_w(uint8_t data); 116 void sparkman_spritebank_latch_w(uint8_t data); 117 void sparkman_spritebank_w(uint8_t data); 118 void sparkman_write_disable_w(uint8_t data); 119 void suna8_wram_w(offs_t offset, uint8_t data); 120 void sparkman_coin_counter_w(uint8_t data); 121 uint8_t sparkman_c0a3_r(); 122 123 uint8_t banked_paletteram_r(offs_t offset); 124 uint8_t suna8_banked_spriteram_r(offs_t offset); 125 void suna8_spriteram_w(offs_t offset, uint8_t data); 126 void suna8_banked_spriteram_w(offs_t offset, uint8_t data); 127 128 void suna8_vh_start_common(bool has_text, GFXBANK_TYPE_T gfxbank_type); 129 DECLARE_VIDEO_START(suna8_text); 130 DECLARE_VIDEO_START(suna8_sparkman); 131 DECLARE_VIDEO_START(suna8_brickzn); 132 DECLARE_VIDEO_START(suna8_starfigh); 133 134 DECLARE_MACHINE_RESET(brickzn); 135 DECLARE_MACHINE_RESET(hardhea2); 136 uint32_t screen_update_suna8(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect); 137 TIMER_DEVICE_CALLBACK_MEMBER(hardhea2_interrupt); 138 139 // samples 140 void suna8_play_samples_w(uint8_t data); 141 void rranger_play_samples_w(uint8_t data); 142 void suna8_samples_number_w(uint8_t data); 143 void play_sample(int index); 144 SAMPLES_START_CB_MEMBER(sh_start); 145 146 void draw_sprites (screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int start, int end, int which); 147 void draw_text_sprites(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int start, int end, int ypos, bool write_mask); 148 uint8_t *brickzn_decrypt(); 149 150 void brickzn11_map(address_map &map); 151 void brickzn_io_map(address_map &map); 152 void brickzn_map(address_map &map); 153 void brickzn_pcm_io_map(address_map &map); 154 void brickzn_pcm_map(address_map &map); 155 void brickzn_sound_map(address_map &map); 156 void decrypted_opcodes_map(address_map &map); 157 void hardhea2_map(address_map &map); 158 void hardhea2b_map(address_map &map); 159 void hardhea2b_decrypted_opcodes_map(address_map &map); 160 void hardhead_io_map(address_map &map); 161 void hardhead_map(address_map &map); 162 void hardhead_sound_io_map(address_map &map); 163 void hardhead_sound_map(address_map &map); 164 void rranger_io_map(address_map &map); 165 void rranger_map(address_map &map); 166 void rranger_sound_map(address_map &map); 167 void sparkman_map(address_map &map); 168 void starfigh_map(address_map &map); 169 machine_start()170 virtual void machine_start() override { m_leds.resolve(); } 171 172 required_device<cpu_device> m_maincpu; 173 optional_shared_ptr<uint8_t> m_hardhead_ip; 174 optional_shared_ptr<uint8_t> m_spriteram; 175 optional_shared_ptr<uint8_t> m_wram; 176 optional_shared_ptr<uint8_t> m_banked_paletteram; 177 required_device<cpu_device> m_audiocpu; 178 optional_device<samples_device> m_samples; 179 required_device<gfxdecode_device> m_gfxdecode; 180 required_device<screen_device> m_screen; 181 required_device<palette_device> m_palette; 182 required_device<generic_latch_8_device> m_soundlatch; 183 required_device<generic_latch_8_device> m_soundlatch2; 184 optional_memory_bank m_bank0d; 185 required_memory_bank m_bank1; 186 optional_memory_bank m_bank1d; 187 188 uint8_t m_rombank; 189 uint8_t m_rombank_latch; 190 uint8_t m_spritebank; 191 uint8_t m_palettebank; 192 uint8_t m_paletteram_enab; 193 uint8_t m_prot2; 194 uint8_t m_prot2_prev; 195 196 uint8_t m_protection_val; 197 uint8_t m_nmi_enable; 198 uint8_t m_spritebank_latch; 199 uint8_t m_write_disable; 200 uint8_t m_prot_opcode_toggle; 201 uint8_t m_remap_sound; 202 uint8_t* m_decrypt; 203 204 uint8_t m_gfxbank; 205 206 bool m_has_text; // has text sprites (older games) 207 208 // samples 209 std::unique_ptr<int16_t[]> m_samplebuf; 210 int m_sample, m_play; 211 int m_numsamples; 212 213 #if TILEMAPS 214 tilemap_t *m_bg_tilemap; 215 int m_tiles; 216 int m_trombank; 217 int m_page; 218 219 TILE_GET_INFO_MEMBER(get_tile_info); 220 #endif 221 output_finder<2> m_leds; 222 }; 223 224 #endif // MAME_INCLUDES_SUNA8_H 225