Beginnings of new GUI

This commit is contained in:
Shamus Hammons 2009-01-30 15:17:27 +00:00
parent 834dd9b03b
commit 2a82c98a26
11 changed files with 112 additions and 23 deletions

View File

@ -24,9 +24,9 @@ autoSaveState = 1
#floppyImage1 = ./disks/bt1_boot.dsk
# Yes
#floppyImage1 = ./disks/bt2_boot.dsk
# No (PRODOS 8 V1.4 - UNABLE TO LOAD ATINIT FILE)
# Yes (but segfaults in the timer routine in the title screen)
floppyImage1 = ./disks/bt3_boot_fixed.dsk
#floppyImage1 = ./disks/Bard's Tale III - The Thief of Fate (Boot) (Disk 1 of 4).dsk
floppyImage2 = ./disks/bt3_character_fixed.dsk
# Yes
#floppyImage1 = ./disks/Sabotage.dsk
# ??? (//c or //e w/128K required)
@ -39,13 +39,17 @@ floppyImage1 = ./disks/bt3_boot_fixed.dsk
#floppyImage1 = ./disks/wolfenstein_dos32.nib
# Yes, keys???
#floppyImage1 = ./disks/MidnightMagic_etc.dsk
# ??? (PRODOS 8 V1.4 - UNABLE TO LOAD ATINIT FILE)
# ??? Loads, then dumps to monitor (This is IIe or IIc only)
#floppyImage1 = ./disks/battle_chess_1.dsk
# Yes
#floppyImage1 = ./disks/MoebiusI-1.dsk
# Yes, but crashes on the attract mode
#floppyImage2 = ./disks/MoebiusI-2.dsk
# Yes, but crashes on the attract mode (does the same in AppleWin)
# Also, has keyboard troubles... no, write problems
#floppyImage1 = ./disks/moebiusiia.dsk
#floppyImage1 = ./disks/MoebiusIIA.dsk
# Yes
#floppyImage2 = ./disks/MoebiusIIB.dsk
# Yes, but segfaults on title screen
#floppyImage1 = ./disks/wind_walker_1.dsk
# Yes
#floppyImage1 = ./disks/dino_eggs.dsk
@ -58,11 +62,13 @@ floppyImage1 = ./disks/bt3_boot_fixed.dsk
# Yes, autoloads!
#floppyImage1 = ./disks/u2prog-patched.dsk
#floppyImage2 = ./disks/u2player-jlh.dsk
# Yes
#floppyImage1 = ./disks/TheHeist.dsk
# OpenGL options: 1 - use OpenGL rendering, 0 - use old style rendering
useOpenGL = 1
useOpenGL = 0
# OpenGL filtering type: 1 - blurry, 0 - sharp

View File

