# Recompiler hooks for Magician's Quest: Mysterious Times (YNNE, USA).
# Format: <module> <address> replace|before|instead <c_function>
# Addresses were found by instruction pattern (tools/find_sdk.py); the NitroSDK build is the same as FFCC's.

# NitroSDK thread context switches: guest threads run on host fibers (runtime/src/nitro.cpp).
main 020897dc replace ntr_nitro_save_context   # OS_SaveContext
main 02089828 replace ntr_nitro_load_context   # OS_LoadContext
main 02089770 replace ntr_nitro_init_context   # OS_InitContext

# IRQ dispatch: enters OS_IrqHandler_ThreadSwitch explicitly (game/src/ynne_hooks.cpp).
itcm 01ffcd58 replace mq_os_irq_handler        # OS_IrqHandler

# The game's own task system switches stacks (save lr/sp, load pc/sp, bx). Tasks run on host fibers.
main 02003b80 replace ntr_task_swap            # task swap (save current, continue next)
main 02003bb8 replace ntr_task_load            # task continue (current task finished)

# OS_SpinWait: spend the exact number of cycles. The VBlank handler waits with it before testing whether the 3D
# engine is done (GXSTAT busy) to swap the dual-screen 3D; counted short, the engine still shows busy and it never swaps.
main 0208a814 replace ntr_os_spin_wait          # OS_SpinWait

# Widescreen: the game's perspective setup (fovy, aspect, near, far), called with 4:3.
main 020093d0 before mq_perspective_aspect

# Logo skip: the frame setup for 3D on both screens starts with the title.
main 0200275c before mq_on_dual_screen_3d

# Text speed: the text box's draw (box, characters to show) is told to show more of them.
main 020127f8 before mq_text_box_draw
