1 // license:BSD-3-Clause 2 // copyright-holders:Olivier Galibert 3 /* 4 Sega system24 hardware 5 6 */ 7 8 #ifndef MAME_VIDEO_SEGAIC24_H 9 #define MAME_VIDEO_SEGAIC24_H 10 11 #pragma once 12 13 #include "tilemap.h" 14 15 16 class segas24_tile_device : public device_t, public device_gfx_interface 17 { 18 friend class segas24_tile_config; 19 20 public: segas24_tile_device(const machine_config & mconfig,const char * tag,device_t * owner,uint32_t clock,uint16_t _tile_mask)21 segas24_tile_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, uint16_t _tile_mask) 22 : segas24_tile_device(mconfig, tag, owner, clock) 23 { 24 set_tile_mask(_tile_mask); 25 } 26 27 segas24_tile_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); 28 29 // configuration set_tile_mask(uint16_t _tile_mask)30 void set_tile_mask(uint16_t _tile_mask) { tile_mask = _tile_mask; } 31 32 uint16_t tile_r(offs_t offset); 33 void tile_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 34 uint16_t char_r(offs_t offset); 35 void char_w(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 36 void xhout_w(uint16_t data); 37 void xvout_w(uint16_t data); 38 39 void draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int pri, int flags); 40 void draw(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int layer, int pri, int flags); 41 xhout_write_callback()42 auto xhout_write_callback() { return m_xhout_write_cb.bind(); } xvout_write_callback()43 auto xvout_write_callback() { return m_xvout_write_cb.bind(); } 44 45 protected: 46 virtual void device_start() override; 47 48 private: 49 enum { 50 SYS24_TILES = 0x4000 51 }; 52 53 std::unique_ptr<uint16_t[]> char_ram; 54 std::unique_ptr<uint16_t[]> tile_ram; 55 int char_gfx_index; 56 tilemap_t *tile_layer[4]; 57 uint16_t tile_mask; 58 59 static const gfx_layout char_layout; 60 61 void tile_info(int offset, tile_data &tileinfo, tilemap_memory_index tile_index); 62 TILE_GET_INFO_MEMBER(tile_info_0s); 63 TILE_GET_INFO_MEMBER(tile_info_0w); 64 TILE_GET_INFO_MEMBER(tile_info_1s); 65 TILE_GET_INFO_MEMBER(tile_info_1w); 66 67 void draw_rect(screen_device &screen, bitmap_ind16 &bm, bitmap_ind8 &tm, bitmap_ind16 &dm, const uint16_t *mask, 68 uint16_t tpri, uint8_t lpri, int win, int sx, int sy, int xx1, int yy1, int xx2, int yy2); 69 void draw_rect(screen_device &screen, bitmap_ind16 &bm, bitmap_ind8 &tm, bitmap_rgb32 &dm, const uint16_t *mask, 70 uint16_t tpri, uint8_t lpri, int win, int sx, int sy, int xx1, int yy1, int xx2, int yy2); 71 72 template<class BitmapClass> 73 void draw_common(screen_device &screen, BitmapClass &bitmap, const rectangle &cliprect, int layer, int pri, int flags); 74 75 devcb_write16 m_xhout_write_cb; 76 devcb_write16 m_xvout_write_cb; 77 }; 78 79 class segas24_sprite_device : public device_t 80 { 81 friend class segas24_sprite_config; 82 83 public: 84 segas24_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); 85 86 uint16_t read(offs_t offset); 87 void write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 88 89 void draw(bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, const int *spri); 90 91 protected: 92 virtual void device_start() override; 93 94 private: 95 std::unique_ptr<uint16_t[]> sprite_ram; 96 }; 97 98 99 class segas24_mixer_device : public device_t 100 { 101 friend class segas24_mixer_config; 102 103 public: 104 segas24_mixer_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock); 105 106 uint16_t read(offs_t offset); 107 void write(offs_t offset, uint16_t data, uint16_t mem_mask = ~0); 108 109 uint16_t get_reg(int reg); 110 111 protected: 112 virtual void device_start() override; 113 114 private: 115 uint16_t mixer_reg[16]; 116 }; 117 118 DECLARE_DEVICE_TYPE(S24TILE, segas24_tile_device) 119 DECLARE_DEVICE_TYPE(S24SPRITE, segas24_sprite_device) 120 DECLARE_DEVICE_TYPE(S24MIXER, segas24_mixer_device) 121 122 #endif // MAME_VIDEO_SEGAIC24_H 123