obj/gui.o \
obj/guimisc.o \
obj/menu.o \
+ obj/text.o \
obj/textedit.o \
obj/window.o \
\
uint8 diskRom[0x100]; // Disk ROM space
V65C02REGS mainCPU;
uint8 appleType = APPLE_TYPE_II;
+FloppyDrive floppyDrive;
// Local variables
static uint8 lastKeyPressed = 0;
static bool keyDown = false;
-static FloppyDrive floppyDrive;
+//static FloppyDrive floppyDrive;
enum { LC_BANK_1, LC_BANK_2 };
//
#include "types.h"
+#include "floppy.h"
enum { APPLE_TYPE_II, APPLE_TYPE_IIE, APPLE_TYPE_IIC };
extern uint8 ram[0x10000], rom[0x10000]; // RAM & ROM pointers
extern uint8 appleType;
+extern FloppyDrive floppyDrive;
0x0, 0x7, 0xE, 0x6, 0xD, 0x5, 0xC, 0x4, 0xB, 0x3, 0xA, 0x2, 0x9, 0x1, 0x8, 0xF };
uint8 FloppyDrive::poSector[16] = {
0x0, 0x8, 0x1, 0x9, 0x2, 0xA, 0x3, 0xB, 0x4, 0xC, 0x5, 0xD, 0x6, 0xE, 0x7, 0xF };
+char FloppyDrive::nameBuf[MAX_PATH];
// FloppyDrive class implementation...
}
}
+const char * FloppyDrive::GetImageName(uint8 driveNum/*= 0*/)
+{
+ // Set up a zero-length string for return value
+ nameBuf[0] = 0;
+
+ if (driveNum > 1)
+ {
+ WriteLog("FLOPPY: Attempted to get image name for drive #%u!\n", driveNum);
+ return nameBuf;
+ }
+
+ // Now we attempt to strip out extraneous paths/extensions to get just the filename
+ const char * startOfFile = strrchr(imageName[driveNum], '/');
+ const char * startOfExt = strrchr(imageName[driveNum], '.');
+
+ // If there isn't a path, assume we're starting at the beginning
+ if (startOfFile == NULL)
+ startOfFile = &imageName[driveNum][0];
+ else
+ startOfFile++;
+
+ // If there isn't an extension, assume it's at the terminating NULL
+ if (startOfExt == NULL)
+ startOfExt = &imageName[driveNum][0] + strlen(imageName[driveNum]);
+
+ // Now copy the filename (may copy nothing!)
+ int j = 0;
+
+ for(const char * i=startOfFile; i<startOfExt; i++)
+ nameBuf[j++] = *i;
+
+ nameBuf[j] = 0;
+
+ return nameBuf;
+}
+
+
// Memory mapped I/O functions
/*
bool SaveImageAs(const char * filename, uint8 driveNum = 0);
void CreateBlankImage(uint8 driveNum = 0);
void SwapImages(void);
+ const char * GetImageName(uint8 driveNum = 0);
// I/O functions ($C0Ex accesses)
static uint8 header[21];
static uint8 doSector[16];
static uint8 poSector[16];
+ static char nameBuf[MAX_PATH];
};
#endif // __FLOPPY_H__
#include "menu.h" // Element class methods are pulled in here...
#include "window.h"
#include "button.h"
+#include "text.h"
#include "video.h"
+#include "apple2.h"
// Debug support
//#define DEBUG_MAIN_LOOP
#include "log.h"
//#endif
+/*
+Work flow: Draw floppy drive.
+If disk in drive, MO shows eject graphic, otherwise show load graphic.
+If hit 'new blank image':
+ If disk in drive, ask if want to save if modified
+ else, load it
+
+*/
+
GUI::GUI(SDL_Surface * surface): menuItem(new MenuItems())
{
windowList.push_back(new Window(30, 30, 200, 100));
windowList.push_back(new Window(30, 140, 200, 100));
windowList.push_back(new Button(30, 250, "Click!"));
+ windowList.push_back(new Text(30, 20, floppyDrive.GetImageName(0)));
+ windowList.push_back(new Text(30, 130, floppyDrive.GetImageName(1)));
}
GUI::~GUI()
--- /dev/null
+//
+// Static text class
+//
+// by James L. Hammons
+//
+
+#include "text.h"
+
+#include "guimisc.h"
+
+Text::Text(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/, Element * parent/*= NULL*/):
+ Element(x, y, w, h, parent)
+{
+ fgColor = 0xFF8484FF, bgColor = 0xFF84FF4D;
+}
+
+Text::Text(uint32 x, uint32 y, std::string s, uint32 fg/*= 0xFF8484FF*/, uint32 bg/*= 0xFF84FF4D*/, Element * parent/*= NULL*/):
+ Element(x, y, 0, 0, parent), text(s)
+{
+ fgColor = fg, bgColor = bg;
+}
+
+void Text::Draw(void)
+{
+ if (text.length() > 0)
+// DrawString(screenBuffer, extents.x + offsetX, extents.y + offsetY, false, "%s", text.c_str());
+ DrawStringOpaque(screen, extents.x, extents.y, fgColor, bgColor, "%s", text.c_str());
+}
--- /dev/null
+//
+// Static text class
+//
+// by James L. Hammons
+//
+
+#ifndef __TEXT_H__
+#define __TEXT_H__
+
+#include <string>
+#include "element.h"
+
+class Text: public Element
+{
+ public:
+ Text(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = 0, Element * parent = NULL);
+ Text(uint32 x, uint32 y, std::string s, uint32 fg = 0xFF8484FF, uint32 bg = 0xFF84FF4D, Element * parent = NULL);
+ virtual void HandleKey(SDLKey key) {}
+ virtual void HandleMouseMove(uint32 x, uint32 y) {}
+ virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown) {}
+ virtual void Draw(void);
+ virtual void Notify(Element *) {}
+
+ protected:
+// uint32 fgColor, bgColor;
+ std::string text;
+};
+
+#endif // __TEXT_H__