/*
PROGMAIN.c
Copyright (C) 2009 Bernd Schmidt, Philip Cummins, Paul C. Pratt
You can redistribute this file and/or modify it under the terms
of version 2 of the GNU General Public License as published by
the Free Software Foundation. You should have received a copy
of the license along with this file; see the file COPYING.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
license for more details.
*//*
PROGram MAIN.
*/#ifndef AllFiles#include"SYSDEPNS.h"#include"MYOSGLUE.h"#include"EMCONFIG.h"#include"GLOBGLUE.h"#include"M68KITAB.h"#include"MINEM68K.h"#include"VIAEMDEV.h"#if EmVIA2#include"VIA2EMDV.h"#endif#include"IWMEMDEV.h"#include"SCCEMDEV.h"#if EmRTC#include"RTCEMDEV.h"#endif#include"ROMEMDEV.h"#include"SCSIEMDV.h"#include"SONYEMDV.h"#include"SCRNEMDV.h"#if EmVidCard#include"VIDEMDEV.h"#endif#if EmClassicKbrd#include"KBRDEMDV.h"#elif EmPMU#include"PMUEMDEV.h"#else#include"ADBEMDEV.h"#endif#if EmASC#include"ASCEMDEV.h"#else#if MySoundEnabled && (CurEmMd != kEmMd_PB100)#include"SNDEMDEV.h"#endif#endif#include"MOUSEMDV.h"#endif#include"PROGMAIN.h"/*
ReportAbnormalID unused 0x1002 - 0x10FF
*/LOCALPROCEmulatedHardwareZap(void){Memory_Reset();ICT_Zap();IWM_Reset();SCC_Reset();SCSI_Reset();VIA1_Zap();#if EmVIA2VIA2_Zap();#endifSony_Reset();Extn_Reset();m68k_reset();}LOCALPROCDoMacReset(void){Sony_EjectAllDisks();EmulatedHardwareZap();}LOCALPROCInterruptReset_Update(void){SetInterruptButton(falseblnr);/*
in case has been set. so only stays set
for 60th of a second.
*/if(WantMacInterrupt){SetInterruptButton(trueblnr);WantMacInterrupt=falseblnr;}if(WantMacReset){DoMacReset();WantMacReset=falseblnr;}}LOCALPROCSubTickNotify(intSubTick){#if 0 dbglog_writeCStr("ending sub tick ");
dbglog_writeNum(SubTick);
dbglog_writeReturn();
#endif
#if EmASCASC_SubTick(SubTick);#else#if MySoundEnabled && (CurEmMd != kEmMd_PB100)MacSound_SubTick(SubTick);#elseUnusedParam(SubTick);#endif#endif}#define CyclesScaledPerTick (130240UL * kMyClockMult * kCycleScale)#define CyclesScaledPerSubTick (CyclesScaledPerTick / kNumSubTicks)LOCALVARui4rSubTickCounter;LOCALPROCSubTickTaskDo(void){SubTickNotify(SubTickCounter);++SubTickCounter;if(SubTickCounter<(kNumSubTicks-1)){/*
final SubTick handled by SubTickTaskEnd,
since CyclesScaledPerSubTick * kNumSubTicks
might not equal CyclesScaledPerTick.
*/ICT_add(kICT_SubTick,CyclesScaledPerSubTick);}}LOCALPROCSubTickTaskStart(void){SubTickCounter=0;ICT_add(kICT_SubTick,CyclesScaledPerSubTick);}LOCALPROCSubTickTaskEnd(void){SubTickNotify(kNumSubTicks-1);}LOCALPROCSixtiethSecondNotify(void){#if dbglog_HAVE && 0dbglog_WriteNote("begin new Sixtieth");#endifMouse_Update();InterruptReset_Update();#if EmClassicKbrdKeyBoard_Update();#endif#if EmADBADB_Update();#endifSixtieth_PulseNtfy();/* Vertical Blanking Interrupt */Sony_Update();#if EmLocalTalkLocalTalkTick();#endif#if EmRTCRTC_Interrupt();#endif#if EmVidCardVid_Update();#endifSubTickTaskStart();}LOCALPROCSixtiethEndNotify(void){SubTickTaskEnd();Mouse_EndTickNotify();Screen_EndTickNotify();#if dbglog_HAVE && 0dbglog_WriteNote("end Sixtieth");#endif}LOCALPROCExtraTimeBeginNotify(void){#if 0 dbglog_writeCStr("begin extra time");
dbglog_writeReturn();
#endif
VIA1_ExtraTimeBegin();#if EmVIA2VIA2_ExtraTimeBegin();#endif}LOCALPROCExtraTimeEndNotify(void){VIA1_ExtraTimeEnd();#if EmVIA2VIA2_ExtraTimeEnd();#endif#if 0 dbglog_writeCStr("end extra time");
dbglog_writeReturn();
#endif
}GLOBALPROCEmulationReserveAlloc(void){ReserveAllocOneBlock(&RAM,kRAM_Size+RAMSafetyMarginFudge,5,falseblnr);#if EmVidCardReserveAllocOneBlock(&VidROM,kVidROM_Size,5,falseblnr);#endif#if IncludeVidMemReserv