#endif
#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
#include <stdint.h>
-#include <malloc.h>
#include "3ds_utils.h"
#define MAP_FAILED ((void *)-1)
+void SysPrintf(const char *fmt, ...);
+
+#if 0 // not used
static void* dynarec_cache = NULL;
static void* dynarec_cache_mapping = NULL;
}
svcDuplicateHandle(¤tHandle, 0xFFFF8001);
- svcControlProcessMemory(currentHandle, addr, dynarec_cache,
+ svcControlProcessMemory(currentHandle, (uintptr_t)addr, (uintptr_t)dynarec_cache,
len, MEMOP_MAP, prot);
svcCloseHandle(currentHandle);
dynarec_cache_mapping = addr;
return addr_out;
}
-static inline int mprotect(void *addr, size_t len, int prot)
-{
- if(__ctr_svchax)
- {
- uint32_t currentHandle;
- svcDuplicateHandle(¤tHandle, 0xFFFF8001);
- svcControlProcessMemory(currentHandle, addr, NULL,
- len, MEMOP_PROT, prot);
- svcCloseHandle(currentHandle);
- return 0;
- }
-
- printf("mprotect called without svcControlProcessMemory access !\n");
- return -1;
-}
-
static inline int munmap(void *addr, size_t len)
{
if((addr == dynarec_cache_mapping) && __ctr_svchax)
uint32_t currentHandle;
svcDuplicateHandle(¤tHandle, 0xFFFF8001);
svcControlProcessMemory(currentHandle,
- dynarec_cache, dynarec_cache_mapping,
+ (uintptr_t)dynarec_cache, (uintptr_t)dynarec_cache_mapping,
len, MEMOP_UNMAP, 0b111);
svcCloseHandle(currentHandle);
dynarec_cache_mapping = NULL;
return 0;
}
+#endif
+
+static inline int mprotect(void *addr, size_t len, int prot)
+{
+ if (__ctr_svchax)
+ {
+ uint32_t currentHandle = 0;
+ int r;
+ svcDuplicateHandle(¤tHandle, 0xFFFF8001);
+ r = svcControlProcessMemory(currentHandle, (uintptr_t)addr, 0,
+ len, MEMOP_PROT, prot);
+ svcCloseHandle(currentHandle);
+ if (r < 0) {
+ SysPrintf("svcControlProcessMemory failed for %p %u %x: %d\n",
+ addr, len, prot, r);
+ return -1;
+ }
+ return 0;
+ }
+
+ SysPrintf("mprotect called without svcControlProcessMemory access!\n");
+ return -1;
+}
#ifdef __cplusplus
};
static bool axis_bounds_modifier;
/* PSX max resolution is 640x512, but with enhancement it's 1024x512 */
+#ifdef GPU_NEON
#define VOUT_MAX_WIDTH 1024
+#else
+#define VOUT_MAX_WIDTH 640
+#endif
#define VOUT_MAX_HEIGHT 512
//Dummy functions
}
#endif
+static void log_mem_usage(void)
+{
+#ifdef _3DS
+ extern u32 __heap_size, __linear_heap_size, __stacksize__;
+ extern char __end__; // 3dsx.ld
+ u32 app_memory = *((volatile u32 *)0x1FF80040);
+ s64 mem_used = 0;
+ if (__ctr_svchax)
+ svcGetSystemInfo(&mem_used, 0, 1);
+
+ SysPrintf("mem: %d/%d heap: %d linear: %d stack: %d exe: %d\n", (int)mem_used, app_memory,
+ __heap_size, __linear_heap_size, __stacksize__, (int)&__end__ - 0x100000);
+#endif
+}
+
static void *pl_mmap(unsigned int size)
{
return psxMap(0, size, 0, MAP_TAG_VRAM);
{
size_t i;
unsigned int cd_index = 0;
- bool is_m3u = (strcasestr(info->path, ".m3u") != NULL);
- bool is_exe = (strcasestr(info->path, ".exe") != NULL);
+ bool is_m3u, is_exe;
int ret;
struct retro_input_descriptor desc[] = {
LogErr("info->path required\n");
return false;
}
+ is_m3u = (strcasestr(info->path, ".m3u") != NULL);
+ is_exe = (strcasestr(info->path, ".exe") != NULL);
update_variables(false);
set_retro_memmap();
retro_set_audio_buff_status_cb();
+ log_mem_usage();
if (check_unsatisfied_libcrypt())
show_notification("LibCrypt protected game with missing SBI detected", 3000, 3);
struct retro_rumble_interface rumble;
int ret;
+ log_mem_usage();
+
msg_interface_version = 0;
environ_cb(RETRO_ENVIRONMENT_GET_MESSAGE_INTERFACE_VERSION, &msg_interface_version);
vout_buf = linearMemAlign(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2, 0x80);
#elif defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L) && P_HAVE_POSIX_MEMALIGN
if (posix_memalign(&vout_buf, 16, VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2) != 0)
- vout_buf = (void *) 0;
+ vout_buf = NULL;
else
memset(vout_buf, 0, VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT * 2);
#else
vout_buf = calloc(VOUT_MAX_WIDTH * VOUT_MAX_HEIGHT, 2);
#endif
+ if (vout_buf == NULL)
+ {
+ LogErr("OOM for vout_buf.\n");
+ exit(1);
+ }
vout_buf_ptr = vout_buf;
#define LE16TOH(x) (x)
#endif
-#define BIT(x) (1 << (x))
+#undef BIT
+#define BIT(x) (1u << (x))
#define PSX_GPU_STATUS_DHEIGHT BIT(19)
#define PSX_GPU_STATUS_PAL BIT(20)