#ifdef MEDIA174_S10EA_S10EB_S11E_S12E_S12G_S13FA_S13FB_S20E_S21E_SU1E
/*_*************************** Fix function names **************************_*/
/* The Megamax C linker orders functions in the jump table at the beginning of the executable file based on hashes of their names. This section renames functions so that the order is the same as in the original game */
#ifndef THINK_C
#define E0061_SOUND_Exception77Handler_TimerA_SoundPlayer                         E061_aAA6_
#define F0003_MAIN_ProcessNewPartyMap_CPSE                                        F003_aaaS_
#define F0006_MAIN_HighlightScreenBox                                             F006_aamz_
#define F0007_MAIN_CopyBytes                                                      F007_aAA7_
#define F0008_MAIN_ClearBytes                                                     F008_aA19_
#define F0009_MAIN_WriteSpacedBytes                                               F009_aA49_
#define F0010_MAIN_WriteSpacedWords                                               F010_aAA7_
#define F0018_MAIN_SetExceptionVectors                                            F018_aaat_
#define F0019_MAIN_DisplayErrorAndStop                                            F019_aarz_
#define F0020_MAIN_BlitToViewport                                                 F020_aAA5_
#define F0021_MAIN_BlitToScreen                                                   F021_a002_
#define F0022_MAIN_Delay                                                          F022_aaaU_
#define F0023_MAIN_GetAbsoluteValue                                               F023_aarz_
#define F0024_MAIN_GetMinimumValue                                                F024_aatz_
#define F0025_MAIN_GetMaximumValue                                                F025_aatz_
#define F0026_MAIN_GetBoundedValue                                                F026_a003_
#define F0027_MAIN_Get16bitRandomNumber                                           F027_AA59_
#define F0028_MAIN_Get1BitRandomNumber                                            F028_a000_
#define F0029_MAIN_Get2BitRandomNumber                                            F029_AA19_
#define F0030_MAIN_GetScaledProduct                                               F030_aaaW_
#define F0031_OBJECT_LoadNames                                                    F031_aAA2_
#define F0032_OBJECT_GetType                                                      F032_aaaY_
#define F0033_OBJECT_GetIconIndex                                                 F033_aaaz_
#define F0034_OBJECT_DrawLeaderHandObjectName                                     F034_aaau_
#define F0035_OBJECT_ClearLeaderHandObjectName                                    F035_aaaw_
#define F0036_OBJECT_ExtractIconFromBitmap                                        F036_aA19_
#define F0037_OBJECT_DrawIconToScreen                                             F037_aA29_
#define F0038_OBJECT_DrawIconInSlotBox                                            F038_AA07_
#define F0039_OBJECT_GetIconIndexInSlotBox                                        F039_aaaL_
#define F0040_TEXT_Print                                                          F040_aacZ_
#define F0041_TEXT_PrintWithTrailingSpaces                                        F041_aadZ_
#define F0043_TEXT_MESSAGEAREA_ClearAllRows                                       F043_aahz_
#define F0047_TEXT_MESSAGEAREA_PrintMessage                                       F047_xzzz_
#define F0051_TEXT_MESSAGEAREA_PrintLineFeed                                      F051_AA19_
#define F0052_TEXT_PrintToViewport                                                F052_aaoz_
#define F0053_TEXT_PrintToLogicalScreen                                           F053_aajz_
#define F0054_TEXT_Initialize                                                     F054_aAA1_
#define F0060_SOUND_Play_CPSX                                                          F060_AA29_
#define F0062_SOUND_Initialize                                                    F062_aalz_
#define F0063_SOUND_KeyClickOff                                                   F063_aA05_
#define F0064_SOUND_RequestPlay_CPSD                                              F064_aadz_
#define F0065_SOUND_PlayPendingSound_CPSD                                         F065_aanz_
#define F0066_MOUSE_Initialize                                                    F066_aalz_
#define F0067_MOUSE_SetPointerToNormal                                            F067_aaat_
#define F0068_MOUSE_SetPointerToObject                                            F068_aagz_
#define F0069_MOUSE_SetPointer                                                    F069_aaaL_
#define F0070_MOUSE_ProcessCommands125To128_ClickOnChampionIcon                   F070_aajz_
#define F0075_MOUSE_Exception70Handler_IKBD_MIDI_MouseStatus                      F075_xxxx_
#define F0076_MOUSE_OnMouseButtonsStatusChange                                    F076_xxxx_
#define F0077_MOUSE_EnableScreenUpdate_CPSE                                       F077_aA39_
#define F0078_MOUSE_DisableScreenUpdate                                           F078_xzzz_
#define F0079_CPSC_GetChecksumAdd                                                 F079_a002_
#define F0094_DUNGEONVIEW_LoadFloorSet                                            F094_mzzz_
#define F0095_DUNGEONVIEW_LoadWallSet                                             F095_izzz_
#define F0096_DUNGEONVIEW_LoadCurrentMapGraphics_CPSDF                            F096_qzzz_
#define F0097_DUNGEONVIEW_DrawViewport                                            F097_lzzz_
#define F0098_DUNGEONVIEW_DrawFloorAndCeiling                                     F098_rzzz_
#define F0106_DUNGEONVIEW_TestResetToStep1_CPSF                                   F106_rzzz_
#define F0128_DUNGEONVIEW_Draw_CPSF                                               F128_rzzz_
#define F0129_VIDEO_BlitShrinkWithPaletteChanges                                  F129_szzz_
#define F0132_VIDEO_Blit                                                          F132_xzzz_
#define F0134_VIDEO_FillBitmap                                                    F134_zzzz_
#define F0135_VIDEO_FillBox                                                       F135_xzzz_
#define F0136_VIDEO_HatchScreenBox                                                F136_nzzz_
#define F0137_CPSEF_PatchFunctionWithHiddenCodeLauncher                           F137_pzzz_
#define F0139_DUNGEON_IsCreatureAllowedOnMap                                      F139_aqzz_
#define F0140_DUNGEON_GetObjectWeight                                             F140_yzzz_
#define F0141_DUNGEON_GetObjectInfoIndex                                          F141_anzz_
#define F0142_DUNGEON_GetProjectileAspect                                         F142_aqzz_
#define F0143_DUNGEON_GetArmourDefense                                            F143_mzzz_
#define F0144_DUNGEON_GetCreatureAttributes                                       F144_amzz_
#define F0145_DUNGEON_GetGroupCells                                               F145_rzzz_
#define F0146_DUNGEON_SetGroupCells                                               F146_aczz_
#define F0147_DUNGEON_GetGroupDirections                                          F147_aawz_
#define F0148_DUNGEON_SetGroupDirections                                          F148_aayz_
#define F0149_DUNGEON_IsWallOrnamentAnAlcove                                      F149_aawz_
#define F0150_DUNGEON_UpdateMapCoordinatesAfterRelativeMovement                   F150_wzzz_
#define F0151_DUNGEON_GetSquare                                                   F151_rzzz_
#define F0153_DUNGEON_GetRelativeSquareType                                       F153_yzzz_
#define F0154_DUNGEON_GetLocationAfterLevelChange                                 F154_afzz_
#define F0155_DUNGEON_GetStairsExitDirection                                      F155_ahzz_
#define F0156_DUNGEON_GetThingData                                                F156_afzz_
#define F0157_DUNGEON_GetSquareFirstThingData                                     F157_rzzz_
#define F0158_DUNGEON_GetWeaponInfo                                               F158_ayzz_
#define F0159_DUNGEON_GetNextThing                                                F159_rzzz_
#define F0161_DUNGEON_GetSquareFirstThing                                         F161_szzz_
#define F0162_DUNGEON_GetSquareFirstObject                                        F162_afzz_
#define F0163_DUNGEON_LinkThingToList                                             F163_amzz_
#define F0164_DUNGEON_UnlinkThingFromList                                         F164_dzzz_
#define F0166_DUNGEON_GetUnusedThing                                              F166_szzz_
#define F0167_DUNGEON_GetObjectForProjectileLauncherOrObjectGenerator             F167_aozz_
#define F0168_DUNGEON_DecodeText                                                  F168_ajzz_
#define F0172_DUNGEON_SetSquareAspect                                             F172_awzz_
#define F0173_DUNGEON_SetCurrentMap                                               F173_gzzz_
#define F0174_DUNGEON_SetCurrentMapAndPartyMap                                    F174_aozz_
#define F0175_GROUP_GetThing                                                      F175_gzzz_
#define F0176_GROUP_GetCreatureOrdinalInCell                                      F176_avzz_
#define F0177_GROUP_GetMeleeTargetCreatureOrdinal                                 F177_aszz_
#define F0178_GROUP_GetGroupValueUpdatedWithCreatureValue                         F178_aazz_
#define F0180_GROUP_StartWandering                                                F180_hzzz_
#define F0181_GROUP_DeleteEvents                                                  F181_czzz_
#define F0182_GROUP_StopAttacking                                                 F182_aqzz_
#define F0183_GROUP_AddActiveGroup                                                F183_kzzz_
#define F0184_GROUP_RemoveActiveGroup                                             F184_ahzz_
#define F0185_GROUP_GetGenerated                                                  F185_auzz_
#define F0187_GROUP_DropMovingCreatureFixedPossessions                            F187_czzz_
#define F0188_GROUP_DropGroupPossessions                                          F188_aozz_
#define F0189_GROUP_Delete                                                        F189_awzz_
#define F0190_GROUP_GetDamageCreatureOutcome                                      F190_zzzz_
#define F0191_GROUP_GetDamageAllCreaturesOutcome                                  F191_aayz_
#define F0192_GROUP_GetResistanceAdjustedPoisonAttack                             F192_ayzz_
#define F0194_GROUP_RemoveAllActiveGroups                                         F194_hzzz_
#define F0195_GROUP_AddAllActiveGroups                                            F195_akzz_
#define F0196_GROUP_InitializeActiveGroups                                        F196_aozz_
#define F0209_GROUP_ProcessEvents29to41                                           F209_xzzz_
#define F0210_CPSE_ProcessEvent22_IsFuzzySectorValid_NormalBytes                  F210_uzzz_
#define F0211_CPSDF_GetSubroutineAbsoluteAddress                                  F211_vzzz_
#define F0212_PROJECTILE_Create                                                   F212_mzzz_
#define F0213_EXPLOSION_Create                                                    F213_hzzz_
#define F0214_PROJECTILE_DeleteEvent                                              F214_pzzz_
#define F0215_PROJECTILE_Delete                                                   F215_lzzz_
#define F0218_PROJECTILE_GetImpactCount                                           F218_ezzz_
#define F0224_GROUP_FluxCageAction                                                F224_zzzz_
#define F0225_GROUP_FuseAction                                                    F225_dzzz_
#define F0226_GROUP_GetDistanceBetweenSquares                                     F226_ozzz_
#define F0227_GROUP_IsDestinationVisibleFromSource                                F227_qzzz_
#define F0228_GROUP_GetDirectionsWhereDestinationIsVisibleFromSource              F228_uzzz_
#define F0229_GROUP_SetOrderedCellsToAttack                                       F229_hzzz_
#define F0230_GROUP_GetChampionDamage                                             F230_ezzz_
#define F0231_GROUP_GetMeleeActionDamage                                          F231_izzz_
#define F0232_GROUP_IsDoorDestroyedByAttack                                       F232_dzzz_
#define F0233_TIMELINE_Initialize_CPSE                                                 F233_wzzz_
#define F0235_TIMELINE_GetIndex                                                   F235_bzzz_
#define F0236_TIMELINE_FixPlacement                                               F236_pzzz_
#define F0237_TIMELINE_DeleteEvent                                                F237_rzzz_
#define F0238_TIMELINE_AddEvent_GetEventIndex_CPSE                                F238_pzzz_
#define F0260_TIMELINE_RefreshAllChampionStatusBoxes                              F260_pzzz_
#define F0261_TIMELINE_Process_CPSEF                                              F261_hzzz_
#define F0264_MOVE_IsLevitating                                                   F264_avzz_
#define F0267_MOVE_GetMoveResult_CPSCE                                            F267_dzzz_
#define F0268_SENSOR_AddEvent                                                     F268_fzzz_
#define F0275_SENSOR_IsTriggeredByClickOnWall                                     F275_aszz_
#define F0276_SENSOR_ProcessThingAdditionOrRemoval                                F276_qzzz_
#define F0277_CPSE_IsFuzzySectorValid_FuzzyBits                                   F277_jzzz_
#define F0278_CHAMPION_ResetDataToStartGame                                       F278_apzz_
#define F0280_CHAMPION_AddCandidateChampionToParty                                F280_agzz_
#define F0282_CHAMPION_ProcessCommands160To162_ClickInResurrectReincarnatePanel   F282_xzzz_
#define F0283_CHAMPION_ViAltarRebirth                                             F283_azzz_
#define F0284_CHAMPION_SetPartyDirection                                          F284_czzz_
#define F0285_CHAMPION_GetIndexInCell                                             F285_szzz_
#define F0286_CHAMPION_GetTargetChampionIndex                                     F286_hzzz_
#define F0292_CHAMPION_DrawState                                                  F292_arzz_
#define F0293_CHAMPION_DrawAllChampionStates                                      F293_ahzz_
#define F0294_CHAMPION_IsAmmunitionCompatibleWithWeapon                           F294_aozz_
#define F0296_CHAMPION_DrawChangedObjectIcons                                     F296_aizz_
#define F0297_CHAMPION_PutObjectInLeaderHand                                      F297_atzz_
#define F0298_CHAMPION_GetObjectRemovedFromLeaderHand                             F298_aqzz_
#define F0300_CHAMPION_GetObjectRemovedFromSlot                                   F300_aozz_
#define F0301_CHAMPION_AddObjectInSlot                                            F301_apzz_
#define F0302_CHAMPION_ProcessCommands28To65_ClickOnSlotBox                       F302_mzzz_
#define F0303_CHAMPION_GetSkillLevel                                              F303_AA09_
#define F0304_CHAMPION_AddSkillExperience                                         F304_apzz_
#define F0307_CHAMPION_GetStatisticAdjustedAttack                                 F307_fzzz_
#define F0308_CHAMPION_IsLucky                                                    F308_vzzz_
#define F0309_CHAMPION_GetMaximumLoad                                             F309_awzz_
#define F0310_CHAMPION_GetMovementTicks                                           F310_AA08_
#define F0311_CHAMPION_GetDexterity                                               F311_wzzz_
#define F0312_CHAMPION_GetStrength                                                F312_xzzz_
#define F0314_CHAMPION_WakeUp                                                     F314_gzzz_
#define F0315_CHAMPION_GetScentOrdinal                                            F315_arzz_
#define F0316_CHAMPION_DeleteScent                                                F316_aizz_
#define F0317_CHAMPION_AddScentStrength                                           F317_adzz_
#define F0320_CHAMPION_ApplyAndDrawPendingDamageAndWounds                         F320_akzz_
#define F0321_CHAMPION_AddPendingDamageAndWounds_GetDamage                        F321_AA29_
#define F0322_CHAMPION_Poison                                                     F322_lzzz_
#define F0324_CHAMPION_DamageAll_GetDamagedChampionCount                          F324_aezz_
#define F0325_CHAMPION_DecrementStamina                                           F325_bzzz_
#define F0326_CHAMPION_ShootProjectile                                            F326_ozzz_
#define F0327_CHAMPION_IsProjectileSpellCast                                      F327_kzzz_
#define F0328_CHAMPION_IsObjectThrown                                             F328_nzzz_
#define F0329_CHAMPION_IsLeaderHandObjectThrown                                   F329_hzzz_
#define F0330_CHAMPION_DisableAction                                              F330_szzz_
#define F0331_CHAMPION_ApplyTimeEffects_CPSF                                      F331_auzz_
#define F0334_INVENTORY_CloseChest                                                F334_akzz_
#define F0337_INVENTORY_SetDungeonViewPalette                                     F337_akzz_
#define F0338_INVENTORY_DecreaseTorchesLightPower_CPSE                            F338_atzz_
#define F0347_INVENTORY_DrawPanel                                                 F347_xxxx_
#define F0349_INVENTORY_ProcessCommand70_ClickOnMouth                             F349_dzzz_
#define F0350_INVENTORY_DrawStopPressingMouth                                     F350_aqzz_
#define F0352_INVENTORY_ProcessCommand71_ClickOnEye                               F352_aszz_
#define F0353_INVENTORY_DrawStopPressingEye                                       F353_auzz_
#define F0354_INVENTORY_DrawStatusBoxPortrait                                     F354_szzz_
#define F0355_INVENTORY_Toggle_CPSE                                               F355_hzzz_
#define F0356_CPSE_IsFuzzySectorValid_ByteValuesAndFuzzyBitCount                  F356_ozzz_
#define F0357_COMMAND_DiscardAllInput                                             F357_qzzz_
#define F0359_COMMAND_ProcessClick_CPSC                                           F359_hzzz_
#define F0361_COMMAND_ProcessKeyPress                                             F361_nzzz_
#define F0363_COMMAND_HighlightBoxDisable                                         F363_pzzz_
#define F0368_COMMAND_SetLeader                                                   F368_fzzz_
#define F0379_COMMAND_DrawRestScreen                                              F379_jzzz_
#define F0380_COMMAND_ProcessQueue_CPSC                                           F380_xzzz_
#define F0386_MENUS_DrawActionIcon                                                F386_ezzz_
#define F0387_MENUS_DrawActionArea                                                F387_hzzz_
#define F0388_MENUS_ClearActingChampion                                           F388_rzzz_
#define F0390_MENUS_RefreshActionAreaAndSetChampionDirectionMaximumDamageReceived F390_rzzz_
#define F0393_MENUS_DrawSpellAreaControls                                         F393_lzzz_
#define F0394_MENUS_SetMagicCasterAndDrawSpellArea                                F394_ozzz_
#define F0395_MENUS_DrawMovementArrows                                            F395_pzzz_
#define F0396_MENUS_LoadSpellAreaLinesBitmap                                      F396_pzzz_
#define F0413_CPSC_GetChecksumEor                                                 F413_AA08_
#define F0428_DIALOG_RequireGameDiskInDrive_NoDialogDrawn                         F428_AA39_
#define F0433_STARTEND_ProcessCommand140_SaveGame_CPSCDF                          F433_AA39_
#define F0442_STARTEND_ProcessCommand202_EntranceDrawCredits                      F442_AA08_
#define F0444_STARTEND_Endgame                                                    F444_AA29_
#define F0446_STARTEND_FuseSequence                                               F446_zzzz_
#define F0448_STARTUP1_InitializeMemoryManager_CPSADEF                            F448_xxxx_
#define F0456_START_DrawDisabledMenus                                             F456_vzzz_
#define F0457_START_DrawEnabledMenus_CPSF                                         F457_AA08_
#define F0461_START_AllocateFlippedWallBitmaps                                    F461_AA08_
#define F0463_START_InitializeGame_CPSADEF                                        F463_wzzz_
#define F0464_CPSC_GetChecksumSub                                                 F464_AA07_
#define F0466_EXPAND_GraphicToBitmap                                              F466_rzzz_
#define F0468_MEMORY_Allocate                                                     F468_ozzz_
#define F0469_MEMORY_FreeAtHeapTop                                                F469_rzzz_
#define F0470_MEMORY_FreeAtHeapBottom                                             F470_xzzz_
#define F0475_MEMORY_Initialize                                                   F475_ozzz_
#define F0476_MEMORY_InitializeGraphicMemory                                      F476_mzzz_
#define F0477_MEMORY_OpenGraphicsDat_CPSDF                                        F477_izzz_
#define F0478_MEMORY_CloseGraphicsDat_CPSDF                                       F478_gzzz_
#define F0479_MEMORY_ReadGraphicsDatHeader                                        F479_izzz_
#define F0480_CACHE_ReleaseBlock                                                  F480_AA07_
#define F0484_MEMORY_LoadGraphics_CPSDEF                                          F484_gzzz_
#define F0488_MEMORY_ExpandGraphicToBitmap                                        F488_bzzz_
#define F0489_MEMORY_GetNativeBitmapOrGraphic                                     F489_ayzz_
#define F0490_MEMORY_LoadDecompressAndExpandGraphic                               F490_lzzz_
#define F0491_CACHE_IsDerivedBitmapInCache                                        F491_xzzz_
#define F0492_CACHE_GetDerivedBitmap                                              F492_mzzz_
#define F0493_CACHE_AddDerivedBitmap                                              F493_hzzz_
#define F0494_MEMORY_GetGraphicDecompressedByteCount                              F494_ozzz_
#define F0497_LZW_Decompress                                                      F497_pzzz_
#define R0055_TOS_CallBIOS                                                        R055_xxxx_
#define R0056_TOS_CallXBIOS                                                       R056_aaal_
#define R0057_TOS_CallGEMDOS                                                      R057_rzzz_
#define R0138_CPSEF_HiddenCodeLauncher                                            R138_lzzz_
#define S0059_TOS_SetException257Vector_CriticalError                             S059_aaac_
#define S0080_CPSDF_CheckDMATransferCompletion                                    S080_aaat_
#define S0081_CPSDF_TurnOffFloppyDrive                                            S081_aaao_
#define S0465_CPSD_ReadSector247                                                  S465_qzzz_
#define V0061000_RemainingSoundSampleCount                                        V061_1_HHH
#define V0061001_SoundSampleRepeatCount                                           V061_2_A79
#define V0061002_NextSoundSample                                                  V061_3_aav
#define V0061003_CurrentChannelsAmplitudeTable                                    V061_4_GFF
#define V0061004_ChannelsAmplitudeTableLoud                                       V061_5_xxx
#define V0061005_ChannelsAmplitudeTableSoft                                       V061_6_dzz
#endif

