From: S?bastien G. <kx...@us...> - 2004-03-29 22:20:13
|
Update of /cvsroot/vba/VisualBoyAdvance/src/sdl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3551/src/sdl Added Files: Makefile.am Makefile.in SDL.cpp TestEmu.cpp debugger.cpp debugger.h Log Message: GTK+ frontend draft added. --- NEW FILE: TestEmu.cpp --- /* * VisualBoyAdvanced - Nintendo Gameboy/GameboyAdvance (TM) emulator * Copyrigh(c) 1999-2002 Forgotten (vb...@em...) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <stdarg.h> #include <stdlib.h> #include <stdio.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include "AutoBuild.h" #include "GBA.h" #include "debugger.h" #include "Sound.h" #include "unzip.h" #include "Util.h" #include "gb/GB.h" #include "gb/gbGlobals.h" #ifdef __GNUC__ #include <unistd.h> #define GETCWD getcwd #else #include <direct.h> #define GETCWD _getcwd #endif #ifdef MMX extern "C" bool cpu_mmx; #endif extern bool soundEcho; extern bool soundLowPass; extern bool soundReverse; extern void remoteInit(); extern void remoteCleanUp(); extern void remoteStubMain(); extern void remoteStubSignal(int,int); extern void remoteOutput(char *, u32); extern void remoteSetProtocol(int); extern void remoteSetPort(int); extern void debuggerOutput(char *, u32); struct EmulatedSystem emulator; static u8 COPYRIGHT[] = { 0xa9, 0x96, 0x8c, 0x8a, 0x9e, 0x93, 0xbd, 0x90, 0x86, 0xbe, 0x9b, 0x89, 0x9e, 0x91, 0x9c, 0x9a, 0xdf, 0xd7, 0xbc, 0xd6, 0xdf, 0xce, 0xc6, 0xc6, 0xc6, 0xd3, 0xcd, 0xcf, 0xcf, 0xcf, 0xd3, 0xcd, 0xcf, 0xcf, 0xce, 0xdf, 0x9d, 0x86, 0xdf, 0xb9, 0x90, 0x8d, 0x98, 0x90, 0x8b, 0x8b, 0x9a, 0x91, 0x00 }; int systemRedShift = 0; int systemBlueShift = 16; int systemGreenShift = 8; int systemColorDepth = 32; int systemDebug = 0; int systemVerbose = 0; int systemSaveUpdateCounter = SYSTEM_SAVE_NOT_UPDATED; int cartridgeType = 3; int captureFormat = 0; int emulating = 0; int RGB_LOW_BITS_MASK=0x821; int systemFrameSkip = 0; u32 systemColorMap32[0x10000]; u16 systemColorMap16[0x10000]; u16 systemGbPalette[24]; char filename[2048]; char biosFileName[2048]; char captureDir[2048]; char saveDir[2048]; char batteryDir[2048]; bool paused = false; bool debugger = true; bool debuggerStub = false; bool systemSoundOn = false; bool removeIntros = false; extern void debuggerSignal(int,int); void (*dbgMain)() = debuggerMain; void (*dbgSignal)(int,int) = debuggerSignal; void (*dbgOutput)(char *, u32) = debuggerOutput; char *sdlGetFilename(char *name) { static char filebuffer[2048]; int len = strlen(name); char *p = name + len - 1; while(true) { if(*p == '/' || *p == '\\') { p++; break; } len--; p--; if(len == 0) break; } if(len == 0) strcpy(filebuffer, name); else strcpy(filebuffer, p); return filebuffer; } void usage(char *cmd) { printf("%s file-name\n",cmd); } int main(int argc, char **argv) { fprintf(stderr,"VisualBoyAdvance-Test version %s\n", VERSION); #ifdef __GNUC__ fprintf(stderr,"Linux version\n"); #else fprintf(stderr,"Windows version\n"); #endif captureDir[0] = 0; saveDir[0] = 0; batteryDir[0] = 0; char buffer[1024]; int op = -1; systemFrameSkip = frameSkip = 2; gbBorderOn = 0; parseDebug = true; if(!debuggerStub) { if(argc <= 1) { systemMessage(0,"Missing image name"); usage(argv[0]); exit(-1); } } for(int i = 0; i < 24;) { systemGbPalette[i++] = (0x1f) | (0x1f << 5) | (0x1f << 10); systemGbPalette[i++] = (0x15) | (0x15 << 5) | (0x15 << 10); systemGbPalette[i++] = (0x0c) | (0x0c << 5) | (0x0c << 10); systemGbPalette[i++] = 0; } if(argc == 2) { char *szFile = argv[optind]; bool failed = false; if(CPUIsZipFile(szFile)) { unzFile unz = unzOpen(szFile); if(unz == NULL) { systemMessage(0, "Cannot open file %s", szFile); exit(-1); } int r = unzGoToFirstFile(unz); if(r != UNZ_OK) { unzClose(unz); systemMessage(0, "Bad ZIP file %s", szFile); exit(-1); } bool found = false; unz_file_info info; while(true) { r = unzGetCurrentFileInfo(unz, &info, buffer, sizeof(buffer), NULL, 0, NULL, 0); if(r != UNZ_OK) { unzClose(unz); systemMessage(0,"Bad ZIP file %s", szFile); exit(-1); } if(utilIsGBImage(buffer)) { found = true; cartridgeType = 1; break; } if(utilIsGBAImage(buffer)) { found = true; cartridgeType = 0; break; } r = unzGoToNextFile(unz); if(r != UNZ_OK) break; } if(!found) { unzClose(unz); systemMessage(0, "No image found on ZIP file %s", szFile); exit(-1); } unzClose(unz); } if(utilIsGBImage(szFile) || cartridgeType == 1) { failed = !gbLoadRom(szFile); cartridgeType = 1; emulator = GBSystem; } else if(utilIsGBAImage(szFile) || cartridgeType == 0) { failed = !CPULoadRom(szFile); cartridgeType = 0; emulator = GBASystem; CPUInit(biosFileName, useBios); CPUReset(); } else { systemMessage(0, "Unknown file type %s", szFile); exit(-1); } if(failed) { systemMessage(0, "Failed to load file %s", szFile); exit(-1); } strcpy(filename, szFile); char *p = strrchr(filename, '.'); if(p) *p = 0; } else { cartridgeType = 0; strcpy(filename, "gnu_stub"); rom = (u8 *)malloc(0x2000000); workRAM = (u8 *)calloc(1, 0x40000); bios = (u8 *)calloc(1,0x4000); internalRAM = (u8 *)calloc(1,0x8000); paletteRAM = (u8 *)calloc(1,0x400); vram = (u8 *)calloc(1, 0x20000); oam = (u8 *)calloc(1, 0x400); pix = (u8 *)calloc(1, 4 * 240 * 160); ioMem = (u8 *)calloc(1, 0x400); emulator = GBASystem; CPUInit(biosFileName, useBios); CPUReset(); } if(debuggerStub) remoteInit(); if(cartridgeType == 0) { } else if (cartridgeType == 1) { if(gbBorderOn) { gbBorderLineSkip = 256; gbBorderColumnSkip = 48; gbBorderRowSkip = 40; } else { gbBorderLineSkip = 160; gbBorderColumnSkip = 0; gbBorderRowSkip = 0; } } else { } for(int i = 0; i < 0x10000; i++) { systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | (((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x7c00) >> 10) << systemBlueShift); } emulating = 1; soundInit(); while(emulating) { if(!paused) { if(debugger && emulator.emuHasDebugger) dbgMain(); else emulator.emuMain(emulator.emuCount); } } emulating = 0; fprintf(stderr,"Shutting down\n"); remoteCleanUp(); soundShutdown(); if(gbRom != NULL || rom != NULL) { emulator.emuCleanUp(); } return 0; } void systemMessage(int num, const char *msg, ...) { char buffer[2048]; va_list valist; va_start(valist, msg); vsprintf(buffer, msg, valist); fprintf(stderr, "%s\n", buffer); va_end(valist); } void systemDrawScreen() { } bool systemReadJoypads() { return true; } u32 systemReadJoypad(int) { return 0; } void systemShowSpeed(int speed) { } void system10Frames(int rate) { } void systemFrame() { } void systemSetTitle(const char *title) { } void systemScreenCapture(int a) { char buffer[2048]; if(captureFormat) { if(captureDir[0]) sprintf(buffer, "%s/%s%02d.bmp", captureDir, sdlGetFilename(filename), a); else sprintf(buffer, "%s%02d.bmp", filename, a); emulator.emuWriteBMP(buffer); } else { if(captureDir[0]) sprintf(buffer, "%s/%s%02d.png", captureDir, sdlGetFilename(filename), a); else sprintf(buffer, "%s%02d.png", filename, a); emulator.emuWritePNG(buffer); } systemScreenMessage("Screen capture"); } u32 systemReadJoypadExtended() { return 0; } void systemWriteDataToSoundBuffer() { } bool systemSoundInit() { return true; } void systemSoundShutdown() { } void systemSoundPause() { } void systemSoundResume() { } void systemSoundReset() { } static int ticks = 0; u32 systemGetClock() { return ticks++; } void systemUpdateMotionSensor() { } int systemGetSensorX() { return 0; } int systemGetSensorY() { return 0; } void systemGbPrint(u8 *data,int pages,int feed,int palette, int contrast) { } void systemScreenMessage(const char *msg) { } bool systemCanChangeSoundQuality() { return false; } bool systemPauseOnFrame() { return false; } void systemGbBorderOn() { } --- NEW FILE: Makefile.am --- bin_PROGRAMS = VisualBoyAdvance noinst_PROGRAMS = TestEmu VisualBoyAdvance_SOURCES = \ SDL.cpp \ debugger.cpp \ debugger.h \ ../2xSaI.cpp \ ../AutoBuild.h \ ../Cheats.cpp \ ../Cheats.h \ ../EEprom.cpp \ ../EEprom.h \ ../Flash.cpp \ ../Flash.h \ ../GBA.cpp \ ../GBA.h \ ../GBAinline.h \ ../Gfx.cpp \ ../Gfx.h \ ../Globals.cpp \ ../Globals.h \ ../Mode0.cpp \ ../Mode1.cpp \ ../Mode2.cpp \ ../Mode3.cpp \ ../Mode4.cpp \ ../Mode5.cpp \ ../NLS.h \ ../Port.h \ ../RTC.cpp \ ../RTC.h \ ../Sound.cpp \ ../Sound.h \ ../Sram.cpp \ ../Sram.h \ ../System.h \ ../Text.cpp \ ../Text.h \ ../Util.cpp \ ../Util.h \ ../admame.cpp \ ../agbprint.cpp \ ../agbprint.h \ ../arm-new.h \ ../armdis.cpp \ ../armdis.h \ ../bilinear.cpp \ ../bios.cpp \ ../bios.h \ ../elf.cpp \ ../elf.h \ ../expr-lex.cpp \ ../expr.cpp \ ../expr.cpp.h \ ../exprNode.cpp \ ../exprNode.h \ ../getopt.c \ ../getopt.h \ ../getopt1.c \ ../hq2x.cpp \ ../hq2x.h \ ../interframe.cpp \ ../interp.h \ ../lq2x.h \ ../memgzio.c \ ../memgzio.h \ ../motionblur.cpp \ ../pixel.cpp \ ../remote.cpp \ ../scanline.cpp \ ../simple2x.cpp \ ../thumb.h \ ../unzip.cpp \ ../unzip.h VisualBoyAdvance_LDADD = @VBA_LIBS@ @SDL_LIBS@ TestEmu_SOURCES = \ TestEmu.cpp \ debugger.cpp \ debugger.h \ ../2xSaI.cpp \ ../AutoBuild.h \ ../Cheats.cpp \ ../Cheats.h \ ../EEprom.cpp \ ../EEprom.h \ ../Flash.cpp \ ../Flash.h \ ../GBA.cpp \ ../GBA.h \ ../GBAinline.h \ ../Gfx.cpp \ ../Gfx.h \ ../Globals.cpp \ ../Globals.h \ ../Mode0.cpp \ ../Mode1.cpp \ ../Mode2.cpp \ ../Mode3.cpp \ ../Mode4.cpp \ ../Mode5.cpp \ ../NLS.h \ ../Port.h \ ../RTC.cpp \ ../RTC.h \ ../Sound.cpp \ ../Sound.h \ ../Sram.cpp \ ../Sram.h \ ../System.h \ ../Text.cpp \ ../Text.h \ ../Util.cpp \ ../Util.h \ ../admame.cpp \ ../agbprint.cpp \ ../agbprint.h \ ../arm-new.h \ ../armdis.cpp \ ../armdis.h \ ../bios.cpp \ ../bios.h \ ../elf.cpp \ ../elf.h \ ../expr-lex.cpp \ ../expr.cpp \ ../expr.cpp.h \ ../exprNode.cpp \ ../exprNode.h \ ../hq2x.cpp \ ../hq2x.h \ ../interp.h \ ../lq2x.h \ ../memgzio.c \ ../memgzio.h \ ../motionblur.cpp \ ../pixel.cpp \ ../remote.cpp \ ../scanline.cpp \ ../simple2x.cpp \ ../thumb.h \ ../unzip.cpp \ ../unzip.h TestEmu_LDADD = @VBA_LIBS@ @SDL_LIBS@ AM_CPPFLAGS = \ -I$(top_srcdir)/src \ -DSDL AM_CXXFLAGS = -fno-exceptions @SDL_CFLAGS@ --- NEW FILE: debugger.cpp --- /* * VisualBoyAdvanced - Nintendo Gameboy/GameboyAdvance (TM) emulator * Copyrigh(c) 1999-2002 Forgotten (vb...@em...) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <stdio.h> [...1415 lines suppressed...] continue; commandCount++; while((s = strtok(NULL, " \t\n"))) { commands[commandCount++] = s; if(commandCount == 10) break; } for(int j = 0; ; j++) { if(debuggerCommands[j].name == NULL) { printf("Unrecognized command %s. Type h for help.\n", commands[0]); break; } if(!strcmp(commands[0], debuggerCommands[j].name)) { debuggerCommands[j].function(commandCount, commands); break; } } } } --- NEW FILE: SDL.cpp --- /* * VisualBoyAdvanced - Nintendo Gameboy/GameboyAdvance (TM) emulator * Copyrigh(c) 1999-2002 Forgotten (vb...@em...) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include <stdarg.h> [...3402 lines suppressed...] } srcPitch = srcWidth * 2+4; } else { if(systemColorDepth != 32) filterFunction = NULL; RGB_LOW_BITS_MASK = 0x010101; if(systemColorDepth == 32) { Init_2xSaI(32); } for(int i = 0; i < 0x10000; i++) { systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | (((i & 0x3e0) >> 5) << systemGreenShift) | (((i & 0x7c00) >> 10) << systemBlueShift); } if(systemColorDepth == 32) srcPitch = srcWidth*4 + 4; else srcPitch = srcWidth*3; } } --- NEW FILE: Makefile.in --- # Makefile.in generated by automake 1.7.9 from Makefile.am. # @configure_input@ # Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 # Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ srcdir = @srcdir@ top_srcdir = @top_srcdir@ VPATH = @srcdir@ [...1494 lines suppressed...] ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS uninstall-info-am .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic clean-noinstPROGRAMS ctags distclean \ distclean-compile distclean-generic distclean-tags distdir dvi \ dvi-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-exec install-exec-am \ install-info install-info-am install-man install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS uninstall-info-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: --- NEW FILE: debugger.h --- /* * VisualBoyAdvanced - Nintendo Gameboy/GameboyAdvance (TM) emulator * Copyrigh(c) 1999-2002 Forgotten (vb...@em...) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ extern void debuggerMain(); |