diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/3d.h | 150 | ||||
-rw-r--r-- | source/Makefile | 342 | ||||
-rw-r--r-- | source/Makefile.in | 339 | ||||
-rw-r--r-- | source/apu.cpp | 186 | ||||
-rw-r--r-- | source/apudebug.cpp | 439 | ||||
-rw-r--r-- | source/c4emu.cpp | 142 | ||||
-rw-r--r-- | source/cpuops.cpp | 17 | ||||
-rw-r--r-- | source/debug.cpp | 2220 | ||||
-rw-r--r-- | source/dma.cpp | 71 | ||||
-rw-r--r-- | source/dsp1.cpp | 16 | ||||
-rw-r--r-- | source/getset.h | 32 | ||||
-rw-r--r-- | source/sa1.cpp | 9 | ||||
-rw-r--r-- | source/sa1cpu.cpp | 15 | ||||
-rw-r--r-- | source/spc700.cpp | 8 | ||||
-rw-r--r-- | source/spc700.h | 10 |
15 files changed, 11 insertions, 3985 deletions
diff --git a/source/3d.h b/source/3d.h deleted file mode 100644 index da82860..0000000 --- a/source/3d.h +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************* - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - - (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com) and - Jerremy Koot (jkoot@snes9x.com) - - (c) Copyright 2001 - 2004 John Weidman (jweidman@slip.net) - - (c) Copyright 2002 - 2004 Brad Jorsch (anomie@users.sourceforge.net), - funkyass (funkyass@spam.shaw.ca), - Joel Yliluoma (http://iki.fi/bisqwit/) - Kris Bleakley (codeviolation@hotmail.com), - Matthew Kendora, - Nach (n-a-c-h@users.sourceforge.net), - Peter Bortas (peter@bortas.org) and - zones (kasumitokoduck@yahoo.com) - - C4 x86 assembler and some C emulation code - (c) Copyright 2000 - 2003 zsKnight (zsknight@zsnes.com), - _Demo_ (_demo_@zsnes.com), and Nach - - C4 C++ code - (c) Copyright 2003 Brad Jorsch - - DSP-1 emulator code - (c) Copyright 1998 - 2004 Ivar (ivar@snes9x.com), _Demo_, Gary Henderson, - John Weidman, neviksti (neviksti@hotmail.com), - Kris Bleakley, Andreas Naive - - DSP-2 emulator code - (c) Copyright 2003 Kris Bleakley, John Weidman, neviksti, Matthew Kendora, and - Lord Nightmare (lord_nightmare@users.sourceforge.net - - OBC1 emulator code - (c) Copyright 2001 - 2004 zsKnight, pagefault (pagefault@zsnes.com) and - Kris Bleakley - Ported from x86 assembler to C by sanmaiwashi - - SPC7110 and RTC C++ emulator code - (c) Copyright 2002 Matthew Kendora with research by - zsKnight, John Weidman, and Dark Force - - S-DD1 C emulator code - (c) Copyright 2003 Brad Jorsch with research by - Andreas Naive and John Weidman - - S-RTC C emulator code - (c) Copyright 2001 John Weidman - - ST010 C++ emulator code - (c) Copyright 2003 Feather, Kris Bleakley, John Weidman and Matthew Kendora - - Super FX x86 assembler emulator code - (c) Copyright 1998 - 2003 zsKnight, _Demo_, and pagefault - - Super FX C emulator code - (c) Copyright 1997 - 1999 Ivar, Gary Henderson and John Weidman - - - SH assembler code partly based on x86 assembler code - (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) - - - Specific ports contains the works of other authors. See headers in - individual files. - - Snes9x homepage: http://www.snes9x.com - - Permission to use, copy, modify and distribute Snes9x in both binary and - source form, for non-commercial purposes, is hereby granted without fee, - providing that this license information and copyright notice appear with - all copies and any derived work. - - This software is provided 'as-is', without any express or implied - warranty. In no event shall the authors be held liable for any damages - arising from the use of this software. - - Snes9x is freeware for PERSONAL USE only. Commercial users should - seek permission of the copyright holders first. Commercial use includes - charging money for Snes9x or software derived from Snes9x. - - The copyright holders request that bug fixes and improvements to the code - should be forwarded to them so everyone can benefit from the modifications - in future versions. - - Super NES and Super Nintendo Entertainment System are trademarks of - Nintendo Co., Limited and its subsidiary companies. -*******************************************************************************/ - -#ifndef _3D_H_ -#define _3D_H_ - -#if defined(USE_OPENGL) -#include <GL/gl.h> -#include <GL/glu.h> - -#ifdef __linux__ -#include <GL/glx.h> -#endif - -typedef struct -{ - bool8 packed_pixels_extension_present; - bool8 draw_cube; - uint32 version; - // Texture format - GLint internal_format; - GLint format; - GLint type; - - GLint max_texture_size;// 256 or 512 - GLint texture_size; - uint32 num_textures; // 1 if max_texture_size == 256, 2 otherwise - GLuint textures [2]; -} OpenGLData; - -extern OpenGLData OpenGL; - -bool8 S9xOpenGLInit (); -bool8 S9xOpenGLInit2 (); -void S9xOpenGLPutImage (int width, int height); -void S9xOpenGLDeinit (); - -#endif - -#ifdef USE_GLIDE -#include <glide.h> - -typedef struct -{ - bool8 voodoo_present; - GrVertex sq[4]; - GrTexInfo texture; - int32 texture_mem_size; - int32 texture_mem_start; - float x_offset, y_offset; - float x_scale, y_scale; - float voodoo_width; - float voodoo_height; -} GlideData; - -extern GlideData Glide; -bool8 S9xGlideEnable (bool8 enable); -void S9xGlideDeinit (); -bool8 S9xGlideInit (); -bool8 S9xVoodooInitialise (); -#endif - -#endif - diff --git a/source/Makefile b/source/Makefile deleted file mode 100644 index 9bc8f97..0000000 --- a/source/Makefile +++ /dev/null @@ -1,342 +0,0 @@ -# Generated automatically from Makefile.in by configure. -#ZSNESFX=1 -#ZSNESC4=1 -#ASMCPU=1 -#SPC700ASM=1 -#NETPLAY=1 -#UNZIP=1 -#GLIDE=1 -#OPENGL=1 -#AIDO=1 -#GUI=0 -#THREAD_SOUND=1 -#ASMKREED=1 -SDD1_DECOMP=1 -#SDD1_VERIFY=0 - -#Fairly good and special-char-safe descriptor of the os being built on. -OS=`uname -s -r -m|sed \"s/ /-/g\"|tr \"[A-Z]\" \"[a-z]\"|tr \"/()\" \"___\"` -BUILDDIR=. -#BUILDDIR=build/$(OS) - - -ifdef ZSNESFX -FXOBJ=i386/fxemu2b.o i386/fxemu2.o i386/fxemu2c.o i386/fxtable.o i386/sfxproc.o i386/ZSNES.O -FXDEFINES=-DZSNES_FX -DEXECUTE_SUPERFX_PER_LINE -FXDEPENDS=zsnes_fx -FXNO_DEPENDS=c_fx -else -FXOBJ=fxinst.o fxemu.o fxdbg.o -FXDEFINES=-DEXECUTE_SUPERFX_PER_LINE -FXDEPENDS=c_fx -FXNO_DEPENDS=zsnes_fx -endif - -ifdef ZSNESC4 -C4OBJ=i386/C4.O i386/zsnesc4.o c4.o -C4DEFINES=-DZSNES_C4 -C4DEPENDS=zsnes_c4 -C4NO_DEPENDS=c_c4 -else -C4OBJ=c4.o c4emu.o -C4DEFINES= -C4DEPENDS=c_c4 -C4NO_DEPENDS=zsnes_c4 -endif - -ifdef SPC700ASM -SOUNDOBJ=spctool/spc700.o spctool/dsp.o spctool.o spctool/soundmod.o SPC.O -SOUNDDEFINES=-DSPCTOOL -else -SOUNDOBJ=spc700.o soundux.o apu.o -SOUNDDEFINES=-DSPC700_C -endif - -ifdef ASMCPU -CPUOBJ=i386/cpuops.o i386/cpuexec.o i386/sa1ops.o -else -CPUOBJ=cpuops.o cpuexec.o sa1cpu.o -endif - -ifdef ASMKREED -KREEDOBJ=i386/2XSAIMMX.O i386/bilinear.o 2xsai.o -KREEDDEFINES=-DMMX -else -KREEDDEFINES= -# KREEDOBJ=2xsai.o -endif - -ifdef SDD1_DECOMP -SDD1OBJ=sdd1emu.o -ifdef SDD1_VERIFY -SDD1DEFINES=-DSDD1_DECOMP -DSDD1_VERIFY -else -SDD1DEFINES=-DSDD1_DECOMP -endif -else -SDD1DEFINES= -SDD1OBJ= -endif - -SPC7110OBJ=spc7110.o -OBC1OBJ=obc1.o -SETAOBJ=seta.o seta010.o seta011.o seta018.o - -OBJECTS=$(CPUOBJ) $(SOUNDOBJ) apudebug.o $(FXOBJ) $(C4OBJ) \ - cpu.o sa1.o debug.o sdd1.o tile.o srtc.o \ - gfx.o memmap.o snaporig.o clip.o dsp1.o \ - movie.o \ - ppu.o dma.o snes9x.o snapshot.o screenshot.o \ - cheats.o cheats2.o data.o unix/unix.o unix/config.o globals.o \ - $(SPC7110OBJ) $(OBC1OBJ) $(SETAOBJ) $(KREEDOBJ) $(SDD1OBJ) - -#OBJECTS += ../zlib/libz.a - -#FIXME: The gui is bitrotted if it ever worked at all. Remove? -ifdef GUI -GUIOBJS = unix/snes9x_gui.o unix/moc_snes9x_gui.o -GUILIBS = -L$(QTDIR)/lib -lqt -GUIDEFINES = -I$(QTDIR)/include -endif - -ifdef NETPLAY -OBJECTS += netplay.o server.o -NETPLAYDEFINES=-DNETPLAY_SUPPORT -SERVER_OBJECTS=server.o -endif - -ifdef UNZIP -OBJECTS += loadzip.o unzip/unzip.o unzip/explode.o unzip/unreduce.o unzip/unshrink.o -UNZIPDEFINES=-DUNZIP_SUPPORT -endif - -ifdef THREAD_SOUND -CPUDEFINES += -DUSE_THREADS -EXTRALIBS += -lpthread -endif - -ifdef GLIDE -GLIDEOBJS = unix/glide.o -GLIDEDEFINES = -DUSE_GLIDE -I/usr/include/glide -GLIDELIBS = -lglide2x -endif - -ifdef OPENGL -OPENGLOBJS = unix/opengl.o -OPENGLDEFINES = -DUSE_OPENGL -OPENGLLIBS = -lGL -lGLU -ldl -endif - -ifdef AIDO -AIDOOBJS = unix/aido.o -AIDODEFINES = -DUSE_AIDO -endif - -JOYDEFINES = - -MOC = $(QTDIR)/bin/moc -CCC = c++ -fno-rtti -GASM = c++ -CC = gcc -NASM = /usr/bin/nasm - -#INCLUDES = -I../zlib -INONE -INCLUDES = -INONE - -#OPTIMISE = -mcpu=pentiumpro -O6 -fomit-frame-pointer -fno-exceptions -Wall -W -pedantic -Wno-unused-parameter -pipe -OPTIMISE = -O6 -fomit-frame-pointer -fno-exceptions -Wall -W -pedantic -Wno-unused-parameter -pipe - -#OPTIMISE=-g -fno-exceptions - -CCFLAGS = $(OPTIMISE) -DMITSHM \ - -I. \ --Iunzip \ --DVAR_CYCLES \ --DCPU_SHUTDOWN \ --DSPC700_SHUTDOWN \ -$(FXDEFINES) \ -$(C4DEFINES) \ -$(CPUDEFINES) \ -$(SOUNDDEFINES) \ -$(NETPLAYDEFINES) \ -$(UNZIPDEFINES) \ -$(GLIDEDEFINES) \ -$(OPENGLDEFINES) \ -$(AIDODEFINES) \ -$(GUIDEFINES) \ -$(KREEDDEFINES) \ -$(SDD1DEFINES) \ -$(JOYDEFINES) \ --DNO_INLINE_SET_GET -DNOASM -DHAVE_MKSTEMP '-DACCEPT_SIZE_T=size_t' - -#-DOLD_COLOUR_BLENDING -#-DSOUND -#-DDEBUGGER -#-DNO_INLINE_SET_GET -#-DVAR_CYCLES -#-DCPU_SHUTDOWN -#-DSPC700_SHUTDOWN - -CFLAGS=$(CCFLAGS) - -.SUFFIXES: .o .cpp .c .cc .h .m .i .S .asm .obj .O .CPP .C .ASM -#FIXME: Why is this set statically? -#LDLIBS = -L/usr/X11R6/lib -# -L../zlib - -ifdef GLIDE -all: Makefile configure offsets gsnes9x -else -ifdef OPENGL -all: Makefile configure offsets osnes9x -else -# all: Makefile configure offsets snes9x -all: Makefile configure snes9x -endif -endif - -Makefile: configure Makefile.in - @echo "Makefile is older than configure or in-file. Run configure or touch Makefile." - exit 1 - -configure: configure.in - @echo "configure is older than in-file. Run autoconf or touch configure." - exit 1 - -#ssnes9x -#ggisnes9x -#xf86snes9x - -# offsets: offsets.o -# $(CCC) $(INCLUDES) -o $@ offsets.o -# ./offsets >i386/offsets.h - -#../zlib/libz.a: -# cd ../zlib && sh ./configure && make - -snes9x: $(OBJECTS) $(AIDOOBJS) $(GUIOBJS) - $(CCC) $(INCLUDES) -o $@ $(OBJECTS) $(AIDOOBJS) $(GLIDEOBJS) $(OPENGLOBJS) $(GUIOBJS) $(LDLIBS) $(GLIDELIBS) $(OPENGLLIBS) $(GUILIBS) -lnsl -lXext -lX11 $(EXTRALIBS) -lm - -ssnes9x: $(OBJECTS) unix/svga.o - $(CCC) $(INCLUDES) -o $@ $(OBJECTS) $(GLIDEOBJS) unix/svga.o $(LDLIBS) $(GLIDELIBS) -lvga -lvgagl $(EXTRALIBS) -lm - -gsnes9x: $(OBJECTS) $(GLIDEOBJS) - $(CCC) $(INCLUDES) -o $@ $(OBJECTS) $(GLIDEOBJS) $(LDLIBS) -lglide $(EXTRALIBS) -lm - -ggisnes9x: $(OBJECTS) unix/ggi.o - $(CCC) $(INCLUDES) -o $@ $(OBJECTS) unix/ggi.o $(LDLIBS) -lggi $(EXTRALIBS) -lm - -osnes9x: $(OBJECTS) $(OPENGLOBJS) - $(CCC) $(INCLUDES) -o $@ $(OBJECTS) $(OPENGLOBJS) $(LDLIBS) $(OPENGLLIBS) -lnsl -lXext -lX11 $(EXTRALIBS) -lm - -s9xserver: $(SERVER_OBJECTS) - $(CCC) $(INCLUDES) -o $@ $(SERVER_OBJECTS) - -.cpp.o: - $(CCC) $(INCLUDES) -c $(CCFLAGS) $*.cpp -o $@ - -.c.o: - $(CC) $(INCLUDES) -c $(CCFLAGS) $*.c -o $@ - -.cpp.S: - $(GASM) $(INCLUDES) -S $(CCFLAGS) $*.cpp -o $@ - -.cpp.i: - $(GASM) $(INCLUDES) -E $(CCFLAGS) $*.cpp -o $@ - -.S.o: - $(GASM) $(INCLUDES) -c $(CCFLAGS) $*.S -o $@ - -.S.i: - $(GASM) $(INCLUDES) -c -E $(CCFLAGS) $*.S -o $@ - -.asm.o: - $(NASM) -f elf $(FXDEFINES) -i. -ii386 -o $@ $*.asm - -.obj.o: - cp $*.obj $*.o - -.CPP.O: - $(CCC) $(INCLUDES) -c $(CCFLAGS) -x c++ $*.CPP -o $@ - -.C.O: - $(CC) $(INCLUDES) -c $(CCFLAGS) $*.C -o $@ - -.ASM.O: - $(NASM) -f elf $(FXDEFINES) -i . -i i386 $*.ASM -o $@ - -unix/moc_snes9x_gui.cpp: unix/snes9x_gui.h - $(MOC) unix/snes9x_gui.h -o $@ - -clean: - rm -f $(OBJECTS) offsets.o unix/svga.o unix/aido.o unix/ggi.o unix/xf86.o unix/glide.o - -#release: CCFLAGS += -DNO_DEBUGGER - -_bin-package: - RELNR=`grep "#define VERSION" snes9x.h | sed -e 's/"//g' | awk '{ print $$3 }'` && \ - echo $$RELNR && \ - RELNAME=snes9x-$${RELNR} && export RELNAME && \ - test \! -f $${RELNAME}.tar.gz && \ - DISTDIR=disttmp/$${RELNAME}/ && \ - rm -rf disttmp && \ - mkdir disttmp && \ - mkdir $${DISTDIR} && \ - cp snes9x $${DISTDIR} && \ - cp config.info hardware.txt problems.txt changes.txt ../faqs.txt ../readme.txt ../readme.unix $${DISTDIR} && \ - (cd disttmp && tar cvf - $${RELNAME}) | gzip -c > $${RELNAME}.tar.gz &&\ - rm -rf disttmp - -#FIXME: Should possibly have clean, but not in xenofarm build -bin-release: snes9x _bin-package - -#FIXME: Intelligent messages when bailing out. -#FIXME: See those ls:s? Don't look to closely at the statements... -_src-package: - RELNR=`grep "#define VERSION" snes9x.h | sed -e 's/"//g' | awk '{ print $$3 }'` && \ - echo $$RELNR && \ - RELNAME=snes9x-$${RELNR}-src && \ - test \! -f $${RELNAME}.tar.gz && \ - test \! `ls *~` && \ - test \! `ls *.o` && \ - test \! -f snes9x && \ - export RELNR && export RELNAME && \ - (cd .. && PWD=`pwd` && SNESDIR=`basename $$PWD` && cd .. && \ - DISTDIR=disttmp/$${RELNAME} && \ - rm -rf disttmp && \ - mkdir disttmp && \ - cp -r $${SNESDIR} $${DISTDIR} && \ - rm -f $${DISTDIR}/snes9x/config.* 2>/dev/null && \ - rm -f $${DISTDIR}/snes9x/conftezt.out.* 2>/dev/null && \ - rm -rf $${DISTDIR}/snes9x/autom4te.cache 2>/dev/null && \ - rm $${DISTDIR}/snes9x/Makefile && \ - find disttmp -name CVS -type f -exec rm "{}" \; && \ - find disttmp -name CVS -type d -exec rm "{}" \; && \ - (cd disttmp && tar cvf - $${RELNAME}) | gzip -c > $${RELNAME}.tar.gz && \ - mv $${RELNAME}.tar.gz $${SNESDIR}/snes9x/ ) && \ - rm -rf disttmp - -#Requires: -# 1. Prestine checkout -# 2. `autoconf` -# 3. `./configure` -src-release: depend _src-package - -xenofarm: - ./xenofarm.sh - cd build/xenofarm && tar cf - . > ../../../xenofarm_result.tar - gzip -f9 ../xenofarm_result.tar - -# And now for the impressive testsuite: -verify: snes9x - ./snes9x --selftest - -#FIXME: Make a auto-self-reference. -depend: - $(CC) $(CFLAGS) -MM -MG \ - `find . '(' -name '*.c' -o -name '*.cpp' -o -name '*.S' ')' -print -o -name msdos -prune` \ - | sed -e 's@^[^ :]*: *\([^ ]*/\)[^ /]*@\1&@' \ - >dependencies - -include dependencies - diff --git a/source/Makefile.in b/source/Makefile.in deleted file mode 100644 index 82f5b86..0000000 --- a/source/Makefile.in +++ /dev/null @@ -1,339 +0,0 @@ -@ZSNESFX@ -@ZSNESC4@ -@ASMCPU@ -@SPC700ASM@ -NETPLAY=1 -UNZIP=1 -@GLIDE@ -@OPENGL@ -@AIDO@ -#GUI=0 -@THREAD_SOUND@ -@ASMKREED@ -@SDD1_DECOMP@ -#SDD1_VERIFY=0 - -#Fairly good and special-char-safe descriptor of the os being built on. -OS=`uname -s -r -m|sed \"s/ /-/g\"|tr \"[A-Z]\" \"[a-z]\"|tr \"/()\" \"___\"` -BUILDDIR=. -#BUILDDIR=build/$(OS) - - -ifdef ZSNESFX -FXOBJ=i386/fxemu2b.o i386/fxemu2.o i386/fxemu2c.o i386/fxtable.o i386/sfxproc.o i386/ZSNES.O -FXDEFINES=-DZSNES_FX -DEXECUTE_SUPERFX_PER_LINE -FXDEPENDS=zsnes_fx -FXNO_DEPENDS=c_fx -else -FXOBJ=fxinst.o fxemu.o fxdbg.o -FXDEFINES=-DEXECUTE_SUPERFX_PER_LINE -FXDEPENDS=c_fx -FXNO_DEPENDS=zsnes_fx -endif - -ifdef ZSNESC4 -C4OBJ=i386/C4.O i386/zsnesc4.o c4.o -C4DEFINES=-DZSNES_C4 -C4DEPENDS=zsnes_c4 -C4NO_DEPENDS=c_c4 -else -C4OBJ=c4.o c4emu.o -C4DEFINES= -C4DEPENDS=c_c4 -C4NO_DEPENDS=zsnes_c4 -endif - -ifdef SPC700ASM -SOUNDOBJ=spctool/spc700.o spctool/dsp.o spctool.o spctool/soundmod.o SPC.O -SOUNDDEFINES=-DSPCTOOL -else -SOUNDOBJ=spc700.o soundux.o apu.o @I386SPC@ -SOUNDDEFINES=-DSPC700_C -endif - -ifdef ASMCPU -CPUOBJ=i386/cpuops.o i386/cpuexec.o i386/sa1ops.o -else -CPUOBJ=cpuops.o cpuexec.o sa1cpu.o -endif - -ifdef ASMKREED -KREEDOBJ=i386/2XSAIMMX.O i386/bilinear.o 2xsai.o -KREEDDEFINES=-DMMX -else -KREEDDEFINES= -KREEDOBJ=2xsai.o -endif - -ifdef SDD1_DECOMP -SDD1OBJ=sdd1emu.o -ifdef SDD1_VERIFY -SDD1DEFINES=-DSDD1_DECOMP -DSDD1_VERIFY -else -SDD1DEFINES=-DSDD1_DECOMP -endif -else -SDD1DEFINES= -SDD1OBJ= -endif - -SPC7110OBJ=spc7110.o -OBC1OBJ=obc1.o -SETAOBJ=seta.o seta010.o seta011.o seta018.o - -OBJECTS=$(CPUOBJ) $(SOUNDOBJ) apudebug.o $(FXOBJ) $(C4OBJ) \ - cpu.o sa1.o debug.o sdd1.o tile.o srtc.o \ - gfx.o memmap.o snaporig.o clip.o dsp1.o \ - movie.o \ - ppu.o dma.o snes9x.o snapshot.o screenshot.o \ - cheats.o cheats2.o data.o unix/unix.o unix/config.o globals.o \ - $(SPC7110OBJ) $(OBC1OBJ) $(SETAOBJ) $(KREEDOBJ) $(SDD1OBJ) - -#OBJECTS += ../zlib/libz.a - -#FIXME: The gui is bitrotted if it ever worked at all. Remove? -ifdef GUI -GUIOBJS = unix/snes9x_gui.o unix/moc_snes9x_gui.o -GUILIBS = -L$(QTDIR)/lib -lqt -GUIDEFINES = -I$(QTDIR)/include -endif - -ifdef NETPLAY -OBJECTS += netplay.o server.o -NETPLAYDEFINES=-DNETPLAY_SUPPORT -SERVER_OBJECTS=server.o -endif - -ifdef UNZIP -OBJECTS += loadzip.o unzip/unzip.o unzip/explode.o unzip/unreduce.o unzip/unshrink.o -UNZIPDEFINES=-DUNZIP_SUPPORT -endif - -ifdef THREAD_SOUND -CPUDEFINES += -DUSE_THREADS -EXTRALIBS += -lpthread -endif - -ifdef GLIDE -GLIDEOBJS = unix/glide.o -GLIDEDEFINES = -DUSE_GLIDE -I/usr/include/glide -GLIDELIBS = -lglide2x -endif - -ifdef OPENGL -OPENGLOBJS = unix/opengl.o -OPENGLDEFINES = -DUSE_OPENGL -OPENGLLIBS = -lGL -lGLU -ldl -endif - -ifdef AIDO -AIDOOBJS = unix/aido.o -AIDODEFINES = -DUSE_AIDO -endif - -JOYDEFINES = @JOYDEFINES@ - -MOC = $(QTDIR)/bin/moc -CCC = @CXX@ @RTTIFLAG@ -GASM = @CXX@ -CC = @CC@ -NASM = @NASM@ - -#INCLUDES = -I../zlib @XINCLUDES@ -INCLUDES = @XINCLUDES@ - -OPTIMISE = @OPTIMIZE@ - -#OPTIMISE=-g -fno-exceptions - -CCFLAGS = $(OPTIMISE) -DMITSHM \ -@CPUINC@ -I. \ --Iunzip \ --DVAR_CYCLES \ --DCPU_SHUTDOWN \ --DSPC700_SHUTDOWN \ -$(FXDEFINES) \ -$(C4DEFINES) \ -$(CPUDEFINES) \ -$(SOUNDDEFINES) \ -$(NETPLAYDEFINES) \ -$(UNZIPDEFINES) \ -$(GLIDEDEFINES) \ -$(OPENGLDEFINES) \ -$(AIDODEFINES) \ -$(GUIDEFINES) \ -$(KREEDDEFINES) \ -$(SDD1DEFINES) \ -$(JOYDEFINES) \ --DNO_INLINE_SET_GET @SYSDEFINES@ - -#-DOLD_COLOUR_BLENDING -#-DSOUND -#-DDEBUGGER -#-DNO_INLINE_SET_GET -#-DVAR_CYCLES -#-DCPU_SHUTDOWN -#-DSPC700_SHUTDOWN - -CFLAGS=$(CCFLAGS) - -.SUFFIXES: .o .cpp .c .cc .h .m .i .S .asm .obj .O .CPP .C .ASM -#FIXME: Why is this set statically? -#LDLIBS = -L/usr/X11R6/lib -# -L../zlib - -ifdef GLIDE -all: Makefile configure offsets gsnes9x -else -ifdef OPENGL -all: Makefile configure offsets osnes9x -else -all: Makefile configure offsets snes9x -endif -endif - -Makefile: configure Makefile.in - @echo "Makefile is older than configure or in-file. Run configure or touch Makefile." - exit 1 - -configure: configure.in - @echo "configure is older than in-file. Run autoconf or touch configure." - exit 1 - -#ssnes9x -#ggisnes9x -#xf86snes9x - -offsets: offsets.o - $(CCC) $(INCLUDES) -o $@ offsets.o - ./offsets >i386/offsets.h - -#../zlib/libz.a: -# cd ../zlib && sh ./configure && make - -snes9x: $(OBJECTS) unix/x11.o $(AIDOOBJS) $(GUIOBJS) - $(CCC) $(INCLUDES) -o $@ $(OBJECTS) $(AIDOOBJS) $(GLIDEOBJS) $(OPENGLOBJS) unix/x11.o $(GUIOBJS) $(LDLIBS) $(GLIDELIBS) $(OPENGLLIBS) $(GUILIBS) @SYSLIBS@ -lXext -lX11 $(EXTRALIBS) -lm - -ssnes9x: $(OBJECTS) unix/svga.o - $(CCC) $(INCLUDES) -o $@ $(OBJECTS) $(GLIDEOBJS) unix/svga.o $(LDLIBS) $(GLIDELIBS) -lvga -lvgagl $(EXTRALIBS) -lm - -gsnes9x: $(OBJECTS) $(GLIDEOBJS) - $(CCC) $(INCLUDES) -o $@ $(OBJECTS) $(GLIDEOBJS) $(LDLIBS) -lglide $(EXTRALIBS) -lm - -ggisnes9x: $(OBJECTS) unix/ggi.o - $(CCC) $(INCLUDES) -o $@ $(OBJECTS) unix/ggi.o $(LDLIBS) -lggi $(EXTRALIBS) -lm - -osnes9x: $(OBJECTS) unix/x11.o $(OPENGLOBJS) - $(CCC) $(INCLUDES) -o $@ $(OBJECTS) unix/x11.o $(OPENGLOBJS) $(LDLIBS) $(OPENGLLIBS) @SYSLIBS@ -lXext -lX11 $(EXTRALIBS) -lm - -s9xserver: $(SERVER_OBJECTS) - $(CCC) $(INCLUDES) -o $@ $(SERVER_OBJECTS) - -.cpp.o: - $(CCC) $(INCLUDES) -c $(CCFLAGS) $*.cpp -o $@ - -.c.o: - $(CC) $(INCLUDES) -c $(CCFLAGS) $*.c -o $@ - -.cpp.S: - $(GASM) $(INCLUDES) -S $(CCFLAGS) $*.cpp -o $@ - -.cpp.i: - $(GASM) $(INCLUDES) -E $(CCFLAGS) $*.cpp -o $@ - -.S.o: - $(GASM) $(INCLUDES) -c $(CCFLAGS) $*.S -o $@ - -.S.i: - $(GASM) $(INCLUDES) -c -E $(CCFLAGS) $*.S -o $@ - -.asm.o: - $(NASM) -f elf $(FXDEFINES) -i. -ii386 -o $@ $*.asm - -.obj.o: - cp $*.obj $*.o - -.CPP.O: - $(CCC) $(INCLUDES) -c $(CCFLAGS) -x c++ $*.CPP -o $@ - -.C.O: - $(CC) $(INCLUDES) -c $(CCFLAGS) $*.C -o $@ - -.ASM.O: - $(NASM) -f elf $(FXDEFINES) -i . -i i386 $*.ASM -o $@ - -unix/moc_snes9x_gui.cpp: unix/snes9x_gui.h - $(MOC) unix/snes9x_gui.h -o $@ - -clean: - rm -f $(OBJECTS) offsets.o unix/svga.o unix/aido.o unix/x11.o unix/ggi.o unix/xf86.o unix/glide.o - -#release: CCFLAGS += -DNO_DEBUGGER - -_bin-package: - RELNR=`grep "#define VERSION" snes9x.h | sed -e 's/"//g' | awk '{ print $$3 }'` && \ - echo $$RELNR && \ - RELNAME=snes9x-$${RELNR} && export RELNAME && \ - test \! -f $${RELNAME}.tar.gz && \ - DISTDIR=disttmp/$${RELNAME}/ && \ - rm -rf disttmp && \ - mkdir disttmp && \ - mkdir $${DISTDIR} && \ - cp snes9x $${DISTDIR} && \ - cp config.info hardware.txt problems.txt changes.txt ../faqs.txt ../readme.txt ../readme.unix $${DISTDIR} && \ - (cd disttmp && tar cvf - $${RELNAME}) | gzip -c > $${RELNAME}.tar.gz &&\ - rm -rf disttmp - -#FIXME: Should possibly have clean, but not in xenofarm build -bin-release: snes9x _bin-package - -#FIXME: Intelligent messages when bailing out. -#FIXME: See those ls:s? Don't look to closely at the statements... -_src-package: - RELNR=`grep "#define VERSION" snes9x.h | sed -e 's/"//g' | awk '{ print $$3 }'` && \ - echo $$RELNR && \ - RELNAME=snes9x-$${RELNR}-src && \ - test \! -f $${RELNAME}.tar.gz && \ - test \! `ls *~` && \ - test \! `ls *.o` && \ - test \! -f snes9x && \ - export RELNR && export RELNAME && \ - (cd .. && PWD=`pwd` && SNESDIR=`basename $$PWD` && cd .. && \ - DISTDIR=disttmp/$${RELNAME} && \ - rm -rf disttmp && \ - mkdir disttmp && \ - cp -r $${SNESDIR} $${DISTDIR} && \ - rm -f $${DISTDIR}/snes9x/config.* 2>/dev/null && \ - rm -f $${DISTDIR}/snes9x/conftezt.out.* 2>/dev/null && \ - rm -rf $${DISTDIR}/snes9x/autom4te.cache 2>/dev/null && \ - rm $${DISTDIR}/snes9x/Makefile && \ - find disttmp -name CVS -type f -exec rm "{}" \; && \ - find disttmp -name CVS -type d -exec rm "{}" \; && \ - (cd disttmp && tar cvf - $${RELNAME}) | gzip -c > $${RELNAME}.tar.gz && \ - mv $${RELNAME}.tar.gz $${SNESDIR}/snes9x/ ) && \ - rm -rf disttmp - -#Requires: -# 1. Prestine checkout -# 2. `autoconf` -# 3. `./configure` -src-release: depend _src-package - -xenofarm: - ./xenofarm.sh - cd build/xenofarm && tar cf - . > ../../../xenofarm_result.tar - gzip -f9 ../xenofarm_result.tar - -# And now for the impressive testsuite: -verify: snes9x - ./snes9x --selftest - -#FIXME: Make a auto-self-reference. -depend: - $(CC) $(CFLAGS) -MM -MG \ - `find . '(' -name '*.c' -o -name '*.cpp' -o -name '*.S' ')' -print -o -name msdos -prune` \ - | sed -e 's@^[^ :]*: *\([^ ]*/\)[^ /]*@\1&@' \ - >dependencies - -include dependencies - diff --git a/source/apu.cpp b/source/apu.cpp index 53e0425..ee41096 100644 --- a/source/apu.cpp +++ b/source/apu.cpp @@ -108,10 +108,6 @@ int spc_is_dumping_temp; uint8 spc_dump_dsp[0x100]; extern int NoiseFreq [32]; -#ifdef DEBUGGER -void S9xTraceSoundDSP (const char *s, int i1 = 0, int i2 = 0, int i3 = 0, - int i4 = 0, int i5 = 0, int i6 = 0, int i7 = 0); -#endif bool8 S9xInitAPU () { @@ -227,11 +223,8 @@ void S9xSetAPUDSP (uint8 byte) APU.DSP [APU_KOFF] = 0; APU.DSP [APU_KON] = 0; S9xSetEchoWriteEnable (FALSE); -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] DSP reset\n", ICPU.Scanline); -#endif - // Kill sound + + // Kill sound S9xResetSound (FALSE); } else @@ -239,10 +232,6 @@ void S9xSetAPUDSP (uint8 byte) S9xSetEchoWriteEnable (!(byte & APU_ECHO_DISABLED)); if (byte & APU_MUTE) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] Mute sound\n", ICPU.Scanline); -#endif S9xSetSoundMute (TRUE); } else @@ -259,54 +248,23 @@ void S9xSetAPUDSP (uint8 byte) case APU_NON: if (byte != APU.DSP [APU_NON]) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] Noise:", ICPU.Scanline); -#endif uint8 mask = 1; for (int c = 0; c < 8; c++, mask <<= 1) { int type; + if (byte & mask) - { type = SOUND_NOISE; -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - { - if (APU.DSP [reg] & mask) - S9xTraceSoundDSP ("%d,", c); - else - S9xTraceSoundDSP ("%d(on),", c); - } -#endif - } else - { type = SOUND_SAMPLE; -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - { - if (APU.DSP [reg] & mask) - S9xTraceSoundDSP ("%d(off),", c); - } -#endif - } + S9xSetSoundType (c, type); } -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("\n"); -#endif } break; case APU_MVOL_LEFT: if (byte != APU.DSP [APU_MVOL_LEFT]) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] Master volume left:%d\n", - ICPU.Scanline, (signed char) byte); -#endif S9xSetMasterVolume ((signed char) byte, (signed char) APU.DSP [APU_MVOL_RIGHT]); } @@ -314,11 +272,6 @@ void S9xSetAPUDSP (uint8 byte) case APU_MVOL_RIGHT: if (byte != APU.DSP [APU_MVOL_RIGHT]) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] Master volume right:%d\n", - ICPU.Scanline, (signed char) byte); -#endif S9xSetMasterVolume ((signed char) APU.DSP [APU_MVOL_LEFT], (signed char) byte); } @@ -326,11 +279,6 @@ void S9xSetAPUDSP (uint8 byte) case APU_EVOL_LEFT: if (byte != APU.DSP [APU_EVOL_LEFT]) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] Echo volume left:%d\n", - ICPU.Scanline, (signed char) byte); -#endif S9xSetEchoVolume ((signed char) byte, (signed char) APU.DSP [APU_EVOL_RIGHT]); } @@ -338,20 +286,11 @@ void S9xSetAPUDSP (uint8 byte) case APU_EVOL_RIGHT: if (byte != APU.DSP [APU_EVOL_RIGHT]) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] Echo volume right:%d\n", - ICPU.Scanline, (signed char) byte); -#endif S9xSetEchoVolume ((signed char) APU.DSP [APU_EVOL_LEFT], (signed char) byte); } break; case APU_ENDX: -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] Reset ENDX\n", ICPU.Scanline); -#endif byte = 0; break; @@ -359,19 +298,10 @@ void S9xSetAPUDSP (uint8 byte) // if (byte) { uint8 mask = 1; -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] Key off:", ICPU.Scanline); -#endif for (int c = 0; c < 8; c++, mask <<= 1) { if ((byte & mask) != 0) { -#ifdef DEBUGGER - - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("%d,", c); -#endif if (APU.KeyedChannels & mask) { { @@ -393,10 +323,6 @@ void S9xSetAPUDSP (uint8 byte) S9xPlaySample (c); } } -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("\n"); -#endif } //KeyOnPrev=0; APU.DSP [APU_KOFF] = byte; @@ -415,19 +341,10 @@ void S9xSetAPUDSP (uint8 byte) if (byte) { uint8 mask = 1; -#ifdef DEBUGGER - - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] Key on:", ICPU.Scanline); -#endif for (int c = 0; c < 8; c++, mask <<= 1) { if ((byte & mask) != 0) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("%d,", c); -#endif // Pac-In-Time requires that channels can be key-on // regardeless of their current state. if((APU.DSP [APU_KOFF] & mask) ==0) @@ -442,10 +359,6 @@ void S9xSetAPUDSP (uint8 byte) else KeyOn|=mask; } } -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("\n"); -#endif } spc_is_dumping_temp = byte; return; @@ -461,11 +374,6 @@ void S9xSetAPUDSP (uint8 byte) // At Shin Megami Tensei suggestion 6/11/00 // if (byte != APU.DSP [reg]) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] %d volume left: %d\n", - ICPU.Scanline, reg>>4, (signed char) byte); -#endif S9xSetSoundVolume (reg >> 4, (signed char) byte, (signed char) APU.DSP [reg + 1]); } @@ -481,11 +389,6 @@ void S9xSetAPUDSP (uint8 byte) // At Shin Megami Tensei suggestion 6/11/00 // if (byte != APU.DSP [reg]) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] %d volume right: %d\n", - ICPU.Scanline, reg >>4, (signed char) byte); -#endif S9xSetSoundVolume (reg >> 4, (signed char) APU.DSP [reg - 1], (signed char) byte); } @@ -499,11 +402,6 @@ void S9xSetAPUDSP (uint8 byte) case APU_P_LOW + 0x50: case APU_P_LOW + 0x60: case APU_P_LOW + 0x70: -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] %d freq low: %d\n", - ICPU.Scanline, reg>>4, byte); -#endif S9xSetSoundHertz (reg >> 4, ((byte + (APU.DSP [reg + 1] << 8)) & FREQUENCY_MASK) * 8); break; @@ -515,11 +413,6 @@ void S9xSetAPUDSP (uint8 byte) case APU_P_HIGH + 0x50: case APU_P_HIGH + 0x60: case APU_P_HIGH + 0x70: -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] %d freq high: %d\n", - ICPU.Scanline, reg>>4, byte); -#endif S9xSetSoundHertz (reg >> 4, (((byte << 8) + APU.DSP [reg - 1]) & FREQUENCY_MASK) * 8); break; @@ -534,11 +427,6 @@ void S9xSetAPUDSP (uint8 byte) case APU_SRCN + 0x70: if (byte != APU.DSP [reg]) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] %d sample number: %d\n", - ICPU.Scanline, reg>>4, byte); -#endif S9xSetSoundSample (reg >> 4, byte); } break; @@ -553,11 +441,6 @@ void S9xSetAPUDSP (uint8 byte) case APU_ADSR1 + 0x70: if (byte != APU.DSP [reg]) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] %d adsr1: %02x\n", - ICPU.Scanline, reg>>4, byte); -#endif { S9xFixEnvelope (reg >> 4, APU.DSP [reg + 2], byte, APU.DSP [reg + 1]); @@ -575,11 +458,6 @@ void S9xSetAPUDSP (uint8 byte) case APU_ADSR2 + 0x70: if (byte != APU.DSP [reg]) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] %d adsr2: %02x\n", - ICPU.Scanline, reg>>4, byte); -#endif { S9xFixEnvelope (reg >> 4, APU.DSP [reg + 1], APU.DSP [reg - 1], byte); @@ -597,11 +475,6 @@ void S9xSetAPUDSP (uint8 byte) case APU_GAIN + 0x70: if (byte != APU.DSP [reg]) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] %d gain: %02x\n", - ICPU.Scanline, reg>>4, byte); -#endif { S9xFixEnvelope (reg >> 4, byte, APU.DSP [reg - 2], APU.DSP [reg - 1]); @@ -630,39 +503,11 @@ void S9xSetAPUDSP (uint8 byte) break; case APU_DIR: -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - S9xTraceSoundDSP ("[%d] Sample directory to: %02x\n", - ICPU.Scanline, byte); -#endif break; case APU_PMON: if (byte != APU.DSP [APU_PMON]) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - { - S9xTraceSoundDSP ("[%d] FreqMod:", ICPU.Scanline); - uint8 mask = 1; - for (int c = 0; c < 8; c++, mask <<= 1) - { - if (byte & mask) - { - if (APU.DSP [reg] & mask) - S9xTraceSoundDSP ("%d", c); - else - S9xTraceSoundDSP ("%d(on),", c); - } - else - { - if (APU.DSP [reg] & mask) - S9xTraceSoundDSP ("%d(off),", c); - } - } - S9xTraceSoundDSP ("\n"); - } -#endif S9xSetFrequencyModulationEnable (byte); } break; @@ -670,29 +515,6 @@ void S9xSetAPUDSP (uint8 byte) case APU_EON: if (byte != APU.DSP [APU_EON]) { -#ifdef DEBUGGER - if (Settings.TraceSoundDSP) - { - S9xTraceSoundDSP ("[%d] Echo:", ICPU.Scanline); - uint8 mask = 1; - for (int c = 0; c < 8; c++, mask <<= 1) - { - if (byte & mask) - { - if (APU.DSP [reg] & mask) - S9xTraceSoundDSP ("%d", c); - else - S9xTraceSoundDSP ("%d(on),", c); - } - else - { - if (APU.DSP [reg] & mask) - S9xTraceSoundDSP ("%d(off),", c); - } - } - S9xTraceSoundDSP ("\n"); - } -#endif S9xSetEchoEnable (byte); } break; diff --git a/source/apudebug.cpp b/source/apudebug.cpp deleted file mode 100644 index 9fa2668..0000000 --- a/source/apudebug.cpp +++ /dev/null @@ -1,439 +0,0 @@ -/******************************************************************************* - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - - (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com) and - Jerremy Koot (jkoot@snes9x.com) - - (c) Copyright 2001 - 2004 John Weidman (jweidman@slip.net) - - (c) Copyright 2002 - 2004 Brad Jorsch (anomie@users.sourceforge.net), - funkyass (funkyass@spam.shaw.ca), - Joel Yliluoma (http://iki.fi/bisqwit/) - Kris Bleakley (codeviolation@hotmail.com), - Matthew Kendora, - Nach (n-a-c-h@users.sourceforge.net), - Peter Bortas (peter@bortas.org) and - zones (kasumitokoduck@yahoo.com) - - C4 x86 assembler and some C emulation code - (c) Copyright 2000 - 2003 zsKnight (zsknight@zsnes.com), - _Demo_ (_demo_@zsnes.com), and Nach - - C4 C++ code - (c) Copyright 2003 Brad Jorsch - - DSP-1 emulator code - (c) Copyright 1998 - 2004 Ivar (ivar@snes9x.com), _Demo_, Gary Henderson, - John Weidman, neviksti (neviksti@hotmail.com), - Kris Bleakley, Andreas Naive - - DSP-2 emulator code - (c) Copyright 2003 Kris Bleakley, John Weidman, neviksti, Matthew Kendora, and - Lord Nightmare (lord_nightmare@users.sourceforge.net - - OBC1 emulator code - (c) Copyright 2001 - 2004 zsKnight, pagefault (pagefault@zsnes.com) and - Kris Bleakley - Ported from x86 assembler to C by sanmaiwashi - - SPC7110 and RTC C++ emulator code - (c) Copyright 2002 Matthew Kendora with research by - zsKnight, John Weidman, and Dark Force - - S-DD1 C emulator code - (c) Copyright 2003 Brad Jorsch with research by - Andreas Naive and John Weidman - - S-RTC C emulator code - (c) Copyright 2001 John Weidman - - ST010 C++ emulator code - (c) Copyright 2003 Feather, Kris Bleakley, John Weidman and Matthew Kendora - - Super FX x86 assembler emulator code - (c) Copyright 1998 - 2003 zsKnight, _Demo_, and pagefault - - Super FX C emulator code - (c) Copyright 1997 - 1999 Ivar, Gary Henderson and John Weidman - - - SH assembler code partly based on x86 assembler code - (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) - - - Specific ports contains the works of other authors. See headers in - individual files. - - Snes9x homepage: http://www.snes9x.com - - Permission to use, copy, modify and distribute Snes9x in both binary and - source form, for non-commercial purposes, is hereby granted without fee, - providing that this license information and copyright notice appear with - all copies and any derived work. - - This software is provided 'as-is', without any express or implied - warranty. In no event shall the authors be held liable for any damages - arising from the use of this software. - - Snes9x is freeware for PERSONAL USE only. Commercial users should - seek permission of the copyright holders first. Commercial use includes - charging money for Snes9x or software derived from Snes9x. - - The copyright holders request that bug fixes and improvements to the code - should be forwarded to them so everyone can benefit from the modifications - in future versions. - - Super NES and Super Nintendo Entertainment System are trademarks of - Nintendo Co., Limited and its subsidiary companies. -*******************************************************************************/ - -#include "snes9x.h" -#include "spc700.h" -#include "apu.h" -#include "soundux.h" -#include "cpuexec.h" - -#ifdef SPCTOOL -#include "spctool/spc700.h" -#endif - -#ifdef DEBUGGER -extern int NoiseFreq [32]; - -FILE *apu_trace = NULL; - -static char *S9xMnemonics [256] = { -"NOP", "TCALL0", "SET0 $%02X", "BBS0 $%02X,$%04X", -"OR A,$%02X", "OR A,$%04X", "OR A,(X)", "OR A,($%02X+X)", -"OR A,#$%02X", "OR $%02X,$%02X", "OR1 C,$%04X,%d", "ASL $%02X", -"ASL $%04X", "PUSH PSW", "TSET1 $%04X", "BRK", -"BPL $%04X", "TCALL1", "CLR0 $%02X", "BBC0 $%02X,$%04X", -"OR A,$%02X+X", "OR A,$%04X+X", "OR A,$%04X+Y", "OR A,($%02X)+Y", -"OR $%02X,#$%02X", "OR (X),(Y)", "DECW $%02X", "ASL $%02X+X", -"ASL A", "DEC X", "CMP X,$%04X", "JMP ($%04X+X)", -"CLRP", "TCALL2", "SET1 $%02X", "BBS1 $%02X,$%04X", -"AND A,$%02X", "AND A,$%04X", "AND A,(X)", "AND A,($%02X+X)", -"AND A,$%02X", "AND $%02X,$%02X", "OR1 C,$%04X, not %d", "ROL $%02X", -"ROL $%04X", "PUSH A", "CBNE $%02X,$%04X", "BRA $%04X", -"BMI $%04X", "TCALL3", "CLR1 $%02X", "BBC1 $%02X,$%04X", -"AND A,$%02X+X", "AND A,$%04X+X", "AND A,$%04X+Y", "AND A,($%02X)+Y", -"AND $%02X,#$%02X", "AND (X),(Y)", "INCW $%02X", "ROL $%02X+X", -"ROL A", "INC X", "CMP X,$%02X", "CALL $%04X", -"SETP", "TCALL4", "SET2 $%02X", "BBS2 $%02X,$%04X", -"EOR A,$%02X", "EOR A,$%04X", "EOR A,(X)", "EOR A,($%02X+X)", -"EOR A,#$%02X", "EOR $%02X,$%02X", "AND1 C,$%04X,%d", "LSR $%02X", -"LSR $%04X", "PUSH X", "TCLR1 $%04X", "PCALL $%02X", -"BVC $%04X", "TCALL5", "CLR2 $%02X", "BBC2 $%02X,$%04X", -"EOR A,$%02X+X", "EOR A,$%04X+X", "EOR A,$%04X+Y", "EOR A,($%02X)+Y", -"EOR $%02X,#$%02X", "EOR (X),(Y)", "CMPW YA,$%02X", "LSR $%02X+X", -"LSR A", "MOV X,A", "CMP Y,$%04X", "JMP $%04X", -"CLRC", "TCALL6", "SET3 $%02X", "BBS3 $%02X,$%04X", -"CMP A,$%02X", "CMP A,$%04X", "CMP A,(X)", "CMP A,($%02X+X)", -"CMP A,#$%02X", "CMP $%02X,$%02X", "AND1 C, $%04X, not %d", "ROR $%02X", -"ROR $%04X", "PUSH Y", "DBNZ $%02X,$%04X", "RET", -"BVS $%04X", "TCALL7", "CLR3 $%02X", "BBC3 $%02X,$%04X", -"CMP A,$%02X+X", "CMP A,$%04X+X", "CMP A,$%04X+Y", "CMP A,($%02X)+Y", -"CMP $%02X,#$%02X", "CMP (X),(Y)", "ADDW YA,$%02X", "ROR $%02X+X", -"ROR A", "MOV A,X", "CMP Y,$%02X", "RETI", -"SETC", "TCALL8", "SET4 $%02X", "BBS4 $%02X,$%04X", -"ADC A,$%02X", "ADC A,$%04X", "ADC A,(X)", "ADC A,($%02X+X)", -"ADC A,#$%02X", "ADC $%02X,$%02X", "EOR1 C,%04,%d", "DEC $%02X", -"DEC $%04X", "MOV Y,#$%02X", "POP PSW", "MOV $%02X,#$%02X", -"BCC $%04X", "TCALL9", "CLR4 $%02X", "BBC4 $%02X,$%04X", -"ADC A,$%02X+X", "ADC A,$%04X+X", "ADC A,$%04X+Y", "ADC A,($%02X)+Y", -"ADC $%02X,#$%02X", "ADC (X),(Y)", "SUBW YA,$%02X", "DEC $%02X+X", -"DEC A", "MOV X,SP", "DIV YA,X", "XCN A", -"EI", "TCALL10", "SET5 $%02X", "BBS5 $%02X,$%04X", -"SBC A,$%02X", "SBC A,$%04X", "SBC A,(X)", "SBC A,($%02X+X)", -"SBC A,#$%02X", "SBC $%02X,$%02X", "MOV1 C,$%04X,%d", "INC $%02X", -"INC $%04X", "CMP Y,#$%02X", "POP A", "MOV (X)+,A", -"BCS $%04X", "TCALL11", "CLR5 $%02X", "BBC5 $%02X,$%04X", -"SBC A,$%02X+X", "SBC A,$%04X+X", "SBC A,$%04X+Y", "SBC A,($%02X)+Y", -"SBC $%02X,#$%02X", "SBC (X),(Y)", "MOVW YA,$%02X", "INC $%02X+X", -"INC A", "MOV SP,X", "DAS", "MOV A,(X)+", -"DI", "TCALL12", "SET6 $%02X", "BBS6 $%02X,$%04X", -"MOV $%02X,A", "MOV $%04X,A", "MOV (X),A", "MOV ($%02X+X),A", -"CMP X,#$%02X", "MOV $%04X,X", "MOV1 $%04X,%d,C", "MOV $%02X,Y", -"MOV $%04X,Y", "MOV X,#$%02X", "POP X", "MUL YA", -"BNE $%04X", "TCALL13", "CLR6 $%02X", "BBC6 $%02X,$%04X", -"MOV $%02X+X,A", "MOV $%04X+X,A", "MOV $%04X+Y,A", "MOV ($%02X)+Y,A", -"MOV $%02X,X", "MOV $%02X+Y,X", "MOVW $%02X,YA", "MOV $%02X+X,Y", -"DEC Y", "MOV A,Y", "CBNE $%02X+X,$%04X", "DAA", -"CLRV", "TCALL14", "SET7 $%02X", "BBS7 $%02X,$%04X", -"MOV A,$%02X", "MOV A,$%04X", "MOV A,(X)", "MOV A,($%02X+X)", -"MOV A,#$%02X", "MOV X,$%04X", "NOT1 $%04X,%d", "MOV Y,$%02X", -"MOV Y,$%04X", "NOTC", "POP Y", "SLEEP", -"BEQ $%04X", "TCALL15", "CLR7 $%02X", "BBC7 $%02X,$%04X", -"MOV A,$%02X+X", "MOV A,$%04X+X", "MOV A,$%04X+Y", "MOV A,($%02X)+Y", -"MOV X,$%02X", "MOV X,$%02X+Y", "MOV $%02X,$%02X", "MOV Y,$%02X+X", -"INC Y", "MOV Y,A", "DBNZ Y,$%04X", "STOP" -}; - -#undef ABS - -#define DP 0 -#define ABS 1 -#define IM 2 -#define DP2DP 3 -#define DPIM 4 -#define DPREL 5 -#define ABSBIT 6 -#define REL 7 - -static uint8 Modes [256] = { - IM, IM, DP, DPREL, - DP, ABS, IM, DP, - DP, DP2DP, ABSBIT, DP, - ABS, IM, ABS, IM, - REL, IM, DP, DPREL, - DP, ABS, ABS, DP, - DPIM, IM, DP, DP, - IM, IM, ABS, ABS, - IM, IM, DP, DPREL, - DP, ABS, IM, DP, - DP, DP2DP, ABSBIT, DP, - ABS, IM, DPREL, REL, - REL, IM, DP, DPREL, - DP, ABS, ABS, DP, - DPIM, IM, DP, DP, - IM, IM, DP, ABS, - IM, IM, DP, DPREL, - DP, ABS, IM, DP, - DP, DP2DP, ABSBIT, DP, - ABS, IM, ABS, DP, - REL, IM, DP, DPREL, - DP, ABS, ABS, DP, - DPIM, IM, DP, DP, - IM, IM, ABS, ABS, - IM, IM, DP, DPREL, - DP, ABS, IM, DP, - DP, DP2DP, ABSBIT, DP, - ABS, IM, DPREL, IM, - REL, IM, DP, DPREL, - DP, ABS, ABS, DP, - DPIM, IM, DP, DP, - IM, IM, DP, IM, - IM, IM, DP, DPREL, - DP, ABS, IM, DP, - DP, DP2DP, ABSBIT, DP, - ABS, DP, IM, DPIM, - REL, IM, DP, DPREL, - DP, ABS, ABS, DP, - DPIM, IM, DP, DP, - IM, IM, IM, IM, - IM, IM, DP, DPREL, - DP, ABS, IM, DP, - DP, DP2DP, ABSBIT, DP, - ABS, DP, IM, IM, - REL, IM, DP, DPREL, - DP, ABS, ABS, DP, - DPIM, IM, DP, DP, - IM, IM, IM, IM, - IM, IM, DP, DPREL, - DP, ABS, IM, DP, - DP, ABS, ABSBIT, DP, - ABS, DP, IM, IM, - REL, IM, DP, DPREL, - DP, ABS, ABS, DP, - DP, DP, DP, DP, - IM, IM, DPREL, IM, - IM, IM, DP, DPREL, - DP, ABS, IM, DP, - DP, ABS, ABSBIT, DP, - ABS, IM, IM, IM, - REL, IM, DP, DPREL, - DP, ABS, ABS, DP, - DP, DP, DP2DP, DP, - IM, IM, REL, IM -}; - -static uint8 ModesToBytes [] = { - 2, 3, 1, 3, 3, 3, 3, 2 -}; - -static FILE *SoundTracing = NULL; - -void S9xOpenCloseSoundTracingFile (bool8 open) -{ - if (open && !SoundTracing) - { - SoundTracing = fopen ("sound_trace.log", "w"); - } - else - if (!open && SoundTracing) - { - fclose (SoundTracing); - SoundTracing = NULL; - } -} - -void S9xTraceSoundDSP (const char *s, int i1 = 0, int i2 = 0, int i3 = 0, - int i4 = 0, int i5 = 0, int i6 = 0, int i7 = 0) -{ - fprintf (SoundTracing, s, i1, i2, i3, i4, i5, i6, i7); -} - -int S9xTraceAPU () -{ - char buffer [200]; - - uint8 b = S9xAPUOPrint (buffer, IAPU.PC - IAPU.RAM); - if (apu_trace == NULL) - apu_trace = fopen ("apu_trace.log", "wb"); - - fprintf (apu_trace, "%s\n", buffer); - return (b); -} - -int S9xAPUOPrint (char *buffer, uint16 Address) -{ - char mnem [100]; - uint8 *p = IAPU.RAM + Address; - int mode = Modes [*p]; - int bytes = ModesToBytes [mode]; - - switch (bytes) - { - case 1: - sprintf (buffer, "%04X %02X ", p - IAPU.RAM, *p); - break; - case 2: - sprintf (buffer, "%04X %02X %02X ", p - IAPU.RAM, *p, - *(p + 1)); - break; - case 3: - sprintf (buffer, "%04X %02X %02X %02X ", p - IAPU.RAM, *p, - *(p + 1), *(p + 2)); - break; - } - - switch (mode) - { - case DP: - sprintf (mnem, S9xMnemonics [*p], *(p + 1)); - break; - case ABS: - sprintf (mnem, S9xMnemonics [*p], *(p + 1) + (*(p + 2) << 8)); - break; - case IM: - sprintf (mnem, S9xMnemonics [*p]); - break; - case DP2DP: - sprintf (mnem, S9xMnemonics [*p], *(p + 2), *(p + 1));; - break; - case DPIM: - sprintf (mnem, S9xMnemonics [*p], *(p + 2), *(p + 1));; - break; - case DPREL: - sprintf (mnem, S9xMnemonics [*p], *(p + 1), - (intptr_t) (p + 3 - IAPU.RAM) + (signed char) *(p + 2)); - break; - case ABSBIT: - sprintf (mnem, S9xMnemonics [*p], (*(p + 1) + (*(p + 2) << 8)) & 0x1fff, - *(p + 2) >> 5); - break; - case REL: - sprintf (mnem, S9xMnemonics [*p], - (intptr_t) (p + 2 - IAPU.RAM) + (signed char) *(p + 1)); - break; - } - - sprintf (buffer, "%s %-20s A:%02X X:%02X Y:%02X S:%02X P:%c%c%c%c%c%c%c%c %03dl %04dl %04dl", - buffer, mnem, - APURegisters.YA.B.A, APURegisters.X, APURegisters.YA.B.Y, - APURegisters.S, - APUCheckNegative () ? 'N' : 'n', - APUCheckOverflow () ? 'V' : 'v', - APUCheckDirectPage () ? 'P' : 'p', - APUCheckBreak () ? 'B' : 'b', - APUCheckHalfCarry () ? 'H' : 'h', - APUCheckInterrupt () ? 'I' : 'i', - APUCheckZero () ? 'Z' : 'z', - APUCheckCarry () ? 'C' : 'c', - CPU.V_Counter, - CPU.Cycles, - APU.Cycles); - - return (bytes); -} - -const char *as_binary (uint8 data) -{ - static char buf [9]; - - for (int i = 7; i >= 0; i--) - buf [7 - i] = ((data & (1 << i)) != 0) + '0'; - - buf [8] = 0; - return (buf); -} - -void S9xPrintAPUState () -{ - printf ("Master volume left: %d, right: %d\n", - SoundData.master_volume_left, SoundData.master_volume_right); - printf ("Echo: %s %s, Delay: %d Feedback: %d Left: %d Right: %d\n", - SoundData.echo_write_enabled ? "on" : "off", - as_binary (SoundData.echo_enable), - SoundData.echo_buffer_size >> 9, - SoundData.echo_feedback, SoundData.echo_volume_left, - SoundData.echo_volume_right); - - printf ("Noise: %s, Frequency: %d, Pitch mod: %s\n", as_binary (APU.DSP [APU_NON]), - NoiseFreq [APU.DSP [APU_FLG] & 0x1f], - as_binary (SoundData.pitch_mod)); - extern int FilterTaps [8]; - - printf ("Filter: "); - for (int i = 0; i < 8; i++) - printf ("%03d, ", FilterTaps [i]); - printf ("\n"); - for (int J = 0; J < 8; J++) - { - register Channel *ch = &SoundData.channels[J]; - - printf ("%d: ", J); - if (ch->state == SOUND_SILENT) - { - printf ("off\n"); - } - else - if (!(so.sound_switch & (1 << J))) - printf ("muted by user using channel on/off toggle\n"); - else - { - int freq = ch->hertz; - if (APU.DSP [APU_NON] & (1 << J)) //ch->type == SOUND_NOISE) - { - freq = NoiseFreq [APU.DSP [APU_FLG] & 0x1f]; - printf ("noise, "); - } - else - printf ("sample %d, ", APU.DSP [APU_SRCN + J * 0x10]); - - printf ("freq: %d", freq); - if (J > 0 && (SoundData.pitch_mod & (1 << J)) && - ch->type != SOUND_NOISE) - { - printf ("(mod), "); - } - else - printf (", "); - - printf ("left: %d, right: %d, ", - ch->volume_left, ch->volume_right); - - static char* envelope [] = - { - "silent", "attack", "decay", "sustain", "release", "gain", - "inc_lin", "inc_bent", "dec_lin", "dec_exp" - }; - printf ("%s envx: %d, target: %d, %ld", ch->state > 9 ? "???" : envelope [ch->state], - ch->envx, ch->envx_target, ch->erate); - printf ("\n"); - } - } -} -#endif - - diff --git a/source/c4emu.cpp b/source/c4emu.cpp index be08f07..f188853 100644 --- a/source/c4emu.cpp +++ b/source/c4emu.cpp @@ -106,9 +106,6 @@ void S9xInitC4 () uint8 S9xGetC4 (uint16 Address) { -#ifdef DEBUGGER - if(Settings.BGLayering) printf("%02x from %04x\n", Memory.C4RAM[Address-0x6000], Address); -#endif return (Memory.C4RAM [Address-0x6000]); } @@ -146,12 +143,6 @@ static void C4ConvOAM(void){ globalY=READ_WORD(Memory.C4RAM+0x0623); OAMptr2=Memory.C4RAM+0x200+(Memory.C4RAM[0x626]>>2); -#ifdef DEBUGGER - if(Memory.C4RAM[0x625]!=0) printf("$6625=%02x, expected 00\n", Memory.C4RAM[0x625]); - if((Memory.C4RAM[0x626]>>2)!=Memory.C4RAM[0x629]) printf("$6629=%02x, expected %02x\n", Memory.C4RAM[0x629], (Memory.C4RAM[0x626]>>2)); - if(((uint16)Memory.C4RAM[0x626]<<2)!=READ_WORD(Memory.C4RAM+0x627)) printf("$6627=%04x, expected %04x\n", READ_WORD(Memory.C4RAM+0x627), ((uint16)Memory.C4RAM[0x626]<<2)); -#endif - if(Memory.C4RAM[0x0620]!=0){ SprCount=128-Memory.C4RAM[0x626]; uint8 offset=(Memory.C4RAM[0x626]&3)*2; @@ -270,11 +261,6 @@ static void C4DoScaleRotate(int row_padding){ int32 Cx=(int16)READ_WORD(Memory.C4RAM+0x1f83); int32 Cy=(int16)READ_WORD(Memory.C4RAM+0x1f86); -#ifdef DEBUGGER - if(Memory.C4RAM[0x1f97]!=0) printf("$7f97=%02x, expected 00\n", Memory.C4RAM[0x1f97]); - if((Cx&~1)!=w/2 || (Cy&~1)!=h/2) printf("Center is not middle of image! (%d, %d) != (%d, %d)\n", Cx, Cy, w/2, h/2); -#endif - // Calculate start position (i.e. (Ox, Oy) = (0, 0)) // The low 12 bits are fractional, so (Cx<<12) gives us the Cx we want in // the function. We do Cx*A etc normally because the matrix parameters @@ -381,11 +367,6 @@ static void C4DrawWireFrame(void) int16 X2, Y2, Z2; uint8 Color; -#ifdef DEBUGGER - if(READ_3WORD(Memory.C4RAM+0x1f8f)&0xff00ff) printf("wireframe: Unexpected value in $7f8f: %06x\n", READ_3WORD(Memory.C4RAM+0x1f8f)); - if(READ_3WORD(Memory.C4RAM+0x1fa4)!=0x001000) printf("wireframe: Unexpected value in $7fa4: %06x\n", READ_3WORD(Memory.C4RAM+0x1fa4)); -#endif - for(int i=Memory.C4RAM[0x0295]; i>0; i--, line+=5){ if(line[0]==0xff && line[1]==0xff){ uint8 *tmp=line-5; @@ -413,10 +394,6 @@ static void C4TransformLines(void){ C4WFDist=Memory.C4RAM[0x1f89]; C4WFScale=Memory.C4RAM[0x1f8c]; -#ifdef DEBUGGER - if(Memory.C4RAM[0x1f8a]!=0x90) printf("lines: $7f8a = %02x, expected 90\n", READ_WORD(Memory.C4RAM+0x1f8a)); -#endif - // transform vertices uint8 *ptr=Memory.C4RAM; { @@ -469,10 +446,6 @@ static void C4BitPlaneWave(){ uint16 mask1=0xc0c0; uint16 mask2=0x3f3f; -#ifdef DEBUGGER - if(READ_3WORD(Memory.C4RAM+0x1f80) != Memory.C4RAM[waveptr+0xb00]) printf("$7f80=%06x, expected %02x\n", READ_3WORD(Memory.C4RAM+0x1f80), Memory.C4RAM[waveptr+0xb00]); -#endif - for(int j=0; j<0x10; j++){ do { int16 height=-((int8)Memory.C4RAM[waveptr+0xb00])-16; @@ -529,10 +502,6 @@ static void C4SprDisintegrate() Cx=(int16)READ_WORD(Memory.C4RAM+0x1f80); Cy=(int16)READ_WORD(Memory.C4RAM+0x1f83); -#ifdef DEBUGGER - if((Cx&~1)!=width/2 || (Cy&~1)!=height/2) printf("Center is not middle of image for disintegrate! (%d, %d) != (%d, %d)\n", Cx, Cy, width/2, height/2); -#endif - scaleX=(int16)READ_WORD(Memory.C4RAM+0x1f86); scaleY=(int16)READ_WORD(Memory.C4RAM+0x1f8f); StartX=-Cx*scaleX+(Cx<<8); @@ -565,58 +534,34 @@ static void S9xC4ProcessSprites() switch(Memory.C4RAM[0x1f4d]) { case 0x00: // Build OAM -#ifdef DEBUGGER -// printf("00 00 Build OAM!\n"); -#endif C4ConvOAM(); break; case 0x03: // Scale/Rotate -#ifdef DEBUGGER -// printf("00 03 Scale/Rotate!\n"); -#endif C4DoScaleRotate(0); break; case 0x05: // Transform Lines -#ifdef DEBUGGER -// printf("00 05 Transform Lines!\n"); -#endif C4TransformLines(); break; case 0x07: // Scale/Rotate -#ifdef DEBUGGER -// printf("00 07 Scale/Rotate!\n"); -#endif C4DoScaleRotate(64); break; case 0x08: // Draw wireframe -#ifdef DEBUGGER -// printf("00 08 Draw wireframe!\n"); -#endif C4DrawWireFrame(); break; case 0x0b: // Disintegrate -#ifdef DEBUGGER - printf("00 0b Disintegrate!\n"); -#endif C4SprDisintegrate(); break; case 0x0c: // Wave -#ifdef DEBUGGER -// printf("00 0b Wave!\n"); -#endif C4BitPlaneWave(); break; default: -#ifdef DEBUGGER - printf ("Unknown C4 sprite command (%02x)\n", Memory.C4RAM [0x1f4d]); -#endif break; } } @@ -624,20 +569,13 @@ static void S9xC4ProcessSprites() void S9xSetC4 (uint8 byte, uint16 Address) { int i; - -#ifdef DEBUGGER - if(Settings.BGLayering) printf("%02x to %04x\n", byte, Address); -#endif Memory.C4RAM [Address-0x6000] = byte; if (Address == 0x7f4f) - { - if(Memory.C4RAM[0x1f4d]==0x0e && byte<0x40 && (byte&3)==0) - { -#ifdef DEBUGGER - printf("Test command %02x 0e used!\n", byte); -#endif - Memory.C4RAM[0x1f80]=byte>>2; - } + { + if(Memory.C4RAM[0x1f4d]==0x0e && byte<0x40 && (byte&3)==0) + { + Memory.C4RAM[0x1f80]=byte>>2; + } else { switch (byte) @@ -647,19 +585,11 @@ void S9xSetC4 (uint8 byte, uint16 Address) break; case 0x01: // Draw wireframe -#ifdef DEBUGGER - //printf("01 Draw wireframe used!\n"); - if(Memory.C4RAM[0x1f4d]!=8) printf("$7f4d=%02x, expected 08 for command 01 %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); -#endif memset(Memory.C4RAM+0x300, 0, 16*12*3*4); C4DrawWireFrame(); break; case 0x05: // Propulsion (?) -#ifdef DEBUGGER - printf("05 Propulsion (?)!\n"); - if(Memory.C4RAM[0x1f4d]!=2) printf("$7f4d=%02x, expected 02 for command 05 %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); -#endif { int32 tmp=0x10000; if(READ_WORD(Memory.C4RAM+0x1f83)){ @@ -670,10 +600,6 @@ void S9xSetC4 (uint8 byte, uint16 Address) break; case 0x0d: // Set vector length -#ifdef DEBUGGER - printf("0d Set vector length!\n"); - if(Memory.C4RAM[0x1f4d]!=2) printf("$7f4d=%02x, expected 02 for command 0d %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); -#endif C41FXVal=READ_WORD(Memory.C4RAM+0x1f80); C41FYVal=READ_WORD(Memory.C4RAM+0x1f83); C41FDistVal=READ_WORD(Memory.C4RAM+0x1f86); @@ -683,10 +609,6 @@ void S9xSetC4 (uint8 byte, uint16 Address) break; case 0x10: // Polar to rectangluar -#ifdef DEBUGGER -// printf("10 Polar->Rect!\n"); - if(Memory.C4RAM[0x1f4d]!=2) printf("$7f4d=%02x, expected 02 for command 10 %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); -#endif { int32 tmp=SAR((int32)READ_WORD(Memory.C4RAM+0x1f83)*C4CosTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*2, 16); WRITE_3WORD(Memory.C4RAM+0x1f86, tmp); @@ -696,10 +618,6 @@ void S9xSetC4 (uint8 byte, uint16 Address) break; case 0x13: // Polar to rectangluar -#ifdef DEBUGGER -// printf("13 Polar->Rect!\n"); - if(Memory.C4RAM[0x1f4d]!=2) printf("$7f4d=%02x, expected 02 for command 13 %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); -#endif { int32 tmp=SAR((int32)READ_WORD(Memory.C4RAM+0x1f83)*C4CosTable[READ_WORD(Memory.C4RAM+0x1f80)&0x1ff]*2, 8); WRITE_3WORD(Memory.C4RAM+0x1f86, tmp); @@ -709,10 +627,6 @@ void S9xSetC4 (uint8 byte, uint16 Address) break; case 0x15: // Pythagorean -#ifdef DEBUGGER - printf("15 Pythagorean!\n"); - if(Memory.C4RAM[0x1f4d]!=2) printf("$7f4d=%02x, expected 02 for command 15 %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); -#endif C41FXVal=READ_WORD(Memory.C4RAM+0x1f80); C41FYVal=READ_WORD(Memory.C4RAM+0x1f83); C41FDist=(int16)sqrt((double)C41FXVal*C41FXVal + (double)C41FYVal*C41FYVal); @@ -720,10 +634,6 @@ void S9xSetC4 (uint8 byte, uint16 Address) break; case 0x1f: // atan -#ifdef DEBUGGER -// printf("1f atan!\n"); - if(Memory.C4RAM[0x1f4d]!=2) printf("$7f4d=%02x, expected 02 for command 1f %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); -#endif C41FXVal=READ_WORD(Memory.C4RAM+0x1f80); C41FYVal=READ_WORD(Memory.C4RAM+0x1f83); C4Op1F(); @@ -732,16 +642,8 @@ void S9xSetC4 (uint8 byte, uint16 Address) case 0x22: // Trapezoid { -#ifdef DEBUGGER -// printf("22 Trapezoid!\n"); - if(Memory.C4RAM[0x1f4d]!=2) printf("$7f4d=%02x, expected 02 for command 22 %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); -#endif int16 angle1=READ_WORD(Memory.C4RAM+0x1f8c)&0x1ff; int16 angle2=READ_WORD(Memory.C4RAM+0x1f8f)&0x1ff; -#ifdef DEBUGGER - if(C4CosTable[angle1]==0) fprintf(stderr, "22 Trapezoid: Invalid tangent! angle1=%d\n", angle1); - if(C4CosTable[angle2]==0) fprintf(stderr, "22 Trapezoid: Invalid tangent! angle2=%d\n", angle2); -#endif int32 tan1=(C4CosTable[angle1]!=0)?((((int32)C4SinTable[angle1])<<16)/C4CosTable[angle1]):0x80000000; int32 tan2=(C4CosTable[angle2]!=0)?((((int32)C4SinTable[angle2])<<16)/C4CosTable[angle2]):0x80000000; int16 y = READ_WORD(Memory.C4RAM+0x1f83) - READ_WORD(Memory.C4RAM+0x1f89); @@ -788,10 +690,6 @@ void S9xSetC4 (uint8 byte, uint16 Address) break; case 0x25: // Multiply -#ifdef DEBUGGER - printf("25 Multiply!\n"); - if(Memory.C4RAM[0x1f4d]!=2) printf("$7f4d=%02x, expected 02 for command 25 %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); -#endif { int32 foo=READ_3WORD(Memory.C4RAM+0x1f80); int32 bar=READ_3WORD(Memory.C4RAM+0x1f83); @@ -801,12 +699,6 @@ void S9xSetC4 (uint8 byte, uint16 Address) break; case 0x2d: // Transform Coords -#ifdef DEBUGGER -// printf("2d Transform Coords!\n"); - if(Memory.C4RAM[0x1f4d]!=2) printf("$7f4d=%02x, expected 02 for command 2d %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); - if(READ_3WORD(Memory.C4RAM+0x1f8f)&0xff00ff) printf("2d transform coords: Unexpected value in $7f8f: %06x\n", READ_3WORD(Memory.C4RAM+0x1f8f)); - if(READ_3WORD(Memory.C4RAM+0x1f8c)!=0x001000) printf("0d transform coords: Unexpected value in $7f8c: %06x\n", READ_3WORD(Memory.C4RAM+0x1f8c)); -#endif C4WFXVal=READ_WORD(Memory.C4RAM+0x1f81); C4WFYVal=READ_WORD(Memory.C4RAM+0x1f84); C4WFZVal=READ_WORD(Memory.C4RAM+0x1f87); @@ -820,10 +712,6 @@ void S9xSetC4 (uint8 byte, uint16 Address) break; case 0x40: // Sum -#ifdef DEBUGGER - printf("40 Sum!\n"); - if(Memory.C4RAM[0x1f4d]!=0x0e) printf("$7f4d=%02x, expected 0e for command 40 %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); -#endif { uint16 sum=0; for(int i=0; i<0x800; sum+=Memory.C4RAM[i++]); @@ -832,10 +720,6 @@ void S9xSetC4 (uint8 byte, uint16 Address) break; case 0x54: // Square -#ifdef DEBUGGER - printf("54 Square!\n"); - if(Memory.C4RAM[0x1f4d]!=0x0e) printf("$7f4d=%02x, expected 0e for command 54 %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); -#endif { int64 a=SAR((int64)READ_3WORD(Memory.C4RAM+0x1f80)<<40, 40); // printf("%08X%08X\n", (uint32)(a>>32), (uint32)(a&0xFFFFFFFF)); @@ -847,37 +731,21 @@ void S9xSetC4 (uint8 byte, uint16 Address) break; case 0x5c: // Immediate Reg -#ifdef DEBUGGER - printf("5c Immediate Reg!\n"); - if(Memory.C4RAM[0x1f4d]!=0x0e) printf("$7f4d=%02x, expected 0e for command 5c %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); -#endif for (i = 0; i < 12 * 4; i++) Memory.C4RAM [i] = C4TestPattern [i]; break; case 0x89: // Immediate ROM -#ifdef DEBUGGER - printf("89 Immediate ROM!\n"); - if(Memory.C4RAM[0x1f4d]!=0x0e) printf("$7f4d=%02x, expected 0e for command 89 %02x\n", Memory.C4RAM[0x1f4d], Memory.C4RAM[0x1f4d]); -#endif Memory.C4RAM [0x1f80] = 0x36; Memory.C4RAM [0x1f81] = 0x43; Memory.C4RAM [0x1f82] = 0x05; break; default: -#ifdef DEBUGGER - printf ("Unknown C4 command (%02x)\n", byte); -#endif break; } } } else if (Address == 0x7f47) { -#ifdef DEBUGGER -// printf("C4 load memory %06x => %04x, %04x bytes\n", READ_3WORD(Memory.C4RAM+0x1f40), READ_WORD(Memory.C4RAM+0x1f45), READ_WORD(Memory.C4RAM+0x1f43)); - if(byte != 0) printf("C4 load: non-0 written to $7f47! Wrote %02x\n", byte); - if(READ_WORD(Memory.C4RAM+0x1f45) < 0x6000 || (READ_WORD(Memory.C4RAM+0x1f45) + READ_WORD(Memory.C4RAM+0x1f43)) > 0x6c00) printf("C4 load: Dest unusual! It's %04x\n", READ_WORD(Memory.C4RAM+0x1f45)); -#endif // memmove required: Can overlap arbitrarily [Neb] memmove(Memory.C4RAM+(READ_WORD(Memory.C4RAM+0x1f45)&0x1fff), S9xGetMemPointer(READ_3WORD(Memory.C4RAM+0x1f40)), diff --git a/source/cpuops.cpp b/source/cpuops.cpp index 2279158..eb698eb 100644 --- a/source/cpuops.cpp +++ b/source/cpuops.cpp @@ -4416,11 +4416,6 @@ static void OpFB (void) /* BRK *************************************************************************************** */ static void Op00 (void) { -#ifdef DEBUGGER - if (CPU.Flags & TRACE_FLAG) - S9xTraceMessage ("*** BRK"); -#endif - #ifndef SA1_OPCODES CPU.BRKTriggered = TRUE; #endif @@ -4475,10 +4470,6 @@ static void Op82 (void) /* IRQ *************************************************************************************** */ void S9xOpcode_IRQ (void) { -#ifdef DEBUGGER - if (CPU.Flags & TRACE_FLAG) - S9xTraceMessage ("*** IRQ"); -#endif if (!CheckEmulation()) { PushB (ICPU.Registers.PB); @@ -4533,10 +4524,6 @@ void S9xOpcode_IRQ (void) /* NMI *************************************************************************************** */ void S9xOpcode_NMI (void) { -#ifdef DEBUGGER - if (CPU.Flags & TRACE_FLAG) - S9xTraceMessage ("*** NMI"); -#endif if (!CheckEmulation()) { PushB (ICPU.Registers.PB); @@ -4590,10 +4577,6 @@ void S9xOpcode_NMI (void) /* COP *************************************************************************************** */ static void Op02 (void) { -#ifdef DEBUGGER - if (CPU.Flags & TRACE_FLAG) - S9xTraceMessage ("*** COP"); -#endif if (!CheckEmulation()) { PushB (ICPU.Registers.PB); diff --git a/source/debug.cpp b/source/debug.cpp deleted file mode 100644 index 6ea02e9..0000000 --- a/source/debug.cpp +++ /dev/null @@ -1,2220 +0,0 @@ -/******************************************************************************* - Snes9x - Portable Super Nintendo Entertainment System (TM) emulator. - - (c) Copyright 1996 - 2002 Gary Henderson (gary.henderson@ntlworld.com) and - Jerremy Koot (jkoot@snes9x.com) - - (c) Copyright 2001 - 2004 John Weidman (jweidman@slip.net) - - (c) Copyright 2002 - 2004 Brad Jorsch (anomie@users.sourceforge.net), - funkyass (funkyass@spam.shaw.ca), - Joel Yliluoma (http://iki.fi/bisqwit/) - Kris Bleakley (codeviolation@hotmail.com), - Matthew Kendora, - Nach (n-a-c-h@users.sourceforge.net), - Peter Bortas (peter@bortas.org) and - zones (kasumitokoduck@yahoo.com) - - C4 x86 assembler and some C emulation code - (c) Copyright 2000 - 2003 zsKnight (zsknight@zsnes.com), - _Demo_ (_demo_@zsnes.com), and Nach - - C4 C++ code - (c) Copyright 2003 Brad Jorsch - - DSP-1 emulator code - (c) Copyright 1998 - 2004 Ivar (ivar@snes9x.com), _Demo_, Gary Henderson, - John Weidman, neviksti (neviksti@hotmail.com), - Kris Bleakley, Andreas Naive - - DSP-2 emulator code - (c) Copyright 2003 Kris Bleakley, John Weidman, neviksti, Matthew Kendora, and - Lord Nightmare (lord_nightmare@users.sourceforge.net - - OBC1 emulator code - (c) Copyright 2001 - 2004 zsKnight, pagefault (pagefault@zsnes.com) and - Kris Bleakley - Ported from x86 assembler to C by sanmaiwashi - - SPC7110 and RTC C++ emulator code - (c) Copyright 2002 Matthew Kendora with research by - zsKnight, John Weidman, and Dark Force - - S-DD1 C emulator code - (c) Copyright 2003 Brad Jorsch with research by - Andreas Naive and John Weidman - - S-RTC C emulator code - (c) Copyright 2001 John Weidman - - ST010 C++ emulator code - (c) Copyright 2003 Feather, Kris Bleakley, John Weidman and Matthew Kendora - - Super FX x86 assembler emulator code - (c) Copyright 1998 - 2003 zsKnight, _Demo_, and pagefault - - Super FX C emulator code - (c) Copyright 1997 - 1999 Ivar, Gary Henderson and John Weidman - - - SH assembler code partly based on x86 assembler code - (c) Copyright 2002 - 2004 Marcus Comstedt (marcus@mc.pp.se) - - - Specific ports contains the works of other authors. See headers in - individual files. - - Snes9x homepage: http://www.snes9x.com - - Permission to use, copy, modify and distribute Snes9x in both binary and - source form, for non-commercial purposes, is hereby granted without fee, - providing that this license information and copyright notice appear with - all copies and any derived work. - - This software is provided 'as-is', without any express or implied - warranty. In no event shall the authors be held liable for any damages - arising from the use of this software. - - Snes9x is freeware for PERSONAL USE only. Commercial users should - seek permission of the copyright holders first. Commercial use includes - charging money for Snes9x or software derived from Snes9x. - - The copyright holders request that bug fixes and improvements to the code - should be forwarded to them so everyone can benefit from the modifications - in future versions. - - Super NES and Super Nintendo Entertainment System are trademarks of - Nintendo Co., Limited and its subsidiary companies. -*******************************************************************************/ - -#include <string.h> -#ifdef HAVE_STRINGS_H -#include <strings.h> -#endif - -#include "snes9x.h" -#include "memmap.h" -#include "cpuops.h" -#include "cheats.h" -#include "ppu.h" -#include "cpuexec.h" -#include "debug.h" -#include "missing.h" -#include "display.h" -#include "apu.h" -#include "sa1.h" -#include "spc7110.h" - -#ifdef DEBUGGER -static void WhatsMissing (); -static void WhatsUsed (); -EXTERN_C SDMA DMA[8]; -extern struct SCheatData Cheat; - -#ifdef SPCTOOL -#include "spctool/spc700.h" -extern "C" void TraceSPC (unsigned char *PC, unsigned short YA, unsigned char X, - SPCFlags PS, unsigned char *SP); -#endif - -FILE *trace = NULL; -FILE *trace2 = NULL; -struct SBreakPoint S9xBreakpoint[6]; -struct SDebug -{ - struct - { - uint8 Bank; - uint16 Address; - } Dump; - struct - { - uint8 Bank; - uint16 Address; - } Unassemble; -} Debug = -{ - { - 0, 0 - }, - { - 0, 0 - } -}; -char *HelpMessage[] = { - "Command Help:", - "? - Shows this Command Help", - "r - Shows the Registers", - "i - Shows the interrupt vectors", - "t - Trace current instruction [Step-into]", - "T - Toggle CPU instruction tracing to trace.log", - "D - Toggle DMA tracing to stdout", - "H - Toggle H-DMA tracing to stdout", - "P - Toggle DSP tracing to stdout", - "U - Toggle unknown register read/write tracing", - "V - Toggle non-DMA V-RAM read/write tracing", - "R - Reset ROM.", - "p - Proceed to next instruction [Step-over]", - "s - Skip to next instruction [Skip]", - "S - dump sprite (OBJ) status", - "g [Address] - Go or Go to [Address]", - "u [Address] - Disassemble from PC or [Address]", - "d [Address] - Dump from PC or [Address]", - "bv [Number] - View Breakpoints or View Breakpoint [Number]", - "bs [Number] [Address] - Enable/Disable Breakpoint", - " [Enable example: BS #2 $02:8002]", - " [Disable example: BS #2]", - "c - Dump SNES colour palette", - "W - Show what SNES hardware features a ROM is using", - " which might not be implemented yet.", - "w - Show some SNES hardware features used so far in this frame", - "q - Quit emulator", - "", - "[Address] - $Bank:Address or $Address", - " [For example: $01:8123]", - "[Number] - #Number", - " [For example: #1]", - "a - Show Sound CPU status", - "A - Toggle sound CPU instruction tracing to aputrace.log", - "B - Toggle sound DSP register tracing", - "C - Dump sound sample addresses", - "ad [Address] - Dump sound CPU RAM from PC or [Address]", - "", NULL}; - -char *S9xMnemonics[256] = { - "BRK", "ORA", "COP", "ORA", "TSB", "ORA", "ASL", "ORA", - "PHP", "ORA", "ASL", "PHD", "TSB", "ORA", "ASL", "ORA", - "BPL", "ORA", "ORA", "ORA", "TRB", "ORA", "ASL", "ORA", - "CLC", "ORA", "INC", "TCS", "TRB", "ORA", "ASL", "ORA", - "JSR", "AND", "JSL", "AND", "BIT", "AND", "ROL", "AND", - "PLP", "AND", "ROL", "PLD", "BIT", "AND", "ROL", "AND", - "BMI", "AND", "AND", "AND", "BIT", "AND", "ROL", "AND", - "SEC", "AND", "DEC", "TSC", "BIT", "AND", "ROL", "AND", - "RTI", "EOR", "DB ", "EOR", "MVP", "EOR", "LSR", "EOR", - "PHA", "EOR", "LSR", "PHK", "JMP", "EOR", "LSR", "EOR", - "BVC", "EOR", "EOR", "EOR", "MVN", "EOR", "LSR", "EOR", - "CLI", "EOR", "PHY", "TCD", "JMP", "EOR", "LSR", "EOR", - "RTS", "ADC", "PER", "ADC", "STZ", "ADC", "ROR", "ADC", - "PLA", "ADC", "ROR", "RTL", "JMP", "ADC", "ROR", "ADC", - "BVS", "ADC", "ADC", "ADC", "STZ", "ADC", "ROR", "ADC", - "SEI", "ADC", "PLY", "TDC", "JMP", "ADC", "ROR", "ADC", - "BRA", "STA", "BRL", "STA", "STY", "STA", "STX", "STA", - "DEY", "BIT", "TXA", "PHB", "STY", "STA", "STX", "STA", - "BCC", "STA", "STA", "STA", "STY", "STA", "STX", "STA", - "TYA", "STA", "TXS", "TXY", "STZ", "STA", "STZ", "STA", - "LDY", "LDA", "LDX", "LDA", "LDY", "LDA", "LDX", "LDA", - "TAY", "LDA", "TAX", "PLB", "LDY", "LDA", "LDX", "LDA", - "BCS", "LDA", "LDA", "LDA", "LDY", "LDA", "LDX", "LDA", - "CLV", "LDA", "TSX", "TYX", "LDY", "LDA", "LDX", "LDA", - "CPY", "CMP", "REP", "CMP", "CPY", "CMP", "DEC", "CMP", - "INY", "CMP", "DEX", "WAI", "CPY", "CMP", "DEC", "CMP", - "BNE", "CMP", "CMP", "CMP", "PEI", "CMP", "DEC", "CMP", - "CLD", "CMP", "PHX", "STP", "JML", "CMP", "DEC", "CMP", - "CPX", "SBC", "SEP", "SBC", "CPX", "SBC", "INC", "SBC", - "INX", "SBC", "NOP", "XBA", "CPX", "SBC", "INC", "SBC", - "BEQ", "SBC", "SBC", "SBC", "PEA", "SBC", "INC", "SBC", - "SED", "SBC", "PLX", "XCE", "JSR", "SBC", "INC", "SBC" -}; -int AddrModes[256] = { - //0 1 2 3 4 5 6 7 8 9 A B C D E F - 3, 10, 3, 19, 6, 6, 6, 12, 0, 1,24, 0, 14, 14, 14, 17, //0 - 4, 11, 9, 20, 6, 7, 7, 13, 0, 16,24, 0, 14, 15, 15, 18, //1 - 14, 10,17, 19, 6, 6, 6, 12, 0, 1,24, 0, 14, 14, 14, 17, //2 - 4, 11, 9, 20, 7, 7, 7, 13, 0, 16,24, 0, 15, 15, 15, 18, //3 - 0, 10, 3, 19, 25,6, 6, 12, 0, 1,24, 0, 14, 14, 14, 17, //4 - 4, 11, 9, 20, 25,7, 7, 13, 0, 16, 0, 0, 17, 15, 15, 18, //5 - 0, 10, 5, 19, 6, 6, 6, 12, 0, 1,24, 0, 21, 14, 14, 17, //6 - 4, 11, 9, 20, 7, 7, 7, 13, 0, 16, 0, 0, 23, 15, 15, 18, //7 - 4, 10, 5, 19, 6, 6, 6, 12, 0, 1, 0, 0, 14, 14, 14, 17, //8 - 4, 11, 9, 20, 7, 7, 8, 13, 0, 16, 0, 0, 14, 15, 15, 18, //9 - 2, 10, 2, 19, 6, 6, 6, 12, 0, 1, 0, 0, 14, 14, 14, 17, //A - 4, 11, 9, 20, 7, 7, 8, 13, 0, 16, 0, 0, 15, 15, 16, 18, //B - 2, 10, 3, 19, 6, 6, 6, 12, 0, 1, 0, 0, 14, 14, 14, 17, //C - 4, 11, 9, 9, 0, 7, 7, 13, 0, 16, 0, 0, 22, 15, 15, 18, //D - 2, 10, 3, 19, 6, 6, 6, 12, 0, 1, 0, 0, 14, 14, 14, 17, //E - 4, 11, 9, 20,14, 7, 7, 13, 0, 16, 0, 0, 23, 15, 15, 18 //F -}; - -uint8 S9xOPrint (char *Line, uint8 Bank, uint16 Address) -{ - uint8 S9xOpcode; - uint8 Operant[3]; - uint16 Word; - uint8 Byte; - uint8 Size = 0; - char SByte; - short SWord; - -#if 0 - sprintf (Line, "%04X%04X%04X%04X%02X%04X%c%c%c%c%c%c%c%c%c%03d%03d", - Registers.A.W, Registers.X.W, Registers.Y.W, - Registers.D.W, Registers.DB, Registers.S.W, - CheckEmulation () ? 'E' : 'e', - CheckNegative () ? 'N' : 'n', - CheckOverflow () ? 'V' : 'v', - CheckMemory () ? 'M' : 'm', - CheckIndex () ? 'X' : 'x', - CheckDecimal () ? 'D' : 'd', - CheckIRQ () ? 'I' : 'i', - CheckZero () ? 'Z' : 'z', - CheckCarry () ? 'C' : 'c', - CPU.Cycles, - CPU.V_Counter); - return (0); - -#else - uint32 Cycles = CPU.Cycles; - uint8 *WaitAddress = CPU.WaitAddress; - - S9xOpcode = S9xGetByte ((Bank << 16) + Address); - sprintf (Line, "$%02X:%04X %02X ", Bank, Address, S9xOpcode); - Operant[0] = S9xGetByte ((Bank << 16) + Address + 1); - Operant[1] = S9xGetByte ((Bank << 16) + Address + 2); - Operant[2] = S9xGetByte ((Bank << 16) + Address + 3); - - switch (AddrModes[S9xOpcode]) - { - case 0: - //Implied - sprintf (Line, "%s %s", Line, S9xMnemonics[S9xOpcode]); - Size = 1; - break; - case 1: - //Immediate[MemoryFlag] - if (!CheckFlag (MemoryFlag)) - { - //Accumulator 16 - Bit - sprintf (Line, "%s%02X %02X %s #$%02X%02X", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Size = 3; - } - else - { - //Accumulator 8 - Bit - sprintf (Line, "%s%02X %s #$%02X", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Size = 2; - } - break; - case 2: - //Immediate[IndexFlag] - if (!CheckFlag (IndexFlag)) - { - //X / Y 16 - Bit - sprintf (Line, "%s%02X %02X %s #$%02X%02X", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Size = 3; - } - else - { - //X / Y 8 - Bit - sprintf (Line, "%s%02X %s #$%02X", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Size = 2; - } - break; - case 3: - //Immediate[Always 8 - Bit] - if (1) - { - //Always 8 - Bit - sprintf (Line, "%s%02X %s #$%02X", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Size = 2; - } - break; - case 4: - //Relative - sprintf (Line, "%s%02X %s $%02X", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - SByte = Operant[0]; - Word = Address; - Word += SByte; - Word += 2; - sprintf (Line, "%-32s[$%04X]", Line, Word); - Size = 2; - break; - case 5: - //Relative Long - sprintf (Line, "%s%02X %02X %s $%02X%02X", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - SWord = (Operant[1] << 8) | Operant[0]; - Word = Address; - Word += SWord; - Word += 3; - sprintf (Line, "%-32s[$%04X]", Line, Word); - Size = 3; - break; - case 6: - //Direct - sprintf (Line, "%s%02X %s $%02X", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += Registers.D.W; - sprintf (Line, "%-32s[$00:%04X]", Line, Word); - Size = 2; - break; - case 7: - //Direct indexed (with x) - sprintf (Line, "%s%02X %s $%02X,x", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += Registers.D.W; - Word += Registers.X.W; - sprintf (Line, "%-32s[$00:%04X]", Line, Word); - Size = 2; - break; - case 8: - //Direct indexed (with y) - sprintf (Line, "%s%02X %s $%02X,y", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += Registers.D.W; - Word += Registers.Y.W; - sprintf (Line, "%-32s[$00:%04X]", Line, Word); - Size = 2; - break; - case 9: - //Direct Indirect - sprintf (Line, "%s%02X %s ($%02X)", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += Registers.D.W; - Word = S9xGetWord (Word); - sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.DB, Word); - Size = 2; - break; - case 10: - //Direct Indexed Indirect - sprintf (Line, "%s%02X %s ($%02X,x)", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += Registers.D.W; - Word += Registers.X.W; - Word = S9xGetWord (Word); - sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.DB, Word); - Size = 2; - break; - case 11: - //Direct Indirect Indexed - sprintf (Line, "%s%02X %s ($%02X),y", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += Registers.D.W; - Word = S9xGetWord (Word); - Word += Registers.Y.W; - sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.DB, Word); - Size = 2; - break; - case 12: - //Direct Indirect Long - sprintf (Line, "%s%02X %s [$%02X]", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += Registers.D.W; - Byte = S9xGetByte (Word + 2); - Word = S9xGetWord (Word); - sprintf (Line, "%-32s[$%02X:%04X]", Line, Byte, Word); - Size = 2; - break; - case 13: - //Direct Indirect Indexed Long - sprintf (Line, "%s%02X %s [$%02X],y", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += Registers.D.W; - Byte = S9xGetByte (Word + 2); - Word = S9xGetWord (Word); - Word += Registers.Y.W; - sprintf (Line, "%-32s[$%02X:%04X]", Line, Byte, Word); - Size = 2; - break; - case 14: - //Absolute - sprintf (Line, "%s%02X %02X %s $%02X%02X", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.DB, Word); - Size = 3; - break; - case 15: - //Absolute Indexed (With X) - sprintf (Line, "%s%02X %02X %s $%02X%02X,x", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - Word += Registers.X.W; - sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.DB, Word); - Size = 3; - break; - case 16: - //Absolute Indexed (With Y) - sprintf (Line, "%s%02X %02X %s $%02X%02X,y", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - Word += Registers.Y.W; - sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.DB, Word); - Size = 3; - break; - case 17: - //Absolute long - sprintf (Line, "%s%02X %02X %02X %s $%02X%02X%02X", - Line, - Operant[0], - Operant[1], - Operant[2], - S9xMnemonics[S9xOpcode], - Operant[2], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - sprintf (Line, "%-32s[$%02X:%04X]", Line, Operant[2], Word); - Size = 4; - break; - case 18: - //Absolute Indexed long - sprintf (Line, "%s%02X %02X %02X %s $%02X%02X%02X,x", - Line, - Operant[0], - Operant[1], - Operant[2], - S9xMnemonics[S9xOpcode], - Operant[2], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - Word += Registers.X.W; - sprintf (Line, "%-32s[$%02X:%04X]", Line, Operant[2], Word); - Size = 4; - break; - case 19: - //StackRelative - sprintf (Line, "%s%02X %s $%02X,s", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Registers.S.W; - Word += Operant[0]; - sprintf (Line, "%-32s[$00:%04X]", Line, Word); - Size = 2; - break; - case 20: - //Stack Relative Indirect Indexed - sprintf (Line, "%s%02X %s ($%02X,s),y", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Registers.S.W; - Word += Operant[0]; - Word = S9xGetWord (Word); - Word += Registers.Y.W; - sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.DB, Word); - Size = 2; - break; - case 21: - //Absolute Indirect - sprintf (Line, "%s%02X %02X %s ($%02X%02X)", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - Word = S9xGetWord (Word); - sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.PB, Word); - Size = 3; - break; - case 22: - //Absolute Indirect Long - sprintf (Line, "%s%02X %02X %s [$%02X%02X]", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - Byte = S9xGetByte (Word + 2); - Word = S9xGetWord (Word); - sprintf (Line, "%-32s[$%02X:%04X]", Line, Byte, Word); - Size = 3; - break; - case 23: - //Absolute Indexed Indirect - sprintf (Line, "%s%02X %02X %s ($%02X%02X,x)", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - Word += Registers.X.W; - Word = S9xGetWord (ICPU.ShiftedPB + Word); - sprintf (Line, "%-32s[$%02X:%04X]", Line, Registers.PB, Word); - Size = 3; - break; - case 24: - //Implied accumulator - sprintf (Line, "%s %s A", Line, S9xMnemonics[S9xOpcode]); - Size = 1; - break; - case 25: - // MVN/MVP SRC DST - sprintf (Line, "%s %s %02X %02X", Line, S9xMnemonics[S9xOpcode], - Operant[0], Operant[1]); - Size = 3; - break; - } -// XXX: - sprintf (Line, "%-44s A:%04X X:%04X Y:%04X D:%04X DB:%02X S:%04X P:%c%c%c%c%c%c%c%c%c HC:%03d VC:%03ld %02x", - Line, Registers.A.W, Registers.X.W, Registers.Y.W, - Registers.D.W, Registers.DB, Registers.S.W, - CheckEmulation () ? 'E' : 'e', - CheckNegative () ? 'N' : 'n', - CheckOverflow () ? 'V' : 'v', - CheckMemory () ? 'M' : 'm', - CheckIndex () ? 'X' : 'x', - CheckDecimal () ? 'D' : 'd', - CheckIRQ () ? 'I' : 'i', - CheckZero () ? 'Z' : 'z', - CheckCarry () ? 'C' : 'c', - Cycles, - CPU.V_Counter, - CPU.IRQActive); - - CPU.Cycles = Cycles; - CPU.WaitAddress = WaitAddress; - return Size; -#endif -} - -uint8 S9xSA1OPrint (char *Line, uint8 Bank, uint16 Address) -{ - uint8 S9xOpcode; - uint8 Operant[3]; - uint16 Word; - uint8 Byte; - uint8 Size = 0; - char SByte; - short SWord; - -#if 0 - sprintf (Line, "%04X%04X%04X%04X%02X%04X%c%c%c%c%c%c%c%c%c%03d%03d", - SA1Registers.A.W, SA1Registers.X.W, SA1Registers.Y.W, - SA1Registers.D.W, SA1Registers.DB, SA1Registers.S.W, - SA1CheckEmulation () ? 'E' : 'e', - SA1CheckNegative () ? 'N' : 'n', - SA1CheckOverflow () ? 'V' : 'v', - SA1CheckMemory () ? 'M' : 'm', - SA1CheckIndex () ? 'X' : 'x', - SA1CheckDecimal () ? 'D' : 'd', - SA1CheckIRQ () ? 'I' : 'i', - SA1CheckZero () ? 'Z' : 'z', - SA1CheckCarry () ? 'C' : 'c', - CPU.Cycles, - CPU.V_Counter); - return (0); - -#else - S9xOpcode = S9xSA1GetByte ((Bank << 16) + Address); - sprintf (Line, "$%02X:%04X %02X ", Bank, Address, S9xOpcode); - Operant[0] = S9xSA1GetByte ((Bank << 16) + Address + 1); - Operant[1] = S9xSA1GetByte ((Bank << 16) + Address + 2); - Operant[2] = S9xSA1GetByte ((Bank << 16) + Address + 3); - - switch (AddrModes[S9xOpcode]) - { - case 0: - //Implied - sprintf (Line, "%s %s", Line, S9xMnemonics[S9xOpcode]); - Size = 1; - break; - case 1: - //Immediate[MemoryFlag] - if (!SA1CheckFlag (MemoryFlag)) - { - //Accumulator 16 - Bit - sprintf (Line, "%s%02X %02X %s #$%02X%02X", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Size = 3; - } - else - { - //Accumulator 8 - Bit - sprintf (Line, "%s%02X %s #$%02X", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Size = 2; - } - break; - case 2: - //Immediate[IndexFlag] - if (!SA1CheckFlag (IndexFlag)) - { - //X / Y 16 - Bit - sprintf (Line, "%s%02X %02X %s #$%02X%02X", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Size = 3; - } - else - { - //X / Y 8 - Bit - sprintf (Line, "%s%02X %s #$%02X", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Size = 2; - } - break; - case 3: - //Immediate[Always 8 - Bit] - if (1) - { - //Always 8 - Bit - sprintf (Line, "%s%02X %s #$%02X", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Size = 2; - } - break; - case 4: - //Relative - sprintf (Line, "%s%02X %s $%02X", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - SByte = Operant[0]; - Word = Address; - Word += SByte; - Word += 2; - sprintf (Line, "%-32s[$%04X]", Line, Word); - Size = 2; - break; - case 5: - //Relative Long - sprintf (Line, "%s%02X %02X %s $%02X%02X", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - SWord = (Operant[1] << 8) | Operant[0]; - Word = Address; - Word += SWord; - Word += 3; - sprintf (Line, "%-32s[$%04X]", Line, Word); - Size = 3; - break; - case 6: - //Direct - sprintf (Line, "%s%02X %s $%02X", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += SA1Registers.D.W; - sprintf (Line, "%-32s[$00:%04X]", Line, Word); - Size = 2; - break; - case 7: - //Direct indexed (with x) - sprintf (Line, "%s%02X %s $%02X,x", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += SA1Registers.D.W; - Word += SA1Registers.X.W; - sprintf (Line, "%-32s[$00:%04X]", Line, Word); - Size = 2; - break; - case 8: - //Direct indexed (with y) - sprintf (Line, "%s%02X %s $%02X,y", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += SA1Registers.D.W; - Word += SA1Registers.Y.W; - sprintf (Line, "%-32s[$00:%04X]", Line, Word); - Size = 2; - break; - case 9: - //Direct Indirect - sprintf (Line, "%s%02X %s ($%02X)", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += SA1Registers.D.W; - Word = S9xSA1GetWord (Word); - sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.DB, Word); - Size = 2; - break; - case 10: - //Direct Indexed Indirect - sprintf (Line, "%s%02X %s ($%02X,x)", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += SA1Registers.D.W; - Word += SA1Registers.X.W; - Word = S9xSA1GetWord (Word); - sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.DB, Word); - Size = 2; - break; - case 11: - //Direct Indirect Indexed - sprintf (Line, "%s%02X %s ($%02X),y", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += SA1Registers.D.W; - Word = S9xSA1GetWord (Word); - Word += SA1Registers.Y.W; - sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.DB, Word); - Size = 2; - break; - case 12: - //Direct Indirect Long - sprintf (Line, "%s%02X %s [$%02X]", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += SA1Registers.D.W; - Byte = S9xSA1GetByte (Word + 2); - Word = S9xSA1GetWord (Word); - sprintf (Line, "%-32s[$%02X:%04X]", Line, Byte, Word); - Size = 2; - break; - case 13: - //Direct Indirect Indexed Long - sprintf (Line, "%s%02X %s [$%02X],y", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = Operant[0]; - Word += SA1Registers.D.W; - Byte = S9xSA1GetByte (Word + 2); - Word = S9xSA1GetWord (Word); - Word += SA1Registers.Y.W; - sprintf (Line, "%-32s[$%02X:%04X]", Line, Byte, Word); - Size = 2; - break; - case 14: - //Absolute - sprintf (Line, "%s%02X %02X %s $%02X%02X", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.DB, Word); - Size = 3; - break; - case 15: - //Absolute Indexed (With X) - sprintf (Line, "%s%02X %02X %s $%02X%02X,x", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - Word += SA1Registers.X.W; - sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.DB, Word); - Size = 3; - break; - case 16: - //Absolute Indexed (With Y) - sprintf (Line, "%s%02X %02X %s $%02X%02X,y", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - Word += SA1Registers.Y.W; - sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.DB, Word); - Size = 3; - break; - case 17: - //Absolute long - sprintf (Line, "%s%02X %02X %02X %s $%02X%02X%02X", - Line, - Operant[0], - Operant[1], - Operant[2], - S9xMnemonics[S9xOpcode], - Operant[2], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - sprintf (Line, "%-32s[$%02X:%04X]", Line, Operant[2], Word); - Size = 4; - break; - case 18: - //Absolute Indexed long - sprintf (Line, "%s%02X %02X %02X %s $%02X%02X%02X,x", - Line, - Operant[0], - Operant[1], - Operant[2], - S9xMnemonics[S9xOpcode], - Operant[2], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - Word += SA1Registers.X.W; - sprintf (Line, "%-32s[$%02X:%04X]", Line, Operant[2], Word); - Size = 4; - break; - case 19: - //StackRelative - sprintf (Line, "%s%02X %s $%02X,s", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = SA1Registers.S.W; - Word += Operant[0]; - sprintf (Line, "%-32s[$00:%04X]", Line, Word); - Size = 2; - break; - case 20: - //Stack Relative Indirect Indexed - sprintf (Line, "%s%02X %s ($%02X,s),y", - Line, - Operant[0], - S9xMnemonics[S9xOpcode], - Operant[0]); - Word = SA1Registers.S.W; - Word += Operant[0]; - Word = S9xSA1GetWord (Word); - Word += SA1Registers.Y.W; - sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.DB, Word); - Size = 2; - break; - case 21: - //Absolute Indirect - sprintf (Line, "%s%02X %02X %s ($%02X%02X)", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - Word = S9xSA1GetWord (Word); - sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.PB, Word); - Size = 3; - break; - case 22: - //Absolute Indirect Long - sprintf (Line, "%s%02X %02X %s [$%02X%02X]", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - Byte = S9xSA1GetByte (Word + 2); - Word = S9xSA1GetWord (Word); - sprintf (Line, "%-32s[$%02X:%04X]", Line, Byte, Word); - Size = 3; - break; - case 23: - //Absolute Indexed Indirect - sprintf (Line, "%s%02X %02X %s ($%02X%02X,x)", - Line, - Operant[0], - Operant[1], - S9xMnemonics[S9xOpcode], - Operant[1], - Operant[0]); - Word = (Operant[1] << 8) | Operant[0]; - Word += SA1Registers.X.W; - Word = S9xSA1GetWord (SA1.ShiftedPB + Word); - sprintf (Line, "%-32s[$%02X:%04X]", Line, SA1Registers.PB, Word); - Size = 3; - break; - case 24: - //Implied accumulator - sprintf (Line, "%s %s A", Line, S9xMnemonics[S9xOpcode]); - Size = 1; - break; - case 25: - // MVN/MVP SRC DST - sprintf (Line, "%s %s %02X %02X", Line, S9xMnemonics[S9xOpcode], - Operant[0], Operant[1]); - Size = 3; - break; - } - sprintf (Line, "%-44s A:%04X X:%04X Y:%04X D:%04X DB:%02X S:%04X P:%c%c%c%c%c%c%c%c%c HC:%03ld VC:%03ld", - Line, SA1Registers.A.W, SA1Registers.X.W, SA1Registers.Y.W, - SA1Registers.D.W, SA1Registers.DB, SA1Registers.S.W, - SA1CheckEmulation () ? 'E' : 'e', - SA1CheckNegative () ? 'N' : 'n', - SA1CheckOverflow () ? 'V' : 'v', - SA1CheckMemory () ? 'M' : 'm', - SA1CheckIndex () ? 'X' : 'x', - SA1CheckDecimal () ? 'D' : 'd', - SA1CheckIRQ () ? 'I' : 'i', - SA1CheckZero () ? 'Z' : 'z', - SA1CheckCarry () ? 'C' : 'c', - CPU.Cycles, - CPU.V_Counter); - - return Size; -#endif -} - -/**********************************************************************************************/ -/* DPrint() */ -/* This function prints a line in the debug listbox and deletes upperlines if needed */ -/**********************************************************************************************/ -void DPrint (char *Line) -{ - printf ("%s\n", Line); -} -/**********************************************************************************************/ -/* GetNumber() */ -/* This function gets a number from a debug command */ -/**********************************************************************************************/ -int GetNumber (char *Line, uint16 * Number) -{ - int i; - if (sscanf (Line, " #%d", &i) == 1) - { - *Number = i; - return (1); - } - return (-1); -} -/**********************************************************************************************/ -/* GetStartAddress() */ -/* This function gets a starting address from a debug command */ -/**********************************************************************************************/ -short GetStartAddress (char *Line, uint8 *Bank, uint32 *Address) -{ - int a, b; - if (sscanf (Line + 1, " $%x:%x", &b, &a) != 2) - return (-1); - *Bank = b; - *Address = a; - return (1); -} -/**********************************************************************************************/ -/* ProcessDebugCommand() */ -/* This function processes a debug command */ -/**********************************************************************************************/ -void ProcessDebugCommand (char *Line) -{ - uint8 Bank = Registers.PB; - uint32 Address = CPU.PC - CPU.PCBase; - uint16 Hold; - uint16 Number; - char String [512]; - short ErrorCode; - - if (strcasecmp (Line, "cheat") == 0) - { - S9xStartCheatSearch (&Cheat); - printf ("Cheat Search Started\n"); - return; - } - if (strcasecmp (Line, "less") == 0) - { - S9xSearchForChange (&Cheat, S9X_LESS_THAN, S9X_8_BITS, FALSE, TRUE); - printf ("Recorded all values that have decreased\n"); - return; - } - if (strcasecmp (Line, "print") == 0) - { - printf ("Cheat search results:\n"); - S9xOutputCheatSearchResults (&Cheat); - return; - } - - if (strncasecmp (Line, "constant", 8) == 0) - { - uint32 Byte; - if (sscanf (&Line [8], "%x %x", &Address, &Byte) == 2) - S9xAddCheat (TRUE, TRUE, Address, Byte); - return; - } - - if (strncasecmp (Line, "dump", 4) == 0) - { - int Count; - if (sscanf (&Line [4], "%x %d", &Address, &Count) == 2) - { - sprintf (String, "%06x%05d.sd2", Address, Count); - FILE *fs = fopen (String, "wb"); - if (fs) - { - int i; - for (i = 0; i < Count; i++) - putc (S9xGetByte (Address + i), fs); - - fclose (fs); - } - else - printf ("Can't open %s for writing\n", String); - } - else - printf ("Usage: dump start_address_in_hex count_in_decimal\n"); - return; - } - if (Line[0] == 'i') - { - printf ("Vectors:\n"); - sprintf (String, " 8 Bit 16 Bit "); - DPrint (String); - sprintf (String, "ABT $00:%04X|$00:%04X", S9xGetWord (0xFFF8), S9xGetWord (0xFFE8)); - DPrint (String); - sprintf (String, "BRK $00:%04X|$00:%04X", S9xGetWord (0xFFFE), S9xGetWord (0xFFE6)); - DPrint (String); - sprintf (String, "COP $00:%04X|$00:%04X", S9xGetWord (0xFFF4), S9xGetWord (0xFFE4)); - DPrint (String); - sprintf (String, "IRQ $00:%04X|$00:%04X", S9xGetWord (0xFFFE), S9xGetWord (0xFFEE)); - DPrint (String); - sprintf (String, "NMI $00:%04X|$00:%04X", S9xGetWord (0xFFFA), S9xGetWord (0xFFEA)); - DPrint (String); - sprintf (String, "RES $00:%04X", S9xGetWord (0xFFFC)); - DPrint (String); - } - if (strncmp (Line, "ai", 2) == 0) - { - printf ("APU vectors:"); - for (int i = 0; i < 0x40; i += 2) - { - if (i % 16 == 0) - printf ("\n%04x ", 0xffc0 + i); - printf ("%04x ", APU.ExtraRAM [i]); - } - printf ("\n"); - } - if (Line[0] == 's') - { - CPU.PC += S9xOPrint (String, Bank, Address); - Bank = Registers.PB; - Address = CPU.PC - CPU.PCBase; - Line[0] = 'r'; - } - if (Line[0] == 'z') - { - uint16 *p = (uint16 *) &Memory.VRAM [PPU.BG[2].SCBase << 1]; - for (int l = 0; l < 32; l++) - { - for (int c = 0; c < 32; c++, p++) - { - printf ("%04x,", *p++); - } - printf ("\n"); - } - } - if (*Line == 'c') - { - printf ("Colours:\n"); - for (int i = 0; i < 256; i++) - { - printf ("%02x%02x%02x ", PPU.CGDATA[i] & 0x1f, - (PPU.CGDATA[i] >> 5) & 0x1f, - (PPU.CGDATA[i] >> 10) & 0x1f); - } - printf ("\n"); - } - if (*Line == 'S') - { - int SmallWidth, LargeWidth; - int SmallHeight, LargeHeight; - switch ((Memory.FillRAM[0x2101] >> 5) & 7) - { - case 0: - SmallWidth = SmallHeight = 8; - LargeWidth = LargeHeight = 16; - break; - case 1: - SmallWidth = SmallHeight = 8; - LargeWidth = LargeHeight = 32; - break; - case 2: - SmallWidth = SmallHeight = 8; - LargeWidth = LargeHeight = 64; - break; - case 3: - SmallWidth = SmallHeight = 16; - LargeWidth = LargeHeight = 32; - break; - case 4: - SmallWidth = SmallHeight = 16; - LargeWidth = LargeHeight = 64; - break; - default: - case 5: - SmallWidth = SmallHeight = 32; - LargeWidth = LargeHeight = 64; - break; - case 6: - SmallWidth = 16; SmallHeight = 32; - LargeWidth = 32; LargeHeight = 64; - break; - case 7: - SmallWidth = 16; SmallHeight = 32; - LargeWidth = LargeHeight = 32; - break; - } - printf ("Sprites: Small: %dx%d, Large: %dx%d, OAMAddr: 0x%04x, OBJNameBase: 0x%04x, OBJNameSelect: 0x%04x, First: %d\n", - SmallWidth,SmallHeight, LargeWidth,LargeHeight, PPU.OAMAddr, - PPU.OBJNameBase, PPU.OBJNameSelect, PPU.FirstSprite); -// for (int p = 0; p < 4; p++) -// { -// int c = 0; -// int i; -// for (i = 0; GFX.OBJList [i] >= 0; i++) -// { -// if (PPU.OBJ[GFX.OBJList [i]].Priority == p) -// c++; -// } -// printf ("Priority %d: %03d, ", p, c); -// } -// printf ("\n"); - for (int i = 0; i < 128; i++) - { - printf ("X:%3d Y:%3d %c%c%d%c ", - PPU.OBJ[i].HPos, - PPU.OBJ[i].VPos, - PPU.OBJ[i].VFlip ? 'V' : 'v', - PPU.OBJ[i].HFlip ? 'H' : 'h', - PPU.OBJ[i].Priority, - PPU.OBJ[i].Size ? 'S' : 's'); - if (i % 4 == 3) - printf ("\n"); - } - } - if (*Line == 'T') - { - if (Line [1] == 'S') - { - SA1.Flags ^= TRACE_FLAG; - if (SA1.Flags & TRACE_FLAG) - { - printf ("SA1 CPU instruction tracing enabled.\n"); - if (trace2 == NULL) - trace2 = fopen ("trace_sa1.log", "wb"); - } - else - { - printf ("SA1 CPU instruction tracing disabled.\n"); - fclose (trace2); - trace2 = NULL; - } - } - else - { - CPU.Flags ^= TRACE_FLAG; - if (CPU.Flags & TRACE_FLAG) - { - printf ("CPU instruction tracing enabled.\n"); - if (trace == NULL) - trace = fopen ("trace.log", "wb"); - } - else - { - printf ("CPU instruction tracing disabled.\n"); - fclose (trace); - trace = NULL; - } - } - } - if (*Line == 'A') - { - APU.Flags ^= TRACE_FLAG; - - extern FILE *apu_trace; - if (APU.Flags & TRACE_FLAG) - { -#ifdef SPCTOOL - printf ("ENABLED\n"); - _SetSPCDbg (TraceSPC); //Install debug handler -#endif - if (apu_trace == NULL) - apu_trace = fopen ("aputrace.log", "wb"); - } - else - { -#ifdef SPCTOOL - _SetSPCDbg (NULL); -#endif - if (apu_trace) - { - fclose (apu_trace); - apu_trace = NULL; - } - } - - printf ("APU tracing %s\n", APU.Flags & TRACE_FLAG ? "enabled" : - "disabled"); - } - if (*Line == 'B') - { - Settings.TraceSoundDSP ^= 1; - printf ("Sound DSP register tracing %s\n", Settings.TraceSoundDSP ? - "enabled" : "disabled"); - - S9xOpenCloseSoundTracingFile (Settings.TraceSoundDSP); - } - - if (*Line == 'b') - S9xPrintAPUState (); - - if (*Line == 'C') - { - printf ("SPC700 sample addresses at 0x%04x:\n", APU.DSP [APU_DIR] << 8); - for (int i = 0; i < 256; i++) - { - uint8 *dir = IAPU.RAM + - (((APU.DSP [APU_DIR] << 8) + - i * 4) & 0xffff); - int addr = *dir + (*(dir + 1) << 8); - int addr2 = *(dir + 2) + (*(dir + 3) << 8); - printf ("%04X %04X;", addr, addr2); - if (i % 8 == 7) - printf ("\n"); - } - } - if (*Line == 'R') - { - S9xReset (); - printf ("SNES reset.\n"); - CPU.Flags |= DEBUG_MODE_FLAG; - } - if (strncmp (Line, "ad", 2) == 0) - { - int Count = 16; - Address = 0; - if (sscanf (Line+2, "%x,%x", &Address, &Count) != 2) - { - if (sscanf (Line + 2, "%x", &Address) == 1) - Count = 16; - } - printf ("APU RAM dump:\n"); - for (int l = 0; l < Count; l += 16) - { - printf ("%04X ", Address); - for (int i = 0; i < 16; i++) - printf ("%02X ", IAPU.RAM [Address++]); - printf ("\n"); - } - *Line = 0; - } - if (*Line == 'a') - { - printf ("APU in-ports: %02X %02X %02X %02X\n", - IAPU.RAM [0xF4], IAPU.RAM [0xF5], IAPU.RAM [0xF6], IAPU.RAM [0xF7]); -#ifdef SPCTOOL - printf ("APU out-ports: %02X %02X %02X %02X\n", - _SPCOutP [0], _SPCOutP [1], _SPCOutP [2], _SPCOutP [3]); -#else - printf ("APU out-ports: %02X %02X %02X %02X\n", - APU.OutPorts [0], APU.OutPorts [1], APU.OutPorts [2], APU.OutPorts [3]); -#endif - printf ("ROM/RAM switch: %s\n", (IAPU.RAM [0xf1] & 0x80) ? "ROM" : "RAM"); - for (int i = 0; i < 3; i++) - if (APU.TimerEnabled [i]) - printf ("Timer%d enabled, Value: 0x%03X, 4-bit: 0x%02X, Target: 0x%03X\n", - i, APU.Timer [i], IAPU.RAM [0xfd + i], APU.TimerTarget [i]); - } - if (*Line == 'P') - { - Settings.TraceDSP = !Settings.TraceDSP; - printf ("DSP tracing %s\n", Settings.TraceDSP ? "enabled" : "disabled"); - } - if (Line[0] == 'p') - { - S9xBreakpoint[5].Enabled = FALSE; - Address += S9xOPrint (String, Bank, Address); - if (strncmp (&String[18], "JMP", 3) != 0 && - strncmp (&String[18], "JML", 3) != 0 && - strncmp (&String[18], "RT", 2) != 0 && - strncmp (&String[18], "BRA", 3)) - { - S9xBreakpoint[5].Enabled = TRUE; - S9xBreakpoint[5].Bank = Bank; - S9xBreakpoint[5].Address = Address; - } - else - { - CPU.Flags |= SINGLE_STEP_FLAG; - CPU.Flags &= ~DEBUG_MODE_FLAG; - } - } - if (Line[0] == 'b') - { - if (Line[1] == 's') - { - GetNumber (Line + 2, &Hold); - if (Hold > 4) - Hold = 0; - if (Hold < 5) - if (GetStartAddress (Line + 5, &Bank, &Address) == -1) - { - //Clear S9xBreakpoint - S9xBreakpoint[Hold].Enabled = FALSE; - } - else - { - //Set S9xBreakpoint - S9xBreakpoint[Hold].Enabled = TRUE; - S9xBreakpoint[Hold].Bank = Bank; - S9xBreakpoint[Hold].Address = Address; - CPU.Flags |= BREAK_FLAG; - } - Line = "bv"; - } - if (Line[1] == 'v') - { - Number = 0; - if (GetNumber (Line + 2, &Number) == -1 && - Number < 5) - { - //Show All Breakpoints - DPrint ("Breakpoints:"); - for (Number = 0; Number != 5; Number++) - { - if (S9xBreakpoint[Number].Enabled) - sprintf (String, "%i @ $%02X:%04X", Number, S9xBreakpoint[Number].Bank, S9xBreakpoint[Number].Address); - else - sprintf (String, "%i @ Disabled", Number); - DPrint (String); - } - } - else - { - //Show selected S9xBreakpoint - DPrint ("Breakpoint:"); - if (S9xBreakpoint[Number].Enabled) - sprintf (String, "%i @ $%02X:%04X", Number, S9xBreakpoint[Number].Bank, S9xBreakpoint[Number].Address); - else - sprintf (String, "%i @ Disabled", Number); - DPrint (String); - } - } - } - if (Line[0] == '?' || strcasecmp (Line, "help") == 0) - { - for (short Counter = 0; HelpMessage[Counter] != NULL; Counter++) - DPrint (HelpMessage[Counter]); - } - if (Line[0] == 't') - { - CPU.Flags |= SINGLE_STEP_FLAG; - CPU.Flags &= ~DEBUG_MODE_FLAG; - } - if (Line[0] == 'f') - { - CPU.Flags |= FRAME_ADVANCE_FLAG; - CPU.Flags &= ~DEBUG_MODE_FLAG; - // Render this frame - IPPU.RenderThisFrame = TRUE; - IPPU.FrameSkip = 0; - if (sscanf (&Line [1], "%d", &ICPU.FrameAdvanceCount) != 1) - ICPU.Frame = 0; - } - - if (Line[0] == 'g') - { - S9xBreakpoint[5].Enabled = FALSE; - int i; - bool8 found = FALSE; - for (i = 0; i < 5; i++) - { - if (S9xBreakpoint[i].Enabled) - { - found = TRUE; - if (S9xBreakpoint[i].Bank == Registers.PB && - S9xBreakpoint[i].Address == CPU.PC - CPU.PCBase) - { - S9xBreakpoint[i].Enabled = 2; - break; - } - } - } - if (!found) - CPU.Flags &= ~BREAK_FLAG; - ErrorCode = GetStartAddress (Line, &Bank, &Address); - if (ErrorCode == 1) - { - S9xBreakpoint[5].Enabled = TRUE; - S9xBreakpoint[5].Bank = Bank; - S9xBreakpoint[5].Address = Address; - CPU.Flags |= BREAK_FLAG; - } - CPU.Flags &= ~DEBUG_MODE_FLAG; - } - if (*Line == 'D') - { - Settings.TraceDMA = !Settings.TraceDMA; - printf ("DMA tracing %s\n", Settings.TraceDMA ? "enabled" : "disabled"); - } - if (*Line == 'V') - { - Settings.TraceVRAM = !Settings.TraceVRAM; - printf ("Non-DMA VRAM write tracing %s\n", Settings.TraceVRAM ? "enabled" : "disabled"); - } - if (*Line == 'H') - { - Settings.TraceHDMA = !Settings.TraceHDMA; - printf ("H-DMA tracing %s\n", Settings.TraceHDMA ? "enabled" : "disabled"); - } - if (*Line == 'U') - { - Settings.TraceUnknownRegisters = !Settings.TraceUnknownRegisters; - printf ("Unknown registers read/write tracing %s\n", - Settings.TraceUnknownRegisters ? "enabled" : "disabled"); - } - if (Line[0] == 'd') - { - int CLine; - int CByte; - uint32 Cycles = CPU.Cycles; - uint8 MemoryByte; - - if (Debug.Dump.Bank != 0 || Debug.Dump.Address != 0) - { - Bank = Debug.Dump.Bank; - Address = Debug.Dump.Address; - } - ErrorCode = GetStartAddress (Line, &Bank, &Address); - for (CLine = 0; CLine != 10; CLine++) - { - sprintf (String, "$%02X:%04X", Bank, Address); - for (CByte = 0; CByte != 16; CByte++) - { - if (Address + CByte == 0x2140 || - Address + CByte == 0x2141 || - Address + CByte == 0x2142 || - Address + CByte == 0x2143 || - Address + CByte == 0x4210) - { - MemoryByte = 0; - } - else - { - MemoryByte = S9xGetByte ((Bank << 16) + Address + CByte); - } - sprintf (String, "%s %02X", String, MemoryByte); - } - sprintf (String, "%s-", String); - for (CByte = 0; CByte != 16; CByte++) - { - if (Address + CByte == 0x2140 || - Address + CByte == 0x2141 || - Address + CByte == 0x2142 || - Address + CByte == 0x2143 || - Address + CByte == 0x4210) - { - MemoryByte = 0; - } - else - { - MemoryByte = S9xGetByte ((Bank << 16) + Address + CByte); - } - if (MemoryByte < 32 || MemoryByte >= 127) - MemoryByte = '?'; - sprintf (String, "%s%c", String, MemoryByte); - } - Address += 16; - DPrint (String); - } - Debug.Dump.Bank = Bank; - Debug.Dump.Address = Address; - CPU.Cycles = Cycles; - } - - if (*Line == 'q') - S9xExit (); - if (*Line == 'W') - WhatsMissing (); - if (*Line == 'w') - WhatsUsed (); - if (Line[0] == 'r') - { -#if 0 - sprintf (String, - "A[%04X] X[%04X] Y[%04X] S[%04X] D[%04X] DB[%02X] P[%02X] F[%s %s %s %s %s %s %s %s / %s]", - Registers.A.W, - Registers.X.W, - Registers.Y.W, - Registers.S.W, - Registers.D.W, - Registers.DB, - Registers.PL, - (Registers.P.W & 128) != 0 ? "N" : "n", - (Registers.P.W & 64) != 0 ? "V" : "v", - (Registers.P.W & 32) != 0 ? "M" : "m", - (Registers.P.W & 16) != 0 ? "X" : "x", - (Registers.P.W & 8) != 0 ? "D" : "d", - (Registers.P.W & 4) != 0 ? "I" : "i", - (Registers.P.W & 2) != 0 ? "Z" : "z", - (Registers.P.W & 1) != 0 ? "C" : "c", - (Registers.P.W & 256) != 0 ? "E" : "e"); - DPrint (String); -#endif - S9xOPrint (String, Bank, Address); - DPrint (String); - } - if (Line[0] == 'u') - { - if (Debug.Unassemble.Bank != 0 || Debug.Unassemble.Address != 0) - { - Bank = Debug.Unassemble.Bank; - Address = Debug.Unassemble.Address; - } - ErrorCode = GetStartAddress (Line, &Bank, &Address); - for (short Counter = 0; Counter != 10; Counter++) - { - Address += S9xOPrint (String, Bank, Address); - DPrint (String); - } - Debug.Unassemble.Bank = Bank; - Debug.Unassemble.Address = Address; - } - DPrint (""); - return; -} -static void PrintWindow (uint8 * a) -{ - for (int i = 0; i < 6; i++) - if (a[i]) - switch (i) - { - case 0: - printf ("Background 0, "); - break; - case 1: - printf ("Background 1, "); - break; - case 2: - printf ("Background 2, "); - break; - case 3: - printf ("Background 3, "); - break; - case 4: - printf ("Objects, "); - break; - case 5: - printf ("Colour window, "); - break; - } -} -static char *ClipFn (int logic) -{ - switch (logic) - { - case CLIP_OR: - return ("OR"); - case CLIP_AND: - return ("AND"); - case CLIP_XOR: - return ("XOR"); - case CLIP_XNOR: - return ("XNOR"); - default: - return ("???"); - } -} - -static void WhatsUsed () -{ - printf ("V-line: %ld, H-Pos: %ld\n", CPU.V_Counter, CPU.Cycles); - printf ("Screen mode: %d, ", PPU.BGMode); - if (PPU.BGMode <= 1 && (Memory.FillRAM [0x2105] & 8)) - printf ("(BG#2 Priority)"); - - printf ("Brightness: %d", PPU.Brightness); - if (Memory.FillRAM[0x2100] & 0x80) - printf (" (screen blanked)"); - printf ("\n"); - if (Memory.FillRAM[0x2133] & 1) - printf ("Interlace, "); - if (Memory.FillRAM[0x2133] & 4) - printf ("240 line visible, "); - if (Memory.FillRAM[0x2133] & 8) - printf ("Pseudo 512 pixels horizontal resolution, "); - if (Memory.FillRAM[0x2133] & 0x40) - printf ("Mode 7 priority per pixel, "); - printf ("\n"); - if (PPU.BGMode == 7 && (Memory.FillRAM[0x211a] & 3)) - printf ("Mode 7 flipping, "); - if (PPU.BGMode == 7) - printf ("Mode 7 screen repeat: %d,", (Memory.FillRAM[0x211a] & 0xc0) >> 6); - if (Memory.FillRAM[0x2130] & 1) - printf ("32K colour mode, "); - if (PPU.BGMode == 7) - { - // Sign extend 13 bit values to 16 bit values... - if (PPU.CentreX & (1 << 12)) - PPU.CentreX |= 0xe000; - if (PPU.CentreY & (1 << 12)) - PPU.CentreY |= 0xe000; - - printf ("\nMatrix A: %.3f, B: %.3f, C: %.3f, D: %.3f, Centre X: %d Y:%d\n", - (double) PPU.MatrixA / 256, (double) PPU.MatrixB / 256, - (double) PPU.MatrixC / 256, (double) PPU.MatrixD / 256, - PPU.CentreX, PPU.CentreY); - } - if ((Memory.FillRAM[0x2106] & 0xf0) && (Memory.FillRAM[0x2106] & 0x0f)) - { - printf ("\nMosaic effect(%d) on ", PPU.Mosaic); - for (int i = 0; i < 4; i++) - if (Memory.FillRAM[0x2106] & (1 << i)) - printf ("BG%d,", i); - printf (","); - } - if (PPU.HVBeamCounterLatched) - printf ("V and H beam pos latched, "); - if (Memory.FillRAM[0x4200] & 0x20) - printf ("V-IRQ enabled at %d\n", PPU.IRQVBeamPos); - if (Memory.FillRAM[0x4200] & 0x10) - printf ("H-IRQ enabled at %d\n", PPU.IRQHBeamPos); - if (Memory.FillRAM[0x4200] & 0x80) - printf ("V-blank NMI enabled\n"); - int i; - for (i = 0; i < 8; i++) - { - if (missing.hdma_this_frame & (1 << i)) - { - printf ("H-DMA %d [%d] 0x%02X%04X->0x21%02X %s %s 0x%02X%04X %s addressing\n", - i, DMA[i].TransferMode, - DMA[i].ABank, DMA[i].AAddress, DMA[i].BAddress, - DMA[i].AAddressDecrement ? "dec" : "inc", - DMA[i].Repeat ? "repeat" : "continue", - DMA[i].IndirectBank, DMA[i].IndirectAddress, - DMA[i].HDMAIndirectAddressing ? "indirect" : "absolute"); - } - } - for (i = 0; i < 8; i++) - { - if (missing.dma_this_frame & (1 << i)) - { - printf ("DMA %d %d 0x%02X%04X->0x21%02X Num: %d %s\n", - i, DMA[i].TransferMode, DMA[i].ABank, DMA[i].AAddress, - DMA[i].BAddress, DMA[i].TransferBytes, - DMA[i].AAddressFixed ? "fixed" : - (DMA[i].AAddressDecrement ? "dec" : "inc")); - } - } - printf ("VRAM write address: 0x%04x(%s), Full Graphic: %d, Address inc: %d\n", - PPU.VMA.Address, - PPU.VMA.High ? "Byte" : "Word", - PPU.VMA.FullGraphicCount, PPU.VMA.Increment); - - for (i = 0; i < 4; i++) - { - printf ("BG%d: VOffset:%d, HOffset:%d, W:%d, H:%d, TS:%d, BA:0x%04x, TA:0x%04X\n", - i, PPU.BG[i].VOffset, PPU.BG[i].HOffset, - (PPU.BG[i].SCSize & 1) * 32 + 32, - (PPU.BG[i].SCSize & 2) * 16 + 32, - PPU.BG[i].BGSize * 8 + 8, - PPU.BG[i].SCBase, - PPU.BG[i].NameBase); - } - char *s = ""; - switch ((Memory.FillRAM [0x2130] & 0xc0) >> 6) - { - case 0: s = "always on"; break; - case 1: s = "inside"; break; - case 2: s = "outside"; break; - case 3: s = "always off"; break; - } - printf ("Main screen (%s): ", s); - for (i = 0; i < 5; i++) - if (Memory.FillRAM[0x212c] & (1 << i)) - switch (i) - { - case 0: - printf ("BG0,"); - break; - case 1: - printf ("BG1,"); - break; - case 2: - printf ("BG2,"); - break; - case 3: - printf ("BG3,"); - break; - case 4: - printf ("OBJ,"); - break; - } - - switch ((Memory.FillRAM [0x2130] & 0x30) >> 4) - { - case 0: s = "always on"; break; - case 1: s = "inside"; break; - case 2: s = "outside"; break; - case 3: s = "always off"; break; - } - - printf ("\nSub-screen (%s): ", s); - for (i = 0; i < 5; i++) - if (Memory.FillRAM[0x212d] & (1 << i)) - switch (i) - { - case 0: - printf ("BG0,"); - break; - case 1: - printf ("BG1,"); - break; - case 2: - printf ("BG2,"); - break; - case 3: - printf ("BG3,"); - break; - case 4: - printf ("OBJ,"); - break; - } - printf ("\n"); - if ((Memory.FillRAM[0x2131] & 0x3f)) - { - if (Memory.FillRAM[0x2131] & 0x80) - { - if (Memory.FillRAM[0x2130] & 0x02) - printf ("Subscreen subtract"); - else - printf ("Fixed colour subtract"); - } - else - { - if (Memory.FillRAM[0x2130] & 0x02) - printf ("Subscreen addition"); - else - printf ("Fixed colour addition"); - } - if (Memory.FillRAM [0x2131] & 0x40) - printf ("(half):"); - else - printf (":"); - - for (i = 0; i < 6; i++) - if (Memory.FillRAM[0x2131] & (1 << i)) - { - switch (i) - { - case 0: - printf ("BG0,"); - break; - case 1: - printf ("BG1,"); - break; - case 2: - printf ("BG2,"); - break; - case 3: - printf ("BG3,"); - break; - case 4: - printf ("OBJ,"); - break; - case 5: - printf ("BACK,"); - break; - } - } - printf ("\n"); - } - printf ("\nWindow 1 (%d, %d, %02x, %02x): ", PPU.Window1Left, - PPU.Window1Right, Memory.FillRAM [0x212e], Memory.FillRAM [0x212f]); - for (i = 0; i < 6; i++) - if (PPU.ClipWindow1Enable [i]) - switch (i) - { - case 0: - printf ("BG0(%s-%s),", PPU.ClipWindow1Inside [i] ? "I" : "O", - ClipFn (PPU.ClipWindowOverlapLogic[0])); - break; - case 1: - printf ("BG1(%s-%s),", PPU.ClipWindow1Inside [i] ? "I" : "O", - ClipFn (PPU.ClipWindowOverlapLogic[1])); - break; - case 2: - printf ("BG2(%s-%s),", PPU.ClipWindow1Inside [i] ? "I" : "O", - ClipFn (PPU.ClipWindowOverlapLogic[2])); - break; - case 3: - printf ("BG3(%s-%s),", PPU.ClipWindow1Inside [i] ? "I" : "O", - ClipFn (PPU.ClipWindowOverlapLogic[3])); - break; - case 4: - printf ("OBJ(%s-%s),", PPU.ClipWindow1Inside [i] ? "I" : "O", - ClipFn (PPU.ClipWindowOverlapLogic[4])); - break; - case 5: - printf ("COL(%s-%s)", PPU.ClipWindow1Inside [i] ? "I" : "O", - ClipFn (PPU.ClipWindowOverlapLogic[5])); - break; - } - - printf ("\nWindow 2 (%d, %d): ", PPU.Window2Left, - PPU.Window2Right); - for (i = 0; i < 6; i++) - if (PPU.ClipWindow2Enable [i]) - switch (i) - { - case 0: - printf ("BG0(%s),", PPU.ClipWindow2Inside [i] ? "I" : "O"); - break; - case 1: - printf ("BG1(%s),", PPU.ClipWindow2Inside [i] ? "I" : "O"); - break; - case 2: - printf ("BG2(%s),", PPU.ClipWindow2Inside [i] ? "I" : "O"); - break; - case 3: - printf ("BG3(%s),", PPU.ClipWindow2Inside [i] ? "I" : "O"); - break; - case 4: - printf ("OBJ(%s),", PPU.ClipWindow2Inside [i] ? "I" : "O"); - break; - case 5: - printf ("COL(%s)", PPU.ClipWindow2Inside [i] ? "I" : "O"); - break; - } - - printf ("\nFixed colour: %02x%02x%02x\n", PPU.FixedColourRed, - PPU.FixedColourGreen, PPU.FixedColourBlue); -} - -static void WhatsMissing () -{ - printf ("Processor: "); - if (missing.emulate6502) - printf ("emulation mode, "); - if (missing.decimal_mode) - printf ("decimal mode,"); - if (missing.mv_8bit_index) - printf ("MVP/MVN with 8bit index registers and XH or YH > 0,"); - if (missing.mv_8bit_acc) - printf ("MVP/MVN with 8bit accumulator > 255"); - printf ("\nScreen modes used:"); - int i; - for (i = 0; i < 8; i++) - if (missing.modes[i]) - printf (" %d,", i); - printf ("\n"); - if (missing.interlace) - printf ("Interlace, "); - if (missing.pseudo_512) - printf ("Pseudo 512 pixels horizontal resolution, "); - if (missing.lines_239) - printf ("240 lines visible,"); - if (missing.sprite_double_height) - printf ("double-hight sprites,"); - printf ("\n"); - if (missing.mode7_fx) - printf ("Mode 7 rotation/scaling, "); - if (missing.matrix_read) - printf ("Mode 7 read matrix registers, "); - if (missing.mode7_flip) - printf ("Mode 7 flipping, "); - if (missing.mode7_bgmode) - printf ("Mode 7 priority per pixel, "); - if (missing.direct) - printf ("Direct 32000 colour mode"); - printf ("\n"); - if (missing.mosaic) - printf ("Mosaic effect, "); - if (missing.subscreen) - printf ("Subscreen enabled, "); - if (missing.subscreen_add) - printf ("Subscreen colour add, "); - if (missing.subscreen_sub) - printf ("Subscreen colour subtract, "); - if (missing.fixed_colour_add) - printf ("Fixed colour add, "); - if (missing.fixed_colour_sub) - printf ("Fixed colour subtract"); - printf ("\n"); - printf ("Window 1 enabled on:"); - PrintWindow (missing.window1); - printf ("\nWindow 2 enabled on:"); - PrintWindow (missing.window2); - printf ("\n"); - if (missing.bg_offset_read) - printf ("BG offset read, "); - if (missing.oam_address_read) - printf ("OAM address read,"); - if (missing.sprite_priority_rotation) - printf ("Sprite priority rotation, "); - if (missing.fast_rom) - printf ("Fast 3.58MHz ROM access enabled, "); - if (missing.matrix_multiply) - printf ("Matrix multiply 16bit by 8bit used"); - printf ("\n"); - if (missing.virq) - printf ("V-position IRQ used at line %d, ", missing.virq_pos); - if (missing.hirq) - printf ("H-position IRQ used at position %d, ", missing.hirq_pos); - printf ("\n"); - if (missing.h_v_latch) - printf ("H and V-Pos latched, "); - if (missing.h_counter_read) - printf ("H-Pos read, "); - if (missing.v_counter_read) - printf ("V-Pos read"); - printf ("\n"); - if (missing.oam_read) - printf ("OAM read, "); - if (missing.vram_read) - printf ("VRAM read, "); - if (missing.cgram_read) - printf ("CG-RAM read, "); - if (missing.wram_read) - printf ("WRAM read, "); - if (missing.dma_read) - printf ("DMA read,"); - if (missing.vram_inc) - printf ("VRAM inc: %d,", missing.vram_inc); - if (missing.vram_full_graphic_inc) - printf ("VRAM full graphic inc: %d,", missing.vram_full_graphic_inc); - printf ("\n"); - for (i = 0; i < 8; i++) - { - if (missing.hdma[i].used) - { - printf ("HDMA %d, 0x%02X%04X->0x21%02X %s ", i, - missing.hdma[i].abus_bank, missing.hdma[i].abus_address, - missing.hdma[i].bbus_address, - missing.hdma[i].indirect_address ? "indirect" : "absolute"); - if (missing.hdma[i].force_table_address_write) - printf ("Forced address write, "); - if (missing.hdma[i].force_table_address_read) - printf ("Current address read, "); - if (missing.hdma[i].line_count_write) - printf ("Line count write, "); - if (missing.hdma[i].line_count_read) - printf ("Line count read"); - printf ("\n"); - } - } - for (i = 0; i < 8; i++) - { - if (missing.dma_channels & (1 << i)) - { - printf ("DMA %d %d 0x%02X%04X->0x21%02X Num: %d %s\n", - i, DMA[i].TransferMode, DMA[i].ABank, DMA[i].AAddress, - DMA[i].BAddress, DMA[i].TransferBytes, - DMA[i].AAddressFixed ? "fixed" : - (DMA[i].AAddressDecrement ? "dec" : "inc")); - } - } - if (missing.unknownppu_read) - printf ("Read from unknown PPU register: $%04X\n", missing.unknownppu_read); - if (missing.unknownppu_write) - printf ("Write to unknown PPU register: $%04X\n", missing.unknownppu_write); - if (missing.unknowncpu_read) - printf ("Read from unknown CPU register: $%04X\n", missing.unknowncpu_read); - if (missing.unknowncpu_write) - printf ("Write to unknown CPU register: $%04X\n", missing.unknowncpu_write); - if (missing.unknowndsp_read) - printf ("Read from unknown DSP register: $%04X\n", missing.unknowndsp_read); - if (missing.unknowndsp_write) - printf ("Write to unknown DSP register: $%04X\n", missing.unknowndsp_write); -} - -void S9xDoDebug () -{ - char Line[513]; - Debug.Dump.Bank = 0; - Debug.Dump.Address = 0; - Debug.Unassemble.Bank = 0; - Debug.Unassemble.Address = 0; - S9xTextMode (); - ProcessDebugCommand ("r"); - while (CPU.Flags & DEBUG_MODE_FLAG) - { - printf ("> "); - fflush (stdout); - fgets (Line, sizeof (Line) - 1, stdin); - Line [strlen (Line) - 1] = 0; - ProcessDebugCommand (Line); - } - if (!(CPU.Flags & SINGLE_STEP_FLAG)) - S9xGraphicsMode (); -} - -void S9xTrace () -{ - if(!trace) - trace=fopen("trace.log", "a"); - char String [512]; - S9xOPrint (String, Registers.PB, CPU.PC - CPU.PCBase); - fprintf (trace, "%s\n", String); -} - -void S9xSA1Trace () -{ - char String [512]; - S9xSA1OPrint (String, SA1Registers.PB, SA1.PC - SA1.PCBase); - fprintf (trace2, "%s\n", String); - fflush (trace2); -} - -void S9xTraceMessage (const char *s) -{ - if(s) - { - if (trace) - fprintf (trace, "%s\n", s); - else - if (trace2) - fprintf (trace2, "%s\n", s); - } -} - -extern "C" void TraceSA1 () -{ - SA1.Flags ^= TRACE_FLAG; - if (SA1.Flags & TRACE_FLAG) - { - printf ("SA1 CPU instruction tracing enabled.\n"); - if (trace2 == NULL) - trace2 = fopen ("trace_sa1.log", "wb"); - } - else - { - printf ("SA1 CPU instruction tracing disabled.\n"); - fclose (trace2); - trace2 = NULL; - } -} - -extern "C" void Trace () -{ - CPU.Flags ^= TRACE_FLAG; - if (CPU.Flags & TRACE_FLAG) - { - if (trace == NULL) - trace = fopen ("trace.log", "wb"); - printf ("CPU instruction tracing enabled.\n"); - } - else - { - printf ("CPU instruction tracing disabled.\n"); - fclose (trace); - trace = NULL; - } -} - -#endif - diff --git a/source/dma.cpp b/source/dma.cpp index 96f705f..0ed7535 100644 --- a/source/dma.cpp +++ b/source/dma.cpp @@ -438,34 +438,6 @@ void S9xDoDMA (uint8 Channel) } } -#ifdef DEBUGGER - if (Settings.TraceDMA) - { - sprintf (String, "DMA[%d]: %s Mode: %d 0x%02X%04X->0x21%02X Bytes: %d (%s) V-Line:%ld", - Channel, d->TransferDirection ? "read" : "write", - d->TransferMode, d->ABank, d->AAddress, - d->BAddress, d->TransferBytes, - d->AAddressFixed ? "fixed" : - (d->AAddressDecrement ? "dec" : "inc"), - CPU.V_Counter); - if (d->BAddress == 0x18 || d->BAddress == 0x19 || d->BAddress == 0x39 || d->BAddress == 0x3a) - sprintf (String, "%s VRAM: %04X (%d,%d) %s", String, - PPU.VMA.Address, - PPU.VMA.Increment, PPU.VMA.FullGraphicCount, - PPU.VMA.High ? "word" : "byte"); - - else - if (d->BAddress == 0x22 || d->BAddress == 0x3b) - - sprintf (String, "%s CGRAM: %02X (%x)", String, PPU.CGADD, - PPU.CGFLIP); - else - if (d->BAddress == 0x04 || d->BAddress == 0x38) - sprintf (String, "%s OBJADDR: %04X", String, PPU.OAMAddr); - S9xMessage (S9X_TRACE, S9X_DMA_TRACE, String); - } -#endif - if (!d->TransferDirection) { /* XXX: DMA is potentially broken here for cases where we DMA across @@ -738,17 +710,6 @@ void S9xDoDMA (uint8 Channel) count -= 4; } while (count > 0); } - else - { -#ifdef DEBUGGER - // if (Settings.TraceDMA) - { - sprintf (String, "Unknown DMA transfer mode: %d on channel %d\n", - d->TransferMode, Channel); - S9xMessage (S9X_TRACE, S9X_DMA_TRACE, String); - } -#endif - } } else { @@ -836,14 +797,6 @@ void S9xDoDMA (uint8 Channel) break; default: -#ifdef DEBUGGER - if (1) //Settings.TraceDMA) - { - sprintf (String, "Unknown DMA transfer mode: %d on channel %d\n", - d->TransferMode, Channel); - S9xMessage (S9X_TRACE, S9X_DMA_TRACE, String); - } -#endif count = 0; break; } @@ -918,12 +871,6 @@ void S9xStartHDMA () } } -#ifdef DEBUGGER -void S9xTraceSoundDSP (const char *s, int i1 = 0, int i2 = 0, int i3 = 0, - int i4 = 0, int i5 = 0, int i6 = 0, int i7 = 0); -#endif - - uint8 S9xDoHDMA (uint8 byte) { struct SDMA *p = &DMA [0]; @@ -1034,24 +981,6 @@ uint8 S9xDoHDMA (uint8 byte) } } -#ifdef DEBUGGER - if (Settings.TraceSoundDSP && p->FirstLine && - p->BAddress >= 0x40 && p->BAddress <= 0x43) - S9xTraceSoundDSP ("Spooling data!!!\n"); - if (Settings.TraceHDMA && p->FirstLine) - { - sprintf (String, "H-DMA[%d] (%d) 0x%02X%04X->0x21%02X %s, Count: %3d, Rep: %s, V-LINE: %3ld %02X%04X", - p-DMA, p->TransferMode, p->IndirectBank, - p->IndirectAddress, - p->BAddress, - p->HDMAIndirectAddressing ? "ind" : "abs", - p->LineCount, - p->Repeat ? "yes" : "no ", CPU.V_Counter, - p->ABank, p->Address); - S9xMessage (S9X_TRACE, S9X_HDMA_TRACE, String); - } -#endif - switch (p->TransferMode) { case 0: diff --git a/source/dsp1.cpp b/source/dsp1.cpp index 244d8b0..4e32a54 100644 --- a/source/dsp1.cpp +++ b/source/dsp1.cpp @@ -125,14 +125,6 @@ uint8 S9xGetDSP (uint16 address) { uint8 t; -#ifdef DEBUGGER - if (Settings.TraceDSP) - { - sprintf (String, "DSP read: 0x%04X", address); - S9xMessage (S9X_TRACE, S9X_TRACE_DSP1, String); - } -#endif - t=(*GetDSP)(address); //DSP1GetByte(address); return (t); @@ -140,14 +132,6 @@ uint8 S9xGetDSP (uint16 address) void S9xSetDSP (uint8 byte, uint16 address) { -#ifdef DEBUGGER - missing.unknowndsp_write = address; - if (Settings.TraceDSP) - { - sprintf (String, "DSP write: 0x%04X=0x%02X", address, byte); - S9xMessage (S9X_TRACE, S9X_TRACE_DSP1, String); - } -#endif (*SetDSP)(byte, address); //DSP1SetByte(byte, address); } diff --git a/source/getset.h b/source/getset.h index be81c23..71f54c7 100644 --- a/source/getset.h +++ b/source/getset.h @@ -174,10 +174,7 @@ uint8 S9xGetByte (uint32 Address) - case CMemory::MAP_DEBUG: - #ifdef DEBUGGER - printf ("DEBUG R(B) %06x\n", Address); - #endif + case CMemory::MAP_DEBUG: return OpenBus; @@ -189,9 +186,6 @@ uint8 S9xGetByte (uint32 Address) MessageBox(GUI.hWnd, address, TEXT("GetByte"), MB_OK); #endif -#ifdef DEBUGGER - printf ("R(B) %06x\n", Address); -#endif return OpenBus; } } @@ -298,9 +292,6 @@ uint16 S9xGetWord (uint32 Address) return S9xGetST018(Address)| (S9xGetST018((Address+1))<<8); case CMemory::MAP_DEBUG: - #ifdef DEBUGGER - printf ("DEBUG R(W) %06x\n", Address); - #endif return (OpenBus | (OpenBus<<8)); default: @@ -311,9 +302,6 @@ uint16 S9xGetWord (uint32 Address) MessageBox(GUI.hWnd, address, TEXT("GetWord"), MB_OK); #endif -#ifdef DEBUGGER - printf ("R(W) %06x\n", Address); -#endif return (OpenBus | (OpenBus<<8)); } } @@ -388,9 +376,6 @@ void S9xSetByte (uint8 Byte, uint32 Address) return; case CMemory::MAP_DEBUG: -#ifdef DEBUGGER - printf ("W(B) %06x\n", Address); -#endif case CMemory::MAP_SA1RAM: *(Memory.SRAM + (Address & 0xffff)) = Byte; @@ -670,9 +655,6 @@ uint8 *S9xGetMemPointer (uint32 Address) switch ((intptr_t) GetAddress) { case CMemory::MAP_SPC7110_DRAM: -#ifdef SPC7110_DEBUG - printf("Getting Base pointer to DRAM\n"); -#endif return &s7r.bank50[Address&0x0000FFFF]; case CMemory::MAP_PPU: return (Memory.FillRAM + (Address & 0xffff)); @@ -694,9 +676,6 @@ uint8 *S9xGetMemPointer (uint32 Address) case CMemory::MAP_SETA_DSP: return Memory.SRAM+ ((Address & 0xffff) & Memory.SRAMMask); case CMemory::MAP_DEBUG: -#ifdef DEBUGGER - printf ("GMP %06x\n", Address); -#endif default: case CMemory::MAP_NONE: #if defined(MK_TRACE_BAD_READS) || defined(MK_TRACE_BAD_WRITES) @@ -705,9 +684,6 @@ uint8 *S9xGetMemPointer (uint32 Address) MessageBox(GUI.hWnd, fsd, TEXT("Rogue DMA"), MB_OK); #endif -#ifdef DEBUGGER - printf ("GMP %06x\n", Address); -#endif return (0); } } @@ -765,15 +741,9 @@ void S9xSetPCBase (uint32 Address) return; case CMemory::MAP_DEBUG: -#ifdef DEBUGGER - printf ("SBP %06x\n", Address); -#endif default: case CMemory::MAP_NONE: -#ifdef DEBUGGER - printf ("SBP %06x\n", Address); -#endif CPU.PCBase = Memory.SRAM; CPU.PC = Memory.SRAM + (Address & 0xffff); return; diff --git a/source/sa1.cpp b/source/sa1.cpp index f67a9d6..474f731 100644 --- a/source/sa1.cpp +++ b/source/sa1.cpp @@ -225,9 +225,6 @@ uint8 S9xSA1GetByte (uint32 address) case CMemory::MAP_DEBUG: default: -#ifdef DEBUGGER -// printf ("R(B) %06x\n", address); -#endif return OpenBus; } } @@ -343,9 +340,6 @@ void S9xSA1SetPCBase (uint32 address) return; case CMemory::MAP_DEBUG: -#ifdef DEBUGGER - printf ("SBP %06x\n", address); -#endif default: case CMemory::MAP_NONE: @@ -463,9 +457,6 @@ void S9xSetSA1 (uint8 byte, uint32 address) if (byte & 0x10) { Memory.FillRAM [0x2301] |= 0x10; -#ifdef DEBUGGER - printf ("###SA1 NMI\n"); -#endif if (Memory.FillRAM [0x220a] & 0x10) { } diff --git a/source/sa1cpu.cpp b/source/sa1cpu.cpp index 5382528..299aab3 100644 --- a/source/sa1cpu.cpp +++ b/source/sa1cpu.cpp @@ -233,20 +233,7 @@ void S9xSA1MainLoop () else SA1.Flags &= ~IRQ_PENDING_FLAG; } -#ifdef DEBUGGER - if (SA1.Flags & TRACE_FLAG) - { - for (i = 0; i < 3 && SA1.Executing; i++) - { - S9xSA1Trace (); -#ifdef CPU_SHUTDOWN - SA1.PCAtOpcodeStart = SA1.PC; -#endif - (*SA1.S9xOpcodes [*SA1.PC++].S9xOpcode) (); - } - } - else -#endif + for (i = 0; i < 3 && SA1.Executing; i++) { #ifdef CPU_SHUTDOWN diff --git a/source/spc700.cpp b/source/spc700.cpp index 7f2c5d2..3bfeeac 100644 --- a/source/spc700.cpp +++ b/source/spc700.cpp @@ -141,22 +141,14 @@ void STOP (char *s) { char buffer[100]; -#ifdef DEBUGGER - S9xAPUOPrint (buffer, IAPU.PC - IAPU.RAM); -#else buffer[0] = '\0'; -#endif sprintf (String, "Sound CPU in unknown state executing %s at %04X\n%s\n", s, IAPU.PC - IAPU.RAM, buffer); S9xMessage (S9X_ERROR, S9X_APU_STOPPED, String); APU.TimerEnabled[0] = APU.TimerEnabled[1] = APU.TimerEnabled[2] = FALSE; IAPU.APUExecuting = FALSE; -#ifdef DEBUGGER - CPU.Flags |= DEBUG_MODE_FLAG; -#else S9xExit (); -#endif } #define TCALL(n)\ diff --git a/source/spc700.h b/source/spc700.h index abb413e..29f071b 100644 --- a/source/spc700.h +++ b/source/spc700.h @@ -174,21 +174,11 @@ EXTERN_C int32 ESPC (int32); #else -#ifdef DEBUGGER #define APU_EXECUTE1() \ { \ - if (APU.Flags & TRACE_FLAG) \ - S9xTraceAPU ();\ APU.Cycles += S9xAPUCycles [*IAPU.PC]; \ (*S9xApuOpcodes[*IAPU.PC]) (); \ } -#else -#define APU_EXECUTE1() \ -{ \ - APU.Cycles += S9xAPUCycles [*IAPU.PC]; \ - (*S9xApuOpcodes[*IAPU.PC]) (); \ -} -#endif #define APU_EXECUTE() \ if (IAPU.APUExecuting) \ |