/*_**************************** Memory addresses ***************************_*/
#define C0x0070_ADDRESS_INTERRUPT_AUTOVECTOR_4_VERTICAL_BLANK       0x0070 /* Interrupt Autovector Level 4 (Vertical Blank) */
#define C0x0090_ADDRESS_INTERRUPT_VECTOR_TRAP_4                     0x0090 /* TRAP #4 */
#define C0x0114_ADDRESS_INTERRUPT_VECTOR_5_MFP_TIMER_C              0x0114 /* Interrupt Vector 5 MFP Timer C (200hz Clock) */
#define C0x0118_ADDRESS_INTERRUPT_VECTOR_6_KEYBOARD_MIDI            0x0118 /* Interrupt Vector 6 Keyboard/MIDI (ACIA) */
#define C0x0120_ADDRESS_INTERRUPT_VECTOR_8_TIMER_B_HORIZONTAL_BLANK 0x0120 /* Interrupt Vector 8 Timer B (Horizontal Blank) */
#define C0x0404_ADDRESS_SYSTEM_VARIABLE_etv_critic                  0x0404 /* GEM Critical error handler */
#define C0x043E_ADDRESS_SYSTEM_VARIABLE_flock                       0x043E /* Floppy lock */
#define C0x0472_ADDRESS_SYSTEM_VARIABLE_hdv_bpb                     0x0472 /* Vector for getbpb for hard disk */
#define C0x0476_ADDRESS_SYSTEM_VARIABLE_hdv_rw                      0x0476 /* Vector for read/write routine for hard disk */
#define C0x047E_ADDRESS_SYSTEM_VARIABLE_hdv_mediach                 0x047E /* Vector for hard disk media change */
#define C0x0484_ADDRESS_SYSTEM_VARIABLE_conterm                     0x0484 /* Attribute vector for console output */
#define C0x04A6_ADDRESS_SYSTEM_VARIABLE__nflops                     0x04A6 /* Number of connected floppy drives */
#define C0x04F2_ADDRESS_SYSTEM_VARIABLE__sysbase                    0x04F2 /* Pointer to start of OS */

