Remove template code generators

This commit is contained in:
angelosa 2021-11-29 16:33:58 +01:00
parent c58bbf1c89
commit f7930b625c
8 changed files with 0 additions and 679 deletions

View File

@ -1,39 +0,0 @@
/*! @file doxy_driver.h
@license BSD-3-Clause
@copyright Angelo Salese & the MAME team
@basehw 4enraya
Main CPU: Z80
Sound Chip: AY8910
@memmap 4enraya,Z80
0x0000-0xbfff ROM
0xc000-0xcfff work RAM
0xd000-0xdfff VRAM mirrored write,
tilemap offset = address & 0x3ff
tile number = bits 0-7 = data, bits 8,9 = address bits 10,11
0xe000-0xefff VRAM mirror
0xf000-0xffff NOP
@iomap 4enraya,Z80
0x00-0x00 R dip-switches
0x01-0x01 R inputs
0x02-0x02 R system inputs
0x23-0x23 W ay8910 data write
0x33-0x33 W ay8910 control write
@irq 4enraya,Z80
@irqnum 0 @irqname Timer IRQ
*/
/**
template for Doxygen commenting style for drivers
All accepted special commands that aren't in Doxygen needs to be hooked up into the ini file.
memmap/iomap/irq -> [%s,%s] -> [name_of_romset,cpu_name]
irqnum -> type of irq, might accept one or two commands (for vectors)
irqname -> A description of the irq used, might use brief and extended description.
@sa http://www.stack.nl/~dimitri/doxygen/manual/commands.html
@todo needs discussion for accepted standardized syntax
*/

View File

@ -1,76 +0,0 @@
# license: BSD-3-Clause
"""Simple Python script to generate a new definition from the template_* files
"""
import argparse
import os
def get_args():
parser = argparse.ArgumentParser(description="""
Create a new device .cpp/.h definition, using template_device.* as a base.
All arguments are sanitized to match the given patterns
"""
)
parser.add_argument(
"-device_file",
required=True,
type=str,
help="The device .cpp/.h base file name, also the header macro directive \"acorn_vidc20.cpp\" -> \"MAME_MACHINE_ACORN_VIDC20_H\""
)
# TODO: directory option, honor with os.getcwd() as default
parser.add_argument(
"-license_opt",
default="BSD-3-Clause",
type=str,
help="License option"
)
parser.add_argument(
"-device_longname",
required=True,
type=str,
help="Friendly name for a device \"Acorn VIDC20\""
)
parser.add_argument(
"-device_classname",
required=True,
type=str,
help="Class declaration \"acorn_vidc20\", this will also be the filename output"
)
parser.add_argument(
"-device_typename",
required=True,
type=str,
help='Type handle declaration \"ACORN_VIDC20\"'
)
parser.add_argument(
"-author_name",
required=True,
type=str,
help="Your author handle name in copyright header"
)
# TODO: add optional structures like device_memory_interface
user_input = vars(parser.parse_args())
return {
**user_input,
"device_header": user_input["device_file"].upper()
}
def sanitize(k, v):
rules_fn = {
"device_typename": lambda v: v.upper().strip(),
"device_classname": lambda v: v.lower().strip()
# TODO: validate license_opt with an enum
}
return rules_fn.get(k, lambda v: v.strip())(v)
if __name__ == '__main__':
args = get_args()
for file_type in [".cpp", ".h"]:
with open(".{0}template_device{1}".format(os.path.sep, file_type), "r", encoding="utf-8", newline="\n") as template_fh:
buf_string = template_fh.read()
for k, v in args.items():
if k == "device_file":
continue
buf_string = buf_string.replace("<" + k + ">", sanitize(k, v))
with open(".{0}{1}{2}".format(os.path.sep, args["device_file"], file_type), "w", encoding="utf-8", newline="\n") as result_fh:
result_fh.write(buf_string)

View File

