summaryrefslogblamecommitdiffstatshomepage
path: root/src/mame/video/k051316.h
blob: 7e984b015479e316100383beac0112fe0702e011 (plain) (tree)
1
2
3
4
5
6
7
8

                                                          


                            
            
 
 




                                                                                      
                                                                                                                                     

                                              
                                                                        

                                
                                                          
 
                                        
                                                                 

                                  
                                                            
 
 
                                                                   

       
                                                                                                        
 


                                            


                                           
                                               
 





                                                                                            
         

                                
         
 















                                                                                      
                                                                                                                          

                                           
                                                                                                                  
                                                            
 

                                 

                                             
 

                         

                                   
                          
 
                                                
 

                       
                              
                        
                                         
 


                                            
                                            
 
                              
// license:BSD-3-Clause
// copyright-holders:Fabio Priuli,Acho A. Tang, R. Belmont
#ifndef MAME_VIDEO_K051316_H
#define MAME_VIDEO_K051316_H

#pragma once


typedef device_delegate<void (int *code, int *color, int *flags)> k051316_cb_delegate;
#define K051316_CB_MEMBER(_name)   void _name(int *code, int *color, int *flags)


#define MCFG_K051316_CB(_class, _method) \
	downcast<k051316_device &>(*device).set_k051316_callback(k051316_cb_delegate(&_class::_method, #_class "::" #_method, this));

#define MCFG_K051316_OFFSETS(_xoffs, _yoffs) \
	downcast<k051316_device &>(*device).set_offsets(_xoffs, _yoffs);

#define MCFG_K051316_BPP(_bpp) \
	downcast<k051316_device &>(*device).set_bpp(_bpp);

#define MCFG_K051316_LAYER_MASK(_mask) \
	downcast<k051316_device &>(*device).set_layermask(_mask);

#define MCFG_K051316_WRAP(_wrap) \
	downcast<k051316_device &>(*device).set_wrap(_wrap);


class k051316_device : public device_t, public device_gfx_interface
{
public:
	k051316_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	static const gfx_layout charlayout4;
	static const gfx_layout charlayout7;
	static const gfx_layout charlayout8;
	DECLARE_GFXDECODE_MEMBER(gfxinfo);
	DECLARE_GFXDECODE_MEMBER(gfxinfo7);
	DECLARE_GFXDECODE_MEMBER(gfxinfo8);
	DECLARE_GFXDECODE_MEMBER(gfxinfo4_ram);

	// configuration
	void set_k051316_callback(k051316_cb_delegate callback) { m_k051316_cb = callback; }
	void set_wrap(int wrap) { m_wrap = wrap; }
	void set_bpp(int bpp);
	void set_layermask(int mask) { m_layermask = mask; }
	void set_offsets(int x_offset, int y_offset)
	{
		m_dx = x_offset;
		m_dy = y_offset;
	}

	/*
	The callback is passed:
	- code (range 00-FF, contents of the first tilemap RAM byte)
	- color (range 00-FF, contents of the first tilemap RAM byte). Note that bit 6
	  seems to be hardcoded as flip X.
	The callback must put:
	- in code the resulting tile number
	- in color the resulting color index
	- if necessary, put flags for the TileMap code in the tile_info
	  structure (e.g. TILE_FLIPX)
	*/

	DECLARE_READ8_MEMBER( read );
	DECLARE_WRITE8_MEMBER( write );
	DECLARE_READ8_MEMBER( rom_r );
	DECLARE_WRITE8_MEMBER( ctrl_w );
	void zoom_draw(screen_device &screen, bitmap_ind16 &bitmap,const rectangle &cliprect,int flags,uint32_t priority);
	void wraparound_enable(int status);

	void mark_gfx_dirty(offs_t byteoffset) { gfx(0)->mark_dirty(byteoffset * m_pixels_per_byte / (16 * 16)); }
	void mark_tmap_dirty() { m_tmap->mark_all_dirty(); }

protected:
	// device-level overrides
	virtual void device_start() override;
	virtual void device_reset() override;

private:
	// internal state
	std::vector<uint8_t> m_ram;
	uint8_t m_ctrlram[16];
	tilemap_t *m_tmap;

	optional_region_ptr<uint8_t> m_zoom_rom;

	int m_dx, m_dy;
	int m_wrap;
	int m_pixels_per_byte;
	int m_layermask;
	k051316_cb_delegate m_k051316_cb;

	TILE_GET_INFO_MEMBER(get_tile_info);
};

DECLARE_DEVICE_TYPE(K051316, k051316_device)

#endif // MAME_VIDEO_K051316_H