Converted to SDL 2, added fullscreen toggle.

This commit is contained in:
Shamus Hammons 2013-09-08 21:18:23 -05:00
parent 5ad8269882
commit c0bc82a632
51 changed files with 1315 additions and 2156 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
apple2
apple2.log
disks/
gmon.out
obj/

View File

@ -12,7 +12,6 @@ ifeq "$(OSTYPE)" "msys" # Win32
SYSTYPE = __GCCWIN32__
EXESUFFIX = .exe
GLLIB = -lopengl32
ICON = obj/icon.o
SDLLIBTYPE = --libs
MSG = Win32 on MinGW
@ -23,7 +22,6 @@ ifeq "darwin" "$(findstring darwin,$(OSTYPE))" # Should catch both 'darwin' and
SYSTYPE = __GCCUNIX__ -D_OSX_
EXESUFFIX =
GLLIB =
ICON =
SDLLIBTYPE = --static-libs
MSG = Mac OS X
@ -32,7 +30,6 @@ else # *nix
SYSTYPE = __GCCUNIX__
EXESUFFIX =
GLLIB = -lGL
ICON =
SDLLIBTYPE = --libs
MSG = generic Unix/Linux
@ -45,28 +42,28 @@ LD = gcc
TARGET = apple2
# Note that we use optimization level 2 instead of 3--3 doesn't seem to gain much over 2
#CFLAGS = -MMD -Wall -Wno-switch -O2 -D$(SYSTYPE) -ffast-math -fomit-frame-pointer `sdl-config --cflags`
#CFLAGS = -MMD -Wall -Wno-switch -O2 -D$(SYSTYPE) -ffast-math -fomit-frame-pointer `sdl2-config --cflags`
#CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -O2 -D$(SYSTYPE) \
# No optimization and w/gcov flags, so that we get an accurate picture from gcov
#CFLAGS = -MMD -Wall -Wno-switch -D$(SYSTYPE) \
# -ffast-math -fomit-frame-pointer `sdl-config --cflags` -fprofile-arcs -ftest-coverage
# -ffast-math -fomit-frame-pointer `sdl2-config --cflags` -fprofile-arcs -ftest-coverage
#CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -D$(SYSTYPE) \
# -ffast-math -fomit-frame-pointer `sdl-config --cflags` -fprofile-arcs -ftest-coverage
# -ffast-math -fomit-frame-pointer `sdl2-config --cflags` -fprofile-arcs -ftest-coverage
# No optimization for profiling with gprof...
CFLAGS = -MMD -Wall -Wno-switch -D$(SYSTYPE) \
-ffast-math `sdl-config --cflags` -pg -g
-ffast-math `sdl2-config --cflags` -pg -g
CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -D$(SYSTYPE) \
-ffast-math `sdl-config --cflags` -pg -g
# -fomit-frame-pointer `sdl-config --cflags` -g
# -fomit-frame-pointer `sdl-config --cflags` -DLOG_UNMAPPED_MEMORY_ACCESSES
-ffast-math `sdl2-config --cflags` -pg -g
# -fomit-frame-pointer `sdl2-config --cflags` -g
# -fomit-frame-pointer `sdl2-config --cflags` -DLOG_UNMAPPED_MEMORY_ACCESSES
LDFLAGS =
#LIBS = -L/usr/local/lib -L/usr/lib `sdl-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB)
#LIBS = -L/usr/local/lib -L/usr/lib `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB)
# Link in the gcov library (for profiling purposes)
#LIBS = -L/usr/local/lib -L/usr/lib `sdl-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB) -lgcov
#LIBS = -L/usr/local/lib -L/usr/lib `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB) -lgcov
# Link in the gprof lib
LIBS = -L/usr/local/lib -L/usr/lib `sdl-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB) -pg
LIBS = -L/usr/local/lib -L/usr/lib `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB) -pg
INCS = -I. -I./src -I/usr/local/include -I/usr/include
@ -89,7 +86,6 @@ OBJS = \
obj/floppy.o \
obj/log.o \
obj/sdlemu_config.o \
obj/sdlemu_opengl.o \
obj/settings.o \
obj/sound.o \
obj/timing.o \
@ -107,11 +103,11 @@ all: checkenv message obj $(TARGET)$(EXESUFFIX)
checkenv:
@echo
@echo -en "\033[01;33m***\033[00;32m Checking compilation environment... \033[00m"
ifeq "" "$(shell which sdl-config)"
ifeq "" "$(shell which sdl2-config)"
@echo
@echo
@echo -e "\033[01;33mIt seems that you don't have the SDL development libraries installed.
@echo -e "have installed them, make sure that the sdl-config file is somewhere in your"
@echo -e "\033[01;33mIt seems that you don't have the SDL 2 development libraries installed.
@echo -e "have installed them, make sure that the sdl2-config file is somewhere in your"
@echo -e "path and is executable.\033[00m"
@echo
#Is there a better way to break out of the makefile?
@ -165,3 +161,4 @@ $(TARGET)$(EXESUFFIX): $(OBJS)
# The "-" in front in there just in case they haven't been created yet
-include obj/*.d

View File

@ -21,7 +21,7 @@ autoSaveState = 1
#floppyImage1 = ./disks/temp.nib
#floppyImage1 = ./disks/temp.dsk
# Yes
floppyImage1 = ./disks/bt1_boot.dsk
#floppyImage1 = ./disks/bt1_boot.dsk
# Yes
#floppyImage1 = ./disks/bt2_boot.dsk
# Yes (but segfaults in the timer routine in the title screen--NB: Not anymore...)
@ -50,7 +50,7 @@ floppyImage1 = ./disks/bt1_boot.dsk
#floppyImage1 = ./disks/MoebiusIIA.dsk
#floppyImage2 = ./disks/MoebiusIIB.dsk
# Yes
#floppyImage1 = ./disks/wind_walker_1.dsk
floppyImage1 = ./disks/wind_walker_1.dsk
# Yes
#floppyImage1 = ./disks/dino_eggs.dsk
# ??? 1, yes; 2, no

View File

@ -31,7 +31,7 @@
#include "apple2.h"
#include <SDL.h>
#include <SDL2/SDL.h>
#include <fstream>
#include <string>
#include <iomanip>
@ -64,36 +64,36 @@
// Global variables
uint8 ram[0x10000], rom[0x10000]; // RAM & ROM spaces
uint8 ram2[0x10000];
uint8 diskRom[0x100]; // Disk ROM space
uint8_t ram[0x10000], rom[0x10000]; // RAM & ROM spaces
uint8_t ram2[0x10000];
uint8_t diskRom[0x100]; // Disk ROM space
V65C02REGS mainCPU; // v65C02 execution context
uint8 appleType = APPLE_TYPE_II;
uint8_t appleType = APPLE_TYPE_II;
FloppyDrive floppyDrive;
// Local variables
static uint8 lastKeyPressed = 0;
static uint8_t lastKeyPressed = 0;
static bool keyDown = false;
//static FloppyDrive floppyDrive;
enum { LC_BANK_1, LC_BANK_2 };
static uint8 visibleBank = LC_BANK_1;
static uint8_t visibleBank = LC_BANK_1;
static bool readRAM = false;
static bool writeRAM = false;
static bool running = true; // Machine running state flag...
static uint32 startTicks;
static uint32_t startTicks;
static GUI * gui = NULL;
// Local functions (technically, they're global...)
bool LoadImg(char * filename, uint8 * ram, int size);
uint8 RdMem(uint16 addr);
void WrMem(uint16 addr, uint8 b);
bool LoadImg(char * filename, uint8_t * ram, int size);
uint8_t RdMem(uint16_t addr);
void WrMem(uint16_t addr, uint8_t b);
static void SaveApple2State(const char * filename);
static bool LoadApple2State(const char * filename);
@ -139,7 +139,7 @@ WriteLog("CPU: SDL_SemWait(mainSem);\n");
#endif
SDL_SemWait(mainSem);
uint32 cycles = 17066;
uint32_t cycles = 17066;
#ifdef CPU_THREAD_OVERFLOW_COMPENSATION
// ODD! It's closer *without* this overflow compensation. ??? WHY ???
overflow += 0.666666667;
@ -241,9 +241,9 @@ $C0EE - Disk set read mode
// V65C02 read/write memory functions
//
uint8 RdMem(uint16 addr)
uint8_t RdMem(uint16_t addr)
{
uint8 b;
uint8_t b;
#if 0
if (addr >= 0xC000 && addr <= 0xC0FF)
@ -263,7 +263,7 @@ if (addr >= 0xC080 && addr <= 0xC08F)
//This is bogus: keyDown is set to false, so return val NEVER is set...
//Fixed...
//Also, this is IIe/IIc only...!
uint8 retVal = lastKeyPressed | (keyDown ? 0x80 : 0x00);
uint8_t retVal = lastKeyPressed | (keyDown ? 0x80 : 0x00);
keyDown = false;
return retVal;
}
@ -569,7 +569,7 @@ APPENDIX F Assembly Language Program Listings
13 DDRB2 EQU $C482 ;DATA DIRECTION REGISTER (B)
14 DDRA2 EQU $C483 ;DATA DIRECTION REGISTER (A)
*/
void WrMem(uint16 addr, uint8 b)
void WrMem(uint16_t addr, uint8_t b)
{
//temp...
//extern V6809REGS regs;
@ -839,7 +839,7 @@ if (addr >= 0xD000 && addr <= 0xD00F)
//
// Load a file into RAM/ROM image space
//
bool LoadImg(char * filename, uint8 * ram, int size)
bool LoadImg(char * filename, uint8_t * ram, int size)
{
FILE * fp = fopen(filename, "rb");
@ -862,9 +862,9 @@ static bool LoadApple2State(const char * filename)
}
#ifdef CPU_CLOCK_CHECKING
uint8 counter = 0;
uint32 totalCPU = 0;
uint64 lastClock = 0;
uint8_t counter = 0;
uint32_t totalCPU = 0;
uint64_t lastClock = 0;
#endif
//
// Main loop
@ -961,10 +961,12 @@ memcpy(ram + 0xD000, ram + 0xC000, 0x1000);
WriteLog("About to initialize audio...\n");
SoundInit();
SDL_EnableUNICODE(1); // Needed to do key translation shit
//nope SDL_EnableUNICODE(1); // Needed to do key translation shit
// gui = new GUI(surface); // Set up the GUI system object...
gui = new GUI(mainSurface); // Set up the GUI system object...
// gui = new GUI(mainSurface); // Set up the GUI system object...
// SDL 2... this will likely cause Apple 2 to crash
// gui = new GUI(NULL); // Set up the GUI system object...
#if 0
gui->AddMenuTitle("Apple2");
gui->AddMenuItem("Test!", TestWindow/*, hotkey*/);
@ -983,7 +985,7 @@ memcpy(ram + 0xD000, ram + 0xC000, 0x1000);
#ifdef THREADED_65C02
cpuCond = SDL_CreateCond();
cpuThread = SDL_CreateThread(CPUThreadFunc, NULL);
cpuThread = SDL_CreateThread(CPUThreadFunc, NULL, NULL);
//Hmm... CPU does POST (+1), wait, then WAIT (-1)
mainSem = SDL_CreateSemaphore(1);
// SDL_sem * mainMutex = SDL_CreateMutex();
@ -1118,21 +1120,25 @@ static void FrameCallback(void)
{
switch (event.type)
{
case SDL_KEYDOWN:
if (event.key.keysym.unicode != 0)
{
case SDL_TEXTINPUT:
// if (event.key.keysym.unicode != 0)
// {
//Need to do some key translation here, and screen out non-apple keys as well...
if (event.key.keysym.sym == SDLK_TAB) // Prelim key screening...
break;
// if (event.key.keysym.sym == SDLK_TAB) // Prelim key screening...
if (event.edit.text[0] == '\t') // Prelim key screening...
break;
lastKeyPressed = event.key.keysym.unicode;
keyDown = true;
//kludge: should have a caps lock thingy here...
//or all uppercase for ][+...
if (lastKeyPressed >= 'a' && lastKeyPressed <='z')
lastKeyPressed &= 0xDF; // Convert to upper case...
}
// lastKeyPressed = event.key.keysym.unicode;
lastKeyPressed = event.edit.text[0];
keyDown = true;
//kludge: should have a caps lock thingy here...
//or all uppercase for ][+...
if (lastKeyPressed >= 'a' && lastKeyPressed <='z')
lastKeyPressed &= 0xDF; // Convert to upper case...
// }
break;
case SDL_KEYDOWN:
// CTRL+RESET key emulation (mapped to CTRL+`)
// This doesn't work...
// if (event.key.keysym.sym == SDLK_BREAK && (event.key.keysym.mod & KMOD_CTRL))
@ -1146,12 +1152,14 @@ static void FrameCallback(void)
lastKeyPressed = 0x15, keyDown = true;
else if (event.key.keysym.sym == SDLK_LEFT)
lastKeyPressed = 0x08, keyDown = true;
else if (event.key.keysym.sym == SDLK_RETURN)
lastKeyPressed = 0x0D, keyDown = true;
// Use ALT+Q to exit, as well as the usual window decoration method
if (event.key.keysym.sym == SDLK_q && (event.key.keysym.mod & KMOD_ALT))
running = false;
if (event.key.keysym.sym == SDLK_F12)
if (event.key.keysym.sym == SDLK_F11)
dumpDis = !dumpDis; // Toggle the disassembly process
// else if (event.key.keysym.sym == SDLK_F11)
// floppyDrive.LoadImage("./disks/bt1_char.dsk");//Kludge to load char disk...
@ -1196,6 +1204,23 @@ else if (event.key.keysym.sym == SDLK_F10)
SpawnMessage("Volume: %s", volStr);
}
static bool fullscreenDebounce = false;
if (event.key.keysym.sym == SDLK_F12)
{
if (!fullscreenDebounce)
{
ToggleFullScreen();
fullscreenDebounce = true;
}
}
// else
break;
case SDL_KEYUP:
if (event.key.keysym.sym == SDLK_F12)
fullscreenDebounce = false;
break;
case SDL_QUIT:
running = false;
@ -1211,10 +1236,10 @@ else if (event.key.keysym.sym == SDLK_F10)
counter++;
if (counter == 60)
{
uint64 clock = GetCurrentV65C02Clock();
//totalCPU += (uint32)(clock - lastClock);
uint64_t clock = GetCurrentV65C02Clock();
//totalCPU += (uint32_t)(clock - lastClock);
printf("Executed %u cycles...\n", (uint32)(clock - lastClock));
printf("Executed %u cycles...\n", (uint32_t)(clock - lastClock));
lastClock = clock;
// totalCPU = 0;
counter = 0;
@ -1254,7 +1279,7 @@ One way would be to use a fractional accumulator, then subtract 1 every
time it overflows. Like so:
double overflow = 0;
uint32 time = 20;
uint32_t time = 20;
while (!done)
{
Execute6808(&soundCPU, time);

View File

@ -2,13 +2,13 @@
// Apple 2 SDL Portable Apple Emulator
//
#include "types.h"
#include <stdint.h>
#include "floppy.h"
enum { APPLE_TYPE_II, APPLE_TYPE_IIE, APPLE_TYPE_IIC };
// Global variables (exported)
extern uint8 ram[0x10000], rom[0x10000]; // RAM & ROM pointers
extern uint8 appleType;
extern uint8_t ram[0x10000], rom[0x10000]; // RAM & ROM pointers
extern uint8_t appleType;
extern FloppyDrive floppyDrive;

View File

@ -28,8 +28,9 @@
#include "applevideo.h"
#include <string.h> // for memset()
#include <stdio.h>
#include <stdarg.h> // for va_* stuff
#include <string> // for vsprintf()
//#include <string> // for vsprintf()
#include "apple2.h"
#include "video.h"
#include "charset.h"
@ -72,11 +73,11 @@ bool alternateCharset;
// Local variables
// We set up the colors this way so that they'll be endian safe
// when we cast them to a uint32. Note that the format is RGBA.
// when we cast them to a uint32_t. Note that the format is RGBA.
// "Master Color Values" palette
static uint8 colors[16 * 4] = {
static uint8_t colors[16 * 4] = {
0x00, 0x00, 0x00, 0xFF, // Black
0xDD, 0x00, 0x33, 0xFF, // Deep Red (Magenta)
0x00, 0x00, 0x99, 0xFF, // Dark Blue
@ -97,7 +98,7 @@ static uint8 colors[16 * 4] = {
// This palette comes from ApplePC's colors (more realistic to my eye ;-)
static uint8 altColors[16 * 4] = {
static uint8_t altColors[16 * 4] = {
0x00, 0x00, 0x00, 0xFF,
0x7D, 0x20, 0x41, 0xFF,
0x41, 0x30, 0x7D, 0xFF,
@ -117,14 +118,14 @@ static uint8 altColors[16 * 4] = {
// Lo-res starting line addresses
static uint16 lineAddrLoRes[24] = {
static uint16_t lineAddrLoRes[24] = {
0x0400, 0x0480, 0x0500, 0x0580, 0x0600, 0x0680, 0x0700, 0x0780,
0x0428, 0x04A8, 0x0528, 0x05A8, 0x0628, 0x06A8, 0x0728, 0x07A8,
0x0450, 0x04D0, 0x0550, 0x05D0, 0x0650, 0x06D0, 0x0750, 0x07D0 };
// Hi-res starting line addresses
static uint16 lineAddrHiRes[192] = {
static uint16_t lineAddrHiRes[192] = {
0x2000, 0x2400, 0x2800, 0x2C00, 0x3000, 0x3400, 0x3800, 0x3C00,
0x2080, 0x2480, 0x2880, 0x2C80, 0x3080, 0x3480, 0x3880, 0x3C80,
0x2100, 0x2500, 0x2900, 0x2D00, 0x3100, 0x3500, 0x3900, 0x3D00,
@ -155,7 +156,7 @@ static uint16 lineAddrHiRes[192] = {
0x2350, 0x2750, 0x2B50, 0x2F50, 0x3350, 0x3750, 0x3B50, 0x3F50,
0x23D0, 0x27D0, 0x2BD0, 0x2FD0, 0x33D0, 0x37D0, 0x3BD0, 0x3FD0 };
uint16 appleHiresToMono[0x200] = {
uint16_t appleHiresToMono[0x200] = {
0x0000, 0x3000, 0x0C00, 0x3C00, 0x0300, 0x3300, 0x0F00, 0x3F00,
0x00C0, 0x30C0, 0x0CC0, 0x3CC0, 0x03C0, 0x33C0, 0x0FC0, 0x3FC0, // $0x
0x0030, 0x3030, 0x0C30, 0x3C30, 0x0330, 0x3330, 0x0F30, 0x3F30,
@ -225,18 +226,18 @@ uint16 appleHiresToMono[0x200] = {
0x207F, 0x387F, 0x267F, 0x3E7F, 0x21FF, 0x39FF, 0x27FF, 0x3FFF // $Fx
};
//static uint8 blurTable[0x800][8]; // Color TV blur table
static uint8 blurTable[0x80][8]; // Color TV blur table
static uint32 * palette = (uint32 *)altColors;
//static uint8_t blurTable[0x800][8]; // Color TV blur table
static uint8_t blurTable[0x80][8]; // Color TV blur table
static uint32_t * palette = (uint32_t *)altColors;
enum { ST_FIRST_ENTRY = 0, ST_COLOR_TV = 0, ST_WHITE_MONO, ST_GREEN_MONO, ST_LAST_ENTRY };
static uint8 screenType = ST_COLOR_TV;
static uint8_t screenType = ST_COLOR_TV;
// Local functions
static void Render40ColumnTextLine(uint8 line);
static void Render40ColumnTextLine(uint8_t line);
static void Render40ColumnText(void);
static void RenderLoRes(uint16 toLine = 24);
static void RenderHiRes(uint16 toLine = 192);
static void RenderLoRes(uint16_t toLine = 24);
static void RenderHiRes(uint16_t toLine = 192);
void SetupBlurTable(void)
@ -247,26 +248,26 @@ void SetupBlurTable(void)
// from 0-$7FF stepping by 16 does. Hm.
// Well, it seems that going from 0-$7F doesn't have enough precision to do the job.
#if 0
// for(uint16 bitPat=0; bitPat<0x800; bitPat++)
for(uint16 bitPat=0; bitPat<0x80; bitPat++)
// for(uint16_t bitPat=0; bitPat<0x800; bitPat++)
for(uint16_t bitPat=0; bitPat<0x80; bitPat++)
{
/* uint16 w3 = bitPat & 0x888;
uint16 w2 = bitPat & 0x444;
uint16 w1 = bitPat & 0x222;
uint16 w0 = bitPat & 0x111;*/
uint16 w3 = bitPat & 0x88;
uint16 w2 = bitPat & 0x44;
uint16 w1 = bitPat & 0x22;
uint16 w0 = bitPat & 0x11;
/* uint16_t w3 = bitPat & 0x888;
uint16_t w2 = bitPat & 0x444;
uint16_t w1 = bitPat & 0x222;
uint16_t w0 = bitPat & 0x111;*/
uint16_t w3 = bitPat & 0x88;
uint16_t w2 = bitPat & 0x44;
uint16_t w1 = bitPat & 0x22;
uint16_t w0 = bitPat & 0x11;
uint16 blurred3 = (w3 | (w3 >> 1) | (w3 >> 2) | (w3 >> 3)) & 0x00FF;
uint16 blurred2 = (w2 | (w2 >> 1) | (w2 >> 2) | (w2 >> 3)) & 0x00FF;
uint16 blurred1 = (w1 | (w1 >> 1) | (w1 >> 2) | (w1 >> 3)) & 0x00FF;
uint16 blurred0 = (w0 | (w0 >> 1) | (w0 >> 2) | (w0 >> 3)) & 0x00FF;
uint16_t blurred3 = (w3 | (w3 >> 1) | (w3 >> 2) | (w3 >> 3)) & 0x00FF;
uint16_t blurred2 = (w2 | (w2 >> 1) | (w2 >> 2) | (w2 >> 3)) & 0x00FF;
uint16_t blurred1 = (w1 | (w1 >> 1) | (w1 >> 2) | (w1 >> 3)) & 0x00FF;
uint16_t blurred0 = (w0 | (w0 >> 1) | (w0 >> 2) | (w0 >> 3)) & 0x00FF;
for(int8 i=7; i>=0; i--)
for(int8_t i=7; i>=0; i--)
{
uint8 color = (((blurred0 >> i) & 0x01) << 3)
uint8_t color = (((blurred0 >> i) & 0x01) << 3)
| (((blurred1 >> i) & 0x01) << 2)
| (((blurred2 >> i) & 0x01) << 1)
| ((blurred3 >> i) & 0x01);
@ -274,18 +275,18 @@ void SetupBlurTable(void)
}
}
#else
for(uint16 bitPat=0; bitPat<0x800; bitPat+=0x10)
for(uint16_t bitPat=0; bitPat<0x800; bitPat+=0x10)
{
uint16 w0 = bitPat & 0x111, w1 = bitPat & 0x222, w2 = bitPat & 0x444, w3 = bitPat & 0x888;
uint16_t w0 = bitPat & 0x111, w1 = bitPat & 0x222, w2 = bitPat & 0x444, w3 = bitPat & 0x888;
uint16 blurred0 = (w0 | (w0 >> 1) | (w0 >> 2) | (w0 >> 3)) & 0x00FF;
uint16 blurred1 = (w1 | (w1 >> 1) | (w1 >> 2) | (w1 >> 3)) & 0x00FF;
uint16 blurred2 = (w2 | (w2 >> 1) | (w2 >> 2) | (w2 >> 3)) & 0x00FF;
uint16 blurred3 = (w3 | (w3 >> 1) | (w3 >> 2) | (w3 >> 3)) & 0x00FF;
uint16_t blurred0 = (w0 | (w0 >> 1) | (w0 >> 2) | (w0 >> 3)) & 0x00FF;
uint16_t blurred1 = (w1 | (w1 >> 1) | (w1 >> 2) | (w1 >> 3)) & 0x00FF;
uint16_t blurred2 = (w2 | (w2 >> 1) | (w2 >> 2) | (w2 >> 3)) & 0x00FF;
uint16_t blurred3 = (w3 | (w3 >> 1) | (w3 >> 2) | (w3 >> 3)) & 0x00FF;
for(int8 i=7; i>=0; i--)
for(int8_t i=7; i>=0; i--)
{
uint8 color = (((blurred0 >> i) & 0x01) << 3)
uint8_t color = (((blurred0 >> i) & 0x01) << 3)
| (((blurred1 >> i) & 0x01) << 2)
| (((blurred2 >> i) & 0x01) << 1)
| ((blurred3 >> i) & 0x01);
@ -295,20 +296,22 @@ void SetupBlurTable(void)
#endif
}
void TogglePalette(void)
{
if (palette == (uint32 *)colors)
if (palette == (uint32_t *)colors)
{
palette = (uint32 *)altColors;
palette = (uint32_t *)altColors;
SpawnMessage("Color TV palette");
}
else
{
palette = (uint32 *)colors;
palette = (uint32_t *)colors;
SpawnMessage("\"Master Color Values\" palette");
}
}
void CycleScreenTypes(void)
{
char scrTypeStr[3][40] = { "Color TV", "White monochrome", "Green monochrome" };
@ -321,7 +324,8 @@ void CycleScreenTypes(void)
SpawnMessage("%s", scrTypeStr[screenType]);
}
static uint32 msgTicks = 0;
static uint32_t msgTicks = 0;
static char message[4096];
void SpawnMessage(const char * text, ...)
@ -335,62 +339,64 @@ void SpawnMessage(const char * text, ...)
msgTicks = 120;
}
static void DrawString2(uint32 x, uint32 y, uint32 color);
static void DrawString2(uint32_t x, uint32_t y, uint32_t color);
static void DrawString(void)
{
//This approach works, and seems to be fast enough... Though it probably would
//be better to make the oversized font to match this one...
for(uint32 x=7; x<=9; x++)
for(uint32 y=7; y<=9; y++)
for(uint32_t x=7; x<=9; x++)
for(uint32_t y=7; y<=9; y++)
DrawString2(x, y, 0x00000000);
DrawString2(8, 8, 0x0020FF20);
}
static void DrawString2(uint32 x, uint32 y, uint32 color)
static void DrawString2(uint32_t x, uint32_t y, uint32_t color)
{
//uint32 x = 8, y = 8;
uint32 length = strlen(message), address = x + (y * VIRTUAL_SCREEN_WIDTH);
// uint32 color = 0x0020FF20;
//uint32_t x = 8, y = 8;
uint32_t length = strlen(message), address = x + (y * VIRTUAL_SCREEN_WIDTH);
// uint32_t color = 0x0020FF20;
//This could be done ahead of time, instead of on each pixel...
//(Now it is!)
uint8 nBlue = (color >> 16) & 0xFF, nGreen = (color >> 8) & 0xFF, nRed = color & 0xFF;
uint8_t nBlue = (color >> 16) & 0xFF, nGreen = (color >> 8) & 0xFF, nRed = color & 0xFF;
for(uint32 i=0; i<length; i++)
for(uint32_t i=0; i<length; i++)
{
uint8 c = message[i];
uint8_t c = message[i];
c = (c < 32 ? 0 : c - 32);
uint32 fontAddr = (uint32)c * FONT_WIDTH * FONT_HEIGHT;
uint32_t fontAddr = (uint32_t)c * FONT_WIDTH * FONT_HEIGHT;
for(uint32 yy=0; yy<FONT_HEIGHT; yy++)
for(uint32_t yy=0; yy<FONT_HEIGHT; yy++)
{
for(uint32 xx=0; xx<FONT_WIDTH; xx++)
for(uint32_t xx=0; xx<FONT_WIDTH; xx++)
{
/* uint8 fontTrans = font1[fontAddr++];
// uint32 newTrans = (fontTrans * transparency / 255) << 24;
uint32 newTrans = fontTrans << 24;
uint32 pixel = newTrans | color;
/* uint8_t fontTrans = font1[fontAddr++];
// uint32_t newTrans = (fontTrans * transparency / 255) << 24;
uint32_t newTrans = fontTrans << 24;
uint32_t pixel = newTrans | color;
*(scrBuffer + address + xx + (yy * VIRTUAL_SCREEN_WIDTH)) = pixel;//*/
uint8 trans = font1[fontAddr++];
uint8_t trans = font1[fontAddr++];
if (trans)
{
uint32 existingColor = *(scrBuffer + address + xx + (yy * VIRTUAL_SCREEN_WIDTH));
uint32_t existingColor = *(scrBuffer + address + xx + (yy * VIRTUAL_SCREEN_WIDTH));
uint8 eBlue = (existingColor >> 16) & 0xFF,
uint8_t eBlue = (existingColor >> 16) & 0xFF,
eGreen = (existingColor >> 8) & 0xFF,
eRed = existingColor & 0xFF;
//This could be sped up by using a table of 5 + 5 + 5 bits (32 levels transparency -> 32768 entries)
//Here we've modified it to have 33 levels of transparency (could have any # we want!)
//because dividing by 32 is faster than dividing by 31...!
uint8 invTrans = 255 - trans;
uint8_t invTrans = 255 - trans;
uint32 bRed = (eRed * invTrans + nRed * trans) / 255;
uint32 bGreen = (eGreen * invTrans + nGreen * trans) / 255;
uint32 bBlue = (eBlue * invTrans + nBlue * trans) / 255;
uint32_t bRed = (eRed * invTrans + nRed * trans) / 255;
uint32_t bGreen = (eGreen * invTrans + nGreen * trans) / 255;
uint32_t bBlue = (eBlue * invTrans + nBlue * trans) / 255;
//THIS IS NOT ENDIAN SAFE
*(scrBuffer + address + xx + (yy * VIRTUAL_SCREEN_WIDTH)) = 0xFF000000 | (bBlue << 16) | (bGreen << 8) | bRed;
@ -402,13 +408,14 @@ static void DrawString2(uint32 x, uint32 y, uint32 color)
}
}
static void Render40ColumnTextLine(uint8 line)
static void Render40ColumnTextLine(uint8_t line)
{
uint32 pixelOn = (screenType == ST_GREEN_MONO ? 0xFF61FF61 : 0xFFFFFFFF);
uint32_t pixelOn = (screenType == ST_GREEN_MONO ? 0xFF61FF61 : 0xFFFFFFFF);
for(int x=0; x<40; x++)
{
uint8 chr = ram[lineAddrLoRes[line] + (displayPage2 ? 0x0400 : 0x0000) + x];
uint8_t chr = ram[lineAddrLoRes[line] + (displayPage2 ? 0x0400 : 0x0000) + x];
// Render character at (x, y)
@ -416,7 +423,7 @@ static void Render40ColumnTextLine(uint8 line)
{
for(int cx=0; cx<7; cx++)
{
uint32 pixel = 0xFF000000;
uint32_t pixel = 0xFF000000;
if (!alternateCharset)
{
@ -455,13 +462,15 @@ static void Render40ColumnTextLine(uint8 line)
}
}
static void Render40ColumnText(void)
{
for(uint8 line=0; line<24; line++)
for(uint8_t line=0; line<24; line++)
Render40ColumnTextLine(line);
}
static void RenderLoRes(uint16 toLine/*= 24*/)
static void RenderLoRes(uint16_t toLine/*= 24*/)
{
// NOTE: The green mono rendering doesn't skip every other line... !!! FIX !!!
// Also, we could set up three different Render functions depending on which
@ -488,18 +497,18 @@ fb 9e be -> 11 [1101] -> 11? PINK
be ae fb -> 7 [1110] -> 7? LIGHT BLUE (CYAN)
fb fb fb -> 15 [1111] -> 15 WHITE
*/
uint8 mirrorNybble[16] = { 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 };
uint8_t mirrorNybble[16] = { 0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15 };
//This is the old "perfect monitor" rendering code...
/* if (screenType != ST_COLOR_TV) // Not correct, but for now...
//if (1)
{
for(uint16 y=0; y<toLine; y++)
for(uint16_t y=0; y<toLine; y++)
{
for(uint16 x=0; x<40; x++)
for(uint16_t x=0; x<40; x++)
{
uint8 scrByte = ram[lineAddrLoRes[y] + (displayPage2 ? 0x0400 : 0x0000) + x];
uint32 pixel = palette[scrByte & 0x0F];
uint8_t scrByte = ram[lineAddrLoRes[y] + (displayPage2 ? 0x0400 : 0x0000) + x];
uint32_t pixel = palette[scrByte & 0x0F];
for(int cy=0; cy<4; cy++)
for(int cx=0; cx<14; cx++)
@ -515,22 +524,22 @@ fb fb fb -> 15 [1111] -> 15 WHITE
}
else//*/
uint32 pixelOn = (screenType == ST_WHITE_MONO ? 0xFFFFFFFF : 0xFF61FF61);
uint32_t pixelOn = (screenType == ST_WHITE_MONO ? 0xFFFFFFFF : 0xFF61FF61);
for(uint16 y=0; y<toLine; y++)
for(uint16_t y=0; y<toLine; y++)
{
// Do top half of lores screen bytes...
uint32 previous3Bits = 0;
uint32_t previous3Bits = 0;
for(uint16 x=0; x<40; x+=2)
for(uint16_t x=0; x<40; x+=2)
{
uint8 scrByte1 = ram[lineAddrLoRes[y] + (displayPage2 ? 0x0400 : 0x0000) + x + 0] & 0x0F;
uint8 scrByte2 = ram[lineAddrLoRes[y] + (displayPage2 ? 0x0400 : 0x0000) + x + 1] & 0x0F;
uint8_t scrByte1 = ram[lineAddrLoRes[y] + (displayPage2 ? 0x0400 : 0x0000) + x + 0] & 0x0F;
uint8_t scrByte2 = ram[lineAddrLoRes[y] + (displayPage2 ? 0x0400 : 0x0000) + x + 1] & 0x0F;
scrByte1 = mirrorNybble[scrByte1];
scrByte2 = mirrorNybble[scrByte2];
// This is just a guess, but it'll have to do for now...
uint32 pixels = previous3Bits | (scrByte1 << 24) | (scrByte1 << 20) | (scrByte1 << 16)
uint32_t pixels = previous3Bits | (scrByte1 << 24) | (scrByte1 << 20) | (scrByte1 << 16)
| ((scrByte1 & 0x0C) << 12) | ((scrByte2 & 0x03) << 12)
| (scrByte2 << 8) | (scrByte2 << 4) | scrByte2;
@ -540,16 +549,16 @@ fb fb fb -> 15 [1111] -> 15 WHITE
if (screenType == ST_COLOR_TV)
{
for(uint8 i=0; i<7; i++)
for(uint8_t i=0; i<7; i++)
{
uint8 bitPat = (pixels & 0x7F000000) >> 24;
uint8_t bitPat = (pixels & 0x7F000000) >> 24;
pixels <<= 4;
for(uint8 j=0; j<4; j++)
for(uint8_t j=0; j<4; j++)
{
uint8 color = blurTable[bitPat][j];
uint8_t color = blurTable[bitPat][j];
for(uint32 cy=0; cy<8; cy++)
for(uint32_t cy=0; cy<8; cy++)
{
scrBuffer[((x * 14) + (i * 4) + j) + (((y * 16) + cy) * VIRTUAL_SCREEN_WIDTH)] = palette[color];
// scrBuffer[((x * 14) + (i * 4) + j) + (((y * 16) + cy) * VIRTUAL_SCREEN_WIDTH)] = palette[color];
@ -563,7 +572,7 @@ fb fb fb -> 15 [1111] -> 15 WHITE
{
for(int j=0; j<28; j++)
{
for(uint32 cy=0; cy<8; cy++)
for(uint32_t cy=0; cy<8; cy++)
{
scrBuffer[((x * 14) + j) + (((y * 16) + cy) * VIRTUAL_SCREEN_WIDTH)] = (pixels & 0x08000000 ? pixelOn : 0xFF000000);
// scrBuffer[((x * 14) + j) + (((y * 16) + cy) * VIRTUAL_SCREEN_WIDTH)] = (pixels & 0x08000000 ? pixelOn : 0xFF000000);
@ -578,14 +587,14 @@ fb fb fb -> 15 [1111] -> 15 WHITE
previous3Bits = 0;
for(uint16 x=0; x<40; x+=2)
for(uint16_t x=0; x<40; x+=2)
{
uint8 scrByte1 = ram[lineAddrLoRes[y] + (displayPage2 ? 0x0400 : 0x0000) + x + 0] >> 4;
uint8 scrByte2 = ram[lineAddrLoRes[y] + (displayPage2 ? 0x0400 : 0x0000) + x + 1] >> 4;
uint8_t scrByte1 = ram[lineAddrLoRes[y] + (displayPage2 ? 0x0400 : 0x0000) + x + 0] >> 4;
uint8_t scrByte2 = ram[lineAddrLoRes[y] + (displayPage2 ? 0x0400 : 0x0000) + x + 1] >> 4;
scrByte1 = mirrorNybble[scrByte1];
scrByte2 = mirrorNybble[scrByte2];
// This is just a guess, but it'll have to do for now...
uint32 pixels = previous3Bits | (scrByte1 << 24) | (scrByte1 << 20) | (scrByte1 << 16)
uint32_t pixels = previous3Bits | (scrByte1 << 24) | (scrByte1 << 20) | (scrByte1 << 16)
| ((scrByte1 & 0x0C) << 12) | ((scrByte2 & 0x03) << 12)
| (scrByte2 << 8) | (scrByte2 << 4) | scrByte2;
@ -595,16 +604,16 @@ fb fb fb -> 15 [1111] -> 15 WHITE
if (screenType == ST_COLOR_TV)
{
for(uint8 i=0; i<7; i++)
for(uint8_t i=0; i<7; i++)
{
uint8 bitPat = (pixels & 0x7F000000) >> 24;
uint8_t bitPat = (pixels & 0x7F000000) >> 24;
pixels <<= 4;
for(uint8 j=0; j<4; j++)
for(uint8_t j=0; j<4; j++)
{
uint8 color = blurTable[bitPat][j];
uint8_t color = blurTable[bitPat][j];
for(uint32 cy=8; cy<16; cy++)
for(uint32_t cy=8; cy<16; cy++)
{
scrBuffer[((x * 14) + (i * 4) + j) + (((y * 16) + cy) * VIRTUAL_SCREEN_WIDTH)] = palette[color];
// scrBuffer[((x * 14) + (i * 4) + j) + (((y * 16) + cy) * VIRTUAL_SCREEN_WIDTH)] = palette[color];
@ -618,7 +627,7 @@ fb fb fb -> 15 [1111] -> 15 WHITE
{
for(int j=0; j<28; j++)
{
for(uint32 cy=8; cy<16; cy++)
for(uint32_t cy=8; cy<16; cy++)
{
scrBuffer[((x * 14) + j) + (((y * 16) + cy) * VIRTUAL_SCREEN_WIDTH)] = (pixels & 0x08000000 ? pixelOn : 0xFF000000);
// scrBuffer[((x * 14) + j) + (((y * 16) + cy) * VIRTUAL_SCREEN_WIDTH)] = (pixels & 0x08000000 ? pixelOn : 0xFF000000);
@ -631,32 +640,33 @@ fb fb fb -> 15 [1111] -> 15 WHITE
}
}
static void RenderHiRes(uint16 toLine/*= 192*/)
static void RenderHiRes(uint16_t toLine/*= 192*/)
{
// NOTE: Not endian safe. !!! FIX !!! [DONE]
#if 0
uint32 pixelOn = (screenType == ST_WHITE_MONO ? 0xFFFFFFFF : 0xFF61FF61);
uint32_t pixelOn = (screenType == ST_WHITE_MONO ? 0xFFFFFFFF : 0xFF61FF61);
#else
// Now it is. Now roll this fix into all the other places... !!! FIX !!!
// The colors are set in the 8-bit array as R G B A
uint8 monoColors[8] = { 0xFF, 0xFF, 0xFF, 0xFF, 0x61, 0xFF, 0x61, 0xFF };
uint32 * colorPtr = (uint32 *)monoColors;
uint32 pixelOn = (screenType == ST_WHITE_MONO ? colorPtr[0] : colorPtr[1]);
uint8_t monoColors[8] = { 0xFF, 0xFF, 0xFF, 0xFF, 0x61, 0xFF, 0x61, 0xFF };
uint32_t * colorPtr = (uint32_t *)monoColors;
uint32_t pixelOn = (screenType == ST_WHITE_MONO ? colorPtr[0] : colorPtr[1]);
#endif
for(uint16 y=0; y<toLine; y++)
for(uint16_t y=0; y<toLine; y++)
{
uint16 previousLoPixel = 0;
uint32 previous3bits = 0;
uint16_t previousLoPixel = 0;
uint32_t previous3bits = 0;
for(uint16 x=0; x<40; x+=2)
for(uint16_t x=0; x<40; x+=2)
{
uint8 screenByte = ram[lineAddrHiRes[y] + (displayPage2 ? 0x2000 : 0x0000) + x];
uint32 pixels = appleHiresToMono[previousLoPixel | screenByte];
uint8_t screenByte = ram[lineAddrHiRes[y] + (displayPage2 ? 0x2000 : 0x0000) + x];
uint32_t pixels = appleHiresToMono[previousLoPixel | screenByte];
previousLoPixel = (screenByte << 2) & 0x0100;
screenByte = ram[lineAddrHiRes[y] + (displayPage2 ? 0x2000 : 0x0000) + x + 1];
uint32 pixels2 = appleHiresToMono[previousLoPixel | screenByte];
uint32_t pixels2 = appleHiresToMono[previousLoPixel | screenByte];
previousLoPixel = (screenByte << 2) & 0x0100;
pixels = previous3bits | (pixels << 14) | pixels2;
@ -667,14 +677,14 @@ static void RenderHiRes(uint16 toLine/*= 192*/)
if (screenType == ST_COLOR_TV)
{
for(uint8 i=0; i<7; i++)
for(uint8_t i=0; i<7; i++)
{
uint8 bitPat = (pixels & 0x7F000000) >> 24;
uint8_t bitPat = (pixels & 0x7F000000) >> 24;
pixels <<= 4;
for(uint8 j=0; j<4; j++)
for(uint8_t j=0; j<4; j++)
{
uint8 color = blurTable[bitPat][j];
uint8_t color = blurTable[bitPat][j];
#if 0
//This doesn't seem to make things go any faster...
//It's the OpenGL render that's faster... Hmm...
@ -705,6 +715,7 @@ static void RenderHiRes(uint16 toLine/*= 192*/)
}
}
void RenderVideoFrame(void)
{
//temp...
@ -755,3 +766,4 @@ return;//*/
RenderScreenBuffer();
}

View File

@ -292,10 +292,10 @@ void _AYWriteReg(int n, int r, int v)
// /length/ is the number of samples we require
// NB. This should be called at twice the 6522 IRQ rate or (eg) 60Hz if no IRQ.
void AY8910Update(int chip, int16 ** buffer, int length) // [TC: Removed static]
void AY8910Update(int chip, int16_t ** buffer, int length) // [TC: Removed static]
{
struct AY8910 * PSG = &AYPSG[chip];
int16 * buf1, * buf2, * buf3;
int16_t * buf1, * buf2, * buf3;
int outn;
buf1 = buffer[0];
@ -726,7 +726,7 @@ void AY8910_InitClock(int clock)
AY8910_set_clock(chip, clock);
}
uint8 * AY8910_GetRegsPtr(uint16 chipNum)
uint8_t * AY8910_GetRegsPtr(uint16_t chipNum)
{
if (chipNum >= MAX_8910)
return NULL;

View File

@ -1,16 +1,16 @@
#ifndef AY8910_H
#define AY8910_H
#include "types.h"
#include <stdint.h>
#define MAX_8910 4
void _AYWriteReg(int n, int r, int v);
void AY8910_reset(int chip);
void AY8910Update(int chip, int16 ** buffer, int length);
void AY8910Update(int chip, int16_t ** buffer, int length);
void AY8910_InitAll(int clock, int sampleRate);
void AY8910_InitClock(int clock);
uint8 * AY8910_GetRegsPtr(uint16 chipNum);
uint8_t * AY8910_GetRegsPtr(uint16_t chipNum);
#endif

View File

@ -20,7 +20,7 @@ extern V65C02REGS mainCPU;//Hm. Shouldn't we pass this shit in? ANSWER: YES. !!!
// Private globals variables
static uint8 op_mat[256] = {
static uint8_t op_mat[256] = {
14, 6, 0, 0, 2, 2, 2, 2, 14, 1, 14, 0, 8, 8, 8, 13,
13, 7, 5, 0, 2, 3, 3, 2, 14, 10, 14, 0, 8, 9, 9, 13,
8, 6, 0, 0, 2, 2, 2, 2, 14, 1, 14, 0, 8, 8, 8, 13,
@ -38,7 +38,7 @@ static uint8 op_mat[256] = {
1, 6, 0, 0, 2, 2, 2, 2, 14, 1, 14, 0, 8, 8, 8, 13,
13, 7, 5, 0, 0, 3, 3, 2, 14, 10, 14, 0, 0, 9, 9, 13 };
static uint8 mnemonics[256][6] = {
static uint8_t mnemonics[256][6] = {
"BRK ","ORA ","??? ","??? ","TSB ","ORA ","ASL ","RMB0 ",
"PHP ","ORA ","ASL ","??? ","TSB ","ORA ","ASL ","BBR0 ",
"BPL ","ORA ","ORA ","??? ","TRB ","ORA ","ASL ","RMB1 ",
@ -75,15 +75,15 @@ static uint8 mnemonics[256][6] = {
//
// Display bytes in mem in hex
//
static void DisplayBytes(uint16 src, uint32 dst)
static void DisplayBytes(uint16_t src, uint32_t dst)
{
WriteLog("%04X: ", src);
uint8 cnt = 0; // Init counter...
uint8_t cnt = 0; // Init counter...
if (src > dst)
dst += 0x10000; // That should fix the FFFF bug...
for(uint32 i=src; i<dst; i++)
for(uint32_t i=src; i<dst; i++)
{
WriteLog("%02X ", mainCPU.RdMem(i));
cnt++; // Bump counter...
@ -96,7 +96,7 @@ static void DisplayBytes(uint16 src, uint32 dst)
//
// Decode a 65C02 instruction
//
int Decode65C02(uint16 pc)
int Decode65C02(uint16_t pc)
{
/*
0) illegal
@ -117,8 +117,8 @@ int Decode65C02(uint16 pc)
*/
char outbuf[80];
uint16 addr = pc;
uint8 opcode = mainCPU.RdMem(addr++); // Get the opcode
uint16_t addr = pc;
uint8_t opcode = mainCPU.RdMem(addr++); // Get the opcode
switch (op_mat[opcode]) // Decode the addressing mode...
{
@ -162,8 +162,8 @@ int Decode65C02(uint16 pc)
sprintf(outbuf, "%s ($%04X,X)", mnemonics[opcode], mainCPU.RdMem(addr++) | (mainCPU.RdMem(addr++) << 8));
break;
case 13: // Relative
// sprintf(outbuf, "%s $%04X", mnemonics[opcode], ++addr + (int16)(int8)mainCPU.RdMem(addr));
sprintf(outbuf, "%s $%04X", mnemonics[opcode], addr + (int16)((int8)mainCPU.RdMem(addr)) + 1);
// sprintf(outbuf, "%s $%04X", mnemonics[opcode], ++addr + (int16_t)(int8_t)mainCPU.RdMem(addr));
sprintf(outbuf, "%s $%04X", mnemonics[opcode], addr + (int16_t)((int8_t)mainCPU.RdMem(addr)) + 1);
addr++;
break;
case 14: // Inherent

View File

@ -8,8 +8,8 @@
#ifndef __DIS65C02_H__
#define __DIS65C02_H__
#include "types.h"
#include <stdint.h>
int Decode65C02(uint16 pc);
int Decode65C02(uint16_t pc);
#endif // __DIS65C02_H__

View File

@ -1,6 +1,6 @@
/* GIMP RGBA C-Source image dump (fd-img-128x128.c) */
uint8 floppyDiskImg[] = {
uint8_t floppyDiskImg[] = {
// 128 / 256, 128 % 256, // width (HI byte, LO byte)
// 128 / 256, 128 % 256, // height (HI byte, LO byte)
"\000\200\000\200" // Same thing as above, just in octal... :-P

View File

@ -29,13 +29,13 @@ enum { IO_MODE_READ, IO_MODE_WRITE };
// FloppyDrive class variable initialization
uint8 FloppyDrive::header[21] = {
uint8_t FloppyDrive::header[21] = {
0xD5, 0xAA, 0x96, 0xFF, 0xFE, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xDE, 0xAA, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xD5, 0xAA, 0xAD };
uint8 FloppyDrive::doSector[16] = {
uint8_t FloppyDrive::doSector[16] = {
0x0, 0x7, 0xE, 0x6, 0xD, 0x5, 0xC, 0x4, 0xB, 0x3, 0xA, 0x2, 0x9, 0x1, 0x8, 0xF };
uint8 FloppyDrive::poSector[16] = {
uint8_t FloppyDrive::poSector[16] = {
0x0, 0x8, 0x1, 0x9, 0x2, 0xA, 0x3, 0xB, 0x4, 0xC, 0x5, 0xD, 0x6, 0xE, 0x7, 0xF };
char FloppyDrive::nameBuf[MAX_PATH];
@ -60,7 +60,7 @@ FloppyDrive::~FloppyDrive()
delete[] disk[1];
}
bool FloppyDrive::LoadImage(const char * filename, uint8 driveNum/*= 0*/)
bool FloppyDrive::LoadImage(const char * filename, uint8_t driveNum/*= 0*/)
{
WriteLog("FLOPPY: Attempting to load image '%s' in drive #%u.\n", filename, driveNum);
@ -86,7 +86,7 @@ bool FloppyDrive::LoadImage(const char * filename, uint8 driveNum/*= 0*/)
fseek(fp, 0, SEEK_END);
diskSize[driveNum] = ftell(fp);
fseek(fp, 0, SEEK_SET);
disk[driveNum] = new uint8[diskSize[driveNum]];
disk[driveNum] = new uint8_t[diskSize[driveNum]];
fread(disk[driveNum], 1, diskSize[driveNum], fp);
fclose(fp);
@ -112,7 +112,7 @@ bool FloppyDrive::LoadImage(const char * filename, uint8 driveNum/*= 0*/)
return true;
}
bool FloppyDrive::SaveImage(uint8 driveNum/*= 0*/)
bool FloppyDrive::SaveImage(uint8_t driveNum/*= 0*/)
{
if (driveNum > 1)
{
@ -153,7 +153,7 @@ bool FloppyDrive::SaveImage(uint8 driveNum/*= 0*/)
return true;
}
bool FloppyDrive::SaveImageAs(const char * filename, uint8 driveNum/*= 0*/)
bool FloppyDrive::SaveImageAs(const char * filename, uint8_t driveNum/*= 0*/)
{
//WARNING: Buffer overflow possibility
#warning "Buffer overflow possible--!!! FIX !!!"
@ -161,12 +161,12 @@ bool FloppyDrive::SaveImageAs(const char * filename, uint8 driveNum/*= 0*/)
return SaveImage(driveNum);
}
void FloppyDrive::CreateBlankImage(uint8 driveNum/*= 0*/)
void FloppyDrive::CreateBlankImage(uint8_t driveNum/*= 0*/)
{
if (disk[driveNum] != NULL)
delete disk[driveNum];
disk[driveNum] = new uint8[143360];
disk[driveNum] = new uint8_t[143360];
diskSize[driveNum] = 143360;
memset(disk[driveNum], 0x00, 143360);
memset(nybblizedImage[driveNum], 0x00, 232960); // Set it to 0 instead of $FF for proper formatting...
@ -178,7 +178,7 @@ SpawnMessage("New blank image inserted in drive %u...", driveNum);
void FloppyDrive::SwapImages(void)
{
uint8 nybblizedImageTmp[232960];
uint8_t nybblizedImageTmp[232960];
char imageNameTmp[MAX_PATH];
memcpy(nybblizedImageTmp, nybblizedImage[0], 232960);
@ -189,29 +189,29 @@ void FloppyDrive::SwapImages(void)
memcpy(imageName[0], imageName[1], MAX_PATH);
memcpy(imageName[1], imageNameTmp, MAX_PATH);
uint8 * diskTmp = disk[0];
uint8_t * diskTmp = disk[0];
disk[0] = disk[1];
disk[1] = diskTmp;
uint32 diskSizeTmp = diskSize[0];
uint32_t diskSizeTmp = diskSize[0];
diskSize[0] = diskSize[1];
diskSize[1] = diskSizeTmp;
uint8 diskTypeTmp = diskType[0];
uint8_t diskTypeTmp = diskType[0];
diskType[0] = diskType[1];
diskType[1] = diskTypeTmp;
uint8 imageDirtyTmp = imageDirty[0];
uint8_t imageDirtyTmp = imageDirty[0];
imageDirty[0] = imageDirty[1];
imageDirty[1] = imageDirtyTmp;
uint8 writeProtectedTmp = writeProtected[0];
uint8_t writeProtectedTmp = writeProtected[0];
writeProtected[0] = writeProtected[1];
writeProtected[1] = writeProtectedTmp;
SpawnMessage("Drive 0: %s...", imageName[0]);
}
void FloppyDrive::DetectImageType(const char * filename, uint8 driveNum)
void FloppyDrive::DetectImageType(const char * filename, uint8_t driveNum)
{
diskType[driveNum] = DT_UNKNOWN;
@ -268,7 +268,7 @@ WriteLog("FLOPPY: Detected image type %s...\n", (diskType[driveNum] == DT_NYBBLE
"DOS 3.3 image" : (diskType[driveNum] == DT_PRODOS ? "ProDOS image" : "unknown"))));
}
void FloppyDrive::NybblizeImage(uint8 driveNum)
void FloppyDrive::NybblizeImage(uint8_t driveNum)
{
// Format of a sector is header (23) + nybbles (343) + footer (30) = 396
// (short by 20 bytes of 416 [413 if 48 byte header is one time only])
@ -277,7 +277,7 @@ void FloppyDrive::NybblizeImage(uint8 driveNum)
// hdr (21) + nybbles (343) + footer (48) = 412 bytes per sector
// (not incl. 64 byte track marker)
uint8 footer[48] = {
uint8_t footer[48] = {
0xDE, 0xAA, 0xEB, 0xFF, 0xEB, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
@ -285,7 +285,7 @@ void FloppyDrive::NybblizeImage(uint8 driveNum)
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
uint8 diskbyte[0x40] = {
uint8_t diskbyte[0x40] = {
0x96, 0x97, 0x9A, 0x9B, 0x9D, 0x9E, 0x9F, 0xA6,
0xA7, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF, 0xB2, 0xB3,
0xB4, 0xB5, 0xB6, 0xB7, 0xB9, 0xBA, 0xBB, 0xBC,
@ -295,15 +295,15 @@ void FloppyDrive::NybblizeImage(uint8 driveNum)
0xED, 0xEE, 0xEF, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6,
0xF7, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF };
uint8 * img = nybblizedImage[driveNum];
uint8_t * img = nybblizedImage[driveNum];
memset(img, 0xFF, 232960); // Doesn't matter if 00s or FFs...
for(uint8 trk=0; trk<35; trk++)
for(uint8_t trk=0; trk<35; trk++)
{
memset(img, 0xFF, 64); // Write gap 1, 64 bytes (self-sync)
img += 64;
for(uint8 sector=0; sector<16; sector++)
for(uint8_t sector=0; sector<16; sector++)
{
memcpy(img, header, 21); // Set up the sector header
@ -315,7 +315,7 @@ void FloppyDrive::NybblizeImage(uint8 driveNum)
img[10] = ((trk ^ sector ^ 0xFE) & 0x55) | 0xAA;
img += 21;
uint8 * bytes = disk[driveNum];
uint8_t * bytes = disk[driveNum];
if (diskType[driveNum] == DT_DOS33)
bytes += (doSector[sector] * 256) + (trk * 256 * 16);
@ -326,7 +326,7 @@ void FloppyDrive::NybblizeImage(uint8 driveNum)
// Convert the 256 8-bit bytes into 342 6-bit bytes.
for(uint16 i=0; i<0x56; i++)
for(uint16_t i=0; i<0x56; i++)
{
img[i] = ((bytes[(i + 0xAC) & 0xFF] & 0x01) << 7)
| ((bytes[(i + 0xAC) & 0xFF] & 0x02) << 5)
@ -345,12 +345,12 @@ void FloppyDrive::NybblizeImage(uint8 driveNum)
img[342] = 0x00;
for(uint16 i=342; i>0; i--)
for(uint16_t i=342; i>0; i--)
img[i] = img[i] ^ img[i - 1];
// Using a lookup table, convert the 6-bit bytes into disk bytes.
for(uint16 i=0; i<343; i++)
for(uint16_t i=0; i<343; i++)
//#define TEST_NYBBLIZATION
#ifdef TEST_NYBBLIZATION
{
@ -371,9 +371,9 @@ WriteLog("FL: i = %u, img[i] = %02X, diskbyte = %02X\n", i, img[i], diskbyte[img
}
}
void FloppyDrive::DenybblizeImage(uint8 driveNum)
void FloppyDrive::DenybblizeImage(uint8_t driveNum)
{
uint8 decodeNybble[0x80] = {
uint8_t decodeNybble[0x80] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04,
@ -399,19 +399,19 @@ void FloppyDrive::DenybblizeImage(uint8 driveNum)
return;
}
uint8 * srcImg = nybblizedImage[driveNum];
uint8 * dstImg = disk[driveNum];
uint8 buffer[345]; // 2 extra bytes for the unpack routine below...
uint8_t * srcImg = nybblizedImage[driveNum];
uint8_t * dstImg = disk[driveNum];
uint8_t buffer[345]; // 2 extra bytes for the unpack routine below...
for(uint8 trk=0; trk<35; trk++)
for(uint8_t trk=0; trk<35; trk++)
{
uint8 * trackBase = srcImg + (trk * 6656);
uint8_t * trackBase = srcImg + (trk * 6656);
for(uint8 sector=0; sector<16; sector++)
for(uint8_t sector=0; sector<16; sector++)
{
uint16 sectorStart = (uint16)-1;
uint16_t sectorStart = (uint16_t)-1;
for(uint16 i=0; i<6656; i++)
for(uint16_t i=0; i<6656; i++)
{
if (trackBase[i] == header[0]
&& trackBase[(i + 1) % 6656] == header[1]
@ -420,7 +420,7 @@ void FloppyDrive::DenybblizeImage(uint8 driveNum)
&& trackBase[(i + 4) % 6656] == header[4])
{
//Could also check the track # at +5,6...
uint8 foundSector = ((trackBase[(i + 7) % 6656] & 0x55) << 1)
uint8_t foundSector = ((trackBase[(i + 7) % 6656] & 0x55) << 1)
| (trackBase[(i + 8) % 6656] & 0x55);
if (foundSector == sector)
@ -432,7 +432,7 @@ void FloppyDrive::DenybblizeImage(uint8 driveNum)
}
// Sanity check...
if (sectorStart == (uint16)-1)
if (sectorStart == (uint16_t)-1)
{
WriteLog("FLOPPY: Failed to find sector %u (track %u) in nybble image!\n",
sector, trk);
@ -441,24 +441,24 @@ void FloppyDrive::DenybblizeImage(uint8 driveNum)
// Using a lookup table, convert the disk bytes into 6-bit bytes.
for(uint16 i=0; i<343; i++)
for(uint16_t i=0; i<343; i++)
buffer[i] = decodeNybble[trackBase[(sectorStart + i) % 6656] & 0x7F];
// XOR the data block with itself, offset by one byte.
for(uint16 i=1; i<342; i++)
for(uint16_t i=1; i<342; i++)
buffer[i] = buffer[i] ^ buffer[i - 1];
// Convert the 342 6-bit bytes into 256 8-bit bytes (at buffer + $56).
for(uint16 i=0; i<0x56; i++)
for(uint16_t i=0; i<0x56; i++)
{
buffer[0x056 + i] |= ((buffer[i] >> 3) & 0x01) | ((buffer[i] >> 1) & 0x02);
buffer[0x0AC + i] |= ((buffer[i] >> 5) & 0x01) | ((buffer[i] >> 3) & 0x02);
buffer[0x102 + i] |= ((buffer[i] >> 7) & 0x01) | ((buffer[i] >> 5) & 0x02);
}
uint8 * bytes = dstImg;
uint8_t * bytes = dstImg;
if (diskType[driveNum] == DT_DOS33)
bytes += (doSector[sector] * 256) + (trk * 256 * 16);
@ -472,7 +472,7 @@ void FloppyDrive::DenybblizeImage(uint8 driveNum)
}
}
const char * FloppyDrive::GetImageName(uint8 driveNum/*= 0*/)
const char * FloppyDrive::GetImageName(uint8_t driveNum/*= 0*/)
{
// Set up a zero-length string for return value
nameBuf[0] = 0;
@ -508,7 +508,7 @@ const char * FloppyDrive::GetImageName(uint8 driveNum/*= 0*/)
return nameBuf;
}
void FloppyDrive::EjectImage(uint8 driveNum/*= 0*/)
void FloppyDrive::EjectImage(uint8_t driveNum/*= 0*/)
{
// Probably want to save a dirty image... ;-)
SaveImage(driveNum);
@ -527,7 +527,7 @@ void FloppyDrive::EjectImage(uint8 driveNum/*= 0*/)
memset(nybblizedImage[driveNum], 0xFF, 232960); // Doesn't matter if 00s or FFs...
}
bool FloppyDrive::DriveIsEmpty(uint8 driveNum/*= 0*/)
bool FloppyDrive::DriveIsEmpty(uint8_t driveNum/*= 0*/)
{
if (driveNum > 1)
{
@ -539,7 +539,7 @@ bool FloppyDrive::DriveIsEmpty(uint8 driveNum/*= 0*/)
return (imageName[driveNum][0] == 0 ? true : false);
}
bool FloppyDrive::DiskIsWriteProtected(uint8 driveNum/*= 0*/)
bool FloppyDrive::DiskIsWriteProtected(uint8_t driveNum/*= 0*/)
{
if (driveNum > 1)
{
@ -550,7 +550,7 @@ bool FloppyDrive::DiskIsWriteProtected(uint8 driveNum/*= 0*/)
return writeProtected[driveNum];
}
void FloppyDrive::SetWriteProtect(bool state, uint8 driveNum/*= 0*/)
void FloppyDrive::SetWriteProtect(bool state, uint8_t driveNum/*= 0*/)
{
if (driveNum > 1)
{
@ -575,7 +575,7 @@ also more versatile and can represent the older 13-sector disks, many copy-prote
other unusual encodings.
*/
void FloppyDrive::ControlStepper(uint8 addr)
void FloppyDrive::ControlStepper(uint8_t addr)
{
// $C0E0 - 7
/*
@ -585,7 +585,7 @@ bit 0 is the "do something" bit.
*/
if (addr & 0x01)
{
uint8 newPhase = (addr >> 1) & 0x03;
uint8_t newPhase = (addr >> 1) & 0x03;
//WriteLog("*** Stepper change [%u]: track = %u, phase = %u, newPhase = %u\n", addr, track, phase, newPhase);
if (((phase + 1) & 0x03) == newPhase)
@ -606,19 +606,19 @@ SpawnMessage("Stepping to track %u...", track);
// return something if read mode...
}
void FloppyDrive::ControlMotor(uint8 addr)
void FloppyDrive::ControlMotor(uint8_t addr)
{
// $C0E8 - 9
motorOn = addr;
}
void FloppyDrive::DriveEnable(uint8 addr)
void FloppyDrive::DriveEnable(uint8_t addr)
{
// $C0EA - B
activeDrive = addr;
}
uint8 FloppyDrive::ReadWrite(void)
uint8_t FloppyDrive::ReadWrite(void)
{
SpawnMessage("%u:%sing %s track %u, sector %u...", activeDrive,
(ioMode == IO_MODE_READ ? "Read" : "Write"),
@ -644,20 +644,20 @@ Which we now do. :-)
return 0;//is this more like it?
}
uint8 diskByte = nybblizedImage[activeDrive][(track * 6656) + currentPos];
uint8_t diskByte = nybblizedImage[activeDrive][(track * 6656) + currentPos];
currentPos = (currentPos + 1) % 6656;
//WriteLog("FL: diskByte=%02X, currentPos=%u\n", diskByte, currentPos);
return diskByte;
}
uint8 FloppyDrive::GetLatchValue(void)
uint8_t FloppyDrive::GetLatchValue(void)
{
// $C0ED
return latchValue;
}
void FloppyDrive::SetLatchValue(uint8 value)
void FloppyDrive::SetLatchValue(uint8_t value)
{
// $C0ED
latchValue = value;

View File

@ -12,7 +12,7 @@
#else
#include <stdlib.h> // for MAX_PATH on MinGW/Darwin
#endif
#include "types.h"
#include <stdint.h>
enum { DT_UNKNOWN, DT_DOS33, DT_PRODOS, DT_NYBBLE };
@ -22,54 +22,54 @@ class FloppyDrive
FloppyDrive();
~FloppyDrive();
bool LoadImage(const char * filename, uint8 driveNum = 0);
bool SaveImage(uint8 driveNum = 0);
bool SaveImageAs(const char * filename, uint8 driveNum = 0);
void CreateBlankImage(uint8 driveNum = 0);
bool LoadImage(const char * filename, uint8_t driveNum = 0);
bool SaveImage(uint8_t driveNum = 0);
bool SaveImageAs(const char * filename, uint8_t driveNum = 0);
void CreateBlankImage(uint8_t driveNum = 0);
void SwapImages(void);
const char * GetImageName(uint8 driveNum = 0);
void EjectImage(uint8 driveNum = 0);
bool DriveIsEmpty(uint8 driveNum = 0);
bool DiskIsWriteProtected(uint8 driveNum = 0);
void SetWriteProtect(bool, uint8 driveNum = 0);
const char * GetImageName(uint8_t driveNum = 0);
void EjectImage(uint8_t driveNum = 0);
bool DriveIsEmpty(uint8_t driveNum = 0);
bool DiskIsWriteProtected(uint8_t driveNum = 0);
void SetWriteProtect(bool, uint8_t driveNum = 0);
// I/O functions ($C0Ex accesses)
void ControlStepper(uint8 addr);
void ControlMotor(uint8 addr);
void DriveEnable(uint8 addr);
uint8 ReadWrite(void);
uint8 GetLatchValue(void);
void SetLatchValue(uint8 value);
void ControlStepper(uint8_t addr);
void ControlMotor(uint8_t addr);
void DriveEnable(uint8_t addr);
uint8_t ReadWrite(void);
uint8_t GetLatchValue(void);
void SetLatchValue(uint8_t value);
void SetReadMode(void);
void SetWriteMode(void);
protected:
void DetectImageType(const char * filename, uint8 driveNum);
void NybblizeImage(uint8 driveNum);
void DenybblizeImage(uint8 driveNum);
void DetectImageType(const char * filename, uint8_t driveNum);
void NybblizeImage(uint8_t driveNum);
void DenybblizeImage(uint8_t driveNum);
private:
char imageName[2][MAX_PATH];
uint8 * disk[2];
uint32 diskSize[2];
uint8 diskType[2];
uint8_t * disk[2];
uint32_t diskSize[2];
uint8_t diskType[2];
bool imageDirty[2];
bool writeProtected[2];
uint8 motorOn;
uint8 activeDrive;
uint8 ioMode;
uint8 latchValue;
uint8 phase;
uint8 track;
uint8_t motorOn;
uint8_t activeDrive;
uint8_t ioMode;
uint8_t latchValue;
uint8_t phase;
uint8_t track;
uint8 nybblizedImage[2][232960];
uint32 currentPos;
uint8_t nybblizedImage[2][232960];
uint32_t currentPos;
// And here are some private class variables (to reduce function redundancy):
static uint8 header[21];
static uint8 doSector[16];
static uint8 poSector[16];
static uint8_t header[21];
static uint8_t doSector[16];
static uint8_t poSector[16];
static char nameBuf[MAX_PATH];
};

View File

@ -42,7 +42,7 @@ Some notes about this class:
- Button colors are hardwired (for plain text buttons)
*/
Button::Button(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/,
Button::Button(uint32_t x/*= 0*/, uint32_t y/*= 0*/, uint32_t w/*= 0*/, uint32_t h/*= 0*/,
Element * parent/*= NULL*/):
Element(x, y, w, h, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, parent),
activated(false), clicked(false), inside(false),
@ -52,7 +52,7 @@ Button::Button(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*
// Should we make a local button bitmap here?
}
Button::Button(uint32 x, uint32 y, uint32 w, uint32 h, SDL_Surface * upImg, Element * parent/*= NULL*/):
Button::Button(uint32_t x, uint32_t y, uint32_t w, uint32_t h, SDL_Surface * upImg, Element * parent/*= NULL*/):
Element(x, y, w, h, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, parent),
activated(false), clicked(false), inside(false),
buttonUp(upImg), buttonDown(NULL), buttonHover(NULL), surfacesAreLocal(false),
@ -61,7 +61,7 @@ Button::Button(uint32 x, uint32 y, uint32 w, uint32 h, SDL_Surface * upImg, Elem
// if (upImg == NULL)
// return;
//
// uint32 width = ((Bitmap *)upImg)->width, height = ((Bitmap *)upImg)->height;
// uint32_t width = ((Bitmap *)upImg)->width, height = ((Bitmap *)upImg)->height;
//
// buttonUp = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
// 32, MASK_R, MASK_G, MASK_B, MASK_A);
@ -70,7 +70,7 @@ Button::Button(uint32 x, uint32 y, uint32 w, uint32 h, SDL_Surface * upImg, Elem
// Should we make a local button bitmap here? NO--it's passed in!
}
Button::Button(uint32 x, uint32 y, SDL_Surface * bU, SDL_Surface * bH/*= NULL*/,
Button::Button(uint32_t x, uint32_t y, SDL_Surface * bU, SDL_Surface * bH/*= NULL*/,
SDL_Surface * bD/*= NULL*/, Element * parent/*= NULL*/):
Element(x, y, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, parent),
activated(false), clicked(false), inside(false),
@ -82,7 +82,7 @@ Button::Button(uint32 x, uint32 y, SDL_Surface * bU, SDL_Surface * bH/*= NULL*/,
extents.h = buttonUp->h;
}
Button::Button(uint32 x, uint32 y, uint32 w, uint32 h, std::string s, Element * parent/*= NULL*/):
Button::Button(uint32_t x, uint32_t y, uint32_t w, uint32_t h, std::string s, Element * parent/*= NULL*/):
Element(x, y, w, h, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0xFF, parent),
activated(false), clicked(false), inside(false),
buttonUp(NULL), buttonDown(NULL), buttonHover(NULL), surfacesAreLocal(true),
@ -91,7 +91,7 @@ Button::Button(uint32 x, uint32 y, uint32 w, uint32 h, std::string s, Element *
// Create the button surfaces here...
}
Button::Button(uint32 x, uint32 y, std::string s, Element * parent/*= NULL*/):
Button::Button(uint32_t x, uint32_t y, std::string s, Element * parent/*= NULL*/):
Element(x, y, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0xCF, 0x00, 0xFF, parent),
activated(false), clicked(false), inside(false),
buttonUp(NULL), buttonDown(NULL), buttonHover(NULL), surfacesAreLocal(true),
@ -110,7 +110,7 @@ Button::Button(uint32 x, uint32 y, std::string s, Element * parent/*= NULL*/):
MASK_R, MASK_G, MASK_B, MASK_A);
//bleh
uint8 r1, g1, b1, a1;
uint8_t r1, g1, b1, a1;
SDL_GetRGBA(fgColor, screen->format, &r1, &g1, &b1, &a1);
fgColor = SDL_MapRGBA(buttonUp->format, r1, g1, b1, a1);
SDL_GetRGBA(bgColor, screen->format, &r1, &g1, &b1, &a1);
@ -151,11 +151,11 @@ Button::~Button()
}
}
void Button::HandleKey(SDLKey key)
void Button::HandleKey(SDL_Scancode key)
{
}
void Button::HandleMouseMove(uint32 x, uint32 y)
void Button::HandleMouseMove(uint32_t x, uint32_t y)
{
if (!visible)
return;
@ -165,7 +165,7 @@ void Button::HandleMouseMove(uint32 x, uint32 y)
CheckStateAndRedrawIfNeeded();
}
void Button::HandleMouseButton(uint32 x, uint32 y, bool mouseDown)
void Button::HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown)
{
if (!visible)
return;

View File

@ -17,15 +17,15 @@
class Button: public Element
{
public:
Button(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = 0, Element * parent = NULL);
Button(uint32 x, uint32 y, uint32 w, uint32 h, SDL_Surface * upImg, Element * parent = NULL);
Button(uint32 x, uint32 y, SDL_Surface * bU, SDL_Surface * bH = NULL, SDL_Surface * bD = NULL, Element * parent = NULL);
Button(uint32 x, uint32 y, uint32 w, uint32 h, std::string s, Element * parent = NULL);
Button(uint32 x, uint32 y, std::string s, Element * parent = NULL);
Button(uint32_t x = 0, uint32_t y = 0, uint32_t w = 0, uint32_t h = 0, Element * parent = NULL);
Button(uint32_t x, uint32_t y, uint32_t w, uint32_t h, SDL_Surface * upImg, Element * parent = NULL);
Button(uint32_t x, uint32_t y, SDL_Surface * bU, SDL_Surface * bH = NULL, SDL_Surface * bD = NULL, Element * parent = NULL);
Button(uint32_t x, uint32_t y, uint32_t w, uint32_t h, std::string s, Element * parent = NULL);
Button(uint32_t x, uint32_t y, std::string s, Element * parent = NULL);
~Button();
virtual void HandleKey(SDLKey key);
virtual void HandleMouseMove(uint32 x, uint32 y);
virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown);
virtual void HandleKey(SDL_Scancode key);
virtual void HandleMouseMove(uint32_t x, uint32_t y);
virtual void HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown);
virtual void Draw(void);
virtual void Notify(Element *);
bool ButtonClicked(void);
@ -36,8 +36,8 @@ class Button: public Element
protected:
bool activated, clicked, inside;
SDL_Surface * buttonUp, * buttonDown, * buttonHover;
uint32 fgColorHL;
uint32 bgColorHL;
uint32_t fgColorHL;
uint32_t bgColorHL;
private:
bool surfacesAreLocal;

View File

@ -48,7 +48,7 @@ IDEA: Make a recently used file list when ejecting a disk, either here or in
// NOTE: FG/BG colors are hard-wired
//
DiskWindow::DiskWindow(FloppyDrive * fdp, uint32 x/*= 0*/, uint32 y/*= 0*/): Window(x, y, 200, 140, NULL), floppyDrive(fdp)
DiskWindow::DiskWindow(FloppyDrive * fdp, uint32_t x/*= 0*/, uint32_t y/*= 0*/): Window(x, y, 200, 140, NULL), floppyDrive(fdp)
{
//Could probably move this into the initializer list as well...
// closeButton = new Button(w - (cbWidth + 1), 1, cbUp, cbHover, cbDown, this);
@ -104,7 +104,7 @@ printf("Inside ~DiskWindow()...\n");
#endif
}
void DiskWindow::HandleKey(SDLKey key)
void DiskWindow::HandleKey(SDL_Scancode key)
{
Window::HandleKey(key);
#if 0
@ -116,34 +116,34 @@ void DiskWindow::HandleKey(SDLKey key)
}
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
list[i]->HandleKey(key);
#endif
}
void DiskWindow::HandleMouseMove(uint32 x, uint32 y)
void DiskWindow::HandleMouseMove(uint32_t x, uint32_t y)
{
Window::HandleMouseMove(x, y);
#if 0
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
// Make coords relative to upper right corner of this window...
list[i]->HandleMouseMove(x - extents.x, y - extents.y);
#endif
}
void DiskWindow::HandleMouseButton(uint32 x, uint32 y, bool mouseDown)
void DiskWindow::HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown)
{
Window::HandleMouseButton(x, y, mouseDown);
#if 0
#if 1
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
// Make coords relative to upper right corner of this window...
list[i]->HandleMouseButton(x - extents.x, y - extents.y, mouseDown);
#else //? This works in draggablewindow2...
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
{
// Make coords relative to upper right corner of this window...
list[i]->HandleMouseButton(x - extents.x, y - extents.y, mouseDown);
@ -164,7 +164,7 @@ void DiskWindow::Draw(void)
SDL_FillRect(screen, &extents, bgColor);
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
list[i]->Draw();
needToRefreshScreen = true;

View File

@ -15,11 +15,11 @@ class Text;
class DiskWindow: public Window
{
public:
DiskWindow(FloppyDrive * fdp, uint32 x = 0, uint32 y = 0);
DiskWindow(FloppyDrive * fdp, uint32_t x = 0, uint32_t y = 0);
~DiskWindow(); //Does this destructor need to be virtual? Not sure... Check!
virtual void HandleKey(SDLKey key);
virtual void HandleMouseMove(uint32 x, uint32 y);
virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown);
virtual void HandleKey(SDL_Scancode key);
virtual void HandleMouseMove(uint32_t x, uint32_t y);
virtual void HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown);
virtual void Draw(void);
virtual void Notify(Element *);
// void AddElement(Element * e);
@ -32,7 +32,7 @@ class DiskWindow: public Window
private:
FloppyDrive * floppyDrive;
// uint16 cbWidth, cbHeight;
// uint16_t cbWidth, cbHeight;
// SDL_Surface * cbUp, * cbDown, * cbHover;
Text * name1, * name2;
Button * load1, * load2, * eject1, * eject2,

View File

@ -41,7 +41,7 @@
// NOTE: FG/BG colors are hard-wired
//
DraggableWindow::DraggableWindow(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/,
DraggableWindow::DraggableWindow(uint32_t x/*= 0*/, uint32_t y/*= 0*/, uint32_t w/*= 0*/, uint32_t h/*= 0*/,
void (* f)(Element *)/*= NULL*/):
Element(x, y, w, h, 0x4D, 0xFF, 0x84, 0xFF, 0x1F, 0x84, 0x84, 0xFF), handler(f),
clicked(false),
@ -58,8 +58,8 @@ DraggableWindow::DraggableWindow(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0
list.push_back(closeButton);
#ifdef BACKGROUND_IMG_TEST
uint16 imgWidth = (floppyDiskImg[0] << 8) | floppyDiskImg[1];
uint16 imgHeight = (floppyDiskImg[2] << 8) | floppyDiskImg[3];
uint16_t imgWidth = (floppyDiskImg[0] << 8) | floppyDiskImg[1];
uint16_t imgHeight = (floppyDiskImg[2] << 8) | floppyDiskImg[3];
img = SDL_CreateRGBSurfaceFrom(&floppyDiskImg[4], imgWidth, imgHeight, 32, imgWidth * 4,
MASK_R, MASK_G, MASK_B, MASK_A);
#endif
@ -70,7 +70,7 @@ img = SDL_CreateRGBSurfaceFrom(&floppyDiskImg[4], imgWidth, imgHeight, 32, imgWi
DraggableWindow::~DraggableWindow()
{
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
if (list[i])
delete list[i];
@ -83,9 +83,9 @@ SDL_FreeSurface(img);
SDL_FreeSurface(cbHover);
}
void DraggableWindow::HandleKey(SDLKey key)
void DraggableWindow::HandleKey(SDL_Scancode key)
{
if (key == SDLK_ESCAPE)
if (key == SDL_SCANCODE_ESCAPE)
{
SDL_Event event;
event.type = SDL_USEREVENT, event.user.code = WINDOW_CLOSE;
@ -93,11 +93,11 @@ void DraggableWindow::HandleKey(SDLKey key)
}
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
list[i]->HandleKey(key);
}
void DraggableWindow::HandleMouseMove(uint32 x, uint32 y)
void DraggableWindow::HandleMouseMove(uint32_t x, uint32_t y)
{
if (clicked)
{
@ -112,12 +112,12 @@ void DraggableWindow::HandleMouseMove(uint32 x, uint32 y)
}
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
// Make coords relative to upper right corner of this window...
list[i]->HandleMouseMove(x - extents.x, y - extents.y);
}
void DraggableWindow::HandleMouseButton(uint32 x, uint32 y, bool mouseDown)
void DraggableWindow::HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown)
{
clicked = false;
@ -129,7 +129,7 @@ void DraggableWindow::HandleMouseButton(uint32 x, uint32 y, bool mouseDown)
}
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
{
// Make coords relative to upper right corner of this window...
list[i]->HandleMouseButton(x - extents.x, y - extents.y, mouseDown);
@ -148,7 +148,7 @@ void DraggableWindow::Draw(void)
SDL_FillRect(screen, &(*i), bgColor);
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
list[i]->Draw();
#else
// These are *always* top level and parentless, so no need to traverse up through
@ -162,7 +162,7 @@ void DraggableWindow::Draw(void)
SDL_BlitSurface(img, &src, screen, &dst);
extern char textChar2e[];
uint8 * fontAddr = (uint8 *)textChar2e + ((128 + 32) * 7 * 8);
uint8_t * fontAddr = (uint8_t *)textChar2e + ((128 + 32) * 7 * 8);
SetNewFont(Font(fontAddr, 7, 8));
DrawStringOpaque(screen, extents.x + 8, extents.y + 6, 0xFF000000, 0xFFFFFFFF, "Ultima III - Boo");
DrawStringOpaque(screen, extents.x + 8, extents.y + 14, 0xFF000000, 0xFFFFFFFF, "0123456789012345");
@ -174,7 +174,7 @@ void DraggableWindow::Draw(void)
#endif
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
list[i]->Draw();
#endif

View File

@ -15,12 +15,12 @@ class Button; // Forward declaration
class DraggableWindow: public Element
{
public:
DraggableWindow(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = 0,
DraggableWindow(uint32_t x = 0, uint32_t y = 0, uint32_t w = 0, uint32_t h = 0,
void (* f)(Element *) = NULL);
~DraggableWindow(); //Does this destructor need to be virtual? Not sure... Check!
virtual void HandleKey(SDLKey key);
virtual void HandleMouseMove(uint32 x, uint32 y);
virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown);
virtual void HandleKey(SDL_Scancode key);
virtual void HandleMouseMove(uint32_t x, uint32_t y);
virtual void HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown);
virtual void Draw(void);
virtual void Notify(Element *);
void AddElement(Element * e);
@ -33,7 +33,7 @@ class DraggableWindow: public Element
SDL_Rect offset;
private:
uint16 cbWidth, cbHeight;
uint16_t cbWidth, cbHeight;
SDL_Surface * cbUp, * cbDown, * cbHover;
SDL_Surface * img;
};

View File

@ -44,13 +44,13 @@
// NOTE: FG/BG colors are hard-wired
//
DraggableWindow2::DraggableWindow2(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/,
DraggableWindow2::DraggableWindow2(uint32_t x/*= 0*/, uint32_t y/*= 0*/, uint32_t w/*= 0*/, uint32_t h/*= 0*/,
void (* f)(Element *)/*= NULL*/):
Window(x, y, w, h, f), clicked(false)
{
#ifdef BACKGROUND_IMG_TEST
uint16 imgWidth = (floppyDiskImg[0] << 8) | floppyDiskImg[1];
uint16 imgHeight = (floppyDiskImg[2] << 8) | floppyDiskImg[3];
uint16_t imgWidth = (floppyDiskImg[0] << 8) | floppyDiskImg[1];
uint16_t imgHeight = (floppyDiskImg[2] << 8) | floppyDiskImg[3];
img = SDL_CreateRGBSurfaceFrom(&floppyDiskImg[4], imgWidth, imgHeight, 32, imgWidth * 4,
MASK_R, MASK_G, MASK_B, MASK_A);
// label = SDL_CreateRGBSurface(SDL_SWSURFACE, 16*7, 32, 32,
@ -59,7 +59,7 @@ DraggableWindow2::DraggableWindow2(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*=
//Prolly should draw this in the constructor...
//Now is! :-D
extern char textChar2e[];
uint8 * fontAddr = (uint8 *)textChar2e + ((128 + 32) * 7 * 8);
uint8_t * fontAddr = (uint8_t *)textChar2e + ((128 + 32) * 7 * 8);
SetNewFont(Font(fontAddr, 7, 8));
// DrawStringOpaque(label, 0, 0, 0xFF000000, 0xFFFFFFFF, "Ultima III - Boo");
// DrawStringOpaque(label, 0, 8, 0xFF000000, 0xFFFFFFFF, "0123456789012345");
@ -92,14 +92,14 @@ printf("Inside ~DraggableWindow2()...\n");
#endif
}
void DraggableWindow2::HandleMouseMove(uint32 x, uint32 y)
void DraggableWindow2::HandleMouseMove(uint32_t x, uint32_t y)
{
if (clicked)
{
//Need to check whether or not we've run into the extents of the screen... !!! FIX !!!
//[DONE]
int32 newX = x - offset.x;
int32 newY = y - offset.y;
int32_t newX = x - offset.x;
int32_t newY = y - offset.y;
SDL_Rect clip = GetParentRect();
if (newX < clip.x)
@ -127,13 +127,13 @@ void DraggableWindow2::HandleMouseMove(uint32 x, uint32 y)
}
// Handle the items this window contains...
// for(uint32 i=0; i<list.size(); i++)
// for(uint32_t i=0; i<list.size(); i++)
// Make coords relative to upper right corner of this window...
// list[i]->HandleMouseMove(x - extents.x, y - extents.y);
Window::HandleMouseMove(x, y);
}
void DraggableWindow2::HandleMouseButton(uint32 x, uint32 y, bool mouseDown)
void DraggableWindow2::HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown)
{
clicked = false;
@ -145,7 +145,7 @@ void DraggableWindow2::HandleMouseButton(uint32 x, uint32 y, bool mouseDown)
}
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
{
// Make coords relative to upper right corner of this window...
list[i]->HandleMouseButton(x - extents.x, y - extents.y, mouseDown);
@ -177,7 +177,7 @@ void DraggableWindow2::Draw(void)
// SDL_BlitSurface(label, &src, screen, &dst);
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
list[i]->Draw();
#else
// These are *always* top level and parentless, so no need to traverse up through
@ -192,7 +192,7 @@ void DraggableWindow2::Draw(void)
//WTF? Unnecessary!
// extern char textChar2e[];
// uint8 * fontAddr = (uint8 *)textChar2e + ((128 + 32) * 7 * 8);
// uint8_t * fontAddr = (uint8_t *)textChar2e + ((128 + 32) * 7 * 8);
// SetNewFont(Font(fontAddr, 7, 8));
// DrawStringOpaque(screen, extents.x + 8, extents.y + 6, 0xFF000000, 0xFFFFFFFF, "Ultima III - Boo");
// DrawStringOpaque(screen, extents.x + 8, extents.y + 14, 0xFF000000, 0xFFFFFFFF, "0123456789012345");
@ -204,7 +204,7 @@ void DraggableWindow2::Draw(void)
#endif
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
list[i]->Draw();
#endif

View File

@ -13,11 +13,11 @@
class DraggableWindow2: public Window
{
public:
DraggableWindow2(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = 0,
DraggableWindow2(uint32_t x = 0, uint32_t y = 0, uint32_t w = 0, uint32_t h = 0,
void (* f)(Element *) = NULL);
~DraggableWindow2(); // Does this destructor need to be virtual? No, it doesn't!
virtual void HandleMouseMove(uint32 x, uint32 y);
virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown);
virtual void HandleMouseMove(uint32_t x, uint32_t y);
virtual void HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown);
virtual void Draw(void);
protected:

View File

@ -40,7 +40,7 @@
SDL_Surface * Element::screen = NULL;
bool Element::needToRefreshScreen = false;
Element::Element(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/,
Element::Element(uint32_t x/*= 0*/, uint32_t y/*= 0*/, uint32_t w/*= 0*/, uint32_t h/*= 0*/,
Element * parentElement/*= NULL*/): parent(parentElement), backstore(NULL), visible(true)
{
extents.x = x,
@ -50,9 +50,9 @@ Element::Element(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*=
coverList.push_back(extents);
}
Element::Element(uint32 x, uint32 y, uint32 w, uint32 h,
uint8 fgR/*= 0xFF*/, uint8 fgG/*= 0xFF*/, uint8 fgB/*= 0xFF*/, uint8 fgA/*= 0xFF*/,
uint8 bgR/*= 0x00*/, uint8 bgG/*= 0x00*/, uint8 bgB/*= 0x00*/, uint8 bgA/*= 0xFF*/,
Element::Element(uint32_t x, uint32_t y, uint32_t w, uint32_t h,
uint8_t fgR/*= 0xFF*/, uint8_t fgG/*= 0xFF*/, uint8_t fgB/*= 0xFF*/, uint8_t fgA/*= 0xFF*/,
uint8_t bgR/*= 0x00*/, uint8_t bgG/*= 0x00*/, uint8_t bgB/*= 0x00*/, uint8_t bgA/*= 0xFF*/,
Element * parentElement/*= NULL*/): parent(parentElement), backstore(NULL), visible(true)
{
extents.x = x,
@ -63,9 +63,9 @@ Element::Element(uint32 x, uint32 y, uint32 w, uint32 h,
#if 0
// This *should* allow us to store our colors in an endian safe way... :-/
uint8 * c = (uint8 *)&fgColor;
uint8_t * c = (uint8_t *)&fgColor;
c[0] = fgR, c[1] = fgG, c[2] = fgB, c[3] = fgA;
c = (uint8 *)&bgColor;
c = (uint8_t *)&bgColor;
c[0] = bgR, c[1] = bgG, c[2] = bgB, c[3] = bgA;
#else
fgColor = SDL_MapRGBA(screen->format, fgR, fgG, fgB, fgA);
@ -83,10 +83,10 @@ Element::~Element()
}
}
bool Element::Inside(uint32 x, uint32 y)
bool Element::Inside(uint32_t x, uint32_t y)
{
return (x >= (uint32)extents.x && x < (uint32)(extents.x + extents.w)
&& y >= (uint32)extents.y && y < (uint32)(extents.y + extents.h) ? true : false);
return (x >= (uint32_t)extents.x && x < (uint32_t)(extents.x + extents.w)
&& y >= (uint32_t)extents.y && y < (uint32_t)(extents.y + extents.h) ? true : false);
}
//Badly named--!!! FIX !!! [DONE]
@ -255,10 +255,10 @@ Steps:
//This approach won't work--if no rect1 then we're screwed! [FIXED]
//Now *that* will work...
SDL_Rect current = *i;
uint32 bottomOfRect1 = current.y;
// uint32 rightOfRect2 = current.x;
// uint32 leftOfRect3 = current.x + current.w;
uint32 topOfRect4 = current.y + current.h;
uint32_t bottomOfRect1 = current.y;
// uint32_t rightOfRect2 = current.x;
// uint32_t leftOfRect3 = current.x + current.w;
uint32_t topOfRect4 = current.y + current.h;
// Rectangle #1 (top)
if (r.y > current.y) // Simple rectangle degeneracy test...

View File

@ -12,26 +12,26 @@
enum { WINDOW_CLOSE, MENU_ITEM_CHOSEN, SCREEN_REFRESH_NEEDED };
#include <SDL.h>
#include <SDL2/SDL.h>
#include <list>
#include "types.h"
#include <stdint.h>
class Element
{
public:
Element(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = 0,
Element(uint32_t x = 0, uint32_t y = 0, uint32_t w = 0, uint32_t h = 0,
Element * parentElement = NULL);
Element(uint32 x, uint32 y, uint32 w, uint32 h,
uint8 fgR = 0xFF, uint8 fgG = 0xFF, uint8 fgB = 0xFF, uint8 fgA = 0xFF,
uint8 bgR = 0x00, uint8 bgG = 0x00, uint8 bgB = 0x00, uint8 bgA = 0xFF,
Element(uint32_t x, uint32_t y, uint32_t w, uint32_t h,
uint8_t fgR = 0xFF, uint8_t fgG = 0xFF, uint8_t fgB = 0xFF, uint8_t fgA = 0xFF,
uint8_t bgR = 0x00, uint8_t bgG = 0x00, uint8_t bgB = 0x00, uint8_t bgA = 0xFF,
Element * parentElement = NULL);
virtual ~Element(); // Destructor cannot be pure virtual...
virtual void HandleKey(SDLKey key) = 0; // These are "pure" virtual functions...
virtual void HandleMouseMove(uint32 x, uint32 y) = 0;
virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown) = 0;
virtual void HandleKey(SDL_Scancode key) = 0; // These are "pure" virtual functions...
virtual void HandleMouseMove(uint32_t x, uint32_t y) = 0;
virtual void HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown) = 0;
virtual void Draw(void) = 0;
virtual void Notify(Element *) = 0;
bool Inside(uint32 x, uint32 y);
bool Inside(uint32_t x, uint32_t y);
//Badly named, though we may code something that does this...
// SDL_Rect GetParentCorner(void);
SDL_Rect GetScreenCoords(void);
@ -54,10 +54,10 @@ class Element
protected:
SDL_Rect extents;
uint32 state;
uint32_t state;
Element * parent;
uint32 fgColor;
uint32 bgColor;
uint32_t fgColor;
uint32_t bgColor;
SDL_Surface * backstore;
std::list<SDL_Rect> coverList;
bool visible;

View File

@ -34,7 +34,7 @@
// This works, but the colors are rendered incorrectly. Also, it seems that there's
// fullscreen blitting still going on--dragging the disk is fast at first but then
// gets painfully slow. Not sure what's going on there.
#define USE_NEW_MAINBUFFERING
//#define USE_NEW_MAINBUFFERING
//#ifdef DEBUG_MAIN_LOOP
#include "log.h"
@ -64,6 +64,7 @@ GUI::GUI(SDL_Surface * surface): menuItem(new MenuItems())
windowList.push_back(new DiskWindow(&floppyDrive, 240, 20));
}
GUI::~GUI()
{
// Clean up menuItem, if any
@ -78,17 +79,20 @@ GUI::~GUI()
delete *i;
}
void GUI::AddMenuTitle(const char * title)
{
menuItem->title = title;
menuItem->item.clear();
}
void GUI::AddMenuItem(const char * item, Element * (* a)(void)/*= NULL*/, SDLKey k/*= SDLK_UNKNOWN*/)
void GUI::AddMenuItem(const char * item, Element * (* a)(void)/*= NULL*/, SDL_Scancode k/*= SDLK_UNKNOWN*/)
{
menuItem->item.push_back(NameAction(item, a, k));
}
void GUI::CommitItemsToMenu(void)
{
//We could just do a simple check here to see if more than one item is in the list,
@ -104,6 +108,7 @@ void GUI::CommitItemsToMenu(void)
((Menu *)(*windowList.begin()))->Add(*menuItem);
}
void GUI::Run(void)
{
exitGUI = false;
@ -111,7 +116,8 @@ void GUI::Run(void)
SDL_Event event;
std::list<Element *>::iterator i;
SDL_EnableKeyRepeat(150, 75);
// Not sure what replaces this in SDL2...
// SDL_EnableKeyRepeat(150, 75);
// Also: Need to pick up backbuffer (for those windows that have them)
// BEFORE drawing...
@ -194,6 +200,8 @@ WriteLog(" -- SDL_USEREVENT\n");
FlipMainScreen();
#endif
}
//Not sure what to do here for SDL2...
#if 0
else if (event.type == SDL_ACTIVEEVENT)
{
//Need to do a screen refresh here...
@ -203,9 +211,10 @@ WriteLog(" -- SDL_USEREVENT\n");
#ifndef USE_NEW_MAINBUFFERING
RenderScreenBuffer();
#else
FlipMainScreen();
FlipMainScreen();
#endif
}
#endif
else if (event.type == SDL_KEYDOWN)
{
#ifdef DEBUG_MAIN_LOOP
@ -218,7 +227,7 @@ WriteLog(" -- SDL_KEYDOWN\n");
//Probably should only give this to the top level window...
// for(i=windowList.begin(); i!=windowList.end(); i++)
// (*i)->HandleKey(event.key.keysym.sym);
windowList.back()->HandleKey(event.key.keysym.sym);
windowList.back()->HandleKey(event.key.keysym.scancode);
}
else if (event.type == SDL_MOUSEMOTION)
{
@ -459,11 +468,14 @@ WriteLog("Screen refresh called!\n");
//SDL_Delay(10);
}
SDL_EnableKeyRepeat(0, 0);
// Not sure what to do for this in SDL 2...
// SDL_EnableKeyRepeat(0, 0);
// return false;
}
void GUI::Stop(void)
{
exitGUI = true;
}

View File

@ -7,20 +7,21 @@
#ifndef __GUI_H__
#define __GUI_H__
#include <SDL.h>
#include <SDL2/SDL.h>
#include <list>
class Menu; // Now *this* should work, since we've got pointers...
class MenuItems;
class Element;
class GUI
{
public:
GUI(SDL_Surface *);
~GUI();
void AddMenuTitle(const char *);
void AddMenuItem(const char *, Element * (* a)(void) = NULL, SDLKey k = SDLK_UNKNOWN);
void AddMenuItem(const char *, Element * (* a)(void) = NULL, SDL_Scancode k = SDL_SCANCODE_UNKNOWN);
void CommitItemsToMenu(void);
void Run(void);
void Stop(void);
@ -35,3 +36,4 @@ class GUI
};
#endif // __GUI_H__

View File

@ -7,7 +7,7 @@
#ifndef __GUIELEMENTS_H__
#define __GUIELEMENTS_H__
#include "types.h"
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
@ -28,10 +28,10 @@ struct Bitmap {
//NOTE: 32-bit pixels are in the format of ABGR...
// This may not be endian safe... Mac users?
//Using the GIMP C style bitmap is portable in that it's specified in bytes
//but we can cast it in uint32s and thus it will display correctly regardless of
//but we can cast it in uint32_ts and thus it will display correctly regardless of
//the underlying endianess. At least, in theory. ;-)
uint32 mousePic[] = {
uint32_t mousePic[] = {
6, 8,
0xFF00FF00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000, // +
@ -63,7 +63,7 @@ uint32 mousePic[] = {
*/
};
uint32 upArrowBox[] = {
uint32_t upArrowBox[] = {
8, 8,
0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649, // ++++++++
@ -76,7 +76,7 @@ uint32 upArrowBox[] = {
0xFFBD8400,0xFFBD8400,0xFFBD8400,0xFFBD8400,0xFFBD8400,0xFFBD8400,0xFFBD8400,0xFFBD8400 // ........
};
uint32 downArrowBox[] = {
uint32_t downArrowBox[] = {
8, 8,
0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649, // ++++++++
@ -134,7 +134,7 @@ static const struct {
"\0",
};
uint32 pushButtonUp[] = {
uint32_t pushButtonUp[] = {
8, 8,
0x00000000, 0xFF1B1B1B, 0xFF545477, 0xFF525292, 0xFF474787, 0xFF363659, 0xFF0F0F0F, 0x00000000,
@ -147,7 +147,7 @@ uint32 pushButtonUp[] = {
0x00000000, 0xFF0D0D0D, 0xFF343456, 0xFF3D3D80, 0xFF3D3D82, 0xFF333358, 0xFF0D0D0D, 0x00000000
};
uint8 pbuAlpha[] = {
uint8_t pbuAlpha[] = {
0xFF, 0xE4, 0xA0, 0x99, 0xA4, 0xBE, 0xF0, 0xFF,
0xE3, 0x85, 0x00, 0x00, 0x00, 0x00, 0xAF, 0xF0,
0x9F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0,
@ -204,7 +204,7 @@ static const struct {
"yy\343xxx\303xxx\177sss\35\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0",
};
uint32 pushButtonDown[] = {
uint32_t pushButtonDown[] = {
8, 8,
0x00000000, 0xFF1B1B1B, 0xFF8B8B90, 0xFF8C8CAF, 0xFF767699, 0xFF56565B, 0xFF0F0F0F, 0x00000000,
@ -217,7 +217,7 @@ uint32 pushButtonDown[] = {
0x00000000, 0xFF101010, 0xFF4E4E55, 0xFF5B5B83, 0xFF5B5B84, 0xFF4D4D54, 0xFF101010, 0x00000000
};
uint8 pbdAlpha[] = {
uint8_t pbdAlpha[] = {
0xFF, 0xE4, 0x72, 0x68, 0x7E, 0xA7, 0xF0, 0xFF,
0xE4, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x93, 0xF0,
0x71, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB2,
@ -228,7 +228,7 @@ uint8 pbdAlpha[] = {
0xFF, 0xEF, 0xAE, 0x98, 0x97, 0xAF, 0xEF, 0xFF
};
uint32 slideSwitchUp[] = {
uint32_t slideSwitchUp[] = {
8, 16,
//0C7F -> 000011 00011 11111 -> 0000 1100 0001 1000 1111 1111 -> 0C 18 FF
@ -250,7 +250,7 @@ uint32 slideSwitchUp[] = {
0xFFBD8400,0xFFBD8400,0xFFBD8400,0xFFBD8400,0xFFBD8400,0xFFBD8400,0xFFBD8400,0xFFBD8400 // ........
};
uint32 slideSwitchDown[] = {
uint32_t slideSwitchDown[] = {
8, 16,
0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649,0xFFF7D649, // ++++++++
@ -274,7 +274,7 @@ uint32 slideSwitchDown[] = {
#define CLOSEBOX_WIDTH 15
#define CLOSEBOX_HEIGHT 15
uint32 closeBox[] = {
uint32_t closeBox[] = {
15, 15,
0x00000000, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0x00000000,
@ -294,7 +294,7 @@ uint32 closeBox[] = {
0x00000000, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0x00000000
};
uint32 closeBoxHover[] = {
uint32_t closeBoxHover[] = {
15, 15,
0x00000000, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0x00000000,
@ -314,7 +314,7 @@ uint32 closeBoxHover[] = {
0x00000000, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0x00000000
};
uint32 closeBoxDown[] = {
uint32_t closeBoxDown[] = {
15, 15,
0x00000000, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0xFF3838ED, 0x00000000,

File diff suppressed because it is too large Load Diff

View File

@ -9,16 +9,16 @@
#include <SDL.h>
#include <stdarg.h>
#include "types.h"
#include <stdint.h>
// Useful structs
struct Font
{
Font(uint8 * d = NULL, uint32 w = 0, uint32 h = 0): data(d), width(w), height(h) {}
Font(uint8_t * d = NULL, uint32_t w = 0, uint32_t h = 0): data(d), width(w), height(h) {}
uint8 * data;
uint32 width, height;
uint8_t * data;
uint32_t width, height;
};
// Okay, this is ugly but works and I can't think of any better way to handle this. So what
@ -40,13 +40,13 @@ struct Font
// Global functions
//void SetFont(uint8 *, uint32, uint32);
//void SetFont(uint8_t *, uint32_t, uint32_t);
void SetNewFont(Font);
void RestoreOldFont(void);
uint32 GetFontWidth(void);
uint32 GetFontHeight(void);
void DrawStringTrans(SDL_Surface * screen, uint32 x, uint32 y, uint32 color, const char * text, ...);
void DrawStringOpaque(SDL_Surface * screen, uint32 x, uint32 y, uint32 fg, uint32 bg, const char * text, ...);
uint32_t GetFontWidth(void);
uint32_t GetFontHeight(void);
void DrawStringTrans(SDL_Surface * screen, uint32_t x, uint32_t y, uint32_t color, const char * text, ...);
void DrawStringOpaque(SDL_Surface * screen, uint32_t x, uint32_t y, uint32_t fg, uint32_t bg, const char * text, ...);
//Not sure these belong here, but there you go...
bool RectanglesIntersect(SDL_Rect r1, SDL_Rect r2);
@ -54,9 +54,9 @@ bool RectangleFirstInsideSecond(SDL_Rect r1, SDL_Rect r2);
// GUI bitmaps (exported)
extern uint8 closeBox[];
extern uint8 closeBoxDown[];
extern uint8 closeBoxHover[];
extern uint8 floppyDiskImg[];
extern uint8_t closeBox[];
extern uint8_t closeBoxDown[];
extern uint8_t closeBoxHover[];
extern uint8_t floppyDiskImg[];
#endif // __GUIMISC_H__

View File

@ -41,21 +41,21 @@ MenuItems::MenuItems(): charLength(0), popupBackstore(NULL)
{
}
bool MenuItems::Inside(uint32 x, uint32 y)
bool MenuItems::Inside(uint32_t x, uint32_t y)
{
return (x >= (uint32)extents.x && x < (uint32)(extents.x + extents.w)
&& y >= (uint32)extents.y && y < (uint32)(extents.y + extents.h) ? true : false);
return (x >= (uint32_t)extents.x && x < (uint32_t)(extents.x + extents.w)
&& y >= (uint32_t)extents.y && y < (uint32_t)(extents.y + extents.h) ? true : false);
}
//
// Menu class implementation
//
Menu::Menu(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/,
uint8 fgcR/*= 0x00*/, uint8 fgcG/*= 0x00*/, uint8 fgcB/*= 0x7F*/, uint8 fgcA/*= 0xFF*/,
uint8 bgcR/*= 0x3F*/, uint8 bgcG/*= 0x3F*/, uint8 bgcB/*= 0xFF*/, uint8 bgcA/*= 0xFF*/,
uint8 fgchR/*= 0x3F*/, uint8 fgchG/*= 0x3F*/, uint8 fgchB/*= 0xFF*/, uint8 fgchA/*= 0xFF*/,
uint8 bgchR/*= 0x87*/, uint8 bgchG/*= 0x87*/, uint8 bgchB/*= 0xFF*/, uint8 bgchA/*= 0xFF*/):
Menu::Menu(uint32_t x/*= 0*/, uint32_t y/*= 0*/, uint32_t w/*= 0*/, uint32_t h/*= 0*/,
uint8_t fgcR/*= 0x00*/, uint8_t fgcG/*= 0x00*/, uint8_t fgcB/*= 0x7F*/, uint8_t fgcA/*= 0xFF*/,
uint8_t bgcR/*= 0x3F*/, uint8_t bgcG/*= 0x3F*/, uint8_t bgcB/*= 0xFF*/, uint8_t bgcA/*= 0xFF*/,
uint8_t fgchR/*= 0x3F*/, uint8_t fgchG/*= 0x3F*/, uint8_t fgchB/*= 0xFF*/, uint8_t fgchA/*= 0xFF*/,
uint8_t bgchR/*= 0x87*/, uint8_t bgchG/*= 0x87*/, uint8_t bgchB/*= 0xFF*/, uint8_t bgchA/*= 0xFF*/):
Element(x, y, w, GetFontHeight(), fgcR, fgcG, fgcB, fgcA, bgcR, bgcG, bgcB, bgcA),
activated(false), clicked(false),
inside(0), insidePopup(0), menuChosen(-1), menuItemChosen(-1),
@ -65,9 +65,9 @@ Menu::Menu(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/,
#if 0
// This *should* allow us to store our colors in an endian safe way... :-/
// Nope. Only on SW surfaces. With HW, all bets are off. :-(
uint8 * c = (uint8 *)&fgColorHL;
uint8_t * c = (uint8_t *)&fgColorHL;
c[0] = fgchR, c[1] = fgchG, c[2] = fgchB, c[3] = fgchA;
c = (uint8 *)&bgColorHL;
c = (uint8_t *)&bgColorHL;
c[0] = bgchR, c[1] = bgchG, c[2] = bgchB, c[3] = bgchA;
#else
fgColorHL = SDL_MapRGBA(screen->format, fgchR, fgchG, fgchB, fgchA);
@ -77,20 +77,20 @@ Menu::Menu(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/,
Menu::~Menu()
{
for(uint32 i=0; i<itemList.size(); i++)
for(uint32_t i=0; i<itemList.size(); i++)
{
if (itemList[i].popupBackstore)
SDL_FreeSurface(itemList[i].popupBackstore);
}
}
void Menu::HandleKey(SDLKey key)
void Menu::HandleKey(SDL_Scancode key)
{
SaveStateVariables();
for(uint32 i=0; i<itemList.size(); i++)
for(uint32_t i=0; i<itemList.size(); i++)
{
for(uint32 j=0; j<itemList[i].item.size(); j++)
for(uint32_t j=0; j<itemList[i].item.size(); j++)
{
if (itemList[i].item[j].hotKey == key)
{
@ -109,7 +109,7 @@ void Menu::HandleKey(SDLKey key)
CheckStateAndRedrawIfNeeded();
}
void Menu::HandleMouseMove(uint32 x, uint32 y)
void Menu::HandleMouseMove(uint32_t x, uint32_t y)
{
#ifdef DEBUG_MENU
WriteLog("--> Inside Menu::HandleMouseMove()...\n");
@ -121,11 +121,11 @@ WriteLog("--> Inside Menu::HandleMouseMove()...\n");
if (Inside(x, y))
{
// Find out *where* we are inside the menu bar
uint32 xpos = extents.x;
uint32_t xpos = extents.x;
for(uint32 i=0; i<itemList.size(); i++)
for(uint32_t i=0; i<itemList.size(); i++)
{
uint32 width = (itemList[i].title.length() + 2) * GetFontWidth();
uint32_t width = (itemList[i].title.length() + 2) * GetFontWidth();
if (x >= xpos && x < xpos + width)
{
@ -152,7 +152,7 @@ WriteLog("--> Inside Menu::HandleMouseMove()...\n");
CheckStateAndRedrawIfNeeded();
}
void Menu::HandleMouseButton(uint32 x, uint32 y, bool mouseDown)
void Menu::HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown)
{
#ifdef DEBUG_MENU
WriteLog("--> Inside Menu::HandleMouseButton()...\n");
@ -201,13 +201,13 @@ WriteLog("--> Inside Menu::Draw()...\n");
#endif
char separator[] = "--------------------------------------------------------";
uint32 xpos = extents.x;
uint32_t xpos = extents.x;
for(uint32 i=0; i<itemList.size(); i++)
for(uint32_t i=0; i<itemList.size(); i++)
{
uint32 color1 = fgColor, color2 = bgColor;
uint32_t color1 = fgColor, color2 = bgColor;
if (inside == (i + 1) || (menuChosen != -1 && (uint32)menuChosen == i))
if (inside == (i + 1) || (menuChosen != -1 && (uint32_t)menuChosen == i))
color1 = fgColorHL, color2 = bgColorHL;
DrawStringOpaque(screen, xpos, extents.y, color1, color2,
@ -234,11 +234,11 @@ WriteLog("--> Attempting to prime pubs...\n pubs x/y/w/h = %u/%u/%u/%u\n s
// Draw sub menu (but only if active)
if (clicked)
{
uint32 ypos = extents.y + GetFontHeight() + 1;
uint32_t ypos = extents.y + GetFontHeight() + 1;
for(uint32 i=0; i<itemList[menuChosen].item.size(); i++)
for(uint32_t i=0; i<itemList[menuChosen].item.size(); i++)
{
uint32 color1 = fgColor, color2 = bgColor;
uint32_t color1 = fgColor, color2 = bgColor;
if (insidePopup == i + 1)
color1 = fgColorHL, color2 = bgColorHL, menuItemChosen = i;
@ -274,7 +274,7 @@ void Menu::Notify(Element *)
void Menu::Add(MenuItems mi)
{
for(uint32 i=0; i<mi.item.size(); i++)
for(uint32_t i=0; i<mi.item.size(); i++)
if (mi.item[i].name.length() > mi.charLength)
mi.charLength = mi.item[i].name.length();

View File

@ -15,9 +15,9 @@ struct NameAction
{
std::string name;
Element * (* action)(void);
SDLKey hotKey;
SDL_Scancode hotKey;
NameAction(std::string n, Element * (* a)(void) = NULL, SDLKey k = SDLK_UNKNOWN): name(n),
NameAction(std::string n, Element * (* a)(void) = NULL, SDL_Scancode k = SDL_SCANCODE_UNKNOWN): name(n),
action(a), hotKey(k) {}
};
@ -25,11 +25,11 @@ class MenuItems
{
public:
MenuItems();
bool Inside(uint32 x, uint32 y);
bool Inside(uint32_t x, uint32_t y);
std::string title;
std::vector<NameAction> item;
uint32 charLength;
uint32_t charLength;
SDL_Rect extents;
SDL_Surface * popupBackstore;
};
@ -37,15 +37,15 @@ class MenuItems
class Menu: public Element
{
public:
Menu(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = 0,
uint8 fgcR = 0x00, uint8 fgcG = 0x00, uint8 fgcB = 0x7F, uint8 fgcA = 0xFF,
uint8 bgcR = 0x3F, uint8 bgcG = 0x3F, uint8 bgcB = 0xFF, uint8 bgcA = 0xFF,
uint8 fgchR = 0x3F, uint8 fgchG = 0x3F, uint8 fgchB = 0xFF, uint8 fgchA = 0xFF,
uint8 bgchR = 0x87, uint8 bgchG = 0x87, uint8 bgchB = 0xFF, uint8 bgchA = 0xFF);
Menu(uint32_t x = 0, uint32_t y = 0, uint32_t w = 0, uint32_t h = 0,
uint8_t fgcR = 0x00, uint8_t fgcG = 0x00, uint8_t fgcB = 0x7F, uint8_t fgcA = 0xFF,
uint8_t bgcR = 0x3F, uint8_t bgcG = 0x3F, uint8_t bgcB = 0xFF, uint8_t bgcA = 0xFF,
uint8_t fgchR = 0x3F, uint8_t fgchG = 0x3F, uint8_t fgchB = 0xFF, uint8_t fgchA = 0xFF,
uint8_t bgchR = 0x87, uint8_t bgchG = 0x87, uint8_t bgchB = 0xFF, uint8_t bgchA = 0xFF);
~Menu();
virtual void HandleKey(SDLKey key);
virtual void HandleMouseMove(uint32 x, uint32 y);
virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown);
virtual void HandleKey(SDL_Scancode key);
virtual void HandleMouseMove(uint32_t x, uint32_t y);
virtual void HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown);
virtual void Draw(void);
virtual void Notify(Element *);
void Add(MenuItems mi);
@ -54,14 +54,14 @@ class Menu: public Element
protected:
bool activated, clicked;
uint32 inside, insidePopup;
uint32_t inside, insidePopup;
int menuChosen, menuItemChosen;
uint32 fgColorHL, bgColorHL;
uint32_t fgColorHL, bgColorHL;
private:
std::vector<MenuItems> itemList;
bool activatedSave, clickedSave;
uint32 insideSave, insidePopupSave;
uint32_t insideSave, insidePopupSave;
int menuChosenSave, menuItemChosenSave;
};

View File

@ -8,13 +8,13 @@
#include "guimisc.h"
Text::Text(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/, Element * parent/*= NULL*/):
Text::Text(uint32_t x/*= 0*/, uint32_t y/*= 0*/, uint32_t w/*= 0*/, uint32_t h/*= 0*/, Element * parent/*= NULL*/):
Element(x, y, w, h, parent)
{
fgColor = 0xFF8484FF, bgColor = 0xFF84FF4D;
}
Text::Text(uint32 x, uint32 y, std::string s, uint32 fg/*= 0xFF8484FF*/, uint32 bg/*= 0xFF84FF4D*/, Element * parent/*= NULL*/):
Text::Text(uint32_t x, uint32_t y, std::string s, uint32_t fg/*= 0xFF8484FF*/, uint32_t bg/*= 0xFF84FF4D*/, Element * parent/*= NULL*/):
Element(x, y, 0, 0, parent), text(s)
{
fgColor = fg, bgColor = bg;

View File

@ -13,17 +13,17 @@
class Text: public Element
{
public:
Text(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = 0, Element * parent = NULL);
Text(uint32 x, uint32 y, std::string s, uint32 fg = 0xFF8484FF, uint32 bg = 0xFF84FF4D, Element * parent = NULL);
virtual void HandleKey(SDLKey key) {}
virtual void HandleMouseMove(uint32 x, uint32 y) {}
virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown) {}
Text(uint32_t x = 0, uint32_t y = 0, uint32_t w = 0, uint32_t h = 0, Element * parent = NULL);
Text(uint32_t x, uint32_t y, std::string s, uint32_t fg = 0xFF8484FF, uint32_t bg = 0xFF84FF4D, Element * parent = NULL);
virtual void HandleKey(SDL_Scancode key) {}
virtual void HandleMouseMove(uint32_t x, uint32_t y) {}
virtual void HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown) {}
virtual void Draw(void);
virtual void Notify(Element *) {}
void SetText(std::string s);
protected:
// uint32 fgColor, bgColor;
// uint32_t fgColor, bgColor;
std::string text;
};

View File

@ -31,7 +31,7 @@
// Text edit class implementation
//
TextEdit::TextEdit(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/,
TextEdit::TextEdit(uint32_t x/*= 0*/, uint32_t y/*= 0*/, uint32_t w/*= 0*/, uint32_t h/*= 0*/,
std::string s/*= ""*/, Element * parent/*= NULL*/):
Element(x, y, w, h, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x40, 0x40, 0xFF, parent),
activated(false), clicked(false), inside(false),
@ -44,9 +44,9 @@ TextEdit::TextEdit(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*
// Setup hardwired colors...
uint8 * c = (uint8 *)&hiliteColor;
uint8_t * c = (uint8_t *)&hiliteColor;
c[0] = 0xFF, c[1] = 0x80, c[2] = 0x00, c[3] = 0xFF;
c = (uint8 *)&cursorColor;
c = (uint8_t *)&cursorColor;
c[0] = 0x40, c[1] = 0xFF, c[2] = 0x60, c[3] = 0xFF;
// Create the text edit surface here...
@ -64,18 +64,20 @@ TextEdit::~TextEdit()
}
//Set different filters depending on type passed in on construction, e.g., filename, amount, etc...?
void TextEdit::HandleKey(SDLKey key)
void TextEdit::HandleKey(SDL_Scancode key)
{
if (!activated)
return;
// Punting this for now on SDL 2...
#if 0
SaveStateVariables();
SDLMod keyMod = SDL_GetModState();
if ((key >= SDLK_a && key <= SDLK_z) || (key >= SDLK_0 && key <= SDLK_9)
|| key == SDLK_PERIOD || key == SDLK_SLASH || key == SDLK_SPACE)
{
uint8 chr = (uint8)key;
uint8_t chr = (uint8_t)key;
// Handle shift key as well...
if (keyMod & KMOD_SHIFT)
@ -134,16 +136,17 @@ void TextEdit::HandleKey(SDLKey key)
}
CheckStateAndRedrawIfNeeded();
#endif
}
void TextEdit::HandleMouseMove(uint32 x, uint32 y)
void TextEdit::HandleMouseMove(uint32_t x, uint32_t y)
{
SaveStateVariables();
inside = Inside(x, y);
CheckStateAndRedrawIfNeeded();
}
void TextEdit::HandleMouseButton(uint32 x, uint32 y, bool mouseDown)
void TextEdit::HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown)
{
SaveStateVariables();

View File

@ -13,11 +13,11 @@
class TextEdit: public Element
{
public:
TextEdit(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = 0, std::string s = "", Element * parent = NULL);
TextEdit(uint32_t x = 0, uint32_t y = 0, uint32_t w = 0, uint32_t h = 0, std::string s = "", Element * parent = NULL);
~TextEdit();
virtual void HandleKey(SDLKey key);
virtual void HandleMouseMove(uint32 x, uint32 y);
virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown);
virtual void HandleKey(SDL_Scancode key);
virtual void HandleMouseMove(uint32_t x, uint32_t y);
virtual void HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown);
virtual void Draw(void);
virtual void Notify(Element *);
std::string GetText(void);
@ -28,12 +28,12 @@ class TextEdit: public Element
bool activated, clicked, inside;
SDL_Surface * img;
std::string text;
uint32 caretPos, scrollPos;
uint32_t caretPos, scrollPos;
private:
bool activatedSave, clickedSave, insideSave;
uint32 caretPosSave, scrollPosSave, lengthSave;
uint32 hiliteColor, cursorColor;
uint32_t caretPosSave, scrollPosSave, lengthSave;
uint32_t hiliteColor, cursorColor;
};
#endif // __TEXTEDIT_H__

View File

@ -43,7 +43,7 @@
// NOTE: FG/BG colors are hard-wired
//
Window::Window(uint32 x/*= 0*/, uint32 y/*= 0*/, uint32 w/*= 0*/, uint32 h/*= 0*/,
Window::Window(uint32_t x/*= 0*/, uint32_t y/*= 0*/, uint32_t w/*= 0*/, uint32_t h/*= 0*/,
void (* f)(Element *)/*= NULL*/):
Element(x, y, w, h, 0x4D, 0xFF, 0x84, 0xFF, 0x1F, 0x84, 0x84, 0xFF), handler(f),
cbWidth((closeBox[0] << 8) | closeBox[1]), cbHeight((closeBox[2] << 8) | closeBox[3]),
@ -67,7 +67,7 @@ Window::~Window()
#ifdef DESTRUCTOR_TESTING
printf("Inside ~Window()...\n");
#endif
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
if (list[i])
delete list[i];
@ -76,9 +76,9 @@ printf("Inside ~Window()...\n");
SDL_FreeSurface(cbHover);
}
void Window::HandleKey(SDLKey key)
void Window::HandleKey(SDL_Scancode key)
{
if (key == SDLK_ESCAPE)
if (key == SDL_SCANCODE_ESCAPE)
{
SDL_Event event;
event.type = SDL_USEREVENT, event.user.code = WINDOW_CLOSE;
@ -86,28 +86,28 @@ void Window::HandleKey(SDLKey key)
}
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
list[i]->HandleKey(key);
}
void Window::HandleMouseMove(uint32 x, uint32 y)
void Window::HandleMouseMove(uint32_t x, uint32_t y)
{
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
// Make coords relative to upper right corner of this window...
list[i]->HandleMouseMove(x - extents.x, y - extents.y);
}
void Window::HandleMouseButton(uint32 x, uint32 y, bool mouseDown)
void Window::HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown)
{
#if 1
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
// Make coords relative to upper right corner of this window...
list[i]->HandleMouseButton(x - extents.x, y - extents.y, mouseDown);
#else //? This works in draggablewindow2...
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
{
// Make coords relative to upper right corner of this window...
list[i]->HandleMouseButton(x - extents.x, y - extents.y, mouseDown);
@ -127,7 +127,7 @@ void Window::Draw(void)
SDL_FillRect(screen, &(*i), bgColor);
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
list[i]->Draw();
#else
if (drawBackground)
@ -140,7 +140,7 @@ void Window::Draw(void)
RestoreScreenFromBackstore();
// Handle the items this window contains...
for(uint32 i=0; i<list.size(); i++)
for(uint32_t i=0; i<list.size(); i++)
list[i]->Draw();
#endif

View File

@ -15,12 +15,12 @@ class Button; // Forward declaration
class Window: public Element
{
public:
Window(uint32 x = 0, uint32 y = 0, uint32 w = 0, uint32 h = 0,
Window(uint32_t x = 0, uint32_t y = 0, uint32_t w = 0, uint32_t h = 0,
void (* f)(Element *) = NULL);
~Window(); //Does this destructor need to be virtual? Not sure... Check!
virtual void HandleKey(SDLKey key);
virtual void HandleMouseMove(uint32 x, uint32 y);
virtual void HandleMouseButton(uint32 x, uint32 y, bool mouseDown);
virtual void HandleKey(SDL_Scancode key);
virtual void HandleMouseMove(uint32_t x, uint32_t y);
virtual void HandleMouseButton(uint32_t x, uint32_t y, bool mouseDown);
virtual void Draw(void);
virtual void Notify(Element *);
void AddElement(Element * e);
@ -33,7 +33,7 @@ class Window: public Element
std::vector<Element *> list;
private:
uint16 cbWidth, cbHeight;
uint16_t cbWidth, cbHeight;
SDL_Surface * cbUp, * cbDown, * cbHover;
bool drawBackground;
};

View File

@ -1,38 +0,0 @@
//
// This file was automagically generated by raw2c (by James L. Hammons)
//
char icon[0x1000] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0xFF, 0x99, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x80, 0x00, 0x80, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x86, 0x86, 0x86, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};

View File

@ -16,12 +16,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include "types.h"
#include <stdint.h>
#define MAX_LOG_SIZE 10000000 // Maximum size of log file (10 MB)
static FILE * log_stream = NULL;
static uint32 logSize = 0;
static uint32_t logSize = 0;
bool InitLog(const char * path)
{

View File

@ -1,535 +0,0 @@
/*
* SDLEMU library - Free sdl related functions library
* Copyrigh(c) 1999-2004 sdlemu development crew
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/* SDLEMU_OPENGL.C
SDLEMU related sources for using OpenGL with SDL.
By Niels Wagenaar | http://sdlemu.ngemu.com | shalafi@xs4all.nl
Version 1.0.001 - 4-10-2004
- Added support for 16, 24 and 32 bit textures;
- Added support for 16, 24 and 32 bit texture rendering;
Version 1.0.002 - 6-10-2004
- Cleaned up a lot of code and removed non functional and obsolete code;
- Removed sdlemu_resize_texture function because of double code;
- Removed the texture creation from the sdlemu_init_opengl;
- Added sdlemu_create_texture function to replace the sdlemu_resize_texture function
and the texture creation in sdlemu_init_opengl;
- Added the usage of OPENGL_16BPP_CORRECT_RGBA for activating the correct 16bpp RGBA masks;
- Added the usage of WANT_OPENGL_ALPHA for using ALPHA blending with 32bpp textures;
- Added automatic and override texture bpp depth setting (based upon the src surface);
*/
#include "sdlemu_opengl.h"
static SDL_Surface *texture = 0;
static GLuint texid = 0;
static GLfloat texcoord[4];
static unsigned int glFilter;
static unsigned int texturebpp = 0; // 16, 24 or 32 bpp
static SDL_Surface * overlay = 0;
static GLuint overlayID = 0;
static GLfloat overlayCoord[4];
void sdlemu_create_overlay(SDL_Surface * dst, int src_bpp);
static int showOverlay = 0;
static inline int power_of_two(int input)
{
int value = 1;
while (value < input)
value <<= 1;
return value;
}
void sdlemu_init_opengl(SDL_Surface * src, SDL_Surface * dst, int texturetype, int filter, int src_bpp)
{
printf("\nOpenGL driver information :\n");
printf("\n");
printf("Vendor: %s\n", glGetString(GL_VENDOR));
printf("Renderer: %s\n", glGetString(GL_RENDERER));
printf("Version: %s\n", glGetString(GL_VERSION));
printf("OpenGL drawmethod: ");
switch (texturetype)
{
case 1:
printf("GL_QUAD rendering\n\n");
break;
default:
printf("GL_TRIANGLE rendering\n\n");
break;
}
glFilter = filter;
// Let us create the texture information :
sdlemu_create_texture(src, dst, filter, src_bpp);
sdlemu_create_overlay(dst, src_bpp);
}
void sdlemu_draw_texture(SDL_Surface * dst, SDL_Surface * src, int texturetype)
{
/*
This is needed when we want to render OpenGL textures with the Alpha mask set.
Be warned! This only works with the bpp of texture en *src set to 32.
*/
#ifdef WANT_OPENGL_ALPHA
Uint32 saved_flags;
Uint8 saved_alpha;
/* Save the alpha blending attributes */
saved_flags = src->flags&(SDL_SRCALPHA|SDL_RLEACCELOK);
saved_alpha = src->format->alpha;
if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
SDL_SetAlpha(src, 0, 0);
}
// Blit the src display to the texture.
SDL_BlitSurface(src, NULL, texture, NULL);
/* Restore the alpha blending attributes */
if ( (saved_flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
SDL_SetAlpha(src, saved_flags, saved_alpha);
}
#else
SDL_BlitSurface(src, NULL, texture, NULL);
#endif
// SDL_BlitSurface(src, NULL, overlay, NULL);
/*Uint32 * pix = (Uint32 *)overlay->pixels;
Uint32 y,x;
for(y=10; y<200; y++)
for(x=30; x<250; x++)
pix[x+(y*1024)] = 0x800000FF;//*/
glBlendFunc(GL_ONE, GL_ZERO);
glBindTexture(GL_TEXTURE_2D, texid);
// Texturemap complete texture to surface so we have free scaling
// and antialiasing
switch (texturebpp)
{
case 16:
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture->w, texture->h,
GL_RGB, GL_UNSIGNED_SHORT_5_6_5, texture->pixels);
break;
case 24:
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture->w, texture->h,
GL_RGB, GL_UNSIGNED_BYTE, texture->pixels);
break;
case 32:
default:
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, texture->w, texture->h,
GL_RGBA, GL_UNSIGNED_BYTE, texture->pixels);
break;
}
// Render the texture to the screen using OpenGL!
switch (texturetype)
{
case 1:
glBegin(GL_QUADS);
glTexCoord2f(texcoord[0], texcoord[1]);
glVertex2f(0, 0);
glTexCoord2f(texcoord[2], texcoord[1]);
glVertex2f(dst->w, 0);
glTexCoord2f(texcoord[2], texcoord[3]);
glVertex2f(dst->w, dst->h);
glTexCoord2f(texcoord[0], texcoord[3]);
glVertex2f(0, dst->h);
glEnd();
default:
glBegin(GL_TRIANGLE_STRIP);
glTexCoord2f(texcoord[0], texcoord[1]); glVertex3i(0, 0, 0);
glTexCoord2f(texcoord[2], texcoord[1]); glVertex3i(dst->w, 0, 0);
glTexCoord2f(texcoord[0], texcoord[3]); glVertex3i(0, dst->h, 0);
glTexCoord2f(texcoord[2], texcoord[3]); glVertex3i(dst->w, dst->h, 0);
glEnd();
}//*/
if (showOverlay)
{
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glBindTexture(GL_TEXTURE_2D, overlayID);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, overlay->w, overlay->h, GL_RGBA, GL_UNSIGNED_BYTE, overlay->pixels);
glBegin(GL_QUADS);
glTexCoord2f(overlayCoord[0], overlayCoord[1]);
glVertex2f(0, 0);
glTexCoord2f(overlayCoord[2], overlayCoord[1]);
glVertex2f(dst->w, 0);
glTexCoord2f(overlayCoord[2], overlayCoord[3]);
glVertex2f(dst->w, dst->h);
glTexCoord2f(overlayCoord[0], overlayCoord[3]);
glVertex2f(0, dst->h);
glEnd();
}
//Do some OpenGL stuff here...
//Doesn't work...
/*unsigned long int map[25] = {
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF,
0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF
};
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glRasterPos2i(10, 10);
glDrawPixels(5, 5, GL_RGBA, GL_UNSIGNED_INT, map);//*/
// glFlush();
SDL_GL_SwapBuffers();
// glFinish();
}
void sdlemu_close_opengl(void)
{
if (texture)
SDL_FreeSurface(texture);
if (overlay)
SDL_FreeSurface(overlay);
}
void sdlemu_create_overlay(SDL_Surface * dst, int src_bpp)
{
// Local variables.
Uint32 rmask, gmask, bmask, amask; // Needed for creating RGBA masks.
// Delete old texture (if allocated). Useful when there is a screen resize.
if (overlay)
SDL_FreeSurface(overlay);
// Texture width/height should be power of 2 of the SDL_Surface *src when using OpenGL.
// So, find the largest power of two that will contain both the width and height
int w = power_of_two(dst->w);
int h = power_of_two(dst->h);
printf("OpenGL - Overlay size : %d x %d\n", w, h);
// Setting bpp based upon src_bpp.
int bpp = src_bpp;
// We allow the developer to set its own texture bpp. But if the value is NULL or
// not equal to 16, 24 or 32, we make the texturebpp the same as the BPP from src.
if (bpp == 16 || bpp == 24 || bpp == 32)
texturebpp = bpp;
else
texturebpp = dst->format->BitsPerPixel;
printf("OpenGL - Overlay depth : %d bpp\n", texturebpp);
// Now were are going to create a SDL_Surface named texture. This will be our surface
// which will function as a buffer between the SDL_Surface *src and SDL_Surface *dst.
// This buffer is needed because we need to convert the SDL_Surface *src to an OpenGL
// texture with a depth of 16, 24 or 32 bpp, before we can blit the pixels to *dst
// using OpenGL.
//
// NOTE: Seems the byte order here *is* important!
switch (texturebpp)
{
case 16: // *src has depth of 16 bpp
/*
According to information on the SDL mailinglist and on internet, the following
rgba masks should be the ones to use. But somehow the screen gets f*cked up and
the RGB colours are incorrect (at least in Virtual Jaguar/SDL).
Compile with -DOPENGL_16BPP_CORRECT_RGBA to use this RGBA values.
*/
#ifdef OPENGL_16BPP_CORRECT_RGBA
rmask = 0x7C00;
gmask = 0x03E0;
bmask = 0x001F;
amask = 0x0000;
#else
rmask = 0x0000;
gmask = 0x0000;
bmask = 0x0000;
amask = 0x0000;
#endif
break;
case 24: // *src has depth of 24 bpp
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0x00FF0000;
gmask = 0x0000FF00;
bmask = 0x000000FF;
amask = 0x00000000; // IMPORTANT! 24 bpp doesn't use Alpha (at least in our case).
#else
rmask = 0x000000FF;
gmask = 0x0000FF00;
bmask = 0x00FF0000;
amask = 0x00000000; // IMPORTANT! 24 bpp doesn't use Alpha (at least in our case).
#endif
break;
case 32: //*src has depth of 32 bpp
default: //which is also the default.
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xFF000000;
gmask = 0x00FF0000;
bmask = 0x0000FF00;
amask = 0x000000FF;
#else
rmask = 0x000000FF;
gmask = 0x0000FF00;
bmask = 0x00FF0000;
amask = 0xFF000000;
#endif
break;
}
// Creating SDL_Surface texture based upon the above settings.
overlay = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, texturebpp, rmask, gmask, bmask, amask);
// Setting up the texture coordinates.
overlayCoord[0] = 0.0f;
overlayCoord[1] = 0.0f;
overlayCoord[2] = (GLfloat)(dst->w) / overlay->w;
overlayCoord[3] = (GLfloat)(dst->h) / overlay->h;
// create a RGB(A) texture for the texture surface
glGenTextures(1, &overlayID);
glBindTexture(GL_TEXTURE_2D, overlayID);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
// Setting texture mode.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
// Generate the texture using the above information.
switch (texturebpp)
{
case 16:
// Normal 16bpp depth based textures consist out of GL_RGB5 and doesn't have support for Alpha channels.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5, overlay->w, overlay->h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
break;
case 24:
// The 24bpp depth based textures consist out of GL_RGB8 and doesn't have support for Alpha channels.
//
// IMPORTANT : If you don't use Alpha. Use textures with a depth of 16bpp.
// If you use Alpha. Use textures with a depth of 32bpp.
// 24bpp textures are SLOW and avoid them at all costs!
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, overlay->w, overlay->h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
break;
case 32:
default:
// The 32bpp depth based textures consist out of GL_RGBA8 and has support for Alpha channels.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, overlay->w, overlay->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
break;
}
}
void * sdlemuGetOverlayPixels(void)
{
return overlay->pixels;
}
Uint32 sdlemuGetOverlayWidthInPixels(void)
{
return overlay->pitch / 4;
}
void sdlemuEnableOverlay(void)
{
showOverlay = 1;
}
void sdlemuDisableOverlay(void)
{
showOverlay = 0;
}
void sdlemu_create_texture(SDL_Surface * src, SDL_Surface * dst, int filter, int src_bpp)
{
// Local variables.
int w , h; // w and h contain the width and height of the OpenGL texture.
Uint32 rmask, gmask, bmask, amask; // Needed for creating RGBA masks.
int bpp;
// Delete old texture (if allocated). Useful when there is a screen resize.
if (texture)
SDL_FreeSurface(texture);
// Texture width/height should be power of 2 of the SDL_Surface *src when using OpenGL.
// So, find the largest power of two that will contain both the width and height
w = power_of_two(src->w);
h = power_of_two(src->h);
printf("OpenGL - Texture size : %d x %d\n", w, h);
// Setting bpp based upon src_bpp.
bpp = src_bpp;
// We allow the developer to set its own texture bpp. But if the value is NULL or
// not equal to 16, 24 or 32, we make the texturebpp the same as the BPP from src.
if (bpp == 16 || bpp == 24 || bpp == 32)
texturebpp = bpp;
else
texturebpp = src->format->BitsPerPixel;
printf("OpenGL - Texture depth : %d bpp\n", texturebpp);
// Now were are going to create a SDL_Surface named texture. This will be our surface
// which will function as a buffer between the SDL_Surface *src and SDL_Surface *dst.
// This buffer is needed because we need to convert the SDL_Surface *src to an OpenGL
// texture with a depth of 16, 24 or 32 bpp, before we can blit the pixels to *dst
// using OpenGL.
//
// NOTE: Seems the byte order here *is* important!
switch (texturebpp)
{
case 16: // *src has depth of 16 bpp
/*
According to information on the SDL mailinglist and on internet, the following
rgba masks should be the ones to use. But somehow the screen gets f*cked up and
the RGB colours are incorrect (at least in Virtual Jaguar/SDL).
Compile with -DOPENGL_16BPP_CORRECT_RGBA to use this RGBA values.
*/
#ifdef OPENGL_16BPP_CORRECT_RGBA
rmask = 0x7C00;
gmask = 0x03E0;
bmask = 0x001F;
amask = 0x0000;
#else
rmask = 0x0000;
gmask = 0x0000;
bmask = 0x0000;
amask = 0x0000;
#endif
break;
case 24: // *src has depth of 24 bpp
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0x00FF0000;
gmask = 0x0000FF00;
bmask = 0x000000FF;
amask = 0x00000000; // IMPORTANT! 24 bpp doesn't use Alpha (at least in our case).
#else
rmask = 0x000000FF;
gmask = 0x0000FF00;
bmask = 0x00FF0000;
amask = 0x00000000; // IMPORTANT! 24 bpp doesn't use Alpha (at least in our case).
#endif
break;
case 32: //*src has depth of 32 bpp
default: //which is also the default.
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
rmask = 0xFF000000;
gmask = 0x00FF0000;
bmask = 0x0000FF00;
amask = 0x000000FF;
#else
rmask = 0x000000FF;
gmask = 0x0000FF00;
bmask = 0x00FF0000;
amask = 0xFF000000;
#endif
break;
}
// Creating SDL_Surface texture based upon the above settings.
texture = SDL_CreateRGBSurface(SDL_SWSURFACE, w, h, texturebpp, rmask, gmask, bmask, amask);
// Setting up OpenGL
glDisable(GL_FOG);
glDisable(GL_LIGHTING);
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
// glDisable(GL_BLEND);
glEnable(GL_BLEND);
glDisable(GL_NORMALIZE);
glDisable(GL_ALPHA_TEST);
glEnable(GL_TEXTURE_2D);
// glBlendFunc(GL_SRC_ALPHA, GL_ONE);
// glBlendFunc(GL_ONE, GL_SRC_ALPHA);
//This works, but in a wrong way...
// glBlendFunc(GL_ONE, GL_ONE);
// Definitely needed for screen resolution larger then the *src.
// This way we can have automatic scaling functionality.
glViewport(0, 0, dst->w, dst->h);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glOrtho(0.0, (GLdouble)dst->w, (GLdouble)dst->h, 0.0, 0.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
// Setting up the texture coordinates.
texcoord[0] = 0.0f;
texcoord[1] = 0.0f;
texcoord[2] = (GLfloat)(src->w) / texture->w;
texcoord[3] = (GLfloat)(src->h) / texture->h;
// create a RGB(A) texture for the texture surface
glGenTextures(1, &texid);
glBindTexture(GL_TEXTURE_2D, texid);
// Setting up the OpenGL Filters. These filters are important when we/you
// want to scale the texture.
if (filter)
{
// Textures are rendered in best quality.
printf("OpenGL filters: enabled\n");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
}
else
{
// Textures are rendered in normal quality.
printf("OpenGL filters: disabled\n");
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
// Setting texture mode.
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
// Generate the texture using the above information.
switch (texturebpp)
{
case 16:
// Normal 16bpp depth based textures consist out of GL_RGB5 and doesn't have support for Alpha channels.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB5, texture->w, texture->h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
break;
case 24:
// The 24bpp depth based textures consist out of GL_RGB8 and doesn't have support for Alpha channels.
//
// IMPORTANT : If you don't use Alpha. Use textures with a depth of 16bpp.
// If you use Alpha. Use textures with a depth of 32bpp.
// 24bpp textures are SLOW and avoid them at all costs!
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, texture->w, texture->h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
break;
case 32:
default:
// The 32bpp depth based textures consist out of GL_RGBA8 and has support for Alpha channels.
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, texture->w, texture->h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
break;
}
}

View File

@ -1,43 +0,0 @@
/*
* SDLEMU library - Free sdl related functions library
* Copyrigh(c) 1999-2002 sdlemu development crew
*
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __SDLEMU_OPENGL_H__
#define __SDLEMU_OPENGL_H__
#include "SDL.h"
#include "SDL_opengl.h"
#ifdef __cplusplus
extern "C" {
#endif
void sdlemu_init_opengl(SDL_Surface * src, SDL_Surface * dst, int texturetype, int filter, int src_bpp);
void sdlemu_draw_texture(SDL_Surface * dst, SDL_Surface * src, int texturetype);
void sdlemu_close_opengl(void);
void sdlemu_create_texture(SDL_Surface * src, SDL_Surface * dst, int filter, int src_bpp);
void * sdlemuGetOverlayPixels(void);
Uint32 sdlemuGetOverlayWidthInPixels(void);
void sdlemuEnableOverlay(void);
void sdlemuDisableOverlay(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -15,20 +15,23 @@
#include <stdlib.h>
#include <string>
#include "SDL.h"
#include <SDL2/SDL.h>
#include "sdlemu_config.h"
#include "log.h"
using namespace std;
// Global variables
Settings settings;
// Private function prototypes
static void CheckForTrailingSlash(char * path);
//
// Load Apple2's settings
//
@ -51,49 +54,49 @@ void LoadSettings(void)
settings.autoStateSaving = sdlemu_getval_bool("autoSaveState", true);
// Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
settings.p1KeyBindings[0] = sdlemu_getval_int("p1k_up", SDLK_UP);
settings.p1KeyBindings[1] = sdlemu_getval_int("p1k_down", SDLK_DOWN);
settings.p1KeyBindings[2] = sdlemu_getval_int("p1k_left", SDLK_LEFT);
settings.p1KeyBindings[3] = sdlemu_getval_int("p1k_right", SDLK_RIGHT);
settings.p1KeyBindings[4] = sdlemu_getval_int("p1k_c", SDLK_z);
settings.p1KeyBindings[5] = sdlemu_getval_int("p1k_b", SDLK_x);
settings.p1KeyBindings[6] = sdlemu_getval_int("p1k_a", SDLK_c);
settings.p1KeyBindings[7] = sdlemu_getval_int("p1k_option", SDLK_QUOTE);
settings.p1KeyBindings[8] = sdlemu_getval_int("p1k_pause", SDLK_RETURN);
settings.p1KeyBindings[9] = sdlemu_getval_int("p1k_0", SDLK_KP0);
settings.p1KeyBindings[10] = sdlemu_getval_int("p1k_1", SDLK_KP1);
settings.p1KeyBindings[11] = sdlemu_getval_int("p1k_2", SDLK_KP2);
settings.p1KeyBindings[12] = sdlemu_getval_int("p1k_3", SDLK_KP3);
settings.p1KeyBindings[13] = sdlemu_getval_int("p1k_4", SDLK_KP4);
settings.p1KeyBindings[14] = sdlemu_getval_int("p1k_5", SDLK_KP5);
settings.p1KeyBindings[15] = sdlemu_getval_int("p1k_6", SDLK_KP6);
settings.p1KeyBindings[16] = sdlemu_getval_int("p1k_7", SDLK_KP7);
settings.p1KeyBindings[17] = sdlemu_getval_int("p1k_8", SDLK_KP8);
settings.p1KeyBindings[18] = sdlemu_getval_int("p1k_9", SDLK_KP9);
settings.p1KeyBindings[19] = sdlemu_getval_int("p1k_pound", SDLK_KP_DIVIDE);
settings.p1KeyBindings[20] = sdlemu_getval_int("p1k_star", SDLK_KP_MULTIPLY);
settings.p1KeyBindings[0] = sdlemu_getval_int("p1k_up", SDL_SCANCODE_UP);
settings.p1KeyBindings[1] = sdlemu_getval_int("p1k_down", SDL_SCANCODE_DOWN);
settings.p1KeyBindings[2] = sdlemu_getval_int("p1k_left", SDL_SCANCODE_LEFT);
settings.p1KeyBindings[3] = sdlemu_getval_int("p1k_right", SDL_SCANCODE_RIGHT);
settings.p1KeyBindings[4] = sdlemu_getval_int("p1k_c", SDL_SCANCODE_Z);
settings.p1KeyBindings[5] = sdlemu_getval_int("p1k_b", SDL_SCANCODE_X);
settings.p1KeyBindings[6] = sdlemu_getval_int("p1k_a", SDL_SCANCODE_C);
settings.p1KeyBindings[7] = sdlemu_getval_int("p1k_option", SDL_SCANCODE_APOSTROPHE);
settings.p1KeyBindings[8] = sdlemu_getval_int("p1k_pause", SDL_SCANCODE_RETURN);
settings.p1KeyBindings[9] = sdlemu_getval_int("p1k_0", SDL_SCANCODE_KP_0);
settings.p1KeyBindings[10] = sdlemu_getval_int("p1k_1", SDL_SCANCODE_KP_1);
settings.p1KeyBindings[11] = sdlemu_getval_int("p1k_2", SDL_SCANCODE_KP_2);
settings.p1KeyBindings[12] = sdlemu_getval_int("p1k_3", SDL_SCANCODE_KP_3);
settings.p1KeyBindings[13] = sdlemu_getval_int("p1k_4", SDL_SCANCODE_KP_4);
settings.p1KeyBindings[14] = sdlemu_getval_int("p1k_5", SDL_SCANCODE_KP_5);
settings.p1KeyBindings[15] = sdlemu_getval_int("p1k_6", SDL_SCANCODE_KP_6);
settings.p1KeyBindings[16] = sdlemu_getval_int("p1k_7", SDL_SCANCODE_KP_7);
settings.p1KeyBindings[17] = sdlemu_getval_int("p1k_8", SDL_SCANCODE_KP_8);
settings.p1KeyBindings[18] = sdlemu_getval_int("p1k_9", SDL_SCANCODE_KP_9);
settings.p1KeyBindings[19] = sdlemu_getval_int("p1k_pound", SDL_SCANCODE_KP_DIVIDE);
settings.p1KeyBindings[20] = sdlemu_getval_int("p1k_star", SDL_SCANCODE_KP_MULTIPLY);
settings.p2KeyBindings[0] = sdlemu_getval_int("p2k_up", SDLK_UP);
settings.p2KeyBindings[1] = sdlemu_getval_int("p2k_down", SDLK_DOWN);
settings.p2KeyBindings[2] = sdlemu_getval_int("p2k_left", SDLK_LEFT);
settings.p2KeyBindings[3] = sdlemu_getval_int("p2k_right", SDLK_RIGHT);
settings.p2KeyBindings[4] = sdlemu_getval_int("p2k_c", SDLK_z);
settings.p2KeyBindings[5] = sdlemu_getval_int("p2k_b", SDLK_x);
settings.p2KeyBindings[6] = sdlemu_getval_int("p2k_a", SDLK_c);
settings.p2KeyBindings[7] = sdlemu_getval_int("p2k_option", SDLK_QUOTE);
settings.p2KeyBindings[8] = sdlemu_getval_int("p2k_pause", SDLK_RETURN);
settings.p2KeyBindings[9] = sdlemu_getval_int("p2k_0", SDLK_KP0);
settings.p2KeyBindings[10] = sdlemu_getval_int("p2k_1", SDLK_KP1);
settings.p2KeyBindings[11] = sdlemu_getval_int("p2k_2", SDLK_KP2);
settings.p2KeyBindings[12] = sdlemu_getval_int("p2k_3", SDLK_KP3);
settings.p2KeyBindings[13] = sdlemu_getval_int("p2k_4", SDLK_KP4);
settings.p2KeyBindings[14] = sdlemu_getval_int("p2k_5", SDLK_KP5);
settings.p2KeyBindings[15] = sdlemu_getval_int("p2k_6", SDLK_KP6);
settings.p2KeyBindings[16] = sdlemu_getval_int("p2k_7", SDLK_KP7);
settings.p2KeyBindings[17] = sdlemu_getval_int("p2k_8", SDLK_KP8);
settings.p2KeyBindings[18] = sdlemu_getval_int("p2k_9", SDLK_KP9);
settings.p2KeyBindings[19] = sdlemu_getval_int("p2k_pound", SDLK_KP_DIVIDE);
settings.p2KeyBindings[20] = sdlemu_getval_int("p2k_star", SDLK_KP_MULTIPLY);
settings.p2KeyBindings[0] = sdlemu_getval_int("p2k_up", SDL_SCANCODE_UP);
settings.p2KeyBindings[1] = sdlemu_getval_int("p2k_down", SDL_SCANCODE_DOWN);
settings.p2KeyBindings[2] = sdlemu_getval_int("p2k_left", SDL_SCANCODE_LEFT);
settings.p2KeyBindings[3] = sdlemu_getval_int("p2k_right", SDL_SCANCODE_RIGHT);
settings.p2KeyBindings[4] = sdlemu_getval_int("p2k_c", SDL_SCANCODE_Z);
settings.p2KeyBindings[5] = sdlemu_getval_int("p2k_b", SDL_SCANCODE_X);
settings.p2KeyBindings[6] = sdlemu_getval_int("p2k_a", SDL_SCANCODE_C);
settings.p2KeyBindings[7] = sdlemu_getval_int("p2k_option", SDL_SCANCODE_APOSTROPHE);
settings.p2KeyBindings[8] = sdlemu_getval_int("p2k_pause", SDL_SCANCODE_RETURN);
settings.p2KeyBindings[9] = sdlemu_getval_int("p2k_0", SDL_SCANCODE_KP_0);
settings.p2KeyBindings[10] = sdlemu_getval_int("p2k_1", SDL_SCANCODE_KP_1);
settings.p2KeyBindings[11] = sdlemu_getval_int("p2k_2", SDL_SCANCODE_KP_2);
settings.p2KeyBindings[12] = sdlemu_getval_int("p2k_3", SDL_SCANCODE_KP_3);
settings.p2KeyBindings[13] = sdlemu_getval_int("p2k_4", SDL_SCANCODE_KP_4);
settings.p2KeyBindings[14] = sdlemu_getval_int("p2k_5", SDL_SCANCODE_KP_5);
settings.p2KeyBindings[15] = sdlemu_getval_int("p2k_6", SDL_SCANCODE_KP_6);
settings.p2KeyBindings[16] = sdlemu_getval_int("p2k_7", SDL_SCANCODE_KP_7);
settings.p2KeyBindings[17] = sdlemu_getval_int("p2k_8", SDL_SCANCODE_KP_8);
settings.p2KeyBindings[18] = sdlemu_getval_int("p2k_9", SDL_SCANCODE_KP_9);
settings.p2KeyBindings[19] = sdlemu_getval_int("p2k_pound", SDL_SCANCODE_KP_DIVIDE);
settings.p2KeyBindings[20] = sdlemu_getval_int("p2k_star", SDL_SCANCODE_KP_MULTIPLY);
strcpy(settings.BIOSPath, sdlemu_getval_string("BIOSROM", "./ROMs/apple2.rom"));
strcpy(settings.disksPath, sdlemu_getval_string("disks", "./disks"));
@ -103,6 +106,7 @@ void LoadSettings(void)
CheckForTrailingSlash(settings.disksPath);
}
//
// Save Apple2's settings
//
@ -110,6 +114,7 @@ void SaveSettings(void)
{
}
//
// Check path for a trailing slash, and append if not present
//
@ -119,3 +124,4 @@ static void CheckForTrailingSlash(char * path)
if (path[strlen(path) - 1] != '/')
strcat(path, "/"); // NOTE: Possible buffer overflow
}

View File

@ -12,26 +12,26 @@
#else
#include <stdlib.h> // for MAX_PATH on MinGW/Darwin
#endif
#include "types.h"
#include <stdint.h>
// Settings struct
struct Settings
{
bool useJoystick;
int32 joyport; // Joystick port
int32_t joyport; // Joystick port
bool hardwareTypeNTSC; // Set to false for PAL
bool fullscreen;
bool useOpenGL;
uint32 glFilter;
uint32 frameSkip;
uint32 renderType;
uint32_t glFilter;
uint32_t frameSkip;
uint32_t renderType;
bool autoStateSaving; // Auto-state loading/saving on entry/exit
// Keybindings in order of U, D, L, R, C, B, A, Op, Pa, 0-9, #, *
uint16 p1KeyBindings[21];
uint16 p2KeyBindings[21];
uint16_t p1KeyBindings[21];
uint16_t p2KeyBindings[21];
// Paths
@ -58,3 +58,4 @@ void SaveSettings(void);
extern Settings settings;
#endif // __SETTINGS_H__

View File

@ -23,7 +23,7 @@
#include "sound.h"
#include <string.h> // For memset, memcpy
#include <SDL.h>
#include <SDL2/SDL.h>
#include "log.h"
// Useful defines
@ -63,15 +63,15 @@
static SDL_AudioSpec desired, obtained;
static bool soundInitialized = false;
static bool speakerState = false;
static int16 soundBuffer[SOUND_BUFFER_SIZE];
static uint32 soundBufferPos;
static uint64 lastToggleCycles;
static int16_t soundBuffer[SOUND_BUFFER_SIZE];
static uint32_t soundBufferPos;
static uint64_t lastToggleCycles;
static SDL_cond * conditional = NULL;
static SDL_mutex * mutex = NULL;
static SDL_mutex * mutex2 = NULL;
static int16 sample;
static uint8 ampPtr = 14; // Start with -16 - +16
static int16 amplitude[17] = { 0, 1, 2, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047,
static int16_t sample;
static uint8_t ampPtr = 14; // Start with -16 - +16
static int16_t amplitude[17] = { 0, 1, 2, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047,
4095, 8191, 16383, 32767 };
#ifdef WRITE_OUT_WAVE
static FILE * fp = NULL;
@ -162,30 +162,30 @@ static void SDLSoundCallback(void * userdata, Uint8 * buffer8, int length8)
SDL_mutexP(mutex2);
// Recast this as a 16-bit type...
int16 * buffer = (int16 *)buffer8;
uint32 length = (uint32)length8 / 2;
int16_t * buffer = (int16_t *)buffer8;
uint32_t length = (uint32_t)length8 / 2;
if (soundBufferPos < length) // The sound buffer is starved...
{
for(uint32 i=0; i<soundBufferPos; i++)
for(uint32_t i=0; i<soundBufferPos; i++)
buffer[i] = soundBuffer[i];
// Fill buffer with last value
// memset(buffer + soundBufferPos, (uint8)sample, length - soundBufferPos);
for(uint32 i=soundBufferPos; i<length; i++)
buffer[i] = (uint16)sample;
// memset(buffer + soundBufferPos, (uint8_t)sample, length - soundBufferPos);
for(uint32_t i=soundBufferPos; i<length; i++)
buffer[i] = (uint16_t)sample;
soundBufferPos = 0; // Reset soundBufferPos to start of buffer...
}
else
{
// Fill sound buffer with frame buffered sound
// memcpy(buffer, soundBuffer, length);
for(uint32 i=0; i<length; i++)
for(uint32_t i=0; i<length; i++)
buffer[i] = soundBuffer[i];
soundBufferPos -= length;
// Move current buffer down to start
for(uint32 i=0; i<soundBufferPos; i++)
for(uint32_t i=0; i<soundBufferPos; i++)
soundBuffer[i] = soundBuffer[length + i];
}
@ -211,13 +211,13 @@ So... I guess what we could do is this:
the time position back (or copies data down from what it took out)
*/
void HandleBuffer(uint64 elapsedCycles)
void HandleBuffer(uint64_t elapsedCycles)
{
// Step 1: Calculate delta time
uint64 deltaCycles = elapsedCycles - lastToggleCycles;
uint64_t deltaCycles = elapsedCycles - lastToggleCycles;
// Step 2: Calculate new buffer position
uint32 currentPos = (uint32)((double)deltaCycles / CYCLES_PER_SAMPLE);
uint32_t currentPos = (uint32_t)((double)deltaCycles / CYCLES_PER_SAMPLE);
// Step 3: Make sure there's room for it
// We need to lock since we touch both soundBuffer and soundBufferPos
@ -236,21 +236,21 @@ void HandleBuffer(uint64 elapsedCycles)
currentPos += soundBufferPos;
#ifdef WRITE_OUT_WAVE
uint32 sbpSave = soundBufferPos;
uint32_t sbpSave = soundBufferPos;
#endif
// Backfill with current toggle state
while (soundBufferPos < currentPos)
soundBuffer[soundBufferPos++] = (uint16)sample;
soundBuffer[soundBufferPos++] = (uint16_t)sample;
#ifdef WRITE_OUT_WAVE
fwrite(&soundBuffer[sbpSave], sizeof(int16), currentPos - sbpSave, fp);
fwrite(&soundBuffer[sbpSave], sizeof(int16_t), currentPos - sbpSave, fp);
#endif
SDL_mutexV(mutex2);
lastToggleCycles = elapsedCycles;
}
void ToggleSpeaker(uint64 elapsedCycles)
void ToggleSpeaker(uint64_t elapsedCycles)
{
if (!soundInitialized)
return;
@ -260,7 +260,7 @@ void ToggleSpeaker(uint64 elapsedCycles)
sample = (speakerState ? amplitude[ampPtr] : -amplitude[ampPtr]);
}
void AdjustLastToggleCycles(uint64 elapsedCycles)
void AdjustLastToggleCycles(uint64_t elapsedCycles)
{
if (!soundInitialized)
return;
@ -306,7 +306,7 @@ void VolumeDown(void)
ampPtr--;
}
uint8 GetVolume(void)
uint8_t GetVolume(void)
{
return ampPtr;
}

View File

@ -8,7 +8,7 @@
#ifndef __SOUND_H__
#define __SOUND_H__
#include "types.h"
#include <stdint.h>
// Global variables (exported)
@ -17,11 +17,11 @@
void SoundInit(void);
void SoundDone(void);
void ToggleSpeaker(uint64 elapsedCycles);
//void AddToSoundTimeBase(uint64 cycles);
void AdjustLastToggleCycles(uint64 elapsedCycles);
void ToggleSpeaker(uint64_t elapsedCycles);
//void AddToSoundTimeBase(uint64_t cycles);
void AdjustLastToggleCycles(uint64_t elapsedCycles);
void VolumeUp(void);
void VolumeDown(void);
uint8 GetVolume(void);
uint8_t GetVolume(void);
#endif // __SOUND_H__

View File

@ -40,18 +40,18 @@ struct Event
//let's try +1... nope.
static Event eventList[EVENT_LIST_SIZE];
static uint32 nextEvent;
static uint32_t nextEvent;
void InitializeEventList(void)
{
for(uint32 i=0; i<EVENT_LIST_SIZE; i++)
for(uint32_t i=0; i<EVENT_LIST_SIZE; i++)
eventList[i].valid = false;
}
//We just slap the next event into the list, no checking, no nada...
void SetCallbackTime(void (* callback)(void), double time)
{
for(uint32 i=0; i<EVENT_LIST_SIZE; i++)
for(uint32_t i=0; i<EVENT_LIST_SIZE; i++)
{
if (!eventList[i].valid)
{
@ -69,7 +69,7 @@ void SetCallbackTime(void (* callback)(void), double time)
void RemoveCallback(void (* callback)(void))
{
for(uint32 i=0; i<EVENT_LIST_SIZE; i++)
for(uint32_t i=0; i<EVENT_LIST_SIZE; i++)
{
if (eventList[i].valid && eventList[i].timerCallback == callback)
{
@ -82,7 +82,7 @@ void RemoveCallback(void (* callback)(void))
void AdjustCallbackTime(void (* callback)(void), double time)
{
for(uint32 i=0; i<EVENT_LIST_SIZE; i++)
for(uint32_t i=0; i<EVENT_LIST_SIZE; i++)
{
if (eventList[i].valid && eventList[i].timerCallback == callback)
{
@ -103,7 +103,7 @@ double GetTimeToNextEvent(void)
double time = 0;
bool firstTime = true;
for(uint32 i=0; i<EVENT_LIST_SIZE; i++)
for(uint32_t i=0; i<EVENT_LIST_SIZE; i++)
{
if (eventList[i].valid)
{
@ -138,7 +138,7 @@ void HandleNextEvent(void)
double elapsedTime = eventList[nextEvent].eventTime;
void (* event)(void) = eventList[nextEvent].timerCallback;
for(uint32 i=0; i<EVENT_LIST_SIZE; i++)
for(uint32_t i=0; i<EVENT_LIST_SIZE; i++)
if (eventList[i].valid)
eventList[i].eventTime -= elapsedTime;

View File

@ -8,7 +8,7 @@
#ifndef __TIMING_H__
#define __TIMING_H__
#include "types.h"
#include <stdint.h>
// Note that these are NTSC timings:
@ -17,9 +17,9 @@
//#define HORIZ_PERIOD_IN_USEC 63.5555
#define M6502_CYCLE_IN_USEC 0.9765625
//#define USEC_TO_RISC_CYCLES(u) (uint32)(((u) / RISC_CYCLE_IN_USEC) + 0.5)
//#define USEC_TO_M68K_CYCLES(u) (uint32)(((u) / M68K_CYCLE_IN_USEC) + 0.5)
#define USEC_TO_M6502_CYCLES(u) ((uint32)(((u) / M6502_CYCLE_IN_USEC) + 0.5))
//#define USEC_TO_RISC_CYCLES(u) (uint32_t)(((u) / RISC_CYCLE_IN_USEC) + 0.5)
//#define USEC_TO_M68K_CYCLES(u) (uint32_t)(((u) / M68K_CYCLE_IN_USEC) + 0.5)
#define USEC_TO_M6502_CYCLES(u) ((uint32_t)(((u) / M6502_CYCLE_IN_USEC) + 0.5))
void InitializeEventList(void);
void SetCallbackTime(void (* callback)(void), double time);

View File

@ -1,22 +0,0 @@
//
// Fundamental variable types
// by James L. Hammons
//
#ifndef __TYPES_H__
#define __TYPES_H__
// This should be portable, since it's part of the C99 standard...!
#include <stdint.h>
typedef uint8_t uint8;
typedef int8_t int8;
typedef uint16_t uint16;
typedef int16_t int16;
typedef uint32_t uint32;
typedef int32_t int32;
typedef uint64_t uint64;
typedef int64_t int64;
#endif // __TYPES_H__

File diff suppressed because it is too large Load Diff

View File

@ -8,7 +8,7 @@
#ifndef __V65C02_H__
#define __V65C02_H__
#include "types.h"
#include <stdint.h>
// Useful defines
@ -31,17 +31,17 @@
struct V65C02REGS
{
uint16 pc; // 65C02 PC register
uint8 cc; // 65C02 Condition Code register
uint8 sp; // 65C02 System stack pointer (bound to $01xx)
uint8 a; // 65C02 A register
uint8 x; // 65C02 X index register
uint8 y; // 65C02 Y register
// uint32 clock; // 65C02 clock (@ 1 MHz, wraps at 71.5 minutes)
uint64 clock; // 65C02 clock (@ 1 MHz, wraps at 570842 years)
uint8 (* RdMem)(uint16); // Address of BYTE read routine
void (* WrMem)(uint16, uint8); // Address of BYTE write routine
uint16 cpuFlags; // v65C02 IRQ/RESET flags
uint16_t pc; // 65C02 PC register
uint8_t cc; // 65C02 Condition Code register
uint8_t sp; // 65C02 System stack pointer (bound to $01xx)
uint8_t a; // 65C02 A register
uint8_t x; // 65C02 X index register
uint8_t y; // 65C02 Y register
// uint32_t clock; // 65C02 clock (@ 1 MHz, wraps at 71.5 minutes)
uint64_t clock; // 65C02 clock (@ 1 MHz, wraps at 570842 years)
uint8_t (* RdMem)(uint16_t); // Address of BYTE read routine
void (* WrMem)(uint16_t, uint8_t); // Address of BYTE write routine
uint16_t cpuFlags; // v65C02 IRQ/RESET flags
};
// Global variables (exported)
@ -50,7 +50,7 @@ extern bool dumpDis;
// Function prototypes
void Execute65C02(V65C02REGS *, uint32); // Function to execute 65C02 instructions
uint64 GetCurrentV65C02Clock(void); // Get the clock of the currently executing CPU
void Execute65C02(V65C02REGS *, uint32_t); // Function to execute 65C02 instructions
uint64_t GetCurrentV65C02Clock(void); // Get the clock of the currently executing CPU
#endif // __V65C02_H__

View File

@ -12,347 +12,88 @@
//
#include "video.h"
//#include <SDL.h>
#include <SDL2/SDL.h>
#include <string.h> // Why??? (for memset, etc... Lazy!) Dunno why, but this just strikes me as wrong...
#include <malloc.h>
#include "sdlemu_opengl.h"
#include "log.h"
#include "settings.h"
#include "icon.h"
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
#define MASK_R 0xFF000000
#define MASK_G 0x00FF0000
#define MASK_B 0x0000FF00
#define MASK_A 0x000000FF
#else
#define MASK_R 0x000000FF
#define MASK_G 0x0000FF00
#define MASK_B 0x00FF0000
#define MASK_A 0xFF000000
#endif
//#define TEST_ALPHA_BLENDING
// Exported global variables (actually, these are LOCAL global variables, EXPORTED...)
SDL_Surface * surface, * mainSurface, * someAlphaSurface;
Uint32 mainSurfaceFlags;
//uint32 scrBuffer[VIRTUAL_SCREEN_WIDTH * VIRTUAL_SCREEN_HEIGHT];
uint32 * scrBuffer = NULL, * mainScrBuffer = NULL;
SDL_Joystick * joystick;
static SDL_Window * sdlWindow = NULL;
static SDL_Renderer * sdlRenderer = NULL;
static SDL_Texture * sdlTexture = NULL;
uint32_t scrBuffer[VIRTUAL_SCREEN_WIDTH * VIRTUAL_SCREEN_HEIGHT * sizeof(uint32_t)];
//
// Prime SDL and create surfaces
//
bool InitVideo(void)
{
// Set up SDL library
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE | SDL_INIT_EVENTTHREAD) < 0)
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE) != 0)
{
WriteLog("Video: Could not initialize the SDL library: %s\n", SDL_GetError());
return false;
}
//Set icon (mainly for Win32 target--though seems to work under KDE as well...!)
SDL_Surface * iconSurf = SDL_CreateRGBSurfaceFrom(icon, 32, 32, 32, 128,
MASK_R, MASK_G, MASK_B, MASK_A);
SDL_WM_SetIcon(iconSurf, NULL);
SDL_FreeSurface(iconSurf);
int retVal = SDL_CreateWindowAndRenderer(VIRTUAL_SCREEN_WIDTH * 2, VIRTUAL_SCREEN_HEIGHT * 2, SDL_WINDOW_OPENGL, &sdlWindow, &sdlRenderer);
// Get proper info about the platform we're running on...
const SDL_VideoInfo * info = SDL_GetVideoInfo();
if (!info)
if (retVal != 0)
{
WriteLog("Video: SDL is unable to get the video info: %s\n", SDL_GetError());
WriteLog("Video: Could not window and/or renderer: %s\n", SDL_GetError());
return false;
}
if (settings.useOpenGL)
{
mainSurfaceFlags = SDL_HWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF | SDL_OPENGL;
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
}
else
{
mainSurfaceFlags = SDL_DOUBLEBUF;
// Make the scaled rendering look smoother.
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
// SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
SDL_RenderSetLogicalSize(sdlRenderer, VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT);
if (info->hw_available)
{
mainSurfaceFlags = SDL_HWSURFACE | SDL_HWPALETTE;
WriteLog("Video: Hardware available...\n");
}
if (info->blit_hw)
{
mainSurfaceFlags |= SDL_HWACCEL;
WriteLog("Video: Hardware blit available...\n");
}
}
if (settings.fullscreen)
mainSurfaceFlags |= SDL_FULLSCREEN;
// Create the primary SDL display (32 BPP)
if (!settings.useOpenGL)
mainSurface = SDL_SetVideoMode(VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT, 32, mainSurfaceFlags);
else
// mainSurface = SDL_SetVideoMode(VIRTUAL_SCREEN_WIDTH * 2, VIRTUAL_SCREEN_HEIGHT * 2, 32, mainSurfaceFlags);
// mainSurface = SDL_SetVideoMode(VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT * 2, 32, mainSurfaceFlags);
mainSurface = SDL_SetVideoMode(VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT, 32, mainSurfaceFlags);
if (mainSurface == NULL)
{
WriteLog("Video: SDL is unable to set the video mode: %s\n", SDL_GetError());
return false;
}
SDL_WM_SetCaption("Apple 2 SDL", "Apple 2 SDL");
// Create the secondary SDL display (32 BPP) that we use directly
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT, 32,
MASK_R, MASK_G, MASK_B, MASK_A);
#if 0
WriteLog("Video: Created secondary surface with attributes:\n\n");
WriteLog("\tWidth, height: %u x %u\n", surface->w, surface->h);
WriteLog("\t Pitch: %u\n", surface->pitch);
WriteLog("\t Palette: %08X\n", surface->format->palette);
WriteLog("\t BPP: %u\n", surface->format->BitsPerPixel);
WriteLog("\t BytesPP: %u\n", surface->format->BytesPerPixel);
WriteLog("\t RMask: %08X\n", surface->format->Rmask);
WriteLog("\t GMask: %08X\n", surface->format->Gmask);
WriteLog("\t BMask: %08X\n", surface->format->Bmask);
WriteLog("\t AMask: %08X\n", surface->format->Amask);
WriteLog("\n");
#endif
if (surface == NULL)
{
WriteLog("Video: Could not create secondary SDL surface: %s\n", SDL_GetError());
return false;
}
if (settings.useOpenGL)
sdlemu_init_opengl(surface, mainSurface, 1 /*method*/, settings.glFilter /*texture type (linear, nearest)*/,
0 /* Automatic bpp selection based upon src */);
// Initialize Joystick support under SDL
/* if (settings.useJoystick)
{
if (SDL_NumJoysticks() <= 0)
{
settings.useJoystick = false;
WriteLog("Video: No joystick(s) or joypad(s) detected on your system. Using keyboard...\n");
}
else
{
if ((joystick = SDL_JoystickOpen(settings.joyport)) == 0)
{
settings.useJoystick = false;
WriteLog("Video: Unable to open a Joystick on port: %d\n", (int)settings.joyport);
}
else
WriteLog("Video: Using: %s\n", SDL_JoystickName(settings.joyport));
}
}//*/
// Set up the scrBuffer
scrBuffer = (uint32 *)surface->pixels; // Kludge--And shouldn't have to lock since it's a software surface...
//needed? Dunno. Mebbe an SDL function instead?
// memset(scrBuffer, 0x00, VIRTUAL_SCREEN_WIDTH * VIRTUAL_SCREEN_HEIGHT * sizeof(uint32));
// Set up the mainScrBuffer
mainScrBuffer = (uint32 *)mainSurface->pixels; // May need to lock...
#ifdef TEST_ALPHA_BLENDING
//Here's some code to test alpha blending...
//Well whaddya know, it works. :-)
someAlphaSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, 30, 30, 32,
MASK_R, MASK_G, MASK_B, MASK_A);
for(int i=0; i<30; i++)
{
for(int j=0; j<30; j++)
{
uint32 color = (uint32)(((double)(i * j) / (29.0 * 29.0)) * 255.0);
color = (color << 24) | 0x00FF00FF;
((uint32 *)someAlphaSurface->pixels)[(j * 30) + i] = color;
}
}
//End test code
#endif
sdlTexture = SDL_CreateTexture(sdlRenderer,
SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING,
VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT);
WriteLog("Video: Successfully initialized.\n");
return true;
}
//
// Free various SDL components
//
void VideoDone(void)
{
WriteLog("Video: Shutting down OpenGL...\n");
if (settings.useOpenGL)
sdlemu_close_opengl();
// WriteLog("Video: Shutting down joystick....\n");
// SDL_JoystickClose(joystick);
WriteLog("Video: Freeing 'surface'...\n");
SDL_FreeSurface(surface);
#warning "The problem is here: Doing the SDL_Quit function causes a double free. !!! FIX !!!"
#warning "Some googling suggests that it may be the thread component causing the trouble."
#if 0
*** glibc detected *** ./apple2: double free or corruption (!prev): 0x08239480 ***
======= Backtrace: =========
/lib/libc.so.6[0xb7c96572]
/lib/libc.so.6[0xb7c97cc3]
/lib/libc.so.6(cfree+0x6d)[0xb7c9afed]
/usr/lib/dri/radeon_dri.so(_mesa_free+0x1d)[0xb6edefbd]
/usr/lib/dri/radeon_dri.so(_mesa_delete_texture_image+0x41)[0xb6efc6b1]
/usr/lib/dri/radeon_dri.so(_mesa_delete_texture_object+0x75)[0xb6f032d5]
/usr/lib/dri/radeon_dri.so[0xb6e898fd]
/usr/lib/dri/radeon_dri.so[0xb6eab379]
/usr/lib/dri/radeon_dri.so(_mesa_HashDeleteAll+0x66)[0xb6ecb236]
/usr/lib/dri/radeon_dri.so[0xb6eabb76]
/usr/lib/dri/radeon_dri.so(_mesa_free_context_data+0x1d1)[0xb6eac8e1]
/usr/lib/dri/radeon_dri.so(_mesa_destroy_context+0x26)[0xb6eac976]
/usr/lib/dri/radeon_dri.so(radeonDestroyContext+0x13b)[0xb6e7b97b]
/usr/lib/dri/radeon_dri.so[0xb6e779c7]
//usr//lib/opengl/xorg-x11/lib/libGL.so.1[0xb7dc3e0c]
//usr//lib/opengl/xorg-x11/lib/libGL.so.1[0xb7d9ec75]
/usr/lib/libSDL-1.2.so.0[0xb7f488d2]
/usr/lib/libSDL-1.2.so.0[0xb7f4cb67]
/usr/lib/libSDL-1.2.so.0[0xb7f4cda7]
/usr/lib/libSDL-1.2.so.0(SDL_VideoQuit+0x4e)[0xb7f3af6e]
/usr/lib/libSDL-1.2.so.0(SDL_QuitSubSystem+0x5b)[0xb7f0e5cb]
/usr/lib/libSDL-1.2.so.0(SDL_Quit+0x1e)[0xb7f0e66e]
./apple2[0x806b3e5]
./apple2[0x806be81]
/lib/libc.so.6(__libc_start_main+0xe1)[0xb7c3da51]
./apple2[0x804a541]
#endif
// WriteLog("Video: Shutting down SDL subsystems...\n");
// SDL_QuitSubSystem(SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_EVENTTHREAD);
WriteLog("Video: Shutting down SDL...\n");
SDL_Quit();
WriteLog("Video: Done.\n");
}
//
// Render the screen buffer to the primary screen surface
//
//void RenderBackbuffer(void)
void RenderScreenBuffer(void)
{
//WriteLog("Video: Blitting a %u x %u surface to the main surface...\n", surface->w, surface->h);
//Don't need this crapola--why have a separate buffer just to copy it to THIS
//buffer in order to copy it to the main screen? That's what *I* thought!
/* if (SDL_MUSTLOCK(surface))
while (SDL_LockSurface(surface) < 0)
SDL_Delay(10);
memcpy(surface->pixels, scrBuffer, VIRTUAL_SCREEN_WIDTH * VIRTUAL_SCREEN_HEIGHT * sizeof(uint32));
if (SDL_MUSTLOCK(surface))
SDL_UnlockSurface(surface);//*/
#ifdef TEST_ALPHA_BLENDING
SDL_Rect dstRect = { 100, 100, 30, 30 };
SDL_BlitSurface(someAlphaSurface, NULL, surface, &dstRect);
#endif
if (settings.useOpenGL)
sdlemu_draw_texture(mainSurface, surface, 1/*1=GL_QUADS*/);
else
{
// SDL_Rect rect = { 0, 0, surface->w, surface->h };
// SDL_BlitSurface(surface, &rect, mainSurface, &rect);
SDL_BlitSurface(surface, NULL, mainSurface, NULL);
SDL_Flip(mainSurface);
}
SDL_UpdateTexture(sdlTexture, NULL, scrBuffer, VIRTUAL_SCREEN_WIDTH * sizeof(Uint32));
SDL_RenderClear(sdlRenderer);
SDL_RenderCopy(sdlRenderer, sdlTexture, NULL, NULL);
SDL_RenderPresent(sdlRenderer);
}
// Is this even necessary? (Could call SDL_Flip directly...)
void FlipMainScreen(void)
{
#ifdef TEST_ALPHA_BLENDING
SDL_Rect dstRect = { 100, 100, 30, 30 };
SDL_BlitSurface(someAlphaSurface, NULL, mainSurface, &dstRect);
#endif
if (settings.useOpenGL)
sdlemu_draw_texture(mainSurface, surface, 1/*1=GL_QUADS*/);
else
SDL_Flip(mainSurface);
}
/*
//
// Resize the main SDL screen & scrBuffer
//
void ResizeScreen(uint32 width, uint32 height)
{
char window_title[256];
SDL_FreeSurface(surface);
surface = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height, 16,
0x7C00, 0x03E0, 0x001F, 0);
if (surface == NULL)
{
WriteLog("Video: Could not create primary SDL surface: %s", SDL_GetError());
exit(1);
}
if (settings.useOpenGL)
// This seems to work well for resizing (i.e., changes in the pixel width)...
sdlemu_resize_texture(surface, mainSurface, settings.glFilter);
else
{
mainSurface = SDL_SetVideoMode(width, height, 16, mainSurfaceFlags);
if (mainSurface == NULL)
{
WriteLog("Video: SDL is unable to set the video mode: %s\n", SDL_GetError());
exit(1);
}
}
sWriteLog(window_title, "Virtual Jaguar (%i x %i)", (int)width, (int)height);
SDL_WM_SetCaption(window_title, window_title);
// This seems to work well for resizing (i.e., changes in the pixel width)...
// if (settings.useOpenGL)
// sdlemu_resize_texture(surface, mainSurface);
}*/
/*
//
// Fullscreen <-> window switching
//
//NOTE: This does *NOT* work with OpenGL rendering! !!! FIX !!!
void ToggleFullscreen(void)
void ToggleFullScreen(void)
{
settings.fullscreen = !settings.fullscreen;
mainSurfaceFlags &= ~SDL_FULLSCREEN;
if (settings.fullscreen)
mainSurfaceFlags |= SDL_FULLSCREEN;
int retVal = SDL_SetWindowFullscreen(sdlWindow, (settings.fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0));
SDL_ShowCursor(settings.fullscreen ? 0 : 1);
if (!settings.useOpenGL)
mainSurface = SDL_SetVideoMode(VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT, 32, mainSurfaceFlags);
else
// mainSurface = SDL_SetVideoMode(VIRTUAL_SCREEN_WIDTH * 2, VIRTUAL_SCREEN_HEIGHT * 2, 32, mainSurfaceFlags);
// mainSurface = SDL_SetVideoMode(VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT * 2, 32, mainSurfaceFlags);
mainSurface = SDL_SetVideoMode(VIRTUAL_SCREEN_WIDTH, VIRTUAL_SCREEN_HEIGHT, 32, mainSurfaceFlags);
// mainSurface = SDL_SetVideoMode(tom_width, tom_height, 16, mainSurfaceFlags);
if (mainSurface == NULL)
{
WriteLog("Video: SDL is unable to set the video mode: %s\n", SDL_GetError());
exit(1);
}
SDL_WM_SetCaption("Apple 2 SDL", "Apple 2 SDL");
if (retVal != 0)
WriteLog("Video::ToggleFullScreen: SDL error = %s\n", SDL_GetError());
}
//*/

View File

@ -5,8 +5,7 @@
#ifndef __VIDEO_H__
#define __VIDEO_H__
#include <SDL.h> // For SDL_Surface
#include "types.h" // For uint32
#include <stdint.h> // For uint32_t
//#define VIRTUAL_SCREEN_WIDTH 280
#define VIRTUAL_SCREEN_WIDTH 560
@ -15,19 +14,13 @@
bool InitVideo(void);
void VideoDone(void);
//void RenderBackbuffer(void);
void RenderScreenBuffer(void);
void FlipMainScreen(void);
//void ResizeScreen(uint32 width, uint32 height);
//uint32 GetSDLScreenPitch(void);
//void ToggleFullscreen(void);
void ToggleFullScreen(void);
// Exported crap
//extern uint32 scrBuffer[VIRTUAL_SCREEN_WIDTH * VIRTUAL_SCREEN_HEIGHT];
extern uint32 * scrBuffer;
extern uint32 * mainScrBuffer;
extern SDL_Surface * surface;
extern SDL_Surface * mainSurface;
extern uint32_t scrBuffer[];
extern uint32_t mainScrBuffer[];
#endif // __VIDEO_H__