#include <string.h>
#include <stdint.h>
+#include "plugin_lib.h"
#include "plugin.h"
+#include "../libpcsxcore/psemu_plugin_defs.h"
+#include "../plugins/cdrcimg/cdrcimg.h"
static int dummy_func() {
return 0;
extern void SPUplayCDDAchannel(short *, int);
/* PAD */
-static uint8_t CurByte;
-
-static unsigned char PADstartPoll(int pad) {
- CurByte = 0;
- return 0xFF;
+static long PADreadPort1(PadDataS *pad)
+{
+ pad->controllerType = PSE_PAD_TYPE_STANDARD;
+ pad->buttonStatus = ~keystate;
+ return 0;
}
-static unsigned char PADpoll(unsigned char value) {
- static uint8_t buf[] = {0x41, 0x5A, 0xFF, 0xFF, 0x80, 0x80, 0x80, 0x80};
- if (CurByte >= 4)
- return 0;
- return buf[CurByte++];
+static long PADreadPort2(PadDataS *pad)
+{
+ pad->controllerType = PSE_PAD_TYPE_STANDARD;
+ pad->buttonStatus = ~keystate >> 16;
+ return 0;
}
/* GPU */
DIRECT_SPU(SPUasync),
DIRECT_SPU(SPUplayCDDAchannel),
/* PAD */
- DUMMY_PAD(PADconfigure),
- DUMMY_PAD(PADabout),
DUMMY_PAD(PADinit),
DUMMY_PAD(PADshutdown),
- DUMMY_PAD(PADtest),
DUMMY_PAD(PADopen),
DUMMY_PAD(PADclose),
+ DUMMY_PAD(PADsetSensitive),
+ DIRECT_PAD(PADreadPort1),
+ DIRECT_PAD(PADreadPort2),
+/*
DUMMY_PAD(PADquery),
- DUMMY_PAD(PADreadPort1),
- DUMMY_PAD(PADreadPort2),
+ DUMMY_PAD(PADconfigure),
+ DUMMY_PAD(PADtest),
+ DUMMY_PAD(PADabout),
DUMMY_PAD(PADkeypressed),
- DUMMY_PAD(PADsetSensitive),
- DIRECT_PAD(PADstartPoll),
- DIRECT_PAD(PADpoll),
+ DUMMY_PAD(PADstartPoll),
+ DUMMY_PAD(PADpoll),
+*/
/* GPU */
DIRECT_GPU(GPUupdateLace),
DIRECT_GPU(GPUinit),
{
int i;
+ if (id == PLUGIN_CDRCIMG)
+ return cdrcimg_get_sym(sym);
+
for (i = 0; i < ARRAY_SIZE(plugin_funcs); i++) {
if (id != plugin_funcs[i].id)
continue;
return plugin_funcs[i].func;
}
- fprintf(stderr, "plugin_link: missing symbol %d %s\n", id, sym);
+ //fprintf(stderr, "plugin_link: missing symbol %d %s\n", id, sym);
return NULL;
}
+#ifdef PCNT
+
+/* basic profile stuff */
+#include "pcnt.h"
+
+unsigned int pcounters[PCNT_CNT];
+unsigned int pcounter_starts[PCNT_CNT];
+
+#define pc_hook_func(name, args, pargs, cnt) \
+extern void (*name) args; \
+static void (*o_##name) args; \
+static void w_##name args \
+{ \
+ unsigned int pc_start = pcnt_get(); \
+ o_##name pargs; \
+ pcounters[cnt] += pcnt_get() - pc_start; \
+}
+
+#define pc_hook_func_ret(retn, name, args, pargs, cnt) \
+extern retn (*name) args; \
+static retn (*o_##name) args; \
+static retn w_##name args \
+{ \
+ retn ret; \
+ unsigned int pc_start = pcnt_get(); \
+ ret = o_##name pargs; \
+ pcounters[cnt] += pcnt_get() - pc_start; \
+ return ret; \
+}
+
+pc_hook_func (GPU_writeStatus, (uint32_t a0), (a0), PCNT_GPU)
+pc_hook_func (GPU_writeData, (uint32_t a0), (a0), PCNT_GPU)
+pc_hook_func (GPU_writeDataMem, (uint32_t *a0, int a1), (a0, a1), PCNT_GPU)
+pc_hook_func_ret(uint32_t, GPU_readStatus, (void), (), PCNT_GPU)
+pc_hook_func_ret(uint32_t, GPU_readData, (void), (), PCNT_GPU)
+pc_hook_func (GPU_readDataMem, (uint32_t *a0, int a1), (a0, a1), PCNT_GPU)
+pc_hook_func_ret(long, GPU_dmaChain, (uint32_t *a0, int32_t a1), (a0, a1), PCNT_GPU)
+pc_hook_func (GPU_updateLace, (void), (), PCNT_GPU)
+
+pc_hook_func (SPU_writeRegister, (unsigned long a0, unsigned short a1), (a0, a1), PCNT_SPU)
+pc_hook_func_ret(unsigned short,SPU_readRegister, (unsigned long a0), (a0), PCNT_SPU)
+pc_hook_func (SPU_writeDMA, (unsigned short a0), (a0), PCNT_SPU)
+pc_hook_func_ret(unsigned short,SPU_readDMA, (void), (), PCNT_SPU)
+pc_hook_func (SPU_writeDMAMem, (unsigned short *a0, int a1), (a0, a1), PCNT_SPU)
+pc_hook_func (SPU_readDMAMem, (unsigned short *a0, int a1), (a0, a1), PCNT_SPU)
+pc_hook_func (SPU_playADPCMchannel, (void *a0), (a0), PCNT_SPU)
+pc_hook_func (SPU_async, (unsigned int a0), (a0), PCNT_SPU)
+pc_hook_func (SPU_playCDDAchannel, (short *a0, int a1), (a0, a1), PCNT_SPU)
+
+#define hook_it(name) { \
+ o_##name = name; \
+ name = w_##name; \
+}
+
+void pcnt_hook_plugins(void)
+{
+ /* test it first */
+ pcnt_get();
+
+ hook_it(GPU_writeStatus);
+ hook_it(GPU_writeData);
+ hook_it(GPU_writeDataMem);
+ hook_it(GPU_readStatus);
+ hook_it(GPU_readData);
+ hook_it(GPU_readDataMem);
+ hook_it(GPU_dmaChain);
+ hook_it(GPU_updateLace);
+ hook_it(SPU_writeRegister);
+ hook_it(SPU_readRegister);
+ hook_it(SPU_writeDMA);
+ hook_it(SPU_readDMA);
+ hook_it(SPU_writeDMAMem);
+ hook_it(SPU_readDMAMem);
+ hook_it(SPU_playADPCMchannel);
+ hook_it(SPU_async);
+ hook_it(SPU_playCDDAchannel);
+}
+
+#endif