@ -555,7 +555,8 @@ SETALTCH = $C00F ;use alt char set- norm inverse, LC; no Flash (WR-only)
{
//Actually, according to the A2 ref, this should do nothing since a write
//is immediately preceded by a read leaving it in the same state it was...
// keyDown = false;
//But leaving this out seems to fuck up the key handling of some games...
keyDown = false;
}
else if (addr == 0xC050)
{
@ -787,7 +788,7 @@ int main(int /*argc*/, char * /*argv*/[])
//Load up disk image from config file (for now)...
floppyDrive.LoadImage(settings.diskImagePath1, 0);
// floppyDrive.LoadImage(settings.diskImagePath2, 1);
floppyDrive.LoadImage(settings.diskImagePath2, 1);
// floppyDrive.LoadImage("./disks/temp.nib", 1); // Load temp .nib file into second drive...
//Kill the DOS ROM in slot 6 for now...
@ -848,7 +849,8 @@ memcpy(ram + 0xD000, ram + 0xC000, 0x1000);
SoundInit();
SDL_EnableUNICODE(1); // Needed to do key translation shit
gui = new GUI(surface); // Set up the GUI system object...
// gui = new GUI(surface); // Set up the GUI system object...
gui = new GUI(mainSurface); // Set up the GUI system object...
gui->AddMenuTitle("Apple2");
gui->AddMenuItem("Test!", TestWindow/*, hotkey*/);
gui->AddMenuItem("");

View File

@ -500,13 +500,13 @@ fb fb fb -> 15 [1111] -> 15 WHITE
{
uint8 scrByte = ram[lineAddrLoRes[y] + (displayPage2 ? 0x0400 : 0x0000) + x];
uint32 pixel = palette[scrByte & 0x0F];
for(int cy=0; cy<4; cy++)
for(int cx=0; cx<14; cx++)
scrBuffer[((x * 14) + cx) + (((y * 8) + cy) * VIRTUAL_SCREEN_WIDTH)] = pixel;
pixel = palette[scrByte >> 4];
for(int cy=4; cy<8; cy++)
for(int cx=0; cx<14; cx++)
scrBuffer[(x * 14) + (y * VIRTUAL_SCREEN_WIDTH * 8) + cx + (cy * VIRTUAL_SCREEN_WIDTH)] = pixel;
@ -633,7 +633,7 @@ fb fb fb -> 15 [1111] -> 15 WHITE
static void RenderHiRes(uint16 toLine/*= 192*/)
{
// NOTE: Not endian safe. !!! FIX !!!
// NOTE: Not endian safe. !!! FIX !!! [DONE]
#if 0
uint32 pixelOn = (screenType == ST_WHITE_MONO ? 0xFFFFFFFF : 0xFF61FF61);
#else

View File

@ -61,11 +61,16 @@ Element::Element(uint32 x, uint32 y, uint32 w, uint32 h,
extents.h = h;
coverList.push_back(extents);
#if 0
// This *should* allow us to store our colors in an endian safe way... :-/
uint8 * c = (uint8 *)&fgColor;
c[0] = fgR, c[1] = fgG, c[2] = fgB, c[3] = fgA;
c = (uint8 *)&bgColor;
c[0] = bgR, c[1] = bgG, c[2] = bgB, c[3] = bgA;
#else
fgColor = SDL_MapRGBA(screen->format, fgR, fgG, fgB, fgA);
bgColor = SDL_MapRGBA(screen->format, bgR, bgG, bgB, bgA);
#endif
}
Element::~Element()

View File

@ -24,18 +24,26 @@
#include "video.h"
// Debug support
//#define DEBUG_MAIN_LOOP
// New main screen buffering
// This works, but the colors are rendered incorrectly. Also, it seems that there's
// fullscreen blitting still going on--dragging the disk is fast at first but then
// gets painfully slow. Not sure what's going on there.
#define USE_NEW_MAINBUFFERING
//#ifdef DEBUG_MAIN_LOOP
#include "log.h"
//#endif
GUI::GUI(SDL_Surface * mainSurface): menuItem(new MenuItems())
GUI::GUI(SDL_Surface * surface): menuItem(new MenuItems())
{
windowList.push_back(new Menu());
Element::SetScreen(mainSurface);
Element::SetScreen(surface);
// windowList.push_back(new Menu());
// Create drive windows, and config windows here...
}
GUI::~GUI()
@ -91,12 +99,17 @@ void GUI::Run(void)
for(i=windowList.begin(); i!=windowList.end(); i++)
(*i)->Draw();
#ifndef USE_NEW_MAINBUFFERING
RenderScreenBuffer();
#else
FlipMainScreen();
#endif
// Main loop
while (!exitGUI)
{
if (SDL_PollEvent(&event))
// if (SDL_PollEvent(&event))
if (SDL_WaitEvent(&event))
{
#ifdef DEBUG_MAIN_LOOP
WriteLog("An event was found!");
@ -153,7 +166,11 @@ WriteLog(" -- SDL_USEREVENT\n");
//Dirty rectangle is also possible...
else if (event.user.code == SCREEN_REFRESH_NEEDED)
#ifndef USE_NEW_MAINBUFFERING
RenderScreenBuffer();
#else
FlipMainScreen();
#endif
}
else if (event.type == SDL_ACTIVEEVENT)
{
@ -161,7 +178,11 @@ WriteLog(" -- SDL_USEREVENT\n");
if (event.active.state == SDL_APPMOUSEFOCUS)
showMouse = (event.active.gain ? true : false);
#ifndef USE_NEW_MAINBUFFERING
RenderScreenBuffer();
#else
FlipMainScreen();
#endif
}
else if (event.type == SDL_KEYDOWN)
{
@ -399,13 +420,21 @@ else
if (Element::ScreenNeedsRefreshing())
{
#ifndef USE_NEW_MAINBUFFERING
#ifdef DEBUG_MAIN_LOOP
WriteLog("Screen refresh called!\n");
#endif
RenderScreenBuffer();
Element::ScreenWasRefreshed();
#else
FlipMainScreen();
Element::ScreenWasRefreshed();
#endif
}
}
//hm. Works, but slows things way down.
//Now we use WaitEvents() instead. Yay!
//SDL_Delay(10);
}
SDL_EnableKeyRepeat(0, 0);

View File

@ -86,6 +86,12 @@ void DrawStringTrans(SDL_Surface * screen, uint32 x, uint32 y, uint32 color, con
SDL_Rect rect;
rect.x = x, rect.y = y;
//bleh
uint8 r1, g1, b1, a1;
SDL_GetRGBA(color, screen->format, &r1, &g1, &b1, &a1);
color = SDL_MapRGBA(chr->format, r1, g1, b1, a1);
//helb
for(uint32 i=0; i<length; i++)
{
uint8 c = string[i];
@ -135,6 +141,14 @@ void DrawStringOpaque(SDL_Surface * screen, uint32 x, uint32 y, uint32 fg, uint3
SDL_Rect rect;
rect.x = x, rect.y = y;
//bleh (we have to map colors from the HW surface to the SW surface)
uint8 r1, g1, b1, a1;
SDL_GetRGBA(fg, screen->format, &r1, &g1, &b1, &a1);
fg = SDL_MapRGBA(chr->format, r1, g1, b1, a1);
SDL_GetRGBA(bg, screen->format, &r1, &g1, &b1, &a1);
bg = SDL_MapRGBA(chr->format, r1, g1, b1, a1);
//helb
for(uint32 i=0; i<length; i++)
{
uint8 c = string[i];

View File

@ -62,11 +62,17 @@ Menu::Menu(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/,
activatedSave(false), clickedSave(false),
insideSave(0), insidePopupSave(0), menuChosenSave(-1), menuItemChosenSave(-1)
{
#if 0
// This *should* allow us to store our colors in an endian safe way... :-/
// Nope. Only on SW surfaces. With HW, all bets are off. :-(
uint8 * c = (uint8 *)&fgColorHL;
c[0] = fgchR, c[1] = fgchG, c[2] = fgchB, c[3] = fgchA;
c = (uint8 *)&bgColorHL;
c[0] = bgchR, c[1] = bgchG, c[2] = bgchB, c[3] = bgchA;
#else
fgColorHL = SDL_MapRGBA(screen->format, fgchR, fgchG, fgchB, fgchA);
bgColorHL = SDL_MapRGBA(screen->format, bgchR, bgchG, bgchB, bgchA);
#endif
}
Menu::~Menu()

View File

@ -30,7 +30,7 @@
#define SAMPLES_PER_FRAME (SAMPLE_RATE / 60.0)
#define CYCLES_PER_SAMPLE (1024000.0 / SAMPLE_RATE)
#define SOUND_BUFFER_SIZE (8192)
#define AMPLITUDE (32) // -32 - +32 seems to be plenty loud!
//#define AMPLITUDE (16) // -32 - +32 seems to be plenty loud!
// Global variables
@ -46,6 +46,9 @@ static uint32 sampleBase;
static SDL_cond * conditional = NULL;
static SDL_mutex * mutex = NULL;
static SDL_mutex * mutex2 = NULL;
static uint8 ampPtr = 5;
static uint16 amplitude[17] = { 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048,
4096, 8192, 16384, 32768 };
// Private function prototypes
@ -56,8 +59,8 @@ static void SDLSoundCallback(void * userdata, Uint8 * buffer, int length);
//
void SoundInit(void)
{
// To weed out problems for now...
#if 0
// To weed out problems for now...
return;
#endif
@ -126,7 +129,7 @@ static void SDLSoundCallback(void * userdata, Uint8 * buffer, int length)
buffer[i] = soundBuffer[i];
// Fill buffer with last value
memset(buffer + soundBufferPos, (uint8)(speakerState ? AMPLITUDE : -AMPLITUDE), length - soundBufferPos);
memset(buffer + soundBufferPos, (uint8)(speakerState ? amplitude[ampPtr] : -amplitude[ampPtr]), length - soundBufferPos);
soundBufferPos = 0; // Reset soundBufferPos to start of buffer...
sampleBase = 0; // & sampleBase...
//Ick. This should never happen!
@ -215,7 +218,7 @@ WriteLog("--> after spinlock (sampleBase=%u)...\n", sampleBase);
#endif
}
int8 sample = (speakerState ? AMPLITUDE : -AMPLITUDE);
int8 sample = (speakerState ? amplitude[ampPtr] : -amplitude[ampPtr]);
while (soundBufferPos < currentPos)
soundBuffer[soundBufferPos++] = (uint8)sample;

View File

@ -38,6 +38,7 @@ struct Event
void (* timerCallback)(void);
};
//let's try +1... nope.
static Event eventList[EVENT_LIST_SIZE];
static uint32 nextEvent;
@ -98,6 +99,7 @@ double GetTimeToNextEvent(void)
// increasing time, we have to search through the list for the lowest one.
//ALSO: There's a bug here--nextEvent is getting a bogus value/getting clobbered...
// Seems like it's getting clobbered somewhere other than here...
double time = 0;
bool firstTime = true;
@ -125,6 +127,9 @@ double GetTimeToNextEvent(void)
if (time == 0)
WriteLog("TIMING: GetTimeToNextEvent() failed to find next event!\n");
if (nextEvent >= EVENT_LIST_SIZE)
WriteLog("TIMING: GetTimeToNextEvent() has bad nextEvent (=%u)!\n", nextEvent);
return time;
}

View File

@ -40,7 +40,7 @@
SDL_Surface * surface, * mainSurface, * someAlphaSurface;
Uint32 mainSurfaceFlags;
//uint32 scrBuffer[VIRTUAL_SCREEN_WIDTH * VIRTUAL_SCREEN_HEIGHT];
uint32 * scrBuffer = NULL;
uint32 * scrBuffer = NULL, * mainScrBuffer = NULL;
SDL_Joystick * joystick;
//
@ -160,6 +160,8 @@ WriteLog("\n");//*/
scrBuffer = (uint32 *)surface->pixels; // Kludge--And shouldn't have to lock since it's a software surface...
//needed? Dunno. Mebbe an SDL function instead?
// memset(scrBuffer, 0x00, VIRTUAL_SCREEN_WIDTH * VIRTUAL_SCREEN_HEIGHT * sizeof(uint32));
// Set up the mainScrBuffer
mainScrBuffer = (uint32 *)mainSurface->pixels; // May need to lock...
#ifdef TEST_ALPHA_BLENDING
//Here's some code to test alpha blending...
@ -230,6 +232,20 @@ SDL_BlitSurface(someAlphaSurface, NULL, surface, &dstRect);
}
}
// Is this even necessary? (Could call SDL_Flip directly...)
void FlipMainScreen(void)
{
#ifdef TEST_ALPHA_BLENDING
SDL_Rect dstRect = { 100, 100, 30, 30 };
SDL_BlitSurface(someAlphaSurface, NULL, mainSurface, &dstRect);
#endif
if (settings.useOpenGL)
sdlemu_draw_texture(mainSurface, surface, 1/*1=GL_QUADS*/);
else
SDL_Flip(mainSurface);
}
/*
//
// Resize the main SDL screen & scrBuffer

View File

@ -17,6 +17,7 @@ bool InitVideo(void);
void VideoDone(void);
//void RenderBackbuffer(void);
void RenderScreenBuffer(void);
void FlipMainScreen(void);
//void ResizeScreen(uint32 width, uint32 height);
//uint32 GetSDLScreenPitch(void);
//void ToggleFullscreen(void);
@ -25,6 +26,8 @@ void RenderScreenBuffer(void);
//extern uint32 scrBuffer[VIRTUAL_SCREEN_WIDTH * VIRTUAL_SCREEN_HEIGHT];
extern uint32 * scrBuffer;
extern uint32 * mainScrBuffer;
extern SDL_Surface * surface;
extern SDL_Surface * mainSurface;
#endif // __VIDEO_H__