/* ** PSF driver main() replacement */ int psfdrv(void) { unsigned long seq_size = *((unsigned long *)MY_SEQ); /* ** Initialize and startup stuff */ SetSp(0x800C58E4); SpuInit(); minit(); /* ** Load sound file for instrument set */ mopen_file(MY_INSTR); /* ** Load sound file for sequence */ if (seq_size != 0) { /* this call should always execute mopenplay_seq, since I modified mopen_file a lot */ mopen_file(MY_SEQ); mplay_seq(MY_SEQ, 0x1200); } else { die(); } /* ** Loop a while. */ loopforever(); return 0; }
/* run the user's supplied interrupt handler and clean up the state after it: we wake up the return thread and then loop indefinitely; it overwrites our execution context to set us back to where we were before the interrupt if the argument "arg" is NULL, it's a clock interrupt; otherwise, it's a pointer to a network_interrupt_arg_t, which contains information about the packet which has arrived. disables interrupts before passing control to the return thread. */ void __fastcall receive_interrupt(CONTEXT* context, int type, void* arg) { signal_queue_t* sq; interrupt_queue_t* interrupt_info; readytoreturn = FALSE; //dbgprintf("SYS:Running user interrupt handler, context = 0x%x, arg = 0x%x.\n", // context, arg); /* find the appropriate handler */ interrupt_info = interrupt_queue; while (interrupt_info!=NULL && interrupt_info->type!=type) interrupt_info = interrupt_info->next; if (interrupt_info == NULL) { /* we couldn't find the interrupt with type "type" so we crask the sistem. */ dbgprintf("INT ERR: An interrupt of the unregistered type %d was received. Crashing.\n ", type); exit(-1); } else { /* now, call the appropriate interrupt handler */ //dbgprintf("SYS:interrupt of type %d.\n", type); if (interrupt_info->handler != NULL) interrupt_info->handler(arg); } WaitOnObject(mutex); assert(signalq == NULL); sq = (signal_queue_t *) malloc(sizeof(signal_queue_t)); sq->context = context; sq->threadid = system_thread; sq->next = signalq; signalq = sq; if (interrupt_level == ENABLED) { //dbgprintf("SYS:disabling interrupts in handler.\n"); interrupt_level = DISABLED; } ReleaseMutex(mutex); /* * This is correct but not elegant (it's a kluge forced on us by Windows). * We need an atomic way to wake up the * assist thread and go to sleep ourselves. One could use SignalAndWait * here, but SignalAndWait is not supported on CE */ ReleaseSemaphore(cleanup, 1, NULL); /* tell the return thread to run */ readytoreturn = TRUE; /* if (DEBUG) kprintf("SYS:Looping forever.\n"); */ loopforever(); }
/* ** PSF driver main() replacement */ int psfdrv(void) { void *pac; int rtype; int rdepth; int r; int play_a0; int play_a1; int play_a2; int play_a3; pac = (void*)(GM_PAC); /* ** Retrieve parameters and set useful defaults if they're zero */ rtype = PARAM_RTYPE; rdepth = PARAM_RDEPTH; /* ** Retrieve parameters for playback function */ play_a0 = PARAM_PLAY_A0; /* 0 (driver seems to ignore this parameter, perhaps) */ play_a1 = PARAM_PLAY_A1; /* target set (0 for BGM, maybe reverse-order of the file order?) */ play_a2 = PARAM_PLAY_A2; /* target song (index of DMF sequence) */ play_a3 = PARAM_PLAY_A3; /* loading method? (seems to be 1 for BGM, 0 for others) */ /* ** Initialize and startup stuff (comes from original main routine) */ //ResetCallback(); SsInit(); SsInitHot(); // since HokutoSsInitHot(0) contains MemCard things HokutoSsStart(); /* ** Reverb setup ** Actually the game already has set the reverb parameters ** during the initialization above. Anyway, here it is. */ if (rtype != 0 || rdepth != 0) { if(!rtype) rtype = 4; if(!rdepth) rdepth = 0; SsUtReverbOff(); //SsSetRVol(0x20, 0x20); SsUtSetReverbType(rtype); SsUtSetReverbDepth(rdepth, rdepth); SsUtReverbOn(); } /* ** Load the PAC */ r = HokutoSsOpenPac(pac, 15); ASSERT(r == 0); /* ** Play the DMF */ HokutoSsPlaySeq(play_a0, play_a1, play_a2, play_a3); /* ** Loop a while. */ loopforever(); return 0; }