]> Shamusworld >> Repos - stargem2/commitdiff
Converted to SDL 2, added fullscreen support (F12 to toggle).
authorShamus Hammons <jlhamm@acm.org>
Sun, 8 Sep 2013 01:30:05 +0000 (20:30 -0500)
committerShamus Hammons <jlhamm@acm.org>
Sun, 8 Sep 2013 01:30:05 +0000 (20:30 -0500)
24 files changed:
.gitignore [new file with mode: 0644]
Makefile
src/dis6808.cpp
src/dis6808.h
src/dis6809.cpp
src/dis6809.h
src/icon.h [deleted file]
src/log.cpp
src/sdlemu_opengl.c [deleted file]
src/sdlemu_opengl.h [deleted file]
src/settings.cpp
src/settings.h
src/sound.cpp
src/stargem2.cpp
src/timing.cpp
src/timing.h
src/types.h [deleted file]
src/v6808.cpp
src/v6808.h
src/v6809.cpp
src/v6809.h
src/video.cpp
src/video.h
stargem2.cfg

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..0f86ce6
--- /dev/null
@@ -0,0 +1,5 @@
+cmos.ram
+obj/
+sg2.state
+stargem2
+stargem2.log
index 65dc220089f3d503b8b613ab2522c03f1eef0739..a7e1ea3daee32d9fd4dbde7bddf9939b058db0f4 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -10,18 +10,15 @@ ifeq "$(OSTYPE)" "msys"                                                     # Win32
 
 SYSTYPE    = __GCCWIN32__
 EXESUFFIX  = .exe
-GLLIB      = -lopengl32
 ICON       = obj/icon.o
 SDLLIBTYPE = --libs
 MSG        = Win32 on MinGW
 
 else
-#ifeq "$(OSTYPE)" "darwin"
 ifeq "darwin" "$(findstring darwin,$(OSTYPE))" # Should catch both 'darwin' and 'darwin7.0'
 
 SYSTYPE    = __GCCUNIX__ -D_OSX_
 EXESUFFIX  =
-GLLIB      =
 ICON       =
 SDLLIBTYPE = --static-libs
 MSG        = Mac OS X
@@ -30,7 +27,6 @@ else                                                                                  # *nix
 
 SYSTYPE    = __GCCUNIX__
 EXESUFFIX  =
-GLLIB      = -lGL
 ICON       =
 SDLLIBTYPE = --libs
 MSG        = generic Unix/Linux
@@ -42,15 +38,15 @@ CC         = gcc
 LD         = gcc
 TARGET     = stargem2
 
-CFLAGS   = -MMD -Wall -Wno-switch -Wno-uninitialized -Wno-unused -O2 -D$(SYSTYPE) -fomit-frame-pointer `sdl-config --cflags`
+CFLAGS   = -MMD -Wall -Wno-switch -Wno-uninitialized -Wno-unused -O2 -D$(SYSTYPE) -fomit-frame-pointer `sdl2-config --cflags`
 CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -Wno-uninitialized -Wno-unused -O2 -D$(SYSTYPE) \
-               -fomit-frame-pointer `sdl-config --cflags` \
+               -fomit-frame-pointer `sdl2-config --cflags` \
                -g
 #              -DLOG_UNMAPPED_MEMORY_ACCESSES
 
 LDFLAGS =
 
