1 // license:BSD-3-Clause 2 // copyright-holders:Farfetch'd,David Haywood,Tomasz Slanina 3 /*************************************************************************** 4 5 tecmosys protection simulation 6 7 ***************************************************************************/ 8 #ifndef MAME_INCLUDES_TECMOSYS_H 9 #define MAME_INCLUDES_TECMOSYS_H 10 11 #pragma once 12 13 #include "machine/eepromser.h" 14 #include "machine/gen_latch.h" 15 #include "machine/input_merger.h" 16 #include "machine/watchdog.h" 17 #include "emupal.h" 18 #include "screen.h" 19 #include "tilemap.h" 20 21 class tecmosys_state : public driver_device 22 { 23 public: tecmosys_state(const machine_config & mconfig,device_type type,const char * tag)24 tecmosys_state(const machine_config &mconfig, device_type type, const char *tag) 25 : driver_device(mconfig, type, tag) 26 , m_maincpu(*this, "maincpu") 27 , m_audiocpu(*this, "audiocpu") 28 , m_eeprom(*this, "eeprom") 29 , m_watchdog(*this, "watchdog") 30 , m_gfxdecode(*this, "gfxdecode") 31 , m_screen(*this, "screen") 32 , m_palette(*this, "palette") 33 , m_soundlatch(*this, "soundlatch") 34 , m_soundnmi(*this, "soundnmi") 35 , m_spriteram(*this, "spriteram") 36 , m_tilemap_paletteram16(*this, "tmap_palette") 37 , m_vram(*this, "vram_%u", 0) 38 , m_lineram(*this, "bg%u_lineram", 0) 39 , m_scroll(*this, "scroll_%u", 0) 40 , m_880000regs(*this, "880000regs") 41 , m_sprite_region(*this, "sprites") 42 , m_audiobank(*this, "audiobank") 43 , m_okibank(*this, "okibank%u", 1) 44 { 45 } 46 47 void tecmosys(machine_config &config); 48 49 void init_tkdensha(); 50 void init_deroon(); 51 void init_tkdensho(); 52 53 protected: 54 virtual void machine_start() override; 55 virtual void video_start() override; 56 57 private: 58 required_device<cpu_device> m_maincpu; 59 required_device<cpu_device> m_audiocpu; 60 required_device<eeprom_serial_93cxx_device> m_eeprom; 61 required_device<watchdog_timer_device> m_watchdog; 62 required_device<gfxdecode_device> m_gfxdecode; 63 required_device<screen_device> m_screen; 64 required_device<palette_device> m_palette; 65 required_device<generic_latch_8_device> m_soundlatch; 66 required_device<input_merger_device> m_soundnmi; 67 68 required_shared_ptr<u16> m_spriteram; 69 required_shared_ptr<u16> m_tilemap_paletteram16; 70 required_shared_ptr_array<u16, 4> m_vram; 71 required_shared_ptr_array<u16, 3> m_lineram; 72 required_shared_ptr_array<u16, 4> m_scroll; 73 required_shared_ptr<u16> m_880000regs; 74 75 required_region_ptr<u8> m_sprite_region; 76 std::unique_ptr<u8[]> m_sprite_gfx; 77 offs_t m_sprite_gfx_mask; 78 79 required_memory_bank m_audiobank; 80 required_memory_bank_array<2> m_okibank; 81 82 int m_spritelist; 83 bitmap_ind16 m_sprite_bitmap; 84 bitmap_ind16 m_tmp_tilemap_composebitmap; 85 bitmap_ind16 m_tmp_tilemap_renderbitmap; 86 tilemap_t *m_tilemap[4]; 87 u8 m_device_read_ptr; 88 u8 m_device_status; 89 const struct prot_data* m_device_data; 90 u8 m_device_value; 91 92 u8 sound_command_pending_r(); 93 void sound_nmi_disable_w(u8 data); 94 void unk880000_w(offs_t offset, u16 data, u16 mem_mask = ~0); 95 u16 unk880000_r(offs_t offset); 96 void z80_bank_w(u8 data); 97 void oki_bank_w(u8 data); 98 u16 prot_status_r(offs_t offset, u16 mem_mask = ~0); 99 void prot_status_w(u16 data); 100 u16 prot_data_r(); 101 void prot_data_w(u16 data); 102 template<int Layer> void vram_w(offs_t offset, u16 data, u16 mem_mask = ~0); 103 void tilemap_paletteram16_xGGGGGRRRRRBBBBB_word_w(offs_t offset, u16 data, u16 mem_mask = ~0); 104 template<int Layer> void lineram_w(offs_t offset, u16 data, u16 mem_mask = ~0); 105 u16 eeprom_r(); 106 void eeprom_w(offs_t offset, u16 data, u16 mem_mask = ~0); 107 108 template<int Layer> TILE_GET_INFO_MEMBER(get_tile_info); 109 110 u32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); 111 void prot_init(int which); 112 void prot_reset(); 113 inline void set_color_555(pen_t color, int rshift, int gshift, int bshift, u16 data); 114 void render_sprites_to_bitmap(const rectangle &cliprect, u16 extrax, u16 extray); 115 void tilemap_copy_to_compose(u16 pri, const rectangle &cliprect); 116 void do_final_mix(bitmap_rgb32 &bitmap, const rectangle &cliprect); 117 void descramble(); 118 119 void io_map(address_map &map); 120 void main_map(address_map &map); 121 void oki_map(address_map &map); 122 void sound_map(address_map &map); 123 }; 124 125 #endif // MAME_INCLUDES_TECMOSYS_H 126