@ -1,129 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:<author_name>
/*****************************************************************************
*
* template for CPU cores
*
*****************************************************************************/
#include "emu.h"
#include "xxx.h"
#include "debugger.h"
DEFINE_DEVICE_TYPE(XXX, xxx_cpu_device, "xxx", "XXX")
/* FLAGS */
#if 0
#define S 0x80
#define Z 0x40
#define OV 0x20
#define C 0x10
#endif
#define xxx_readop(A) m_program->read_dword(A)
#define xxx_readmem16(A) m_data->read_dword(A)
#define xxx_writemem16(A,B) m_data->write_dword((A),B)
/***********************************
* illegal opcodes
***********************************/
void xxx_cpu_device::xxx_illegal()
{
logerror("xxx illegal opcode at 0x%04x\n", m_pc);
m_icount -= 1;
}
/* Execute cycles */
void cp1610_cpu_device::execute_run()
{
uint16_t opcode;
do
{
debugger_instruction_hook(this, m_pc);
opcode = xxx_readop(m_pc);
m_pc++;
switch( opcode )
{
default:
xxx_illegal();
break;
}
} while( m_icount > 0 );
}
void xxx_cpu_device::device_start()
{
m_program = &space(AS_PROGRAM);
m_data = &space(AS_DATA);
save_item(NAME(m_pc));
save_item(NAME(m_flags));
// Register state for debugger
state_add( CP1610_R0, "PC", m_pc ).formatstr("%02X");
state_add( STATE_GENPC, "GENPC", m_r[7] ).noshow();
state_add( STATE_GENPCBASE, "CURPC", m_r[7] ).noshow();
state_add( STATE_GENFLAGS, "GENFLAGS", m_flags ).noshow();
m_icountptr = &m_icount;
}
#if 0
void xxx_cpu_device::execute_set_input(int irqline, int state)
{
switch(irqline)
{
case XXX_INT_INTRM: // level-sensitive
m_intrm_pending = ((ASSERT_LINE == state) || (HOLD_LINE == state));
m_intrm_state = (ASSERT_LINE == state);
break;
case XXX_RESET: // edge-sensitive
if (CLEAR_LINE != state)
m_reset_pending = 1;
m_reset_state = (ASSERT_LINE == state);
break;
case XXX_INT_INTR: // edge-sensitive
if (CLEAR_LINE != state)
m_intr_pending = 1;
m_intr_state = (ASSERT_LINE == state);
break;
}
}
#endif
xxx_cpu_device::xxx_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: cpu_device(mconfig, XXX, tag, owner, clock)
, m_program_config("program", ENDIANNESS_BIG, 8, 32, -1)
, m_data_config("data", ENDIANNESS_BIG, 8, 32, 0)
{
}
void xxx_cpu_device::state_string_export(const device_state_entry &entry, std::string &str) const
{
switch (entry.index())
{
case STATE_GENFLAGS:
str = util::string_format("%c%c%c%c",
m_flags & 0x80 ? 'S':'.',
m_flags & 0x40 ? 'Z':'.',
m_flags & 0x20 ? 'V':'.',
m_flags & 0x10 ? 'C':'.');
break;
}
}
offs_t xxx_cpu_device::disassemble(char *buffer, offs_t pc, const uint32_t *oprom, const uint32_t *opram, uint32_t options)
{
return CPU_DISASSEMBLE_NAME(xxx)(this, buffer, pc, opcodes, params, options);
}

View File

@ -1,70 +0,0 @@
// license:BSD-3-Clause
// copyright-holders:<author_name>
/*****************************************************************************
*
* template for CPU cores
*
*****************************************************************************/
#ifndef MAME_CPU_XXX_H
#define MAME_CPU_XXX_H
#pragma once
enum
{
#if UNUSED
XXX_R0=1, XXX_R1, XXX_R2, XXX_R3,
XXX_R4, XXX_R5, XXX_R6, XXX_R7
#endif
};
class xxx_cpu_device : public cpu_device
{
public:
// construction/destruction
xxx_cpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
protected:
// device-level overrides
virtual void device_start() override;
virtual void device_reset() override;
// device_execute_interface overrides
virtual uint32_t execute_min_cycles() const noexcept override { return 1; }
virtual uint32_t execute_max_cycles() const noexcept override { return 7; }
virtual uint32_t execute_input_lines() const noexcept override { return 0; }
virtual void execute_run() override;
virtual void execute_set_input(int inputnum, int state) override;
// device_memory_interface overrides
virtual const address_space_config *memory_space_config(int spacenum) const override { return (spacenum == AS_PROGRAM) ? &m_program_config : (spacenum == AS_DATA) ? &m_data_config : nullptr; }
// device_state_interface overrides
virtual void state_string_export(const device_state_entry &entry, std::string &str) const override;
// device_disasm_interface overrides
virtual uint32_t opcode_alignment() const override { return 4; }
virtual offs_t disassemble(char *buffer, offs_t pc, const data_buffer &opcodes, const data_buffer &params, uint32_t options) override;
private:
address_space_config m_program_config;
uint8_t m_pc; /* registers */
uint8_t m_flags; /* flags */
address_space *m_program;
address_space *m_data;
int m_icount;
void xxx_illegal();
};
DECLARE_DEVICE_TYPE(XXX, xxx_cpu_device)
CPU_DISASSEMBLE( xxx );
#endif // MAME_CPU_XXX_H

