summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/includes
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2022-06-27 16:29:25 +1000
committer Vas Crabb <vas@vastheman.com>2022-06-27 17:06:39 +1000
commit06a305490065668c4613212915c714291a20a2ca (patch)
treebb87112c5dcbb90d77f658efde44261a9d3bdef1 /src/mame/includes
parentab60f40c2a716ec30dc8bcdc6e58f1ad1b7916bc (diff)
Reduced project cross-dependencies, slightly improved renaming script.
Diffstat (limited to 'src/mame/includes')
-rw-r--r--src/mame/includes/model2.h16
-rw-r--r--src/mame/includes/pk8000.h51
-rw-r--r--src/mame/includes/xbox.h175
-rw-r--r--src/mame/includes/xbox_nv2a.h895
-rw-r--r--src/mame/includes/xbox_pci.h492
-rw-r--r--src/mame/includes/xbox_usb.h534
6 files changed, 8 insertions, 2155 deletions
diff --git a/src/mame/includes/model2.h b/src/mame/includes/model2.h
index ed0b77b21be..43a9a3b396f 100644
--- a/src/mame/includes/model2.h
+++ b/src/mame/includes/model2.h
@@ -663,56 +663,56 @@ public:
/* checker = 0, textured = 0, transparent = 0 */
#define MODEL2_FUNC 0
#define MODEL2_FUNC_NAME model2_3d_render_0
- #include "video/model2rd.hxx"
+ #include "video/model2rd.ipp"
#undef MODEL2_FUNC
#undef MODEL2_FUNC_NAME
/* checker = 0, textured = 0, translucent = 1 */
#define MODEL2_FUNC 1
#define MODEL2_FUNC_NAME model2_3d_render_1
- #include "video/model2rd.hxx"
+ #include "video/model2rd.ipp"
#undef MODEL2_FUNC
#undef MODEL2_FUNC_NAME
/* checker = 0, textured = 1, translucent = 0 */
#define MODEL2_FUNC 2
#define MODEL2_FUNC_NAME model2_3d_render_2
- #include "video/model2rd.hxx"
+ #include "video/model2rd.ipp"
#undef MODEL2_FUNC
#undef MODEL2_FUNC_NAME
/* checker = 0, textured = 1, translucent = 1 */
#define MODEL2_FUNC 3
#define MODEL2_FUNC_NAME model2_3d_render_3
- #include "video/model2rd.hxx"
+ #include "video/model2rd.ipp"
#undef MODEL2_FUNC
#undef MODEL2_FUNC_NAME
/* checker = 1, textured = 0, translucent = 0 */
#define MODEL2_FUNC 4
#define MODEL2_FUNC_NAME model2_3d_render_4
- #include "video/model2rd.hxx"
+ #include "video/model2rd.ipp"
#undef MODEL2_FUNC
#undef MODEL2_FUNC_NAME
/* checker = 1, textured = 0, translucent = 1 */
#define MODEL2_FUNC 5
#define MODEL2_FUNC_NAME model2_3d_render_5
- #include "video/model2rd.hxx"
+ #include "video/model2rd.ipp"
#undef MODEL2_FUNC
#undef MODEL2_FUNC_NAME
/* checker = 1, textured = 1, translucent = 0 */
#define MODEL2_FUNC 6
#define MODEL2_FUNC_NAME model2_3d_render_6
- #include "video/model2rd.hxx"
+ #include "video/model2rd.ipp"
#undef MODEL2_FUNC
#undef MODEL2_FUNC_NAME
/* checker = 1, textured = 1, translucent = 1 */
#define MODEL2_FUNC 7
#define MODEL2_FUNC_NAME model2_3d_render_7
- #include "video/model2rd.hxx"
+ #include "video/model2rd.ipp"
#undef MODEL2_FUNC
#undef MODEL2_FUNC_NAME
diff --git a/src/mame/includes/pk8000.h b/src/mame/includes/pk8000.h
deleted file mode 100644
index cb92dca6aa7..00000000000
--- a/src/mame/includes/pk8000.h
+++ /dev/null
@@ -1,51 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Miodrag Milanovic
-#ifndef MAME_INCLUDES_PK8000_H
-#define MAME_INCLUDES_PK8000_H
-
-#pragma once
-
-#include "emupal.h"
-
-class pk8000_base_state : public driver_device
-{
-public:
- pk8000_base_state(const machine_config &mconfig, device_type type, const char *tag)
- : driver_device(mconfig, type, tag)
- , m_maincpu(*this, "maincpu")
- { }
-
-protected:
- uint8_t _84_porta_r();
- void _84_porta_w(uint8_t data);
- void _84_portc_w(uint8_t data);
-
- uint8_t video_color_r();
- void video_color_w(uint8_t data);
- uint8_t text_start_r();
- void text_start_w(uint8_t data);
- uint8_t chargen_start_r();
- void chargen_start_w(uint8_t data);
- uint8_t video_start_r();
- void video_start_w(uint8_t data);
- uint8_t color_start_r();
- void color_start_w(uint8_t data);
- uint8_t color_r(offs_t offset);
- void color_w(offs_t offset, uint8_t data);
-
- void pk8000_palette(palette_device &palette) const;
- uint32_t video_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect, uint8_t *videomem);
-
- uint8_t m_text_start = 0;
- uint8_t m_chargen_start = 0;
- uint8_t m_video_start = 0;
- uint8_t m_color_start = 0;
-
- uint8_t m_video_mode = 0;
- uint8_t m_video_color = 0;
- uint8_t m_color[32];
- uint8_t m_video_enable = 0;
- required_device<cpu_device> m_maincpu;
-};
-
-#endif // MAME_INCLUDES_PK8000_H
diff --git a/src/mame/includes/xbox.h b/src/mame/includes/xbox.h
deleted file mode 100644
index c0779b740f3..00000000000
--- a/src/mame/includes/xbox.h
+++ /dev/null
@@ -1,175 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Samuele Zannoli
-#ifndef MAME_INCLUDES_XBOX_H
-#define MAME_INCLUDES_XBOX_H
-
-#pragma once
-
-#include "xbox_nv2a.h"
-#include "xbox_usb.h"
-
-#include "machine/idectrl.h"
-#include "machine/pic8259.h"
-
-/*
- * PIC16LC connected to SMBus
- */
-
-class xbox_pic16lc_device : public device_t, public smbus_interface
-{
-public:
- xbox_pic16lc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual int execute_command(int command, int rw, int data) override;
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
-
-private:
- uint8_t buffer[0xff];
-};
-
-DECLARE_DEVICE_TYPE(XBOX_PIC16LC, xbox_pic16lc_device)
-
-/*
- * CX25871 connected to SMBus
- */
-
-class xbox_cx25871_device : public device_t, public smbus_interface
-{
-public:
- xbox_cx25871_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual int execute_command(int command, int rw, int data) override;
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
-
-private:
-};
-
-DECLARE_DEVICE_TYPE(XBOX_CX25871, xbox_cx25871_device)
-
-/*
- * EEPROM connected to SMBus
- */
-
-class xbox_eeprom_device : public device_t, public smbus_interface
-{
-public:
- xbox_eeprom_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual int execute_command(int command, int rw, int data) override;
-
- std::function<void(void)> hack_eeprom;
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
-
-private:
-};
-
-DECLARE_DEVICE_TYPE(XBOX_EEPROM, xbox_eeprom_device)
-
-/*
- * Super-io connected to lpc bus used as a rs232 debug port
- */
-
-class xbox_superio_device : public device_t, public lpcbus_device_interface
-{
-public:
- xbox_superio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual void map_extra(address_space *memory_space, address_space *io_space) override;
- virtual void set_host(int index, lpcbus_host_interface *host) override;
-
- uint8_t read(offs_t offset);
- void write(offs_t offset, uint8_t data);
- uint8_t read_rs232(offs_t offset);
- void write_rs232(offs_t offset, uint8_t data);
-
-protected:
- virtual void device_start() override;
-
-private:
- void internal_io_map(address_map &map);
-
- lpcbus_host_interface *lpchost = nullptr;
- int lpcindex = 0;
- address_space *memspace = nullptr;
- address_space *iospace = nullptr;
- bool configuration_mode;
- int index;
- int selected;
- uint8_t registers[16][256]{}; // 256 registers for up to 16 devices, registers 0-0x2f common to all
-};
-
-DECLARE_DEVICE_TYPE(XBOX_SUPERIO, xbox_superio_device)
-
-/*
- * Base
- */
-
-class xbox_base_state : public driver_device
-{
-public:
- xbox_base_state(const machine_config &mconfig, device_type type, const char *tag) :
- driver_device(mconfig, type, tag),
- nvidia_nv2a(nullptr),
- debug_irq_active(false),
- debug_irq_number(0),
- m_maincpu(*this, "maincpu"),
- mcpxlpc(*this, ":pci:01.0"),
- ide(*this, ":pci:09.0:ide1"),
- debugc_bios(nullptr) { }
-
- void xbox_base(machine_config &config);
-
-protected:
- void debug_generate_irq(int irq, bool active);
- virtual void hack_eeprom() {}
- virtual void hack_usb() {}
-
- DECLARE_WRITE_LINE_MEMBER(vblank_callback);
- uint32_t screen_update_callback(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
-
- virtual void machine_start() override;
- DECLARE_WRITE_LINE_MEMBER(maincpu_interrupt);
- IRQ_CALLBACK_MEMBER(irq_callback);
-
- nv2a_renderer *nvidia_nv2a;
- bool debug_irq_active;
- int debug_irq_number;
- required_device<cpu_device> m_maincpu;
- required_device<mcpx_isalpc_device> mcpxlpc;
- required_device<bus_master_ide_controller_device> ide;
- static const struct debugger_constants
- {
- uint32_t id;
- uint32_t parameter[8]; // c c c ? ? ? x x
- } debugp[];
- const debugger_constants *debugc_bios;
-
-private:
- void dump_string_command(const std::vector<std::string> &params);
- void dump_process_command(const std::vector<std::string> &params);
- void dump_list_command(const std::vector<std::string> &params);
- void dump_dpc_command(const std::vector<std::string> &params);
- void dump_timer_command(const std::vector<std::string> &params);
- void curthread_command(const std::vector<std::string> &params);
- void threadlist_command(const std::vector<std::string> &params);
- void generate_irq_command(const std::vector<std::string> &params);
- void nv2a_combiners_command(const std::vector<std::string> &params);
- void nv2a_wclipping_command(const std::vector<std::string> &params);
- void waitvblank_command(const std::vector<std::string> &params);
- void grab_texture_command(const std::vector<std::string> &params);
- void grab_vprog_command(const std::vector<std::string> &params);
- void vprogdis_command(const std::vector<std::string> &params);
- void vdeclaration_command(const std::vector<std::string> &params);
- void help_command(const std::vector<std::string> &params);
- void xbox_debug_commands(const std::vector<std::string> &params);
- int find_bios_index();
- bool find_bios_hash(int bios, uint32_t &crc32);
- void find_debug_params();
-};
-
-#endif // MAME_INCLUDES_XBOX_H
diff --git a/src/mame/includes/xbox_nv2a.h b/src/mame/includes/xbox_nv2a.h
deleted file mode 100644
index 81c400bb877..00000000000
--- a/src/mame/includes/xbox_nv2a.h
+++ /dev/null
@@ -1,895 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Samuele Zannoli
-/*
- * geforce 3d (NV2A) vertex program disassembler
- */
-#ifndef MAME_INCLUDES_XBOX_NV2A_H
-#define MAME_INCLUDES_XBOX_NV2A_H
-
-#pragma once
-
-#include "machine/pic8259.h"
-#include "video/poly.h"
-
-class vertex_program_disassembler {
- static char const *const srctypes[];
- static char const *const scaops[];
- static int const scapar2[];
- static char const *const vecops[];
- static int const vecpar2[];
- static char const *const vecouts[];
- static char const compchar[];
- int o[6];
- int state;
-
- struct sourcefields
- {
- int Sign;
- int SwizzleX;
- int SwizzleY;
- int SwizzleZ;
- int SwizzleW;
- int TempIndex;
- int ParameterType;
- };
-
- struct fields
- {
- int ScaOperation = 0;
- int VecOperation = 0;
- int SourceConstantIndex = 0;
- int InputIndex = 0;
- sourcefields src[3]{};
- int VecTempWriteMask = 0;
- int VecTempIndex = 0;
- int ScaTempWriteMask = 0;
- int OutputWriteMask = 0;
- int OutputSelect = 0;
- int OutputIndex = 0;
- int MultiplexerControl = 0;
- int Usea0x = 0;
- int EndOfProgram = 0;
- };
- fields f;
-
- void decodefields(unsigned int *dwords, int offset, fields &decoded);
- int disassemble_mask(int mask, char *s);
- int disassemble_swizzle(sourcefields f, char *s);
- int disassemble_source(sourcefields f, fields fi, char *s);
- int disassemble_output(fields f, char *s);
- int output_types(fields f, int *o);
-public:
- vertex_program_disassembler() { state = 0; }
- int disassemble(unsigned int *instruction, char *line);
-};
-
-/*
- * geforce 3d (NV2A) vertex structure
- */
-struct vertex_nv {
- union {
- float fv[4];
- uint32_t iv[4];
- } attribute[16];
-};
-
-/*
- * geforce 3d (NV2A) vertex program simulator
- */
-class vertex_program_simulator {
-public:
- enum VectorialOperation {
- VecNOP=0,
- VecMOV,
- VecMUL,
- VecADD,
- VecMAD,
- VecDP3,
- VecDPH,
- VecDP4,
- VecDST,
- VecMIN,
- VecMAX,
- VecSLT,
- VecSGE,
- VecARL
- };
- enum ScalarOperation {
- ScaNOP=0,
- ScaIMV,
- ScaRCP,
- ScaRCC,
- ScaRSQ,
- ScaEXP,
- ScaLOG,
- ScaLIT
- };
- vertex_program_simulator();
- // input vertex
- vertex_nv *input;
- // input parameters
- struct constant {
- float fv[4];
- void iv(int idx, uint32_t value)
- {
- union
- {
- uint32_t i;
- float f;
- } cnv;
-
- cnv.i = value;
- fv[idx] = cnv.f;
- }
- } c_constant[192];
- union temp {
- float fv[4];
- } r_register[32];
- // output vertex
- vertex_nv *output;
- // instructions
- struct instruction {
- unsigned int i[4];
- int modified;
- struct decoded {
- int SwizzleA[4], NegateA, ParameterTypeA, TempIndexA;
- int SwizzleB[4], NegateB, ParameterTypeB, TempIndexB;
- int SwizzleC[4], NegateC, ParameterTypeC, TempIndexC;
- VectorialOperation VecOperation;
- ScalarOperation ScaOperation;
- int OutputWriteMask, MultiplexerControl;
- int VecTempWriteMask, ScaTempWriteMask;
- int VecTempIndex, OutputIndex;
- int InputIndex;
- int SourceConstantIndex;
- int OutputSelect;
- int Usea0x;
- int EndOfProgram;
- } d;
- } op[256];
-public:
- void set_data(vertex_nv *in, vertex_nv *out);
- void reset();
- int step();
- void decode_instruction(int address);
- void execute();
- void jump(int address);
- void process(int address, vertex_nv *in, vertex_nv *out, int count);
- int status();
-private:
- void initialize_outputs();
- void initialize_temps();
- void initialize_constants();
- void generate_input(float t[4], int sign, int type, int temp, int swizzle[4]);
- void compute_vectorial_operation(float t[4], int instruction, float par[3 * 4]);
- void compute_scalar_operation(float t[4], int instruction, float par[3 * 4]);
- void assign_output(int index, float t[4], int mask);
- void assign_register(int index, float t[4], int mask);
- void assign_constant(int index, float t[4], int mask);
-
- int ip;
- int a0x;
-};
-
-struct Combiner {
- enum class InputRegister {
- Zero = 0,
- Color0,
- Color1,
- FogColor,
- PrimaryColor,
- SecondaryColor,
- Texture0Color = 8,
- Texture1Color,
- Texture2Color,
- Texture3Color,
- Spare0,
- Spare1,
- SumClamp,
- EF
- };
- enum class MapFunction {
- UnsignedIdentity = 0,
- UnsignedInvert,
- ExpandNormal,
- ExpandNegate,
- HalfBiasNormal,
- HalfBiasNegate,
- SignedIdentyty,
- SignedNegate
- };
- struct {
- struct {
- float A[4]; // 0=R 1=G 2=B 3=A
- float B[4];
- float C[4];
- float D[4];
- float E[4];
- float F[4];
- float G;
- float EF[4];
- float sumclamp[4];
- } variables;
- struct {
- float RGBop1[4]; // 0=R 1=G 2=B
- float RGBop2[4];
- float RGBop3[4];
- float Aop1;
- float Aop2;
- float Aop3;
- } functions;
- struct {
- float primarycolor[4]; // rw
- float secondarycolor[4];
- float texture0color[4];
- float texture1color[4];
- float texture2color[4];
- float texture3color[4];
- float color0[4];
- float color1[4];
- float spare0[4];
- float spare1[4];
- float fogcolor[4]; // ro
- float zero[4];
- } registers;
- float output[4];
- } work[WORK_MAX_THREADS]{};
- struct {
- struct {
- float constantcolor0[4];
- float constantcolor1[4];
- struct {
- InputRegister A_input;
- int A_component;
- MapFunction A_mapping;
- InputRegister B_input;
- int B_component;
- MapFunction B_mapping;
- InputRegister C_input;
- int C_component;
- MapFunction C_mapping;
- InputRegister D_input;
- int D_component;
- MapFunction D_mapping;
- } mapin_alpha;
- struct {
- InputRegister A_input;
- int A_component;
- MapFunction A_mapping;
- InputRegister B_input;
- int B_component;
- MapFunction B_mapping;
- InputRegister C_input;
- int C_component;
- MapFunction C_mapping;
- InputRegister D_input;
- int D_component;
- MapFunction D_mapping;
- } mapin_rgb;
- struct {
- InputRegister CD_output;
- InputRegister AB_output;
- InputRegister SUM_output;
- int CD_dotproduct;
- int AB_dotproduct;
- int muxsum;
- int bias;
- int scale;
- } mapout_alpha;
- struct {
- InputRegister CD_output;
- InputRegister AB_output;
- InputRegister SUM_output;
- int CD_dotproduct;
- int AB_dotproduct;
- int muxsum;
- int bias;
- int scale;
- } mapout_rgb;
- } stage[8];
- struct {
- float constantcolor0[4];
- float constantcolor1[4];
- int color_sum_clamp;
- struct {
- InputRegister G_input;
- int G_component;
- MapFunction G_mapping;
- } mapin_alpha;
- struct {
- InputRegister A_input;
- int A_component;
- MapFunction A_mapping;
- InputRegister B_input;
- int B_component;
- MapFunction B_mapping;
- InputRegister C_input;
- int C_component;
- MapFunction C_mapping;
- InputRegister D_input;
- int D_component;
- MapFunction D_mapping;
- InputRegister E_input;
- int E_component;
- MapFunction E_mapping;
- InputRegister F_input;
- int F_component;
- MapFunction F_mapping;
- } mapin_rgb;
- } final;
- int stages;
- } setup{};
- int used;
-};
-
-class nv2a_renderer; // forward declaration
-struct nvidia_object_data
-{
- nv2a_renderer *data;
-};
-
-/*
- * geforce 3d (NV2A) accelerator
- */
-/* very simplified view
-there is a set of context objects
-
-context objects are stored in RAMIN
-each context object is identified by an handle stored in RAMHT
-
-each context object can be assigned to a channel
-to assign you give to the channel an handle for the object
-
-offset in ramht=(((((handle >> 11) xor handle) >> 11) xor handle) & 0x7ff)*8
-offset in ramht contains the handle itself
-offset in ramht+4 contains in the lower 16 bits the offset in RAMIN divided by 16
-
-objects have methods used to do drawing
-most methods set parameters, others actually draw
-*/
-
-class nv2a_rasterizer : public poly_manager<double, nvidia_object_data, 26>
-{
-public:
- nv2a_rasterizer(running_machine &machine) : poly_manager<double, nvidia_object_data, 26>(machine)
- {
- }
-};
-
-class nv2a_renderer
-{
-public:
- enum class VERTEX_PARAMETER {
- PARAM_COLOR_B = 0,
- PARAM_COLOR_G,
- PARAM_COLOR_R,
- PARAM_COLOR_A,
- PARAM_TEXTURE0_S,
- PARAM_TEXTURE0_T,
- PARAM_TEXTURE0_R,
- PARAM_TEXTURE0_Q,
- PARAM_TEXTURE1_S,
- PARAM_TEXTURE1_T,
- PARAM_TEXTURE1_R,
- PARAM_TEXTURE1_Q,
- PARAM_TEXTURE2_S,
- PARAM_TEXTURE2_T,
- PARAM_TEXTURE2_R,
- PARAM_TEXTURE2_Q,
- PARAM_TEXTURE3_S,
- PARAM_TEXTURE3_T,
- PARAM_TEXTURE3_R,
- PARAM_TEXTURE3_Q,
- PARAM_SECONDARY_COLOR_B,
- PARAM_SECONDARY_COLOR_G,
- PARAM_SECONDARY_COLOR_R,
- PARAM_SECONDARY_COLOR_A,
- PARAM_Z,
- PARAM_1W,
- ALL
- };
- enum class NV2A_BEGIN_END {
- STOP = 0,
- POINTS = 1,
- LINES = 2,
- LINE_LOOP = 3,
- LINE_STRIP = 4,
- TRIANGLES = 5,
- TRIANGLE_STRIP = 6,
- TRIANGLE_FAN = 7,
- QUADS = 8,
- QUAD_STRIP = 9,
- POLYGON = 10
- };
- enum class NV2A_VERTEX_ATTR {
- POS = 0, // position
- WEIGHT = 1, // blend weight
- NORMAL = 2,
- COLOR0 = 3, // diffuse
- COLOR1 = 4, // specular
- FOG = 5,
- BACKCOLOR0 = 7, // back diffuse
- BACKCOLOR1 = 8, // back specular
- TEX0 = 9, // texture coordinate
- TEX1 = 10,
- TEX2 = 11,
- TEX3 = 12
- };
- enum class NV2A_VTXBUF_TYPE {
- UBYTE_D3D = 0, // what is the difference with opengl UBYTE ?
- FLOAT = 2,
- UBYTE_OGL = 4,
- USHORT = 5,
- FLOAT_PACKED = 6 // used for vertex color
- };
- enum class NV2A_TEX_FORMAT {
- L8 = 0x0,
- I8 = 0x1,
- A1R5G5B5 = 0x2,
- A4R4G4B4 = 0x4,
- R5G6B5 = 0x5,
- A8R8G8B8 = 0x6,
- X8R8G8B8 = 0x7,
- INDEX8 = 0xb,
- DXT1 = 0xc,
- DXT3 = 0xe,
- DXT5 = 0xf,
- A1R5G5B5_RECT = 0x10,
- R5G6B5_RECT = 0x11,
- A8R8G8B8_RECT = 0x12,
- L8_RECT = 0x13,
- DSDT8_RECT = 0x17,
- A8 = 0x19,
- A8L8 = 0x1a,
- I8_RECT = 0x1b,
- A4R4G4B4_RECT = 0x1d,
- R8G8B8_RECT = 0x1e,
- A8L8_RECT = 0x20,
- Z24 = 0x2a,
- Z24_RECT = 0x2b,
- Z16 = 0x2c,
- Z16_RECT = 0x2d,
- DSDT8 = 0x28,
- HILO16 = 0x33,
- HILO16_RECT = 0x36,
- HILO8 = 0x44,
- SIGNED_HILO8 = 0x45,
- HILO8_RECT = 0x46,
- SIGNED_HILO8_RECT = 0x47
- };
- enum class NV2A_LOGIC_OP {
- CLEAR = 0x1500,
- AND = 0x1501,
- AND_REVERSE = 0x1502,
- COPY = 0x1503,
- AND_INVERTED = 0x1504,
- NOOP = 0x1505,
- XOR = 0x1506,
- OR = 0x1507,
- NOR = 0x1508,
- EQUIV = 0x1509,
- INVERT = 0x150a,
- OR_REVERSE = 0x150b,
- COPY_INVERTED = 0x150c,
- OR_INVERTED = 0x150d,
- NAND = 0x150e,
- SET = 0x150f
- };
- enum class NV2A_BLEND_EQUATION {
- FUNC_ADD = 0x8006,
- MIN = 0x8007,
- MAX = 0x8008,
- FUNC_SUBTRACT = 0x800a,
- FUNC_REVERSE_SUBTRACT = 0x80b
- };
- enum class NV2A_BLEND_FACTOR {
- ZERO = 0x0000,
- ONE = 0x0001,
- SRC_COLOR = 0x0300,
- ONE_MINUS_SRC_COLOR = 0x0301,
- SRC_ALPHA = 0x0302,
- ONE_MINUS_SRC_ALPHA = 0x0303,
- DST_ALPHA = 0x0304,
- ONE_MINUS_DST_ALPHA = 0x0305,
- DST_COLOR = 0x0306,
- ONE_MINUS_DST_COLOR = 0x0307,
- SRC_ALPHA_SATURATE = 0x0308,
- CONSTANT_COLOR = 0x8001,
- ONE_MINUS_CONSTANT_COLOR = 0x8002,
- CONSTANT_ALPHA = 0x8003,
- ONE_MINUS_CONSTANT_ALPHA = 0x8004
- };
- enum class NV2A_COMPARISON_OP {
- NEVER = 0x0200,
- LESS = 0x0201,
- EQUAL = 0x0202,
- LEQUAL = 0x0203,
- GREATER = 0x0204,
- NOTEQUAL = 0x0205,
- GEQUAL = 0x0206,
- ALWAYS = 0x0207
- };
- enum class NV2A_STENCIL_OP {
- ZEROOP = 0x0000,
- INVERTOP = 0x150a,
- KEEP = 0x1e00,
- REPLACE = 0x1e01,
- INCR = 0x1e02,
- DECR = 0x1e03,
- INCR_WRAP = 0x8507,
- DECR_WRAP = 0x8508
- };
- enum class NV2A_RT_TYPE {
- LINEAR = 1,
- SWIZZLED = 2
- };
- enum class NV2A_RT_DEPTH_FORMAT {
- Z16 = 0x0001,
- Z24S8 = 0x0002
- };
- enum class NV2A_COLOR_FORMAT {
- X1R5G5B5_Z1R5G5B5 = 1,
- X1R5G5B5_X1R5G5B5 = 2,
- R5G6B5 = 3,
- X8R8G8B8_Z8R8G8B8 = 4,
- X8R8G8B8_X8R8G8B8 = 5,
- X1A7R8G8B8_Z1A7R8G8B8 = 6,
- X1A7R8G8B8_X1A7R8G8B8 = 7,
- A8R8G8B8 = 8,
- B8 = 9,
- G8B8 = 10
- };
- enum class NV2A_GL_FRONT_FACE {
- CW = 0x0900,
- CCW = 0x0901
- };
- enum class NV2A_GL_CULL_FACE {
- FRONT = 0x0404,
- BACK = 0x0405,
- FRONT_AND_BACK = 0x0408
- };
- enum class COMMAND {
- CALL = 7,
- JUMP = 6,
- NON_INCREASING = 5,
- OLD_JUMP = 4,
- LONG_NON_INCREASING = 3,
- RETURN = 2,
- SLI_CONDITIONAL = 1,
- INCREASING = 0,
- INVALID = -1
- };
-
- struct nv2avertex_t : public nv2a_rasterizer::vertex_t
- {
- double w;
- };
-
- nv2a_renderer(running_machine &machine)
- : rasterizer(machine)
- , mach(machine)
- {
- memset(channel, 0, sizeof(channel));
- memset(pfifo, 0, sizeof(pfifo));
- memset(pcrtc, 0, sizeof(pcrtc));
- memset(pmc, 0, sizeof(pmc));
- memset(pgraph, 0, sizeof(pgraph));
- memset(ramin, 0, sizeof(ramin));
- computedilated();
- objectdata = &(rasterizer.object_data().next());
- objectdata->data = this;
- combiner.used = 0;
- primitives_total_count = 0;
- primitives_batches_count = 0;
- indexesleft_count = 0;
- triangles_bfculled = 0;
- vertex_pipeline = 4;
- color_mask = 0xffffffff;
- backface_culling_enabled = false;
- backface_culling_winding = NV2A_GL_FRONT_FACE::CCW;
- backface_culling_culled = NV2A_GL_CULL_FACE::BACK;
- alpha_test_enabled = false;
- alpha_reference = 0;
- alpha_func = NV2A_COMPARISON_OP::ALWAYS;
- depth_test_enabled = false;
- depth_function = NV2A_COMPARISON_OP::LESS;
- depth_write_enabled = false;
- stencil_test_enabled = false;
- stencil_func = NV2A_COMPARISON_OP::ALWAYS;
- stencil_ref = 0;
- stencil_mask = -1;
- stencil_op_fail = NV2A_STENCIL_OP::KEEP;
- stencil_op_zfail = NV2A_STENCIL_OP::KEEP;
- stencil_op_zpass = NV2A_STENCIL_OP::KEEP;
- blending_enabled = false;
- blend_equation = NV2A_BLEND_EQUATION::FUNC_ADD;
- blend_color = 0;
- blend_function_destination = NV2A_BLEND_FACTOR::ZERO;
- blend_function_source = NV2A_BLEND_FACTOR::ONE;
- logical_operation_enabled = false;
- logical_operation = NV2A_LOGIC_OP::COPY;
- fog_color = 0;
- for (int n = 0; n < 4; n++) {
- texture[n].enabled = 0;
- texture[n].mode = 0;
- texture[n].addrmodes = 1;
- texture[n].addrmodet = 1;
- texture[n].addrmoder = 1;
- }
- for (int n = 0; n < 8; n++)
- clippingwindows[n].set(0, 0, 640, 480);
- limits_rendertarget.set(0, 0, 640, 480);
- pitch_rendertarget = 0;
- pitch_depthbuffer = 0;
- size_rendertarget = 0;
- size_depthbuffer = 0;
- log2height_rendertarget = 0;
- log2width_rendertarget = 0;
- dilate_rendertarget = 0;
- antialiasing_rendertarget = 0;
- type_rendertarget = NV2A_RT_TYPE::LINEAR;
- depthformat_rendertarget = NV2A_RT_DEPTH_FORMAT::Z24S8;
- colorformat_rendertarget = NV2A_COLOR_FORMAT::A8R8G8B8;
- bytespixel_rendertarget = 4;
- clear_rendertarget.set(0, 0, 639, 479);
- primitive_type = NV2A_BEGIN_END::STOP;
- antialias_control = 0;
- supersample_factor_x = 1.0;
- supersample_factor_y = 1.0;
- rendertarget = nullptr;
- depthbuffer = nullptr;
- displayedtarget = nullptr;
- old_rendertarget = nullptr;
- puller_waiting = 0;
- debug_grab_texttype = -1;
- debug_grab_textfile = nullptr;
- enable_waitvblank = true;
- enable_clipping_w = false;
- memset(&vertexbuffer, 0, sizeof(vertexbuffer));
- memset(&persistvertexattr, 0, sizeof(persistvertexattr));
- for (int n = 0; n < 16; n++)
- persistvertexattr.attribute[n].fv[3] = 1;
- }
- running_machine &machine() { return mach; }
- uint32_t geforce_r(offs_t offset, uint32_t mem_mask = ~0);
- void geforce_w(address_space &space, offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
- DECLARE_WRITE_LINE_MEMBER(vblank_callback);
- uint32_t screen_update_callback(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
- bool update_interrupts();
- void set_irq_callbaclk(std::function<void(int state)> callback) { irq_callback = callback; }
-
- void render_texture_simple(int32_t scanline, const nv2a_rasterizer::extent_t &extent, const nvidia_object_data &extradata, int threadid);
- void render_color(int32_t scanline, const nv2a_rasterizer::extent_t &extent, const nvidia_object_data &extradata, int threadid);
- void render_register_combiners(int32_t scanline, const nv2a_rasterizer::extent_t &extent, const nvidia_object_data &objectdata, int threadid);
-
- COMMAND geforce_commandkind(uint32_t word);
- uint32_t geforce_object_offset(uint32_t handle);
- void geforce_read_dma_object(uint32_t handle, uint32_t &offset, uint32_t &size);
- void geforce_assign_object(address_space &space, uint32_t chanel, uint32_t subchannel, uint32_t address);
- int execute_method(address_space &space, uint32_t channel, uint32_t subchannel, uint32_t method, uint32_t address, int &countlen);
- int execute_method_3d(address_space &space, uint32_t chanel, uint32_t subchannel, uint32_t maddress, uint32_t address, uint32_t data, int &countlen);
- int execute_method_m2mf(address_space &space, uint32_t chanel, uint32_t subchannel, uint32_t maddress, uint32_t address, uint32_t data, int &countlen);
- int execute_method_surf2d(address_space &space, uint32_t chanel, uint32_t subchannel, uint32_t maddress, uint32_t address, uint32_t data, int &countlen);
- int execute_method_blit(address_space &space, uint32_t chanel, uint32_t subchannel, uint32_t maddress, uint32_t address, uint32_t data, int &countlen);
- void surface_2d_blit();
- uint32_t texture_get_texel(int number, int x, int y);
- uint8_t *read_pixel(int x, int y, int32_t c[4]);
- void write_pixel(int x, int y, uint32_t color, int z);
- void combiner_initialize_registers(int id, float rgba[6][4]);
- void combiner_initialize_stage(int id, int stage_number);
- void combiner_initialize_final(int id);
- void combiner_map_stage_input(int id, int stage_number); // map combiner registers to variables A..D
- void combiner_map_stage_output(int id, int stage_number); // map combiner calculation results to combiner registers
- void combiner_map_final_input(int id); // map final combiner registers to variables A..F
- void combiner_final_output(int id); // generate final combiner output
- float combiner_map_input_select(int id, Combiner::InputRegister code, int index); // get component index in register selected as input
- float *combiner_map_input_select_array(int id, Combiner::InputRegister code); // get pointer to register selected as input
- float *combiner_map_output_select_array(int id, Combiner::InputRegister code); // get pointer to register selected as output
- float combiner_map_input_function(Combiner::MapFunction code, float value); // apply input mapping function code to value
- void combiner_map_input_function_array(Combiner::MapFunction code, float *data); // apply input mapping function code to data
- void combiner_function_AB(int id, float result[4]); // calculate values for possible outputs
- void combiner_function_AdotB(int id, float result[4]);
- void combiner_function_CD(int id, float result[4]);
- void combiner_function_CdotD(int id, float result[4]);
- void combiner_function_ABmuxCD(int id, float result[4]);
- void combiner_function_ABsumCD(int id, float result[4]);
- void combiner_compute_rgb_outputs(int id, int index);
- void combiner_compute_alpha_outputs(int id, int index);
- void combiner_argb8_float(uint32_t color, float reg[4]); // convert from color to float array
- uint32_t combiner_float_argb8(float reg[4]); // convert from float array to color
- uint32_t dilate0(uint32_t value, int bits);
- uint32_t dilate1(uint32_t value, int bits);
- void computedilated(void);
- bool toggle_register_combiners_usage();
- bool toggle_wait_vblank_support();
- bool toggle_clipping_w_support();
- void debug_grab_texture(int type, const char *filename);
- void debug_grab_vertex_program_slot(int slot, uint32_t *instruction);
- void start(address_space *cpu_space);
- void set_ram_base(void *base);
- void savestate_items();
- void compute_supersample_factors(float &horizontal, float &vertical);
- void compute_limits_rendertarget(uint32_t chanel, uint32_t subchannel);
- void compute_size_rendertarget(uint32_t chanel, uint32_t subchannel);
- void extract_packed_float(uint32_t data, float &first, float &second, float &third);
- void read_vertex(address_space &space, offs_t address, vertex_nv &vertex, int attrib);
- int read_vertices_0x180x(address_space &space, int destination, uint32_t address, int limit);
- int read_vertices_0x1810(address_space &space, int destination, int offset, int limit);
- int read_vertices_0x1818(address_space &space, int destination, uint32_t address, int limit);
- void convert_vertices(vertex_nv *source, nv2avertex_t *destination);
- void assemble_primitive(int source, int count);
- void process_persistent_vertex();
- int clip_triangle_w(nv2avertex_t vi[3], nv2avertex_t *vo);
- uint32_t render_triangle_clipping(const rectangle &cliprect, nv2avertex_t &_v1, nv2avertex_t &_v2, nv2avertex_t &_v3);
- uint32_t render_triangle_culling(const rectangle &cliprect, nv2avertex_t &_v1, nv2avertex_t &_v2, nv2avertex_t &_v3);
- void clear_render_target(int what, uint32_t value);
- void clear_depth_buffer(int what, uint32_t value);
- inline uint8_t *direct_access_ptr(offs_t address);
- TIMER_CALLBACK_MEMBER(puller_timer_work);
-
- nv2a_rasterizer rasterizer;
- running_machine &mach;
- struct {
- uint32_t regs[0x80 / 4];
- struct {
- uint32_t offset;
- uint32_t objclass;
- uint32_t method[0x2000 / 4];
- } object;
- } channel[32][8];
- uint32_t pfifo[0x2000 / 4];
- uint32_t pcrtc[0x1000 / 4];
- uint32_t pmc[0x1000 / 4];
- uint32_t pgraph[0x2000 / 4];
- uint32_t ramin[0x100000 / 4];
- uint32_t dma_offset[13];
- uint32_t dma_size[13];
- uint8_t *basemempointer = nullptr;
- uint8_t *topmempointer = nullptr;
- std::function<void(int state)> irq_callback;
- rectangle clippingwindows[8];
- rectangle limits_rendertarget;
- uint32_t pitch_rendertarget;
- uint32_t pitch_depthbuffer;
- uint32_t size_rendertarget;
- uint32_t size_depthbuffer;
- int log2height_rendertarget;
- int log2width_rendertarget;
- int dilate_rendertarget;
- int antialiasing_rendertarget;
- NV2A_RT_TYPE type_rendertarget;
- NV2A_RT_DEPTH_FORMAT depthformat_rendertarget;
- NV2A_COLOR_FORMAT colorformat_rendertarget;
- int bytespixel_rendertarget;
- rectangle clear_rendertarget;
- uint32_t antialias_control;
- float supersample_factor_x;
- float supersample_factor_y;
- uint32_t *rendertarget;
- uint32_t *depthbuffer;
- uint32_t *displayedtarget;
- uint32_t *old_rendertarget;
- struct {
- uint32_t address[16];
- int type[16];
- int stride[16];
- int words[16];
- int offset[16 + 1];
- int enabled; // bitmask
- } vertexbuffer;
- struct {
- int enabled;
- int sizes;
- int sizet;
- int sizer;
- int dilate;
- NV2A_TEX_FORMAT format;
- bool rectangle;
- int rectangle_pitch;
- void *buffer;
- int dma0;
- int dma1;
- int mode;
- int cubic;
- int noborder;
- int dims;
- int mipmap;
- int colorkey;
- int imagefield;
- int aniso;
- int mipmapmaxlod = 0;
- int mipmapminlod = 0;
- int rectheight = 0;
- int rectwidth = 0;
- int addrmodes;
- int addrmodet;
- int addrmoder;
- } texture[4];
- uint32_t triangles_bfculled;
- NV2A_BEGIN_END primitive_type;
- uint32_t primitives_count = 0;
- uint32_t primitives_total_count;
- uint32_t primitives_batches_count;
- int indexesleft_count;
- int indexesleft_first = 0;
- uint32_t vertex_indexes[1024]; // vertex indices sent by the software to the 3d accelerator
- int vertex_count = 0;
- unsigned int vertex_first = 0;
- int vertex_accumulated = 0;
- vertex_nv vertex_software[1024+2]; // vertex attributes sent by the software to the 3d accelerator
- nv2avertex_t vertex_xy[1024+2]; // vertex attributes computed by the 3d accelerator
- vertex_nv persistvertexattr; // persistent vertex attributes
- nv2a_rasterizer::render_delegate render_spans_callback;
- Combiner combiner;
- uint32_t color_mask;
- bool backface_culling_enabled;
- NV2A_GL_FRONT_FACE backface_culling_winding;
- NV2A_GL_CULL_FACE backface_culling_culled;
- bool alpha_test_enabled;
- bool depth_test_enabled;
- bool stencil_test_enabled;
- bool depth_write_enabled;
- bool blending_enabled;
- bool logical_operation_enabled;
- NV2A_COMPARISON_OP alpha_func;
- int alpha_reference;
- NV2A_COMPARISON_OP depth_function;
- NV2A_COMPARISON_OP stencil_func;
- int stencil_ref;
- int stencil_mask;
- NV2A_STENCIL_OP stencil_op_fail;
- NV2A_STENCIL_OP stencil_op_zfail;
- NV2A_STENCIL_OP stencil_op_zpass;
- NV2A_BLEND_EQUATION blend_equation;
- NV2A_BLEND_FACTOR blend_function_source;
- NV2A_BLEND_FACTOR blend_function_destination;
- uint32_t blend_color;
- NV2A_LOGIC_OP logical_operation;
- uint32_t fog_color;
- struct {
- float modelview[4][4];
- float modelview_inverse[4][4];
- float composite[4][4];
- float projection[4][4];
- float translate[4];
- float scale[4];
- } matrix;
- struct {
- vertex_program_simulator exec;
- int instructions;
- int upload_instruction_index;
- int upload_instruction_component;
- int start_instruction;
- int upload_parameter_index;
- int upload_parameter_component;
- } vertexprogram;
- int vertex_pipeline;
-
- struct {
- int format = 0;
- uint32_t pitch_source = 0;
- uint32_t pitch_destination = 0;
- offs_t source_address = 0;
- offs_t destination_address = 0;
- int op = 0;
- int width = 0;
- int heigth = 0;
- uint32_t sourcex = 0;
- uint32_t sourcey = 0;
- uint32_t destinationx = 0;
- uint32_t destinationy = 0;
- } bitblit;
- emu_timer *puller_timer = nullptr;
- int puller_waiting = 0;
- address_space *puller_space = nullptr;
- uint32_t dilated0[16][2048]{};
- uint32_t dilated1[16][2048]{};
- int dilatechose[256]{};
- nvidia_object_data *objectdata = nullptr;
- int debug_grab_texttype = 0;
- char *debug_grab_textfile = nullptr;
- bool enable_waitvblank = false;
- bool enable_clipping_w = false;
-};
-
-#endif // MAME_INCLUDES_XBOX_NV2A_H
diff --git a/src/mame/includes/xbox_pci.h b/src/mame/includes/xbox_pci.h
deleted file mode 100644
index 52e9e5c4a52..00000000000
--- a/src/mame/includes/xbox_pci.h
+++ /dev/null
@@ -1,492 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Samuele Zannoli
-#ifndef MAME_INCLUDES_XBOX_PCI_H
-#define MAME_INCLUDES_XBOX_PCI_H
-
-#pragma once
-
-#include "machine/pit8253.h"
-#include "xbox_nv2a.h"
-#include "xbox_usb.h"
-
-/*
- * Host
- */
-
-class nv2a_host_device : public pci_host_device {
-public:
- template <typename T>
- nv2a_host_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&cpu_tag)
- : nv2a_host_device(mconfig, tag, owner, clock)
- {
- set_ids_host(0x10de02a5, 0, 0);
- set_cpu_tag(std::forward<T>(cpu_tag));
- }
- nv2a_host_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual void map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space,
- uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space) override;
- template <typename T> void set_cpu_tag(T &&cpu_tag) { cpu.set_tag(std::forward<T>(cpu_tag)); }
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
-
-private:
- required_device<device_memory_interface> cpu;
-};
-
-DECLARE_DEVICE_TYPE(NV2A_HOST, nv2a_host_device)
-
-/*
- * Ram
- */
-
-class nv2a_ram_device : public pci_device {
-public:
- nv2a_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, int memory_size)
- : nv2a_ram_device(mconfig, tag, owner, clock)
- {
- ram_size = memory_size;
- }
- nv2a_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- virtual void config_map(address_map &map) override;
-
- virtual void map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space,
- uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space) override;
-
-protected:
- virtual void device_start() override;
-
- uint32_t config_register_r();
- void config_register_w(uint32_t data);
-
-private:
- int ram_size = 0;
- std::vector<uint32_t> ram;
-};
-
-DECLARE_DEVICE_TYPE(NV2A_RAM, nv2a_ram_device)
-
-/*
- * LPC Bus
- */
-
-class lpcbus_host_interface {
-public:
- virtual void set_virtual_line(int line, int state) = 0;
- virtual void remap() = 0;
-};
-
-class lpcbus_device_interface {
-public:
- virtual void map_extra(address_space *memory_space, address_space *io_space) = 0;
- virtual void set_host(int index, lpcbus_host_interface *host) = 0;
-};
-
-class mcpx_isalpc_device : public pci_device, public lpcbus_host_interface {
-public:
- mcpx_isalpc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, uint32_t subsystem_id);
- mcpx_isalpc_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- auto smi() { return m_smi_callback.bind(); }
- auto interrupt_output() { return m_interrupt_output.bind(); }
- auto boot_state_hook() { return m_boot_state_hook.bind(); }
-
- uint32_t acknowledge();
- void debug_generate_irq(int irq, int state);
-
- virtual void set_virtual_line(int line, int state) override;
- virtual void remap() override;
-
- uint32_t acpi_r(offs_t offset, uint32_t mem_mask = ~0);
- void acpi_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
- void boot_state_w(uint8_t data);
-
- DECLARE_WRITE_LINE_MEMBER(irq1);
- DECLARE_WRITE_LINE_MEMBER(irq3);
- DECLARE_WRITE_LINE_MEMBER(irq11);
- DECLARE_WRITE_LINE_MEMBER(irq10);
- DECLARE_WRITE_LINE_MEMBER(irq14);
- DECLARE_WRITE_LINE_MEMBER(irq15);
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
- virtual void device_add_mconfig(machine_config &config) override;
- virtual void map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space,
- uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space) override;
-
- DECLARE_WRITE_LINE_MEMBER(interrupt_ouptut_changed);
- uint8_t get_slave_ack(offs_t offset);
- DECLARE_WRITE_LINE_MEMBER(pit8254_out0_changed);
- DECLARE_WRITE_LINE_MEMBER(pit8254_out1_changed);
- DECLARE_WRITE_LINE_MEMBER(pit8254_out2_changed);
-
-private:
- void internal_io_map(address_map &map);
- void lpc_io(address_map &map);
- void update_smi_line();
- void speaker_set_spkrdata(uint8_t data);
-
- uint8_t portb_r();
- void portb_w(uint8_t data);
-
- devcb_write_line m_smi_callback;
- devcb_write_line m_interrupt_output;
- devcb_write8 m_boot_state_hook;
- required_device<pic8259_device> pic8259_1;
- required_device<pic8259_device> pic8259_2;
- required_device<pit8254_device> pit8254;
-
- uint16_t m_pm1_status;
- uint16_t m_pm1_enable;
- uint16_t m_pm1_control;
- uint16_t m_pm1_timer;
- uint16_t m_gpe0_status;
- uint16_t m_gpe0_enable;
- uint16_t m_global_smi_control;
- uint8_t m_smi_command_port;
- uint8_t m_gpio_mode[26];
- lpcbus_device_interface *lpcdevices[16];
- uint8_t m_speaker;
- bool m_refresh;
- uint8_t m_pit_out2;
- uint8_t m_spkrdata;
- uint8_t m_channel_check;
-};
-
-DECLARE_DEVICE_TYPE(MCPX_ISALPC, mcpx_isalpc_device)
-
-/*
- * SMBus
- */
-
-class smbus_interface {
-public:
- virtual int execute_command(int command, int rw, int data) = 0;
-};
-
-class mcpx_smbus_device : public pci_device {
-public:
- mcpx_smbus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, uint32_t subsystem_id);
- mcpx_smbus_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- auto interrupt_handler() { return m_interrupt_handler.bind(); }
-
- uint32_t smbus0_r(offs_t offset, uint32_t mem_mask = ~0);
- void smbus0_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
- uint32_t smbus1_r(offs_t offset, uint32_t mem_mask = ~0);
- void smbus1_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
-
- virtual void config_map(address_map &map) override;
-
-private:
- devcb_write_line m_interrupt_handler;
- struct smbus_state {
- int status;
- int control;
- int address;
- int data;
- int command;
- int rw;
- smbus_interface *devices[128];
- uint32_t words[256 / 4];
- } smbusst[2];
- void smbus_io0(address_map &map);
- void smbus_io1(address_map &map);
- void smbus_io2(address_map &map);
- uint32_t smbus_read(int bus, offs_t offset, uint32_t mem_mask);
- void smbus_write(int bus, offs_t offset, uint32_t data, uint32_t mem_mask);
- uint8_t minimum_grant_r() { return 3; }
- uint8_t maximum_latency_r() { return 1; }
-};
-
-DECLARE_DEVICE_TYPE(MCPX_SMBUS, mcpx_smbus_device)
-
-/*
- * OHCI USB Controller
- */
-class usb_function_device;
-class mcpx_ohci_device : public pci_device {
-public:
- mcpx_ohci_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, uint32_t subsystem_id);
- mcpx_ohci_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- void set_hack_callback(std::function<void(void)> hack) { hack_callback = hack; }
- void plug_usb_device(int port, device_usb_ohci_function_interface *function);
-
- auto interrupt_handler() { return m_interrupt_handler.bind(); }
-
- uint32_t ohci_r(offs_t offset);
- void ohci_w(offs_t offset, uint32_t data);
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
- virtual void device_config_complete() override;
-
- virtual void config_map(address_map &map) override;
-
- TIMER_CALLBACK_MEMBER(usb_update);
-
-private:
- ohci_usb_controller *ohci_usb;
- devcb_write_line m_interrupt_handler;
- emu_timer *timer;
- required_device<cpu_device> maincpu;
- std::function<void(void)> hack_callback;
- void ohci_mmio(address_map &map);
- struct dev_t {
- device_usb_ohci_function_interface *dev;
- int port;
- } connecteds[4];
- int connecteds_count;
- uint8_t minimum_grant_r() { return 3; }
- uint8_t maximum_latency_r() { return 1; }
-};
-
-DECLARE_DEVICE_TYPE(MCPX_OHCI, mcpx_ohci_device)
-
-/*
- * Ethernet
- */
-
-class mcpx_eth_device : public pci_device {
-public:
- mcpx_eth_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- uint32_t eth_r();
- void eth_w(uint32_t data);
- uint32_t eth_io_r();
- void eth_io_w(uint32_t data);
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
-
-private:
- void eth_mmio(address_map &map);
- void eth_io(address_map &map);
-};
-
-DECLARE_DEVICE_TYPE(MCPX_ETH, mcpx_eth_device)
-
-/*
- * Audio Processing Unit
- */
-
-class mcpx_apu_device : public pci_device {
-public:
- template <typename T>
- mcpx_apu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, uint32_t subsystem_id, T &&cpu_tag)
- : mcpx_apu_device(mconfig, tag, owner, clock)
- {
- set_ids(0x10de01b0, 0xc2, 0x040100, subsystem_id);
- set_cpu_tag(std::forward<T>(cpu_tag));
- }
- mcpx_apu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- template <typename T> void set_cpu_tag(T &&cpu_tag) { cpu.set_tag(std::forward<T>(cpu_tag)); }
-
- uint32_t apu_r(offs_t offset, uint32_t mem_mask = ~0);
- void apu_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
-
- virtual void config_map(address_map &map) override;
-
- TIMER_CALLBACK_MEMBER(audio_update);
-
-private:
- required_device<device_memory_interface> cpu;
- // APU contains 3 dsps: voice processor (VP) global processor (GP) encode processor (EP)
- struct apu_state {
- uint32_t memory[0x60000 / 4]{};
- uint32_t gpdsp_sgaddress = 0; // global processor scatter-gather
- uint32_t gpdsp_sgblocks = 0;
- uint32_t gpdsp_address = 0;
- uint32_t epdsp_sgaddress = 0; // encoder processor scatter-gather
- uint32_t epdsp_sgblocks = 0;
- uint32_t epdsp_sgaddress2 = 0;
- uint32_t epdsp_sgblocks2 = 0;
- int voice_number = 0;
- uint32_t voices_heap_blockaddr[1024]{};
- uint64_t voices_active[4]{}; //one bit for each voice: 1 playing 0 not
- uint32_t voicedata_address = 0;
- int voices_frequency[256]{}; // sample rate
- int voices_position[256]{}; // position in samples * 1000
- int voices_position_start[256]{}; // position in samples * 1000
- int voices_position_end[256]{}; // position in samples * 1000
- int voices_position_increment[256]{}; // position increment every 1ms * 1000
- emu_timer *timer = nullptr;
- address_space *space = nullptr;
- } apust;
- void apu_mmio(address_map &map);
- uint8_t minimum_grant_r() { return 1; }
- uint8_t maximum_latency_r() { return 0xc; }
-};
-
-DECLARE_DEVICE_TYPE(MCPX_APU, mcpx_apu_device)
-
-/*
- * AC97 Audio Controller
- */
-
-class mcpx_ac97_audio_device : public pci_device {
-public:
- mcpx_ac97_audio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, uint32_t subsystem_id);
- mcpx_ac97_audio_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- uint32_t ac97_audio_r(offs_t offset, uint32_t mem_mask = ~0);
- void ac97_audio_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
- uint32_t ac97_audio_io0_r();
- void ac97_audio_io0_w(uint32_t data);
- uint32_t ac97_audio_io1_r();
- void ac97_audio_io1_w(uint32_t data);
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
-
- virtual void config_map(address_map &map) override;
-
-private:
- struct ac97_state {
- uint32_t mixer_regs[0x84 / 4];
- uint32_t controller_regs[0x40 / 4];
- } ac97st;
- void ac97_mmio(address_map &map);
- void ac97_io0(address_map &map);
- void ac97_io1(address_map &map);
- uint8_t minimum_grant_r() { return 2; }
- uint8_t maximum_latency_r() { return 5; }
-};
-
-DECLARE_DEVICE_TYPE(MCPX_AC97_AUDIO, mcpx_ac97_audio_device)
-
-/*
- * AC97 Modem Controller
- */
-
-class mcpx_ac97_modem_device : public pci_device {
-public:
- mcpx_ac97_modem_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-};
-
-DECLARE_DEVICE_TYPE(MCPX_AC97_MODEM, mcpx_ac97_modem_device)
-
-/*
- * IDE Controller
- */
-
-class mcpx_ide_device : public pci_device {
-public:
- mcpx_ide_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, uint32_t subsystem_id);
- mcpx_ide_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- auto pri_interrupt_handler() { return m_pri_interrupt_handler.bind(); }
- auto sec_interrupt_handler() { return m_sec_interrupt_handler.bind(); }
-
- void class_rev_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
- uint8_t pri_read_cs1_r();
- void pri_write_cs1_w(uint8_t data);
- uint8_t sec_read_cs1_r();
- void sec_write_cs1_w(uint8_t data);
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
- virtual void device_add_mconfig(machine_config &config) override;
- virtual void map_extra(uint64_t memory_window_start, uint64_t memory_window_end, uint64_t memory_offset, address_space *memory_space,
- uint64_t io_window_start, uint64_t io_window_end, uint64_t io_offset, address_space *io_space) override;
-
- virtual void config_map(address_map &map) override;
-
-private:
- required_device<bus_master_ide_controller_device> m_pri;
- required_device<bus_master_ide_controller_device> m_sec;
- devcb_write_line m_pri_interrupt_handler;
- devcb_write_line m_sec_interrupt_handler;
- void ide_pri_command(address_map &map);
- void ide_pri_control(address_map &map);
- void ide_sec_command(address_map &map);
- void ide_sec_control(address_map &map);
- void ide_io(address_map &map);
- DECLARE_WRITE_LINE_MEMBER(ide_pri_interrupt);
- DECLARE_WRITE_LINE_MEMBER(ide_sec_interrupt);
- uint8_t minimum_grant_r() { return 3; }
- uint8_t maximum_latency_r() { return 1; }
-};
-
-DECLARE_DEVICE_TYPE(MCPX_IDE, mcpx_ide_device)
-
-
-/*
- * AGP Bridge
- */
-
-class nv2a_agp_device : public agp_bridge_device {
-public:
- nv2a_agp_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, uint32_t main_id, uint32_t revision)
- : nv2a_agp_device(mconfig, tag, owner, clock)
- {
- set_ids_bridge(main_id, revision);
- }
- nv2a_agp_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
-
- void config_map(address_map& map) override;
-
- uint32_t unknown_r(offs_t offset, uint32_t mem_mask = ~0);
- void unknown_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
-};
-
-DECLARE_DEVICE_TYPE(NV2A_AGP, nv2a_agp_device)
-
-/*
- * NV2A 3D Accelerator
- */
-
-class nv2a_gpu_device : public agp_device {
-public:
- template <typename T>
- nv2a_gpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&cpu_tag)
- : nv2a_gpu_device(mconfig, tag, owner, clock)
- {
- set_cpu_tag(std::forward<T>(cpu_tag));
- }
- nv2a_gpu_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- template <typename T> void set_cpu_tag(T &&cpu_tag) { cpu.set_tag(std::forward<T>(cpu_tag)); }
- nv2a_renderer *debug_get_renderer() { return nvidia_nv2a; }
-
- auto interrupt_handler() { return m_interrupt_handler.bind(); }
-
- uint32_t geforce_r(offs_t offset, uint32_t mem_mask = ~0);
- void geforce_w(address_space &space, offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
- uint32_t nv2a_mirror_r(offs_t offset, uint32_t mem_mask = ~0);
- void nv2a_mirror_w(offs_t offset, uint32_t data, uint32_t mem_mask = ~0);
-
-protected:
- virtual void device_start() override;
- virtual void device_reset() override;
-
-private:
- nv2a_renderer *nvidia_nv2a;
- required_device<device_memory_interface> cpu;
- devcb_write_line m_interrupt_handler;
- address_space *m_program;
- void nv2a_mmio(address_map &map);
- void nv2a_mirror(address_map &map);
-};
-
-DECLARE_DEVICE_TYPE(NV2A_GPU, nv2a_gpu_device)
-
-#endif // MAME_INCLUDES_XBOX_PCI_H
diff --git a/src/mame/includes/xbox_usb.h b/src/mame/includes/xbox_usb.h
deleted file mode 100644
index 495e68ad749..00000000000
--- a/src/mame/includes/xbox_usb.h
+++ /dev/null
@@ -1,534 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Samuele Zannoli
-#ifndef MAME_INCLUDES_XBOX_USB_H
-#define MAME_INCLUDES_XBOX_USB_H
-
-#pragma once
-
-#include <forward_list>
-#include <functional>
-#include <memory>
-
-
-struct OHCIEndpointDescriptor {
- int mps = 0; // MaximumPacketSize
- int f = 0; // Format
- int k = 0; // sKip
- int s = 0; // Speed
- int d = 0; // Direction
- int en = 0; // EndpointNumber
- int fa = 0; // FunctionAddress
- uint32_t tailp = 0; // TDQueueTailPointer
- uint32_t headp = 0; // TDQueueHeadPointer
- uint32_t nexted = 0; // NextED
- int c = 0; // toggleCarry
- int h = 0; // Halted
- uint32_t word0 = 0;
-};
-
-struct OHCITransferDescriptor {
- int cc = 0; // ConditionCode
- int ec = 0; // ErrorCount
- int t = 0; // DataToggle
- int di = 0; // DelayInterrupt
- int dp = 0; // Direction/PID
- int r = 0; // bufferRounding
- uint32_t cbp = 0; // CurrentBufferPointer
- uint32_t nexttd = 0; // NextTD
- uint32_t be = 0; // BufferEnd
- uint32_t word0 = 0;
-};
-
-struct OHCIIsochronousTransferDescriptor {
- int cc = 0; // ConditionCode
- int fc = 0; // FrameCount
- int di = 0; // DelayInterrupt
- int sf = 0; // StartingFrame
- uint32_t bp0 = 0; // BufferPage0
- uint32_t nexttd = 0; // NextTD
- uint32_t be = 0; // BufferEnd
- uint32_t offset[8]{}; // Offset/PacketStatusWord
- uint32_t word0 = 0;
- uint32_t word1 = 0;
-};
-
-enum OHCIRegisters {
- HcRevision=0,
- HcControl,
- HcCommandStatus,
- HcInterruptStatus,
- HcInterruptEnable,
- HcInterruptDisable,
- HcHCCA,
- HcPeriodCurrentED,
- HcControlHeadED,
- HcControlCurrentED,
- HcBulkHeadED,
- HcBulkCurrentED,
- HcDoneHead,
- HcFmInterval,
- HcFmRemaining,
- HcFmNumber,
- HcPeriodicStart,
- HcLSThreshold,
- HcRhDescriptorA,
- HcRhDescriptorB,
- HcRhStatus,
- HcRhPortStatus1
-};
-
-enum HcControlBits
-{
- CBSR = 3 << 0, // ControlBulkServiceRatio
- PLE = 1 << 2, // PeriodicListEnable
- IE = 1 << 3, // IsochronousEnable
- CLE = 1 << 4, // ControlListEnable
- BLE = 1 << 5, // BulkListEnable
- HCFS = 3 << 6, // HostControllerFunctionalState
- IR = 1 << 8, // InterruptRouting
- RWC = 1 << 9, // RemoteWakeupConnected
- RWE = 1 << 10 // RemoteWakeupEnable
-};
-
-enum HcCommandStatusBits
-{
- HCR = 1 << 0, // HostControllerReset
- CLF = 1 << 1, // ControlListFilled
- BLF = 1 << 2, // BulkListFilled
- OCR = 1 << 3, // OwnershipChangeRequest
- SOC = 3 << 16 // SchedulingOverrunCount
-};
-
-enum HcInterruptEnableBits
-{
- SO = 1 << 0, // SchedulingOverrun
- WDH = 1 << 1, // WritebackDoneHead
- SF = 1 << 2, // StartofFrame
- RD = 1 << 3, // ResumeDetected
- UE = 1 << 4, // UnrecoverableError
- FNO = 1 << 5, // FrameNumberOverflow
- RHSC = 1 << 6, // RootHubStatusChange
- OC = 1 << 30, // OwnershipChange
- MIE = 1 << 31, // MasterInterruptEnable
-};
-
-
-enum HcRhDescriptorABits
-{
- NDP = 0xff << 0, // NumberDownstreamPorts
- PSM = 1 << 8, // PowerSwitchingMode
- NPS = 1 << 9, // NoPowerSwitching
- DT = 1 << 10, // DeviceType
- OCPM = 1 << 11, // OverCurrentProtectionMode
- NOCPM = 1 << 12, // NoOverCurrentProtection
- POTPGT = 0xff << 24 // PowerOnToPowerGoodTime
-};
-
-enum HcRhDescriptorBBits
-{
- DR = 0xffff << 0, // DeviceRemovable
- PPCM = 0xffff << 16 // PortPowerControlMask
-};
-
-enum HcRhStatusBits
-{
- LPS = 1 << 0, // LocalPowerStatus
- OCI = 1 << 1, // OverCurrentIndicator
- DRWE = 1 << 15, // DeviceRemoteWakeupEnable
- LPSC = 1 << 16, // LocalPowerStatusChange
- OCIC = 1 << 17, // OverCurrentIndicatorChange
- CRWE = 1 << 31, // ClearRemoteWakeupEnable
-};
-
-enum HcRhPortStatusBits
-{
- CCS = 1 << 0, // CurrentConnectStatus
- PES = 1 << 1, // PortEnableStatus
- PSS = 1 << 2, // PortSuspendStatus
- POCI = 1 << 3, // PortOverCurrentIndicator
- PRS = 1 << 4, // PortResetStatus
- PPS = 1 << 8, // PortPowerStatus
- LSDA = 1 << 9, // LowSpeedDeviceAttached
- CSC = 1 << 16, // ConnectStatusChange
- PESC = 1 << 17, // PortEnableStatusChange
- PSSC = 1 << 18, // PortSuspendStatusChange
- POCIC = 1 << 19, // PortOverCurrentIndicatorChange
- PRSC = 1 << 20 // PortResetStatusChange
-};
-
-enum OHCIHostControllerFunctionalState {
- UsbReset=0,
- UsbResume,
- UsbOperational,
- UsbSuspend
-};
-
-enum OHCIInterrupt {
- SchedulingOverrun=1,
- WritebackDoneHead=2,
- StartofFrame=4,
- ResumeDetected=8,
- UnrecoverableError=16,
- FrameNumberOverflow=32,
- RootHubStatusChange=64,
- OwnershipChange=0x40000000,
- MasterInterruptEnable=0x80000000
-};
-
-enum OHCICompletionCode {
- NoError=0,
- CRC,
- BitStuffing,
- DataToggleMismatch,
- Stall,
- DeviceNotResponding,
- PIDCheckFailure,
- UnexpectedPID,
- DataOverrun,
- DataUnderrun,
- BufferOverrun=12,
- BufferUnderrun,
- NotAccessed=14
-};
-
-struct USBSetupPacket {
- uint8_t bmRequestType = 0;
- uint8_t bRequest = 0;
- uint16_t wValue = 0;
- uint16_t wIndex = 0;
- uint16_t wLength = 0;
-};
-
-struct USBStandardDeviceDescriptor {
- uint8_t bLength = 0;
- uint8_t bDescriptorType = 0;
- uint16_t bcdUSB = 0;
- uint8_t bDeviceClass = 0;
- uint8_t bDeviceSubClass = 0;
- uint8_t bDeviceProtocol = 0;
- uint8_t bMaxPacketSize0 = 0;
- uint16_t idVendor = 0;
- uint16_t idProduct = 0;
- uint16_t bcdDevice = 0;
- uint8_t iManufacturer = 0;
- uint8_t iProduct = 0;
- uint8_t iSerialNumber = 0;
- uint8_t bNumConfigurations = 0;
-};
-
-struct USBStandardConfigurationDescriptor {
- uint8_t bLength = 0;
- uint8_t bDescriptorType = 0;
- uint16_t wTotalLength = 0;
- uint8_t bNumInterfaces = 0;
- uint8_t bConfigurationValue = 0;
- uint8_t iConfiguration = 0;
- uint8_t bmAttributes = 0;
- uint8_t MaxPower = 0;
-};
-
-struct USBStandardInterfaceDescriptor {
- uint8_t bLength = 0;
- uint8_t bDescriptorType = 0;
- uint8_t bInterfaceNumber = 0;
- uint8_t bAlternateSetting = 0;
- uint8_t bNumEndpoints = 0;
- uint8_t bInterfaceClass = 0;
- uint8_t bInterfaceSubClass = 0;
- uint8_t bInterfaceProtocol = 0;
- uint8_t iInterface = 0;
-};
-
-struct USBStandardEndpointDescriptor {
- uint8_t bLength = 0;
- uint8_t bDescriptorType = 0;
- uint8_t bEndpointAddress = 0;
- uint8_t bmAttributes = 0;
- uint16_t wMaxPacketSize = 0;
- uint8_t bInterval = 0;
-};
-
-enum USBPid {
- SetupPid=0,
- OutPid,
- InPid
-};
-
-enum USBRequestCode {
- GET_STATUS=0,
- CLEAR_FEATURE=1,
- SET_FEATURE=3,
- SET_ADDRESS=5,
- GET_DESCRIPTOR=6,
- SET_DESCRIPTOR=7,
- GET_CONFIGURATION=8,
- SET_CONFIGURATION=9,
- GET_INTERFACE=10,
- SET_INTERFACE=11,
- SYNCH_FRAME=12
-};
-
-enum USBDescriptorType {
- DEVICE=1,
- CONFIGURATION=2,
- STRING=3,
- INTERFACE=4,
- ENDPOINT=5
-};
-
-enum USBRequestType
-{
- StandardType=0,
- ClassType,
- VendorType,
- ReservedType
-};
-
-enum USBRequestRecipient
-{
- DeviceRecipient=0,
- InterfaceRecipient,
- EndpointRecipient,
- OtherRecipient
-};
-
-enum USBDeviceState
-{
- DefaultState,
- AddressState,
- ConfiguredState
-};
-
-enum USBControlDirection
-{
- HostToDevice=0,
- DeviceToHost=1
-};
-
-enum USBEndpointType
-{
- ControlEndpoint=0,
- IsochronousEndpoint,
- BulkEndpoint,
- InterruptEndpoint
-};
-
-struct usb_device_string
-{
- uint8_t *position = nullptr;
- int size = 0;
-};
-
-struct usb_device_interfac_alternate
-{
- uint8_t *position = nullptr;
- int size = 0;
- USBStandardInterfaceDescriptor interface_descriptor;
- std::forward_list<USBStandardEndpointDescriptor> endpoint_descriptors;
-};
-
-struct usb_device_interfac
-{
- uint8_t *position = nullptr;
- int size = 0;
- std::forward_list<usb_device_interfac_alternate> alternate_settings;
- int selected_alternate;
-};
-
-struct usb_device_configuration
-{
- USBStandardConfigurationDescriptor configuration_descriptor;
- uint8_t *position = nullptr;
- int size = 0;
- std::forward_list<usb_device_interfac> interfaces;
-};
-
-/*
- * OHCI Usb Controller
- */
-
-class device_usb_ohci_function_interface; // forward declaration
-
-class ohci_usb_controller
-{
-public:
- ohci_usb_controller();
- ~ohci_usb_controller() {}
- void usb_ohci_plug(int port, device_usb_ohci_function_interface *function);
- void usb_ohci_device_address_changed(int old_address, int new_address);
- void set_cpu(cpu_device *cpu) { m_maincpu = cpu; }
- void set_timer(emu_timer *timer) { ohcist.timer = timer; }
- void set_irq_callback(std::function<void(int state)> callback) { irq_callback = callback; }
-
- void start();
- void reset();
- void timer(int param);
-
- uint32_t read(offs_t offset);
- void write(offs_t offset, uint32_t data);
-
-private:
- void usb_ohci_interrupts();
- void usb_ohci_read_endpoint_descriptor(uint32_t address);
- void usb_ohci_writeback_endpoint_descriptor(uint32_t address);
- void usb_ohci_read_transfer_descriptor(uint32_t address);
- void usb_ohci_writeback_transfer_descriptor(uint32_t address);
- void usb_ohci_read_isochronous_transfer_descriptor(uint32_t address);
- void usb_ohci_writeback_isochronous_transfer_descriptor(uint32_t address);
- std::function<void (int state)> irq_callback;
- cpu_device *m_maincpu = nullptr;
- struct {
- uint32_t hc_regs[256]{};
- struct {
- device_usb_ohci_function_interface *function = nullptr;
- int address = 0;
- int delay = 0;
- } ports[4 + 1];
- struct
- {
- device_usb_ohci_function_interface *function = nullptr;
- int port = 0;
- } address[256];
- emu_timer *timer = nullptr;
- int state = 0;
- uint32_t framenumber = 0;
- uint32_t nextinterupted = 0;
- uint32_t nextbulked = 0;
- int interruptbulkratio = 0;
- int writebackdonehadcounter = 0;
- address_space *space = nullptr;
- uint8_t buffer[1024]{};
- OHCIEndpointDescriptor endpoint_descriptor;
- OHCITransferDescriptor transfer_descriptor;
- OHCIIsochronousTransferDescriptor isochronous_transfer_descriptor;
- } ohcist;
-};
-
-/*
- * Base class for usb devices
- */
-
-class device_usb_ohci_function_interface : public device_interface {
-public:
- virtual void initialize();
- virtual void execute_reset();
- virtual void execute_connect() {}
- virtual void execute_disconnect() {}
- void set_bus_manager(ohci_usb_controller *usb_bus_manager);
- int execute_transfer(int endpoint, int pid, uint8_t *buffer, int size);
-protected:
- device_usb_ohci_function_interface(const machine_config &config, device_t &device);
- virtual int handle_nonstandard_request(int endpoint, USBSetupPacket *setup) { return -1; }
- virtual int handle_get_status_request(int endpoint, USBSetupPacket *setup) { return 0; }
- virtual int handle_clear_feature_request(int endpoint, USBSetupPacket *setup) { return 0; }
- virtual int handle_set_feature_request(int endpoint, USBSetupPacket *setup) { return 0; }
- virtual int handle_set_descriptor_request(int endpoint, USBSetupPacket *setup) { return 0; }
- virtual int handle_synch_frame_request(int endpoint, USBSetupPacket *setup) { return 0; }
- virtual void handle_status_stage(int endpoint) { return; }
- virtual int handle_bulk_pid(int endpoint, int pid, uint8_t *buffer, int size) { return 0; }
- virtual int handle_interrupt_pid(int endpoint, int pid, uint8_t *buffer, int size) { return 0; }
- virtual int handle_isochronous_pid(int endpoint, int pid, uint8_t *buffer, int size) { return 0; }
-
- void add_device_descriptor(const USBStandardDeviceDescriptor &descriptor);
- void add_configuration_descriptor(const USBStandardConfigurationDescriptor &descriptor);
- void add_interface_descriptor(const USBStandardInterfaceDescriptor &descriptor);
- void add_endpoint_descriptor(const USBStandardEndpointDescriptor &descriptor);
- void add_string_descriptor(const uint8_t *descriptor);
- void select_configuration(int index);
- void select_alternate(int interfacei, int index);
- int find_alternate(int interfacei);
- uint8_t *position_device_descriptor(int &size);
- uint8_t *position_configuration_descriptor(int index, int &size);
- uint8_t *position_string_descriptor(int index, int &size);
- ohci_usb_controller *busmanager = nullptr;
- struct {
- int type = 0;
- int controldirection = 0;
- int controltype = 0;
- int controlrecipient = 0;
- int remain = 0;
- uint8_t *position = nullptr;
- uint8_t buffer[128]{};
- } endpoints[256];
- int state = 0;
- bool settingaddress = false;
- int newaddress = 0;
- int address = 0;
- int configurationvalue = 0;
- std::unique_ptr<uint8_t []> descriptors;
- int descriptors_pos = 0;
- bool wantstatuscallback = false;
- USBStandardDeviceDescriptor device_descriptor;
- std::forward_list<usb_device_configuration> configurations;
- std::forward_list<usb_device_string> device_strings;
- usb_device_configuration *latest_configuration = nullptr;
- usb_device_interfac_alternate *latest_alternate = nullptr;
- usb_device_configuration *selected_configuration = nullptr;
-};
-
-/*
- * Usb port connector
- */
-
-class ohci_usb_connector : public device_t, public device_single_card_slot_interface<device_usb_ohci_function_interface>
-{
-public:
- template <typename T>
- ohci_usb_connector(const machine_config &mconfig, const char *tag, device_t *owner, T &&opts, const char *dflt, bool fixed)
- : ohci_usb_connector(mconfig, tag, owner, 0)
- {
- option_reset();
- opts(*this);
- set_default_option(dflt);
- set_fixed(fixed);
- }
-
- ohci_usb_connector(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- virtual ~ohci_usb_connector();
-
-protected:
- virtual void device_start() override;
-};
-
-DECLARE_DEVICE_TYPE(OHCI_USB_CONNECTOR, ohci_usb_connector)
-
-/*
- * Game controller usb device
- */
-
-DECLARE_DEVICE_TYPE(OHCI_GAME_CONTROLLER, ohci_game_controller_device)
-
-class ohci_game_controller_device : public device_t, public device_usb_ohci_function_interface
-{
-public:
- ohci_game_controller_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
- void initialize() override;
- int handle_nonstandard_request(int endpoint, USBSetupPacket *setup) override;
- int handle_interrupt_pid(int endpoint, int pid, uint8_t *buffer, int size) override;
-
-protected:
- virtual void device_start() override;
- virtual ioport_constructor device_input_ports() const override;
-private:
- static const USBStandardDeviceDescriptor devdesc;
- static const USBStandardConfigurationDescriptor condesc;
- static const USBStandardInterfaceDescriptor intdesc;
- static const USBStandardEndpointDescriptor enddesc82;
- static const USBStandardEndpointDescriptor enddesc02;
- required_ioport m_ThumbstickLh; // left analog thumbstick horizontal movement
- required_ioport m_ThumbstickLv; // left analog thumbstick vertical movement
- required_ioport m_ThumbstickRh; // right analog thumbstick horizontal movement
- required_ioport m_ThumbstickRv; // right analog thumbstick vertical movement
- required_ioport m_DPad; // pressure sensitive directional pad
- required_ioport m_TriggerL; // analog trigger
- required_ioport m_TriggerR; // analog trigger
- required_ioport m_Buttons; // digital buttons
- required_ioport m_AGreen; // analog button
- required_ioport m_BRed; // analog button
- required_ioport m_XBlue; // analog button
- required_ioport m_YYellow; // analog button
- required_ioport m_Black; // analog button
- required_ioport m_White; // analog button
-};
-
-#endif // MAME_INCLUDES_XBOX_USB_H