typedef struct {
        void (*midivec)();  /* MIDI Input */
        void (*vkbderr)();  /* IKBD Error */
        void (*vmiderr)();  /* MIDI Error */
        void (*statvec)();  /* IKBD Status */
        void (*mousevec)(); /* IKBD Mouse */
        void (*clockvec)(); /* IKBD Clock */
        void (*joyvec)();   /* IKBD Joystick */
        void (*midisys)();  /* Main MIDI Vector */
        void (*ikbdsys)();  /* Main IKBD Vector */
        char ikbdstate;
} KBDVECS;

typedef struct {
        int16_t* contrl;
        int16_t* global;
        int16_t* intin;
        int16_t* intout;
        int16_t** addrin;
        int16_t** addrout;
} AESPB;

typedef struct {
        int16_t* contrl;
        int16_t* intin;
        int16_t* ptsin;
        int16_t* intout;
        int16_t* ptsout;
} VDIPB;

typedef struct { /* Size = 44 = 0x2C */
        int16_t Status;
        unsigned char* Graphic;
        int16_t Box[4];
        int16_t Width;
        int16_t Height;
        int16_t ColorDepth;
        int16_t TransparentColor;
        char FTLFileName[20];
        int16_t Command;
} SWITCH_OPTION;

#define SWITCH_OPTION_COUNT 50

