Pi0 now supports 1581
This commit is contained in:
parent
75032d3f6f
commit
f9481c5450
3 changed files with 21 additions and 156 deletions
|
@ -418,6 +418,7 @@ bool FileBrowser::BrowsableList::CheckBrowseNavigation()
|
||||||
dirty |= views[index].CheckBrowseNavigation(index != 0);
|
dirty |= views[index].CheckBrowseNavigation(index != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if not defined(EXPERIMENTALZERO)
|
||||||
// check for keys a-z and 0-9
|
// check for keys a-z and 0-9
|
||||||
char searchChar = inputMappings->getKeyboardNumLetter();
|
char searchChar = inputMappings->getKeyboardNumLetter();
|
||||||
if (searchChar)
|
if (searchChar)
|
||||||
|
@ -489,6 +490,7 @@ bool FileBrowser::BrowsableList::CheckBrowseNavigation()
|
||||||
dirty |= 1;
|
dirty |= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
return dirty;
|
return dirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,9 +2,7 @@
|
||||||
#define DEFS_H
|
#define DEFS_H
|
||||||
|
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#ifndef EXPERIMENTALZERO
|
|
||||||
#define PI1581SUPPORT 1
|
#define PI1581SUPPORT 1
|
||||||
#endif
|
|
||||||
// Indicates a Pi with the 40 pin GPIO connector
|
// Indicates a Pi with the 40 pin GPIO connector
|
||||||
// so that additional functionality (e.g. test pins) can be enabled
|
// so that additional functionality (e.g. test pins) can be enabled
|
||||||
#if defined(RPIZERO) || defined(RPIBPLUS) || defined(RPI2) || defined(RPI3)
|
#if defined(RPIZERO) || defined(RPIBPLUS) || defined(RPI2) || defined(RPI3)
|
||||||
|
|
173
src/main.cpp
173
src/main.cpp
|
@ -692,15 +692,16 @@ DMA_ControlBlock dmaSoundCB =
|
||||||
0, 0
|
0, 0
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if not defined(EXPERIMENTALZERO)
|
||||||
static void PlaySoundDMA()
|
static void PlaySoundDMA()
|
||||||
{
|
{
|
||||||
#if not defined(EXPERIMENTALZERO)
|
|
||||||
write32(PWM_DMAC, PWM_ENAB + 0x0001);
|
write32(PWM_DMAC, PWM_ENAB + 0x0001);
|
||||||
write32(DMA_ENABLE, 1); // DMA_EN0
|
write32(DMA_ENABLE, 1); // DMA_EN0
|
||||||
write32(DMA0_BASE + DMA_CONBLK_AD, (u32)&dmaSoundCB);
|
write32(DMA0_BASE + DMA_CONBLK_AD, (u32)&dmaSoundCB);
|
||||||
write32(DMA0_BASE + DMA_CS, DMA_ACTIVE);
|
write32(DMA0_BASE + DMA_CS, DMA_ACTIVE);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void GlobalSetDeviceID(u8 id)
|
void GlobalSetDeviceID(u8 id)
|
||||||
{
|
{
|
||||||
|
@ -733,156 +734,6 @@ void CheckAutoMountImage(EXIT_TYPE reset_reason , FileBrowser* fileBrowser)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(EXPERIMENTALZERO)
|
|
||||||
EXIT_TYPE Emulate1541(FileBrowser* fileBrowser)
|
|
||||||
{
|
|
||||||
bool oldLED = false;
|
|
||||||
unsigned ctBefore = 0;
|
|
||||||
unsigned ctAfter = 0;
|
|
||||||
int cycleCount = 0;
|
|
||||||
unsigned caddyIndex;
|
|
||||||
int headSoundCounter = 0;
|
|
||||||
int headSoundFreqCounter = 0;
|
|
||||||
// const int headSoundFreq = 833; // 1200Hz = 1/1200 * 10^6;
|
|
||||||
const int headSoundFreq = 1000000 / options.SoundOnGPIOFreq(); // 1200Hz = 1/1200 * 10^6;
|
|
||||||
unsigned char oldHeadDir;
|
|
||||||
int resetCount = 0;
|
|
||||||
bool refreshOutsAfterCPUStep = true;
|
|
||||||
unsigned numberOfImages = diskCaddy.GetNumberOfImages();
|
|
||||||
unsigned numberOfImagesMax = numberOfImages;
|
|
||||||
if (numberOfImagesMax > 10)
|
|
||||||
numberOfImagesMax = 10;
|
|
||||||
|
|
||||||
diskCaddy.Display();
|
|
||||||
|
|
||||||
inputMappings->directDiskSwapRequest = 0;
|
|
||||||
// Force an update on all the buttons now before we start emulation mode.
|
|
||||||
IEC_Bus::ReadBrowseMode();
|
|
||||||
|
|
||||||
bool extraRAM = options.GetExtraRAM();
|
|
||||||
DataBusReadFn dataBusRead = extraRAM ? read6502ExtraRAM : read6502;
|
|
||||||
DataBusWriteFn dataBusWrite = extraRAM ? write6502ExtraRAM : write6502;
|
|
||||||
M6502& m6502 = pi1541.m6502;
|
|
||||||
m6502.SetBusFunctions(dataBusRead, dataBusWrite);
|
|
||||||
|
|
||||||
IEC_Bus::VIA = &pi1541.VIA[0];
|
|
||||||
IEC_Bus::port = pi1541.VIA[0].GetPortB();
|
|
||||||
pi1541.Reset(); // will call IEC_Bus::Reset();
|
|
||||||
IEC_Bus::OutputLED = false;
|
|
||||||
IEC_Bus::LetSRQBePulledHigh();
|
|
||||||
ctBefore = read32(ARM_SYSTIMER_CLO);
|
|
||||||
|
|
||||||
//resetWhileEmulating = false;
|
|
||||||
selectedViaIECCommands = false;
|
|
||||||
|
|
||||||
u32 hash = pi1541.drive.GetDiskImage()->GetHash();
|
|
||||||
// 0x42c02586 = maniac_mansion_s1[lucasfilm_1989](ntsc).g64
|
|
||||||
// 0x18651422 = aliens[electric_dreams_1987].g64
|
|
||||||
// 0x2a7f4b77 = zak_mckracken_boot[activision_1988](manual)(!).g64
|
|
||||||
if (hash == 0x42c02586 || hash == 0x18651422 || hash == 0x2a7f4b77)
|
|
||||||
{
|
|
||||||
refreshOutsAfterCPUStep = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (cycleCount < FAST_BOOT_CYCLES)
|
|
||||||
{
|
|
||||||
m6502.Step();
|
|
||||||
pi1541.Update();
|
|
||||||
cycleCount++;
|
|
||||||
IEC_Bus::ReadEmulationMode1541();
|
|
||||||
}
|
|
||||||
bool buttonState = false;
|
|
||||||
bool prevButtonState = false;
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
|
|
||||||
if (m6502.SYNC()) // About to start a new instruction.
|
|
||||||
{
|
|
||||||
pc = m6502.GetPC();
|
|
||||||
// See if the emulated cpu is executing CD:_ (ie back out of emulated image)
|
|
||||||
if (snoopIndex == 0 && (pc == SNOOP_CD_CBM || pc == SNOOP_CD_JIFFY_BOTH || pc == SNOOP_CD_JIFFY_DRIVEONLY)) snoopPC = pc;
|
|
||||||
|
|
||||||
if (pc == snoopPC)
|
|
||||||
{
|
|
||||||
if (Snoop(m6502.GetA()))
|
|
||||||
{
|
|
||||||
return EXIT_CD;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
m6502.Step(); // If the CPU reads or writes to the VIA then clk and data can change
|
|
||||||
|
|
||||||
if (refreshOutsAfterCPUStep)
|
|
||||||
IEC_Bus::RefreshOuts1541(); // Now output all outputs.
|
|
||||||
|
|
||||||
IEC_Bus::OutputLED = pi1541.drive.IsLEDOn();
|
|
||||||
if (IEC_Bus::OutputLED ^ oldLED)
|
|
||||||
{
|
|
||||||
SetACTLed(IEC_Bus::OutputLED);
|
|
||||||
oldLED = IEC_Bus::OutputLED;
|
|
||||||
}
|
|
||||||
|
|
||||||
pi1541.Update();
|
|
||||||
|
|
||||||
if (__builtin_expect(IEC_Bus::IsReset(), false))
|
|
||||||
resetCount++;
|
|
||||||
else
|
|
||||||
resetCount = 0;
|
|
||||||
|
|
||||||
if ((resetCount > 10))
|
|
||||||
{
|
|
||||||
return EXIT_RESET;
|
|
||||||
}
|
|
||||||
|
|
||||||
buttonState = IEC_Bus::AnyButtonPressed();
|
|
||||||
if (__builtin_expect(buttonState, false))
|
|
||||||
{
|
|
||||||
IEC_Bus::ReadButtonsEmulationMode();
|
|
||||||
inputMappings->CheckButtonsEmulationMode();
|
|
||||||
if (numberOfImages > 1)
|
|
||||||
{
|
|
||||||
bool nextDisk = inputMappings->NextDisk();
|
|
||||||
bool prevDisk = inputMappings->PrevDisk();
|
|
||||||
if (nextDisk)
|
|
||||||
{
|
|
||||||
pi1541.drive.Insert(diskCaddy.PrevDisk());
|
|
||||||
}
|
|
||||||
if (prevDisk)
|
|
||||||
{
|
|
||||||
pi1541.drive.Insert(diskCaddy.NextDisk());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bool exitEmulation = inputMappings->Exit();
|
|
||||||
if (exitEmulation)
|
|
||||||
return EXIT_KEYBOARD;
|
|
||||||
}
|
|
||||||
else if (__builtin_expect(!buttonState & prevButtonState, false))
|
|
||||||
{
|
|
||||||
IEC_Bus::ReadButtonsEmulationMode();
|
|
||||||
inputMappings->CheckButtonsEmulationMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
prevButtonState = buttonState;
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
ctAfter = read32(ARM_SYSTIMER_CLO);
|
|
||||||
} while (ctAfter == ctBefore); // Sync to the 1MHz clock
|
|
||||||
|
|
||||||
|
|
||||||
ctBefore = ctAfter;
|
|
||||||
IEC_Bus::ReadEmulationMode1541();
|
|
||||||
|
|
||||||
IEC_Bus::RefreshOuts1541(); // Now output all outputs.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
return EXIT_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
EXIT_TYPE Emulate1541(FileBrowser* fileBrowser)
|
EXIT_TYPE Emulate1541(FileBrowser* fileBrowser)
|
||||||
{
|
{
|
||||||
EXIT_TYPE exitReason = EXIT_UNKNOWN;
|
EXIT_TYPE exitReason = EXIT_UNKNOWN;
|
||||||
|
@ -903,9 +754,13 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser)
|
||||||
if (numberOfImagesMax > 10)
|
if (numberOfImagesMax > 10)
|
||||||
numberOfImagesMax = 10;
|
numberOfImagesMax = 10;
|
||||||
|
|
||||||
|
#if not defined(EXPERIMENTALZERO)
|
||||||
core0RefreshingScreen.Acquire();
|
core0RefreshingScreen.Acquire();
|
||||||
|
#endif
|
||||||
diskCaddy.Display();
|
diskCaddy.Display();
|
||||||
|
#if not defined(EXPERIMENTALZERO)
|
||||||
core0RefreshingScreen.Release();
|
core0RefreshingScreen.Release();
|
||||||
|
#endif
|
||||||
|
|
||||||
inputMappings->directDiskSwapRequest = 0;
|
inputMappings->directDiskSwapRequest = 0;
|
||||||
// Force an update on all the buttons now before we start emulation mode.
|
// Force an update on all the buttons now before we start emulation mode.
|
||||||
|
@ -975,6 +830,7 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser)
|
||||||
oldLED = IEC_Bus::OutputLED;
|
oldLED = IEC_Bus::OutputLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if not defined(EXPERIMENTALZERO)
|
||||||
// Do head moving sound
|
// Do head moving sound
|
||||||
unsigned char headDir = pi1541.drive.GetLastHeadDirection();
|
unsigned char headDir = pi1541.drive.GetLastHeadDirection();
|
||||||
if (headDir ^ oldHeadDir) // Need to start a new sound?
|
if (headDir ^ oldHeadDir) // Need to start a new sound?
|
||||||
|
@ -1001,13 +857,15 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser)
|
||||||
IEC_Bus::OutputSound = !IEC_Bus::OutputSound;
|
IEC_Bus::OutputSound = !IEC_Bus::OutputSound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
IEC_Bus::ReadButtonsEmulationMode();
|
IEC_Bus::ReadButtonsEmulationMode();
|
||||||
|
|
||||||
// Other core will check the uart (as it is slow) (could enable uart irqs - will they execute on this core?)
|
// Other core will check the uart (as it is slow) (could enable uart irqs - will they execute on this core?)
|
||||||
|
#if not defined(EXPERIMENTALZERO)
|
||||||
inputMappings->CheckKeyboardEmulationMode(numberOfImages, numberOfImagesMax);
|
inputMappings->CheckKeyboardEmulationMode(numberOfImages, numberOfImagesMax);
|
||||||
|
#endif
|
||||||
inputMappings->CheckButtonsEmulationMode();
|
inputMappings->CheckButtonsEmulationMode();
|
||||||
|
|
||||||
bool exitEmulation = inputMappings->Exit();
|
bool exitEmulation = inputMappings->Exit();
|
||||||
|
@ -1089,7 +947,6 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser)
|
||||||
}
|
}
|
||||||
return exitReason;
|
return exitReason;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(PI1581SUPPORT)
|
#if defined(PI1581SUPPORT)
|
||||||
EXIT_TYPE Emulate1581(FileBrowser* fileBrowser)
|
EXIT_TYPE Emulate1581(FileBrowser* fileBrowser)
|
||||||
|
@ -1112,9 +969,13 @@ EXIT_TYPE Emulate1581(FileBrowser* fileBrowser)
|
||||||
if (numberOfImagesMax > 10)
|
if (numberOfImagesMax > 10)
|
||||||
numberOfImagesMax = 10;
|
numberOfImagesMax = 10;
|
||||||
|
|
||||||
|
#if not defined(EXPERIMENTALZERO)
|
||||||
core0RefreshingScreen.Acquire();
|
core0RefreshingScreen.Acquire();
|
||||||
|
#endif
|
||||||
diskCaddy.Display();
|
diskCaddy.Display();
|
||||||
|
#if not defined(EXPERIMENTALZERO)
|
||||||
core0RefreshingScreen.Release();
|
core0RefreshingScreen.Release();
|
||||||
|
#endif
|
||||||
|
|
||||||
inputMappings->directDiskSwapRequest = 0;
|
inputMappings->directDiskSwapRequest = 0;
|
||||||
// Force an update on all the buttons now before we start emulation mode.
|
// Force an update on all the buttons now before we start emulation mode.
|
||||||
|
@ -1170,6 +1031,7 @@ EXIT_TYPE Emulate1581(FileBrowser* fileBrowser)
|
||||||
oldLED = IEC_Bus::OutputLED;
|
oldLED = IEC_Bus::OutputLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if not defined(EXPERIMENTALZERO)
|
||||||
// Do head moving sound
|
// Do head moving sound
|
||||||
unsigned int track = pi1581.wd177x.GetCurrentTrack();
|
unsigned int track = pi1581.wd177x.GetCurrentTrack();
|
||||||
if (track != oldTrack) // Need to start a new sound?
|
if (track != oldTrack) // Need to start a new sound?
|
||||||
|
@ -1185,6 +1047,7 @@ EXIT_TYPE Emulate1581(FileBrowser* fileBrowser)
|
||||||
PlaySoundDMA();
|
PlaySoundDMA();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other core will check the uart (as it is slow) (could enable uart irqs - will they execute on this core?)
|
// Other core will check the uart (as it is slow) (could enable uart irqs - will they execute on this core?)
|
||||||
|
@ -1232,6 +1095,7 @@ EXIT_TYPE Emulate1581(FileBrowser* fileBrowser)
|
||||||
}
|
}
|
||||||
ctBefore = ctAfter;
|
ctBefore = ctAfter;
|
||||||
|
|
||||||
|
#if not defined(EXPERIMENTALZERO)
|
||||||
if (options.SoundOnGPIO() && headSoundCounter > 0)
|
if (options.SoundOnGPIO() && headSoundCounter > 0)
|
||||||
{
|
{
|
||||||
headSoundFreqCounter--; // Continue updating a GPIO non DMA sound.
|
headSoundFreqCounter--; // Continue updating a GPIO non DMA sound.
|
||||||
|
@ -1242,6 +1106,7 @@ EXIT_TYPE Emulate1581(FileBrowser* fileBrowser)
|
||||||
IEC_Bus::OutputSound = !IEC_Bus::OutputSound;
|
IEC_Bus::OutputSound = !IEC_Bus::OutputSound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (numberOfImages > 1)
|
if (numberOfImages > 1)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue