X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fmainwin.cpp;h=d601a4fff48b9758be7e83a3cb98dde15f30aa12;hb=HEAD;hp=4ca0ae1716a2d12e8e8f30638ec3cc42fe6b9633;hpb=7fb379d6be716f3b6c9dd15d604805c8987d7de0;p=wozmaker diff --git a/src/mainwin.cpp b/src/mainwin.cpp index 4ca0ae1..d601a4f 100644 --- a/src/mainwin.cpp +++ b/src/mainwin.cpp @@ -210,8 +210,37 @@ void MainWin::HandleSaveFile(void) void MainWin::HandleSettings(void) { + // Sanity check + if (Global::a2r == NULL) + return; + SettingsDialog dlg(this); + dlg.line[0].setText((char *)GetMetadata("title")); + dlg.line[1].setText((char *)GetMetadata("subtitle")); + dlg.line[2].setText((char *)GetMetadata("publisher")); + dlg.line[3].setText((char *)GetMetadata("developer")); + dlg.line[4].setText((char *)GetMetadata("copyright")); + dlg.line[5].setText((char *)GetMetadata("version")); + dlg.line[6].setText((char *)GetMetadata("notes")); + dlg.line[7].setText((char *)GetMetadata("side_name")); + dlg.line[8].setText((char *)GetMetadata("contributor")); + + uint16_t machBits = GetRequiredMachineBits(); + + dlg.check[0].setChecked(machBits & 0x001 ? true : false); + dlg.check[1].setChecked(machBits & 0x002 ? true : false); + dlg.check[2].setChecked(machBits & 0x004 ? true : false); + dlg.check[3].setChecked(machBits & 0x008 ? true : false); + dlg.check[4].setChecked(machBits & 0x010 ? true : false); + dlg.check[5].setChecked(machBits & 0x020 ? true : false); + dlg.check[6].setChecked(machBits & 0x040 ? true : false); + dlg.check[7].setChecked(machBits & 0x080 ? true : false); + dlg.check[8].setChecked(machBits & 0x100 ? true : false); + dlg.check[9].setChecked(Global::a2r->writeProtected ? true : false); + + dlg.combo[1].setCurrentIndex(GetRequiredRAMIndex()); + if (dlg.exec() == false) return; @@ -221,143 +250,6 @@ void MainWin::HandleSettings(void) void MainWin::AboutWozMaker(void) { - QMessageBox::about(this, tr("About WOZ Maker"), tr("WOZ Maker v1.0.0\n\nWritten by James Hammons\n\nCopyright (C) 2018 Underground Software")); -} - - -#if 0 -bool MainWin::LoadA2R(const QString filename) -{ -/* -Really, this crap should go into fileio.cpp. !!! FIX !!! -*/ - static uint8_t a2rHdr[8] = { 0x41, 0x32, 0x52, 0x32, 0xFF, 0x0A, 0x0D, 0x0A }; - static uint8_t a2rHdr1[8] = { 0x41, 0x32, 0x52, 0x31, 0xFF, 0x0A, 0x0D, 0x0A }; - - if (Global::a2r != NULL) - free(Global::a2r); - - Global::a2r = (A2R *)ReadFile(filename.toUtf8().data(), &Global::a2rSize); - - if (Global::a2r == NULL) - return false; - - // Sanity check, to see if what we asked for is what we got - if (memcmp(Global::a2r->magic1, a2rHdr, 8) != 0) - { - // It's not a v2 A2R file, maybe it's v1? - if (memcmp(Global::a2r->magic1, a2rHdr1, 8) == 0) - { - // Bytes 8-F are usually: 01 00 8D 00 A5 01 00 00 - // First, allocate mem to copy the old version to the new: - uint8_t * oldfile = (uint8_t *)Global::a2r; - uint8_t * newfile = (uint8_t *)malloc(Global::a2rSize + 36); - memcpy(newfile + 52, oldfile + 16, Global::a2rSize - 16); - - // Make sure creator is set correctly (v1 doesn't have it) - memset(Global::a2r->creator, 0x20, 32); - - // Swap in the new file, free the old one - free(Global::a2r); - Global::a2r = (A2R *)newfile; - Global::a2rSize += 36; // Add in the size of the INFO chunk - - // Fix up stuff that's different between v1 and v2 -//printf("A2R Size: %08X\n", Global::a2rSize); -//printf("A2R Stream Size: %08X (preswap)\n", Global::a2r->strmSize); - SwapBytes32((uint8_t *)&Global::a2r->strmSize); -//printf("A2R Stream Size: %08X (postswap)\n", Global::a2r->strmSize); - uint32_t dataSize = Uint32LE(Global::a2r->strmSize); - uint32_t pos = 0; - - while (pos < dataSize) - { - A2RStream * stream = (A2RStream *)(&Global::a2r->data[pos]); - - if (stream->location == 0xFF) - break; - - SwapBytes32(stream->dataLength); - SwapBytes32(stream->estLoopPoint); - pos += 10 + Uint32LE(stream->dataLength); - } - - // Change INFO to META & fix size (if any, dunno if it's optional) - if (Global::a2rSize > (60 + dataSize)) - { - memcpy(&Global::a2r->data[dataSize], "META", 4); - SwapBytes32(&Global::a2r->data[dataSize + 4]); - } - } - else - { - free(Global::a2r); - Global::a2r = NULL; - - QMessageBox::critical(this, "Bad A2R file", "It may have an .a2r extension, but it isn't a valid A2R file."); - - return false; - } - } - - // Setup individual stream pointers - Global::numStreams = 0; - uint8_t * streamPtr = Global::a2r->data; - - while ((*streamPtr != 0xFF) && (Global::numStreams < 800)) - { - Global::stream[Global::numStreams] = (A2RStream *)streamPtr; - streamPtr += 10 + Uint32LE(Global::stream[Global::numStreams]->dataLength); - Global::numStreams++; - } - - // Metadata check - Global::metadata = NULL; - - if (Global::a2rSize > (60 + Uint32LE(Global::a2r->strmSize))) - { - Global::metadata = (A2RMetadata *)((uint8_t *)Global::a2r + (60 + Uint32LE(Global::a2r->strmSize))); - - // Make sure it's plausible metadata - if (memcmp(Global::metadata->metaTag, "META", 4) != 0) - Global::metadata = NULL; - } - - // Unpack TMNG & XTMG streams to simplify analysis - for(uint32_t i=0; icaptureType == 2) - continue; - - // We skip the first timing byte because it can't tell you what the actual time was when the pulse was seen--it's the time between when the *capture* started and the pulse was seen, not the time between the previous pulse and this one! So that first one is discarded since it's worse than useless; it's misleading. - for(uint32_t j=1; jdataLength); j++) - { - uint32_t a = Global::stream[i]->data[j]; - - while ((Global::stream[i]->data[j] == 0xFF) || (a < 24)) - { - j++; - a += Global::stream[i]->data[j]; - } - - Global::wave[i][Global::waveLen[i]] = a; - Global::waveLen[i]++; - } - } - -//ISO-8061 date format -#if 0 - char buf[200]; - time_t t = time(NULL); - tm * tmp = gmtime(&t); - strftime(buf, sizeof(buf), "%FT%TZ", tmp); - printf("Time is: %s\n", buf); -#endif - - return true; + QMessageBox::about(this, tr("About WOZ Maker"), tr("WOZ Maker v1.0.0\n\nWritten by James Hammons\n\nCopyright (C) 2019 Underground Software")); } -#endif