typedef struct { /* Size = 52 = 0x34 */
        int16_t SegmentType;
        int16_t SegmentId;
        int16_t X;
        int16_t Y;
        int16_t TransparentColor;
        char FTLFileName[42];
} SWITCHIMAGE;

#define Rwabs(a, b, c, d, e)               (long)R0055_TOS_CallBIOS(0x04, a, b, c, d, e)
#define Mediach(a)                         (long)R0055_TOS_CallBIOS(0x09, a)
#define Drvmap()                           (long)R0055_TOS_CallBIOS(0x0A)
#define Kbshift(a)                         (long)R0055_TOS_CallBIOS(0x0B, a)
#define Logbase()                          (char*)R0056_TOS_CallXBIOS(0x03)
#define Getrez()                           (int16_t)R0056_TOS_CallXBIOS(0x04)
#define Setscreen(a, b, c)                 (void)R0056_TOS_CallXBIOS(0x05, a, b, c)
#define Setpalette(a)                      (void)R0056_TOS_CallXBIOS(0x06, a)
#define Floprd(a, b, c, d, e, f, g)        (int16_t)R0056_TOS_CallXBIOS(0x08, a, b, c, d, e, f, g)
#define Flopwr(a, b, c, d, e, f, g)        (long)R0056_TOS_CallXBIOS(0x09, a, b, c, d, e, f, g)
#define Flopfmt(a, b, c, d, e, f, g, h, i) (long)R0056_TOS_CallXBIOS(0x0A, a, b, c, d, e, f, g, h, i)
#define Random()                           (unsigned long)R0056_TOS_CallXBIOS(0x11)
#define Protobt(a, b, c, d)                (void)R0056_TOS_CallXBIOS(0x12, a, b, c, d)
#define Jdisint(a)                         (void)R0056_TOS_CallXBIOS(0x1A, a)
#define Jenabint(a)                        (void)R0056_TOS_CallXBIOS(0x1B, a)
#define Giaccess(a, b)                     (char)R0056_TOS_CallXBIOS(0x1C, a, b)
#define Xbtimer(a, b, c, d)                (void)R0056_TOS_CallXBIOS(0x1F, a, b, c, d)
#define Kbdvbase()                         (KBDVECS*)R0056_TOS_CallXBIOS(0x22)
#define Vsync()                            (void)R0056_TOS_CallXBIOS(0x25)
#define Supexec(a)                         (long)R0056_TOS_CallXBIOS(0x26, a)
#define Cconin()                           (int16_t)R0057_TOS_CallGEMDOS(0x01)
#define Cconout(a)                         (void)R0057_TOS_CallGEMDOS(0x02, a)
#define Crawcin()                          (long)R0057_TOS_CallGEMDOS(0x07)
#define Cconws(a)                          (void)R0057_TOS_CallGEMDOS(0x09, a)
#define Cconis()                           (int16_t)R0057_TOS_CallGEMDOS(0x0B)
#define Super(a)                           (long)R0057_TOS_CallGEMDOS(0x20, a)
#define Fgetdta()                          (char*)R0057_TOS_CallGEMDOS(0x2F)
#define Fsetdta(a)                         (void)R0057_TOS_CallGEMDOS(0x1A, a)
#define Dfree(a, b)                        (long)R0057_TOS_CallGEMDOS(0x36, a, b)
#define Fcreate(a, b)                      (long)R0057_TOS_CallGEMDOS(0x3C, a, b)
#define Fopen(a, b)                        (long)R0057_TOS_CallGEMDOS(0x3D, a, b)
#define Fclose(a)                          (long)R0057_TOS_CallGEMDOS(0x3E, a)
#define Fread(a, b, c)                     (long)R0057_TOS_CallGEMDOS(0x3F, a, b, c)
#define Fwrite(a, b, c)                    (long)R0057_TOS_CallGEMDOS(0x40, a, b, c)
#define Fdelete(a)                         (long)R0057_TOS_CallGEMDOS(0x41, a)
#define Fseek(a, b, c)                     (long)R0057_TOS_CallGEMDOS(0x42, a, b, c)
#define Malloc(a)                          (long)R0057_TOS_CallGEMDOS(0x48, a)
#define Mfree(a)                           (long)R0057_TOS_CallGEMDOS(0x49, a)
#define Fsfirst(a, b)                      (long)R0057_TOS_CallGEMDOS(0x4E, a, b)
#define Fsnext()                           (int16_t)R0057_TOS_CallGEMDOS(0x4F)
#define Frename(a, b, c)                   (long)R0057_TOS_CallGEMDOS(0x56, a, b, c)