View File

@ -1,83 +0,0 @@
// license:<license_opt>
// copyright-holders:<author_name>
/***************************************************************************
<device_longname>
***************************************************************************/
#include "emu.h"
#include "<device_classname>.h"
//**************************************************************************
// GLOBAL VARIABLES
//**************************************************************************
// device type definition
DEFINE_DEVICE_TYPE(<device_typename>, <device_classname>_device, "<device_classname>", "<device_longname>")
//**************************************************************************
// LIVE DEVICE
//**************************************************************************
//-------------------------------------------------
// <device_classname>_device - constructor
//-------------------------------------------------
<device_classname>_device::<device_classname>_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock)
: device_t(mconfig, <device_typename>, tag, owner, clock)
{
}
//-------------------------------------------------
// device_add_mconfig - device-specific machine
// configuration addiitons
//-------------------------------------------------
void <device_classname>_device::device_add_mconfig(machine_config &config)
{
//DEVICE(config, ...);
}
//-------------------------------------------------
// device_start - device-specific startup
//-------------------------------------------------
void <device_classname>_device::device_start()
{
}
//-------------------------------------------------
// device_reset - device-specific reset
//-------------------------------------------------
void <device_classname>_device::device_reset()
{
}
//**************************************************************************
// READ/WRITE HANDLERS
//**************************************************************************
uint8_t <device_classname>_device::read(address_space &space, offs_t offset, uint8_t mem_mask = ~0)
{
return 0;
}
void <device_classname>_device::write(address_space &space, offs_t offset, uint8_t data, uint8_t mem_mask = ~0)
{
}

View File

@ -1,40 +0,0 @@
// license:<license_opt>
// copyright-holders:<author_name>
/***************************************************************************
<device_longname>
***************************************************************************/
#ifndef MAME_MACHINE_<device_header>_H
#define MAME_MACHINE_<device_header>_H
#pragma once
//**************************************************************************
// TYPE DEFINITIONS
//**************************************************************************
class <device_classname>_device : public device_t
{
public:
// construction/destruction
<device_classname>_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
// I/O operations
void write(address_space &space, offs_t offset, uint8_t data, uint8_t mem_mask = ~0);
uint8_t read(address_space &space, offs_t offset, uint8_t mem_mask = ~0);
protected:
// device-level overrides
//virtual void device_validity_check(validity_checker &valid) const override;
virtual void device_add_mconfig(machine_config &config) override;
virtual void device_start() override;
virtual void device_reset() override;
};
// device type definition
DECLARE_DEVICE_TYPE(<device_typename>, <device_classname>_device)
#endif // MAME_MACHINE_<device_header>_H

View File

