Skip to content

Commit

Permalink
Use a different fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RocketRobz committed Oct 14, 2019
1 parent 488aa96 commit 023cd4e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
10 changes: 0 additions & 10 deletions retail/cardengine/arm9/source/card_engine_header.s
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ patches_offset:
.word patches
thumbPatches_offset:
.word thumbPatches
intr_vblank_orig_return:
.word 0x00000000
intr_ipc_orig_return:
.word 0x00000000
moduleParams:
Expand All @@ -39,13 +37,6 @@ irqTable:

card_engine_start:

vblankHandler:
@ Hook the return address, then go back to the original function
stmdb sp!, {lr}
adr lr, code_handler_start_ipc
ldr r0, intr_vblank_orig_return
bx r0

ipcSyncHandler:
@ Hook the return address, then go back to the original function
stmdb sp!, {lr}
Expand Down Expand Up @@ -91,7 +82,6 @@ patches:
.word terminateForPullOutRef
needFlushDCCache:
.word 0x0
.word vblankHandler
.word ipcSyncHandler
thumbPatches:
.word thumb_card_read_arm9
Expand Down
13 changes: 6 additions & 7 deletions retail/cardengine/arm9/source/cardengine.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ static void hookIPC_SYNC(void) {
}
}

static void hookVblank(void) {
u32* vblankHandler = ce9->irqTable;
ce9->intr_vblank_orig_return = *vblankHandler;
*vblankHandler = ce9->patches->vblankHandlerRef;
static void enableIPC_SYNC(void) {
if (IPC_SYNC_hooked && !(REG_IE & IRQ_IPC_SYNC)) {
REG_IE |= IRQ_IPC_SYNC;
}
}

void myIrqHandlerIPC(void) {
Expand Down Expand Up @@ -211,6 +211,7 @@ int cardRead(u32* cacheStruct, u8* dst0, u32 src0, u32 len0) {
cardReadCount++;

initialize();
enableIPC_SYNC();

vu32* cardStruct = (vu32*)(isSdk5(ce9->moduleParams) ? 0x027DFFC0 : ce9->cardStruct0);

Expand Down Expand Up @@ -249,8 +250,6 @@ u32 nandWrite(void* memory,void* flash,u32 len,u32 dma) {


u32 myIrqEnable(u32 irq) {
const char* romTid = getRomTid(ndsHeader);

int oldIME = enterCriticalSection();

#ifdef DEBUG
Expand All @@ -260,7 +259,7 @@ u32 myIrqEnable(u32 irq) {
setDeviceOwner();
initialize();

(strncmp(romTid, "AKW", 3) == 0) ? hookVblank() : hookIPC_SYNC();
hookIPC_SYNC();

u32 irq_before = REG_IE | IRQ_IPC_SYNC;
irq |= IRQ_IPC_SYNC;
Expand Down
2 changes: 0 additions & 2 deletions retail/common/include/cardengine_header_arm9.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ typedef struct cardengineArm9Patches {
u32* cacheFlushRef;
u32* readCachedRef;
u32 needFlushDCCache;
u32* vblankHandlerRef;
u32* ipcSyncHandlerRef;
} __attribute__ ((__packed__)) cardengineArm9Patches;

Expand Down Expand Up @@ -51,7 +50,6 @@ typedef struct cardengineArm9 {
u32 ce9;
cardengineArm9Patches* patches;
cardengineArm9ThumbPatches* thumbPatches;
u32 intr_vblank_orig_return;
u32 intr_ipc_orig_return;
const module_params_t* moduleParams;
u32 fileCluster;
Expand Down

0 comments on commit 023cd4e

Please sign in to comment.