diff options
author | 2017-05-07 23:18:47 +1000 | |
---|---|---|
committer | 2017-05-14 21:44:11 +1000 | |
commit | 0f0d39ef81562c75e79176dd3bebb1e491ca39d5 (patch) | |
tree | 201cee7fdf55ee800f83859a92efd2cfe66cf2b3 /src/devices/cpu/psx/psxdefs.h | |
parent | e6c4be2b4d71c7a6c95be0bae111eb416ff0f9e7 (diff) |
Move static data out of devices into the device types. This is a significant change, so please pay attention.
The core changes are:
* Short name, full name and source file are no longer members of device_t, they are part of the device type
* MACHINE_COFIG_START no longer needs a driver class
* MACHINE_CONFIG_DERIVED_CLASS is no longer necessary
* Specify the state class you want in the GAME/COMP/CONS line
* The compiler will work out the base class where the driver init member is declared
* There is one static device type object per driver rather than one per machine configuration
Use DECLARE_DEVICE_TYPE or DECLARE_DEVICE_TYPE_NS to declare device type.
* DECLARE_DEVICE_TYPE forward-declares teh device type and class, and declares extern object finders.
* DECLARE_DEVICE_TYPE_NS is for devices classes in namespaces - it doesn't forward-declare the device type.
Use DEFINE_DEVICE_TYPE or DEFINE_DEVICE_TYPE_NS to define device types.
* These macros declare storage for the static data, and instantiate the device type and device finder templates.
The rest of the changes are mostly just moving stuff out of headers that shouldn't be there, renaming stuff for consistency, and scoping stuff down where appropriate.
Things I've actually messed with substantially:
* More descriptive names for a lot of devices
* Untangled the fantasy sound from the driver state, which necessitates breaking up sound/flip writes
* Changed DECO BSMT2000 ready callback into a device delegate
* Untangled Microprose 3D noise from driver state
* Used object finders for CoCo multipak, KC85 D002, and Irem sound subdevices
* Started to get TI-99 stuff out of the TI-990 directory and arrange bus devices properly
* Started to break out common parts of Samsung ARM SoC devices
* Turned some of FM, SID, SCSP DSP, EPIC12 and Voodoo cores into something resmbling C++
* Tried to make Z180 table allocation/setup a bit safer
* Converted generic keyboard/terminal to not use WRITE8 - space/offset aren't relevant
* Dynamically allocate generic terminal buffer so derived devices (e.g. teleprinter) can specify size
* Imporved encapsulation of Z80DART channels
* Refactored the SPC7110 bit table generator loop to make it more readable
* Added wrappers for SNES PPU operations so members can be made protected
* Factored out some boilerplate for YM chips with PSG
* toaplan2 gfx
* stic/intv resolution
* Video System video
* Out Run/Y-board sprite alignment
* GIC video hookup
* Amstrad CPC ROM box members
* IQ151 ROM cart region
* MSX cart IRQ callback resolution time
* SMS passthrough control devices starting subslots
I've smoke-tested several drivers, but I've probably missed something. Things I've missed will likely blow up spectacularly with failure to bind errors and the like. Let me know if there's more subtle breakage (could have happened in FM or Voodoo).
And can everyone please, please try to keep stuff clean. In particular, please stop polluting the global namespace. Keep things out of headers that don't need to be there, and use things that can be scoped down rather than macros.
It feels like an uphill battle trying to get this stuff under control while more of it's added.
Diffstat (limited to 'src/devices/cpu/psx/psxdefs.h')
-rw-r--r-- | src/devices/cpu/psx/psxdefs.h | 126 |
1 files changed, 126 insertions, 0 deletions
diff --git a/src/devices/cpu/psx/psxdefs.h b/src/devices/cpu/psx/psxdefs.h new file mode 100644 index 00000000000..fde2456b515 --- /dev/null +++ b/src/devices/cpu/psx/psxdefs.h @@ -0,0 +1,126 @@ +// license:BSD-3-Clause +// copyright-holders:smf +#ifndef MAME_CPU_PSX_PSXDEFS_H +#define MAME_CPU_PSX_PSXDEFS_H + +#pragma once + + +#define PSXCPU_DELAYR_PC ( 32 ) +#define PSXCPU_DELAYR_NOTPC ( 33 ) + +#define PSXCPU_BYTE_EXTEND( a ) ( (int32_t)(int8_t)a ) +#define PSXCPU_WORD_EXTEND( a ) ( (int32_t)(int16_t)a ) + +#define INS_OP( op ) ( ( op >> 26 ) & 63 ) +#define INS_RS( op ) ( ( op >> 21 ) & 31 ) +#define INS_RT( op ) ( ( op >> 16 ) & 31 ) +#define INS_IMMEDIATE( op ) ( op & 0xffff ) +#define INS_TARGET( op ) ( op & 0x3ffffff ) +#define INS_RD( op ) ( ( op >> 11 ) & 31 ) +#define INS_SHAMT( op ) ( ( op >> 6 ) & 31 ) +#define INS_FUNCT( op ) ( op & 63 ) +#define INS_CODE( op ) ( ( op >> 6 ) & 0xfffff ) +#define INS_CO( op ) ( ( op >> 25 ) & 1 ) +#define INS_COFUN( op ) ( op & 0x1ffffff ) +#define INS_CF( op ) ( op & 31 ) +#define INS_BC( op ) ( ( op >> 16 ) & 1 ) +#define INS_RT_REGIMM( op ) ( ( op >> 16 ) & 1 ) + +#define OP_SPECIAL ( 0 ) +#define OP_REGIMM ( 1 ) +#define OP_J ( 2 ) +#define OP_JAL ( 3 ) +#define OP_BEQ ( 4 ) +#define OP_BNE ( 5 ) +#define OP_BLEZ ( 6 ) +#define OP_BGTZ ( 7 ) +#define OP_ADDI ( 8 ) +#define OP_ADDIU ( 9 ) +#define OP_SLTI ( 10 ) +#define OP_SLTIU ( 11 ) +#define OP_ANDI ( 12 ) +#define OP_ORI ( 13 ) +#define OP_XORI ( 14 ) +#define OP_LUI ( 15 ) +#define OP_COP0 ( 16 ) +#define OP_COP1 ( 17 ) +#define OP_COP2 ( 18 ) +#define OP_COP3 ( 19 ) +#define OP_LB ( 32 ) +#define OP_LH ( 33 ) +#define OP_LWL ( 34 ) +#define OP_LW ( 35 ) +#define OP_LBU ( 36 ) +#define OP_LHU ( 37 ) +#define OP_LWR ( 38 ) +#define OP_SB ( 40 ) +#define OP_SH ( 41 ) +#define OP_SWL ( 42 ) +#define OP_SW ( 43 ) +#define OP_SWR ( 46 ) +#define OP_LWC0 ( 48 ) +#define OP_LWC1 ( 49 ) +#define OP_LWC2 ( 50 ) +#define OP_LWC3 ( 51 ) +#define OP_SWC0 ( 56 ) +#define OP_SWC1 ( 57 ) +#define OP_SWC2 ( 58 ) +#define OP_SWC3 ( 59 ) + +/* OP_SPECIAL */ +#define FUNCT_SLL ( 0 ) +#define FUNCT_SRL ( 2 ) +#define FUNCT_SRA ( 3 ) +#define FUNCT_SLLV ( 4 ) +#define FUNCT_SRLV ( 6 ) +#define FUNCT_SRAV ( 7 ) +#define FUNCT_JR ( 8 ) +#define FUNCT_JALR ( 9 ) +#define FUNCT_SYSCALL ( 12 ) +#define FUNCT_BREAK ( 13 ) +#define FUNCT_MFHI ( 16 ) +#define FUNCT_MTHI ( 17 ) +#define FUNCT_MFLO ( 18 ) +#define FUNCT_MTLO ( 19 ) +#define FUNCT_MULT ( 24 ) +#define FUNCT_MULTU ( 25 ) +#define FUNCT_DIV ( 26 ) +#define FUNCT_DIVU ( 27 ) +#define FUNCT_ADD ( 32 ) +#define FUNCT_ADDU ( 33 ) +#define FUNCT_SUB ( 34 ) +#define FUNCT_SUBU ( 35 ) +#define FUNCT_AND ( 36 ) +#define FUNCT_OR ( 37 ) +#define FUNCT_XOR ( 38 ) +#define FUNCT_NOR ( 39 ) +#define FUNCT_SLT ( 42 ) +#define FUNCT_SLTU ( 43 ) + +/* OP_REGIMM */ +#define RT_BLTZ ( 0 ) +#define RT_BGEZ ( 1 ) +#define RT_BLTZAL ( 16 ) +#define RT_BGEZAL ( 17 ) + +/* OP_COP0/OP_COP1/OP_COP2 */ +#define RS_MFC ( 0 ) +#define RS_CFC ( 2 ) +#define RS_MTC ( 4 ) +#define RS_CTC ( 6 ) +#define RS_BC ( 8 ) +#define RS_BC_ALT ( 12 ) + +/* BC_BC */ +#define BC_BCF ( 0 ) +#define BC_BCT ( 1 ) + +/* OP_COP0 */ +#define CF_TLBR ( 1 ) +#define CF_TLBWI ( 2 ) +#define CF_TLBWR ( 6 ) +#define CF_TLBP ( 8 ) +#define CF_RFE ( 16 ) + +#endif // MAME_CPU_PSX_PSXDEFS_H |