#define Physbase()                         (void*)R0056_TOS_CallXBIOS(0x02)
#define Pterm(a)                           (long)R0057_TOS_CallGEMDOS(0x4C, a)
#define Dsetpath(a)                        (long)R0057_TOS_CallGEMDOS(0x3B, a)
#define Dgetpath(a, b)                     (long)R0057_TOS_CallGEMDOS(0x47, a, b)

#define appl_init()              F1534_CallAES(10);
#define appl_read()              F1534_CallAES(11);
#define appl_write()             F1534_CallAES(12);
#define appl_find()              F1534_CallAES(13);
#define appl_tplay()             F1534_CallAES(14);
#define appl_trecord()           F1534_CallAES(15);
#define appl_exit()              F1534_CallAES(19);
#define evnt_keybd()             F1534_CallAES(20);
#define evnt_button()            F1534_CallAES(21);
#define evnt_mouse()             F1534_CallAES(22);
#define evnt_mesag()             F1534_CallAES(23);
#define evnt_timer()             F1534_CallAES(24);
#define evnt_multi()             F1534_CallAES(25);
#define evnt_dclick()            F1534_CallAES(26);
#define menu_bar()               F1534_CallAES(30);
#define menu_icheck()            F1534_CallAES(31);
#define menu_ienable()           F1534_CallAES(32);
#define menu_tnormal()           F1534_CallAES(33);
#define menu_text()              F1534_CallAES(34);
#define menu_register()          F1534_CallAES(35);
#define objc_add()               F1534_CallAES(40);
#define objc_delete()            F1534_CallAES(41);
#define objc_draw()              F1534_CallAES(42);
#define objc_find()              F1534_CallAES(43);
#define objc_offset()            F1534_CallAES(44);
#define objc_order()             F1534_CallAES(45);
#define objc_edit()              F1534_CallAES(46);
#define objc_change()            F1534_CallAES(47);
#define form_do()                F1534_CallAES(50);
#define form_dial()              F1534_CallAES(51);
#define form_alert()             F1534_CallAES(52);
#define form_error()             F1534_CallAES(53);
#define form_center()            F1534_CallAES(54);
#define form_keybd()             F1534_CallAES(55);
#define form_button()            F1534_CallAES(56);
#define graf_rubberbox()         F1534_CallAES(70);
#define graf_dragbox()           F1534_CallAES(71);
#define graf_movebox()           F1534_CallAES(72);
#define graf_growbox()           F1534_CallAES(73);
#define graf_shrinkbox()         F1534_CallAES(74);
#define graf_watchbox()          F1534_CallAES(75);
#define graf_slidebox()          F1534_CallAES(76);
#define graf_handle()            F1534_CallAES(77);
#define graf_mouse()             F1534_CallAES(78);
#define graf_mkstate()           F1534_CallAES(79);
#define scrp_read()              F1534_CallAES(80);
#define scrp_write()             F1534_CallAES(81);
#define fsel_input()             F1534_CallAES(90);
#define wind_create()            F1534_CallAES(100);
#define wind_open()              F1534_CallAES(101);
#define wind_close()             F1534_CallAES(102);
#define wind_delete()            F1534_CallAES(103);
#define wind_get()               F1534_CallAES(104);
#define wind_set()               F1534_CallAES(105);
#define wind_find()              F1534_CallAES(106);
#define wind_update()            F1534_CallAES(107);
#define wind_calc()              F1534_CallAES(108);
#define rsrc_load()              F1534_CallAES(110);
#define rsrc_free()              F1534_CallAES(111);
#define rsrc_gaddr()             F1534_CallAES(112);
#define rsrc_saddr()             F1534_CallAES(113);
#define rsrc_obfix()             F1534_CallAES(114);
#define shel_read()              F1534_CallAES(120);
#define shel_write()             F1534_CallAES(121);
#define shel_get()               F1534_CallAES(122);
#define shel_put()               F1534_CallAES(123);
#define shel_find()              F1534_CallAES(124);
#define shel_envrn()             F1534_CallAES(125);

