beetle-psx-libretro/mednafen/psx/psx.h

138 lines
4.3 KiB
C
Raw Normal View History

2013-09-08 11:41:01 +00:00
#ifndef __MDFN_PSX_PSX_H
#define __MDFN_PSX_PSX_H
2020-09-16 18:19:03 +00:00
#include <stdint.h>
2013-09-08 11:41:01 +00:00
2020-09-16 18:19:03 +00:00
#include "../masmem.h"
#include "../mednafen-types.h"
#include "../video/surface.h"
2013-09-08 11:41:01 +00:00
2014-06-15 04:40:33 +00:00
// Comment out these 2 defines for extra speeeeed.
#define PSX_DBGPRINT_ENABLE 1
#define PSX_EVENT_SYSTEM_CHECKS 1
// It's highly unlikely the user will want these if they're intentionally compiling without the debugger.
#ifndef WANT_DEBUGGER
2015-07-24 13:59:40 +00:00
#undef PSX_DBGPRINT_ENABLE
#undef PSX_EVENT_SYSTEM_CHECKS
2013-09-08 11:41:01 +00:00
#endif
#define PSX_DBG_ERROR 0 // Emulator-level error.
#define PSX_DBG_WARNING 1 // Warning about game doing questionable things/hitting stuff that might not be emulated correctly.
#define PSX_DBG_BIOS_PRINT 2 // BIOS printf/putchar output.
#define PSX_DBG_SPARSE 3 // Sparse(relatively) information debug messages(CDC commands).
#define PSX_DBG_FLOOD 4 // Heavy informational debug messages(GPU commands; TODO).
2014-06-15 04:40:33 +00:00
#if PSX_DBGPRINT_ENABLE
2016-06-06 22:59:50 +00:00
void PSX_DBG(unsigned level, const char *format, ...);
2014-06-15 04:40:33 +00:00
2015-07-24 13:59:40 +00:00
#define PSX_WARNING(format, ...) { PSX_DBG(PSX_DBG_WARNING, format "\n", ## __VA_ARGS__); }
#define PSX_DBGINFO(format, ...) { }
2014-06-15 04:40:33 +00:00
#else
2015-07-24 13:59:40 +00:00
static void PSX_DBG(unsigned level, const char* format, ...) { }
static void PSX_WARNING(const char* format, ...) { }
static void PSX_DBGINFO(const char* format, ...) { }
2014-06-15 04:40:33 +00:00
#endif
2016-02-02 17:08:43 +00:00
typedef int32_t pscpu_timestamp_t;
bool MDFN_FASTCALL PSX_EventHandler(const int32_t timestamp);
2013-09-08 11:41:01 +00:00
void MDFN_FASTCALL PSX_MemWrite8(int32_t timestamp, uint32_t A, uint32_t V);
void MDFN_FASTCALL PSX_MemWrite16(int32_t timestamp, uint32_t A, uint32_t V);
void MDFN_FASTCALL PSX_MemWrite24(int32_t timestamp, uint32_t A, uint32_t V);
void MDFN_FASTCALL PSX_MemWrite32(int32_t timestamp, uint32_t A, uint32_t V);
2013-09-08 11:41:01 +00:00
uint8_t MDFN_FASTCALL PSX_MemRead8(int32_t &timestamp, uint32_t A);
uint16_t MDFN_FASTCALL PSX_MemRead16(int32_t &timestamp, uint32_t A);
uint32_t MDFN_FASTCALL PSX_MemRead24(int32_t &timestamp, uint32_t A);
uint32_t MDFN_FASTCALL PSX_MemRead32(int32_t &timestamp, uint32_t A);
2013-09-08 11:41:01 +00:00
2015-07-24 13:59:40 +00:00
uint8_t PSX_MemPeek8(uint32_t A);
uint16_t PSX_MemPeek16(uint32_t A);
uint32_t PSX_MemPeek32(uint32_t A);
2013-09-08 11:41:01 +00:00
2015-07-24 13:59:40 +00:00
// Should write to WO-locations if possible
void PSX_MemPoke8(uint32_t A, uint8_t V);
void PSX_MemPoke16(uint32_t A, uint16_t V);
void PSX_MemPoke32(uint32_t A, uint32_t V);
2013-09-08 11:41:01 +00:00
2015-07-24 13:59:40 +00:00
void PSX_RequestMLExit(void);
void ForceEventUpdates(const int32_t timestamp);
2013-09-08 11:41:01 +00:00
2015-07-24 13:59:40 +00:00
enum
{
PSX_EVENT__SYNFIRST = 0,
PSX_EVENT_GPU,
PSX_EVENT_CDC,
//PSX_EVENT_SPU,
PSX_EVENT_TIMER,
PSX_EVENT_DMA,
PSX_EVENT_FIO,
PSX_EVENT__SYNLAST,
2015-07-24 20:35:23 +00:00
PSX_EVENT__COUNT
2015-07-24 13:59:40 +00:00
};
2013-09-08 11:41:01 +00:00
#define PSX_EVENT_MAXTS 0x20000000
void PSX_SetEventNT(const int type, const int32_t next_timestamp);
2015-07-24 13:59:40 +00:00
void PSX_SetDMACycleSteal(unsigned stealage);
2013-09-08 11:41:01 +00:00
// PSX_GPULineHook modified to take surface pitch (in pixels) and upscale factor for software renderer internal upscaling
void PSX_GPULineHook(const int32_t timestamp, const int32_t line_timestamp, bool vsync, uint32_t *pixels, const MDFN_PixelFormat* const format, const unsigned width, const unsigned pix_clock_offset, const unsigned pix_clock, const unsigned pix_clock_divider, const unsigned surf_pitchinpix, const unsigned upscale_factor);
2013-09-08 11:41:01 +00:00
2015-07-24 13:59:40 +00:00
uint32_t PSX_GetRandU32(uint32_t mina, uint32_t maxa);
2013-09-08 11:41:01 +00:00
#include "dis.h"
#include "cpu.h"
#include "irq.h"
#include "gpu.h"
#include "dma.h"
#include "debug.h"
2015-07-24 13:59:40 +00:00
class PS_CDC;
class PS_SPU;
2013-09-08 11:41:01 +00:00
2019-07-14 20:05:54 +00:00
extern PS_CPU *PSX_CPU;
extern PS_CDC *PSX_CDC;
extern PS_SPU *PSX_SPU;
extern MultiAccessSizeMem<512 * 1024, uint32, false> *BIOSROM;
extern MultiAccessSizeMem<2048 * 1024, uint32_t, false> *MainRAM;
extern MultiAccessSizeMem<1024, uint32_t, false> *ScratchRAM;
#ifdef HAVE_LIGHTREC
enum DYNAREC {DYNAREC_DISABLED, DYNAREC_EXECUTE, DYNAREC_EXECUTE_ONE, DYNAREC_RUN_INTERPRETER};
extern enum DYNAREC psx_dynarec;
#endif
2013-09-08 11:41:01 +00:00
#define OVERCLOCK_SHIFT 8
extern int32_t psx_overclock_factor;
static INLINE void overclock_device_to_cpu(int32_t &clock) {
if (psx_overclock_factor) {
int64_t n = clock;
n = (n * psx_overclock_factor) + (1 << (OVERCLOCK_SHIFT)) - 1;
n >>= OVERCLOCK_SHIFT;
clock = n;
}
}
static INLINE void overclock_cpu_to_device(int32_t &clock) {
if (psx_overclock_factor) {
int64_t n = clock;
n = (n << OVERCLOCK_SHIFT) + (psx_overclock_factor - 1);
n /= psx_overclock_factor;
clock = n;
}
}
2018-02-09 10:09:28 +00:00
extern unsigned psx_gpu_overclock_shift;
2013-09-08 11:41:01 +00:00
#endif