#include <3ds.h>
+#include <string.h>
#include "patcher.h"
#include "fsldr.h"
#include "internal.h"
#endif
#include "../../../source/config.h"
#include "../../../source/patch_format.h"
-
+/*
int
memcmp(const void *buf1, const void *buf2, u32 size)
{
return 0;
}
+*/
// Quick Search algorithm, adapted from
// http://igm.univ-mlv.fr/~lecroq/string/node19.html#SECTION00190
#ifndef __MEMORY_H
#define __MEMORY_H
-int memcmp(const void *buf1, const void *buf2, u32 size);
+//int memcmp(const void *buf1, const void *buf2, u32 size);
u8 *memfind(u8 *startPos, u32 size, const void *pattern, u32 patternSize);
u32 patchMemory(u8 *start, u32 size, const void *pattern, u32 patSize, int offset, const void *replace, u32 repSize, u32 count);
size_t strnlen(const char *string, size_t maxlen);
#include <stdint.h>
#include <stddef.h>
-#ifndef LOADER
#include "std/unused.h"
-#include "std/memory.h"
-#include "firm/firm.h"
-#include "config.h"
-#include "common.h"
+
+#ifndef LOADER
+ #include "std/memory.h"
+ #include "firm/firm.h"
+ #include "config.h"
+ #include "common.h"
+ #include "firm/fcram.h"
+#else
+ #include <string.h>
#endif
#define OP_NOP 0x00
int is_n3ds = 1; // TODO - We don't really need to care, but it should still work from loader
#endif
+#define STACK_SIZE 4096
+#ifdef LOADER
+ static uint8_t stack_glob[STACK_SIZE];
+#else
+ static uint8_t *stack_glob = NULL;
+#endif
+
int
-exec_bytecode(uint8_t *bytecode, uint16_t ver, uint32_t len, int debug)
+exec_bytecode(uint8_t *bytecode, uint32_t len, uint8_t* stack, uint32_t stack_size, uint16_t ver, int debug)
{
if (!init_bytecode) {
#ifndef LOADER
init_bytecode = 1;
}
+ memset(stack, 0, stack_size); // Clear stack.
+
+ _UNUSED size_t top = stack_size - 1;
+
#ifdef LOADER
size_t set_mode = 18;
#else
}
found = gt = lt = eq = 0;
+ memset(stack, 0, stack_size); // Clear stack.
+ top = stack_size - 1;
+
bytecode = code + 1;
#ifndef LOADER
set_mode = 3;
debug = 1;
}
- return exec_bytecode(patch_mem, ver, patch_len, debug);
+#ifndef LOADER
+ if (stack_glob == NULL) {
+ stack_glob = static_allocate(STACK_SIZE);
+ }
+#endif
+
+ return exec_bytecode(patch_mem, patch_len, stack_glob, STACK_SIZE, ver, debug);
}
screen_init();
clear_bg();
load_bg_top(PATH_BITS "/top.bin");
- load_bg_bottom(PATH_BITS "/bottom.bin"); // This is basically a menuhax splash (90deg rotated RGB8 pixel data)
+ load_bg_bottom(PATH_BITS "/bottom.bin"); // This is basically a menuhax splash (90deg rotated BGR8 pixel data)
clear_disp(TOP_SCREEN);
clear_disp(BOTTOM_SCREEN);