#define C0_RESERVED                                                      0
#define CM13_ERROR_EWRPRO_MEDIUM_WRITE_PROTECTED                       -13
#define C0L_FILLER                                                      0L
#define C001_SECTOR_1                                                    1
#define C007_SECTOR_7                                                    7
#define C010_SECTOR_10                                                  10
#define C247_SECTOR_247                                                247
#define C0_TRACK_0                                                       0
#define C0_SIDE_0                                                        0
#define C1_ONE_SECTOR                                                    1
#define C2_TWO_SECTORS                                                   2
#define C9_SECTORS_PER_TRACK                                             9
#define C1_INTERLEAVE                                                    1
#define C0x87654321_MAGIC                                       0x87654321
#define C0_READ_WITH_MEDIA_CHANGE                                        0
#define C0_LOGICAL_SECTOR_0                                              0
#define C0_FILE_ATTRIBUTES                                               0
#define C0_READ_ONLY                                                     0
#define C2_READ_WRITE_ACCESS                                             2
#define C0_SEEK_FROM_BEGINNING_OF_FILE                                   0
#define C1_SEEK_FROM_CURRENT_POSITION                                    1
#define C2_SEEK_FROM_END_OF_FILE                                         2
#define C0_TIMER_A                                                       0
#define C1_DELAY_MODE_4_PRESCALE                                         1
#define C05_INTERRUPT_TIMER_C                                            5
#define C13_INTERRUPT_TIMER_A                                           13
#define CM1L_NO_CHANGE                                                  -1L
#define CM1_NO_RESOLUTION_CHANGE                                        -1
#define C0x01000001_SERIAL_RANDOM                               0x01000001
#define C2_80_TRACKS_SINGLE_SIDED                                        2
#define C0_DISK_NOT_EXECUTABLE                                           0
#define MASK0x0000_READ_PSG_REGISTER                                0x0000
#define MASK0x0080_WRITE_PSG_REGISTER                               0x0080
#define C07_REGISTER_PSG_MODE                                            7
#define C11_REGISTER_PSG_WAVEFORM_FREQUENCY_LOW_BYTE                    11
#define C12_REGISTER_PSG_WAVEFORM_FREQUENCY_HIGH_BYTE                   12
#define C0x003F_MODE_ENABLE_TONE_AND_WHITE_NOISE_CHANNELS_A_B_C     0x003F


extern char* _base; /* Process base page. This variable is declared in the C loader init.c */
extern BOOLEAN G0663_B_LZW_RepetitionEnabled;
extern int16_t G0664_i_LZW_CodeBitCount;
extern int16_t G0665_i_LZW_CurrentMaximumCode;
extern int16_t G0666_i_LZW_AbsoluteMaximumCode;
extern char G0667_ac_LZW_InputBuffer[12];
extern int16_t G0668_i_LZW_DictionaryNextAvailableCode;
extern BOOLEAN G0669_B_LZW_DictionaryFlushed;
extern unsigned char G0670_auc_LZW_Unreferenced[9];
extern unsigned char G0671_auc_LZW_LeastSignificantBitMasks[9];
extern int16_t G0672_i_LZW_InputBufferBitIndex;
extern int16_t G0673_i_LZW_InputBufferBitCount;
extern int16_t G0674_i_LZW_CharacterToRepeat;


extern int16_t E0061_SOUND_Exception77Handler_TimerA_SoundPlayer();
extern int16_t V0061000_RemainingSoundSampleCount();
extern int16_t V0061001_SoundSampleRepeatCount();
extern int16_t V0061002_NextSoundSample();
extern int16_t V0061003_CurrentChannelsAmplitudeTable();
extern int16_t V0061004_ChannelsAmplitudeTableLoud();
extern int16_t V0061005_ChannelsAmplitudeTableSoft();
#endif
