2007-05-29 02:37:11 +00:00
|
|
|
//
|
2013-10-13 20:22:19 +00:00
|
|
|
// gui.cpp
|
2007-05-29 02:37:11 +00:00
|
|
|
//
|
|
|
|
// Graphical User Interface support
|
2013-09-28 23:15:54 +00:00
|
|
|
// by James Hammons
|
2019-04-17 03:29:58 +00:00
|
|
|
// © 2014-2019 Underground Software
|
2007-05-29 02:37:11 +00:00
|
|
|
//
|
2013-09-28 23:15:54 +00:00
|
|
|
// JLH = James Hammons <jlhamm@acm.org>
|
2007-05-29 02:37:11 +00:00
|
|
|
//
|
|
|
|
// WHO WHEN WHAT
|
2017-06-02 02:42:15 +00:00
|
|
|
// --- ---------- -----------------------------------------------------------
|
2007-05-29 02:37:11 +00:00
|
|
|
// JLH 02/03/2006 Created this file
|
|
|
|
// JLH 03/13/2006 Added functions to allow shutting down GUI externally
|
2007-05-29 05:16:51 +00:00
|
|
|
// JLH 03/22/2006 Finalized basic multiple window support
|
2014-03-25 15:45:09 +00:00
|
|
|
// JLH 03/03/2014 Refactored GUI to use SDL 2, more modern approach as well
|
2007-05-29 02:37:11 +00:00
|
|
|
//
|
2007-05-29 05:16:51 +00:00
|
|
|
// STILL TO DO:
|
2007-05-29 02:37:11 +00:00
|
|
|
//
|
2007-05-29 05:16:51 +00:00
|
|
|
// - Memory leak on quitting with a window active [DONE]
|
|
|
|
// - Multiple window handling [DONE]
|
2007-05-29 02:37:11 +00:00
|
|
|
//
|
|
|
|
|
2014-03-03 16:27:20 +00:00
|
|
|
#include "gui.h"
|
2019-04-17 03:29:58 +00:00
|
|
|
#include <vector>
|
2014-03-03 16:27:20 +00:00
|
|
|
#include "apple2.h"
|
2019-04-17 03:29:58 +00:00
|
|
|
#include "config.h"
|
2014-03-03 16:27:20 +00:00
|
|
|
#include "diskselector.h"
|
2019-04-17 03:29:58 +00:00
|
|
|
#include "elements.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"
|
2019-04-17 03:29:58 +00:00
|
|
|
#include "font10pt.h"
|
2014-03-03 16:27:20 +00:00
|
|
|
#include "log.h"
|
|
|
|
#include "video.h"
|
|
|
|
|
2013-10-09 02:01:09 +00:00
|
|
|
// Icons, in GIMP "C" format
|
2013-10-10 03:21:44 +00:00
|
|
|
#include "gfx/icon-selection.c"
|
2013-10-12 03:13:08 +00:00
|
|
|
#include "gfx/disk-icon.c"
|
2013-10-09 02:01:09 +00:00
|
|
|
#include "gfx/power-off-icon.c"
|
|
|
|
#include "gfx/power-on-icon.c"
|
2013-10-13 20:22:19 +00:00
|
|
|
#include "gfx/disk-swap-icon.c"
|
2013-10-12 03:13:08 +00:00
|
|
|
#include "gfx/disk-door-open.c"
|
|
|
|
#include "gfx/disk-door-closed.c"
|
2013-10-13 20:22:19 +00:00
|
|
|
#include "gfx/save-state-icon.c"
|
|
|
|
#include "gfx/load-state-icon.c"
|
|
|
|
#include "gfx/config-icon.c"
|
2013-10-12 03:13:08 +00:00
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
// Okay, this is ugly but works and I can't think of any better way to handle
|
|
|
|
// this. So what we do when we pass the GIMP bitmaps into a function is pass
|
|
|
|
// them as a (void *) and then cast them as type (Bitmap *) in order to use
|
|
|
|
// them. Yes, it's ugly. Come up with something better!
|
|
|
|
|
|
|
|
struct Bitmap {
|
|
|
|
unsigned int width;
|
|
|
|
unsigned int height;
|
|
|
|
unsigned int bytesPerPixel; // 3:RGB, 4:RGBA
|
|
|
|
unsigned char pixelData[];
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2013-10-12 03:13:08 +00:00
|
|
|
const char numeralOne[(7 * 7) + 1] =
|
|
|
|
" @@ "
|
|
|
|
" @@@ "
|
|
|
|
"@@@@ "
|
|
|
|
" @@ "
|
|
|
|
" @@ "
|
|
|
|
" @@ "
|
|
|
|
"@@@@@@ ";
|
|
|
|
|
|
|
|
const char numeralTwo[(7 * 7) + 1] =
|
|
|
|
" @@@@@ "
|
|
|
|
"@@ @@"
|
|
|
|
" @@@"
|
|
|
|
" @@@@ "
|
|
|
|
" @@@ "
|
|
|
|
"@@ "
|
|
|
|
"@@@@@@@";
|
|
|
|
|
|
|
|
const char ejectIcon[(8 * 7) + 1] =
|
|
|
|
" @@ "
|
|
|
|
" @@@@ "
|
|
|
|
" @@@@@@ "
|
|
|
|
"@@@@@@@@"
|
|
|
|
" "
|
|
|
|
"@@@@@@@@"
|
|
|
|
"@@@@@@@@";
|
|
|
|
|
2019-04-17 03:29:58 +00:00
|
|
|
const char newDiskIcon[(30 * 6) + 1] =
|
|
|
|
"@@ @@ @@@@@ @@ @@ @@ "
|
|
|
|
"@@@ @@ @@ @@ @@ @@@@ "
|
|
|
|
"@@@@ @@ @@@@ @@ @ @@ @@@@@@"
|
|
|
|
"@@ @@@@ @@ @@@@@@@ @@ "
|
|
|
|
"@@ @@@ @@ @@@@@@@ @@@@@ "
|
|
|
|
"@@ @@ @@@@@ @@ @@ @@@@ ";
|
|
|
|
|
2013-10-12 03:13:08 +00:00
|
|
|
const char driveLight[(5 * 5) + 1] =
|
|
|
|
" @@@ "
|
|
|
|
"@@@@@"
|
|
|
|
"@@@@@"
|
|
|
|
"@@@@@"
|
|
|
|
" @@@ ";
|
2013-10-09 02:01:09 +00:00
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
SDL_Texture * GUI::overlay = NULL;
|
|
|
|
SDL_Rect GUI::olDst;
|
|
|
|
int GUI::sidebarState = SBS_HIDDEN;
|
|
|
|
int32_t GUI::dx = 0;
|
|
|
|
int32_t GUI::iconSelected = -1;
|
|
|
|
bool GUI::hasKeyboardFocus = false;
|
2014-03-27 17:46:00 +00:00
|
|
|
bool GUI::powerOnState = true;
|
|
|
|
|
2013-10-10 03:21:44 +00:00
|
|
|
int32_t lastIconSelected = -1;
|
|
|
|
SDL_Texture * iconSelection = NULL;
|
2013-10-12 03:13:08 +00:00
|
|
|
SDL_Texture * diskIcon = NULL;
|
2013-10-09 02:01:09 +00:00
|
|
|
SDL_Texture * disk1Icon = NULL;
|
|
|
|
SDL_Texture * disk2Icon = NULL;
|
|
|
|
SDL_Texture * powerOnIcon = NULL;
|
|
|
|
SDL_Texture * powerOffIcon = NULL;
|
2013-10-13 20:22:19 +00:00
|
|
|
SDL_Texture * diskSwapIcon = NULL;
|
|
|
|
SDL_Texture * stateSaveIcon = NULL;
|
|
|
|
SDL_Texture * stateLoadIcon = NULL;
|
|
|
|
SDL_Texture * configIcon = NULL;
|
2013-10-12 03:13:08 +00:00
|
|
|
SDL_Texture * doorOpen = NULL;
|
|
|
|
SDL_Texture * doorClosed = NULL;
|
2013-10-10 03:21:44 +00:00
|
|
|
uint32_t texturePointer[128 * 380];
|
2013-10-13 20:22:19 +00:00
|
|
|
const char iconHelp[7][80] = { "Turn emulated Apple off/on",
|
|
|
|
"Insert floppy image into drive #1", "Insert floppy image into drive #2",
|
|
|
|
"Swap disks", "Save emulator state", "Load emulator state",
|
|
|
|
"Configure Apple2" };
|
2014-03-26 13:05:47 +00:00
|
|
|
bool disk1EjectHovered = false;
|
|
|
|
bool disk2EjectHovered = false;
|
2019-04-17 03:29:58 +00:00
|
|
|
bool disk1NewDiskHovered = false;
|
|
|
|
bool disk2NewDiskHovered = false;
|
2014-03-26 13:05:47 +00:00
|
|
|
|
2019-04-17 03:29:58 +00:00
|
|
|
SDL_Texture * GUI::charStamp = NULL;
|
|
|
|
uint32_t GUI::stamp[FONT_WIDTH * FONT_HEIGHT];
|
2013-10-13 20:22:19 +00:00
|
|
|
|
|
|
|
#define SIDEBAR_X_POS (VIRTUAL_SCREEN_WIDTH - 80)
|
2013-10-08 21:55:07 +00:00
|
|
|
|
2019-04-17 03:29:58 +00:00
|
|
|
//std::vector<void *> objList;
|
|
|
|
|
2013-10-08 21:55:07 +00:00
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
GUI::GUI(void)
|
2013-10-08 21:55:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
GUI::~GUI(void)
|
2013-10-08 21:55:07 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
void GUI::Init(SDL_Renderer * renderer)
|
2013-10-08 21:55:07 +00:00
|
|
|
{
|
|
|
|
overlay = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
|
2013-10-09 02:01:09 +00:00
|
|
|
SDL_TEXTUREACCESS_TARGET, 128, 380);
|
2019-04-17 03:29:58 +00:00
|
|
|
charStamp = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888,
|
|
|
|
SDL_TEXTUREACCESS_TARGET, FONT_WIDTH, FONT_HEIGHT);
|
2013-10-08 21:55:07 +00:00
|
|
|
|
|
|
|
if (!overlay)
|
|
|
|
{
|
|
|
|
WriteLog("GUI: Could not create overlay!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SDL_SetTextureBlendMode(overlay, SDL_BLENDMODE_BLEND) == -1)
|
|
|
|
WriteLog("GUI: Could not set blend mode for overlay.\n");
|
|
|
|
|
2019-04-17 03:29:58 +00:00
|
|
|
if (SDL_SetTextureBlendMode(charStamp, SDL_BLENDMODE_BLEND) == -1)
|
|
|
|
WriteLog("GUI: Could not set blend mode for charStamp.\n");
|
|
|
|
|
2013-10-09 02:01:09 +00:00
|
|
|
for(uint32_t i=0; i<128*380; i++)
|
2013-10-11 20:10:47 +00:00
|
|
|
texturePointer[i] = 0xB0A000A0;
|
2013-10-08 21:55:07 +00:00
|
|
|
|
|
|
|
SDL_UpdateTexture(overlay, NULL, texturePointer, 128 * sizeof(Uint32));
|
|
|
|
|
|
|
|
olDst.x = VIRTUAL_SCREEN_WIDTH;
|
2013-10-09 02:01:09 +00:00
|
|
|
olDst.y = 2;
|
2013-10-08 21:55:07 +00:00
|
|
|
olDst.w = 128;
|
2013-10-09 02:01:09 +00:00
|
|
|
olDst.h = 380;
|
|
|
|
|
2013-10-13 20:22:19 +00:00
|
|
|
iconSelection = CreateTexture(renderer, &icon_selection);
|
|
|
|
diskIcon = CreateTexture(renderer, &disk_icon);
|
|
|
|
doorOpen = CreateTexture(renderer, &door_open);
|
|
|
|
doorClosed = CreateTexture(renderer, &door_closed);
|
|
|
|
disk1Icon = CreateTexture(renderer, &disk_icon);
|
|
|
|
disk2Icon = CreateTexture(renderer, &disk_icon);
|
|
|
|
powerOffIcon = CreateTexture(renderer, &power_off);
|
|
|
|
powerOnIcon = CreateTexture(renderer, &power_on);
|
|
|
|
diskSwapIcon = CreateTexture(renderer, &disk_swap);
|
|
|
|
stateSaveIcon = CreateTexture(renderer, &save_state);
|
|
|
|
stateLoadIcon = CreateTexture(renderer, &load_state);
|
|
|
|
configIcon = CreateTexture(renderer, &config);
|
2013-10-09 02:01:09 +00:00
|
|
|
|
2013-10-12 03:13:08 +00:00
|
|
|
// Set up drive icons in their current states
|
2013-10-13 20:22:19 +00:00
|
|
|
// AssembleDriveIcon(renderer, 0);
|
|
|
|
// AssembleDriveIcon(renderer, 1);
|
2013-10-12 03:13:08 +00:00
|
|
|
|
2013-10-09 02:01:09 +00:00
|
|
|
if (SDL_SetRenderTarget(renderer, overlay) < 0)
|
|
|
|
{
|
|
|
|
WriteLog("GUI: Could not set Render Target to overlay... (%s)\n", SDL_GetError());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-11 20:10:47 +00:00
|
|
|
DrawSidebarIcons(renderer);
|
2013-10-09 02:01:09 +00:00
|
|
|
// Set render target back to default
|
|
|
|
SDL_SetRenderTarget(renderer, NULL);
|
|
|
|
}
|
2013-10-08 21:55:07 +00:00
|
|
|
|
2013-10-13 20:22:19 +00:00
|
|
|
DiskSelector::Init(renderer);
|
2019-04-17 03:29:58 +00:00
|
|
|
Config::Init(renderer);
|
2013-10-08 21:55:07 +00:00
|
|
|
WriteLog("GUI: Successfully initialized.\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
SDL_Texture * GUI::CreateTexture(SDL_Renderer * renderer, const void * source)
|
2013-10-11 20:10:47 +00:00
|
|
|
{
|
|
|
|
Bitmap * bitmap = (Bitmap *)source;
|
|
|
|
SDL_Texture * texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_ABGR8888,
|
2013-10-12 03:13:08 +00:00
|
|
|
// SDL_TEXTUREACCESS_STATIC, bitmap->width, bitmap->height);
|
|
|
|
SDL_TEXTUREACCESS_TARGET, bitmap->width, bitmap->height);
|
2013-10-11 20:10:47 +00:00
|
|
|
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
|
|
|
SDL_UpdateTexture(texture, NULL, (Uint32 *)bitmap->pixelData,
|
|
|
|
bitmap->width * sizeof(Uint32));
|
|
|
|
|
|
|
|
return texture;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
void GUI::MouseDown(int32_t x, int32_t y, uint32_t buttons)
|
2013-10-08 21:55:07 +00:00
|
|
|
{
|
2014-03-30 18:07:30 +00:00
|
|
|
DiskSelector::MouseDown(x, y, buttons);
|
2019-04-17 03:29:58 +00:00
|
|
|
Config::MouseDown(x, y, buttons);
|
2014-03-30 18:07:30 +00:00
|
|
|
|
2014-03-26 13:05:47 +00:00
|
|
|
if (sidebarState != SBS_SHOWN)
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (iconSelected)
|
|
|
|
{
|
|
|
|
// Power
|
|
|
|
case 0:
|
2014-03-27 17:46:00 +00:00
|
|
|
powerOnState = !powerOnState;
|
|
|
|
SetPowerState();
|
|
|
|
|
|
|
|
if (!powerOnState)
|
|
|
|
SpawnMessage("*** POWER OFF ***");
|
|
|
|
|
2014-03-26 13:05:47 +00:00
|
|
|
break;
|
|
|
|
// Disk #1
|
|
|
|
case 1:
|
|
|
|
SpawnMessage("*** DISK #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
|
|
|
if (disk1EjectHovered && !floppyDrive[0].IsEmpty(0))
|
2014-03-30 18:07:30 +00:00
|
|
|
{
|
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].EjectImage(0);
|
2014-03-30 18:07:30 +00:00
|
|
|
SpawnMessage("*** DISK #1 EJECTED ***");
|
|
|
|
}
|
|
|
|
|
2019-04-17 03:29:58 +00:00
|
|
|
if (!disk1EjectHovered && !disk1NewDiskHovered)
|
2014-03-30 18:07:30 +00:00
|
|
|
{
|
|
|
|
// Load the disk selector
|
2019-04-17 03:29:58 +00:00
|
|
|
Config::HideWindow();
|
2014-03-30 18:07:30 +00:00
|
|
|
DiskSelector::ShowWindow(0);
|
|
|
|
}
|
2014-03-26 13:05:47 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
// Disk #2
|
|
|
|
case 2:
|
|
|
|
SpawnMessage("*** DISK #2 ***");
|
|
|
|
|
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 (disk2EjectHovered && !floppyDrive[0].IsEmpty(1))
|
2014-03-30 18:07:30 +00:00
|
|
|
{
|
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].EjectImage(1);
|
2014-03-30 18:07:30 +00:00
|
|
|
SpawnMessage("*** DISK #2 EJECTED ***");
|
|
|
|
}
|
|
|
|
|
2019-04-17 03:29:58 +00:00
|
|
|
if (!disk2EjectHovered && !disk2NewDiskHovered)
|
2014-03-30 18:07:30 +00:00
|
|
|
{
|
|
|
|
// Load the disk selector
|
2019-04-17 03:29:58 +00:00
|
|
|
Config::HideWindow();
|
2014-03-30 18:07:30 +00:00
|
|
|
DiskSelector::ShowWindow(1);
|
|
|
|
}
|
2014-03-26 13:05:47 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
// Swap disks
|
|
|
|
case 3:
|
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].SwapImages();
|
2014-03-30 18:07:30 +00:00
|
|
|
SpawnMessage("*** DISKS SWAPPED ***");
|
2014-03-26 13:05:47 +00:00
|
|
|
break;
|
|
|
|
// Save state
|
|
|
|
case 4:
|
|
|
|
SpawnMessage("*** SAVE STATE ***");
|
|
|
|
break;
|
|
|
|
// Load state
|
|
|
|
case 5:
|
|
|
|
SpawnMessage("*** LOAD STATE ***");
|
|
|
|
break;
|
|
|
|
// Configuration
|
|
|
|
case 6:
|
|
|
|
SpawnMessage("*** CONFIGURATION ***");
|
2019-04-17 03:29:58 +00:00
|
|
|
// Load the configuration window
|
|
|
|
DiskSelector::HideWindow();
|
|
|
|
Config::ShowWindow();
|
2014-03-26 13:05:47 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-10-08 21:55:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
void GUI::MouseUp(int32_t x, int32_t y, uint32_t buttons)
|
2013-10-08 21:55:07 +00:00
|
|
|
{
|
2014-03-30 18:07:30 +00:00
|
|
|
DiskSelector::MouseUp(x, y, buttons);
|
2019-04-17 03:29:58 +00:00
|
|
|
Config::MouseUp(x, y, buttons);
|
2013-10-08 21:55:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
void GUI::MouseMove(int32_t x, int32_t y, uint32_t buttons)
|
2013-10-08 21:55:07 +00:00
|
|
|
{
|
2014-03-30 18:07:30 +00:00
|
|
|
DiskSelector::MouseMove(x, y, buttons);
|
2019-04-17 03:29:58 +00:00
|
|
|
Config::MouseMove(x, y, buttons);
|
2014-03-30 18:07:30 +00:00
|
|
|
|
2013-10-10 03:21:44 +00:00
|
|
|
if (sidebarState != SBS_SHOWN)
|
2013-10-08 21:55:07 +00:00
|
|
|
{
|
2013-10-10 03:21:44 +00:00
|
|
|
iconSelected = -1;
|
|
|
|
|
2013-10-13 20:22:19 +00:00
|
|
|
if (x > SIDEBAR_X_POS)
|
2013-10-08 21:55:07 +00:00
|
|
|
{
|
|
|
|
//printf("GUI: sidebar showing (x = %i)...\n", x);
|
|
|
|
sidebarState = SBS_SHOWING;
|
|
|
|
dx = -8;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//printf("GUI: sidebar hiding[1] (x = %i)...\n", x);
|
|
|
|
sidebarState = SBS_HIDING;
|
|
|
|
dx = 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-10-13 20:22:19 +00:00
|
|
|
if (x < SIDEBAR_X_POS)
|
2013-10-08 21:55:07 +00:00
|
|
|
{
|
2013-10-11 20:10:47 +00:00
|
|
|
iconSelected = lastIconSelected = -1;
|
2013-10-10 03:21:44 +00:00
|
|
|
HandleIconSelection(sdlRenderer);
|
2013-10-08 21:55:07 +00:00
|
|
|
//printf("GUI: sidebar hiding[2] (x = %i)...\n", x);
|
|
|
|
sidebarState = SBS_HIDING;
|
|
|
|
dx = 8;
|
|
|
|
}
|
2013-10-10 03:21:44 +00:00
|
|
|
// We're in the right zone, and the sidebar is shown, so let's select
|
|
|
|
// something!
|
|
|
|
else
|
|
|
|
{
|
2013-10-11 20:10:47 +00:00
|
|
|
if (y < 4 || y > 383)
|
2013-10-10 03:21:44 +00:00
|
|
|
{
|
|
|
|
iconSelected = -1;
|
|
|
|
}
|
|
|
|
else
|
2013-10-11 20:10:47 +00:00
|
|
|
iconSelected = (y - 4) / 54;
|
2013-10-10 03:21:44 +00:00
|
|
|
|
2014-03-26 13:05:47 +00:00
|
|
|
// It's y+2 because the sidebar sits at (SIDEBAR_X_POS, 2)
|
|
|
|
disk1EjectHovered = ((x >= (SIDEBAR_X_POS + 24 + 29))
|
|
|
|
&& (x < (SIDEBAR_X_POS + 24 + 29 + 8))
|
|
|
|
&& (y >= (63 + 31 + 2))
|
2014-03-26 22:44:47 +00:00
|
|
|
&& (y < (63 + 31 + 2 + 7)) ? true : false);
|
2014-03-26 13:05:47 +00:00
|
|
|
|
|
|
|
disk2EjectHovered = ((x >= (SIDEBAR_X_POS + 24 + 29))
|
|
|
|
&& (x < (SIDEBAR_X_POS + 24 + 29 + 8))
|
|
|
|
&& (y >= (117 + 31 + 2))
|
|
|
|
&& (y < (117 + 31 + 2 + 7)) ? true : false);
|
|
|
|
|
2019-04-17 03:29:58 +00:00
|
|
|
disk1NewDiskHovered = ((x >= (SIDEBAR_X_POS + 24 + 6))
|
|
|
|
&& (x < (SIDEBAR_X_POS + 24 + 6 + 30))
|
|
|
|
&& (y >= (63 + 31 + 2))
|
|
|
|
&& (y < (63 + 31 + 2 + 6)) ? true : false);
|
|
|
|
|
|
|
|
disk2NewDiskHovered = ((x >= (SIDEBAR_X_POS + 24 + 6))
|
|
|
|
&& (x < (SIDEBAR_X_POS + 24 + 6 + 30))
|
|
|
|
&& (y >= (117 + 31 + 2))
|
|
|
|
&& (y < (117 + 31 + 2 + 6)) ? true : false);
|
|
|
|
|
2013-10-10 03:21:44 +00:00
|
|
|
if (iconSelected != lastIconSelected)
|
|
|
|
{
|
|
|
|
HandleIconSelection(sdlRenderer);
|
|
|
|
lastIconSelected = iconSelected;
|
2014-03-28 20:31:42 +00:00
|
|
|
|
|
|
|
if ((iconSelected >= 0) && (iconSelected <= 6))
|
|
|
|
SpawnMessage("%s", iconHelp[iconSelected]);
|
2013-10-13 20:22:19 +00:00
|
|
|
|
|
|
|
// Show what's in the selected drive
|
|
|
|
if (iconSelected >= 1 && iconSelected <= 2)
|
|
|
|
{
|
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 (!floppyDrive[0].IsEmpty(iconSelected - 1))
|
|
|
|
SpawnMessage("\"%s\"", floppyDrive[0].ImageName(iconSelected - 1));
|
2013-10-13 20:22:19 +00:00
|
|
|
}
|
2013-10-10 03:21:44 +00:00
|
|
|
}
|
|
|
|
}
|
2013-10-08 21:55:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-17 03:29:58 +00:00
|
|
|
bool GUI::KeyDown(uint32_t key)
|
|
|
|
{
|
|
|
|
return Config::KeyDown(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
void GUI::HandleIconSelection(SDL_Renderer * renderer)
|
2013-10-08 21:55:07 +00:00
|
|
|
{
|
2013-10-12 03:13:08 +00:00
|
|
|
// Set up drive icons in their current states
|
|
|
|
AssembleDriveIcon(renderer, 0);
|
|
|
|
AssembleDriveIcon(renderer, 1);
|
|
|
|
|
2013-10-10 03:21:44 +00:00
|
|
|
// Reload the background...
|
|
|
|
SDL_UpdateTexture(overlay, NULL, texturePointer, 128 * sizeof(Uint32));
|
|
|
|
|
|
|
|
if (SDL_SetRenderTarget(renderer, overlay) < 0)
|
|
|
|
{
|
|
|
|
WriteLog("GUI: Could not set Render Target to overlay... (%s)\n", SDL_GetError());
|
2013-10-08 21:55:07 +00:00
|
|
|
return;
|
2013-10-10 03:21:44 +00:00
|
|
|
}
|
2013-10-08 21:55:07 +00:00
|
|
|
|
2013-10-11 20:10:47 +00:00
|
|
|
// Draw the icon selector, if an icon is selected
|
2013-10-10 03:21:44 +00:00
|
|
|
if (iconSelected >= 0)
|
|
|
|
{
|
2013-10-11 20:10:47 +00:00
|
|
|
SDL_Rect dst;// = { 54, 54, 24 - 7, 2 };
|
2013-10-12 03:13:08 +00:00
|
|
|
dst.w = dst.h = 54, dst.x = 24 - 7, dst.y = 2 + (iconSelected * 54);
|
2013-10-10 03:21:44 +00:00
|
|
|
SDL_RenderCopy(renderer, iconSelection, NULL, &dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawSidebarIcons(renderer);
|
|
|
|
|
|
|
|
// Set render target back to default
|
|
|
|
SDL_SetRenderTarget(renderer, NULL);
|
2013-10-08 21:55:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
void GUI::AssembleDriveIcon(SDL_Renderer * renderer, int driveNumber)
|
2013-10-12 03:13:08 +00:00
|
|
|
{
|
|
|
|
SDL_Texture * drive[2] = { disk1Icon, disk2Icon };
|
|
|
|
const char * number[2] = { numeralOne, numeralTwo };
|
|
|
|
|
|
|
|
if (SDL_SetRenderTarget(renderer, drive[driveNumber]) < 0)
|
|
|
|
{
|
|
|
|
WriteLog("GUI: Could not set Render Target to overlay... (%s)\n", SDL_GetError());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_RenderClear(renderer);
|
|
|
|
SDL_RenderCopy(renderer, diskIcon, NULL, NULL);
|
|
|
|
|
|
|
|
// Drive door @ (16, 7)
|
|
|
|
SDL_Rect dst;
|
|
|
|
dst.w = 8, dst.h = 10, dst.x = 16, dst.y = 7;
|
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
|
|
|
SDL_RenderCopy(renderer, (floppyDrive[0].IsEmpty(driveNumber) ?
|
2013-10-12 03:13:08 +00:00
|
|
|
doorOpen : doorClosed), NULL, &dst);
|
|
|
|
|
|
|
|
// Numeral @ (30, 20)
|
|
|
|
DrawCharArray(renderer, number[driveNumber], 30, 20, 7, 7, 0xD0, 0xE0, 0xF0);
|
|
|
|
DrawDriveLight(renderer, driveNumber);
|
|
|
|
DrawEjectButton(renderer, driveNumber);
|
2019-04-17 03:29:58 +00:00
|
|
|
DrawNewDiskButton(renderer, driveNumber);
|
2013-10-12 03:13:08 +00:00
|
|
|
|
|
|
|
// Set render target back to default
|
|
|
|
SDL_SetRenderTarget(renderer, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
void GUI::DrawEjectButton(SDL_Renderer * renderer, int driveNumber)
|
2013-10-12 03:13:08 +00:00
|
|
|
{
|
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 (floppyDrive[0].IsEmpty(driveNumber))
|
2013-10-12 03:13:08 +00:00
|
|
|
return;
|
|
|
|
|
2014-03-26 13:05:47 +00:00
|
|
|
uint8_t r = 0x00, g = 0xAA, b = 0x00;
|
|
|
|
|
|
|
|
if ((driveNumber == 0 && disk1EjectHovered)
|
|
|
|
|| (driveNumber == 1 && disk2EjectHovered))
|
|
|
|
r = 0x20, g = 0xFF, b = 0x20;
|
|
|
|
|
|
|
|
DrawCharArray(renderer, ejectIcon, 29, 31, 8, 7, r, g, b);
|
2013-10-12 03:13:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-17 03:29:58 +00:00
|
|
|
void GUI::DrawNewDiskButton(SDL_Renderer * renderer, int driveNumber)
|
|
|
|
{
|
|
|
|
if (!floppyDrive[0].IsEmpty(driveNumber))
|
|
|
|
return;
|
|
|
|
|
|
|
|
uint8_t r = 0x00, g = 0xAA, b = 0x00;
|
|
|
|
|
|
|
|
if ((driveNumber == 0 && disk1NewDiskHovered)
|
|
|
|
|| (driveNumber == 1 && disk2NewDiskHovered))
|
|
|
|
r = 0x20, g = 0xFF, b = 0x20;
|
|
|
|
|
|
|
|
DrawCharArray(renderer, newDiskIcon, 6, 31, 30, 6, r, g, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
void GUI::DrawDriveLight(SDL_Renderer * renderer, int driveNumber)
|
2013-10-12 03:13:08 +00:00
|
|
|
{
|
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
|
|
|
int lightState = floppyDrive[0].DriveLightStatus(driveNumber);
|
2013-10-12 03:13:08 +00:00
|
|
|
int r = 0x77, g = 0x00, b = 0x00;
|
|
|
|
|
|
|
|
if (lightState == DLS_READ)
|
|
|
|
r = 0x20, g = 0xFF, b = 0x20;
|
|
|
|
else if (lightState == DLS_WRITE)
|
|
|
|
r = 0xFF, g = 0x30, b = 0x30;
|
|
|
|
|
|
|
|
// Drive light @ (8, 21)
|
|
|
|
DrawCharArray(renderer, driveLight, 8, 21, 5, 5, r, g, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
void GUI::DrawCharArray(SDL_Renderer * renderer, const char * array, int x,
|
2013-10-12 03:13:08 +00:00
|
|
|
int y, int w, int h, int r, int g, int b)
|
|
|
|
{
|
|
|
|
SDL_SetRenderDrawColor(renderer, r, g, b, 0xFF);
|
|
|
|
|
|
|
|
for(int j=0; j<h; j++)
|
|
|
|
{
|
|
|
|
for(int i=0; i<w; i++)
|
|
|
|
{
|
|
|
|
if (array[(j * w) + i] != ' ')
|
|
|
|
SDL_RenderDrawPoint(renderer, x + i, y + j);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-04-17 03:29:58 +00:00
|
|
|
void GUI::DrawCharacter(SDL_Renderer * renderer, int x, int y, uint8_t c, bool invert/*= false*/)
|
|
|
|
{
|
|
|
|
uint32_t inv = (invert ? 0x000000FF : 0x00000000);
|
|
|
|
uint32_t pixel = 0xFFFFC000; // RRGGBBAA
|
|
|
|
uint8_t * ptr = (uint8_t *)&font10pt[(c - 0x20) * FONT_WIDTH * FONT_HEIGHT];
|
|
|
|
SDL_Rect dst;
|
|
|
|
dst.x = x * FONT_WIDTH, dst.y = y * FONT_HEIGHT, dst.w = FONT_WIDTH, dst.h = FONT_HEIGHT;
|
|
|
|
|
|
|
|
for(int i=0; i<FONT_WIDTH*FONT_HEIGHT; i++)
|
|
|
|
stamp[i] = (pixel | ptr[i]) ^ inv;
|
|
|
|
|
|
|
|
SDL_UpdateTexture(charStamp, NULL, stamp, FONT_WIDTH * sizeof(Uint32));
|
|
|
|
SDL_RenderCopy(renderer, charStamp, NULL, &dst);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// N.B.: This draws a char at an abosulte X/Y position, not on a grid
|
|
|
|
//
|
|
|
|
void GUI::DrawCharacterVert(SDL_Renderer * renderer, int x, int y, uint8_t c, bool invert/*= false*/)
|
|
|
|
{
|
|
|
|
uint32_t inv = (invert ? 0x000000FF : 0x00000000);
|
|
|
|
uint32_t pixel = 0xFFFFC000; // RRGGBBAA
|
|
|
|
uint8_t * ptr = (uint8_t *)&font10pt[(c - 0x20) * FONT_WIDTH * FONT_HEIGHT];
|
|
|
|
SDL_Rect dst;
|
|
|
|
dst.x = x, dst.y = y, dst.w = FONT_WIDTH, dst.h = FONT_HEIGHT;
|
|
|
|
SDL_Point pt = { FONT_WIDTH - 1, FONT_HEIGHT - 1 };
|
|
|
|
|
|
|
|
for(int i=0; i<FONT_WIDTH*FONT_HEIGHT; i++)
|
|
|
|
stamp[i] = (pixel | ptr[i]) ^ inv;
|
|
|
|
|
|
|
|
SDL_SetTextureBlendMode(charStamp, SDL_BLENDMODE_NONE);
|
|
|
|
SDL_UpdateTexture(charStamp, NULL, stamp, FONT_WIDTH * sizeof(Uint32));
|
|
|
|
SDL_RenderCopyEx(renderer, charStamp, NULL, &dst, 270.0, &pt, SDL_FLIP_NONE);
|
|
|
|
SDL_SetTextureBlendMode(charStamp, SDL_BLENDMODE_BLEND);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GUI::DrawString(SDL_Renderer * renderer, int x, int y, const char * s, bool invert/*= false*/)
|
|
|
|
{
|
|
|
|
int len = strlen(s);
|
|
|
|
|
|
|
|
for(int i=0; i<len; i++)
|
|
|
|
DrawCharacter(renderer, x + i, y, s[i], invert);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// N.B.: This draws a char at an abosulte X/Y position, not on a grid
|
|
|
|
//
|
|
|
|
void GUI::DrawStringVert(SDL_Renderer * renderer, int x, int y, const char * s, bool invert/*= false*/)
|
|
|
|
{
|
|
|
|
int len = strlen(s);
|
|
|
|
|
|
|
|
for(int i=0; i<len; i++)
|
|
|
|
DrawCharacterVert(renderer, x, y - (FONT_WIDTH * i), s[i], invert);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GUI::DrawBox(SDL_Renderer * renderer, int x, int y, int w, int h, int r/*= 0x00*/, int g/*= 0xAA*/, int b/*= 0x00*/)
|
|
|
|
{
|
|
|
|
SDL_SetRenderDrawColor(renderer, r, g, b, 0xFF);
|
|
|
|
|
|
|
|
for(int i=0; i<w; i++)
|
|
|
|
{
|
|
|
|
SDL_RenderDrawPoint(renderer, x + i, y);
|
|
|
|
SDL_RenderDrawPoint(renderer, x + i, y + h - 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
for(int i=0; i<h; i++)
|
|
|
|
{
|
|
|
|
SDL_RenderDrawPoint(renderer, x, y + i);
|
|
|
|
SDL_RenderDrawPoint(renderer, x + w - 1, y + i);
|
|
|
|
}
|
|
|
|
|
|
|
|
SDL_SetRenderDrawColor(renderer, 0x00, 0x00, 0x00, 0x00);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
void GUI::HandleGUIState(void)
|
2013-10-08 21:55:07 +00:00
|
|
|
{
|
|
|
|
olDst.x += dx;
|
|
|
|
|
2013-10-13 20:22:19 +00:00
|
|
|
if (olDst.x < SIDEBAR_X_POS && sidebarState == SBS_SHOWING)
|
2013-10-08 21:55:07 +00:00
|
|
|
{
|
2013-10-13 20:22:19 +00:00
|
|
|
olDst.x = SIDEBAR_X_POS;
|
2013-10-08 21:55:07 +00:00
|
|
|
sidebarState = SBS_SHOWN;
|
|
|
|
dx = 0;
|
|
|
|
}
|
|
|
|
else if (olDst.x > VIRTUAL_SCREEN_WIDTH && sidebarState == SBS_HIDING)
|
|
|
|
{
|
|
|
|
olDst.x = VIRTUAL_SCREEN_WIDTH;
|
|
|
|
sidebarState = SBS_HIDDEN;
|
|
|
|
dx = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
void GUI::DrawSidebarIcons(SDL_Renderer * renderer)
|
2013-10-10 03:21:44 +00:00
|
|
|
{
|
2013-10-13 20:22:19 +00:00
|
|
|
SDL_Texture * icons[7] = { powerOnIcon, disk1Icon, disk2Icon, diskSwapIcon,
|
|
|
|
stateSaveIcon, stateLoadIcon, configIcon };
|
2013-10-10 03:21:44 +00:00
|
|
|
|
2014-03-27 17:46:00 +00:00
|
|
|
icons[0] = (powerOnState ? powerOnIcon : powerOffIcon);
|
2017-06-22 03:57:57 +00:00
|
|
|
SDL_Rect dst = { 24, 2 + 7, 40, 40 };
|
2013-10-10 03:21:44 +00:00
|
|
|
|
|
|
|
for(int i=0; i<7; i++)
|
|
|
|
{
|
|
|
|
SDL_RenderCopy(renderer, icons[i], NULL, &dst);
|
|
|
|
dst.y += 54;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-03-25 15:45:09 +00:00
|
|
|
void GUI::Render(SDL_Renderer * renderer)
|
2013-10-10 03:21:44 +00:00
|
|
|
{
|
2019-04-17 03:29:58 +00:00
|
|
|
// Sanity check
|
2013-10-10 03:21:44 +00:00
|
|
|
if (!overlay)
|
|
|
|
return;
|
|
|
|
|
|
|
|
HandleGUIState();
|
2013-10-12 03:13:08 +00:00
|
|
|
|
|
|
|
if (sidebarState != SBS_HIDDEN)
|
|
|
|
HandleIconSelection(renderer);
|
|
|
|
|
2013-10-10 03:21:44 +00:00
|
|
|
SDL_RenderCopy(renderer, overlay, NULL, &olDst);
|
2013-10-13 20:22:19 +00:00
|
|
|
|
|
|
|
// Hmm.
|
|
|
|
DiskSelector::Render(renderer);
|
2019-04-17 03:29:58 +00:00
|
|
|
Config::Render(renderer);
|
2013-10-10 03:21:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-10-08 21:55:07 +00:00
|
|
|
/*
|
|
|
|
GUI Considerations:
|
|
|
|
|
|
|
|
screen is 560 x 384
|
|
|
|
|
|
|
|
cut into 7 pieces give ~54 pix per piece
|
|
|
|
So, let's try 40x40 icons, and see if that's good enough...
|
2013-10-10 03:21:44 +00:00
|
|
|
Selection is 54x54.
|
2013-10-08 21:55:07 +00:00
|
|
|
|
|
|
|
drive proportions: 1.62 : 1
|
|
|
|
|
|
|
|
Icon order:
|
|
|
|
|
|
|
|
+-----+
|
|
|
|
| |
|
|
|
|
|Power|
|
|
|
|
| |
|
|
|
|
+-----+
|
|
|
|
|
|
|
|
+-----+
|
|
|
|
| |
|
|
|
|
|Disk1|
|
|
|
|
| ^| <-- eject button
|
|
|
|
+-----+
|
|
|
|
|
|
|
|
+-----+
|
|
|
|
| |
|
|
|
|
|Disk2|
|
|
|
|
| ^|
|
|
|
|
+-----+
|
|
|
|
|
|
|
|
+-----+
|
|
|
|
| |
|
|
|
|
|Swap |
|
|
|
|
| |
|
|
|
|
+-----+
|
|
|
|
|
|
|
|
+-----+
|
|
|
|
| |
|
|
|
|
|Confg|
|
|
|
|
| |
|
|
|
|
+-----+
|
|
|
|
|
|
|
|
maybe state save/load
|
|
|
|
|
|
|
|
*/
|
|
|
|
|