maniac_mansion_s1[lucasfilm_1989](ntsc).g64 now works.

This commit is contained in:
Stephen White 2019-04-28 18:02:01 +10:00
parent cf0d4e11dd
commit 79c4d83bdb
3 changed files with 39 additions and 3 deletions

View file

@ -30,6 +30,8 @@ extern "C"
#include "rpi-gpio.h" #include "rpi-gpio.h"
} }
extern u32 HashBuffer(const void* pBuffer, u32 length);
unsigned char DiskImage::readBuffer[READBUFFER_SIZE]; unsigned char DiskImage::readBuffer[READBUFFER_SIZE];
static unsigned char compressionBuffer[HALF_TRACK_COUNT * MAX_TRACK_LENGTH]; static unsigned char compressionBuffer[HALF_TRACK_COUNT * MAX_TRACK_LENGTH];
@ -144,6 +146,7 @@ void DiskImage::Close()
memset(trackLengths, 0, sizeof(trackLengths)); memset(trackLengths, 0, sizeof(trackLengths));
diskType = NONE; diskType = NONE;
fileInfo = 0; fileInfo = 0;
hash = 0;
} }
void DiskImage::DumpTrack(unsigned track) void DiskImage::DumpTrack(unsigned track)
@ -762,7 +765,9 @@ bool DiskImage::OpenG64(const FILINFO* fileInfo, unsigned char* diskImage, unsig
if (memcmp(diskImage, "GCR-1541", 8) == 0) if (memcmp(diskImage, "GCR-1541", 8) == 0)
{ {
//DEBUG_LOG("Is G64\r\n"); hash = HashBuffer(diskImage, size);
//DEBUG_LOG("Is G64 %08x\r\n", hash);
unsigned char numTracks = diskImage[9]; unsigned char numTracks = diskImage[9];
//DEBUG_LOG("numTracks = %d\r\n", numTracks); //DEBUG_LOG("numTracks = %d\r\n", numTracks);

View file

@ -167,6 +167,8 @@ public:
bool WriteD64(char* name = 0); bool WriteD64(char* name = 0);
bool WriteG64(char* name = 0); bool WriteG64(char* name = 0);
unsigned GetHash() const { return hash; }
private: private:
void CloseD64(); void CloseD64();
void CloseG64(); void CloseG64();
@ -204,6 +206,7 @@ private:
unsigned attachedImageSize; unsigned attachedImageSize;
DiskType diskType; DiskType diskType;
const FILINFO* fileInfo; const FILINFO* fileInfo;
unsigned hash;
unsigned short trackLengths[HALF_TRACK_COUNT]; unsigned short trackLengths[HALF_TRACK_COUNT];
union union

View file

@ -580,6 +580,24 @@ static bool Snoop(u8 a)
return false; return false;
} }
//--------------------------------------------------------------------------------------
// This is an implementation of FNV-1a
// (http://www.isthe.com/chongo/tech/comp/fnv/)
//--------------------------------------------------------------------------------------
u32 HashBuffer(const void* pBuffer, u32 length)
{
u8* pu8Buffer = (u8*)pBuffer;
u32 hash = 0x811c9dc5U;
while (length)
{
hash ^= *pu8Buffer++;
hash *= 16777619U;
--length;
}
return hash;
}
EmulatingMode BeginEmulating(FileBrowser* fileBrowser, const char* filenameForIcon) EmulatingMode BeginEmulating(FileBrowser* fileBrowser, const char* filenameForIcon)
{ {
DiskImage* diskImage = diskCaddy.SelectFirstImage(); DiskImage* diskImage = diskCaddy.SelectFirstImage();
@ -679,7 +697,7 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser)
const int headSoundFreq = 1000000 / options.SoundOnGPIOFreq(); // 1200Hz = 1/1200 * 10^6; const int headSoundFreq = 1000000 / options.SoundOnGPIOFreq(); // 1200Hz = 1/1200 * 10^6;
unsigned char oldHeadDir; unsigned char oldHeadDir;
int resetCount = 0; int resetCount = 0;
bool refreshOutsAfterCPUStep = true;
unsigned numberOfImages = diskCaddy.GetNumberOfImages(); unsigned numberOfImages = diskCaddy.GetNumberOfImages();
unsigned numberOfImagesMax = numberOfImages; unsigned numberOfImagesMax = numberOfImages;
if (numberOfImagesMax > 10) if (numberOfImagesMax > 10)
@ -707,6 +725,14 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser)
//resetWhileEmulating = false; //resetWhileEmulating = false;
selectedViaIECCommands = false; selectedViaIECCommands = false;
u32 hash = pi1541.drive.GetDiskImage()->GetHash();
// 0x42c02586 = maniac_mansion_s1[lucasfilm_1989](ntsc).g64
// 0x18651422 = aliens[electric_dreams_1987].g64
if (hash == 0x42c02586 || hash == 0x18651422)
{
refreshOutsAfterCPUStep = false;
}
while (exitReason == EXIT_UNKNOWN) while (exitReason == EXIT_UNKNOWN)
{ {
@ -738,7 +764,9 @@ EXIT_TYPE Emulate1541(FileBrowser* fileBrowser)
//read32(ARM_SYSTIMER_CLO); //read32(ARM_SYSTIMER_CLO);
//read32(ARM_SYSTIMER_CLO); //read32(ARM_SYSTIMER_CLO);
IEC_Bus::RefreshOuts1541(); // Now output all outputs. // IEC_Bus::ReadEmulationMode1541();
if (refreshOutsAfterCPUStep)
IEC_Bus::RefreshOuts1541(); // Now output all outputs.
IEC_Bus::OutputLED = pi1541.drive.IsLEDOn(); IEC_Bus::OutputLED = pi1541.drive.IsLEDOn();
if (IEC_Bus::OutputLED ^ oldLED) if (IEC_Bus::OutputLED ^ oldLED)