#
# Makefile for Thunder SDL
#
+# by James L. Hammons
+# (C) 2009 Underground Software
+# This software is licensed under the GPL v3 or later
+#
+
+ifeq "$(OSTYPE)" "msys" # Win32
+
+SYSTYPE = __GCCWIN32__
+EXESUFFIX = .exe
+GLLIB = -lopengl32
+ICON = obj/icon.o
+SDLLIBTYPE = --libs
+MSG = Win32 on MinGW
-# Uncomment the following lines to compile for Win32
+else
+#ifeq "$(OSTYPE)" "darwin"
+ifeq "darwin" "$(findstring darwin,$(OSTYPE))" # Should catch both 'darwin' and 'darwin7.0'
-SYSTYPE = __GCCWIN32__
-EXESUFFIX = .exe
-GLLIB = opengl32
-ICON = thunder-ico.o
+SYSTYPE = __GCCUNIX__ -D_OSX_
+EXESUFFIX =
+GLLIB =
+ICON =
+SDLLIBTYPE = --static-libs
+MSG = Mac OS X
-# Uncomment the following lines to compile for *nix
+else # *nix
-#SYSTYPE = __GCCUNIX__
-#EXESUFFIX =
-#GLLIB = GL
-#ICON =
+SYSTYPE = __GCCUNIX__
+EXESUFFIX =
+GLLIB = -lGL
+ICON =
+SDLLIBTYPE = --libs
+MSG = generic Unix/Linux
+
+endif
+endif
CC = gcc
LD = gcc
TARGET = thunder
-SDL_CFLAGS = -I/c/mingw/include/SDL -Dmain=SDL_main
-SDL_CONFIG = /mingw/bin/sdl-config
-SDL_LIBS = -L/c/mingw/lib -lmingw32 -lSDLmain -lSDL -mwindows
+CFLAGS = -MMD -Wall -Wno-switch -Wno-uninitialized -Wno-unused -O2 -D$(SYSTYPE) -fomit-frame-pointer `sdl-config --cflags`
+CPPFLAGS = -MMD -Wall -Wno-switch -Wno-non-virtual-dtor -Wno-uninitialized -Wno-unused -O2 -D$(SYSTYPE) \
+ -fomit-frame-pointer `sdl-config --cflags` \
+ -g
+# -DLOG_UNMAPPED_MEMORY_ACCESSES
+
+LDFLAGS =
+
+# Ugh, let's get rid of the ref to -lcurses
+LIBS = -L/usr/local/lib `sdl-config $(SDLLIBTYPE)` -lstdc++ -lz $(GLLIB) -lcurses
+
+INCS = -I. -Isrc -I/usr/local/include
+
+OBJS = \
+ obj/gui.o \
+ obj/log.o \
+ obj/resource.o \
+ obj/screen.o \
+ obj/v6809.o \
+ obj/thunder.o \
+ $(ICON)
+
+all: checkenv message obj $(TARGET)$(EXESUFFIX)
+ @echo
+ @echo -e "\033[01;33m***\033[00;32m Looks like it compiled OK... Give it a whirl!\033[00m"
-# DEFS = -DX86_ASM -DLSB_FIRST
-DEFS =
-CFLAGS = -fstrength-reduce -fomit-frame-pointer -O2 -Wall -Wno-unused \
- -Wno-uninitialized -Wno-comment $(SDL_CFLAGS)
-LIBS = -lstdc++ $(SDL_LIBS)
-OBJS = obj/log.o obj/v6809.o obj/screen.o obj/gui.o obj/resource.o obj/thunder.o $(ICON)
+# Check the compilation environment, barf if not appropriate
-all: obj $(TARGET)
+checkenv:
+ @echo
+ @echo -en "\033[01;33m***\033[00;32m Checking compilation environment... \033[00m"
+ifeq "" "$(shell which sdl-config)"
+ @echo
+ @echo
+ @echo -e "\033[01;33mIt seems that you don't have the SDL development libraries installed.
+ @echo -e "have installed them, make sure that the sdl-config file is somewhere in your"
+ @echo -e "path and is executable.\033[00m"
+ @echo
+#Is there a better way to break out of the makefile?
+ @break
+else
+ @echo -e "\033[01;37mOK\033[00m"
+endif
+
+message:
+ @echo
+ @echo -e "\033[01;33m***\033[00;32m Building Thunder/SDL for $(MSG)...\033[00m"
+ @echo
clean:
- rm -rf obj
- rm -f ./$(TARGET)$(EXESUFFIX)
+ @echo -en "\033[01;33m***\033[00;32m Cleaning out the garbage...\033[00m"
+ @rm -rf obj
+ @rm -f ./$(TARGET)$(EXESUFFIX)
+ @echo -e "\033[01;37mdone!\033[00m"
obj:
- mkdir obj
+ @mkdir obj
-$(TARGET): $(OBJS)
- $(LD) $(LDFLAGS) -o $@$(EXESUFFIX) $(OBJS) $(LIBS)
-# strip --strip-all $(TARGET)$(EXESUFFIX)
-# upx -9 $(TARGET)$(EXESUFFIX)
+# This is only done for Win32 at the moment...
+
+ifneq "" "$(ICON)"
+$(ICON): res/$(TARGET).rc res/$(TARGET).ico
+ @echo -e "\033[01;33m***\033[00;32m Processing icon...\033[00m"
+ @windres -i res/$(TARGET).rc -o $(ICON) --include-dir=./res
+endif
-#obj/%.o: src/%.c
-# $(CC) -c $< -o $@
+obj/%.o: src/%.c
+ @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
+ @$(CC) $(CFLAGS) $(INCS) -c $< -o $@
-#obj/%.o: src/%.cpp
-obj/%.o: %.cpp %.h
- $(CC) $(CFLAGS) -c $< -o $@
+obj/%.o: src/%.cpp
+ @echo -e "\033[01;33m***\033[00;32m Compiling $<...\033[00m"
+ @$(CC) $(CPPFLAGS) $(INCS) -c $< -o $@
+
+obj/%.o: src/%.asm
+ nasm -f elf32 -I res/ $< -o $@
+# *** sigh *** yet another variable... !!! FIX !!!
+# nasm -f coff $< -o $@
+
+$(TARGET)$(EXESUFFIX): $(OBJS)
+ @echo -e "\033[01;33m***\033[00;32m Linking it all together...\033[00m"
+ @$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
+# strip --strip-all $(TARGET)$(EXESUFFIX)
+# upx -9 $(TARGET)$(EXESUFFIX)
-obj/%.o: %.cpp
- $(CC) $(CFLAGS) -c $< -o $@
+# Pull in dependencies autogenerated by gcc's -MMD switch
+# The "-" in front in there just in case they haven't been created yet
-obj/%.o: %.asm %.h
- nasm -f coff $< -o $@
+-include obj/*.d
//
// Thunder Graphic User Interface
-// v1.0 (Last build: 8/1/1998)
//
-// by Jimmy Hamm
-// (C) 1998 Underground Software
+// by James L. Hammons
+// (c) 2004, 2009 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// WHO WHEN WHAT
+// --- ---------- ------------------------------------------------------------
+// JLH 07/23/2009 Added changelog ;-)
//
#include <string>
0,1,0,0,1,0,
0,1,0,0,1,0,
0,0,1,1,0,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bn1[] = {
0,0,0,0,0,0,
0,0,1,0,0,0,
0,0,1,0,0,0,
0,1,1,1,0,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bn2[] = {
0,0,0,0,0,0,
0,0,1,1,0,0,
0,1,0,0,0,0,
0,1,1,1,1,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bn3[] = {
0,0,0,0,0,0,
0,1,1,1,0,0,
0,0,0,0,1,0,
0,1,1,1,0,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bn4[] = {
0,0,0,0,0,0,
0,1,0,1,0,0,
0,1,1,1,1,0,
0,0,0,1,0,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bn5[] = {
0,0,0,0,0,0,
0,1,1,1,0,0,
0,0,0,0,1,0,
0,1,1,1,0,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bn6[] = {
0,0,0,0,0,0,
0,1,1,1,0,0,
0,1,0,0,1,0,
0,0,1,1,0,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bn7[] = {
0,0,0,0,0,0,
0,0,0,1,0,0,
0,0,1,0,0,0,
0,0,1,0,0,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bn8[] = {
0,0,0,0,0,0,
0,0,1,1,0,0,
0,1,0,0,1,0,
0,0,1,1,0,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bn9[] = {
0,0,0,0,0,0,
0,0,1,1,1,0,
0,0,0,0,1,0,
0,0,1,1,0,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bnA[] = {
0,0,0,0,0,0,
0,1,1,1,1,0,
0,1,0,0,1,0,
0,1,0,0,1,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bnB[] = {
0,0,0,0,0,0,
0,1,1,1,0,0,
0,1,0,0,1,0,
0,1,1,1,0,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bnC[] = {
0,0,0,0,0,0,
0,1,0,0,0,0,
0,1,0,0,1,0,
0,0,1,1,0,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bnD[] = {
0,0,0,0,0,0,
0,1,0,0,1,0,
0,1,0,0,1,0,
0,1,1,1,0,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bnE[] = {
0,0,0,0,0,0,
0,1,1,1,1,0,
0,1,0,0,0,0,
0,1,1,1,1,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
BYTE bnF[] = {
0,0,0,0,0,0,
0,1,1,1,0,0,
0,1,0,0,0,0,
0,1,0,0,0,0,
- 0,0,0,0,0,0
+ 0,0,0,0,0,0
};
//
if (b) my_scr[scadr+xx+yy*320] = b;
}
}
- for(int i=0; i<16; i++)
+ for(int i=0; i<16; i++)
{
scadr = dbase + (5*320+5) + i*7*320;
if (i>7) scadr += 17*320; // Adjust for DSW #2
{
for(int xx=0; xx<5; xx++)
{
- my_scr[scadr++] = idsbutton[bmpptr++];
+ my_scr[scadr++] = idsbutton[bmpptr++];
}
scadr += 315; // Adjust position...
}
if (!user_selected_something) // i.e. we're not inside a selection...
{
DrawSmallIcons(selection); // 'selection' is icon *not* to draw
- DrawLargeIcon(selection);
+ DrawLargeIcon(selection);
}
else
{
//SpawnSound(USERSOUND, SBLAH);
user_selected_something = true;
dswitch = 0; // Set at first dipswitch
- }
+ }
if (selection == OPTIONS) // Edit emulator settings
{
}
}
if (selection == SNAPSHOT) // Snapshot
{
- SpawnSound(USERSOUND, SCAMERA);
+ SpawnSound(USERSOUND, SCAMERA);
SnapPCX(screen);
}
if (selection == RESET) // Reset machine
// Log handler
//
// by James L. Hammons
+// (c) 2004, 2009 Underground Software
+//
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// WHO WHEN WHAT
+// --- ---------- ------------------------------------------------------------
+// JLH 07/23/2009 Added changelog ;-)
//
#include "types.h"
static FILE * log_stream = NULL;
static uint32 logSize = 0;
-bool InitLog(char * path)
+bool InitLog(const char * path)
{
log_stream = fopen(path, "wrt");
extern "C" {
#endif
-bool InitLog(char *);
+bool InitLog(const char *);
void LogDone(void);
void WriteLog(const char * text, ...);
-;\r
-; Thunder GUI resources\r
-;\r
-; by Jimmy Hamm\r
-; (C) 1998 Underground Software\r
-;\r
-[SECTION .data]\r
-[GLOBAL _sunknown]\r
-[GLOBAL _scya]\r
-[GLOBAL _scamera]\r
-[GLOBAL _sunknownlen]\r
-[GLOBAL _scyalen]\r
-[GLOBAL _scameralen]\r
-\r
-[GLOBAL _inoguib]\r
-[GLOBAL _idipswb]\r
-[GLOBAL _ipl1stb]\r
-[GLOBAL _ipl2stb] \r
-[GLOBAL _ii30hzb] \r
-[GLOBAL _ii60hzb] \r
-[GLOBAL _icoinub] \r
-[GLOBAL _isnapsb] \r
-[GLOBAL _iresetb] \r
-[GLOBAL _ibyebyb] \r
-[GLOBAL _ikeycnb]\r
-\r
-[GLOBAL _inoguis]\r
-[GLOBAL _idipsws]\r
-[GLOBAL _ipl1sts]\r
-[GLOBAL _ipl2sts] \r
-[GLOBAL _ii30hzs] \r
-[GLOBAL _ii60hzs] \r
-[GLOBAL _icoinus] \r
-[GLOBAL _isnapss] \r
-[GLOBAL _iresets] \r
-[GLOBAL _ibyebys] \r
-[GLOBAL _ikeycns]\r
-[GLOBAL _ichecks]\r
-\r
-[GLOBAL _idswitch]\r
-[GLOBAL _idsbutton]\r
-[GLOBAL _idstext1]\r
-[GLOBAL _idstext2]\r
-[GLOBAL _idstext3]\r
-[GLOBAL _idstext4]\r
-[GLOBAL _idstext5]\r
-[GLOBAL _idstext6]\r
-[GLOBAL _idstext7]\r
-[GLOBAL _idstext8]\r
-[GLOBAL _idstext9]\r
-[GLOBAL _idstext10]\r
-[GLOBAL _idstext11]\r
-[GLOBAL _idstext12]\r
-\r
-; Sounds\r
-\r
-_sunknown DD _sunknownlen+4\r
-_scya DD _scyalen+4\r
-_scamera DD _scameralen+4\r
-\r
-_sunknownlen\r
- incbin "unknown.wav", 54 ; Skip header, keep length\r
-_scyalen\r
- incbin "cya.wav", 54 ; Skip header, keep length\r
-_scameralen\r
- incbin "camera.wav", 54 ; Skip header, keep length\r
-\r
-; Graphics\r
-\r
-_inoguib DD fnoguib\r
-_idipswb DD fdipswb\r
-_ipl1stb DD fpl1stb\r
-_ipl2stb DD fpl2stb\r
-_ii30hzb DD fi30hzb\r
-_ii60hzb DD fi60hzb\r
-_icoinub DD fcoinub\r
-_isnapsb DD fsnapsb\r
-_iresetb DD fresetb\r
-_ibyebyb DD fbyebyb\r
-_ikeycnb DD fkeycnb\r
-\r
-_inoguis DD fnoguis\r
-_idipsws DD fdipsws\r
-_ipl1sts DD fpl1sts\r
-_ipl2sts DD fpl2sts\r
-_ii30hzs DD fi30hzs\r
-_ii60hzs DD fi60hzs\r
-_icoinus DD fcoinus\r
-_isnapss DD fsnapss\r
-_iresets DD fresets\r
-_ibyebys DD fbyebys\r
-_ikeycns DD fkeycns\r
-_ichecks DD fchecks\r
-\r
-_idswitch DD fdswitch\r
-_idsbutton DD fdsbutton\r
-_idstext1 DD fdstext1\r
-_idstext2 DD fdstext2\r
-_idstext3 DD fdstext3\r
-_idstext4 DD fdstext4\r
-_idstext5 DD fdstext5\r
-_idstext6 DD fdstext6\r
-_idstext7 DD fdstext7\r
-_idstext8 DD fdstext8\r
-_idstext9 DD fdstext9\r
-_idstext10 DD fdstext10\r
-_idstext11 DD fdstext11\r
-_idstext12 DD fdstext12\r
-\r
-fnoguib\r
- incbin "noguib.raw" ; 44x44\r
-fdipswb\r
- incbin "dipswb.raw" ; 42x34\r
-fpl1stb\r
- incbin "pl1stb.raw" ; 50x33\r
-fpl2stb\r
- incbin "pl2stb.raw" ; 52x29 [Light green: 125]\r
-fi30hzb\r
- incbin "i30hzb.raw" ; 58x40\r
-fi60hzb\r
- incbin "i60hzb.raw" ; 58x40\r
-fcoinub\r
- incbin "coinub.raw" ; 58x40\r
-fsnapsb\r
- incbin "snapsb.raw" ; 58x40\r
-fresetb\r
- incbin "resetb.raw" ; 58x40\r
-fbyebyb\r
- incbin "byebyb.raw" ; 58x40\r
-fkeycnb\r
- incbin "keycnb.raw" ; 58x40\r
-\r
-fnoguis\r
- incbin "noguis.raw" ; 44x44\r
-fdipsws\r
- incbin "dipsws.raw" ; 42x34\r
-fpl1sts\r
- incbin "pl1sts.raw" ; 50x33\r
-fpl2sts\r
- incbin "pl2sts.raw" ; 52x29 [Light green: 125]\r
-fi30hzs\r
- incbin "i30hzs.raw" ; 58x40\r
-fi60hzs\r
- incbin "i60hzs.raw" ; 58x40\r
-fcoinus\r
- incbin "coinus.raw" ; 58x40\r
-fsnapss\r
- incbin "snapss.raw" ; 58x40\r
-fresets\r
- incbin "resets.raw" ; 58x40\r
-fbyebys\r
- incbin "byebys.raw" ; 58x40\r
-fkeycns\r
- incbin "keycns.raw" ; 58x40\r
-fchecks\r
- incbin "checks.raw" ; 58x40\r
-\r
-fdswitch\r
- incbin "dswitch.raw" ; 26x65\r
-fdsbutton\r
- incbin "dsbutton.raw" ; 4x4\r
-fdstext1\r
- incbin "dstext1.raw" ; 48x7\r
-fdstext2\r
- incbin "dstext2.raw" ; 80x9\r
-fdstext3\r
- incbin "dstext3.raw" ; 96x7\r
-fdstext4\r
- incbin "dstext4.raw" ; 82x9\r
-fdstext5\r
- incbin "dstext5.raw" ; 60x7\r
-fdstext6\r
- incbin "dstext6.raw" ; 76x7\r
-fdstext7\r
- incbin "dstext7.raw" ; 57x7\r
-fdstext8\r
- incbin "dstext8.raw" ; 33x7\r
-fdstext9\r
- incbin "dstext9.raw" ; 50x9\r
-fdstext10\r
- incbin "dstext10.raw" ; 62x7\r
-fdstext11\r
- incbin "dstext11.raw" ; 65x9\r
-fdstext12\r
- incbin "dstext12.raw" ; 63x7\r
+;
+; Thunder GUI resources
+;
+; by Jimmy Hamm
+; (C) 1998 Underground Software
+;
+[SECTION .data]
+[GLOBAL sunknown]
+[GLOBAL scya]
+[GLOBAL scamera]
+[GLOBAL sunknownlen]
+[GLOBAL scyalen]
+[GLOBAL scameralen]
+
+[GLOBAL inoguib]
+[GLOBAL idipswb]
+[GLOBAL ipl1stb]
+[GLOBAL ipl2stb]
+[GLOBAL ii30hzb]
+[GLOBAL ii60hzb]
+[GLOBAL icoinub]
+[GLOBAL isnapsb]
+[GLOBAL iresetb]
+[GLOBAL ibyebyb]
+[GLOBAL ikeycnb]
+
+[GLOBAL inoguis]
+[GLOBAL idipsws]
+[GLOBAL ipl1sts]
+[GLOBAL ipl2sts]
+[GLOBAL ii30hzs]
+[GLOBAL ii60hzs]
+[GLOBAL icoinus]
+[GLOBAL isnapss]
+[GLOBAL iresets]
+[GLOBAL ibyebys]
+[GLOBAL ikeycns]
+[GLOBAL ichecks]
+
+[GLOBAL idswitch]
+[GLOBAL idsbutton]
+[GLOBAL idstext1]
+[GLOBAL idstext2]
+[GLOBAL idstext3]
+[GLOBAL idstext4]
+[GLOBAL idstext5]
+[GLOBAL idstext6]
+[GLOBAL idstext7]
+[GLOBAL idstext8]
+[GLOBAL idstext9]
+[GLOBAL idstext10]
+[GLOBAL idstext11]
+[GLOBAL idstext12]
+
+; Sounds
+
+sunknown DD sunknownlen+4
+scya DD scyalen+4
+scamera DD scameralen+4
+
+sunknownlen
+ incbin "unknown.wav", 54 ; Skip header, keep length
+scyalen
+ incbin "cya.wav", 54 ; Skip header, keep length
+scameralen
+ incbin "camera.wav", 54 ; Skip header, keep length
+
+; Graphics
+
+inoguib DD fnoguib
+idipswb DD fdipswb
+ipl1stb DD fpl1stb
+ipl2stb DD fpl2stb
+ii30hzb DD fi30hzb
+ii60hzb DD fi60hzb
+icoinub DD fcoinub
+isnapsb DD fsnapsb
+iresetb DD fresetb
+ibyebyb DD fbyebyb
+ikeycnb DD fkeycnb
+
+inoguis DD fnoguis
+idipsws DD fdipsws
+ipl1sts DD fpl1sts
+ipl2sts DD fpl2sts
+ii30hzs DD fi30hzs
+ii60hzs DD fi60hzs
+icoinus DD fcoinus
+isnapss DD fsnapss
+iresets DD fresets
+ibyebys DD fbyebys
+ikeycns DD fkeycns
+ichecks DD fchecks
+
+idswitch DD fdswitch
+idsbutton DD fdsbutton
+idstext1 DD fdstext1
+idstext2 DD fdstext2
+idstext3 DD fdstext3
+idstext4 DD fdstext4
+idstext5 DD fdstext5
+idstext6 DD fdstext6
+idstext7 DD fdstext7
+idstext8 DD fdstext8
+idstext9 DD fdstext9
+idstext10 DD fdstext10
+idstext11 DD fdstext11
+idstext12 DD fdstext12
+
+fnoguib
+ incbin "noguib.raw" ; 44x44
+fdipswb
+ incbin "dipswb.raw" ; 42x34
+fpl1stb
+ incbin "pl1stb.raw" ; 50x33
+fpl2stb
+ incbin "pl2stb.raw" ; 52x29 [Light green: 125]
+fi30hzb
+ incbin "i30hzb.raw" ; 58x40
+fi60hzb
+ incbin "i60hzb.raw" ; 58x40
+fcoinub
+ incbin "coinub.raw" ; 58x40
+fsnapsb
+ incbin "snapsb.raw" ; 58x40
+fresetb
+ incbin "resetb.raw" ; 58x40
+fbyebyb
+ incbin "byebyb.raw" ; 58x40
+fkeycnb
+ incbin "keycnb.raw" ; 58x40
+
+fnoguis
+ incbin "noguis.raw" ; 44x44
+fdipsws
+ incbin "dipsws.raw" ; 42x34
+fpl1sts
+ incbin "pl1sts.raw" ; 50x33
+fpl2sts
+ incbin "pl2sts.raw" ; 52x29 [Light green: 125]
+fi30hzs
+ incbin "i30hzs.raw" ; 58x40
+fi60hzs
+ incbin "i60hzs.raw" ; 58x40
+fcoinus
+ incbin "coinus.raw" ; 58x40
+fsnapss
+ incbin "snapss.raw" ; 58x40
+fresets
+ incbin "resets.raw" ; 58x40
+fbyebys
+ incbin "byebys.raw" ; 58x40
+fkeycns
+ incbin "keycns.raw" ; 58x40
+fchecks
+ incbin "checks.raw" ; 58x40
+
+fdswitch
+ incbin "dswitch.raw" ; 26x65
+fdsbutton
+ incbin "dsbutton.raw" ; 4x4
+fdstext1
+ incbin "dstext1.raw" ; 48x7
+fdstext2
+ incbin "dstext2.raw" ; 80x9
+fdstext3
+ incbin "dstext3.raw" ; 96x7
+fdstext4
+ incbin "dstext4.raw" ; 82x9
+fdstext5
+ incbin "dstext5.raw" ; 60x7
+fdstext6
+ incbin "dstext6.raw" ; 76x7
+fdstext7
+ incbin "dstext7.raw" ; 57x7
+fdstext8
+ incbin "dstext8.raw" ; 33x7
+fdstext9
+ incbin "dstext9.raw" ; 50x9
+fdstext10
+ incbin "dstext10.raw" ; 62x7
+fdstext11
+ incbin "dstext11.raw" ; 65x9
+fdstext12
+ incbin "dstext12.raw" ; 63x7
// JLH 03/12/2003 Ported this crud to Simple Directmedia Layer
//
+#include "screen.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string> // For memset()
-#include "SDL.h"
#include "gui.h"
-#include "screen.h"
// Private function prototypes
-void DrawSprites(BYTE priority);
+void DrawSprites(uint8 priority);
int FindPCXName(void);
// Private global variables
-BYTE my_scr[0x14000]; // Screen buffer...
-BYTE palette[768]; // Screen palette
-BYTE ccolor[256][8]; // Character colors
-BYTE scolor[128][16]; // Sprite colors
+uint8 my_scr[0x14000]; // Screen buffer...
+uint8 palette[768]; // Screen palette
+uint8 ccolor[256][8]; // Character colors
+uint8 scolor[128][16]; // Sprite colors
bool charbase; // Character base pointer...
-BYTE hScrollOffset; // Horizontal scroll offset
-BYTE vScrollOffset; // Vertical scroll offset
-BYTE spr_color_index; // Sprite color index
-DWORD offsets[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; // Scroll offsets...
-DWORD voffsets[8] = { 0, 320, 640, 960, 1280, 1600, 1920, 2240 };
+uint8 hScrollOffset; // Horizontal scroll offset
+uint8 vScrollOffset; // Vertical scroll offset
+uint8 spr_color_index; // Sprite color index
+uint32 offsets[8] = { 0, 1, 2, 3, 4, 5, 6, 7 }; // Scroll offsets...
+uint32 voffsets[8] = { 0, 320, 640, 960, 1280, 1600, 1920, 2240 };
extern bool show_text; // Whether or not to show text
extern bool show_scr; // Whether or not to show screen
//
// Render the NAMCO screen
//
-void BlitChar(SDL_Surface * scr, BYTE * chr, BYTE * ram)
+void BlitChar(SDL_Surface * scr, uint8 * chr, uint8 * ram)
{
if (show_scr)
{
int sx, sy;
- DWORD sc_base = ((ram[0x9000] << 8) | ram[0x9001]) + 4; // Adjust hscroll val
+ uint32 sc_base = ((ram[0x9000] << 8) | ram[0x9001]) + 4; // Adjust hscroll val
hScrollOffset = sc_base & 0x07; // Horiz. scroll offset
sc_base = (sc_base & 0xFFF8) >> 2; // Skip odds..
- BYTE vsc_base = ((ram[0x9002] + 1) & 0xF8) >> 3;// Vertical scroll addr adjust
+ uint8 vsc_base = ((ram[0x9002] + 1) & 0xF8) >> 3;// Vertical scroll addr adjust
vScrollOffset = ((ram[0x9002] + 1) & 0x07); // Vertical fine scroll amount
- DWORD scp1 = 0x0180 | ((sc_base + 0x04) & 0x7F); /*0x0188;*/
- DWORD scp2 = 0x1180 | ((sc_base + 0x04) & 0x7F); /*0x1188;*/
- DWORD scp3 = 0x2180 | ((sc_base + 0x04) & 0x7F); /*0x2188;*/
- DWORD scp = 0x3208;
+ uint32 scp1 = 0x0180 | ((sc_base + 0x04) & 0x7F); /*0x0188;*/
+ uint32 scp2 = 0x1180 | ((sc_base + 0x04) & 0x7F); /*0x1188;*/
+ uint32 scp3 = 0x2180 | ((sc_base + 0x04) & 0x7F); /*0x2188;*/
+ uint32 scp = 0x3208;
scp1 += vsc_base * 0x80;
scp1 &= 0x0FFF; // Set vertical scroll addr
scp2 += vsc_base * 0x80;
scp3 += vsc_base * 0x80;
scp3 = 0x2000 | (scp3 & 0x0FFF); // Set vertical scroll addr
- DWORD chBaseOffset = (charbase ? 0x20000 : 0x00000);
+ uint32 chBaseOffset = (charbase ? 0x20000 : 0x00000);
for(sy=0; sy<29; sy++)
{
for(sx=0; sx<37; sx++)
{
- BYTE scp_lo = (scp1 + (sx << 1)) & 0x7F;// Let LO byte wrap only...
- WORD sp2 = (scp1 & 0xFF80) | scp_lo;
- BYTE tile = ram[sp2++];
- BYTE index = ram[sp2] & 0x03;
- BYTE color = ram[sp2];
- DWORD chind = chBaseOffset + (((index << 8) + tile) * 64);
- DWORD sc_addr = (sx * 8) + (sy * 2560); // Start addr in my_scr[]
+ uint8 scp_lo = (scp1 + (sx << 1)) & 0x7F;// Let LO byte wrap only...
+ uint16 sp2 = (scp1 & 0xFF80) | scp_lo;
+ uint8 tile = ram[sp2++];
+ uint8 index = ram[sp2] & 0x03;
+ uint8 color = ram[sp2];
+ uint32 chind = chBaseOffset + (((index << 8) + tile) * 64);
+ uint32 sc_addr = (sx * 8) + (sy * 2560); // Start addr in my_scr[]
for(int y=0; y<8; y++)
{
{
for(sx=0; sx<37; sx++)
{
- BYTE scp_lo = (scp2 + (sx << 1)) & 0x7F; // Let LO byte wrap only...
- WORD sp2 = (scp2 & 0xFF80) | scp_lo;
- BYTE tile = ram[sp2++];
- BYTE index = ram[sp2] & 0x03;
- BYTE color = ram[sp2];
- DWORD chind = chBaseOffset + (((index << 8) + tile) * 64);
- DWORD sc_addr = (sx * 8) + (sy * 2560); // Start addr in my_scr[]
+ uint8 scp_lo = (scp2 + (sx << 1)) & 0x7F; // Let LO byte wrap only...
+ uint16 sp2 = (scp2 & 0xFF80) | scp_lo;
+ uint8 tile = ram[sp2++];
+ uint8 index = ram[sp2] & 0x03;
+ uint8 color = ram[sp2];
+ uint32 chind = chBaseOffset + (((index << 8) + tile) * 64);
+ uint32 sc_addr = (sx * 8) + (sy * 2560); // Start addr in my_scr[]
for(int y=0; y<8; y++)
{
{
for(sx=0; sx<37; sx++)
{
- BYTE scp_lo = (scp3 + (sx << 1)) & 0x7F; // Let LO byte wrap only...
- WORD sp2 = (scp3 & 0xFF80) | scp_lo;
- BYTE tile = ram[sp2++];
- BYTE index = ram[sp2] & 0x03;
- BYTE color = ram[sp2];
- DWORD chind = 0x40000 + (((index << 8) + tile) * 64);
- DWORD sc_addr = (sx * 8) + (sy * 2560); // Start addr in my_scr[]
+ uint8 scp_lo = (scp3 + (sx << 1)) & 0x7F; // Let LO byte wrap only...
+ uint16 sp2 = (scp3 & 0xFF80) | scp_lo;
+ uint8 tile = ram[sp2++];
+ uint8 index = ram[sp2] & 0x03;
+ uint8 color = ram[sp2];
+ uint32 chind = 0x40000 + (((index << 8) + tile) * 64);
+ uint32 sc_addr = (sx * 8) + (sy * 2560); // Start addr in my_scr[]
for(int y=0; y<8; y++)
{
{
for(sx=0; sx<36; sx++)
{
- WORD sp2 = scp + (sx << 1);
- BYTE tile = ram[sp2++];
- BYTE index = ram[sp2] & 0x03;
- BYTE color = ram[sp2];
- DWORD chind = 0x50000 + (((index << 8) + tile) * 64);
- DWORD sc_addr = (sx * 8) + (sy * 2560) + hScrollOffset + voffsets[vScrollOffset]; // Start addr in my_scr[]
+ uint16 sp2 = scp + (sx << 1);
+ uint8 tile = ram[sp2++];
+ uint8 index = ram[sp2] & 0x03;
+ uint8 color = ram[sp2];
+ uint32 chind = 0x50000 + (((index << 8) + tile) * 64);
+ uint32 sc_addr = (sx * 8) + (sy * 2560) + hScrollOffset + voffsets[vScrollOffset]; // Start addr in my_scr[]
for(int y=0; y<8; y++)
{
for(int x=0; x<8; x++)
{
if (chr[chind] != 7)
- my_scr[sc_addr] = ccolor[color][chr[chind]];
+ my_scr[sc_addr] = ccolor[color][chr[chind]];
sc_addr++;
chind++;
/* for(int i=0; i<224; i++)
{
memcpy((char *)scr->pixels + scr->pitch * i,
- my_scr + (DWORD)(offsets[hScrollOffset]+voffsets[vScrollOffset]) + i * 320, 320);
+ my_scr + (uint32)(offsets[hScrollOffset]+voffsets[vScrollOffset]) + i * 320, 320);
}//*/
// Doubled pixel blit (should be faster now!)
- BYTE * pMem = (BYTE *)scr->pixels + ((scr->pitch * 8 + 16) * 2);
- DWORD src = (DWORD)(offsets[hScrollOffset] + voffsets[vScrollOffset]),
+ uint8 * pMem = (uint8 *)scr->pixels + ((scr->pitch * 8 + 16) * 2);
+ uint32 src = (uint32)(offsets[hScrollOffset] + voffsets[vScrollOffset]),
dst1 = 0, dst2 = scr->pitch;
- DWORD srcAdd = 320 - 288, dstAdd = (scr->pitch * 2) - (288 * 2);
+ uint32 srcAdd = 320 - 288, dstAdd = (scr->pitch * 2) - (288 * 2);
for(int i=0; i<224; i++)
{
}//*/
// Scanlined pixel blit
-/* BYTE * pMem = (BYTE *)scr->pixels + ((scr->pitch * 8 + 16) * 2);
- DWORD src = (DWORD)(offsets[hScrollOffset] + voffsets[vScrollOffset]),
+/* uint8 * pMem = (uint8 *)scr->pixels + ((scr->pitch * 8 + 16) * 2);
+ uint32 src = (uint32)(offsets[hScrollOffset] + voffsets[vScrollOffset]),
dst1 = 0, dst2 = scr->pitch;
- DWORD srcAdd = 320 - 288, dstAdd = (scr->pitch * 2) - (288 * 2);
+ uint32 srcAdd = 320 - 288, dstAdd = (scr->pitch * 2) - (288 * 2);
for(int i=0; i<224; i++)
{
//
// Draw sprites at priority level (new code)
//
-void DrawSprites(BYTE priority)
+void DrawSprites(uint8 priority)
{
- extern BYTE * gram1; // Game RAM space
+ extern uint8 * gram1; // Game RAM space
- for(WORD i=0x5800; i<0x6000; i+=0x10)
+ for(uint16 i=0x5800; i<0x6000; i+=0x10)
{
if ((gram1[i + 8] & 0xC0) == priority) // Check for correct layer...
{
spr_color_index = gram1[i + 6] >> 1; // Set color...
- WORD x = ((gram1[i + 6] & 0x01) << 8) | gram1[i + 7];
+ uint16 x = ((gram1[i + 6] & 0x01) << 8) | gram1[i + 7];
if (x > 512 - 32)
x -= 512; // Handle neg x values
- WORD y = 192 - gram1[i + 9];
- WORD hdr = (gram1[i + 4] & 0x90) << 8 | (gram1[i + 8] & 0x14);
- BYTE flip = gram1[i + 4] & 0x20; // Horizontal flip
- DWORD spr_num = ((gram1[i + 4] & 0x07) << 9) | ((gram1[i + 5] & 0x7F) << 2);
+ uint16 y = 192 - gram1[i + 9];
+ uint16 hdr = (gram1[i + 4] & 0x90) << 8 | (gram1[i + 8] & 0x14);
+ uint8 flip = gram1[i + 4] & 0x20; // Horizontal flip
+ uint32 spr_num = ((gram1[i + 4] & 0x07) << 9) | ((gram1[i + 5] & 0x7F) << 2);
Sprite(spr_num, x, y, flip, hdr); // Draw sprite...
}
//
// Sprite handler
//
-void Sprite(DWORD sprnum, WORD x, WORD y, BYTE flip, WORD spr_id)
+void Sprite(uint32 sprnum, uint16 x, uint16 y, uint8 flip, uint16 spr_id)
{
- extern BYTE * spr_rom;
+ extern uint8 * spr_rom;
// To show or not to show a 16x16 block in the 4x4 grid...
bool horiz_bl = false, vert_bl = false;
- DWORD sc_addr;
+ uint32 sc_addr;
x += hScrollOffset; // Adjust x-coord
y += vScrollOffset; // Adjust y-coord
if (!flip)
{
- for(WORD sy=0; sy<16; sy++)
+ for(uint16 sy=0; sy<16; sy++)
{
- for(WORD sx=0; sx<16; sx+=2)
+ for(uint16 sx=0; sx<16; sx+=2)
{
- BYTE b1 = spr_rom[sprnum] >> 4, b2 = spr_rom[sprnum++] & 0x0F;
- WORD spy = y + sy, spx = x + sx; // Need to optimize this clipping!
+ uint8 b1 = spr_rom[sprnum] >> 4, b2 = spr_rom[sprnum++] & 0x0F;
+ uint16 spy = y + sy, spx = x + sx; // Need to optimize this clipping!
if (spy > 223 || spx > 299)
sc_addr = 0x13FFE;
if (horiz_bl)
{
- for(WORD sy=0; sy<16; sy++)
+ for(uint16 sy=0; sy<16; sy++)
{
- for(WORD sx=16; sx<32; sx+=2)
+ for(uint16 sx=16; sx<32; sx+=2)
{
- BYTE b1 = spr_rom[sprnum] >> 4, b2 = spr_rom[sprnum++] & 0x0F;
- WORD spy = y + sy, spx = x + sx;
+ uint8 b1 = spr_rom[sprnum] >> 4, b2 = spr_rom[sprnum++] & 0x0F;
+ uint16 spy = y + sy, spx = x + sx;
if (spy > 223 || spx > 299)
sc_addr = 0x13FFE;
{
y += 16; // Do next row...
- for(WORD sy=0; sy<16; sy++)
+ for(uint16 sy=0; sy<16; sy++)
{
- for(WORD sx=0; sx<16; sx+=2)
+ for(uint16 sx=0; sx<16; sx+=2)
{
- BYTE b1 = spr_rom[sprnum] >> 4, b2 = spr_rom[sprnum++] & 0x0F;
- WORD spy = y + sy, spx = x + sx;
+ uint8 b1 = spr_rom[sprnum] >> 4, b2 = spr_rom[sprnum++] & 0x0F;
+ uint16 spy = y + sy, spx = x + sx;
if (spy > 223 || spx > 299)
sc_addr = 0x13FFE;
if (horiz_bl)
{
- for(WORD sy=0; sy<16; sy++)
+ for(uint16 sy=0; sy<16; sy++)
{
- for(WORD sx=16; sx<32; sx+=2)
+ for(uint16 sx=16; sx<32; sx+=2)
{
- BYTE b1 = spr_rom[sprnum] >> 4, b2 = spr_rom[sprnum++] & 0x0F;
- WORD spy = y + sy, spx = x + sx;
+ uint8 b1 = spr_rom[sprnum] >> 4, b2 = spr_rom[sprnum++] & 0x0F;
+ uint16 spy = y + sy, spx = x + sx;
if (spy > 223 || spx > 299)
sc_addr = 0x13FFE;
{
if (horiz_bl)
{
- for(WORD sy=0; sy<16; sy++)
+ for(uint16 sy=0; sy<16; sy++)
{
- for(WORD sx=30; sx!=14; sx-=2)
+ for(uint16 sx=30; sx!=14; sx-=2)
{
- BYTE b1 = spr_rom[sprnum]>>4, b2 = spr_rom[sprnum++]&0x0F;
- WORD spy = y+sy, spx = x+sx;
+ uint8 b1 = spr_rom[sprnum]>>4, b2 = spr_rom[sprnum++]&0x0F;
+ uint16 spy = y+sy, spx = x+sx;
if ((spy>223) || (spx>299))
sc_addr = 0x13FFE;
else
}
}
}
- for(WORD sy=0; sy<16; sy++)
+ for(uint16 sy=0; sy<16; sy++)
{
- for(WORD sx=14; sx!=0xFFFE; sx-=2)
+ for(uint16 sx=14; sx!=0xFFFE; sx-=2)
{
- BYTE b1 = spr_rom[sprnum]>>4, b2 = spr_rom[sprnum++]&0x0F;
- WORD spy = y+sy, spx = x+sx;
+ uint8 b1 = spr_rom[sprnum]>>4, b2 = spr_rom[sprnum++]&0x0F;
+ uint16 spy = y+sy, spx = x+sx;
if ((spy>223) || (spx>299))
sc_addr = 0x13FFE;
else
y += 16; // Adjust Y coord...
if (horiz_bl)
{
- for(WORD sy=0; sy<16; sy++)
+ for(uint16 sy=0; sy<16; sy++)
{
- for(WORD sx=30; sx!=14; sx-=2)
+ for(uint16 sx=30; sx!=14; sx-=2)
{
- BYTE b1 = spr_rom[sprnum]>>4, b2 = spr_rom[sprnum++]&0x0F;
- WORD spy = y+sy, spx = x+sx;
+ uint8 b1 = spr_rom[sprnum]>>4, b2 = spr_rom[sprnum++]&0x0F;
+ uint16 spy = y+sy, spx = x+sx;
if ((spy>223) || (spx>299))
sc_addr = 0x13FFE;
else
}
}
}
- for(WORD sy=0; sy<16; sy++)
+ for(uint16 sy=0; sy<16; sy++)
{
- for(WORD sx=14; sx!=0xFFFE; sx-=2)
+ for(uint16 sx=14; sx!=0xFFFE; sx-=2)
{
- BYTE b1 = spr_rom[sprnum]>>4, b2 = spr_rom[sprnum++]&0x0F;
- WORD spy = y+sy, spx = x+sx;
+ uint8 b1 = spr_rom[sprnum]>>4, b2 = spr_rom[sprnum++]&0x0F;
+ uint16 spy = y+sy, spx = x+sx;
if ((spy>223) || (spx>299))
sc_addr = 0x13FFE;
else
// Instead of using the screen, we should use our internal buffer...
SDL_LockSurface(scr);
- DWORD mem = scr->pitch * 8; // Skip first line... WAS:320*8;
+ uint32 mem = scr->pitch * 8; // Skip first line... WAS:320*8;
for (line=0; line<=YMax; line++)
{
int count;
int last;
int xpos;
- BYTE * pMem = (BYTE *)scr->pixels;
+ uint8 * pMem = (uint8 *)scr->pixels;
xpos = 0;
while (xpos < bytesPerLine)
//
// SCREEN.H
//
-// This sets screen to Mode X so we can use the WHOLE laptop screen
-// (i.e. 320x240)
-//
-// Tweaked by James L. Hammons
-//
+// by James L. Hammons
// (C) 1997 Underground Software
+//
#ifndef __SCREEN_H__
#define __SCREEN_H__
+#include "SDL.h"
#include "types.h"
void SnapPCX(SDL_Surface *); // Take a PCX snapshot
-void BlitChar(SDL_Surface *, BYTE *, BYTE *); // Show NAMCO screen
-void Sprite(DWORD, WORD, WORD, BYTE, WORD); // Show sprite on the screen
+void BlitChar(SDL_Surface *, uint8 *, uint8 *); // Show NAMCO screen
+void Sprite(uint32, uint16, uint16, uint8, uint16); // Show sprite on the screen
#endif // __SCREEN_H__
//
-// Thunder: A Rolling Thunder Emulator w/6809 debugger v0.40
-// (Last build: 3/6/2004)
+// Thunder: A Rolling Thunder Emulator w/6809 debugger
//
// by James L. Hammons
+// (c) 2004, 2009 Underground Software
//
-// (c) 2004 Underground Software
+// JLH = James L. Hammons <jlhamm@acm.org>
+//
+// WHO WHEN WHAT
+// --- ---------- ------------------------------------------------------------
+// JLH 07/23/2009 Added changelog ;-)
//
-#define THUNDER_VERSION "0.4.0"
-#define THUNDER_BETA_VERSION "6"
+#define THUNDER_VERSION "0.5.0"
#include <iostream>
#include <iomanip>
#include <new>
#include <stdio.h>
#include <stdlib.h>
-#include <conio.h> // For getch()
+//#include <conio.h> // For getch()
+#include <curses.h> // For getch()
#include <time.h>
#include "SDL.h" // Get yer SDL out...!
#include "types.h"
using namespace std; // Yes!
-/*
+#if 0
#define ROM1 "RT3-1B.ROM"
#define ROM2 "RT3-2B.ROM"
#define ROM3 "RT3-3.ROM"
#define PROM3 "RT1-3.BIN"
#define PROM4 "RT1-4.BIN"
#define PROM5 "RT1-5.BIN"
-*/
+#else
#define ROM1 "rt3-1b.9c"
#define ROM2 "rt3-2b.12c"
#define ROM3 "rt3-3.12d"
#define PROM4 "mb7138h.6v"
#define PROM5 "mb7112e.6u"
#define MCUROM "rt1-mcu.bin"
+#endif
// Global defines
V6809REGS cpu1, cpu2;
-bool trace = false; // ditto...
+bool trace1 = false; // ditto...
bool looking_at_rom = true; // true = R1, false = R2
DWORD banksw1, banksw2; // Bank switch addresses
WORD game_over_switch; // Game over delay
bool irqGoA = true; // IRQ switch for CPU #1
bool irqGoB = true; // IRQ switch for CPU #2
-WORD refresh = 0; // Crappy global screen stuff...
+WORD refresh_ = 0; // Crappy global screen stuff...
bool refresh2 = true;
DWORD psg_lens[16] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
"A", "B", "CC", "DP", "??", "??", "??", "??" },
iregs[4][2] = {"X", "Y", "U", "S" };
-//
-// Fetch a byte out of memory
-//
-/*BYTE Fetch()
-{
-// extern WORD sr, ur, xr, yr; // Needed for tracelog
- extern WORD pcr;
- BYTE b;
-
- b = (pcr < 0x8000 ? gram1[pcr] : grom1[pcr]);
- pcr++;
-
- return b;
-}*/
-
-//
-// Fetch a word out of memory (little endian format)
-//
-/*WORD FetchW()
-{
- WORD w = Fetch() << 8; w |= Fetch();
- return w;
-}*/
-
//
// Read a byte from memory (without touching PC. Not a Fetch!)
//
charbase = true; // Char banksw2
if (addr == 0x8400) // Frame go strobe? VBlank acknowledge?
{
- if (refresh++ == 1) // 30 Hz...
+ if (refresh_++ == 1) // 30 Hz...
{
BlitChar(screen, chr_rom, gram1);
- refresh = (refresh2 ? 1 : 0); // 60/30 Hz...
+ refresh_ = (refresh2 ? 1 : 0); // 60/30 Hz...
}
// irqGoA = true; // Will this work??? no...
cpu1.cpuFlags |= V6809_ASSERT_LINE_IRQ;//wil wok???
}
}
-//
-// Fetch a byte out of memory (2nd processor)
-//
-/*BYTE FetchB()
-{
-// extern WORD sr, ur, xr, yr; // Needed for tracelog
- extern WORD pcrB;
- BYTE b;
-
- if (pcrB<0x8000)
- {
- if (pcrB<0x2000)
- b = gram1[pcrB+0x4000];
- if ((pcrB>0x1FFF) && (pcrB<0x6000))
- b = gram1[pcrB-0x2000];
- if (pcrB>0x5FFF)
- b = gram1[pcrB];
- }
- else
- b = grom2[pcrB];
- pcrB++;
-
- return b;
-}
-
-//
-// Fetch a word out of memory (little endian format) (2nd processor)
-//
-WORD FetchWB()
-{
- WORD w = FetchB() << 8; w |= FetchB();
- return w;
-}*/
-
//
// Read a byte from memory (without touching PC. Not a Fetch!) (2nd processor)
//
if (operand&0x10) strcat(tmp, "X ");
if (operand&0x20) strcat(tmp, "Y ");
if (operand&0x40) (((opcode==0x34)||(opcode==0x35))
- ? strcat(tmp, "U ") : strcat(tmp, "S "));
+ ? strcat(tmp, "U ") : strcat(tmp, "S "));
if (operand&0x80) strcat(tmp, "PC");
}
sprintf(outbuf, "%s %s", mnem, tmp);
case 8:
{ boff = DFetch(); sprintf(tmp, "($%02X,%s)", boff,
iregs[reg]); break; }
- case 9:
+ case 9:
{ woff = DFetchW(); sprintf(tmp, "($%04X,%s)", woff,
iregs[reg]); break; }
case 11: sprintf(tmp, "(D,%s)", iregs[reg]); break;
case 12:
{ boff = DFetch(); sprintf(tmp, "($%02X,PC)", boff); break; }
- case 13:
+ case 13:
{ woff = DFetchW(); sprintf(tmp, "($%04X,PC)", woff); break; }
case 15:
{ woff = DFetchW(); sprintf(tmp, "[$%04X]", woff); break; }
- default: strcpy(tmp, "??");
+ default: strcpy(tmp, "??");
}
}
else
case 8:
{ boff = DFetch(); sprintf(tmp, "($%02X),%s", boff,
iregs[reg]); break; }
- case 9:
+ case 9:
{ woff = DFetchW(); sprintf(tmp, "($%04X),%s", woff,
iregs[reg]); break; }
case 11: sprintf(tmp, "(D),%s", iregs[reg]); break;
case 12:
{ boff = DFetch(); sprintf(tmp, "($%02X),PC", boff); break; }
- case 13:
+ case 13:
{ woff = DFetchW(); sprintf(tmp, "($%04X),PC", woff); break; }
- default: strcpy(tmp, "??");
+ default: strcpy(tmp, "??");
}
}
}
for(int i=0; i<len; i++)
{
if (str[i]>='0' && str[i]<='9')
- {
+ {
value = (value<<4) | (unsigned)(str[i]-'0');
}
if (str[i]>='a' && str[i]<='f')
- {
+ {
value = (value<<4) | (unsigned)(str[i]-'a')+10;
}
if (str[i]>='A' && str[i]<='F')
- {
+ {
value = (value<<4) | (unsigned)(str[i]-'A')+10;
}
}
ff.open(filename, ios::binary | ios::in); // Open 'da file...
if (ff)
- {
+ {
for(long i=0; i<32768; i++) // Read it in...
{
ff.get(ch);
// Generic Load file into image space
// (No error checking performed! Responsibility of caller!)
//
-bool LoadImg(char * filename, BYTE * mem, DWORD address, DWORD length)
+bool LoadImg(const char * filename, BYTE * mem, DWORD address, DWORD length)
{
ifstream ff;
char path[80];
// ff.open(filename, ios::binary | ios::in); // Open 'da file...
ff.open(path, ios::binary | ios::in); // Open 'da file...
if (ff)
- {
+ {
for(DWORD i=0; i<length; i++) // Read it in...
{
ff.get(ch);
// tr.open("exe.log", ios::binary | ios::out); // Tracelog
- cout << endl << "THUNDER beta "THUNDER_BETA_VERSION" ";
- cout << "by Jimmy Hamm <jlhamm@acm.org>" << endl;
- cout << "Serial #20030313 / Prerelease" << endl;
- cout << "(C) 2003 Underground Software" << endl << endl;
+ cout << endl << "THUNDER v"THUNDER_VERSION" ";
+ cout << "by James Hammmmons" << endl;
+ cout << "Serial #20090723 / Prerelease" << endl;
+ cout << "(C) 2003, 2009 Underground Software" << endl << endl;
- cout << "This emulator is freeware. If you paid for it you were RIPPED OFF"
+ cout << "This emulator is free software. If you paid for it you were RIPPED OFF"
<< endl << endl;
cout << "Initializing SDL..." << endl;
return -1;
}
- SDL_WM_SetCaption("Thunder Beta 6", "Thunder");
+ SDL_WM_SetCaption("Thunder v"THUNDER_VERSION" ", "Thunder");
cout << "Allocating memory..." << endl;
//Does this anyway... set_new_handler(0); // Make 'new' return NULL on failure...
if (!LoadImg(ROM22, voice_rom, 0x10000, 0x10000)) // Load 22nd ROM
{ cout << "Could not open file '" << ROM22 << "'!" << endl; return -1; }
-
+
if (!UnpackFonts()) // Load 5, 6, 7, 8th ROMs
{
cout << "Could not open font files!" << endl;
return -1;
}
- LoadPSGs(); // Load samples if they're there...
+ // Load samples if they're there...
+ LoadPSGs();
LoadFMs();
// Quick 'n' Dirty voice dump (sound 0x0E)
// Set up V6809 execution contexts
- memset(&cpu1, sizeof(V6809REGS), 0);
+ memset(&cpu1, 0, sizeof(V6809REGS));
cpu1.RdMem = RdMem;
cpu1.WrMem = WrMem;
cpu1.cpuFlags |= V6809_ASSERT_LINE_RESET;
- memset(&cpu2, sizeof(V6809REGS), 0);
+ memset(&cpu2, 0, sizeof(V6809REGS));
cpu2.RdMem = RdMemB;
cpu2.WrMem = WrMemB;
cpu2.cpuFlags |= V6809_ASSERT_LINE_RESET;
lbuff[0] = 32;
dpc = htod(lbuff);
}
- printf("%04X: ", dpc);
+ printf("%04X: ", dpc);
WORD pc_save = cpu1.pc, pcB_save = cpu2.pc;
cpu1.pc = dpc; cpu2.pc = dpc;
for(int i=0; i<16; i++)
WriteLog("Executing 'run' command...\n");
DWORD my_clock = 0;
running = true; // Set running status...
- trace = false;
+ trace1 = false;
SetRefreshRate(refresh2); // Tell GUI our refresh rate
//for(WORD i=0; i<0x8000; i++) gram2[i] = grom3[i]; //Temp
else cpu1.cc = 0xFF; // Set CC register
cpu2.pc = ((grom2[0xFFFE]<<8) | grom2[0xFFFF]); // Reset 6809 #2
- cpu2.cc = 0xFF; // Set CC register
+ cpu2.cc = 0xFF; // Set CC register
while(iclock < 8000) // was 17000, 20000, 5000
{
Execute6809(&cpu1, 1); Execute6809(&cpu2, 1);
colors[i].g = palette[i*3+1];
colors[i].b = palette[i*3+2];
}
- SDL_SetPalette(screen, SDL_LOGPAL|SDL_PHYSPAL, colors, 0, 256);
+ SDL_SetPalette(screen, SDL_LOGPAL | SDL_PHYSPAL, colors, 0, 256);
+
+#if 1
+ // This confirms that we're getting video to the screen...
+ SDL_LockSurface(screen);
+
+ uint8 pixel = 0;
+ uint8 * pixels = (uint8 *)(screen->pixels);
+
+ for(uint32 y=0; y<480; y++)
+ for(uint32 x=0; x<640; x++)
+ pixels[(y * 640) + x] = pixel++;
+
+ SDL_UnlockSurface(screen);
+ SDL_UpdateRect(screen, 0, 0, 0, 0);
+#endif
for(int i=0; i<256; i++)
keys[i] = 0; // Clear keyboard buffer...
oldTicks = SDL_GetTicks();
+WriteLog("About to set up audio...\n");
// This crap SHOULD be in sound.cpp (not yet created)...
SDL_AudioSpec desired, obtained;
desired.freq = 22050;
}
SDL_PauseAudio(0); // Get that audio going!
+WriteLog("About to enter main loop...\n");
while (running)
{
HandleGUIDebounce(); // Debounce GUI keys
// SDL key handling...
+#warning "MAKE REPOSITORY FOR THIS THING! !!! FIX !!!"
+#warning "AND USE THE OLD SOURCE FOR THE BASE!!!"
+#warning "KEYS ARE FUCKED UP! !!! FIX !!!"
// keyPressed = 0; // Reset keypress
while (SDL_PollEvent(&event) != 0) // Bleed out all pending key events...
{
}
if (keys[0x3E]) // Do PCX snapshot (F4)
{
- SpawnSound(USERSOUND, SCAMERA);
+ SpawnSound(USERSOUND, SCAMERA);
SnapPCX(screen);
debounce = 10;
}
Execute6809(&cpu2, 10);
}
// }
- if (enable_cpu)
+
+// if (enable_cpu)
+ if (true)
{
/*// if (irqGoA)
cpu1.cpuFlags |= V6809_ASSERT_LINE_IRQ;
Execute6809(&cpu2, 25000);
cpu2.clock -= 25000; // Remove 25K ticks from clock (in case it overflowed)//*/
- cpu1.cpuFlags |= V6809_ASSERT_LINE_IRQ;
- cpu2.cpuFlags |= V6809_ASSERT_LINE_IRQ;
+// cpu1.cpuFlags |= V6809_ASSERT_LINE_IRQ;
+// cpu2.cpuFlags |= V6809_ASSERT_LINE_IRQ;
while (cpu1.clock < 25000)
{
// Gay, but what are ya gonna do?
Execute6809(&cpu1, 5);
Execute6809(&cpu2, 5);
}
+
cpu1.clock -= 25000; // Remove 25K ticks from clock (in case it overflowed)
cpu2.clock -= 25000; // Remove 25K ticks from clock (in case it overflowed)//*/
-/* while (my_clock < 25000) // Cycles in 60th of a sec at 1.5 Mhz
- {
- // pcx = cpu1.pc; // Tracelog stuff
- if (brk && (cpu1.pc == brkpnt))
- {
- running = false;
- break;
- }
- if (brk2 && (cpu2.pc == brkpnt2))
- {
- running = false;
- break;
- }
- DWORD prev = iclock;
-
- BYTE opcode = Fetch(); // Get the opcode
- if (opcode == 0x10)
- {
- exec_op1[Fetch()]();
- goto TEXE_NEXT;
- }
- if (opcode == 0x11)
- {
- exec_op2[Fetch()]();
- goto TEXE_NEXT;
- }
- exec_op0[opcode]();
-TEXE_NEXT:
-
- if (iclock > 25000)
- {
- iclock = 0;
-// if (irqGoA)
-// {
- if ((!(cpu1.cc&0x10)) && irqGoA)
- {
- irqGoA = false;
-// if (!(cpu1.cc&0x10)) // Process an interrupt?
-// {
- cpu1.cc |= 0x80; // Set E
- WrMem(--cpu1.s, cpu1.pc&0xFF); WrMem(--cpu1.s, cpu1.pc>>8); // Save all regs...
- WrMem(--cpu1.s, cpu1.u&0xFF); WrMem(--cpu1.s, cpu1.u>>8);
- WrMem(--cpu1.s, cpu1.y&0xFF); WrMem(--cpu1.s, cpu1.y>>8);
- WrMem(--cpu1.s, cpu1.x&0xFF); WrMem(--cpu1.s, cpu1.x>>8);
- WrMem(--cpu1.s, cpu1.dp); WrMem(--cpu1.s, cpu1.b);
- WrMem(--cpu1.s, cpu1.a); WrMem(--cpu1.s, cpu1.cc);
- cpu1.cc |= 0x50; // Set F,I
- cpu1.pc = (grom1[0xFFF8]<<8) | grom1[0xFFF9]; // And do it!
- // Need to find out why RdMem is returning wrong values here...
- }
- }
-// }//irgGoA
- if (iclock > prev)
- my_clock += (iclock - prev); // Increment my_clock
-
- // pcx = cpu2.pc; // Tracelog stuff
- opcode = FetchB(); // Get the opcode
- if (opcode == 0x10)
- {
- exec_op1B[FetchB()]();
- goto TEXE_NEXT2;
- }
- if (opcode == 0x11)
- {
- exec_op2B[FetchB()]();
- goto TEXE_NEXT2;
- }
- exec_op0B[opcode]();
-TEXE_NEXT2:
-
- if (iclockB > 25000)//24550) // Slightly faster IRQs for SUB processor
- {
- iclockB = 0;
-// if (irqGoB)
-// {
- if ((!(cpu2.cc&0x10)) && irqGoB)
- {
- irqGoB = false;
-// if (!(cpu2.cc&0x10)) // Process an interrupt?
-// {
- cpu2.cc |= 0x80; // Set E
- WrMemB(--cpu2.s, cpu2.pc&0xFF); WrMemB(--cpu2.s, cpu2.pc>>8); // Save all regs...
- WrMemB(--cpu2.s, cpu2.u&0xFF); WrMemB(--cpu2.s, cpu2.u>>8);
- WrMemB(--cpu2.s, cpu2.y&0xFF); WrMemB(--cpu2.s, cpu2.y>>8);
- WrMemB(--cpu2.s, cpu2.x&0xFF); WrMemB(--cpu2.s, cpu2.x>>8);
- WrMemB(--cpu2.s, cpu2.dp); WrMemB(--cpu2.s, cpu2.b);
- WrMemB(--cpu2.s, cpu2.a); WrMemB(--cpu2.s, cpu2.cc);
- cpu2.cc |= 0x50; // Set F,I
- cpu2.pc = (grom2[0xFFF8]<<8) | grom2[0xFFF9]; // And do it!
- }
- }
-// } // irqGoB
- // if (brk && (cpu1.pc == brkpnt)) running = false; // Stop running!
- }
- my_clock -= 25000; // Remove frame count from iclock*/
} // END: enable_cpu
-// if (refresh++ == 1) // 30 Hz...
+
+// if (refresh_++ == 1) // 30 Hz...
// {
// if (scr_type)
// BlitWilliamsScreen(gram1); // Display the screen...
// else
// BlitChar(screen, chr_rom, gram1);
-// refresh = (refresh2 ? 1 : 0); // 60/30 Hz...
+// refresh_ = (refresh2 ? 1 : 0); // 60/30 Hz...
// }
+//temp, for testing...
+BlitChar(screen, chr_rom, gram1);
// Speed throttling happens here...
- while (SDL_GetTicks() - oldTicks < 16); // Actually, it's 16.66... Need to account for that somehow
+ while (SDL_GetTicks() - oldTicks < 16) // Actually, it's 16.66... Need to account for that somehow
+ SDL_Delay(1); // Release our timeslice...
+
oldTicks = SDL_GetTicks();
+//cout << "Finished frame..." << endl;
}
// Stop_audio_output();