/* Sim beta 1b by Olivier Armand (ExtendeD) - */ /* Compile all the files of the project with the GCC switches : * -fno-function-cse -mregparm=3 -fomit-frame-pointer * and the AS swith -l * You can also use the Makefile provided with Make. * The project can be built without problems with TIGCC v0.94 or higher. */ /* The source code is provided for your curiosity, and to let you help * me improve the program. * But please ask me before using any part of this source code in your * programs. */ /* Entry point of Sim. */ #include "sim.h" #include "common.h" #include "misc.h" #include "kbdemu.h" #include "no_calc_detect.h" static BOOL Running = FALSE; /* Registered with atexit(). */ void CleanRunning (void) { Running = FALSE; } void _main (void) { KbdEmuType kbd_emu_type; void *patched_prgm; unsigned short plen; HARDWARE_PARM_BLOCK parm_block; /* must be local ! (see InstallKbdEmu()). */ BOOL emulating_this_calc; /* Prepare the CleanAll() mechanism. */ CleanAllInit (); /* Sim must not emulate itself. */ if (Running == TRUE) fatal ("Sim: cannot run myself."); Running = TRUE; xatexit (CleanRunning); /* Create a T_REMAP_MATRIX. */ RemapMatrix = xmalloc (sizeof (T_REMAP_MATRIX)); /* Read the arguments and the keys script, and create a copy of the program. */ patched_prgm = CopyPrgmToRAM (GetArgsAndKbdMat (RemapMatrix, &kbd_emu_type, &emulating_this_calc)); plen = *((unsigned short*)patched_prgm)++; InstallKbdEmu (patched_prgm, plen, kbd_emu_type, emulating_this_calc, &parm_block); if (!emulating_this_calc) PatchNoCalcDetect (patched_prgm, plen, CALCULATOR); RunPrgm ((char*)patched_prgm - sizeof (short)); }