robmcmullen-apple2/src/gui/diskselector.cpp

787 lines
18 KiB
C++
Raw Normal View History

2013-12-17 01:27:51 +00:00
//
// diskselector.cpp
//
// Floppy disk selector GUI
// by James Hammons
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
// © 2014-2018 Underground Software
2013-12-17 01:27:51 +00:00
//
// JLH = James Hammons <jlhamm@acm.org>
//
// WHO WHEN WHAT
2017-06-02 02:42:15 +00:00
// --- ---------- -----------------------------------------------------------
2013-12-17 01:27:51 +00:00
// JLH 10/13/2013 Created this file
//
// STILL TO DO:
//
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
// - Fix bug where hovering on scroll image causes it to fly across the screen
// [DONE]
2013-12-17 01:27:51 +00:00
//
#include "diskselector.h"
#include <dirent.h>
#include <algorithm>
#include <string>
#include <vector>
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
#include "crc32.h"
#include "fileio.h"
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
#include "floppydrive.h"
#include "font10pt.h"
#include "gui.h"
2013-12-17 01:27:51 +00:00
#include "log.h"
#include "settings.h"
#include "video.h"
// Icons, in GIMP "C" format
#include "gfx/scroll-left.c"
#include "gfx/scroll-right.c"
struct Bitmap {
unsigned int width;
unsigned int height;
unsigned int bytesPerPixel; // 3:RGB, 4:RGBA
unsigned char pixelData[];
};
enum { DSS_SHOWING, DSS_HIDING, DSS_SHOWN, DSS_HIDDEN, DSS_LSB_SHOWING, DSS_LSB_SHOWN, DSS_LSB_HIDING, DSS_RSB_SHOWING, DSS_RSB_SHOWN, DSS_RSB_HIDING, DSS_TEXT_SCROLLING };
#define DS_WIDTH 402
#define DS_HEIGHT 322
#define SCROLL_HOT_WIDTH 48
#define DS_XPOS ((VIRTUAL_SCREEN_WIDTH - DS_WIDTH) / 2)
#define DS_YPOS ((VIRTUAL_SCREEN_HEIGHT - DS_HEIGHT) / 2)
static bool entered = false;
static int driveNumber;
static int diskSelectorState = DSS_HIDDEN;
static int diskSelected = -1;
static int lastDiskSelected = -1;
static int numColumns;
static int colStart = 0;
static int dxLeft = 0;
static int dxRight = 0;
static int rsbPos = DS_WIDTH;
static int lsbPos = -40;
static int textScrollCount = 0;
static bool refresh = false;
/*
So, how this will work for multiple columns, where the number of columns is greater than 3, is to have an arrow button pop up on the left or right hand side (putting the mouse on the left or right side of the disk selector activates (shows) the button, if such a move can be made. Button hides when the mouse moves out of the hot zone or when it has no more effect.
*/
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
// We make provision for sets of 32 or less...
/*
The way the manifests are laid out, we make the assumption that the boot disk of a set is always listed first. Therefore, image[0] will always be the boot disk.
*/
struct DiskSet
{
uint8_t num; // # of disks in this set
std::string name; // The name of this disk set
// std::string fullPath; // The path to the containing folder
std::string image[32]; // List of disk images in this set
std::string imgName[32];// List of human readable names of disk images
uint32_t crc[32]; // List of CRC32s of the disk images in the set
uint32_t crcFound[32]; // List of CRC32s actually discovered on filesystem
DiskSet(): num(0) {}
};
2013-12-17 01:27:51 +00:00
//
// Struct to hold filenames & full paths to same
2013-12-17 01:27:51 +00:00
//
struct FileStruct
2013-12-17 01:27:51 +00:00
{
std::string image;
std::string fullPath;
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
DiskSet diskSet;
// FileStruct(): diskSet(NULL) {}
// ~FileStruct() { if (diskSet != NULL) delete diskSet; }
// Functor, to presumably make the std::sort go faster
bool operator()(const FileStruct & a, const FileStruct & b) const
2013-12-17 01:27:51 +00:00
{
return (strcasecmp(a.image.c_str(), b.image.c_str()) < 0 ? true : false);
2013-12-17 01:27:51 +00:00
}
};
static SDL_Texture * window = NULL;
static uint32_t windowPixels[DS_WIDTH * DS_HEIGHT];
SDL_Texture * scrollLeftIcon = NULL;
SDL_Texture * scrollRightIcon = NULL;
2013-12-17 01:27:51 +00:00
bool DiskSelector::showWindow = false;
std::vector<FileStruct> fsList;
std::vector<FileStruct> hdList;
2013-12-17 01:27:51 +00:00
void DiskSelector::Init(SDL_Renderer * renderer)
{
window = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
SDL_TEXTUREACCESS_TARGET, DS_WIDTH, DS_HEIGHT);
2013-12-17 01:27:51 +00:00
if (!window)
{
WriteLog("GUI (DiskSelector): Could not create window!\n");
return;
}
if (SDL_SetTextureBlendMode(window, SDL_BLENDMODE_BLEND) == -1)
WriteLog("GUI (DiskSelector): Could not set blend mode for window.\n");
scrollLeftIcon = GUI::CreateTexture(renderer, &scroll_left);
scrollRightIcon = GUI::CreateTexture(renderer, &scroll_right);
for(uint32_t i=0; i<DS_WIDTH*DS_HEIGHT; i++)
windowPixels[i] = 0xEF007F00;
2013-12-17 01:27:51 +00:00
SDL_UpdateTexture(window, NULL, windowPixels, DS_WIDTH * sizeof(Uint32));
FindDisks();
FindHardDisks();
2013-12-17 01:27:51 +00:00
DrawFilenames(renderer);
}
//
// Find all disks images top level call
//
void DiskSelector::FindDisks(void)
{
fsList.clear();
FindDisks(settings.disksPath);
std::sort(fsList.begin(), fsList.end(), FileStruct());
// Calculate the number of columns in the file selector...
numColumns = (int)ceilf((float)fsList.size() / 27.0f);
WriteLog("GUI (DiskSelector)::FindDisks(): # of columns is %i (%i files)\n", numColumns, fsList.size());
}
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
/*
OK, so the way that you can determine if a file is a directory in a cross-
platform way is to do an opendir() call on a discovered filename. If it
returns NULL, then it's a regular file and not a directory. Though I think the
Linux method is more elegant. :-P
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
*/
//
// Find all disks images within path (recursive call does depth first search)
//
2013-12-17 01:27:51 +00:00
void DiskSelector::FindDisks(const char * path)
{
DIR * dir = opendir(path);
2013-12-17 01:27:51 +00:00
if (!dir)
{
WriteLog("GUI (DiskSelector)::FindDisks: Could not open directory \"%s\%!\n", path);
2013-12-17 01:27:51 +00:00
return;
}
dirent * ent;
while ((ent = readdir(dir)) != NULL)
{
char buf[0x10000];
sprintf(buf, "%s/%s", path, ent->d_name);
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
// Cross-platform way to test if it's a directory...
DIR * test = opendir(buf);
// if ((ent->d_type == DT_REG) && HasLegalExtension(ent->d_name))
if (test == NULL)
{
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
if (HasLegalExtension(ent->d_name))
{
FileStruct fs;
fs.image = ent->d_name;
fs.fullPath = buf;
fsList.push_back(fs);
}
}
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
// else if (ent->d_type == DT_DIR)
else
{
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
// Make sure we close the thing, since it's a bona-fide dir!
closedir(test);
// Only recurse if the directory is not one of the special ones...
if ((strcmp(ent->d_name, "..") != 0)
&& (strcmp(ent->d_name, ".") != 0))
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
{
// Check to see if this is a special directory with a manifest
char buf2[0x10000];
sprintf(buf2, "%s/manifest.txt", buf);
FILE * fp = fopen(buf2, "r");
// No manifest means it's just a regular directory...
if (fp == NULL)
FindDisks(buf);
else
{
// Read the manifest and all that good stuff
FileStruct fs;
ReadManifest(fp, &fs.diskSet);
fclose(fp);
// Finally, check that the stuff in the manifest is
// actually in the directory...
if (CheckManifest(buf, &fs.diskSet) == true)
{
fs.fullPath = buf;
fs.image = fs.diskSet.name;
fsList.push_back(fs);
}
else
WriteLog("Manifest for '%s' failed check phase.\n", fs.diskSet.name.c_str());
#if 0
printf("Name found: \"%s\" (%d)\nDisks:\n", fs.diskSet.name.c_str(), fs.diskSet.num);
for(int i=0; i<fs.diskSet.num; i++)
printf("%s (CRC: %08X)\n", fs.diskSet.image[i].c_str(), fs.diskSet.crc[i]);
#endif
}
}
}
2013-12-17 01:27:51 +00:00
}
closedir(dir);
}
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
void DiskSelector::ReadManifest(FILE * fp, DiskSet * ds)
{
char line[0x10000];
int disksFound = 0;
int lineNo = 0;
while (!feof(fp))
{
fgets(line, 0x10000, fp);
lineNo++;
if ((line[0] == '#') || (line[0] == '\n'))
; // Do nothing with comments or blank lines...
else
{
char buf[1024];
char crcbuf[16];
char altName[1024];
if (strncmp(line, "diskset", 7) == 0)
{
sscanf(line, "diskset=\"%[^\"]\"", buf);
ds->name = buf;
}
else if (strncmp(line, "disks", 5) == 0)
{
sscanf(line, "disks=%hhd", &ds->num);
}
else if (strncmp(line, "disk", 4) == 0)
{
int n = sscanf(line, "disk=%s %s (%s)", buf, crcbuf, altName);
if ((n == 2) || (n == 3))
{
ds->image[disksFound] = buf;
ds->crc[disksFound] = strtoul(crcbuf, NULL, 16);
disksFound++;
if (n == 3)
ds->imgName[disksFound] = altName;
else
{
// Find the file's extension, if any
char * ext = strrchr(buf, '.');
// Kill the disk extension, if it exists
if (ext != NULL)
*ext = 0;
ds->imgName[disksFound] = buf;
}
}
else
WriteLog("Malformed disk descriptor in manifest at line %d\n", lineNo);
}
}
}
if (disksFound != ds->num)
WriteLog("Found only %d entries in manifest, expected %hhd\n", disksFound, ds->num);
}
bool DiskSelector::CheckManifest(const char * path, DiskSet * ds)
{
uint8_t found = 0;
for(int i=0; i<ds->num; i++)
{
std::string filename = path;
filename += "/";
filename += ds->image[i];
uint32_t size;
uint8_t * buf = ReadFile(filename.c_str(), &size);
if (buf != NULL)
{
ds->crcFound[i] = CRC32(buf, size);
free(buf);
found++;
if (ds->crc[i] != ds->crcFound[i])
{
WriteLog("Warning: Bad CRC32 for '%s'. Expected: %08X, found: %08X\n", ds->image[i], ds->crc[i], ds->crcFound[i]);
}
}
}
return (found == ds->num ? true : false);
}
2013-12-17 01:27:51 +00:00
bool DiskSelector::HasLegalExtension(const char * name)
{
// Find the file's extension, if any
2013-12-17 01:27:51 +00:00
const char * ext = strrchr(name, '.');
// No extension, so fuggetaboutit
if (ext == NULL)
return false;
// Otherwise, look for a legal extension
// We should be smarter than this, and look at headers & file sizes instead
if ((strcasecmp(ext, ".dsk") == 0)
|| (strcasecmp(ext, ".do") == 0)
|| (strcasecmp(ext, ".po") == 0)
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
|| (strcasecmp(ext, ".woz") == 0))
2013-12-17 01:27:51 +00:00
return true;
return false;
}
//
// Find all disks images top level call
//
void DiskSelector::FindHardDisks(void)
{
hdList.clear();
FindHardDisks(settings.disksPath);
std::sort(hdList.begin(), hdList.end(), FileStruct());
WriteLog("GUI (DiskSelector)::FindHardDisks(): # of HDs is %i\n", hdList.size());
}
//
// Find all hard disk images within path (recursive call does depth first search)
//
void DiskSelector::FindHardDisks(const char * path)
{
DIR * dir = opendir(path);
if (!dir)
{
WriteLog("GUI (DiskSelector)::FindHardDisks: Could not open directory \"%s\%!\n", path);
return;
}
dirent * ent;
while ((ent = readdir(dir)) != NULL)
{
char buf[0x10000];
sprintf(buf, "%s/%s", path, ent->d_name);
// Cross-platform way to test if it's a directory (test = NULL -> file)
DIR * test = opendir(buf);
if (test == NULL)
{
const char * ext = strrchr(ent->d_name, '.');
if ((ext != NULL)
&& ((strcasecmp(ext, ".2mg") == 0)
|| (strcasecmp(ext, ".hdv") == 0)))
{
FileStruct fs;
fs.image = ent->d_name;
fs.fullPath = buf;
hdList.push_back(fs);
}
}
else
{
// Make sure we close the thing, since it's a bona-fide dir!
closedir(test);
// Only recurse if the directory is not one of the special ones...
if ((strcmp(ent->d_name, "..") != 0)
&& (strcmp(ent->d_name, ".") != 0))
{
FindHardDisks(buf);
}
}
}
closedir(dir);
}
2013-12-17 01:27:51 +00:00
void DiskSelector::DrawFilenames(SDL_Renderer * renderer)
{
if (SDL_SetRenderTarget(renderer, window) < 0)
{
WriteLog("GUI: Could not set Render Target to overlay... (%s)\n", SDL_GetError());
return;
}
// 3 columns of 16 chars apiece (with 8X16 font), 18 rows
// 3 columns of 18 chars apiece (with 7X12 font), 24 rows
// 3 columns of 21 chars apiece (with 6X11 font), 27 rows
2013-12-17 01:27:51 +00:00
unsigned int count = 0;
unsigned int fsStart = colStart * 27;
int offset = 0;
// Draw partial columns (for scrolling left/right)
// [could probably combine these...]
if (textScrollCount < 0)
{
int partialColStart = (colStart - 1) * 27;
offset = -1 * textScrollCount;
2013-12-17 01:27:51 +00:00
for(unsigned int y=0; y<27; y++)
{
for(unsigned int i=22+textScrollCount, x=0; i<21; i++, x++)
{
if (i >= fsList[partialColStart + y].image.length())
break;
GUI::DrawCharacter(renderer, x + 1, y + 1, fsList[partialColStart + y].image[i], false);
}
}
}
else if (textScrollCount > 0)
{
offset = 22 - textScrollCount;
for(unsigned int y=0; y<27; y++)
{
for(unsigned int i=textScrollCount, x=0; i<21; i++, x++)
{
if (i >= fsList[fsStart + y].image.length())
break;
GUI::DrawCharacter(renderer, x + 1, y + 1, fsList[fsStart + y].image[i], false);
}
}
fsStart += 27;
}
while (fsStart < fsList.size())
2013-12-17 01:27:51 +00:00
{
// int currentX = (count / 18) * 17;
// int currentY = (count % 18);
// int currentX = (count / 24) * 19;
// int currentY = (count % 24);
int currentX = (count / 27) * 22;
int currentY = (count % 27);
// for(unsigned int i=0; i<16; i++)
// for(unsigned int i=0; i<18; i++)
for(unsigned int i=0; i<21; i++)
2013-12-17 01:27:51 +00:00
{
if (i >= fsList[fsStart].image.length())
2013-12-17 01:27:51 +00:00
break;
bool invert = (diskSelected == (int)fsStart ? true : false);
GUI::DrawCharacter(renderer, currentX + i + 1 + offset, currentY + 1, fsList[fsStart].image[i], invert);
2013-12-17 01:27:51 +00:00
}
count++;
fsStart++;
2013-12-17 01:27:51 +00:00
// if (count >= (18 * 3))
// if (count >= (24 * 3))
if (count >= (27 * 3))
2013-12-17 01:27:51 +00:00
break;
}
// If a disk is selected, show it on the top line in inverse video
if (diskSelected > -1)
{
for(unsigned int i=0; i<65; i++)
{
if (i >= fsList[diskSelected].image.length())
break;
GUI::DrawCharacter(renderer, i + 1, 0, fsList[diskSelected].image[i], true);
}
}
2013-12-17 01:27:51 +00:00
// Set render target back to default
SDL_SetRenderTarget(renderer, NULL);
}
void DiskSelector::ShowWindow(int drive)
{
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
diskSelectorState = DSS_SHOWN;
entered = false;
showWindow = true;
driveNumber = drive;
}
void DiskSelector::HideWindow(void)
{
diskSelectorState = DSS_HIDDEN;
dxLeft = 0;
dxRight = 0;
rsbPos = DS_WIDTH;
lsbPos = -40;
showWindow = false;
refresh = true;
}
2013-12-17 01:27:51 +00:00
void DiskSelector::MouseDown(int32_t x, int32_t y, uint32_t buttons)
{
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
if (!showWindow || !entered)
return;
if ((diskSelectorState == DSS_LSB_SHOWING) || (diskSelectorState == DSS_LSB_SHOWN))
{
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
colStart--;
textScrollCount = 21;
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
if (colStart == 0)
{
diskSelectorState = DSS_LSB_HIDING;
dxLeft = -8;
}
return;
}
if ((diskSelectorState == DSS_RSB_SHOWING) || (diskSelectorState == DSS_RSB_SHOWN))
{
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
colStart++;
textScrollCount = -21;
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
if ((colStart + 3) == numColumns)
{
diskSelectorState = DSS_RSB_HIDING;
dxRight = 8;
}
return;
}
if (diskSelected != -1)
{
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
floppyDrive[0].LoadImage(fsList[diskSelected].fullPath.c_str(), driveNumber);
}
showWindow = false;
2013-12-17 01:27:51 +00:00
}
void DiskSelector::MouseUp(int32_t x, int32_t y, uint32_t buttons)
{
if (!showWindow)
return;
2013-12-17 01:27:51 +00:00
}
void DiskSelector::MouseMove(int32_t x, int32_t y, uint32_t buttons)
{
if (!showWindow)
return;
// Check to see if DS has been hovered yet, and, if so, set a flag to show
// that it has
if (!entered && ((x >= DS_XPOS) && (x <= (DS_XPOS + DS_WIDTH))
&& (y >= DS_YPOS) && (y <= (DS_YPOS + DS_HEIGHT))))
entered = true;
// Check to see if the DS, since being hovered, is now no longer being
// hovered
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
//N.B.: Should probably make like a 1/2 to 1 second timeout to allow for overshooting the edge of the thing, maybe have the window fade out gradually and let it come back if you enter before it leaves...
if (entered && ((x < DS_XPOS) || (x > (DS_XPOS + DS_WIDTH))
|| (y < DS_YPOS) || (y > (DS_YPOS + DS_HEIGHT))))
{
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
diskSelectorState = DSS_HIDDEN;
dxLeft = 0;
dxRight = 0;
rsbPos = DS_WIDTH;
lsbPos = -40;
showWindow = false;
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
refresh = true;
return;
}
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
// Bail out if the DS hasn't been entered yet
if (!entered)
return;
/*
states:
+-----+---------------------+-----+
| | | |
| | | |
+-----+---------------------+-----+
^ ^ ^
| | x is here and state is DSS_SHOWN
| x is here and state is DSS_LSB_SHOWING or DSS_RSB_SHOWING
x is here and state is DSS_SHOWN
*/
if (x < (DS_XPOS + SCROLL_HOT_WIDTH))
{
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
if ((colStart > 0) && (diskSelectorState == DSS_SHOWN))
{
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
diskSelectorState = DSS_LSB_SHOWING;
dxLeft = 8;
}
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
}
else if (x > (DS_XPOS + DS_WIDTH - SCROLL_HOT_WIDTH))
{
if (((colStart + 3) < numColumns) && (diskSelectorState == DSS_SHOWN))
{
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
diskSelectorState = DSS_RSB_SHOWING;
dxRight = -8;
}
}
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
else
{
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
// Handle the excluded middle :-P
if ((diskSelectorState == DSS_LSB_SHOWING)
|| (diskSelectorState == DSS_LSB_SHOWN))
{
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
diskSelectorState = DSS_LSB_HIDING;
dxLeft = -8;
}
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
else if ((diskSelectorState == DSS_RSB_SHOWING)
|| (diskSelectorState == DSS_RSB_SHOWN))
{
Misc. improvements, added WOZ file support to floppy emulation - Refactored old MMU slot code to be more flexible - Moved all Mockingboard related code to its own compilation unit - Refactored old 6522 & AY-3-8910 code into v6522VIA & vAY8910 :-) - Fixed BCD mode for ADC and SBC in v65C02 - Finally fixed text mode characters in both ALTCHARSET and regular modes - Added new floppy disk controller Logic State Sequencer emulation - Fixed v65C02 to be cycle exact (as far as I can tell) - Fixed a bunch of bugs in v65C02 - Dropped NIB support - Added WOZ 1.0 file support That last item is a bit of a big deal, as I had been thinking about writing a new file format that would be bit-based--since the NIB nybble format, while better than pretty much all the other formats out there, fails hard in things like extra sync bits and half tracks. So, somewhat serendipitously, I stumbled upon the Applesauce project and found out that not only had other people been thinking in more or less the same direction, they had created it and had made disk images to try! So now, because of this, WOZ is the internal format used by the floppy emulation (as opposed to NIB) which, along with the new disk Logic State Sequencer emulator, makes it possible to format floppy disks correctly for the first time. :-) One ironic consequence of this is that NIB format can no longer be properly supported. The irony comes from the fact that before there was LSS emulation, NIB was the most accurate format you could get to represent the low level format of a disk, but now, with proper LSS emulation, it's the worst format for representing a floppy disk. And the main reason for this is that NIB doesn't contain sync bits, and has no mechanism to represent them--so when feeding them to the new LSS emulation, they will fail horribly because without sync bits, the bitstream represented by a NIB formatted disk can and will be misinterpreted by the LSS. And since there is now a format that properly represents the bitstream on a floppy disk (WOZ), there's absolutely no reason to keep NIB around or support it anymore. While it was a nice interim format to have around (when the emulation of the disk was "imperfectly perfect"), it now no longer has a place in disk preservation and/or emulation. Another consequence of this new format is that Apple2 only supports writing of WOZ images--it will no longer support writing of DSK and its bretheren. However, since those formats are extremely limited in their scope (they literally only represented the contents of the sectors on a disk) we still support reading them; Apple2 will automagically upconvert them and save them as WOZs (it will use the same filename but substitute "woz" for the old extension). So if you're wondering why your DSKs are unchanged when saving to them, you now know why. :-) Big, big thanks to the Applesauce guys and everyone who contributed and continues to contribute to that project; your efforts are very much appreciated--you guys are awesome!
2019-01-24 02:33:05 +00:00
diskSelectorState = DSS_RSB_HIDING;
dxRight = 8;
}
}
// The -1 terms move the origin to the upper left corner (from 1 in, and 1
// down)
int xChar = ((x - DS_XPOS) / FONT_WIDTH) - 1;
int yChar = ((y - DS_YPOS) / FONT_HEIGHT) - 1;
diskSelected = ((xChar / 22) * 27) + yChar + (colStart * 27);
if ((yChar < 0) || (yChar >= 27)
|| (diskSelected >= (int)fsList.size())
|| (diskSelectorState == DSS_LSB_SHOWING)
|| (diskSelectorState == DSS_LSB_SHOWN)
|| (diskSelectorState == DSS_RSB_SHOWING)
|| (diskSelectorState == DSS_RSB_SHOWN))
diskSelected = -1;
if (diskSelected != lastDiskSelected)
{
HandleSelection(sdlRenderer);
lastDiskSelected = diskSelected;
}
}
void DiskSelector::HandleGUIState(void)
{
lsbPos += dxLeft;
rsbPos += dxRight;
if ((lsbPos > (SCROLL_HOT_WIDTH - 40)) && (diskSelectorState == DSS_LSB_SHOWING))
{
diskSelectorState = DSS_LSB_SHOWN;
lsbPos = SCROLL_HOT_WIDTH - 40;
dxLeft = 0;
}
else if ((lsbPos < -40) && (diskSelectorState == DSS_LSB_HIDING))
{
diskSelectorState = DSS_SHOWN;
lsbPos = -40;
dxLeft = 0;
}
else if ((rsbPos < (DS_WIDTH - SCROLL_HOT_WIDTH)) && (diskSelectorState == DSS_RSB_SHOWING))
{
diskSelectorState = DSS_RSB_SHOWN;
rsbPos = DS_WIDTH - SCROLL_HOT_WIDTH;
dxRight = 0;
}
else if ((rsbPos > DS_WIDTH) && (diskSelectorState == DSS_RSB_HIDING))
{
diskSelectorState = DSS_SHOWN;
rsbPos = DS_WIDTH;
dxRight = 0;
}
if (textScrollCount < 0)
{
textScrollCount += 2;
if (textScrollCount > 0)
{
textScrollCount = 0;
refresh = true;
}
}
else if (textScrollCount > 0)
{
textScrollCount -= 2;
if (textScrollCount < 0)
{
textScrollCount = 0;
refresh = true;
}
}
}
void DiskSelector::HandleSelection(SDL_Renderer * renderer)
{
SDL_UpdateTexture(window, NULL, windowPixels, DS_WIDTH * sizeof(Uint32));
DrawFilenames(renderer);
refresh = false;
2013-12-17 01:27:51 +00:00
}
void DiskSelector::Render(SDL_Renderer * renderer)
{
if (!(window && showWindow))
2013-12-17 01:27:51 +00:00
return;
HandleGUIState();
if (((diskSelectorState != DSS_LSB_SHOWN)
&& (diskSelectorState != DSS_RSB_SHOWN)
&& (diskSelectorState != DSS_SHOWN))
|| (textScrollCount != 0) || refresh)
HandleSelection(renderer);
// Render scroll arrows (need to figure out why no alpha!)
SDL_SetRenderTarget(renderer, window);
SDL_Rect dst2 = { 0, ((DS_HEIGHT - 40) / 2), 40, 40 };
dst2.x = lsbPos;
SDL_RenderCopy(renderer, scrollLeftIcon, NULL, &dst2);
SDL_Rect dst3 = { 0, ((DS_HEIGHT - 40) / 2), 40, 40 };
dst3.x = rsbPos;
SDL_RenderCopy(renderer, scrollRightIcon, NULL, &dst3);
SDL_SetRenderTarget(renderer, NULL);
2017-06-02 02:42:15 +00:00
SDL_Rect dst = { DS_XPOS, DS_YPOS, DS_WIDTH, DS_HEIGHT };
2013-12-17 01:27:51 +00:00
SDL_RenderCopy(renderer, window, NULL, &dst);
}