summaryrefslogtreecommitdiffstats
path: root/src/mame/drivers/mitchell.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mame/drivers/mitchell.cpp')
-rw-r--r--src/mame/drivers/mitchell.cpp210
1 files changed, 110 insertions, 100 deletions
diff --git a/src/mame/drivers/mitchell.cpp b/src/mame/drivers/mitchell.cpp
index 18c14d502fa..390b0f5413b 100644
--- a/src/mame/drivers/mitchell.cpp
+++ b/src/mame/drivers/mitchell.cpp
@@ -315,70 +315,76 @@ WRITE8_MEMBER(mitchell_state::input_w)
*
*************************************/
-ADDRESS_MAP_START(mitchell_state::mgakuen_map)
- AM_RANGE(0x0000, 0x7fff) AM_ROM
- AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
- AM_RANGE(0xc000, 0xc7ff) AM_RAM_DEVWRITE("palette", palette_device, write8) /* palette RAM */
- AM_RANGE(0xc800, 0xcfff) AM_READWRITE(pang_colorram_r, pang_colorram_w) AM_SHARE("colorram") /* Attribute RAM */
- AM_RANGE(0xd000, 0xdfff) AM_READWRITE(mgakuen_videoram_r, mgakuen_videoram_w) AM_SHARE("videoram") /* char RAM */
- AM_RANGE(0xe000, 0xefff) AM_RAM /* Work RAM */
- AM_RANGE(0xf000, 0xffff) AM_READWRITE(mgakuen_objram_r, mgakuen_objram_w) /* OBJ RAM */
-ADDRESS_MAP_END
-
-ADDRESS_MAP_START(mitchell_state::mitchell_map)
- AM_RANGE(0x0000, 0x7fff) AM_ROM
- AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
- AM_RANGE(0xc000, 0xc7ff) AM_READWRITE(pang_paletteram_r,pang_paletteram_w) /* Banked palette RAM */
- AM_RANGE(0xc800, 0xcfff) AM_READWRITE(pang_colorram_r,pang_colorram_w) AM_SHARE("colorram") /* Attribute RAM */
- AM_RANGE(0xd000, 0xdfff) AM_READWRITE(pang_videoram_r,pang_videoram_w) AM_SHARE("videoram")/* Banked char / OBJ RAM */
- AM_RANGE(0xe000, 0xffff) AM_RAM AM_SHARE("nvram") /* Work RAM */
-ADDRESS_MAP_END
-
-ADDRESS_MAP_START(mitchell_state::decrypted_opcodes_map)
- AM_RANGE(0x0000, 0x7fff) AM_ROMBANK("bank0d")
- AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1d")
- AM_RANGE(0xe000, 0xffff) AM_RAM AM_SHARE("nvram") /* Work RAM */
-ADDRESS_MAP_END
-
-ADDRESS_MAP_START(mitchell_state::mitchell_io_map)
- ADDRESS_MAP_GLOBAL_MASK(0xff)
- AM_RANGE(0x00, 0x00) AM_WRITE(pang_gfxctrl_w) /* Palette bank, layer enable, coin counters, more */
- AM_RANGE(0x00, 0x02) AM_READ(input_r) /* The Mahjong games and Block Block need special input treatment */
- AM_RANGE(0x01, 0x01) AM_WRITE(input_w)
- AM_RANGE(0x02, 0x02) AM_WRITE(pang_bankswitch_w) /* Code bank register */
- AM_RANGE(0x03, 0x03) AM_DEVWRITE("ymsnd", ym2413_device, data_port_w)
- AM_RANGE(0x04, 0x04) AM_DEVWRITE("ymsnd", ym2413_device, register_port_w)
- AM_RANGE(0x05, 0x05) AM_READ(pang_port5_r) AM_DEVWRITE("oki", okim6295_device, write)
- AM_RANGE(0x06, 0x06) AM_NOP /* watchdog? IRQ ack? video buffering? */
- AM_RANGE(0x07, 0x07) AM_WRITE(pang_video_bank_w) /* Video RAM bank register */
- AM_RANGE(0x08, 0x08) AM_WRITE(eeprom_cs_w)
- AM_RANGE(0x10, 0x10) AM_WRITE(eeprom_clock_w)
- AM_RANGE(0x18, 0x18) AM_WRITE(eeprom_serial_w)
-ADDRESS_MAP_END
+void mitchell_state::mgakuen_map(address_map &map)
+{
+ map(0x0000, 0x7fff).rom();
+ map(0x8000, 0xbfff).bankr("bank1");
+ map(0xc000, 0xc7ff).ram().w(m_palette, FUNC(palette_device::write8)); /* palette RAM */
+ map(0xc800, 0xcfff).rw(this, FUNC(mitchell_state::pang_colorram_r), FUNC(mitchell_state::pang_colorram_w)).share("colorram"); /* Attribute RAM */
+ map(0xd000, 0xdfff).rw(this, FUNC(mitchell_state::mgakuen_videoram_r), FUNC(mitchell_state::mgakuen_videoram_w)).share("videoram"); /* char RAM */
+ map(0xe000, 0xefff).ram(); /* Work RAM */
+ map(0xf000, 0xffff).rw(this, FUNC(mitchell_state::mgakuen_objram_r), FUNC(mitchell_state::mgakuen_objram_w)); /* OBJ RAM */
+}
+
+void mitchell_state::mitchell_map(address_map &map)
+{
+ map(0x0000, 0x7fff).rom();
+ map(0x8000, 0xbfff).bankr("bank1");
+ map(0xc000, 0xc7ff).rw(this, FUNC(mitchell_state::pang_paletteram_r), FUNC(mitchell_state::pang_paletteram_w)); /* Banked palette RAM */
+ map(0xc800, 0xcfff).rw(this, FUNC(mitchell_state::pang_colorram_r), FUNC(mitchell_state::pang_colorram_w)).share("colorram"
// license:BSD-3-Clause
// copyright-holders:Couriersud, Olivier Galibert, R. Belmont
//============================================================
//
//  draw13.h - SDL 2.0 drawing implementation
//
//  SDLMAME by Olivier Galibert and R. Belmont
//
//============================================================

#pragma once

#ifndef __DRAW13__
#define __DRAW13__

// OSD headers
#ifndef OSD_WINDOWS
#include "osdsdl.h"
#include "window.h"
#else
#include "../windows/window.h"
typedef UINT64 HashT;
#endif

// standard SDL headers
#include "sdl/sdlinc.h"

struct quad_setup_data
{
	quad_setup_data()
		: dudx(0)
		, dvdx(0)
		, dudy(0)
		, dvdy(0)
		, startu(0)
		, startv(0)
		, rotwidth(0)
		, rotheight(0)
	{
	}

	void compute(const render_primitive &prim, const int prescale);

	INT32   dudx, dvdx, dudy, dvdy;
	INT32   startu, startv;
	INT32   rotwidth, rotheight;
};

//============================================================
//  Textures
//============================================================

class renderer_sdl1;
struct copy_info_t;

/* texture_info holds information about a texture */
class texture_info
{
	friend class simple_list<texture_info>;
public:
	texture_info(renderer_sdl1 *renderer, const render_texinfo &texsource, const quad_setup_data &setup, const UINT32 flags);
	~texture_info();

	void set_data(const render_texinfo &texsource, const UINT32 flags);
	void render_quad(const render_primitive *prim, const int x, const int y);
	bool matches(const render_primitive &prim, const quad_setup_data &setup);

	copy_info_t *compute_size_type();

	void                *m_pixels;            // pixels for the texture
	int                 m_pitch;

	copy_info_t         *m_copyinfo;
	quad_setup_data     m_setup;

	osd_ticks_t         m_last_access;

	int raw_width() const { return m_texinfo.width; }
	int raw_height() const { return m_texinfo.height; }

	texture_info *next() { return m_next; }
	const render_texinfo &texinfo() const { return m_texinfo; }
	render_texinfo &texinfo() { return m_texinfo; }

	HashT hash() const { return m_hash; }
	UINT32 flags() const { return m_flags; }
	// FIXME:
	bool is_pixels_owned() const;

private:
	void set_coloralphamode(SDL_Texture *texture_id, const render_color *color);

	Uint32              m_sdl_access;
	renderer_sdl1 *     m_renderer;
	render_texinfo      m_texinfo;            // copy of the texture info
	HashT               m_hash;               // hash value for the texture (must be >= pointer size)
	UINT32              m_flags;              // rendering flags

	SDL_Texture *       m_texture_id;
	bool                m_is_rotated;

	int                 m_format;             // texture format
	SDL_BlendMode       m_sdl_blendmode;

	texture_info *      m_next;               // next texture in the list
};

//============================================================
//  TEXCOPY FUNCS
//============================================================

enum SDL_TEXFORMAT_E
{
	SDL_TEXFORMAT_ARGB32 = 0,
	SDL_TEXFORMAT_RGB32,
	SDL_TEXFORMAT_RGB32_PALETTED,
	SDL_TEXFORMAT_YUY16,
	SDL_TEXFORMAT_YUY16_PALETTED,
	SDL_TEXFORMAT_PALETTE16,
	SDL_TEXFORMAT_RGB15,
	SDL_TEXFORMAT_RGB15_PALETTED,
	SDL_TEXFORMAT_PALETTE16A,
	SDL_TEXFORMAT_PALETTE16_ARGB1555,
	SDL_TEXFORMAT_RGB15_ARGB1555,
	SDL_TEXFORMAT_RGB15_PALETTED_ARGB1555,
	SDL_TEXFORMAT_LAST = SDL_TEXFORMAT_RGB15_PALETTED_ARGB1555
};

#include "blit13.h"

struct copy_info_t
{
	int                 src_fmt;
	Uint32              dst_fmt;
	const blit_base     *blitter;
	Uint32              bm_mask;
	const char          *srcname;
	const char          *dstname;
	/* Statistics */
	UINT64              pixel_count;
	INT64               time;
	int                 samples;
	int                 perf;
	/* list */
	copy_info_t           *next;
};

/* sdl_info is the information about SDL for the current screen */
class renderer_sdl1 : public osd_renderer
{
public:
	renderer_sdl1(osd_window *window, int extra_flags);

	virtual ~renderer_sdl1()
	{
		destroy_all_textures();
		SDL_DestroyRenderer(m_sdl_renderer);
		m_sdl_renderer = nullptr;
	}

	static bool init(running_machine &machine);
	static void exit();

	virtual int create() override;
	virtual int draw(const int update) override;
	virtual int xy_to_render_target(const int x, const int y, int *xt, int *yt) override;
	virtual render_primitive_list *get_primitives() override;

	int RendererSupportsFormat(Uint32 format, Uint32 access, const char *sformat);

	SDL_Renderer *  m_sdl_renderer;

	static copy_info_t* s_blit_info[SDL_TEXFORMAT_LAST+1];

private:
	void expand_copy_info(const copy_info_t *list);
	void add_list(copy_info_t **head, const copy_info_t *element, Uint32 bm);

	void render_quad(texture_info *texture, const render_primitive *prim, const int x, const int y);

	texture_info *texture_find(const render_primitive &prim, const quad_setup_data &setup);
	texture_info *texture_update(const render_primitive &prim);

	void destroy_all_textures();

	INT32           m_blittimer;


	simple_list<texture_info>  m_texlist;                // list of active textures

	float           m_last_hofs;
	float           m_last_vofs;

	int             m_width;
	int             m_height;

	osd_dim         m_blit_dim;

	struct
	{
		Uint32  format;
		int     status;
	} fmt_support[30];

	// Stats
	INT64           m_last_blit_time;
	INT64           m_last_blit_pixels;

	static bool s_blit_info_initialized;
	static const copy_info_t s_blit_info_default[];
};

#endif // __DRAW13__