[RETURN]
GFXDECODE_START
種別:マクロ
場所:[src/emu/drawgfx.h](注:MAME内)

Code
#define GFXDECODE_START( name ) const gfx_decode_entry gfxdecodeinfo_##name[] = {

Description Sample
static GFXDECODE_START( apple2_gfxdecodeinfo )
        GFXDECODE_ENTRY( REGION_GFX1, 0x0000, apple2_text_layout, 0, 2 )
        GFXDECODE_ENTRY( REGION_GFX1, 0x0000, apple2_dbltext_layout, 0, 2 )
GFXDECODE_END
GFXDECODE_ENTRY
種別:マクロ
場所:[src/emu/drawgfx.h](注:MAME内)

Code
#define GFXDECODE_ENTRY(region,offset,layout,start,colors) { region, offset, &layout, start, colors, 0, 0 };

Description Sample
static GFXDECODE_START( apple2_gfxdecodeinfo )
        GFXDECODE_ENTRY( REGION_GFX1, 0x0000, apple2_text_layout, 0, 2 )
        GFXDECODE_ENTRY( REGION_GFX1, 0x0000, apple2_dbltext_layout, 0, 2 )
GFXDECODE_END
GFXDECODE_END
種別:マクロ
場所:[src/emu/drawgfx.h](注:MAME内)

Code
#define GFXDECODE_END { -1 } };

Description Sample
static GFXDECODE_START( apple2_gfxdecodeinfo )
        GFXDECODE_ENTRY( REGION_GFX1, 0x0000, apple2_text_layout, 0, 2 )
        GFXDECODE_ENTRY( REGION_GFX1, 0x0000, apple2_dbltext_layout, 0, 2 )
GFXDECODE_END
_gfx_layout
種別:構造体
場所:[src/emu/drawgfx.h](注:MAME内)

Code
struct _gfx_layout
{
	UINT16			width;				/* pixel width of each element */
	UINT16			height;				/* pixel height of each element */
	UINT32			total;				/* total number of elements, or RGN_FRAC() */
	UINT16			planes;				/* number of bitplanes */
	UINT32			planeoffset[MAX_GFX_PLANES]; /* bit offset of each bitplane */
	UINT32			xoffset[MAX_GFX_SIZE]; /* bit offset of each horizontal pixel */
	UINT32			yoffset[MAX_GFX_SIZE]; /* bit offset of each vertical pixel */
	UINT32			charincrement;		/* distance between two consecutive elements (in bits) */
	const UINT32 *	extxoffs;			/* extended X offset array for really big layouts */
	const UINT32 *	extyoffs;			/* extended Y offset array for really big layouts */
};

