--- /dev/null
+cmos.ram
+obj/
+sg2.state
+stargem2
+stargem2.log
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
SYSTYPE = __GCCUNIX__
EXESUFFIX =
-GLLIB = -lGL
ICON =
SDLLIBTYPE = --libs
MSG = generic Unix/Linux
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
obj/settings.o \
obj/sound.o \
obj/sdlemu_config.o \
- obj/sdlemu_opengl.o \
obj/timing.o \
obj/stargem2.o \
$(ICON)
# The "-" in front in there just in case they haven't been created yet
-include obj/*.d
+
"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...
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...
{
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;
return addr - pc;
}
+
#ifndef __DIS6809_H__
#define __DIS6809_H__
-#include "types.h"
+#include <stdint.h>
-int Decode6808(uint16 pc);
+int Decode6808(uint16_t pc);
#endif // __DIS6809_H__
//
// 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];
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);
//
// 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?
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;
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
#ifndef __DIS6809_H__
#define __DIS6809_H__
-#include "types.h"
+#include <stdint.h>
-int Decode6809(uint16);
+int Decode6809(uint16_t);
#endif // __DIS6809_H__
+++ /dev/null
-//
-// 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
-};
#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)
{
+++ /dev/null
-/*
- * 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;
- }
-}
+++ /dev/null
-/*
- * 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
#include <stdlib.h>
#include <string>
-#include "SDL.h"
+//#include "SDL.h"
+#include <SDL2/SDL.h>
#include "sdlemu_config.h"
#include "log.h"
// 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/"));
#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,
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
extern Settings settings;
#endif // __SETTINGS_H__
+
#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
//
}
// 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);
WriteLog("Sound: Successfully initialized.\n");
}
+
//
// Close down the SDL sound subsystem
//
}
}
+
//
// 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)
{
}
}
}
+
// --- ---------- ------------------------------------------------------------
// 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>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
-#include "types.h"
+#include <stdint.h>
#include "log.h"
#include "v6808.h"
#include "v6809.h"
#include "dis6809.h"
#include "dis6808.h"
+
//#define __DEBUG__
//#define LOG_PIA1_IO
// 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);
{
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)
for(int i=0; i<12; i++)
{
- uint32 baseAddress = i * 0x1000;
+ uint32_t baseAddress = i * 0x1000;
if (i > 8)
baseAddress += 0x4000;
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...
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)
{
WriteLog("\n");
}//*/
-/*uint32 pc = 0;
+/*uint32_t pc = 0;
while (pc < 0xFFFF)
{
pc += Decode6809(pc);
//
// 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");
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;
#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];
{
//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
}
//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);//*/
return b;
}
-void WrMem6809(uint16 addr, uint8 b)
+void WrMem6809(uint16_t addr, uint8_t b)
{
//temp...
//extern V6809REGS regs;
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]];
}
// 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;
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;
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]];
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;
//
#include "timing.h"
-
-#include "types.h"
+#include <stdint.h>
#include "log.h"
#define EVENT_LIST_SIZE 512
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)
{
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)
{
}
}
+
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)
{
}
}
+
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)
{
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;
(*event)();
}
+
#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);
+++ /dev/null
-//
-// 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__
// 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))
// 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,
// 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);
}
//
// 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); \
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);
}
// 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); \
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);
}
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);
}
// 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);
}
*/
#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);
}
static void Op63(void) // COM ZP, X
{
- uint8 m;
+ uint8_t m;
READ_ZP_X_WB(m);
OP_COM_HANDLER(m);
WRITE_BACK(m);
static void Op73(void) // COM ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_COM_HANDLER(m);
WRITE_BACK(m);
static void Op60(void) // NEG ZP, X
{
- uint8 m;
+ uint8_t m;
READ_ZP_X_WB(m);
OP_NEG_HANDLER(m);
WRITE_BACK(m);
static void Op70(void) // NEG ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_NEG_HANDLER(m);
WRITE_BACK(m);
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;
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
static void Op6A(void) // DEC ZP, X
{
- uint8 m;
+ uint8_t m;
READ_ZP_X_WB(m);
OP_DEC_HANDLER(m);
WRITE_BACK(m);
static void Op7A(void) // DEC ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_DEC_HANDLER(m);
WRITE_BACK(m);
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);
}
static void Op6C(void) // INC ZP, X
{
- uint8 m;
+ uint8_t m;
READ_ZP_X_WB(m);
OP_INC_HANDLER(m);
WRITE_BACK(m);
static void Op7C(void) // INC ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_INC_HANDLER(m);
WRITE_BACK(m);
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);
}
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);
}
// 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; \
static void Op69(void) // ROL ZP, X
{
- uint8 m;
+ uint8_t m;
READ_ZP_X_WB(m);
OP_ROL_HANDLER(m);
WRITE_BACK(m);
static void Op79(void) // ROL ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_ROL_HANDLER(m);
WRITE_BACK(m);
// 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; \
static void Op66(void) // ROR ZP, X
{
- uint8 m;
+ uint8_t m;
READ_ZP_X_WB(m);
OP_ROR_HANDLER(m);
WRITE_BACK(m);
static void Op76(void) // ROR ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_ROR_HANDLER(m);
WRITE_BACK(m);
// 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; \
static void Op68(void) // ASL ZP, X
{
- uint8 m;
+ uint8_t m;
READ_ZP_X_WB(m);
OP_ASL_HANDLER(m);
WRITE_BACK(m);
static void Op78(void) // ASL ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_ASL_HANDLER(m);
WRITE_BACK(m);
// 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; \
static void Op67(void) // ASR ZP, X
{
- uint8 m;
+ uint8_t m;
READ_ZP_X_WB(m);
OP_ASR_HANDLER(m);
WRITE_BACK(m);
static void Op77(void) // ASR ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_ASR_HANDLER(m);
WRITE_BACK(m);
// LSR opcodes
#define OP_LSR_HANDLER(m) \
- uint8 newCarry = m & 0x01; \
+ uint8_t newCarry = m & 0x01; \
m >>= 1; \
SET_ZN(m); \
flagC = newCarry; \
static void Op64(void) // LSR ZP, X
{
- uint8 m;
+ uint8_t m;
READ_ZP_X_WB(m);
OP_LSR_HANDLER(m);
WRITE_BACK(m);
static void Op74(void) // LSR ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_LSR_HANDLER(m);
WRITE_BACK(m);
// 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);
}
// 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);
}
static void Op6D(void) // TST ZP, X
{
- uint8 m;
+ uint8_t m;
READ_ZP_X_WB(m);
OP_TST_HANDLER(m);
WRITE_BACK(m);
static void Op7D(void) // TST ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_TST_HANDLER(m);
WRITE_BACK(m);
*/
#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);
}
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);
}
static void Op20(void) // BRA
{
- int16 m = (int16)(int8)READ_IMM;
+ int16_t m = (int16_t)(int8_t)READ_IMM;
regs.pc += m;
}
// 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
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);
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);
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);
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);
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);
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));
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);
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);
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);
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);
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);
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);
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);
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;
}
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;
}
//
// 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];
}
//
// 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(®s, 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)
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))
//
// Get the clock of the currently executing CPU
//
-uint64 GetCurrentV6808Clock(void)
+uint64_t GetCurrentV6808Clock(void)
{
return regs.clock;
}
#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__
+
#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)
#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))
// 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
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
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
// 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);
//
// Function to read TFR/EXG post byte
//
-uint16 ReadEXG(uint8 code)
+uint16_t ReadEXG(uint8_t code)
{
- uint16 retval;
+ uint16_t retval;
switch (code)
{
//
// Function to set TFR/EXG data
//
-void WriteEXG(uint8 code, uint16 data)
+void WriteEXG(uint8_t code, uint16_t data)
{
switch (code)
{
//
// Function to decode register data
//
-uint16 DecodeReg(uint8 reg)
+uint16_t DecodeReg(uint8_t reg)
{
- uint16 retval;
+ uint16_t retval;
switch (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);
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:
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:
}
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; }
}
}
// 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); \
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);
}
// 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); \
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; \
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);
}
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);
}
// 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; \
static void Op08(void) // ASL DP
{
- uint8 m;
+ uint8_t m;
READ_DP_WB(m);
OP_ASL_HANDLER(m);
WRITE_BACK(m);
static void Op68(void) // ASL IDX
{
- uint8 m;
+ uint8_t m;
READ_IDX_WB(m);
OP_ASL_HANDLER(m);
WRITE_BACK(m);
static void Op78(void) // ASL ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_ASL_HANDLER(m);
WRITE_BACK(m);
// 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);
static void Op67(void) // ASR IDX
{
- uint8 m;
+ uint8_t m;
READ_IDX_WB(m);
OP_ASR_HANDLER(m);
WRITE_BACK(m);
static void Op77(void) // ASR ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_ASR_HANDLER(m);
WRITE_BACK(m);
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)...
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);
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);
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);
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);
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;
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);
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;
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);
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;
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)));
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));
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)));
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));
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)...
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);
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);
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;
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);
static void Op1027(void) // LBEQ
{
// Z
- uint16 offset = READ_IMM16;
+ uint16_t offset = READ_IMM16;
#ifdef TEST_DONT_BRANCH_OPTIMIZATION
regs.pc += offset * flagZ;
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);
static void Op1029(void) // LBVS
{
// V
- uint16 offset = READ_IMM16;
+ uint16_t offset = READ_IMM16;
#ifdef TEST_DONT_BRANCH_OPTIMIZATION
regs.pc += offset * flagV;
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);
static void Op102B(void) // LBMI
{
// N
- uint16 offset = READ_IMM16;
+ uint16_t offset = READ_IMM16;
#ifdef TEST_DONT_BRANCH_OPTIMIZATION
regs.pc += offset * flagN;
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)));
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));
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)));
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));
// 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);
}
static void Op0F(void) // CLR DP
{
- uint8 m;
+ uint8_t m;
READ_DP_WB(m);
OP_CLR_HANDLER(m);
WRITE_BACK(m);
static void Op6F(void) // CLR IDX
{
- uint8 m;
+ uint8_t m;
READ_IDX_WB(m);
OP_CLR_HANDLER(m);
WRITE_BACK(m);
static void Op7F(void) // CLR ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_CLR_HANDLER(m);
WRITE_BACK(m);
// 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);
}
static void Op03(void) // COM DP
{
- uint8 m;
+ uint8_t m;
READ_DP_WB(m);
OP_COM_HANDLER(m);
WRITE_BACK(m);
static void Op63(void) // COM IDX
{
- uint8 m;
+ uint8_t m;
READ_IDX_WB(m);
OP_COM_HANDLER(m);
WRITE_BACK(m);
static void Op73(void) // COM ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_COM_HANDLER(m);
WRITE_BACK(m);
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)
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
static void Op0A(void) // DEC DP
{
- uint8 m;
+ uint8_t m;
READ_DP_WB(m);
OP_DEC_HANDLER(m);
WRITE_BACK(m);
static void Op6A(void) // DEC IDX
{
- uint8 m;
+ uint8_t m;
READ_IDX_WB(m);
OP_DEC_HANDLER(m);
WRITE_BACK(m);
static void Op7A(void) // DEC ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_DEC_HANDLER(m);
WRITE_BACK(m);
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);
}
static void Op0C(void) // INC DP
{
- uint8 m;
+ uint8_t m;
READ_DP_WB(m);
OP_INC_HANDLER(m);
WRITE_BACK(m);
static void Op6C(void) // INC IDX
{
- uint8 m;
+ uint8_t m;
READ_IDX_WB(m);
OP_INC_HANDLER(m);
WRITE_BACK(m);
static void Op7C(void) // INC ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_INC_HANDLER(m);
WRITE_BACK(m);
static void Op17(void) // LBSR
{
- uint16 word = FetchMemW(regs.pc);
+ uint16_t word = FetchMemW(regs.pc);
PUSHS16(regs.pc);
regs.pc += word;
}
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;
}
{
// 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)
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)
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);
}
static void Op04(void) // LSR DP
{
- uint8 m;
+ uint8_t m;
READ_DP_WB(m);
OP_LSR_HANDLER(m);
WRITE_BACK(m);
static void Op64(void) // LSR IDX
{
- uint8 m;
+ uint8_t m;
READ_IDX_WB(m);
OP_LSR_HANDLER(m);
WRITE_BACK(m);
static void Op74(void) // LSR ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_LSR_HANDLER(m);
WRITE_BACK(m);
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);
// 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); \
*/
static void Op00(void) // NEG DP
{
- uint8 m;
+ uint8_t m;
READ_DP_WB(m);
OP_NEG_HANDLER(m);
WRITE_BACK(m);
static void Op60(void) // NEG IDX
{
- uint8 m;
+ uint8_t m;
READ_IDX_WB(m);
OP_NEG_HANDLER(m);
WRITE_BACK(m);
static void Op70(void) // NEG ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_NEG_HANDLER(m);
WRITE_BACK(m);
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);
}
static void Op34(void) // PSHS
{
- uint8 m = READ_IMM;
+ uint8_t m = READ_IMM;
if (m & 0x80)
PUSHS16(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 Op35(void) // PULS
{
- uint8 m = READ_IMM;
+ uint8_t m = READ_IMM;
if (m & 0x01)
{
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);
}
// 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)
{
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]);
}
// 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; \
*/
static void Op09(void) // ROL DP
{
- uint8 m;
+ uint8_t m;
READ_DP_WB(m);
OP_ROL_HANDLER(m);
WRITE_BACK(m);
static void Op69(void) // ROL IDX
{
- uint8 m;
+ uint8_t m;
READ_IDX_WB(m);
OP_ROL_HANDLER(m);
WRITE_BACK(m);
static void Op79(void) // ROL ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_ROL_HANDLER(m);
WRITE_BACK(m);
// 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; \
static void Op06(void) // ROR DP
{
- uint8 m;
+ uint8_t m;
READ_DP_WB(m);
OP_ROR_HANDLER(m);
WRITE_BACK(m);
static void Op66(void) // ROR IDX
{
- uint8 m;
+ uint8_t m;
READ_IDX_WB(m);
OP_ROR_HANDLER(m);
WRITE_BACK(m);
static void Op76(void) // ROR ABS
{
- uint8 m;
+ uint8_t m;
READ_ABS_WB(m);
OP_ROR_HANDLER(m);
WRITE_BACK(m);
// 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);
}
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);
}
// 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; \
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);
}
static void Op0D(void) // TST DP
{
- uint8 m = READ_DP;
+ uint8_t m = READ_DP;
OP_TST_HANDLER(m);
}
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);
}
//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
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];
}
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];
}
//
// 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];
}
#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.
return;
myMemcpy(®s, context, sizeof(V6809REGS));
- UNPACK_FLAGS; // Explode flags register into individual uint8s
+ UNPACK_FLAGS; // Explode flags register into individual uint8_ts
// Execute here...
// 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)
{
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...
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 ***
{
}
// 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, ®s, sizeof(V6809REGS));
//
// Get the clock of the currently executing CPU
//
-uint64 GetCurrentV6809Clock(void)
+uint64_t GetCurrentV6809Clock(void)
{
return regs.clock;
}
//
// 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)
#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__
+
//
#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
+
#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__
+
# 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
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
#k_advance = 261 # SDLK_KP5
#k_high_score_reset = 262 # SDLK_KP6
#k_slam_switch = 263 # SDLK_KP7
+