@ -1,199 +0,0 @@
// license:<license>
// copyright-holders:<author_name>
/***************************************************************************
<template_header>
***************************************************************************/
#include "emu.h"
#include "cpu/z80/z80.h"
#include "emupal.h"
#include "screen.h"
#include "speaker.h"
#define MAIN_CLOCK XTAL(8'000'000)
class xxx_state : public driver_device
{
public:
xxx_state(const machine_config &mconfig, device_type type, const char *tag)
: driver_device(mconfig, type, tag)
, m_maincpu(*this, "maincpu")
, m_palette(*this, "palette")
{
}
void xxx(machine_config &config);
protected:
// driver_device overrides
virtual void machine_start() override;
virtual void machine_reset() override;
virtual void video_start() override;
private:
// screen updates
uint32_t screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
void xxx_palette(palette_device &palette) const;
void xxx_io(address_map &map);
void xxx_map(address_map &map);
// devices
required_device<cpu_device> m_maincpu;
required_device<palette_device> m_palette;
};
void xxx_state::video_start()
{
}
uint32_t xxx_state::screen_update( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect )
{
return 0;
}
void xxx_state::xxx_map(address_map &map)
{
map(0x0000, 0x7fff).rom();
}
void xxx_state::xxx_io(address_map &map)
{
map.global_mask(0xff);
}
static INPUT_PORTS_START( xxx )
/* dummy active high structure */
PORT_START("SYSA")
PORT_DIPNAME( 0x01, 0x00, "SYSA" )
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x01, DEF_STR( On ) )
PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x02, DEF_STR( On ) )
PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x04, DEF_STR( On ) )
PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x08, DEF_STR( On ) )
PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x10, DEF_STR( On ) )
PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x20, DEF_STR( On ) )
PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x40, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x00, DEF_STR( Off ) )
PORT_DIPSETTING( 0x80, DEF_STR( On ) )
/* dummy active low structure */
PORT_START("DSWA")
PORT_DIPNAME( 0x01, 0x01, "DSWA" )
PORT_DIPSETTING( 0x01, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x02, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x08, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x10, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
PORT_DIPSETTING( 0x00, DEF_STR( On ) )
INPUT_PORTS_END
static const gfx_layout charlayout =
{
8,8,
RGN_FRAC(1,1),
1,
{ RGN_FRAC(0,1) },
{ 0, 1, 2, 3, 4, 5, 6, 7 },
{ 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
8*8
};
static GFXDECODE_START( gfx_xxx )
GFXDECODE_ENTRY( "gfx1", 0, charlayout, 0, 1 )
GFXDECODE_END
void xxx_state::machine_start()
{
}
void xxx_state::machine_reset()
{
}
void xxx_state::xxx_palette(palette_device &palette) const
{
}
void xxx_state::xxx(machine_config &config)
{
/* basic machine hardware */
Z80(config, m_maincpu, MAIN_CLOCK/2);
m_maincpu->set_addrmap(AS_PROGRAM, &xxx_state::xxx_map);
m_maincpu->set_addrmap(AS_IO, &xxx_state::xxx_io);
/* video hardware */
screen_device &screen(SCREEN(config, "screen", SCREEN_TYPE_RASTER));
screen.set_screen_update(FUNC(xxx_state::screen_update));
screen.set_raw(MAIN_CLOCK/2, 442, 0, 320, 264, 0, 240); /* generic NTSC video timing at 320x240 */
screen.set_palette(m_palette);
GFXDECODE(config, "gfxdecode", m_palette, gfx_xxx);
PALETTE(config, m_palette, FUNC(xxx_state::xxx_palette), 8);
/* sound hardware */
SPEAKER(config, "mono").front_center();
}
/***************************************************************************
Machine driver(s)
***************************************************************************/
<rom_load>
ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASE00 )
ROM_REGION( 0x10000, "gfx1", ROMREGION_ERASE00 )
// See src/emu/gamedrv.h for details
// For a game:
// GAME(YEAR,NAME,PARENT,MACHINE,INPUT,CLASS,DRIVER_INIT,MONITOR,COMPANY,FULLNAME,FLAGS)
// For a console:
// CONS(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,CLASS,DRIVER_INIT,COMPANY,FULLNAME,FLAGS)
// For a computer:
// COMP(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,CLASS,DRIVER_INIT,COMPANY,FULLNAME,FLAGS)
// For a generic system:
// SYST(YEAR,NAME,PARENT,COMPAT,MACHINE,INPUT,CLASS,DRIVER_INIT,COMPANY,FULLNAME,FLAGS)
GAME( 198?, xxx, 0, xxx, xxx, xxx_state, empty_init, ROT0, "<template_manufacturer>", "<template_machinename>", MACHINE_IS_SKELETON )

View File

@ -1,43 +0,0 @@
The template family tree is an attempt to ease the pain to write CPUs/drivers/devices
from scratch (useful especially for smaller targets).
===
Usage:
- Any "xxx" name is case-sensitive (i.e., XXX -> NAMEOFDEVICE, xxx -> nameofdevice);
===
License:
Copyright (c) 2014, Angelo Salese & the MAME team
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
===
TODO:
- Define convention for template inputs (i.e. optimal for each host);
- Write template drivers for different endianesses;
- Write template header for drivers;
- Write tool program that auto-generate contents;
- Fix SCREEN_RAW_PARAMS, perhaps actually link to a framework class/macro list, a couple of references are:
http://www.ntsc-tv.com/ntsc-index-02.htm
http://www.intersil.com/content/dam/Intersil/documents/tb36/tb368.pdf