|
| 1 | +/* |
| 2 | +# _____ ___ ____ ___ ____ |
| 3 | +# ____| | ____| | | |____| |
| 4 | +# | ___| |____ ___| ____| | \ PS2DEV Open Source Project. |
| 5 | +#----------------------------------------------------------------------- |
| 6 | +# Copyright ps2dev - http://www.ps2dev.org |
| 7 | +# Licenced under Academic Free License version 2.0 |
| 8 | +# Review ps2sdk README & LICENSE files for further details. |
| 9 | +*/ |
| 10 | + |
| 11 | +#include "irx_imports.h" |
| 12 | + |
| 13 | +// Based on the module from SDK 3.1.0. |
| 14 | + |
| 15 | +struct poffemu_param_stru |
| 16 | +{ |
| 17 | + int m_cdvdman_intr_efid; |
| 18 | + void (*m_cdvdman_poff_cb)(void *); |
| 19 | + void *m_cdvdman_poffarg; |
| 20 | + int m_sema_id; |
| 21 | +}; |
| 22 | + |
| 23 | +static struct poffemu_param_stru sCdPtbl; |
| 24 | + |
| 25 | +static unsigned int _sceCdPoffEmu(struct poffemu_param_stru *arg) |
| 26 | +{ |
| 27 | + Kprintf("PowerOff Simulation Start\n"); |
| 28 | + iSetEventFlag(arg->m_cdvdman_intr_efid, 4); |
| 29 | + iSetEventFlag(arg->m_cdvdman_intr_efid, 0x10); |
| 30 | + if ( arg->m_cdvdman_poff_cb ) |
| 31 | + arg->m_cdvdman_poff_cb(arg->m_cdvdman_poffarg); |
| 32 | + iSignalSema(arg->m_sema_id); |
| 33 | + return 0; |
| 34 | +} |
| 35 | + |
| 36 | +int _start(int ac, char **av) |
| 37 | +{ |
| 38 | + int unusedval; |
| 39 | + iop_sema_t semaparam; |
| 40 | + // Unofficial: the following variable has been made local stack |
| 41 | + iop_sys_clock_t sCdPoff_time; |
| 42 | + |
| 43 | + (void)ac; |
| 44 | + (void)av; |
| 45 | + |
| 46 | + semaparam.attr = 1; |
| 47 | + semaparam.initial = 0; |
| 48 | + semaparam.max = 1; |
| 49 | + semaparam.option = 0; |
| 50 | + sCdPtbl.m_sema_id = CreateSema(&semaparam); |
| 51 | + sCdPtbl.m_cdvdman_intr_efid = sceCdSC(0xFFFFFFF5, &unusedval); |
| 52 | + sCdPtbl.m_cdvdman_poff_cb = 0; |
| 53 | + if ( (unsigned int)sceCdSC(0xFFFFFFF7, &unusedval) < 0x222 ) |
| 54 | + { |
| 55 | + Kprintf("This cdvdman.irx doesn't support the simulation of PowerOff_Callback of IOP\n"); |
| 56 | + } |
| 57 | + else |
| 58 | + { |
| 59 | + sCdPtbl.m_cdvdman_poffarg = (void *)(uiptr)sceCdSC(0xFFFFFFE6, (int *)&sCdPtbl.m_cdvdman_poff_cb); |
| 60 | + } |
| 61 | + sCdPoff_time.hi = 0; |
| 62 | + sCdPoff_time.lo = 0x90000; |
| 63 | + SetAlarm(&sCdPoff_time, (unsigned int (*)(void *))_sceCdPoffEmu, &sCdPtbl); |
| 64 | + WaitSema(sCdPtbl.m_sema_id); |
| 65 | + DeleteSema(sCdPtbl.m_sema_id); |
| 66 | + return 1; |
| 67 | +} |
0 commit comments