summaryrefslogblamecommitdiffstatshomepage
path: root/src/mame/video/segaic24.h
blob: 6073a0f71c095bc69101cd926d6502f989023155 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11

                                     




                        



                             


                                                  
                                                                          






                                           
                                                   
                                      
 





                                                                                                   
 
                                                                        


                                         
       
                                                                                                             
 
                        
                                                                           
 



                                       

                                        
 

                                                                                                                         
 

                                                                                                                                                     
 
          
                                             
 




                                    

                                             

                                 
                           


                                            
                                                                                         



                                           
 



                                                                                                                                  
 
                                    
                                                                                                                                
 

                                       

  
                                             


                                           
       
                                                                                                               
 


                                      
                                                                                                                  

          
                                             
 
        
                                               


  
                                            


                                          
       
                                                                                                              
 


                                      
                                  

          
                                             
 
        
                               

  


                                                     
 
                               
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
/*
  Sega system24 hardware

*/

#ifndef MAME_VIDEO_SEGAIC24_H
#define MAME_VIDEO_SEGAIC24_H

#pragma once

#define MCFG_S24TILE_DEVICE_ADD(_tag, tile_mask) \
	MCFG_DEVICE_ADD(_tag, S24TILE, 0) \
	downcast<segas24_tile_device &>(*device).set_tile_mask(tile_mask);

#define MCFG_S24SPRITE_DEVICE_ADD(_tag) \
	MCFG_DEVICE_ADD(_tag, S24SPRITE, 0)

#define MCFG_S24MIXER_DEVICE_ADD(_tag) \
	MCFG_DEVICE_ADD(_tag, S24MIXER, 0)

#define MCFG_S24TILE_DEVICE_PALETTE(_palette_tag) \
	MCFG_GFX_PALETTE(_palette_tag)

#define MCFG_S24TILE_XHOUT_CALLBACK(_write) \
	devcb = &downcast<segas24_tile_device &>(*device).set_xhout_write_callback(DEVCB_##_write);

#define MCFG_S24TILE_XVOUT_CALLBACK(_write) \
	devcb = &downcast<segas24_tile_device &>(*device).set_xvout_write_callback(DEVCB_##_write);


class segas24_tile_device : public device_t, public device_gfx_interface
{
	friend class segas24_tile_config;

public:
	segas24_tile_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	// configuration
	void set_tile_mask(uint16_t _tile_mask) { tile_mask = _tile_mask; }

	DECLARE_READ16_MEMBER(tile_r);
	DECLARE_WRITE16_MEMBER(tile_w);
	DECLARE_READ16_MEMBER(char_r);
	DECLARE_WRITE16_MEMBER(char_w);
	DECLARE_WRITE16_MEMBER(xhout_w);
	DECLARE_WRITE16_MEMBER(xvout_w);

	void draw(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, int layer, int pri, int flags);
	void draw(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect, int layer, int pri, int flags);

	template <class Object> devcb_base &set_xhout_write_callback(Object &&cb) { return m_xhout_write_cb.set_callback(std::forward<Object>(cb)); }
	template <class Object> devcb_base &set_xvout_write_callback(Object &&cb) { return m_xvout_write_cb.set_callback(std::forward<Object>(cb)); }

protected:
	virtual void device_start() override;

private:
	enum {
		SYS24_TILES = 0x4000
	};

	std::unique_ptr<uint16_t[]> char_ram;
	std::unique_ptr<uint16_t[]> tile_ram;
	int char_gfx_index;
	tilemap_t *tile_layer[4];
	uint16_t tile_mask;

	static const gfx_layout char_layout;

	void tile_info(int offset, tile_data &tileinfo, tilemap_memory_index tile_index);
	TILE_GET_INFO_MEMBER(tile_info_0s);
	TILE_GET_INFO_MEMBER(tile_info_0w);
	TILE_GET_INFO_MEMBER(tile_info_1s);
	TILE_GET_INFO_MEMBER(tile_info_1w);

	void draw_rect(screen_device &screen, bitmap_ind16 &bm, bitmap_ind8 &tm, bitmap_ind16 &dm, const uint16_t *mask,
					uint16_t tpri, uint8_t lpri, int win, int sx, int sy, int xx1, int yy1, int xx2, int yy2);
	void draw_rect(screen_device &screen, bitmap_ind16 &bm, bitmap_ind8 &tm, bitmap_rgb32 &dm, const uint16_t *mask,
					uint16_t tpri, uint8_t lpri, int win, int sx, int sy, int xx1, int yy1, int xx2, int yy2);

	template<class _BitmapClass>
	void draw_common(screen_device &screen, _BitmapClass &bitmap, const rectangle &cliprect, int layer, int pri, int flags);

	devcb_write16 m_xhout_write_cb;
	devcb_write16 m_xvout_write_cb;
};

class segas24_sprite_device : public device_t
{
	friend class segas24_sprite_config;

public:
	segas24_sprite_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	DECLARE_READ16_MEMBER(read);
	DECLARE_WRITE16_MEMBER(write);

	void draw(bitmap_ind16 &bitmap, const rectangle &cliprect, bitmap_ind8 &priority_bitmap, const int *spri);

protected:
	virtual void device_start() override;

private:
	std::unique_ptr<uint16_t[]> sprite_ram;
};


class segas24_mixer_device : public device_t
{
	friend class segas24_mixer_config;

public:
	segas24_mixer_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	DECLARE_READ16_MEMBER(read);
	DECLARE_WRITE16_MEMBER(write);

	uint16_t get_reg(int reg);

protected:
	virtual void device_start() override;

private:
	uint16_t mixer_reg[16];
};

DECLARE_DEVICE_TYPE(S24TILE,   segas24_tile_device)
DECLARE_DEVICE_TYPE(S24SPRITE, segas24_sprite_device)
DECLARE_DEVICE_TYPE(S24MIXER,  segas24_mixer_device)

#endif // MAME_VIDEO_SEGAIC24_H