Commit pandora source code

This commit is contained in:
Chips-fr 2015-05-13 18:47:23 +00:00
parent f10bc4f2bf
commit e86cde6318
276 changed files with 263292 additions and 0 deletions

82
src/od-pandora/config.h Normal file
View file

@ -0,0 +1,82 @@
/*
* UAE - The Un*x Amiga Emulator
*
* User configuration options
*
* Copyright 1995 - 1998 Bernd Schmidt
*/
/*
* Please note: Many things are configurable with command line parameters,
* and you can put anything you can pass on the command line into a
* configuration file ~/.uaerc. Please read the documentation for more
* information.
*
* NOTE NOTE NOTE
* Whenever you change something in this file, you have to "make clean"
* afterwards.
* Don't remove the '#' signs. If you want to enable something, move it out
* of the C comment block, if you want to disable something, move it inside
* the block.
*/
/*
* When USE_COMPILER is defined, a m68k->i386 instruction compiler will be
* used. This is experimental. It has only been tested on a Linux/i386 ELF
* machine, although it might work on other i386 Unices.
* This is supposed to speed up application programs. It will not work very
* well for hardware bangers like games and demos, in fact it will be much
* slower. It can also be slower for some applications and/or benchmarks.
* It needs a lot of tuning. Please let me know your results with this.
* The second define, RELY_ON_LOADSEG_DETECTION, decides how the compiler
* tries to detect self-modifying code. If it is not set, the first bytes
* of every compiled routine are used as checksum before executing the
* routine. If it is set, the UAE filesystem will perform some checks to
* detect whether an executable is being loaded. This is less reliable
* (it won't work if you don't use the harddisk emulation, so don't try to
* use floppies or even the RAM disk), but much faster.
*
* @@@ NOTE: This option is unfortunately broken in this version. Don't
* try to use it. @@@
*
#define USE_COMPILER
#define RELY_ON_LOADSEG_DETECTION
*/
#undef USE_COMPILER
#undef RELY_ON_LOADSEG_DETECTION
/*
* Set USER_PROGRAMS_BEHAVE to 1 or 2 to indicate that you are only running
* non-hardware banging programs which leave all the dirty work to the
* Kickstart. This affects the compiler. Any program that is _not_ in the ROM
* (i.e. everything but the Kickstart) will use faster memory access
* functions.
* There is of course the problem that the Amiga doesn't really distinguish
* between user programs and the kernel. Not all of the OS is in the ROM,
* e.g. the parallel.device is on the disk and gets loaded into RAM at least
* with Kickstart 1.3 (don't know about newer Kickstarts). So you probably
* can't print, and some other stuff may also fail to work.
* A useless option, really, given the way lots of Amiga software is written.
#define USER_PROGRAMS_BEHAVE 0
*/
/***************************************************************************
* Operating system/machine specific options
* Configure these for your CPU. The default settings should work on any
* machine, but may not give optimal performance everywhere.
* (These don't do very much yet, except HAVE_RDTSC
*/
/*
* Define this on PPro's, K6's and maybe other non-x86 CPUs.
#undef MULTIPLICATION_PROFITABLE
*/
/*
* PPros don't like branches. With this option, UAE tries to avoid them in some
* places.
#undef BRANCHES_ARE_EXPENSIVE
*/
#define MUSIC_VOLUME 80

View file

@ -0,0 +1,17 @@
/*
* UAE - The Un*x Amiga Emulator
*
* exec.library multitasking emulation
*
* Copyright 1996 Bernd Schmidt
*/
struct switch_struct {
int dummy;
};
/* Looks weird. I think I had a report once that some compiler chokes if
* the statement is empty. */
#define EXEC_SWITCH_TASKS(run, ready) do { int i = 0; i++; } while(0)
#define EXEC_SETUP_SWS(t) do { int i = 0; i++; } while(0)

View file

@ -0,0 +1,36 @@
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "fsdb.h"
int dos_errno(void)
{
int e = errno;
switch (e) {
case ENOMEM: return ERROR_NO_FREE_STORE;
case EEXIST: return ERROR_OBJECT_EXISTS;
case EACCES: return ERROR_WRITE_PROTECTED;
case ENOENT: return ERROR_OBJECT_NOT_AROUND;
case ENOTDIR: return ERROR_OBJECT_WRONG_TYPE;
case ENOSPC: return ERROR_DISK_IS_FULL;
case EBUSY: return ERROR_OBJECT_IN_USE;
case EISDIR: return ERROR_OBJECT_WRONG_TYPE;
#if defined(ETXTBSY)
case ETXTBSY: return ERROR_OBJECT_IN_USE;
#endif
#if defined(EROFS)
case EROFS: return ERROR_DISK_WRITE_PROTECTED;
#endif
#if defined(ENOTEMPTY)
#if ENOTEMPTY != EEXIST
case ENOTEMPTY: return ERROR_DIRECTORY_NOT_EMPTY;
#endif
#endif
default:
write_log(("Unimplemented error %s\n", strerror(e)));
return ERROR_NOT_IMPLEMENTED;
}
}

33
src/od-pandora/gp2x.h Normal file
View file

@ -0,0 +1,33 @@
#ifndef _GP2X_H
#define _GP2X_H
#define GP2X_BUTTON_Y 0
#define GP2X_BUTTON_A 1
#define GP2X_BUTTON_X 2
#define GP2X_BUTTON_B 3
#define GP2X_BUTTON_R 8
#define GP2X_BUTTON_L 7
#define GP2X_BUTTON_START 5
#define GP2X_BUTTON_SELECT 4
#define GP2X_UP (1<<0)
#define GP2X_UP_LEFT (1<<1)
#define GP2X_LEFT (1<<2)
#define GP2X_DOWN_LEFT (1<<3)
#define GP2X_DOWN (1<<4)
#define GP2X_DOWN_RIGHT (1<<5)
#define GP2X_RIGHT (1<<6)
#define GP2X_UP_RIGHT (1<<7)
#define GP2X_A (1<<12)
#define GP2X_B (1<<13)
#define GP2X_X (1<<15)
#define GP2X_Y (1<<14)
#define GP2X_L (1<<10)
#define GP2X_R (1<<11)
#define GP2X_SELECT (1<<9)
#define GP2X_START (1<<8)
#define GP2X_VOL_UP (1<<16)
#define GP2X_VOL_DOWN (1<<17)
#define GP2X_PUSH (1<<27)
#endif

View file

@ -0,0 +1,352 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeRadioButton.hpp"
#include "UaeDropDown.hpp"
#include "UaeCheckBox.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "memory.h"
#include "uae.h"
#include "autoconf.h"
#include "filesys.h"
#include "gui.h"
#include "target.h"
#include "gui_handling.h"
#define DIALOG_WIDTH 520
#define DIALOG_HEIGHT 242
static const char *harddisk_filter[] = { ".hdf", "\0" };
static bool dialogResult = false;
static bool dialogFinished = false;
static gcn::Window *wndEditFilesysHardfile;
static gcn::Button* cmdOK;
static gcn::Button* cmdCancel;
static gcn::Label *lblDevice;
static gcn::TextField *txtDevice;
static gcn::UaeCheckBox* chkReadWrite;
static gcn::Label *lblBootPri;
static gcn::TextField *txtBootPri;
static gcn::Label *lblPath;
static gcn::TextField *txtPath;
static gcn::Button* cmdPath;
static gcn::Label *lblSurfaces;
static gcn::TextField *txtSurfaces;
static gcn::Label *lblReserved;
static gcn::TextField *txtReserved;
static gcn::Label *lblSectors;
static gcn::TextField *txtSectors;
static gcn::Label *lblBlocksize;
static gcn::TextField *txtBlocksize;
class FilesysHardfileActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if(actionEvent.getSource() == cmdPath)
{
char tmp[MAX_PATH];
strncpy(tmp, txtPath->getText().c_str(), MAX_PATH);
wndEditFilesysHardfile->releaseModalFocus();
if(SelectFile("Select harddisk file", tmp, harddisk_filter))
txtPath->setText(tmp);
wndEditFilesysHardfile->requestModalFocus();
cmdPath->requestFocus();
}
else
{
if (actionEvent.getSource() == cmdOK)
{
if(txtDevice->getText().length() <= 0)
{
// ToDo: Message to user
return;
}
dialogResult = true;
}
dialogFinished = true;
}
}
};
static FilesysHardfileActionListener* filesysHardfileActionListener;
static void InitEditFilesysHardfile(void)
{
wndEditFilesysHardfile = new gcn::Window("Edit");
wndEditFilesysHardfile->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
wndEditFilesysHardfile->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
wndEditFilesysHardfile->setBaseColor(gui_baseCol + 0x202020);
wndEditFilesysHardfile->setCaption("Volume settings");
wndEditFilesysHardfile->setTitleBarHeight(TITLEBAR_HEIGHT);
filesysHardfileActionListener = new FilesysHardfileActionListener();
cmdOK = new gcn::Button("Ok");
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdOK->setBaseColor(gui_baseCol + 0x202020);
cmdOK->setId("hdfOK");
cmdOK->addActionListener(filesysHardfileActionListener);
cmdCancel = new gcn::Button("Cancel");
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
cmdCancel->setId("hdfCancel");
cmdCancel->addActionListener(filesysHardfileActionListener);
lblDevice = new gcn::Label("Device Name:");
lblDevice->setSize(100, LABEL_HEIGHT);
lblDevice->setAlignment(gcn::Graphics::RIGHT);
txtDevice = new gcn::TextField();
txtDevice->setSize(80, TEXTFIELD_HEIGHT);
txtDevice->setId("hdfDev");
chkReadWrite = new gcn::UaeCheckBox("Read/Write", true);
chkReadWrite->setId("hdfRW");
lblBootPri = new gcn::Label("Boot priority:");
lblBootPri->setSize(84, LABEL_HEIGHT);
lblBootPri->setAlignment(gcn::Graphics::RIGHT);
txtBootPri = new gcn::TextField();
txtBootPri->setSize(40, TEXTFIELD_HEIGHT);
txtBootPri->setId("hdfBootPri");
lblSurfaces = new gcn::Label("Surfaces:");
lblSurfaces->setSize(84, LABEL_HEIGHT);
lblSurfaces->setAlignment(gcn::Graphics::RIGHT);
txtSurfaces = new gcn::TextField();
txtSurfaces->setSize(40, TEXTFIELD_HEIGHT);
txtSurfaces->setId("hdfSurface");
lblReserved = new gcn::Label("Reserved:");
lblReserved->setSize(84, LABEL_HEIGHT);
lblReserved->setAlignment(gcn::Graphics::RIGHT);
txtReserved = new gcn::TextField();
txtReserved->setSize(40, TEXTFIELD_HEIGHT);
txtReserved->setId("hdfReserved");
lblSectors = new gcn::Label("Sectors:");
lblSectors->setSize(84, LABEL_HEIGHT);
lblSectors->setAlignment(gcn::Graphics::RIGHT);
txtSectors = new gcn::TextField();
txtSectors->setSize(40, TEXTFIELD_HEIGHT);
txtSectors->setId("hdfSectors");
lblBlocksize = new gcn::Label("Blocksize:");
lblBlocksize->setSize(84, LABEL_HEIGHT);
lblBlocksize->setAlignment(gcn::Graphics::RIGHT);
txtBlocksize = new gcn::TextField();
txtBlocksize->setSize(40, TEXTFIELD_HEIGHT);
txtBlocksize->setId("hdfBlocksize");
lblPath = new gcn::Label("Path:");
lblPath->setSize(100, LABEL_HEIGHT);
lblPath->setAlignment(gcn::Graphics::RIGHT);
txtPath = new gcn::TextField();
txtPath->setSize(338, TEXTFIELD_HEIGHT);
txtPath->setEnabled(false);
cmdPath = new gcn::Button("...");
cmdPath->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdPath->setBaseColor(gui_baseCol + 0x202020);
cmdPath->setId("hdfPath");
cmdPath->addActionListener(filesysHardfileActionListener);
int posY = DISTANCE_BORDER;
wndEditFilesysHardfile->add(lblDevice, DISTANCE_BORDER, posY);
wndEditFilesysHardfile->add(txtDevice, DISTANCE_BORDER + lblDevice->getWidth() + 8, posY);
wndEditFilesysHardfile->add(chkReadWrite, 240, posY);
wndEditFilesysHardfile->add(lblBootPri, 374, posY);
wndEditFilesysHardfile->add(txtBootPri, 374 + lblBootPri->getWidth() + 8, posY);
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
wndEditFilesysHardfile->add(lblPath, DISTANCE_BORDER, posY);
wndEditFilesysHardfile->add(txtPath, DISTANCE_BORDER + lblPath->getWidth() + 8, posY);
wndEditFilesysHardfile->add(cmdPath, wndEditFilesysHardfile->getWidth() - DISTANCE_BORDER - SMALL_BUTTON_WIDTH, posY);
posY += txtPath->getHeight() + DISTANCE_NEXT_Y;
wndEditFilesysHardfile->add(lblSurfaces, DISTANCE_BORDER, posY);
wndEditFilesysHardfile->add(txtSurfaces, DISTANCE_BORDER + lblSurfaces->getWidth() + 8, posY);
wndEditFilesysHardfile->add(lblReserved, 240, posY);
wndEditFilesysHardfile->add(txtReserved, 240 + lblReserved->getWidth() + 8, posY);
posY += txtSurfaces->getHeight() + DISTANCE_NEXT_Y;
wndEditFilesysHardfile->add(lblSectors, DISTANCE_BORDER, posY);
wndEditFilesysHardfile->add(txtSectors, DISTANCE_BORDER + lblSectors->getWidth() + 8, posY);
wndEditFilesysHardfile->add(lblBlocksize, 240, posY);
wndEditFilesysHardfile->add(txtBlocksize, 240 + lblBlocksize->getWidth() + 8, posY);
posY += txtSectors->getHeight() + DISTANCE_NEXT_Y;
wndEditFilesysHardfile->add(cmdOK);
wndEditFilesysHardfile->add(cmdCancel);
gui_top->add(wndEditFilesysHardfile);
txtDevice->requestFocus();
wndEditFilesysHardfile->requestModalFocus();
}
static void ExitEditFilesysHardfile(void)
{
wndEditFilesysHardfile->releaseModalFocus();
gui_top->remove(wndEditFilesysHardfile);
delete lblDevice;
delete txtDevice;
delete chkReadWrite;
delete lblBootPri;
delete txtBootPri;
delete lblPath;
delete txtPath;
delete cmdPath;
delete lblSurfaces;
delete txtSurfaces;
delete lblReserved;
delete txtReserved;
delete lblSectors;
delete txtSectors;
delete lblBlocksize;
delete txtBlocksize;
delete cmdOK;
delete cmdCancel;
delete filesysHardfileActionListener;
delete wndEditFilesysHardfile;
}
static void EditFilesysHardfileLoop(void)
{
while(!dialogFinished)
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
if (event.type == SDL_KEYDOWN)
{
switch(event.key.keysym.sym)
{
case SDLK_ESCAPE:
dialogFinished = true;
break;
case SDLK_UP:
if(HandleNavigation(DIRECTION_UP))
continue; // Don't change value when enter ComboBox -> don't send event to control
break;
case SDLK_DOWN:
if(HandleNavigation(DIRECTION_DOWN))
continue; // Don't change value when enter ComboBox -> don't send event to control
break;
case SDLK_LEFT:
if(HandleNavigation(DIRECTION_LEFT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
case SDLK_RIGHT:
if(HandleNavigation(DIRECTION_RIGHT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
case SDLK_PAGEDOWN:
case SDLK_HOME:
event.key.keysym.sym = SDLK_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
}
}
//-------------------------------------------------
// Send event to guichan-controls
//-------------------------------------------------
gui_input->pushInput(event);
}
// Now we let the Gui object perform its logic.
uae_gui->logic();
// Now we let the Gui object draw itself.
uae_gui->draw();
// Finally we update the screen.
SDL_Flip(gui_screen);
}
}
bool EditFilesysHardfile(int unit_no)
{
char *volname, *devname, *rootdir, *filesys;
int secspertrack, surfaces, cylinders, reserved, blocksize, readonly, bootpri;
uae_u64 size;
const char *failure;
dialogResult = false;
dialogFinished = false;
InitEditFilesysHardfile();
if(unit_no >= 0)
{
char tmp[32];
failure = get_filesys_unit(currprefs.mountinfo, unit_no,
&devname, &volname, &rootdir, &readonly, &secspertrack, &surfaces, &reserved,
&cylinders, &size, &blocksize, &bootpri, &filesys, 0);
txtDevice->setText(devname);
txtPath->setText(rootdir);
chkReadWrite->setSelected(!readonly);
snprintf(tmp, 32, "%d", bootpri);
txtBootPri->setText(tmp);
snprintf(tmp, 32, "%d", surfaces);
txtSurfaces->setText(tmp);
snprintf(tmp, 32, "%d", reserved);
txtReserved->setText(tmp);
snprintf(tmp, 32, "%d", secspertrack);
txtSectors->setText(tmp);
snprintf(tmp, 32, "%d", blocksize);
txtBlocksize->setText(tmp);
}
else
{
txtDevice->setText("");
txtPath->setText(currentDir);
chkReadWrite->setSelected(true);
txtBootPri->setText("0");
txtSurfaces->setText("1");
txtReserved->setText("2");
txtSectors->setText("32");
txtBlocksize->setText("512");
}
EditFilesysHardfileLoop();
ExitEditFilesysHardfile();
if(dialogResult)
{
if(unit_no >= 0)
kill_filesys_unit(currprefs.mountinfo, unit_no);
else
extractPath((char *) txtPath->getText().c_str(), currentDir);
failure = add_filesys_unit(currprefs.mountinfo, (char *) txtDevice->getText().c_str(),
0, (char *) txtPath->getText().c_str(), !chkReadWrite->isSelected(),
atoi(txtSectors->getText().c_str()), atoi(txtSurfaces->getText().c_str()),
atoi(txtReserved->getText().c_str()), atoi(txtBlocksize->getText().c_str()),
atoi(txtBootPri->getText().c_str()), 0, 0);
}
return dialogResult;
}

View file

@ -0,0 +1,303 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeRadioButton.hpp"
#include "UaeDropDown.hpp"
#include "UaeCheckBox.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "memory.h"
#include "uae.h"
#include "autoconf.h"
#include "filesys.h"
#include "gui.h"
#include "target.h"
#include "gui_handling.h"
#define DIALOG_WIDTH 520
#define DIALOG_HEIGHT 202
static bool dialogResult = false;
static bool dialogFinished = false;
static gcn::Window *wndEditFilesysVirtual;
static gcn::Button* cmdOK;
static gcn::Button* cmdCancel;
static gcn::Label *lblDevice;
static gcn::TextField *txtDevice;
static gcn::Label *lblVolume;
static gcn::TextField *txtVolume;
static gcn::Label *lblPath;
static gcn::TextField *txtPath;
static gcn::Button* cmdPath;
static gcn::UaeCheckBox* chkReadWrite;
static gcn::Label *lblBootPri;
static gcn::TextField *txtBootPri;
class FilesysVirtualActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if(actionEvent.getSource() == cmdPath)
{
char tmp[MAX_PATH];
strncpy(tmp, txtPath->getText().c_str(), MAX_PATH);
wndEditFilesysVirtual->releaseModalFocus();
if(SelectFolder("Select folder", tmp))
txtPath->setText(tmp);
wndEditFilesysVirtual->requestModalFocus();
cmdPath->requestFocus();
}
else
{
if (actionEvent.getSource() == cmdOK)
{
if(txtDevice->getText().length() <= 0)
{
// ToDo: Message to user
return;
}
if(txtVolume->getText().length() <= 0)
{
// ToDo: Message to user
return;
}
dialogResult = true;
}
dialogFinished = true;
}
}
};
static FilesysVirtualActionListener* filesysVirtualActionListener;
static void InitEditFilesysVirtual(void)
{
wndEditFilesysVirtual = new gcn::Window("Edit");
wndEditFilesysVirtual->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
wndEditFilesysVirtual->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
wndEditFilesysVirtual->setBaseColor(gui_baseCol + 0x202020);
wndEditFilesysVirtual->setCaption("Volume settings");
wndEditFilesysVirtual->setTitleBarHeight(TITLEBAR_HEIGHT);
filesysVirtualActionListener = new FilesysVirtualActionListener();
cmdOK = new gcn::Button("Ok");
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdOK->setBaseColor(gui_baseCol + 0x202020);
cmdOK->setId("virtOK");
cmdOK->addActionListener(filesysVirtualActionListener);
cmdCancel = new gcn::Button("Cancel");
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
cmdCancel->setId("virtCancel");
cmdCancel->addActionListener(filesysVirtualActionListener);
lblDevice = new gcn::Label("Device Name:");
lblDevice->setSize(100, LABEL_HEIGHT);
lblDevice->setAlignment(gcn::Graphics::RIGHT);
txtDevice = new gcn::TextField();
txtDevice->setSize(80, TEXTFIELD_HEIGHT);
txtDevice->setId("virtDev");
lblVolume = new gcn::Label("Volume Label:");
lblVolume->setSize(100, LABEL_HEIGHT);
lblVolume->setAlignment(gcn::Graphics::RIGHT);
txtVolume = new gcn::TextField();
txtVolume->setSize(80, TEXTFIELD_HEIGHT);
txtVolume->setId("virtVol");
lblPath = new gcn::Label("Path:");
lblPath->setSize(100, LABEL_HEIGHT);
lblPath->setAlignment(gcn::Graphics::RIGHT);
txtPath = new gcn::TextField();
txtPath->setSize(338, TEXTFIELD_HEIGHT);
txtPath->setEnabled(false);
cmdPath = new gcn::Button("...");
cmdPath->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdPath->setBaseColor(gui_baseCol + 0x202020);
cmdPath->setId("virtPath");
cmdPath->addActionListener(filesysVirtualActionListener);
chkReadWrite = new gcn::UaeCheckBox("Read/Write", true);
chkReadWrite->setId("virtRW");
lblBootPri = new gcn::Label("Boot priority:");
lblBootPri->setSize(84, LABEL_HEIGHT);
lblBootPri->setAlignment(gcn::Graphics::RIGHT);
txtBootPri = new gcn::TextField();
txtBootPri->setSize(40, TEXTFIELD_HEIGHT);
txtBootPri->setId("virtBootpri");
int posY = DISTANCE_BORDER;
wndEditFilesysVirtual->add(lblDevice, DISTANCE_BORDER, posY);
wndEditFilesysVirtual->add(txtDevice, DISTANCE_BORDER + lblDevice->getWidth() + 8, posY);
wndEditFilesysVirtual->add(chkReadWrite, 260, posY);
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
wndEditFilesysVirtual->add(lblVolume, DISTANCE_BORDER, posY);
wndEditFilesysVirtual->add(txtVolume, DISTANCE_BORDER + lblDevice->getWidth() + 8, posY);
wndEditFilesysVirtual->add(lblBootPri, 260, posY);
wndEditFilesysVirtual->add(txtBootPri, 260 + lblBootPri->getWidth() + 8, posY);
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
wndEditFilesysVirtual->add(lblPath, DISTANCE_BORDER, posY);
wndEditFilesysVirtual->add(txtPath, DISTANCE_BORDER + lblDevice->getWidth() + 8, posY);
wndEditFilesysVirtual->add(cmdPath, wndEditFilesysVirtual->getWidth() - DISTANCE_BORDER - SMALL_BUTTON_WIDTH, posY);
posY += txtDevice->getHeight() + DISTANCE_NEXT_Y;
wndEditFilesysVirtual->add(cmdOK);
wndEditFilesysVirtual->add(cmdCancel);
gui_top->add(wndEditFilesysVirtual);
txtDevice->requestFocus();
wndEditFilesysVirtual->requestModalFocus();
}
static void ExitEditFilesysVirtual(void)
{
wndEditFilesysVirtual->releaseModalFocus();
gui_top->remove(wndEditFilesysVirtual);
delete lblDevice;
delete txtDevice;
delete lblVolume;
delete txtVolume;
delete lblPath;
delete txtPath;
delete cmdPath;
delete chkReadWrite;
delete lblBootPri;
delete txtBootPri;
delete cmdOK;
delete cmdCancel;
delete filesysVirtualActionListener;
delete wndEditFilesysVirtual;
}
static void EditFilesysVirtualLoop(void)
{
while(!dialogFinished)
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
if (event.type == SDL_KEYDOWN)
{
switch(event.key.keysym.sym)
{
case SDLK_ESCAPE:
dialogFinished = true;
break;
case SDLK_UP:
if(HandleNavigation(DIRECTION_UP))
continue; // Don't change value when enter ComboBox -> don't send event to control
break;
case SDLK_DOWN:
if(HandleNavigation(DIRECTION_DOWN))
continue; // Don't change value when enter ComboBox -> don't send event to control
break;
case SDLK_LEFT:
if(HandleNavigation(DIRECTION_LEFT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
case SDLK_RIGHT:
if(HandleNavigation(DIRECTION_RIGHT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
case SDLK_PAGEDOWN:
case SDLK_HOME:
event.key.keysym.sym = SDLK_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
}
}
//-------------------------------------------------
// Send event to guichan-controls
//-------------------------------------------------
gui_input->pushInput(event);
}
// Now we let the Gui object perform its logic.
uae_gui->logic();
// Now we let the Gui object draw itself.
uae_gui->draw();
// Finally we update the screen.
SDL_Flip(gui_screen);
}
}
bool EditFilesysVirtual(int unit_no)
{
char *volname, *devname, *rootdir, *filesys;
int secspertrack, surfaces, cylinders, reserved, blocksize, readonly, bootpri;
uae_u64 size;
const char *failure;
dialogResult = false;
dialogFinished = false;
InitEditFilesysVirtual();
if(unit_no >= 0)
{
char tmp[32];
failure = get_filesys_unit(currprefs.mountinfo, unit_no,
&devname, &volname, &rootdir, &readonly, &secspertrack, &surfaces, &reserved,
&cylinders, &size, &blocksize, &bootpri, &filesys, 0);
txtDevice->setText(devname);
txtVolume->setText(volname);
txtPath->setText(rootdir);
chkReadWrite->setSelected(!readonly);
snprintf(tmp, 32, "%d", bootpri);
txtBootPri->setText(tmp);
}
else
{
txtDevice->setText("");
txtVolume->setText("");
txtPath->setText(currentDir);
chkReadWrite->setSelected(true);
txtBootPri->setText("0");
}
EditFilesysVirtualLoop();
ExitEditFilesysVirtual();
if(dialogResult)
{
if(unit_no >= 0)
kill_filesys_unit(currprefs.mountinfo, unit_no);
else
extractPath((char *) txtPath->getText().c_str(), currentDir);
failure = add_filesys_unit(currprefs.mountinfo, (char *) txtDevice->getText().c_str(),
(char *) txtVolume->getText().c_str(), (char *) txtPath->getText().c_str(),
!chkReadWrite->isSelected(), 0, 0, 0, 0, atoi(txtBootPri->getText().c_str()), 0, 0);
}
return dialogResult;
}

View file

@ -0,0 +1,142 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "uae.h"
#include "gui.h"
#include "target.h"
#include "gui_handling.h"
extern SDL_Surface *prSDLScreen;
static int msg_done = 0;
class DoneActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
msg_done = 1;
}
};
static DoneActionListener* doneActionListener;
void InGameMessage(const char *msg)
{
gcn::Gui* msg_gui;
gcn::SDLGraphics* msg_graphics;
gcn::SDLInput* msg_input;
gcn::contrib::SDLTrueTypeFont* msg_font;
gcn::Color msg_baseCol;
gcn::Container* msg_top;
gcn::Window *wndMsg;
gcn::Button* cmdDone;
gcn::TextBox* txtMsg;
int msgWidth = 260;
int msgHeight = 100;
msg_graphics = new gcn::SDLGraphics();
msg_graphics->setTarget(prSDLScreen);
msg_input = new gcn::SDLInput();
msg_gui = new gcn::Gui();
msg_gui->setGraphics(msg_graphics);
msg_gui->setInput(msg_input);
msg_baseCol.r = 192;
msg_baseCol.g = 192;
msg_baseCol.b = 208;
msg_top = new gcn::Container();
msg_top->setDimension(gcn::Rectangle((prSDLScreen->w - msgWidth) / 2, (prSDLScreen->h - msgHeight) / 2, msgWidth, msgHeight));
msg_top->setBaseColor(msg_baseCol);
msg_gui->setTop(msg_top);
TTF_Init();
msg_font = new gcn::contrib::SDLTrueTypeFont("data/FreeSans.ttf", 10);
gcn::Widget::setGlobalFont(msg_font);
doneActionListener = new DoneActionListener();
wndMsg = new gcn::Window("Load");
wndMsg->setSize(msgWidth, msgHeight);
wndMsg->setPosition(0, 0);
wndMsg->setBaseColor(msg_baseCol + 0x202020);
wndMsg->setCaption("Information");
wndMsg->setTitleBarHeight(12);
cmdDone = new gcn::Button("Ok");
cmdDone->setSize(40, 20);
cmdDone->setBaseColor(msg_baseCol + 0x202020);
cmdDone->addActionListener(doneActionListener);
txtMsg = new gcn::TextBox(msg);
txtMsg->setEnabled(false);
txtMsg->setPosition(6, 6);
txtMsg->setSize(wndMsg->getWidth() - 16, 46);
txtMsg->setOpaque(false);
wndMsg->add(txtMsg, 6, 6);
wndMsg->add(cmdDone, (wndMsg->getWidth() - cmdDone->getWidth()) / 2, wndMsg->getHeight() - 38);
msg_top->add(wndMsg);
cmdDone->requestFocus();
msg_done = 0;
while(!msg_done)
{
//-------------------------------------------------
// Check user input
//-------------------------------------------------
SDL_Event event;
while(SDL_PollEvent(&event))
{
if (event.type == SDL_KEYDOWN)
{
switch(event.key.keysym.sym)
{
case SDLK_PAGEDOWN:
case SDLK_HOME:
case SDLK_RETURN:
msg_done = 1;
break;
}
}
//-------------------------------------------------
// Send event to guichan-controls
//-------------------------------------------------
msg_input->pushInput(event);
}
// Now we let the Gui object perform its logic.
msg_gui->logic();
// Now we let the Gui object draw itself.
msg_gui->draw();
// Finally we update the screen.
SDL_Flip(prSDLScreen);
}
msg_top->remove(wndMsg);
delete txtMsg;
delete cmdDone;
delete doneActionListener;
delete wndMsg;
delete msg_font;
delete msg_top;
delete msg_gui;
delete msg_input;
delete msg_graphics;
}

View file

@ -0,0 +1,287 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeRadioButton.hpp"
#include "UaeDropDown.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "target.h"
#include "gui_handling.h"
typedef struct
{
std::string activeWidget;
std::string leftWidget;
std::string rightWidget;
std::string upWidget;
std::string downWidget;
} NavigationMap;
static NavigationMap navMap[] =
{
// active move left move right move up move down
// main_window
{ "Paths", "SystemROMs", "SystemROMs", "Reset", "Configurations" },
{ "Configurations", "ConfigList", "ConfigList", "Paths", "CPU" },
{ "CPU", "7 Mhz", "68000", "Configurations", "Chipset" },
{ "Chipset", "BlitNormal", "OCS", "CPU", "ROM" },
{ "ROM", "MainROM", "cboMainROM", "Chipset", "RAM" },
{ "RAM", "Chipmem", "Chipmem", "ROM", "Floppy drives" },
{ "Floppy drives", "cmdSel0", "DF0:", "RAM", "Hard drives" },
{ "Hard drives", "cmdDel0", "cmdProp0", "Floppy drives", "Display" },
{ "Display", "sldWidth", "sldWidth", "Hard drives", "Sound" },
{ "Sound", "sndDisable", "sndDisable", "Display", "Input" },
{ "Input", "cboCtrlConfig", "cboCtrlConfig", "Sound", "Miscellaneous" },
{ "Miscellaneous", "Status Line", "Status Line", "Input", "Savestates" },
{ "Savestates", "State0", "State0", "Miscellaneous", "Reset" },
{ "Reset", "Start", "Quit", "Savestates", "Paths" },
{ "Quit", "Reset", "Restart", "Savestates", "Paths" },
{ "Restart", "Quit", "Start", "Savestates", "Paths" },
{ "Start", "Restart", "Reset", "Savestates", "Paths" },
// PanelPaths
{ "SystemROMs", "Paths", "Paths", "RescanROMs", "ConfigPath" },
{ "ConfigPath", "Paths", "Paths", "SystemROMs", "RescanROMs" },
{ "RescanROMs", "Paths", "Paths", "ConfigPath", "SystemROMs" },
// PanelConfig
{ "ConfigList", "Configurations", "ConfigName", "", "" },
{ "ConfigName", "Configurations", "Configurations", "ConfigList", "ConfigDesc" },
{ "ConfigDesc", "Configurations", "Configurations", "ConfigName", "ConfigLoad" },
{ "ConfigLoad", "Configurations", "ConfigSave", "ConfigDesc", "ConfigList" },
{ "ConfigSave", "ConfigLoad", "CfgDelete", "ConfigDesc", "ConfigList" },
{ "CfgDelete", "ConfigSave", "Configurations", "ConfigDesc", "ConfigList" },
// active move left move right move up move down
// PanelCPU
{ "68000", "CPU", "7 Mhz", "JIT", "68010" },
{ "68010", "CPU", "14 Mhz", "68000", "68EC020" },
{ "68EC020", "CPU", "28 Mhz", "68010", "68020" },
{ "68020", "CPU", "Fastest", "68EC020", "68040" },
{ "68040", "CPU", "Fastest", "68020", "CPUComp" },
{ "CPUComp", "CPU", "Fastest", "68040", "JIT" },
{ "JIT", "CPU", "Fastest", "CPUComp", "68000" },
{ "7 Mhz", "68000", "CPU", "Fastest", "14 Mhz" },
{ "14 Mhz", "68010", "CPU", "7 Mhz", "28 Mhz" },
{ "28 Mhz", "68EC020", "CPU", "14 Mhz", "Fastest" },
{ "Fastest", "68020", "CPU", "28 Mhz", "7 Mhz" },
// PanelChipset
{ "OCS", "Chipset", "BlitNormal", "CollFull", "ECS" },
{ "ECS", "Chipset", "Immediate", "OCS", "AGA" },
{ "AGA", "Chipset", "Improved", "ECS", "NTSC" },
{ "NTSC", "Chipset", "Chipset", "AGA", "CollNone" },
{ "BlitNormal", "OCS", "Chipset", "CollFull", "Immediate" },
{ "Immediate", "ECS", "Chipset", "BlitNormal", "Improved" },
{ "Improved", "AGA", "Chipset", "Immediate", "CollNone" },
{ "CollNone", "Chipset", "Chipset", "NTSC", "Sprites only" },
{ "Sprites only", "Chipset", "Chipset", "CollNone", "CollPlay" },
{ "CollPlay", "Chipset", "Chipset", "Sprites only", "CollFull" },
{ "CollFull", "Chipset", "Chipset", "CollPlay", "OCS" },
// active move left move right move up move down
// PanelROM
{ "cboMainROM", "ROM", "MainROM", "cboExtROM", "cboExtROM" },
{ "MainROM", "cboMainROM", "ROM", "ExtROM", "ExtROM" },
{ "cboExtROM", "ROM", "ExtROM", "cboMainROM", "cboMainROM" },
{ "ExtROM", "cboExtROM", "ROM", "MainROM", "MainROM" },
//PanelRAM
{ "Chipmem", "", "", "RAM", "Slowmem" },
{ "Slowmem", "", "", "Chipmem", "Fastmem" },
{ "Fastmem", "", "", "Slowmem", "RAM" },
//PanelFloppy
{ "DF0:", "Floppy drives", "cboType0", "SaveForDisk", "cboDisk0" },
{ "cboType0", "DF0:", "cmdEject0", "SaveForDisk", "cboDisk0" },
{ "cmdEject0", "cboType0", "cmdSel0", "SaveForDisk", "cboDisk0" },
{ "cmdSel0", "cmdEject0", "Floppy drives", "SaveForDisk", "cboDisk0" },
{ "cboDisk0", "Floppy drives", "Floppy drives", "DF0:", "DF1:" },
{ "DF1:", "Floppy drives", "cboType1", "cboDisk0", "cboDisk1" },
{ "cboType1", "DF1:", "cmdEject1", "cboDisk0", "cboDisk1" },
{ "cmdEject1", "cboType1", "cmdSel1", "cboDisk0", "cboDisk1" },
{ "cmdSel1", "cmdEject1", "Floppy drives", "cboDisk0", "cboDisk1" },
{ "cboDisk1", "Floppy drives", "Floppy drives", "DF1:", "DF2:" },
{ "DF2:", "Floppy drives", "cboType2", "cboDisk1", "cboDisk2" },
{ "cboType2", "DF2:", "cmdEject2", "cboDisk1", "cboDisk2" },
{ "cmdEject2", "cboType2", "cmdSel2", "cboDisk1", "cboDisk2" },
{ "cmdSel2", "cmdEject2", "Floppy drives", "cboDisk1", "cboDisk2" },
{ "cboDisk2", "Floppy drives", "Floppy drives", "DF2:", "DF3:" },
{ "DF3:", "Floppy drives", "cboType3", "cboDisk2", "cboDisk3" },
{ "cboType3", "DF3:", "cmdEject3", "cboDisk2", "cboDisk3" },
{ "cmdEject3", "cboType3", "cmdSel3", "cboDisk2", "cboDisk3" },
{ "cmdSel3", "cmdEject3", "Floppy drives", "cboDisk2", "cboDisk3" },
{ "cboDisk3", "Floppy drives", "Floppy drives", "DF3:", "DriveSpeed" },
{ "DriveSpeed", "", "", "cboDisk3", "SaveForDisk" },
{ "SaveForDisk", "Floppy drives", "Floppy drives", "DriveSpeed", "DF0:" },
// active move left move right move up move down
// PanelHD
{ "cmdProp0", "Hard drives", "cmdDel0", "cmdAddDir", "cmdProp1" },
{ "cmdDel0", "cmdProp0", "Hard drives", "cmdAddHDF", "cmdDel1" },
{ "cmdProp1", "Hard drives", "cmdDel1", "cmdProp0", "cmdProp2" },
{ "cmdDel1", "cmdProp1", "Hard drives", "cmdDel0", "cmdDel2" },
{ "cmdProp2", "Hard drives", "cmdDel2", "cmdProp1", "cmdProp3" },
{ "cmdDel2", "cmdProp2", "Hard drives", "cmdDel1", "cmdDel3" },
{ "cmdProp3", "Hard drives", "cmdDel3", "cmdProp2", "cmdProp4" },
{ "cmdDel3", "cmdProp3", "Hard drives", "cmdDel2", "cmdDel4" },
{ "cmdProp4", "Hard drives", "cmdDel4", "cmdProp3", "cmdAddDir" },
{ "cmdDel4", "cmdProp4", "Hard drives", "cmdDel3", "cmdAddHDF" },
{ "cmdAddDir", "Hard drives", "cmdAddHDF", "cmdProp4", "cmdProp0" },
{ "cmdAddHDF", "cmdAddDir", "Hard drives", "cmdDel4", "cmdDel0" },
// PanelDisplay
{ "sldWidth", "", "", "Frameskip", "sldHeight" },
{ "sldHeight", "", "", "sldWidth", "sldVertPos" },
{ "sldVertPos", "", "", "sldHeight", "Frameskip" },
{ "Frameskip", "Display", "Display", "sldVertPos", "sldWidth" },
//PanelSound
{ "sndDisable", "Sound", "Mono", "sldStereoDelay", "sndDisEmu" },
{ "sndDisEmu", "Sound", "Stereo", "sndDisable", "sndEmulate" },
{ "sndEmulate", "Sound", "Stereo", "sndDisEmu", "sndEmuBest" },
{ "sndEmuBest", "Sound", "Stereo", "sndEmulate", "cboFrequency" },
{ "Mono", "sndDisable", "Sound", "sldStereoDelay", "Stereo" },
{ "Stereo", "sndDisEmu", "Sound", "Mono", "cboFrequency" },
{ "cboFrequency", "Sound", "Sound", "sndEmuBest", "cboInterpol" },
{ "cboInterpol", "Sound", "Sound", "cboFrequency", "cboFilter" },
{ "cboFilter", "Sound", "Sound", "cboInterpol", "sldSeparation" },
{ "sldSeparation", "", "", "cboFilter", "sldStereoDelay" },
{ "sldStereoDelay", "", "", "sldSeparation", "sndDisable" },
// PanelInput
{ "cboCtrlConfig", "Input", "Input", "cboLeft", "cboJoystick" },
{ "cboJoystick", "Input", "cboAutofire", "cboCtrlConfig", "cboTapDelay" },
{ "cboAutofire", "cboJoystick", "Input", "cboCtrlConfig", "cboTapDelay" },
{ "cboTapDelay", "Input", "Input", "cboJoystick", "MouseSpeed" },
{ "MouseSpeed", "", "", "cboTapDelay", "StylusOffset" },
{ "StylusOffset", "", "", "MouseSpeed", "cboDPAD" },
{ "cboDPAD", "Input", "CustomCtrl", "StylusOffset", "cboA" },
{ "CustomCtrl", "cboDPAD", "Input", "StylusOffset", "cboB" },
{ "cboA", "Input", "cboB", "cboDPAD", "cboX" },
{ "cboB", "cboA", "Input", "CustomCtrl", "cboY" },
{ "cboX", "Input", "cboY", "cboA", "cboL" },
{ "cboY", "cboX", "Input", "cboB", "cboR" },
{ "cboL", "Input", "cboR", "cboX", "cboUp" },
{ "cboR", "cboL", "Input", "cboY", "cboDown" },
{ "cboUp", "Input", "cboDown", "cboL", "cboLeft" },
{ "cboDown", "cboUp", "Input", "cboR", "cboRight" },
{ "cboLeft", "Input", "cboRight", "cboUp", "cboCtrlConfig" },
{ "cboRight", "cboLeft", "Input", "cboDown", "cboCtrlConfig" },
// PanelMisc
{ "Status Line", "Miscellaneous", "Miscellaneous", "PandSpeed", "ShowGUI" },
{ "ShowGUI", "Miscellaneous", "Miscellaneous", "Status Line", "PandSpeed" },
{ "PandSpeed", "", "", "ShowGUI", "Status Line" },
// PanelSavestate
{ "State0", "Savestates", "Savestates", "LoadState", "State1" },
{ "State1", "Savestates", "Savestates", "State0", "State2" },
{ "State2", "Savestates", "Savestates", "State1", "State3" },
{ "State3", "Savestates", "Savestates", "State2", "LoadState" },
{ "LoadState", "Savestates", "SaveState", "State3", "State0" },
{ "SaveState", "LoadState", "Savestates", "State3", "State0" },
// active move left move right move up move down
// EditFilesysVirtual
{ "virtDev", "virtRW", "virtRW", "virtOK", "virtVol" },
{ "virtVol", "virtBootpri", "virtBootpri", "virtDev", "virtPath" },
{ "virtPath", "", "", "virtBootpri", "virtCancel" },
{ "virtRW", "virtDev", "virtDev", "virtOK", "virtBootpri" },
{ "virtBootpri", "virtVol", "virtVol", "virtRW", "virtPath" },
{ "virtOK", "virtCancel", "virtCancel", "virtPath", "virtRW" },
{ "virtCancel", "virtOK", "virtOK", "virtPath", "virtRW" },
// EditFilesysHardfile
{ "hdfDev", "hdfBootPri", "hdfRW", "hdfOK", "hdfPath" },
{ "hdfRW", "hdfDev", "hdfBootPri", "hdfOK", "hdfPath" },
{ "hdfBootPri", "hdfRW", "hdfDev", "hdfCancel", "hdfPath" },
{ "hdfSurface", "hdfReserved", "hdfReserved", "hdfPath", "hdfSectors" },
{ "hdfReserved", "hdfSurface", "hdfSurface", "hdfPath", "hdfBlocksize" },
{ "hdfSectors", "hdfBlocksize", "hdfBlocksize", "hdfSurface", "hdfOK" },
{ "hdfBlocksize", "hdfSectors", "hdfSectors", "hdfReserved", "hdfOK" },
{ "hdfPath", "", "", "hdfBootPri", "hdfReserved" },
{ "hdfOK", "hdfCancel", "hdfCancel", "hdfBlocksize", "hdfBootPri" },
{ "hdfCancel", "hdfOK", "hdfOK", "hdfBlocksize", "hdfBootPri" },
{ "END", "", "", "", "" }
};
bool HandleNavigation(int direction)
{
gcn::FocusHandler* focusHdl = gui_top->_getFocusHandler();
gcn::Widget* focusTarget = NULL;
if(focusHdl != NULL)
{
gcn::Widget* activeWidget = focusHdl->getFocused();
if(activeWidget != NULL && activeWidget->getId().length() > 0)
{
std::string activeName = activeWidget->getId();
bool bFoundEnabled = false;
while(!bFoundEnabled)
{
std::string searchFor = "";
for(int i=0; navMap[i].activeWidget != "END"; ++i)
{
if(navMap[i].activeWidget == activeName)
{
switch(direction)
{
case DIRECTION_LEFT:
searchFor = navMap[i].leftWidget;
break;
case DIRECTION_RIGHT:
searchFor = navMap[i].rightWidget;
break;
case DIRECTION_UP:
searchFor = navMap[i].upWidget;
break;
case DIRECTION_DOWN:
searchFor = navMap[i].downWidget;
break;
}
if(searchFor.length() > 0)
{
focusTarget = gui_top->findWidgetById(searchFor);
if(focusTarget != NULL)
{
if(focusTarget->isEnabled())
bFoundEnabled = true;
else
activeName = searchFor;
}
}
break;
}
}
if(searchFor == "")
bFoundEnabled = true; // No entry to navigate to -> exit loop
}
if(focusTarget != NULL)
{
if(!activeWidget->getId().substr(0, 3).compare("cbo"))
{
gcn::UaeDropDown *dropdown = (gcn::UaeDropDown *) activeWidget;
if(dropdown->isDroppedDown() && (direction == DIRECTION_UP || direction == DIRECTION_DOWN))
focusTarget = NULL; // Up/down navigates in list if dropped down
}
}
}
}
if(focusTarget != NULL)
focusTarget->requestFocus();
return (focusTarget != NULL);
}

View file

@ -0,0 +1,316 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeRadioButton.hpp"
#include "UaeCheckBox.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "uae.h"
#include "gui.h"
#include "target.h"
#include "gui_handling.h"
static gcn::Window *grpCPU;
static gcn::UaeRadioButton* optCPU68000;
static gcn::UaeRadioButton* optCPU68010;
static gcn::UaeRadioButton* optCPU68EC020;
static gcn::UaeRadioButton* optCPU68020;
static gcn::UaeRadioButton* optCPU68040;
static gcn::UaeCheckBox* chkCPUCompatible;
static gcn::UaeCheckBox* chkJIT;
static gcn::Window *grpFPU;
static gcn::UaeRadioButton* optFPUnone;
static gcn::UaeRadioButton* optFPU68881;
static gcn::UaeRadioButton* optFPU68882;
static gcn::Window *grpCPUSpeed;
static gcn::UaeRadioButton* opt7Mhz;
static gcn::UaeRadioButton* opt14Mhz;
static gcn::UaeRadioButton* opt28Mhz;
static gcn::UaeRadioButton* optFastest;
class CPUButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == optCPU68000)
{
changed_prefs.cpu_level = 0;
changed_prefs.address_space_24 = true;
}
else if (actionEvent.getSource() == optCPU68010)
{
changed_prefs.cpu_level = 1;
changed_prefs.address_space_24 = true;
changed_prefs.cpu_compatible = 0;
}
else if (actionEvent.getSource() == optCPU68EC020)
{
changed_prefs.cpu_level = 2;
changed_prefs.address_space_24 = true;
changed_prefs.cpu_compatible = 0;
}
else if (actionEvent.getSource() == optCPU68020)
{
changed_prefs.cpu_level = 2;
changed_prefs.address_space_24 = false;
changed_prefs.cpu_compatible = 0;
}
else if (actionEvent.getSource() == optCPU68040)
{
changed_prefs.cpu_level = 4;
changed_prefs.address_space_24 = false;
changed_prefs.cpu_compatible = 0;
}
RefreshPanelCPU();
}
};
static CPUButtonActionListener* cpuButtonActionListener;
class FPUButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == optFPUnone)
{
if(changed_prefs.cpu_level == 3)
changed_prefs.cpu_level = 2;
}
else if(actionEvent.getSource() == optFPU68881)
{
if(changed_prefs.cpu_level == 2)
changed_prefs.cpu_level = 3;
}
else
;
}
};
static FPUButtonActionListener* fpuButtonActionListener;
class CPUSpeedButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == opt7Mhz)
changed_prefs.m68k_speed = M68K_SPEED_7MHZ_CYCLES;
else if (actionEvent.getSource() == opt14Mhz)
changed_prefs.m68k_speed = M68K_SPEED_14MHZ_CYCLES;
else if (actionEvent.getSource() == opt28Mhz)
changed_prefs.m68k_speed = M68K_SPEED_25MHZ_CYCLES;
else if (actionEvent.getSource() == optFastest)
changed_prefs.m68k_speed = -1;
}
};
static CPUSpeedButtonActionListener* cpuSpeedButtonActionListener;
class CPUCompActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (chkCPUCompatible->isSelected())
{
changed_prefs.cpu_compatible = 1;
changed_prefs.cachesize = 0;
}
else
{
changed_prefs.cpu_compatible = 0;
}
RefreshPanelCPU();
}
};
static CPUCompActionListener* cpuCompActionListener;
class JITActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (chkJIT->isSelected())
{
changed_prefs.cpu_compatible = 0;
changed_prefs.cachesize = 8192;
}
else
{
changed_prefs.cachesize = 0;
}
RefreshPanelCPU();
}
};
static JITActionListener* jitActionListener;
void InitPanelCPU(const struct _ConfigCategory& category)
{
cpuButtonActionListener = new CPUButtonActionListener();
cpuCompActionListener = new CPUCompActionListener();
jitActionListener = new JITActionListener();
optCPU68000 = new gcn::UaeRadioButton("68000", "radiocpugroup");
optCPU68000->addActionListener(cpuButtonActionListener);
optCPU68010 = new gcn::UaeRadioButton("68010", "radiocpugroup");
optCPU68010->addActionListener(cpuButtonActionListener);
optCPU68EC020 = new gcn::UaeRadioButton("68EC020", "radiocpugroup");
optCPU68EC020->addActionListener(cpuButtonActionListener);
optCPU68020 = new gcn::UaeRadioButton("68020", "radiocpugroup");
optCPU68020->addActionListener(cpuButtonActionListener);
optCPU68040 = new gcn::UaeRadioButton("68040", "radiocpugroup");
optCPU68040->addActionListener(cpuButtonActionListener);
chkCPUCompatible = new gcn::UaeCheckBox("More compatible", true);
chkCPUCompatible->setId("CPUComp");
chkCPUCompatible->addActionListener(cpuCompActionListener);
chkJIT = new gcn::UaeCheckBox("JIT", true);
chkJIT->setId("JIT");
chkJIT->addActionListener(jitActionListener);
grpCPU = new gcn::Window("CPU");
grpCPU->setPosition(DISTANCE_BORDER, DISTANCE_BORDER);
grpCPU->add(optCPU68000, 5, 10);
grpCPU->add(optCPU68010, 5, 40);
grpCPU->add(optCPU68EC020, 5, 70);
grpCPU->add(optCPU68020, 5, 100);
grpCPU->add(optCPU68040, 5, 130);
grpCPU->add(chkCPUCompatible, 5, 170);
grpCPU->add(chkJIT, 5, 200);
grpCPU->setMovable(false);
grpCPU->setSize(160, 245);
grpCPU->setBaseColor(gui_baseCol);
category.panel->add(grpCPU);
fpuButtonActionListener = new FPUButtonActionListener();
optFPUnone = new gcn::UaeRadioButton("None", "radiofpugroup");
optFPUnone->setId("FPUnone");
optFPUnone->addActionListener(fpuButtonActionListener);
optFPU68881 = new gcn::UaeRadioButton("68881", "radiofpugroup");
optFPU68881->addActionListener(fpuButtonActionListener);
optFPU68882 = new gcn::UaeRadioButton("68882", "radiofpugroup");
optFPU68882->addActionListener(fpuButtonActionListener);
grpFPU = new gcn::Window("FPU");
grpFPU->setPosition(DISTANCE_BORDER, DISTANCE_BORDER + grpCPU->getHeight() + DISTANCE_NEXT_Y);
grpFPU->add(optFPUnone, 5, 10);
grpFPU->add(optFPU68881, 5, 40);
// grpFPU->add(optFPU68882, 5, 70);
grpFPU->setMovable(false);
grpFPU->setSize(grpCPU->getWidth(), 115);
grpFPU->setBaseColor(gui_baseCol);
category.panel->add(grpFPU);
cpuSpeedButtonActionListener = new CPUSpeedButtonActionListener();
opt7Mhz = new gcn::UaeRadioButton("7 Mhz", "radiocpuspeedgroup");
opt7Mhz->addActionListener(cpuSpeedButtonActionListener);
opt14Mhz = new gcn::UaeRadioButton("14 Mhz", "radiocpuspeedgroup");
opt14Mhz->addActionListener(cpuSpeedButtonActionListener);
opt28Mhz = new gcn::UaeRadioButton("28 Mhz", "radiocpuspeedgroup");
opt28Mhz->addActionListener(cpuSpeedButtonActionListener);
optFastest = new gcn::UaeRadioButton("Fastest", "radiocpuspeedgroup");
optFastest->addActionListener(cpuSpeedButtonActionListener);
grpCPUSpeed = new gcn::Window("CPU Speed");
grpCPUSpeed->setPosition(DISTANCE_BORDER + grpCPU->getWidth() + DISTANCE_NEXT_X, DISTANCE_BORDER);
grpCPUSpeed->add(opt7Mhz, 5, 10);
grpCPUSpeed->add(opt14Mhz, 5, 40);
grpCPUSpeed->add(opt28Mhz, 5, 70);
grpCPUSpeed->add(optFastest, 5, 100);
grpCPUSpeed->setMovable(false);
grpCPUSpeed->setSize(95, 145);
grpCPUSpeed->setBaseColor(gui_baseCol);
category.panel->add(grpCPUSpeed);
RefreshPanelCPU();
}
void ExitPanelCPU(void)
{
delete optCPU68000;
delete optCPU68010;
delete optCPU68EC020;
delete optCPU68020;
delete optCPU68040;
delete chkCPUCompatible;
delete chkJIT;
delete grpCPU;
delete cpuButtonActionListener;
delete cpuCompActionListener;
delete jitActionListener;
delete optFPUnone;
delete optFPU68881;
delete optFPU68882;
delete grpFPU;
delete fpuButtonActionListener;
delete opt7Mhz;
delete opt14Mhz;
delete opt28Mhz;
delete optFastest;
delete grpCPUSpeed;
delete cpuSpeedButtonActionListener;
}
void RefreshPanelCPU(void)
{
if(changed_prefs.address_space_24)
{
if(changed_prefs.cpu_level == 0)
optCPU68000->setSelected(true);
else if(changed_prefs.cpu_level == 1)
optCPU68010->setSelected(true);
else if(changed_prefs.cpu_level == 2)
optCPU68EC020->setSelected(true);
}
else
{
if(changed_prefs.cpu_level == 2)
optCPU68020->setSelected(true);
else if(changed_prefs.cpu_level == 4)
optCPU68040->setSelected(true);
}
chkCPUCompatible->setSelected(changed_prefs.cpu_compatible > 0);
chkCPUCompatible->setEnabled(changed_prefs.cpu_level == 0);
chkJIT->setSelected(changed_prefs.cachesize > 0);
if(changed_prefs.cpu_level <= 2)
optFPUnone->setSelected(true);
else
optFPU68881->setSelected(true);
if (changed_prefs.m68k_speed == M68K_SPEED_7MHZ_CYCLES)
opt7Mhz->setSelected(true);
else if (changed_prefs.m68k_speed == M68K_SPEED_14MHZ_CYCLES)
opt14Mhz->setSelected(true);
else if (changed_prefs.m68k_speed == M68K_SPEED_25MHZ_CYCLES)
opt28Mhz->setSelected(true);
else if (changed_prefs.m68k_speed == -1)
optFastest->setSelected(true);
}

View file

@ -0,0 +1,238 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeRadioButton.hpp"
#include "UaeCheckBox.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "uae.h"
#include "gui.h"
#include "custom.h"
#include "target.h"
#include "gui_handling.h"
static gcn::Window *grpChipset;
static gcn::UaeRadioButton* optOCS;
static gcn::UaeRadioButton* optECS;
static gcn::UaeRadioButton* optAGA;
static gcn::UaeCheckBox* chkNTSC;
static gcn::Window *grpBlitter;
static gcn::UaeRadioButton* optBlitNormal;
static gcn::UaeRadioButton* optBlitImmed;
static gcn::UaeRadioButton* optBlitImproved;
static gcn::Window *grpCollisionLevel;
static gcn::UaeRadioButton* optCollNone;
static gcn::UaeRadioButton* optCollSprites;
static gcn::UaeRadioButton* optCollPlayfield;
static gcn::UaeRadioButton* optCollFull;
class ChipsetButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == optOCS)
changed_prefs.chipset_mask = CSMASK_ECS_AGNUS;
else if (actionEvent.getSource() == optECS)
changed_prefs.chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE;
else
changed_prefs.chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE | CSMASK_AGA;
}
};
static ChipsetButtonActionListener* chipsetButtonActionListener;
class NTSCButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (chkNTSC->isSelected())
{
changed_prefs.ntscmode = true;
changed_prefs.chipset_refreshrate = 60;
}
else
{
changed_prefs.ntscmode = false;
changed_prefs.chipset_refreshrate = 50;
}
}
};
static NTSCButtonActionListener* ntscButtonActionListener;
class BlitterButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
changed_prefs.immediate_blits = optBlitImmed->isSelected();
changed_prefs.pandora_partial_blits = optBlitImproved->isSelected();
}
};
static BlitterButtonActionListener* blitterButtonActionListener;
class CollisionButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == optCollNone)
changed_prefs.collision_level = 0;
else if (actionEvent.getSource() == optCollSprites)
changed_prefs.collision_level = 1;
else if (actionEvent.getSource() == optCollPlayfield)
changed_prefs.collision_level = 2;
else
changed_prefs.collision_level = 3;
}
};
static CollisionButtonActionListener* collisionButtonActionListener;
void InitPanelChipset(const struct _ConfigCategory& category)
{
chipsetButtonActionListener = new ChipsetButtonActionListener();
ntscButtonActionListener = new NTSCButtonActionListener();
optOCS = new gcn::UaeRadioButton("OCS", "radiochipsetgroup");
optOCS->addActionListener(chipsetButtonActionListener);
optECS = new gcn::UaeRadioButton("ECS", "radiochipsetgroup");
optECS->addActionListener(chipsetButtonActionListener);
optAGA = new gcn::UaeRadioButton("AGA", "radiochipsetgroup");
optAGA->addActionListener(chipsetButtonActionListener);
chkNTSC = new gcn::UaeCheckBox("NTSC");
chkNTSC->addActionListener(ntscButtonActionListener);
grpChipset = new gcn::Window("Chipset");
grpChipset->setPosition(DISTANCE_BORDER, DISTANCE_BORDER);
grpChipset->add(optOCS, 5, 10);
grpChipset->add(optECS, 5, 40);
grpChipset->add(optAGA, 5, 70);
grpChipset->add(chkNTSC, 5, 110);
grpChipset->setMovable(false);
grpChipset->setSize(100, 155);
grpChipset->setBaseColor(gui_baseCol);
category.panel->add(grpChipset);
blitterButtonActionListener = new BlitterButtonActionListener();
optBlitNormal = new gcn::UaeRadioButton("Normal", "radiocblittergroup");
optBlitNormal->setId("BlitNormal");
optBlitNormal->addActionListener(blitterButtonActionListener);
optBlitImmed = new gcn::UaeRadioButton("Immediate", "radiocblittergroup");
optBlitImmed->addActionListener(blitterButtonActionListener);
optBlitImproved = new gcn::UaeRadioButton("Improved", "radiocblittergroup");
optBlitImproved->addActionListener(blitterButtonActionListener);
grpBlitter = new gcn::Window("Blitter");
grpBlitter->setPosition(DISTANCE_BORDER + grpChipset->getWidth() + DISTANCE_NEXT_X, DISTANCE_BORDER);
grpBlitter->add(optBlitNormal, 5, 10);
grpBlitter->add(optBlitImmed, 5, 40);
grpBlitter->add(optBlitImproved, 5, 70);
grpBlitter->setMovable(false);
grpBlitter->setSize(120, 115);
grpBlitter->setBaseColor(gui_baseCol);
category.panel->add(grpBlitter);
collisionButtonActionListener = new CollisionButtonActionListener();
optCollNone = new gcn::UaeRadioButton("None", "radioccollisiongroup");
optCollNone->setId("CollNone");
optCollNone->addActionListener(collisionButtonActionListener);
optCollSprites = new gcn::UaeRadioButton("Sprites only", "radioccollisiongroup");
optCollSprites->addActionListener(collisionButtonActionListener);
optCollPlayfield = new gcn::UaeRadioButton("Sprites and Sprites vs. Playfield", "radioccollisiongroup");
optCollPlayfield->setId("CollPlay");
optCollPlayfield->addActionListener(collisionButtonActionListener);
optCollFull = new gcn::UaeRadioButton("Full (rarely needed)", "radioccollisiongroup");
optCollFull->setId("CollFull");
optCollFull->addActionListener(collisionButtonActionListener);
grpCollisionLevel = new gcn::Window("Collision Level");
grpCollisionLevel->setPosition(DISTANCE_BORDER, DISTANCE_BORDER + grpChipset->getHeight() + DISTANCE_NEXT_Y);
grpCollisionLevel->add(optCollNone, 5, 10);
grpCollisionLevel->add(optCollSprites, 5, 40);
grpCollisionLevel->add(optCollPlayfield, 5, 70);
grpCollisionLevel->add(optCollFull, 5, 100);
grpCollisionLevel->setMovable(false);
grpCollisionLevel->setSize(250, 145);
grpCollisionLevel->setBaseColor(gui_baseCol);
category.panel->add(grpCollisionLevel);
RefreshPanelChipset();
}
void ExitPanelChipset(void)
{
delete optOCS;
delete optECS;
delete optAGA;
delete chkNTSC;
delete grpChipset;
delete chipsetButtonActionListener;
delete ntscButtonActionListener;
delete optBlitNormal;
delete optBlitImmed;
delete optBlitImproved;
delete grpBlitter;
delete blitterButtonActionListener;
delete optCollNone;
delete optCollSprites;
delete optCollPlayfield;
delete optCollFull;
delete grpCollisionLevel;
delete collisionButtonActionListener;
}
void RefreshPanelChipset(void)
{
if (changed_prefs.chipset_mask == CSMASK_ECS_AGNUS)
optOCS->setSelected(true);
else if (changed_prefs.chipset_mask == (CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE))
optECS->setSelected(true);
else if (changed_prefs.chipset_mask == (CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE | CSMASK_AGA))
optAGA->setSelected(true);
chkNTSC->setSelected(changed_prefs.ntscmode);
if(changed_prefs.immediate_blits)
optBlitImmed->setSelected(true);
else if (changed_prefs.pandora_partial_blits)
optBlitImproved->setSelected(true);
else
optBlitNormal->setSelected(true);
if(changed_prefs.collision_level == 0)
optCollNone->setSelected(true);
else if(changed_prefs.collision_level == 1)
optCollSprites->setSelected(true);
else if(changed_prefs.collision_level == 2)
optCollPlayfield->setSelected(true);
else
optCollFull->setSelected(true);
}

View file

@ -0,0 +1,322 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeListBox.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "uae.h"
#include "gui.h"
#include "target.h"
#include "gui_handling.h"
static char last_active_config[MAX_PATH] = { '\0' };
static gcn::Button *cmdLoad;
static gcn::Button *cmdSave;
static gcn::Button *cmdLoadFrom;
static gcn::Button *cmdSaveAs;
static gcn::Button *cmdDelete;
static gcn::Label *lblName;
static gcn::TextField *txtName;
static gcn::Label *lblDesc;
static gcn::TextField *txtDesc;
static gcn::UaeListBox* lstConfigs;
static gcn::ScrollArea* scrAreaConfigs;
bool LoadConfigByName(const char *name)
{
ConfigFileInfo* config = SearchConfigInList(name);
if(config != NULL)
{
txtName->setText(config->Name);
txtDesc->setText(config->Description);
my_cfgfile_load(&changed_prefs, config->FullPath, 0);
strncpy(last_active_config, config->Name, MAX_PATH);
RefreshAllPanels();
}
return false;
}
class ConfigsListModel : public gcn::ListModel
{
std::vector<std::string> configs;
public:
ConfigsListModel()
{
}
int getNumberOfElements()
{
return configs.size();
}
std::string getElementAt(int i)
{
if(i >= configs.size() || i < 0)
return "---";
return configs[i];
}
void InitConfigsList(void)
{
configs.clear();
for(int i=0; i<ConfigFilesList.size(); ++i)
{
char tmp[MAX_DPATH];
strncpy(tmp, ConfigFilesList[i]->Name, MAX_DPATH);
if(strlen(ConfigFilesList[i]->Description) > 0)
{
strncat(tmp, " (", MAX_DPATH);
strncat(tmp, ConfigFilesList[i]->Description, MAX_DPATH);
strncat(tmp, ")", MAX_DPATH);
}
configs.push_back(tmp);
}
}
};
static ConfigsListModel *configsList;
class ConfigButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
int i;
if (actionEvent.getSource() == cmdLoad)
{
//-----------------------------------------------
// Load selected configuration
//-----------------------------------------------
i = lstConfigs->getSelected();
my_cfgfile_load(&changed_prefs, ConfigFilesList[i]->FullPath, 0);
strncpy(last_active_config, ConfigFilesList[i]->Name, MAX_PATH);
RefreshAllPanels();
}
else if(actionEvent.getSource() == cmdSave)
{
//-----------------------------------------------
// Save current configuration
//-----------------------------------------------
char filename[MAX_DPATH];
if(!txtName->getText().empty())
{
fetch_configurationpath(filename, MAX_DPATH);
strncat(filename, txtName->getText().c_str(), MAX_DPATH);
strncat(filename, ".uae", MAX_DPATH);
strncpy(changed_prefs.description, txtDesc->getText().c_str(), 256);
if(cfgfile_save(&changed_prefs, filename, 0))
RefreshPanelConfig();
}
}
else if(actionEvent.getSource() == cmdLoadFrom)
{
}
else if(actionEvent.getSource() == cmdSaveAs)
{
}
else if(actionEvent.getSource() == cmdDelete)
{
//-----------------------------------------------
// Delete selected config
//-----------------------------------------------
char msg[256];
i = lstConfigs->getSelected();
if(i >= 0 && strcmp(ConfigFilesList[i]->Name, OPTIONSFILENAME))
{
snprintf(msg, 256, "Do you want to delete '%s' ?", ConfigFilesList[i]->Name);
if(ShowMessage("Delete Configuration", msg, "", "Yes", "No"))
{
remove(ConfigFilesList[i]->FullPath);
if(!strcmp(last_active_config, ConfigFilesList[i]->Name))
{
txtName->setText("");
txtDesc->setText("");
last_active_config[0] = '\0';
}
ConfigFilesList.erase(ConfigFilesList.begin() + i);
RefreshPanelConfig();
}
cmdDelete->requestFocus();
}
}
}
};
static ConfigButtonActionListener* configButtonActionListener;
class ConfigsListActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
int selected_item;
selected_item = lstConfigs->getSelected();
if(!txtName->getText().compare(ConfigFilesList[selected_item]->Name))
{
//-----------------------------------------------
// Selected same config again -> load and start it
//-----------------------------------------------
my_cfgfile_load(&changed_prefs, ConfigFilesList[selected_item]->FullPath, 0);
strncpy(last_active_config, ConfigFilesList[selected_item]->Name, MAX_PATH);
RefreshAllPanels();
uae_reset(0);
gui_running = false;
}
else
{
txtName->setText(ConfigFilesList[selected_item]->Name);
txtDesc->setText(ConfigFilesList[selected_item]->Description);
}
}
};
static ConfigsListActionListener* configsListActionListener;
void InitPanelConfig(const struct _ConfigCategory& category)
{
configButtonActionListener = new ConfigButtonActionListener();
cmdLoad = new gcn::Button("Load");
cmdLoad->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdLoad->setBaseColor(gui_baseCol);
cmdLoad->setId("ConfigLoad");
cmdLoad->addActionListener(configButtonActionListener);
cmdSave = new gcn::Button("Save");
cmdSave->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdSave->setBaseColor(gui_baseCol);
cmdSave->setId("ConfigSave");
cmdSave->addActionListener(configButtonActionListener);
cmdLoadFrom = new gcn::Button("Load From...");
cmdLoadFrom->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdLoadFrom->setBaseColor(gui_baseCol);
cmdLoadFrom->setId("CfgLoadFrom");
cmdLoadFrom->addActionListener(configButtonActionListener);
cmdLoadFrom->setEnabled(false);
cmdSaveAs = new gcn::Button("Save As...");
cmdSaveAs->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdSaveAs->setBaseColor(gui_baseCol);
cmdSaveAs->setId("CfgSaveAs");
cmdSaveAs->addActionListener(configButtonActionListener);
cmdSaveAs->setEnabled(false);
cmdDelete = new gcn::Button("Delete");
cmdDelete->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdDelete->setBaseColor(gui_baseCol);
cmdDelete->setId("CfgDelete");
cmdDelete->addActionListener(configButtonActionListener);
int buttonX = DISTANCE_BORDER;
int buttonY = category.panel->getHeight() - DISTANCE_BORDER - BUTTON_HEIGHT;
category.panel->add(cmdLoad, buttonX, buttonY);
buttonX += BUTTON_WIDTH + DISTANCE_NEXT_X;
category.panel->add(cmdSave, buttonX, buttonY);
buttonX += BUTTON_WIDTH + 3 * DISTANCE_NEXT_X;
// category.panel->add(cmdLoadFrom, buttonX, buttonY);
buttonX += BUTTON_WIDTH + DISTANCE_NEXT_X;
// category.panel->add(cmdSaveAs, buttonX, buttonY);
buttonX = category.panel->getWidth() - DISTANCE_BORDER - BUTTON_WIDTH;
category.panel->add(cmdDelete, buttonX, buttonY);
lblName = new gcn::Label("Name:");
lblName->setSize(90, LABEL_HEIGHT);
lblName->setAlignment(gcn::Graphics::RIGHT);
txtName = new gcn::TextField();
txtName->setSize(300, TEXTFIELD_HEIGHT);
txtName->setId("ConfigName");
lblDesc = new gcn::Label("Description:");
lblDesc->setSize(90, LABEL_HEIGHT);
lblDesc->setAlignment(gcn::Graphics::RIGHT);
txtDesc = new gcn::TextField();
txtDesc->setSize(300, TEXTFIELD_HEIGHT);
txtDesc->setId("ConfigDesc");
category.panel->add(lblName, DISTANCE_BORDER, 2 + buttonY - DISTANCE_NEXT_Y - 2 * TEXTFIELD_HEIGHT - 10);
category.panel->add(txtName, DISTANCE_BORDER + lblName->getWidth() + 8, buttonY - DISTANCE_NEXT_Y - 2 * TEXTFIELD_HEIGHT - 10);
category.panel->add(lblDesc, DISTANCE_BORDER, 2 + buttonY - DISTANCE_NEXT_Y - TEXTFIELD_HEIGHT);
category.panel->add(txtDesc, DISTANCE_BORDER + lblName->getWidth() + 8, buttonY - DISTANCE_NEXT_Y - TEXTFIELD_HEIGHT);
ReadConfigFileList();
configsList = new ConfigsListModel();
configsList->InitConfigsList();
configsListActionListener = new ConfigsListActionListener();
lstConfigs = new gcn::UaeListBox(configsList);
lstConfigs->setSize(category.panel->getWidth() - 2 * DISTANCE_BORDER - 22, 232);
lstConfigs->setBaseColor(gui_baseCol);
lstConfigs->setWrappingEnabled(true);
lstConfigs->setId("ConfigList");
lstConfigs->addActionListener(configsListActionListener);
scrAreaConfigs = new gcn::ScrollArea(lstConfigs);
scrAreaConfigs->setFrameSize(1);
scrAreaConfigs->setPosition(DISTANCE_BORDER, DISTANCE_BORDER);
scrAreaConfigs->setSize(category.panel->getWidth() - 2 * DISTANCE_BORDER - 2, 252);
scrAreaConfigs->setScrollbarWidth(20);
scrAreaConfigs->setBaseColor(gui_baseCol);
category.panel->add(scrAreaConfigs);
if(strlen(last_active_config) == 0)
strncpy(last_active_config, OPTIONSFILENAME, MAX_PATH);
txtName->setText(last_active_config);
txtDesc->setText(changed_prefs.description);
RefreshPanelConfig();
}
void ExitPanelConfig(void)
{
delete lstConfigs;
delete scrAreaConfigs;
delete configsListActionListener;
delete configsList;
delete cmdLoad;
delete cmdSave;
delete cmdLoadFrom;
delete cmdSaveAs;
delete cmdDelete;
delete configButtonActionListener;
delete lblName;
delete txtName;
delete lblDesc;
delete txtDesc;
}
void RefreshPanelConfig(void)
{
ReadConfigFileList();
configsList->InitConfigsList();
// Search current entry
if(!txtName->getText().empty())
{
for(int i=0; i<ConfigFilesList.size(); ++i)
{
if(!strcmp(ConfigFilesList[i]->Name, txtName->getText().c_str()))
{
// Select current entry
lstConfigs->setSelected(i);
break;
}
}
}
}

View file

@ -0,0 +1,195 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeRadioButton.hpp"
#include "UaeDropDown.hpp"
#include "UaeCheckBox.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "memory.h"
#include "uae.h"
#include "gui.h"
#include "target.h"
#include "gui_handling.h"
const int amigawidth_values[] = { 320, 352, 384, 640, 704, 768 };
const int amigaheight_values[] = { 200, 216, 240, 256, 262, 270 };
static gcn::Window *grpAmigaScreen;
static gcn::Label* lblAmigaWidth;
static gcn::Label* lblAmigaWidthInfo;
static gcn::Slider* sldAmigaWidth;
static gcn::Label* lblAmigaHeight;
static gcn::Label* lblAmigaHeightInfo;
static gcn::Slider* sldAmigaHeight;
static gcn::Label* lblVertPos;
static gcn::Label* lblVertPosInfo;
static gcn::Slider* sldVertPos;
static gcn::UaeCheckBox* chkFrameskip;
class AmigaScreenActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == sldAmigaWidth)
{
if(changed_prefs.gfx_size.width != amigawidth_values[(int)(sldAmigaWidth->getValue())])
{
changed_prefs.gfx_size.width = amigawidth_values[(int)(sldAmigaWidth->getValue())];
RefreshPanelDisplay();
}
}
else if (actionEvent.getSource() == sldAmigaHeight)
{
if(changed_prefs.gfx_size.height != amigaheight_values[(int)(sldAmigaHeight->getValue())])
{
changed_prefs.gfx_size.height = amigaheight_values[(int)(sldAmigaHeight->getValue())];
RefreshPanelDisplay();
}
}
else if (actionEvent.getSource() == sldVertPos)
{
if(changed_prefs.pandora_vertical_offset != (int)(sldVertPos->getValue()))
{
changed_prefs.pandora_vertical_offset = (int)(sldVertPos->getValue());
RefreshPanelDisplay();
}
}
else if (actionEvent.getSource() == chkFrameskip)
{
changed_prefs.gfx_framerate = chkFrameskip->isSelected() ? 1 : 0;
}
}
};
AmigaScreenActionListener* amigaScreenActionListener;
void InitPanelDisplay(const struct _ConfigCategory& category)
{
amigaScreenActionListener = new AmigaScreenActionListener();
lblAmigaWidth = new gcn::Label("Width:");
lblAmigaWidth->setSize(80, LABEL_HEIGHT);
lblAmigaWidth->setAlignment(gcn::Graphics::RIGHT);
sldAmigaWidth = new gcn::Slider(0, 5);
sldAmigaWidth->setSize(160, SLIDER_HEIGHT);
sldAmigaWidth->setBaseColor(gui_baseCol);
sldAmigaWidth->setMarkerLength(20);
sldAmigaWidth->setStepLength(1);
sldAmigaWidth->setId("sldWidth");
sldAmigaWidth->addActionListener(amigaScreenActionListener);
lblAmigaWidthInfo = new gcn::Label("320");
lblAmigaHeight = new gcn::Label("Height:");
lblAmigaHeight->setSize(80, LABEL_HEIGHT);
lblAmigaHeight->setAlignment(gcn::Graphics::RIGHT);
sldAmigaHeight = new gcn::Slider(0, 5);
sldAmigaHeight->setSize(160, SLIDER_HEIGHT);
sldAmigaHeight->setBaseColor(gui_baseCol);
sldAmigaHeight->setMarkerLength(20);
sldAmigaHeight->setStepLength(1);
sldAmigaHeight->setId("sldHeight");
sldAmigaHeight->addActionListener(amigaScreenActionListener);
lblAmigaHeightInfo = new gcn::Label("200");
lblVertPos = new gcn::Label("Vert. offset:");
lblVertPos->setSize(80, LABEL_HEIGHT);
lblVertPos->setAlignment(gcn::Graphics::RIGHT);
sldVertPos = new gcn::Slider(-16, 16);
sldVertPos->setSize(160, SLIDER_HEIGHT);
sldVertPos->setBaseColor(gui_baseCol);
sldVertPos->setMarkerLength(20);
sldVertPos->setStepLength(1);
sldVertPos->setId("sldVertPos");
sldVertPos->addActionListener(amigaScreenActionListener);
lblVertPosInfo = new gcn::Label("000");
chkFrameskip = new gcn::UaeCheckBox("Frameskip");
chkFrameskip->addActionListener(amigaScreenActionListener);
grpAmigaScreen = new gcn::Window("Amiga Screen");
grpAmigaScreen->setPosition(DISTANCE_BORDER, DISTANCE_BORDER);
int posY = 10;
grpAmigaScreen->add(lblAmigaWidth, 8, posY);
grpAmigaScreen->add(sldAmigaWidth, 100, posY);
grpAmigaScreen->add(lblAmigaWidthInfo, 100 + sldAmigaWidth->getWidth() + 12, posY);
posY += sldAmigaWidth->getHeight() + DISTANCE_NEXT_Y;
grpAmigaScreen->add(lblAmigaHeight, 8, posY);
grpAmigaScreen->add(sldAmigaHeight, 100, posY);
grpAmigaScreen->add(lblAmigaHeightInfo, 100 + sldAmigaHeight->getWidth() + 12, posY);
posY += sldAmigaHeight->getHeight() + DISTANCE_NEXT_Y;
grpAmigaScreen->add(lblVertPos, 8, posY);
grpAmigaScreen->add(sldVertPos, 100, posY);
grpAmigaScreen->add(lblVertPosInfo, 100 + sldVertPos->getWidth() + 12, posY);
posY += sldVertPos->getHeight() + DISTANCE_NEXT_Y;
grpAmigaScreen->setMovable(false);
grpAmigaScreen->setSize(320, posY + DISTANCE_BORDER);
grpAmigaScreen->setBaseColor(gui_baseCol);
category.panel->add(grpAmigaScreen);
category.panel->add(chkFrameskip, DISTANCE_BORDER, DISTANCE_BORDER + grpAmigaScreen->getHeight() + DISTANCE_NEXT_Y);
RefreshPanelDisplay();
}
void ExitPanelDisplay(void)
{
delete lblAmigaWidth;
delete sldAmigaWidth;
delete lblAmigaWidthInfo;
delete lblAmigaHeight;
delete sldAmigaHeight;
delete lblAmigaHeightInfo;
delete lblVertPos;
delete sldVertPos;
delete lblVertPosInfo;
delete grpAmigaScreen;
delete chkFrameskip;
delete amigaScreenActionListener;
}
void RefreshPanelDisplay(void)
{
int i;
char tmp[32];
for(i=0; i<6; ++i)
{
if(changed_prefs.gfx_size.width == amigawidth_values[i])
{
sldAmigaWidth->setValue(i);
snprintf(tmp, 32, "%d", changed_prefs.gfx_size.width);
lblAmigaWidthInfo->setCaption(tmp);
break;
}
}
for(i=0; i<6; ++i)
{
if(changed_prefs.gfx_size.height == amigaheight_values[i])
{
sldAmigaHeight->setValue(i);
snprintf(tmp, 32, "%d", changed_prefs.gfx_size.height);
lblAmigaHeightInfo->setCaption(tmp);
break;
}
}
sldVertPos->setValue(changed_prefs.pandora_vertical_offset);
snprintf(tmp, 32, "%d", changed_prefs.pandora_vertical_offset);
lblVertPosInfo->setCaption(tmp);
chkFrameskip->setSelected(changed_prefs.gfx_framerate);
}

View file

@ -0,0 +1,505 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeRadioButton.hpp"
#include "UaeDropDown.hpp"
#include "UaeCheckBox.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "memory.h"
#include "disk.h"
#include "uae.h"
#include "gui.h"
#include "target.h"
#include "gui_handling.h"
static gcn::UaeCheckBox* chkDFx[4];
static gcn::UaeDropDown* cboDFxType[4];
static gcn::UaeCheckBox* chkDFxWriteProtect[4];
static gcn::Button* cmdDFxInfo[4];
static gcn::Button* cmdDFxEject[4];
static gcn::Button* cmdDFxSelect[4];
static gcn::UaeDropDown* cboDFxFile[4];
static gcn::Label* lblDriveSpeed;
static gcn::Label* lblDriveSpeedInfo;
static gcn::Slider* sldDriveSpeed;
static gcn::UaeCheckBox* chkLoadConfig;
static gcn::Button *cmdSaveForDisk;
static const char *diskfile_filter[] = { ".adf", ".adz", ".zip", ".gz", "\0" };
static const char *drivespeedlist[] = { "100% (compatible)", "200%", "400%", "800%" };
static const int drivespeedvalues[] = { 100, 200, 400, 800 };
static void AdjustDropDownControls(void);
class DriveTypeListModel : public gcn::ListModel
{
private:
std::vector<std::string> types;
public:
DriveTypeListModel()
{
types.push_back("Disabled");
types.push_back("3.5'' DD");
types.push_back("3.5'' HD");
types.push_back("5.25'' SD");
types.push_back("3.5'' ESCOM");
}
int getNumberOfElements()
{
return types.size();
}
std::string getElementAt(int i)
{
if(i < 0 || i >= types.size())
return "---";
return types[i];
}
};
static DriveTypeListModel driveTypeList;
class DiskfileListModel : public gcn::ListModel
{
public:
DiskfileListModel()
{
}
int getNumberOfElements()
{
return lstMRUDiskList.size();
}
std::string getElementAt(int i)
{
if(i < 0 || i >= lstMRUDiskList.size())
return "---";
return lstMRUDiskList[i];
}
};
static DiskfileListModel diskfileList;
class DriveTypeActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
//---------------------------------------
// New drive type selected
//---------------------------------------
for(int i=0; i<4; ++i)
{
if (actionEvent.getSource() == cboDFxType[i])
changed_prefs.dfxtype[i] = cboDFxType[i]->getSelected() - 1;
}
RefreshPanelFloppy();
}
};
static DriveTypeActionListener* driveTypeActionListener;
class DFxCheckActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
for(int i=0; i<4; ++i)
{
if (actionEvent.getSource() == chkDFx[i])
{
//---------------------------------------
// Drive enabled/disabled
//---------------------------------------
if(chkDFx[i]->isSelected())
changed_prefs.dfxtype[i] = DRV_35_DD;
else
changed_prefs.dfxtype[i] = DRV_NONE;
}
else if(actionEvent.getSource() == chkDFxWriteProtect[i])
{
//---------------------------------------
// Write-protect changed
//---------------------------------------
// ToDo: set write protect for floppy
}
}
RefreshPanelFloppy();
}
};
static DFxCheckActionListener* dfxCheckActionListener;
class DFxButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
for(int i=0; i<4; ++i)
{
if (actionEvent.getSource() == cmdDFxInfo[i])
{
//---------------------------------------
// Show info about current disk-image
//---------------------------------------
if(changed_prefs.dfxtype[i] != DRV_NONE && strlen(changed_prefs.df[i]) > 0)
; // ToDo: Show info dialog
}
else if (actionEvent.getSource() == cmdDFxEject[i])
{
//---------------------------------------
// Eject disk from drive
//---------------------------------------
disk_eject(i);
strcpy(changed_prefs.df[i], "");
AdjustDropDownControls();
}
else if (actionEvent.getSource() == cmdDFxSelect[i])
{
//---------------------------------------
// Select disk for drive
//---------------------------------------
char tmp[MAX_PATH];
if(strlen(changed_prefs.df[i]) > 0)
strncpy(tmp, changed_prefs.df[i], MAX_PATH);
else
strncpy(tmp, currentDir, MAX_PATH);
if(SelectFile("Select disk image file", tmp, diskfile_filter))
{
if(strncmp(changed_prefs.df[i], tmp, MAX_PATH))
{
strncpy(changed_prefs.df[i], tmp, sizeof(changed_prefs.df[i]));
disk_insert(i, tmp);
AddFileToDiskList(tmp, 1);
extractPath(tmp, currentDir);
if(i == 0 && chkLoadConfig->isSelected())
{
// Search for config of disk
extractFileName(changed_prefs.df[i], tmp);
removeFileExtension(tmp);
LoadConfigByName(tmp);
}
AdjustDropDownControls();
}
}
cmdDFxSelect[i]->requestFocus();
}
}
}
};
static DFxButtonActionListener* dfxButtonActionListener;
static bool bIgnoreListChange = false;
class DiskFileActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
for(int i=0; i<4; ++i)
{
if (actionEvent.getSource() == cboDFxFile[i])
{
//---------------------------------------
// Diskimage from list selected
//---------------------------------------
if(!bIgnoreListChange)
{
int idx = cboDFxFile[i]->getSelected();
if(idx < 0)
{
disk_eject(i);
strcpy(changed_prefs.df[i], "");
AdjustDropDownControls();
}
else
{
if(diskfileList.getElementAt(idx).compare(changed_prefs.df[i]))
{
strncpy(changed_prefs.df[i], diskfileList.getElementAt(idx).c_str(), sizeof(changed_prefs.df[i]));
disk_insert(i, changed_prefs.df[i]);
lstMRUDiskList.erase(lstMRUDiskList.begin() + idx);
lstMRUDiskList.insert(lstMRUDiskList.begin(), changed_prefs.df[i]);
bIgnoreListChange = true;
cboDFxFile[i]->setSelected(0);
bIgnoreListChange = false;
if(i == 0 && chkLoadConfig->isSelected())
{
// Search for config of disk
char tmp[MAX_PATH];
extractFileName(changed_prefs.df[i], tmp);
removeFileExtension(tmp);
LoadConfigByName(tmp);
}
}
}
}
}
}
}
};
static DiskFileActionListener* diskFileActionListener;
class DriveSpeedSliderActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
changed_prefs.floppy_speed = drivespeedvalues[(int)sldDriveSpeed->getValue()];
RefreshPanelFloppy();
}
};
static DriveSpeedSliderActionListener* driveSpeedSliderActionListener;
class SaveForDiskActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
//---------------------------------------
// Save configuration for current disk
//---------------------------------------
if(strlen(changed_prefs.df[0]) > 0)
{
char filename[MAX_DPATH];
char diskname[MAX_PATH];
extractFileName(changed_prefs.df[0], diskname);
removeFileExtension(diskname);
fetch_configurationpath(filename, MAX_DPATH);
strncat(filename, diskname, MAX_DPATH);
strncat(filename, ".uae", MAX_DPATH);
snprintf(changed_prefs.description, 256, "Configuration for disk '%s'", diskname);
if(cfgfile_save(&changed_prefs, filename, 0))
RefreshPanelConfig();
}
}
};
static SaveForDiskActionListener* saveForDiskActionListener;
void InitPanelFloppy(const struct _ConfigCategory& category)
{
int posX;
int posY = DISTANCE_BORDER;
int i;
dfxCheckActionListener = new DFxCheckActionListener();
driveTypeActionListener = new DriveTypeActionListener();
dfxButtonActionListener = new DFxButtonActionListener();
diskFileActionListener = new DiskFileActionListener();
driveSpeedSliderActionListener = new DriveSpeedSliderActionListener();
saveForDiskActionListener = new SaveForDiskActionListener();
for(i=0; i<4; ++i)
{
char tmp[20];
snprintf(tmp, 20, "DF%d:", i);
chkDFx[i] = new gcn::UaeCheckBox(tmp);
chkDFx[i]->addActionListener(dfxCheckActionListener);
cboDFxType[i] = new gcn::UaeDropDown(&driveTypeList);
cboDFxType[i]->setSize(106, DROPDOWN_HEIGHT);
cboDFxType[i]->setBaseColor(gui_baseCol);
snprintf(tmp, 20, "cboType%d", i);
cboDFxType[i]->setId(tmp);
cboDFxType[i]->addActionListener(driveTypeActionListener);
chkDFxWriteProtect[i] = new gcn::UaeCheckBox("Write-protected");
chkDFxWriteProtect[i]->addActionListener(dfxCheckActionListener);
chkDFxWriteProtect[i]->setEnabled(false);
cmdDFxInfo[i] = new gcn::Button("?");
cmdDFxInfo[i]->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdDFxInfo[i]->setBaseColor(gui_baseCol);
cmdDFxInfo[i]->addActionListener(dfxButtonActionListener);
cmdDFxEject[i] = new gcn::Button("Eject");
cmdDFxEject[i]->setSize(SMALL_BUTTON_WIDTH * 2, SMALL_BUTTON_HEIGHT);
cmdDFxEject[i]->setBaseColor(gui_baseCol);
snprintf(tmp, 20, "cmdEject%d", i);
cmdDFxEject[i]->setId(tmp);
cmdDFxEject[i]->addActionListener(dfxButtonActionListener);
cmdDFxSelect[i] = new gcn::Button("...");
cmdDFxSelect[i]->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdDFxSelect[i]->setBaseColor(gui_baseCol);
snprintf(tmp, 20, "cmdSel%d", i);
cmdDFxSelect[i]->setId(tmp);
cmdDFxSelect[i]->addActionListener(dfxButtonActionListener);
cboDFxFile[i] = new gcn::UaeDropDown(&diskfileList);
cboDFxFile[i]->setSize(category.panel->getWidth() - 2 * DISTANCE_BORDER, DROPDOWN_HEIGHT);
cboDFxFile[i]->setBaseColor(gui_baseCol);
snprintf(tmp, 20, "cboDisk%d", i);
cboDFxFile[i]->setId(tmp);
cboDFxFile[i]->addActionListener(diskFileActionListener);
if(i == 0)
{
chkLoadConfig = new gcn::UaeCheckBox("Load config with same name as disk");
chkLoadConfig->setId("LoadDiskCfg");
}
}
lblDriveSpeed = new gcn::Label("Floppy Drive Emulation Speed:");
sldDriveSpeed = new gcn::Slider(0, 3);
sldDriveSpeed->setSize(110, SLIDER_HEIGHT);
sldDriveSpeed->setBaseColor(gui_baseCol);
sldDriveSpeed->setMarkerLength(20);
sldDriveSpeed->setStepLength(1);
sldDriveSpeed->setId("DriveSpeed");
sldDriveSpeed->addActionListener(driveSpeedSliderActionListener);
lblDriveSpeedInfo = new gcn::Label(drivespeedlist[0]);
cmdSaveForDisk = new gcn::Button("Save config for disk");
cmdSaveForDisk->setSize(BUTTON_WIDTH * 2, BUTTON_HEIGHT);
cmdSaveForDisk->setBaseColor(gui_baseCol);
cmdSaveForDisk->setId("SaveForDisk");
cmdSaveForDisk->addActionListener(saveForDiskActionListener);
for(i=0; i<4; ++i)
{
posX = DISTANCE_BORDER;
category.panel->add(chkDFx[i], posX, posY);
posX += 100;
category.panel->add(cboDFxType[i], posX, posY);
posX += cboDFxType[i]->getWidth() + 2 * DISTANCE_NEXT_X;
// category.panel->add(chkDFxWriteProtect[i], posX, posY);
posX += chkDFxWriteProtect[i]->getWidth() + 4 * DISTANCE_NEXT_X;
// category.panel->add(cmdDFxInfo[i], posX, posY);
posX += cmdDFxInfo[i]->getWidth() + DISTANCE_NEXT_X;
category.panel->add(cmdDFxEject[i], posX, posY);
posX += cmdDFxEject[i]->getWidth() + DISTANCE_NEXT_X;
category.panel->add(cmdDFxSelect[i], posX, posY);
posY += chkDFx[i]->getHeight() + 8;
category.panel->add(cboDFxFile[i], DISTANCE_BORDER, posY);
if(i == 0)
{
posY += cboDFxFile[i]->getHeight() + 8;
category.panel->add(chkLoadConfig, DISTANCE_BORDER, posY);
}
posY += cboDFxFile[i]->getHeight() + DISTANCE_NEXT_Y + 4;
}
posX = DISTANCE_BORDER;
category.panel->add(lblDriveSpeed, posX, posY);
posX += lblDriveSpeed->getWidth() + 8;
category.panel->add(sldDriveSpeed, posX, posY);
posX += sldDriveSpeed->getWidth() + DISTANCE_NEXT_X;
category.panel->add(lblDriveSpeedInfo, posX, posY);
posY += sldDriveSpeed->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(cmdSaveForDisk, DISTANCE_BORDER, category.panel->getHeight() - DISTANCE_BORDER - BUTTON_HEIGHT);
RefreshPanelFloppy();
}
void ExitPanelFloppy(void)
{
for(int i=0; i<4; ++i)
{
delete chkDFx[i];
delete cboDFxType[i];
delete chkDFxWriteProtect[i];
delete cmdDFxInfo[i];
delete cmdDFxEject[i];
delete cmdDFxSelect[i];
delete cboDFxFile[i];
}
delete chkLoadConfig;
delete lblDriveSpeed;
delete sldDriveSpeed;
delete lblDriveSpeedInfo;
delete cmdSaveForDisk;
delete dfxCheckActionListener;
delete driveTypeActionListener;
delete dfxButtonActionListener;
delete diskFileActionListener;
delete driveSpeedSliderActionListener;
delete saveForDiskActionListener;
}
static void AdjustDropDownControls(void)
{
int i, j;
bIgnoreListChange = true;
for(i=0; i<4; ++i)
{
cboDFxFile[i]->clearSelected();
if((changed_prefs.dfxtype[i] != DRV_NONE) && strlen(changed_prefs.df[i]) > 0)
{
for(j=0; j<lstMRUDiskList.size(); ++j)
{
if(!lstMRUDiskList[j].compare(changed_prefs.df[i]))
{
cboDFxFile[i]->setSelected(j);
break;
}
}
}
}
bIgnoreListChange = false;
}
void RefreshPanelFloppy(void)
{
int i;
AdjustDropDownControls();
for(i=0; i<4; ++i)
{
bool driveEnabled = changed_prefs.dfxtype[i] != DRV_NONE;
chkDFx[i]->setSelected(driveEnabled);
cboDFxType[i]->setSelected(changed_prefs.dfxtype[i] + 1);
chkDFxWriteProtect[i]->setSelected(false);
cmdDFxInfo[i]->setEnabled(driveEnabled);
cmdDFxEject[i]->setEnabled(driveEnabled);
cmdDFxSelect[i]->setEnabled(driveEnabled);
cboDFxFile[i]->setEnabled(driveEnabled);
}
chkLoadConfig->setSelected(true);
for(i=0; i<4; ++i)
{
if(changed_prefs.floppy_speed == drivespeedvalues[i])
{
sldDriveSpeed->setValue(i);
lblDriveSpeedInfo->setCaption(drivespeedlist[i]);
break;
}
}
}

View file

@ -0,0 +1,292 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeRadioButton.hpp"
#include "UaeDropDown.hpp"
#include "UaeCheckBox.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "memory.h"
#include "uae.h"
#include "autoconf.h"
#include "filesys.h"
#include "gui.h"
#include "target.h"
#include "gui_handling.h"
#define MAX_HD_DEVICES 5
enum { COL_DEVICE, COL_VOLUME, COL_PATH, COL_READWRITE, COL_SIZE, COL_BOOTPRI, COL_COUNT };
static const char *column_caption[] = {
"Device", "Volume", "Path", "R/W", "Size", "Bootpri" };
static const int COLUMN_SIZE[] = {
50, // Device
70, // Volume
260, // Path
40, // R/W
50, // Size
50 // Bootpri
};
static gcn::Label* lblList[COL_COUNT];
static gcn::Container* listEntry[MAX_HD_DEVICES];
static gcn::TextField* listCells[MAX_HD_DEVICES][COL_COUNT];
static gcn::Button* listCmdProps[MAX_HD_DEVICES];
static gcn::ImageButton* listCmdDelete[MAX_HD_DEVICES];
static gcn::Button* cmdAddDirectory;
static gcn::Button* cmdAddHardfile;
class HDRemoveActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
for(int i=0; i<MAX_HD_DEVICES; ++i)
{
if (actionEvent.getSource() == listCmdDelete[i])
{
kill_filesys_unit(currprefs.mountinfo, i);
break;
}
}
cmdAddDirectory->requestFocus();
RefreshPanelHD();
}
};
static HDRemoveActionListener* hdRemoveActionListener;
class HDEditActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
for(int i=0; i<MAX_HD_DEVICES; ++i)
{
if (actionEvent.getSource() == listCmdProps[i])
{
int type = is_hardfile (currprefs.mountinfo, i);
if(type == FILESYS_VIRTUAL)
EditFilesysVirtual(i);
else
EditFilesysHardfile(i);
listCmdProps[i]->requestFocus();
break;
}
}
RefreshPanelHD();
}
};
static HDEditActionListener* hdEditActionListener;
class AddVirtualHDActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
EditFilesysVirtual(-1);
cmdAddDirectory->requestFocus();
RefreshPanelHD();
}
};
AddVirtualHDActionListener* addVirtualHDActionListener;
class AddHardfileActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
EditFilesysHardfile(-1);
cmdAddHardfile->requestFocus();
RefreshPanelHD();
}
};
AddHardfileActionListener* addHardfileActionListener;
void InitPanelHD(const struct _ConfigCategory& category)
{
int row, col;
int posX;
int posY = DISTANCE_BORDER;
char tmp[20];
hdRemoveActionListener = new HDRemoveActionListener();
hdEditActionListener = new HDEditActionListener();
addVirtualHDActionListener = new AddVirtualHDActionListener();
addHardfileActionListener = new AddHardfileActionListener();
for(col=0; col<COL_COUNT; ++col)
lblList[col] = new gcn::Label(column_caption[col]);
for(row=0; row<MAX_HD_DEVICES; ++row)
{
listEntry[row] = new gcn::Container();
listEntry[row]->setSize(category.panel->getWidth() - 2 * DISTANCE_BORDER, TEXTFIELD_HEIGHT + 4);
listEntry[row]->setBaseColor(gui_baseCol);
listEntry[row]->setFrameSize(0);
listCmdProps[row] = new gcn::Button("...");
listCmdProps[row]->setBaseColor(gui_baseCol);
listCmdProps[row]->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
snprintf(tmp, 20, "cmdProp%d", row);
listCmdProps[row]->setId(tmp);
listCmdProps[row]->addActionListener(hdEditActionListener);
listCmdDelete[row] = new gcn::ImageButton("data/delete.png");
listCmdDelete[row]->setBaseColor(gui_baseCol);
listCmdDelete[row]->setSize(SMALL_BUTTON_HEIGHT, SMALL_BUTTON_HEIGHT);
snprintf(tmp, 20, "cmdDel%d", row);
listCmdDelete[row]->setId(tmp);
listCmdDelete[row]->addActionListener(hdRemoveActionListener);
for(col=0; col<COL_COUNT; ++col)
{
listCells[row][col] = new gcn::TextField();
listCells[row][col]->setSize(COLUMN_SIZE[col] - 8, TEXTFIELD_HEIGHT);
listCells[row][col]->setEnabled(false);
listCells[row][col]->setBackgroundColor(gui_baseCol);
}
}
cmdAddDirectory = new gcn::Button("Add Directory");
cmdAddDirectory->setBaseColor(gui_baseCol);
cmdAddDirectory->setSize(BUTTON_WIDTH + 20, BUTTON_HEIGHT);
cmdAddDirectory->setId("cmdAddDir");
cmdAddDirectory->addActionListener(addVirtualHDActionListener);
cmdAddHardfile = new gcn::Button("Add Hardfile");
cmdAddHardfile->setBaseColor(gui_baseCol);
cmdAddHardfile->setSize(BUTTON_WIDTH + 20, BUTTON_HEIGHT);
cmdAddHardfile->setId("cmdAddHDF");
cmdAddHardfile->addActionListener(addHardfileActionListener);
posX = DISTANCE_BORDER + 2 + SMALL_BUTTON_WIDTH + 34;
for(col=0; col<COL_COUNT; ++col)
{
category.panel->add(lblList[col], posX, posY);
posX += COLUMN_SIZE[col];
}
posY += lblList[0]->getHeight() + 2;
for(row=0; row<MAX_HD_DEVICES; ++row)
{
posX = 0;
listEntry[row]->add(listCmdProps[row], posX, 2);
posX += listCmdProps[row]->getWidth() + 4;
listEntry[row]->add(listCmdDelete[row], posX, 2);
posX += listCmdDelete[row]->getWidth() + 8;
for(col=0; col<COL_COUNT; ++col)
{
listEntry[row]->add(listCells[row][col], posX, 2);
posX += COLUMN_SIZE[col];
}
category.panel->add(listEntry[row], DISTANCE_BORDER, posY);
posY += listEntry[row]->getHeight() + 4;
}
posY = category.panel->getHeight() - DISTANCE_BORDER - BUTTON_HEIGHT;
category.panel->add(cmdAddDirectory, DISTANCE_BORDER, posY);
category.panel->add(cmdAddHardfile, DISTANCE_BORDER + cmdAddDirectory->getWidth() + DISTANCE_NEXT_X, posY);
RefreshPanelHD();
}
void ExitPanelHD(void)
{
int row, col;
for(col=0; col<COL_COUNT; ++col)
delete lblList[col];
for(row=0; row<MAX_HD_DEVICES; ++row)
{
delete listCmdProps[row];
delete listCmdDelete[row];
for(col=0; col<COL_COUNT; ++col)
delete listCells[row][col];
delete listEntry[row];
}
delete cmdAddDirectory;
delete cmdAddHardfile;
delete hdRemoveActionListener;
delete hdEditActionListener;
delete addVirtualHDActionListener;
delete addHardfileActionListener;
}
void RefreshPanelHD(void)
{
int row, col;
char tmp[32];
char *volname, *devname, *rootdir, *filesys;
int secspertrack, surfaces, cylinders, reserved, blocksize, readonly, type, bootpri;
uae_u64 size;
const char *failure;
int units = nr_units(currprefs.mountinfo);
for(row=0; row<MAX_HD_DEVICES; ++row)
{
if(row < units)
{
failure = get_filesys_unit(currprefs.mountinfo, row,
&devname, &volname, &rootdir, &readonly, &secspertrack, &surfaces, &reserved,
&cylinders, &size, &blocksize, &bootpri, &filesys, 0);
type = is_hardfile (currprefs.mountinfo, row);
if(type == FILESYS_VIRTUAL)
{
listCells[row][COL_DEVICE]->setText(devname);
listCells[row][COL_VOLUME]->setText(volname);
listCells[row][COL_PATH]->setText(rootdir);
if(readonly)
listCells[row][COL_READWRITE]->setText("no");
else
listCells[row][COL_READWRITE]->setText("yes");
listCells[row][COL_SIZE]->setText("n/a");
snprintf(tmp, 32, "%d", bootpri);
listCells[row][COL_BOOTPRI]->setText(tmp);
}
else
{
listCells[row][COL_DEVICE]->setText(devname);
listCells[row][COL_VOLUME]->setText("n/a");
listCells[row][COL_PATH]->setText(rootdir);
if(readonly)
listCells[row][COL_READWRITE]->setText("no");
else
listCells[row][COL_READWRITE]->setText("yes");
if (size >= 1024 * 1024 * 1024)
snprintf (tmp, 32, "%.1fG", ((double)(uae_u32)(size / (1024 * 1024))) / 1024.0);
else
snprintf (tmp, 32, "%.1fM", ((double)(uae_u32)(size / (1024))) / 1024.0);
listCells[row][COL_SIZE]->setText(tmp);
snprintf(tmp, 32, "%d", bootpri);
listCells[row][COL_BOOTPRI]->setText(tmp);
}
listCmdProps[row]->setEnabled(true);
listCmdDelete[row]->setEnabled(true);
}
else
{
// Empty slot
for(col=0; col<COL_COUNT; ++col)
listCells[row][col]->setText("");
listCmdProps[row]->setEnabled(false);
listCmdDelete[row]->setEnabled(false);
}
}
}

View file

@ -0,0 +1,536 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeRadioButton.hpp"
#include "UaeDropDown.hpp"
#include "UaeCheckBox.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "memory.h"
#include "uae.h"
#include "autoconf.h"
#include "filesys.h"
#include "gui.h"
#include "target.h"
#include "gui_handling.h"
static const char *mousespeed_list[] = { ".25", ".5", "1x", "2x", "4x" };
static const int mousespeed_values[] = { 2, 5, 10, 20, 40 };
static const char *stylusoffset_list[] = { "None", "1 px", "2 px", "3 px", "4 px", "5 px", "6 px", "7 px", "8 px", "9 px", "10 px" };
static const int stylusoffset_values[] = { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 };
static gcn::Label *lblCtrlConfig;
static gcn::UaeDropDown* cboCtrlConfig;
static gcn::Label *lblJoystick;
static gcn::UaeDropDown* cboJoystick;
static gcn::Label *lblAutofire;
static gcn::UaeDropDown* cboAutofire;
static gcn::Label* lblMouseSpeed;
static gcn::Label* lblMouseSpeedInfo;
static gcn::Slider* sldMouseSpeed;
static gcn::Label *lblTapDelay;
static gcn::UaeDropDown* cboTapDelay;
static gcn::Label* lblStylusOffset;
static gcn::Label* lblStylusOffsetInfo;
static gcn::Slider* sldStylusOffset;
static gcn::UaeCheckBox* chkCustomCtrl;
static gcn::Label *lblDPAD;
static gcn::UaeDropDown* cboDPAD;
static gcn::Label *lblA;
static gcn::UaeDropDown* cboA;
static gcn::Label *lblB;
static gcn::UaeDropDown* cboB;
static gcn::Label *lblX;
static gcn::UaeDropDown* cboX;
static gcn::Label *lblY;
static gcn::UaeDropDown* cboY;
static gcn::Label *lblL;
static gcn::UaeDropDown* cboL;
static gcn::Label *lblR;
static gcn::UaeDropDown* cboR;
static gcn::Label *lblUp;
static gcn::UaeDropDown* cboUp;
static gcn::Label *lblDown;
static gcn::UaeDropDown* cboDown;
static gcn::Label *lblLeft;
static gcn::UaeDropDown* cboLeft;
static gcn::Label *lblRight;
static gcn::UaeDropDown* cboRight;
class StringListModel : public gcn::ListModel
{
private:
std::vector<std::string> values;
public:
StringListModel(const char *entries[], int count)
{
for(int i=0; i<count; ++i)
values.push_back(entries[i]);
}
int getNumberOfElements()
{
return values.size();
}
std::string getElementAt(int i)
{
if(i < 0 || i >= values.size())
return "---";
return values[i];
}
};
const char *ctrlConfigValues[] = {
"A=Autofire, X=Fire, Y=Space, B=2nd",
"A=Fire, X=Autofire, Y=Space, B=2nd",
"A=Autofire, X=Jump, Y=Fire, B=2nd",
"A=Fire, X=Jump, Y=Autofire, B=2nd"
};
StringListModel ctrlConfigList(ctrlConfigValues, 4);
const char *joystickValues[] = { "Port0", "Port1", "Both" };
StringListModel joystickList(joystickValues, 3);
const char *autofireValues[] = { "Light", "Medium", "Heavy" };
StringListModel autofireList(autofireValues, 3);
const char *tapDelayValues[] = { "Normal", "Short", "None" };
StringListModel tapDelayList(tapDelayValues, 3);
const char *dPADValues[] = { "Joystick", "Mouse", "Custom" };
StringListModel dPADList(dPADValues, 3);
const char *mappingValues[] = {
"Joystick Right", "Joystick Left", "Joystick Down", "Joystick Up",
"Joystick fire but.2", "Joystick fire but.1", "Mouse right button", "Mouse left button",
"------------------",
"Arrow Up", "Arrow Down", "Arrow Left", "Arrow Right", "Numpad 0", "Numpad 1", "Numpad 2",
"Numpad 3", "Numpad 4", "Numpad 5", "Numpad 6", "Numpad 7", "Numpad 8", "Numpad 9",
"Numpad Enter", "Numpad /", "Numpad *", "Numpad -", "Numpad +",
"Numpad Delete", "Numpad (", "Numpad )",
"Space", "Backspace", "Tab", "Return", "Escape", "Delete",
"Left Shift", "Right Shift", "CAPS LOCK", "CTRL", "Left ALT", "Right ALT",
"Left Amiga Key", "Right Amiga Key", "Help", "Left Bracket", "Right Bracket",
"Semicolon", "Comma", "Period", "Slash", "Backslash", "Quote", "#",
"</>", "Backquote", "-", "=",
"A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z",
"1", "2", "3", "4", "5", "6", "7", "8", "9", "0",
"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "NULL"
};
StringListModel mappingList(mappingValues, 105);
class InputActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == cboCtrlConfig)
changed_prefs.pandora_joyConf = cboCtrlConfig->getSelected();
else if (actionEvent.getSource() == cboJoystick)
changed_prefs.pandora_joyPort = (cboJoystick->getSelected() + 1) % 3;
else if (actionEvent.getSource() == cboAutofire)
{
if(cboAutofire->getSelected() == 0)
changed_prefs.input_autofire_framecnt = 12;
else if (cboAutofire->getSelected() == 1)
changed_prefs.input_autofire_framecnt = 8;
else
changed_prefs.input_autofire_framecnt = 4;
}
else if (actionEvent.getSource() == sldMouseSpeed)
{
changed_prefs.input_joymouse_multiplier = mousespeed_values[(int)(sldMouseSpeed->getValue())];
RefreshPanelInput();
}
else if (actionEvent.getSource() == cboTapDelay)
{
if(cboTapDelay->getSelected() == 0)
changed_prefs.pandora_tapDelay = 10;
else if (cboTapDelay->getSelected() == 1)
changed_prefs.pandora_tapDelay = 5;
else
changed_prefs.pandora_tapDelay = 2;
}
else if (actionEvent.getSource() == sldStylusOffset)
{
changed_prefs.pandora_stylusOffset = stylusoffset_values[(int)(sldStylusOffset->getValue())];
RefreshPanelInput();
}
else if (actionEvent.getSource() == chkCustomCtrl)
changed_prefs.pandora_customControls = chkCustomCtrl->isSelected() ? 1 : 0;
else if (actionEvent.getSource() == cboDPAD)
changed_prefs.pandora_custom_dpad = cboDPAD->getSelected();
else if (actionEvent.getSource() == cboA)
changed_prefs.pandora_custom_A = cboA->getSelected() - 8;
else if (actionEvent.getSource() == cboB)
changed_prefs.pandora_custom_B = cboB->getSelected() - 8;
else if (actionEvent.getSource() == cboX)
changed_prefs.pandora_custom_X = cboX->getSelected() - 8;
else if (actionEvent.getSource() == cboY)
changed_prefs.pandora_custom_Y = cboY->getSelected() - 8;
else if (actionEvent.getSource() == cboL)
changed_prefs.pandora_custom_L = cboL->getSelected() - 8;
else if (actionEvent.getSource() == cboR)
changed_prefs.pandora_custom_R = cboR->getSelected() - 8;
else if (actionEvent.getSource() == cboUp)
changed_prefs.pandora_custom_up = cboUp->getSelected() - 8;
else if (actionEvent.getSource() == cboDown)
changed_prefs.pandora_custom_down = cboDown->getSelected() - 8;
else if (actionEvent.getSource() == cboLeft)
changed_prefs.pandora_custom_left = cboLeft->getSelected() - 8;
else if (actionEvent.getSource() == cboRight)
changed_prefs.pandora_custom_right = cboRight->getSelected() - 8;
}
};
static InputActionListener* inputActionListener;
void InitPanelInput(const struct _ConfigCategory& category)
{
inputActionListener = new InputActionListener();
lblCtrlConfig = new gcn::Label("Control Config:");
lblCtrlConfig->setSize(100, LABEL_HEIGHT);
lblCtrlConfig->setAlignment(gcn::Graphics::RIGHT);
cboCtrlConfig = new gcn::UaeDropDown(&ctrlConfigList);
cboCtrlConfig->setSize(280, DROPDOWN_HEIGHT);
cboCtrlConfig->setBaseColor(gui_baseCol);
cboCtrlConfig->setId("cboCtrlConfig");
cboCtrlConfig->addActionListener(inputActionListener);
lblJoystick = new gcn::Label("Joystick:");
lblJoystick->setSize(100, LABEL_HEIGHT);
lblJoystick->setAlignment(gcn::Graphics::RIGHT);
cboJoystick = new gcn::UaeDropDown(&joystickList);
cboJoystick->setSize(80, DROPDOWN_HEIGHT);
cboJoystick->setBaseColor(gui_baseCol);
cboJoystick->setId("cboJoystick");
cboJoystick->addActionListener(inputActionListener);
lblAutofire = new gcn::Label("Autofire Rate:");
lblAutofire->setSize(100, LABEL_HEIGHT);
lblAutofire->setAlignment(gcn::Graphics::RIGHT);
cboAutofire = new gcn::UaeDropDown(&autofireList);
cboAutofire->setSize(80, DROPDOWN_HEIGHT);
cboAutofire->setBaseColor(gui_baseCol);
cboAutofire->setId("cboAutofire");
cboAutofire->addActionListener(inputActionListener);
lblMouseSpeed = new gcn::Label("Mouse Speed:");
lblMouseSpeed->setSize(100, LABEL_HEIGHT);
lblMouseSpeed->setAlignment(gcn::Graphics::RIGHT);
sldMouseSpeed = new gcn::Slider(0, 4);
sldMouseSpeed->setSize(110, SLIDER_HEIGHT);
sldMouseSpeed->setBaseColor(gui_baseCol);
sldMouseSpeed->setMarkerLength(20);
sldMouseSpeed->setStepLength(1);
sldMouseSpeed->setId("MouseSpeed");
sldMouseSpeed->addActionListener(inputActionListener);
lblMouseSpeedInfo = new gcn::Label(".25");
lblTapDelay = new gcn::Label("Tap Delay:");
lblTapDelay->setSize(100, LABEL_HEIGHT);
lblTapDelay->setAlignment(gcn::Graphics::RIGHT);
cboTapDelay = new gcn::UaeDropDown(&tapDelayList);
cboTapDelay->setSize(80, DROPDOWN_HEIGHT);
cboTapDelay->setBaseColor(gui_baseCol);
cboTapDelay->setId("cboTapDelay");
cboTapDelay->addActionListener(inputActionListener);
lblStylusOffset = new gcn::Label("Stylus Offset:");
lblStylusOffset->setSize(100, LABEL_HEIGHT);
lblStylusOffset->setAlignment(gcn::Graphics::RIGHT);
sldStylusOffset = new gcn::Slider(0, 10);
sldStylusOffset->setSize(110, SLIDER_HEIGHT);
sldStylusOffset->setBaseColor(gui_baseCol);
sldStylusOffset->setMarkerLength(20);
sldStylusOffset->setStepLength(1);
sldStylusOffset->setId("StylusOffset");
sldStylusOffset->addActionListener(inputActionListener);
lblStylusOffsetInfo = new gcn::Label("10 px");
chkCustomCtrl = new gcn::UaeCheckBox("Custom Control");
chkCustomCtrl->setId("CustomCtrl");
chkCustomCtrl->addActionListener(inputActionListener);
lblDPAD = new gcn::Label("DPAD:");
lblDPAD->setSize(100, LABEL_HEIGHT);
lblDPAD->setAlignment(gcn::Graphics::RIGHT);
cboDPAD = new gcn::UaeDropDown(&dPADList);
cboDPAD->setSize(80, DROPDOWN_HEIGHT);
cboDPAD->setBaseColor(gui_baseCol);
cboDPAD->setId("cboDPAD");
cboDPAD->addActionListener(inputActionListener);
lblA = new gcn::Label("<A>:");
lblA->setSize(100, LABEL_HEIGHT);
lblA->setAlignment(gcn::Graphics::RIGHT);
cboA = new gcn::UaeDropDown(&mappingList);
cboA->setSize(150, DROPDOWN_HEIGHT);
cboA->setBaseColor(gui_baseCol);
cboA->setId("cboA");
cboA->addActionListener(inputActionListener);
lblB = new gcn::Label("<B>:");
lblB->setSize(100, LABEL_HEIGHT);
lblB->setAlignment(gcn::Graphics::RIGHT);
cboB = new gcn::UaeDropDown(&mappingList);
cboB->setSize(150, DROPDOWN_HEIGHT);
cboB->setBaseColor(gui_baseCol);
cboB->setId("cboB");
cboB->addActionListener(inputActionListener);
lblX = new gcn::Label("<X>:");
lblX->setSize(100, LABEL_HEIGHT);
lblX->setAlignment(gcn::Graphics::RIGHT);
cboX = new gcn::UaeDropDown(&mappingList);
cboX->setSize(150, DROPDOWN_HEIGHT);
cboX->setBaseColor(gui_baseCol);
cboX->setId("cboX");
cboX->addActionListener(inputActionListener);
lblY = new gcn::Label("<Y>:");
lblY->setSize(100, LABEL_HEIGHT);
lblY->setAlignment(gcn::Graphics::RIGHT);
cboY = new gcn::UaeDropDown(&mappingList);
cboY->setSize(150, DROPDOWN_HEIGHT);
cboY->setBaseColor(gui_baseCol);
cboY->setId("cboY");
cboY->addActionListener(inputActionListener);
lblL = new gcn::Label("<L>:");
lblL->setSize(100, LABEL_HEIGHT);
lblL->setAlignment(gcn::Graphics::RIGHT);
cboL = new gcn::UaeDropDown(&mappingList);
cboL->setSize(150, DROPDOWN_HEIGHT);
cboL->setBaseColor(gui_baseCol);
cboL->setId("cboL");
cboL->addActionListener(inputActionListener);
lblR = new gcn::Label("<R>:");
lblR->setSize(100, LABEL_HEIGHT);
lblR->setAlignment(gcn::Graphics::RIGHT);
cboR = new gcn::UaeDropDown(&mappingList);
cboR->setSize(150, DROPDOWN_HEIGHT);
cboR->setBaseColor(gui_baseCol);
cboR->setId("cboR");
cboR->addActionListener(inputActionListener);
lblUp = new gcn::Label("Up:");
lblUp->setSize(100, LABEL_HEIGHT);
lblUp->setAlignment(gcn::Graphics::RIGHT);
cboUp = new gcn::UaeDropDown(&mappingList);
cboUp->setSize(150, DROPDOWN_HEIGHT);
cboUp->setBaseColor(gui_baseCol);
cboUp->setId("cboUp");
cboUp->addActionListener(inputActionListener);
lblDown = new gcn::Label("Down:");
lblDown->setSize(100, LABEL_HEIGHT);
lblDown->setAlignment(gcn::Graphics::RIGHT);
cboDown = new gcn::UaeDropDown(&mappingList);
cboDown->setSize(150, DROPDOWN_HEIGHT);
cboDown->setBaseColor(gui_baseCol);
cboDown->setId("cboDown");
cboDown->addActionListener(inputActionListener);
lblLeft = new gcn::Label("Left:");
lblLeft->setSize(100, LABEL_HEIGHT);
lblLeft->setAlignment(gcn::Graphics::RIGHT);
cboLeft = new gcn::UaeDropDown(&mappingList);
cboLeft->setSize(150, DROPDOWN_HEIGHT);
cboLeft->setBaseColor(gui_baseCol);
cboLeft->setId("cboLeft");
cboLeft->addActionListener(inputActionListener);
lblRight = new gcn::Label("Right:");
lblRight->setSize(100, LABEL_HEIGHT);
lblRight->setAlignment(gcn::Graphics::RIGHT);
cboRight = new gcn::UaeDropDown(&mappingList);
cboRight->setSize(150, DROPDOWN_HEIGHT);
cboRight->setBaseColor(gui_baseCol);
cboRight->setId("cboRight");
cboRight->addActionListener(inputActionListener);
int posY = DISTANCE_BORDER;
category.panel->add(lblCtrlConfig, DISTANCE_BORDER, posY);
category.panel->add(cboCtrlConfig, DISTANCE_BORDER + lblCtrlConfig->getWidth() + 8, posY);
posY += cboCtrlConfig->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblJoystick, DISTANCE_BORDER, posY);
category.panel->add(cboJoystick, DISTANCE_BORDER + lblJoystick->getWidth() + 8, posY);
category.panel->add(lblAutofire, 300, posY);
category.panel->add(cboAutofire, 300 + lblAutofire->getWidth() + 8, posY);
posY += cboAutofire->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblTapDelay, DISTANCE_BORDER, posY);
category.panel->add(cboTapDelay, DISTANCE_BORDER + lblTapDelay->getWidth() + 8, posY);
posY += cboTapDelay->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblMouseSpeed, DISTANCE_BORDER, posY);
category.panel->add(sldMouseSpeed, DISTANCE_BORDER + lblMouseSpeed->getWidth() + 8, posY);
category.panel->add(lblMouseSpeedInfo, sldMouseSpeed->getX() + sldMouseSpeed->getWidth() + 12, posY);
posY += sldMouseSpeed->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblStylusOffset, DISTANCE_BORDER, posY);
category.panel->add(sldStylusOffset, DISTANCE_BORDER + lblStylusOffset->getWidth() + 8, posY);
category.panel->add(lblStylusOffsetInfo, sldStylusOffset->getX() + sldStylusOffset->getWidth() + 12, posY);
posY += sldStylusOffset->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblDPAD, DISTANCE_BORDER, posY);
category.panel->add(cboDPAD, DISTANCE_BORDER + lblDPAD->getWidth() + 8, posY);
category.panel->add(chkCustomCtrl, 320, posY);
posY += cboDPAD->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblA, DISTANCE_BORDER, posY);
category.panel->add(cboA, DISTANCE_BORDER + lblA->getWidth() + 8, posY);
category.panel->add(lblB, 300, posY);
category.panel->add(cboB, 300 + lblB->getWidth() + 8, posY);
posY += cboA->getHeight() + 4;
category.panel->add(lblX, DISTANCE_BORDER, posY);
category.panel->add(cboX, DISTANCE_BORDER + lblX->getWidth() + 8, posY);
category.panel->add(lblY, 300, posY);
category.panel->add(cboY, 300 + lblY->getWidth() + 8, posY);
posY += cboX->getHeight() + 4;
category.panel->add(lblL, DISTANCE_BORDER, posY);
category.panel->add(cboL, DISTANCE_BORDER + lblL->getWidth() + 8, posY);
category.panel->add(lblR, 300, posY);
category.panel->add(cboR, 300 + lblR->getWidth() + 8, posY);
posY += cboL->getHeight() + 4;
category.panel->add(lblUp, DISTANCE_BORDER, posY);
category.panel->add(cboUp, DISTANCE_BORDER + lblUp->getWidth() + 8, posY);
category.panel->add(lblDown, 300, posY);
category.panel->add(cboDown, 300 + lblDown->getWidth() + 8, posY);
posY += cboUp->getHeight() + 4;
category.panel->add(lblLeft, DISTANCE_BORDER, posY);
category.panel->add(cboLeft, DISTANCE_BORDER + lblLeft->getWidth() + 8, posY);
category.panel->add(lblRight, 300, posY);
category.panel->add(cboRight, 300 + lblRight->getWidth() + 8, posY);
posY += cboLeft->getHeight() + 4;
RefreshPanelInput();
}
void ExitPanelInput(void)
{
delete lblCtrlConfig;
delete cboCtrlConfig;
delete lblJoystick;
delete cboJoystick;
delete lblAutofire;
delete cboAutofire;
delete lblMouseSpeed;
delete sldMouseSpeed;
delete lblMouseSpeedInfo;
delete lblTapDelay;
delete cboTapDelay;
delete lblStylusOffset;
delete sldStylusOffset;
delete lblStylusOffsetInfo;
delete chkCustomCtrl;
delete lblDPAD;
delete cboDPAD;
delete lblA;
delete cboA;
delete lblB;
delete cboB;
delete lblX;
delete cboX;
delete lblY;
delete cboY;
delete lblL;
delete cboL;
delete lblR;
delete cboR;
delete lblUp;
delete cboUp;
delete lblDown;
delete cboDown;
delete lblLeft;
delete cboLeft;
delete lblRight;
delete cboRight;
delete inputActionListener;
}
void RefreshPanelInput(void)
{
int i;
cboCtrlConfig->setSelected(changed_prefs.pandora_joyConf);
cboJoystick->setSelected((changed_prefs.pandora_joyPort + 2) % 3);
if (changed_prefs.input_autofire_framecnt == 12)
cboAutofire->setSelected(0);
else if (changed_prefs.input_autofire_framecnt == 8)
cboAutofire->setSelected(1);
else
cboAutofire->setSelected(2);
for(i=0; i<5; ++i)
{
if(changed_prefs.input_joymouse_multiplier == mousespeed_values[i])
{
sldMouseSpeed->setValue(i);
lblMouseSpeedInfo->setCaption(mousespeed_list[i]);
break;
}
}
if (changed_prefs.pandora_tapDelay == 10)
cboTapDelay->setSelected(0);
else if (changed_prefs.pandora_tapDelay == 5)
cboTapDelay->setSelected(1);
else
cboTapDelay->setSelected(2);
for(i=0; i<11; ++i)
{
if(changed_prefs.pandora_stylusOffset == stylusoffset_values[i])
{
sldStylusOffset->setValue(i);
lblStylusOffsetInfo->setCaption(stylusoffset_list[i]);
break;
}
}
chkCustomCtrl->setSelected(changed_prefs.pandora_customControls);
cboDPAD->setSelected(changed_prefs.pandora_custom_dpad);
cboA->setSelected(changed_prefs.pandora_custom_A + 8);
cboB->setSelected(changed_prefs.pandora_custom_B + 8);
cboX->setSelected(changed_prefs.pandora_custom_X + 8);
cboY->setSelected(changed_prefs.pandora_custom_Y + 8);
cboL->setSelected(changed_prefs.pandora_custom_L + 8);
cboR->setSelected(changed_prefs.pandora_custom_R + 8);
cboUp->setSelected(changed_prefs.pandora_custom_up + 8);
cboDown->setSelected(changed_prefs.pandora_custom_down + 8);
cboLeft->setSelected(changed_prefs.pandora_custom_left + 8);
cboRight->setSelected(changed_prefs.pandora_custom_right + 8);
}

View file

@ -0,0 +1,114 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeRadioButton.hpp"
#include "UaeDropDown.hpp"
#include "UaeCheckBox.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "memory.h"
#include "uae.h"
#include "autoconf.h"
#include "filesys.h"
#include "gui.h"
#include "target.h"
#include "gui_handling.h"
static gcn::UaeCheckBox* chkStatusLine;
static gcn::UaeCheckBox* chkShowGUI;
static gcn::Label* lblPandoraSpeed;
static gcn::Label* lblPandoraSpeedInfo;
static gcn::Slider* sldPandoraSpeed;
class MiscActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == chkStatusLine)
changed_prefs.leds_on_screen = chkStatusLine->isSelected();
else if (actionEvent.getSource() == chkShowGUI)
changed_prefs.start_gui = chkShowGUI->isSelected();
else if (actionEvent.getSource() == sldPandoraSpeed)
{
int newspeed = (int) sldPandoraSpeed->getValue();
newspeed = newspeed - (newspeed % 20);
if(changed_prefs.pandora_cpu_speed != newspeed)
{
changed_prefs.pandora_cpu_speed = newspeed;
RefreshPanelMisc();
}
}
}
};
MiscActionListener* miscActionListener;
void InitPanelMisc(const struct _ConfigCategory& category)
{
miscActionListener = new MiscActionListener();
chkStatusLine = new gcn::UaeCheckBox("Status Line");
chkStatusLine->addActionListener(miscActionListener);
chkShowGUI = new gcn::UaeCheckBox("Show GUI on startup");
chkShowGUI->setId("ShowGUI");
chkShowGUI->addActionListener(miscActionListener);
lblPandoraSpeed = new gcn::Label("Pandora Speed:");
lblPandoraSpeed->setSize(110, LABEL_HEIGHT);
lblPandoraSpeed->setAlignment(gcn::Graphics::RIGHT);
sldPandoraSpeed = new gcn::Slider(500, 1260);
sldPandoraSpeed->setSize(200, SLIDER_HEIGHT);
sldPandoraSpeed->setBaseColor(gui_baseCol);
sldPandoraSpeed->setMarkerLength(20);
sldPandoraSpeed->setStepLength(20);
sldPandoraSpeed->setId("PandSpeed");
sldPandoraSpeed->addActionListener(miscActionListener);
lblPandoraSpeedInfo = new gcn::Label("1000 MHz");
int posY = DISTANCE_BORDER;
category.panel->add(chkStatusLine, DISTANCE_BORDER, posY);
posY += chkStatusLine->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(chkShowGUI, DISTANCE_BORDER, posY);
posY += chkShowGUI->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblPandoraSpeed, DISTANCE_BORDER, posY);
category.panel->add(sldPandoraSpeed, DISTANCE_BORDER + lblPandoraSpeed->getWidth() + 8, posY);
category.panel->add(lblPandoraSpeedInfo, sldPandoraSpeed->getX() + sldPandoraSpeed->getWidth() + 12, posY);
posY += sldPandoraSpeed->getHeight() + DISTANCE_NEXT_Y;
RefreshPanelMisc();
}
void ExitPanelMisc(void)
{
delete chkStatusLine;
delete chkShowGUI;
delete lblPandoraSpeed;
delete sldPandoraSpeed;
delete lblPandoraSpeedInfo;
delete miscActionListener;
}
void RefreshPanelMisc(void)
{
char tmp[20];
chkStatusLine->setSelected(changed_prefs.leds_on_screen);
chkShowGUI->setSelected(changed_prefs.start_gui);
sldPandoraSpeed->setValue(changed_prefs.pandora_cpu_speed);
snprintf(tmp, 20, "%d MHz", changed_prefs.pandora_cpu_speed);
lblPandoraSpeedInfo->setCaption(tmp);
}

View file

@ -0,0 +1,150 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "uae.h"
#include "gui.h"
#include "target.h"
#include "gui_handling.h"
static gcn::Label *lblSystemROMs;
static gcn::TextField *txtSystemROMs;
static gcn::Button *cmdSystemROMs;
static gcn::Label *lblConfigPath;
static gcn::TextField *txtConfigPath;
static gcn::Button *cmdConfigPath;
static gcn::Button *cmdRescanROMs;
class FolderButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
char tmp[MAX_PATH];
if (actionEvent.getSource() == cmdSystemROMs)
{
fetch_rompath(tmp, MAX_PATH);
if(SelectFolder("Folder for System ROMs", tmp))
{
set_rompath(tmp);
RefreshPanelPaths();
}
cmdSystemROMs->requestFocus();
}
else if(actionEvent.getSource() == cmdConfigPath)
{
fetch_configurationpath(tmp, MAX_PATH);
if(SelectFolder("Folder for configuration files", tmp))
{
set_configurationpath(tmp);
RefreshPanelPaths();
RefreshPanelConfig();
}
cmdConfigPath->requestFocus();
}
}
};
static FolderButtonActionListener* folderButtonActionListener;
class RescanROMsButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
RescanROMs();
RefreshPanelROM();
}
};
static RescanROMsButtonActionListener* rescanROMsButtonActionListener;
void InitPanelPaths(const struct _ConfigCategory& category)
{
int textFieldWidth = category.panel->getWidth() - 2 * DISTANCE_BORDER - SMALL_BUTTON_WIDTH - DISTANCE_NEXT_X;
int yPos = DISTANCE_BORDER;
folderButtonActionListener = new FolderButtonActionListener();
lblSystemROMs = new gcn::Label("System ROMs:");
lblSystemROMs->setSize(120, LABEL_HEIGHT);
txtSystemROMs = new gcn::TextField();
txtSystemROMs->setSize(textFieldWidth, TEXTFIELD_HEIGHT);
txtSystemROMs->setEnabled(false);
cmdSystemROMs = new gcn::Button("...");
cmdSystemROMs->setId("SystemROMs");
cmdSystemROMs->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdSystemROMs->setBaseColor(gui_baseCol);
cmdSystemROMs->addActionListener(folderButtonActionListener);
lblConfigPath = new gcn::Label("Configuration files:");
lblConfigPath->setSize(120, LABEL_HEIGHT);
txtConfigPath = new gcn::TextField();
txtConfigPath->setSize(textFieldWidth, TEXTFIELD_HEIGHT);
txtConfigPath->setEnabled(false);
cmdConfigPath = new gcn::Button("...");
cmdConfigPath->setId("ConfigPath");
cmdConfigPath->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdConfigPath->setBaseColor(gui_baseCol);
cmdConfigPath->addActionListener(folderButtonActionListener);
category.panel->add(lblSystemROMs, DISTANCE_BORDER, yPos);
yPos += lblSystemROMs->getHeight();
category.panel->add(txtSystemROMs, DISTANCE_BORDER, yPos);
category.panel->add(cmdSystemROMs, DISTANCE_BORDER + textFieldWidth + DISTANCE_NEXT_X, yPos);
yPos += txtSystemROMs->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblConfigPath, DISTANCE_BORDER, yPos);
yPos += lblConfigPath->getHeight();
category.panel->add(txtConfigPath, DISTANCE_BORDER, yPos);
category.panel->add(cmdConfigPath, DISTANCE_BORDER + textFieldWidth + DISTANCE_NEXT_X, yPos);
yPos += txtConfigPath->getHeight() + DISTANCE_NEXT_Y;
rescanROMsButtonActionListener = new RescanROMsButtonActionListener();
cmdRescanROMs = new gcn::Button("Rescan ROMs");
cmdRescanROMs->setSize(120, BUTTON_HEIGHT);
cmdRescanROMs->setBaseColor(gui_baseCol);
cmdRescanROMs->setId("RescanROMs");
cmdRescanROMs->addActionListener(rescanROMsButtonActionListener);
category.panel->add(cmdRescanROMs, DISTANCE_BORDER, category.panel->getHeight() - BUTTON_HEIGHT - DISTANCE_BORDER);
RefreshPanelPaths();
}
void ExitPanelPaths(void)
{
delete lblSystemROMs;
delete txtSystemROMs;
delete cmdSystemROMs;
delete lblConfigPath;
delete txtConfigPath;
delete cmdConfigPath;
delete folderButtonActionListener;
delete cmdRescanROMs;
delete rescanROMsButtonActionListener;
}
void RefreshPanelPaths(void)
{
char tmp[MAX_PATH];
fetch_rompath(tmp, MAX_PATH);
txtSystemROMs->setText(tmp);
fetch_configurationpath(tmp, MAX_PATH);
txtConfigPath->setText(tmp);
}

View file

@ -0,0 +1,179 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeRadioButton.hpp"
#include "UaeDropDown.hpp"
#include "UaeCheckBox.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "memory.h"
#include "uae.h"
#include "gui.h"
#include "target.h"
#include "gui_handling.h"
static const char *ChipMem_list[] = { "512 K", "1 MB", "2 MB", "4 MB", "8 MB" };
static const int ChipMem_values[] = { 0x080000, 0x100000, 0x200000, 0x400000, 0x800000 };
static const char *SlowMem_list[] = { "None", "512 K", "1 MB", "1.5 MB", "1.8 MB" };
static const int SlowMem_values[] = { 0x000000, 0x080000, 0x100000, 0x180000, 0x1c0000 };
static const char *FastMem_list[] = { "None", "1 MB", "2 MB", "4 MB", "8 MB" };
static const int FastMem_values[] = { 0x000000, 0x100000, 0x200000, 0x400000, 0x800000 };
static gcn::Window *grpRAM;
static gcn::Label* lblChipmem;
static gcn::Label* lblChipsize;
static gcn::Slider* sldChipmem;
static gcn::Label* lblSlowmem;
static gcn::Label* lblSlowsize;
static gcn::Slider* sldSlowmem;
static gcn::Label* lblFastmem;
static gcn::Label* lblFastsize;
static gcn::Slider* sldFastmem;
class MemorySliderActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == sldChipmem) {
changed_prefs.chipmem_size = ChipMem_values[(int)(sldChipmem->getValue())];
if ((changed_prefs.chipmem_size > 0x200000) && (changed_prefs.fastmem_size > 0))
changed_prefs.fastmem_size = 0;
}
if (actionEvent.getSource() == sldSlowmem) {
changed_prefs.bogomem_size = SlowMem_values[(int)(sldSlowmem->getValue())];
}
if (actionEvent.getSource() == sldFastmem) {
changed_prefs.fastmem_size = FastMem_values[(int)(sldFastmem->getValue())];
if (changed_prefs.fastmem_size > 0 && changed_prefs.chipmem_size > 0x200000)
changed_prefs.chipmem_size = 0x200000;
}
RefreshPanelRAM();
}
};
static MemorySliderActionListener* memorySliderActionListener;
void InitPanelRAM(const struct _ConfigCategory& category)
{
memorySliderActionListener = new MemorySliderActionListener();
lblChipmem = new gcn::Label("Chip:");
sldChipmem = new gcn::Slider(0, 4);
sldChipmem->setSize(110, SLIDER_HEIGHT);
sldChipmem->setBaseColor(gui_baseCol);
sldChipmem->setMarkerLength(20);
sldChipmem->setStepLength(1);
sldChipmem->setId("Chipmem");
sldChipmem->addActionListener(memorySliderActionListener);
lblChipsize = new gcn::Label("None ");
lblSlowmem = new gcn::Label("Slow:");
sldSlowmem = new gcn::Slider(0, 4);
sldSlowmem->setSize(110, SLIDER_HEIGHT);
sldSlowmem->setBaseColor(gui_baseCol);
sldSlowmem->setMarkerLength(20);
sldSlowmem->setStepLength(1);
sldSlowmem->setId("Slowmem");
sldSlowmem->addActionListener(memorySliderActionListener);
lblSlowsize = new gcn::Label("None ");
lblFastmem = new gcn::Label("Fast:");
sldFastmem = new gcn::Slider(0, 4);
sldFastmem->setSize(110, SLIDER_HEIGHT);
sldFastmem->setBaseColor(gui_baseCol);
sldFastmem->setMarkerLength(20);
sldFastmem->setStepLength(1);
sldFastmem->setId("Fastmem");
sldFastmem->addActionListener(memorySliderActionListener);
lblFastsize = new gcn::Label("None ");
grpRAM = new gcn::Window("Memory Settings");
grpRAM->setPosition(DISTANCE_BORDER, DISTANCE_BORDER);
int posY = 10;
grpRAM->add(lblChipmem, 8, posY);
grpRAM->add(sldChipmem, 50, posY);
grpRAM->add(lblChipsize, 50 + sldChipmem->getWidth() + 12, posY);
posY += sldChipmem->getHeight() + DISTANCE_NEXT_Y;
grpRAM->add(lblSlowmem, 8, posY);
grpRAM->add(sldSlowmem, 50, posY);
grpRAM->add(lblSlowsize, 50 + sldSlowmem->getWidth() + 12, posY);
posY += sldSlowmem->getHeight() + DISTANCE_NEXT_Y;
grpRAM->add(lblFastmem, 8, posY);
grpRAM->add(sldFastmem, 50, posY);
grpRAM->add(lblFastsize, 50 + sldFastmem->getWidth() + 12, posY);
posY += sldFastmem->getHeight() + DISTANCE_NEXT_Y;
grpRAM->setMovable(false);
grpRAM->setSize(230, posY + DISTANCE_BORDER);
grpRAM->setBaseColor(gui_baseCol);
category.panel->add(grpRAM);
RefreshPanelRAM();
}
void ExitPanelRAM(void)
{
delete lblChipmem;
delete sldChipmem;
delete lblChipsize;
delete lblSlowmem;
delete sldSlowmem;
delete lblSlowsize;
delete lblFastmem;
delete sldFastmem;
delete lblFastsize;
delete grpRAM;
delete memorySliderActionListener;
}
void RefreshPanelRAM(void)
{
int i;
for(i=0; i<5; ++i)
{
if(changed_prefs.chipmem_size == ChipMem_values[i])
{
sldChipmem->setValue(i);
lblChipsize->setCaption(ChipMem_list[i]);
break;
}
}
for(i=0; i<5; ++i)
{
if(changed_prefs.bogomem_size == SlowMem_values[i])
{
sldSlowmem->setValue(i);
lblSlowsize->setCaption(SlowMem_list[i]);
break;
}
}
for(i=0; i<5; ++i)
{
if(changed_prefs.fastmem_size == FastMem_values[i])
{
sldFastmem->setValue(i);
lblFastsize->setCaption(FastMem_list[i]);
break;
}
}
}

View file

@ -0,0 +1,249 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeRadioButton.hpp"
#include "UaeDropDown.hpp"
#include "UaeCheckBox.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "memory.h"
#include "uae.h"
#include "gui.h"
#include "target.h"
#include "gui_handling.h"
static gcn::Label *lblMainROM;
static gcn::UaeDropDown* cboMainROM;
static gcn::Button *cmdMainROM;
static gcn::Label *lblExtROM;
static gcn::UaeDropDown* cboExtROM;
static gcn::Button *cmdExtROM;
static gcn::UaeCheckBox* chkMapROM;
class ROMListModel : public gcn::ListModel
{
private:
std::vector<std::string> roms;
std::vector<int> idxToAvailableROMs;
int ROMType;
public:
ROMListModel(int romtype)
{
ROMType = romtype;
}
int getNumberOfElements()
{
return roms.size();
}
std::string getElementAt(int i)
{
if(i < 0 || i >= roms.size())
return "---";
return roms[i];
}
AvailableROM* getROMat(int i)
{
if(i >= 0 && i < idxToAvailableROMs.size())
return idxToAvailableROMs[i] < 0 ? NULL : lstAvailableROMs[idxToAvailableROMs[i]];
return NULL;
}
int InitROMList(char *current)
{
roms.clear();
idxToAvailableROMs.clear();
if(ROMType & (ROMTYPE_EXTCDTV | ROMTYPE_EXTCD32))
{
roms.push_back("");
idxToAvailableROMs.push_back(-1);
}
int currIdx = -1;
for(int i=0; i<lstAvailableROMs.size(); ++i)
{
if(lstAvailableROMs[i]->ROMType & ROMType)
{
if(!strcasecmp(lstAvailableROMs[i]->Path, current))
currIdx = roms.size();
roms.push_back(lstAvailableROMs[i]->Name);
idxToAvailableROMs.push_back(i);
}
}
return currIdx;
}
};
static ROMListModel *mainROMList;
static ROMListModel *extROMList;
class MainROMActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
AvailableROM* rom = mainROMList->getROMat(cboMainROM->getSelected());
if(rom != NULL)
strncpy(changed_prefs.romfile, rom->Path, sizeof(changed_prefs.romfile));
}
};
static MainROMActionListener* mainROMActionListener;
class ExtROMActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
AvailableROM* rom = extROMList->getROMat(cboExtROM->getSelected());
if(rom != NULL)
strncpy(changed_prefs.romextfile, rom->Path, sizeof(changed_prefs.romextfile));
else
strncpy(changed_prefs.romextfile, "", sizeof(changed_prefs.romextfile));
}
};
static ExtROMActionListener* extROMActionListener;
class ROMButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
char tmp[MAX_PATH];
const char *filter[] = { ".rom", "\0" };
if (actionEvent.getSource() == cmdMainROM)
{
strncpy(tmp, currentDir, MAX_PATH);
if(SelectFile("Select System ROM", tmp, filter))
{
AvailableROM *newrom;
newrom = new AvailableROM();
extractFileName(tmp, newrom->Name);
removeFileExtension(newrom->Name);
strncpy(newrom->Path, tmp, MAX_PATH);
newrom->ROMType = ROMTYPE_KICK;
lstAvailableROMs.push_back(newrom);
strncpy(changed_prefs.romfile, tmp, sizeof(changed_prefs.romfile));
RefreshPanelROM();
}
cmdMainROM->requestFocus();
}
else if (actionEvent.getSource() == cmdExtROM)
{
strncpy(tmp, currentDir, MAX_PATH);
if(SelectFile("Select Extended ROM", tmp, filter))
{
AvailableROM *newrom;
newrom = new AvailableROM();
extractFileName(tmp, newrom->Name);
removeFileExtension(newrom->Name);
strncpy(newrom->Path, tmp, MAX_PATH);
newrom->ROMType = ROMTYPE_EXTCDTV;
lstAvailableROMs.push_back(newrom);
strncpy(changed_prefs.romextfile, tmp, sizeof(changed_prefs.romextfile));
RefreshPanelROM();
}
cmdExtROM->requestFocus();
}
}
};
static ROMButtonActionListener* romButtonActionListener;
void InitPanelROM(const struct _ConfigCategory& category)
{
mainROMActionListener = new MainROMActionListener();
extROMActionListener = new ExtROMActionListener();
romButtonActionListener = new ROMButtonActionListener();
mainROMList = new ROMListModel(ROMTYPE_KICK | ROMTYPE_KICKCD32);
extROMList = new ROMListModel(ROMTYPE_EXTCDTV | ROMTYPE_EXTCD32);
lblMainROM = new gcn::Label("Main ROM File:");
lblMainROM->setSize(200, LABEL_HEIGHT);
cboMainROM = new gcn::UaeDropDown(mainROMList);
cboMainROM->setSize(400, DROPDOWN_HEIGHT);
cboMainROM->setBaseColor(gui_baseCol);
cboMainROM->setId("cboMainROM");
cboMainROM->addActionListener(mainROMActionListener);
cmdMainROM = new gcn::Button("...");
cmdMainROM->setId("MainROM");
cmdMainROM->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdMainROM->setBaseColor(gui_baseCol);
cmdMainROM->addActionListener(romButtonActionListener);
lblExtROM = new gcn::Label("Extended ROM File:");
lblExtROM->setSize(200, LABEL_HEIGHT);
cboExtROM = new gcn::UaeDropDown(extROMList);
cboExtROM->setSize(400, DROPDOWN_HEIGHT);
cboExtROM->setBaseColor(gui_baseCol);
cboExtROM->setId("cboExtROM");
cboExtROM->addActionListener(extROMActionListener);
cmdExtROM = new gcn::Button("...");
cmdExtROM->setId("ExtROM");
cmdExtROM->setSize(SMALL_BUTTON_WIDTH, SMALL_BUTTON_HEIGHT);
cmdExtROM->setBaseColor(gui_baseCol);
cmdExtROM->addActionListener(romButtonActionListener);
chkMapROM = new gcn::UaeCheckBox("MapROM emulation", true);
chkMapROM->setEnabled(false);
int posY = DISTANCE_BORDER;
category.panel->add(lblMainROM, DISTANCE_BORDER, posY);
posY += lblMainROM->getHeight() + 4;
category.panel->add(cboMainROM, DISTANCE_BORDER, posY);
category.panel->add(cmdMainROM, DISTANCE_BORDER + cboMainROM->getWidth() + DISTANCE_NEXT_X, posY);
posY += cboMainROM->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblExtROM, DISTANCE_BORDER, posY);
posY += lblExtROM->getHeight() + 4;
category.panel->add(cboExtROM, DISTANCE_BORDER, posY);
category.panel->add(cmdExtROM, DISTANCE_BORDER + cboExtROM->getWidth() + DISTANCE_NEXT_X, posY);
posY += cboExtROM->getHeight() + DISTANCE_NEXT_Y;
// category.panel->add(chkMapROM, DISTANCE_BORDER, posY);
posY += chkMapROM->getHeight() + DISTANCE_NEXT_Y;
RefreshPanelROM();
}
void ExitPanelROM(void)
{
delete lblMainROM;
delete cboMainROM;
delete cmdMainROM;
delete mainROMList;
delete mainROMActionListener;
delete lblExtROM;
delete cboExtROM;
delete cmdExtROM;
delete extROMList;
delete extROMActionListener;
delete romButtonActionListener;
delete chkMapROM;
}
void RefreshPanelROM(void)
{
int idx = mainROMList->InitROMList(changed_prefs.romfile);
cboMainROM->setSelected(idx);
idx = extROMList->InitROMList(changed_prefs.romextfile);
cboExtROM->setSelected(idx);
chkMapROM->setSelected(false);
}

View file

@ -0,0 +1,233 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <SDL/SDL_image.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeRadioButton.hpp"
#include "UaeCheckBox.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "xwin.h"
#include "custom.h"
#include "drawing.h"
#include "uae.h"
#include "gui.h"
#include "savestate.h"
#include "target.h"
#include "gui_handling.h"
int currentStateNum = 0;
static gcn::Window *grpNumber;
static gcn::UaeRadioButton* optState0;
static gcn::UaeRadioButton* optState1;
static gcn::UaeRadioButton* optState2;
static gcn::UaeRadioButton* optState3;
static gcn::Window *wndScreenshot;
static gcn::Icon* icoSavestate = 0;
static gcn::Image *imgSavestate = 0;
static gcn::Button* cmdLoadState;
static gcn::Button* cmdSaveState;
class SavestateActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == optState0)
currentStateNum = 0;
else if (actionEvent.getSource() == optState1)
currentStateNum = 1;
else if (actionEvent.getSource() == optState2)
currentStateNum = 2;
else if (actionEvent.getSource() == optState3)
currentStateNum = 3;
else if (actionEvent.getSource() == cmdLoadState)
{
//------------------------------------------
// Load state
//------------------------------------------
if(emulating)
{
if(strlen(savestate_fname) > 0)
{
FILE *f = fopen(savestate_fname,"rb");
if (f)
{
fclose(f);
savestate_initsave(savestate_fname, 2);
savestate_state = STATE_DORESTORE;
gui_running = false;
}
}
if(savestate_state != STATE_DORESTORE)
ShowMessage("Loading savestate", "Statefile doesn't exist.", "", "Ok", "");
}
else
ShowMessage("Loading savestate", "Emulation hasn't started yet.", "", "Ok", "");
}
else if (actionEvent.getSource() == cmdSaveState)
{
//------------------------------------------
// Save current state
//------------------------------------------
if(emulating)
{
savestate_initsave(savestate_fname, 2);
save_state (savestate_fname, "...");
savestate_state = STATE_DOSAVE; // Just to create the screenshot
delay_savestate_frame = 1;
gui_running = false;
}
else
ShowMessage("Saving state", "Emulation hasn't started yet.", "", "Ok", "");
}
RefreshPanelSavestate();
}
};
static SavestateActionListener* savestateActionListener;
void InitPanelSavestate(const struct _ConfigCategory& category)
{
savestateActionListener = new SavestateActionListener();
optState0 = new gcn::UaeRadioButton("0", "radiostategroup");
optState0->setId("State0");
optState0->addActionListener(savestateActionListener);
optState1 = new gcn::UaeRadioButton("1", "radiostategroup");
optState1->setId("State1");
optState1->addActionListener(savestateActionListener);
optState2 = new gcn::UaeRadioButton("2", "radiostategroup");
optState2->setId("State2");
optState2->addActionListener(savestateActionListener);
optState3 = new gcn::UaeRadioButton("3", "radiostategroup");
optState3->setId("State3");
optState3->addActionListener(savestateActionListener);
grpNumber = new gcn::Window("Number");
grpNumber->add(optState0, 5, 10);
grpNumber->add(optState1, 5, 40);
grpNumber->add(optState2, 5, 70);
grpNumber->add(optState3, 5, 100);
grpNumber->setMovable(false);
grpNumber->setSize(60, 145);
grpNumber->setBaseColor(gui_baseCol);
wndScreenshot = new gcn::Window("State screen");
wndScreenshot->setMovable(false);
wndScreenshot->setSize(400, 300);
wndScreenshot->setBaseColor(gui_baseCol);
cmdLoadState = new gcn::Button("Load State");
cmdLoadState->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdLoadState->setBaseColor(gui_baseCol);
cmdLoadState->setId("LoadState");
cmdLoadState->addActionListener(savestateActionListener);
cmdSaveState = new gcn::Button("Save State");
cmdSaveState->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdSaveState->setBaseColor(gui_baseCol);
cmdSaveState->setId("SaveState");
cmdSaveState->addActionListener(savestateActionListener);
category.panel->add(grpNumber, DISTANCE_BORDER, DISTANCE_BORDER);
category.panel->add(wndScreenshot, DISTANCE_BORDER + 100, DISTANCE_BORDER);
int buttonY = category.panel->getHeight() - DISTANCE_BORDER - BUTTON_HEIGHT;
category.panel->add(cmdLoadState, DISTANCE_BORDER, buttonY);
category.panel->add(cmdSaveState, DISTANCE_BORDER + BUTTON_WIDTH + DISTANCE_NEXT_X, buttonY);
RefreshPanelSavestate();
}
void ExitPanelSavestate(void)
{
delete optState0;
delete optState1;
delete optState2;
delete optState3;
delete grpNumber;
if(imgSavestate != 0)
delete imgSavestate;
imgSavestate = 0;
if(icoSavestate != 0)
delete icoSavestate;
icoSavestate = 0;
delete wndScreenshot;
delete cmdLoadState;
delete cmdSaveState;
delete savestateActionListener;
}
void RefreshPanelSavestate(void)
{
if(icoSavestate != 0)
{
wndScreenshot->remove(icoSavestate);
delete icoSavestate;
icoSavestate = 0;
}
if(imgSavestate != 0)
{
delete imgSavestate;
imgSavestate = 0;
}
switch(currentStateNum)
{
case 0:
optState0->setSelected(true);
break;
case 1:
optState1->setSelected(true);
break;
case 2:
optState2->setSelected(true);
break;
case 3:
optState3->setSelected(true);
break;
}
gui_update();
if(strlen(screenshot_filename) > 0)
{
FILE *f=fopen(screenshot_filename,"rb");
if (f)
{
fclose(f);
gcn::Rectangle rect = wndScreenshot->getChildrenArea();
SDL_Surface *loadedImage = IMG_Load(screenshot_filename);
if(loadedImage != NULL)
{
SDL_Rect source = {0, 0, 0, 0 };
SDL_Rect target = {0, 0, 0, 0 };
SDL_Surface *scaled = SDL_CreateRGBSurface(loadedImage->flags, rect.width, rect.height, loadedImage->format->BitsPerPixel, loadedImage->format->Rmask, loadedImage->format->Gmask, loadedImage->format->Bmask, loadedImage->format->Amask);
source.w = loadedImage->w;
source.h = loadedImage->h;
target.w = rect.width;
target.h = rect.height;
SDL_SoftStretch(loadedImage, &source, scaled, &target);
SDL_FreeSurface(loadedImage);
imgSavestate = new gcn::SDLImage(scaled, true);
icoSavestate = new gcn::Icon(imgSavestate);
wndScreenshot->add(icoSavestate);
}
}
}
}

View file

@ -0,0 +1,461 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "UaeRadioButton.hpp"
#include "UaeCheckBox.hpp"
#include "UaeDropDown.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "uae.h"
#include "gui.h"
#include "custom.h"
#include "target.h"
#include "gui_handling.h"
#include "sounddep/sound.h"
static gcn::Window *grpSound;
static gcn::UaeRadioButton* optSoundDisabled;
static gcn::UaeRadioButton* optSoundDisabledEmu;
static gcn::UaeRadioButton* optSoundEmulated;
static gcn::UaeRadioButton* optSoundEmulatedBest;
static gcn::Window *grpMode;
static gcn::UaeRadioButton* optMono;
static gcn::UaeRadioButton* optStereo;
static gcn::Label* lblFrequency;
static gcn::UaeDropDown* cboFrequency;
static gcn::Label* lblInterpolation;
static gcn::UaeDropDown* cboInterpolation;
static gcn::Label* lblFilter;
static gcn::UaeDropDown* cboFilter;
static gcn::Label* lblSeparation;
static gcn::Label* lblSeparationInfo;
static gcn::Slider* sldSeparation;
static gcn::Label* lblStereoDelay;
static gcn::Label* lblStereoDelayInfo;
static gcn::Slider* sldStereoDelay;
static int curr_separation_idx;
static int curr_stereodelay_idx;
class FrequencyListModel : public gcn::ListModel
{
private:
std::vector<std::string> freq;
public:
FrequencyListModel()
{
freq.push_back("11025");
freq.push_back("22050");
freq.push_back("32000");
freq.push_back("44100");
}
int getNumberOfElements()
{
return freq.size();
}
std::string getElementAt(int i)
{
if(i < 0 || i >= freq.size())
return "---";
return freq[i];
}
};
static FrequencyListModel frequencyTypeList;
class InterpolationListModel : public gcn::ListModel
{
private:
std::vector<std::string> entry;
public:
InterpolationListModel()
{
entry.push_back("Disabled");
entry.push_back("Anti");
entry.push_back("Sinc");
entry.push_back("RH");
entry.push_back("Crux");
}
int getNumberOfElements()
{
return entry.size();
}
std::string getElementAt(int i)
{
if(i < 0 || i >= entry.size())
return "---";
return entry[i];
}
};
static InterpolationListModel interpolationTypeList;
class FilterListModel : public gcn::ListModel
{
private:
std::vector<std::string> entry;
public:
FilterListModel()
{
entry.push_back("Always off");
entry.push_back("Emulated (A500)");
entry.push_back("Emulated (A1200)");
entry.push_back("Always on (A500)");
entry.push_back("Always on (A1200)");
}
int getNumberOfElements()
{
return entry.size();
}
std::string getElementAt(int i)
{
if(i < 0 || i >= entry.size())
return "---";
return entry[i];
}
};
static FilterListModel filterTypeList;
class SoundActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == optSoundDisabled)
changed_prefs.produce_sound = 0;
else if (actionEvent.getSource() == optSoundDisabledEmu)
changed_prefs.produce_sound = 1;
else if (actionEvent.getSource() == optSoundEmulated)
changed_prefs.produce_sound = 2;
else if (actionEvent.getSource() == optSoundEmulatedBest)
changed_prefs.produce_sound = 3;
else if (actionEvent.getSource() == optMono)
changed_prefs.sound_stereo = 0;
else if (actionEvent.getSource() == optStereo)
changed_prefs.sound_stereo = 1;
else if (actionEvent.getSource() == cboFrequency)
{
switch(cboFrequency->getSelected())
{
case 0:
changed_prefs.sound_freq = 11025;
break;
case 1:
changed_prefs.sound_freq = 22050;
break;
case 2:
changed_prefs.sound_freq = 32000;
break;
case 3:
changed_prefs.sound_freq = 44100;
break;
}
}
else if (actionEvent.getSource() == cboInterpolation)
changed_prefs.sound_interpol = cboInterpolation->getSelected();
else if (actionEvent.getSource() == cboFilter)
{
switch (cboFilter->getSelected())
{
case 0:
changed_prefs.sound_filter = FILTER_SOUND_OFF;
break;
case 1:
changed_prefs.sound_filter = FILTER_SOUND_EMUL;
changed_prefs.sound_filter_type = 0;
break;
case 2:
changed_prefs.sound_filter = FILTER_SOUND_EMUL;
changed_prefs.sound_filter_type = 1;
break;
case 3:
changed_prefs.sound_filter = FILTER_SOUND_ON;
changed_prefs.sound_filter_type = 0;
break;
case 4:
changed_prefs.sound_filter = FILTER_SOUND_ON;
changed_prefs.sound_filter_type = 1;
break;
}
}
else if (actionEvent.getSource() == sldSeparation)
{
if(curr_separation_idx != (int)(sldSeparation->getValue())
&& changed_prefs.sound_stereo > 0)
{
curr_separation_idx = (int)(sldSeparation->getValue());
changed_prefs.sound_stereo_separation = 10 - curr_separation_idx;
}
}
else if (actionEvent.getSource() == sldStereoDelay)
{
if(curr_stereodelay_idx != (int)(sldStereoDelay->getValue())
&& changed_prefs.sound_stereo > 0)
{
curr_stereodelay_idx = (int)(sldStereoDelay->getValue());
if(curr_stereodelay_idx > 0)
changed_prefs.sound_mixed_stereo = curr_stereodelay_idx;
else
changed_prefs.sound_mixed_stereo = -1;
}
}
RefreshPanelSound();
}
};
static SoundActionListener* soundActionListener;
void InitPanelSound(const struct _ConfigCategory& category)
{
soundActionListener = new SoundActionListener();
optSoundDisabled = new gcn::UaeRadioButton("Disabled", "radiosoundgroup");
optSoundDisabled->setId("sndDisable");
optSoundDisabled->addActionListener(soundActionListener);
optSoundDisabledEmu = new gcn::UaeRadioButton("Disabled, but emulated", "radiosoundgroup");
optSoundDisabledEmu->setId("sndDisEmu");
optSoundDisabledEmu->addActionListener(soundActionListener);
optSoundEmulated = new gcn::UaeRadioButton("Enabled", "radiosoundgroup");
optSoundEmulated->setId("sndEmulate");
optSoundEmulated->addActionListener(soundActionListener);
optSoundEmulatedBest = new gcn::UaeRadioButton("Enabled, most accurate", "radiosoundgroup");
optSoundEmulatedBest->setId("sndEmuBest");
optSoundEmulatedBest->addActionListener(soundActionListener);
grpSound = new gcn::Window("Sound Emulation");
grpSound->add(optSoundDisabled, 5, 10);
grpSound->add(optSoundDisabledEmu, 5, 40);
grpSound->add(optSoundEmulated, 5, 70);
grpSound->add(optSoundEmulatedBest, 5, 100);
grpSound->setMovable(false);
grpSound->setSize(200, 150);
grpSound->setBaseColor(gui_baseCol);
lblFrequency = new gcn::Label("Frequency:");
lblFrequency->setSize(130, LABEL_HEIGHT);
lblFrequency->setAlignment(gcn::Graphics::RIGHT);
cboFrequency = new gcn::UaeDropDown(&frequencyTypeList);
cboFrequency->setSize(160, DROPDOWN_HEIGHT);
cboFrequency->setBaseColor(gui_baseCol);
cboFrequency->setId("cboFrequency");
cboFrequency->addActionListener(soundActionListener);
optMono = new gcn::UaeRadioButton("Mono", "radiosoundmodegroup");
optMono->addActionListener(soundActionListener);
optStereo = new gcn::UaeRadioButton("Stereo", "radiosoundmodegroup");
optStereo->addActionListener(soundActionListener);
grpMode = new gcn::Window("Mode");
grpMode->add(optMono, 5, 10);
grpMode->add(optStereo, 5, 40);
grpMode->setMovable(false);
grpMode->setSize(90, 90);
grpMode->setBaseColor(gui_baseCol);
lblInterpolation = new gcn::Label("Interpolation:");
lblInterpolation->setSize(130, LABEL_HEIGHT);
lblInterpolation->setAlignment(gcn::Graphics::RIGHT);
cboInterpolation = new gcn::UaeDropDown(&interpolationTypeList);
cboInterpolation->setSize(160, DROPDOWN_HEIGHT);
cboInterpolation->setBaseColor(gui_baseCol);
cboInterpolation->setId("cboInterpol");
cboInterpolation->addActionListener(soundActionListener);
lblFilter = new gcn::Label("Filter:");
lblFilter->setSize(130, LABEL_HEIGHT);
lblFilter->setAlignment(gcn::Graphics::RIGHT);
cboFilter = new gcn::UaeDropDown(&filterTypeList);
cboFilter->setSize(160, DROPDOWN_HEIGHT);
cboFilter->setBaseColor(gui_baseCol);
cboFilter->setId("cboFilter");
cboFilter->addActionListener(soundActionListener);
lblSeparation = new gcn::Label("Stereo separation:");
lblSeparation->setSize(130, LABEL_HEIGHT);
lblSeparation->setAlignment(gcn::Graphics::RIGHT);
sldSeparation = new gcn::Slider(0, 10);
sldSeparation->setSize(160, SLIDER_HEIGHT);
sldSeparation->setBaseColor(gui_baseCol);
sldSeparation->setMarkerLength(20);
sldSeparation->setStepLength(1);
sldSeparation->setId("sldSeparation");
sldSeparation->addActionListener(soundActionListener);
lblSeparationInfo = new gcn::Label("100%");
lblStereoDelay = new gcn::Label("Stereo delay:");
lblStereoDelay->setSize(130, LABEL_HEIGHT);
lblStereoDelay->setAlignment(gcn::Graphics::RIGHT);
sldStereoDelay = new gcn::Slider(0, 10);
sldStereoDelay->setSize(160, SLIDER_HEIGHT);
sldStereoDelay->setBaseColor(gui_baseCol);
sldStereoDelay->setMarkerLength(20);
sldStereoDelay->setStepLength(1);
sldStereoDelay->setId("sldStereoDelay");
sldStereoDelay->addActionListener(soundActionListener);
lblStereoDelayInfo = new gcn::Label("10");
int posY = DISTANCE_BORDER;
category.panel->add(grpSound, DISTANCE_BORDER, posY);
category.panel->add(grpMode, grpSound->getX() + grpSound->getWidth() + DISTANCE_NEXT_X, posY);
posY += grpSound->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblFrequency, DISTANCE_BORDER, posY);
category.panel->add(cboFrequency, lblFrequency->getX() + lblFrequency->getWidth() + 12, posY);
posY += cboFrequency->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblInterpolation, DISTANCE_BORDER, posY);
category.panel->add(cboInterpolation, lblInterpolation->getX() + lblInterpolation->getWidth() + 12, posY);
posY += cboInterpolation->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblFilter, DISTANCE_BORDER, posY);
category.panel->add(cboFilter, lblFilter->getX() + lblFilter->getWidth() + 12, posY);
posY += cboFilter->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(lblSeparation, DISTANCE_BORDER, posY);
category.panel->add(sldSeparation, lblSeparation->getX() + lblSeparation->getWidth() + 12, posY);
category.panel->add(lblSeparationInfo, sldSeparation->getX() + sldSeparation->getWidth() + 12, posY);
posY += SLIDER_HEIGHT + DISTANCE_NEXT_Y;
category.panel->add(lblStereoDelay, DISTANCE_BORDER, posY);
category.panel->add(sldStereoDelay, lblStereoDelay->getX() + lblStereoDelay->getWidth() + 12, posY);
category.panel->add(lblStereoDelayInfo, sldStereoDelay->getX() + sldStereoDelay->getWidth() + 12, posY);
posY += SLIDER_HEIGHT + DISTANCE_NEXT_Y;
RefreshPanelSound();
}
void ExitPanelSound(void)
{
delete optSoundDisabled;
delete optSoundDisabledEmu;
delete optSoundEmulated;
delete optSoundEmulatedBest;
delete grpSound;
delete optMono;
delete optStereo;
delete grpMode;
delete lblFrequency;
delete cboFrequency;
delete lblInterpolation;
delete cboInterpolation;
delete lblFilter;
delete cboFilter;
delete lblSeparation;
delete sldSeparation;
delete lblSeparationInfo;
delete lblStereoDelay;
delete sldStereoDelay;
delete lblStereoDelayInfo;
delete soundActionListener;
}
void RefreshPanelSound(void)
{
char tmp[10];
int i;
switch(changed_prefs.produce_sound)
{
case 0:
optSoundDisabled->setSelected(true);
break;
case 1:
optSoundDisabledEmu->setSelected(true);
break;
case 2:
optSoundEmulated->setSelected(true);
break;
case 3:
optSoundEmulatedBest->setSelected(true);
break;
}
if (changed_prefs.sound_stereo == 0)
optMono->setSelected(true);
else if (changed_prefs.sound_stereo == 1)
optStereo->setSelected(true);
switch(changed_prefs.sound_freq)
{
case 11025:
cboFrequency->setSelected(0);
break;
case 22050:
cboFrequency->setSelected(1);
break;
case 32000:
cboFrequency->setSelected(2);
break;
default:
cboFrequency->setSelected(3);
break;
}
cboInterpolation->setSelected(changed_prefs.sound_interpol);
i = 0;
switch (changed_prefs.sound_filter)
{
case 0:
i = 0;
break;
case 1:
i = changed_prefs.sound_filter_type ? 2 : 1;
break;
case 2:
i = changed_prefs.sound_filter_type ? 4 : 3;
break;
}
cboFilter->setSelected(i);
if(changed_prefs.sound_stereo == 0)
{
curr_separation_idx = 0;
curr_stereodelay_idx = 0;
}
else
{
curr_separation_idx = 10 - changed_prefs.sound_stereo_separation;
curr_stereodelay_idx = changed_prefs.sound_mixed_stereo > 0 ? changed_prefs.sound_mixed_stereo : 0;
}
sldSeparation->setValue(curr_separation_idx);
sldSeparation->setEnabled(changed_prefs.sound_stereo >= 1);
snprintf(tmp, 10, "%d%%", 100 - 10 * curr_separation_idx);
lblSeparationInfo->setCaption(tmp);
sldStereoDelay->setValue(curr_stereodelay_idx);
sldStereoDelay->setEnabled(changed_prefs.sound_stereo >= 1);
if(curr_stereodelay_idx <= 0)
lblStereoDelayInfo->setCaption("-");
else
{
snprintf(tmp, 10, "%d", curr_stereodelay_idx);
lblStereoDelayInfo->setCaption(tmp);
}
}

View file

@ -0,0 +1,315 @@
#include <algorithm>
#include <guichan.hpp>
#include <iostream>
#include <sstream>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "uae.h"
#include "gui.h"
#include "gui_handling.h"
#define DIALOG_WIDTH 520
#define DIALOG_HEIGHT 400
static bool dialogResult = false;
static bool dialogFinished = false;
static char workingDir[MAX_PATH];
static const char **filefilter;
static gcn::Window *wndSelectFile;
static gcn::Button* cmdOK;
static gcn::Button* cmdCancel;
static gcn::ListBox* lstFiles;
static gcn::ScrollArea* scrAreaFiles;
static gcn::TextField *txtCurrent;
class SelectFileListModel : public gcn::ListModel
{
std::vector<std::string> dirs;
std::vector<std::string> files;
public:
SelectFileListModel(const char * path)
{
changeDir(path);
}
int getNumberOfElements()
{
return dirs.size() + files.size();
}
std::string getElementAt(int i)
{
if(i >= dirs.size() + files.size() || i < 0)
return "---";
if(i < dirs.size())
return dirs[i];
return files[i - dirs.size()];
}
void changeDir(const char *path)
{
ReadDirectory(path, &dirs, &files);
if(dirs.size() == 0)
dirs.push_back("..");
FilterFiles(&files, filefilter);
}
bool isDir(int i)
{
return (i < dirs.size());
}
};
static SelectFileListModel *fileList;
class FileButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == cmdOK)
{
int selected_item;
selected_item = lstFiles->getSelected();
if(fileList->isDir(selected_item))
return; // Directory selected -> Ok not possible
strcat(workingDir, "/");
strcat(workingDir, fileList->getElementAt(selected_item).c_str());
dialogResult = true;
}
dialogFinished = true;
}
};
static FileButtonActionListener* fileButtonActionListener;
static void checkfoldername (char *current)
{
char *ptr;
char actualpath [MAX_PATH];
DIR *dir;
if (dir = opendir(current))
{
fileList->changeDir(current);
ptr = realpath(current, actualpath);
strcpy(workingDir, ptr);
closedir(dir);
}
else
strcpy(workingDir, start_path_data);
txtCurrent->setText(workingDir);
}
static void checkfilename(char *current)
{
char actfile[MAX_PATH];
extractFileName(current, actfile);
for(int i=0; i<fileList->getNumberOfElements(); ++i)
{
if(!fileList->isDir(i) && !strcasecmp(fileList->getElementAt(i).c_str(), actfile))
{
lstFiles->setSelected(i);
break;
}
}
}
class SelectFileActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
int selected_item;
char foldername[256] = "";
selected_item = lstFiles->getSelected();
strcpy(foldername, workingDir);
strcat(foldername, "/");
strcat(foldername, fileList->getElementAt(selected_item).c_str());
if(fileList->isDir(selected_item))
checkfoldername(foldername);
else
{
strncpy(workingDir, foldername, sizeof(workingDir));
dialogResult = true;
dialogFinished = true;
}
}
};
static SelectFileActionListener* selectFileActionListener;
static void InitSelectFile(const char *title)
{
wndSelectFile = new gcn::Window("Load");
wndSelectFile->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
wndSelectFile->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
wndSelectFile->setBaseColor(gui_baseCol + 0x202020);
wndSelectFile->setCaption(title);
wndSelectFile->setTitleBarHeight(TITLEBAR_HEIGHT);
fileButtonActionListener = new FileButtonActionListener();
cmdOK = new gcn::Button("Ok");
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdOK->setBaseColor(gui_baseCol + 0x202020);
cmdOK->addActionListener(fileButtonActionListener);
cmdCancel = new gcn::Button("Cancel");
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
cmdCancel->addActionListener(fileButtonActionListener);
txtCurrent = new gcn::TextField();
txtCurrent->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, TEXTFIELD_HEIGHT);
txtCurrent->setPosition(DISTANCE_BORDER, 10);
txtCurrent->setEnabled(false);
selectFileActionListener = new SelectFileActionListener();
fileList = new SelectFileListModel(".");
lstFiles = new gcn::ListBox(fileList);
lstFiles->setSize(800, 252);
lstFiles->setBaseColor(gui_baseCol);
lstFiles->setWrappingEnabled(true);
lstFiles->addActionListener(selectFileActionListener);
scrAreaFiles = new gcn::ScrollArea(lstFiles);
scrAreaFiles->setFrameSize(1);
scrAreaFiles->setPosition(DISTANCE_BORDER, 10 + TEXTFIELD_HEIGHT + 10);
scrAreaFiles->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, 272);
scrAreaFiles->setScrollbarWidth(20);
scrAreaFiles->setBaseColor(gui_baseCol + 0x202020);
wndSelectFile->add(cmdOK);
wndSelectFile->add(cmdCancel);
wndSelectFile->add(txtCurrent);
wndSelectFile->add(scrAreaFiles);
gui_top->add(wndSelectFile);
lstFiles->requestFocus();
lstFiles->setSelected(0);
wndSelectFile->requestModalFocus();
}
static void ExitSelectFile(void)
{
wndSelectFile->releaseModalFocus();
gui_top->remove(wndSelectFile);
delete cmdOK;
delete cmdCancel;
delete fileButtonActionListener;
delete txtCurrent;
delete lstFiles;
delete scrAreaFiles;
delete selectFileActionListener;
delete fileList;
delete wndSelectFile;
}
static void SelectFileLoop(void)
{
while(!dialogFinished)
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
if (event.type == SDL_KEYDOWN)
{
switch(event.key.keysym.sym)
{
case SDLK_ESCAPE:
dialogFinished = true;
break;
case SDLK_LEFT:
{
gcn::FocusHandler* focusHdl = gui_top->_getFocusHandler();
gcn::Widget* activeWidget = focusHdl->getFocused();
if(activeWidget == lstFiles)
cmdCancel->requestFocus();
else if(activeWidget == cmdCancel)
cmdOK->requestFocus();
else if(activeWidget == cmdOK)
lstFiles->requestFocus();
continue;
}
break;
case SDLK_RIGHT:
{
gcn::FocusHandler* focusHdl = gui_top->_getFocusHandler();
gcn::Widget* activeWidget = focusHdl->getFocused();
if(activeWidget == lstFiles)
cmdOK->requestFocus();
else if(activeWidget == cmdCancel)
lstFiles->requestFocus();
else if(activeWidget == cmdOK)
cmdCancel->requestFocus();
continue;
}
break;
case SDLK_PAGEDOWN:
case SDLK_HOME:
event.key.keysym.sym = SDLK_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
}
}
//-------------------------------------------------
// Send event to guichan-controls
//-------------------------------------------------
gui_input->pushInput(event);
}
// Now we let the Gui object perform its logic.
uae_gui->logic();
// Now we let the Gui object draw itself.
uae_gui->draw();
// Finally we update the screen.
SDL_Flip(gui_screen);
}
}
bool SelectFile(const char *title, char *value, const char *filter[])
{
dialogResult = false;
dialogFinished = false;
filefilter = filter;
InitSelectFile(title);
extractPath(value, workingDir);
checkfoldername(workingDir);
checkfilename(value);
SelectFileLoop();
ExitSelectFile();
if(dialogResult)
strncpy(value, workingDir, MAX_PATH);
return dialogResult;
}

View file

@ -0,0 +1,273 @@
#include <algorithm>
#include <guichan.hpp>
#include <iostream>
#include <sstream>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "uae.h"
#include "gui_handling.h"
#define DIALOG_WIDTH 520
#define DIALOG_HEIGHT 400
static bool dialogResult = false;
static bool dialogFinished = false;
static char workingDir[MAX_PATH];
static gcn::Window *wndSelectFolder;
static gcn::Button* cmdOK;
static gcn::Button* cmdCancel;
static gcn::ListBox* lstFolders;
static gcn::ScrollArea* scrAreaFolders;
static gcn::TextField *txtCurrent;
class ButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == cmdOK)
{
dialogResult = true;
}
dialogFinished = true;
}
};
static ButtonActionListener* buttonActionListener;
class DirListModel : public gcn::ListModel
{
std::vector<std::string> dirs;
public:
DirListModel(const char * path)
{
changeDir(path);
}
int getNumberOfElements()
{
return dirs.size();
}
std::string getElementAt(int i)
{
if(i >= dirs.size() || i < 0)
return "---";
return dirs[i];
}
void changeDir(const char *path)
{
ReadDirectory(path, &dirs, NULL);
if(dirs.size() == 0)
dirs.push_back("..");
}
};
static DirListModel dirList(".");
static void checkfoldername (char *current)
{
char *ptr;
char actualpath [PATH_MAX];
DIR *dir;
if (dir = opendir(current))
{
dirList = current;
ptr = realpath(current, actualpath);
strcpy(workingDir, ptr);
closedir(dir);
}
else
strcpy(workingDir, start_path_data);
txtCurrent->setText(workingDir);
}
class ListBoxActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
int selected_item;
char foldername[256] = "";
selected_item = lstFolders->getSelected();
strcpy(foldername, workingDir);
strcat(foldername, "/");
strcat(foldername, dirList.getElementAt(selected_item).c_str());
checkfoldername(foldername);
}
};
static ListBoxActionListener* listBoxActionListener;
static void InitSelectFolder(const char *title)
{
wndSelectFolder = new gcn::Window("Load");
wndSelectFolder->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
wndSelectFolder->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
wndSelectFolder->setBaseColor(gui_baseCol + 0x202020);
wndSelectFolder->setCaption(title);
wndSelectFolder->setTitleBarHeight(TITLEBAR_HEIGHT);
buttonActionListener = new ButtonActionListener();
cmdOK = new gcn::Button("Ok");
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdOK->setBaseColor(gui_baseCol + 0x202020);
cmdOK->addActionListener(buttonActionListener);
cmdCancel = new gcn::Button("Cancel");
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
cmdCancel->addActionListener(buttonActionListener);
txtCurrent = new gcn::TextField();
txtCurrent->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, TEXTFIELD_HEIGHT);
txtCurrent->setPosition(DISTANCE_BORDER, 10);
txtCurrent->setEnabled(false);
listBoxActionListener = new ListBoxActionListener();
lstFolders = new gcn::ListBox(&dirList);
lstFolders->setSize(800, 252);
lstFolders->setBaseColor(gui_baseCol);
lstFolders->setWrappingEnabled(true);
lstFolders->addActionListener(listBoxActionListener);
scrAreaFolders = new gcn::ScrollArea(lstFolders);
scrAreaFolders->setFrameSize(1);
scrAreaFolders->setPosition(DISTANCE_BORDER, 10 + TEXTFIELD_HEIGHT + 10);
scrAreaFolders->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER - 4, 272);
scrAreaFolders->setScrollbarWidth(20);
scrAreaFolders->setBaseColor(gui_baseCol + 0x202020);
wndSelectFolder->add(cmdOK);
wndSelectFolder->add(cmdCancel);
wndSelectFolder->add(txtCurrent);
wndSelectFolder->add(scrAreaFolders);
gui_top->add(wndSelectFolder);
lstFolders->requestFocus();
lstFolders->setSelected(0);
wndSelectFolder->requestModalFocus();
}
static void ExitSelectFolder(void)
{
wndSelectFolder->releaseModalFocus();
gui_top->remove(wndSelectFolder);
delete cmdOK;
delete cmdCancel;
delete buttonActionListener;
delete txtCurrent;
delete lstFolders;
delete scrAreaFolders;
delete listBoxActionListener;
delete wndSelectFolder;
}
static void SelectFolderLoop(void)
{
while(!dialogFinished)
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
if (event.type == SDL_KEYDOWN)
{
switch(event.key.keysym.sym)
{
case SDLK_ESCAPE:
dialogFinished = true;
break;
case SDLK_LEFT:
{
gcn::FocusHandler* focusHdl = gui_top->_getFocusHandler();
gcn::Widget* activeWidget = focusHdl->getFocused();
if(activeWidget == lstFolders)
cmdCancel->requestFocus();
else if(activeWidget == cmdCancel)
cmdOK->requestFocus();
else if(activeWidget == cmdOK)
lstFolders->requestFocus();
continue;
}
break;
case SDLK_RIGHT:
{
gcn::FocusHandler* focusHdl = gui_top->_getFocusHandler();
gcn::Widget* activeWidget = focusHdl->getFocused();
if(activeWidget == lstFolders)
cmdOK->requestFocus();
else if(activeWidget == cmdCancel)
lstFolders->requestFocus();
else if(activeWidget == cmdOK)
cmdCancel->requestFocus();
continue;
}
break;
case SDLK_PAGEDOWN:
case SDLK_HOME:
event.key.keysym.sym = SDLK_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
}
}
//-------------------------------------------------
// Send event to guichan-controls
//-------------------------------------------------
gui_input->pushInput(event);
}
// Now we let the Gui object perform its logic.
uae_gui->logic();
// Now we let the Gui object draw itself.
uae_gui->draw();
// Finally we update the screen.
SDL_Flip(gui_screen);
}
}
bool SelectFolder(const char *title, char *value)
{
dialogResult = false;
dialogFinished = false;
InitSelectFolder(title);
checkfoldername(value);
SelectFolderLoop();
ExitSelectFolder();
if(dialogResult)
{
strncpy(value, workingDir, MAX_PATH);
if(value[strlen(value) - 1] != '/')
strcat(value, "/");
}
return dialogResult;
}

View file

@ -0,0 +1,94 @@
#include "osdep/gui/SelectorEntry.hpp"
#include "guichan/widgets/container.hpp"
#include "guichan/widgets/icon.hpp"
#include "guichan/widgets/label.hpp"
namespace gcn
{
SelectorEntry::SelectorEntry(const std::string& caption, const std::string& imagepath)
{
addWidgetListener(this);
active = false;
container = new gcn::Container();
container->setOpaque(true);
label = new gcn::Label(caption);
label->setHeight(16);
gcn::Image *img = gcn::Image::load(imagepath);
icon = new gcn::Icon(img);
icon->setSize(16, 16);
container->add(icon, 4, 4);
container->add(label, 24, 4);
setFocusable(true);
setId(caption);
}
SelectorEntry::~SelectorEntry()
{
removeWidgetListener(this);
delete container;
delete label;
delete icon;
}
void SelectorEntry::draw(Graphics* graphics)
{
container->draw(graphics);
if(isFocused())
graphics->drawRectangle(Rectangle(2, 2, getWidth() - 4, getHeight() - 4));
}
void SelectorEntry::setInactiveColor(const Color& color)
{
inactiveColor = color;
if(!active)
container->setBaseColor(color);
}
void SelectorEntry::setActiveColor(const Color& color)
{
activeColor = color;
if(active)
container->setBaseColor(color);
}
void SelectorEntry::setActive(bool active)
{
this->active = active;
if(active)
container->setBaseColor(activeColor);
else
container->setBaseColor(inactiveColor);
}
bool SelectorEntry::getActive(void)
{
return active;
}
void SelectorEntry::widgetResized(const Event& event)
{
if(container->getWidth() != getWidth())
container->setWidth(getWidth());
if(container->getHeight() != getHeight())
container->setHeight(getHeight());
if(label->getWidth() != getWidth() - label->getX() - 4)
label->setWidth(getWidth() - label->getX() - 4);
}
}

View file

@ -0,0 +1,51 @@
#ifndef GCN_SELECTORENTRY_HPP
#define GCN_SELECTORENTRY_HPP
#include <list>
#include "guichan/basiccontainer.hpp"
#include "guichan/graphics.hpp"
#include "guichan/platform.hpp"
#include "guichan/widgetlistener.hpp"
namespace gcn
{
class Container;
class Icon;
class Label;
class Color;
class WidgetListener;
class GCN_CORE_DECLSPEC SelectorEntry :
public Widget,
public WidgetListener
{
public:
SelectorEntry(const std::string& caption, const std::string& imagepath);
virtual ~SelectorEntry();
virtual void draw(Graphics* graphics);
void setInactiveColor(const Color& color);
void setActiveColor(const Color& color);
void setActive(bool active);
bool getActive(void);
virtual void widgetResized(const Event& event);
protected:
Container *container;
Icon *icon;
Label *label;
Color inactiveColor;
Color activeColor;
bool active;
};
}
#endif // end GCN_SELECTORENTRY_HPP

View file

@ -0,0 +1,172 @@
#include <algorithm>
#include <guichan.hpp>
#include <iostream>
#include <sstream>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "gui.h"
#include "gui_handling.h"
#define DIALOG_WIDTH 340
#define DIALOG_HEIGHT 140
static bool dialogResult = false;
static bool dialogFinished = false;
static gcn::Window *wndShowMessage;
static gcn::Button* cmdOK;
static gcn::Button* cmdCancel;
static gcn::Label* lblText1;
static gcn::Label* lblText2;
class ShowMessageActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == cmdOK)
dialogResult = true;
dialogFinished = true;
}
};
static ShowMessageActionListener* showMessageActionListener;
static void InitShowMessage(void)
{
wndShowMessage = new gcn::Window("Message");
wndShowMessage->setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
wndShowMessage->setPosition((GUI_WIDTH - DIALOG_WIDTH) / 2, (GUI_HEIGHT - DIALOG_HEIGHT) / 2);
wndShowMessage->setBaseColor(gui_baseCol + 0x202020);
wndShowMessage->setTitleBarHeight(TITLEBAR_HEIGHT);
showMessageActionListener = new ShowMessageActionListener();
lblText1 = new gcn::Label("");
lblText1->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER, LABEL_HEIGHT);
lblText2 = new gcn::Label("");
lblText2->setSize(DIALOG_WIDTH - 2 * DISTANCE_BORDER, LABEL_HEIGHT);
cmdOK = new gcn::Button("Ok");
cmdOK->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdOK->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - 2 * BUTTON_WIDTH - DISTANCE_NEXT_X, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdOK->setBaseColor(gui_baseCol + 0x202020);
cmdOK->addActionListener(showMessageActionListener);
cmdCancel = new gcn::Button("Cancel");
cmdCancel->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdCancel->setPosition(DIALOG_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, DIALOG_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - 10);
cmdCancel->setBaseColor(gui_baseCol + 0x202020);
cmdCancel->addActionListener(showMessageActionListener);
wndShowMessage->add(lblText1, DISTANCE_BORDER, DISTANCE_BORDER);
wndShowMessage->add(lblText2, DISTANCE_BORDER, DISTANCE_BORDER + lblText1->getHeight() + 4);
wndShowMessage->add(cmdOK);
wndShowMessage->add(cmdCancel);
gui_top->add(wndShowMessage);
cmdOK->requestFocus();
wndShowMessage->requestModalFocus();
}
static void ExitShowMessage(void)
{
wndShowMessage->releaseModalFocus();
gui_top->remove(wndShowMessage);
delete lblText1;
delete lblText2;
delete cmdOK;
delete cmdCancel;
delete showMessageActionListener;
delete wndShowMessage;
}
static void ShowMessageLoop(void)
{
while(!dialogFinished)
{
SDL_Event event;
while(SDL_PollEvent(&event))
{
if (event.type == SDL_KEYDOWN)
{
switch(event.key.keysym.sym)
{
case SDLK_ESCAPE:
dialogFinished = true;
break;
case SDLK_LEFT:
case SDLK_RIGHT:
{
gcn::FocusHandler* focusHdl = gui_top->_getFocusHandler();
gcn::Widget* activeWidget = focusHdl->getFocused();
if(activeWidget == cmdCancel)
cmdOK->requestFocus();
else if(activeWidget == cmdOK)
cmdCancel->requestFocus();
continue;
}
break;
case SDLK_PAGEDOWN:
case SDLK_HOME:
event.key.keysym.sym = SDLK_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
}
}
//-------------------------------------------------
// Send event to guichan-controls
//-------------------------------------------------
gui_input->pushInput(event);
}
// Now we let the Gui object perform its logic.
uae_gui->logic();
// Now we let the Gui object draw itself.
uae_gui->draw();
// Finally we update the screen.
SDL_Flip(gui_screen);
}
}
bool ShowMessage(const char *title, const char *line1, const char *line2, const char *button1, const char *button2)
{
dialogResult = false;
dialogFinished = false;
InitShowMessage();
wndShowMessage->setCaption(title);
lblText1->setCaption(line1);
lblText2->setCaption(line2);
cmdOK->setCaption(button1);
cmdCancel->setCaption(button2);
if(strlen(button2) == 0)
{
cmdCancel->setVisible(false);
cmdOK->setPosition(cmdCancel->getX(), cmdCancel->getY());
}
ShowMessageLoop();
ExitShowMessage();
return dialogResult;
}

View file

@ -0,0 +1,87 @@
#include "UaeCheckBox.hpp"
#include "guichan/widgets/checkbox.hpp"
#include "guichan/font.hpp"
#include "guichan/graphics.hpp"
#include "guichan/key.hpp"
#include "guichan/mouseinput.hpp"
namespace gcn
{
UaeCheckBox::UaeCheckBox()
: CheckBox()
{
}
UaeCheckBox::UaeCheckBox(const std::string &caption,
bool selected)
: CheckBox(caption, selected)
{
setId(caption);
}
UaeCheckBox::~UaeCheckBox()
{
}
void UaeCheckBox::draw(Graphics* graphics)
{
drawBox(graphics);
graphics->setFont(getFont());
graphics->setColor(getForegroundColor());
const int h = getHeight() + getHeight() / 2;
graphics->drawText(getCaption(), h - 2, 0);
if (isFocused())
{
graphics->setColor(Color(0x000000));
graphics->drawRectangle(Rectangle(0,
0,
getWidth(),
getHeight()));
}
}
void UaeCheckBox::drawBox(Graphics *graphics)
{
const int h = getHeight() - 2;
const int alpha = getBaseColor().a;
Color faceColor = getBaseColor();
faceColor.a = alpha;
Color highlightColor = faceColor + 0x303030;
highlightColor.a = alpha;
Color shadowColor = faceColor - 0x303030;
shadowColor.a = alpha;
graphics->setColor(shadowColor);
graphics->drawLine(1, 1, h, 1);
graphics->drawLine(1, 1, 1, h);
graphics->setColor(highlightColor);
graphics->drawLine(h, 1, h, h);
graphics->drawLine(1, h, h - 1, h);
Color backCol = getBackgroundColor();
if(!isEnabled())
backCol = backCol - 0x303030;
graphics->setColor(backCol);
graphics->fillRectangle(Rectangle(2, 2, h - 2, h - 2));
graphics->setColor(getForegroundColor());
if (mSelected)
{
graphics->drawLine(3, 9, 6, h - 2);
graphics->drawLine(4, 9, 7, h - 2);
graphics->drawLine(6, h - 2, h - 3, 4);
graphics->drawLine(7, h - 2, h - 2, 4);
}
}
}

View file

@ -0,0 +1,35 @@
#ifndef GCN_UAECHECKBOX_HPP
#define GCN_UAECHECKBOX_HPP
#include <map>
#include <string>
#include "guichan/keylistener.hpp"
#include "guichan/mouselistener.hpp"
#include "guichan/platform.hpp"
#include "guichan/widget.hpp"
#include "guichan/widgets/checkbox.hpp"
namespace gcn
{
class GCN_CORE_DECLSPEC UaeCheckBox : public CheckBox
{
public:
UaeCheckBox();
UaeCheckBox(const std::string &caption,
bool selected = false);
virtual ~UaeCheckBox();
virtual void draw(Graphics* graphics);
protected:
virtual void drawBox(Graphics *graphics);
};
}
#endif // end GCN_UAECHECKBOX_HPP

View file

@ -0,0 +1,62 @@
#include "UaeDropDown.hpp"
#include "guichan/widgets/dropdown.hpp"
#include "guichan/font.hpp"
#include "guichan/graphics.hpp"
#include "guichan/key.hpp"
#include "guichan/mouseinput.hpp"
namespace gcn
{
UaeDropDown::UaeDropDown(ListModel *listModel,
ScrollArea *scrollArea,
ListBox *listBox)
: DropDown(listModel, scrollArea, listBox)
{
mScrollArea->setScrollbarWidth(20);
}
UaeDropDown::~UaeDropDown()
{
}
void UaeDropDown::keyPressed(KeyEvent& keyEvent)
{
if (keyEvent.isConsumed())
return;
Key key = keyEvent.getKey();
if ((key.getValue() == Key::ENTER || key.getValue() == Key::SPACE)
&& !mDroppedDown)
{
dropDown();
keyEvent.consume();
}
else if (key.getValue() == Key::UP)
{
setSelected(getSelected() - 1);
keyEvent.consume();
distributeActionEvent();
}
else if (key.getValue() == Key::DOWN)
{
setSelected(getSelected() + 1);
keyEvent.consume();
distributeActionEvent();
}
}
void UaeDropDown::clearSelected(void)
{
mListBox->setSelected(-1);
}
bool UaeDropDown::isDroppedDown(void)
{
return mDroppedDown;
}
}

View file

@ -0,0 +1,34 @@
#ifndef GCN_UAEDROPDOWN_HPP
#define GCN_UAEDROPDOWN_HPP
#include <map>
#include <string>
#include "guichan/keylistener.hpp"
#include "guichan/mouselistener.hpp"
#include "guichan/platform.hpp"
#include "guichan/widget.hpp"
#include "guichan/widgets/dropdown.hpp"
namespace gcn
{
class GCN_CORE_DECLSPEC UaeDropDown : public DropDown
{
public:
UaeDropDown(ListModel *listModel = NULL,
ScrollArea *scrollArea = NULL,
ListBox *listBox = NULL);
virtual ~UaeDropDown();
virtual void keyPressed(KeyEvent& keyEvent);
void clearSelected(void);
bool isDroppedDown(void);
};
}
#endif // end GCN_UAEDROPDOWN_HPP

View file

@ -0,0 +1,105 @@
#include "UaeListBox.hpp"
#include "guichan/widgets/listbox.hpp"
#include "guichan/basiccontainer.hpp"
#include "guichan/font.hpp"
#include "guichan/graphics.hpp"
#include "guichan/key.hpp"
#include "guichan/listmodel.hpp"
#include "guichan/mouseinput.hpp"
#include "guichan/selectionlistener.hpp"
namespace gcn
{
UaeListBox::UaeListBox()
: ListBox()
{
}
UaeListBox::UaeListBox(ListModel *listModel)
: ListBox(listModel)
{
}
UaeListBox::~UaeListBox()
{
}
void UaeListBox::draw(Graphics* graphics)
{
graphics->setColor(getBackgroundColor());
graphics->fillRectangle(Rectangle(0, 0, getWidth(), getHeight()));
if (mListModel == NULL)
{
return;
}
graphics->setColor(getForegroundColor());
graphics->setFont(getFont());
// Check the current clip area so we don't draw unnecessary items
// that are not visible.
const ClipRectangle currentClipArea = graphics->getCurrentClipArea();
int rowHeight = getRowHeight();
// Calculate the number of rows to draw by checking the clip area.
// The addition of two makes covers a partial visible row at the top
// and a partial visible row at the bottom.
int numberOfRows = currentClipArea.height / rowHeight + 2;
if (numberOfRows > mListModel->getNumberOfElements())
{
numberOfRows = mListModel->getNumberOfElements();
}
// Calculate which row to start drawing. If the list box
// has a negative y coordinate value we should check if
// we should drop rows in the begining of the list as
// they might not be visible. A negative y value is very
// common if the list box for instance resides in a scroll
// area and the user has scrolled the list box downwards.
int startRow;
if (getY() < 0)
{
startRow = -1 * (getY() / rowHeight);
}
else
{
startRow = 0;
}
int i;
// The y coordinate where we start to draw the text is
// simply the y coordinate multiplied with the font height.
int y = rowHeight * startRow;
for (i = startRow; i < startRow + numberOfRows; ++i)
{
if (i == mSelected)
{
if(isFocused())
graphics->setColor(getSelectionColor());
else
graphics->setColor(0xd0d0d0);
graphics->fillRectangle(Rectangle(0, y, getWidth(), rowHeight));
graphics->setColor(getForegroundColor());
}
// If the row height is greater than the font height we
// draw the text with a center vertical alignment.
if (rowHeight > getFont()->getHeight())
{
graphics->drawText(mListModel->getElementAt(i), 1, y + rowHeight / 2 - getFont()->getHeight() / 2);
}
else
{
graphics->drawText(mListModel->getElementAt(i), 1, y);
}
y += rowHeight;
}
}
}

View file

@ -0,0 +1,30 @@
#ifndef GCN_UAELISTBOX_HPP
#define GCN_UAELISTBOX_HPP
#include <list>
#include "guichan/keylistener.hpp"
#include "guichan/listmodel.hpp"
#include "guichan/mouselistener.hpp"
#include "guichan/platform.hpp"
#include "guichan/widget.hpp"
#include "guichan/widgets/listbox.hpp"
namespace gcn
{
class GCN_CORE_DECLSPEC UaeListBox : public ListBox
{
public:
UaeListBox();
UaeListBox(ListModel *listModel);
virtual ~UaeListBox();
virtual void draw(Graphics* graphics);
};
}
#endif // end GCN_UAELISTBOX_HPP

View file

@ -0,0 +1,59 @@
#include "UaeRadioButton.hpp"
#include "guichan/widgets/radiobutton.hpp"
#include "guichan/font.hpp"
#include "guichan/graphics.hpp"
#include "guichan/key.hpp"
#include "guichan/mouseinput.hpp"
namespace gcn
{
UaeRadioButton::UaeRadioButton()
: RadioButton()
{
}
UaeRadioButton::UaeRadioButton(const std::string &caption,
const std::string &group,
bool selected)
: RadioButton(caption, group, selected)
{
setId(caption);
}
UaeRadioButton::~UaeRadioButton()
{
// Remove us from the group list
setGroup("");
}
void UaeRadioButton::draw(Graphics* graphics)
{
graphics->pushClipArea(Rectangle(1,
1,
getWidth() - 1,
getHeight() - 1));
drawBox(graphics);
graphics->popClipArea();
graphics->setFont(getFont());
graphics->setColor(getForegroundColor());
if (isFocused())
{
graphics->setColor(Color(0x000000));
graphics->drawRectangle(Rectangle(0,
0,
getWidth(),
getHeight()));
}
int h = getHeight() + getHeight() / 2;
graphics->drawText(getCaption(), h - 2, 0);
}
}

View file

@ -0,0 +1,33 @@
#ifndef GCN_UAERADIOBUTTON_HPP
#define GCN_UAERADIOBUTTON_HPP
#include <map>
#include <string>
#include "guichan/keylistener.hpp"
#include "guichan/mouselistener.hpp"
#include "guichan/platform.hpp"
#include "guichan/widget.hpp"
#include "guichan/widgets/radiobutton.hpp"
namespace gcn
{
class GCN_CORE_DECLSPEC UaeRadioButton : public RadioButton
{
public:
UaeRadioButton();
UaeRadioButton(const std::string &caption,
const std::string &group,
bool selected = false);
virtual ~UaeRadioButton();
virtual void draw(Graphics* graphics);
};
}
#endif // end GCN_UAERADIOBUTTON_HPP

View file

@ -0,0 +1,109 @@
#ifndef _GUI_HANDLING_H
#define _GUI_HANDLING_H
#define GUI_WIDTH 800
#define GUI_HEIGHT 480
#define DISTANCE_BORDER 15
#define DISTANCE_NEXT_X 15
#define DISTANCE_NEXT_Y 15
#define BUTTON_WIDTH 90
#define BUTTON_HEIGHT 30
#define SMALL_BUTTON_WIDTH 30
#define SMALL_BUTTON_HEIGHT 22
#define LABEL_HEIGHT 20
#define TEXTFIELD_HEIGHT 24
#define DROPDOWN_HEIGHT 22
#define SLIDER_HEIGHT 18
#define TITLEBAR_HEIGHT 24
typedef struct _ConfigCategory {
const char *category;
const char *imagepath;
gcn::SelectorEntry *selector;
gcn::Container *panel;
void (*InitFunc) (const struct _ConfigCategory& category);
void (*ExitFunc) (void);
void (*RefreshFunc) (void);
} ConfigCategory;
extern bool gui_running;
extern ConfigCategory categories[];
extern gcn::Gui* uae_gui;
extern gcn::Container* gui_top;
extern gcn::Color gui_baseCol;
extern gcn::SDLInput* gui_input;
extern SDL_Surface* gui_screen;
extern char currentDir[MAX_DPATH];
extern char last_loaded_config[MAX_DPATH];
typedef struct {
char Name[MAX_DPATH];
char FullPath[MAX_DPATH];
char Description[MAX_DPATH];
} ConfigFileInfo;
extern std::vector<ConfigFileInfo*> ConfigFilesList;
void InitPanelPaths(const struct _ConfigCategory& category);
void ExitPanelPaths(void);
void RefreshPanelPaths(void);
void InitPanelConfig(const struct _ConfigCategory& category);
void ExitPanelConfig(void);
void RefreshPanelConfig(void);
void InitPanelCPU(const struct _ConfigCategory& category);
void ExitPanelCPU(void);
void RefreshPanelCPU(void);
void InitPanelChipset(const struct _ConfigCategory& category);
void ExitPanelChipset(void);
void RefreshPanelChipset(void);
void InitPanelROM(const struct _ConfigCategory& category);
void ExitPanelROM(void);
void RefreshPanelROM(void);
void InitPanelRAM(const struct _ConfigCategory& category);
void ExitPanelRAM(void);
void RefreshPanelRAM(void);
void InitPanelFloppy(const struct _ConfigCategory& category);
void ExitPanelFloppy(void);
void RefreshPanelFloppy(void);
void InitPanelHD(const struct _ConfigCategory& category);
void ExitPanelHD(void);
void RefreshPanelHD(void);
void InitPanelDisplay(const struct _ConfigCategory& category);
void ExitPanelDisplay(void);
void RefreshPanelDisplay(void);
void InitPanelSound(const struct _ConfigCategory& category);
void ExitPanelSound(void);
void RefreshPanelSound(void);
void InitPanelInput(const struct _ConfigCategory& category);
void ExitPanelInput(void);
void RefreshPanelInput(void);
void InitPanelMisc(const struct _ConfigCategory& category);
void ExitPanelMisc(void);
void RefreshPanelMisc(void);
void InitPanelSavestate(const struct _ConfigCategory& category);
void ExitPanelSavestate(void);
void RefreshPanelSavestate(void);
void RefreshAllPanels(void);
void InGameMessage(const char *msg);
bool ShowMessage(const char *title, const char *line1, const char *line2, const char *button1, const char *button2);
bool SelectFolder(const char *title, char *value);
bool SelectFile(const char *title, char *value, const char *filter[]);
bool EditFilesysVirtual(int unit_no);
bool EditFilesysHardfile(int unit_no);
bool LoadConfigByName(const char *name);
ConfigFileInfo* SearchConfigInList(const char *name);
extern void ReadDirectory(const char *path, std::vector<std::string> *dirs, std::vector<std::string> *files);
extern void FilterFiles(std::vector<std::string> *files, const char *filter[]);
enum { DIRECTION_NONE, DIRECTION_UP, DIRECTION_DOWN, DIRECTION_LEFT, DIRECTION_RIGHT };
bool HandleNavigation(int direction);
extern char *screenshot_filename;
extern int currentStateNum;
extern int delay_savestate_frame;
#endif // _GUI_HANDLING_H

View file

@ -0,0 +1,507 @@
#include <guichan.hpp>
#include <SDL/SDL_ttf.h>
#include <guichan/sdl.hpp>
#include "sdltruetypefont.hpp"
#include "SelectorEntry.hpp"
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "uae.h"
#include "gui.h"
#include "target.h"
#include "gui_handling.h"
bool gui_running = false;
static int last_active_panel = 1;
ConfigCategory categories[] = {
{ "Paths", "data/paths.ico", NULL, NULL, InitPanelPaths, ExitPanelPaths, RefreshPanelPaths },
{ "Configurations", "data/file.ico", NULL, NULL, InitPanelConfig, ExitPanelConfig, RefreshPanelConfig },
{ "CPU", "data/cpu.ico", NULL, NULL, InitPanelCPU, ExitPanelCPU, RefreshPanelCPU },
{ "Chipset", "data/cpu.ico", NULL, NULL, InitPanelChipset, ExitPanelChipset, RefreshPanelChipset },
{ "ROM", "data/chip.ico", NULL, NULL, InitPanelROM, ExitPanelROM, RefreshPanelROM },
{ "RAM", "data/chip.ico", NULL, NULL, InitPanelRAM, ExitPanelRAM, RefreshPanelRAM },
{ "Floppy drives", "data/35floppy.ico", NULL, NULL, InitPanelFloppy, ExitPanelFloppy, RefreshPanelFloppy },
{ "Hard drives", "data/drive.ico", NULL, NULL, InitPanelHD, ExitPanelHD, RefreshPanelHD },
{ "Display", "data/screen.ico", NULL, NULL, InitPanelDisplay, ExitPanelDisplay, RefreshPanelDisplay },
{ "Sound", "data/sound.ico", NULL, NULL, InitPanelSound, ExitPanelSound, RefreshPanelSound },
{ "Input", "data/joystick.ico", NULL, NULL, InitPanelInput, ExitPanelInput, RefreshPanelInput },
{ "Miscellaneous", "data/misc.ico", NULL, NULL, InitPanelMisc, ExitPanelMisc, RefreshPanelMisc },
{ "Savestates", "data/savestate.png", NULL, NULL, InitPanelSavestate, ExitPanelSavestate, RefreshPanelSavestate },
{ NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
enum { PANEL_PATHS, PANEL_CONFIGURATIONS, PANEL_CPU, PANEL_CHIPSET, PANEL_ROM, PANEL_RAM,
PANEL_FLOPPY, PANEL_HD, PANEL_DISPLAY, PANEL_SOUND, PANEL_INPUT, PANEL_MISC, PANEL_SAVESTATES,
NUM_PANELS };
gcn::Gui* uae_gui;
gcn::Color gui_baseCol;
gcn::Color gui_baseColLabel;
gcn::Color colSelectorInactive;
gcn::Color colSelectorActive;
gcn::Container* gui_top;
gcn::Container* selectors;
gcn::contrib::SDLTrueTypeFont* gui_font;
SDL_Surface* gui_screen;
gcn::SDLGraphics* gui_graphics;
gcn::SDLInput* gui_input;
gcn::SDLImageLoader* gui_imageLoader;
namespace sdl
{
void gui_init()
{
//-------------------------------------------------
// Set layer for GUI screen
//-------------------------------------------------
char tmp[20];
snprintf(tmp, 20, "%dx%d", GUI_WIDTH, GUI_HEIGHT);
setenv("SDL_OMAP_LAYER_SIZE", tmp, 1);
snprintf(tmp, 20, "0,0,0,0");
setenv("SDL_OMAP_BORDER_CUT", tmp, 1);
//-------------------------------------------------
// Create new screen for GUI
//-------------------------------------------------
gui_screen = SDL_SetVideoMode(GUI_WIDTH, GUI_HEIGHT, 16, SDL_SWSURFACE);
SDL_EnableUNICODE(1);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
SDL_ShowCursor(SDL_ENABLE);
//-------------------------------------------------
// Create helpers for guichan
//-------------------------------------------------
gui_imageLoader = new gcn::SDLImageLoader();
gcn::Image::setImageLoader(gui_imageLoader);
gui_graphics = new gcn::SDLGraphics();
gui_graphics->setTarget(gui_screen);
gui_input = new gcn::SDLInput();
uae_gui = new gcn::Gui();
uae_gui->setGraphics(gui_graphics);
uae_gui->setInput(gui_input);
}
void gui_halt()
{
delete uae_gui;
delete gui_imageLoader;
delete gui_input;
delete gui_graphics;
SDL_FreeSurface(gui_screen);
gui_screen = NULL;
}
void gui_run()
{
//-------------------------------------------------
// The main loop
//-------------------------------------------------
while(gui_running)
{
//-------------------------------------------------
// Check user input
//-------------------------------------------------
SDL_Event event;
while(SDL_PollEvent(&event))
{
if (event.type == SDL_QUIT)
{
//-------------------------------------------------
// Quit entire program via SQL-Quit
//-------------------------------------------------
uae_quit();
gui_running = false;
break;
}
else if (event.type == SDL_KEYDOWN)
{
switch(event.key.keysym.sym)
{
case SDLK_q:
//-------------------------------------------------
// Quit entire program via Q on keyboard
//-------------------------------------------------
uae_quit();
gui_running = false;
break;
case SDLK_ESCAPE:
case SDLK_RCTRL:
//-------------------------------------------------
// Reset Amiga
//-------------------------------------------------
uae_reset(0);
gui_running = false;
break;
case SDLK_LCTRL:
if(emulating)
{
//------------------------------------------------
// Continue emulation
//------------------------------------------------
gui_running = false;
}
else
{
//------------------------------------------------
// First start of emulator -> reset Amiga
//------------------------------------------------
uae_reset(0);
gui_running = false;
}
break;
case SDLK_PAGEDOWN:
case SDLK_HOME:
//------------------------------------------------
// Simulate press of enter when 'X' pressed
//------------------------------------------------
event.key.keysym.sym = SDLK_RETURN;
gui_input->pushInput(event); // Fire key down
event.type = SDL_KEYUP; // and the key up
break;
case SDLK_UP:
if(HandleNavigation(DIRECTION_UP))
continue; // Don't change value when enter ComboBox -> don't send event to control
break;
case SDLK_DOWN:
if(HandleNavigation(DIRECTION_DOWN))
continue; // Don't change value when enter ComboBox -> don't send event to control
break;
case SDLK_LEFT:
if(HandleNavigation(DIRECTION_LEFT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
case SDLK_RIGHT:
if(HandleNavigation(DIRECTION_RIGHT))
continue; // Don't change value when enter Slider -> don't send event to control
break;
}
}
//-------------------------------------------------
// Send event to guichan-controls
//-------------------------------------------------
gui_input->pushInput(event);
}
// Now we let the Gui object perform its logic.
uae_gui->logic();
// Now we let the Gui object draw itself.
uae_gui->draw();
// Finally we update the screen.
SDL_Flip(gui_screen);
}
}
}
namespace widgets
{
// Main buttons
gcn::Button* cmdQuit;
gcn::Button* cmdReset;
gcn::Button* cmdRestart;
gcn::Button* cmdStart;
class MainButtonActionListener : public gcn::ActionListener
{
public:
void action(const gcn::ActionEvent& actionEvent)
{
if (actionEvent.getSource() == cmdQuit)
{
//-------------------------------------------------
// Quit entire program via click on Quit-button
//-------------------------------------------------
uae_quit();
gui_running = false;
}
else if(actionEvent.getSource() == cmdReset)
{
//-------------------------------------------------
// Reset Amiga via click on Reset-button
//-------------------------------------------------
uae_reset(0);
gui_running = false;
}
else if(actionEvent.getSource() == cmdRestart)
{
//-------------------------------------------------
// Restart emulator
//-------------------------------------------------
char tmp[MAX_PATH];
fetch_configurationpath (tmp, sizeof (tmp));
if(strlen(last_loaded_config) > 0)
strcat (tmp, last_loaded_config);
else
{
strcat (tmp, OPTIONSFILENAME);
strcat (tmp, ".uae");
}
uae_restart(0, tmp);
gui_running = false;
}
else if(actionEvent.getSource() == cmdStart)
{
if(emulating)
{
//------------------------------------------------
// Continue emulation
//------------------------------------------------
gui_running = false;
}
else
{
//------------------------------------------------
// First start of emulator -> reset Amiga
//------------------------------------------------
uae_reset(0);
gui_running = false;
}
}
}
};
MainButtonActionListener* mainButtonActionListener;
class PanelFocusListener : public gcn::FocusListener
{
public:
void focusGained(const gcn::Event& event)
{
int i;
for(i=0; categories[i].category != NULL; ++i)
{
if(event.getSource() == categories[i].selector)
{
categories[i].selector->setActive(true);
categories[i].panel->setVisible(true);
last_active_panel = i;
}
else
{
categories[i].selector->setActive(false);
categories[i].panel->setVisible(false);
}
}
}
};
PanelFocusListener* panelFocusListener;
void gui_init()
{
int i;
int yPos;
//-------------------------------------------------
// Define base colors
//-------------------------------------------------
gui_baseCol.r = 192;
gui_baseCol.g = 192;
gui_baseCol.b = 208;
gui_baseColLabel.r = gui_baseCol.r;
gui_baseColLabel.g = gui_baseCol.g;
gui_baseColLabel.b = gui_baseCol.b;
gui_baseColLabel.a = 192;
colSelectorInactive.r = 255;
colSelectorInactive.g = 255;
colSelectorInactive.b = 255;
colSelectorActive.r = 192;
colSelectorActive.g = 192;
colSelectorActive.b = 255;
//-------------------------------------------------
// Create container for main page
//-------------------------------------------------
gui_top = new gcn::Container();
gui_top->setDimension(gcn::Rectangle(0, 0, GUI_WIDTH, GUI_HEIGHT));
gui_top->setBaseColor(gui_baseCol);
uae_gui->setTop(gui_top);
//-------------------------------------------------
// Initialize fonts
//-------------------------------------------------
TTF_Init();
gui_font = new gcn::contrib::SDLTrueTypeFont("data/FreeSans.ttf", 14);
gcn::Widget::setGlobalFont(gui_font);
//--------------------------------------------------
// Create main buttons
//--------------------------------------------------
mainButtonActionListener = new MainButtonActionListener();
cmdQuit = new gcn::Button("Quit");
cmdQuit->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdQuit->setBaseColor(gui_baseCol);
cmdQuit->setId("Quit");
cmdQuit->addActionListener(mainButtonActionListener);
cmdReset = new gcn::Button("Reset");
cmdReset->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdReset->setBaseColor(gui_baseCol);
cmdReset->setId("Reset");
cmdReset->addActionListener(mainButtonActionListener);
cmdRestart = new gcn::Button("Restart");
cmdRestart->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdRestart->setBaseColor(gui_baseCol);
cmdRestart->setId("Restart");
cmdRestart->addActionListener(mainButtonActionListener);
cmdStart = new gcn::Button("Start");
if(emulating)
cmdStart->setCaption("Resume");
cmdStart->setSize(BUTTON_WIDTH, BUTTON_HEIGHT);
cmdStart->setBaseColor(gui_baseCol);
cmdStart->setId("Start");
cmdStart->addActionListener(mainButtonActionListener);
//--------------------------------------------------
// Create selector entries
//--------------------------------------------------
int workAreaHeight = GUI_HEIGHT - 2 * DISTANCE_BORDER - BUTTON_HEIGHT - DISTANCE_NEXT_Y;
selectors = new gcn::Container();
selectors->setSize(150, workAreaHeight - 2);
selectors->setBaseColor(colSelectorInactive);
selectors->setFrameSize(1);
int panelStartX = DISTANCE_BORDER + selectors->getWidth() + 2 + 11;
panelFocusListener = new PanelFocusListener();
for(i=0; categories[i].category != NULL; ++i)
{
categories[i].selector = new gcn::SelectorEntry(categories[i].category, categories[i].imagepath);
categories[i].selector->setActiveColor(colSelectorActive);
categories[i].selector->setInactiveColor(colSelectorInactive);
categories[i].selector->setSize(150, 24);
categories[i].selector->addFocusListener(panelFocusListener);
categories[i].panel = new gcn::Container();
categories[i].panel->setId(categories[i].category);
categories[i].panel->setSize(GUI_WIDTH - panelStartX - DISTANCE_BORDER - 1, workAreaHeight - 2);
categories[i].panel->setBaseColor(gui_baseCol);
categories[i].panel->setFrameSize(1);
categories[i].panel->setVisible(false);
}
//--------------------------------------------------
// Initialize panels
//--------------------------------------------------
for(i=0; categories[i].category != NULL; ++i)
{
if(categories[i].InitFunc != NULL)
(*categories[i].InitFunc) (categories[i]);
}
//--------------------------------------------------
// Place everything on main form
//--------------------------------------------------
gui_top->add(cmdReset, DISTANCE_BORDER, GUI_HEIGHT - DISTANCE_BORDER - BUTTON_HEIGHT);
gui_top->add(cmdQuit, DISTANCE_BORDER + BUTTON_WIDTH + DISTANCE_NEXT_X, GUI_HEIGHT - DISTANCE_BORDER - BUTTON_HEIGHT);
// gui_top->add(cmdRestart, DISTANCE_BORDER + 2 * BUTTON_WIDTH + 2 * DISTANCE_NEXT_X, GUI_HEIGHT - DISTANCE_BORDER - BUTTON_HEIGHT);
gui_top->add(cmdStart, GUI_WIDTH - DISTANCE_BORDER - BUTTON_WIDTH, GUI_HEIGHT - DISTANCE_BORDER - BUTTON_HEIGHT);
gui_top->add(selectors, DISTANCE_BORDER + 1, DISTANCE_BORDER + 1);
for(i=0, yPos=0; categories[i].category != NULL; ++i, yPos += 24)
{
selectors->add(categories[i].selector, 0, yPos);
gui_top->add(categories[i].panel, panelStartX, DISTANCE_BORDER + 1);
}
//--------------------------------------------------
// Activate last active panel
//--------------------------------------------------
categories[last_active_panel].selector->requestFocus();
}
void gui_halt()
{
int i;
for(i=0; categories[i].category != NULL; ++i)
{
if(categories[i].ExitFunc != NULL)
(*categories[i].ExitFunc) ();
}
for(i=0; categories[i].category != NULL; ++i)
delete categories[i].selector;
delete panelFocusListener;
delete selectors;
delete cmdQuit;
delete cmdReset;
delete cmdRestart;
delete cmdStart;
delete mainButtonActionListener;
delete gui_font;
delete gui_top;
}
}
void RefreshAllPanels(void)
{
int i;
for(i=0; categories[i].category != NULL; ++i)
{
if(categories[i].RefreshFunc != NULL)
(*categories[i].RefreshFunc) ();
}
}
void run_gui(void)
{
gui_running = true;
try
{
sdl::gui_init();
widgets::gui_init();
sdl::gui_run();
widgets::gui_halt();
sdl::gui_halt();
}
// Catch all Guichan exceptions.
catch (gcn::Exception e)
{
std::cout << e.getMessage() << std::endl;
uae_quit();
}
// Catch all Std exceptions.
catch (std::exception e)
{
std::cout << "Std exception: " << e.what() << std::endl;
uae_quit();
}
// Catch all unknown exceptions.
catch (...)
{
std::cout << "Unknown exception" << std::endl;
uae_quit();
}
if(quit_program > 1 || quit_program < -1)
{
//--------------------------------------------------
// Prepare everything for Reset of Amiga
//--------------------------------------------------
currprefs.nr_floppies = changed_prefs.nr_floppies;
}
}

View file

@ -0,0 +1,171 @@
/* _______ __ __ __ ______ __ __ _______ __ __
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
*
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
*
*
* Per Larsson a.k.a finalman
* Olof Naessén a.k.a jansem/yakslem
*
* Visit: http://guichan.sourceforge.net
*
* License: (BSD)
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Guichan nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
* For comments regarding functions please see the header file.
*/
#include "sdltruetypefont.hpp"
#include "guichan/exception.hpp"
#include "guichan/image.hpp"
#include "guichan/graphics.hpp"
#include "guichan/sdl/sdlgraphics.hpp"
namespace gcn
{
namespace contrib
{
SDLTrueTypeFont::SDLTrueTypeFont (const std::string& filename, int size)
{
mRowSpacing = 0;
mGlyphSpacing = 0;
mAntiAlias = true;
mFilename = filename;
mFont = NULL;
mFont = TTF_OpenFont(filename.c_str(), size);
if (mFont == NULL)
{
throw GCN_EXCEPTION("SDLTrueTypeFont::SDLTrueTypeFont. "+std::string(TTF_GetError()));
}
}
SDLTrueTypeFont::~SDLTrueTypeFont()
{
TTF_CloseFont(mFont);
}
int SDLTrueTypeFont::getWidth(const std::string& text) const
{
int w, h;
TTF_SizeText(mFont, text.c_str(), &w, &h);
return w;
}
int SDLTrueTypeFont::getHeight() const
{
return TTF_FontHeight(mFont) + mRowSpacing;
}
void SDLTrueTypeFont::drawString(gcn::Graphics* graphics, const std::string& text, const int x, const int y)
{
if (text == "")
{
return;
}
gcn::SDLGraphics *sdlGraphics = dynamic_cast<gcn::SDLGraphics *>(graphics);
if (sdlGraphics == NULL)
{
throw GCN_EXCEPTION("SDLTrueTypeFont::drawString. Graphics object not an SDL graphics object!");
return;
}
// This is needed for drawing the Glyph in the middle if we have spacing
int yoffset = getRowSpacing() / 2;
Color col = sdlGraphics->getColor();
SDL_Color sdlCol;
sdlCol.b = col.b;
sdlCol.r = col.r;
sdlCol.g = col.g;
SDL_Surface *textSurface;
if (mAntiAlias)
{
textSurface = TTF_RenderText_Blended(mFont, text.c_str(), sdlCol);
}
else
{
textSurface = TTF_RenderText_Solid(mFont, text.c_str(), sdlCol);
}
SDL_Rect dst, src;
dst.x = x;
dst.y = y + yoffset;
src.w = textSurface->w;
src.h = textSurface->h;
src.x = 0;
src.y = 0;
sdlGraphics->drawSDLSurface(textSurface, src, dst);
SDL_FreeSurface(textSurface);
}
void SDLTrueTypeFont::setRowSpacing(int spacing)
{
mRowSpacing = spacing;
}
int SDLTrueTypeFont::getRowSpacing()
{
return mRowSpacing;
}
void SDLTrueTypeFont::setGlyphSpacing(int spacing)
{
mGlyphSpacing = spacing;
}
int SDLTrueTypeFont::getGlyphSpacing()
{
return mGlyphSpacing;
}
void SDLTrueTypeFont::setAntiAlias(bool antiAlias)
{
mAntiAlias = antiAlias;
}
bool SDLTrueTypeFont::isAntiAlias()
{
return mAntiAlias;
}
}
}

View file

@ -0,0 +1,156 @@
/* _______ __ __ __ ______ __ __ _______ __ __
* / _____/\ / /\ / /\ / /\ / ____/\ / /\ / /\ / ___ /\ / |\/ /\
* / /\____\// / // / // / // /\___\// /_// / // /\_/ / // , |/ / /
* / / /__ / / // / // / // / / / ___ / // ___ / // /| ' / /
* / /_// /\ / /_// / // / // /_/_ / / // / // /\_/ / // / | / /
* /______/ //______/ //_/ //_____/\ /_/ //_/ //_/ //_/ //_/ /|_/ /
* \______\/ \______\/ \_\/ \_____\/ \_\/ \_\/ \_\/ \_\/ \_\/ \_\/
*
* Copyright (c) 2004 - 2008 Olof Naessén and Per Larsson
*
*
* Per Larsson a.k.a finalman
* Olof Naessén a.k.a jansem/yakslem
*
* Visit: http://guichan.sourceforge.net
*
* License: (BSD)
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name of Guichan nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef GCN_CONTRIB_SDLTRUETYPEFONT_HPP
#define GCN_CONTRIB_SDLTRUETYPEFONT_HPP
#include <map>
#include <string>
#include <SDL/SDL_ttf.h>
#include "guichan/font.hpp"
#include "guichan/platform.hpp"
namespace gcn
{
class Graphics;
namespace contrib
{
/**
* SDL True Type Font implementation of Font. It uses the SDL_ttf library
* to display True Type Fonts with SDL.
*
* NOTE: You must initialize the SDL_ttf library before using this
* class. Also, remember to call the SDL_ttf libraries quit
* function.
*
* @author Walluce Pinkham
* @author Olof Naessén
*/
class GCN_EXTENSION_DECLSPEC SDLTrueTypeFont: public Font
{
public:
/**
* Constructor.
*
* @param filename the filename of the True Type Font.
* @param size the size the font should be in.
*/
SDLTrueTypeFont (const std::string& filename, int size);
/**
* Destructor.
*/
virtual ~SDLTrueTypeFont();
/**
* Sets the spacing between rows in pixels. Default is 0 pixels.
* The spacing can be negative.
*
* @param spacing the spacing in pixels.
*/
virtual void setRowSpacing (int spacing);
/**
* Gets the spacing between rows in pixels.
*
* @return the spacing.
*/
virtual int getRowSpacing();
/**
* Sets the spacing between letters in pixels. Default is 0 pixels.
* The spacing can be negative.
*
* @param spacing the spacing in pixels.
*/
virtual void setGlyphSpacing(int spacing);
/**
* Gets the spacing between letters in pixels.
*
* @return the spacing.
*/
virtual int getGlyphSpacing();
/**
* Sets the use of anti aliasing..
*
* @param antaAlias true for use of antia aliasing.
*/
virtual void setAntiAlias(bool antiAlias);
/**
* Checks if anti aliasing is used.
*
* @return true if anti aliasing is used.
*/
virtual bool isAntiAlias();
// Inherited from Font
virtual int getWidth(const std::string& text) const;
virtual int getHeight() const;
virtual void drawString(Graphics* graphics, const std::string& text, int x, int y);
protected:
TTF_Font *mFont;
int mHeight;
int mGlyphSpacing;
int mRowSpacing;
std::string mFilename;
bool mAntiAlias;
};
}
}
#endif

View file

@ -0,0 +1,113 @@
#include<stdio.h>
#include<stdlib.h>
#include<SDL.h>
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "gp2x.h"
#include "inputmode.h"
#include "uae.h"
#include "target.h"
extern SDL_Surface *prSDLScreen;
static SDL_Surface *inputMode[3];
void inputmode_init(void)
{
int i;
char tmpchar[256];
SDL_Surface* tmp;
if(inputMode[0] == NULL)
{
snprintf(tmpchar, 256, "%s/data/joystick.bmp", start_path_data);
tmp = SDL_LoadBMP(tmpchar);
if (tmp)
{
inputMode[0] = SDL_DisplayFormat(tmp);
SDL_FreeSurface(tmp);
}
}
if(inputMode[1] == NULL)
{
snprintf(tmpchar, 256, "%s/data/mouse.bmp", start_path_data);
tmp = SDL_LoadBMP(tmpchar);
if (tmp)
{
inputMode[1] = SDL_DisplayFormat(tmp);
SDL_FreeSurface(tmp);
}
}
if(inputMode[2] == NULL)
{
snprintf(tmpchar, 256, "%s/data/remapping.bmp", start_path_data);
tmp = SDL_LoadBMP(tmpchar);
if (tmp)
{
inputMode[2] = SDL_DisplayFormat(tmp);
SDL_FreeSurface(tmp);
}
}
show_inputmode = 0;
}
void inputmode_redraw(void)
{
SDL_Rect r;
SDL_Surface* surface;
r.x=80;
r.y=prSDLScreen->h-200;
r.w=160;
r.h=160;
if (inputMode[0] && inputMode[1] && inputMode[2])
{
surface = inputMode[currprefs.pandora_custom_dpad];
SDL_BlitSurface(surface,NULL,prSDLScreen,&r);
}
}
void set_joyConf(void)
{
if(changed_prefs.pandora_joyConf == 0)
{
changed_prefs.pandora_button1 = GP2X_BUTTON_X;
changed_prefs.pandora_button2 = GP2X_BUTTON_A;
changed_prefs.pandora_jump = -1;
changed_prefs.pandora_autofireButton1 = GP2X_BUTTON_B;
}
else if(changed_prefs.pandora_joyConf == 1)
{
changed_prefs.pandora_button1 = GP2X_BUTTON_B;
changed_prefs.pandora_button2 = GP2X_BUTTON_A;
changed_prefs.pandora_jump = -1;
changed_prefs.pandora_autofireButton1 = GP2X_BUTTON_X;
}
else if(changed_prefs.pandora_joyConf == 2)
{
changed_prefs.pandora_button1 = GP2X_BUTTON_Y;
changed_prefs.pandora_button2 = GP2X_BUTTON_A;
changed_prefs.pandora_jump = GP2X_BUTTON_X;
changed_prefs.pandora_autofireButton1 = GP2X_BUTTON_B;
}
else if(changed_prefs.pandora_joyConf == 3)
{
changed_prefs.pandora_button1 = GP2X_BUTTON_B;
changed_prefs.pandora_button2 = GP2X_BUTTON_A;
changed_prefs.pandora_jump = GP2X_BUTTON_X;
changed_prefs.pandora_autofireButton1 = GP2X_BUTTON_Y;
}
}

View file

@ -0,0 +1,10 @@
#define SIMULATE_SHIFT 0x200
#define SIMULATE_RELEASED_SHIFT 0x400
void inputmode_init(void);
void inputmode_redraw(void);
void set_joyConf(void);
extern int show_inputmode;

221
src/od-pandora/joystick.cpp Normal file
View file

@ -0,0 +1,221 @@
/*
* UAE - The Un*x Amiga Emulator
*
* Joystick emulation for Linux and BSD. They share too much code to
* split this file.
*
* Copyright 1997 Bernd Schmidt
* Copyright 1998 Krister Walfridsson
*/
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "uae.h"
#include "options.h"
#include "memory.h"
#include "custom.h"
#include "joystick.h"
#include "SDL.h"
#ifdef GP2X
#include "gp2x.h"
#include "xwin.h"
#if defined(PANDORA) || defined (ANDROIDSDL)
extern int dpadUp;
extern int dpadDown;
extern int dpadLeft;
extern int dpadRight;
extern int buttonA;
extern int buttonB;
extern int buttonX;
extern int buttonY;
extern int triggerL;
extern int triggerR;
#endif
static int delay=0;
#endif
static int nr_joysticks;
static SDL_Joystick *uae4all_joy0, *uae4all_joy1;
void read_joystick(int nr, unsigned int *dir, int *button)
{
int left = 0, right = 0, top = 0, bot = 0, upRight=0, downRight=0, upLeft=0, downLeft=0, x=0, y=0, a=0, b=0;
SDL_Joystick *joy = nr == 0 ? uae4all_joy0 : uae4all_joy1;
*dir = 0;
*button = 0;
nr = (~nr)&0x1;
SDL_JoystickUpdate ();
if (!triggerR /*R+dpad = arrow keys*/ && currprefs.pandora_custom_dpad==0)
{
// get joystick direction via dPad or joystick
if (dpadRight || SDL_JoystickGetAxis(joy, 0) > 0) right=1;
if (dpadLeft || SDL_JoystickGetAxis(joy, 0) < 0) left=1;
if (dpadUp || SDL_JoystickGetAxis(joy, 1) < 0) top=1;
if (dpadDown || SDL_JoystickGetAxis(joy, 1) > 0) bot=1;
if (currprefs.pandora_joyConf)
{
if ((buttonX && currprefs.pandora_jump > -1) || SDL_JoystickGetButton(joy, currprefs.pandora_jump))
top = 1;
}
}
if(currprefs.pandora_customControls)
{
// get joystick direction via custom keys
if((currprefs.pandora_custom_A==-5 && buttonA) || (currprefs.pandora_custom_B==-5 && buttonB) || (currprefs.pandora_custom_X==-5 && buttonX) || (currprefs.pandora_custom_Y==-5 && buttonY) || (currprefs.pandora_custom_L==-5 && triggerL) || (currprefs.pandora_custom_R==-5 && triggerR))
top = 1;
else if(currprefs.pandora_custom_dpad == 2)
{
if((currprefs.pandora_custom_up==-5 && dpadUp) || (currprefs.pandora_custom_down==-5 && dpadDown) || (currprefs.pandora_custom_left==-5 && dpadLeft) || (currprefs.pandora_custom_right==-5 && dpadRight))
top = 1;
}
if((currprefs.pandora_custom_A==-6 && buttonA) || (currprefs.pandora_custom_B==-6 && buttonB) || (currprefs.pandora_custom_X==-6 && buttonX) || (currprefs.pandora_custom_Y==-6 && buttonY) || (currprefs.pandora_custom_L==-6 && triggerL) || (currprefs.pandora_custom_R==-6 && triggerR))
bot = 1;
else if(currprefs.pandora_custom_dpad == 2)
{
if((currprefs.pandora_custom_up==-6 && dpadUp) || (currprefs.pandora_custom_down==-6 && dpadDown) || (currprefs.pandora_custom_left==-6 && dpadLeft) || (currprefs.pandora_custom_right==-6 && dpadRight))
bot = 1;
}
if((currprefs.pandora_custom_A==-7 && buttonA) || (currprefs.pandora_custom_B==-7 && buttonB) || (currprefs.pandora_custom_X==-7 && buttonX) || (currprefs.pandora_custom_Y==-7 && buttonY) || (currprefs.pandora_custom_L==-7 && triggerL) || (currprefs.pandora_custom_R==-7 && triggerR))
left = 1;
else if(currprefs.pandora_custom_dpad == 2)
{
if((currprefs.pandora_custom_up==-7 && dpadUp) || (currprefs.pandora_custom_down==-7 && dpadDown) || (currprefs.pandora_custom_left==-7 && dpadLeft) || (currprefs.pandora_custom_right==-7 && dpadRight))
left = 1;
}
if((currprefs.pandora_custom_A==-8 && buttonA) || (currprefs.pandora_custom_B==-8 && buttonB) || (currprefs.pandora_custom_X==-8 && buttonX) || (currprefs.pandora_custom_Y==-8 && buttonY) || (currprefs.pandora_custom_L==-8 && triggerL) || (currprefs.pandora_custom_R==-8 && triggerR))
right = 1;
else if(currprefs.pandora_custom_dpad == 2)
{
if((currprefs.pandora_custom_up==-8 && dpadUp) || (currprefs.pandora_custom_down==-8 && dpadDown) || (currprefs.pandora_custom_left==-8 && dpadLeft) || (currprefs.pandora_custom_right==-8 && dpadRight))
right = 1;
}
}
if(currprefs.pandora_custom_dpad == 0) // dPad as joystick
{
// Handle autofire (only available if no custom controls active)
if(!currprefs.pandora_customControls &&
(((currprefs.pandora_autofireButton1==GP2X_BUTTON_B && buttonA)
|| (currprefs.pandora_autofireButton1==GP2X_BUTTON_X && buttonX)
|| (currprefs.pandora_autofireButton1==GP2X_BUTTON_Y && buttonY))
&& delay > currprefs.input_autofire_framecnt))
{
if(!buttonB)
*button=1;
delay=0;
*button |= (buttonB & 1) << 1;
}
}
if(currprefs.pandora_customControls)
{
// get joystick button via custom controls
if((currprefs.pandora_custom_A==-3 && buttonA) || (currprefs.pandora_custom_B==-3 && buttonB) || (currprefs.pandora_custom_X==-3 && buttonX) || (currprefs.pandora_custom_Y==-3 && buttonY) || (currprefs.pandora_custom_L==-3 && triggerL) || (currprefs.pandora_custom_R==-3 && triggerR))
*button = 1;
else if(currprefs.pandora_custom_dpad == 2)
{
if((currprefs.pandora_custom_up==-3 && dpadUp) || (currprefs.pandora_custom_down==-3 && dpadDown) || (currprefs.pandora_custom_left==-3 && dpadLeft) || (currprefs.pandora_custom_right==-3 && dpadRight))
*button = 1;
}
if((currprefs.pandora_custom_A==-4 && buttonA) || (currprefs.pandora_custom_B==-4 && buttonB) || (currprefs.pandora_custom_X==-4 && buttonX) || (currprefs.pandora_custom_Y==-4 && buttonY) || (currprefs.pandora_custom_L==-4 && triggerL) || (currprefs.pandora_custom_R==-4 && triggerR))
*button |= 1 << 1;
else if(currprefs.pandora_custom_dpad == 2)
{
if((currprefs.pandora_custom_up==-4 && dpadUp) || (currprefs.pandora_custom_down==-4 && dpadDown) || (currprefs.pandora_custom_left==-4 && dpadLeft) || (currprefs.pandora_custom_right==-4 && dpadRight))
*button |= 1 << 1;
}
delay++;
}
else
{
// get joystick button via ABXY or joystick
*button = ((currprefs.pandora_button1==GP2X_BUTTON_B && buttonA) || (currprefs.pandora_button1==GP2X_BUTTON_X && buttonX) || (currprefs.pandora_button1==GP2X_BUTTON_Y && buttonY) || SDL_JoystickGetButton(joy, currprefs.pandora_button1)) & 1;
delay++;
*button |= ((buttonB || SDL_JoystickGetButton(joy, currprefs.pandora_button2)) & 1) << 1;
}
// normal joystick movement
if (left)
top = !top;
if (right)
bot = !bot;
*dir = bot | (right << 1) | (top << 8) | (left << 9);
if(currprefs.pandora_joyPort != 0)
{
// Only one joystick active
if((nr == 0 && currprefs.pandora_joyPort == 2) || (nr == 1 && currprefs.pandora_joyPort == 1))
{
*dir = 0;
*button = 0;
}
}
}
void handle_joymouse(void)
{
if (currprefs.pandora_custom_dpad == 1)
{
int mouseScale = currprefs.input_joymouse_multiplier / 2;
if (buttonY) // slow mouse active
mouseScale = currprefs.input_joymouse_multiplier / 10;
if (dpadLeft)
{
lastmx -= mouseScale;
newmousecounters=1;
}
if (dpadRight)
{
lastmx += mouseScale;
newmousecounters=1;
}
if (dpadUp)
{
lastmy -= mouseScale;
newmousecounters=1;
}
if (dpadDown)
{
lastmy += mouseScale;
newmousecounters=1;
}
}
}
void init_joystick(void)
{
int i;
nr_joysticks = SDL_NumJoysticks ();
if (nr_joysticks > 0)
uae4all_joy0 = SDL_JoystickOpen (0);
if (nr_joysticks > 1)
uae4all_joy1 = SDL_JoystickOpen (1);
else
uae4all_joy1 = NULL;
}
void close_joystick(void)
{
if (nr_joysticks > 0)
SDL_JoystickClose (uae4all_joy0);
if (nr_joysticks > 1)
SDL_JoystickClose (uae4all_joy1);
}

207
src/od-pandora/keyboard.cpp Normal file
View file

@ -0,0 +1,207 @@
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "options.h"
#include "uae.h"
#include "memory.h"
#include "xwin.h"
#include "custom.h"
#include "drawing.h"
#include "keyboard.h"
#include "keybuf.h"
#include "gui.h"
#include <SDL.h>
/* Decode KeySyms. This function knows about all keys that are common
* between different keyboard languages. */
static int kc_decode (SDL_keysym *prKeySym)
{
#ifdef PANDORA
// Special handling of Pandora keyboard:
// Some keys requires shift on Amiga, so we simulate shift...
switch (prKeySym->sym)
{
case SDLK_COLON:
return SIMULATE_SHIFT | AK_SEMICOLON;
case SDLK_QUESTION:
return SIMULATE_SHIFT | AK_SLASH;
case SDLK_HASH:
return SIMULATE_SHIFT | AK_3;
case SDLK_DOLLAR:
return SIMULATE_SHIFT | AK_4;
case SDLK_QUOTEDBL:
return SIMULATE_SHIFT | AK_QUOTE;
case SDLK_PLUS:
return SIMULATE_SHIFT | AK_EQUAL;
case SDLK_AT:
return SIMULATE_SHIFT | AK_2;
case SDLK_LEFTPAREN:
return SIMULATE_SHIFT | AK_9;
case SDLK_RIGHTPAREN:
return SIMULATE_SHIFT | AK_0;
case SDLK_EXCLAIM:
return SIMULATE_SHIFT | AK_1;
case SDLK_UNDERSCORE:
return SIMULATE_SHIFT | AK_MINUS;
case SDLK_2:
if(prKeySym->mod == KMOD_LSHIFT)
return SIMULATE_SHIFT | AK_LBRACKET;
break;
case SDLK_3:
if(prKeySym->mod == KMOD_LSHIFT)
return SIMULATE_SHIFT | AK_RBRACKET;
break;
case SDLK_4:
if(prKeySym->mod == KMOD_LSHIFT)
return SIMULATE_SHIFT | AK_BACKQUOTE;
break;
case SDLK_9:
if(prKeySym->mod == KMOD_LSHIFT)
return SIMULATE_RELEASED_SHIFT | AK_LBRACKET;
break;
case SDLK_0:
if(prKeySym->mod == KMOD_LSHIFT)
return SIMULATE_RELEASED_SHIFT | AK_RBRACKET;
break;
case 124: // code for '|'
return SIMULATE_SHIFT | AK_BACKSLASH;
}
#endif
switch (prKeySym->sym)
{
case SDLK_b: return AK_B;
case SDLK_c: return AK_C;
case SDLK_d: return AK_D;
case SDLK_e: return AK_E;
case SDLK_f: return AK_F;
case SDLK_g: return AK_G;
case SDLK_h: return AK_H;
case SDLK_i: return AK_I;
case SDLK_j: return AK_J;
case SDLK_k: return AK_K;
case SDLK_l: return AK_L;
case SDLK_n: return AK_N;
case SDLK_o: return AK_O;
case SDLK_p: return AK_P;
case SDLK_r: return AK_R;
case SDLK_s: return AK_S;
case SDLK_t: return AK_T;
case SDLK_u: return AK_U;
case SDLK_v: return AK_V;
case SDLK_x: return AK_X;
case SDLK_0: return AK_0;
case SDLK_1: return AK_1;
case SDLK_2: return AK_2;
case SDLK_3: return AK_3;
case SDLK_4: return AK_4;
case SDLK_5: return AK_5;
case SDLK_6: return AK_6;
case SDLK_7: return AK_7;
case SDLK_8: return AK_8;
case SDLK_9: return AK_9;
case SDLK_KP0: return AK_NP0;
case SDLK_KP1: return AK_NP1;
case SDLK_KP2: return AK_NP2;
case SDLK_KP3: return AK_NP3;
case SDLK_KP4: return AK_NP4;
case SDLK_KP5: return AK_NP5;
case SDLK_KP6: return AK_NP6;
case SDLK_KP7: return AK_NP7;
case SDLK_KP8: return AK_NP8;
case SDLK_KP9: return AK_NP9;
case SDLK_KP_DIVIDE: return AK_NPDIV;
case SDLK_KP_MULTIPLY: return AK_NPMUL;
case SDLK_KP_MINUS: return AK_NPSUB;
case SDLK_KP_PLUS: return AK_NPADD;
case SDLK_KP_PERIOD: return AK_NPDEL;
case SDLK_KP_ENTER: return AK_ENT;
case SDLK_F1: return AK_F1;
case SDLK_F2: return AK_F2;
case SDLK_F3: return AK_F3;
case SDLK_F4: return AK_F4;
case SDLK_F5: return AK_F5;
case SDLK_F6: return AK_F6;
case SDLK_F7: return AK_F7;
case SDLK_F8: return AK_F8;
case SDLK_F9: return AK_F9;
case SDLK_F10: return AK_F10;
case SDLK_BACKSPACE: return AK_BS;
case SDLK_DELETE: return AK_DEL;
case SDLK_LCTRL: return AK_CTRL;
case SDLK_RCTRL: return AK_RCTRL;
case SDLK_TAB: return AK_TAB;
case SDLK_LALT: return AK_LALT;
case SDLK_RALT: return AK_RALT;
case SDLK_RMETA: return AK_RAMI;
case SDLK_LMETA: return AK_LAMI;
case SDLK_RETURN: return AK_RET;
case SDLK_SPACE: return AK_SPC;
case SDLK_LSHIFT: return AK_LSH;
case SDLK_RSHIFT: return AK_RSH;
case SDLK_ESCAPE: return AK_ESC;
case SDLK_INSERT: return AK_HELP;
case SDLK_HOME: return AK_NPLPAREN;
case SDLK_END: return AK_NPRPAREN;
case SDLK_CAPSLOCK: return AK_CAPSLOCK;
case SDLK_UP: return AK_UP;
case SDLK_DOWN: return AK_DN;
case SDLK_LEFT: return AK_LF;
case SDLK_RIGHT: return AK_RT;
case SDLK_PAGEUP: return AK_RAMI; /* PgUp mapped to right amiga */
case SDLK_PAGEDOWN: return AK_LAMI; /* PgDn mapped to left amiga */
default: return -1;
}
}
static int decode_us (SDL_keysym *prKeySym)
{
switch(prKeySym->sym)
{
/* US specific */
case SDLK_a: return AK_A;
case SDLK_m: return AK_M;
case SDLK_q: return AK_Q;
case SDLK_y: return AK_Y;
case SDLK_w: return AK_W;
case SDLK_z: return AK_Z;
case SDLK_LEFTBRACKET: return AK_LBRACKET;
case SDLK_RIGHTBRACKET: return AK_RBRACKET;
case SDLK_COMMA: return AK_COMMA;
case SDLK_PERIOD: return AK_PERIOD;
case SDLK_SLASH: return AK_SLASH;
case SDLK_SEMICOLON: return AK_SEMICOLON;
case SDLK_MINUS: return AK_MINUS;
case SDLK_EQUALS: return AK_EQUAL;
/* this doesn't work: */
case SDLK_BACKQUOTE: return AK_QUOTE;
case SDLK_QUOTE: return AK_BACKQUOTE;
case SDLK_BACKSLASH: return AK_BACKSLASH;
default: return -1;
}
}
int keycode2amiga(SDL_keysym *prKeySym)
{
int iAmigaKeycode = kc_decode(prKeySym);
if (iAmigaKeycode == -1)
return decode_us(prKeySym);
return iAmigaKeycode;
}
int getcapslockstate (void)
{
return 0;
}
void setcapslockstate (int state)
{
}

View file

@ -0,0 +1,679 @@
#define _MENU_CONFIG_CPP
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "autoconf.h"
#include "options.h"
#include "gui.h"
#include "sounddep/sound.h"
#include "custom.h"
#include "osdep/gp2x.h"
#include "cfgfile.h"
#include "uae.h"
#include "disk.h"
#include "../inputmode.h"
static int kickstart;
static int presetModeId = 2;
int saveMenu_n_savestate = 0;
static void SetPresetMode(int mode, struct uae_prefs *p)
{
presetModeId = mode;
switch(mode)
{
case 0:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 768;
break;
case 1:
p->gfx_size.height = 216;
p->gfx_size_fs.width = 716;
break;
case 2:
p->gfx_size.height = 240;
p->gfx_size_fs.width = 640;
break;
case 3:
p->gfx_size.height = 256;
p->gfx_size_fs.width = 600;
break;
case 4:
p->gfx_size.height = 262;
p->gfx_size_fs.width = 588;
break;
case 5:
p->gfx_size.height = 270;
p->gfx_size_fs.width = 570;
break;
case 6:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 640;
break;
case 7:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 800;
break;
case 10:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 768;
break;
case 11:
p->gfx_size.height = 216;
p->gfx_size_fs.width = 716;
break;
case 12:
p->gfx_size.height = 240;
p->gfx_size_fs.width = 640;
break;
case 13:
p->gfx_size.height = 256;
p->gfx_size_fs.width = 600;
break;
case 14:
p->gfx_size.height = 262;
p->gfx_size_fs.width = 588;
break;
case 15:
p->gfx_size.height = 270;
p->gfx_size_fs.width = 570;
break;
case 16:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 640;
break;
case 17:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 800;
break;
case 20:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 800;
break;
case 21:
p->gfx_size.height = 216;
p->gfx_size_fs.width = 784;
break;
case 22:
p->gfx_size.height = 240;
p->gfx_size_fs.width = 704;
break;
case 23:
p->gfx_size.height = 256;
p->gfx_size_fs.width = 660;
break;
case 24:
p->gfx_size.height = 262;
p->gfx_size_fs.width = 640;
break;
case 25:
p->gfx_size.height = 270;
p->gfx_size_fs.width = 624;
break;
case 26:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 704;
break;
case 27:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 800;
break;
case 30:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 800;
break;
case 31:
p->gfx_size.height = 216;
p->gfx_size_fs.width = 784;
break;
case 32:
p->gfx_size.height = 240;
p->gfx_size_fs.width = 704;
break;
case 33:
p->gfx_size.height = 256;
p->gfx_size_fs.width = 660;
break;
case 34:
p->gfx_size.height = 262;
p->gfx_size_fs.width = 640;
break;
case 35:
p->gfx_size.height = 270;
p->gfx_size_fs.width = 624;
break;
case 36:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 704;
break;
case 37:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 800;
break;
case 40:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 800;
break;
case 41:
p->gfx_size.height = 216;
p->gfx_size_fs.width = 800;
break;
case 42:
p->gfx_size.height = 240;
p->gfx_size_fs.width = 768;
break;
case 43:
p->gfx_size.height = 256;
p->gfx_size_fs.width = 720;
break;
case 44:
p->gfx_size.height = 262;
p->gfx_size_fs.width = 704;
break;
case 45:
p->gfx_size.height = 270;
p->gfx_size_fs.width = 684;
break;
case 46:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 800;
break;
case 47:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 800;
break;
case 50:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 800;
break;
case 51:
p->gfx_size.height = 216;
p->gfx_size_fs.width = 800;
break;
case 52:
p->gfx_size.height = 240;
p->gfx_size_fs.width = 768;
break;
case 53:
p->gfx_size.height = 256;
p->gfx_size_fs.width = 720;
break;
case 54:
p->gfx_size.height = 262;
p->gfx_size_fs.width = 704;
break;
case 55:
p->gfx_size.height = 270;
p->gfx_size_fs.width = 684;
break;
case 56:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 800;
break;
case 57:
p->gfx_size.height = 200;
p->gfx_size_fs.width = 800;
break;
default:
p->gfx_size.height = 240;
p->gfx_size_fs.width = 640;
presetModeId = 2;
break;
}
switch(presetModeId / 10)
{
case 0:
p->gfx_size.width = 320;
break;
case 1:
p->gfx_size.width = 640;
break;
case 2:
p->gfx_size.width = 352;
break;
case 3:
p->gfx_size.width = 704;
break;
case 4:
p->gfx_size.width = 384;
break;
case 5:
p->gfx_size.width = 768;
break;
}
}
static void SetDefaultMenuSettings(int general)
{
if(general < 2)
{
while(nr_units(currprefs.mountinfo) > 0)
kill_filesys_unit(currprefs.mountinfo, 0);
}
kickstart = 1;
SetPresetMode(2, &changed_prefs);
}
static void replace(char * str,char replace, char toreplace)
{
while(*str)
{
if (*str==toreplace) *str=replace;
str++;
}
}
int create_configfilename(char *dest, char *basename, int fromDir)
{
char *p;
p = basename + strlen(basename) - 1;
while (*p != '/')
p--;
p++;
if(fromDir == 0)
{
int len = strlen(p) + 1;
char filename[len];
strcpy(filename, p);
char *pch = &filename[len];
while (pch != filename && *pch != '.')
pch--;
if (pch)
{
*pch='\0';
snprintf(dest, 300, "%s/conf/%s.uae", start_path_data, filename);
return 1;
}
}
else
{
snprintf(dest, 300, "%s/conf/%s.uae", start_path_data, p);
return 1;
}
return 0;
}
const char *kickstarts_rom_names[] = { "kick12.rom\0", "kick13.rom\0", "kick20.rom\0", "kick31.rom\0", "aros-amiga-m68k-rom.bin\0" };
const char *extended_rom_names[] = { "\0", "\0", "\0", "\0", "aros-amiga-m68k-ext.bin\0" };
const char *kickstarts_names[] = { "KS ROM v1.2\0", "KS ROM v1.3\0", "KS ROM v2.05\0", "KS ROM v3.1\0", "\0" };
#ifdef ANDROIDSDL
const char *af_kickstarts_rom_names[] = { "amiga-os-120.rom\0", "amiga-os-130.rom\0", "amiga-os-204.rom\0", "amiga-os-310-a1200.rom\0" };
#endif
static bool CheckKickstart(void)
{
char kickpath[MAX_DPATH];
int i;
// Search via filename
fetch_rompath(kickpath, MAX_DPATH);
strncat(kickpath, kickstarts_rom_names[kickstart], MAX_DPATH);
for(i=0; i<lstAvailableROMs.size(); ++i)
{
if(!strcasecmp(lstAvailableROMs[i]->Path, kickpath))
{
// Found it
strncpy(changed_prefs.romfile, kickpath, sizeof(changed_prefs.romfile));
return true;
}
}
// Search via name
if(strlen(kickstarts_names[kickstart]) > 0)
{
for(i=0; i<lstAvailableROMs.size(); ++i)
{
if(!strncasecmp(lstAvailableROMs[i]->Name, kickstarts_names[kickstart], strlen(kickstarts_names[kickstart])))
{
// Found it
strncpy(changed_prefs.romfile, lstAvailableROMs[i]->Path, sizeof(changed_prefs.romfile));
return true;
}
}
}
return false;
}
// In this procedure, we use changed_prefs
int loadconfig_old(const char *orgpath, int general)
{
char path[MAX_PATH];
strcpy(path, orgpath);
char *ptr = strstr(path, ".uae");
if(ptr > 0)
{
*(ptr + 1) = '\0';
strcat(path, "conf");
}
FILE *f=fopen(path,"rt");
if (!f){
write_log ("No config file %s!\n",path);
return 0;
}
else
{
// Set everthing to default and clear HD settings
SetDefaultMenuSettings(general);
char filebuffer[256];
int dummy;
fscanf(f,"kickstart=%d\n",&kickstart);
#if defined(PANDORA) || defined(ANDROIDSDL)
fscanf(f,"scaling=%d\n",&dummy);
#else
fscanf(f,"scaling=%d\n",&mainMenu_enableHWscaling);
#endif
fscanf(f,"showstatus=%d\n", &changed_prefs.leds_on_screen);
fscanf(f,"mousemultiplier=%d\n", &changed_prefs.input_joymouse_multiplier);
changed_prefs.input_joymouse_multiplier *= 10;
#if defined(PANDORA) || defined(ANDROIDSDL)
fscanf(f,"systemclock=%d\n",&dummy); // mainMenu_throttle never changes -> removed
fscanf(f,"syncthreshold=%d\n", &dummy); // timeslice_mode never changes -> removed
#else
fscanf(f,"systemclock=%d\n",&mainMenu_throttle);
fscanf(f,"syncthreshold=%d\n", &timeslice_mode);
#endif
fscanf(f,"frameskip=%d\n", &changed_prefs.gfx_framerate);
fscanf(f,"sound=%d\n",&changed_prefs.produce_sound );
if(changed_prefs.produce_sound >= 10)
{
changed_prefs.sound_stereo = 1;
changed_prefs.produce_sound -= 10;
if(changed_prefs.produce_sound > 0)
changed_prefs.produce_sound += 1;
}
else
changed_prefs.sound_stereo = 0;
fscanf(f,"soundrate=%d\n",&changed_prefs.sound_freq);
fscanf(f,"autosave=%d\n", &dummy);
fscanf(f,"gp2xclock=%d\n", &dummy);
int joybuffer = 0;
fscanf(f,"joyconf=%d\n",&joybuffer);
changed_prefs.pandora_joyConf = (joybuffer & 0x0f);
changed_prefs.pandora_joyPort = ((joybuffer >> 4) & 0x0f);
fscanf(f,"autofireRate=%d\n",&changed_prefs.input_autofire_framecnt);
fscanf(f,"autofire=%d\n", &dummy);
fscanf(f,"stylusOffset=%d\n",&changed_prefs.pandora_stylusOffset);
fscanf(f,"tapDelay=%d\n",&changed_prefs.pandora_tapDelay);
fscanf(f,"scanlines=%d\n", &dummy);
#if defined(PANDORA) || defined(ANDROIDSDL)
fscanf(f,"ham=%d\n",&dummy);
#else
fscanf(f,"ham=%d\n",&mainMenu_ham);
#endif
fscanf(f,"enableScreenshots=%d\n", &dummy);
fscanf(f,"floppyspeed=%d\n",&changed_prefs.floppy_speed);
fscanf(f,"drives=%d\n", &changed_prefs.nr_floppies);
fscanf(f,"videomode=%d\n", &changed_prefs.ntscmode);
if(changed_prefs.ntscmode)
changed_prefs.chipset_refreshrate = 60;
else
changed_prefs.chipset_refreshrate = 50;
fscanf(f,"mainMenu_cpuSpeed=%d\n",&changed_prefs.pandora_cpu_speed);
fscanf(f,"presetModeId=%d\n",&presetModeId);
fscanf(f,"moveX=%d\n", &changed_prefs.pandora_horizontal_offset);
fscanf(f,"moveY=%d\n", &changed_prefs.pandora_vertical_offset);
fscanf(f,"displayedLines=%d\n",&changed_prefs.gfx_size.height);
fscanf(f,"screenWidth=%d\n", &changed_prefs.gfx_size_fs.width);
fscanf(f,"cutLeft=%d\n", &dummy);
fscanf(f,"cutRight=%d\n", &dummy);
fscanf(f,"customControls=%d\n",&changed_prefs.pandora_customControls);
fscanf(f,"custom_dpad=%d\n",&changed_prefs.pandora_custom_dpad);
fscanf(f,"custom_up=%d\n",&changed_prefs.pandora_custom_up);
fscanf(f,"custom_down=%d\n",&changed_prefs.pandora_custom_down);
fscanf(f,"custom_left=%d\n",&changed_prefs.pandora_custom_left);
fscanf(f,"custom_right=%d\n",&changed_prefs.pandora_custom_right);
fscanf(f,"custom_A=%d\n",&changed_prefs.pandora_custom_A);
fscanf(f,"custom_B=%d\n",&changed_prefs.pandora_custom_B);
fscanf(f,"custom_X=%d\n",&changed_prefs.pandora_custom_X);
fscanf(f,"custom_Y=%d\n",&changed_prefs.pandora_custom_Y);
fscanf(f,"custom_L=%d\n",&changed_prefs.pandora_custom_L);
fscanf(f,"custom_R=%d\n",&changed_prefs.pandora_custom_R);
fscanf(f,"cpu=%d\n", &changed_prefs.cpu_level);
if(changed_prefs.cpu_level > M68000)
// Was old format
changed_prefs.cpu_level = M68020;
fscanf(f,"chipset=%d\n", &changed_prefs.chipset_mask);
changed_prefs.immediate_blits = (changed_prefs.chipset_mask & 0x100) == 0x100;
changed_prefs.pandora_partial_blits = (changed_prefs.chipset_mask & 0x200) == 0x200;
switch (changed_prefs.chipset_mask & 0xff)
{
case 1: changed_prefs.chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE; break;
case 2: changed_prefs.chipset_mask = CSMASK_ECS_AGNUS | CSMASK_ECS_DENISE | CSMASK_AGA; break;
default: changed_prefs.chipset_mask = CSMASK_ECS_AGNUS; break;
}
fscanf(f,"cpu=%d\n", &changed_prefs.m68k_speed);
if(changed_prefs.m68k_speed < 0)
{
// New version of this option
changed_prefs.m68k_speed = -changed_prefs.m68k_speed;
}
else
{
// Old version (500 5T 1200 12T 12T2)
if(changed_prefs.m68k_speed >= 2)
{
// 1200: set to 68020 with 14 MHz
changed_prefs.cpu_level = M68020;
changed_prefs.m68k_speed--;
if(changed_prefs.m68k_speed > 2)
changed_prefs.m68k_speed = 2;
}
}
if(changed_prefs.m68k_speed == 1)
changed_prefs.m68k_speed = M68K_SPEED_14MHZ_CYCLES;
if(changed_prefs.m68k_speed == 2)
changed_prefs.m68k_speed = M68K_SPEED_25MHZ_CYCLES;
changed_prefs.cachesize = 0;
changed_prefs.cpu_compatible = 0;
if(general == 0)
{
disk_eject(0);
disk_eject(1);
disk_eject(2);
disk_eject(3);
fscanf(f,"df0=%s\n",&filebuffer);
replace(filebuffer,' ','|');
strcpy(changed_prefs.df[0], filebuffer);
disk_insert(0, filebuffer);
if(changed_prefs.nr_floppies > 1)
{
memset(filebuffer, 0, 256);
fscanf(f,"df1=%s\n",&filebuffer);
replace(filebuffer,' ','|');
strcpy(changed_prefs.df[1], filebuffer);
disk_insert(1, filebuffer);
}
if(changed_prefs.nr_floppies > 2)
{
memset(filebuffer, 0, 256);
fscanf(f,"df2=%s\n",&filebuffer);
replace(filebuffer,' ','|');
strcpy(changed_prefs.df[2], filebuffer);
disk_insert(2, filebuffer);
}
if(changed_prefs.nr_floppies > 3)
{
memset(filebuffer, 0, 256);
fscanf(f,"df3=%s\n",&filebuffer);
replace(filebuffer,' ','|');
strcpy(changed_prefs.df[3], filebuffer);
disk_insert(3, filebuffer);
}
}
else
{
fscanf(f,"script=%d\n", &dummy);
fscanf(f,"screenshot=%d\n", &dummy);
fread(filebuffer, 1, 4, f);
fseek(f, -4, SEEK_CUR);
filebuffer[4] = '\0';
if(strcmp(filebuffer, "skip") == 0)
fscanf(f,"skipintro=%d\n", &dummy);
fscanf(f,"boot_hd=%d\n", &dummy);
fscanf(f,"hard_disk_dir=", filebuffer);
filebuffer[0] = '\0';
{
char c[2] = {0, 0};
*c = fgetc(f);
while (*c && (*c != '\n')) {
strcat(filebuffer, c);
*c = fgetc(f);
}
}
if (filebuffer[0] == '*')
filebuffer[0] = '\0';
if(filebuffer[0] != '\0')
parse_filesys_spec(0, filebuffer);
fscanf(f,"hard_disk_file=", filebuffer);
filebuffer[0] = '\0';
{
char c[2] = {0, 0};
*c = fgetc(f);
while (*c && (*c != '\n')) {
strcat(filebuffer, c);
*c = fgetc(f);
}
}
if (filebuffer[0] == '*')
filebuffer[0] = '\0';
if(filebuffer[0] != '\0')
parse_hardfile_spec(filebuffer);
}
currprefs.nr_floppies = changed_prefs.nr_floppies;
for(int i=0; i<4; ++i)
{
if(i < changed_prefs.nr_floppies)
changed_prefs.dfxtype[i] = DRV_35_DD;
else
changed_prefs.dfxtype[i] = DRV_NONE;
}
fscanf(f,"chipmemory=%d\n",&changed_prefs.chipmem_size);
if(changed_prefs.chipmem_size < 10)
// Was saved in old format
changed_prefs.chipmem_size = 0x80000 << changed_prefs.chipmem_size;
fscanf(f,"slowmemory=%d\n",&changed_prefs.bogomem_size);
if(changed_prefs.bogomem_size > 0 && changed_prefs.bogomem_size < 10)
// Was saved in old format
changed_prefs.bogomem_size =
(changed_prefs.bogomem_size <= 2) ? 0x080000 << changed_prefs.bogomem_size :
(changed_prefs.bogomem_size == 3) ? 0x180000 : 0x1c0000;
fscanf(f,"fastmemory=%d\n",&changed_prefs.fastmem_size);
if(changed_prefs.fastmem_size > 0 && changed_prefs.fastmem_size < 10)
// Was saved in old format
changed_prefs.fastmem_size = 0x080000 << changed_prefs.fastmem_size;
#ifdef ANDROIDSDL
fscanf(f,"onscreen=%d\n",&mainMenu_onScreen);
fscanf(f,"onScreen_textinput=%d\n",&mainMenu_onScreen_textinput);
fscanf(f,"onScreen_dpad=%d\n",&mainMenu_onScreen_dpad);
fscanf(f,"onScreen_button1=%d\n",&mainMenu_onScreen_button1);
fscanf(f,"onScreen_button2=%d\n",&mainMenu_onScreen_button2);
fscanf(f,"onScreen_button3=%d\n",&mainMenu_onScreen_button3);
fscanf(f,"onScreen_button4=%d\n",&mainMenu_onScreen_button4);
fscanf(f,"onScreen_button5=%d\n",&mainMenu_onScreen_button5);
fscanf(f,"onScreen_button6=%d\n",&mainMenu_onScreen_button6);
fscanf(f,"custom_position=%d\n",&mainMenu_custom_position);
fscanf(f,"pos_x_textinput=%d\n",&mainMenu_pos_x_textinput);
fscanf(f,"pos_y_textinput=%d\n",&mainMenu_pos_y_textinput);
fscanf(f,"pos_x_dpad=%d\n",&mainMenu_pos_x_dpad);
fscanf(f,"pos_y_dpad=%d\n",&mainMenu_pos_y_dpad);
fscanf(f,"pos_x_button1=%d\n",&mainMenu_pos_x_button1);
fscanf(f,"pos_y_button1=%d\n",&mainMenu_pos_y_button1);
fscanf(f,"pos_x_button2=%d\n",&mainMenu_pos_x_button2);
fscanf(f,"pos_y_button2=%d\n",&mainMenu_pos_y_button2);
fscanf(f,"pos_x_button3=%d\n",&mainMenu_pos_x_button3);
fscanf(f,"pos_y_button3=%d\n",&mainMenu_pos_y_button3);
fscanf(f,"pos_x_button4=%d\n",&mainMenu_pos_x_button4);
fscanf(f,"pos_y_button4=%d\n",&mainMenu_pos_y_button4);
fscanf(f,"pos_x_button5=%d\n",&mainMenu_pos_x_button5);
fscanf(f,"pos_y_button5=%d\n",&mainMenu_pos_y_button5);
fscanf(f,"pos_x_button6=%d\n",&mainMenu_pos_x_button6);
fscanf(f,"pos_y_button6=%d\n",&mainMenu_pos_y_button6);
fscanf(f,"quick_switch=%d\n",&mainMenu_quickSwitch);
fscanf(f,"FloatingJoystick=%d\n",&mainMenu_FloatingJoystick);
#endif
fclose(f);
}
SetPresetMode(presetModeId, &changed_prefs);
CheckKickstart();
set_joyConf();
return 1;
}

View file

@ -0,0 +1,749 @@
@ Some functions and tests to increase performance in drawing.cpp and custom.cpp
.arm
.global TRACE_Start
.global TRACE_mem
.global ARM_doline_n1
.global NEON_doline_n2
.global NEON_doline_n3
.global NEON_doline_n4
.global NEON_doline_n6
.global NEON_doline_n8
.text
.align 8
TRACE_Start:
stmdb sp!, {r0, r1}
stmdb sp!, {r1}
ldr r1, =TRACE_mem
str r0, [r1]
add r1, r1, #4
ldmia sp!, {r0}
str r0, [r1]
add r1, r1, #4
str r2, [r1]
add r1, r1, #4
str r3, [r1]
add r1, r1, #4
str r4, [r1]
add r1, r1, #4
str r5, [r1]
add r1, r1, #4
str r6, [r1]
add r1, r1, #4
str r7, [r1]
add r1, r1, #4
str r8, [r1]
add r1, r1, #4
str r9, [r1]
add r1, r1, #4
str r10, [r1]
add r1, r1, #4
str r11, [r1]
add r1, r1, #4
str r12, [r1]
add r1, r1, #4
str r13, [r1]
add r1, r1, #4
str r14, [r1]
add r1, r1, #4
str r15, [r1]
ldmia sp!, {r0, r1}
bx lr
@----------------------------------------------------------------
@ ARM_doline_n1
@
@ r0: uae_u32 *pixels
@ r1: int wordcount
@ r2: int lineno
@
@ void ARM_doline_n1(uae_u32 *pixels, int wordcount, int lineno);
@
@----------------------------------------------------------------
ARM_doline_n1:
stmdb sp!, {r4-r9, lr}
mov r3, #1600
mul r2, r2, r3
ldr r3, =line_data
add r3, r3, r2 @ real_bplpt[0]
ldr r4, =Lookup_doline_n1
sub r3, r3, #4
ARM_doline_n1_loop:
ldr r2, [r3, #4]!
@ add r3, r3, #4
ubfx r5, r2, #28, #4
add r5, r4, r5, lsl #2
ldr r6, [r5]
ubfx r5, r2, #24, #4
add r5, r4, r5, lsl #2
ldr r7, [r5]
ubfx r5, r2, #20, #4
add r5, r4, r5, lsl #2
ldr r8, [r5]
ubfx r5, r2, #16, #4
add r5, r4, r5, lsl #2
ldr r9, [r5]
stmia r0!, {r6-r9}
ubfx r5, r2, #12, #4
add r5, r4, r5, lsl #2
ldr r6, [r5]
ubfx r5, r2, #8, #4
add r5, r4, r5, lsl #2
ldr r7, [r5]
ubfx r5, r2, #4, #4
add r5, r4, r5, lsl #2
ldr r8, [r5]
ubfx r5, r2, #0, #4
add r5, r4, r5, lsl #2
ldr r9, [r5]
stmia r0!, {r6-r9}
subs r1, r1, #1
bgt ARM_doline_n1_loop
ldmia sp!, {r4-r9, pc}
.align 8
@----------------------------------------------------------------
@ NEON_doline_n2
@
@ r0: uae_u32 *pixels
@ r1: int wordcount
@ r2: int lineno
@
@ void NEON_doline_n2(uae_u32 *pixels, int wordcount, int lineno);
@
@----------------------------------------------------------------
NEON_doline_n2:
mov r3, #1600
mul r2, r2, r3
ldr r3, =line_data
add r2, r3, r2 @ real_bplpt[0]
add r3, r2, #200
@ Load masks to registers
vmov.u8 d18, #0x55
vmov.u8 d19, #0x33
vmov.u8 d20, #0x0f
NEON_doline_n2_loop:
@ Load data as early as possible
vldmia r2!, {d4}
vldmia r3!, {d6}
@ MERGE (b6, b7, 0x55555555, 1);
vshr.u8 d16, d4, #1 @ tmpb = b >> shift
vshl.u8 d17, d6, #1 @ tmpa = a << shift
vbit.u8 d6, d16, d18 @ a = a and bit set from tmpb if mask is true
vbif.u8 d4, d17, d18 @ b = b and bit set from tmpa if mask is false
@ MERGE_0(b4, b6, 0x33333333, 2);
vshr.u8 d16, d6, #2 @ tmp = b >> shift
vand.8 d2, d16, d19 @ a = tmp & mask
vand.8 d6, d6, d19 @ b = b & mask
@ MERGE_0(b5, b7, 0x33333333, 2);
vshr.u8 d16, d4, #2 @ tmp = b >> shift
vand.8 d0, d16, d19 @ a = tmp & mask
vand.8 d4, d4, d19 @ b = b & mask
@ MERGE_0(b0, b4, 0x0f0f0f0f, 4);
vshr.u8 d16, d2, #4 @ tmp = b >> shift
vand.8 d3, d16, d20 @ a = tmp & mask
vand.8 d2, d2, d20 @ b = b & mask
@ MERGE_0(b1, b5, 0x0f0f0f0f, 4);
vshr.u8 d16, d0, #4 @ tmp = b >> shift
vand.8 d1, d16, d20 @ a = tmp & mask
vand.8 d0, d0, d20 @ b = b & mask
@ MERGE_0(b2, b6, 0x0f0f0f0f, 4);
vshr.u8 d16, d6, #4 @ tmp = b >> shift
vand.8 d7, d16, d20 @ a = tmp & mask
vand.8 d6, d6, d20 @ b = b & mask
@ MERGE_0(b3, b7, 0x0f0f0f0f, 4);
vshr.u8 d16, d4, #4 @ tmp = b >> shift
vand.8 d5, d16, d20 @ a = tmp & mask
vand.8 d4, d4, d20 @ b = b & mask
vzip.8 d3, d7
vzip.8 d1, d5
vzip.8 d2, d6
vzip.8 d0, d4
vzip.8 d3, d1
vzip.8 d2, d0
vzip.32 d3, d2
vzip.32 d1, d0
vst1.8 {d0, d1, d2, d3}, [r0]!
cmp r1, #1 @ Exit from here if odd number of words
bxeq lr
subs r1, r1, #2 @ We handle 2 words (64 bit) per loop: wordcount -= 2
vzip.8 d7, d5
vzip.8 d6, d4
vzip.32 d7, d6
vzip.32 d5, d4
vst1.8 {d4, d5, d6, d7}, [r0]!
bgt NEON_doline_n2_loop
NEON_doline_n2_exit:
bx lr
.align 8
@----------------------------------------------------------------
@ NEON_doline_n3
@
@ r0: uae_u32 *pixels
@ r1: int wordcount
@ r2: int lineno
@
@ void NEON_doline_n3(uae_u32 *pixels, int wordcount, int lineno);
@
@----------------------------------------------------------------
NEON_doline_n3:
stmdb sp!, {r4, lr}
mov r3, #1600
mul r2, r2, r3
ldr r3, =line_data
add r2, r3, r2 @ real_bplpt[0]
add r3, r2, #200
add r4, r3, #200
@ Load data as early as possible
vldmia r4!, {d0}
@ Load masks to registers
vmov.u8 d18, #0x55
vmov.u8 d19, #0x33
vmov.u8 d20, #0x0f
NEON_doline_n3_loop:
@ Load from real_bplpt (now loaded earlier)
@ vld1.8 d0, [r4]!
@ vld1.8 d4, [r2]!
@ vld1.8 d6, [r3]!
@ Load data as early as possible
vldmia r2!, {d4}
vldmia r3!, {d6}
@ MERGE_0(b4, b5, 0x55555555, 1);
vshr.u8 d16, d0, #1 @ tmp = b >> shift
vand.8 d2, d16, d18 @ a = tmp & mask
vand.8 d0, d0, d18 @ b = b & mask
@ MERGE (b6, b7, 0x55555555, 1);
vshr.u8 d16, d4, #1 @ tmpb = b >> shift
vshl.u8 d17, d6, #1 @ tmpa = a << shift
vbit.u8 d6, d16, d18 @ a = a and bit set from tmpb if mask is true
vbif.u8 d4, d17, d18 @ b = b and bit set from tmpa if mask is false
@ MERGE (b4, b6, 0x33333333, 2);
vshr.u8 d16, d6, #2 @ tmpb = b >> shift
vshl.u8 d17, d2, #2 @ tmpa = a << shift
vbit.u8 d2, d16, d19 @ a = a and bit set from tmpb if mask is true
vbif.u8 d6, d17, d19 @ b = b and bit set from tmpa if mask is false
@ MERGE (b5, b7, 0x33333333, 2);
vshr.u8 d16, d4, #2 @ tmpb = b >> shift
vshl.u8 d17, d0, #2 @ tmpa = a << shift
vbit.u8 d0, d16, d19 @ a = a and bit set from tmpb if mask is true
vbif.u8 d4, d17, d19 @ b = b and bit set from tmpa if mask is false
@ MERGE_0(b0, b4, 0x0f0f0f0f, 4);
vshr.u8 d16, d2, #4 @ tmp = b >> shift
vand.8 d3, d16, d20 @ a = tmp & mask
vand.8 d2, d2, d20 @ b = b & mask
@ MERGE_0(b1, b5, 0x0f0f0f0f, 4);
vshr.u8 d16, d0, #4 @ tmp = b >> shift
vand.8 d1, d16, d20 @ a = tmp & mask
vand.8 d0, d0, d20 @ b = b & mask
@ MERGE_0(b2, b6, 0x0f0f0f0f, 4);
vshr.u8 d16, d6, #4 @ tmp = b >> shift
vand.8 d7, d16, d20 @ a = tmp & mask
vand.8 d6, d6, d20 @ b = b & mask
@ MERGE_0(b3, b7, 0x0f0f0f0f, 4);
vshr.u8 d16, d4, #4 @ tmp = b >> shift
vand.8 d5, d16, d20 @ a = tmp & mask
vand.8 d4, d4, d20 @ b = b & mask
vzip.8 d3, d7
vzip.8 d1, d5
vzip.8 d2, d6
vzip.8 d0, d4
vzip.8 d3, d1
vzip.8 d2, d0
vzip.32 d3, d2
vzip.32 d1, d0
vst1.8 {d0, d1, d2, d3}, [r0]!
cmp r1, #1 @ Exit from here if odd number of words
ldmeqia sp!, {r4, pc}
subs r1, r1, #2 @ We handle 2 words (64 bit) per loop: wordcount -= 2
@ Load next data (if needed) as early as possible
vldmiagt r4!, {d0}
vzip.8 d7, d5
vzip.8 d6, d4
vzip.32 d7, d6
vzip.32 d5, d4
vst1.8 {d4, d5, d6, d7}, [r0]!
bgt NEON_doline_n3_loop
NEON_doline_n3_exit:
ldmia sp!, {r4, pc}
.align 8
@----------------------------------------------------------------
@ NEON_doline_n4
@
@ r0: uae_u32 *pixels
@ r1: int wordcount
@ r2: int lineno
@
@ void NEON_doline_n4(uae_u32 *pixels, int wordcount, int lineno);
@
@----------------------------------------------------------------
NEON_doline_n4:
stmdb sp!, {r4-r5, lr}
mov r3, #1600
mul r2, r2, r3
ldr r3, =line_data
add r2, r3, r2 @ real_bplpt[0]
add r3, r2, #200
add r4, r3, #200
add r5, r4, #200
@ Load data as early as possible
vldmia r4!, {d0}
vldmia r5!, {d2}
@ Load masks to registers
vmov.u8 d18, #0x55
vmov.u8 d19, #0x33
vmov.u8 d20, #0x0f
NEON_doline_n4_loop:
@ Load from real_bplpt (now loaded earlier)
@ vld1.8 d0, [r4]!
@ vld1.8 d2, [r5]!
@ vld1.8 d4, [r2]!
@ vld1.8 d6, [r3]!
@ Load data as early as possible
vldmia r2!, {d4}
@ MERGE (b4, b5, 0x55555555, 1);
vshr.u8 d16, d0, #1 @ tmpb = b >> shift
vshl.u8 d17, d2, #1 @ tmpa = a << shift
vldmia r3!, {d6}
vbit.u8 d2, d16, d18 @ a = a and bit set from tmpb if mask is true
vbif.u8 d0, d17, d18 @ b = b and bit set from tmpa if mask is false
@ MERGE (b6, b7, 0x55555555, 1);
vshr.u8 d16, d4, #1 @ tmpb = b >> shift
vshl.u8 d17, d6, #1 @ tmpa = a << shift
vbit.u8 d6, d16, d18 @ a = a and bit set from tmpb if mask is true
vbif.u8 d4, d17, d18 @ b = b and bit set from tmpa if mask is false
@ MERGE (b4, b6, 0x33333333, 2);
vshr.u8 d16, d6, #2 @ tmpb = b >> shift
vshl.u8 d17, d2, #2 @ tmpa = a << shift
vbit.u8 d2, d16, d19 @ a = a and bit set from tmpb if mask is true
vbif.u8 d6, d17, d19 @ b = b and bit set from tmpa if mask is false
@ MERGE (b5, b7, 0x33333333, 2);
vshr.u8 d16, d4, #2 @ tmpb = b >> shift
vshl.u8 d17, d0, #2 @ tmpa = a << shift
vbit.u8 d0, d16, d19 @ a = a and bit set from tmpb if mask is true
vbif.u8 d4, d17, d19 @ b = b and bit set from tmpa if mask is false
@ MERGE_0(b0, b4, 0x0f0f0f0f, 4);
vshr.u8 d16, d2, #4 @ tmp = b >> shift
vand.8 d3, d16, d20 @ a = tmp & mask
vand.8 d2, d2, d20 @ b = b & mask
@ MERGE_0(b1, b5, 0x0f0f0f0f, 4);
vshr.u8 d16, d0, #4 @ tmp = b >> shift
vand.8 d1, d16, d20 @ a = tmp & mask
vand.8 d0, d0, d20 @ b = b & mask
@ MERGE_0(b2, b6, 0x0f0f0f0f, 4);
vshr.u8 d16, d6, #4 @ tmp = b >> shift
vand.8 d7, d16, d20 @ a = tmp & mask
vand.8 d6, d6, d20 @ b = b & mask
@ MERGE_0(b3, b7, 0x0f0f0f0f, 4);
vshr.u8 d16, d4, #4 @ tmp = b >> shift
vand.8 d5, d16, d20 @ a = tmp & mask
vand.8 d4, d4, d20 @ b = b & mask
vzip.8 d3, d7
vzip.8 d1, d5
vzip.8 d2, d6
vzip.8 d0, d4
vzip.8 d3, d1
vzip.8 d2, d0
vzip.32 d3, d2
vzip.32 d1, d0
vst1.8 {d0, d1, d2, d3}, [r0]!
cmp r1, #1 @ Exit from here if odd number of words
ldmeqia sp!, {r4-r5, pc}
subs r1, r1, #2 @ We handle 2 words (64 bit) per loop: wordcount -= 2
@ Load next data (if needed) as early as possible
vldmiagt r4!, {d0}
vzip.8 d7, d5
vzip.8 d6, d4
vldmiagt r5!, {d2}
vzip.32 d7, d6
vzip.32 d5, d4
vst1.8 {d4, d5, d6, d7}, [r0]!
bgt NEON_doline_n4_loop
NEON_doline_n4_exit:
ldmia sp!, {r4-r5, pc}
.align 8
@----------------------------------------------------------------
@ NEON_doline_n6
@
@ r0: uae_u32 *pixels
@ r1: int wordcount
@ r2: int lineno
@
@ void NEON_doline_n6(uae_u32 *pixels, int wordcount, int lineno);
@
@----------------------------------------------------------------
NEON_doline_n6:
stmdb sp!, {r4-r7, lr}
mov r3, #1600
mul r2, r2, r3
ldr r3, =line_data
add r2, r3, r2 @ real_bplpt[0]
add r3, r2, #200
add r4, r3, #200
add r5, r4, #200
add r6, r5, #200
add r7, r6, #200
@ Load masks to registers
vmov.u8 d18, #0x55
vmov.u8 d19, #0x33
vmov.u8 d20, #0x0f
NEON_doline_n6_loop:
@ Load data as early as possible
vldmia r6!, {d5}
vldmia r7!, {d7}
@ Load data as early as possible
vldmia r4!, {d0}
@ MERGE (b2, b3, 0x55555555, 1);
vshr.u8 d16, d5, #1 @ tmpb = b >> shift
vshl.u8 d17, d7, #1 @ tmpa = a << shift
@ Load data as early as possible
vldmia r5!, {d2}
vbit.u8 d7, d16, d18 @ a = a and bit set from tmpb if mask is true
vbif.u8 d5, d17, d18 @ b = b and bit set from tmpa if mask is false
@ Load data as early as possible
vldmia r2!, {d4}
@ MERGE (b4, b5, 0x55555555, 1);
vshr.u8 d16, d0, #1 @ tmpb = b >> shift
vshl.u8 d17, d2, #1 @ tmpa = a << shift
@ Load data as early as possible
vldmia r3!, {d6}
vbit.u8 d2, d16, d18 @ a = a and bit set from tmpb if mask is true
vbif.u8 d0, d17, d18 @ b = b and bit set from tmpa if mask is false
@ MERGE (b6, b7, 0x55555555, 1);
vshr.u8 d16, d4, #1 @ tmpb = b >> shift
vshl.u8 d17, d6, #1 @ tmpa = a << shift
vbit.u8 d6, d16, d18 @ a = a and bit set from tmpb if mask is true
vbif.u8 d4, d17, d18 @ b = b and bit set from tmpa if mask is false
@ MERGE_0(b0, b2, 0x33333333, 2);
vshr.u8 d16, d7, #2 @ tmp = b >> shift
vand.8 d3, d16, d19 @ a = tmp & mask
vand.8 d7, d7, d19 @ b = b & mask
@ MERGE_0(b1, b3, 0x33333333, 2);
vshr.u8 d16, d5, #2 @ tmp = b >> shift
vand.8 d1, d16, d19 @ a = tmp & mask
vand.8 d5, d5, d19 @ b = b & mask
@ MERGE (b4, b6, 0x33333333, 2);
vshr.u8 d16, d6, #2 @ tmpb = b >> shift
vshl.u8 d17, d2, #2 @ tmpa = a << shift
vbit.u8 d2, d16, d19 @ a = a and bit set from tmpb if mask is true
vbif.u8 d6, d17, d19 @ b = b and bit set from tmpa if mask is false
@ MERGE (b5, b7, 0x33333333, 2);
vshr.u8 d16, d4, #2 @ tmpb = b >> shift
vshl.u8 d17, d0, #2 @ tmpa = a << shift
vbit.u8 d0, d16, d19 @ a = a and bit set from tmpb if mask is true
vbif.u8 d4, d17, d19 @ b = b and bit set from tmpa if mask is false
@ MERGE (b0, b4, 0x0f0f0f0f, 4);
vshr.u8 d16, d2, #4 @ tmpb = b >> shift
vshl.u8 d17, d3, #4 @ tmpa = a << shift
vbit.u8 d3, d16, d20 @ a = a and bit set from tmpb if mask is true
vbif.u8 d2, d17, d20 @ b = b and bit set from tmpa if mask is false
@ MERGE (b1, b5, 0x0f0f0f0f, 4);
vshr.u8 d16, d0, #4 @ tmpb = b >> shift
vshl.u8 d17, d1, #4 @ tmpa = a << shift
vbit.u8 d1, d16, d20 @ a = a and bit set from tmpb if mask is true
vbif.u8 d0, d17, d20 @ b = b and bit set from tmpa if mask is false
@ MERGE (b2, b6, 0x0f0f0f0f, 4);
vshr.u8 d16, d6, #4 @ tmpb = b >> shift
vshl.u8 d17, d7, #4 @ tmpa = a << shift
vbit.u8 d7, d16, d20 @ a = a and bit set from tmpb if mask is true
vbif.u8 d6, d17, d20 @ b = b and bit set from tmpa if mask is false
@ MERGE (b3, b7, 0x0f0f0f0f, 4);
vshr.u8 d16, d4, #4 @ tmpb = b >> shift
vshl.u8 d17, d5, #4 @ tmpa = a << shift
vbit.u8 d5, d16, d20 @ a = a and bit set from tmpb if mask is true
vbif.u8 d4, d17, d20 @ b = b and bit set from tmpa if mask is false
vzip.8 d3, d7
vzip.8 d1, d5
vzip.8 d2, d6
vzip.8 d0, d4
vzip.8 d3, d1
vzip.8 d2, d0
vzip.32 d3, d2
vzip.32 d1, d0
vst1.8 {d0, d1, d2, d3}, [r0]!
cmp r1, #1 @ Exit from here if odd number of words
ldmeqia sp!, {r4-r7, pc}
subs r1, r1, #2 @ We handle 2 words (64 bit) per loop: wordcount -= 2
vzip.8 d7, d5
vzip.8 d6, d4
vzip.32 d7, d6
vzip.32 d5, d4
vst1.8 {d4, d5, d6, d7}, [r0]!
bgt NEON_doline_n6_loop
NEON_doline_n6_exit:
ldmia sp!, {r4-r7, pc}
.align 8
@----------------------------------------------------------------
@ NEON_doline_n8
@
@ r0: uae_u32 *pixels
@ r1: int wordcount
@ r2: int lineno
@
@ void NEON_doline_n8(uae_u32 *pixels, int wordcount, int lineno);
@
@----------------------------------------------------------------
NEON_doline_n8:
stmdb sp!, {r4-r9, lr}
mov r3, #1600
mul r2, r2, r3
ldr r3, =line_data
add r2, r3, r2 @ real_bplpt[0]
add r3, r2, #200
add r4, r3, #200
add r5, r4, #200
add r6, r5, #200
add r7, r6, #200
add r8, r7, #200
add r9, r8, #200
@ Load data as early as possible
vldmia r8!, {d1}
vldmia r9!, {d3}
@ Load masks to registers
vmov.u8 d18, #0x55
vmov.u8 d19, #0x33
vmov.u8 d20, #0x0f
NEON_doline_n8_loop:
@ Load data as early as possible
vldmia r6!, {d5}
@ MERGE (b0, b1, 0x55555555, 1);
vshr.u8 d16, d1, #1 @ tmpb = b >> shift
vshl.u8 d17, d3, #1 @ tmpa = a << shift
@ Load data as early as possible
vldmia r7!, {d7}
vbit.u8 d3, d16, d18 @ a = a and bit set from tmpb if mask is true
vbif.u8 d1, d17, d18 @ b = b and bit set from tmpa if mask is false
@ Load data as early as possible
vldmia r4!, {d0}
@ MERGE (b2, b3, 0x55555555, 1);
vshr.u8 d16, d5, #1 @ tmpb = b >> shift
vshl.u8 d17, d7, #1 @ tmpa = a << shift
@ Load data as early as possible
vldmia r5!, {d2}
vbit.u8 d7, d16, d18 @ a = a and bit set from tmpb if mask is true
vbif.u8 d5, d17, d18 @ b = b and bit set from tmpa if mask is false
@ Load data as early as possible
vldmia r2!, {d4}
@ MERGE (b4, b5, 0x55555555, 1);
vshr.u8 d16, d0, #1 @ tmpb = b >> shift
vshl.u8 d17, d2, #1 @ tmpa = a << shift
@ Load data as early as possible
vldmia r3!, {d6}
vbit.u8 d2, d16, d18 @ a = a and bit set from tmpb if mask is true
vbif.u8 d0, d17, d18 @ b = b and bit set from tmpa if mask is false
@ MERGE (b6, b7, 0x55555555, 1);
vshr.u8 d16, d4, #1 @ tmpb = b >> shift
vshl.u8 d17, d6, #1 @ tmpa = a << shift
vbit.u8 d6, d16, d18 @ a = a and bit set from tmpb if mask is true
vbif.u8 d4, d17, d18 @ b = b and bit set from tmpa if mask is false
@ MERGE (b0, b2, 0x33333333, 2);
vshr.u8 d16, d7, #2 @ tmpb = b >> shift
vshl.u8 d17, d3, #2 @ tmpa = a << shift
vbit.u8 d3, d16, d19 @ a = a and bit set from tmpb if mask is true
vbif.u8 d7, d17, d19 @ b = b and bit set from tmpa if mask is false
@ MERGE (b1, b3, 0x33333333, 2);
vshr.u8 d16, d5, #2 @ tmpb = b >> shift
vshl.u8 d17, d1, #2 @ tmpa = a << shift
vbit.u8 d1, d16, d19 @ a = a and bit set from tmpb if mask is true
vbif.u8 d5, d17, d19 @ b = b and bit set from tmpa if mask is false
@ MERGE (b4, b6, 0x33333333, 2);
vshr.u8 d16, d6, #2 @ tmpb = b >> shift
vshl.u8 d17, d2, #2 @ tmpa = a << shift
vbit.u8 d2, d16, d19 @ a = a and bit set from tmpb if mask is true
vbif.u8 d6, d17, d19 @ b = b and bit set from tmpa if mask is false
@ MERGE (b5, b7, 0x33333333, 2);
vshr.u8 d16, d4, #2 @ tmpb = b >> shift
vshl.u8 d17, d0, #2 @ tmpa = a << shift
vbit.u8 d0, d16, d19 @ a = a and bit set from tmpb if mask is true
vbif.u8 d4, d17, d19 @ b = b and bit set from tmpa if mask is false
@ MERGE (b0, b4, 0x0f0f0f0f, 4);
vshr.u8 d16, d2, #4 @ tmpb = b >> shift
vshl.u8 d17, d3, #4 @ tmpa = a << shift
vbit.u8 d3, d16, d20 @ a = a and bit set from tmpb if mask is true
vbif.u8 d2, d17, d20 @ b = b and bit set from tmpa if mask is false
@ MERGE (b1, b5, 0x0f0f0f0f, 4);
vshr.u8 d16, d0, #4 @ tmpb = b >> shift
vshl.u8 d17, d1, #4 @ tmpa = a << shift
vbit.u8 d1, d16, d20 @ a = a and bit set from tmpb if mask is true
vbif.u8 d0, d17, d20 @ b = b and bit set from tmpa if mask is false
@ MERGE (b2, b6, 0x0f0f0f0f, 4);
vshr.u8 d16, d6, #4 @ tmpb = b >> shift
vshl.u8 d17, d7, #4 @ tmpa = a << shift
vbit.u8 d7, d16, d20 @ a = a and bit set from tmpb if mask is true
vbif.u8 d6, d17, d20 @ b = b and bit set from tmpa if mask is false
@ MERGE (b3, b7, 0x0f0f0f0f, 4);
vshr.u8 d16, d4, #4 @ tmpb = b >> shift
vshl.u8 d17, d5, #4 @ tmpa = a << shift
vbit.u8 d5, d16, d20 @ a = a and bit set from tmpb if mask is true
vbif.u8 d4, d17, d20 @ b = b and bit set from tmpa if mask is false
vzip.8 d3, d7
vzip.8 d1, d5
vzip.8 d2, d6
vzip.8 d0, d4
vzip.8 d3, d1
vzip.8 d2, d0
vzip.32 d3, d2
vzip.32 d1, d0
vst1.8 {d0, d1, d2, d3}, [r0]!
cmp r1, #1 @ Exit from here if odd number of words
ldmeqia sp!, {r4-r9, pc}
subs r1, r1, #2 @ We handle 2 words (64 bit) per loop: wordcount -= 2
@ Load data as early as possible
vldmiagt r8!, {d1}
vzip.8 d7, d5
vzip.8 d6, d4
@ Load data as early as possible
vldmiagt r9!, {d3}
vzip.32 d7, d6
vzip.32 d5, d4
vst1.8 {d4, d5, d6, d7}, [r0]!
bgt NEON_doline_n8_loop
NEON_doline_n8_exit:
ldmia sp!, {r4-r9, pc}
.data
.align 8
Lookup_doline_n1:
.long 0x00000000, 0x01000000, 0x00010000, 0x01010000
.long 0x00000100, 0x01000100, 0x00010100, 0x01010100
.long 0x00000001, 0x01000001, 0x00010001, 0x01010001
.long 0x00000101, 0x01000101, 0x00010101, 0x01010101
TRACE_mem:
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000
.long 0x00000000, 0x00000000, 0x00000000, 0x00000000

842
src/od-pandora/pandora.cpp Normal file
View file

@ -0,0 +1,842 @@
/*
* UAE - The Un*x Amiga Emulator
*
* Pandora interface
*
*/
#include <algorithm>
#include <iostream>
#include <vector>
#include <stdlib.h>
#include <stdarg.h>
#include <asm/sigcontext.h>
#include <signal.h>
#include <dlfcn.h>
#include <execinfo.h>
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "autoconf.h"
#include "uae.h"
#include "options.h"
#include "gui.h"
#include "events.h"
#include "memory.h"
#include "custom.h"
#include "xwin.h"
#include "drawing.h"
#include "inputdevice.h"
#include "keybuf.h"
#include "keyboard.h"
#include "joystick.h"
#include "disk.h"
#include "savestate.h"
#include <SDL.h>
#include "gp2x.h"
extern void signal_segv(int signum, siginfo_t* info, void*ptr);
extern int doStylusRightClick;
extern int mouseMoving;
extern int justClicked;
extern int fcounter;
extern int keycode2amiga(SDL_keysym *prKeySym);
extern int loadconfig_old(const char *orgpath, int general);
/* Keyboard and mouse */
/* Keyboard */
int uae4all_keystate[256];
#ifdef PANDORA
static int shiftWasPressed = 0;
#endif
char start_path_data[MAX_DPATH];
char currentDir[MAX_DPATH];
int show_inputmode = 0;
int sleep_resolution = 1000 / 1;
static char config_path[MAX_DPATH];
static char rom_path[MAX_DPATH];
char last_loaded_config[MAX_DPATH] = { '\0' };
static bool slow_mouse = false;
static bool cpuSpeedChanged = false;
static int lastCpuSpeed = 600;
extern "C" int main( int argc, char *argv[] );
void sleep_millis (int ms)
{
usleep(ms * 1000);
}
void sleep_millis_busy (int ms)
{
usleep(ms * 1000);
}
void logging_init( void )
{
#ifdef WITH_LOGGING
static int started;
static int first;
char debugfilename[MAX_DPATH];
if (first > 1) {
write_log ("***** RESTART *****\n");
return;
}
if (first == 1) {
if (debugfile)
fclose (debugfile);
debugfile = 0;
}
sprintf(debugfilename, "%s/uae4all_log.txt", start_path_data);
if(!debugfile)
debugfile = fopen(debugfilename, "wt");
first++;
write_log ( "UAE4ALL Logfile\n\n");
#endif
}
void logging_cleanup( void )
{
#ifdef WITH_LOGGING
if(debugfile)
fclose(debugfile);
debugfile = 0;
#endif
}
void target_default_options (struct uae_prefs *p, int type)
{
memcpy(&changed_prefs, &currprefs, sizeof(struct uae_prefs));
p->pandora_horizontal_offset = 0;
p->pandora_vertical_offset = 0;
p->pandora_cpu_speed = 600;
p->pandora_partial_blits = 0;
p->pandora_joyConf = 0;
p->pandora_joyPort = 0;
p->pandora_tapDelay = 10;
p->pandora_stylusOffset = 0;
p->pandora_customControls = 0;
p->pandora_custom_dpad = 0;
p->pandora_custom_up = 0;
p->pandora_custom_down = 0;
p->pandora_custom_left = 0;
p->pandora_custom_right = 0;
p->pandora_custom_A = 0;
p->pandora_custom_B = 0;
p->pandora_custom_X = 0;
p->pandora_custom_Y = 0;
p->pandora_custom_L = 0;
p->pandora_custom_R = 0;
p->pandora_button1 = GP2X_BUTTON_X;
p->pandora_button2 = GP2X_BUTTON_A;
p->pandora_autofireButton1 = GP2X_BUTTON_B;
p->pandora_jump = -1;
}
void target_save_options (struct zfile *f, struct uae_prefs *p)
{
cfgfile_write (f, "pandora.blitter_in_partial_mode=%d\n", p->pandora_partial_blits);
cfgfile_write (f, "pandora.cpu_speed=%d\n", p->pandora_cpu_speed);
cfgfile_write (f, "pandora.joy_conf=%d\n", p->pandora_joyConf);
cfgfile_write (f, "pandora.joy_port=%d\n", p->pandora_joyPort);
cfgfile_write (f, "pandora.stylus_offset=%d\n", p->pandora_stylusOffset);
cfgfile_write (f, "pandora.tap_delay=%d\n", p->pandora_tapDelay);
cfgfile_write (f, "pandora.custom_controls=%d\n", p->pandora_customControls);
cfgfile_write (f, "pandora.custom_dpad=%d\n", p->pandora_custom_dpad);
cfgfile_write (f, "pandora.custom_up=%d\n", p->pandora_custom_up);
cfgfile_write (f, "pandora.custom_down=%d\n", p->pandora_custom_down);
cfgfile_write (f, "pandora.custom_left=%d\n", p->pandora_custom_left);
cfgfile_write (f, "pandora.custom_right=%d\n", p->pandora_custom_right);
cfgfile_write (f, "pandora.custom_a=%d\n", p->pandora_custom_A);
cfgfile_write (f, "pandora.custom_b=%d\n", p->pandora_custom_B);
cfgfile_write (f, "pandora.custom_x=%d\n", p->pandora_custom_X);
cfgfile_write (f, "pandora.custom_y=%d\n", p->pandora_custom_Y);
cfgfile_write (f, "pandora.custom_l=%d\n", p->pandora_custom_L);
cfgfile_write (f, "pandora.custom_r=%d\n", p->pandora_custom_R);
cfgfile_write (f, "pandora.move_x=%d\n", p->pandora_horizontal_offset);
cfgfile_write (f, "pandora.move_y=%d\n", p->pandora_vertical_offset);
cfgfile_write (f, "pandora.button1=%d\n", p->pandora_button1);
cfgfile_write (f, "pandora.button2=%d\n", p->pandora_button2);
cfgfile_write (f, "pandora.autofire_button=%d\n", p->pandora_autofireButton1);
cfgfile_write (f, "pandora.jump=%d\n", p->pandora_jump);
}
int target_parse_option (struct uae_prefs *p, char *option, char *value)
{
int result = (cfgfile_intval (option, value, "blitter_in_partial_mode", &p->pandora_partial_blits, 1)
|| cfgfile_intval (option, value, "cpu_speed", &p->pandora_cpu_speed, 1)
|| cfgfile_intval (option, value, "joy_conf", &p->pandora_joyConf, 1)
|| cfgfile_intval (option, value, "joy_port", &p->pandora_joyPort, 1)
|| cfgfile_intval (option, value, "stylus_offset", &p->pandora_stylusOffset, 1)
|| cfgfile_intval (option, value, "tap_delay", &p->pandora_tapDelay, 1)
|| cfgfile_intval (option, value, "custom_controls", &p->pandora_customControls, 1)
|| cfgfile_intval (option, value, "custom_dpad", &p->pandora_custom_dpad, 1)
|| cfgfile_intval (option, value, "custom_up", &p->pandora_custom_up, 1)
|| cfgfile_intval (option, value, "custom_down", &p->pandora_custom_down, 1)
|| cfgfile_intval (option, value, "custom_left", &p->pandora_custom_left, 1)
|| cfgfile_intval (option, value, "custom_right", &p->pandora_custom_right, 1)
|| cfgfile_intval (option, value, "custom_a", &p->pandora_custom_A, 1)
|| cfgfile_intval (option, value, "custom_b", &p->pandora_custom_B, 1)
|| cfgfile_intval (option, value, "custom_x", &p->pandora_custom_X, 1)
|| cfgfile_intval (option, value, "custom_y", &p->pandora_custom_Y, 1)
|| cfgfile_intval (option, value, "custom_l", &p->pandora_custom_L, 1)
|| cfgfile_intval (option, value, "custom_r", &p->pandora_custom_R, 1)
|| cfgfile_intval (option, value, "move_x", &p->pandora_horizontal_offset, 1)
|| cfgfile_intval (option, value, "move_y", &p->pandora_vertical_offset, 1)
|| cfgfile_intval (option, value, "button1", &p->pandora_button1, 1)
|| cfgfile_intval (option, value, "button2", &p->pandora_button2, 1)
|| cfgfile_intval (option, value, "autofire_button", &p->pandora_autofireButton1, 1)
|| cfgfile_intval (option, value, "jump", &p->pandora_jump, 1)
);
}
void fetch_configurationpath (char *out, int size)
{
strncpy(out, config_path, size);
}
void set_configurationpath(char *newpath)
{
strncpy(config_path, newpath, MAX_DPATH);
}
void fetch_rompath (char *out, int size)
{
strncpy(out, rom_path, size);
}
void set_rompath(char *newpath)
{
strncpy(rom_path, newpath, MAX_DPATH);
}
void fetch_savestatepath(char *out, int size)
{
strncpy(out, start_path_data, size);
strncat(out, "/savestates/", size);
}
void fetch_screenshotpath(char *out, int size)
{
strncpy(out, start_path_data, size);
strncat(out, "/screenshots/", size);
}
int my_cfgfile_load (struct uae_prefs *p, const char *filename, int general)
{
int result = 0;
while(nr_units(currprefs.mountinfo) > 0)
kill_filesys_unit(currprefs.mountinfo, 0);
char *ptr = strstr(filename, ".uae");
if(ptr > 0)
{
int type = CONFIG_TYPE_HARDWARE | CONFIG_TYPE_HOST;
result = cfgfile_load(p, filename, &type, 0);
}
if(result)
{
set_joyConf();
extractFileName(filename, last_loaded_config);
}
else if (general >= 0)
result = loadconfig_old(filename, general);
if(result)
{
for(int i=0; i < p->nr_floppies; ++i)
{
if(strncmp(currprefs.df[i], p->df[i], 256))
{
if(strlen(p->df[i]) > 0)
disk_insert(i, p->df[i]);
else
disk_eject(i);
}
if(strlen(p->df[i]) > 0)
AddFileToDiskList(p->df[i], 1);
}
inputdevice_updateconfig (p);
}
return result;
}
int check_configfile(char *file)
{
char tmp[MAX_PATH];
FILE *f = fopen(file, "rt");
if(f)
{
fclose(f);
return 1;
}
strcpy(tmp, file);
char *ptr = strstr(tmp, ".uae");
if(ptr > 0)
{
*(ptr + 1) = '\0';
strcat(tmp, "conf");
f = fopen(tmp, "rt");
if(f)
{
fclose(f);
return 2;
}
}
return 0;
}
void extractFileName(const char * str,char *buffer)
{
const char *p=str+strlen(str)-1;
while(*p != '/' && p > str)
p--;
p++;
strcpy(buffer,p);
}
void extractPath(char *str, char *buffer)
{
strcpy(buffer, str);
char *p = buffer + strlen(buffer) - 1;
while(*p != '/' && p > buffer)
p--;
p[1] = '\0';
}
void removeFileExtension(char *filename)
{
char *p = filename + strlen(filename) - 1;
while(p > filename && *p != '.')
{
*p = '\0';
--p;
}
*p = '\0';
}
void ReadDirectory(const char *path, std::vector<std::string> *dirs, std::vector<std::string> *files)
{
DIR *dir;
struct dirent *dent;
if(dirs != NULL)
dirs->clear();
if(files != NULL)
files->clear();
dir = opendir(path);
if(dir != NULL)
{
while((dent = readdir(dir)) != NULL)
{
if(dent->d_type == DT_DIR)
{
if(dirs != NULL)
dirs->push_back(dent->d_name);
}
else if (files != NULL)
files->push_back(dent->d_name);
}
if(dirs != NULL && dirs->size() > 0 && (*dirs)[0] == ".")
dirs->erase(dirs->begin());
closedir(dir);
}
if(dirs != NULL)
std::sort(dirs->begin(), dirs->end());
if(files != NULL)
std::sort(files->begin(), files->end());
}
void saveAdfDir(void)
{
char path[MAX_DPATH];
int i;
snprintf(path, MAX_DPATH, "%s/conf/adfdir.conf", start_path_data);
FILE *f=fopen(path,"w");
if (!f)
return;
char buffer[MAX_DPATH];
snprintf(buffer, MAX_DPATH, "path=%s\n", currentDir);
fputs(buffer,f);
snprintf(buffer, MAX_DPATH, "config_path=%s\n", config_path);
fputs(buffer, f);
snprintf(buffer, MAX_DPATH, "rom_path=%s\n", rom_path);
fputs(buffer, f);
snprintf(buffer, MAX_DPATH, "ROMs=%d\n", lstAvailableROMs.size());
fputs(buffer, f);
for(i=0; i<lstAvailableROMs.size(); ++i)
{
snprintf(buffer, MAX_DPATH, "ROMName=%s\n", lstAvailableROMs[i]->Name);
fputs(buffer, f);
snprintf(buffer, MAX_DPATH, "ROMPath=%s\n", lstAvailableROMs[i]->Path);
fputs(buffer, f);
snprintf(buffer, MAX_DPATH, "ROMType=%d\n", lstAvailableROMs[i]->ROMType);
fputs(buffer, f);
}
snprintf(buffer, MAX_DPATH, "MRUDiskList=%d\n", lstMRUDiskList.size());
fputs(buffer, f);
for(i=0; i<lstMRUDiskList.size(); ++i)
{
snprintf(buffer, MAX_DPATH, "Diskfile=%s\n", lstMRUDiskList[i].c_str());
fputs(buffer, f);
}
fclose(f);
return;
}
void get_string(FILE *f, char *dst, int size)
{
char buffer[MAX_PATH];
fgets(buffer, MAX_PATH, f);
int i = strlen (buffer);
while (i > 0 && (buffer[i - 1] == '\t' || buffer[i - 1] == ' '
|| buffer[i - 1] == '\r' || buffer[i - 1] == '\n'))
buffer[--i] = '\0';
strncpy(dst, buffer, size);
}
void loadAdfDir(void)
{
char path[MAX_DPATH];
int i;
strcpy(currentDir, start_path_data);
snprintf(config_path, MAX_DPATH, "%s/conf/", start_path_data);
snprintf(rom_path, MAX_DPATH, "%s/kickstarts/", start_path_data);
snprintf(path, MAX_DPATH, "%s/conf/adfdir.conf", start_path_data);
FILE *f1=fopen(path,"rt");
if(f1)
{
fscanf(f1, "path=");
get_string(f1, currentDir, sizeof(currentDir));
if(!feof(f1))
{
fscanf(f1, "config_path=");
get_string(f1, config_path, sizeof(config_path));
fscanf(f1, "rom_path=");
get_string(f1, rom_path, sizeof(rom_path));
int numROMs;
fscanf(f1, "ROMs=%d\n", &numROMs);
for(i=0; i<numROMs; ++i)
{
AvailableROM *tmp;
tmp = new AvailableROM();
fscanf(f1, "ROMName=");
get_string(f1, tmp->Name, sizeof(tmp->Name));
fscanf(f1, "ROMPath=");
get_string(f1, tmp->Path, sizeof(tmp->Path));
fscanf(f1, "ROMType=%d\n", &(tmp->ROMType));
lstAvailableROMs.push_back(tmp);
}
lstMRUDiskList.clear();
int numDisks = 0;
char disk[MAX_PATH];
fscanf(f1, "MRUDiskList=%d\n", &numDisks);
for(i=0; i<numDisks; ++i)
{
fscanf(f1, "Diskfile=");
get_string(f1, disk, sizeof(disk));
lstMRUDiskList.push_back(disk);
}
}
fclose(f1);
}
}
void setCpuSpeed()
{
char speedCmd[128];
currprefs.pandora_cpu_speed = changed_prefs.pandora_cpu_speed;
if(currprefs.pandora_cpu_speed != lastCpuSpeed)
{
snprintf((char*)speedCmd, 128, "unset DISPLAY; echo y | sudo -n /usr/pandora/scripts/op_cpuspeed.sh %d", currprefs.pandora_cpu_speed);
system(speedCmd);
lastCpuSpeed = currprefs.pandora_cpu_speed;
cpuSpeedChanged = true;
}
if(changed_prefs.ntscmode != currprefs.ntscmode)
{
if(changed_prefs.ntscmode)
system("sudo /usr/pandora/scripts/op_lcdrate.sh 60");
else
system("sudo /usr/pandora/scripts/op_lcdrate.sh 50");
}
}
void resetCpuSpeed(void)
{
if(cpuSpeedChanged)
{
FILE* f = fopen ("/etc/pandora/conf/cpu.conf", "rt");
if(f)
{
char line[128];
for(int i=0; i<6; ++i)
{
fscanf(f, "%s\n", &line);
if(strncmp(line, "default:", 8) == 0)
{
int value = 0;
sscanf(line, "default:%d", &value);
if(value > 500 && value < 1200)
{
lastCpuSpeed = value - 10;
currprefs.pandora_cpu_speed = changed_prefs.pandora_cpu_speed = value;
setCpuSpeed();
printf("CPU speed reset to %d\n", value);
}
}
}
fclose(f);
}
}
}
int main (int argc, char *argv[])
{
struct sigaction action;
// Get startup path
getcwd(start_path_data, MAX_DPATH);
loadAdfDir();
snprintf(savestate_fname, MAX_PATH, "%s/saves/default.ads", start_path_data);
logging_init ();
memset(&action, 0, sizeof(action));
action.sa_sigaction = signal_segv;
action.sa_flags = SA_SIGINFO;
if(sigaction(SIGSEGV, &action, NULL) < 0)
{
printf("Failed to set signal handler (SIGSEGV).\n");
abort();
}
if(sigaction(SIGILL, &action, NULL) < 0)
{
printf("Failed to set signal handler (SIGILL).\n");
abort();
}
alloc_AmigaMem();
real_main (argc, argv);
free_AmigaMem();
logging_cleanup();
return 0;
}
int needmousehack (void)
{
return 1;
}
int mousehack_allowed (void)
{
return 1;
}
void keyboard_init(void)
{
int i;
for (i = 256; i--;)
uae4all_keystate[i] = 0;
shiftWasPressed = 0;
}
void handle_events (void)
{
SDL_Event rEvent;
int iAmigaKeyCode;
int i, j;
int iIsHotKey = 0;
/* Handle GUI events */
gui_handle_events ();
handle_joymouse();
while (SDL_PollEvent(&rEvent))
{
switch (rEvent.type)
{
case SDL_QUIT:
uae_quit();
break;
case SDL_KEYDOWN:
if(rEvent.key.keysym.sym==SDLK_PAGEUP)
slow_mouse=true;
if(currprefs.pandora_custom_dpad == 1) // dPad as mouse, why these emulation of key presses?
{
if(rEvent.key.keysym.sym==SDLK_RSHIFT)
{
uae4all_keystate[AK_LALT] = 1;
record_key(AK_LALT << 1);
}
if(rEvent.key.keysym.sym==SDLK_RCTRL || rEvent.key.keysym.sym==SDLK_END || rEvent.key.keysym.sym==SDLK_HOME)
{
uae4all_keystate[AK_RALT] = 1;
record_key(AK_RALT << 1);
}
if(rEvent.key.keysym.sym==SDLK_PAGEDOWN)
{
uae4all_keystate[AK_DN] = 1;
record_key(AK_DN << 1);
}
}
if (rEvent.key.keysym.sym==SDLK_LALT)
{
// state moves thus:
// joystick mode (with virt keyboard on L and R)
// mouse mode (with mouse buttons on L and R)
// remapping mode (with whatever's been supplied)
// back to start of state
currprefs.pandora_custom_dpad++;
if(currprefs.pandora_custom_dpad > 2)
currprefs.pandora_custom_dpad = 0;
changed_prefs.pandora_custom_dpad = currprefs.pandora_custom_dpad;
if(currprefs.pandora_custom_dpad == 2)
mousehack_set(mousehack_follow);
else
mousehack_set (mousehack_dontcare);
show_inputmode = 1;
}
if (rEvent.key.keysym.sym==SDLK_RSHIFT || rEvent.key.keysym.sym==SDLK_RCTRL)
doStylusRightClick = 1;
if (rEvent.key.keysym.sym!=SDLK_UP && rEvent.key.keysym.sym!=SDLK_DOWN && rEvent.key.keysym.sym!=SDLK_LEFT &&
rEvent.key.keysym.sym!=SDLK_RIGHT && rEvent.key.keysym.sym!=SDLK_PAGEUP && rEvent.key.keysym.sym!=SDLK_PAGEDOWN &&
rEvent.key.keysym.sym!=SDLK_HOME && rEvent.key.keysym.sym!=SDLK_END && rEvent.key.keysym.sym!=SDLK_LALT &&
rEvent.key.keysym.sym!=SDLK_LCTRL && rEvent.key.keysym.sym!=SDLK_RSHIFT && rEvent.key.keysym.sym!=SDLK_RCTRL)
{
iAmigaKeyCode = keycode2amiga(&(rEvent.key.keysym));
if (iAmigaKeyCode >= 0)
{
#ifdef PANDORA
if(iAmigaKeyCode & SIMULATE_SHIFT)
{
// We need to simulate shift
iAmigaKeyCode = iAmigaKeyCode & 0x1ff;
shiftWasPressed = uae4all_keystate[AK_LSH];
if(!shiftWasPressed)
{
uae4all_keystate[AK_LSH] = 1;
record_key(AK_LSH << 1);
}
}
if(iAmigaKeyCode & SIMULATE_RELEASED_SHIFT)
{
// We need to simulate released shift
iAmigaKeyCode = iAmigaKeyCode & 0x1ff;
shiftWasPressed = uae4all_keystate[AK_LSH];
if(shiftWasPressed)
{
uae4all_keystate[AK_LSH] = 0;
record_key((AK_LSH << 1) | 1);
}
}
#endif
if (!uae4all_keystate[iAmigaKeyCode])
{
uae4all_keystate[iAmigaKeyCode] = 1;
record_key(iAmigaKeyCode << 1);
}
}
}
break;
case SDL_KEYUP:
if(rEvent.key.keysym.sym==SDLK_PAGEUP)
slow_mouse = false;
if(currprefs.pandora_custom_dpad == 1) // dPad as mouse, why these emulation of key presses?
{
if(rEvent.key.keysym.sym==SDLK_RSHIFT)
{
uae4all_keystate[AK_LALT] = 0;
record_key((AK_LALT << 1) | 1);
}
if(rEvent.key.keysym.sym==SDLK_RCTRL || rEvent.key.keysym.sym==SDLK_END || rEvent.key.keysym.sym==SDLK_HOME)
{
uae4all_keystate[AK_RALT] = 0;
record_key((AK_RALT << 1) | 1);
}
if(rEvent.key.keysym.sym==SDLK_PAGEDOWN)
{
uae4all_keystate[AK_DN] = 0;
record_key((AK_DN << 1) | 1);
}
}
if (rEvent.key.keysym.sym==SDLK_RSHIFT || rEvent.key.keysym.sym==SDLK_RCTRL)
{
doStylusRightClick = 0;
mouseMoving = 0;
justClicked = 0;
fcounter = 0;
buttonstate[2] = 0;
}
if (rEvent.key.keysym.sym==SDLK_LALT)
{
show_inputmode = 0;
}
if (rEvent.key.keysym.sym!=SDLK_UP && rEvent.key.keysym.sym!=SDLK_DOWN && rEvent.key.keysym.sym!=SDLK_LEFT &&
rEvent.key.keysym.sym!=SDLK_RIGHT && rEvent.key.keysym.sym!=SDLK_PAGEUP && rEvent.key.keysym.sym!=SDLK_PAGEDOWN &&
rEvent.key.keysym.sym!=SDLK_HOME && rEvent.key.keysym.sym!=SDLK_END && rEvent.key.keysym.sym!=SDLK_LALT &&
rEvent.key.keysym.sym!=SDLK_LCTRL && rEvent.key.keysym.sym!=SDLK_RSHIFT && rEvent.key.keysym.sym!=SDLK_RCTRL)
{
iAmigaKeyCode = keycode2amiga(&(rEvent.key.keysym));
if (iAmigaKeyCode >= 0)
{
#ifdef PANDORA
if(iAmigaKeyCode & SIMULATE_SHIFT)
{
// We needed to simulate shift
iAmigaKeyCode = iAmigaKeyCode & 0x1ff;
if(!shiftWasPressed)
{
uae4all_keystate[AK_LSH] = 0;
record_key((AK_LSH << 1) | 1);
shiftWasPressed = 0;
}
}
if(iAmigaKeyCode & SIMULATE_RELEASED_SHIFT)
{
// We needed to simulate released shift
iAmigaKeyCode = iAmigaKeyCode & 0x1ff;
if(shiftWasPressed)
{
uae4all_keystate[AK_LSH] = 1;
record_key(AK_LSH << 1);
shiftWasPressed = 0;
}
}
#endif
uae4all_keystate[iAmigaKeyCode] = 0;
record_key((iAmigaKeyCode << 1) | 1);
}
}
break;
case SDL_MOUSEBUTTONDOWN:
if (currprefs.pandora_custom_dpad < 2)
buttonstate[(rEvent.button.button-1)%3] = 1;
break;
case SDL_MOUSEBUTTONUP:
if (currprefs.pandora_custom_dpad < 2)
buttonstate[(rEvent.button.button-1)%3] = 0;
break;
case SDL_MOUSEMOTION:
if(currprefs.pandora_custom_dpad == 2)
{
lastmx = rEvent.motion.x*2 - currprefs.pandora_stylusOffset + stylusAdjustX >> 1;
lastmy = rEvent.motion.y*2 - currprefs.pandora_stylusOffset + stylusAdjustY >> 1;
//mouseMoving = 1;
}
else if(slow_mouse)
{
lastmx += rEvent.motion.xrel;
lastmy += rEvent.motion.yrel;
if(rEvent.motion.x == 0)
lastmx -= 2;
if(rEvent.motion.y == 0)
lastmy -= 2;
if(rEvent.motion.x == currprefs.gfx_size.width - 1)
lastmx += 2;
if(rEvent.motion.y == currprefs.gfx_size.height - 1)
lastmy += 2;
}
else
{
int mouseScale = currprefs.input_joymouse_multiplier / 2;
lastmx += rEvent.motion.xrel * mouseScale;
lastmy += rEvent.motion.yrel * mouseScale;
if(rEvent.motion.x == 0)
lastmx -= mouseScale * 4;
if(rEvent.motion.y == 0)
lastmy -= mouseScale * 4;
if(rEvent.motion.x == currprefs.gfx_size.width - 1)
lastmx += mouseScale * 4;
if(rEvent.motion.y == currprefs.gfx_size.height - 1)
lastmy += mouseScale * 4;
}
newmousecounters = 1;
break;
}
}
}
void uae_set_thread_priority (int pri)
{
}

View file

@ -0,0 +1,126 @@
#include <sys/timeb.h>
#include <fcntl.h>
#include <unistd.h>
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "zfile.h"
void filesys_init( void )
{
}
int my_existsfile (const char *name)
{
struct stat st;
if (lstat (name, &st) == -1) {
return 0;
} else {
if (!S_ISDIR(st.st_mode))
return 1;
}
return 0;
}
int my_existsdir(const char *name)
{
struct stat st;
if(lstat(name, &st) == -1) {
return 0;
} else {
if (S_ISDIR(st.st_mode))
return 1;
}
return 0;
}
void *my_opendir (const char* name)
{
return opendir(name);
}
void my_closedir (void* dir)
{
closedir((DIR *) dir);
}
int my_readdir (void* dir, char* name)
{
struct dirent *de;
if (!dir)
return 0;
de = readdir((DIR *) dir);
if(de == 0)
return 0;
strncpy(name, de->d_name, MAX_PATH);
return 1;
}
int my_rmdir (const char*name)
{
return rmdir(name);
}
int my_mkdir (const char*name)
{
return mkdir(name, 0777);
}
int my_unlink (const char* name)
{
return unlink(name);
}
int my_rename (const char* oldname, const char* newname)
{
return rename(oldname, newname);
}
void *my_open (const char* name, int flags)
{
return (void *) open(name, flags);
}
void my_close (void* f)
{
close((int) f);
}
unsigned int my_lseek (void* f, unsigned int offset, int pos)
{
return lseek((int) f, offset, pos);
}
unsigned int my_read (void* f, void* b, unsigned int len)
{
return read((int) f, b, len);
}
unsigned int my_write (void* f, void* b, unsigned int len)
{
return write((int) f, b, len);
}
int my_truncate (const char *name, long int len)
{
return truncate(name, len);
}

View file

@ -0,0 +1,465 @@
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "uae.h"
#include "options.h"
#include "gui.h"
#include "xwin.h"
#include "custom.h"
#include "drawing.h"
#include "events.h"
#include "osdep/inputmode.h"
#include "savestate.h"
#include <png.h>
#include <SDL.h>
#include <SDL_image.h>
#include <SDL_gfxPrimitives.h>
#ifdef ANDROIDSDL
#include <android/log.h>
#endif
extern int stylusClickOverride;
/* SDL variable for output of emulation and menu */
SDL_Surface *prSDLScreen = NULL;
uae_u16 *prSDLScreenPixels;
static SDL_Surface *current_screenshot = NULL;
static int curr_layer_width = 0;
static char screenshot_filename_default[255]={
'/', 't', 'm', 'p', '/', 'n', 'u', 'l', 'l', '.', 'p', 'n', 'g', '\0'
};
char *screenshot_filename=(char *)&screenshot_filename_default[0];
FILE *screenshot_file=NULL;
static void CreateScreenshot(void);
static int save_thumb(char *path);
int delay_savestate_frame = 0;
#define VIDEO_FLAGS_INIT SDL_SWSURFACE|SDL_FULLSCREEN
#ifdef ANDROIDSDL
#define VIDEO_FLAGS VIDEO_FLAGS_INIT
#else
#define VIDEO_FLAGS VIDEO_FLAGS_INIT | SDL_DOUBLEBUF
#endif
int justClicked = 0;
int mouseMoving = 0;
int fcounter = 0;
int doStylusRightClick = 0;
static unsigned long previous_synctime = 0;
static unsigned long next_synctime = 0;
int graphics_setup (void)
{
return 1;
}
void InitAmigaVidMode(struct uae_prefs *p)
{
/* Initialize structure for Amiga video modes */
gfxvidinfo.pixbytes = 2;
gfxvidinfo.bufmem = (uae_u8 *)prSDLScreen->pixels;
gfxvidinfo.linemem = 0;
gfxvidinfo.emergmem = 0;
gfxvidinfo.width = p->gfx_size.width;
gfxvidinfo.height = p->gfx_size.height;
gfxvidinfo.maxblocklines = 0;
gfxvidinfo.rowbytes = prSDLScreen->pitch;
}
void graphics_subshutdown (void)
{
SDL_FreeSurface(prSDLScreen);
prSDLScreen = NULL;
}
static void CalcPandoraWidth(struct uae_prefs *p)
{
int amigaWidth = p->gfx_size.width;
int amigaHeight = p->gfx_size.height;
int pandHeight = 480;
if(amigaWidth > 600)
amigaWidth = amigaWidth / 2; // Hires selected, but we calc in lores
int pandWidth = (amigaWidth * pandHeight) / amigaHeight;
pandWidth = pandWidth & (~1);
if((pandWidth * amigaHeight) / pandHeight < amigaWidth)
pandWidth += 2;
if(pandWidth > 800)
pandWidth = 800;
p->gfx_size_fs.width = pandWidth;
}
void update_display(struct uae_prefs *p)
{
if(prSDLScreen != NULL)
graphics_subshutdown();
CalcPandoraWidth(p);
if(curr_layer_width != p->gfx_size_fs.width)
{
char layersize[20];
snprintf(layersize, 20, "%dx480", p->gfx_size_fs.width);
#ifndef WIN32
setenv("SDL_OMAP_LAYER_SIZE", layersize, 1);
#endif
}
#ifdef ANDROIDSDL
update_onscreen();
#endif
if(prSDLScreen == NULL || prSDLScreen->w != p->gfx_size.width || prSDLScreen->h != p->gfx_size.height)
{
#if defined(PANDORA) && !defined(WIN32)
prSDLScreen = SDL_SetVideoMode(p->gfx_size.width, p->gfx_size.height, 16, SDL_SWSURFACE|SDL_FULLSCREEN|SDL_DOUBLEBUF);
#elif defined(PANDORA) && defined(WIN32)
prSDLScreen = SDL_SetVideoMode(p->gfx_size.width, p->gfx_size.height, 16, SDL_SWSURFACE|SDL_DOUBLEBUF);
#else
prSDLScreen = SDL_SetVideoMode(p->gfx_size.width, p->gfx_size.height, 16, SDL_SWSURFACE|SDL_FULLSCREEN);
#endif
}
SDL_ShowCursor(SDL_DISABLE);
InitAmigaVidMode(p);
init_row_map();
framecnt = 1; // Don't draw frame before reset done
}
int check_prefs_changed_gfx (void)
{
int changed = 0;
if(currprefs.gfx_size.height != changed_prefs.gfx_size.height ||
currprefs.gfx_size.width != changed_prefs.gfx_size.width ||
currprefs.gfx_size_fs.width != changed_prefs.gfx_size_fs.width)
{
cfgfile_configuration_change(1);
currprefs.gfx_size.height = changed_prefs.gfx_size.height;
currprefs.gfx_size.width = changed_prefs.gfx_size.width;
currprefs.gfx_size_fs.width = changed_prefs.gfx_size_fs.width;
update_display(&currprefs);
changed = 1;
}
if (currprefs.leds_on_screen != changed_prefs.leds_on_screen ||
currprefs.pandora_vertical_offset != changed_prefs.pandora_vertical_offset)
{
currprefs.leds_on_screen = changed_prefs.leds_on_screen;
currprefs.pandora_vertical_offset = changed_prefs.pandora_vertical_offset;
changed = 1;
}
if (currprefs.chipset_refreshrate != changed_prefs.chipset_refreshrate)
{
currprefs.chipset_refreshrate = changed_prefs.chipset_refreshrate;
init_hz ();
changed = 1;
}
return changed;
}
int lockscr (void)
{
SDL_LockSurface(prSDLScreen);
return 1;
}
void unlockscr (void)
{
SDL_UnlockSurface(prSDLScreen);
}
void flush_block ()
{
SDL_UnlockSurface (prSDLScreen);
if (show_inputmode)
inputmode_redraw();
if (savestate_state == STATE_DOSAVE)
{
if(delay_savestate_frame > 0)
--delay_savestate_frame;
else
{
CreateScreenshot();
save_thumb(screenshot_filename);
savestate_state = 0;
}
}
unsigned long start = read_processor_time();
if(start < next_synctime && next_synctime - start > time_per_frame - 1000)
usleep((next_synctime - start) - 1000);
SDL_Flip(prSDLScreen);
last_synctime = read_processor_time();
if(last_synctime - next_synctime > time_per_frame - 1000)
adjust_idletime(0);
else
adjust_idletime(next_synctime - start);
if(last_synctime - next_synctime > time_per_frame - 5000)
next_synctime = last_synctime + time_per_frame * (1 + currprefs.gfx_framerate);
else
next_synctime = next_synctime + time_per_frame * (1 + currprefs.gfx_framerate);
SDL_LockSurface (prSDLScreen);
if(stylusClickOverride)
{
justClicked = 0;
mouseMoving = 0;
}
else
{
if(justClicked)
{
buttonstate[0] = 0;
buttonstate[2] = 0;
justClicked = 0;
}
if(mouseMoving)
{
if(fcounter >= currprefs.pandora_tapDelay)
{
if(doStylusRightClick)
{
buttonstate[2] = 1;
}
else
{
buttonstate[0] = 1;
mouseMoving = 0;
justClicked = 1;
fcounter = 0;
}
}
fcounter++;
}
}
init_row_map();
}
void black_screen_now(void)
{
SDL_FillRect(prSDLScreen,NULL,0);
SDL_Flip(prSDLScreen);
}
static void graphics_subinit (void)
{
if (prSDLScreen == NULL)
{
fprintf(stderr, "Unable to set video mode: %s\n", SDL_GetError());
return;
}
else
{
prSDLScreenPixels=(uae_u16 *)prSDLScreen->pixels;
SDL_LockSurface(prSDLScreen);
SDL_UnlockSurface(prSDLScreen);
SDL_Flip(prSDLScreen);
SDL_ShowCursor(SDL_DISABLE);
InitAmigaVidMode(&currprefs);
}
lastmx = lastmy = 0;
newmousecounters = 0;
}
STATIC_INLINE int bitsInMask (unsigned long mask)
{
/* count bits in mask */
int n = 0;
while (mask)
{
n += mask & 1;
mask >>= 1;
}
return n;
}
STATIC_INLINE int maskShift (unsigned long mask)
{
/* determine how far mask is shifted */
int n = 0;
while (!(mask & 1))
{
n++;
mask >>= 1;
}
return n;
}
static int init_colors (void)
{
int i;
int red_bits, green_bits, blue_bits;
int red_shift, green_shift, blue_shift;
/* Truecolor: */
red_bits = bitsInMask(prSDLScreen->format->Rmask);
green_bits = bitsInMask(prSDLScreen->format->Gmask);
blue_bits = bitsInMask(prSDLScreen->format->Bmask);
red_shift = maskShift(prSDLScreen->format->Rmask);
green_shift = maskShift(prSDLScreen->format->Gmask);
blue_shift = maskShift(prSDLScreen->format->Bmask);
alloc_colors64k (red_bits, green_bits, blue_bits, red_shift, green_shift, blue_shift, 0);
for (i = 0; i < 4096; i++)
xcolors[i] = xcolors[i] * 0x00010001;
return 1;
}
int graphics_init (void)
{
int i,j;
graphics_subinit ();
init_row_map ();
if (!init_colors ())
return 0;
buttonstate[0] = buttonstate[1] = buttonstate[2] = 0;
keyboard_init();
return 1;
}
void graphics_leave (void)
{
graphics_subshutdown ();
SDL_VideoQuit();
//dumpcustom ();
}
#define systemRedShift (prSDLScreen->format->Rshift)
#define systemGreenShift (prSDLScreen->format->Gshift)
#define systemBlueShift (prSDLScreen->format->Bshift)
#define systemRedMask (prSDLScreen->format->Rmask)
#define systemGreenMask (prSDLScreen->format->Gmask)
#define systemBlueMask (prSDLScreen->format->Bmask)
static int save_png(SDL_Surface* surface, char *path)
{
int w = surface->w;
int h = surface->h;
unsigned char * pix = (unsigned char *)surface->pixels;
unsigned char writeBuffer[1024 * 3];
FILE *f = fopen(path,"wb");
if(!f) return 0;
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
NULL,
NULL,
NULL);
if(!png_ptr) {
fclose(f);
return 0;
}
png_infop info_ptr = png_create_info_struct(png_ptr);
if(!info_ptr) {
png_destroy_write_struct(&png_ptr,NULL);
fclose(f);
return 0;
}
png_init_io(png_ptr,f);
png_set_IHDR(png_ptr,
info_ptr,
w,
h,
8,
PNG_COLOR_TYPE_RGB,
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT);
png_write_info(png_ptr,info_ptr);
unsigned char *b = writeBuffer;
int sizeX = w;
int sizeY = h;
int y;
int x;
unsigned short *p = (unsigned short *)pix;
for(y = 0; y < sizeY; y++)
{
for(x = 0; x < sizeX; x++)
{
unsigned short v = p[x];
*b++ = ((v & systemRedMask ) >> systemRedShift ) << 3; // R
*b++ = ((v & systemGreenMask) >> systemGreenShift) << 2; // G
*b++ = ((v & systemBlueMask ) >> systemBlueShift ) << 3; // B
}
p += surface->pitch / 2;
png_write_row(png_ptr,writeBuffer);
b = writeBuffer;
}
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(f);
return 1;
}
static void CreateScreenshot(void)
{
int w, h;
if(current_screenshot != NULL)
{
SDL_FreeSurface(current_screenshot);
current_screenshot = NULL;
}
w=prSDLScreen->w;
h=prSDLScreen->h;
current_screenshot = SDL_CreateRGBSurface(prSDLScreen->flags,w,h,prSDLScreen->format->BitsPerPixel,prSDLScreen->format->Rmask,prSDLScreen->format->Gmask,prSDLScreen->format->Bmask,prSDLScreen->format->Amask);
SDL_BlitSurface(prSDLScreen, NULL, current_screenshot, NULL);
}
static int save_thumb(char *path)
{
int ret = 0;
if(current_screenshot != NULL)
{
ret = save_png(current_screenshot, path);
SDL_FreeSurface(current_screenshot);
current_screenshot = NULL;
}
return ret;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,49 @@
#include "sysconfig.h"
#include "sysdeps.h"
#include "config.h"
#include "autoconf.h"
#include "uae.h"
#include "options.h"
#include "gui.h"
#include "custom.h"
#include "memory.h"
#include <sys/mman.h>
#include <SDL.h>
uae_u8* natmem_offset = 0;
const int totalAmigaMemSize = 0x1000000;
void free_AmigaMem(void)
{
if(natmem_offset != 0)
{
// munlock(natmem_offset, totalAmigaMemSize);
free(natmem_offset);
natmem_offset;
}
}
void alloc_AmigaMem(void)
{
int res;
free_AmigaMem();
natmem_offset = (uae_u8*)malloc(totalAmigaMemSize);
if(natmem_offset == 0)
{
printf("Failed to alloc complete Amiga memory.\n");
abort();
}
// res = mlock(natmem_offset, totalAmigaMemSize);
// if(res != 0)
// {
// printf("Failed to lock Amiga memory.\n");
// free(natmem_offset);
// abort();
// }
}

View file

@ -0,0 +1,299 @@
/*
* sigsegv_linux_arm.cpp - x86_64 Linux SIGSEGV handler
*
* Copyright (c) 2014 Jens Heitmann ARAnyM dev team (see AUTHORS)
*
* Inspired by Bernie Meyer's UAE-JIT and Gwenole Beauchesne's Basilisk II-JIT
*
* This file is part of the ARAnyM project which builds a new and powerful
* TOS/FreeMiNT compatible virtual machine running on almost any hardware.
*
* ARAnyM is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* ARAnyM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with ARAnyM; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "sysconfig.h"
#include "sysdeps.h"
#include "options.h"
#include "events.h"
#include "include/memory.h"
#include "custom.h"
#include "newcpu.h"
#include "comptbl.h"
#include "compemu.h"
#include <asm/sigcontext.h>
#include <signal.h>
#include <dlfcn.h>
#include <execinfo.h>
#include <SDL.h>
#define DEBUG 0
#include "debug.h"
enum transfer_type_t {
TYPE_UNKNOWN,
TYPE_LOAD,
TYPE_STORE
};
enum type_size_t {
SIZE_UNKNOWN,
SIZE_BYTE,
SIZE_WORD,
SIZE_INT
};
static int in_handler=0;
enum {
ARM_REG_PC = 15,
ARM_REG_CPSR = 16
};
static inline void unknown_instruction(uae_u32 instr)
{
panicbug("Unknown instruction %08x!", instr);
SDL_Quit();
abort();
}
static bool handle_arm_instruction(unsigned long *pregs, uintptr addr)
{
unsigned int *pc = (unsigned int *)pregs[ARM_REG_PC];
D(panicbug("IP: %p [%08x] %p\n", pc, pc[0], addr));
if (pc == 0) return false;
if (in_handler > 0)
{
panicbug("Segmentation fault in handler :-(");
return false;
}
in_handler += 1;
transfer_type_t transfer_type = TYPE_UNKNOWN;
int transfer_size = SIZE_UNKNOWN;
enum { SIGNED, UNSIGNED };
int style = UNSIGNED;
// Handle load/store instructions only
const unsigned int opcode = pc[0];
switch ((opcode >> 25) & 7) {
case 0: // Halfword and Signed Data Transfer (LDRH, STRH, LDRSB, LDRSH)
// Determine transfer size (S/H bits)
switch ((opcode >> 5) & 3) {
case 0: // SWP instruction
panicbug("FIXME: SWP Instruction\n");
break;
case 1: // Unsigned halfwords
transfer_size = SIZE_WORD;
break;
case 3: // Signed halfwords
style = SIGNED;
transfer_size = SIZE_WORD;
break;
case 2: // Signed byte
style = SIGNED;
transfer_size = SIZE_BYTE;
break;
}
break;
case 2:
case 3: // Single Data Transfer (LDR, STR)
style = UNSIGNED;
// Determine transfer size (B bit)
if (((opcode >> 22) & 1) == 1)
transfer_size = SIZE_BYTE;
else
transfer_size = SIZE_INT;
break;
default:
panicbug("FIXME: support load/store mutliple?\n");
return false;
}
// Check for invalid transfer size (SWP instruction?)
if (transfer_size == SIZE_UNKNOWN) {
panicbug("Invalid transfer size\n");
return false;
}
// Determine transfer type (L bit)
if (((opcode >> 20) & 1) == 1)
transfer_type = TYPE_LOAD;
else
transfer_type = TYPE_STORE;
int rd = (opcode >> 12) & 0xf;
#if DEBUG
static const char * reg_names[] = {
"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
"r8", "r9", "sl", "fp", "ip", "sp", "lr", "pc"
};
panicbug("%s %s register %s\n",
transfer_size == SIZE_BYTE ? "byte" :
transfer_size == SIZE_WORD ? "word" :
transfer_size == SIZE_INT ? "long" : "unknown",
transfer_type == TYPE_LOAD ? "load to" : "store from",
reg_names[rd]);
panicbug("\n");
// for (int i = 0; i < 16; i++) {
// panicbug("%s : %p", reg_names[i], pregs[i]);
// }
#endif
if (addr >= 0xff000000)
addr &= 0x00ffffff;
if ((addr < 0x00f00000) || (addr > 0x00ffffff))
goto buserr;
if (transfer_type == TYPE_LOAD) {
switch(transfer_size) {
case SIZE_BYTE: {
pregs[rd] = style == SIGNED ? (uae_s8)get_byte(addr) : (uae_u8)get_byte(addr);
break;
}
case SIZE_WORD: {
pregs[rd] = do_byteswap_16(style == SIGNED ? (uae_s16)get_word(addr) : (uae_u16)get_word(addr));
break;
}
case SIZE_INT: {
pregs[rd] = do_byteswap_32(get_long(addr));
break;
}
}
} else {
switch(transfer_size) {
case SIZE_BYTE: {
put_byte(addr, pregs[rd]);
break;
}
case SIZE_WORD: {
put_word(addr, do_byteswap_16(pregs[rd]));
break;
}
case SIZE_INT: {
put_long(addr, do_byteswap_32(pregs[rd]));
break;
}
}
}
pregs[ARM_REG_PC] += 4;
D(panicbug("processed: %p \n", pregs[ARM_REG_PC]));
in_handler--;
return true;
buserr:
D(panicbug("Amiga bus error\n"));
// BUS_ERROR(addr);
return false;
}
#define SIG_READ 1
#define SIG_WRITE 2
extern void dump_compiler(uae_u32 *sp);
void signal_segv(int signum, siginfo_t* info, void*ptr)
{
int i, f = 0;
ucontext_t *ucontext = (ucontext_t*)ptr;
Dl_info dlinfo;
void **bp = 0;
void *ip = 0;
mcontext_t *context = &(ucontext->uc_mcontext);
unsigned long *regs = &context->arm_r0;
uintptr addr = (uintptr)info->si_addr;
addr = (uae_u32) addr - (uae_u32) natmem_offset;
if (handle_arm_instruction(regs, addr))
return;
if(signum == 4)
printf("Illegal Instruction!\n");
else
printf("Segmentation Fault!\n");
printf("info.si_signo = %d\n", signum);
printf("info.si_errno = %d\n", info->si_errno);
// printf("info.si_code = %d (%s)\n", info->si_code, si_codes[info->si_code]);
printf("info.si_code = %d\n", info->si_code);
printf("info.si_addr = %p\n", info->si_addr);
if(signum == 4)
printf(" value = 0x%08x\n", *((uae_u32*)(info->si_addr)));
printf("reg[%02d] = 0x%08x\n",0 , ucontext->uc_mcontext.arm_r0);
printf("reg[%02d] = 0x%08x\n",1 , ucontext->uc_mcontext.arm_r1);
printf("reg[%02d] = 0x%08x\n",2 , ucontext->uc_mcontext.arm_r2);
printf("reg[%02d] = 0x%08x\n",3 , ucontext->uc_mcontext.arm_r3);
printf("reg[%02d] = 0x%08x\n",4 , ucontext->uc_mcontext.arm_r4);
printf("reg[%02d] = 0x%08x\n",5 , ucontext->uc_mcontext.arm_r5);
printf("reg[%02d] = 0x%08x\n",6 , ucontext->uc_mcontext.arm_r6);
printf("reg[%02d] = 0x%08x\n",7 , ucontext->uc_mcontext.arm_r7);
printf("reg[%02d] = 0x%08x\n",8 , ucontext->uc_mcontext.arm_r8);
printf("reg[%02d] = 0x%08x\n",9 , ucontext->uc_mcontext.arm_r9);
printf("reg[%02d] = 0x%08x\n",10 , ucontext->uc_mcontext.arm_r10);
printf("FP = 0x%08x\n", ucontext->uc_mcontext.arm_fp);
printf("IP = 0x%08x\n", ucontext->uc_mcontext.arm_ip);
printf("SP = 0x%08x\n", ucontext->uc_mcontext.arm_sp);
printf("LR = 0x%08x\n", ucontext->uc_mcontext.arm_lr);
printf("PC = 0x%08x\n", ucontext->uc_mcontext.arm_pc);
printf("CPSR = 0x%08x\n", ucontext->uc_mcontext.arm_cpsr);
printf("Fault Address = 0x%08x\n", ucontext->uc_mcontext.fault_address);
printf("Trap no = 0x%08x\n", ucontext->uc_mcontext.trap_no);
printf("Err Code = 0x%08x\n", ucontext->uc_mcontext.error_code);
printf("Old Mask = 0x%08x\n", ucontext->uc_mcontext.oldmask);
dump_compiler((uae_u32*)ucontext->uc_mcontext.arm_pc);
// printf("Stack trace:\n");
// ip = (void*)ucontext->uc_mcontext.arm_r10;
// bp = (void**)ucontext->uc_mcontext.arm_r10;
// while(bp && ip) {
// if (!dladdr(ip, &dlinfo)) {
// printf("IP out of range\n");
// break;
// }
// const char *symname = dlinfo.dli_sname;
// printf("% 2d: %p <%s + 0x%08x> (%s)\n", ++f, ip, symname,
// (unsigned long)ip - (unsigned long)dlinfo.dli_saddr, dlinfo.dli_fname);
// if(dlinfo.dli_sname && !strcmp(dlinfo.dli_sname, "main"))
// break;
// ip = bp[1];
// bp = (void**)bp[0];
// }
//
// printf("Stack trace (non-dedicated):\n");
// char **strings;
// void *bt[20];
// int sz = backtrace(bt, 20);
// strings = backtrace_symbols(bt, sz);
// for(i = 0; i < sz; ++i)
// printf("%s\n", strings[i]);
// printf("End of stack trace.\n");
SDL_Quit();
abort();
}

397
src/od-pandora/sysconfig.h Normal file
View file

@ -0,0 +1,397 @@
/* src/sysconfig.h. Generated automatically by configure. */
/* src/sysconfig.h.in. Generated automatically from configure.in by autoheader. */
/* Define if on AIX 3.
System headers sometimes define this.
We just want to avoid a redefinition error message. */
#ifndef _ALL_SOURCE
/* #undef _ALL_SOURCE */
#endif
/* Define to empty if the keyword does not work. */
/* #undef const */
/* Define if you have the getmntent function. */
#define HAVE_GETMNTENT 1
/* Define if your struct stat has st_blocks. */
/* #undef HAVE_ST_BLOCKS */
/* Define if utime(file, NULL) sets file's timestamp to the present. */
#define HAVE_UTIME_NULL 1
/* Define as __inline if that's what the C compiler calls it. */
/* #undef inline */
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef mode_t */
/* Define to `long' if <sys/types.h> doesn't define. */
/* #undef off_t */
/* Define to `int' if <sys/types.h> doesn't define. */
/* #undef pid_t */
/* Define if you need to in order for stat and other things to work. */
/* #undef _POSIX_SOURCE */
/* Define as the return type of signal handlers (int or void). */
#define RETSIGTYPE void
/* Define if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define if your <sys/time.h> declares struct tm. */
/* #undef TM_IN_SYS_TIME */
/* Define if the X Window System is missing or not being used. */
/* #undef X_DISPLAY_MISSING */
/* Define if you have the Andrew File System. */
/* #undef AFS */
/* Define if there is no specific function for reading the list of
mounted filesystems. fread will be used to read /etc/mnttab. [SVR2] */
/* #undef MOUNTED_FREAD */
/* Define if (like SVR2) there is no specific function for reading the
list of mounted filesystems, and your system has these header files:
<sys/fstyp.h> and <sys/statfs.h>. [SVR3] */
/* #undef MOUNTED_FREAD_FSTYP */
/* Define if there is a function named getfsstat for reading the list
of mounted filesystems. [DEC Alpha running OSF/1] */
/* #undef MOUNTED_GETFSSTAT */
/* Define if there is a function named getmnt for reading the list of
mounted filesystems. [Ultrix] */
/* #undef MOUNTED_GETMNT */
/* Define if there is a function named getmntent for reading the list
of mounted filesystems, and that function takes a single argument.
[4.3BSD, SunOS, HP-UX, Dynix, Irix] */
#define MOUNTED_GETMNTENT1 1
/* Define if there is a function named getmntent for reading the list of
mounted filesystems, and that function takes two arguments. [SVR4] */
/* #undef MOUNTED_GETMNTENT2 */
/* Define if there is a function named getmntinfo for reading the list
of mounted filesystems. [4.4BSD] */
/* #undef MOUNTED_GETMNTINFO */
/* Define if there is a function named listmntent that can be used to
list all mounted filesystems. [UNICOS] */
/* #undef MOUNTED_LISTMNTENT */
/* Define if there is a function named mntctl that can be used to read
the list of mounted filesystems, and there is a system header file
that declares `struct vmount.' [AIX] */
/* #undef MOUNTED_VMOUNT */
/* Define if statfs takes 3 args. [DEC Alpha running OSF/1] */
/* #undef STAT_STATFS3_OSF1 */
/* Define if there is no specific function for reading filesystems usage
information and you have the <sys/filsys.h> header file. [SVR2] */
/* #undef STAT_READ_FILSYS */
/* Define if statfs takes 2 args and struct statfs has a field named f_bsize.
[4.3BSD, SunOS 4, HP-UX, AIX PS/2] */
#define STAT_STATFS2_BSIZE 1
/* Define if statfs takes 2 args and struct statfs has a field named f_fsize.
[4.4BSD, NetBSD] */
/* #undef STAT_STATFS2_FSIZE */
/* Define if statfs takes 2 args and the second argument has
type struct fs_data. [Ultrix] */
/* #undef STAT_STATFS2_FS_DATA */
/* Define if statfs takes 4 args. [SVR3, Dynix, Irix, Dolphin] */
/* #undef STAT_STATFS4 */
/* Define if there is a function named statvfs. [SVR4] */
/* #undef STAT_STATVFS */
/* Define if the block counts reported by statfs may be truncated to 2GB
and the correct values may be stored in the f_spare array.
[SunOS 4.1.2, 4.1.3, and 4.1.3_U1 are reported to have this problem.
SunOS 4.1.1 seems not to be affected.] */
/* #undef STATFS_TRUNCATES_BLOCK_COUNTS */
/* The number of bytes in a __int64. */
#define SIZEOF___INT64 8
/* The number of bytes in a char. */
#define SIZEOF_CHAR 1
/* The number of bytes in a int. */
#define SIZEOF_INT 4
/* The number of bytes in a long. */
#define SIZEOF_LONG 4
/* The number of bytes in a long long. */
#define SIZEOF_LONG_LONG 8
/* The number of bytes in a short. */
#define SIZEOF_SHORT 2
#define SIZEOF_FLOAT 4
#define SIZEOF_DOUBLE 8
#define SIZEOF_VOID_P 4
#define HAVE_ISNAN
#undef HAVE_ISINF
/* Define if you have the bcopy function. */
#define HAVE_BCOPY 1
/* Define if you have the cfmakeraw function. */
/* #undef HAVE_CFMAKERAW */
/* Define if you have the endgrent function. */
#define HAVE_ENDGRENT 1
/* Define if you have the endpwent function. */
#define HAVE_ENDPWENT 1
/* Define if you have the fchdir function. */
#define HAVE_FCHDIR 1
/* Define if you have the ftime function. */
#define HAVE_FTIME 1
/* Define if you have the ftruncate function. */
#define HAVE_FTRUNCATE 1
/* Define if you have the getcwd function. */
#define HAVE_GETCWD 1
/* Define if you have the getmntinfo function. */
/* #undef HAVE_GETMNTINFO */
/* Define if you have the getopt function. */
#define HAVE_GETOPT 1
/* Define if you have the gettimeofday function. */
#define HAVE_GETTIMEOFDAY 1
/* Define if you have the isascii function. */
#define HAVE_ISASCII 1
/* Define if you have the lchown function. */
#define HAVE_LCHOWN 1
/* Define if you have the listmntent function. */
/* #undef HAVE_LISTMNTENT */
/* Define if you have the memcpy function. */
#define HAVE_MEMCPY 1
/* Define if you have the mkdir function. */
#define HAVE_MKDIR 1
/* Define if you have the mkfifo function. */
#define HAVE_MKFIFO 1
/* Define if you have the readdir_r function. */
#define HAVE_READDIR_R 1
/* Define if you have the rmdir function. */
#define HAVE_RMDIR 1
/* Define if you have the select function. */
#define HAVE_SELECT 1
/* Define if you have the setitimer function. */
#define HAVE_SETITIMER 1
/* Define if you have the sigaction function. */
#define HAVE_SIGACTION 1
/* Define if you have the strchr function. */
#define HAVE_STRCHR 1
/* Define if you have the strdup function. */
#define HAVE_STRDUP 1
/* Define if you have the strerror function. */
#define HAVE_STRERROR 1
/* Define if you have the strrchr function. */
#define HAVE_STRRCHR 1
/* Define if you have the strstr function. */
#define HAVE_STRSTR 1
/* Define if you have the tcgetattr function. */
#define HAVE_TCGETATTR 1
/* Define if you have the vfprintf function. */
#define HAVE_VFPRINTF 1
/* Define if you have the vprintf function. */
#define HAVE_VPRINTF 1
/* Define if you have the vsprintf function. */
#define HAVE_VSPRINTF 1
/* Define if you have the <SDL/SDL.h> header file. */
/* #undef HAVE_SDL_SDL_H */
/* Define if you have the <curses.h> header file. */
#define HAVE_CURSES_H 1
/* Define if you have the <cybergraphx/cybergraphics.h> header file. */
/* #undef HAVE_CYBERGRAPHX_CYBERGRAPHICS_H */
/* Define if you have the <ddraw.h> header file. */
/* #undef HAVE_DDRAW_H */
/* Define if you have the <devices/ahi.h> header file. */
/* #undef HAVE_DEVICES_AHI_H */
/* Define if you have the <dirent.h> header file. */
#define HAVE_DIRENT_H 1
/* Define if you have the <dmedia/audio.h> header file. */
/* #undef HAVE_DMEDIA_AUDIO_H */
/* Define if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define if you have the <features.h> header file. */
#define HAVE_FEATURES_H 1
/* Define if you have the <getopt.h> header file. */
#define HAVE_GETOPT_H 1
/* Define if you have the <libraries/cybergraphics.h> header file. */
/* #undef HAVE_LIBRARIES_CYBERGRAPHICS_H */
/* Define if you have the <machine/joystick.h> header file. */
/* #undef HAVE_MACHINE_JOYSTICK_H */
/* Define if you have the <machine/soundcard.h> header file. */
/* #undef HAVE_MACHINE_SOUNDCARD_H */
/* Define if you have the <mntent.h> header file. */
#define HAVE_MNTENT_H 1
/* Define if you have the <mnttab.h> header file. */
/* #undef HAVE_MNTTAB_H */
/* Define if you have the <ncurses.h> header file. */
#define HAVE_NCURSES_H 1
/* Define if you have the <ndir.h> header file. */
/* #undef HAVE_NDIR_H */
/* Define if you have the <posix_opt.h> header file. */
/* #undef HAVE_POSIX_OPT_H */
/* Define if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define if you have the <sun/audioio.h> header file. */
/* #undef HAVE_SUN_AUDIOIO_H */
/* Define if you have the <sys/audioio.h> header file. */
/* #undef HAVE_SYS_AUDIOIO_H */
/* Define if you have the <sys/dir.h> header file. */
/* #undef HAVE_SYS_DIR_H */
/* Define if you have the <sys/filsys.h> header file. */
/* #undef HAVE_SYS_FILSYS_H */
/* Define if you have the <sys/fs/s5param.h> header file. */
/* #undef HAVE_SYS_FS_S5PARAM_H */
/* Define if you have the <sys/fs_types.h> header file. */
/* #undef HAVE_SYS_FS_TYPES_H */
/* Define if you have the <sys/fstyp.h> header file. */
/* #undef HAVE_SYS_FSTYP_H */
/* Define if you have the <sys/ioctl.h> header file. */
#define HAVE_SYS_IOCTL_H 1
/* Define if you have the <sys/ipc.h> header file. */
#define HAVE_SYS_IPC_H 1
/* Define if you have the <sys/mount.h> header file. */
#define HAVE_SYS_MOUNT_H 1
/* Define if you have the <sys/ndir.h> header file. */
/* #undef HAVE_SYS_NDIR_H */
/* Define if you have the <sys/param.h> header file. */
#define HAVE_SYS_PARAM_H 1
/* Define if you have the <sys/shm.h> header file. */
#define HAVE_SYS_SHM_H 1
/* Define if you have the <sys/soundcard.h> header file. */
#define HAVE_SYS_SOUNDCARD_H 1
/* Define if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define if you have the <sys/statfs.h> header file. */
#define HAVE_SYS_STATFS_H 1
/* Define if you have the <sys/statvfs.h> header file. */
/* #undef HAVE_SYS_STATVFS_H */
/* Define if you have the <sys/termios.h> header file. */
#define HAVE_SYS_TERMIOS_H 1
/* Define if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define if you have the <sys/utime.h> header file. */
/* #undef HAVE_SYS_UTIME_H */
/* Define if you have the <sys/vfs.h> header file. */
#define HAVE_SYS_VFS_H 1
/* Define if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define if you have the <utime.h> header file. */
#define HAVE_UTIME_H 1
/* Define if you have the <values.h> header file. */
/* #undef HAVE_VALUES_H */
/* Define if you have the <windows.h> header file. */
/* #undef HAVE_WINDOWS_H */
#define FSDB_DIR_SEPARATOR '/'
#define strcmpi(x,y) strcasecmp(x,y)
#define stricmp(x,y) strcasecmp(x,y)
#ifndef MAX_PATH
#define MAX_PATH 256
#endif
#define MAX_DPATH 256
#define WORDS_BIGENDIAN 1
#define M68K_SPEED_7MHZ_CYCLES 0
#define M68K_SPEED_14MHZ_CYCLES 1024
#define M68K_SPEED_25MHZ_CYCLES 128

35
src/od-pandora/target.h Normal file
View file

@ -0,0 +1,35 @@
/*
* UAE - The Un*x Amiga Emulator
*
* Target specific stuff
*
* Copyright 1997 Bernd Schmidt
*/
#define TARGET_NAME "pandora"
#define OPTIONSFILENAME "uaeconfig"
/* Just 0x0 and not 680x0, so that constants can fit in ARM instructions */
#define M68000 0
#define M68020 2
#define SIMULATE_SHIFT 0x200
#define SIMULATE_RELEASED_SHIFT 0x400
extern int emulating;
extern int uae4all_keystate[256];
extern int stylusAdjustX;
extern int stylusAdjustY;
void run_gui(void);
void saveAdfDir(void);
void setCpuSpeed(void);
void resetCpuSpeed(void);
void update_display(struct uae_prefs *);
void graphics_subshutdown (void);
void pandora_stop_sound(void);
void keyboard_init(void);

View file

@ -0,0 +1,32 @@
/*
* UAE - The Un*x Amiga Emulator
*
* Standard write_log that writes to the console
*
* Copyright 2001 Bernd Schmidt
*/
#include "sysconfig.h"
#include "sysdeps.h"
#define WRITE_LOG_BUF_SIZE 4096
FILE *debugfile = NULL;
#ifdef WITH_LOGGING
void write_log (const char *format, ...)
{
int count;
int numwritten;
char buffer[WRITE_LOG_BUF_SIZE];
va_list parms;
va_start (parms, format);
count = vsnprintf( buffer, WRITE_LOG_BUF_SIZE-1, format, parms );
if( debugfile ) {
fprintf( debugfile, buffer );
fflush (debugfile);
}
va_end (parms);
}
#endif