mirror of
https://github.com/zydeco/minivmac4ios.git
synced 2025-02-20 14:29:19 +00:00
1 line
9.8 KiB
C
1 line
9.8 KiB
C
|
/*
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"
LOCALPROC EmulatedHardwareZap(void)
{
Memory_Reset();
ICT_Zap();
IWM_Reset();
SCC_Reset();
SCSI_Reset();
VIA1_Zap();
#if EmVIA2
VIA2_Zap();
#endif
Sony_Reset();
Extn_Reset();
m68k_reset();
}
LOCALPROC DoMacReset(void)
{
Sony_EjectAllDisks();
EmulatedHardwareZap();
}
LOCALPROC InterruptReset_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;
}
}
LOCALPROC SubTickNotify(int SubTick)
{
#if 0
dbglog_writeCStr("ending sub tick ");
dbglog_writeNum(SubTick);
dbglog_writeReturn();
#endif
#if MySoundEnabled && (CurEmMd != kEmMd_PB100)
MacSound_SubTick(SubTick);
#else
UnusedParam(SubTick);
#endif
}
#define CyclesScaledPerTick (130240UL * kMyClockMult * kCycleScale)
#define CyclesScaledPerSubTick (CyclesScaledPerTick / kNumSubTicks)
LOCALVAR ui4r SubTickCounter;
LOCALPROC SubTickTaskDo(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);
}
}
LOCALPROC SubTickTaskStart(void)
{
SubTickCounter = 0;
ICT_add(kICT_SubTick, CyclesScaledPerSubTick);
}
LOCALPROC SubTickTaskEnd(void)
{
SubTickNotify(kNumSubTicks - 1);
}
LOCALPROC SixtiethSecondNotify(void)
{
#if dbglog_HAVE && 0
dbglog_StartLine();
dbglog_writeCStr("begin new Sixtieth");
dbglog_writeReturn();
#endif
Mouse_Update();
InterruptReset_Update();
#if EmClassicKbrd
KeyBoard_Update();
#endif
#if EmADB
ADB_Update();
#endif
Sixtieth_PulseNtfy(); /* Vertical Blanking Interrupt */
Sony_Update();
#if EmLocalTalk
LocalTalkTick();
#endif
#if EmRTC
RTC_Interrupt();
#endif
#if EmVidCard
Vid_Update();
#endif
#if EmASC
ASC_Update();
#endif
SubTickTaskStart();
}
LOCALPROC SixtiethEndNotify(void)
{
SubTickTaskEnd();
Mouse_EndTickNotify();
Screen_EndTickNotify();
#if dbglog_HAVE && 0
dbglog_StartLine();
dbglog_writeCStr("end Sixtieth");
dbglog_writeReturn();
#endif
}
LOCALPROC ExtraTimeBeginNotify(void)
{
#if 0
dbglog_writeCStr("begin extra time");
dbglog_writeReturn();
#endif
VIA1_ExtraTimeBegin();
#if EmVIA2
VIA2_ExtraTimeBegin();
#endif
}
LOCALPROC ExtraTimeEndNotify(void)
{
VIA1_ExtraTimeEnd();
#if EmVIA2
VIA2_ExtraTimeEnd();
#endif
#if 0
dbglog_writeCStr("end extra time");
dbglog_writeReturn();
#endif
}
GLOBALPROC EmulationReserveAlloc(void)
{
ReserveAllocOneBlock(&RAM,
kRAM_Size + RAMSafetyMarginFudge, 5, falseblnr);
#if EmVidCard
ReserveAllocOneBlock(&VidROM, kVidROM_Size, 5, falseblnr);
#endif
|