mirror of
https://github.com/OpenDriver2/REDRIVER2.git
synced 2024-11-22 02:12:43 +01:00
- add TOMB5 emulator code
This commit is contained in:
parent
62a0eda4d6
commit
08403ce5c4
2
.gitignore
vendored
2
.gitignore
vendored
@ -25,5 +25,5 @@ TDR/*
|
||||
xmplayer/*
|
||||
game_rebuild/*
|
||||
src_rebuild/dependencies/*
|
||||
src_rebuild/EMULATOR/*
|
||||
# src_rebuild/EMULATOR/*
|
||||
src_rebuild/.vs/*
|
7
src_rebuild/EMULATOR/ABS.C
Normal file
7
src_rebuild/EMULATOR/ABS.C
Normal file
@ -0,0 +1,7 @@
|
||||
#include "ABS.H"
|
||||
|
||||
/*int abs(int input)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}*/
|
10
src_rebuild/EMULATOR/ABS.H
Normal file
10
src_rebuild/EMULATOR/ABS.H
Normal file
@ -0,0 +1,10 @@
|
||||
/*#ifndef ABS_H
|
||||
#define ABS_H
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(x) (((x)>=0)?(x):(-(x)))
|
||||
#endif
|
||||
|
||||
//extern int abs(int input);
|
||||
|
||||
#endif*/
|
150
src_rebuild/EMULATOR/ASM.H
Normal file
150
src_rebuild/EMULATOR/ASM.H
Normal file
@ -0,0 +1,150 @@
|
||||
#ifndef ASM_H
|
||||
#define ASM_H
|
||||
|
||||
#define R0 $0
|
||||
#define R1 $1
|
||||
#define R2 $2
|
||||
#define R3 $3
|
||||
#define R4 $4
|
||||
#define R5 $5
|
||||
#define R6 $6
|
||||
#define R7 $7
|
||||
#define R8 $8
|
||||
#define R9 $9
|
||||
#define R10 $10
|
||||
#define R11 $11
|
||||
#define R12 $12
|
||||
#define R13 $13
|
||||
#define R14 $14
|
||||
#define R15 $15
|
||||
#define R16 $16
|
||||
#define R17 $17
|
||||
#define R18 $18
|
||||
#define R19 $19
|
||||
#define R20 $20
|
||||
#define R21 $21
|
||||
#define R22 $22
|
||||
#define R23 $23
|
||||
#define R24 $24
|
||||
#define R25 $25
|
||||
#define R26 $26
|
||||
#define R27 $27
|
||||
#define R28 $28
|
||||
#define R29 $29
|
||||
#define R30 $30
|
||||
#define R31 $31
|
||||
|
||||
#if defined(_LANGUAGE_C)||defined(LANGUAGE_C)||defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
#else
|
||||
#define zero $0 /* wired zero */
|
||||
#define AT $1 /* assembler temp */
|
||||
#define v0 $2 /* return value */
|
||||
#define v1 $3
|
||||
#define a0 $4 /* argument registers */
|
||||
#define a1 $5
|
||||
#define a2 $6
|
||||
#define a3 $7
|
||||
#define t0 $8 /* caller saved */
|
||||
#define t1 $9
|
||||
#define t2 $10
|
||||
#define t3 $11
|
||||
#define t4 $12
|
||||
#define t5 $13
|
||||
#define t6 $14
|
||||
#define t7 $15
|
||||
#define s0 $16 /* callee saved */
|
||||
#define s1 $17
|
||||
#define s2 $18
|
||||
#define s3 $19
|
||||
#define s4 $20
|
||||
#define s5 $21
|
||||
#define s6 $22
|
||||
#define s7 $23
|
||||
#define t8 $24 /* code generator */
|
||||
#define t9 $25
|
||||
#define k0 $26 /* kernel temporary */
|
||||
#define k1 $27
|
||||
#define gp $28 /* global pointer */
|
||||
#define sp $29 /* stack pointer */
|
||||
#define fp $30 /* frame pointer */
|
||||
#define ra $31 /* return address */
|
||||
#endif
|
||||
|
||||
|
||||
/* register offset */
|
||||
#define R_R0 0
|
||||
#define R_R1 1
|
||||
#define R_R2 2
|
||||
#define R_R3 3
|
||||
#define R_R4 4
|
||||
#define R_R5 5
|
||||
#define R_R6 6
|
||||
#define R_R7 7
|
||||
#define R_R8 8
|
||||
#define R_R9 9
|
||||
#define R_R10 10
|
||||
#define R_R11 11
|
||||
#define R_R12 12
|
||||
#define R_R13 13
|
||||
#define R_R14 14
|
||||
#define R_R15 15
|
||||
#define R_R16 16
|
||||
#define R_R17 17
|
||||
#define R_R18 18
|
||||
#define R_R19 19
|
||||
#define R_R20 20
|
||||
#define R_R21 21
|
||||
#define R_R22 22
|
||||
#define R_R23 23
|
||||
#define R_R24 24
|
||||
#define R_R25 25
|
||||
#define R_R26 26
|
||||
#define R_R27 27
|
||||
#define R_R28 28
|
||||
#define R_R29 29
|
||||
#define R_R30 30
|
||||
#define R_R31 31
|
||||
#define R_EPC 32
|
||||
#define R_MDHI 33
|
||||
#define R_MDLO 34
|
||||
#define R_SR 35
|
||||
#define R_CAUSE 36
|
||||
#define NREGS 40
|
||||
|
||||
/*
|
||||
* compiler defined bindings
|
||||
*/
|
||||
#define R_ZERO R_R0
|
||||
#define R_AT R_R1
|
||||
#define R_V0 R_R2
|
||||
#define R_V1 R_R3
|
||||
#define R_A0 R_R4
|
||||
#define R_A1 R_R5
|
||||
#define R_A2 R_R6
|
||||
#define R_A3 R_R7
|
||||
#define R_T0 R_R8
|
||||
#define R_T1 R_R9
|
||||
#define R_T2 R_R10
|
||||
#define R_T3 R_R11
|
||||
#define R_T4 R_R12
|
||||
#define R_T5 R_R13
|
||||
#define R_T6 R_R14
|
||||
#define R_T7 R_R15
|
||||
#define R_S0 R_R16
|
||||
#define R_S1 R_R17
|
||||
#define R_S2 R_R18
|
||||
#define R_S3 R_R19
|
||||
#define R_S4 R_R20
|
||||
#define R_S5 R_R21
|
||||
#define R_S6 R_R22
|
||||
#define R_S7 R_R23
|
||||
#define R_T8 R_R24
|
||||
#define R_T9 R_R25
|
||||
#define R_K0 R_R26
|
||||
#define R_K1 R_R27
|
||||
#define R_GP R_R28
|
||||
#define R_SP R_R29
|
||||
#define R_FP R_R30
|
||||
#define R_RA R_R31
|
||||
|
||||
#endif
|
48
src_rebuild/EMULATOR/CMakeLists.txt
Normal file
48
src_rebuild/EMULATOR/CMakeLists.txt
Normal file
@ -0,0 +1,48 @@
|
||||
cmake_minimum_required (VERSION 3.0)
|
||||
|
||||
project (Emulator_${TARGET_ARCH})
|
||||
|
||||
set(OPT_DEFINITIONS "")
|
||||
|
||||
#Extract current source folder name.
|
||||
get_filename_component(PLATFORM_SPECIFIC_FOLDER_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
||||
|
||||
#Enable NTSC mode
|
||||
OPTIONAL_DEFINE(NTSC_VERSION "Enable/Disable NTSC Mode" ON)
|
||||
|
||||
#Enable 32-bit address for tag
|
||||
OPTIONAL_DEFINE(USE_32_BIT_ADDR "Enable/Disable 32-bit address for tag" ON)
|
||||
|
||||
#Setup platform specific / game code include folder
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
|
||||
#Recursively locate the source files for SPEC_PSX.
|
||||
file(GLOB_RECURSE EMULATOR_SPECIFIC_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/*.C ${CMAKE_CURRENT_SOURCE_DIR}/*.S ${CMAKE_CURRENT_SOURCE_DIR}/*.H ${CMAKE_CURRENT_SOURCE_DIR}/*.CUR ${CMAKE_CURRENT_SOURCE_DIR}/*.RC)
|
||||
|
||||
#Group solution source files to correct folders.
|
||||
source_group(${PLATFORM_SPECIFIC_FOLDER_NAME} FILES ${EMULATOR_SPECIFIC_SRCS})
|
||||
|
||||
if(NOT ANDROID)
|
||||
add_library(
|
||||
${PROJECT_NAME}
|
||||
STATIC
|
||||
${EMULATOR_SPECIFIC_SRCS}
|
||||
)
|
||||
endif()
|
||||
|
||||
#Include all platform specific cmake files.
|
||||
include("PLATFORM/Windows.cmake")
|
||||
include("PLATFORM/Mingw.cmake")
|
||||
include("PLATFORM/Linux.cmake")
|
||||
include("PLATFORM/Emscripten.cmake")
|
||||
include("PLATFORM/Android.cmake")
|
||||
|
||||
if (NOT ANDROID)
|
||||
BuildPreProcessorDefinitions()
|
||||
target_compile_definitions(${PROJECT_NAME} PRIVATE GLEW_STATIC)
|
||||
|
||||
set_target_properties(
|
||||
${PROJECT_NAME} PROPERTIES OUTPUT_NAME "PSX"
|
||||
${PROJECT_NAME} PROPERTIES FOLDER "Libs"
|
||||
)
|
||||
endif()
|
30
src_rebuild/EMULATOR/CRASHHANDLER.C
Normal file
30
src_rebuild/EMULATOR/CRASHHANDLER.C
Normal file
@ -0,0 +1,30 @@
|
||||
#ifdef _WINDOWS
|
||||
|
||||
#include <windows.h>
|
||||
#include <Dbghelp.h>
|
||||
#include <tchar.h>
|
||||
|
||||
typedef BOOL(WINAPI *MINIDUMPWRITEDUMP)(HANDLE hProcess, DWORD dwPid, HANDLE hFile, MINIDUMP_TYPE DumpType, CONST PMINIDUMP_EXCEPTION_INFORMATION ExceptionParam, CONST PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam, CONST PMINIDUMP_CALLBACK_INFORMATION CallbackParam);
|
||||
|
||||
void CreateMiniDump(struct _EXCEPTION_POINTERS* exceptionInfo)
|
||||
{
|
||||
HMODULE mhLib = LoadLibrary(_T("dbghelp.dll"));
|
||||
MINIDUMPWRITEDUMP pDump = (MINIDUMPWRITEDUMP)::GetProcAddress(mhLib, "MiniDumpWriteDump");
|
||||
HANDLE hFile = CreateFile(_T("CORE.DMP"), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
|
||||
_MINIDUMP_EXCEPTION_INFORMATION ExInfo;
|
||||
ExInfo.ThreadId = GetCurrentThreadId();
|
||||
ExInfo.ExceptionPointers = exceptionInfo;
|
||||
ExInfo.ClientPointers = FALSE;
|
||||
|
||||
pDump(GetCurrentProcess(), GetCurrentProcessId(), hFile, MiniDumpNormal, &ExInfo, NULL, NULL);
|
||||
CloseHandle(hFile);
|
||||
}
|
||||
|
||||
LONG WINAPI unhandled_handler(struct _EXCEPTION_POINTERS* exceptionInfo)
|
||||
{
|
||||
CreateMiniDump(exceptionInfo);
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
}
|
||||
|
||||
#endif
|
12
src_rebuild/EMULATOR/CRASHHANDLER.H
Normal file
12
src_rebuild/EMULATOR/CRASHHANDLER.H
Normal file
@ -0,0 +1,12 @@
|
||||
#ifndef CRASHHANDLER_H
|
||||
#define CRASHHANDLER_H
|
||||
|
||||
#if defined (_WINDOWS)
|
||||
#include <windows.h>
|
||||
#include <Dbghelp.h>
|
||||
#include <tchar.h>
|
||||
|
||||
LONG WINAPI unhandled_handler(struct _EXCEPTION_POINTERS* apExceptionInfo);
|
||||
#endif
|
||||
|
||||
#endif
|
3163
src_rebuild/EMULATOR/EMULATOR.C
Normal file
3163
src_rebuild/EMULATOR/EMULATOR.C
Normal file
File diff suppressed because it is too large
Load Diff
179
src_rebuild/EMULATOR/EMULATOR.H
Normal file
179
src_rebuild/EMULATOR/EMULATOR.H
Normal file
@ -0,0 +1,179 @@
|
||||
#ifndef EMULATOR_H
|
||||
#define EMULATOR_H
|
||||
|
||||
#include "EMULATOR_PLATFORM_SETUP.H"
|
||||
#include "LIBGPU.H"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define FUNCNAME __FUNCTION__
|
||||
#else
|
||||
#define FUNCNAME __func__
|
||||
#endif
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
#include <android/log.h>
|
||||
#define LOG_TAG_EMU "[EMU] "
|
||||
#define eprintf(fmt, ...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG_EMU, fmt, ##__VA_ARGS__)
|
||||
#define eprinterr(fmt, ...) eprintf("[%s] - " fmt, FUNCNAME, ##__VA_ARGS__);
|
||||
#else
|
||||
#define eprintf(fmt, ...) printf("[EMU] " fmt, ##__VA_ARGS__)
|
||||
#define eprinterr(fmt, ...) eprintf("[%s] - " fmt, FUNCNAME, ##__VA_ARGS__);
|
||||
#endif
|
||||
|
||||
#if defined(__EMSCRIPTEN__)
|
||||
#define UNIMPLEMENTED() 0;
|
||||
#else
|
||||
#define UNIMPLEMENTED() eprinterr("Unimplemented!\n");
|
||||
#endif
|
||||
|
||||
#define RESOLUTION_SCALE (1)
|
||||
|
||||
#define VRAM_WIDTH (1024 * RESOLUTION_SCALE)
|
||||
#define VRAM_HEIGHT (512 * RESOLUTION_SCALE)
|
||||
|
||||
#define TPAGE_WIDTH (256)
|
||||
#define TPAGE_HEIGHT (256)
|
||||
|
||||
#define CLUT_WIDTH (16)
|
||||
#define CLUT_HEIGHT (1)
|
||||
|
||||
#define CTR_RUNNING (0)
|
||||
#define CTR_STOPPED (1)
|
||||
|
||||
#define CTR_MODE_TO_FFFF (0)
|
||||
#define CTR_MODE_TO_TARG (1)
|
||||
|
||||
#define CTR_CLOCK_SYS (0)
|
||||
#define CTR_CLOCK_PIXEL (1)
|
||||
#define CTR_HORIZ_RETRACE (1)
|
||||
|
||||
#define CTR_CLOCK_SYS_ONE (0)
|
||||
#define CTR_CLOCK_SYS_ONE_EIGHTH (1)
|
||||
|
||||
#define GET_TPAGE_X(tpage) ((tpage << 6) & 0x7C0) % (VRAM_WIDTH / RESOLUTION_SCALE);
|
||||
#define GET_TPAGE_Y(tpage) ((((tpage << 4) & 0x100) + ((tpage >> 2) & 0x200))) % (VRAM_HEIGHT / RESOLUTION_SCALE);
|
||||
#define GET_TPAGE_TYPE(tpage) (tpage >> 7) & 0x3;
|
||||
#define GET_CLUT_X(clut) ((clut & 0x3F) << 4);
|
||||
#define GET_CLUT_Y(clut) (clut >> 6);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
unsigned int i_cycle;
|
||||
|
||||
union
|
||||
{
|
||||
unsigned short cycle;
|
||||
unsigned short unk00;
|
||||
};
|
||||
|
||||
unsigned int i_value;
|
||||
|
||||
union
|
||||
{
|
||||
unsigned short value;
|
||||
unsigned short unk01;
|
||||
};
|
||||
|
||||
unsigned int i_target;
|
||||
|
||||
union
|
||||
{
|
||||
unsigned short target;
|
||||
unsigned short unk02;
|
||||
};
|
||||
|
||||
|
||||
unsigned int padding00;
|
||||
unsigned int padding01;
|
||||
} SysCounter;
|
||||
|
||||
extern SysCounter counters[3];
|
||||
|
||||
#pragma pack(push,1)
|
||||
struct Vertex
|
||||
{
|
||||
float x, y, z;
|
||||
float u0, v0;
|
||||
#if defined(OGL) || defined(OGLES) || defined(VK)
|
||||
float col[4];
|
||||
#elif defined(D3D9)
|
||||
D3DCOLOR col;
|
||||
#endif
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
|
||||
enum BlendMode
|
||||
{
|
||||
BM_AVERAGE,
|
||||
BM_ADD,
|
||||
BM_SUBTRACT,
|
||||
BM_ADD_QUATER_SOURCE,
|
||||
BM_DEFAULT
|
||||
};
|
||||
|
||||
extern unsigned int g_lastBoundTexture;
|
||||
#if defined(OGL) || defined(OGLES)
|
||||
extern int Emulator_InitialiseGL();
|
||||
#elif defined(D3D9)
|
||||
extern int Emulator_InitialiseD3D();
|
||||
#endif
|
||||
extern void Emulator_SaveVRAM(const char* outputFileName, int x, int y, int width, int height, int bReadFromFrameBuffer);
|
||||
extern void Emulator_ShutDown();
|
||||
extern void Emulator_SwapWindow();
|
||||
#if defined(OGL) || defined(OGLES) || defined(VK)
|
||||
extern unsigned int Emulator_GenerateTpage(unsigned short tpage, unsigned short clut);
|
||||
#elif defined(D3D9)
|
||||
IDirect3DTexture9* Emulator_GenerateTpage(unsigned short tpage, unsigned short clut);
|
||||
#endif
|
||||
extern void Emulator_DestroyFrameBuffer(unsigned int* fbo);
|
||||
extern void Emulator_GenerateFrameBuffer(unsigned int* fbo);
|
||||
extern void Emulator_GenerateAndBindNullWhite();
|
||||
extern void Emulator_CheckTextureIntersection(RECT16* rect);
|
||||
extern void Emulator_SetBlendMode(int mode, int semiTransparent);
|
||||
extern void Emulator_CounterLoop();
|
||||
extern void Emulator_GenerateLineArray(struct Vertex* vertex, short* p0, short* p1, short* p2, short* p3);
|
||||
extern void Emulator_GenerateVertexArrayQuad(struct Vertex* vertex, short* p0, short* p1, short* p2, short* p3, short w, short h);
|
||||
extern void Emulator_GenerateTexcoordArrayQuad(struct Vertex* vertex, unsigned char* uv0, unsigned char* uv1, unsigned char* uv2, unsigned char* uv3, short w, short h);
|
||||
extern void Emulator_GenerateColourArrayQuad(struct Vertex* vertex, unsigned char* col0, unsigned char* col1, unsigned char* col2, unsigned char* col3, int bMultiplyColour);
|
||||
#if defined(OGL) || defined(OGLES) || defined(D3D9) || defined(VK)
|
||||
extern void Emulator_Ortho2D(float left, float right, float bottom, float top, float znear, float zfar);
|
||||
extern void Emulator_Scalef(float sx, float sy, float sz);
|
||||
#endif
|
||||
#if defined(OGL) || defined(OGLES) || defined(VK)
|
||||
extern void Emulator_BindTexture(unsigned int textureId);
|
||||
#elif defined(D3D9)
|
||||
extern void Emulator_BindTexture(IDirect3DTexture9* texture);
|
||||
#endif
|
||||
extern void Emulator_DestroyTextures(int numTextures, unsigned int* textures);
|
||||
extern void Emulator_SetViewPort(int x, int y, int width, int height);
|
||||
extern void Emulator_SetScissorBox(int x, int y, int width, int height);
|
||||
#if defined(OGL) || defined(OGLES)
|
||||
extern void Emulator_BindFrameBuffer(GLuint frameBufferObject);
|
||||
#elif defined(D3D9)
|
||||
extern void Emulator_BindFrameBuffer(IDirect3DSurface9* frameBufferObject);
|
||||
#elif defined(VK)
|
||||
extern void Emulator_BindFrameBuffer(struct FrameBuffer frameBufferObject);
|
||||
#else
|
||||
extern void Emulator_BindFrameBuffer(int frameBufferObject);
|
||||
#endif
|
||||
extern void Emulator_CreateVertexBuffer(int numVertices, int vertexStride, void* pVertices);
|
||||
#if defined(D3D9)
|
||||
extern IDirect3DDevice9* d3ddev;
|
||||
extern IDirect3DVertexDeclaration9* g_vertexDecl;
|
||||
#endif
|
||||
|
||||
#endif
|
78
src_rebuild/EMULATOR/EMULATOR_GLOBALS.H
Normal file
78
src_rebuild/EMULATOR/EMULATOR_GLOBALS.H
Normal file
@ -0,0 +1,78 @@
|
||||
#ifndef EMULATOR_GLOBALS_H
|
||||
#define EMULATOR_GLOBALS_H
|
||||
|
||||
|
||||
#include <SDL_gamecontroller.h>
|
||||
|
||||
|
||||
#if defined(D3D9)
|
||||
extern IDirect3DTexture9* nullWhiteTexture;
|
||||
extern IDirect3DTexture9* vramTexture;
|
||||
extern IDirect3DSurface9* vramFrameBuffer;
|
||||
extern LPDIRECT3DVERTEXBUFFER9 g_vertexBufferObject;
|
||||
#elif defined(VK)
|
||||
|
||||
struct FrameBufferAttachment
|
||||
{
|
||||
VkImage image;
|
||||
VkDeviceMemory mem;
|
||||
VkImageView view;
|
||||
};
|
||||
|
||||
struct FrameBuffer
|
||||
{
|
||||
int32_t width, height;
|
||||
VkFramebuffer frameBuffer;
|
||||
FrameBufferAttachment color, depth;
|
||||
VkRenderPass renderPass;
|
||||
VkSampler sampler;
|
||||
VkDescriptorImageInfo descriptor;
|
||||
};
|
||||
|
||||
extern struct FrameBuffer vramFrameBuffer;
|
||||
extern unsigned int nullWhiteTexture;
|
||||
#else
|
||||
extern unsigned int nullWhiteTexture;
|
||||
extern unsigned int vramFrameBuffer;
|
||||
extern unsigned int vramTexture;
|
||||
#endif
|
||||
extern int screenWidth;
|
||||
extern int screenHeight;
|
||||
extern int windowWidth;
|
||||
extern int windowHeight;
|
||||
extern uint32_t DMAControlRegister;
|
||||
extern int assetsLoaded;
|
||||
extern unsigned int g_defaultShaderProgram;
|
||||
|
||||
#if defined(OGL) || defined(OGLES) || defined(VK)
|
||||
extern int g_defaultFBO;
|
||||
#elif defined(D3D9)
|
||||
extern IDirect3DSurface9* g_defaultFBO;
|
||||
#else
|
||||
extern int g_defaultFBO;
|
||||
#endif
|
||||
|
||||
struct CachedTexture
|
||||
{
|
||||
#if defined(OGL) || defined(OGLES)
|
||||
unsigned int textureID;
|
||||
#elif defined(D3D9)
|
||||
IDirect3DTexture9* texture;
|
||||
#endif
|
||||
unsigned short tpage;
|
||||
unsigned short clut;
|
||||
unsigned int lastAccess;
|
||||
};
|
||||
|
||||
#define MAX_NUM_CACHED_TEXTURES (512)
|
||||
|
||||
extern struct CachedTexture cachedTextures[MAX_NUM_CACHED_TEXTURES];
|
||||
|
||||
extern unsigned short UpdateGameControllerInput(SDL_GameController* pad);
|
||||
extern unsigned short UpdateKeyboardInput();
|
||||
|
||||
extern SDL_GameController* padHandle[];
|
||||
extern unsigned char* padData[];
|
||||
extern const unsigned char* keyboardState;
|
||||
|
||||
#endif
|
98
src_rebuild/EMULATOR/EMULATOR_PLATFORM_SETUP.H
Normal file
98
src_rebuild/EMULATOR/EMULATOR_PLATFORM_SETUP.H
Normal file
@ -0,0 +1,98 @@
|
||||
#ifndef EMULATOR_PLATFORM_SETUP_H
|
||||
#define EMULATOR_PLATFORM_SETUP_H
|
||||
|
||||
/*
|
||||
* Platform specific emulator setup
|
||||
*/
|
||||
#if (defined(_WINDOWS) || defined(__APPLE__) || defined(__linux__) || defined(__MINGW32__)) && !defined(__ANDROID__)
|
||||
//Open Graphics Library (Embedded Systems)
|
||||
//#define OGLES
|
||||
//#define OGLES_VERSION 2
|
||||
|
||||
//Open Graphics Library
|
||||
#define OGL
|
||||
|
||||
//Direct3D9
|
||||
//#define D3D9
|
||||
|
||||
//Vulkan
|
||||
//#define VK
|
||||
|
||||
#if defined(OGL)
|
||||
#define SDL2
|
||||
#define GLEW
|
||||
#endif
|
||||
|
||||
#elif defined(__EMSCRIPTEN__) || defined(__ANDROID__)
|
||||
#define OGLES
|
||||
#define OGLES_VERSION (2)
|
||||
#if OGLES_VERSION == 2
|
||||
#define ES2_SHADERS
|
||||
#elif OGLES_VERSION == 3
|
||||
#define ES3_SHADERS
|
||||
#endif
|
||||
#define SDL2
|
||||
#endif
|
||||
|
||||
#if defined(GLEW)
|
||||
#define GL_GLEXT_PROTOTYPES 1
|
||||
#include <GL/glew.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Emulator render options.
|
||||
*/
|
||||
#define RO_DOUBLE_BUFFERED
|
||||
|
||||
#if defined(__APPLE__) || defined(__EMSCRIPTEN__)
|
||||
//#include <stddef.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* SDL.H inclusion.
|
||||
*/
|
||||
|
||||
#if defined(__APPLE__)
|
||||
#include <SDL2/SDL.h>
|
||||
#include <SDL2/SDL_opengl.h>
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
#include <SDL2/SDL.h>
|
||||
#elif (defined(_WINDOWS) || defined(__MINGW32__) || defined(__linux__)) && !defined(__ANDROID__)
|
||||
#include <SDL.h>
|
||||
#elif defined (__ANDROID__)
|
||||
#include <SDL.h>
|
||||
#endif
|
||||
|
||||
#if defined (OGL)
|
||||
#include <SDL_opengl.h>///@FIXME see mac!
|
||||
#elif defined (OGLES)
|
||||
#include <SDL_syswm.h>
|
||||
#if OGLES_VERSION == 2
|
||||
#define GL_GLEXT_PROTOTYPES
|
||||
#include <GLES2/gl2.h>
|
||||
#include <GLES2/gl2ext.h>
|
||||
#elif OGLES_VERSION == 3
|
||||
#include <GLES3/gl3.h>
|
||||
#endif
|
||||
#include <EGL/egl.h>
|
||||
#elif defined(VK)
|
||||
#include <SDL_syswm.h>
|
||||
#define VK_USE_PLATFORM_WIN32_KHR
|
||||
#include <vulkan/vulkan.h>
|
||||
#elif defined(D3D9)
|
||||
#include <Windows.h>
|
||||
#include <d3d9.h>
|
||||
#include <d3dx9.h>
|
||||
#endif
|
||||
|
||||
#if !defined (__EMSCRIPTEN__)
|
||||
//#include <SDL_gamecontroller.h>
|
||||
#endif
|
||||
|
||||
#if defined(OGL)
|
||||
#define TEXTURE_FORMAT GL_UNSIGNED_SHORT_1_5_5_5_REV
|
||||
#elif defined(OGLES)
|
||||
#define TEXTURE_FORMAT GL_UNSIGNED_SHORT_5_5_5_1
|
||||
#endif
|
||||
|
||||
#endif
|
31
src_rebuild/EMULATOR/EMULATOR_PRIVATE.H
Normal file
31
src_rebuild/EMULATOR/EMULATOR_PRIVATE.H
Normal file
@ -0,0 +1,31 @@
|
||||
#ifndef EMULATOR_PRIVATE_H
|
||||
#define EMULATOR_PRIVATE_H
|
||||
|
||||
/* Usually called when loading game textures to tell the emulator how to form an atlas for faster drawing */
|
||||
extern void Emulator_HintTextureAtlas(unsigned short tpage, unsigned short clut, unsigned char u0, unsigned char v0, unsigned char u1, unsigned char v1, unsigned char u2, unsigned char v2, unsigned char u3, unsigned char v3, unsigned short bIsQuad);
|
||||
|
||||
/* Usually called at the beginning of main function */
|
||||
extern void Emulator_Initialise(char* windowName, int screenWidth, int screenHeight);
|
||||
|
||||
/* Usually called after ClearOTag/ClearOTagR */
|
||||
extern void Emulator_BeginScene();
|
||||
|
||||
/* Usually called after DrawOTag/DrawOTagEnv */
|
||||
extern void Emulator_EndScene();
|
||||
|
||||
/* Explicitly updates emulator input loop */
|
||||
extern void Emulator_UpdateInput();
|
||||
|
||||
/* Usually called at the end if main function */
|
||||
extern void Emulator_ShutDown();
|
||||
|
||||
/* Placeholder, can inject a TIM file into vram */
|
||||
extern void Emulator_InjectTIM(char* fileName, unsigned short texTpage, unsigned short texClut, unsigned char u0, unsigned char v0, unsigned char u1, unsigned char v1, unsigned char u2, unsigned char v2, unsigned char u3, unsigned char v3);
|
||||
|
||||
/* Usually called when loading a game level to specifically delete all emulator textures for optimisation purposes */
|
||||
extern void Emulator_DestroyAllTextures();
|
||||
|
||||
/* Sets the maximum vertex count value for PGXP vertex caching */
|
||||
extern void Emulator_SetPGXPVertexCount(int vertexCount);
|
||||
|
||||
#endif
|
7
src_rebuild/EMULATOR/EMULATOR_SETUP.H
Normal file
7
src_rebuild/EMULATOR/EMULATOR_SETUP.H
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef EMULATOR_SETUP_H
|
||||
#define EMULATOR_SETUP_H
|
||||
|
||||
//Disc image filename to load for disc image builds
|
||||
#define DISC_IMAGE_FILENAME "TOMB5.BIN"
|
||||
|
||||
#endif
|
19
src_rebuild/EMULATOR/EMULATOR_VERSION.H
Normal file
19
src_rebuild/EMULATOR/EMULATOR_VERSION.H
Normal file
@ -0,0 +1,19 @@
|
||||
#ifndef EMULATOR_VERSION_H
|
||||
#define EMULATOR_VERSION_H
|
||||
|
||||
/* Name of the Emulator */
|
||||
#define EMULATOR_NAME "LIBPSX"
|
||||
|
||||
/* Emulator version */
|
||||
#define EMULATOR_MAJOR_VERSION (1)
|
||||
#define EMULATOR_MINOR_VERSION (93)
|
||||
|
||||
/* Compile date and time */
|
||||
#define EMULATOR_COMPILE_DATE (__DATE__)
|
||||
#define EMULATOR_COMPILE_TIME (__TIME__)
|
||||
|
||||
/* Psy-Q version */
|
||||
#define PSYQ_MAJOR_VERSION (4)
|
||||
#define PSYQ_MINOR_VERSION (7)
|
||||
|
||||
#endif
|
0
src_rebuild/EMULATOR/GPU_D3D9.C
Normal file
0
src_rebuild/EMULATOR/GPU_D3D9.C
Normal file
0
src_rebuild/EMULATOR/GPU_D3D9.H
Normal file
0
src_rebuild/EMULATOR/GPU_D3D9.H
Normal file
118
src_rebuild/EMULATOR/GTEREG.H
Normal file
118
src_rebuild/EMULATOR/GTEREG.H
Normal file
@ -0,0 +1,118 @@
|
||||
#ifndef GTEREG_H
|
||||
#define GTEREG_H
|
||||
|
||||
//Externals
|
||||
extern int LIM(int value, int max, int min, unsigned int flag);
|
||||
|
||||
extern GTERegisters gteRegs;
|
||||
|
||||
extern int docop2(int op);
|
||||
|
||||
/* Data Registers mtc2 mfc2 */
|
||||
#define VX0 (gteRegs.CP2D.p[ 0 ].sw.l)
|
||||
#define VY0 (gteRegs.CP2D.p[ 0 ].sw.h)
|
||||
#define VZ0 (gteRegs.CP2D.p[ 1 ].sw.l)
|
||||
#define VX1 (gteRegs.CP2D.p[ 2 ].w.l)
|
||||
#define VY1 (gteRegs.CP2D.p[ 2 ].w.h)
|
||||
#define VZ1 (gteRegs.CP2D.p[ 3 ].w.l)
|
||||
#define VX2 (gteRegs.CP2D.p[ 4 ].w.l)
|
||||
#define VY2 (gteRegs.CP2D.p[ 4 ].w.h)
|
||||
#define VZ2 (gteRegs.CP2D.p[ 5 ].w.l)
|
||||
#define R (gteRegs.CP2D.p[ 6 ].b.l)
|
||||
#define G (gteRegs.CP2D.p[ 6 ].b.h)
|
||||
#define B (gteRegs.CP2D.p[ 6 ].b.h2)
|
||||
#define CODE (gteRegs.CP2D.p[ 6 ].b.h3)
|
||||
#define OTZ (gteRegs.CP2D.p[ 7 ].w.l)
|
||||
#define IR0 (gteRegs.CP2D.p[ 8 ].sw.l)
|
||||
#define IR1 (gteRegs.CP2D.p[ 9 ].sw.l)
|
||||
#define IR2 (gteRegs.CP2D.p[ 10 ].sw.l)
|
||||
#define IR3 (gteRegs.CP2D.p[ 11 ].sw.l)
|
||||
#define SXY0 (gteRegs.CP2D.p[ 12 ].d)
|
||||
#define SX0 (gteRegs.CP2D.p[ 12 ].sw.l)
|
||||
#define SY0 (gteRegs.CP2D.p[ 12 ].sw.h)
|
||||
#define SXY1 (gteRegs.CP2D.p[ 13 ].d)
|
||||
#define SX1 (gteRegs.CP2D.p[ 13 ].sw.l)
|
||||
#define SY1 (gteRegs.CP2D.p[ 13 ].sw.h)
|
||||
#define SXY2 (gteRegs.CP2D.p[ 14 ].d)
|
||||
#define SX2 (gteRegs.CP2D.p[ 14 ].sw.l)
|
||||
#define SY2 (gteRegs.CP2D.p[ 14 ].sw.h)
|
||||
#define SXYP (gteRegs.CP2D.p[ 15 ].d)
|
||||
#define SXP (gteRegs.CP2D.p[ 15 ].sw.l)
|
||||
#define SYP (gteRegs.CP2D.p[ 15 ].sw.h)
|
||||
#define SZ0 (gteRegs.CP2D.p[ 16 ].w.l)
|
||||
#define SZ1 (gteRegs.CP2D.p[ 17 ].w.l)
|
||||
#define SZ2 (gteRegs.CP2D.p[ 18 ].w.l)
|
||||
#define SZ3 (gteRegs.CP2D.p[ 19 ].w.l)
|
||||
#define RGB0 (gteRegs.CP2D.p[ 20 ].d)
|
||||
#define R0 (gteRegs.CP2D.p[ 20 ].b.l)
|
||||
#define G0 (gteRegs.CP2D.p[ 20 ].b.h)
|
||||
#define B0 (gteRegs.CP2D.p[ 20 ].b.h2)
|
||||
#define CD0 (gteRegs.CP2D.p[ 20 ].b.h3)
|
||||
#define RGB1 (gteRegs.CP2D.p[ 21 ].d)
|
||||
#define R1 (gteRegs.CP2D.p[ 21 ].b.l)
|
||||
#define G1 (gteRegs.CP2D.p[ 21 ].b.h)
|
||||
#define B1 (gteRegs.CP2D.p[ 21 ].b.h2)
|
||||
#define CD1 (gteRegs.CP2D.p[ 21 ].b.h3)
|
||||
#define RGB2 (gteRegs.CP2D.p[ 22 ].d)
|
||||
#define R2 (gteRegs.CP2D.p[ 22 ].b.l)
|
||||
#define G2 (gteRegs.CP2D.p[ 22 ].b.h)
|
||||
#define B2 (gteRegs.CP2D.p[ 22 ].b.h2)
|
||||
#define CD2 (gteRegs.CP2D.p[ 22 ].b.h3)
|
||||
#define RES1 (gteRegs.CP2D.p[ 23 ].d)
|
||||
#define MAC0 (gteRegs.CP2D.p[ 24 ].sd)
|
||||
#define MAC1 (gteRegs.CP2D.p[ 25 ].sd)
|
||||
#define MAC2 (gteRegs.CP2D.p[ 26 ].sd)
|
||||
#define MAC3 (gteRegs.CP2D.p[ 27 ].sd)
|
||||
#define IRGB (gteRegs.CP2D.p[ 28 ].d)
|
||||
#define ORGB (gteRegs.CP2D.p[ 29 ].d)
|
||||
#define LZCS (gteRegs.CP2D.p[ 30 ].d)
|
||||
#define LZCR (gteRegs.CP2D.p[ 31 ].d)
|
||||
|
||||
/* Control Registers ctc2 cfc2*/
|
||||
|
||||
#define R11 (gteRegs.CP2C.p[ 0 ].sw.l)
|
||||
#define R12 (gteRegs.CP2C.p[ 0 ].sw.h)
|
||||
#define R13 (gteRegs.CP2C.p[ 1 ].sw.l)
|
||||
#define R21 (gteRegs.CP2C.p[ 1 ].sw.h)
|
||||
#define R22 (gteRegs.CP2C.p[ 2 ].sw.l)
|
||||
#define R23 (gteRegs.CP2C.p[ 2 ].sw.h)
|
||||
#define R31 (gteRegs.CP2C.p[ 3 ].sw.l)
|
||||
#define R32 (gteRegs.CP2C.p[ 3 ].sw.h)
|
||||
#define R33 (gteRegs.CP2C.p[ 4 ].sw.l)
|
||||
#define TRX (gteRegs.CP2C.p[ 5 ].sd)
|
||||
#define TRY (gteRegs.CP2C.p[ 6 ].sd)
|
||||
#define TRZ (gteRegs.CP2C.p[ 7 ].sd)
|
||||
#define L11 (gteRegs.CP2C.p[ 8 ].sw.l)
|
||||
#define L12 (gteRegs.CP2C.p[ 8 ].sw.h)
|
||||
#define L13 (gteRegs.CP2C.p[ 9 ].sw.l)
|
||||
#define L21 (gteRegs.CP2C.p[ 9 ].sw.h)
|
||||
#define L22 (gteRegs.CP2C.p[ 10 ].sw.l)
|
||||
#define L23 (gteRegs.CP2C.p[ 10 ].sw.h)
|
||||
#define L31 (gteRegs.CP2C.p[ 11 ].sw.l)
|
||||
#define L32 (gteRegs.CP2C.p[ 11 ].sw.h)
|
||||
#define L33 (gteRegs.CP2C.p[ 12 ].sw.l)
|
||||
#define RBK (gteRegs.CP2C.p[ 13 ].sd)
|
||||
#define GBK (gteRegs.CP2C.p[ 14 ].sd)
|
||||
#define BBK (gteRegs.CP2C.p[ 15 ].sd)
|
||||
#define LR1 (gteRegs.CP2C.p[ 16 ].sw.l)
|
||||
#define LR2 (gteRegs.CP2C.p[ 16 ].sw.h)
|
||||
#define LR3 (gteRegs.CP2C.p[ 17 ].sw.l)
|
||||
#define LG1 (gteRegs.CP2C.p[ 17 ].sw.h)
|
||||
#define LG2 (gteRegs.CP2C.p[ 18 ].sw.l)
|
||||
#define LG3 (gteRegs.CP2C.p[ 18 ].sw.h)
|
||||
#define LB1 (gteRegs.CP2C.p[ 19 ].sw.l)
|
||||
#define LB2 (gteRegs.CP2C.p[ 19 ].sw.h)
|
||||
#define LB3 (gteRegs.CP2C.p[ 20 ].sw.l)
|
||||
#define RFC (gteRegs.CP2C.p[ 21 ].sd)
|
||||
#define GFC (gteRegs.CP2C.p[ 22 ].sd)
|
||||
#define BFC (gteRegs.CP2C.p[ 23 ].sd)
|
||||
#define OFX (gteRegs.CP2C.p[ 24 ].sd)
|
||||
#define OFY (gteRegs.CP2C.p[ 25 ].sd)
|
||||
#define H (gteRegs.CP2C.p[ 26 ].sw.l)
|
||||
#define DQA (gteRegs.CP2C.p[ 27 ].sw.l)
|
||||
#define DQB (gteRegs.CP2C.p[ 28 ].sd)
|
||||
#define ZSF3 (gteRegs.CP2C.p[ 29 ].sw.l)
|
||||
#define ZSF4 (gteRegs.CP2C.p[ 30 ].sw.l)
|
||||
#define FLAG (gteRegs.CP2C.p[ 31 ].d)
|
||||
|
||||
#endif
|
29
src_rebuild/EMULATOR/INLINE_C.C
Normal file
29
src_rebuild/EMULATOR/INLINE_C.C
Normal file
@ -0,0 +1,29 @@
|
||||
#include "INLINE_C.H"
|
||||
|
||||
#include "LIBGTE.H"
|
||||
#include "GTEREG.H"
|
||||
|
||||
void gte_SetGeomScreen(int h)
|
||||
{
|
||||
H = h;
|
||||
}
|
||||
|
||||
int gte_ldlzc(int input)
|
||||
{
|
||||
int leadingZeroCount = 0;
|
||||
|
||||
if (input > 0)
|
||||
{
|
||||
for (int i = (sizeof(int) * 8)-1; i >= 0 ; i--)
|
||||
{
|
||||
if (input & (1 << i))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
leadingZeroCount++;
|
||||
}
|
||||
}
|
||||
|
||||
return leadingZeroCount;
|
||||
}
|
7
src_rebuild/EMULATOR/INLINE_C.H
Normal file
7
src_rebuild/EMULATOR/INLINE_C.H
Normal file
@ -0,0 +1,7 @@
|
||||
#ifndef INLINE_C_H
|
||||
#define INLINE_C_H
|
||||
|
||||
extern void gte_SetGeomScreen(int h);
|
||||
extern int gte_ldlzc(int input);
|
||||
|
||||
#endif
|
157
src_rebuild/EMULATOR/KERNEL.H
Normal file
157
src_rebuild/EMULATOR/KERNEL.H
Normal file
@ -0,0 +1,157 @@
|
||||
#ifndef KERNEL_H
|
||||
#define KERNEL_H
|
||||
|
||||
#ifndef R3000_H
|
||||
#include "R3000.H"
|
||||
#endif
|
||||
|
||||
#ifndef ASM_H
|
||||
#include "ASM.H"
|
||||
#endif
|
||||
|
||||
#define DescMask 0xff000000
|
||||
#define DescTH DescMask
|
||||
#define DescHW 0xf0000000
|
||||
#define DescEV 0xf1000000
|
||||
#define DescRC 0xf2000000
|
||||
#define DescUEV 0xf3000000
|
||||
#define DescSW 0xf4000000
|
||||
|
||||
#define HwVBLANK (DescHW|0x01)
|
||||
#define HwGPU (DescHW|0x02)
|
||||
#define HwCdRom (DescHW|0x03)
|
||||
#define HwDMAC (DescHW|0x04)
|
||||
#define HwRTC0 (DescHW|0x05)
|
||||
#define HwRTC1 (DescHW|0x06)
|
||||
#define HwRTC2 (DescHW|0x07)
|
||||
#define HwCNTL (DescHW|0x08)
|
||||
#define HwSPU (DescHW|0x09)
|
||||
#define HwPIO (DescHW|0x0a)
|
||||
#define HwSIO (DescHW|0x0b)
|
||||
|
||||
#define HwCPU (DescHW|0x10)
|
||||
#define HwCARD (DescHW|0x11)
|
||||
#define HwCARD_0 (DescHW|0x12)
|
||||
#define HwCARD_1 (DescHW|0x13)
|
||||
#define SwCARD (DescSW|0x01)
|
||||
#define SwMATH (DescSW|0x02)
|
||||
|
||||
#define RCntCNT0 (DescRC|0x00)
|
||||
#define RCntCNT1 (DescRC|0x01)
|
||||
#define RCntCNT2 (DescRC|0x02)
|
||||
#define RCntCNT3 (DescRC|0x03)
|
||||
|
||||
#define RCntMdINTR 0x1000
|
||||
#define RCntMdNOINTR 0x2000
|
||||
#define RCntMdSC 0x0001
|
||||
#define RCntMdSP 0x0000
|
||||
#define RCntMdFR 0x0000
|
||||
#define RCntMdGATE 0x0010
|
||||
|
||||
#define EvSpCZ 0x0001 /* counter becomes zero */
|
||||
#define EvSpINT 0x0002 /* interrupted */
|
||||
#define EvSpIOE 0x0004 /* end of i/o */
|
||||
#define EvSpCLOSE 0x0008 /* file was closed */
|
||||
#define EvSpACK 0x0010 /* command acknowledged */
|
||||
#define EvSpCOMP 0x0020 /* command completed */
|
||||
#define EvSpDR 0x0040 /* data ready */
|
||||
#define EvSpDE 0x0080 /* data end */
|
||||
#define EvSpTIMOUT 0x0100 /* time out */
|
||||
#define EvSpUNKNOWN 0x0200 /* unknown command */
|
||||
#define EvSpIOER 0x0400 /* end of read buffer */
|
||||
#define EvSpIOEW 0x0800 /* end of write buffer */
|
||||
#define EvSpTRAP 0x1000 /* general interrupt */
|
||||
#define EvSpNEW 0x2000 /* new device */
|
||||
#define EvSpSYSCALL 0x4000 /* system call instruction */
|
||||
#define EvSpERROR 0x8000 /* error happned */
|
||||
#define EvSpPERROR 0x8001 /* previous write error happned */
|
||||
#define EvSpEDOM 0x0301 /* domain error in libmath */
|
||||
#define EvSpERANGE 0x0302 /* range error in libmath */
|
||||
|
||||
#define EvMdINTR 0x1000
|
||||
#define EvMdNOINTR 0x2000
|
||||
|
||||
#define EvStUNUSED 0x0000
|
||||
#define EvStWAIT 0x1000
|
||||
#define EvStACTIVE 0x2000
|
||||
#define EvStALREADY 0x4000
|
||||
|
||||
#define TcbMdRT 0x1000 /* reserved by system */
|
||||
#define TcbMdPRI 0x2000 /* reserved by system */
|
||||
|
||||
#define TcbStUNUSED 0x1000
|
||||
#define TcbStACTIVE 0x4000
|
||||
|
||||
struct ToT {
|
||||
unsigned long *head;
|
||||
long size;
|
||||
};
|
||||
|
||||
struct TCBH {
|
||||
struct TCB *entry; /* NULL */
|
||||
long flag;
|
||||
};
|
||||
|
||||
struct TCB {
|
||||
long status;
|
||||
long mode;
|
||||
unsigned long reg[NREGS]; /* never change the offset of this */
|
||||
long system[6]; /* reserved by system */
|
||||
};
|
||||
|
||||
struct EvCB {
|
||||
unsigned long desc;
|
||||
long status;
|
||||
long spec;
|
||||
long mode;
|
||||
long (*FHandler)();
|
||||
long system[2]; /* reserved by system */
|
||||
};
|
||||
|
||||
//#if !defined(D3D9)
|
||||
#if 0///@FIXME Really not defined D3D9 :/
|
||||
struct EXEC {
|
||||
unsigned long pc0;
|
||||
unsigned long gp0;
|
||||
unsigned long t_addr;
|
||||
unsigned long t_size;
|
||||
unsigned long d_addr;
|
||||
unsigned long d_size;
|
||||
unsigned long b_addr;
|
||||
unsigned long b_size;
|
||||
unsigned long s_addr;
|
||||
unsigned long s_size;
|
||||
unsigned long sp,fp,gp,ret,base;
|
||||
};
|
||||
|
||||
|
||||
struct XF_HDR {
|
||||
char key[8];
|
||||
unsigned long text;
|
||||
unsigned long data;
|
||||
struct EXEC exec;
|
||||
char title[60]; /* "PlayStation(tm) Executable A1" */
|
||||
};
|
||||
#endif
|
||||
|
||||
struct DIRENTRY {
|
||||
char name[20];
|
||||
long attr;
|
||||
long size;
|
||||
struct DIRENTRY *next;
|
||||
long head;
|
||||
char system[4];
|
||||
};
|
||||
|
||||
|
||||
extern struct ToT SysToT[32];
|
||||
|
||||
extern long SysClearRCnt[];
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (0)
|
||||
#endif
|
||||
|
||||
#endif /* _KERNEL_H */
|
||||
|
||||
|
506
src_rebuild/EMULATOR/LIBAPI.C
Normal file
506
src_rebuild/EMULATOR/LIBAPI.C
Normal file
@ -0,0 +1,506 @@
|
||||
#include "LIBAPI.H"
|
||||
|
||||
#include <stdio.h>
|
||||
#include "EMULATOR.H"
|
||||
|
||||
int sp = 0;
|
||||
|
||||
int dword_300[] = { 0x20, 0xD, 0x0, 0x0 };
|
||||
int dword_308[] = { 0x10, 0x20, 0x40, 0x1 };
|
||||
|
||||
long SetRCnt(long spec, unsigned short target, long mode)//(F)
|
||||
{
|
||||
int value = 0x48;
|
||||
|
||||
spec &= 0xFFFF;
|
||||
if (spec > 2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
counters[spec].value = 0;
|
||||
counters[spec].target = target;
|
||||
|
||||
if (spec < 2)
|
||||
{
|
||||
if ((mode & 0x10))
|
||||
{
|
||||
value = 0x49;
|
||||
}
|
||||
else if ((mode & 0x1))//loc_148
|
||||
{
|
||||
value |= 0x100;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//loc_158
|
||||
if (spec == 2 && !(mode & 1))
|
||||
{
|
||||
value = 0x248;
|
||||
}//loc_174
|
||||
}
|
||||
//loc_174
|
||||
if ((mode & 0x1000))
|
||||
{
|
||||
value |= 0x10;
|
||||
}//loc_180
|
||||
|
||||
counters[spec].value = value;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
long GetRCnt(long spec)//(F)
|
||||
{
|
||||
spec &= 0xFFFF;
|
||||
|
||||
if (spec > 2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return counters[spec].cycle;
|
||||
}
|
||||
|
||||
long ResetRCnt(long spec)//(F)
|
||||
{
|
||||
spec &= 0xFFFF;
|
||||
|
||||
if (spec > 2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
counters[spec].cycle = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
long StartRCnt(long spec)//(F)
|
||||
{
|
||||
spec &= 0xFFFF;
|
||||
dword_300[1] |= dword_308[spec];
|
||||
return spec < 3 ? 1 : 0;
|
||||
}
|
||||
|
||||
long StopRCnt(long spec)//TODO
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#undef OpenEvent
|
||||
long OpenEvent(unsigned long unk00, long unk01, long unk02, long(*func)())
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long CloseEvent(long unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long WaitEvent(long unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long TestEvent(long unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long EnableEvent(long unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long DisableEvent(long unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void DeliverEvent(unsigned long unk00, unsigned long unk01)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void UnDeliverEvent(unsigned long unk00, unsigned long unk01)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
long OpenTh(long(*func)(), unsigned long unk01, unsigned long unk02)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CloseTh(long unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int ChangeTh(long unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long open(char* unk00, unsigned long unk01)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long close(long unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long lseek(long unk00, long unk01, long unk02)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long read(long unk00, void* unk01, long unk02)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long write(long unk00, void* unk01, long unk02)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long ioctl(long unk00, long unk01, long unk02)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct DIRENTRY* firstfile(char* unk00, struct DIRENTRY* unk01)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct DIRENTRY* nextfile(struct DIRENTRY* unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long erase(char* unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long undelete(char* unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long format(char* unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
long rename(char* unk00, char* unk01)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long cd(char* unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long LoadTest(char* unk00, struct EXEC* unk01)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long Load(char * unk00, struct EXEC* unk01)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long Exec(struct EXEC * unk00, long unk01, char** unk02)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long LoadExec(char * unk00, unsigned long unk01, unsigned long unk02)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long InitPAD(char * unk00, long unk01, char* unk02, long unk03)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long StartPAD()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void StopPAD()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void EnablePAD()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void DisablePAD()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void FlushCache()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ReturnFromException()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
int EnterCriticalSection()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void ExitCriticalSection()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void Exception()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void SwEnterCriticalSection()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
void SwExitCriticalSection()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
unsigned long SetSp(unsigned long newsp)//(F)
|
||||
{
|
||||
unsigned long old_sp = sp;
|
||||
sp = newsp;
|
||||
return old_sp;
|
||||
}
|
||||
|
||||
unsigned long GetSp()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long GetGp()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long GetCr()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long GetSr()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long GetSysSp()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long SetConf(unsigned long unk00, unsigned long unk01, unsigned long unk02)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void GetConf(unsigned long* unk00, unsigned long* unk01, unsigned long* unk02)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
long _get_errno(void)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long _get_error(long unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SystemError(char unk00, long unk01)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void SetMem(long unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
long Krom2RawAdd(unsigned long unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long Krom2RawAdd2(unsigned short unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _96_init(void)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void _96_remove(void)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void _boot(void)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void ChangeClearPAD(long unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void InitCARD(long val)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
long StartCARD()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long StopCARD()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _bu_init()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
long _card_info(long chan)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long _card_clear(long chan)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long _card_load(long chan)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long _card_auto(long val)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _new_card()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
long _card_status(long drv)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long _card_wait(long drv)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long _card_chan(void)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long _card_write(long chan, long block, unsigned char *buf)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long _card_read(long chan, long block, unsigned char *buf)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long _card_format(long chan)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
104
src_rebuild/EMULATOR/LIBAPI.H
Normal file
104
src_rebuild/EMULATOR/LIBAPI.H
Normal file
@ -0,0 +1,104 @@
|
||||
#ifndef LIBAPI_H
|
||||
#define LIBAPI_H
|
||||
|
||||
#ifndef EMU_KERNEL_H
|
||||
#include "KERNEL.H"
|
||||
#endif
|
||||
|
||||
extern long SetRCnt(long spec, unsigned short target, long mode);
|
||||
extern long GetRCnt(long spec);
|
||||
extern long ResetRCnt(long spec);
|
||||
extern long StartRCnt(long spec);
|
||||
extern long StopRCnt(long spec);
|
||||
|
||||
extern long OpenEvent(unsigned long unk00,long,long,long (*func)());
|
||||
extern long CloseEvent(long unk00);
|
||||
extern long WaitEvent(long unk00);
|
||||
extern long TestEvent(long unk00);
|
||||
extern long EnableEvent(long unk00);
|
||||
extern long DisableEvent(long unk00);
|
||||
extern void DeliverEvent(unsigned long unk00, unsigned long);
|
||||
extern void UnDeliverEvent(unsigned long unk00, unsigned long);
|
||||
|
||||
extern long OpenTh(long (*func)(), unsigned long , unsigned long);
|
||||
extern int CloseTh(long unk00);
|
||||
extern int ChangeTh(long unk00);
|
||||
|
||||
extern long open(char* unk00, unsigned long);
|
||||
extern long close(long unk00);
|
||||
extern long lseek(long unk00, long, long);
|
||||
extern long read(long unk00, void *, long);
|
||||
extern long write(long unk00, void *, long);
|
||||
extern long ioctl(long unk00, long, long);
|
||||
extern struct DIRENTRY* firstfile(char* unk00, struct DIRENTRY *);
|
||||
extern struct DIRENTRY* nextfile(struct DIRENTRY* unk00);
|
||||
extern long erase(char* unk00);
|
||||
|
||||
|
||||
extern long undelete(char* unk00);
|
||||
extern long format(char* unk00);
|
||||
extern long rename(char* unk00, char *);
|
||||
extern long cd(char* unk00);
|
||||
|
||||
extern long LoadTest(char* unk00, struct EXEC *);
|
||||
extern long Load(char * unk00, struct EXEC *);
|
||||
extern long Exec(struct EXEC * unk00, long, char **);
|
||||
extern long LoadExec(char * unk00, unsigned long, unsigned long);
|
||||
|
||||
extern long InitPAD(char * unk00,long ,char *,long);
|
||||
extern long StartPAD();
|
||||
extern void StopPAD();
|
||||
extern void EnablePAD();
|
||||
extern void DisablePAD();
|
||||
|
||||
extern void FlushCache();
|
||||
extern void ReturnFromException();
|
||||
extern int EnterCriticalSection();
|
||||
extern void ExitCriticalSection();
|
||||
extern void Exception();
|
||||
extern void SwEnterCriticalSection();
|
||||
extern void SwExitCriticalSection();
|
||||
|
||||
extern unsigned long SetSp(unsigned long newsp);
|
||||
extern unsigned long GetSp();
|
||||
extern unsigned long GetGp();
|
||||
extern unsigned long GetCr();
|
||||
extern unsigned long GetSr();
|
||||
extern unsigned long GetSysSp();
|
||||
|
||||
extern long SetConf(unsigned long,unsigned long,unsigned long);
|
||||
extern void GetConf(unsigned long *,unsigned long *,unsigned long *);
|
||||
|
||||
extern long _get_errno(void);
|
||||
extern long _get_error(long);
|
||||
|
||||
extern void SystemError( char, long);
|
||||
extern void SetMem(long);
|
||||
|
||||
extern long Krom2RawAdd( unsigned long );
|
||||
extern long Krom2RawAdd2(unsigned short);
|
||||
|
||||
extern void _96_init(void);
|
||||
extern void _96_remove(void);
|
||||
extern void _boot(void);
|
||||
|
||||
extern void ChangeClearPAD( long );
|
||||
|
||||
/* prototypes added by shino 96/05/22 */
|
||||
extern void InitCARD(long val);
|
||||
extern long StartCARD();
|
||||
extern long StopCARD();
|
||||
extern void _bu_init();
|
||||
extern long _card_info(long chan);
|
||||
extern long _card_clear(long chan);
|
||||
extern long _card_load(long chan);
|
||||
extern long _card_auto(long val);
|
||||
extern void _new_card();
|
||||
extern long _card_status(long drv);
|
||||
extern long _card_wait(long drv);
|
||||
extern unsigned long _card_chan(void);
|
||||
extern long _card_write(long chan, long block, unsigned char *buf);
|
||||
extern long _card_read(long chan, long block, unsigned char *buf);
|
||||
extern long _card_format(long chan);
|
||||
|
||||
#endif
|
251
src_rebuild/EMULATOR/LIBCD.C
Normal file
251
src_rebuild/EMULATOR/LIBCD.C
Normal file
@ -0,0 +1,251 @@
|
||||
#include "LIBCD.H"
|
||||
|
||||
#include "EMULATOR_SETUP.H"
|
||||
#include "EMULATOR.H"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
int CD_Debug = 0;
|
||||
|
||||
FILE* openFile = NULL;
|
||||
|
||||
typedef struct commandQueue
|
||||
{
|
||||
unsigned int mode;
|
||||
unsigned char* p;
|
||||
unsigned int processed;
|
||||
unsigned int count;
|
||||
}commandQueue_s, *commandQueue_p;
|
||||
|
||||
#define COMMAND_QUEUE_SIZE 128
|
||||
|
||||
struct commandQueue comQueue[COMMAND_QUEUE_SIZE];
|
||||
int comQueueIndex = 0;
|
||||
int comQueueCount = 0;
|
||||
int currentSector = 0;
|
||||
int sectorSize = 2352;//TODO obtain properly from cue sheet
|
||||
int CD_com = 0;
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct TOC
|
||||
{
|
||||
unsigned char tocEntryLength;
|
||||
unsigned char extEntryLength;
|
||||
unsigned int sectorPosition[2];
|
||||
unsigned int fileSize[2];
|
||||
unsigned char date[7];
|
||||
unsigned char flags;
|
||||
unsigned char fileUnitSize;
|
||||
unsigned char interleaveGapSize;
|
||||
unsigned short volSeqNum[2];
|
||||
unsigned char nameLength;
|
||||
};
|
||||
|
||||
struct Sector
|
||||
{
|
||||
unsigned char sync[12]; /// Sync pattern (usually 00 FF FF FF FF FF FF FF FF FF FF 00)
|
||||
unsigned char addr[3]; /// Sector address (see below for encoding details)
|
||||
unsigned char mode; /// Mode (usually 2 for Mode 2 Form 1/2 sectors)
|
||||
unsigned char subHead[8]; /// Sub-header (00 00 08 00 00 00 08 00 for Form 1 data sectors)
|
||||
unsigned char data[2048]; /// Data (form 1)
|
||||
unsigned char edc[4]; /// Error-detection code (CRC32 of data area)
|
||||
unsigned char ecc[276]; /// Error-correction code (uses Reed-Solomon ECC algorithm)
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
CdlFILE* CdSearchFile(CdlFILE* fp, char* name)
|
||||
{
|
||||
SDL_memset(fp, 0, sizeof(CdlFILE));
|
||||
|
||||
if (name[0] == '\\')
|
||||
{
|
||||
name++;
|
||||
}
|
||||
|
||||
if (openFile != NULL)
|
||||
{
|
||||
fseek(openFile, 22 * sectorSize, SEEK_SET);
|
||||
|
||||
int tocLocalOffset = 0;
|
||||
struct Sector sector;
|
||||
fread(§or, sizeof(struct Sector), 1, openFile);
|
||||
struct TOC* toc = (struct TOC*)§or.data[0];
|
||||
while (toc->tocEntryLength != 0)
|
||||
{
|
||||
if (strcmp((char*)§or.data[tocLocalOffset + sizeof(struct TOC)], name) == 0)
|
||||
{
|
||||
memcpy(&fp->name[0], (char*)§or.data[tocLocalOffset + sizeof(struct TOC)], strlen(name));
|
||||
fp->size = toc->fileSize[0];
|
||||
fseek(openFile, toc->sectorPosition[0] * sectorSize, SEEK_SET);
|
||||
fread(§or, sizeof(struct Sector), 1, openFile);
|
||||
fp->pos.minute = sector.addr[0];
|
||||
fp->pos.second = sector.addr[1];
|
||||
fp->pos.sector = sector.addr[2];
|
||||
|
||||
|
||||
#if _DEBUG
|
||||
eprintf("Found %s\n", name);
|
||||
#endif
|
||||
return fp;
|
||||
}
|
||||
tocLocalOffset += toc->tocEntryLength;
|
||||
toc = (struct TOC*)§or.data[tocLocalOffset];
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CdlLOC* CdIntToPos(int i, CdlLOC* p)
|
||||
{
|
||||
i += 150;
|
||||
p->sector = ENCODE_BCD(i % 75);
|
||||
int rem = i / 75;
|
||||
p->second = ENCODE_BCD(rem % 60);
|
||||
p->minute = ENCODE_BCD(rem / 60);
|
||||
return p;
|
||||
}
|
||||
|
||||
int CdControl(u_char com, u_char * param, u_char * result)
|
||||
{
|
||||
CdlFILE* cd = (CdlFILE*)param;
|
||||
|
||||
CD_com = com;
|
||||
|
||||
switch (com)
|
||||
{
|
||||
case CdlSetloc:
|
||||
fseek(openFile, CdPosToInt(&cd->pos)*sectorSize, SEEK_SET);
|
||||
break;
|
||||
default:
|
||||
eprinterr("Unhandled command 0x%02X!\n", com);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CdControlB(u_char com, u_char* param, u_char* result)
|
||||
{
|
||||
CdlFILE* cd = (CdlFILE*)param;
|
||||
|
||||
CD_com = com;
|
||||
|
||||
switch (com)
|
||||
{
|
||||
case CdlSetloc:
|
||||
fseek(openFile, CdPosToInt(&cd->pos)*sectorSize, SEEK_SET);
|
||||
break;
|
||||
default:
|
||||
eprinterr("Unhandled command 0x%02X!\n", com);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CdControlF(u_char com, u_char * param)
|
||||
{
|
||||
CdlFILE* cd = (CdlFILE*)param;
|
||||
|
||||
CD_com = com;
|
||||
|
||||
switch (com)
|
||||
{
|
||||
case CdlSetloc:
|
||||
fseek(openFile, CdPosToInt(&cd->pos)*sectorSize, SEEK_SET);
|
||||
break;
|
||||
case CdlSetfilter:
|
||||
//fseek(openFile, CdPosToInt(&cd->pos) * sectorSize, SEEK_SET);
|
||||
break;
|
||||
default:
|
||||
eprinterr("Unhandled command 0x%02X!\n", com);
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CdPosToInt(CdlLOC* p)
|
||||
{
|
||||
return (75 * (60 * DECODE_BCD(p->minute) + DECODE_BCD(p->second))) + DECODE_BCD(p->sector) - 150;
|
||||
}
|
||||
|
||||
int CdRead(int sectors, u_long* buf, int mode)
|
||||
{
|
||||
for (int i = 0; i < COMMAND_QUEUE_SIZE; i++)
|
||||
{
|
||||
if (comQueue[i].processed == 1)
|
||||
{
|
||||
comQueue[i].mode = CdlReadS;
|
||||
comQueue[i].p = (unsigned char*)buf;
|
||||
comQueue[i].processed = 0;
|
||||
comQueue[i].count = sectors;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CdReadSync(int mode, u_char* result)
|
||||
{
|
||||
for (int i = 0; i < COMMAND_QUEUE_SIZE; i++)
|
||||
{
|
||||
if (comQueue[i].processed == 0)
|
||||
{
|
||||
struct Sector sector;
|
||||
fread(§or, sizeof(struct Sector), 1, openFile);
|
||||
|
||||
memcpy(comQueue[i].p, §or.data[0], 2048);
|
||||
comQueue[i].p += 2048;
|
||||
|
||||
if (--comQueue[i].count == 0)
|
||||
{
|
||||
comQueue[i].processed = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CdSetDebug(int level)
|
||||
{
|
||||
int lastLevel = CD_Debug;
|
||||
CD_Debug = level;
|
||||
return lastLevel;
|
||||
}
|
||||
|
||||
int CdSync(int mode, u_char * result)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CdInit(void)
|
||||
{
|
||||
SDL_memset(&comQueue, 0, sizeof(comQueue));
|
||||
currentSector = 0;
|
||||
openFile = fopen(DISC_IMAGE_FILENAME, "rb");
|
||||
|
||||
if (openFile == NULL)
|
||||
{
|
||||
eprinterr("Failed to open disc image file! %s\n", DISC_IMAGE_FILENAME);
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (int i = 0; i < COMMAND_QUEUE_SIZE; i++)
|
||||
{
|
||||
comQueue[i].processed = 1;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int CdLastCom(void)
|
||||
{
|
||||
return CD_com;
|
||||
}
|
248
src_rebuild/EMULATOR/LIBCD.H
Normal file
248
src_rebuild/EMULATOR/LIBCD.H
Normal file
@ -0,0 +1,248 @@
|
||||
#ifndef LIBCD_H
|
||||
#define LIBCD_H
|
||||
|
||||
#include "TYPES.H"
|
||||
|
||||
|
||||
#define DECODE_BCD(x) (((x) >> 4) * 10 + ((x) & 0xF))
|
||||
#define ENCODE_BCD(x) ((((x) / 10) << 4) | ((x) % 10))
|
||||
|
||||
#define CdlModeStream 0x100 /* Normal Streaming */
|
||||
#define CdlModeStream2 0x120 /* SUB HEADER information includes */
|
||||
#define CdlModeSpeed 0x80 /* 0: normal speed 1: double speed */
|
||||
#define CdlModeRT 0x40 /* 0: ADPCM off 1: ADPCM on */
|
||||
#define CdlModeSize1 0x20 /* 0: 2048 byte 1: 2340byte */
|
||||
#define CdlModeSize0 0x10 /* 0: - 1: 2328byte */
|
||||
#define CdlModeSF 0x08 /* 0: Channel off 1: Channel on */
|
||||
#define CdlModeRept 0x04 /* 0: Report off 1: Report on */
|
||||
#define CdlModeAP 0x02 /* 0: AutoPause off 1: AutoPause on */
|
||||
#define CdlModeDA 0x01 /* 0: CD-DA off 1: CD-DA on */
|
||||
|
||||
/*
|
||||
* Status Contents
|
||||
*/
|
||||
#define CdlStatPlay 0x80 /* playing CD-DA */
|
||||
#define CdlStatSeek 0x40 /* seeking */
|
||||
#define CdlStatRead 0x20 /* reading data sectors */
|
||||
#define CdlStatShellOpen 0x10 /* once shell open */
|
||||
#define CdlStatSeekError 0x04 /* seek error detected */
|
||||
#define CdlStatStandby 0x02 /* spindle motor rotating */
|
||||
#define CdlStatError 0x01 /* command error detected */
|
||||
|
||||
/*
|
||||
* Macros for CdGetDiskType()
|
||||
*/
|
||||
#define CdlStatNoDisk 0
|
||||
#define CdlOtherFormat 1
|
||||
#define CdlCdromFormat 2
|
||||
|
||||
/*
|
||||
* CD-ROM Primitive Commands
|
||||
*/
|
||||
#define CdlNop 0x01
|
||||
#define CdlSetloc 0x02
|
||||
#define CdlPlay 0x03
|
||||
#define CdlForward 0x04
|
||||
#define CdlBackward 0x05
|
||||
#define CdlReadN 0x06
|
||||
#define CdlStandby 0x07
|
||||
#define CdlStop 0x08
|
||||
#define CdlPause 0x09
|
||||
#define CdlMute 0x0b
|
||||
#define CdlDemute 0x0c
|
||||
#define CdlSetfilter 0x0d
|
||||
#define CdlSetmode 0x0e
|
||||
#define CdlGetparam 0x0f
|
||||
#define CdlGetlocL 0x10
|
||||
#define CdlGetlocP 0x11
|
||||
#define CdlGetTN 0x13
|
||||
#define CdlGetTD 0x14
|
||||
#define CdlSeekL 0x15
|
||||
#define CdlSeekP 0x16
|
||||
#define CdlReadS 0x1B
|
||||
|
||||
/*
|
||||
* Interrupts
|
||||
*/
|
||||
#define CdlNoIntr 0x00 /* No interrupt */
|
||||
#define CdlDataReady 0x01 /* Data Ready */
|
||||
#define CdlComplete 0x02 /* Command Complete */
|
||||
#define CdlAcknowledge 0x03 /* Acknowledge (reserved) */
|
||||
#define CdlDataEnd 0x04 /* End of Data Detected */
|
||||
#define CdlDiskError 0x05 /* Error Detected */
|
||||
|
||||
/*
|
||||
* Library Macros
|
||||
*/
|
||||
#ifndef btoi
|
||||
#define btoi(b) ((b)/16*10 + (b)%16) /* BCD to u_char */
|
||||
#endif
|
||||
#ifndef itob
|
||||
#define itob(i) ((i)/10*16 + (i)%10) /* u_char to BCD */
|
||||
#endif
|
||||
|
||||
#define CdSeekL(p) CdControl(CdlSeekL, (u_char *)p, 0)
|
||||
#define CdSeekP(p) CdControl(CdlSeekP, (u_char *)p, 0)
|
||||
#define CdStandby() CdControl(CdlStandby, 0, 0)
|
||||
#define CdPause() CdControl(CdlPause, 0, 0)
|
||||
#define CdStop() CdControl(CdlStop, 0, 0)
|
||||
#define CdMute() CdControl(CdlMute, 0, 0)
|
||||
#define CdDeMute() CdControl(CdlDemute, 0, 0)
|
||||
#define CdForward() CdControl(CdlForward, 0, 0)
|
||||
#define CdBackward() CdControl(CdlBackward, 0, 0)
|
||||
|
||||
/*
|
||||
* Position
|
||||
*/
|
||||
#define CdlMAXTOC 100
|
||||
|
||||
/*
|
||||
* Callback
|
||||
*/
|
||||
|
||||
typedef void (*CdlCB)(u_char,u_char *);
|
||||
|
||||
/*
|
||||
* Location
|
||||
*/
|
||||
typedef struct {
|
||||
u_char minute; /* minute (BCD) */
|
||||
u_char second; /* second (BCD) */
|
||||
u_char sector; /* sector (BCD) */
|
||||
u_char track; /* track (void) */
|
||||
} CdlLOC;
|
||||
|
||||
/*
|
||||
* ADPCM Filter
|
||||
*/
|
||||
typedef struct {
|
||||
u_char file; /* file ID (always 1) */
|
||||
u_char chan; /* channel ID */
|
||||
u_short pad;
|
||||
} CdlFILTER;
|
||||
|
||||
/*
|
||||
* Attenuator
|
||||
*/
|
||||
typedef struct {
|
||||
u_char val0; /* volume for CD(L) -> SPU (L) */
|
||||
u_char val1; /* volume for CD(L) -> SPU (R) */
|
||||
u_char val2; /* volume for CD(R) -> SPU (L) */
|
||||
u_char val3; /* volume for CD(R) -> SPU (R) */
|
||||
} CdlATV;
|
||||
|
||||
/*
|
||||
* Low Level File System for CdSearchFile()
|
||||
*/
|
||||
#define CdlMAXFILE 64 /* max number of files in a diRECT16ory */
|
||||
#define CdlMAXDIR 128 /* max number of total diRECT16ories */
|
||||
#define CdlMAXLEVEL 8 /* max levels of diRECT16ories */
|
||||
|
||||
typedef struct {
|
||||
CdlLOC pos; /* file location */
|
||||
u_long size; /* file size */
|
||||
char name[16]; /* file name (body) */
|
||||
} CdlFILE;
|
||||
|
||||
|
||||
/*#define MULTI_INTERRUPT */
|
||||
#ifndef MULTI_INTERRUPT
|
||||
#define pauseMULI()
|
||||
#define restartMULI()
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Streaming Structures
|
||||
*/
|
||||
typedef struct {
|
||||
u_short id;
|
||||
u_short type;
|
||||
u_short secCount;
|
||||
u_short nSectors;
|
||||
u_long frameCount;
|
||||
u_long frameSize;
|
||||
|
||||
u_short width;
|
||||
u_short height;
|
||||
u_long dummy1;
|
||||
u_long dummy2;
|
||||
CdlLOC loc;
|
||||
} StHEADER; /* CD-ROM STR structure */
|
||||
|
||||
#define StFREE 0x0000
|
||||
#define StREWIND 0x0001
|
||||
#define StCOMPLETE 0x0002
|
||||
#define StBUSY 0x0003
|
||||
#define StLOCK 0x0004
|
||||
|
||||
#define EDC 0
|
||||
#define SECTOR_SIZE (512) /* Sector Size (word) */
|
||||
#define HEADER_SIZE (8) /* Header Size (word) */
|
||||
|
||||
#define StSTATUS 0x00
|
||||
#define StVER 0x00
|
||||
#define StTYPE 0x01
|
||||
#define StSECTOR_OFFSET 0x02
|
||||
#define StSECTOR_SIZE 0x03
|
||||
#define StFRAME_NO 0x04
|
||||
#define StFRAME_SIZE 0x06
|
||||
|
||||
#define StMOVIE_WIDTH 0x08
|
||||
#define StMOVIE_HEIGHT 0x09
|
||||
|
||||
|
||||
void StSetRing(u_long *ring_addr,u_long ring_size);
|
||||
void StClearRing(void);
|
||||
void StUnSetRing(void);
|
||||
void StSetStream(u_long mode,u_long start_frame,u_long end_frame,
|
||||
void (*func1)(),void (*func2)());
|
||||
void StSetEmulate(u_long *addr,u_long mode,u_long start_frame,
|
||||
u_long end_frame,void (*func1)(),void (*func2)());
|
||||
u_long StFreeRing(u_long *base);
|
||||
u_long StGetNext(u_long **addr,u_long **header);
|
||||
u_long StGetNextS(u_long **addr,u_long **header);
|
||||
u_short StNextStatus(u_long **addr,u_long **header);
|
||||
void StRingStatus(short *free_sectors,short *over_sectors);
|
||||
void StSetMask(u_long mask,u_long start,u_long end);
|
||||
void StCdInterrupt(void);
|
||||
int StGetBackloc(CdlLOC *loc);
|
||||
int StSetChannel(u_long channel);
|
||||
|
||||
void CdFlush(void);
|
||||
CdlFILE *CdSearchFile(CdlFILE *fp, char *name);
|
||||
CdlLOC *CdIntToPos(int i, CdlLOC *p) ;
|
||||
char *CdComstr(u_char com);
|
||||
char *CdIntstr(u_char intr);
|
||||
int CdControl(u_char com, u_char *param, u_char *result);
|
||||
int CdControlB(u_char com, u_char *param, u_char *result);
|
||||
int CdControlF(u_char com, u_char *param);
|
||||
int CdGetSector(void *madr, int size);
|
||||
int CdGetSector2( void* madr, int size );
|
||||
int CdDataSync(int mode);
|
||||
int CdGetToc(CdlLOC *loc) ;
|
||||
int CdPlay(int mode, int *track, int offset);
|
||||
int CdMix(CdlATV *vol);
|
||||
int CdPosToInt(CdlLOC *p);
|
||||
int CdRead(int sectors, u_long *buf, int mode);
|
||||
int CdRead2(long mode);
|
||||
int CdReadFile(char *file, u_long *addr, int nbyte);
|
||||
int CdReadSync(int mode, u_char *result);
|
||||
int CdReady(int mode, u_char *result) ;
|
||||
int CdSetDebug(int level);
|
||||
int CdSync(int mode, u_char *result) ;
|
||||
void (*CdDataCallback(void (*func)()));
|
||||
CdlCB CdReadCallback(CdlCB func);
|
||||
CdlCB CdReadyCallback(CdlCB func);
|
||||
CdlCB CdSyncCallback(CdlCB func);
|
||||
int CdInit(void);
|
||||
int CdReset(int mode);
|
||||
int CdStatus(void);
|
||||
int CdLastCom(void);
|
||||
CdlLOC *CdLastPos(void);
|
||||
int CdMode(void);
|
||||
int CdDiskReady( int mode );
|
||||
int CdGetDiskType( void );
|
||||
struct EXEC *CdReadExec(char *file);
|
||||
void CdReadBreak( void );
|
||||
|
||||
#endif
|
58
src_rebuild/EMULATOR/LIBETC.C
Normal file
58
src_rebuild/EMULATOR/LIBETC.C
Normal file
@ -0,0 +1,58 @@
|
||||
#include "LIBETC.H"
|
||||
|
||||
#include "EMULATOR_PRIVATE.H"
|
||||
#include "EMULATOR.H"
|
||||
|
||||
#if defined(_WINDOWS)
|
||||
#include <d3d9.h>
|
||||
#endif
|
||||
|
||||
void(*vsync_callback)(void) = NULL;
|
||||
|
||||
int ResetCallback(void)
|
||||
{
|
||||
vsync_callback = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int VSync(int mode)
|
||||
{
|
||||
///static int startTime = SDL_GetTicks();
|
||||
|
||||
if (mode == 0)
|
||||
{
|
||||
if (vsync_callback != NULL)
|
||||
{
|
||||
vsync_callback();
|
||||
}
|
||||
|
||||
Emulator_EndScene();
|
||||
///return (SDL_GetTicks() - startTime / 1000);
|
||||
}
|
||||
else if (mode > 0)
|
||||
{
|
||||
while (mode--)
|
||||
{
|
||||
//vblank
|
||||
}
|
||||
Emulator_EndScene();
|
||||
}
|
||||
else if (mode < 0)
|
||||
{
|
||||
//Unimplemented
|
||||
///return (SDL_GetTicks() / 1000);
|
||||
}
|
||||
|
||||
return 0;//Assert?
|
||||
}
|
||||
|
||||
int VSyncCallback(void(*f)(void))
|
||||
{
|
||||
vsync_callback = f;
|
||||
return 0;
|
||||
}
|
||||
|
||||
long GetVideoMode(void)
|
||||
{
|
||||
return MODE_NTSC;
|
||||
}
|
56
src_rebuild/EMULATOR/LIBETC.H
Normal file
56
src_rebuild/EMULATOR/LIBETC.H
Normal file
@ -0,0 +1,56 @@
|
||||
#ifndef LIBETC_H
|
||||
#define LIBETC_H
|
||||
|
||||
#include "TYPES.H"
|
||||
|
||||
extern int PadIdentifier;
|
||||
|
||||
#define PADLup (1<<12)
|
||||
#define PADLdown (1<<14)
|
||||
#define PADLleft (1<<15)
|
||||
#define PADLright (1<<13)
|
||||
#define PADRup (1<< 4)
|
||||
#define PADRdown (1<< 6)
|
||||
#define PADRleft (1<< 7)
|
||||
#define PADRright (1<< 5)
|
||||
#define PADi (1<< 9)
|
||||
#define PADj (1<<10)
|
||||
#define PADk (1<< 8)
|
||||
#define PADl (1<< 3)
|
||||
#define PADm (1<< 1)
|
||||
#define PADn (1<< 2)
|
||||
#define PADo (1<< 0)
|
||||
#define PADh (1<<11)
|
||||
#define PADL1 PADn
|
||||
#define PADL2 PADo
|
||||
#define PADR1 PADl
|
||||
#define PADR2 PADm
|
||||
#define PADstart PADh
|
||||
#define PADselect PADk
|
||||
|
||||
#define MOUSEleft (1<<3)
|
||||
#define MOUSEright (1<<2)
|
||||
|
||||
#define _PAD(x,y) ((y)<<((x)<<4))
|
||||
|
||||
#define getScratchAddr(offset) ((u_long *)(0x1f800000+(offset)*4))
|
||||
|
||||
#define MODE_NTSC 0
|
||||
#define MODE_PAL 1
|
||||
|
||||
extern int CheckCallback(void);
|
||||
extern void PadInit(int mode);
|
||||
extern int ResetCallback(void);
|
||||
extern int RestartCallback(void);
|
||||
extern int StopCallback(void);
|
||||
extern int VSync(int mode);
|
||||
extern int VSyncCallback(void (*f)(void)) ;
|
||||
extern long GetVideoMode (void);
|
||||
extern long SetVideoMode (long mode);
|
||||
extern u_long PadRead(int id);
|
||||
extern void PadStop(void);
|
||||
extern void(*vsync_callback)(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
2886
src_rebuild/EMULATOR/LIBGPU.C
Normal file
2886
src_rebuild/EMULATOR/LIBGPU.C
Normal file
File diff suppressed because it is too large
Load Diff
1081
src_rebuild/EMULATOR/LIBGPU.H
Normal file
1081
src_rebuild/EMULATOR/LIBGPU.H
Normal file
File diff suppressed because it is too large
Load Diff
3016
src_rebuild/EMULATOR/LIBGTE.C
Normal file
3016
src_rebuild/EMULATOR/LIBGTE.C
Normal file
File diff suppressed because it is too large
Load Diff
169
src_rebuild/EMULATOR/LIBGTE.H
Normal file
169
src_rebuild/EMULATOR/LIBGTE.H
Normal file
@ -0,0 +1,169 @@
|
||||
#ifndef LIBGTE_H
|
||||
#define LIBGTE_H
|
||||
|
||||
#include "TYPES.H"
|
||||
|
||||
typedef struct {
|
||||
short m[3][3]; /* 3x3 rotation matrix */
|
||||
long t[3]; /* transfer vector */
|
||||
} MATRIX;
|
||||
|
||||
typedef struct { /* long word type 3D vector */
|
||||
long vx, vy;
|
||||
long vz, pad;
|
||||
} VECTOR;
|
||||
|
||||
struct SVECTOR { /* short word type 3D vector */
|
||||
short vx, vy;
|
||||
short vz, pad;
|
||||
};
|
||||
|
||||
struct CVECTOR { /* color type vector */
|
||||
unsigned char r, g, b, cd;
|
||||
};
|
||||
|
||||
typedef struct { /* 2D short vector */
|
||||
short vx, vy;
|
||||
} DVECTOR;
|
||||
|
||||
extern void InitGeom();
|
||||
extern void SetGeomOffset(int ofx, int ofy);
|
||||
extern void SetGeomScreen(int h);
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct { unsigned char l, h, h2, h3; } b;
|
||||
struct { unsigned short l, h; } w;
|
||||
struct { char l, h, h2, h3; } sb;
|
||||
struct { short l, h; } sw;
|
||||
|
||||
unsigned int d;
|
||||
int sd;
|
||||
} PAIR;
|
||||
|
||||
typedef struct {
|
||||
unsigned char r, g, b, c;
|
||||
} CBGR;
|
||||
|
||||
typedef struct {
|
||||
short x, y, z, pad;
|
||||
} SVector3D;
|
||||
|
||||
typedef struct {
|
||||
short x, y;
|
||||
} SVector2D;
|
||||
|
||||
typedef struct {
|
||||
short z, pad;
|
||||
} SVector2Dz;
|
||||
|
||||
typedef struct {
|
||||
short m11, m12, m13, m21, m22, m23, m31, m32, m33, pad;
|
||||
} SMatrix3D;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
SVector3D v0, v1, v2;
|
||||
CBGR rgb;
|
||||
int otz;
|
||||
int ir0, ir1, ir2, ir3;
|
||||
SVector2D sxy0, sxy1, sxy2, sxyp;
|
||||
SVector2Dz sz0, sz1, sz2, sz3;
|
||||
CBGR rgb0, rgb1, rgb2;
|
||||
int reserved;
|
||||
int mac0, mac1, mac2, mac3;
|
||||
unsigned int irgb, orgb;
|
||||
int lzcs, lzcr;
|
||||
} n;
|
||||
|
||||
unsigned int r[32];
|
||||
PAIR p[32];
|
||||
|
||||
} psxCP2Data;
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct {
|
||||
SMatrix3D rMatrix;
|
||||
int trX, trY, trZ;
|
||||
SMatrix3D lMatrix;
|
||||
int rbk, gbk, bbk;
|
||||
SMatrix3D cMatrix;
|
||||
int rfc, gfc, bfc;
|
||||
int ofx, ofy;
|
||||
int h;
|
||||
int dqa, dqb;
|
||||
int zsf3, zsf4;
|
||||
int flag;
|
||||
} n;
|
||||
unsigned int r[32];
|
||||
PAIR p[32];
|
||||
} psxCP2Ctrl;
|
||||
|
||||
typedef union {
|
||||
struct {
|
||||
unsigned int Index, Random, EntryLo0, BPC,
|
||||
Context, BDA, PIDMask, DCIC,
|
||||
BadVAddr, BDAM, EntryHi, BPCM,
|
||||
Status, Cause, EPC, PRid,
|
||||
Config, LLAddr, WatchLO, WatchHI,
|
||||
XContext, Reserved1, Reserved2, Reserved3,
|
||||
Reserved4, Reserved5, ECC, CacheErr,
|
||||
TagLo, TagHi, ErrorEPC, Reserved6;
|
||||
} n;
|
||||
unsigned int r[32];
|
||||
} psxCP0Regs;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
psxCP0Regs CP0; /* Coprocessor0 Registers */
|
||||
psxCP2Data CP2D; /* Cop2 data registers */
|
||||
psxCP2Ctrl CP2C; /* Cop2 control registers */
|
||||
} GTERegisters;
|
||||
|
||||
extern GTERegisters gteRegs;
|
||||
extern unsigned int gte_leadingzerocount(unsigned int lzcs);
|
||||
|
||||
extern void SetRotMatrix(MATRIX* m);
|
||||
extern void SetLightMatrix(MATRIX* m);
|
||||
extern void SetColorMatrix(MATRIX* m);
|
||||
extern void SetTransMatrix(MATRIX* m);
|
||||
extern void PushMatrix();
|
||||
extern void PopMatrix();
|
||||
extern long RotTransPers(struct SVECTOR* v0, long* sxy, long* p, long* flag);
|
||||
extern void RotTrans(struct SVECTOR* v0, VECTOR* v1, long* flag);
|
||||
extern void NormalColorDpq(struct SVECTOR* v0, struct CVECTOR* v1, long p, struct CVECTOR* v2);
|
||||
extern void NormalColorCol(struct SVECTOR* v0, struct CVECTOR* v1, struct CVECTOR* v2);
|
||||
extern long RotAverageNclip4(struct SVECTOR* v0, struct SVECTOR* v1, struct SVECTOR* v2, struct SVECTOR* v3, long* sxy0/*arg_10*/, long* sxy1/*arg_14*/, long* sxy2/*arg_18*/, long* sxy3/*arg_1C*/, long* p/*arg_20*/, long* otz/*arg_24*/, long* flag/*arg_28*/);
|
||||
extern MATRIX* MulMatrix0(MATRIX* m0, MATRIX* m1, MATRIX* m2);
|
||||
extern MATRIX* MulMatrix(MATRIX* m0, MATRIX* m1);
|
||||
extern MATRIX* MulMatrix2(MATRIX* m0, MATRIX* m1);
|
||||
extern void SetBackColor(long rbk, long gbk, long bbk);
|
||||
extern void SetFarColor(long rfc, long gfc, long bfc);
|
||||
extern MATRIX* RotMatrix(struct SVECTOR* r, MATRIX* m);
|
||||
extern MATRIX* TransMatrix(MATRIX* m, VECTOR* v);
|
||||
extern MATRIX* ScaleMatrix(MATRIX* m, VECTOR* v);
|
||||
extern void SetDQA(int iDQA);
|
||||
extern void SetDQB(int iDQB);
|
||||
extern void SetFogNear(long a, long h);
|
||||
extern int rsin(int a);
|
||||
|
||||
#if defined(PGXP)
|
||||
#define MAX_NUM_VERTICES 32768
|
||||
|
||||
struct PGXPVertex
|
||||
{
|
||||
unsigned int originalSXY2;
|
||||
float x;
|
||||
float y;
|
||||
float z;
|
||||
};
|
||||
|
||||
extern struct PGXPVertex pgxp_vertex_buffer[MAX_NUM_VERTICES];
|
||||
extern int pgxp_vertex_index;
|
||||
extern int pgxp_vertex_count;
|
||||
#endif
|
||||
|
||||
#endif
|
6
src_rebuild/EMULATOR/LIBMATH.H
Normal file
6
src_rebuild/EMULATOR/LIBMATH.H
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef LIBMATH_H
|
||||
#define LIBMATH_H
|
||||
|
||||
|
||||
|
||||
#endif
|
309
src_rebuild/EMULATOR/LIBMCRD.C
Normal file
309
src_rebuild/EMULATOR/LIBMCRD.C
Normal file
@ -0,0 +1,309 @@
|
||||
#include "LIBMCRD.H"
|
||||
#include <stdio.h>
|
||||
#include "EMULATOR.H"
|
||||
#include <string.h>
|
||||
|
||||
#define MC_HEADER_FRAME_INDEX (0)
|
||||
|
||||
#pragma pack(push,1)
|
||||
typedef struct MemoryCardFrame
|
||||
{
|
||||
unsigned int attr;
|
||||
unsigned int size;
|
||||
unsigned short unknown;
|
||||
char name[20];
|
||||
char padding[98];
|
||||
} MemoryCardFrame_s, *MemoryCardFrame_p;
|
||||
#pragma pack(pop)
|
||||
|
||||
int bIsInitialised = 0;
|
||||
int bCanUseMemoryCardFuncs = 0;
|
||||
int memoryCardStatus = -1;
|
||||
|
||||
FILE* memoryCards[2];
|
||||
int memoryCardsNew[2];
|
||||
|
||||
int memoryCardCmds = -1;
|
||||
int memoryCardResult = -1;
|
||||
int openFrameIndex = 0;
|
||||
int currentlyOpenedMemoryCard = -1;
|
||||
|
||||
void MemCardInit(long val)
|
||||
{
|
||||
bIsInitialised = 1;
|
||||
bCanUseMemoryCardFuncs = 0;
|
||||
memoryCardStatus = -1;
|
||||
memoryCardCmds = -1;
|
||||
memoryCardResult = -1;
|
||||
memoryCardsNew[0] = 1;
|
||||
memoryCardsNew[1] = 1;
|
||||
}
|
||||
|
||||
void MemCardEnd()
|
||||
{
|
||||
if (!bCanUseMemoryCardFuncs)
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
void MemCardStart()
|
||||
{
|
||||
bCanUseMemoryCardFuncs = 1;
|
||||
}
|
||||
|
||||
void MemCardStop()
|
||||
{
|
||||
if (!bCanUseMemoryCardFuncs)
|
||||
return;
|
||||
|
||||
bCanUseMemoryCardFuncs = 0;
|
||||
memoryCardStatus = -1;
|
||||
memoryCardCmds = -1;
|
||||
memoryCardResult = -1;
|
||||
memoryCardsNew[0] = 1;
|
||||
memoryCardsNew[1] = 1;
|
||||
|
||||
if (memoryCards[0] != NULL)
|
||||
{
|
||||
fclose(memoryCards[0]);
|
||||
}
|
||||
|
||||
if (memoryCards[1] != NULL)
|
||||
{
|
||||
fclose(memoryCards[1]);
|
||||
}
|
||||
}
|
||||
|
||||
long MemCardExist(long chan)
|
||||
{
|
||||
if (!bCanUseMemoryCardFuncs)
|
||||
return 0;
|
||||
|
||||
char buf[16];
|
||||
sprintf(&buf[0], "%ld.MCD", chan);
|
||||
memoryCards[chan] = fopen(&buf[0], "rb");
|
||||
|
||||
memoryCardCmds = McFuncExist;
|
||||
|
||||
if (memoryCards[chan] == NULL)
|
||||
{
|
||||
memoryCardStatus = -1;//CHECKME
|
||||
memoryCardResult = McErrCardNotExist;//CHECKME
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
fclose(memoryCards[chan]);
|
||||
|
||||
if (memoryCardResult == McErrNewCard)
|
||||
{
|
||||
memoryCardResult = McErrNone;
|
||||
memoryCardStatus = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
memoryCardResult = McErrNewCard;
|
||||
memoryCardStatus = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
long MemCardAccept(long chan)
|
||||
{
|
||||
if (!bCanUseMemoryCardFuncs)
|
||||
return 0;
|
||||
|
||||
char buf[16];
|
||||
sprintf(&buf[0], "%ld.MCD", chan);
|
||||
memoryCards[chan] = fopen(&buf[0], "rb");
|
||||
memoryCardCmds = McFuncAccept;
|
||||
|
||||
unsigned int fileMagic = 0;
|
||||
fread(&fileMagic, 4, 1, memoryCards[chan]);
|
||||
fclose(memoryCards[chan]);
|
||||
|
||||
//Is this card formatted?
|
||||
if (fileMagic != 0x0000434D)
|
||||
{
|
||||
//If not, this is a new card!
|
||||
memoryCardResult = McErrNewCard;
|
||||
memoryCardsNew[chan] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
memoryCardResult = 3;
|
||||
memoryCardStatus = 1;
|
||||
return 1;
|
||||
}
|
||||
long MemCardOpen(long chan, char* file, long flag)
|
||||
{
|
||||
if (!bCanUseMemoryCardFuncs)
|
||||
return 0;
|
||||
|
||||
char buf[16];
|
||||
sprintf(&buf[0], "%ld.MCD", chan);
|
||||
|
||||
switch (flag)
|
||||
{
|
||||
case 1:
|
||||
memoryCards[chan] = fopen(&buf[0], "rb");
|
||||
break;
|
||||
case 2://Unchecked
|
||||
memoryCards[chan] = fopen(&buf[0], "wb");
|
||||
break;
|
||||
}
|
||||
|
||||
fseek(memoryCards[chan], 0, SEEK_SET);
|
||||
currentlyOpenedMemoryCard = chan;
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
struct MemoryCardFrame frame;
|
||||
fread(&frame, sizeof(struct MemoryCardFrame), 1, memoryCards[chan]);
|
||||
|
||||
if (i > MC_HEADER_FRAME_INDEX && frame.name[0] != '\0')
|
||||
{
|
||||
if (strcmp(&frame.name[0], file) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
openFrameIndex += frame.attr & 0x7;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void MemCardClose()
|
||||
{
|
||||
openFrameIndex = -1;
|
||||
fclose(memoryCards[currentlyOpenedMemoryCard]);
|
||||
}
|
||||
|
||||
long MemCardReadData(unsigned long* adrs, long ofs, long bytes)
|
||||
{
|
||||
memoryCardCmds = McFuncReadData;
|
||||
if (bytes % 128)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
fseek(memoryCards[currentlyOpenedMemoryCard], (64 * 128) + (openFrameIndex * 16384) + ofs, SEEK_SET);
|
||||
fread(adrs, bytes, 1, memoryCards[currentlyOpenedMemoryCard]);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
long MemCardReadFile(long chan, char* file, unsigned long* adrs, long ofs, long bytes)
|
||||
{
|
||||
memoryCardCmds = McFuncReadFile;
|
||||
return 0;
|
||||
}
|
||||
|
||||
long MemCardWriteData(unsigned long* adrs, long ofs, long bytes)
|
||||
{
|
||||
memoryCardCmds = McFuncWriteData;
|
||||
return 0;
|
||||
}
|
||||
|
||||
long MemCardWriteFile(long chan, char* file, unsigned long* adrs, long ofs, long bytes)
|
||||
{
|
||||
memoryCardCmds = McFuncWriteFile;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
long MemCardCreateFile(long chan, char* file, long blocks)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long MemCardDeleteFile(long chan, char* file)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long MemCardFormat(long chan)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long MemCardUnformat(long chan)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long MemCardSync(long mode, long* cmds, long* rslt)
|
||||
{
|
||||
static int timesCalled = 0;
|
||||
|
||||
//if (timesCalled++ >= 4) //Doesn't work o.o
|
||||
{
|
||||
timesCalled = 0;
|
||||
|
||||
if (memoryCardCmds != -1)
|
||||
{
|
||||
*cmds = memoryCardCmds;
|
||||
}
|
||||
|
||||
if (memoryCardResult != -1)
|
||||
{
|
||||
*rslt = memoryCardResult;
|
||||
}
|
||||
|
||||
if (mode == 1)
|
||||
{
|
||||
return memoryCardStatus;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
MemCB MemCardCallback(MemCB func)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long MemCardGetDirentry(long chan, char* name, struct DIRENTRY* dir, long* files, long ofs, long max)
|
||||
{
|
||||
char buf[16];
|
||||
sprintf(&buf[0], "%ld.MCD", chan);
|
||||
memoryCards[chan] = fopen(&buf[0], "rb");///@FIXME potential bug, if this is called twice then we can open a card twice. Maybe add a flag for whether memcard is open or not if original SDK did this.
|
||||
fseek(memoryCards[chan], 0, SEEK_SET);
|
||||
|
||||
if (strcmp(name, "*") == 0)
|
||||
{
|
||||
for (int i = 0, head = -64; i < 16; i++, head += 128)
|
||||
{
|
||||
struct MemoryCardFrame frame;
|
||||
fread(&frame, sizeof(struct MemoryCardFrame), 1, memoryCards[chan]);
|
||||
|
||||
if (i > MC_HEADER_FRAME_INDEX && frame.name[0] != '\0')
|
||||
{
|
||||
memcpy(dir->name, &frame.name[0], 20);
|
||||
dir->attr = frame.attr & 0xF0;
|
||||
dir->size = frame.size;
|
||||
dir->next = (struct DIRENTRY*)9;
|
||||
dir->head = head;
|
||||
dir->system[0] = 9;
|
||||
dir++;
|
||||
files[0]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
memoryCardCmds = McFuncExist;
|
||||
memoryCardResult = 0;
|
||||
memoryCardStatus = 1;
|
||||
|
||||
return 0;
|
||||
}
|
45
src_rebuild/EMULATOR/LIBMCRD.H
Normal file
45
src_rebuild/EMULATOR/LIBMCRD.H
Normal file
@ -0,0 +1,45 @@
|
||||
#ifndef LIBMCRD_H
|
||||
#define LIBMCRD_H
|
||||
|
||||
#include "KERNEL.H"
|
||||
|
||||
typedef void (*MemCB)( long cmds, long rslt );
|
||||
|
||||
#define McFuncExist (1)
|
||||
#define McFuncAccept (2)
|
||||
#define McFuncReadFile (3)
|
||||
#define McFuncWriteFile (4)
|
||||
#define McFuncReadData (5)
|
||||
#define McFuncWriteData (6)
|
||||
|
||||
#define McErrNone (0)
|
||||
#define McErrCardNotExist (1)
|
||||
#define McErrCardInvalid (2)
|
||||
#define McErrNewCard (3)
|
||||
#define McErrNotFormat (4)
|
||||
#define McErrFileNotExist (5)
|
||||
#define McErrAlreadyExist (6)
|
||||
#define McErrBlockFull (7)
|
||||
#define McErrExtend (0x8000)
|
||||
|
||||
extern void MemCardInit( long val );
|
||||
extern void MemCardEnd( void );
|
||||
extern void MemCardStart(void);
|
||||
extern void MemCardStop(void);
|
||||
extern long MemCardExist( long chan );
|
||||
extern long MemCardAccept( long chan );
|
||||
extern long MemCardOpen( long chan, char* file, long flag );
|
||||
extern void MemCardClose(void);
|
||||
extern long MemCardReadData( unsigned long* adrs, long ofs, long bytes );
|
||||
extern long MemCardReadFile( long chan, char* file, unsigned long* adrs, long ofs, long bytes );
|
||||
extern long MemCardWriteData( unsigned long* adrs, long ofs, long bytes );
|
||||
extern long MemCardWriteFile( long chan, char* file, unsigned long* adrs, long ofs ,long bytes );
|
||||
extern long MemCardCreateFile( long chan, char* file, long blocks );
|
||||
extern long MemCardDeleteFile( long chan, char* file );
|
||||
extern long MemCardFormat( long chan );
|
||||
extern long MemCardUnformat(long chan);
|
||||
extern long MemCardSync( long mode, long* cmds, long* rslt );
|
||||
extern MemCB MemCardCallback( MemCB func );
|
||||
extern long MemCardGetDirentry( long chan, char* name, struct DIRENTRY* dir, long* files, long ofs, long max );
|
||||
|
||||
#endif
|
309
src_rebuild/EMULATOR/LIBPAD.C
Normal file
309
src_rebuild/EMULATOR/LIBPAD.C
Normal file
@ -0,0 +1,309 @@
|
||||
#include "LIBPAD.H"
|
||||
|
||||
#include "EMULATOR.H"
|
||||
|
||||
SDL_GameController* padHandle[MAX_CONTROLLERS];
|
||||
unsigned char* padData[MAX_CONTROLLERS];
|
||||
const unsigned char* keyboardState;
|
||||
|
||||
void PadInitDirect(unsigned char* pad1, unsigned char* pad2)
|
||||
{
|
||||
if (pad1 != NULL)
|
||||
{
|
||||
padData[0] = pad1;
|
||||
padData[0][0] = 0xFF;
|
||||
}
|
||||
|
||||
if (pad2 != NULL)
|
||||
{
|
||||
padData[1] = pad2;
|
||||
padData[1][0] = 0xFF;
|
||||
}
|
||||
|
||||
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER) < 0)
|
||||
{
|
||||
eprinterr("Failed to initialise subsystem GAMECONTROLLER\n");
|
||||
}
|
||||
|
||||
if (SDL_NumJoysticks() < 1)
|
||||
{
|
||||
eprinterr("Failed to locate a connected gamepad!\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < SDL_NumJoysticks(); i++)
|
||||
{
|
||||
if (SDL_IsGameController(i) && i < MAX_CONTROLLERS)
|
||||
{
|
||||
padHandle[i] = SDL_GameControllerOpen(i);///@TODO close joysticks
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
keyboardState = SDL_GetKeyboardState(NULL);
|
||||
}
|
||||
|
||||
void PadInitMtap(unsigned char* unk00, unsigned char* unk01)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void PadInitGun(unsigned char* unk00, int unk01)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
int PadChkVsync()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PadStartCom()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void PadStopCom()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
unsigned int PadEnableCom(unsigned int unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PadEnableGun(unsigned char unk00)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void PadRemoveGun()
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
int PadGetState(int port)
|
||||
{
|
||||
#if _DEBUG || 1
|
||||
return PadStateStable;//FIXME should check if keyboard is connected
|
||||
#endif
|
||||
if (!(SDL_GameControllerGetAttached(padHandle[port])))
|
||||
{
|
||||
return PadStateDiscon;
|
||||
}
|
||||
else
|
||||
{
|
||||
return PadStateStable;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PadInfoMode(int unk00, int unk01, int unk02)
|
||||
{
|
||||
return 7;//?
|
||||
}
|
||||
|
||||
int PadInfoAct(int unk00, int unk01, int unk02)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PadInfoComb(int unk00, int unk01, int unk02)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PadSetActAlign(int unk00, unsigned char* unk01)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PadSetMainMode(int socket, int offs, int lock)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void PadSetAct(int unk00, unsigned char* unk01, int unk02)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
unsigned short UpdateGameControllerInput(SDL_GameController* pad)
|
||||
{
|
||||
unsigned short ret = 0xFFFF;
|
||||
|
||||
if (SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_X))//Square
|
||||
{
|
||||
ret &= ~0x8000;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_B))//Circle
|
||||
{
|
||||
ret &= ~0x2000;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_Y))//Triangle
|
||||
{
|
||||
ret &= ~0x1000;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_A))//Cross
|
||||
{
|
||||
ret &= ~0x4000;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_LEFTSHOULDER))//L1
|
||||
{
|
||||
ret &= ~0x400;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER))//R1
|
||||
{
|
||||
ret &= ~0x800;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_DPAD_UP))//UP
|
||||
{
|
||||
ret &= ~0x10;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_DPAD_DOWN))//DOWN
|
||||
{
|
||||
ret &= ~0x40;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_DPAD_LEFT))//LEFT
|
||||
{
|
||||
ret &= ~0x80;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_DPAD_RIGHT))//RIGHT
|
||||
{
|
||||
ret &= ~0x20;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetAxis(pad, SDL_CONTROLLER_AXIS_TRIGGERLEFT))//L2
|
||||
{
|
||||
ret &= ~0x100;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetAxis(pad, SDL_CONTROLLER_AXIS_TRIGGERRIGHT))//R2
|
||||
{
|
||||
ret &= ~0x200;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_LEFTSTICK))//L3
|
||||
{
|
||||
ret &= ~0x2;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_RIGHTSTICK))//R3
|
||||
{
|
||||
ret &= ~0x4;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_BACK))//SELECT
|
||||
{
|
||||
ret &= ~0x1;
|
||||
}
|
||||
|
||||
if (SDL_GameControllerGetButton(pad, SDL_CONTROLLER_BUTTON_START))//START
|
||||
{
|
||||
ret &= ~0x8;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned short UpdateKeyboardInput()
|
||||
{
|
||||
unsigned short ret = 0xFFFF;
|
||||
|
||||
//Not initialised yet
|
||||
if (keyboardState == NULL)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
SDL_PumpEvents();
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_X])//Square
|
||||
{
|
||||
ret &= ~0x8000;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_V])//Circle
|
||||
{
|
||||
ret &= ~0x2000;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_Z])//Triangle
|
||||
{
|
||||
ret &= ~0x1000;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_C])//Cross
|
||||
{
|
||||
ret &= ~0x4000;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_LSHIFT])//L1
|
||||
{
|
||||
ret &= ~0x400;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_RSHIFT])//R1
|
||||
{
|
||||
ret &= ~0x800;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_UP])//UP
|
||||
{
|
||||
ret &= ~0x10;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_DOWN])//DOWN
|
||||
{
|
||||
ret &= ~0x40;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_LEFT])//LEFT
|
||||
{
|
||||
ret &= ~0x80;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_RIGHT])//RIGHT
|
||||
{
|
||||
ret &= ~0x20;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_LCTRL])//L2
|
||||
{
|
||||
ret &= ~0x100;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_RCTRL])//R2
|
||||
{
|
||||
ret &= ~0x200;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_SPACE])//SELECT
|
||||
{
|
||||
ret &= ~0x1;
|
||||
}
|
||||
|
||||
if (keyboardState[SDL_SCANCODE_RETURN])//START
|
||||
{
|
||||
ret &= ~0x8;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
55
src_rebuild/EMULATOR/LIBPAD.H
Normal file
55
src_rebuild/EMULATOR/LIBPAD.H
Normal file
@ -0,0 +1,55 @@
|
||||
#ifndef LIBPAD_H
|
||||
#define LIBPAD_H
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#endif
|
||||
#ifndef FALSE
|
||||
#define FALSE 0
|
||||
#endif
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#define PadStateDiscon 0
|
||||
#define PadStateFindPad 1
|
||||
#define PadStateFindCTP1 2
|
||||
#define PadStateFindCTP2 3
|
||||
#define PadStateReqInfo 4
|
||||
#define PadStateExecCmd 5
|
||||
#define PadStateStable 6
|
||||
|
||||
#define InfoModeCurID 1
|
||||
#define InfoModeCurExID 2
|
||||
#define InfoModeCurExOffs 3
|
||||
#define InfoModeIdTable 4
|
||||
|
||||
#define InfoActFunc 1
|
||||
#define InfoActSub 2
|
||||
#define InfoActSize 3
|
||||
#define InfoActCurr 4
|
||||
#define InfoActSign 5
|
||||
|
||||
#define PadMaxCurr 60
|
||||
#define PadCurrCTP1 10
|
||||
|
||||
#define MAX_CONTROLLERS 2
|
||||
|
||||
extern void PadInitDirect(unsigned char* pad1, unsigned char* pad2);
|
||||
extern void PadInitMtap(unsigned char* unk00, unsigned char* unk01);
|
||||
extern void PadInitGun(unsigned char* unk00, int unk01);
|
||||
extern int PadChkVsync();
|
||||
extern void PadStartCom();
|
||||
extern void PadStopCom();
|
||||
extern unsigned int PadEnableCom(unsigned int unk00);
|
||||
extern void PadEnableGun(unsigned char unk00);
|
||||
extern void PadRemoveGun();
|
||||
extern int PadGetState(int port);
|
||||
extern int PadInfoMode(int unk00, int, int unk01);
|
||||
extern int PadInfoAct(int unk00, int, int unk01);
|
||||
extern int PadInfoComb(int unk00, int, int unk01);
|
||||
extern int PadSetActAlign(int unk00, unsigned char* unk01);
|
||||
extern int PadSetMainMode(int socket, int offs, int lock);
|
||||
extern void PadSetAct(int unk00, unsigned char* unk01, int unk02);
|
||||
|
||||
#endif
|
72
src_rebuild/EMULATOR/LIBSN.C
Normal file
72
src_rebuild/EMULATOR/LIBSN.C
Normal file
@ -0,0 +1,72 @@
|
||||
#include "LIBSN.H"
|
||||
|
||||
//#include "EMULATOR.H"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
uintptr_t fileHandle = 0;
|
||||
|
||||
#define INVALID_FILE_HANDLE (-1)
|
||||
|
||||
int PCinit()
|
||||
{
|
||||
//UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
uintptr_t PCopen(char* name, int flags, int perms)
|
||||
{
|
||||
//TOMB5 hack for CUTSEQ.JIZ
|
||||
if (name[0] == '\\')
|
||||
{
|
||||
++name;
|
||||
}
|
||||
|
||||
#if defined(__ANDROID__)
|
||||
char buff[64];
|
||||
sprintf(&buff[0], "/storage/emulated/0/TOMB5/%s", name);
|
||||
name = &buff[0];
|
||||
#endif
|
||||
|
||||
switch (flags)
|
||||
{
|
||||
case 0:
|
||||
fileHandle = (uintptr_t)fopen(name, "rb");
|
||||
break;
|
||||
case 1:
|
||||
fileHandle = (uintptr_t)fopen(name, "wb");
|
||||
break;
|
||||
case 2:
|
||||
fileHandle = (uintptr_t)fopen(name, "rwb");
|
||||
break;
|
||||
}
|
||||
|
||||
return fileHandle == 0 ? INVALID_FILE_HANDLE : fileHandle;
|
||||
}
|
||||
|
||||
int PCcreat(char* name, int perms)
|
||||
{
|
||||
//UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int PClseek(uintptr_t fd, int offset, int mode)
|
||||
{
|
||||
fseek((FILE*)fd, offset, mode);
|
||||
return ftell((FILE*)fd);
|
||||
}
|
||||
|
||||
int PCread(uintptr_t fd, char* buff, int len)
|
||||
{
|
||||
return fread(buff, len, 1, (FILE*)fd);
|
||||
}
|
||||
|
||||
int PCwrite(uintptr_t fd, char* buff, int len)
|
||||
{
|
||||
return fwrite(buff, len, 1, (FILE*)fd);
|
||||
}
|
||||
|
||||
int PCclose(uintptr_t fd)
|
||||
{
|
||||
return fclose((FILE*)fd);
|
||||
}
|
14
src_rebuild/EMULATOR/LIBSN.H
Normal file
14
src_rebuild/EMULATOR/LIBSN.H
Normal file
@ -0,0 +1,14 @@
|
||||
#ifndef LIBSN_H
|
||||
#define LIBSN_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern int PCinit();
|
||||
extern uintptr_t PCopen(char* name, int flags, int perms);
|
||||
extern int PCcreat(char* name, int perms);
|
||||
extern int PClseek(uintptr_t fd, int offset, int mode);
|
||||
extern int PCread(uintptr_t fd, char* buff, int len);
|
||||
extern int PCwrite(uintptr_t fd, char* buff, int len);
|
||||
extern int PCclose(uintptr_t fd);
|
||||
|
||||
#endif
|
286
src_rebuild/EMULATOR/LIBSPU.C
Normal file
286
src_rebuild/EMULATOR/LIBSPU.C
Normal file
@ -0,0 +1,286 @@
|
||||
#include "LIBSPU.H"
|
||||
#include "LIBETC.H"
|
||||
#include <stdio.h>
|
||||
#include "EMULATOR.H"
|
||||
#include "LIBAPI.H"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define SPU_CENTERNOTE (49152)
|
||||
|
||||
short _spu_voice_centerNote[24] =
|
||||
{
|
||||
SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE,
|
||||
SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE,
|
||||
SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE, SPU_CENTERNOTE
|
||||
};
|
||||
|
||||
SpuCommonAttr dword_424;//Might be wrong struct, need to check
|
||||
int _spu_isCalled = 0;
|
||||
int _spu_FiDMA = 0;///@TODO decl as extern find initial value
|
||||
int _spu_EVdma = 0;
|
||||
int _spu_rev_flag = 0;
|
||||
int _spu_rev_reserve_wa = 0;
|
||||
int _spu_rev_offsetaddr = 0;
|
||||
int _spu_rev_startaddr = 0;
|
||||
int _spu_AllocBlockNum = 0;
|
||||
int _spu_AllocLastNum = 0;
|
||||
int _spu_memList = 0;
|
||||
int _spu_trans_mode = 0;
|
||||
int _spu_transMode = 0;
|
||||
int _spu_keystat = 0;
|
||||
int _spu_RQmask = 0;
|
||||
int _spu_RQvoice = 0;
|
||||
int _spu_env = 0;
|
||||
char spu[440];//0x1F801C00 is base address
|
||||
short* _spu_RXX = (short*)&spu[0];
|
||||
int _spu_mem_mode_plus = 3;
|
||||
void* _spu_transferCallback = NULL;///@TODO initial value check
|
||||
int _spu_inTransfer = 0;///@TODO initial value check
|
||||
unsigned short _spu_tsa = 0;
|
||||
|
||||
void SpuGetAllKeysStatus(char* status)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void SpuSetKeyOnWithAttr(SpuVoiceAttr* attr)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void _spu_t(int mode, int flag)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void _spu_Fw(unsigned char* addr, unsigned long size)
|
||||
{
|
||||
//v0 = _spu_transMode
|
||||
//s1 = addr
|
||||
//s0 = size
|
||||
|
||||
if (_spu_trans_mode == 0)
|
||||
{
|
||||
//v0 = _spu_tsa
|
||||
//a1 = _spu_mem_mode_plus
|
||||
//a0 = 2
|
||||
_spu_t(2, _spu_tsa << _spu_mem_mode_plus);
|
||||
///@TODO check if a1 is modified in spu_t
|
||||
}
|
||||
//loc_A84
|
||||
#if 0
|
||||
jal _spu_t
|
||||
sllv $a1, $v0, $a1
|
||||
|
||||
jal _spu_t
|
||||
li $a0, 1
|
||||
|
||||
li $a0, 3
|
||||
move $a1, $s1
|
||||
jal _spu_t
|
||||
move $a2, $s0
|
||||
j loc_A94
|
||||
move $v0, $s0
|
||||
|
||||
loc_A84:
|
||||
move $a0, $s1
|
||||
jal sub_480
|
||||
move $a1, $s0
|
||||
move $v0, $s0
|
||||
|
||||
loc_A94:
|
||||
lw $ra, 0x20+var_8($sp)
|
||||
lw $s1, 0x20+var_C($sp)
|
||||
lw $s0, 0x20+var_10($sp)
|
||||
jr $ra
|
||||
addiu $sp, 0x20
|
||||
# End of function _spu_Fw
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned long SpuWrite(unsigned char* addr, unsigned long size)
|
||||
{
|
||||
if (0x7EFF0 < size)
|
||||
{
|
||||
size = 0x7EFF0;
|
||||
}
|
||||
|
||||
//loc_228
|
||||
_spu_Fw(addr, size);
|
||||
|
||||
if (_spu_transferCallback == NULL)
|
||||
{
|
||||
_spu_inTransfer = 0;
|
||||
}
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
long SpuSetTransferMode(long mode)
|
||||
{
|
||||
long mode_fix = mode == 0 ? 0 : 1;
|
||||
|
||||
//trans_mode = mode;
|
||||
//transMode = mode_fix;
|
||||
|
||||
return mode_fix;
|
||||
}
|
||||
|
||||
unsigned long SpuSetTransferStartAddr(unsigned long addr)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
long SpuIsTransferCompleted(long flag)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _SpuDataCallback(int a0)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void SpuStart()//(F)
|
||||
{
|
||||
long event = 0;
|
||||
|
||||
if (_spu_isCalled == 0)
|
||||
{
|
||||
_spu_isCalled = 1;
|
||||
EnterCriticalSection();
|
||||
_SpuDataCallback(_spu_FiDMA);
|
||||
event = OpenEvent(HwSPU, EvSpCOMP, EvMdNOINTR, NULL);
|
||||
_spu_EVdma = event;
|
||||
EnableEvent(event);
|
||||
ExitCriticalSection();
|
||||
}
|
||||
//loc_348
|
||||
}
|
||||
|
||||
void _spu_init(int a0)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
void _spu_FsetRXX(int a0, int a1, int a2)//(F)
|
||||
{
|
||||
if (a2 == 0)
|
||||
{
|
||||
_spu_RXX[a0] = a1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_spu_RXX[a0] = a1 >> _spu_mem_mode_plus;
|
||||
}
|
||||
}
|
||||
|
||||
void _SpuInit(int a0)
|
||||
{
|
||||
ResetCallback();
|
||||
_spu_init(a0);
|
||||
|
||||
if (a0 == 0)
|
||||
{
|
||||
for (int i = 0; i < sizeof(_spu_voice_centerNote) / sizeof(short); i++)
|
||||
{
|
||||
_spu_voice_centerNote[i] = SPU_CENTERNOTE;
|
||||
}
|
||||
}
|
||||
//loc_240
|
||||
SpuStart();
|
||||
|
||||
_spu_rev_flag = 0;
|
||||
_spu_rev_reserve_wa = 0;
|
||||
dword_424.mask = 0;
|
||||
dword_424.mvol.left = 0;
|
||||
dword_424.mvol.right = 0;
|
||||
dword_424.mvolmode.left = 0;
|
||||
dword_424.mvolmode.right = 0;
|
||||
dword_424.mvolx.left = 0;
|
||||
dword_424.mvolx.right = 0;
|
||||
_spu_rev_offsetaddr = _spu_rev_startaddr;
|
||||
_spu_FsetRXX(209, _spu_rev_startaddr, 0);
|
||||
_spu_AllocBlockNum = 0;
|
||||
_spu_AllocLastNum = 0;
|
||||
_spu_memList = 0;
|
||||
_spu_trans_mode = 0;
|
||||
_spu_transMode = 0;
|
||||
_spu_keystat = 0;
|
||||
_spu_RQmask = 0;
|
||||
_spu_RQvoice = 0;
|
||||
_spu_env = 0;
|
||||
}
|
||||
|
||||
void SpuInit(void)
|
||||
{
|
||||
_SpuInit(0);
|
||||
}
|
||||
|
||||
long SpuSetReverb(long on_off)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
unsigned long SpuSetReverbVoice(long on_off, unsigned long voice_bit)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SpuSetCommonAttr(SpuCommonAttr* attr)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
long SpuInitMalloc(long num, char* top)//(F)
|
||||
{
|
||||
if (num > 0)
|
||||
{
|
||||
//loc_214
|
||||
((int*)top)[0] = 0x40001010;
|
||||
_spu_memList = (uintptr_t)top;
|
||||
_spu_AllocLastNum = 0;
|
||||
_spu_AllocBlockNum = num;
|
||||
((int*)top)[1] = (0x10000000 << _spu_mem_mode_plus) - 0x1010;
|
||||
}
|
||||
|
||||
return num;
|
||||
}
|
||||
|
||||
long SpuMalloc(long size)
|
||||
{
|
||||
return 0/*(long)(uintptr_t)malloc(size)*/;
|
||||
}
|
||||
|
||||
long SpuMallocWithStartAddr(unsigned long addr, long size)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SpuFree(unsigned long addr)
|
||||
{
|
||||
/*free((void*)(uintptr_t)addr)*/;
|
||||
}
|
||||
|
||||
void SpuSetCommonMasterVolume(short mvol_left, short mvol_right)// (F)
|
||||
{
|
||||
//MasterVolume.VolumeLeft.Raw = mvol_left;
|
||||
//MasterVolume.VolumeRight.Raw = mvol_right;
|
||||
}
|
||||
|
||||
long SpuSetReverbModeType(long mode)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
return 0;
|
||||
}
|
||||
|
||||
void SpuSetReverbModeDepth(short depth_left, short depth_right)
|
||||
{
|
||||
UNIMPLEMENTED();
|
||||
}
|
552
src_rebuild/EMULATOR/LIBSPU.H
Normal file
552
src_rebuild/EMULATOR/LIBSPU.H
Normal file
@ -0,0 +1,552 @@
|
||||
#ifndef LIBSPU_H
|
||||
#define LIBSPU_H
|
||||
|
||||
/*****************************************************************
|
||||
* -*- c -*-
|
||||
* $RCSfile: libspu.h,v $
|
||||
*
|
||||
* Copyright (c) 1993, 1994, 1995, 1996 Sony Computer Entertainment Inc.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
* This file is part of ``PlayStation(R)'' Programmer Tool /
|
||||
* Runtime Library.
|
||||
*
|
||||
* R & D Division, Sony Computer Entertainment Inc.
|
||||
*
|
||||
* $Id: libspu.h,v 1.80 1997/06/24 11:14:04 kaol Exp $
|
||||
*
|
||||
*****************************************************************/
|
||||
/*
|
||||
* $PSLibId: Run-time Library Release 4.6$
|
||||
*/
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* CONSTANT
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
#define SPU_SUCCESS 0
|
||||
#define SPU_INVALID_ARGS (-3)
|
||||
#define SPU_DIAG (-2)
|
||||
#define SPU_CHECK (-1)
|
||||
#define SPU_OFF 0
|
||||
#define SPU_ON 1
|
||||
#define SPU_CLEAR 2
|
||||
#define SPU_RESET 3
|
||||
#define SPU_DONT_CARE 4
|
||||
#define SPU_ALL 0
|
||||
#define SPU_CDONLY 5
|
||||
#define SPU_VOICEONLY 6
|
||||
#define SPU_CONT 7
|
||||
#define SPU_BIT 8
|
||||
#define SPU_NULL 0
|
||||
/* Macros below will be obsoleted. */
|
||||
#define SpuDiag SPU_DIAG
|
||||
#define SpuCheck SPU_CHECK
|
||||
#define SpuOff SPU_OFF
|
||||
#define SpuOn SPU_ON
|
||||
#define SpuClear SPU_CLEAR
|
||||
#define SpuReset SPU_RESET
|
||||
#define SpuDontCare SPU_DONT_CARE
|
||||
#define SpuALL SPU_ALL
|
||||
#define SpuCDOnly SPU_CDONLY
|
||||
#define SpuVoiceOnly SPU_VOICEONLY
|
||||
#define SpuCont SPU_CONT
|
||||
#define SpuNull SPU_NULL
|
||||
|
||||
#define SPU_OFF_ENV_ON 2
|
||||
#define SPU_ON_ENV_OFF 3
|
||||
/* Macros below will be obsoleted. */
|
||||
#define SpuOffEnvOn SPU_OFF_ENV_ON
|
||||
#define SpuOnEnvOff SPU_ON_ENV_OFF
|
||||
|
||||
#define SPU_ERROR (-1)
|
||||
/* Macros below will be obsoleted. */
|
||||
#define SpuError SPU_ERROR
|
||||
|
||||
#define SPU_TRANSFER_BY_DMA 0L
|
||||
#define SPU_TRANSFER_BY_IO 1L
|
||||
/* Macros below will be obsoleted. */
|
||||
#define SpuTransferByDMA SPU_TRANSFER_BY_DMA
|
||||
#define SpuTransferByIO SPU_TRANSFER_BY_IO
|
||||
#define SpuTransByDMA SpuTransferByDMA
|
||||
#define SpuTransByIO SpuTransferByIO
|
||||
|
||||
#define SPU_TRANSFER_WAIT 1
|
||||
#define SPU_TRANSFER_PEEK 0
|
||||
#define SPU_TRANSFER_GLANCE SPU_TRANSFER_PEEK
|
||||
|
||||
/*
|
||||
* Voice designate
|
||||
*/
|
||||
|
||||
#ifndef __SPU_VOICE
|
||||
#define __SPU_VOICE
|
||||
|
||||
#define SPU_00CH (0x1L<< 0)
|
||||
#define SPU_01CH (0x1L<< 1)
|
||||
#define SPU_02CH (0x1L<< 2)
|
||||
#define SPU_03CH (0x1L<< 3)
|
||||
#define SPU_04CH (0x1L<< 4)
|
||||
#define SPU_05CH (0x1L<< 5)
|
||||
#define SPU_06CH (0x1L<< 6)
|
||||
#define SPU_07CH (0x1L<< 7)
|
||||
#define SPU_08CH (0x1L<< 8)
|
||||
#define SPU_09CH (0x1L<< 9)
|
||||
#define SPU_10CH (0x1L<<10)
|
||||
#define SPU_11CH (0x1L<<11)
|
||||
#define SPU_12CH (0x1L<<12)
|
||||
#define SPU_13CH (0x1L<<13)
|
||||
#define SPU_14CH (0x1L<<14)
|
||||
#define SPU_15CH (0x1L<<15)
|
||||
#define SPU_16CH (0x1L<<16)
|
||||
#define SPU_17CH (0x1L<<17)
|
||||
#define SPU_18CH (0x1L<<18)
|
||||
#define SPU_19CH (0x1L<<19)
|
||||
|
||||
#define SPU_20CH (0x1L<<20)
|
||||
#define SPU_21CH (0x1L<<21)
|
||||
#define SPU_22CH (0x1L<<22)
|
||||
#define SPU_23CH (0x1L<<23)
|
||||
|
||||
#define SPU_0CH SPU_00CH
|
||||
#define SPU_1CH SPU_01CH
|
||||
#define SPU_2CH SPU_02CH
|
||||
#define SPU_3CH SPU_03CH
|
||||
#define SPU_4CH SPU_04CH
|
||||
#define SPU_5CH SPU_05CH
|
||||
#define SPU_6CH SPU_06CH
|
||||
#define SPU_7CH SPU_07CH
|
||||
#define SPU_8CH SPU_08CH
|
||||
#define SPU_9CH SPU_09CH
|
||||
|
||||
#define SPU_ALLCH (SPU_00CH | SPU_01CH | SPU_02CH | SPU_03CH | SPU_04CH | \
|
||||
SPU_05CH | SPU_06CH | SPU_07CH | SPU_08CH | SPU_09CH | \
|
||||
SPU_10CH | SPU_11CH | SPU_12CH | SPU_13CH | SPU_14CH | \
|
||||
SPU_15CH | SPU_16CH | SPU_17CH | SPU_18CH | SPU_19CH | \
|
||||
SPU_20CH | SPU_21CH | SPU_22CH | SPU_23CH)
|
||||
|
||||
#define SPU_KEYCH(x) (0x1L<<(x))
|
||||
#define SPU_VOICECH(x) SPU_KEYCH(x)
|
||||
|
||||
#endif /* __SPU_VOICE */
|
||||
|
||||
/* for Voice setting */
|
||||
|
||||
#define SPU_VOICE_VOLL (0x01 << 0) /* volume (left) */
|
||||
#define SPU_VOICE_VOLR (0x01 << 1) /* volume (right) */
|
||||
#define SPU_VOICE_VOLMODEL (0x01 << 2) /* volume mode (left) */
|
||||
#define SPU_VOICE_VOLMODER (0x01 << 3) /* volume mode (right) */
|
||||
#define SPU_VOICE_PITCH (0x01 << 4) /* tone (pitch setting) */
|
||||
#define SPU_VOICE_NOTE (0x01 << 5) /* tone (note setting) */
|
||||
#define SPU_VOICE_SAMPLE_NOTE (0x01 << 6) /* waveform data sample note */
|
||||
#define SPU_VOICE_WDSA (0x01 << 7) /* waveform data start address */
|
||||
#define SPU_VOICE_ADSR_AMODE (0x01 << 8) /* ADSR Attack rate mode */
|
||||
#define SPU_VOICE_ADSR_SMODE (0x01 << 9) /* ADSR Sustain rate mode */
|
||||
#define SPU_VOICE_ADSR_RMODE (0x01 << 10) /* ADSR Release rate mode */
|
||||
#define SPU_VOICE_ADSR_AR (0x01 << 11) /* ADSR Attack rate */
|
||||
#define SPU_VOICE_ADSR_DR (0x01 << 12) /* ADSR Decay rate */
|
||||
#define SPU_VOICE_ADSR_SR (0x01 << 13) /* ADSR Sustain rate */
|
||||
#define SPU_VOICE_ADSR_RR (0x01 << 14) /* ADSR Release rate */
|
||||
#define SPU_VOICE_ADSR_SL (0x01 << 15) /* ADSR Sustain level */
|
||||
#define SPU_VOICE_LSAX (0x01 << 16) /* start address for loop */
|
||||
#define SPU_VOICE_ADSR_ADSR1 (0x01 << 17) /* ADSR adsr1 for `VagAtr' */
|
||||
#define SPU_VOICE_ADSR_ADSR2 (0x01 << 18) /* ADSR adsr2 for `VagAtr' */
|
||||
|
||||
#define SPU_VOICE_DIRECT16 0
|
||||
#define SPU_VOICE_LINEARIncN 1
|
||||
#define SPU_VOICE_LINEARIncR 2
|
||||
#define SPU_VOICE_LINEARDecN 3
|
||||
#define SPU_VOICE_LINEARDecR 4
|
||||
#define SPU_VOICE_EXPIncN 5
|
||||
#define SPU_VOICE_EXPIncR 6
|
||||
#define SPU_VOICE_EXPDec 7
|
||||
#define SPU_VOICE_EXPDecN SPU_VOICE_EXPDec
|
||||
#define SPU_VOICE_EXPDecR SPU_VOICE_EXPDec
|
||||
|
||||
#define SPU_DECODED_FIRSTHALF 0
|
||||
#define SPU_DECODED_SECONDHALF 1
|
||||
#define SPU_DECODE_FIRSTHALF SPU_DECODED_FIRSTHALF
|
||||
#define SPU_DECODE_SECONDHALF SPU_DECODED_SECONDHALF
|
||||
|
||||
|
||||
#define SPU_COMMON_MVOLL (0x01 << 0) /* master volume (left) */
|
||||
#define SPU_COMMON_MVOLR (0x01 << 1) /* master volume (right) */
|
||||
#define SPU_COMMON_MVOLMODEL (0x01 << 2) /* master volume mode (left) */
|
||||
#define SPU_COMMON_MVOLMODER (0x01 << 3) /* master volume mode (right) */
|
||||
#define SPU_COMMON_RVOLL (0x01 << 4) /* reverb volume (left) */
|
||||
#define SPU_COMMON_RVOLR (0x01 << 5) /* reverb volume (right) */
|
||||
#define SPU_COMMON_CDVOLL (0x01 << 6) /* CD input volume (left) */
|
||||
#define SPU_COMMON_CDVOLR (0x01 << 7) /* CD input volume (right) */
|
||||
#define SPU_COMMON_CDREV (0x01 << 8) /* CD input reverb on/off */
|
||||
#define SPU_COMMON_CDMIX (0x01 << 9) /* CD input on/off */
|
||||
#define SPU_COMMON_EXTVOLL (0x01 << 10) /* external digital input volume (left) */
|
||||
#define SPU_COMMON_EXTVOLR (0x01 << 11) /* external digital input volume (right) */
|
||||
#define SPU_COMMON_EXTREV (0x01 << 12) /* external digital input reverb on/off */
|
||||
#define SPU_COMMON_EXTMIX (0x01 << 13) /* external digital input on/off */
|
||||
|
||||
/* for Reverb setting */
|
||||
|
||||
#define SPU_REV_MODE (0x01 << 0) /* mode setting */
|
||||
#define SPU_REV_DEPTHL (0x01 << 1) /* reverb depth (left) */
|
||||
#define SPU_REV_DEPTHR (0x01 << 2) /* reverb depth (right) */
|
||||
#define SPU_REV_DELAYTIME (0x01 << 3) /* Delay Time (ECHO, DELAY only) */
|
||||
#define SPU_REV_FEEDBACK (0x01 << 4) /* Feedback (ECHO only) */
|
||||
|
||||
#define SPU_REV_MODE_CHECK (-1)
|
||||
#define SPU_REV_MODE_OFF 0
|
||||
#define SPU_REV_MODE_ROOM 1
|
||||
#define SPU_REV_MODE_STUDIO_A 2
|
||||
#define SPU_REV_MODE_STUDIO_B 3
|
||||
#define SPU_REV_MODE_STUDIO_C 4
|
||||
#define SPU_REV_MODE_HALL 5
|
||||
#define SPU_REV_MODE_SPACE 6
|
||||
#define SPU_REV_MODE_ECHO 7
|
||||
#define SPU_REV_MODE_DELAY 8
|
||||
#define SPU_REV_MODE_PIPE 9
|
||||
#define SPU_REV_MODE_MAX 10
|
||||
|
||||
#define SPU_REV_MODE_CLEAR_WA 0x100
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* Event flushing
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
#define SPU_EVENT_KEY (0x01 << 0)
|
||||
#define SPU_EVENT_PITCHLFO (0x01 << 1)
|
||||
#define SPU_EVENT_NOISE (0x01 << 2)
|
||||
#define SPU_EVENT_REVERB (0x01 << 3)
|
||||
|
||||
#define SPU_EVENT_ALL 0
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* Structure
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
typedef struct {
|
||||
short left; /* Lch */
|
||||
short right; /* Rch */
|
||||
} SpuVolume;
|
||||
|
||||
typedef struct {
|
||||
unsigned long voice; /* set voice:
|
||||
SpuSetVoiceAttr: each voice is a bit array
|
||||
SpuGetVoiceAttr: voice is a bit value */
|
||||
unsigned long mask; /* settings attribute bit (invalid with Get) */
|
||||
SpuVolume volume; /* volume */
|
||||
SpuVolume volmode; /* volume mode */
|
||||
SpuVolume volumex; /* current volume (invalid with Set) */
|
||||
unsigned short pitch; /* tone (pitch setting) */
|
||||
unsigned short note; /* tone (note setting) */
|
||||
unsigned short sample_note; /* tone (note setting) */
|
||||
short envx; /* current envelope value (invalid with Set) */
|
||||
unsigned long addr; /* waveform data start address */
|
||||
unsigned long loop_addr; /* loop start address */
|
||||
long a_mode; /* Attack rate mode */
|
||||
long s_mode; /* Sustain rate mode */
|
||||
long r_mode; /* Release rate mode */
|
||||
unsigned short ar; /* Attack rate */
|
||||
unsigned short dr; /* Decay rate */
|
||||
unsigned short sr; /* Sustain rate */
|
||||
unsigned short rr; /* Release rate */
|
||||
unsigned short sl; /* Sustain level */
|
||||
unsigned short adsr1; /* adsr1 for `VagAtr' */
|
||||
unsigned short adsr2; /* adsr2 for `VagAtr' */
|
||||
} SpuVoiceAttr;
|
||||
|
||||
typedef struct {
|
||||
short voiceNum; /* voice number */
|
||||
short pad; /* padding */
|
||||
SpuVoiceAttr attr; /* voice attribute */
|
||||
} SpuLVoiceAttr;
|
||||
|
||||
typedef struct {
|
||||
unsigned long mask; /* settings mask */
|
||||
|
||||
long mode; /* reverb mode */
|
||||
SpuVolume depth; /* reverb depth */
|
||||
long delay; /* Delay Time (ECHO, DELAY only) */
|
||||
long feedback; /* Feedback (ECHO only) */
|
||||
} SpuReverbAttr;
|
||||
|
||||
#define SPU_DECODEDDATA_SIZE 0x200
|
||||
#define SPU_DECODEDATA_SIZE SPU_DECODEDDATA_SIZE
|
||||
typedef struct {
|
||||
short cd_left [SPU_DECODEDDATA_SIZE];
|
||||
short cd_right [SPU_DECODEDDATA_SIZE];
|
||||
short voice1 [SPU_DECODEDDATA_SIZE];
|
||||
short voice3 [SPU_DECODEDDATA_SIZE];
|
||||
} SpuDecodedData;
|
||||
typedef SpuDecodedData SpuDecodeData;
|
||||
|
||||
typedef struct {
|
||||
SpuVolume volume; /* volume */
|
||||
long reverb; /* reverb on/off */
|
||||
long mix; /* mixing on/off */
|
||||
} SpuExtAttr;
|
||||
|
||||
typedef struct {
|
||||
unsigned long mask; /* settings mask */
|
||||
|
||||
SpuVolume mvol; /* master volume */
|
||||
SpuVolume mvolmode; /* master volume mode */
|
||||
SpuVolume mvolx; /* current master volume */
|
||||
SpuExtAttr cd; /* CD input attributes */
|
||||
SpuExtAttr ext; /* external digital input attributes */
|
||||
} SpuCommonAttr;
|
||||
|
||||
#ifndef __SPU_IRQCALLBACK_PROC
|
||||
#define __SPU_IRQCALLBACK_PROC
|
||||
typedef void (*SpuIRQCallbackProc)(void);
|
||||
#endif /* __SPU_IRQCALLBACK_PROC */
|
||||
#ifndef __SPU_TRANSFERCALLBACK_PROC
|
||||
#define __SPU_TRANSFERCALLBACK_PROC
|
||||
typedef void (*SpuTransferCallbackProc)(void);
|
||||
#endif /* __SPU_TRANSFERCALLBACK_PROC */
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* for SPU Malloc (used in SpuInitMalloc())
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
#define SPU_MALLOC_RECSIZ 8
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* User specifiable global environment
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
typedef struct {
|
||||
unsigned long mask;
|
||||
unsigned long queueing;
|
||||
} SpuEnv;
|
||||
|
||||
#define SPU_ENV_EVENT_QUEUEING (0x01 << 0)
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* prototype declaration
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
extern void SpuInit (void);
|
||||
extern void SpuInitHot (void);
|
||||
extern void SpuStart (void);
|
||||
extern void SpuQuit (void);
|
||||
extern long SpuSetMute (long on_off);
|
||||
extern long SpuGetMute (void);
|
||||
extern void SpuSetEnv (SpuEnv *env);
|
||||
|
||||
extern long SpuSetNoiseClock (long n_clock);
|
||||
extern long SpuGetNoiseClock (void);
|
||||
extern unsigned long SpuSetNoiseVoice (long on_off, unsigned long voice_bit);
|
||||
extern unsigned long SpuGetNoiseVoice (void);
|
||||
|
||||
extern long SpuSetReverb (long on_off);
|
||||
extern long SpuGetReverb (void);
|
||||
extern long SpuSetReverbModeParam (SpuReverbAttr *attr);
|
||||
extern void SpuGetReverbModeParam (SpuReverbAttr *attr);
|
||||
extern long SpuSetReverbDepth (SpuReverbAttr *attr);
|
||||
extern long SpuReserveReverbWorkArea (long on_off);
|
||||
extern long SpuIsReverbWorkAreaReserved (long on_off);
|
||||
extern unsigned long SpuSetReverbVoice (long on_off, unsigned long voice_bit);
|
||||
extern unsigned long SpuGetReverbVoice (void);
|
||||
extern long SpuClearReverbWorkArea (long mode);
|
||||
|
||||
extern unsigned long SpuWrite (unsigned char *addr, unsigned long size);
|
||||
extern unsigned long SpuWrite0 (unsigned long size);
|
||||
extern unsigned long SpuRead (unsigned char *addr, unsigned long size);
|
||||
extern long SpuSetTransferMode (long mode);
|
||||
#define SpuSetTransMode(mode) SpuSetTransferMode((mode))
|
||||
extern long SpuGetTransferMode (void);
|
||||
#define SpuGetTransMode() SpuGetTransferMode()
|
||||
extern unsigned long SpuSetTransferStartAddr (unsigned long addr);
|
||||
#define SpuSetTransStartAddr(addr) SpuSetTransferStartAddr((addr))
|
||||
extern unsigned long SpuGetTransferStartAddr (void);
|
||||
#define SpuGetTransStartAddr() SpuGetTransferStartAddr()
|
||||
extern unsigned long SpuWritePartly (unsigned char *addr, unsigned long size);
|
||||
|
||||
extern long SpuIsTransferCompleted (long flag);
|
||||
extern SpuTransferCallbackProc SpuSetTransferCallback (SpuTransferCallbackProc func);
|
||||
extern long SpuReadDecodedData (SpuDecodedData *d_data, long flag);
|
||||
#define SpuReadDecodeData(d_data,flag) SpuReadDecodedData((d_data), (flag))
|
||||
|
||||
extern long SpuSetIRQ (long on_off);
|
||||
extern long SpuGetIRQ (void);
|
||||
extern unsigned long SpuSetIRQAddr (unsigned long);
|
||||
extern unsigned long SpuGetIRQAddr (void);
|
||||
extern SpuIRQCallbackProc SpuSetIRQCallback (SpuIRQCallbackProc);
|
||||
|
||||
extern void SpuSetVoiceAttr (SpuVoiceAttr *arg);
|
||||
extern void SpuGetVoiceAttr (SpuVoiceAttr *arg);
|
||||
extern void SpuSetKey (long on_off, unsigned long voice_bit);
|
||||
extern void SpuSetKeyOnWithAttr (SpuVoiceAttr *attr);
|
||||
extern long SpuGetKeyStatus (unsigned long voice_bit);
|
||||
extern void SpuGetAllKeysStatus (char *status);
|
||||
extern unsigned long SpuFlush (unsigned long ev);
|
||||
|
||||
extern unsigned long SpuSetPitchLFOVoice (long on_off, unsigned long voice_bit);
|
||||
extern unsigned long SpuGetPitchLFOVoice (void);
|
||||
|
||||
extern void SpuSetCommonAttr (SpuCommonAttr *attr);
|
||||
extern void SpuGetCommonAttr (SpuCommonAttr *attr);
|
||||
|
||||
extern long SpuInitMalloc (long num, char *top);
|
||||
extern long SpuMalloc (long size);
|
||||
extern long SpuMallocWithStartAddr (unsigned long addr, long size);
|
||||
extern void SpuFree (unsigned long addr);
|
||||
|
||||
extern long SpuRGetAllKeysStatus (long min_, long max_, char *status);
|
||||
extern long SpuRSetVoiceAttr (long min_, long max_, SpuVoiceAttr *arg);
|
||||
|
||||
extern void SpuNSetVoiceAttr (int vNum, SpuVoiceAttr *arg);
|
||||
extern void SpuNGetVoiceAttr (int vNum, SpuVoiceAttr *arg);
|
||||
|
||||
extern void SpuLSetVoiceAttr (int num, SpuLVoiceAttr *argList);
|
||||
|
||||
extern void SpuSetVoiceVolume (int vNum, short volL, short volR);
|
||||
extern void SpuSetVoiceVolumeAttr (int vNum, short volL, short volR,
|
||||
short volModeL, short volModeR);
|
||||
extern void SpuSetVoicePitch (int vNum, unsigned short pitch);
|
||||
extern void SpuSetVoiceNote (int vNum, unsigned short note);
|
||||
extern void SpuSetVoiceSampleNote (int vNum, unsigned short sampleNote);
|
||||
extern void SpuSetVoiceStartAddr (int vNum, unsigned long startAddr);
|
||||
extern void SpuSetVoiceLoopStartAddr (int vNum, unsigned long lsa);
|
||||
extern void SpuSetVoiceAR (int vNum, unsigned short AR);
|
||||
extern void SpuSetVoiceDR (int vNum, unsigned short DR);
|
||||
extern void SpuSetVoiceSR (int vNum, unsigned short SR);
|
||||
extern void SpuSetVoiceRR (int vNum, unsigned short RR);
|
||||
extern void SpuSetVoiceSL (int vNum, unsigned short SL);
|
||||
extern void SpuSetVoiceARAttr (int vNum, unsigned short AR, long ARmode);
|
||||
extern void SpuSetVoiceSRAttr (int vNum, unsigned short SR, long SRmode);
|
||||
extern void SpuSetVoiceRRAttr (int vNum, unsigned short RR, long RRmode);
|
||||
extern void SpuSetVoiceADSR (int vNum, unsigned short AR, unsigned short DR,
|
||||
unsigned short SR, unsigned short RR,
|
||||
unsigned short SL);
|
||||
extern void SpuSetVoiceADSRAttr (int vNum,
|
||||
unsigned short AR, unsigned short DR,
|
||||
unsigned short SR, unsigned short RR,
|
||||
unsigned short SL,
|
||||
long ARmode, long SRmode, long RRmode);
|
||||
|
||||
extern void SpuGetVoiceVolume (int vNum, short *volL, short *volR);
|
||||
extern void SpuGetVoiceVolumeAttr (int vNum, short *volL, short *volR,
|
||||
short *volModeL, short *volModeR);
|
||||
extern void SpuGetVoiceVolumeX (int vNum, short *volXL, short *volXR);
|
||||
extern void SpuGetVoicePitch (int vNum, unsigned short *pitch);
|
||||
extern void SpuGetVoiceNote (int vNum, unsigned short *note);
|
||||
extern void SpuGetVoiceSampleNote (int vNum, unsigned short *sampleNote);
|
||||
extern void SpuGetVoiceEnvelope (int vNum, short *envx);
|
||||
extern void SpuGetVoiceStartAddr (int vNum, unsigned long *startAddr);
|
||||
extern void SpuGetVoiceLoopStartAddr (int vNum, unsigned long *loopStartAddr);
|
||||
extern void SpuGetVoiceAR (int vNum, unsigned short *AR);
|
||||
extern void SpuGetVoiceDR (int vNum, unsigned short *DR);
|
||||
extern void SpuGetVoiceSR (int vNum, unsigned short *SR);
|
||||
extern void SpuGetVoiceRR (int vNum, unsigned short *RR);
|
||||
extern void SpuGetVoiceSL (int vNum, unsigned short *SL);
|
||||
extern void SpuGetVoiceARAttr (int vNum, unsigned short *AR, long *ARmode);
|
||||
extern void SpuGetVoiceSRAttr (int vNum, unsigned short *SR, long *SRmode);
|
||||
extern void SpuGetVoiceRRAttr (int vNum, unsigned short *RR, long *RRmode);
|
||||
extern void SpuGetVoiceADSR (int vNum,
|
||||
unsigned short *AR, unsigned short *DR,
|
||||
unsigned short *SR, unsigned short *RR,
|
||||
unsigned short *SL);
|
||||
extern void SpuGetVoiceADSRAttr (int vNum,
|
||||
unsigned short *AR, unsigned short *DR,
|
||||
unsigned short *SR, unsigned short *RR,
|
||||
unsigned short *SL,
|
||||
long *ARmode, long *SRmode, long *RRmode);
|
||||
extern void SpuGetVoiceEnvelopeAttr (int vNum, long *keyStat, short *envx );
|
||||
|
||||
extern void SpuSetCommonMasterVolume (short mvol_left, short mvol_right);
|
||||
extern void SpuSetCommonMasterVolumeAttr (short mvol_left, short mvol_right,
|
||||
short mvolmode_left,
|
||||
short mvolmode_right);
|
||||
extern void SpuSetCommonCDMix (long cd_mix);
|
||||
extern void SpuSetCommonCDVolume (short cd_left, short cd_right);
|
||||
extern void SpuSetCommonCDReverb (long cd_reverb);
|
||||
|
||||
extern void SpuGetCommonMasterVolume (short *mvol_left, short *mvol_right);
|
||||
extern void SpuGetCommonMasterVolumeX (short *mvolx_left, short *mvolx_right);
|
||||
extern void SpuGetCommonMasterVolumeAttr (short *mvol_left, short *mvol_right,
|
||||
short *mvolmode_left,
|
||||
short *mvolmode_right);
|
||||
extern void SpuGetCommonCDMix (long *cd_mix);
|
||||
extern void SpuGetCommonCDVolume (short *cd_left, short *cd_right);
|
||||
extern void SpuGetCommonCDReverb (long *cd_reverb);
|
||||
|
||||
extern long SpuSetReverbModeType (long mode);
|
||||
extern void SpuSetReverbModeDepth (short depth_left, short depth_right);
|
||||
extern void SpuSetReverbModeDelayTime (long delay);
|
||||
extern void SpuSetReverbModeFeedback (long feedback);
|
||||
extern void SpuGetReverbModeType (long *mode);
|
||||
extern void SpuGetReverbModeDepth (short *depth_left, short *depth_right);
|
||||
extern void SpuGetReverbModeDelayTime (long *delay);
|
||||
extern void SpuGetReverbModeFeedback (long *feedback);
|
||||
extern void SpuSetESA( long revAddr );
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus) || defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
||||
#define SPU_ST_NOT_AVAILABLE 0
|
||||
#define SPU_ST_ACCEPT 1
|
||||
|
||||
#define SPU_ST_ERROR (-1)
|
||||
#define SPU_ST_INVALID_ARGUMENT (-2)
|
||||
#define SPU_ST_WRONG_STATUS (-3)
|
||||
|
||||
#define SPU_ST_STOP 2
|
||||
#define SPU_ST_IDLE 3
|
||||
#define SPU_ST_PREPARE 4
|
||||
#define SPU_ST_START 5
|
||||
#define SPU_ST_PLAY 6
|
||||
#define SPU_ST_TRANSFER 7
|
||||
#define SPU_ST_FINAL 8
|
||||
|
||||
|
||||
/* VAG's header size */
|
||||
#define SPU_ST_VAG_HEADER_SIZE 0x30
|
||||
|
||||
typedef struct {
|
||||
char status; /* stream status */
|
||||
char pad1; /* padding */
|
||||
char pad2; /* padding */
|
||||
char pad3; /* padding */
|
||||
long last_size; /* the size of last transferring
|
||||
(last_size <= (size / 2)) */
|
||||
unsigned long buf_addr; /* The start address of stream buffer */
|
||||
unsigned long data_addr; /* The start address of SPU streaming
|
||||
data in main memory */
|
||||
} SpuStVoiceAttr;
|
||||
|
||||
typedef struct {
|
||||
long size; /* The size of stream buffer */
|
||||
long low_priority; /* transfer priority */
|
||||
SpuStVoiceAttr voice [24];
|
||||
} SpuStEnv;
|
||||
|
||||
#ifndef __SPU_ST_TRANSFERCALLBACK_PROC
|
||||
#define __SPU_ST_TRANSFERCALLBACK_PROC
|
||||
typedef void (*SpuStCallbackProc)(unsigned long, long);
|
||||
#endif /* __SPU_TRANSFERCALLBACK_PROC */
|
||||
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
extern SpuStEnv *SpuStInit (long);
|
||||
extern long SpuStQuit (void);
|
||||
extern long SpuStGetStatus (void);
|
||||
extern unsigned long SpuStGetVoiceStatus (void);
|
||||
extern long SpuStTransfer (long flag, unsigned long voice_bit);
|
||||
extern SpuStCallbackProc SpuStSetPreparationFinishedCallback (SpuStCallbackProc func);
|
||||
extern SpuStCallbackProc SpuStSetTransferFinishedCallback (SpuStCallbackProc func);
|
||||
extern SpuStCallbackProc SpuStSetStreamFinishedCallback (SpuStCallbackProc func);
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus) || defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* End on File
|
||||
* ---------------------------------------------------------------- */
|
||||
#endif /* _LIBSPU_H_ */
|
||||
/* DON'T ADD STUFF AFTER THIS */
|
14
src_rebuild/EMULATOR/PLATFORM/Android.cmake
Normal file
14
src_rebuild/EMULATOR/PLATFORM/Android.cmake
Normal file
@ -0,0 +1,14 @@
|
||||
if(ANDROID)
|
||||
|
||||
Message("Compiling for Android!")
|
||||
|
||||
include_directories(${ROOT_DIR}/EXTERNAL/SDL/include)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=format-security -Wno-narrowing -Wno-nonportable-include-path")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-error=format-security -Wno-narrowing -Wno-nonportable-include-path")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wno-error=format-security -Wno-narrowing -Wno-nonportable-include-path")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=format-security -Wno-narrowing -Wno-nonportable-include-path")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-error=format-security -Wno-narrowing -Wno-nonportable-include-path")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-error=format-security -Wno-narrowing -Wno-nonportable-include-path")
|
||||
|
||||
endif()
|
16
src_rebuild/EMULATOR/PLATFORM/Emscripten.cmake
Normal file
16
src_rebuild/EMULATOR/PLATFORM/Emscripten.cmake
Normal file
@ -0,0 +1,16 @@
|
||||
if(EMSCRIPTEN)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
include_directories(${OPENGL_INCLUDE_DIR})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_SDL=2 --emrun -s ASSERTIONS=1 --std=c++11 -s USE_WEBGL2=1 -s FULL_ES3=1 -s WASM=1 -s ALLOW_MEMORY_GROWTH=1")
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=format-security -Wno-narrowing -Wno-nonportable-include-path")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-error=format-security -Wno-narrowing -Wno-nonportable-include-path")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wno-error=format-security -Wno-narrowing -Wno-nonportable-include-path")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=format-security -Wno-narrowing -Wno-nonportable-include-path")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-error=format-security -Wno-narrowing -Wno-nonportable-include-path")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-error=format-security -Wno-narrowing -Wno-nonportable-include-path")
|
||||
|
||||
endif()
|
23
src_rebuild/EMULATOR/PLATFORM/Linux.cmake
Normal file
23
src_rebuild/EMULATOR/PLATFORM/Linux.cmake
Normal file
@ -0,0 +1,23 @@
|
||||
if(LINUX)
|
||||
|
||||
#Find libs
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
#We want to link GLEW statically
|
||||
set(GLEW_USE_STATIC_LIBS ON)
|
||||
find_package(GLEW REQUIRED)
|
||||
|
||||
#Setup project include directories
|
||||
include_directories(${GLEW_INCLUDE_DIR})
|
||||
include_directories(${SDL2_INCLUDE_DIR})
|
||||
|
||||
set(PSX_LIB libPSX.a)
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-narrowing")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-narrowing")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wno-narrowing")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-narrowing")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-narrowing")
|
||||
|
||||
endif()
|
26
src_rebuild/EMULATOR/PLATFORM/Mingw.cmake
Normal file
26
src_rebuild/EMULATOR/PLATFORM/Mingw.cmake
Normal file
@ -0,0 +1,26 @@
|
||||
if(MINGW)
|
||||
|
||||
Message("Compiling for Windows!")
|
||||
|
||||
#Find libs
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(OpenGL REQUIRED)
|
||||
#We want to link GLEW statically
|
||||
set(GLEW_USE_STATIC_LIBS ON)
|
||||
find_package(GLEW REQUIRED)
|
||||
|
||||
#We want to link GLEW statically
|
||||
set(GLEW_USE_STATIC_LIBS ON)
|
||||
|
||||
#Setup project include directories
|
||||
include_directories(${GLEW_INCLUDE_DIR})
|
||||
include_directories(${SDL2_INCLUDE_DIR})
|
||||
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-narrowing -std=c++11")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-narrowing -std=c++11")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -Wno-narrowing -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-narrowing -std=c++11")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Wno-narrowing -std=c++11")
|
||||
|
||||
endif()
|
32
src_rebuild/EMULATOR/PLATFORM/Windows.cmake
Normal file
32
src_rebuild/EMULATOR/PLATFORM/Windows.cmake
Normal file
@ -0,0 +1,32 @@
|
||||
if(MSVC)
|
||||
|
||||
Message("Compiling for Windows!")
|
||||
|
||||
#SET(USE_VULKAN TRUE)
|
||||
#SET(USE_D3D9 TRUE)
|
||||
|
||||
#
|
||||
list(APPEND CMAKE_PREFIX_PATH ${EXTERN_LIB_PATH}/glew-2.1.0)
|
||||
list(APPEND CMAKE_LIBRARY_PATH ${EXTERN_LIB_PATH}/glew-2.1.0/lib/Release/Win32)
|
||||
|
||||
#Find libs
|
||||
find_package(SDL2 REQUIRED)
|
||||
if(USE_VULKAN)
|
||||
find_package(Vulkan REQUIRED)
|
||||
include_directories(${Vulkan_INCLUDE_DIR})
|
||||
elseif(USE_D3D9)
|
||||
find_package(D3D9 REQUIRED)
|
||||
include_directories(${DIRECTX_INCLUDE_DIRS})
|
||||
else()
|
||||
find_package(OpenGL REQUIRED)
|
||||
#We want to link GLEW statically
|
||||
set(GLEW_USE_STATIC_LIBS ON)
|
||||
find_package(GLEW REQUIRED)
|
||||
|
||||
#Setup project include directories
|
||||
include_directories(${GLEW_INCLUDE_DIR})
|
||||
endif()
|
||||
|
||||
include_directories(${SDL2_INCLUDE_DIR})
|
||||
|
||||
endif()
|
235
src_rebuild/EMULATOR/R3000.H
Normal file
235
src_rebuild/EMULATOR/R3000.H
Normal file
@ -0,0 +1,235 @@
|
||||
#ifndef R3000_H
|
||||
#define R3000_H
|
||||
|
||||
#define K0BASE 0x80000000
|
||||
#define K0SIZE 0x20000000
|
||||
#define K1BASE 0xA0000000
|
||||
#define K1SIZE 0x20000000
|
||||
#define K2BASE 0xC0000000
|
||||
#define K2SIZE 0x20000000
|
||||
|
||||
|
||||
|
||||
#define UT_VEC K0BASE /* utlbmiss vector */
|
||||
#define E_VEC (K0BASE+0x80) /* exception vector */
|
||||
#define R_VEC (K1BASE+0x1fc00000) /* reset vector */
|
||||
|
||||
/*
|
||||
* Address conversion macros
|
||||
*/
|
||||
#define K0_TO_K1(x) ((unsigned)(x)|0xA0000000) /* kseg0 to kseg1 */
|
||||
#define K1_TO_K0(x) ((unsigned)(x)&0x9FFFFFFF) /* kseg1 to kseg0 */
|
||||
#define K0_TO_PHYS(x) ((unsigned)(x)&0x1FFFFFFF) /* kseg0 to physical */
|
||||
#define K1_TO_PHYS(x) ((unsigned)(x)&0x1FFFFFFF) /* kseg1 to physical */
|
||||
#define PHYS_TO_K0(x) ((unsigned)(x)|0x80000000) /* physical to kseg0 */
|
||||
#define PHYS_TO_K1(x) ((unsigned)(x)|0xA0000000) /* physical to kseg1 */
|
||||
|
||||
/*
|
||||
* Address predicates
|
||||
*/
|
||||
#define IS_KSEG0(x) ((unsigned)(x) >= K0BASE && (unsigned)(x) < K1BASE)
|
||||
#define IS_KSEG1(x) ((unsigned)(x) >= K1BASE && (unsigned)(x) < K2BASE)
|
||||
#define IS_KSEG2(x) ((unsigned)(x) >= K2BASE && (unsigned)(x) < KPTEBASE)
|
||||
#define IS_KPTESEG(x) ((unsigned)(x) >= KPTEBASE)
|
||||
#define IS_KUSEG(x) ((unsigned)(x) < K0BASE)
|
||||
|
||||
/*
|
||||
* Cache size constants
|
||||
*/
|
||||
#define MINCACHE +(4*1024) /* leading plus for mas's benefit */
|
||||
#define MAXCACHE +(64*1024) /* leading plus for mas's benefit */
|
||||
|
||||
|
||||
/*
|
||||
* Status register
|
||||
*/
|
||||
#define SR_CUMASK 0xf0000000 /* coproc usable bits */
|
||||
|
||||
#define SR_CU3 0x80000000 /* Coprocessor 3 usable */
|
||||
#define SR_CU2 0x40000000 /* Coprocessor 2 usable */
|
||||
#define SR_CU1 0x20000000 /* Coprocessor 1 usable */
|
||||
#define SR_CU0 0x10000000 /* Coprocessor 0 usable */
|
||||
|
||||
#define SR_BEV 0x00400000 /* use boot exception vectors */
|
||||
|
||||
/* Cache control bits */
|
||||
#define SR_TS 0x00200000 /* TLB shutdown */
|
||||
#define SR_PE 0x00100000 /* cache parity error */
|
||||
#define SR_CM 0x00080000 /* cache miss */
|
||||
#define SR_PZ 0x00040000 /* cache parity zero */
|
||||
#define SR_SWC 0x00020000 /* swap cache */
|
||||
#define SR_ISC 0x00010000 /* Isolate data cache */
|
||||
|
||||
#define SR_MM_MODE 0x00010000 /* lwl/swl/etc become scache/etc */
|
||||
#define lcache lwl
|
||||
#define scache swl
|
||||
#define flush lwr $0,
|
||||
#define inval swr $0,
|
||||
|
||||
/*
|
||||
* Interrupt enable bits
|
||||
* (NOTE: bits set to 1 enable the corresponding level interrupt)
|
||||
*/
|
||||
#define SR_IMASK 0x0000ff00 /* Interrupt mask */
|
||||
#define SR_IMASK8 0x00000000 /* mask level 8 */
|
||||
#define SR_IMASK7 0x00008000 /* mask level 7 */
|
||||
#define SR_IMASK6 0x0000c000 /* mask level 6 */
|
||||
#define SR_IMASK5 0x0000e000 /* mask level 5 */
|
||||
#define SR_IMASK4 0x0000f000 /* mask level 4 */
|
||||
#define SR_IMASK3 0x0000f800 /* mask level 3 */
|
||||
#define SR_IMASK2 0x0000fc00 /* mask level 2 */
|
||||
#define SR_IMASK1 0x0000fe00 /* mask level 1 */
|
||||
#define SR_IMASK0 0x0000ff00 /* mask level 0 */
|
||||
|
||||
#define SR_IBIT8 0x00008000 /* bit level 8 */
|
||||
#define SR_IBIT7 0x00004000 /* bit level 7 */
|
||||
#define SR_IBIT6 0x00002000 /* bit level 6 */
|
||||
#define SR_IBIT5 0x00001000 /* bit level 5 */
|
||||
#define SR_IBIT4 0x00000800 /* bit level 4 */
|
||||
#define SR_IBIT3 0x00000400 /* bit level 3 */
|
||||
#define SR_IBIT2 0x00000200 /* bit level 2 */
|
||||
#define SR_IBIT1 0x00000100 /* bit level 1 */
|
||||
|
||||
#define SR_KUO 0x00000020 /* old kernel/user, 0 => k, 1 => u */
|
||||
#define SR_IEO 0x00000010 /* old interrupt enable, 1 => enable */
|
||||
#define SR_KUP 0x00000008 /* prev kernel/user, 0 => k, 1 => u */
|
||||
#define SR_IEP 0x00000004 /* prev interrupt enable, 1 => enable */
|
||||
#define SR_KUC 0x00000002 /* cur kernel/user, 0 => k, 1 => u */
|
||||
#define SR_IEC 0x00000001 /* cur interrupt enable, 1 => enable */
|
||||
|
||||
#define SR_IMASKSHIFT 8
|
||||
|
||||
#define SR_FMT "\20\40BD\26TS\25PE\24CM\23PZ\22SwC\21IsC\20IM7\17IM6\16IM5\15IM4\14IM3\13IM2\12IM1\11IM0\6KUo\5IEo\4KUp\3IEp\2KUc\1IEc"
|
||||
|
||||
/*
|
||||
* Cause Register
|
||||
*/
|
||||
#define CAUSE_BD 0x80000000 /* Branch delay slot */
|
||||
#define CAUSE_CEMASK 0x30000000 /* coprocessor error */
|
||||
#define CAUSE_CESHIFT 28
|
||||
|
||||
/* Interrupt pending bits */
|
||||
#define CAUSE_IP8 0x00008000 /* External level 8 pending */
|
||||
#define CAUSE_IP7 0x00004000 /* External level 7 pending */
|
||||
#define CAUSE_IP6 0x00002000 /* External level 6 pending */
|
||||
#define CAUSE_IP5 0x00001000 /* External level 5 pending */
|
||||
#define CAUSE_IP4 0x00000800 /* External level 4 pending */
|
||||
#define CAUSE_IP3 0x00000400 /* External level 3 pending */
|
||||
#define CAUSE_SW2 0x00000200 /* Software level 2 pending */
|
||||
#define CAUSE_SW1 0x00000100 /* Software level 1 pending */
|
||||
|
||||
#define CAUSE_IPMASK 0x0000FF00 /* Pending interrupt mask */
|
||||
#define CAUSE_IPSHIFT 8
|
||||
|
||||
#define CAUSE_EXCMASK 0x0000003C /* Cause code bits */
|
||||
#define CAUSE_EXCSHIFT 2
|
||||
|
||||
#define CAUSE_FMT "\20\40BD\36CE1\35CE0\20IP8\17IP7\16IP6\15IP5\14IP4\13IP3\12SW2\11SW1\1INT"
|
||||
|
||||
/* Cause register exception codes */
|
||||
|
||||
#define EXC_CODE(x) ((x)<<2)
|
||||
|
||||
/* Hardware exception codes */
|
||||
#define EXC_INT EXC_CODE(0) /* interrupt */
|
||||
#define EXC_MOD EXC_CODE(1) /* TLB mod */
|
||||
#define EXC_RMISS EXC_CODE(2) /* Read TLB Miss */
|
||||
#define EXC_WMISS EXC_CODE(3) /* Write TLB Miss */
|
||||
#define EXC_RADE EXC_CODE(4) /* Read Address Error */
|
||||
#define EXC_WADE EXC_CODE(5) /* Write Address Error */
|
||||
#define EXC_IBE EXC_CODE(6) /* Instruction Bus Error */
|
||||
#define EXC_DBE EXC_CODE(7) /* Data Bus Error */
|
||||
#define EXC_SYSCALL EXC_CODE(8) /* SYSCALL */
|
||||
#define EXC_BREAK EXC_CODE(9) /* BREAKpoint */
|
||||
#define EXC_II EXC_CODE(10) /* Illegal Instruction */
|
||||
#define EXC_CPU EXC_CODE(11) /* CoProcessor Unusable */
|
||||
#define EXC_OV EXC_CODE(12) /* OVerflow */
|
||||
|
||||
/* software exception codes */
|
||||
#define SEXC_SEGV EXC_CODE(16) /* Software detected seg viol */
|
||||
#define SEXC_RESCHED EXC_CODE(17) /* resched request */
|
||||
#define SEXC_PAGEIN EXC_CODE(18) /* page-in request */
|
||||
#define SEXC_CPU EXC_CODE(19) /* coprocessor unusable */
|
||||
|
||||
|
||||
/*
|
||||
* Coprocessor 0 registers
|
||||
*/
|
||||
#define C0_INX $0 /* tlb index */
|
||||
#define C0_RAND $1 /* tlb random */
|
||||
#define C0_TLBLO $2 /* tlb entry low */
|
||||
|
||||
#define C0_CTXT $4 /* tlb context */
|
||||
|
||||
#define C0_PIDMASK $6 /* Mips2 */
|
||||
|
||||
#define C0_BADVADDR $8 /* bad virtual address */
|
||||
|
||||
#define C0_TLBHI $10 /* tlb entry hi */
|
||||
#define C0_PID $10 /* Mips2 */
|
||||
|
||||
#define C0_SR $12 /* status register */
|
||||
#define C0_CAUSE $13 /* exception cause */
|
||||
#define C0_EPC $14 /* exception pc */
|
||||
#define C0_PRID $15 /* revision identifier */
|
||||
#define C0_ERREG $16 /* Mips2 */
|
||||
|
||||
/*
|
||||
* Coprocessor 0 operations
|
||||
*/
|
||||
#define C0_READI 0x1 /* read ITLB entry addressed by C0_INDEX */
|
||||
#define C0_WRITEI 0x2 /* write ITLB entry addressed by C0_INDEX */
|
||||
#define C0_WRITER 0x6 /* write ITLB entry addressed by C0_RAND */
|
||||
#define C0_PROBE 0x8 /* probe for ITLB entry addressed by TLBHI */
|
||||
#define C0_RFE 0x10 /* restore for exception */
|
||||
|
||||
/*
|
||||
* Flags for the nofault handler. 0 means no fault is expected.
|
||||
*/
|
||||
#define NF_BADADDR 1 /* badaddr, wbadaddr */
|
||||
#define NF_COPYIO 2 /* copyin, copyout */
|
||||
#define NF_ADDUPC 3 /* addupc */
|
||||
#define NF_FSUMEM 4 /* fubyte, subyte, fuword, suword */
|
||||
#define NF_USERACC 5 /* useracc */
|
||||
#define NF_SOFTFP 6 /* softfp */
|
||||
#define NF_REVID 7 /* revision ids */
|
||||
#define NF_NENTRIES 8
|
||||
|
||||
/*
|
||||
* TLB size constants
|
||||
*/
|
||||
#define TLBWIREDBASE 0 /* WAG for now */
|
||||
#define NWIREDENTRIES 8 /* WAG for now */
|
||||
#define TLBRANDOMBASE NWIREDENTRIES
|
||||
#define NRANDOMENTRIES (NTLBENTRIES-NWIREDENTRIES)
|
||||
#define NTLBENTRIES 64 /* WAG for now */
|
||||
|
||||
#define TLBRAND_RANDMASK 0x00003f00
|
||||
#define TLBRAND_RANDSHIFT 8
|
||||
|
||||
|
||||
/*
|
||||
* Chip interrupt vector
|
||||
*/
|
||||
#define NC0VECS 8
|
||||
#ifndef LOCORE
|
||||
#ifdef KERNEL
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
extern int (*c0vec_tbl[])();
|
||||
#if defined(_LANGUAGE_C_PLUS_PLUS)||defined(__cplusplus)||defined(c_plusplus)
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif /* !LOCORE */
|
||||
|
||||
#define BRK_KERNEL 0xf1
|
||||
#define EXCEPT_NORM 1
|
||||
#define EXCEPT_UTLB 2
|
||||
#define EXCEPT_BRKPT 3
|
||||
#define EXCEPT_DB 4
|
||||
#define EXCEPT_GDB 4
|
||||
#define EXCEPT_INT 9
|
||||
#define EXCEPT_ELSE 0xff
|
||||
#endif /* _R3000_H */
|
6
src_rebuild/EMULATOR/STRINGS.H
Normal file
6
src_rebuild/EMULATOR/STRINGS.H
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef STRINGS_H
|
||||
#define STRINGS_H
|
||||
|
||||
#include <string.h>//temp
|
||||
|
||||
#endif
|
79
src_rebuild/EMULATOR/TYPES.H
Normal file
79
src_rebuild/EMULATOR/TYPES.H
Normal file
@ -0,0 +1,79 @@
|
||||
#ifndef _SYS_TYPES_H
|
||||
#define _SYS_TYPES_H
|
||||
|
||||
#if !defined(__APPLE__)
|
||||
/* major part of a device */
|
||||
#define major(x) ((int)(((unsigned)(x)>>8)&0377))
|
||||
|
||||
/* minor part of a device */
|
||||
#define minor(x) ((int)((x)&0377))
|
||||
|
||||
/* make a device number */
|
||||
#define makedev(x,y) ((dev_t)(((x)<<8) | (y)))
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _UCHAR_T
|
||||
#define _UCHAR_T
|
||||
typedef unsigned char u_char;
|
||||
#endif
|
||||
#ifndef _USHORT_T
|
||||
#define _USHORT_T
|
||||
typedef unsigned short u_short;
|
||||
#endif
|
||||
#ifndef _UINT_T
|
||||
#define _UINT_T
|
||||
typedef unsigned int u_int;
|
||||
#endif
|
||||
#ifndef _ULONG_T
|
||||
#define _ULONG_T
|
||||
typedef unsigned long u_long;
|
||||
#endif
|
||||
#ifndef _SYSIII_USHORT
|
||||
#define _SYSIII_USHORT
|
||||
typedef unsigned short ushort; /* sys III compat */
|
||||
#endif
|
||||
#ifndef __psx__
|
||||
#ifndef _SYSV_UINT
|
||||
#define _SYSV_UINT
|
||||
typedef unsigned int uint; /* sys V compat */
|
||||
#endif
|
||||
#ifndef _SYSV_ULONG
|
||||
#define _SYSV_ULONG
|
||||
typedef unsigned long ulong; /* sys V compat */
|
||||
#endif
|
||||
#endif /* ! __psx__ */
|
||||
|
||||
#if !__APPLE__
|
||||
typedef struct _physadr { int r[1]; } *physadr;
|
||||
typedef struct label_t {
|
||||
int val[12];
|
||||
} label_t;
|
||||
|
||||
#if !defined(__ANDROID__)
|
||||
typedef struct _quad { long val[2]; } quad;
|
||||
typedef long daddr_t;
|
||||
typedef char * caddr_t;
|
||||
typedef long * qaddr_t;
|
||||
//typedef u_long ino_t;
|
||||
typedef long swblk_t;
|
||||
#endif
|
||||
|
||||
#if !defined(__EMSCRIPTEN__)
|
||||
#ifndef _SIZE_T
|
||||
#define _SIZE_T
|
||||
typedef unsigned int size_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
//typedef long time_t;
|
||||
//typedef short dev_t;
|
||||
//typedef long off_t;
|
||||
//typedef u_short uid_t;
|
||||
//typedef u_short gid_t;
|
||||
|
||||
#endif
|
||||
|
||||
#define NBBY 8
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user