-LIBS = -L/usr/local/lib `sdl-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB)
+LIBS = -L/usr/local/lib `sdl2-config $(SDLLIBTYPE)` -lstdc++ -lz
 
 INCS = -I. -Isrc -I/usr/local/include
 
@@ -64,7 +60,6 @@ OBJS = \
        obj/settings.o      \
        obj/sound.o         \
        obj/sdlemu_config.o \
-       obj/sdlemu_opengl.o \
        obj/timing.o        \
        obj/stargem2.o      \
        $(ICON)
@@ -131,3 +126,4 @@ $(TARGET)$(EXESUFFIX): $(OBJS)
 # The "-" in front in there just in case they haven't been created yet
 
 -include obj/*.d
+
index 17cd301fd51f4c45b5e0a70c069466a63a799060..23ddf7a31b8276139fe2883dfaed374055055958 100755 (executable)
@@ -75,18 +75,19 @@ static char mnemonics[256][6] = {
   "EORB ","ADCB ","ORAB ","ADDB ","???  ","???  ","LDX  ","STX  "
 };
 
+
 //
 // 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 ", soundCPU.RdMem(i));
                cnt++;                                                                                  // Bump counter...
@@ -96,15 +97,16 @@ static void DisplayBytes(uint16 src, uint32 dst)
                WriteLog("   ");
 }
 
+
 //
 // Decode a 6808 instruction
 //
-int Decode6808(uint16 pc)
+int Decode6808(uint16_t pc)
 {
        char outbuf[80];
 
-       uint16 addr = pc, offset;
-       uint8 opcode = soundCPU.RdMem(addr++);                          // Get the opcode
+       uint16_t addr = pc, offset;
+       uint8_t opcode = soundCPU.RdMem(addr++);                        // Get the opcode
 
        switch (op_mat[opcode])                                                         // Decode the addressing mode...
        {
@@ -122,7 +124,7 @@ int Decode6808(uint16 pc)
                break;
        case 3:                                                                                         // Relative
 //             sprintf(outbuf, "%s $%04X", mnemonics[opcode], ++addr + (int16)(int8)soundCPU.RdMem(addr));
-               offset = addr + 1 + (int16)(int8)soundCPU.RdMem(addr);
+               offset = addr + 1 + (int16_t)(int8_t)soundCPU.RdMem(addr);
                addr++;
                sprintf(outbuf, "%s $%04X  ", mnemonics[opcode], offset);
                break;
@@ -148,3 +150,4 @@ int Decode6808(uint16 pc)
 
        return addr - pc;
 }
+
index 3f77e13707dbec385c25462673167d87484a8b63..c2505e3aca8129045427cd2ca64f63b83e05223d 100755 (executable)
@@ -8,8 +8,8 @@
 #ifndef __DIS6809_H__
 #define __DIS6809_H__
 
-#include "types.h"
+#include <stdint.h>
 
-int Decode6808(uint16 pc);
+int Decode6808(uint16_t pc);
 
 #endif // __DIS6809_H__
index dbeeedab774006091318b3ac7fc95131433f5d5f..5f42c5c102567d0467960b31493ffa9958ed519d 100755 (executable)
@@ -191,7 +191,7 @@ iregs[4][2] = {"X", "Y", "U", "S" };
 //
 // Display bytes in mem in hex
 //
-static void DisplayBytes(uint16 src, uint32 dst)
+static void DisplayBytes(uint16_t src, uint32_t dst)
 {
        char buf[20], buf2[20];
 
@@ -201,7 +201,7 @@ static void DisplayBytes(uint16 src, uint32 dst)
        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++)
        {
                sprintf(buf2, "%02X ", mainCPU.RdMem(i));
                strcat(buf, buf2);
@@ -213,15 +213,15 @@ static void DisplayBytes(uint16 src, uint32 dst)
 //
 // Decode a 6809 instruction at 'addr'
 //
-int Decode6809(uint16 pc)
+int Decode6809(uint16_t pc)
 {
        char outbuf[80], mnem[6], tmp[30];
-       uint8 opcode2, operand;
+       uint8_t opcode2, operand;
 
-       uint16 addr = pc, offset;
+       uint16_t addr = pc, offset;
 
-       uint8 opcode = mainCPU.RdMem(addr++);                           // Get the opcode
-       uint8 admode = op_mat1[opcode];                                         // addressing mode
+       uint8_t opcode = mainCPU.RdMem(addr++);                         // Get the opcode
+       uint8_t admode = op_mat1[opcode];                                       // addressing mode
        strcpy(mnem, mnemonics[opcode]);                                        // Copy page 1 opcode
 
        if (opcode == 0x10)                                                                     // Extended opcode?
@@ -254,13 +254,13 @@ int Decode6809(uint16 pc)
        case 3:                                                                                         // Relative
 //DISNOWOK--FIX
 //             sprintf(outbuf, "%s $%04X", mnem, ++addr + (int16)((int8)mainCPU.RdMem(addr)));
-               offset = addr + 1 + (int16)(int8)mainCPU.RdMem(addr);
+               offset = addr + 1 + (int16_t)(int8_t)mainCPU.RdMem(addr);
                addr++;
                sprintf(outbuf, "%s $%04X", mnem, offset);
                break;
        case 4:                                                                                         // Long Relative
 //             sprintf(outbuf, "%s $%04X", mnem, addr + (int16)((mainCPU.RdMem(addr++) << 8) | mainCPU.RdMem(addr++)) + 2);
-               offset = addr + (int16)((mainCPU.RdMem(addr) << 8) | mainCPU.RdMem(addr + 1)) + 2;
+               offset = addr + (int16_t)((mainCPU.RdMem(addr) << 8) | mainCPU.RdMem(addr + 1)) + 2;
                addr += 2;
                sprintf(outbuf, "%s $%04X", mnem, offset);
                break;
@@ -289,9 +289,9 @@ int Decode6809(uint16 pc)
        case 7:                                                                                         // Indexed (the tough one!)
        {
                operand = mainCPU.RdMem(addr++);                                // Get IDX byte
-               uint8 reg = ((operand & 0x60) >> 5), idxind = ((operand & 0x10) >> 4),
+               uint8_t reg = ((operand & 0x60) >> 5), idxind = ((operand & 0x10) >> 4),
                        lo_nyb = (operand & 0x0F),  boff;
-               uint16 woff;
+               uint16_t woff;
 
                strcpy(tmp, "??");
                if (!(operand & 0x80))                                                  // Hi bit set? Then decode 4 bit offset
index 26664de57168bcce5ad19c97c5ec18e20ee3fe2d..796af527d1948a22638da7419dff726a4ec92bde 100755 (executable)
@@ -8,8 +8,8 @@
 #ifndef __DIS6809_H__
 #define __DIS6809_H__
 
-#include "types.h"
+#include <stdint.h>
 
-int Decode6809(uint16);
+int Decode6809(uint16_t);
 
 #endif // __DIS6809_H__
diff --git a/src/icon.h b/src/icon.h
deleted file mode 100755 (executable)
index 1852969..0000000
+++ /dev/null
@@ -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, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  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,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  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,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  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,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  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,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  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, 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,  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, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  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,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0xFF, 0xFF, 0x00, 0xFF,  0xFF, 0xFF, 0x00, 0xFF,  0x00, 0x00, 0x80, 0xFF,  0x00, 0x00, 0x80, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 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,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0xFF, 0xFF, 0x00, 0xFF,  0xFF, 0xFF, 0x00, 0xFF,  0x00, 0x00, 0x80, 0xFF,  0x00, 0x00, 0x80, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 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,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 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, 0x00,
-       0x00, 0x00, 0x00, 0x00,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 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, 0x00,
-       0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 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, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 0xFF,  0x80, 0x80, 0x80, 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, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,
-       0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x80, 0x00, 0xFF,  0x00, 0x80, 0x00, 0xFF,  0x00, 0x80, 0x00, 0xFF,  0x00, 0x80, 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, 0x80, 0x00, 0xFF,  0x00, 0x80, 0x00, 0xFF,  0x00, 0x80, 0x00, 0xFF,  0x00, 0x80, 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,  0xFF, 0xFF, 0x00, 0xFF,  0xFF, 0xFF, 0x00, 0xFF,  0x00, 0x80, 0x00, 0xFF,  0x00, 0x80, 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,  0xFF, 0xFF, 0x00, 0xFF,  0xFF, 0xFF, 0x00, 0xFF,  0x00, 0x80, 0x00, 0xFF,  0x00, 0x80, 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,  0xFF, 0xFF, 0x00, 0xFF,  0xFF, 0xFF, 0x00, 0xFF,  0x00, 0x80, 0x00, 0xFF,  0x00, 0x80, 0x00, 0xFF,  0xFF, 0x00, 0xFF, 0xFF,  0xFF, 0x00, 0xFF, 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,  0xFF, 0xFF, 0x00, 0xFF,  0xFF, 0xFF, 0x00, 0xFF,  0x00, 0x80, 0x00, 0xFF,  0x00, 0x80, 0x00, 0xFF,  0xFF, 0x00, 0xFF, 0xFF,  0xFF, 0x00, 0xFF, 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,  0xFF, 0x00, 0xFF, 0xFF,  0xFF, 0x00, 0xFF, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0xFF, 0xFF,  0xFF, 0x00, 0xFF, 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,  0xFF, 0x00, 0xFF, 0xFF,  0xFF, 0x00, 0xFF, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0xFF, 0xFF,  0xFF, 0x00, 0xFF, 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,  0xFF, 0x00, 0xFF, 0xFF,  0xFF, 0x00, 0xFF, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0xFF, 0xFF,  0xFF, 0x00, 0xFF, 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,  0xFF, 0x00, 0xFF, 0xFF,  0xFF, 0x00, 0xFF, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 0x00, 0xFF, 0xFF,  0xFF, 0x00, 0xFF, 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,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 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, 0x00,  0x00, 0x00, 0x00, 0x00,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 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, 0x00,  0x00, 0x00, 0x00, 0x00,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 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, 0x00,  0x00, 0x00, 0x00, 0x00,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 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, 0x00,  0x00, 0x00, 0x00, 0x00,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 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, 0x00,  0x00, 0x00, 0x00, 0x00,  0xFF, 0x00, 0x00, 0xFF,  0xFF, 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, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00,  0x00, 0x00, 0x00, 0x00
-};
index b5fcf4de30cf58d427508ee3d4f70f6f9c04829d..5d05deedbb917698c1885b936d3258a17e973bcc 100755 (executable)
@@ -8,12 +8,12 @@
 
 #include <stdio.h>
 #include <stdlib.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)
 {
diff --git a/src/sdlemu_opengl.c b/src/sdlemu_opengl.c
deleted file mode 100755 (executable)
index 7ea9faf..0000000
+++ /dev/null
@@ -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;        
-       }    
-}    
diff --git a/src/sdlemu_opengl.h b/src/sdlemu_opengl.h
deleted file mode 100755 (executable)
index 22e0f9a..0000000
+++ /dev/null
@@ -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
index f1c2cc2bc900a8c9454c82e44814c98026cbaa0a..c448e12d52c89cda2b59bdac09be5952acf5ec22 100755 (executable)
@@ -15,7 +15,8 @@
 
 #include <stdlib.h>
 #include <string>
-#include "SDL.h"
+//#include "SDL.h"
+#include <SDL2/SDL.h>
 #include "sdlemu_config.h"
 #include "log.h"
 
@@ -53,27 +54,27 @@ void LoadSettings(void)
        // Keybindings in order of fire, thrust, smartbomb, hyperspace, reverse, up, down, inviso,
        // 1 player start, 2 player start, left coin, center coin, right coin, auto up, advance,
        // high score reset, slam switch
-       settings.keyBindings[S_KEY_FIRE]        = sdlemu_getval_int("k_fire", SDLK_SEMICOLON);
-       settings.keyBindings[S_KEY_THRUST]      = sdlemu_getval_int("k_thrust", SDLK_l);
-       settings.keyBindings[S_KEY_SMARTBOMB]   = sdlemu_getval_int("k_smartbomb", SDLK_SPACE);
-       settings.keyBindings[S_KEY_HYPERSPACE]  = sdlemu_getval_int("k_hyperspace", SDLK_BACKSPACE);
-       settings.keyBindings[S_KEY_REVERSE]     = sdlemu_getval_int("k_reverse", SDLK_RETURN);
-       settings.keyBindings[S_KEY_UP]          = sdlemu_getval_int("k_up", SDLK_r);
-       settings.keyBindings[S_KEY_DOWN]        = sdlemu_getval_int("k_down", SDLK_f);
-       settings.keyBindings[S_KEY_INVISO]      = sdlemu_getval_int("k_inviso", SDLK_a);
-       settings.keyBindings[S_KEY_1P_START]    = sdlemu_getval_int("k_1p_start", SDLK_1);
-       settings.keyBindings[S_KEY_2P_START]    = sdlemu_getval_int("k_2p_start", SDLK_2);
-       settings.keyBindings[S_KEY_LEFT_COIN]   = sdlemu_getval_int("k_left_coin", SDLK_3);
-       settings.keyBindings[S_KEY_CENTER_COIN] = sdlemu_getval_int("k_center_coin", SDLK_4);
-       settings.keyBindings[S_KEY_RIGHT_COIN]  = sdlemu_getval_int("k_right_coin", SDLK_5);
-       settings.keyBindings[S_KEY_AUTO_UP]     = sdlemu_getval_int("k_auto_up", SDLK_F1);
-       settings.keyBindings[S_KEY_ADVANCE]     = sdlemu_getval_int("k_advance", SDLK_F2);
-       settings.keyBindings[S_KEY_HS_RESET]    = sdlemu_getval_int("k_high_score_reset", SDLK_F3);
-       settings.keyBindings[S_KEY_SLAM_SWITCH] = sdlemu_getval_int("k_slam_switch", SDLK_F4);
-//     settings.keyBindings[17] = sdlemu_getval_int("k_8", SDLK_KP8);
-//     settings.keyBindings[18] = sdlemu_getval_int("k_9", SDLK_KP9);
-//     settings.keyBindings[19] = sdlemu_getval_int("k_pound", SDLK_KP_DIVIDE);
-//     settings.keyBindings[20] = sdlemu_getval_int("k_star", SDLK_KP_MULTIPLY);
+       settings.keyBindings[S_KEY_FIRE]        = sdlemu_getval_int("k_fire", SDL_SCANCODE_SEMICOLON);
+       settings.keyBindings[S_KEY_THRUST]      = sdlemu_getval_int("k_thrust", SDL_SCANCODE_L);
+       settings.keyBindings[S_KEY_SMARTBOMB]   = sdlemu_getval_int("k_smartbomb", SDL_SCANCODE_SPACE);
+       settings.keyBindings[S_KEY_HYPERSPACE]  = sdlemu_getval_int("k_hyperspace", SDL_SCANCODE_BACKSPACE);
+       settings.keyBindings[S_KEY_REVERSE]     = sdlemu_getval_int("k_reverse", SDL_SCANCODE_RETURN);
+       settings.keyBindings[S_KEY_UP]          = sdlemu_getval_int("k_up", SDL_SCANCODE_R);
+       settings.keyBindings[S_KEY_DOWN]        = sdlemu_getval_int("k_down", SDL_SCANCODE_F);
+       settings.keyBindings[S_KEY_INVISO]      = sdlemu_getval_int("k_inviso", SDL_SCANCODE_A);
+       settings.keyBindings[S_KEY_1P_START]    = sdlemu_getval_int("k_1p_start", SDL_SCANCODE_1);
+       settings.keyBindings[S_KEY_2P_START]    = sdlemu_getval_int("k_2p_start", SDL_SCANCODE_2);
+       settings.keyBindings[S_KEY_LEFT_COIN]   = sdlemu_getval_int("k_left_coin", SDL_SCANCODE_3);
+       settings.keyBindings[S_KEY_CENTER_COIN] = sdlemu_getval_int("k_center_coin", SDL_SCANCODE_4);
+       settings.keyBindings[S_KEY_RIGHT_COIN]  = sdlemu_getval_int("k_right_coin", SDL_SCANCODE_5);
+       settings.keyBindings[S_KEY_AUTO_UP]     = sdlemu_getval_int("k_auto_up", SDL_SCANCODE_F1);
+       settings.keyBindings[S_KEY_ADVANCE]     = sdlemu_getval_int("k_advance", SDL_SCANCODE_F2);
+       settings.keyBindings[S_KEY_HS_RESET]    = sdlemu_getval_int("k_high_score_reset", SDL_SCANCODE_F3);
+       settings.keyBindings[S_KEY_SLAM_SWITCH] = sdlemu_getval_int("k_slam_switch", SDL_SCANCODE_F4);
+//     settings.keyBindings[17] = sdlemu_getval_int("k_8", SDL_SCANCODE_KP8);
+//     settings.keyBindings[18] = sdlemu_getval_int("k_9", SDL_SCANCODE_KP9);
+//     settings.keyBindings[19] = sdlemu_getval_int("k_pound", SDL_SCANCODE_KP_DIVIDE);
+//     settings.keyBindings[20] = sdlemu_getval_int("k_star", SDL_SCANCODE_KP_MULTIPLY);
 
        strcpy(settings.BIOSPath, sdlemu_getval_string("BIOSROM", "./ROMs/"));
        strcpy(settings.disksPath, sdlemu_getval_string("disks", "./disks/"));
index a768a75ac61caaa7414b5ca1a1a2207d3ad5b877..b1c4caecb83360180a444fd678ea7f3c9b4c93f2 100755 (executable)
@@ -12,7 +12,7 @@
 #else
 #include <stdlib.h>                                                            // for MAX_PATH on MinGW/Darwin
 #endif
-#include "types.h"
+#include <stdint.h>
 
 enum { S_KEY_FIRE = 0, S_KEY_THRUST, S_KEY_SMARTBOMB, S_KEY_HYPERSPACE, S_KEY_REVERSE,
        S_KEY_UP, S_KEY_DOWN, S_KEY_INVISO, S_KEY_1P_START, S_KEY_2P_START, S_KEY_LEFT_COIN,
@@ -24,20 +24,20 @@ enum { S_KEY_FIRE = 0, S_KEY_THRUST, S_KEY_SMARTBOMB, S_KEY_HYPERSPACE, S_KEY_RE
 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 fire, thrust, smartbomb, hyperspace, reverse, up, down, inviso,
        // 1 player start, 2 player start, left coin, center coin, right coin, auto up, advance,
        // high score reset, slam switch
 
-       uint16 keyBindings[21];
+       uint16_t keyBindings[21];
 
        // Paths
 
@@ -62,3 +62,4 @@ void SaveSettings(void);
 extern Settings settings;
 
 #endif // __SETTINGS_H__
+
index 4191928b2c52584c87680ab6c8701ca7990fe0d6..4462e27eccae6c7dba34590c0598ef53eda3ac1b 100755 (executable)
@@ -23,8 +23,8 @@
 
 #include "sound.h"
 
-#include "SDL.h"
-#include "types.h"
+#include <SDL2/SDL.h>
+#include <stdint.h>
 #include "log.h"
 #include "v6808.h"
 #include "timing.h"
 
 static SDL_AudioSpec desired;
 static bool soundInitialized = false;
-static uint32 cyclesToExecuteWholePart;
+static uint32_t cyclesToExecuteWholePart;
 static double cyclesToExecuteFractionalPart;
 
 // Private function prototypes
 
 void SDLSoundCallback(void * userdata, Uint8 * buffer, int length);
 
+
 //
 // Initialize the SDL sound system
 //
@@ -67,7 +68,7 @@ void SoundInit(void)
        }
 
        // Setup clock cycles & etc.
-       cyclesToExecuteWholePart = (uint32)CYCLES_TO_EXECUTE;
+       cyclesToExecuteWholePart = (uint32_t)CYCLES_TO_EXECUTE;
        cyclesToExecuteFractionalPart = CYCLES_TO_EXECUTE - (double)cyclesToExecuteWholePart;
 #if 0
 printf("Cycles to execute: %lf; cycles W: %u; cycles F: %lf\n", CYCLES_TO_EXECUTE, cyclesToExecuteWholePart, cyclesToExecuteFractionalPart);
@@ -78,6 +79,7 @@ printf("Cycles to execute: %lf; cycles W: %u; cycles F: %lf\n", CYCLES_TO_EXECUT
        WriteLog("Sound: Successfully initialized.\n");
 }
 
+
 //
 // Close down the SDL sound subsystem
 //
@@ -91,17 +93,18 @@ void SoundDone(void)
        }
 }
 
+
 //
 // Sound card callback handler
 //
 void SDLSoundCallback(void * userdata, Uint8 * buffer, int length)
 {
        extern V6808REGS soundCPU;
-       extern uint8 sram[];
+       extern uint8_t sram[];
        int cnt = 0;
 
        static float overflow = 0.0;
-       static uint32 time = cyclesToExecuteWholePart;
+       static uint32_t time = cyclesToExecuteWholePart;
 
        while (cnt != length)
        {
@@ -118,3 +121,4 @@ void SDLSoundCallback(void * userdata, Uint8 * buffer, int length)
                }
        }
 }
+
index 107f8dbf241c13caab09edaff25b0b3f29de71e4..db2f65abb7e3061e04f7d6c6277dd0c9a34b2e49 100755 (executable)
 // ---  ----------  ------------------------------------------------------------
 // JLH  06/15/2006  Added changelog ;-)
 // JLH  06/15/2006  Switched over to timeslice execution code
-// JLH  07/15/2009  Solved problem with DEMO mode (IRQ handling)
+// JLH  07/15/2009  Solved problem with DEMO mode (IRQ handling) (No, didn't)
 //
 
-#include "SDL.h"
+
+#include <SDL2/SDL.h>
 #include <fstream>
 #include <string>
 #include <iomanip>
@@ -21,7 +22,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
-#include "types.h"
+#include <stdint.h>
 #include "log.h"
 #include "v6808.h"
 #include "v6809.h"
@@ -32,6 +33,7 @@
 #include "dis6809.h"
 #include "dis6808.h"
 
+
 //#define __DEBUG__
 //#define LOG_PIA1_IO
 
@@ -52,27 +54,27 @@ using namespace std;
 
 // Global variables
 
-uint8 gram[0x10000], grom[0x10000], sram[0x10000], srom[0x10000]; // RAM & ROM spaces
+uint8_t gram[0x10000], grom[0x10000], sram[0x10000], srom[0x10000]; // RAM & ROM spaces
 V6809REGS mainCPU;
 V6808REGS soundCPU;
-uint8 color[16];
-uint32 palette[256];
+uint8_t color[16];
+uint32_t palette[256];
 bool paletteDirty = false;
 
 // Local variables
 
 static bool running = true;                                            // Machine running state flag...
-static uint32 startTicks;
-static uint8 * keys;                                                   // SDL raw keyboard matrix
-static uint64 clockFrameStart;                                 // V6809 clock at the start of the frame
+static uint32_t startTicks;
+static const uint8_t * keys;                                           // SDL raw keyboard matrix
+static uint64_t clockFrameStart;                                       // V6809 clock at the start of the frame
 
 // Function prototypes
 
-uint8 RdMem6809(uint16 addr);
-void WrMem6809(uint16 addr, uint8 b);
-uint8 RdMem6808(uint16 addr);
-void WrMem6808(uint16 addr, uint8 b);
-bool LoadImg(const char * filename, uint8 * ram, int size);
+uint8_t RdMem6809(uint16_t addr);
+void WrMem6809(uint16_t addr, uint8_t b);
+uint8_t RdMem6808(uint16_t addr);
+void WrMem6808(uint16_t addr, uint8_t b);
+bool LoadImg(const char * filename, uint8_t * ram, int size);
 void SaveCMOS(void);
 bool LoadMachineState(void);
 void SaveMachineState(void);
@@ -90,12 +92,12 @@ int main(int /*argc*/, char * /*argv*/[])
 {
        InitLog("stargem2.log");
        WriteLog("StarGem2 - A portable Stargate emulator by James L. Hammons\n");
-       WriteLog("(C) 2009 Underground Software\n\n");
+       WriteLog("(C) 2013 Underground Software\n\n");
 
        LoadSettings();
 
        // Initialize Williams' palette (RGB coded as: 3 bits red, 3 bits green, 2 bits blue)
-       for(uint32 i=0; i<256; i++)
+       for(uint32_t i=0; i<256; i++)
                palette[i] =
 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
                (((i & 0x01) * 33 + ((i & 0x02) >> 1) * 71 + ((i & 0x04) >> 2) * 151) << 24)
@@ -132,7 +134,7 @@ int main(int /*argc*/, char * /*argv*/[])
 
        for(int i=0; i<12; i++)
        {
-               uint32 baseAddress = i * 0x1000;
+               uint32_t baseAddress = i * 0x1000;
 
                if (i > 8)
                        baseAddress += 0x4000;
@@ -172,7 +174,7 @@ int main(int /*argc*/, char * /*argv*/[])
 
        WriteLog("About to intialize audio...\n");
        SoundInit();
-       keys = SDL_GetKeyState(NULL);
+       keys = SDL_GetKeyboardState(NULL);
        srom[0xF800] = 0x37;                                            // Fix checksum so ST works...
        running = true;                                                         // Set running status...
 
@@ -197,7 +199,7 @@ WriteLog("$C900 = $%02X (0=RAM)\n", gram[0xC900]);
 WriteLog("PC: %04X, X: %04X, Y: %04X, S: %04X, U: %04X, A: %02X, B: %02X, DP: %02X, CC: %02X\n", mainCPU.pc, mainCPU.x, mainCPU.y, mainCPU.s, mainCPU.u, mainCPU.a, mainCPU.b, mainCPU.dp, mainCPU.cc);
 WriteLog("\n");
 
-/*uint16 pc = mainCPU.pc;//0x15BA;
+/*uint16_t pc = mainCPU.pc;//0x15BA;
 for(int i=0; i<200; i++)
 //while (pc < 0x9000)
 {
@@ -205,7 +207,7 @@ for(int i=0; i<200; i++)
        WriteLog("\n");
 }//*/
 
-/*uint32 pc = 0;
+/*uint32_t pc = 0;
 while (pc < 0xFFFF)
 {
        pc += Decode6809(pc);
@@ -225,7 +227,7 @@ while (pc < 0xFFFF)
 //
 // Load a file into RAM/ROM image space
 //
-bool LoadImg(const char * filename, uint8 * ram, int size)
+bool LoadImg(const char * filename, uint8_t * ram, int size)
 {
        FILE * fp = fopen(filename, "rb");
 
@@ -272,10 +274,10 @@ bool LoadMachineState(void)
        fclose(fp);
 
        // Set up backbuffer... ;-)
-       for(uint16 i=0x0006; i<0x97F8; i++)                                     // Screen memory
+       for(uint16_t i=0x0006; i<0x97F8; i++)                                   // Screen memory
                WrMem6809(i, gram[i]);
 
-       for(uint16 i=0xC000; i<=0xC00F; i++)                            // Palette memory
+       for(uint16_t i=0xC000; i<=0xC00F; i++)                          // Palette memory
                WrMem6809(i, gram[i]);
 
        paletteDirty = true;
@@ -318,9 +320,9 @@ void SaveMachineState(void)
 #ifdef LOG_PIA1_IO
 char piaRegsName[4][10] = { "PORTA", "PACTL", "PORTB", "PBCTL" };
 #endif
-uint8 RdMem6809(uint16 addr)
+uint8_t RdMem6809(uint16_t addr)
 {
-       uint8 b;
+       uint8_t b;
 
        if (addr >= 0x9000 && addr <= 0xCFFF)           // No ROM between $9000 - $CFFF...
                b = gram[addr];
@@ -340,11 +342,11 @@ uint8 RdMem6809(uint16 addr)
        {
 //Interesting, this code ALSO fucks up the demo...
 //Except when the correct code is called in the scanline callback function...
-               uint32 elapsedCycles = (uint32)(GetCurrentV6809Clock() - clockFrameStart);
-               uint32 scanline = (uint32)((double)elapsedCycles / SCANLINE_DURATION_IN_CYCLES);
+               uint32_t elapsedCycles = (uint32_t)(GetCurrentV6809Clock() - clockFrameStart);
+               uint32_t scanline = (uint32_t)((double)elapsedCycles / SCANLINE_DURATION_IN_CYCLES);
 //Changes here don't seem to do much...
-//             uint32 scanline = (uint32)(((double)elapsedCycles * M6809_CYCLE_IN_USEC) / 70.0);
-               b = (uint8)scanline & 0xFC;                             // Only bits 2-7 are connected...
+//             uint32_t scanline = (uint32_t)(((double)elapsedCycles * M6809_CYCLE_IN_USEC) / 70.0);
+               b = (uint8_t)scanline & 0xFC;                           // Only bits 2-7 are connected...
        }
 #endif
 
@@ -365,7 +367,7 @@ uint8 RdMem6809(uint16 addr)
        }
 
 //temp...
-/*extern uint16 pcr;
+/*extern uint16_t pcr;
 //if (addr >= 0xC000 && addr <= 0xCBFF)
 if (addr == 0x9C59)
        WriteLog("RdMem: Reading address %04X [=%02X, PC=%04X]\n", addr, b, pcr);//*/
@@ -376,7 +378,7 @@ if (addr == 0x9C59)
        return b;
 }
 
-void WrMem6809(uint16 addr, uint8 b)
+void WrMem6809(uint16_t addr, uint8_t b)
 {
 //temp...
 //extern V6809REGS regs;
@@ -392,11 +394,11 @@ void WrMem6809(uint16 addr, uint8 b)
        if (addr >= 0x0006 && addr < 0x97F7)                    // 304 pixels  152-128=24-16=8
        {
                // NOTE: Screen was 304 x 256, but we truncate the vertical dimension here...
-               uint16 sx = (addr >> 7) & 0x01FE, sy = addr & 0x00FF;
+               uint16_t sx = (addr >> 7) & 0x01FE, sy = addr & 0x00FF;
 
                if (sy > 5 && sy < 246)
                {
-                       uint32 saddr = 8 + sx + ((sy - 6) * 320);       // Calc screen address
+                       uint32_t saddr = 8 + sx + ((sy - 6) * 320);     // Calc screen address
                        scrBuffer[saddr + 0] = palette[color[b >> 4]];
                        scrBuffer[saddr + 1] = palette[color[b & 0x0F]];
                }
@@ -424,12 +426,12 @@ if (addr == 0xC80D)
 // 6808 memory functions
 //
 
-uint8 RdMem6808(uint16 addr)
+uint8_t RdMem6808(uint16_t addr)
 {
        return (addr < 0xF000 ? sram[addr] : srom[addr]);
 }
 
-void WrMem6808(uint16 addr, uint8 b)
+void WrMem6808(uint16_t addr, uint8_t b)
 {
        sram[addr] = b;
 
@@ -445,7 +447,7 @@ static void FrameCallback(void)
        SDL_PumpEvents();                                                       // Force key events into the buffer.
        gram[0xC804] = gram[0xC806] = gram[0xC80C] = 0; // Reset PIA ports...
 
-       if (keys[SDLK_ESCAPE])
+       if (keys[SDL_SCANCODE_ESCAPE])
                running = false;                                                // ESC to exit...
 
        if (keys[settings.keyBindings[S_KEY_FIRE]])                     gram[0xC804] |= 0x01;
@@ -468,26 +470,26 @@ static void FrameCallback(void)
        if (keys[settings.keyBindings[S_KEY_CENTER_COIN]])      gram[0xC80C] |= 0x20;
        if (keys[settings.keyBindings[S_KEY_SLAM_SWITCH]])      gram[0xC80C] |= 0x40;
 
-       if (keys[SDLK_F5])                                                      // Sound CPU self-test (F5)
+       if (keys[SDL_SCANCODE_F5])                                                      // Sound CPU self-test (F5)
                soundCPU.cpuFlags |= V6808_ASSERT_LINE_NMI;
-       if (keys[SDLK_F6])                                                      // Reset the 6808 (F6)
+       if (keys[SDL_SCANCODE_F6])                                                      // Reset the 6808 (F6)
                soundCPU.cpuFlags |= V6808_ASSERT_LINE_RESET;
 //Temp, for testing...
 extern bool disasm;
 //disasm = true;
-       if (keys[SDLK_F9])
+       if (keys[SDL_SCANCODE_F9])
                disasm = true;
 
        if (paletteDirty)
        {
-               for(uint32 addr=0x0006; addr<0x97F7; addr++)
+               for(uint32_t addr=0x0006; addr<0x97F7; addr++)
                {
-                       uint16 sx = (addr >> 7) & 0x01FE, sy = addr & 0x00FF;
+                       uint16_t sx = (addr >> 7) & 0x01FE, sy = addr & 0x00FF;
 
                        if (sy > 5 && sy < 246)
                        {
-                               uint32 saddr = 8 + sx + ((sy - 6) * 320);       // Calc screen address
-                               uint8 sb = gram[addr];
+                               uint32_t saddr = 8 + sx + ((sy - 6) * 320);     // Calc screen address
+                               uint8_t sb = gram[addr];
 
                                scrBuffer[saddr + 0] = palette[color[sb >> 4]];
                                scrBuffer[saddr + 1] = palette[color[sb & 0x0F]];
@@ -497,6 +499,19 @@ extern bool disasm;
                paletteDirty = false;
        }
 
+       static bool fullscreenDebounce = false;
+
+       if (keys[SDL_SCANCODE_F12])
+       {
+               if (!fullscreenDebounce)
+               {
+                       ToggleFullScreen();
+                       fullscreenDebounce = true;
+               }
+       }
+       else
+               fullscreenDebounce = false;
+
        RenderScreenBuffer();                                           // 1 frame = 1/60 sec ~ 16667 cycles
        clockFrameStart = mainCPU.clock;
 
index ebca2bfe6e6d9a561737c66cb70cfcb2c2106500..e7ac35f69fc63d1a33d49cbde607fa38acf03845 100755 (executable)
@@ -17,8 +17,7 @@
 //
 
 #include "timing.h"
-
-#include "types.h"
+#include <stdint.h>
 #include "log.h"
 
 #define EVENT_LIST_SIZE       512
@@ -40,19 +39,22 @@ struct Event
     void (* timerCallback)(void);
 };
 
+
 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)
         {
@@ -68,9 +70,10 @@ void SetCallbackTime(void (* callback)(void), double time)
     WriteLog("SetCallbackTime() failed to find an empty slot in the list!\n");
 }
 
+
 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)
         {
@@ -81,9 +84,10 @@ 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)
         {
@@ -94,12 +98,13 @@ void AdjustCallbackTime(void (* callback)(void), double time)
     }
 }
 
+
 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)
         {
@@ -116,12 +121,13 @@ double GetTimeToNextEvent(void)
     return time;
 }
 
+
 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;
 
@@ -129,3 +135,4 @@ void HandleNextEvent(void)
 
     (*event)();
 }
+
index 360ce311ff190a42ebcdb297219af61b03f4f3a5..9fba023098fc0de5ae7553820cd9843729eb687f 100755 (executable)
@@ -15,8 +15,8 @@
 #define M6808_CYCLE_IN_USEC            (1000000.0 / M6808_CLOCK_SPEEK_IN_HZ)
 #define M6809_CYCLE_IN_USEC            (1000000.0 / M6809_CLOCK_SPEED_IN_HZ)
 
-#define USEC_TO_M6808_CYCLES(u)  (uint32)(((u) / M6808_CYCLE_IN_USEC) + 0.5)
-#define USEC_TO_M6809_CYCLES(u)  (uint32)(((u) / M6809_CYCLE_IN_USEC) + 0.5)
+#define USEC_TO_M6808_CYCLES(u)  (uint32_t)(((u) / M6808_CYCLE_IN_USEC) + 0.5)
+#define USEC_TO_M6809_CYCLES(u)  (uint32_t)(((u) / M6809_CYCLE_IN_USEC) + 0.5)
 
 void InitializeEventList(void);
 void SetCallbackTime(void (* callback)(void), double time);
diff --git a/src/types.h b/src/types.h
deleted file mode 100755 (executable)
index faa8684..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-//
-// Fundamental variable types
-// by James L. Hammons
-//
-// Why these aren't a part of the C/C++ standard is beyond me. It seems to me that
-// basic types where you know the width should be a no-brainer.
-// I guess enough people were pissed off by it, so they included it finally. We
-// still alias them because we don't like typing _t after our type identifiers. ;-)
-//
-
-#ifndef __TYPES_H__
-#define __TYPES_H__
-
-#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__
index b1095eb3604a281b71dc3feb1967ffeebd6a303e..ac1352ce49652775b3755e08c6e85d985f441bf0 100755 (executable)
@@ -20,7 +20,7 @@
 // NOTE: V6808_STATE_WAI is not handled in the main loop correctly. !!! FIX !!!
 
 // Some random thoughts: Could there be a performance gain by breaking
-// out the flags in regs.cc into separate uint8 variables (or bools)?
+// out the flags in regs.cc into separate uint8_t variables (or bools)?
 // You'd have to convert on entering and exiting the emulation loop, but I
 // think the perfomance hit would be negligible compared to the gain in not
 // having to mask and shift flags all the time. Investigate after the
 #define SET_N(r)                               (flagN = ((r) & 0x80) >> 7)
 #define SET_V(a,b,r)                   (flagV = (((b) ^ (a) ^ (r) ^ ((r) >> 1)) & 0x80) >> 7)
 
-#define SET_C_CMP(a,b)                 (flagC = ((uint8)(b) < (uint8)(a) ? 1 : 0))
+#define SET_C_CMP(a,b)                 (flagC = ((uint8_t)(b) < (uint8_t)(a) ? 1 : 0))
 #define SET_ZN(r)                              SET_N(r); SET_Z(r)
 #define SET_ZNC_ADD(a,b,r)             SET_N(r); SET_Z(r); SET_C_ADD(a,b)
 #define SET_ZNVC_CMP(a,b,r)            SET_N(r); SET_Z(r); SET_C_CMP(a,b); SET_V(a,b,r)
 
 #define SET_N16(r)                             (flagN = ((r) & 0x8000) >> 15)
 #define SET_V16(a,b,r)                 (flagV = (((b) ^ (a) ^ (r) ^ ((r) >> 1)) & 0x8000) >> 15)
-#define SET_C_CMP16(a,b)               (flagC = ((uint16)(b) < (uint16)(a) ? 1 : 0))
+#define SET_C_CMP16(a,b)               (flagC = ((uint16_t)(b) < (uint16_t)(a) ? 1 : 0))
 #define SET_ZNVC_CMP16(a,b,r)  SET_N16(r); SET_Z(r); SET_C_CMP16(a,b); SET_V16(a,b,r)
 
 #define EA_IMM                         regs.pc++
 #define READ_ZP_X16                    RdMemW(EA_ZP_X)
 #define READ_ABS16                     RdMemW(EA_ABS)
 
-#define READ_IMM_WB(v)         uint16 addr = EA_IMM;           v = regs.RdMem(addr)
-#define READ_ZP_WB(v)          uint16 addr = EA_ZP;            v = regs.RdMem(addr)
-#define READ_ZP_X_WB(v)                uint16 addr = EA_ZP_X;          v = regs.RdMem(addr)
-#define READ_ABS_WB(v)         uint16 addr = EA_ABS;           v = regs.RdMem(addr)
+#define READ_IMM_WB(v)         uint16_t addr = EA_IMM;         v = regs.RdMem(addr)
+#define READ_ZP_WB(v)          uint16_t addr = EA_ZP;          v = regs.RdMem(addr)
+#define READ_ZP_X_WB(v)                uint16_t addr = EA_ZP_X;                v = regs.RdMem(addr)
+#define READ_ABS_WB(v)         uint16_t addr = EA_ABS;         v = regs.RdMem(addr)
 
 #define WRITE_BACK(d)          regs.WrMem(addr, (d))
 
@@ -98,9 +98,9 @@
 // Private global variables
 
 static V6808REGS regs;
-static uint8 flagH, flagI, flagN, flagZ, flagV, flagC;
+static uint8_t flagH, flagI, flagN, flagZ, flagV, flagC;
 
-static uint8 CPUCycles[256] = {
+static uint8_t CPUCycles[256] = {
        1,  2,  1,  1,  1,  1,  2,  2,  4,  4,  2,  2,  2,  2,  2,  2,
        2,  2,  1,  1,  1,  1,  2,  2,  1,  2,  1,  2,  1,  1,  1,  1,
        4,  1,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,  4,
@@ -121,24 +121,24 @@ static uint8 CPUCycles[256] = {
 
 // Private function prototypes
 
-static uint16 RdMemW(uint16);
-static uint16 FetchMemW(uint16);
+static uint16_t RdMemW(uint16_t);
+static uint16_t FetchMemW(uint16_t);
 
 //
 // Read a word out of 6808 memory (little endian format)
 //
-static inline uint16 RdMemW(uint16 address)
+static inline uint16_t RdMemW(uint16_t address)
 {
-       return (uint16)(regs.RdMem(address) << 8) | regs.RdMem(address + 1);
+       return (uint16_t)(regs.RdMem(address) << 8) | regs.RdMem(address + 1);
 }
 
 //
 // Fetch a word out of 6808 memory (little endian format). Increments PC
 //
-static inline uint16 FetchMemW(uint16 address)
+static inline uint16_t FetchMemW(uint16_t address)
 {
        regs.pc += 2;
-       return (uint16)(regs.RdMem(address) << 8) | regs.RdMem(address + 1);
+       return (uint16_t)(regs.RdMem(address) << 8) | regs.RdMem(address + 1);
 }
 
 //
@@ -161,7 +161,7 @@ Add Accumulators        |ABA  |      |      |      |      |1B 2 1|A=A+B     |T T
 // ADD opcodes
 
 #define OP_ADD_HANDLER(m, acc) \
-       uint16 sum = (uint16)(acc) + (m); \
+       uint16_t sum = (uint16_t)(acc) + (m); \
        flagC = sum >> 8; \
        flagH = (sum >> 4) & 0x01; \
        SET_V(m, acc, sum); \
@@ -170,49 +170,49 @@ Add Accumulators        |ABA  |      |      |      |      |1B 2 1|A=A+B     |T T
 
 static void Op8B(void)                                                 // ADDA #
 {
-       uint16 m = READ_IMM;
+       uint16_t m = READ_IMM;
        OP_ADD_HANDLER(m, regs.a);
 }
 
 static void Op9B(void)                                                 // ADDA ZP
 {
-       uint16 m = READ_ZP;
+       uint16_t m = READ_ZP;
        OP_ADD_HANDLER(m, regs.a);
 }
 
 static void OpAB(void)                                                 // ADDA ZP, X
 {
-       uint16 m = READ_ZP_X;
+       uint16_t m = READ_ZP_X;
        OP_ADD_HANDLER(m, regs.a);
 }
 
 static void OpBB(void)                                                 // ADDA ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_ADD_HANDLER(m, regs.a);
 }
 
 static void OpCB(void)                                                 // ADDB #
 {
-       uint16 m = READ_IMM;
+       uint16_t m = READ_IMM;
        OP_ADD_HANDLER(m, regs.b);
 }
 
 static void OpDB(void)                                                 // ADDB ZP
 {
-       uint16 m = READ_ZP;
+       uint16_t m = READ_ZP;
        OP_ADD_HANDLER(m, regs.b);
 }
 
 static void OpEB(void)                                                 // ADDB ZP, X
 {
-       uint16 m = READ_ZP_X;
+       uint16_t m = READ_ZP_X;
        OP_ADD_HANDLER(m, regs.b);
 }
 
 static void OpFB(void)                                                 // ADDB ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_ADD_HANDLER(m, regs.b);
 }
 
@@ -231,7 +231,7 @@ Add with Carry          |ADCA |89 2 2|99 3 2|A9 5 2|B9 4 3|      |A=A+M+C   |T T
 // ADC opcodes
 
 #define OP_ADC_HANDLER(m, acc) \
-       uint16 sum = (uint16)acc + (m) + (uint16)flagC; \
+       uint16_t sum = (uint16_t)acc + (m) + (uint16_t)flagC; \
        flagC = sum >> 8; \
        flagH = (sum >> 4) & 0x01; \
        SET_V(m, acc, sum); \
@@ -240,49 +240,49 @@ Add with Carry          |ADCA |89 2 2|99 3 2|A9 5 2|B9 4 3|      |A=A+M+C   |T T
 
 static void Op89(void)                                                 // ADCA #
 {
-       uint16 m = READ_IMM;
+       uint16_t m = READ_IMM;
        OP_ADC_HANDLER(m, regs.a);
 }
 
 static void Op99(void)                                                 // ADCA ZP
 {
-       uint16 m = READ_ZP;
+       uint16_t m = READ_ZP;
        OP_ADC_HANDLER(m, regs.a);
 }
 
 static void OpA9(void)                                                 // ADCA ZP, X
 {
-       uint16 m = READ_ZP_X;
+       uint16_t m = READ_ZP_X;
        OP_ADC_HANDLER(m, regs.a);
 }
 
 static void OpB9(void)                                                 // ADCA ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_ADC_HANDLER(m, regs.a);
 }
 
 static void OpC9(void)                                                 // ADCB #
 {
-       uint16 m = READ_IMM;
+       uint16_t m = READ_IMM;
        OP_ADC_HANDLER(m, regs.b);
 }
 
 static void OpD9(void)                                                 // ADCB ZP
 {
-       uint16 m = READ_ZP;
+       uint16_t m = READ_ZP;
        OP_ADC_HANDLER(m, regs.b);
 }
 
 static void OpE9(void)                                                 // ADCB ZP, X
 {
-       uint16 m = READ_ZP_X;
+       uint16_t m = READ_ZP_X;
        OP_ADC_HANDLER(m, regs.b);
 }
 
 static void OpF9(void)                                                 // ADCB ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_ADC_HANDLER(m, regs.b);
 }
 
@@ -302,49 +302,49 @@ And                     |ANDA |84 2 2|94 3 2|A4 5 2|B4 4 3|      |A=A+M     |  T
 
 static void Op84(void)                                                 // ANDA #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_AND_HANDLER(m, regs.a);
 }
 
 static void Op94(void)                                                 // ANDA ZP
 {
-       uint8 m = READ_ZP;
+       uint8_t m = READ_ZP;
        OP_AND_HANDLER(m, regs.a);
 }
 
 static void OpA4(void)                                                 // ANDA ZP, X
 {
-       uint16 m = READ_ZP_X;
+       uint16_t m = READ_ZP_X;
        OP_AND_HANDLER(m, regs.a);
 }
 
 static void OpB4(void)                                                 // ANDA ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_AND_HANDLER(m, regs.a);
 }
 
 static void OpC4(void)                                                 // ANDB #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_AND_HANDLER(m, regs.b);
 }
 
 static void OpD4(void)                                                 // ANDB ZP
 {
-       uint8 m = READ_ZP;
+       uint8_t m = READ_ZP;
        OP_AND_HANDLER(m, regs.b);
 }
 
 static void OpE4(void)                                                 // ANDB ZP, X
 {
-       uint16 m = READ_ZP_X;
+       uint16_t m = READ_ZP_X;
        OP_AND_HANDLER(m, regs.b);
 }
 
 static void OpF4(void)                                                 // ANDB ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_AND_HANDLER(m, regs.b);
 }
 
@@ -358,54 +358,54 @@ Bit Test                |BITA |85 2 2|95 3 2|A5 5 2|B5 4 3|      |A+M       |  T
 // BIT opcodes
 
 #define OP_BIT_HANDLER(m, acc) \
-       int8 result = acc & (m); \
+       int8_t result = acc & (m); \
        SET_ZN(result)
 
 static void Op85(void)                                                 // BITA #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_BIT_HANDLER(m, regs.a);
 }
 
 static void Op95(void)                                                 // BITA ZP
 {
-       uint8 m = READ_ZP;
+       uint8_t m = READ_ZP;
        OP_BIT_HANDLER(m, regs.a);
 }
 
 static void OpA5(void)                                                 // BITA ZP, X
 {
-       uint8 m = READ_ZP_X;
+       uint8_t m = READ_ZP_X;
        OP_BIT_HANDLER(m, regs.a);
 }
 
 static void OpB5(void)                                                 // BITA ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_BIT_HANDLER(m, regs.a);
 }
 
 static void OpC5(void)                                                 // BITB #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_BIT_HANDLER(m, regs.b);
 }
 
 static void OpD5(void)                                                 // BITB ZP
 {
-       uint8 m = READ_ZP;
+       uint8_t m = READ_ZP;
        OP_BIT_HANDLER(m, regs.b);
 }
 
 static void OpE5(void)                                                 // BITB ZP, X
 {
-       uint8 m = READ_ZP_X;
+       uint8_t m = READ_ZP_X;
        OP_BIT_HANDLER(m, regs.b);
 }
 
 static void OpF5(void)                                                 // BITB ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_BIT_HANDLER(m, regs.b);
 }
 
@@ -462,54 +462,54 @@ Compare sets flags as if a subtraction had been carried out. If the value in the
 */
 
 #define OP_CMP_HANDLER(m, acc) \
-       uint16 result = acc - (m); \
+       uint16_t result = acc - (m); \
        SET_ZNVC_CMP(m, acc, result)
 
 static void Op81(void)                                                 // CMPA #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_CMP_HANDLER(m, regs.a);
 }
 
 static void Op91(void)                                                 // CMPA ZP
 {
-       uint8 m = READ_ZP;
+       uint8_t m = READ_ZP;
        OP_CMP_HANDLER(m, regs.a);
 }
 
 static void OpA1(void)                                                 // CMPA ZP, X
 {
-       uint8 m = READ_ZP_X;
+       uint8_t m = READ_ZP_X;
        OP_CMP_HANDLER(m, regs.a);
 }
 
 static void OpB1(void)                                                 // CMPA ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_CMP_HANDLER(m, regs.a);
 }
 
 static void OpC1(void)                                                 // CMPB #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_CMP_HANDLER(m, regs.b);
 }
 
 static void OpD1(void)                                                 // CMPB ZP
 {
-       uint8 m = READ_ZP;
+       uint8_t m = READ_ZP;
        OP_CMP_HANDLER(m, regs.b);
 }
 
 static void OpE1(void)                                                 // CMPB ZP, X
 {
-       uint8 m = READ_ZP_X;
+       uint8_t m = READ_ZP_X;
        OP_CMP_HANDLER(m, regs.b);
 }
 
 static void OpF1(void)                                                 // CMPB ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_CMP_HANDLER(m, regs.b);
 }
 
@@ -536,7 +536,7 @@ Complement 1's          |COM  |      |      |63 7 2|73 6 3|      |M=-M      |  T
 
 static void Op63(void)                                                 // COM ZP, X
 {
-       uint8 m;
+       uint8_t m;
        READ_ZP_X_WB(m);
        OP_COM_HANDLER(m);
        WRITE_BACK(m);
@@ -544,7 +544,7 @@ static void Op63(void)                                                      // COM ZP, X
 
 static void Op73(void)                                                 // COM ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_COM_HANDLER(m);
        WRITE_BACK(m);
@@ -578,7 +578,7 @@ Complement 2's          |NEG  |      |      |60 7 2|70 6 3|      |M=00-M    |  T
 
 static void Op60(void)                                                 // NEG ZP, X
 {
-       uint8 m;
+       uint8_t m;
        READ_ZP_X_WB(m);
        OP_NEG_HANDLER(m);
        WRITE_BACK(m);
@@ -586,7 +586,7 @@ static void Op60(void)                                                      // NEG ZP, X
 
 static void Op70(void)                                                 // NEG ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_NEG_HANDLER(m);
        WRITE_BACK(m);
@@ -610,7 +610,7 @@ Decimal Adjust          |DAA  |      |      |      |      |19 2 1|*         |  T
 
 static void Op19(void)                                                 // DAA
 {
-       uint16 result = (uint16)regs.a;
+       uint16_t result = (uint16_t)regs.a;
 
        if ((regs.a & 0x0F) > 0x09 || flagH)
                result += 0x06;
@@ -618,7 +618,7 @@ static void Op19(void)                                                      // DAA
        if ((regs.a & 0xF0) > 0x90 || flagC || ((regs.a & 0xF0) > 0x80 && (regs.a & 0x0F) > 0x09))
                result += 0x60;
 
-       regs.a = (uint8)result;
+       regs.a = (uint8_t)result;
        SET_ZN(result);
        CLR_V;                                                                          // Not sure this is correct...
        flagC |= (result & 0x100) >> 8;                         // Overwrite carry if it was 0, otherwise, ignore
@@ -641,7 +641,7 @@ Decrement               |DEC  |      |      |6A 7 2|7A 6 3|      |M=M-1     |  T
 
 static void Op6A(void)                                                 // DEC ZP, X
 {
-       uint8 m;
+       uint8_t m;
        READ_ZP_X_WB(m);
        OP_DEC_HANDLER(m);
        WRITE_BACK(m);
@@ -649,7 +649,7 @@ static void Op6A(void)                                                      // DEC ZP, X
 
 static void Op7A(void)                                                 // DEC ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_DEC_HANDLER(m);
        WRITE_BACK(m);
@@ -681,49 +681,49 @@ Exclusive OR            |EORA |88 2 2|98 3 2|A8 5 2|B8 4 3|      |A=A(+)M   |  T
 
 static void Op88(void)                                                 // EORA #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_EOR_HANDLER(m, regs.a);
 }
 
 static void Op98(void)                                                 // EORA ZP
 {
-       uint8 m = READ_ZP;
+       uint8_t m = READ_ZP;
        OP_EOR_HANDLER(m, regs.a);
 }
 
 static void OpA8(void)                                                 // EORA ZP, X
 {
-       uint8 m = READ_ZP_X;
+       uint8_t m = READ_ZP_X;
        OP_EOR_HANDLER(m, regs.a);
 }
 
 static void OpB8(void)                                                 // EORA ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_EOR_HANDLER(m, regs.a);
 }
 
 static void OpC8(void)                                                 // EORB #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_EOR_HANDLER(m, regs.b);
 }
 
 static void OpD8(void)                                                 // EORB ZP
 {
-       uint8 m = READ_ZP;
+       uint8_t m = READ_ZP;
        OP_EOR_HANDLER(m, regs.b);
 }
 
 static void OpE8(void)                                                 // EORB ZP, X
 {
-       uint8 m = READ_ZP_X;
+       uint8_t m = READ_ZP_X;
        OP_EOR_HANDLER(m, regs.b);
 }
 
 static void OpF8(void)                                                 // EORB ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_EOR_HANDLER(m, regs.b);
 }
 
@@ -744,7 +744,7 @@ Increment               |INC  |      |      |6C 7 2|7C 6 3|      |M=M+1     |  T
 
 static void Op6C(void)                                                 // INC ZP, X
 {
-       uint8 m;
+       uint8_t m;
        READ_ZP_X_WB(m);
        OP_INC_HANDLER(m);
        WRITE_BACK(m);
@@ -752,7 +752,7 @@ static void Op6C(void)                                                      // INC ZP, X
 
 static void Op7C(void)                                                 // INC ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_INC_HANDLER(m);
        WRITE_BACK(m);
@@ -784,49 +784,49 @@ Load Accumulator        |LDAA |86 2 2|96 3 2|A6 5 2|B6 4 3|      |A=M       |  T
 
 static void Op86(void)                                                 // LDAA #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_LDA_HANDLER(m, regs.a);
 }
 
 static void Op96(void)                                                 // LDAA ZP
 {
-       uint8 m = READ_ZP;
+       uint8_t m = READ_ZP;
        OP_LDA_HANDLER(m, regs.a);
 }
 
 static void OpA6(void)                                                 // LDAA ZP, X
 {
-       uint8 m = READ_ZP_X;
+       uint8_t m = READ_ZP_X;
        OP_LDA_HANDLER(m, regs.a);
 }
 
 static void OpB6(void)                                                 // LDAA ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_LDA_HANDLER(m, regs.a);
 }
 
 static void OpC6(void)                                                 // LDAB #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_LDA_HANDLER(m, regs.b);
 }
 
 static void OpD6(void)                                                 // LDAB ZP
 {
-       uint8 m = READ_ZP;
+       uint8_t m = READ_ZP;
        OP_LDA_HANDLER(m, regs.b);
 }
 
 static void OpE6(void)                                                 // LDAB ZP, X
 {
-       uint8 m = READ_ZP_X;
+       uint8_t m = READ_ZP_X;
        OP_LDA_HANDLER(m, regs.b);
 }
 
 static void OpF6(void)                                                 // LDAB ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_LDA_HANDLER(m, regs.b);
 }
 
@@ -846,49 +846,49 @@ OR, Inclusive           |ORAA |8A 2 2|9A 3 2|AA 5 2|BA 4 3|      |A=A+M     |  T
 
 static void Op8A(void)                                                 // ORAA #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_ORA_HANDLER(m, regs.a);
 }
 
 static void Op9A(void)                                                 // ORAA ZP
 {
-       uint8 m = READ_ZP;
+       uint8_t m = READ_ZP;
        OP_ORA_HANDLER(m, regs.a);
 }
 
 static void OpAA(void)                                                 // ORAA ZP, X
 {
-       uint8 m = READ_ZP_X;
+       uint8_t m = READ_ZP_X;
        OP_ORA_HANDLER(m, regs.a);
 }
 
 static void OpBA(void)                                                 // ORAA ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_ORA_HANDLER(m, regs.a);
 }
 
 static void OpCA(void)                                                 // ORAB #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_ORA_HANDLER(m, regs.b);
 }
 
 static void OpDA(void)                                                 // ORAB ZP
 {
-       uint8 m = READ_ZP;
+       uint8_t m = READ_ZP;
        OP_ORA_HANDLER(m, regs.b);
 }
 
 static void OpEA(void)                                                 // ORAB ZP, X
 {
-       uint8 m = READ_ZP_X;
+       uint8_t m = READ_ZP_X;
        OP_ORA_HANDLER(m, regs.b);
 }
 
 static void OpFA(void)                                                 // ORAB ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_ORA_HANDLER(m, regs.b);
 }
 
@@ -932,7 +932,7 @@ Rotate Left             |ROL  |      |      |69 7 2|79 6 3|      |Memory  *1|  T
 // ROL opcodes
 
 #define OP_ROL_HANDLER(m) \
-       uint8 newCarry = (m & 0x80) >> 7; \
+       uint8_t newCarry = (m & 0x80) >> 7; \
        m = (m << 1) | flagC; \
        SET_ZN(m); \
        flagC = newCarry; \
@@ -940,7 +940,7 @@ Rotate Left             |ROL  |      |      |69 7 2|79 6 3|      |Memory  *1|  T
 
 static void Op69(void)                                                 // ROL ZP, X
 {
-       uint8 m;
+       uint8_t m;
        READ_ZP_X_WB(m);
        OP_ROL_HANDLER(m);
        WRITE_BACK(m);
@@ -948,7 +948,7 @@ static void Op69(void)                                                      // ROL ZP, X
 
 static void Op79(void)                                                 // ROL ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_ROL_HANDLER(m);
        WRITE_BACK(m);
@@ -975,7 +975,7 @@ Rotate Right            |ROR  |      |      |66 7 2|76 6 3|      |Memory  *2|  T
 // ROR opcodes
 
 #define OP_ROR_HANDLER(m) \
-       uint8 newCarry = m & 0x01; \
+       uint8_t newCarry = m & 0x01; \
        m = (m >> 1) | (flagC << 7); \
        SET_ZN(m); \
        flagC = newCarry; \
@@ -983,7 +983,7 @@ Rotate Right            |ROR  |      |      |66 7 2|76 6 3|      |Memory  *2|  T
 
 static void Op66(void)                                                 // ROR ZP, X
 {
-       uint8 m;
+       uint8_t m;
        READ_ZP_X_WB(m);
        OP_ROR_HANDLER(m);
        WRITE_BACK(m);
@@ -991,7 +991,7 @@ static void Op66(void)                                                      // ROR ZP, X
 
 static void Op76(void)                                                 // ROR ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_ROR_HANDLER(m);
        WRITE_BACK(m);
@@ -1018,7 +1018,7 @@ Arithmetic Shift Left   |ASL  |      |      |68 7 2|78 6 3|      |Memory  *3|  T
 // ASL opcodes
 
 #define OP_ASL_HANDLER(m) \
-       uint8 newCarry = (m & 0x80) >> 7; \
+       uint8_t newCarry = (m & 0x80) >> 7; \
        m <<= 1; \
        SET_ZN(m); \
        flagC = newCarry; \
@@ -1026,7 +1026,7 @@ Arithmetic Shift Left   |ASL  |      |      |68 7 2|78 6 3|      |Memory  *3|  T
 
 static void Op68(void)                                                 // ASL ZP, X
 {
-       uint8 m;
+       uint8_t m;
        READ_ZP_X_WB(m);
        OP_ASL_HANDLER(m);
        WRITE_BACK(m);
@@ -1034,7 +1034,7 @@ static void Op68(void)                                                    // ASL ZP, X
 
 static void Op78(void)                                                 // ASL ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_ASL_HANDLER(m);
        WRITE_BACK(m);
@@ -1061,7 +1061,7 @@ Arithmetic Shift Right  |ASR  |      |      |67 7 2|77 6 3|      |Memory  *4|  T
 // ASR opcodes
 
 #define OP_ASR_HANDLER(m) \
-       uint8 newCarry = m & 0x01; \
+       uint8_t newCarry = m & 0x01; \
        m = (m >> 1) | (m & 0x80); \
        SET_ZN(m); \
        flagC = newCarry; \
@@ -1069,7 +1069,7 @@ Arithmetic Shift Right  |ASR  |      |      |67 7 2|77 6 3|      |Memory  *4|  T
 
 static void Op67(void)                                                 // ASR ZP, X
 {
-       uint8 m;
+       uint8_t m;
        READ_ZP_X_WB(m);
        OP_ASR_HANDLER(m);
        WRITE_BACK(m);
@@ -1077,7 +1077,7 @@ static void Op67(void)                                                    // ASR ZP, X
 
 static void Op77(void)                                                 // ASR ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_ASR_HANDLER(m);
        WRITE_BACK(m);
@@ -1104,7 +1104,7 @@ Logic Shift Right       |LSR  |      |      |64 7 2|74 6 3|      |Memory  *5|  T
 // LSR opcodes
 
 #define OP_LSR_HANDLER(m) \
-       uint8 newCarry = m & 0x01; \
+       uint8_t newCarry = m & 0x01; \
        m >>= 1; \
        SET_ZN(m); \
        flagC = newCarry; \
@@ -1112,7 +1112,7 @@ Logic Shift Right       |LSR  |      |      |64 7 2|74 6 3|      |Memory  *5|  T
 
 static void Op64(void)                                                 // LSR ZP, X
 {
-       uint8 m;
+       uint8_t m;
        READ_ZP_X_WB(m);
        OP_LSR_HANDLER(m);
        WRITE_BACK(m);
@@ -1120,7 +1120,7 @@ static void Op64(void)                                                    // LSR ZP, X
 
 static void Op74(void)                                                 // LSR ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_LSR_HANDLER(m);
        WRITE_BACK(m);
@@ -1184,57 +1184,57 @@ Subtract Accumulators   |SBA  |      |      |      |      |10 2 1|A=A-B     |  T
 // SUB opcodes
 
 #define OP_SUB_HANDLER(m, acc) \
-       uint16 sum = (uint16)acc - (m); \
+       uint16_t sum = (uint16_t)acc - (m); \
        flagC = sum >> 15; \
        SET_V(m, acc, sum); \
-       acc = (uint8)sum; \
+       acc = (uint8_t)sum; \
        SET_ZN(acc)
 
 static void Op80(void)                                                 // SUBA #
 {
-       uint16 m = READ_IMM;
+       uint16_t m = READ_IMM;
        OP_SUB_HANDLER(m, regs.a);
 }
 
 static void Op90(void)                                                 // SUBA ZP
 {
-       uint16 m = READ_ZP;
+       uint16_t m = READ_ZP;
        OP_SUB_HANDLER(m, regs.a);
 }
 
 static void OpA0(void)                                                 // SUBA ZP, X
 {
-       uint16 m = READ_ZP_X;
+       uint16_t m = READ_ZP_X;
        OP_SUB_HANDLER(m, regs.a);
 }
 
 static void OpB0(void)                                                 // SUBA ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_SUB_HANDLER(m, regs.a);
 }
 
 static void OpC0(void)                                                 // SUBB #
 {
-       uint16 m = READ_IMM;
+       uint16_t m = READ_IMM;
        OP_SUB_HANDLER(m, regs.b);
 }
 
 static void OpD0(void)                                                 // SUBB ZP
 {
-       uint16 m = READ_ZP;
+       uint16_t m = READ_ZP;
        OP_SUB_HANDLER(m, regs.b);
 }
 
 static void OpE0(void)                                                 // SUBB ZP, X
 {
-       uint16 m = READ_ZP_X;
+       uint16_t m = READ_ZP_X;
        OP_SUB_HANDLER(m, regs.b);
 }
 
 static void OpF0(void)                                                 // SUBB ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_SUB_HANDLER(m, regs.b);
 }
 
@@ -1253,57 +1253,57 @@ Subtract with Carry     |SBCA |82 2 2|92 3 2|A2 5 2|B2 4 3|      |A=A-M-C   |  T
 // SBC opcodes
 
 #define OP_SBC_HANDLER(m, acc) \
-       uint16 sum = (uint16)acc - (m) - (uint16)flagC; \
+       uint16_t sum = (uint16_t)acc - (m) - (uint16_t)flagC; \
        flagC = sum >> 15; \
        SET_V(m, acc, sum); \
-       acc = (uint8)sum; \
+       acc = (uint8_t)sum; \
        SET_ZN(acc)
 
 static void Op82(void)                                                 // SBCA #
 {
-       uint16 m = READ_IMM;
+       uint16_t m = READ_IMM;
        OP_SBC_HANDLER(m, regs.a);
 }
 
 static void Op92(void)                                                 // SBCA ZP
 {
-       uint16 m = READ_ZP;
+       uint16_t m = READ_ZP;
        OP_SBC_HANDLER(m, regs.a);
 }
 
 static void OpA2(void)                                                 // SBCA ZP, X
 {
-       uint16 m = READ_ZP_X;
+       uint16_t m = READ_ZP_X;
        OP_SBC_HANDLER(m, regs.a);
 }
 
 static void OpB2(void)                                                 // SBCA ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_SBC_HANDLER(m, regs.a);
 }
 
 static void OpC2(void)                                                 // SBCB #
 {
-       uint16 m = READ_IMM;
+       uint16_t m = READ_IMM;
        OP_SBC_HANDLER(m, regs.b);
 }
 
 static void OpD2(void)                                                 // SBCB ZP
 {
-       uint16 m = READ_ZP;
+       uint16_t m = READ_ZP;
        OP_SBC_HANDLER(m, regs.b);
 }
 
 static void OpE2(void)                                                 // SBCB ZP, X
 {
-       uint16 m = READ_ZP_X;
+       uint16_t m = READ_ZP_X;
        OP_SBC_HANDLER(m, regs.b);
 }
 
 static void OpF2(void)                                                 // SBCB ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_SBC_HANDLER(m, regs.b);
 }
 
@@ -1344,7 +1344,7 @@ Test, Zero/Minus        |TST  |      |      |6D 7 2|7D 6 3|      |M-00      |  T
 
 static void Op6D(void)                                                 // TST ZP, X
 {
-       uint8 m;
+       uint8_t m;
        READ_ZP_X_WB(m);
        OP_TST_HANDLER(m);
        WRITE_BACK(m);
@@ -1352,7 +1352,7 @@ static void Op6D(void)                                                    // TST ZP, X
 
 static void Op7D(void)                                                 // TST ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_TST_HANDLER(m);
        WRITE_BACK(m);
@@ -1381,30 +1381,30 @@ Compare sets flags as if a subtraction had been carried out. If the value in the
 */
 
 #define OP_CPX_HANDLER(m) \
-       uint32 result = regs.x - (m); \
+       uint32_t result = regs.x - (m); \
        SET_ZNVC_CMP16(m, regs.x, result)
 
 static void Op8C(void)                                                 // CPX #
 {
-       uint16 m = READ_IMM16;
+       uint16_t m = READ_IMM16;
        OP_CPX_HANDLER(m);
 }
 
 static void Op9C(void)                                                 // CPX ZP
 {
-       uint16 m = READ_ZP16;
+       uint16_t m = READ_ZP16;
        OP_CPX_HANDLER(m);
 }
 
 static void OpAC(void)                                                 // CPX ZP, X
 {
-       uint16 m = READ_ZP_X16;
+       uint16_t m = READ_ZP_X16;
        OP_CPX_HANDLER(m);
 }
 
 static void OpBC(void)                                                 // CPX ABS
 {
-       uint16 m = READ_ABS16;
+       uint16_t m = READ_ABS16;
        OP_CPX_HANDLER(m);
 }
 
@@ -1519,37 +1519,37 @@ Store Stack Pointer     |STS  |      |9F 5 2|AF 7 2|BF 6 3|      |Formula 5 |  9
 
 static void OpDF(void)                                                 // STX ZP
 {
-       uint16 m = EA_ZP;
+       uint16_t m = EA_ZP;
        OP_ST_HANDLER(m, regs.x);
 }
 
 static void OpEF(void)                                                 // STX ZP, X
 {
-       uint16 m = EA_ZP_X;
+       uint16_t m = EA_ZP_X;
        OP_ST_HANDLER(m, regs.x);
 }
 
 static void OpFF(void)                                                 // STX ABS
 {
-       uint16 m = EA_ABS;
+       uint16_t m = EA_ABS;
        OP_ST_HANDLER(m, regs.x);
 }
 
 static void Op9F(void)                                                 // STS ZP
 {
-       uint16 m = EA_ZP;
+       uint16_t m = EA_ZP;
        OP_ST_HANDLER(m, regs.s);
 }
 
 static void OpAF(void)                                                 // STS ZP, X
 {
-       uint16 m = EA_ZP_X;
+       uint16_t m = EA_ZP_X;
        OP_ST_HANDLER(m, regs.s);
 }
 
 static void OpBF(void)                                                 // STS ABS
 {
-       uint16 m = EA_ABS;
+       uint16_t m = EA_ABS;
        OP_ST_HANDLER(m, regs.s);
 }
 
@@ -1592,7 +1592,7 @@ Plus                    |BPL  |      |2A 4 2|      |      |      |N=0       |
 
 static void Op20(void)                                                 // BRA
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
        regs.pc += m;
 }
 
@@ -1601,7 +1601,7 @@ static void Op24(void)                                                    // BCC
 // NOTE: We can optimize this by following the maxim: "Don't branch!" by converting the boolean
 //       result into a multiplication. The only way to know if this is a win is to do some profiling
 //       both with and without the optimization.
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
 //Note sure if the ! operator will do what we want, so we use ^ 1
@@ -1614,7 +1614,7 @@ static void Op24(void)                                                    // BCC
 
 static void Op25(void)                                                 // BCS
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += m * (flagC);
@@ -1626,7 +1626,7 @@ static void Op25(void)                                                    // BCS
 
 static void Op27(void)                                                 // BEQ
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += m * (flagZ);
@@ -1638,7 +1638,7 @@ static void Op27(void)                                                    // BEQ
 
 static void Op2C(void)                                                 // BGE
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += m * ((flagN ^ flagV) ^ 0x01);
@@ -1650,7 +1650,7 @@ static void Op2C(void)                                                    // BGE
 
 static void Op2E(void)                                                 // BGT
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += m * ((flagZ | (flagN ^ flagV)) ^ 0x01);
@@ -1662,7 +1662,7 @@ static void Op2E(void)                                                    // BGT
 
 static void Op22(void)                                                 // BHI
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += m * ((flagZ | flagC) ^ 0x01);
@@ -1674,7 +1674,7 @@ static void Op22(void)                                                    // BHI
 
 static void Op2F(void)                                                 // BLE
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += m * (flagZ | (flagN ^ flagV));
@@ -1686,7 +1686,7 @@ static void Op2F(void)                                                    // BLE
 
 static void Op23(void)                                                 // BLS
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += m * (flagZ | flagC);
@@ -1698,7 +1698,7 @@ static void Op23(void)                                                    // BLS
 
 static void Op2D(void)                                                 // BLT
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += m * (flagN ^ flagV);
@@ -1710,7 +1710,7 @@ static void Op2D(void)                                                    // BLT
 
 static void Op2B(void)                                                 // BMI
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += m * (flagN);
@@ -1722,7 +1722,7 @@ static void Op2B(void)                                                    // BMI
 
 static void Op26(void)                                                 // BNE
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += m * (flagZ ^ 0x01);
@@ -1734,7 +1734,7 @@ static void Op26(void)                                                    // BNE
 
 static void Op28(void)                                                 // BVC
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += m * (flagV ^ 0x01);
@@ -1746,7 +1746,7 @@ static void Op28(void)                                                    // BVC
 
 static void Op29(void)                                                 // BVS
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += m * (flagV);
@@ -1758,7 +1758,7 @@ static void Op29(void)                                                    // BVS
 
 static void Op2A(void)                                                 // BPL
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += m * (flagN ^ 0x01);
@@ -1778,7 +1778,7 @@ Jump to Subroutine      |JSR  |      |      |AD 8 2|BD 9 3|      |          |
 
 static void Op8D(void)                                                 // BSR
 {
-       int16 m = (int16)(int8)READ_IMM;
+       int16_t m = (int16_t)(int8_t)READ_IMM;
        PUSH16(regs.pc);
        regs.pc += m;
 }
@@ -1795,14 +1795,14 @@ static void Op7E(void)                                                  // JMP ABS
 
 static void OpAD(void)                                                 // JSR ZP, X
 {
-       uint16 m = EA_ZP_X;
+       uint16_t m = EA_ZP_X;
        PUSH16(regs.pc);
        regs.pc = m;
 }
 
 static void OpBD(void)                                                 // JSR ABS
 {
-       uint16 m = EA_ABS;
+       uint16_t m = EA_ABS;
        PUSH16(regs.pc);
        regs.pc = m;
 }
@@ -2006,11 +2006,11 @@ void (* exec_op[256])() = {
 //
 // Internal "memcpy" (so we don't have to link with any external libraries!)
 //
-static void myMemcpy(void * dst, void * src, uint32 size)
+static void myMemcpy(void * dst, void * src, uint32_t size)
 {
-       uint8 * d = (uint8 *)dst, * s = (uint8 *)src;
+       uint8_t * d = (uint8_t *)dst, * s = (uint8_t *)src;
 
-       for(uint32 i=0; i<size; i++)
+       for(uint32_t i=0; i<size; i++)
                d[i] = s[i];
 }
 
@@ -2021,13 +2021,13 @@ static bool logGo = false;
 //
 // Function to execute 6808 for "cycles" cycles
 //
-void Execute6808(V6808REGS * context, uint32 cycles)
+void Execute6808(V6808REGS * context, uint32_t cycles)
 {
 #warning "V6808_STATE_WAI is not properly handled yet! !!! FIX !!!"
 #warning "Need to convert from destructive clock to non-destructive. !!! FIX !!!"
 
        myMemcpy(&regs, context, sizeof(V6808REGS));
-       UNPACK_FLAGS;                                                           // Explode flags register into individual uint8s
+       UNPACK_FLAGS;                                                           // Explode flags register into individual uint8_ts
 
        // Execute here...
        while (regs.clock < cycles)
@@ -2036,7 +2036,7 @@ void Execute6808(V6808REGS * context, uint32 cycles)
 if (logGo)
        Decode6808(regs.pc);
 #endif
-               uint8 opcode = regs.RdMem(regs.pc++);
+               uint8_t opcode = regs.RdMem(regs.pc++);
 
 #ifdef __DEBUG__
 //if (!(regs.cpuFlags & V6808_STATE_ILLEGAL_INST))
@@ -2116,7 +2116,7 @@ logGo = true;
 //
 // Get the clock of the currently executing CPU
 //
-uint64 GetCurrentV6808Clock(void)
+uint64_t GetCurrentV6808Clock(void)
 {
        return regs.clock;
 }
index 2b25aee042beaa9498af14590ffe17299066c3d7..4ab68a68afb0427313c6951f3c0c21711619843f 100755 (executable)
@@ -9,7 +9,7 @@
 #ifndef __V6808_H__
 #define __V6808_H__
 
-#include "types.h"
+#include <stdint.h>
 
 // Useful defines
 
 
 struct V6808REGS
 {
-       uint16 pc;                                              // 6808 PC register
-       uint16 x;                                               // 6808 X index register
-       uint16 s;                                               // 6808 System stack pointer
-       uint8 cc;                                               // 6808 Condition Code register
-       uint8 a;                                                // 6808 A register
-       uint8 b;                                                // 6808 B register
-       uint64 clock;                                   // 6808 clock
-       uint8 (* RdMem)(uint16);                // Address of uint8 read routine
-       void (* WrMem)(uint16, uint8);  // Address of uint8 write routine
-       uint32 cpuFlags;                                // v6808 IRQ/RESET flags
-       uint32 clockOverrun;                    // Amount of overflow between runs
+       uint16_t pc;                                    // 6808 PC register
+       uint16_t x;                                             // 6808 X index register
+       uint16_t s;                                             // 6808 System stack pointer
+       uint8_t cc;                                             // 6808 Condition Code register
+       uint8_t a;                                              // 6808 A register
+       uint8_t b;                                              // 6808 B register
+       uint64_t clock;                                 // 6808 clock
+       uint8_t (* RdMem)(uint16_t);    // Address of uint8 read routine
+       void (* WrMem)(uint16_t, uint8_t);      // Address of uint8 write routine
+       uint32_t cpuFlags;                              // v6808 IRQ/RESET flags
+       uint32_t clockOverrun;                  // Amount of overflow between runs
 };
 
 // Function prototypes
 
-void Execute6808(V6808REGS *, uint32); // Function to execute 6808 instructions
-uint64 GetCurrentV6808Clock(void);             // Get the clock of the currently executing CPU
+void Execute6808(V6808REGS *, uint32_t);       // Function to execute 6808 instructions
+uint64_t GetCurrentV6808Clock(void);           // Get the clock of the currently executing CPU
 //uint8 GetCCRegister(void);                           // Hmm.
 
 #endif // __V6808_H__
+
index 68b9998539b82e783ab9f8a6eb2b6fb50239d6d2..2bb970f2e5045383a02ddaa07d00dbdcc9b83b88 100755 (executable)
@@ -41,9 +41,9 @@ bool disasm = false;//so we can extern this shit
 #define SET_H(a,b,r)           (flagH = (((a) ^ (b) ^ (r)) & 0x10) >> 4)
 
 //Not sure that this code is computing the carry correctly... Investigate! [Seems to be]
-//#define SET_C_ADD(a,b)               (flagC = ((uint8)(b) > (uint8)(~(a)) ? 1 : 0))
-//#define SET_C_SUB(a,b)               (regs.cc = ((uint8)(b) >= (uint8)(a) ? regs.cc | FLAG_C : regs.cc & ~FLAG_C))
-//#define SET_C_CMP(a,b)               (flagC = ((uint8)(b) >= (uint8)(a) ? 1 : 0))
+//#define SET_C_ADD(a,b)               (flagC = ((uint8_t)(b) > (uint8_t)(~(a)) ? 1 : 0))
+//#define SET_C_SUB(a,b)               (regs.cc = ((uint8_t)(b) >= (uint8_t)(a) ? regs.cc | FLAG_C : regs.cc & ~FLAG_C))
+//#define SET_C_CMP(a,b)               (flagC = ((uint8_t)(b) >= (uint8_t)(a) ? 1 : 0))
 #define SET_ZN(r)                      SET_N(r); SET_Z(r)
 #define SET_ZN16(r)                    SET_N16(r); SET_Z(r)
 //#define SET_ZNC_ADD(a,b,r)   SET_N(r); SET_Z(r); SET_C_ADD(a,b)
@@ -64,10 +64,10 @@ bool disasm = false;//so we can extern this shit
 #define READ_ABS                       regs.RdMem(EA_ABS)
 #define READ_ABS16                     RdMemW(EA_ABS)
 
-#define READ_IMM_WB(v)         uint16 addr = EA_IMM;      v = regs.RdMem(addr)
-#define READ_DP_WB(v)          uint16 addr = EA_DP;       v = regs.RdMem(addr)
-#define READ_IDX_WB(v)         uint16 addr = EA_IDX;      v = regs.RdMem(addr)
-#define READ_ABS_WB(v)         uint16 addr = EA_ABS;      v = regs.RdMem(addr)
+#define READ_IMM_WB(v)         uint16_t addr = EA_IMM;      v = regs.RdMem(addr)
+#define READ_DP_WB(v)          uint16_t addr = EA_DP;       v = regs.RdMem(addr)
+#define READ_IDX_WB(v)         uint16_t addr = EA_IDX;      v = regs.RdMem(addr)
+#define READ_ABS_WB(v)         uint16_t addr = EA_ABS;      v = regs.RdMem(addr)
 
 #define WRITE_BACK(d)          regs.WrMem(addr, (d))
 
@@ -93,9 +93,9 @@ bool disasm = false;//so we can extern this shit
 // Private global variables
 
 static V6809REGS regs;
-static uint8 flagE, flagF, flagH, flagI, flagN, flagZ, flagV, flagC;
+static uint8_t flagE, flagF, flagH, flagI, flagN, flagZ, flagV, flagC;
 
-uint8 page0Cycles[256] = {
+uint8_t page0Cycles[256] = {
        6,  1,  1,  6,  6,  1,  6,  6,  6,  6,  6,  1,  6,  6,  3,  6,          // $0x
        1,  1,  2,  2,  1,  1,  5,  9,  1,  2,  3,  1,  3,  2,  8,  7,          // $1x
        3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,  3,          // $2x
@@ -114,7 +114,7 @@ uint8 page0Cycles[256] = {
        5,  5,  5,  7,  5,  5,  5,  5,  5,  5,  5,  5,  6,  6,  6,  6           // $Fx
 };
 
-uint8 page1Cycles[256] = {
+uint8_t page1Cycles[256] = {
        1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,          // $0x
        1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,          // $1x
        1,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,  5,          // $2x
@@ -133,7 +133,7 @@ uint8 page1Cycles[256] = {
        1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  7,  7           // $Fx
 };
 
-uint8 page2Cycles[256] = {
+uint8_t page2Cycles[256] = {
        1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,          // $0x
        1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,          // $1x
        1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,  1,          // $2x
@@ -154,35 +154,35 @@ uint8 page2Cycles[256] = {
 
 // Private function prototypes
 
-static uint16 RdMemW(uint16 addr);
-static uint16 FetchMemW(uint16 addr);
-static void WrMemW(uint16 addr, uint16 w);
-static uint16 ReadEXG(uint8);                                  // Read TFR/EXG post byte
-static void WriteEXG(uint8, uint16);                   // Set TFR/EXG data
-static uint16 DecodeReg(uint8);                                        // Decode register data
-static uint16 DecodeIDX(uint8);                                        // Decode IDX data
+static uint16_t RdMemW(uint16_t addr);
+static uint16_t FetchMemW(uint16_t addr);
+static void WrMemW(uint16_t addr, uint16_t w);
+static uint16_t ReadEXG(uint8_t);                                      // Read TFR/EXG post byte
+static void WriteEXG(uint8_t, uint16_t);                       // Set TFR/EXG data
+static uint16_t DecodeReg(uint8_t);                                    // Decode register data
+static uint16_t DecodeIDX(uint8_t);                                    // Decode IDX data
 
 //
 // Read word from memory function
 //
-static inline uint16 RdMemW(uint16 addr)
+static inline uint16_t RdMemW(uint16_t addr)
 {
-       return (uint16)(regs.RdMem(addr) << 8) | regs.RdMem(addr + 1);
+       return (uint16_t)(regs.RdMem(addr) << 8) | regs.RdMem(addr + 1);
 }
 
 //
 // Fetch a word from memory function. Increments PC
 //
-static inline uint16 FetchMemW(uint16 addr)
+static inline uint16_t FetchMemW(uint16_t addr)
 {
        regs.pc += 2;
-       return (uint16)(regs.RdMem(addr) << 8) | regs.RdMem(addr + 1);
+       return (uint16_t)(regs.RdMem(addr) << 8) | regs.RdMem(addr + 1);
 }
 
 //
 // Write word to memory function
 //
-static inline void WrMemW(uint16 addr, uint16 w)
+static inline void WrMemW(uint16_t addr, uint16_t w)
 {
        regs.WrMem(addr + 0, w >> 8);
        regs.WrMem(addr + 1, w & 0xFF);
@@ -191,9 +191,9 @@ static inline void WrMemW(uint16 addr, uint16 w)
 //
 // Function to read TFR/EXG post byte
 //
-uint16 ReadEXG(uint8 code)
+uint16_t ReadEXG(uint8_t code)
 {
-       uint16 retval;
+       uint16_t retval;
 
        switch (code)
        {
@@ -238,7 +238,7 @@ uint16 ReadEXG(uint8 code)
 //
 // Function to set TFR/EXG data
 //
-void WriteEXG(uint8 code, uint16 data)
+void WriteEXG(uint8_t code, uint16_t data)
 {
        switch (code)
        {
@@ -268,9 +268,9 @@ void WriteEXG(uint8 code, uint16 data)
 //
 // Function to decode register data
 //
-uint16 DecodeReg(uint8 reg)
+uint16_t DecodeReg(uint8_t reg)
 {
-       uint16 retval;
+       uint16_t retval;
 
        switch (reg)
        {
@@ -290,10 +290,10 @@ uint16 DecodeReg(uint8 reg)
 //
 // Function to decode IDX data
 //
-uint16 DecodeIDX(uint8 code)
+uint16_t DecodeIDX(uint8_t code)
 {
-       uint16 addr, woff;
-       uint8 reg = (code & 0x60) >> 5, idxind = (code & 0x10) >> 4, lo_nyb = code & 0x0F;
+       uint16_t addr, woff;
+       uint8_t reg = (code & 0x60) >> 5, idxind = (code & 0x10) >> 4, lo_nyb = code & 0x0F;
 
        if (!(code & 0x80))                                                     // Hi bit unset? Then decode 4 bit offset
                addr = DecodeReg(reg) + (idxind ? lo_nyb - 16 : lo_nyb);
@@ -330,15 +330,15 @@ uint16 DecodeIDX(uint8 code)
                                addr = RdMemW(woff);
                                break;
                        case 5:
-                               woff = DecodeReg(reg) + (int16)(int8)regs.b;
+                               woff = DecodeReg(reg) + (int16_t)(int8_t)regs.b;
                                addr = RdMemW(woff);
                                break;
                        case 6:
-                               woff = DecodeReg(reg) + (int16)(int8)regs.a;
+                               woff = DecodeReg(reg) + (int16_t)(int8_t)regs.a;
                                addr = RdMemW(woff);
                                break;
                        case 8:
-                               woff = DecodeReg(reg) + (int16)(int8)regs.RdMem(regs.pc++);
+                               woff = DecodeReg(reg) + (int16_t)(int8_t)regs.RdMem(regs.pc++);
                                addr = RdMemW(woff);
                                break;
                        case 9:
@@ -350,7 +350,7 @@ uint16 DecodeIDX(uint8 code)
                                addr = RdMemW(woff);
                                break;
                        case 12:
-                               woff = regs.pc + (int16)(int8)regs.RdMem(regs.pc++);
+                               woff = regs.pc + (int16_t)(int8_t)regs.RdMem(regs.pc++);
                                addr = RdMemW(woff);
                                break;
                        case 13:
@@ -404,12 +404,12 @@ uint16 DecodeIDX(uint8 code)
                    }
                    addr = DecodeReg(reg);  break; }
         case 4:  { addr = DecodeReg(reg);  break; }
-        case 5:  { addr = DecodeReg(reg) + (int16)(int8)regs.b;  break; }
-        case 6:  { addr = DecodeReg(reg) + (int16)(int8)regs.a;  break; }
-        case 8:  { addr = DecodeReg(reg) + (int16)(int8)regs.RdMem(regs.pc++);  break; }
+        case 5:  { addr = DecodeReg(reg) + (int16_t)(int8_t)regs.b;  break; }
+        case 6:  { addr = DecodeReg(reg) + (int16_t)(int8_t)regs.a;  break; }
+        case 8:  { addr = DecodeReg(reg) + (int16_t)(int8_t)regs.RdMem(regs.pc++);  break; }
         case 9:  { addr = DecodeReg(reg) + FetchMemW(regs.pc);  break; }
         case 11: { addr = DecodeReg(reg) + ((regs.a << 8) | regs.b);  break; }
-        case 12: { addr = regs.pc + (int16)(int8)regs.RdMem(regs.pc++);  break; }
+        case 12: { addr = regs.pc + (int16_t)(int8_t)regs.RdMem(regs.pc++);  break; }
         case 13: { addr = regs.pc + FetchMemW(regs.pc);  break; }
                        }
                }
@@ -445,7 +445,7 @@ uint16 DecodeIDX(uint8 code)
 // ADC opcodes
 
 #define OP_ADC_HANDLER(m, acc) \
-       uint16 sum = (uint16)acc + (m) + (uint16)flagC; \
+       uint16_t sum = (uint16_t)acc + (m) + (uint16_t)flagC; \
        flagC = (sum >> 8) & 0x01; \
        SET_H(m, acc, sum); \
        SET_V(m, acc, sum); \
@@ -464,49 +464,49 @@ Old flag handling code:
 
 static void Op89(void)                                                 // ADCA #
 {
-       uint16 m = READ_IMM;
+       uint16_t m = READ_IMM;
        OP_ADC_HANDLER(m, regs.a);
 }
 
 static void Op99(void)                                                 // ADCA DP
 {
-       uint16 m = READ_DP;
+       uint16_t m = READ_DP;
        OP_ADC_HANDLER(m, regs.a);
 }
 
 static void OpA9(void)                                                 // ADCA IDX
 {
-       uint16 m = READ_IDX;
+       uint16_t m = READ_IDX;
        OP_ADC_HANDLER(m, regs.a);
 }
 
 static void OpB9(void)                                                 // ADCA ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_ADC_HANDLER(m, regs.a);
 }
 
 static void OpC9(void)                                                 // ADCB #
 {
-       uint16 m = READ_IMM;
+       uint16_t m = READ_IMM;
        OP_ADC_HANDLER(m, regs.b);
 }
 
 static void OpD9(void)                                                 // ADCB DP
 {
-       uint16 m = READ_DP;
+       uint16_t m = READ_DP;
        OP_ADC_HANDLER(m, regs.b);
 }
 
 static void OpE9(void)                                                 // ADCB IDX
 {
-       uint16 m = READ_IDX;
+       uint16_t m = READ_IDX;
        OP_ADC_HANDLER(m, regs.b);
 }
 
 static void OpF9(void)                                                 // ADCB ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_ADC_HANDLER(m, regs.b);
 }
 
@@ -533,7 +533,7 @@ static void OpF9(void)                                                      // ADCB ABS
 // ADD opcodes
 
 #define OP_ADD_HANDLER(m, acc) \
-       uint16 sum = (uint16)(acc) + (m); \
+       uint16_t sum = (uint16_t)(acc) + (m); \
        flagC = (sum >> 8) & 0x01; \
        SET_H(m, acc, sum); \
        SET_V(m, acc, sum); \
@@ -541,8 +541,8 @@ static void OpF9(void)                                                      // ADCB ABS
        SET_ZN(acc)
 
 #define OP_ADD_HANDLER16(m, hireg, loreg) \
-       uint32 acc = (uint32)((hireg << 8) | loreg); \
-       uint32 sum = acc + (m); \
+       uint32_t acc = (uint32_t)((hireg << 8) | loreg); \
+       uint32_t sum = acc + (m); \
        flagC = (sum >> 16) & 0x01; \
        SET_V16(m, acc, sum); \
        acc = sum & 0xFFFF; \
@@ -571,78 +571,78 @@ Old flags:
 
 static void Op3A(void)                                                 // ABX
 {
-       regs.x += (uint16)regs.b;
+       regs.x += (uint16_t)regs.b;
 }
 
 static void Op8B(void)                                                 // ADDA #
 {
-       uint16 m = READ_IMM;
+       uint16_t m = READ_IMM;
        OP_ADD_HANDLER(m, regs.a);
 }
 
 static void Op9B(void)                                                 // ADDA DP
 {
-       uint16 m = READ_DP;
+       uint16_t m = READ_DP;
        OP_ADD_HANDLER(m, regs.a);
 }
 
 static void OpAB(void)                                                 // ADDA IDX
 {
-       uint16 m = READ_IDX;
+       uint16_t m = READ_IDX;
        OP_ADD_HANDLER(m, regs.a);
 }
 
 static void OpBB(void)                                                 // ADDA ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_ADD_HANDLER(m, regs.a);
 }
 
 static void OpC3(void)                                                 // ADDD #
 {
-       uint32 m = READ_IMM16;
+       uint32_t m = READ_IMM16;
        OP_ADD_HANDLER16(m, regs.a, regs.b);
 }
 
 static void OpCB(void)                                                 // ADDB #
 {
-       uint16 m = READ_IMM;
+       uint16_t m = READ_IMM;
        OP_ADD_HANDLER(m, regs.b);
 }
 
 static void OpD3(void)                                                 // ADDD DP
 {
-       uint32 m = READ_DP16;
+       uint32_t m = READ_DP16;
        OP_ADD_HANDLER16(m, regs.a, regs.b);
 }
 
 static void OpDB(void)                                                 // ADDB DP
 {
-       uint16 m = READ_DP;
+       uint16_t m = READ_DP;
        OP_ADD_HANDLER(m, regs.b);
 }
 
 static void OpE3(void)                                                 // ADDD IDX
 {
-       uint32 m = READ_IDX16;
+       uint32_t m = READ_IDX16;
        OP_ADD_HANDLER16(m, regs.a, regs.b);
 }
 
 static void OpEB(void)                                                 // ADDB IDX
 {
-       uint16 m = READ_IDX;
+       uint16_t m = READ_IDX;
        OP_ADD_HANDLER(m, regs.b);
 }
 
 static void OpF3(void)                                                 // ADDD ABS
 {
-       uint32 m = READ_ABS16;
+       uint32_t m = READ_ABS16;
        OP_ADD_HANDLER16(m, regs.a, regs.b);
 }
 
 static void OpFB(void)                                                 // ADDB ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_ADD_HANDLER(m, regs.b);
 }
 
@@ -670,49 +670,49 @@ static void OpFB(void)                                                    // ADDB ABS
 
 static void Op84(void)                                                 // ANDA #
 {
-       uint16 m = READ_IMM;
+       uint16_t m = READ_IMM;
        OP_AND_HANDLER(m, regs.a);
 }
 
 static void Op94(void)                                                 // ANDA DP
 {
-       uint16 m = READ_DP;
+       uint16_t m = READ_DP;
        OP_AND_HANDLER(m, regs.a);
 }
 
 static void OpA4(void)                                                 // ANDA IDX
 {
-       uint16 m = READ_IDX;
+       uint16_t m = READ_IDX;
        OP_AND_HANDLER(m, regs.a);
 }
 
 static void OpB4(void)                                                 // ANDA ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_AND_HANDLER(m, regs.a);
 }
 
 static void OpC4(void)                                                 // ANDB #
 {
-       uint16 m = READ_IMM;
+       uint16_t m = READ_IMM;
        OP_AND_HANDLER(m, regs.b);
 }
 
 static void OpD4(void)                                                 // ANDB DP
 {
-       uint16 m = READ_DP;
+       uint16_t m = READ_DP;
        OP_AND_HANDLER(m, regs.b);
 }
 
 static void OpE4(void)                                                 // ANDB IDX
 {
-       uint16 m = READ_IDX;
+       uint16_t m = READ_IDX;
        OP_AND_HANDLER(m, regs.b);
 }
 
 static void OpF4(void)                                                 // ANDB ABS
 {
-       uint16 m = READ_ABS;
+       uint16_t m = READ_ABS;
        OP_AND_HANDLER(m, regs.b);
 }
 
@@ -731,7 +731,7 @@ static void OpF4(void)                                                      // ANDB ABS
 // ASL opcodes
 
 #define OP_ASL_HANDLER(m) \
-       uint16 res = m << 1; \
+       uint16_t res = m << 1; \
        SET_V(m, m, res); \
        flagC = (res >> 8) & 0x01; \
        m = res & 0xFF; \
@@ -739,7 +739,7 @@ static void OpF4(void)                                                      // ANDB ABS
 
 static void Op08(void)                                                 // ASL DP
 {
-       uint8 m;
+       uint8_t m;
        READ_DP_WB(m);
        OP_ASL_HANDLER(m);
        WRITE_BACK(m);
@@ -757,7 +757,7 @@ static void Op58(void)                                                      // ASLB
 
 static void Op68(void)                                                 // ASL IDX
 {
-       uint8 m;
+       uint8_t m;
        READ_IDX_WB(m);
        OP_ASL_HANDLER(m);
        WRITE_BACK(m);
@@ -765,7 +765,7 @@ static void Op68(void)                                                      // ASL IDX
 
 static void Op78(void)                                                 // ASL ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_ASL_HANDLER(m);
        WRITE_BACK(m);
@@ -786,14 +786,14 @@ static void Op78(void)                                                    // ASL ABS
 // ASR opcodes (arithmetic, so preserves the sign)
 
 #define OP_ASR_HANDLER(m) \
-       uint8 res = (m & 0x80) | (m >> 1); \
+       uint8_t res = (m & 0x80) | (m >> 1); \
        SET_ZN(res); \
        flagC = m & 0x01; \
        m = res
 
 static void Op07(void)                                                 // ASR DP
 {
-       uint8 m;
+       uint8_t m;
        READ_DP_WB(m);
        OP_ASR_HANDLER(m);
        WRITE_BACK(m);
@@ -811,7 +811,7 @@ static void Op57(void)                                                      // ASRB
 
 static void Op67(void)                                                 // ASR IDX
 {
-       uint8 m;
+       uint8_t m;
        READ_IDX_WB(m);
        OP_ASR_HANDLER(m);
        WRITE_BACK(m);
@@ -819,7 +819,7 @@ static void Op67(void)                                                      // ASR IDX
 
 static void Op77(void)                                                 // ASR ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_ASR_HANDLER(m);
        WRITE_BACK(m);
@@ -868,26 +868,26 @@ static void Op77(void)                                                    // ASR ABS
 
 static void Op16(void)                                                 // LBRA
 {
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
        regs.pc += offset;
 }
 
 static void Op20(void)                                                 // BRA
 {
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
        regs.pc += offset;
 }
 
 static void Op21(void)                                                 // BRN
 {
        // This is basically a 2 byte NOP
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 }
 
 static void Op22(void)                                                 // BHI
 {
        // !C && !Z
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
 //Not sure if the ! operator will do what we want, so we use ^ 1 (we need a 1 or a 0 here)...
@@ -901,7 +901,7 @@ static void Op22(void)                                                      // BHI
 static void Op23(void)                                                 // BLS
 {
        // C || Z
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * (flagZ | flagC);
@@ -914,7 +914,7 @@ static void Op23(void)                                                      // BLS
 static void Op24(void)                                                 // BHS/CC
 {
        // !C
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * (flagC ^ 0x01);
@@ -927,7 +927,7 @@ static void Op24(void)                                                      // BHS/CC
 static void Op25(void)                                                 // BLO/CS
 {
        // C
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 //if (disasm)
 //     WriteLog("[offset=%04X,flagC=%08X]", offset, flagC);
 
@@ -942,7 +942,7 @@ static void Op25(void)                                                      // BLO/CS
 static void Op26(void)                                                 // BNE
 {
        // !Z
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * (flagZ ^ 0x01);
@@ -955,7 +955,7 @@ static void Op26(void)                                                      // BNE
 static void Op27(void)                                                 // BEQ
 {
        // Z
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * flagZ;
@@ -968,7 +968,7 @@ static void Op27(void)                                                      // BEQ
 static void Op28(void)                                                 // BVC
 {
        // !V
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * (flagV ^ 0x01);
@@ -981,7 +981,7 @@ static void Op28(void)                                                      // BVC
 static void Op29(void)                                                 // BVS
 {
        // V
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * flagV;
@@ -994,7 +994,7 @@ static void Op29(void)                                                      // BVS
 static void Op2A(void)                                                 // BPL
 {
        // !N
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * (flagN ^ 0x01);
@@ -1007,7 +1007,7 @@ static void Op2A(void)                                                    // BPL
 static void Op2B(void)                                                 // BMI
 {
        // N
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * flagN;
@@ -1020,7 +1020,7 @@ static void Op2B(void)                                                    // BMI
 static void Op2C(void)                                                 // BGE
 {
        // (N && V) || (!N && !V)
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * ((flagN & flagV) | ((flagN ^ 0x01) & (flagV ^ 0x01)));
@@ -1033,7 +1033,7 @@ static void Op2C(void)                                                    // BGE
 static void Op2D(void)                                                 // BLT
 {
        // (N && !V) || (!N && V)
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * ((flagN & (flagV ^ 0x01)) | ((flagN ^ 0x01) & flagV));
@@ -1046,7 +1046,7 @@ static void Op2D(void)                                                    // BLT
 static void Op2E(void)                                                 // BGT
 {
        // (N && V && !Z) || (!N && !V && !Z)
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * ((flagN & flagV & (flagZ ^ 0x01)) | ((flagN ^ 0x01) & (flagV ^ 0x01) & (flagZ ^ 0x01)));
@@ -1059,7 +1059,7 @@ static void Op2E(void)                                                    // BGT
 static void Op2F(void)                                                 // BLE
 {
        // Z || (N && !V) || (!N && V)
-       int16 offset = (int16)(int8)READ_IMM;
+       int16_t offset = (int16_t)(int8_t)READ_IMM;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * (flagZ | (flagN & (flagV ^ 0x01)) | ((flagN ^ 0x01) & flagV));
@@ -1072,13 +1072,13 @@ static void Op2F(void)                                                  // BLE
 static void Op1021(void)                                               // LBRN
 {
        // This is basically a 4 byte NOP
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 }
 
 static void Op1022(void)                                               // LBHI
 {
        // !C && !Z
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
 //Not sure if the ! operator will do what we want, so we use ^ 1 (we need a 1 or a 0 here)...
@@ -1092,7 +1092,7 @@ static void Op1022(void)                                          // LBHI
 static void Op1023(void)                                               // LBLS
 {
        // C || Z
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * (flagZ | flagC);
@@ -1105,7 +1105,7 @@ static void Op1023(void)                                          // LBLS
 static void Op1024(void)                                               // LBHS/CC
 {
        // !C
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * (flagC ^ 0x01);
@@ -1118,7 +1118,7 @@ static void Op1024(void)                                          // LBHS/CC
 static void Op1025(void)                                               // LBLO/CS
 {
        // C
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * flagC;
@@ -1131,7 +1131,7 @@ static void Op1025(void)                                          // LBLO/CS
 static void Op1026(void)                                               // LBNE
 {
        // !Z
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * (flagZ ^ 0x01);
@@ -1144,7 +1144,7 @@ static void Op1026(void)                                          // LBNE
 static void Op1027(void)                                               // LBEQ
 {
        // Z
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * flagZ;
@@ -1157,7 +1157,7 @@ static void Op1027(void)                                          // LBEQ
 static void Op1028(void)                                               // LBVC
 {
        // !V
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * (flagV ^ 0x01);
@@ -1170,7 +1170,7 @@ static void Op1028(void)                                          // LBVC
 static void Op1029(void)                                               // LBVS
 {
        // V
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * flagV;
@@ -1183,7 +1183,7 @@ static void Op1029(void)                                          // LBVS
 static void Op102A(void)                                               // LBPL
 {
        // !N
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * (flagN ^ 0x01);
@@ -1196,7 +1196,7 @@ static void Op102A(void)                                          // LBPL
 static void Op102B(void)                                               // LBMI
 {
        // N
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * flagN;
@@ -1209,7 +1209,7 @@ static void Op102B(void)                                          // LBMI
 static void Op102C(void)                                               // LBGE
 {
        // (N && V) || (!N && !V)
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * ((flagN & flagV) | ((flagN ^ 0x01) & (flagV ^ 0x01)));
@@ -1222,7 +1222,7 @@ static void Op102C(void)                                          // LBGE
 static void Op102D(void)                                               // LBLT
 {
        // (N && !V) || (!N && V)
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * ((flagN & (flagV ^ 0x01)) | ((flagN ^ 0x01) & flagV));
@@ -1235,7 +1235,7 @@ static void Op102D(void)                                          // LBLT
 static void Op102E(void)                                               // LBGT
 {
        // (N && V && !Z) || (!N && !V && !Z)
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * ((flagN & flagV & (flagZ ^ 0x01)) | ((flagN ^ 0x01) & (flagV ^ 0x01) & (flagZ ^ 0x01)));
@@ -1248,7 +1248,7 @@ static void Op102E(void)                                          // LBGT
 static void Op102F(void)                                               // LBLE
 {
        // Z || (N && !V) || (!N && V)
-       uint16 offset = READ_IMM16;
+       uint16_t offset = READ_IMM16;
 
 #ifdef TEST_DONT_BRANCH_OPTIMIZATION
        regs.pc += offset * (flagZ | (flagN & (flagV ^ 0x01)) | ((flagN ^ 0x01) & flagV));
@@ -1276,55 +1276,55 @@ static void Op102F(void)                                                // LBLE
 // BIT opcodes
 
 #define OP_BIT_HANDLER(m, acc) \
-       uint8 result = acc & (m); \
+       uint8_t result = acc & (m); \
        SET_ZN(result); \
        CLR_V
 
 static void Op85(void)                                                 // BITA #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_BIT_HANDLER(m, regs.a);
 }
 
 static void Op95(void)                                                 // BITA DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_BIT_HANDLER(m, regs.a);
 }
 
 static void OpA5(void)                                                 // BITA IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_BIT_HANDLER(m, regs.a);
 }
 
 static void OpB5(void)                                                 // BITA ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_BIT_HANDLER(m, regs.a);
 }
 
 static void OpC5(void)                                                 // BITB #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_BIT_HANDLER(m, regs.b);
 }
 
 static void OpD5(void)                                                 // BITB DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_BIT_HANDLER(m, regs.b);
 }
 
 static void OpE5(void)                                                 // BITB IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_BIT_HANDLER(m, regs.b);
 }
 
 static void OpF5(void)                                                 // BITB ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_BIT_HANDLER(m, regs.b);
 }
 
@@ -1349,7 +1349,7 @@ static void OpF5(void)                                                    // BITB ABS
 
 static void Op0F(void)                                                 // CLR DP
 {
-       uint8 m;
+       uint8_t m;
        READ_DP_WB(m);
        OP_CLR_HANDLER(m);
        WRITE_BACK(m);
@@ -1367,7 +1367,7 @@ static void Op5F(void)                                                    // CLRB
 
 static void Op6F(void)                                                 // CLR IDX
 {
-       uint8 m;
+       uint8_t m;
        READ_IDX_WB(m);
        OP_CLR_HANDLER(m);
        WRITE_BACK(m);
@@ -1375,7 +1375,7 @@ static void Op6F(void)                                                    // CLR IDX
 
 static void Op7F(void)                                                 // CLR ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_CLR_HANDLER(m);
        WRITE_BACK(m);
@@ -1419,182 +1419,182 @@ static void Op7F(void)                                                        // CLR ABS
 // CMP opcodes
 
 #define OP_CMP_HANDLER(m, acc) \
-       uint16 sum = (uint16)(acc) - (m); \
+       uint16_t sum = (uint16_t)(acc) - (m); \
        flagC = (sum >> 8) & 0x01; \
        SET_V(m, acc, sum); \
        SET_ZN(sum)
 
 #define OP_CMP_HANDLER16(m, acc) \
-       uint32 sum = (uint32)(acc) - (m); \
+       uint32_t sum = (uint32_t)(acc) - (m); \
        flagC = (sum >> 16) & 0x01; \
        SET_V16(m, acc, sum); \
        SET_ZN16(sum)
 
 static void Op81(void)                                                 // CMPA #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_CMP_HANDLER(m, regs.a);
 }
 
 static void Op8C(void)                                                 // CMPX #
 {
-       uint16 m = READ_IMM16;
+       uint16_t m = READ_IMM16;
        OP_CMP_HANDLER16(m, regs.x);
 }
 
 static void Op91(void)                                                 // CMPA DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_CMP_HANDLER(m, regs.a);
 }
 
 static void Op9C(void)                                                 // CMPX DP
 {
-       uint16 m = READ_DP16;
+       uint16_t m = READ_DP16;
        OP_CMP_HANDLER16(m, regs.x);
 }
 
 static void OpA1(void)                                                 // CMPA IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_CMP_HANDLER(m, regs.a);
 }
 
 static void OpAC(void)                                                 // CMPX IDX
 {
-       uint16 m = READ_IDX16;
+       uint16_t m = READ_IDX16;
        OP_CMP_HANDLER16(m, regs.x);
 }
 
 static void OpB1(void)                                                 // CMPA ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_CMP_HANDLER(m, regs.a);
 }
 
 static void OpBC(void)                                                 // CMPX ABS
 {
-       uint16 m = READ_ABS16;
+       uint16_t m = READ_ABS16;
        OP_CMP_HANDLER16(m, regs.x);
 }
 
 static void OpC1(void)                                                 // CMPB #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_CMP_HANDLER(m, regs.b);
 }
 
 static void OpD1(void)                                                 // CMPB DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_CMP_HANDLER(m, regs.b);
 }
 
 static void OpE1(void)                                                 // CMPB IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_CMP_HANDLER(m, regs.b);
 }
 
 static void OpF1(void)                                                 // CMPB ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_CMP_HANDLER(m, regs.b);
 }
 
 static void Op1083(void)                                               // CMPD #
 {
-       uint16 m = READ_IMM16;
+       uint16_t m = READ_IMM16;
        OP_CMP_HANDLER16(m, (regs.a << 8) | regs.b);
 }
 
 static void Op108C(void)                                               // CMPY #
 {
-       uint16 m = READ_IMM16;
+       uint16_t m = READ_IMM16;
        OP_CMP_HANDLER16(m, regs.y);
 }
 
 static void Op1093(void)                                               // CMPD DP
 {
-       uint16 m = READ_DP16;
+       uint16_t m = READ_DP16;
        OP_CMP_HANDLER16(m, (regs.a << 8) | regs.b);
 }
 
 static void Op109C(void)                                               // CMPY DP
 {
-       uint16 m = READ_DP16;
+       uint16_t m = READ_DP16;
        OP_CMP_HANDLER16(m, regs.y);
 }
 
 static void Op10A3(void)                                               // CMPD IDX
 {
-       uint16 m = READ_IDX16;
+       uint16_t m = READ_IDX16;
        OP_CMP_HANDLER16(m, (regs.a << 8) | regs.b);
 }
 
 static void Op10AC(void)                                               // CMPY IDX
 {
-       uint16 m = READ_IDX16;
+       uint16_t m = READ_IDX16;
        OP_CMP_HANDLER16(m, regs.y);
 }
 
 static void Op10B3(void)                                               // CMPD ABS
 {
-       uint16 m = READ_ABS16;
+       uint16_t m = READ_ABS16;
        OP_CMP_HANDLER16(m, (regs.a << 8) | regs.b);
 }
 
 static void Op10BC(void)                                               // CMPY ABS
 {
-       uint16 m = READ_ABS16;
+       uint16_t m = READ_ABS16;
        OP_CMP_HANDLER16(m, regs.y);
 }
 
 static void Op1183(void)                                               // CMPU #
 {
-       uint16 m = READ_IMM16;
+       uint16_t m = READ_IMM16;
        OP_CMP_HANDLER16(m, regs.u);
 }
 
 static void Op118C(void)                                               // CMPS #
 {
-       uint16 m = READ_IMM16;
+       uint16_t m = READ_IMM16;
        OP_CMP_HANDLER16(m, regs.s);
 }
 
 static void Op1193(void)                                               // CMPU DP
 {
-       uint16 m = READ_DP16;
+       uint16_t m = READ_DP16;
        OP_CMP_HANDLER16(m, regs.u);
 }
 
 static void Op119C(void)                                               // CMPS DP
 {
-       uint16 m = READ_DP16;
+       uint16_t m = READ_DP16;
        OP_CMP_HANDLER16(m, regs.s);
 }
 
 static void Op11A3(void)                                               // CMPU IDX
 {
-       uint16 m = READ_IDX16;
+       uint16_t m = READ_IDX16;
        OP_CMP_HANDLER16(m, regs.u);
 }
 
 static void Op11AC(void)                                               // CMPS IDX
 {
-       uint16 m = READ_IDX16;
+       uint16_t m = READ_IDX16;
        OP_CMP_HANDLER16(m, regs.s);
 }
 
 static void Op11B3(void)                                               // CMPU ABS
 {
-       uint16 m = READ_ABS16;
+       uint16_t m = READ_ABS16;
        OP_CMP_HANDLER16(m, regs.u);
 }
 
 static void Op11BC(void)                                               // CMPS ABS
 {
-       uint16 m = READ_ABS16;
+       uint16_t m = READ_ABS16;
        OP_CMP_HANDLER16(m, regs.s);
 }
 
@@ -1620,7 +1620,7 @@ static void Op11BC(void)                                          // CMPS ABS
 
 static void Op03(void)                                                 // COM DP
 {
-       uint8 m;
+       uint8_t m;
        READ_DP_WB(m);
        OP_COM_HANDLER(m);
        WRITE_BACK(m);
@@ -1638,7 +1638,7 @@ static void Op53(void)                                                    // COMB
 
 static void Op63(void)                                                 // COM IDX
 {
-       uint8 m;
+       uint8_t m;
        READ_IDX_WB(m);
        OP_COM_HANDLER(m);
        WRITE_BACK(m);
@@ -1646,7 +1646,7 @@ static void Op63(void)                                                    // COM IDX
 
 static void Op73(void)                                                 // COM ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_COM_HANDLER(m);
        WRITE_BACK(m);
@@ -1785,7 +1785,7 @@ D3FC: 19          DAA              CC=--H----- A=37 B=00 DP=9C X=3C72 Y=CE5C S=B
 
 static void Op19()                                                             // DAA
 {
-       uint16 result = (uint16)regs.a;
+       uint16_t result = (uint16_t)regs.a;
 
 //     if ((regs.a & 0x0F) > 0x09 || (regs.cc & FLAG_H))
        if ((regs.a & 0x0F) > 0x09 || flagH)
@@ -1795,7 +1795,7 @@ static void Op19()                                                                // DAA
        if ((regs.a & 0xF0) > 0x90 || flagC || ((regs.a & 0xF0) > 0x80 && (regs.a & 0x0F) > 0x09))
                result += 0x60;
 
-       regs.a = (uint8)result;
+       regs.a = (uint8_t)result;
        SET_ZN(result);
        CLR_V;
        flagC |= (result & 0x100) >> 8;                         // Overwrite carry if it was 0, otherwise, ignore
@@ -1843,7 +1843,7 @@ static void Op1D()                                                                // SEX
 
 static void Op0A(void)                                                 // DEC DP
 {
-       uint8 m;
+       uint8_t m;
        READ_DP_WB(m);
        OP_DEC_HANDLER(m);
        WRITE_BACK(m);
@@ -1861,7 +1861,7 @@ static void Op5A(void)                                                    // DECB
 
 static void Op6A(void)                                                 // DEC IDX
 {
-       uint8 m;
+       uint8_t m;
        READ_IDX_WB(m);
        OP_DEC_HANDLER(m);
        WRITE_BACK(m);
@@ -1869,7 +1869,7 @@ static void Op6A(void)                                                    // DEC IDX
 
 static void Op7A(void)                                                 // DEC ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_DEC_HANDLER(m);
        WRITE_BACK(m);
@@ -1899,49 +1899,49 @@ static void Op7A(void)                                                  // DEC ABS
 
 static void Op88(void)                                                 // EORA #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_EOR_HANDLER(m, regs.a);
 }
 
 static void Op98(void)                                                 // EORA DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_EOR_HANDLER(m, regs.a);
 }
 
 static void OpA8(void)                                                 // EORA IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_EOR_HANDLER(m, regs.a);
 }
 
 static void OpB8(void)                                                 // EORA ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_EOR_HANDLER(m, regs.a);
 }
 
 static void OpC8(void)                                                 // EORB #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_EOR_HANDLER(m, regs.b);
 }
 
 static void OpD8(void)                                                 // EORB DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_EOR_HANDLER(m, regs.b);
 }
 
 static void OpE8(void)                                                 // EORB IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_EOR_HANDLER(m, regs.b);
 }
 
 static void OpF8(void)                                                 // EORB ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_EOR_HANDLER(m, regs.b);
 }
 
@@ -1966,7 +1966,7 @@ static void OpF8(void)                                                    // EORB ABS
 
 static void Op0C(void)                                                 // INC DP
 {
-       uint8 m;
+       uint8_t m;
        READ_DP_WB(m);
        OP_INC_HANDLER(m);
        WRITE_BACK(m);
@@ -1984,7 +1984,7 @@ static void Op5C(void)                                                    // INCB
 
 static void Op6C(void)                                                 // INC IDX
 {
-       uint8 m;
+       uint8_t m;
        READ_IDX_WB(m);
        OP_INC_HANDLER(m);
        WRITE_BACK(m);
@@ -1992,7 +1992,7 @@ static void Op6C(void)                                                    // INC IDX
 
 static void Op7C(void)                                                 // INC ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_INC_HANDLER(m);
        WRITE_BACK(m);
@@ -2022,7 +2022,7 @@ static void Op0E(void)                                                    // JMP DP
 
 static void Op17(void)                                                 // LBSR
 {
-       uint16 word = FetchMemW(regs.pc);
+       uint16_t word = FetchMemW(regs.pc);
        PUSHS16(regs.pc);
        regs.pc += word;
 }
@@ -2064,28 +2064,28 @@ static void Op7E(void)                                                  // JMP ABS
 
 static void Op8D(void)                                                 // BSR
 {
-       uint16 word = (int16)(int8)READ_IMM;
+       uint16_t word = (int16_t)(int8_t)READ_IMM;
        PUSHS16(regs.pc);
        regs.pc += word;
 }
 
 static void Op9D(void)                                                 // JSR DP
 {
-       uint16 word = EA_DP;
+       uint16_t word = EA_DP;
        PUSHS16(regs.pc);
        regs.pc = word;
 }
 
 static void OpAD(void)                                                 // JSR IDX
 {
-       uint16 word = EA_IDX;
+       uint16_t word = EA_IDX;
        PUSHS16(regs.pc);
        regs.pc = word;
 }
 
 static void OpBD(void)                                                 // JSR ABS
 {
-       uint16 word = EA_ABS;
+       uint16_t word = EA_ABS;
        PUSHS16(regs.pc);
        regs.pc = word;
 }
@@ -2103,10 +2103,10 @@ static void Op1E(void)                                                  // EXG
 {
        // If bit 3 & 7 are not equal, $FF is the result (undocumented)...
 
-       uint8 m = READ_IMM;
-       uint8 reg1 = m >> 4, reg2 = m & 0x0F;
-       uint16 acc1 = ReadEXG(reg1);
-       uint16 acc2 = ReadEXG(reg2);
+       uint8_t m = READ_IMM;
+       uint8_t reg1 = m >> 4, reg2 = m & 0x0F;
+       uint16_t acc1 = ReadEXG(reg1);
+       uint16_t acc2 = ReadEXG(reg2);
 
        // If bit 3 & 7 are not equal, $FF is the result (undocumented)...
        if (((m >> 4) ^ m) & 0x08)
@@ -2118,8 +2118,8 @@ static void Op1E(void)                                                    // EXG
 
 static void Op1F(void)                                                 // TFR
 {
-       uint8 m = READ_IMM;
-       uint16 acc = ReadEXG(m >> 4);
+       uint8_t m = READ_IMM;
+       uint16_t acc = ReadEXG(m >> 4);
 
        // If bit 3 & 7 are not equal, $FF is the result (undocumented)...
        if (((m >> 4) ^ m) & 0x08)
@@ -2183,169 +2183,169 @@ static void Op1F(void)                                                        // TFR
 
 static void Op86(void)                                                 // LDA #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_LDA_HANDLER(m, regs.a);
 }
 
 static void Op8E(void)                                                 // LDX #
 {
-       uint16 m = READ_IMM16;
+       uint16_t m = READ_IMM16;
        OP_LDA_HANDLER16(m, regs.x);
 }
 
 static void Op96(void)                                                 // LDA DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_LDA_HANDLER(m, regs.a);
 }
 
 static void Op9E(void)                                                 // LDX DP
 {
-       uint16 m = READ_DP16;
+       uint16_t m = READ_DP16;
        OP_LDA_HANDLER16(m, regs.x);
 }
 
 static void OpA6(void)                                                 // LDA IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_LDA_HANDLER(m, regs.a);
 }
 
 static void OpAE(void)                                                 // LDX IDX
 {
-       uint16 m = READ_IDX16;
+       uint16_t m = READ_IDX16;
        OP_LDA_HANDLER16(m, regs.x);
 }
 
 static void OpB6(void)                                                 // LDA ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_LDA_HANDLER(m, regs.a);
 }
 
 static void OpBE(void)                                                 // LDX ABS
 {
-       uint16 m = READ_ABS16;
+       uint16_t m = READ_ABS16;
        OP_LDA_HANDLER16(m, regs.x);
 }
 
 static void OpC6(void)                                                 // LDB #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_LDA_HANDLER(m, regs.b);
 }
 
 static void OpCC(void)                                                 // LDD #
 {
-       uint16 m = READ_IMM16;
+       uint16_t m = READ_IMM16;
        OP_LDA_HANDLER16D(m);
 }
 
 static void OpCE(void)                                                 // LDU #
 {
-       uint16 m = READ_IMM16;
+       uint16_t m = READ_IMM16;
        OP_LDA_HANDLER16(m, regs.u);
 }
 
 static void OpD6(void)                                                 // LDB DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_LDA_HANDLER(m, regs.b);
 }
 
 static void OpDC(void)                                                 // LDD DP
 {
-       uint16 m = READ_DP16;
+       uint16_t m = READ_DP16;
        OP_LDA_HANDLER16D(m);
 }
 
 static void OpDE(void)                                                 // LDU DP
 {
-       uint16 m = READ_DP16;
+       uint16_t m = READ_DP16;
        OP_LDA_HANDLER16(m, regs.u);
 }
 
 static void OpE6(void)                                                 // LDB IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_LDA_HANDLER(m, regs.b);
 }
 
 static void OpEC(void)                                                 // LDD IDX
 {
-       uint16 m = READ_IDX16;
+       uint16_t m = READ_IDX16;
        OP_LDA_HANDLER16D(m);
 }
 
 static void OpEE(void)                                                 // LDU IDX
 {
-       uint16 m = READ_IDX16;
+       uint16_t m = READ_IDX16;
        OP_LDA_HANDLER16(m, regs.u);
 }
 
 static void OpF6(void)                                                 // LDB ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_LDA_HANDLER(m, regs.b);
 }
 
 static void OpFC(void)                                                 // LDD ABS
 {
-       uint16 m = READ_ABS16;
+       uint16_t m = READ_ABS16;
        OP_LDA_HANDLER16D(m);
 }
 
 static void OpFE(void)                                                 // LDU ABS
 {
-       uint16 m = READ_ABS16;
+       uint16_t m = READ_ABS16;
        OP_LDA_HANDLER16(m, regs.u);
 }
 
 static void Op108E(void)                                               // LDY #
 {
-       uint16 m = READ_IMM16;
+       uint16_t m = READ_IMM16;
        OP_LDA_HANDLER16(m, regs.y);
 }
 
 static void Op109E(void)                                               // LDY DP
 {
-       uint16 m = READ_DP16;
+       uint16_t m = READ_DP16;
        OP_LDA_HANDLER16(m, regs.y);
 }
 
 static void Op10AE(void)                                               // LDY IDX
 {
-       uint16 m = READ_IDX16;
+       uint16_t m = READ_IDX16;
        OP_LDA_HANDLER16(m, regs.y);
 }
 
 static void Op10BE(void)                                               // LDY ABS
 {
-       uint16 m = READ_ABS16;
+       uint16_t m = READ_ABS16;
        OP_LDA_HANDLER16(m, regs.y);
 }
 
 static void Op10CE(void)                                               // LDS #
 {
-       uint16 m = READ_IMM16;
+       uint16_t m = READ_IMM16;
        OP_LDA_HANDLER16(m, regs.s);
 }
 
 static void Op10DE(void)                                               // LDS DP
 {
-       uint16 m = READ_DP16;
+       uint16_t m = READ_DP16;
        OP_LDA_HANDLER16(m, regs.s);
 }
 
 static void Op10EE(void)                                               // LDS IDX
 {
-       uint16 m = READ_IDX16;
+       uint16_t m = READ_IDX16;
        OP_LDA_HANDLER16(m, regs.s);
 }
 
 static void Op10FE(void)                                               // LDS ABS
 {
-       uint16 m = READ_ABS16;
+       uint16_t m = READ_ABS16;
        OP_LDA_HANDLER16(m, regs.s);
 }
 
@@ -2403,7 +2403,7 @@ static void Op33(void)                                                    // LEAU
 
 static void Op04(void)                                                 // LSR DP
 {
-       uint8 m;
+       uint8_t m;
        READ_DP_WB(m);
        OP_LSR_HANDLER(m);
        WRITE_BACK(m);
@@ -2421,7 +2421,7 @@ static void Op54(void)                                                    // LSRB
 
 static void Op64(void)                                                 // LSR IDX
 {
-       uint8 m;
+       uint8_t m;
        READ_IDX_WB(m);
        OP_LSR_HANDLER(m);
        WRITE_BACK(m);
@@ -2429,7 +2429,7 @@ static void Op64(void)                                                    // LSR IDX
 
 static void Op74(void)                                                 // LSR ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_LSR_HANDLER(m);
        WRITE_BACK(m);
@@ -2445,7 +2445,7 @@ static void Op74(void)                                                    // LSR ABS
 
 static void Op3D(void)                                                 // MUL
 {
-       uint16 prod = regs.a * regs.b;
+       uint16_t prod = regs.a * regs.b;
        regs.a = prod >> 8;
        regs.b = prod & 0xFF;
        SET_Z(prod);
@@ -2468,7 +2468,7 @@ static void Op3D(void)                                                    // MUL
 // NEG opcodes
 
 #define OP_NEG_HANDLER(m) \
-       uint8 res = -m; \
+       uint8_t res = -m; \
        SET_ZN(res); \
        SET_V(0, m, res); \
        flagC = (res >= 0x80 ? 1 : 0); \
@@ -2486,7 +2486,7 @@ static void Op3D(void)                                                    // MUL
 */
 static void Op00(void)                                                 // NEG DP
 {
-       uint8 m;
+       uint8_t m;
        READ_DP_WB(m);
        OP_NEG_HANDLER(m);
        WRITE_BACK(m);
@@ -2504,7 +2504,7 @@ static void Op50(void)                                                    // NEGB
 
 static void Op60(void)                                                 // NEG IDX
 {
-       uint8 m;
+       uint8_t m;
        READ_IDX_WB(m);
        OP_NEG_HANDLER(m);
        WRITE_BACK(m);
@@ -2512,7 +2512,7 @@ static void Op60(void)                                                    // NEG IDX
 
 static void Op70(void)                                                 // NEG ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_NEG_HANDLER(m);
        WRITE_BACK(m);
@@ -2542,49 +2542,49 @@ static void Op70(void)                                                  // NEG ABS
 
 static void Op8A(void)                                                 // ORA #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_OR_HANDLER(m, regs.a);
 }
 
 static void Op9A(void)                                                 // ORA DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_OR_HANDLER(m, regs.a);
 }
 
 static void OpAA(void)                                                 // ORA IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_OR_HANDLER(m, regs.a);
 }
 
 static void OpBA(void)                                                 // ORA ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_OR_HANDLER(m, regs.a);
 }
 
 static void OpCA(void)                                                 // ORB #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_OR_HANDLER(m, regs.b);
 }
 
 static void OpDA(void)                                                 // ORB DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_OR_HANDLER(m, regs.b);
 }
 
 static void OpEA(void)                                                 // ORB IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_OR_HANDLER(m, regs.b);
 }
 
 static void OpFA(void)                                                 // ORB ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_OR_HANDLER(m, regs.b);
 }
 
@@ -2601,7 +2601,7 @@ static void OpFA(void)                                                    // ORB ABS
 
 static void Op34(void)                                                 // PSHS
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
 
        if (m & 0x80)
                PUSHS16(regs.pc);
@@ -2624,13 +2624,13 @@ static void Op34(void)                                                  // PSHS
        }
 
        // Count bits in each nybble to come up with correct cycle counts...
-       uint8 bitCount[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
+       uint8_t bitCount[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
        regs.clock += (1 * bitCount[m & 0x0F]) + (2 * bitCount[m >> 4]);
 }
 
 static void Op35(void)                                                 // PULS
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
 
        if (m & 0x01)
        {
@@ -2653,13 +2653,13 @@ static void Op35(void)                                                  // PULS
                PULLS16(regs.pc);
 
        // Count bits in each nybble to come up with correct cycle counts...
-       uint8 bitCount[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
+       uint8_t bitCount[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
        regs.clock += (1 * bitCount[m & 0x0F]) + (2 * bitCount[m >> 4]);
 }
 
 static void Op36(void)                                                 // PHSU
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
 
        if (m & 0x80)
                PUSHU16(regs.pc);
@@ -2682,13 +2682,13 @@ static void Op36(void)                                                  // PHSU
        }
 
        // Count bits in each nybble to come up with correct cycle counts...
-       uint8 bitCount[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
+       uint8_t bitCount[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
        regs.clock += (1 * bitCount[m & 0x0F]) + (2 * bitCount[m >> 4]);
 }
 
 static void Op37(void)                                                 // PULU
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
 
        if (m & 0x01)
        {
@@ -2711,7 +2711,7 @@ static void Op37(void)                                                    // PULU
                PULLU16(regs.pc);
 
        // Count bits in each nybble to come up with correct cycle counts...
-       uint8 bitCount[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
+       uint8_t bitCount[16] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
        regs.clock += (1 * bitCount[m & 0x0F]) + (2 * bitCount[m >> 4]);
 }
 
@@ -2730,7 +2730,7 @@ static void Op37(void)                                                    // PULU
 // ROL opcodes
 
 #define OP_ROL_HANDLER(m) \
-       uint8 res = (m << 1) | flagC; \
+       uint8_t res = (m << 1) | flagC; \
        SET_ZN(res); \
        SET_V(m, m, res); \
        flagC = (m >> 7) & 0x01; \
@@ -2746,7 +2746,7 @@ static void Op37(void)                                                    // PULU
 */
 static void Op09(void)                                                 // ROL DP
 {
-       uint8 m;
+       uint8_t m;
        READ_DP_WB(m);
        OP_ROL_HANDLER(m);
        WRITE_BACK(m);
@@ -2764,7 +2764,7 @@ static void Op59(void)                                                    // ROLB
 
 static void Op69(void)                                                 // ROL IDX
 {
-       uint8 m;
+       uint8_t m;
        READ_IDX_WB(m);
        OP_ROL_HANDLER(m);
        WRITE_BACK(m);
@@ -2772,7 +2772,7 @@ static void Op69(void)                                                    // ROL IDX
 
 static void Op79(void)                                                 // ROL ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_ROL_HANDLER(m);
        WRITE_BACK(m);
@@ -2793,7 +2793,7 @@ static void Op79(void)                                                    // ROL ABS
 // ROR opcodes
 
 #define OP_ROR_HANDLER(m) \
-       uint8 res = (flagC << 7) | (m >> 1); \
+       uint8_t res = (flagC << 7) | (m >> 1); \
        SET_ZN(res); \
        SET_V(m, m, res); \
        flagC = m & 0x01; \
@@ -2801,7 +2801,7 @@ static void Op79(void)                                                    // ROL ABS
 
 static void Op06(void)                                                 // ROR DP
 {
-       uint8 m;
+       uint8_t m;
        READ_DP_WB(m);
        OP_ROR_HANDLER(m);
        WRITE_BACK(m);
@@ -2819,7 +2819,7 @@ static void Op56(void)                                                    // RORB
 
 static void Op66(void)                                                 // ROR IDX
 {
-       uint8 m;
+       uint8_t m;
        READ_IDX_WB(m);
        OP_ROR_HANDLER(m);
        WRITE_BACK(m);
@@ -2827,7 +2827,7 @@ static void Op66(void)                                                    // ROR IDX
 
 static void Op76(void)                                                 // ROR ABS
 {
-       uint8 m;
+       uint8_t m;
        READ_ABS_WB(m);
        OP_ROR_HANDLER(m);
        WRITE_BACK(m);
@@ -2851,57 +2851,57 @@ static void Op76(void)                                                  // ROR ABS
 // SBC opcodes
 
 #define OP_SBC_HANDLER(m, acc) \
-       uint16 sum = (uint16)acc - (m) - (uint16)flagC; \
+       uint16_t sum = (uint16_t)acc - (m) - (uint16_t)flagC; \
        flagC = (sum >> 8) & 0x01; \
        SET_V(m, acc, sum); \
-       acc = (uint8)sum; \
+       acc = (uint8_t)sum; \
        SET_ZN(acc)
 
 static void Op82(void)                                                 // SBCA #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_SBC_HANDLER(m, regs.a);
 }
 
 static void Op92(void)                                                 // SBCA DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_SBC_HANDLER(m, regs.a);
 }
 
 static void OpA2(void)                                                 // SBCA IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_SBC_HANDLER(m, regs.a);
 }
 
 static void OpB2(void)                                                 // SBCA ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_SBC_HANDLER(m, regs.a);
 }
 
 static void OpC2(void)                                                 // SBCB #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_SBC_HANDLER(m, regs.b);
 }
 
 static void OpD2(void)                                                 // SBCB DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_SBC_HANDLER(m, regs.b);
 }
 
 static void OpE2(void)                                                 // SBCB IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_SBC_HANDLER(m, regs.b);
 }
 
 static void OpF2(void)                                                 // SBCB ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_SBC_HANDLER(m, regs.b);
 }
 
@@ -2947,127 +2947,127 @@ static void OpF2(void)                                                        // SBCB ABS
 
 static void Op97(void)                                                 // STA DP
 {
-       uint16 addr = EA_DP;
+       uint16_t addr = EA_DP;
        OP_STA_HANDLER(addr, regs.a);
 }
 
 static void Op9F(void)                                                 // STX DP
 {
-       uint16 addr = EA_DP;
+       uint16_t addr = EA_DP;
        OP_STA_HANDLER16(addr, regs.x);
 }
 
 static void OpA7(void)                                                 // STA IDX
 {
-       uint16 addr = EA_IDX;
+       uint16_t addr = EA_IDX;
        OP_STA_HANDLER(addr, regs.a);
 }
 
 static void OpAF(void)                                                 // STX IDX
 {
-       uint16 addr = EA_IDX;
+       uint16_t addr = EA_IDX;
        OP_STA_HANDLER16(addr, regs.x);
 }
 
 static void OpB7(void)                                                 // STA ABS
 {
-       uint16 addr = EA_ABS;
+       uint16_t addr = EA_ABS;
        OP_STA_HANDLER(addr, regs.a);
 }
 
 static void OpBF(void)                                                 // STX ABS
 {
-       uint16 addr = EA_ABS;
+       uint16_t addr = EA_ABS;
        OP_STA_HANDLER16(addr, regs.x);
 }
 
 static void OpD7(void)                                                 // STB DP
 {
-       uint16 addr = EA_DP;
+       uint16_t addr = EA_DP;
        OP_STA_HANDLER(addr, regs.b);
 }
 
 static void OpDD(void)                                                 // STD DP
 {
-       uint16 addr = EA_DP;
+       uint16_t addr = EA_DP;
        OP_STA_HANDLER16(addr, (regs.a << 8) | regs.b);
 }
 
 static void OpDF(void)                                                 // STU DP
 {
-       uint16 addr = EA_DP;
+       uint16_t addr = EA_DP;
        OP_STA_HANDLER16(addr, regs.u);
 }
 
 static void OpE7(void)                                                 // STB IDX
 {
-       uint16 addr = EA_IDX;
+       uint16_t addr = EA_IDX;
        OP_STA_HANDLER(addr, regs.b);
 }
 
 static void OpED(void)                                                 // STD IDX
 {
-       uint16 addr = EA_IDX;
+       uint16_t addr = EA_IDX;
        OP_STA_HANDLER16(addr, (regs.a << 8) | regs.b);
 }
 
 static void OpEF(void)                                                 // STU IDX
 {
-       uint16 addr = EA_IDX;
+       uint16_t addr = EA_IDX;
        OP_STA_HANDLER16(addr, regs.u);
 }
 
 static void OpF7(void)                                                 // STB ABS
 {
-       uint16 addr = EA_ABS;
+       uint16_t addr = EA_ABS;
        OP_STA_HANDLER(addr, regs.b);
 }
 
 static void OpFD(void)                                                 // STD ABS
 {
-       uint16 addr = EA_ABS;
+       uint16_t addr = EA_ABS;
        OP_STA_HANDLER16(addr, (regs.a << 8) | regs.b);
 }
 
 static void OpFF(void)                                                 // STU ABS
 {
-       uint16 addr = EA_ABS;
+       uint16_t addr = EA_ABS;
        OP_STA_HANDLER16(addr, regs.u);
 }
 
 static void Op109F(void)                                               // STY DP
 {
-       uint16 addr = EA_DP;
+       uint16_t addr = EA_DP;
        OP_STA_HANDLER16(addr, regs.y);
 }
 
 static void Op10AF(void)                                               // STY IDX
 {
-       uint16 addr = EA_IDX;
+       uint16_t addr = EA_IDX;
        OP_STA_HANDLER16(addr, regs.y);
 }
 
 static void Op10BF(void)                                               // STY ABS
 {
-       uint16 addr = EA_ABS;
+       uint16_t addr = EA_ABS;
        OP_STA_HANDLER16(addr, regs.y);
 }
 
 static void Op10DF(void)                                               // STS DP
 {
-       uint16 addr = EA_DP;
+       uint16_t addr = EA_DP;
        OP_STA_HANDLER16(addr, regs.s);
 }
 
 static void Op10EF(void)                                               // STS IDX
 {
-       uint16 addr = EA_IDX;
+       uint16_t addr = EA_IDX;
        OP_STA_HANDLER16(addr, regs.s);
 }
 
 static void Op10FF(void)                                               // STS ABS
 {
-       uint16 addr = EA_ABS;
+       uint16_t addr = EA_ABS;
        OP_STA_HANDLER16(addr, regs.s);
 }
 
@@ -3093,15 +3093,15 @@ static void Op10FF(void)                                                // STS ABS
 // SUB opcodes
 
 #define OP_SUB_HANDLER(m, acc) \
-       uint16 sum = (uint16)acc - (m); \
+       uint16_t sum = (uint16_t)acc - (m); \
        flagC = (sum >> 8) & 0x01; \
        SET_V(m, acc, sum); \
-       acc = (uint8)sum; \
+       acc = (uint8_t)sum; \
        SET_ZN(acc)
 
 #define OP_SUB_HANDLER16D(m) \
-       uint32 acc = (uint32)((regs.a << 8) | regs.b); \
-       uint32 sum = acc - (m); \
+       uint32_t acc = (uint32_t)((regs.a << 8) | regs.b); \
+       uint32_t sum = acc - (m); \
        flagC = (sum >> 16) & 0x01; \
        SET_V16(m, acc, sum); \
        acc = sum & 0xFFFF; \
@@ -3111,73 +3111,73 @@ static void Op10FF(void)                                                // STS ABS
 
 static void Op80(void)                                                 // SUBA #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_SUB_HANDLER(m, regs.a);
 }
 
 static void Op83(void)                                                 // SUBD #
 {
-       uint16 m = READ_IMM16;
+       uint16_t m = READ_IMM16;
        OP_SUB_HANDLER16D(m);
 }
 
 static void Op90(void)                                                 // SUBA DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_SUB_HANDLER(m, regs.a);
 }
 
 static void Op93(void)                                                 // SUBD DP
 {
-       uint16 m = READ_DP16;
+       uint16_t m = READ_DP16;
        OP_SUB_HANDLER16D(m);
 }
 
 static void OpA0(void)                                                 // SUBA IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_SUB_HANDLER(m, regs.a);
 }
 
 static void OpA3(void)                                                 // SUBD IDX
 {
-       uint16 m = READ_IDX16;
+       uint16_t m = READ_IDX16;
        OP_SUB_HANDLER16D(m);
 }
 
 static void OpB0(void)                                                 // SUBA ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_SUB_HANDLER(m, regs.a);
 }
 
 static void OpB3(void)                                                 // SUBD ABS
 {
-       uint16 m = READ_ABS16;
+       uint16_t m = READ_ABS16;
        OP_SUB_HANDLER16D(m);
 }
 
 static void OpC0(void)                                                 // SUBB #
 {
-       uint8 m = READ_IMM;
+       uint8_t m = READ_IMM;
        OP_SUB_HANDLER(m, regs.b);
 }
 
 static void OpD0(void)                                                 // SUBB DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_SUB_HANDLER(m, regs.b);
 }
 
 static void OpE0(void)                                                 // SUBB IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_SUB_HANDLER(m, regs.b);
 }
 
 static void OpF0(void)                                                 // SUBB ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_SUB_HANDLER(m, regs.b);
 }
 
@@ -3201,7 +3201,7 @@ static void OpF0(void)                                                    // SUBB ABS
 
 static void Op0D(void)                                                 // TST DP
 {
-       uint8 m = READ_DP;
+       uint8_t m = READ_DP;
        OP_TST_HANDLER(m);
 }
 
@@ -3217,13 +3217,13 @@ static void Op5D(void)                                                  // TSTB
 
 static void Op6D(void)                                                 // TST IDX
 {
-       uint8 m = READ_IDX;
+       uint8_t m = READ_IDX;
        OP_TST_HANDLER(m);
 }
 
 static void Op7D(void)                                                 // TST ABS
 {
-       uint8 m = READ_ABS;
+       uint8_t m = READ_ABS;
        OP_TST_HANDLER(m);
 }
 
@@ -3237,8 +3237,8 @@ static void Op01(void)
 
 //temp, for testing...
 #ifdef __DEBUG__
-static uint8 backTrace[256];
-static uint16 btPC[256];
+static uint8_t backTrace[256];
+static uint16_t btPC[256];
 static int btPtr = 0;//*/
 #endif
 static void Op__(void)                                                                 // Illegal opcode
@@ -3331,7 +3331,7 @@ static void (* exec_op2[256])() = {
 static void Op10(void)
 {
 //     exec_op1[regs.RdMem(regs.pc++)]();
-       uint8 opcode = regs.RdMem(regs.pc++);
+       uint8_t opcode = regs.RdMem(regs.pc++);
        exec_op1[opcode]();
        regs.clock += page1Cycles[opcode];
 }
@@ -3340,7 +3340,7 @@ static void Op10(void)
 static void Op11(void)
 {
 //     exec_op2[regs.RdMem(regs.pc++)]();
-       uint8 opcode = regs.RdMem(regs.pc++);
+       uint8_t opcode = regs.RdMem(regs.pc++);
        exec_op2[opcode]();
        regs.clock += page2Cycles[opcode];
 }
@@ -3349,11 +3349,11 @@ static void Op11(void)
 //
 // Internal "memcpy" (so we don't have to link with any external libraries!)
 //
-static void myMemcpy(void * dst, void * src, uint32 size)
+static void myMemcpy(void * dst, void * src, uint32_t size)
 {
-       uint8 * d = (uint8 *)dst, * s = (uint8 *)src;
+       uint8_t * d = (uint8_t *)dst, * s = (uint8_t *)src;
 
-       for(uint32 i=0; i<size; i++)
+       for(uint32_t i=0; i<size; i++)
                d[i] = s[i];
 }
 
@@ -3364,12 +3364,12 @@ static void myMemcpy(void * dst, void * src, uint32 size)
 #ifdef DEBUG_ILLEGAL
 #include "log.h"
 #include "dis6809.h"
-uint8 btPtr = 0;
-uint8 backTrace[256];
+uint8_t btPtr = 0;
+uint8_t backTrace[256];
 V6809REGS btRegs[256];
 bool tripped = false;
 #endif
-void Execute6809(V6809REGS * context, uint32 cycles)
+void Execute6809(V6809REGS * context, uint32_t cycles)
 {
        // If this is not in place, the clockOverrun calculations can cause the V6809 to get
        // stuck in an infinite loop.
@@ -3377,7 +3377,7 @@ void Execute6809(V6809REGS * context, uint32 cycles)
                return;
 
        myMemcpy(&regs, context, sizeof(V6809REGS));
-       UNPACK_FLAGS;                                                           // Explode flags register into individual uint8s
+       UNPACK_FLAGS;                                                           // Explode flags register into individual uint8_ts
 
        // Execute here...
 
@@ -3387,7 +3387,7 @@ void Execute6809(V6809REGS * context, uint32 cycles)
        // through we remove them from the cycles passed in in order to come out
        // approximately even. Over the long run, this unevenness in execution times
        // evens out.
-       uint64 endCycles = regs.clock + (uint64)(cycles - regs.clockOverrun);
+       uint64_t endCycles = regs.clock + (uint64_t)(cycles - regs.clockOverrun);
 
        while (regs.clock < endCycles)
        {
@@ -3403,7 +3403,7 @@ if (!tripped)
                WriteLog("V6809: Executed illegal instruction!!!!\n\nBacktrace:\n\n");
                regs.cpuFlags &= ~V6809_STATE_ILLEGAL_INST;
 
-               for(uint16 i=btPtr; i<btPtr+256; i++)
+               for(uint16_t i=btPtr; i<btPtr+256; i++)
                {
                        Decode6809(btRegs[i & 0xFF].pc);
 // Note that these values are *before* execution, so stale...
@@ -3438,15 +3438,15 @@ btPC[btPtr] = regs.pc;
 btPtr = (btPtr + 1) & 0xFF;//*/
 #endif
 //             exec_op0[regs.RdMem(regs.pc++)]();
-               uint8 opcode = regs.RdMem(regs.pc++);
+               uint8_t opcode = regs.RdMem(regs.pc++);
                exec_op0[opcode]();
                regs.clock += page0Cycles[opcode];
 
                // Handle any pending interrupts
 
 // Hmm, this is bad and only works when flags are changed OUTSIDE of the running context...
-//             uint32 flags = context->cpuFlags;
-               uint32 flags = regs.cpuFlags;
+//             uint32_t flags = context->cpuFlags;
+               uint32_t flags = regs.cpuFlags;
 
                if (flags & V6809_ASSERT_LINE_RESET)                    // *** RESET handler ***
                {
@@ -3546,7 +3546,7 @@ if (disasm) WriteLog("CC=%s%s%s%s%s%s%s%s A=%02X B=%02X DP=%02X X=%04X Y=%04X S=
        }
 
        // Keep track of how much we overran so we can adjust on the next run...
-       regs.clockOverrun = (uint32)(regs.clock - endCycles);
+       regs.clockOverrun = (uint32_t)(regs.clock - endCycles);
 
        regs.cc = PACK_FLAGS;                                           // Mash flags back into the CC register
        myMemcpy(context, &regs, sizeof(V6809REGS));
@@ -3555,7 +3555,7 @@ if (disasm) WriteLog("CC=%s%s%s%s%s%s%s%s A=%02X B=%02X DP=%02X X=%04X Y=%04X S=
 //
 // Get the clock of the currently executing CPU
 //
-uint64 GetCurrentV6809Clock(void)
+uint64_t GetCurrentV6809Clock(void)
 {
        return regs.clock;
 }
@@ -3563,19 +3563,19 @@ uint64 GetCurrentV6809Clock(void)
 //
 // Get the PC of the currently executing CPU
 //
-uint16 GetCurrentV6809PC(void)
+uint16_t GetCurrentV6809PC(void)
 {
        return regs.pc;
 }
 
 // Set a line of the currently executing CPU
-void SetLineOfCurrentV6809(uint32 line)
+void SetLineOfCurrentV6809(uint32_t line)
 {
        regs.cpuFlags |= line;
 }
 
 // Clear a line of the currently executing CPU
-void ClearLineOfCurrentV6809(uint32 line)
+void ClearLineOfCurrentV6809(uint32_t line)
 {
 #ifdef __DEBUG__
 if (disasm)
index 39fc3f84638e86545644c4a2319f5f2d1af7c96e..ae8a33754efbab92c42927d80e2b6ca511004993 100755 (executable)
@@ -9,7 +9,7 @@
 #ifndef __V6809_H__
 #define __V6809_H__
 
-#include "types.h"
+#include <stdint.h>
 
 // Useful defines
 
 
 struct V6809REGS
 {
-       uint16 pc;                                              // 6809 PC register
-       uint16 x;                                               // 6809 X index register
-       uint16 y;                                               // 6809 Y index register
-       uint16 s;                                               // 6809 System stack pointer
-       uint16 u;                                               // 6809 User stack pointer
-       uint8 cc;                                               // 6809 Condition Code register
-       uint8 a;                                                // 6809 A register
-       uint8 b;                                                // 6809 B register
-       uint8 dp;                                               // 6809 Direct Page register
-//     uint32 clock;                                   // 6809 clock (@ 1 MHz, wraps at 71.5 minutes)
-       uint64 clock;                                   // 6809 clock (@ 1 MHz, wraps at 570842 years)
-       uint8 (* RdMem)(uint16);                // Address of uint8 read routine
-       void (* WrMem)(uint16, uint8);  // Address of uint8 write routine
-       uint32 cpuFlags;                                // v6809 IRQ/RESET flags
-       uint32 clockOverrun;
+       uint16_t pc;                                    // 6809 PC register
+       uint16_t x;                                             // 6809 X index register
+       uint16_t y;                                             // 6809 Y index register
+       uint16_t s;                                             // 6809 System stack pointer
+       uint16_t u;                                             // 6809 User stack pointer
+       uint8_t cc;                                             // 6809 Condition Code register
+       uint8_t a;                                              // 6809 A register
+       uint8_t b;                                              // 6809 B register
+       uint8_t dp;                                             // 6809 Direct Page register
+       uint64_t clock;                                 // 6809 clock (@ 1 MHz, wraps at 570842 years)
+       uint8_t (* RdMem)(uint16_t);    // Address of uint8 read routine
+       void (* WrMem)(uint16_t, uint8_t);      // Address of uint8 write routine
+       uint32_t cpuFlags;                              // v6809 IRQ/RESET flags
+       uint32_t clockOverrun;
 };
 
 // Function prototypes
 
-void Execute6809(V6809REGS *, uint32);                 // Function to execute 6809 instructions
-uint64 GetCurrentV6809Clock(void);                             // Get the clock of the currently executing CPU
-uint16 GetCurrentV6809PC(void);                                        // Get the PC of the currently executing CPU
-void SetLineOfCurrentV6809(uint32 line);               // Set a line of the currently executing CPU
-void ClearLineOfCurrentV6809(uint32 line);             // Clear a line of the currently executing CPU
+void Execute6809(V6809REGS *, uint32_t);               // Function to execute 6809 instructions
+uint64_t GetCurrentV6809Clock(void);                   // Get the clock of the currently executing CPU
+uint16_t GetCurrentV6809PC(void);                              // Get the PC of the currently executing CPU
+void SetLineOfCurrentV6809(uint32_t line);             // Set a line of the currently executing CPU
+void ClearLineOfCurrentV6809(uint32_t line);   // Clear a line of the currently executing CPU
 
 #endif // __V6809_H__
+
index da960c8c61b8b86aed4389c81b127acf0fce259b..072808e41bdf3fb370b3ff8a8411a8d6af651868 100755 (executable)
 //
 
 #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 = 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) < 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;
        }
 
-       // Get proper info about the platform we're running on...
-       const SDL_VideoInfo * info = SDL_GetVideoInfo();
-
-       if (!info)
-       {
-               WriteLog("Video: SDL is unable to get the video info: %s\n", SDL_GetError());
-               return false;
-       }
-
-       WriteLog("Video: Hardware is%s available...\n", (info->hw_available ? "" : " NOT"));
-       WriteLog("Video: Hardware blit is%s available...\n", (info->blit_hw ? "" : " NOT"));
-
-       if (settings.useOpenGL)
-       {
-               mainSurfaceFlags = SDL_HWSURFACE | SDL_HWPALETTE | SDL_DOUBLEBUF | SDL_OPENGL;
-               SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
-//We want 32BPP, so force the issue...
-               SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
-               SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
-               SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
-       }
-       else
-       {
-               mainSurfaceFlags = SDL_DOUBLEBUF;
-
-               if (info->hw_available)
-                       mainSurfaceFlags = SDL_HWSURFACE | SDL_HWPALETTE;
-
-               if (info->blit_hw)
-                       mainSurfaceFlags |= SDL_HWACCEL;
-       }
-
-       if (settings.fullscreen)
-               mainSurfaceFlags |= SDL_FULLSCREEN;
-
-       // Create the primary SDL display (32 BPP)
-       if (settings.useOpenGL)
-               mainSurface = SDL_SetVideoMode(VIRTUAL_SCREEN_WIDTH * 2, VIRTUAL_SCREEN_HEIGHT * 2, 32, mainSurfaceFlags);
-       else
-               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;
-       }
+       int retVal = SDL_CreateWindowAndRenderer(VIRTUAL_SCREEN_WIDTH * 3, VIRTUAL_SCREEN_HEIGHT * 3, SDL_WINDOW_OPENGL, &sdlWindow, &sdlRenderer);
 
-       // 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);
-
-       SDL_WM_SetCaption("StarGem2", "StarGem2");
-
-       // 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);
-/*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");//*/
-
-       if (surface == NULL)
+       if (retVal != 0)
        {
-               WriteLog("Video: Could not create secondary SDL surface: %s\n", SDL_GetError());
+               WriteLog("Video: Could not window and/or renderer: %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));
-
-       if (settings.fullscreen)
-               SDL_ShowCursor(SDL_DISABLE);
-
-#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);
+       // 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);
 
-       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)
 {
-       if (settings.useOpenGL)
-               sdlemu_close_opengl();
-
-//     SDL_JoystickClose(joystick);
-       SDL_FreeSurface(surface);
        SDL_Quit();
 }
 
+
 //
 // Render the backbuffer to the primary screen surface
 //
 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_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);
 }
 
-#if 0
+
 //
 // Fullscreen <-> window switching
 //
-//NOTE: This does *NOT* work with OpenGL rendering! !!! FIX !!!
-void ToggleFullscreen(void)
+void ToggleFullScreen(void)
 {
-       vjs.fullscreen = !vjs.fullscreen;
-       mainSurfaceFlags &= ~SDL_FULLSCREEN;
-
-       if (vjs.fullscreen)
-               mainSurfaceFlags |= SDL_FULLSCREEN;
+       settings.fullscreen = !settings.fullscreen;
+       int retVal;
 
-       mainSurface = SDL_SetVideoMode(tom_width, tom_height, 16, mainSurfaceFlags);
-
-       if (mainSurface == NULL)
+       if (settings.fullscreen)
        {
-               WriteLog("Video: SDL is unable to set the video mode: %s\n", SDL_GetError());
-               exit(1);
+               retVal = SDL_SetWindowFullscreen(sdlWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
+               SDL_ShowCursor(0);
+       }
+       else
+       {
+               retVal = SDL_SetWindowFullscreen(sdlWindow, 0);
+               SDL_ShowCursor(1);
        }
 
-       SDL_WM_SetCaption("Virtual Jaguar", "Virtual Jaguar");
+       if (retVal != 0)
+       {
+               WriteLog("Video::ToggleFullScreen: SDL error = %s\n", SDL_GetError());
+       }
 }
-#endif
+
index 56f8e23b1c89fd906f3c0dc5aecf40706e62cf40..abdece39907865c7a54e557e6079f7cd1751eb1b 100755 (executable)
@@ -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
 
 #define VIRTUAL_SCREEN_WIDTH           320
 #define VIRTUAL_SCREEN_HEIGHT          240
 bool InitVideo(void);
 void VideoDone(void);
 void RenderScreenBuffer(void);
-//void ToggleFullscreen(void);
+void ToggleFullScreen(void);
 
 // Exported crap
 
-extern uint32 * scrBuffer;
-extern SDL_Surface * surface;
+extern uint32_t scrBuffer[];
 
 #endif // __VIDEO_H__
+
index c5ef48d965e62ffc705ebd87a48a9988f6c23cb0..c67a25b58658c17c1173902b411d7859f163ee8a 100755 (executable)
@@ -2,23 +2,13 @@
 # StarGem2 configuration file
 #
 
-# Apple ROM paths
+# SG ROM paths
 
 BIOSROM = ./ROMs
-#diskROM = ./ROMs/disk.rom
-#ROMs = ./ROMs
 
-# Auto state loading/saving upon starting/quitting Apple2 (1 - use, 0 - don't use)
+# Auto state loading/saving upon starting/quitting (1 - use, 0 - don't use)
 
 autoSaveState = 1
-#This is the default--we don't advertise it just yet... ;-)
-#autoStateFilename = ./apple2auto.state
-
-# TEMPORARY disk image load paths
-
-# OpenGL options: 1 - use OpenGL rendering, 0 - use old style rendering
-
-useOpenGL = 1
 
 # OpenGL filtering type: 1 - blurry, 0 - sharp
 
@@ -28,20 +18,6 @@ glFilterType = 0
 
 fullscreen = 0
 
-# Backend renderer (OpenGL dependent): 0 - regular, 1 - "TV" style
-
-#renderType = 0
-
-# NTSC/PAL options: 1 - NTSC, 0 - PAL
-
-hardwareTypeNTSC = 1
-
-# Framskip options: 0 - no skip, 1-N - draw every Nth frame
-# Note: Skipping frames may cause strange visual side effects--don't bother
-#       reporting these unless they occur with a frameskip value of 0!
-
-frameSkip = 0
-
 # Joystick options: 1 - use joystick, 0 - don't use
 
 useJoystick = 0
@@ -71,3 +47,4 @@ joyport = 0
 #k_advance = 261                               # SDLK_KP5
 #k_high_score_reset = 262      # SDLK_KP6
 #k_slam_switch = 263                   # SDLK_KP7
+