diff --git a/Makefile b/Makefile index 72788be7..018cd93e 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ MACHINE= $(shell uname -s) CC=gcc CPPC=g++ -CFLAGS=-W -Wall -Wno-unused -O3 -DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DFINAL_VERSION -DBKPT_SUPPORT -DSDL -DSYSCONFDIR="home" -DUSE_OPENGL -DC_CORE +CFLAGS=-W -Wall -Wno-unused -O3 -DHAVE_NETINET_IN_H -DHAVE_ARPA_INET_H -DHAVE_ZLIB_H -DFINAL_VERSION -DBKPT_SUPPORT -DSDL -DSYSCONFDIR="home" -DUSE_OPENGL -DC_CORE CXXFLAGS=${CFLAGS} ASM=nasm ASMFLAGS=-w-orphan-labels -f elf -DELF -O1 -Isrc/hq/asm/ @@ -9,7 +9,7 @@ LFLAGS=-lz -lpng -lGL `sdl-config --libs` STRIP=strip -s DEL=rm -f OE=.o -OUT=vba +OUT=vbam ifeq ($(MACHINE),Darwin) LFLAGS=-lz -lpng -framework OpenGL `sdl-config --libs` @@ -20,7 +20,7 @@ ifeq ($(PLATFORM),win) LFLAGS=-lz -lpng -lSDL -lwsock32 -lopengl32 DELETECOMMAND = del OE=.obj - OUT=vba.exe + OUT=vbam.exe endif ifeq ($(PLATFORM),win-cross) @@ -30,7 +30,11 @@ ifeq ($(PLATFORM),win-cross) LFLAGS=-lz -lpng -lSDL -lwsock32 -lopengl32 STRIP=i586-mingw32-strip -s OE=.obj - OUT=vba.exe + OUT=vbam.exe +endif + +ifndef $(PREFIX) + PREFIX=/usr/local endif MAINDIR=src @@ -102,4 +106,8 @@ ${OUT}: ${OBJECTS} $(STRIP) $@ clean: - $(DEL) ${OUT} ${OBJECTS} + $(DEL) ${OUT} ${OBJECTS} + +install: ${OUT} + install -d $(DESTDIR)$(PREFIX)/bin + install ./${OUT} $(DESTDIR)$(PREFIX)/bin diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..546129bc --- /dev/null +++ b/debian/changelog @@ -0,0 +1,6 @@ +vbam (0.svn307-1) unstable; urgency=low + + * Initial release + + -- Bastien Bouclet Tue, 15 Jan 2008 13:31:45 +0100 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 00000000..3d2c52f7 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..615d1c4e --- /dev/null +++ b/debian/control @@ -0,0 +1,13 @@ +Source: vbam +Section: games +Priority: extra +Maintainer: Bastien Bouclet +Build-Depends: debhelper (>= 5), zlib1g-dev, libpng12-dev, libsdl1.2-dev, libgl1-mesa-dev +Standards-Version: 3.7.2 + +Package: vbam +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: Nintendo GameBoy Advance emulator + VBA-M is a Nintendo GameBoy Advance emulator. It runs homebrew and commercial games. + This version is based on the SDL library. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..5c786a9a --- /dev/null +++ b/debian/copyright @@ -0,0 +1,23 @@ +This package was debianized by Bastien Bouclet on +Tue, 15 Jan 2008 13:31:45 +0100. + +It was downloaded from https://vbam.bountysource.com/ + +Copyright: + + Copyright (C) 1999-2003 Forgotten + Copyright (C) 2004-2006 VBA development team + Copyright (C) 2007-2008 VBA-M development team + +License: + + VBA-M 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. + +On Debian systems, the complete text of the GNU General Public License +can be found in the '/usr/share/common-licenses/GPL' file. + +The Debian packaging is (C) 2008, Bastien Bouclet and +is licensed under the GPL, see `/usr/share/common-licenses/GPL'. diff --git a/debian/dirs b/debian/dirs new file mode 100644 index 00000000..454f2670 --- /dev/null +++ b/debian/dirs @@ -0,0 +1,2 @@ +usr/bin +usr/sbin diff --git a/debian/docs b/debian/docs new file mode 100644 index 00000000..1f4582a8 --- /dev/null +++ b/debian/docs @@ -0,0 +1 @@ +doc/* diff --git a/debian/rules b/debian/rules new file mode 100644 index 00000000..ece29377 --- /dev/null +++ b/debian/rules @@ -0,0 +1,90 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + + + + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif + +build: build-stamp + +build-stamp: + dh_testdir + + # No ASM optimized version since it is i386 specific + $(MAKE) + #docbook-to-man debian/vbam.sgml > vbam.1 + + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + + # Add here commands to clean up after the build process. + -$(MAKE) clean + + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + # Add here commands to install the package into debian/vbam. + $(MAKE) PREFIX=/usr DESTDIR=$(CURDIR)/debian/vbam install + + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples +# dh_install +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_python +# dh_installinit +# dh_installcron +# dh_installinfo + dh_installman + dh_link + dh_strip + dh_compress + dh_fixperms +# dh_perl +# dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install diff --git a/src/AutoBuild.h b/src/AutoBuild.h index 425c57b0..46bec5e7 100644 --- a/src/AutoBuild.h +++ b/src/AutoBuild.h @@ -20,7 +20,7 @@ #ifndef __AUTOBUILD_H__ #define __AUTOBUILD_H__ #ifndef VERSION -#define VERSION "1.8.0" +#define VERSION "1.8.0-SVN" #endif //change the FALSE to TRUE for autoincrement of build number #define INCREMENT_VERSION FALSE diff --git a/src/sdl/SDL.cpp b/src/sdl/SDL.cpp index cde63daf..fa12ce58 100644 --- a/src/sdl/SDL.cpp +++ b/src/sdl/SDL.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #ifdef __APPLE__ #include #include @@ -120,6 +121,8 @@ int srcWidth = 0; int srcHeight = 0; int destWidth = 0; int destHeight = 0; +int desktopWidth = 0; +int desktopHeight = 0; int sensorX = 2047; int sensorY = 2047; @@ -147,12 +150,13 @@ int RGB_LOW_BITS_MASK=0x821; u32 systemColorMap32[0x10000]; u16 systemColorMap16[0x10000]; u16 systemGbPalette[24]; -void (*filterFunction)(u8*,u32,u8*,u8*,u32,int,int) = NULL; +FilterFunc filterFunction = NULL; void (*ifbFunction)(u8*,u32,int,int) = NULL; int ifbType = 0; char filename[2048]; char ipsname[2048]; char biosFileName[2048]; +char gbBiosFileName[2048]; char captureDir[2048]; char saveDir[2048]; char batteryDir[2048]; @@ -412,11 +416,11 @@ FILE *sdlFindFile(const char *name) #ifdef _WIN32 #define PATH_SEP ";" #define FILE_SEP '\\' -#define EXE_NAME "VisualBoyAdvance-SDL.exe" +#define EXE_NAME "vbam.exe" #else // ! _WIN32 #define PATH_SEP ":" #define FILE_SEP '/' -#define EXE_NAME "VisualBoyAdvance" +#define EXE_NAME "vbam" #endif // ! _WIN32 fprintf(stderr, "Searching for file %s\n", name); @@ -652,6 +656,8 @@ void sdlReadPreferences(FILE *f) skipBios = sdlFromHex(value) ? true : false; } else if(!strcmp(key, "biosFile")) { strcpy(biosFileName, value); + } else if(!strcmp(key, "gbBiosFile")) { + strcpy(gbBiosFileName, value); } else if(!strcmp(key, "filter")) { filter = sdlFromHex(value); if(filter < 0 || filter > 17) @@ -790,9 +796,22 @@ void sdlOpenGLInit(int w, int h) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, openGL == 2 ? GL_LINEAR : GL_NEAREST); - textureSize = 256 * filter_enlarge; + // Calculate texture size as a the smallest working power of two + float n1 = log10((float)destWidth ) / log10( 2.0f); + float n2 = log10((float)destHeight ) / log10( 2.0f); + float n = (n1 > n2)? n1 : n2; + + // round up + if (((float)((int)n)) != n) + n = ((float)((int)n)) + 1.0f; + + textureSize = (int)pow(2.0f, n); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureSize, textureSize, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); + + glClearColor(0.0,0.0,0.0,1.0); + glClear( GL_COLOR_BUFFER_BIT ); } void sdlReadPreferences() @@ -998,8 +1017,16 @@ void sdlReadBattery() systemScreenMessage("Loaded battery"); } +void sdlReadDesktopVideoMode() { + const SDL_VideoInfo* vInfo = SDL_GetVideoInfo(); + desktopWidth = vInfo->current_w; + desktopHeight = vInfo->current_h; +} + void sdlInitVideo() { int flags; + int screenWidth; + int screenHeight; filter_enlarge = getFilterEnlargeFactor((Filter)filter); destWidth = filter_enlarge * srcWidth; @@ -1012,7 +1039,15 @@ void sdlInitVideo() { } else flags |= SDL_HWSURFACE | SDL_DOUBLEBUF; - surface = SDL_SetVideoMode(destWidth, destHeight, 0, flags); + if (fullscreen && openGL) { + screenWidth = desktopWidth; + screenHeight = desktopHeight; + } else { + screenWidth = destWidth; + screenHeight = destHeight; + } + + surface = SDL_SetVideoMode(screenWidth, screenHeight, 0, flags); if(surface == NULL) { systemMessage(0, "Failed to set video mode"); @@ -1020,12 +1055,6 @@ void sdlInitVideo() { exit(-1); } - if(openGL) { - free(filterPix); - filterPix = (u8 *)calloc(1, 4 * destWidth * destHeight); - sdlOpenGLInit(destWidth, destHeight); - } - systemRedShift = sdlCalculateShift(surface->format->Rmask); systemGreenShift = sdlCalculateShift(surface->format->Gmask); systemBlueShift = sdlCalculateShift(surface->format->Bmask); @@ -1040,6 +1069,13 @@ void sdlInitVideo() { else srcPitch = srcWidth*3; } + + if(openGL) { + free(filterPix); + filterPix = (u8 *)calloc(1, (systemColorDepth >> 3) * destWidth * destHeight); + sdlOpenGLInit(screenWidth, screenHeight); + } + } #define MOD_KEYS (KMOD_CTRL|KMOD_SHIFT|KMOD_ALT|KMOD_META) @@ -1573,7 +1609,7 @@ Long options only:\n\ int main(int argc, char **argv) { - fprintf(stderr, "VisualBoyAdvance version %s [SDL]\n", VERSION); + fprintf(stderr, "VBA-M version %s [SDL]\n", VERSION); arg0 = argv[0]; @@ -1821,16 +1857,7 @@ int main(int argc, char **argv) // used for the handling of the gb Boot Rom if (gbHardware & 5) - { - char tempName[0x800]; - strcpy(tempName, arg0); - char *p = strrchr(tempName, '\\'); - if(p) { *p = 0x00; } - strcat(tempName, "\\DMG_ROM.bin"); - fprintf(stderr, "%s\n", tempName); - gbCPUInit(tempName, useBios); - } - else useBios = false; + gbCPUInit(gbBiosFileName, useBios); gbReset(); cartridgeType = IMAGE_GB; @@ -1937,6 +1964,8 @@ int main(int argc, char **argv) srcHeight = 240; } + sdlReadDesktopVideoMode(); + sdlInitVideo(); filterFunction = initFilter((Filter)filter, systemColorDepth, srcWidth); @@ -2565,7 +2594,6 @@ bool systemPauseOnFrame() void systemGbBorderOn() { - long flags; srcWidth = 256; srcHeight = 224; gbBorderLineSkip = 256; @@ -2575,32 +2603,4 @@ void systemGbBorderOn() sdlInitVideo(); filterFunction = initFilter((Filter)filter, systemColorDepth, srcWidth); - - if(systemColorDepth == 16) { - if(sdlCalculateMaskWidth(surface->format->Gmask) == 6) { - RGB_LOW_BITS_MASK = 0x821; - } else { - RGB_LOW_BITS_MASK = 0x421; - } - if(cartridgeType == 2) { - for(int i = 0; i < 0x10000; i++) { - systemColorMap16[i] = (((i >> 1) & 0x1f) << systemBlueShift) | - (((i & 0x7c0) >> 6) << systemGreenShift) | - (((i & 0xf800) >> 11) << systemRedShift); - } - } else { - for(int i = 0; i < 0x10000; i++) { - systemColorMap16[i] = ((i & 0x1f) << systemRedShift) | - (((i & 0x3e0) >> 5) << systemGreenShift) | - (((i & 0x7c00) >> 10) << systemBlueShift); - } - } - } else { - RGB_LOW_BITS_MASK = 0x010101; - for(int i = 0; i < 0x10000; i++) { - systemColorMap32[i] = ((i & 0x1f) << systemRedShift) | - (((i & 0x3e0) >> 5) << systemGreenShift) | - (((i & 0x7c00) >> 10) << systemBlueShift); - } - } }