Description Sample
static const gfx_layout apple2_text_layout =
{
	14,8,		/* 14*8 characters */
	256,		/* 256 characters */
	1,			/* 1 bits per pixel */
	{ 0 },		/* no bitplanes; 1 bit per pixel */
	{ 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7 },   /* x offsets */
	{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
	8*8			/* every char takes 8 bytes */
};
INTERRUPT_GEN
種別:マクロ
場所:[src/emu/cpuint.h](注:MAME内)

Code
#define INTERRUPT_GEN(func)		void func(void)

Description Sample
INTERRUPT_GEN( pc8801_interrupt )
{
	pc8801_raise_interrupt(1);
}
TIMER_CALLBACK
種別:マクロ
場所:[src/emu/timer.h](注:MAME内)

Code
#define TIMER_CALLBACK(name)			void name(running_machine *machine, void *ptr, int param)

Description Sample
static TIMER_CALLBACK(pc8801_timer_interrupt)
{
	pc8801_raise_interrupt(2);
}

Comment
TIMERによってコールバックされる関数作成用のマクロ
TIMERコールバック関連の関数であることをパッと見分かりやすくする程度の御利益
実際にコールバックさせるには、timer_alloc関数やtimer_pulse関数で設定を行う必要がある
CPU_VBLANK_INT
種別:マクロ
場所:[src/driver.h](注:MAME内)

Code
#define MDRV_CPU_VBLANK_INT(func, rate)
	if (cpu)	{
		cpu->vblank_interrupt = func;
		cpu->vblank_interrupts_per_frame = (rate);
	}

Description Sample
	MDRV_CPU_VBLANK_INT(pc8801_interrupt,1)
ADDRESS_MAP_START
種別:マクロ
場所:[src/memory.h](注:MAME内)

Code
#define ADDRESS_MAP_START(_name,_space,_bits)							\
address_map *construct_map_##_name(address_map *map)					\
{																		\
	typedef read##_bits##_handler _rh_t;								\
	typedef write##_bits##_handler _wh_t;								\
	_rh_t read;															\
	_wh_t write;														\
	UINT##_bits **base;													\
																		\
	(void)read; (void)write; (void)base;								\
	map->flags = AM_FLAGS_EXTENDED;										\
	map->start = AMEF_DBITS(_bits) | AMEF_SPACE(_space);				\

Description Sample
ADDRESS_MAP_START( pc8801_mem , ADDRESS_SPACE_PROGRAM, 8)
    AM_RANGE(0x0000, 0x5fff) AM_RAMBANK(1)
    AM_RANGE(0x6000, 0x7fff) AM_RAMBANK(2)
    AM_RANGE(0x8000, 0x83ff) AM_RAMBANK(3)
    AM_RANGE(0x8400, 0xbfff) AM_RAMBANK(4)
    AM_RANGE(0xc000, 0xefff) AM_RAMBANK(5)
    AM_RANGE(0xf000, 0xffff) AM_RAMBANK(6)
ADDRESS_MAP_END
AM_READWRITE
種別:マクロ
場所:[src/memory.h](注:MAME内)

Code
#define AM_READWRITE(_read,_write)			AM_READ(_read) AM_WRITE(_write)

Description Sample
	AM_RANGE(0x44, 0x44) AM_READWRITE( YM2203_status_port_0_r, YM2203_control_port_0_w )
	AM_RANGE(0x45, 0x45) AM_READWRITE( YM2203_read_port_0_r, YM2203_write_port_0_w )
AM_READ
種別:マクロ
場所:[src/memory.h](注:MAME内)

Code
#define AM_READ(_handler)												\
	map->read.handler = (genf *)(read = _handler);						\
	map->read_name = #_handler;

Description Sample
	AM_RANGE(0x5c, 0x5c) AM_READ( pc8801_vramtest )
AM_WRITE
種別:マクロ
場所:[src/memory.h](注:MAME内)

Code
#define AM_WRITE(_handler)												\
	map->write.handler = (genf *)(write = _handler);					\
	map->write_name = #_handler;

Description Sample
	AM_RANGE(0x5c, 0x5f) AM_WRITE( pc8801_vramsel )
_running_machine
種別:構造体
場所:[src/emu/mame.h](注:MAME内)

Code
struct _running_machine
{
	/* game-related information */
	const game_driver *		gamedrv;			/* points to the definition of the game machine */
	const machine_config *	drv;				/* points to the constructed machine_config */
	const char *			basename;			/* basename used for game-related paths */

	/* video-related information */
	gfx_element *			gfx[MAX_GFX_ELEMENTS];/* array of pointers to graphic sets (chars, sprites) */
	screen_state			screen[MAX_SCREENS];/* current screen state */
	palette_t *				palette;			/* global palette object */

	/* palette-related information */
/* fix me - some games try to modify remapped_colortable directly */
/* search for "palette hack" to find instances */
	const pen_t *			pens;				/* remapped palette pen numbers */
	struct _colortable_t *	colortable;			/* global colortable for remapping */
	const UINT16 *			game_colortable;	/* lookup table used to map gfx pen numbers to color numbers */
	const pen_t *			remapped_colortable;/* the above, already remapped through Machine->pens */
	pen_t *					shadow_table;		/* table for looking up a shadowed pen */

	/* audio-related information */
	int						sample_rate;		/* the digital audio sample rate */

	/* input-related information */
	input_port_entry *		input_ports;		/* the input ports definition from the driver is copied here and modified */
	mame_file *				record_file;		/* recording file (NULL if not recording) */
	mame_file *				playback_file;		/* playback file (NULL if not recording) */

	/* debugger-related information */
	int						debug_mode;			/* was debug mode enabled? */

	/* MESS-specific information */
#ifdef MESS
	struct IODevice *		devices;
#endif /* MESS */

	/* internal core information */
	mame_private *			mame_data;			/* internal data from mame.c */
	video_private *			video_data;			/* internal data from video.c */
	palette_private *		palette_data;		/* internal data from palette.c */
	streams_private *		streams_data;		/* internal data from streams.c */
	devices_private *		devices_data;		/* internal data from devices.c */

	/* driver-specific information */
	void *					driver_data;		/* drivers can hang data off of here instead of using globals */
};

Description Sample
typedef struct _running_machine running_machine; (mamecore.h)
running_machine *Machine; (mame.c)
AM_RANGE
種別:マクロ
場所:[src/emu/mame.h](注:MAME内)

Code
#define AM_RANGE(_start,_end)											\
	map++;																\
	map->flags = 0;														\
	map->start = (_start);												\
	map->end = (_end);

Description Sample
ADDRESS_MAP_START( pc8801_mem , ADDRESS_SPACE_PROGRAM, 8)
    AM_RANGE(0x0000, 0x5fff) AM_RAMBANK(1)
    AM_RANGE(0x6000, 0x7fff) AM_RAMBANK(2)
    AM_RANGE(0x8000, 0x83ff) AM_RAMBANK(3)
    AM_RANGE(0x8400, 0xbfff) AM_RAMBANK(4)
    AM_RANGE(0xc000, 0xefff) AM_RAMBANK(5)
    AM_RANGE(0xf000, 0xffff) AM_RAMBANK(6)
ADDRESS_MAP_END
AM_RAMBANK
種別:マクロ
場所:[src/emu/mame.h](注:MAME内)

Description Sample
#define AM_RAMBANK(_bank)					AM_READWRITE((_rh_t)(STATIC_BANK1 + (_bank) - 1), (_wh_t)(STATIC_BANK1 + (_bank) - 1))

Description Sample
ADDRESS_MAP_START( pc8801_mem , ADDRESS_SPACE_PROGRAM, 8)
    AM_RANGE(0x0000, 0x5fff) AM_RAMBANK(1)
    AM_RANGE(0x6000, 0x7fff) AM_RAMBANK(2)
    AM_RANGE(0x8000, 0x83ff) AM_RAMBANK(3)
    AM_RANGE(0x8400, 0xbfff) AM_RAMBANK(4)
    AM_RANGE(0xc000, 0xefff) AM_RAMBANK(5)
    AM_RANGE(0xf000, 0xffff) AM_RAMBANK(6)
ADDRESS_MAP_END
_emu_timer
種別:構造体
場所:[src/emu/timer.c](注:MAME内)

Code
struct _emu_timer
{
	emu_timer *	next;
	emu_timer *	prev;
	void 			(*callback)(running_machine *, int);
	void			(*callback_ptr)(running_machine *, void *);
	int 			callback_param;
	void *			callback_ptr_param;
	const char *	file;
	int 			line;
	const char *	func;
	UINT8 			enabled;
	UINT8 			temporary;
	UINT8			ptr;
	attotime 		period;
	attotime 		start;
	attotime 		expire;
};

Description Sample
typedef struct _emu_timer emu_timer; (timer.h)
timer_new(void)
種別:関数
場所:[src/emu/timer.c](注:MAME内)

Code
INLINE emu_timer *timer_new(void)
{
	emu_timer *timer;

	/* remove an empty entry */
	if (!timer_free_head)
	{
		timer_logtimers();
		fatalerror("Out of timers!");
	}
	timer = timer_free_head;
	timer_free_head = timer->next;
	if (!timer_free_head)
		timer_free_tail = NULL;

	return timer;
}

Description Sample
emu_timer *timer = timer_new(); (timer.c)

Comment
emu_timer構造体へのポインタ変数を新規生成する。
emu_timer構造体の数がMAX_TIMERSの値を超えている場合、
ポインタ変数を生成せず、エラーメッセージを出力する。
_timer_alloc_common関数から呼び出される。
INPUT_PORTS_START
種別:マクロ
場所:[src/emu/inptport.h](注:MAME内)

Code
#define INPUT_PORTS_START(name) \
	const input_port_token ipt_##name[] = {

Description Sample
static INPUT_PORTS_START( pc88sr )
	/* [0] */
	PORT_START
	PORT_BIT (0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("pad 0") PORT_CODE(KEYCODE_0_PAD) PORT_CHAR(UCHAR_MAMEKEY(0_PAD))
	PORT_BIT (0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("pad 1") PORT_CODE(KEYCODE_1_PAD) PORT_CHAR(UCHAR_MAMEKEY(1_PAD))
	PORT_BIT (0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("pad 2") PORT_CODE(KEYCODE_2_PAD) PORT_CHAR(UCHAR_MAMEKEY(2_PAD))
	PORT_BIT (0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("pad 3") PORT_CODE(KEYCODE_3_PAD) PORT_CHAR(UCHAR_MAMEKEY(3_PAD))
	PORT_BIT (0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("pad 4") PORT_CODE(KEYCODE_4_PAD) PORT_CHAR(UCHAR_MAMEKEY(4_PAD))
	PORT_BIT (0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("pad 5") PORT_CODE(KEYCODE_5_PAD) PORT_CHAR(UCHAR_MAMEKEY(5_PAD))
	PORT_BIT (0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("pad 6") PORT_CODE(KEYCODE_6_PAD) PORT_CHAR(UCHAR_MAMEKEY(6_PAD))
	PORT_BIT (0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("pad 7") PORT_CODE(KEYCODE_7_PAD) PORT_CHAR(UCHAR_MAMEKEY(7_PAD))
INPUT_PORTS_END
INTERRUPT_GEN
種別:構造体
場所:[src/emu/cpuint.h](注:MAME内)

Code
#define INTERRUPT_GEN(func)		void func(void)

Description Sample
static INTERRUPT_GEN( pc8801fd_interrupt )
{
}
MDRV_CPU_VBLANK_INT(pc8801fd_interrupt,1)
ROM_START
種別:構造体
場所:[src/emu/cpuint.h](注:MAME内)

Code
#define ROM_START(name)								static const rom_entry rom_##name[] = {

Description Sample
ROM_START (pc88srl)
	ROM_REGION(0x18000,REGION_CPU1,0)
	ROM_LOAD ("n80.rom", 0x00000, 0x8000, CRC(27e1857d) SHA1(5b922ed9de07d2a729bdf1da7b57c50ddf08809a))
	ROM_LOAD ("n88.rom", 0x08000, 0x8000, CRC(a0fc0473) SHA1(3b31fc68fa7f47b21c1a1cb027b86b9e87afbfff))
	ROM_LOAD ("n88_0.rom", 0x10000, 0x2000, CRC(710a63ec) SHA1(d239c26ad7ac5efac6e947b0e9549b1534aa970d))
	ROM_LOAD ("n88_1.rom", 0x12000, 0x2000, CRC(c0bd2aa6) SHA1(8528eef7946edf6501a6ccb1f416b60c64efac7c))
	ROM_LOAD ("n88_2.rom", 0x14000, 0x2000, CRC(af2b6efa) SHA1(b7c8bcea219b77d9cc3ee0efafe343cc307425d1))
	ROM_LOAD ("n88_3.rom", 0x16000, 0x2000, CRC(7713c519) SHA1(efce0b51cab9f0da6cf68507757f1245a2867a72))
	ROM_REGION(0x10000,REGION_CPU2,0)
	ROM_LOAD ("disk.rom", 0x0000, 0x0800, CRC(2158d307) SHA1(bb7103a0818850a039c67ff666a31ce49a8d516f))
	ROM_REGION(0x40000,REGION_GFX1,0)
	ROM_LOAD ("kanji1.rom", 0x00000, 0x20000, CRC(6178bd43) SHA1(82e11a177af6a5091dd67f50a2f4bafda84d6556))
	ROM_LOAD ("kanji2.rom", 0x20000, 0x20000, CRC(154803cc) SHA1(7e6591cd465cbb35d6d3446c5a83b46d30fafe95))
ROM_END
memory_set_bankptr
種別:関数
場所:[src/emu/memory.c](注:MAME内)

Code
void memory_set_bankptr(int banknum, void *base)
{
	/* validation checks */
	if (banknum < STATIC_BANK1 || banknum > MAX_EXPLICIT_BANKS || !bankdata[banknum].used)
		fatalerror("memory_set_bankptr called with invalid bank %d", banknum);
	if (bankdata[banknum].dynamic)
		fatalerror("memory_set_bankptr called with dynamic bank %d", banknum);
	if (base == NULL)
		fatalerror("memory_set_bankptr called NULL base");
	if (ALLOW_ONLY_AUTO_MALLOC_BANKS)
		validate_auto_malloc_memory(base, bankdata[banknum].end - bankdata[banknum].base + 1);

	/* set the base */
	bank_ptr[banknum] = base;

	/* if we're executing out of this bank, adjust the opbase pointer */
	if (opcode_entry == banknum && cpu_getactivecpu() >= 0)
	{
		opcode_entry = 0xff;
		memory_set_opbase(activecpu_get_physical_pc_byte());
	}
}

Description Sample
memory_set_bankptr(1, ext_r + 0x0000);
z80ctc_interface
種別:関数
場所:[src/emu/machine/z80ctc.h](注:MAME内)

Code
typedef struct
{
	int baseclock;                       /* timer clock */
	int notimer;                         /* timer disablers */
	void (*intr)(int which);             /* callback when change interrupt status */
	write8_handler zc0;                  /* ZC/TO0 callback */
	write8_handler zc1;                  /* ZC/TO1 callback */
	write8_handler zc2;                  /* ZC/TO2 callback */
} z80ctc_interface;

Description Sample
static z80ctc_interface	sord_m5_ctc_intf =
{
	3800000,
	0,
	sord_m5_ctc_interrupt,
	0,
	0,
	0
};
_mess_image
種別:構造体
場所:[src/emu/image.c](注:MAME内)

Code
struct _mess_image
{
	/* variables that persist across image mounts */
	tag_pool tagpool;
	object_pool *mempool;
	const struct IODevice *dev;

	/* error related info */
	image_error_t err;
	char *err_message;

	/* variables that are only non-zero when an image is mounted */
	core_file *file;
	char *name;
	char *dir;
	char *hash;
	char *basename_noext;
	
	/* flags */
	unsigned int writeable : 1;
	unsigned int created : 1;
	unsigned int is_loading : 1;

	/* info read from the hash file */
	char *longname;
	char *manufacturer;
	char *year;
	char *playable;
	char *extrainfo;

	/* working directory; persists across mounts */
	char *working_directory;

	/* pointer */
	void *ptr;
};

Code
void floppy_drive_set_motor_state(mess_image *img, int state)
{
	int new_motor_state = 0;
	int previous_state = 0;

	/* previous state */
	if (floppy_drive_get_flag_state(img, FLOPPY_DRIVE_MOTOR_ON))
		previous_state = 1;

	/* calc new state */

	/* drive present? */
	if (image_slotexists(img))
	{
		/* disk inserted? */
		if (image_exists(img))
		{
			/* drive present and disc inserted */

			/* state of motor is same as the programmed state */
			if (state)
			{
				new_motor_state = 1;
			}
		}
	}

	if ((new_motor_state^previous_state)!=0)
	{
		/* if timer already setup remove it */
		if (image_slotexists(img))
		{
			struct floppy_drive *pDrive = get_drive(img);

			pDrive->index = 0;
			if (new_motor_state)
			{
				/* off->on */
				/* check it's in range */

				/* setup timer to trigger at rpm */
				floppy_drive_index_callback(Machine, (void*)img);
			}
			else
			{
				/* on->off */
				timer_adjust_ptr(pDrive->index_timer, attotime_zero, attotime_zero);
			}
		}
	}

	floppy_drive_set_flag_state(img, FLOPPY_DRIVE_MOTOR_ON, new_motor_state);

}
devices_init
種別:関数
場所:[src/mess/mess.c]

Code
void devices_init(running_machine *machine)
{
	const struct IODevice *dev;
	int id;
	int result = INIT_FAIL;
	const char *image_name;
	mess_image *image;

	/* initialize natural keyboard support */
	inputx_init();

	/* allocate the IODevice struct */
	machine->devices = (struct IODevice *) devices_allocate(machine->gamedrv);
	if (!machine->devices)
		fatalerror_exitcode(MAMERR_DEVICE, "devices_allocate() failed");
	add_exit_callback(machine, devices_exit);

	/* initialize RAM code */
	ram_init(machine->gamedrv);

	/* init all devices */
	image_init();

	/* make sure that any required devices have been allocated */
	for (dev = machine->devices; dev->type < IO_COUNT; dev++)
	{
		for (id = 0; id < dev->count; id++)
		{
			/* identify the image */
			image = image_from_device_and_index(dev, id);

			/* is an image specified for this image */
			image_name = mess_get_device_option(&dev->devclass, id);
			if ((image_name != NULL) && (image_name[0] != '\0'))
			{
				/* try to load this image */
				result = image_load(image, image_name);

				/* did the image load fail? */
				if (result)
				{
					fatalerror_exitcode(MAMERR_DEVICE, "Device %s load (%s) failed: %s\n",
						device_typename(dev->type),
						osd_basename((char *) image_name),
						image_error(image));
				}
			}
			else
			{
				/* no image... must this device be loaded? */
				if (dev->must_be_loaded)
				{
					fatalerror_exitcode(MAMERR_DEVICE, "Driver requires that device %s must have an image to load\n", device_typename(dev->type));
				}
			}
		}
	}
}

Description Sample
[RETURN]