diff --git a/build_gcw0.sh b/build_gcw0.sh index b8aac0c..1727073 100755 --- a/build_gcw0.sh +++ b/build_gcw0.sh @@ -21,6 +21,6 @@ find . -type f -iname \*.o -delete find . -type f -iname gambatte_sdl -delete rm -f gambatte-dms-gcw0-r572u4-$BDAT.opk -mksquashfs ./dist/gcw0/default.gcw0.desktop ./gambatte_sdl/gambatte-dms.gcw0 ./dist/gcw0/gambatte_dms.png ./dist/gcw0/manual.txt gambatte-dms-gcw0-r572u4-$BDAT.opk -all-root -no-xattrs -noappend -no-exports +mksquashfs ./dist/gcw0/default.gcw0.desktop ./gambatte_sdl/gambatte-dms.gcw0 ./dist/gambatte_dms.png ./dist/manual.txt gambatte-dms-gcw0-r572u4-$BDAT.opk -all-root -no-xattrs -noappend -no-exports find . -type f -iname gambatte-dms.gcw0 -delete diff --git a/build_multi_opk.sh b/build_multi_opk.sh deleted file mode 100755 index 86e3063..0000000 --- a/build_multi_opk.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh - -BDAT=$(date +"%Y%m%d-%H%M%S") -echo '#define BUILDDATE "'$BDAT'"' >./gambatte_sdl/builddate.h - -echo "cd libgambatte && scons" -(cd libgambatte && scons -Q target=retrofw) || exit -echo "cd gambatte_sdl && scons" -(cd gambatte_sdl && scons -Q target=retrofw) -mv gambatte_sdl/gambatte_sdl gambatte_sdl/gambatte-dms.retrofw - -echo "cd gambatte_sdl && scons -c" -(cd gambatte_sdl && scons -c) -echo "cd libgambatte && scons -c" -(cd libgambatte && scons -c) -echo "rm -f *gambatte*/config.log" -rm -f *gambatte*/config.log -echo "rm -rf *gambatte*/.scon*" -rm -rf *gambatte*/.scon* -find . -type f -iname \*.o -delete -find . -type f -iname gambatte_sdl -delete - -echo "cd libgambatte && scons" -(cd libgambatte && scons -Q target=opendingux) || exit -echo "cd gambatte_sdl && scons" -(cd gambatte_sdl && scons -Q target=opendingux) -mv gambatte_sdl/gambatte_sdl gambatte_sdl/gambatte-dms.opendingux - -BDAT=$(date +"%Y%m%d") -rm -f gambatte-dms-multi-r572u4-$BDAT.opk -mksquashfs ./dist/gcw0/default.gcw0.desktop ./dist/retrofw/default.retrofw.desktop ./dist/retrofw/gb.retrofw.desktop ./dist/retrofw/gbc.retrofw.desktop ./gambatte_sdl/gambatte-dms.opendingux ./gambatte_sdl/gambatte-dms.retrofw ./dist/gcw0/gambatte_dms.png ./dist/retrofw/gambatte_dmg.png ./dist/retrofw/gambatte_gbc.png ./dist/gcw0/manual.txt ./dist/retrofw/gambatte.man.txt gambatte-dms-multi-r572u4-$BDAT.opk -all-root -no-xattrs -noappend -no-exports - -echo "cd gambatte_sdl && scons -c" -(cd gambatte_sdl && scons -c) -echo "cd libgambatte && scons -c" -(cd libgambatte && scons -c) -echo "rm -f *gambatte*/config.log" -rm -f *gambatte*/config.log -echo "rm -rf *gambatte*/.scon*" -rm -rf *gambatte*/.scon* -find . -type f -iname \*.o -delete -find . -type f -iname gambatte_sdl -delete - -find . -type f -iname gambatte-dms.retrofw -delete -find . -type f -iname gambatte-dms.opendingux -delete diff --git a/build_opendingux.sh b/build_opendingux.sh deleted file mode 100755 index a0f7bb0..0000000 --- a/build_opendingux.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -BDAT=$(date +"%Y%m%d-%H%M%S") -echo '#define BUILDDATE "'$BDAT'"' >./gambatte_sdl/builddate.h - -echo "cd libgambatte && scons" -(cd libgambatte && scons -Q target=opendingux) || exit -echo "cd gambatte_sdl && scons" -(cd gambatte_sdl && scons -Q target=opendingux) -mv gambatte_sdl/gambatte_sdl gambatte_sdl/gambatte-dms.opendingux - -rm -f gambatte-dms-opendingux-r572u4-$BDAT.opk - -mksquashfs ./dist/gcw0/default.gcw0.desktop ./gambatte_sdl/gambatte-dms.opendingux ./dist/gcw0/gambatte_dms.png ./dist/gcw0/manual.txt gambatte-dms-opendingux-r572u4-$BDAT.opk -all-root -no-xattrs -noappend -no-exports - -echo "cd gambatte_sdl && scons -c" -(cd gambatte_sdl && scons -c) -echo "cd libgambatte && scons -c" -(cd libgambatte && scons -c) -echo "rm -f *gambatte*/config.log" -rm -f *gambatte*/config.log -echo "rm -rf *gambatte*/.scon*" -rm -rf *gambatte*/.scon* -find . -type f -iname \*.o -delete -find . -type f -iname gambatte_sdl -delete - -find . -type f -iname gambatte-dms.opendingux -delete diff --git a/build_retrofw.sh b/build_retrofw.sh deleted file mode 100755 index 53b826e..0000000 --- a/build_retrofw.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -BDAT=$(date +"%Y%m%d-%H%M%S") -echo '#define BUILDDATE "'$BDAT'"' >./gambatte_sdl/builddate.h - -echo "cd libgambatte && scons" -(cd libgambatte && scons -Q target=retrofw) || exit -echo "cd gambatte_sdl && scons" -(cd gambatte_sdl && scons -Q target=retrofw) - -rm -rf /tmp/.gambatte-ipk/ && mkdir -p /tmp/.gambatte-ipk/root/home/retrofw/emus/gambatte /tmp/.gambatte-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators /tmp/.gambatte-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators.systems -cp dist/retrofw/gambatte.man.txt dist/retrofw/gambatte_dms.png dist/retrofw/gambatte_dmg.png dist/retrofw/gambatte_gbc.png /tmp/.gambatte-ipk/root/home/retrofw/emus/gambatte -cp gambatte_sdl/gambatte_sdl /tmp/.gambatte-ipk/root/home/retrofw/emus/gambatte/gambatte-dms.dge -cp dist/retrofw/gambatte.lnk /tmp/.gambatte-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators -cp dist/retrofw/gb.gambatte.lnk dist/retrofw/gbc.gambatte.lnk /tmp/.gambatte-ipk/root/home/retrofw/apps/gmenu2x/sections/emulators.systems -sed "s/^Version:.*/Version: `date +%Y%m%d`/" dist/retrofw/control > /tmp/.gambatte-ipk/control -tar --owner=0 --group=0 -czvf /tmp/.gambatte-ipk/control.tar.gz -C /tmp/.gambatte-ipk/ control -tar --owner=0 --group=0 -czvf /tmp/.gambatte-ipk/data.tar.gz -C /tmp/.gambatte-ipk/root/ . -echo 2.0 > /tmp/.gambatte-ipk/debian-binary -ar r gambatte-dms-retrofw-r572u4-$BDAT.ipk /tmp/.gambatte-ipk/control.tar.gz /tmp/.gambatte-ipk/data.tar.gz /tmp/.gambatte-ipk/debian-binary - -echo "cd gambatte_sdl && scons -c" -(cd gambatte_sdl && scons -c) -echo "cd libgambatte && scons -c" -(cd libgambatte && scons -c) -echo "rm -f *gambatte*/config.log" -rm -f *gambatte*/config.log -echo "rm -rf *gambatte*/.scon*" -rm -rf *gambatte*/.scon* -find . -type f -iname \*.o -delete -find . -type f -iname gambatte_sdl -delete diff --git a/build_retrofw_opk.sh b/build_retrofw_opk.sh index f4321b0..68f262e 100755 --- a/build_retrofw_opk.sh +++ b/build_retrofw_opk.sh @@ -21,6 +21,6 @@ find . -type f -iname \*.o -delete find . -type f -iname gambatte_sdl -delete rm -f gambatte-dms-retrofw-r572u4-$BDAT.opk -mksquashfs ./dist/gcw0/default.gcw0.desktop ./gambatte_sdl/gambatte-dms.gcw0 ./dist/gcw0/gambatte_dms.png ./dist/manual.txt gambatte-dms-gcw0-r572u4-$BDAT.opk -all-root -no-xattrs -noappend -no-exports +mksquashfs ./dist/retrofw/default.retrofw.desktop ./dist/retrofw/gb.retrofw.desktop ./dist/retrofw/gbc.retrofw.desktop ./gambatte_sdl/gambatte-dms.retrofw ./dist/gambatte_dms.png ./dist/gambatte_dmg.png ./dist/gambatte_gbc.png ./dist/manual.txt gambatte-dms-retrofw-r572u4-$BDAT.opk -all-root -no-xattrs -noappend -no-exports find . -type f -iname gambatte-dms.retrofw -delete diff --git a/build_rg350m.sh b/build_rg350m.sh deleted file mode 100755 index 4d7748f..0000000 --- a/build_rg350m.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -BDAT=$(date +"%Y%m%d-%H%M%S") -echo '#define BUILDDATE "'$BDAT'"' >./gambatte_sdl/builddate.h - -echo "cd libgambatte && scons" -(cd libgambatte && scons -Q target=rg350m) || exit -echo "cd gambatte_sdl && scons" -(cd gambatte_sdl && scons -Q target=rg350m) -mv gambatte_sdl/gambatte_sdl gambatte_sdl/gambatte-dms.opendingux - -rm -f gambatte-dms-rg350m-r572u4-$BDAT.opk - -mksquashfs ./dist/gcw0/default.gcw0.desktop ./gambatte_sdl/gambatte-dms.opendingux ./dist/gcw0/gambatte_dms.png ./dist/gcw0/manual.txt gambatte-dms-rg350m-r572u4-$BDAT.opk -all-root -no-xattrs -noappend -no-exports - -echo "cd gambatte_sdl && scons -c" -(cd gambatte_sdl && scons -c) -echo "cd libgambatte && scons -c" -(cd libgambatte && scons -c) -echo "rm -f *gambatte*/config.log" -rm -f *gambatte*/config.log -echo "rm -rf *gambatte*/.scon*" -rm -rf *gambatte*/.scon* -find . -type f -iname \*.o -delete -find . -type f -iname gambatte_sdl -delete - -find . -type f -iname gambatte-dms.opendingux -delete diff --git a/dist/gcw0/default.gcw0.desktop b/dist/gcw0/default.gcw0.desktop index b89435a..e13e044 100644 --- a/dist/gcw0/default.gcw0.desktop +++ b/dist/gcw0/default.gcw0.desktop @@ -1,11 +1,12 @@ [Desktop Entry] Name=Gambatte-DMS Comment=GB/GBC emulator -Exec=gambatte-dms.opendingux %f +Exec=gambatte-dms.gcw0 %f Terminal=false Type=Application StartupNotify=true Icon=gambatte_dms Categories=emulators; +X-OD-NeedsDownscaling=true X-OD-Manual=manual.txt MimeType=application/x-gameboy-rom;application/x-gbc-rom;application/x-gameboy-color-rom;application/x-gzip;application/zip;application/gzip; diff --git a/dist/gcw0/gambatte_dms.png b/dist/gcw0/gambatte_dms.png deleted file mode 100644 index a32239e..0000000 Binary files a/dist/gcw0/gambatte_dms.png and /dev/null differ diff --git a/dist/gcw0/manual.txt b/dist/gcw0/manual.txt deleted file mode 100644 index cf5f924..0000000 --- a/dist/gcw0/manual.txt +++ /dev/null @@ -1,266 +0,0 @@ - -Gambatte-DMS emulator for OpenDingux devices ------------------------------------------------- - -Gambatte is an accuracy-focused, open-source, -cross-platform Game Boy Color emulator written -in C++. It is based on hundreds of corner case -hardware tests, as well as previous documentation -and reverse engineering efforts. - - -Default Ingame Controls ------------------------------------------------- - -D-PAD D-PAD -B Button B Button -A Button A Button -Select Select -Start Start -R trigger / POWER Menu -L trigger Fast Forward - - -General Menu Controls ------------------------------------------------- - -D-PAD Move cursor -B Button Go back / Cancel -A Button Select / Perform action - - -Save States ------------------------------------------------- - -There are 10 savestate slots available per game. -There are options in the menu for loading and -saving states. - -The default slot is always Slot 0. - -The default slot will always be selected when -starting the emulator. Selected savestate slot -will not be saved on emulator exit. - - -Emulator Options ------------------------------------------------- - -Here is a list of the available config options: - -- Show FPS: - Shows or hides the FPS counter. - Default is "Off". - -- Scaler: - Allows to select between a range of scalers. - Default is "No Scaling". - -- Mono Palette: - Allows to load external palette files for - use with monochrome GB games in DMG mode. - The "Auto" option will try to find a palette - with the same name as the ROM file, and it - will load the default palette if it fails. - -- Color Filter: - Allows to load external filter files for - use with color games in GBC mode. - -- DMG/GBC border: - Allows to load external PNG border images - for use in DMG/GBC mode. - The "Auto" option will try to find a border - with the same name as the ROM file, and it - will load the default border if it fails. - -- System: - Allows to select the system priority when - a ROM supports both DMG and GBC modes. - -- Boot Logos: - Allows to use GB/GBC BIOS files to display - the splashscreen logo when loading a game. - -- Ghosting: - Enables or disables frame mixing to mimic - the DMG LCD ghosting. - Default is "DMG only". - -- Controls: - Allows the user to tune the controls. - -- Sound: - Allows the user to select between Mono and - Stereo sound. - Default is "Mono". - - -Palette files ------------------------------------------------- - -Palette files are text files with the extension -".pal" and its format must be: - -0xRRGGBB 0xRRGGBB 0xRRGGBB 0xRRGGBB -0xRRGGBB 0xRRGGBB 0xRRGGBB 0xRRGGBB -0xRRGGBB 0xRRGGBB 0xRRGGBB 0xRRGGBB - -Where each line is a separate 4-color palette -for each sprite layer, and the color order is: -"white" "light-grey" "dark-grey" "black". - - -Filter files ------------------------------------------------- - -Filter files are text files with the extension -".fil" and its format must be: - -a1 a2 a3 a4 -b1 b2 b3 b4 -c1 c2 c3 c4 - -Where each value is a decimal number, ranging -from -255 to 255 which gets applied to the -GBC colors using the following algorithm: - -Rfinal = ((( R*a1 + G*a2 + B*a3 ) >> 8 ) + a4) -Gfinal = ((( R*b1 + G*b2 + B*b3 ) >> 8 ) + b4) -Bfinal = ((( R*c1 + G*c2 + B*c3 ) >> 8 ) + c4) - -A general rule to avoid the resulting colors -exceeding the valid RGB range of 0-255 is that -the sum of the 4 values in a row should always -be between 0-255. - - -File Paths ------------------------------------------------- - -- Emulator Settings are saved in: - $HOME/.gambatte/settings/ - -- Savestates and game saves are stored in: - $HOME/.gambatte/saves/ - -- Palette files must be stored in: - $HOME/.gambatte/palettes/ - -- Filter files must be stored in: - $HOME/.gambatte/filters/ - -- Border images must be stored in: - $HOME/.gambatte/borders/ - -- BIOS files must be stored in: - $HOME/.gambatte/bios/ - -- Valid BIOS filenames are: - gb_bios.bin - gbc_bios.bin - - -Cheats ------------------------------------------------- - -Gambatte supports Game Genie and Game Shark -cheat codes. Each cheat system has its own menu. - -Game Genie cheats: ------------------------- - -Game Genie codes can have 6 or 9 digits. They -are applied once each and they can only be -disabled by exiting the emulator and reloading -the ROM. - -To introduce a code, go to the Game Genie menu, -highlight a code line and press A to enter edit -mode. While in edit mode you can change the -value of each digit by using the D-Pad. -When you're done, press A to save the changes -or B do discard them. - -If you're introducing a 6-digit code, just leave -the last 3 digits as zeroes and your code will -be detected as a 6-digit code. If all digits are -zeroes, the code is ignored. - -There are up to 20 lines for introducing several -codes at once if you need to. - -To apply the cheats, press Start, and then -confirm the action by pressing A. The codes will -then be applied and the code list will be -cleared. - -Cheat codes are not saved on emulator exit. - -Game Shark cheats: ------------------------- - -Game Shark codes have 8 digits. They can be -enabled and disabled at any time. - -To introduce a code, go to the Game Shark menu, -highlight a code line and press A to enter edit -mode. While in edit mode you can change the -value of each digit by using the D-Pad. -When you're done, press A to save the changes -or B do discard them. - -If all digits are zeroes, the code is ignored. - -There are up to 20 lines for introducing several -codes. - -To enable the cheats, select the slot on the -left of the codes and press A to toggle the -desired cheat on and off. An empty slot means -the cheat code is disabled, while a check mark -means it is enabled. - -Cheat codes are not saved on emulator exit. - - -Credits ------------------------------------------------- -Gambatte emulator - -Copyright (C) 2007 by Sindre Aamås -aamas@stud.ntnu.no - -This program is free software; you can -redistribute it and/or modify it under the terms -of the GNU General Public License version 2 as -published by the Free Software Foundation. - -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 -version 2 for more details. - -You should have received a copy of the GNU -General Public License version 2 along with this -program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA - ------------------------------------------------- - -Additional features and menu rework from the -Gambatte-DMS version by Hi-Ban. -Special thanks to Surkow, Senquack and Pingflood -for helping this noob. -Source code available at: -https://github.com/bardeci/dot-matrix-simulator - ------------------------------------------------- - -Game Boy and Game Boy Color are registered -trademarks of Nintendo of America Inc. -Gambatte is not affiliated with or endorsed by -any of the companies mentioned. diff --git a/dist/retrofw/default.retrofw.desktop b/dist/retrofw/default.retrofw.desktop index bfedd16..081c578 100644 --- a/dist/retrofw/default.retrofw.desktop +++ b/dist/retrofw/default.retrofw.desktop @@ -7,6 +7,6 @@ Type=Application StartupNotify=true Icon=gambatte_dms Categories=emulators; -X-OD-Manual=gambatte.man.txt +X-OD-Manual=manual.txt X-OD-Selector=/home/retrofw/roms/gb X-OD-Filter=.zip,.gb,.gbc diff --git a/dist/retrofw/gambatte.man.txt b/dist/retrofw/gambatte.man.txt deleted file mode 100644 index 8eff66d..0000000 --- a/dist/retrofw/gambatte.man.txt +++ /dev/null @@ -1,266 +0,0 @@ - -Gambatte-DMS emulator for RetroFW devices ------------------------------------------------- - -Gambatte is an accuracy-focused, open-source, -cross-platform Game Boy Color emulator written -in C++. It is based on hundreds of corner case -hardware tests, as well as previous documentation -and reverse engineering efforts. - - -Default Ingame Controls ------------------------------------------------- - -D-PAD D-PAD -B Button B Button -A Button A Button -Select Select -Start Start -R trigger / POWER Menu -L trigger Fast Forward - - -General Menu Controls ------------------------------------------------- - -D-PAD Move cursor -B Button Go back / Cancel -A Button Select / Perform action - - -Save States ------------------------------------------------- - -There are 10 savestate slots available per game. -There are options in the menu for loading and -saving states. - -The default slot is always Slot 0. - -The default slot will always be selected when -starting the emulator. Selected savestate slot -will not be saved on emulator exit. - - -Emulator Options ------------------------------------------------- - -Here is a list of the available config options: - -- Show FPS: - Shows or hides the FPS counter. - Default is "Off". - -- Scaler: - Allows to select between a range of scalers. - Default is "No Scaling". - -- Mono Palette: - Allows to load external palette files for - use with monochrome GB games in DMG mode. - The "Auto" option will try to find a palette - with the same name as the ROM file, and it - will load the default palette if it fails. - -- Color Filter: - Allows to load external filter files for - use with color games in GBC mode. - -- DMG/GBC border: - Allows to load external PNG border images - for use in DMG/GBC mode. - The "Auto" option will try to find a border - with the same name as the ROM file, and it - will load the default border if it fails. - -- System: - Allows to select the system priority when - a ROM supports both DMG and GBC modes. - -- Boot Logos: - Allows to use GB/GBC BIOS files to display - the splashscreen logo when loading a game. - -- Ghosting: - Enables or disables frame mixing to mimic - the DMG LCD ghosting. - Default is "DMG only". - -- Controls: - Allows the user to tune the controls. - -- Sound: - Allows the user to select between Mono and - Stereo sound. - Default is "Mono". - - -Palette files ------------------------------------------------- - -Palette files are text files with the extension -".pal" and its format must be: - -0xRRGGBB 0xRRGGBB 0xRRGGBB 0xRRGGBB -0xRRGGBB 0xRRGGBB 0xRRGGBB 0xRRGGBB -0xRRGGBB 0xRRGGBB 0xRRGGBB 0xRRGGBB - -Where each line is a separate 4-color palette -for each sprite layer, and the color order is: -"white" "light-grey" "dark-grey" "black". - - -Filter files ------------------------------------------------- - -Filter files are text files with the extension -".fil" and its format must be: - -a1 a2 a3 a4 -b1 b2 b3 b4 -c1 c2 c3 c4 - -Where each value is a decimal number, ranging -from -255 to 255 which gets applied to the -GBC colors using the following algorithm: - -Rfinal = ((( R*a1 + G*a2 + B*a3 ) >> 8 ) + a4) -Gfinal = ((( R*b1 + G*b2 + B*b3 ) >> 8 ) + b4) -Bfinal = ((( R*c1 + G*c2 + B*c3 ) >> 8 ) + c4) - -A general rule to avoid the resulting colors -exceeding the valid RGB range of 0-255 is that -the sum of the 4 values in a row should always -be between 0-255. - - -File Paths ------------------------------------------------- - -- Emulator Settings are saved in: - $HOME/.gambatte/settings/ - -- Savestates and game saves are stored in: - $HOME/.gambatte/saves/ - -- Palette files must be stored in: - $HOME/.gambatte/palettes/ - -- Filter files must be stored in: - $HOME/.gambatte/filters/ - -- Border images must be stored in: - $HOME/.gambatte/borders/ - -- BIOS files must be stored in: - $HOME/.gambatte/bios/ - -- Valid BIOS filenames are: - gb_bios.bin - gbc_bios.bin - - -Cheats ------------------------------------------------- - -Gambatte supports Game Genie and Game Shark -cheat codes. Each cheat system has its own menu. - -Game Genie cheats: ------------------------- - -Game Genie codes can have 6 or 9 digits. They -are applied once each and they can only be -disabled by exiting the emulator and reloading -the ROM. - -To introduce a code, go to the Game Genie menu, -highlight a code line and press A to enter edit -mode. While in edit mode you can change the -value of each digit by using the D-Pad. -When you're done, press A to save the changes -or B do discard them. - -If you're introducing a 6-digit code, just leave -the last 3 digits as zeroes and your code will -be detected as a 6-digit code. If all digits are -zeroes, the code is ignored. - -There are up to 20 lines for introducing several -codes at once if you need to. - -To apply the cheats, press Start, and then -confirm the action by pressing A. The codes will -then be applied and the code list will be -cleared. - -Cheat codes are not saved on emulator exit. - -Game Shark cheats: ------------------------- - -Game Shark codes have 8 digits. They can be -enabled and disabled at any time. - -To introduce a code, go to the Game Shark menu, -highlight a code line and press A to enter edit -mode. While in edit mode you can change the -value of each digit by using the D-Pad. -When you're done, press A to save the changes -or B do discard them. - -If all digits are zeroes, the code is ignored. - -There are up to 20 lines for introducing several -codes. - -To enable the cheats, select the slot on the -left of the codes and press A to toggle the -desired cheat on and off. An empty slot means -the cheat code is disabled, while a check mark -means it is enabled. - -Cheat codes are not saved on emulator exit. - - -Credits ------------------------------------------------- -Gambatte emulator - -Copyright (C) 2007 by Sindre Aamås -aamas@stud.ntnu.no - -This program is free software; you can -redistribute it and/or modify it under the terms -of the GNU General Public License version 2 as -published by the Free Software Foundation. - -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 -version 2 for more details. - -You should have received a copy of the GNU -General Public License version 2 along with this -program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place - Suite 330, -Boston, MA 02111-1307, USA - ------------------------------------------------- - -Additional features and menu rework from the -Gambatte-DMS version by Hi-Ban. -Special thanks to Surkow, Senquack and Pingflood -for helping this noob. -Source code available at: -https://github.com/bardeci/dot-matrix-simulator - ------------------------------------------------- - -Game Boy and Game Boy Color are registered -trademarks of Nintendo of America Inc. -Gambatte is not affiliated with or endorsed by -any of the companies mentioned. diff --git a/dist/retrofw/gambatte_dmg.png b/dist/retrofw/gambatte_dmg.png deleted file mode 100644 index 03b97f3..0000000 Binary files a/dist/retrofw/gambatte_dmg.png and /dev/null differ diff --git a/dist/retrofw/gambatte_dms.png b/dist/retrofw/gambatte_dms.png deleted file mode 100644 index a32239e..0000000 Binary files a/dist/retrofw/gambatte_dms.png and /dev/null differ diff --git a/dist/retrofw/gambatte_gbc.png b/dist/retrofw/gambatte_gbc.png deleted file mode 100644 index 5434073..0000000 Binary files a/dist/retrofw/gambatte_gbc.png and /dev/null differ diff --git a/dist/retrofw/gb.retrofw.desktop b/dist/retrofw/gb.retrofw.desktop index 5be581e..6c642e8 100644 --- a/dist/retrofw/gb.retrofw.desktop +++ b/dist/retrofw/gb.retrofw.desktop @@ -7,6 +7,6 @@ Type=Application StartupNotify=true Icon=gambatte_dmg Categories=emulators.systems; -X-OD-Manual=gambatte.man.txt +X-OD-Manual=manual.txt X-OD-Selector=/home/retrofw/roms/gb X-OD-Filter=.zip,.gb diff --git a/dist/retrofw/gbc.retrofw.desktop b/dist/retrofw/gbc.retrofw.desktop index 84877c5..c955085 100644 --- a/dist/retrofw/gbc.retrofw.desktop +++ b/dist/retrofw/gbc.retrofw.desktop @@ -7,6 +7,6 @@ Type=Application StartupNotify=true Icon=gambatte_gbc Categories=emulators.systems; -X-OD-Manual=gambatte.man.txt +X-OD-Manual=manual.txt X-OD-Selector=/home/retrofw/roms/gbc X-OD-Filter=.zip,.gbc diff --git a/gambatte_sdl/SConstruct b/gambatte_sdl/SConstruct index a06e5a1..6ee9c2f 100644 --- a/gambatte_sdl/SConstruct +++ b/gambatte_sdl/SConstruct @@ -3,20 +3,13 @@ # -DPOWEROFF: Replaces the "Quit" option with a "Power Off" option. target = ARGUMENTS.get('target', 0) -if target == 'opendingux': +if target == 'gcw0': include_path = ' -I/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include' bin_path = '/opt/gcw0-toolchain/usr/bin/mipsel-linux-' sdl_path = '/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/bin/' - version_defines = ' -DVERSION_OPENDINGUX' + version_defines = ' -DVERSION_GCW0' extra_cflags = '' - print "Building Gambatte SDL with OpenDingux toolchain..." -elif target == 'rg350m': - include_path = ' -I/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include' - bin_path = '/opt/gcw0-toolchain/usr/bin/mipsel-linux-' - sdl_path = '/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/bin/' - version_defines = ' -DVERSION_OPENDINGUX -DVGA_SCREEN' - extra_cflags = '' - print "Building Gambatte SDL with OpenDingux toolchain..." + print "Building Gambatte SDL with GCW0 toolchain..." elif target == 'retrofw': include_path = ' -I/opt/rs97-toolchain/mipsel-buildroot-linux-uclibc/sysroot/usr/include' bin_path = '/opt/rs97-toolchain/bin/mipsel-linux-' diff --git a/gambatte_sdl/builddate.h b/gambatte_sdl/builddate.h index 39efb59..499c345 100644 --- a/gambatte_sdl/builddate.h +++ b/gambatte_sdl/builddate.h @@ -1 +1 @@ -#define BUILDDATE "20201209-193305" +#define BUILDDATE "20210421-010751" diff --git a/gambatte_sdl/libmenu.cpp b/gambatte_sdl/libmenu.cpp index a97ee83..ad50ac4 100644 --- a/gambatte_sdl/libmenu.cpp +++ b/gambatte_sdl/libmenu.cpp @@ -56,10 +56,10 @@ Mix_Chunk *menusound_move = NULL; Mix_Chunk *menusound_ok = NULL; // Default config values -int selectedscaler = 0, showfps = 0, ghosting = 1, biosenabled = 0, colorfilter = 0, gameiscgb = 0, buttonlayout = 0, stereosound = 0, prefercgb = 0, ffwhotkey = 1; +int showfps = 0, ghosting = 1, biosenabled = 0, colorfilter = 0, gameiscgb = 0, buttonlayout = 0, stereosound = 1, prefercgb = 0, ffwhotkey = 1; uint32_t menupalblack = 0x000000, menupaldark = 0x505450, menupallight = 0xA8A8A8, menupalwhite = 0xF8FCF8; int filtervalue[12] = {135, 20, 0, 25, 0, 125, 20, 25, 0, 20, 105, 30}; -std::string dmgbordername = "DEFAULT", gbcbordername = "DEFAULT", palname = "DEFAULT", filtername = "NONE", currgamename = "default"; +std::string selectedscaler= "No Scaling", dmgbordername = "DEFAULT", gbcbordername = "DEFAULT", palname = "DEFAULT", filtername = "NONE", currgamename = "default"; std::string homedir = getenv("HOME"); std::string ipuscaling = "NONE"; int numcodes_gg = NUM_GG_CODES, numcodes_gs = NUM_GS_CODES, selectedcode = 0, editmode = 0, blink = 0, footer_alt = 0; @@ -261,7 +261,7 @@ void clearAllCheats(){ // NOTE: This does not turn off cheats from the game, it } void openMenuAudio(){ -#ifdef VERSION_OPENDINGUX +#ifdef VERSION_GCW0 Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 1792); #elif VERSION_RETROFW Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 1024); @@ -1331,22 +1331,32 @@ void free_menusurfaces(){ //currently unused SDL_FreeSurface(textoverlaycolored); } -int currentEntryInList(menu_t *menu, std::string fname){ - if(fname == "NONE"){ - return 0; - } else if (fname == "DEFAULT"){ - return 1; - } else if (fname == "AUTO"){ - return 2; +int currentEntryInList(menu_t *menu, std::string fname, int isfile){ + if (isfile == 1){ + if(fname == "NONE"){ + return 0; + } else if (fname == "DEFAULT"){ + return 1; + } else if (fname == "AUTO"){ + return 2; + } + fname = fname.substr(0, fname.length() - 4); + int count = menu->n_entries; + int i; + for (i = 0; i < count; ++i) { + if(strcmp(fname.c_str(), menu->entries[i]->text) == 0){ + return i; + } + } + } else if (isfile == 0){ + int count = menu->n_entries; + int i; + for (i = 0; i < count; ++i) { + if(strcmp(fname.c_str(), menu->entries[i]->text) == 0){ + return i; + } + } } - fname = fname.substr(0, fname.length() - 4); - int count = menu->n_entries; - int i; - for (i = 0; i < count; ++i) { - if(strcmp(fname.c_str(), menu->entries[i]->text) == 0){ - return i; - } - } return 0; } @@ -1372,34 +1382,51 @@ void paint_titlebar(SDL_Surface *surface){ } void createBorderSurface(){ - switch(selectedscaler) { - case 5: /* Ayla's fullscreen scaler */ - case 6: /* Bilinear fullscreen scaler */ - case 11: /* Hardware Fullscreen */ -#ifdef VGA_SCREEN - case 14: /* CRT Fullscreen scaler */ - borderimg = SDL_CreateRGBSurface(SDL_SWSURFACE, 8, 8, 16, 0, 0, 0, 0); - break; - case 12: /* Dot Matrix 3x scaler */ - case 13: /* CRT 3x scaler */ -#endif - case 1: /* Ayla's 1.5x scaler */ - case 2: /* Bilinear 1.5x scaler */ - borderimg = SDL_CreateRGBSurface(SDL_SWSURFACE, 212, 160, 16, 0, 0, 0, 0); - break; - case 3: /* Fast 1.66x scaler */ - case 4: /* Bilinear 1.66x scaler */ - borderimg = SDL_CreateRGBSurface(SDL_SWSURFACE, 192, 144, 16, 0, 0, 0, 0); - break; - case 0: /* no scaler */ - case 7: /* Hardware 1.25x */ - case 8: /* Hardware 1.36x */ - case 9: /* Hardware 1.5x */ - case 10: /* Hardware 1.66x */ - default: - borderimg = SDL_CreateRGBSurface(SDL_SWSURFACE, 320, 240, 16, 0, 0, 0, 0); - break; + if (selectedscaler == "FullScreen Fast" || + selectedscaler == "FullScreen Smooth" || + selectedscaler == "FullScreen IPU" || + selectedscaler == "FullScreen IPU-2x" || + selectedscaler == "FullScreen DMG-2x" || + selectedscaler == "FullScreen DMG-3x" || + selectedscaler == "FullScreen Scan-2x" || + selectedscaler == "FullScreen Scan-3x") + { + borderimg = SDL_CreateRGBSurface(SDL_SWSURFACE, 8, 8, 16, 0, 0, 0, 0); + } + else if (selectedscaler == "1.5x IPU-2x" || + selectedscaler == "1.5x DMG-2x" || + selectedscaler == "1.5x Scan-2x") + { + borderimg = SDL_CreateRGBSurface(SDL_SWSURFACE, 214, 160, 16, 0, 0, 0, 0); + } + else if (selectedscaler == "1.5x Fast" || + selectedscaler == "1.5x Smooth" || + selectedscaler == "1.5x DMG-3x" || + selectedscaler == "1.5x Scan-3x") + { + borderimg = SDL_CreateRGBSurface(SDL_SWSURFACE, 212, 160, 16, 0, 0, 0, 0); + } + else if (selectedscaler == "Aspect 1.66x Fast" || + selectedscaler == "Aspect 1.66x Smooth" || + selectedscaler == "Aspect IPU-2x" || + selectedscaler == "Aspect DMG-2x" || + selectedscaler == "Aspect DMG-3x" || + selectedscaler == "Aspect Scan-2x" || + selectedscaler == "Aspect Scan-3x") + { + borderimg = SDL_CreateRGBSurface(SDL_SWSURFACE, 192, 144, 16, 0, 0, 0, 0); + } + else if (selectedscaler == "No Scaling" || + selectedscaler == "1.5x IPU" || + selectedscaler == "Aspect IPU") + { + borderimg = SDL_CreateRGBSurface(SDL_SWSURFACE, 320, 240, 16, 0, 0, 0, 0); + } + else + { + borderimg = SDL_CreateRGBSurface(SDL_SWSURFACE, 320, 240, 16, 0, 0, 0, 0); } + if(gameiscgb == 0){ if(dmgbordername != "NONE") { clear_surface(borderimg, convert_hexcolor(borderimg, menupalwhite)); @@ -1501,118 +1528,146 @@ void paint_border(SDL_Surface *surface){ SDL_Rect rect, rectb; uint32_t barcolor = SDL_MapRGB(surface->format, 0, 0, 0); int bpp = surface->format->BytesPerPixel; - switch(selectedscaler) { - case 0: /* no scaler */ - rect.x = 0; - rect.y = 0; - rect.w = 320; - rect.h = 240; - SDL_BlitSurface(borderimg, &rect, surface, NULL); - break; - case 1: /* Ayla's 1.5x scaler */ - case 2: /* Bilinear 1.5x scaler */ - rect.x = 0; - rect.y = 0; - rect.w = 1; - rect.h = 240; - rectb.x = 319; - rectb.y = 0; - rectb.w = 1; - rectb.h = 240; - SDL_FillRect(surface, &rect, barcolor); - SDL_FillRect(surface, &rectb, barcolor); - offset = 1; - scaleborder15x((uint32_t*)((uint8_t *)surface->pixels + offset * bpp), (uint32_t*)borderimg->pixels); - break; - case 3: /* Fast 1.66x scaler */ - case 4: /* Bilinear 1.66x scaler */ - scaleborder166x((uint32_t*)((uint8_t *)surface->pixels), (uint32_t*)borderimg->pixels); - rect.x = 0; - rect.y = 0; - rect.w = 1; - rect.h = 240; - rectb.x = 319; - rectb.y = 0; - rectb.w = 1; - rectb.h = 240; - SDL_FillRect(surface, &rect, barcolor); - SDL_FillRect(surface, &rectb, barcolor); - break; - case 7: /* Hardware 1.25x */ - rect.x = 32; - rect.y = 24; - rect.w = 256; - rect.h = 192; - SDL_BlitSurface(borderimg, &rect, surface, NULL); - break; - case 8: /* Hardware 1.36x */ - rect.x = 48; - rect.y = 32; - rect.w = 224; - rect.h = 176; - SDL_BlitSurface(borderimg, &rect, surface, NULL); - break; - case 9: /* Hardware 1.5x */ - rect.x = 56; - rect.y = 40; - rect.w = 208; - rect.h = 160; - SDL_BlitSurface(borderimg, &rect, surface, NULL); - break; - case 10: /* Hardware 1.66x*/ - rect.x = 64; - rect.y = 48; - rect.w = 192; - rect.h = 144; - SDL_BlitSurface(borderimg, &rect, surface, NULL); - break; -#ifdef VGA_SCREEN - case 12: /* Dot Matrix 3x scaler */ - rect.x = 0; - rect.y = 0; - rect.w = 2; - rect.h = 480; - rectb.x = 638; - rectb.y = 0; - rectb.w = 2; - rectb.h = 480; - SDL_FillRect(surface, &rect, barcolor); - SDL_FillRect(surface, &rectb, barcolor); - offset = 2; - scaleborder3x((uint32_t*)((uint8_t *)surface->pixels + offset * bpp), (uint32_t*)borderimg->pixels); - break; - case 13: /* CRT 3x scaler */ - rect.x = 0; - rect.y = 0; - rect.w = 2; - rect.h = 480; - rectb.x = 638; - rectb.y = 0; - rectb.w = 2; - rectb.h = 480; - SDL_FillRect(surface, &rect, barcolor); - SDL_FillRect(surface, &rectb, barcolor); - offset = 2; - scaleborder3x_crt((uint32_t*)((uint8_t *)surface->pixels + offset * bpp), (uint32_t*)borderimg->pixels); - break; - case 14: /* CRT Fullscreen */ -#endif - case 5: /* Ayla's fullscreen scaler */ - case 6: /* Bilinear fullscreen scaler */ - case 11: /* Hardware Fullscreen */ - rect.x = 0; - rect.y = 0; - rect.w = 0; - rect.h = 0; - SDL_BlitSurface(borderimg, &rect, surface, NULL); - break; - default: - rect.x = 0; - rect.y = 0; - rect.w = 320; - rect.h = 240; - SDL_BlitSurface(borderimg, &rect, surface, NULL); - break; + if (selectedscaler == "No Scaling") + { + rect.x = 0; + rect.y = 0; + rect.w = 320; + rect.h = 240; + SDL_BlitSurface(borderimg, &rect, surface, NULL); + } + else if (selectedscaler == "1.5x Fast" || + selectedscaler == "1.5x Smooth") + { + rect.x = 0; + rect.y = 0; + rect.w = 1; + rect.h = 240; + rectb.x = 319; + rectb.y = 0; + rectb.w = 1; + rectb.h = 240; + SDL_FillRect(surface, &rect, barcolor); + SDL_FillRect(surface, &rectb, barcolor); + offset = 1; + scaleborder15x((uint32_t*)((uint8_t *)surface->pixels + offset * bpp), (uint32_t*)borderimg->pixels); + } + else if (selectedscaler == "Aspect 1.66x Fast" || + selectedscaler == "Aspect 1.66x Smooth") + { + scaleborder166x((uint32_t*)((uint8_t *)surface->pixels), (uint32_t*)borderimg->pixels); + rect.x = 0; + rect.y = 0; + rect.w = 1; + rect.h = 240; + rectb.x = 319; + rectb.y = 0; + rectb.w = 1; + rectb.h = 240; + SDL_FillRect(surface, &rect, barcolor); + SDL_FillRect(surface, &rectb, barcolor); + } + else if (selectedscaler == "1.5x IPU") + { + rect.x = 56; + rect.y = 40; + rect.w = 208; + rect.h = 160; + SDL_BlitSurface(borderimg, &rect, surface, NULL); + } + else if (selectedscaler == "Aspect IPU") + { + rect.x = 64; + rect.y = 48; + rect.w = 192; + rect.h = 144; + SDL_BlitSurface(borderimg, &rect, surface, NULL); + } + else if (selectedscaler == "1.5x IPU-2x" || + selectedscaler == "1.5x DMG-2x") + { + offset = 0; + scaleborder15x_2((uint32_t*)((uint8_t *)surface->pixels + offset * bpp), (uint32_t*)borderimg->pixels); + } + else if (selectedscaler == "1.5x Scan-2x") + { + offset = 0; + scaleborder15x_crt2((uint32_t*)((uint8_t *)surface->pixels + offset * bpp), (uint32_t*)borderimg->pixels); + } + else if (selectedscaler == "Aspect IPU-2x" || + selectedscaler == "Aspect DMG-2x") + { + offset = 0; + scaleborder166x_2((uint32_t*)((uint8_t *)surface->pixels + offset * bpp), (uint32_t*)borderimg->pixels); + } + else if (selectedscaler == "Aspect Scan-2x") + { + offset = 0; + scaleborder166x_crt2((uint32_t*)((uint8_t *)surface->pixels + offset * bpp), (uint32_t*)borderimg->pixels); + } + else if (selectedscaler == "1.5x DMG-3x") + { + rect.x = 0; + rect.y = 0; + rect.w = 2; + rect.h = 480; + rectb.x = 638; + rectb.y = 0; + rectb.w = 2; + rectb.h = 480; + SDL_FillRect(surface, &rect, barcolor); + SDL_FillRect(surface, &rectb, barcolor); + offset = 2; + scaleborder15x_3((uint32_t*)((uint8_t *)surface->pixels + offset * bpp), (uint32_t*)borderimg->pixels); + } + else if (selectedscaler == "1.5x Scan-3x") + { + rect.x = 0; + rect.y = 0; + rect.w = 2; + rect.h = 480; + rectb.x = 638; + rectb.y = 0; + rectb.w = 2; + rectb.h = 480; + SDL_FillRect(surface, &rect, barcolor); + SDL_FillRect(surface, &rectb, barcolor); + offset = 2; + scaleborder15x_crt3((uint32_t*)((uint8_t *)surface->pixels + offset * bpp), (uint32_t*)borderimg->pixels); + } + else if (selectedscaler == "Aspect DMG-3x") + { + offset = 0; + scaleborder166x_3((uint32_t*)((uint8_t *)surface->pixels + offset * bpp), (uint32_t*)borderimg->pixels); + } + else if (selectedscaler == "Aspect Scan-3x") + { + offset = 0; + scaleborder166x_crt3((uint32_t*)((uint8_t *)surface->pixels + offset * bpp), (uint32_t*)borderimg->pixels); + } + else if ( + selectedscaler == "FullScreen Fast" || + selectedscaler == "FullScreen Smooth" || + selectedscaler == "FullScreen IPU" || + selectedscaler == "FullScreen IPU-2x" || + selectedscaler == "FullScreen DMG-2x" || + selectedscaler == "FullScreen DMG-3x" || + selectedscaler == "FullScreen Scan-2x" || + selectedscaler == "FullScreen Scan-3x") + { + rect.x = 0; + rect.y = 0; + rect.w = 0; + rect.h = 0; + SDL_BlitSurface(borderimg, &rect, surface, NULL); + } + else + { + rect.x = 0; + rect.y = 0; + rect.w = 320; + rect.h = 240; + SDL_BlitSurface(borderimg, &rect, surface, NULL); } } @@ -1949,12 +2004,16 @@ void loadPalette(std::string palettefile){ return; } else if(palettefile == "DEFAULT"){ Uint32 value; -#ifdef VGA_SCREEN - if (selectedscaler == 12) { + if (selectedscaler == "1.5x DMG-2x" || + selectedscaler == "1.5x DMG-3x" || + selectedscaler == "Aspect DMG-2x" || + selectedscaler == "Aspect DMG-3x" || + selectedscaler == "FullScreen DMG-2x"|| + selectedscaler == "FullScreen DMG-3x") { for (int i = 0; i < 3; ++i) { for (int k = 0; k < 4; ++k) { if(k == 0) - value = 0x5B8C07; + value = 0x64960a; if(k == 1) value = 0x187048; if(k == 2) @@ -1964,9 +2023,8 @@ void loadPalette(std::string palettefile){ gambatte_p->setDmgPaletteColor(i, k, value); } } - set_menu_palette(0x5B8C07, 0x187048, 0x084448, 0x002038); + set_menu_palette(0x64960a, 0x187048, 0x084448, 0x002038); } else { -#endif for (int i = 0; i < 3; ++i) { for (int k = 0; k < 4; ++k) { if(k == 0) @@ -1981,9 +2039,7 @@ void loadPalette(std::string palettefile){ } } set_menu_palette(0x64960a, 0x1b7e3e, 0x084e3c, 0x003236); -#ifdef VGA_SCREEN } -#endif return; } else { Uint32 values[12]; @@ -2003,12 +2059,16 @@ void loadPalette(std::string palettefile){ if (fpal == NULL) { printf("Palette file %s not found. Loading default palette...\n", filepath.c_str()); Uint32 value; -#ifdef VGA_SCREEN - if (selectedscaler == 12) { + if (selectedscaler == "1.5x DMG-2x" || + selectedscaler == "1.5x DMG-3x" || + selectedscaler == "Aspect DMG-2x" || + selectedscaler == "Aspect DMG-3x" || + selectedscaler == "FullScreen DMG-2x"|| + selectedscaler == "FullScreen DMG-3x") { for (int i = 0; i < 3; ++i) { for (int k = 0; k < 4; ++k) { if(k == 0) - value = 0x5B8C07; + value = 0x64960a; if(k == 1) value = 0x187048; if(k == 2) @@ -2018,9 +2078,8 @@ void loadPalette(std::string palettefile){ gambatte_p->setDmgPaletteColor(i, k, value); } } - set_menu_palette(0x5B8C07, 0x187048, 0x084448, 0x002038); + set_menu_palette(0x64960a, 0x187048, 0x084448, 0x002038); } else { -#endif for (int i = 0; i < 3; ++i) { for (int k = 0; k < 4; ++k) { if(k == 0) @@ -2035,9 +2094,7 @@ void loadPalette(std::string palettefile){ } } set_menu_palette(0x64960a, 0x1b7e3e, 0x084e3c, 0x003236); -#ifdef VGA_SCREEN } -#endif return; } } else { @@ -2145,7 +2202,7 @@ void saveConfig(int pergame){ } if (fprintf(cfile, "SHOWFPS %d\n" - "SELECTEDSCALER %d\n" + "SELECTEDSCALER %s\n" "PALNAME %s\n" "FILTERNAME %s\n" "DMGBORDERNAME %s\n" @@ -2157,7 +2214,7 @@ void saveConfig(int pergame){ "FFWHOTKEY %d\n" "STEREOSOUND %d\n", showfps, - selectedscaler, + selectedscaler.c_str(), palname.c_str(), filtername.c_str(), dmgbordername.c_str(), @@ -2215,8 +2272,15 @@ void loadConfig(){ sscanf(arg, "%d", &value); showfps = value; } else if (!strcmp(line, "SELECTEDSCALER")) { - sscanf(arg, "%d", &value); - selectedscaler = value; + unsigned int len = strlen(arg); + if (len == 0 || len > sizeof(charvalue) - 1) { + continue; + } + if (arg[len-1] == '\n') { + arg[len-1] = '\0'; + } + strcpy(charvalue, arg); + selectedscaler = std::string(charvalue); } else if (!strcmp(line, "PALNAME")) { unsigned int len = strlen(arg); if (len == 0 || len > sizeof(charvalue) - 1) { diff --git a/gambatte_sdl/libmenu.h b/gambatte_sdl/libmenu.h index 2bad3f9..eeda32a 100644 --- a/gambatte_sdl/libmenu.h +++ b/gambatte_sdl/libmenu.h @@ -14,7 +14,7 @@ extern "C" { #define NUM_GG_CODES 20 #define NUM_GS_CODES 20 -#if defined VERSION_OPENDINGUX +#if defined VERSION_GCW0 #define BLINK_SPEED 12 #define FOOTER_ALT_SPEED 100 @@ -109,10 +109,10 @@ extern SDL_Surface *menuscreen; extern SDL_Surface *surface_menuinout; extern SDL_Surface *textoverlay; extern SDL_Surface *textoverlaycolored; -extern int selectedscaler, showfps, ghosting, biosenabled, colorfilter, gameiscgb, buttonlayout, stereosound, prefercgb, ffwhotkey; +extern int showfps, ghosting, biosenabled, colorfilter, gameiscgb, buttonlayout, stereosound, prefercgb, ffwhotkey; extern uint32_t menupalblack, menupaldark, menupallight, menupalwhite; extern int filtervalue[12]; -extern std::string dmgbordername, gbcbordername, palname, filtername, currgamename, homedir, ipuscaling; +extern std::string selectedscaler, dmgbordername, gbcbordername, palname, filtername, currgamename, homedir, ipuscaling; extern int numcodes_gg, numcodes_gs, selectedcode, editmode; extern int ggcheats[NUM_GG_CODES*9]; extern int gscheats[NUM_GS_CODES*8]; @@ -155,7 +155,7 @@ void convert_bw_surface_colors(SDL_Surface *surface, SDL_Surface *surface2, cons void load_border(std::string borderfilename); void paint_border(SDL_Surface *surface); uint32_t convert_hexcolor(SDL_Surface *surface, const uint32_t color); -int currentEntryInList(menu_t *menu, std::string text); +int currentEntryInList(menu_t *menu, std::string fname, int isfile); void clear_surface(SDL_Surface *surface, Uint32 color); void loadPalette(std::string palettefile); void loadFilter(std::string filterfile); diff --git a/gambatte_sdl/menu.cpp b/gambatte_sdl/menu.cpp index 1f07819..623e804 100644 --- a/gambatte_sdl/menu.cpp +++ b/gambatte_sdl/menu.cpp @@ -28,7 +28,7 @@ static SDL_Surface *fpsfont_bitmap_surface = NULL; static SDL_RWops *RWops; #ifdef ROM_BROWSER -#ifdef VERSION_OPENDINGUX +#ifdef VERSION_GCW0 static std::string gamedir = ("/media/data/roms"); #elif VERSION_RETROFW static std::string gamedir = (homedir + "/roms"); @@ -1146,89 +1146,145 @@ static void callback_scaler(menu_t *caller_menu) { menu_entry->callback = callback_selectedscaler; menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "1.50x Fast"); + menu_entry_set_text(menu_entry, "1.5x Fast"); menu_add_entry(menu, menu_entry); menu_entry->callback = callback_selectedscaler; menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "1.50x Smooth"); + menu_entry_set_text(menu_entry, "1.5x Smooth"); menu_add_entry(menu, menu_entry); menu_entry->callback = callback_selectedscaler; - menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "1.66x Fast"); - menu_add_entry(menu, menu_entry); - menu_entry->callback = callback_selectedscaler; + if (ipuscaling != "NONE") { + menu_entry = new_menu_entry(0); + menu_entry_set_text(menu_entry, "1.5x IPU"); + menu_add_entry(menu, menu_entry); + menu_entry->callback = callback_selectedscaler; - menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "1.66x Smooth"); - menu_add_entry(menu, menu_entry); - menu_entry->callback = callback_selectedscaler; + menu_entry = new_menu_entry(0); + menu_entry_set_text(menu_entry, "1.5x IPU-2x"); + menu_add_entry(menu, menu_entry); + menu_entry->callback = callback_selectedscaler; + } + +#ifdef VERSION_GCW0 + if (ipuscaling != "NONE") { + menu_entry = new_menu_entry(0); + menu_entry_set_text(menu_entry, "1.5x DMG-2x"); + menu_add_entry(menu, menu_entry); + menu_entry->callback = callback_selectedscaler; + + menu_entry = new_menu_entry(0); + menu_entry_set_text(menu_entry, "1.5x DMG-3x"); + menu_add_entry(menu, menu_entry); + menu_entry->callback = callback_selectedscaler; + + menu_entry = new_menu_entry(0); + menu_entry_set_text(menu_entry, "1.5x Scan-2x"); + menu_add_entry(menu, menu_entry); + menu_entry->callback = callback_selectedscaler; + + menu_entry = new_menu_entry(0); + menu_entry_set_text(menu_entry, "1.5x Scan-3x"); + menu_add_entry(menu, menu_entry); + menu_entry->callback = callback_selectedscaler; + } +#endif menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "FullScreen Fast"); + menu_entry_set_text(menu_entry, "Aspect 1.66x Fast"); menu_add_entry(menu, menu_entry); menu_entry->callback = callback_selectedscaler; menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "FullScreen Smooth"); + menu_entry_set_text(menu_entry, "Aspect 1.66x Smooth"); menu_add_entry(menu, menu_entry); menu_entry->callback = callback_selectedscaler; if (ipuscaling != "NONE") { menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "Hw 1.25x"); + menu_entry_set_text(menu_entry, "Aspect IPU"); + menu_add_entry(menu, menu_entry); + menu_entry->callback = callback_selectedscaler; + + menu_entry = new_menu_entry(0); + menu_entry_set_text(menu_entry, "Aspect IPU-2x"); + menu_add_entry(menu, menu_entry); + menu_entry->callback = callback_selectedscaler; + + } + +#ifdef VERSION_GCW0 + if (ipuscaling != "NONE") { + menu_entry = new_menu_entry(0); + menu_entry_set_text(menu_entry, "Aspect DMG-2x"); menu_add_entry(menu, menu_entry); menu_entry->callback = callback_selectedscaler; menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "Hw 1.36x"); + menu_entry_set_text(menu_entry, "Aspect DMG-3x"); menu_add_entry(menu, menu_entry); menu_entry->callback = callback_selectedscaler; menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "Hw 1.50x"); + menu_entry_set_text(menu_entry, "Aspect Scan-2x"); menu_add_entry(menu, menu_entry); menu_entry->callback = callback_selectedscaler; menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "Hw 1.66x"); + menu_entry_set_text(menu_entry, "Aspect Scan-3x"); menu_add_entry(menu, menu_entry); menu_entry->callback = callback_selectedscaler; + } +#endif + + menu_entry = new_menu_entry(0); + menu_entry_set_text(menu_entry, "FullScreen Fast"); + menu_add_entry(menu, menu_entry); + menu_entry->callback = callback_selectedscaler; + + menu_entry = new_menu_entry(0); + menu_entry_set_text(menu_entry, "FullScreen Smooth"); + menu_add_entry(menu, menu_entry); + menu_entry->callback = callback_selectedscaler; + if (ipuscaling != "NONE") { menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "Hw FullScreen"); + menu_entry_set_text(menu_entry, "FullScreen IPU"); menu_add_entry(menu, menu_entry); menu_entry->callback = callback_selectedscaler; -#ifdef OGA_SCREEN + menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "Dot Matrix 2x"); + menu_entry_set_text(menu_entry, "FullScreen IPU-2x"); menu_add_entry(menu, menu_entry); menu_entry->callback = callback_selectedscaler; + } +#ifdef VERSION_GCW0 + if (ipuscaling != "NONE") { menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "CRT 2x"); + menu_entry_set_text(menu_entry, "FullScreen DMG-2x"); menu_add_entry(menu, menu_entry); menu_entry->callback = callback_selectedscaler; -#elif VGA_SCREEN + menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "Dot Matrix 3x"); + menu_entry_set_text(menu_entry, "FullScreen DMG-3x"); menu_add_entry(menu, menu_entry); menu_entry->callback = callback_selectedscaler; menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "CRT 3x"); + menu_entry_set_text(menu_entry, "FullScreen Scan-2x"); menu_add_entry(menu, menu_entry); menu_entry->callback = callback_selectedscaler; menu_entry = new_menu_entry(0); - menu_entry_set_text(menu_entry, "CRT FullScreen"); + menu_entry_set_text(menu_entry, "FullScreen Scan-3x"); menu_add_entry(menu, menu_entry); menu_entry->callback = callback_selectedscaler; -#endif } +#endif - menu->selected_entry = selectedscaler; + menu->selected_entry = currentEntryInList(menu, selectedscaler, 0); playMenuSound_in(); menu_main(menu); @@ -1238,7 +1294,7 @@ static void callback_scaler(menu_t *caller_menu) { static void callback_selectedscaler(menu_t *caller_menu) { playMenuSound_ok(); - selectedscaler = caller_menu->selected_entry; + selectedscaler = std::string(caller_menu->entries[caller_menu->selected_entry]->text); if(gameiscgb == 0){ loadPalette(palname); load_border(dmgbordername); @@ -1300,7 +1356,7 @@ static void callback_dmgpalette(menu_t *caller_menu) { } } - menu->selected_entry = currentEntryInList(menu, palname); + menu->selected_entry = currentEntryInList(menu, palname, 1); playMenuSound_in(); menu_main(menu); @@ -1408,7 +1464,7 @@ static void callback_colorfilter(menu_t *caller_menu) { } } - menu->selected_entry = currentEntryInList(menu, filtername); + menu->selected_entry = currentEntryInList(menu, filtername, 1); playMenuSound_in(); menu_main(menu); @@ -1503,7 +1559,7 @@ static void callback_dmgborderimage(menu_t *caller_menu) { } } - menu->selected_entry = currentEntryInList(menu, dmgbordername); + menu->selected_entry = currentEntryInList(menu, dmgbordername, 1); playMenuSound_in(); menu_main(menu); @@ -1613,7 +1669,7 @@ static void callback_gbcborderimage(menu_t *caller_menu) { } } - menu->selected_entry = currentEntryInList(menu, gbcbordername); + menu->selected_entry = currentEntryInList(menu, gbcbordername, 1); playMenuSound_in(); menu_main(menu); diff --git a/gambatte_sdl/scaler.c b/gambatte_sdl/scaler.c index 753c9e5..21a89c7 100644 --- a/gambatte_sdl/scaler.c +++ b/gambatte_sdl/scaler.c @@ -870,9 +870,472 @@ void scale166x_pseudobilinear(uint32_t* dst, uint32_t* src) } } -#ifdef OGA_SCREEN +void scaleborder15x(uint32_t* dst, uint32_t* src) +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 80; BlockY++) + { + BlockSrc = Src16 + BlockY * 212 * 2; + BlockDst = Dst16 + BlockY * 320 * 3; + for (BlockX = 0; BlockX < 106; BlockX++) + { + // -- Row 1 -- + uint16_t _1 = *(BlockSrc ); + *(BlockDst ) = _1; + uint16_t _2 = *(BlockSrc + 1); + *(BlockDst + 1) = Weight1_1( _1, _2); + *(BlockDst + 2) = _2; + + // -- Row 2 -- + uint16_t _3 = *(BlockSrc + 212 * 1 ); + *(BlockDst + 320 * 1 ) = Weight1_1( _1, _3); + uint16_t _4 = *(BlockSrc + 212 * 1 + 1); + *(BlockDst + 320 * 1 + 1) = Weight1_1_1_1( _1, _2, _3, _4); + *(BlockDst + 320 * 1 + 2) = Weight1_1( _2, _4); + + // -- Row 3 -- + *(BlockDst + 320 * 2 ) = _3; + *(BlockDst + 320 * 2 + 1) = Weight1_1( _3, _4); + *(BlockDst + 320 * 2 + 2) = _4; + + BlockSrc += 2; + BlockDst += 3; + } + } +} + +void scaleborder166x(uint32_t* dst, uint32_t* src) +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 48; BlockY++) + { + BlockSrc = Src16 + BlockY * 192 * 3; + BlockDst = Dst16 + BlockY * 320 * 5; + for (BlockX = 0; BlockX < 64; BlockX++) + { + if(BlockX < 8){ + // -- Row 1 -- + uint16_t _1 = *(BlockSrc ); + *(BlockDst + 1) = _1; + uint16_t _2 = *(BlockSrc + 1); + *(BlockDst + 2) = _2; + uint16_t _3 = *(BlockSrc + 2); + *(BlockDst + 3) = Weight2_1( _2, _3); + *(BlockDst + 4) = _3; + uint16_t _A = *(BlockSrc + 3); + *(BlockDst + 5) = Weight1_2( _3, _A); + + // -- Row 2 -- + uint16_t _4 = *(BlockSrc + 192 * 1 ); + *(BlockDst + 320 * 1 + 1) = Weight2_1( _1, _4); + uint16_t _5 = *(BlockSrc + 192 * 1 + 1); + *(BlockDst + 320 * 1 + 2) = Weight2_1( _2, _5); + uint16_t _6 = *(BlockSrc + 192 * 1 + 2); + *(BlockDst + 320 * 1 + 3) = Weight2_1(Weight2_1( _2, _3), Weight2_1( _5, _6)); + *(BlockDst + 320 * 1 + 4) = Weight2_1( _3, _6); + uint16_t _B = *(BlockSrc + 192 * 1 + 3); + *(BlockDst + 320 * 1 + 5) = Weight2_1(Weight1_2( _3, _A), Weight1_2( _6, _B)); + + // -- Row 3 -- + *(BlockDst + 320 * 2 + 1) = _4; + *(BlockDst + 320 * 2 + 2) = _5; + *(BlockDst + 320 * 2 + 3) = Weight2_1( _5, _6); + *(BlockDst + 320 * 2 + 4) = _6; + *(BlockDst + 320 * 2 + 5) = Weight1_2( _6, _B); + + // -- Row 4 -- + uint16_t _7 = *(BlockSrc + 192 * 2 ); + *(BlockDst + 320 * 3 + 1) = Weight1_2( _4, _7); + uint16_t _8 = *(BlockSrc + 192 * 2 + 1); + *(BlockDst + 320 * 3 + 2) = Weight1_2( _5, _8); + uint16_t _9 = *(BlockSrc + 192 * 2 + 2); + *(BlockDst + 320 * 3 + 3) = Weight1_2(Weight2_1( _5, _6), Weight2_1( _8, _9)); + *(BlockDst + 320 * 3 + 4) = Weight1_2( _6, _9); + uint16_t _C = *(BlockSrc + 192 * 2 + 3); + *(BlockDst + 320 * 3 + 5) = Weight1_2(Weight1_2( _6, _B), Weight1_2( _9, _C)); + + // -- Row 5 -- + *(BlockDst + 320 * 4 + 1) = _7; + *(BlockDst + 320 * 4 + 2) = _8; + *(BlockDst + 320 * 4 + 3) = Weight2_1( _8, _9); + *(BlockDst + 320 * 4 + 4) = _9; + *(BlockDst + 320 * 4 + 5) = Weight1_2( _9, _C); + + } else if (BlockX > 55){ + // -- Row 1 -- + uint16_t _1 = *(BlockSrc ); + *(BlockDst ) = _1; + uint16_t _2 = *(BlockSrc + 1); + *(BlockDst + 1) = Weight1_2( _1, _2); + *(BlockDst + 2) = _2; + uint16_t _3 = *(BlockSrc + 2); + *(BlockDst + 3) = _3; + uint16_t _A = *(BlockSrc + 3); + *(BlockDst + 4) = Weight2_1( _3, _A); + + // -- Row 2 -- + uint16_t _4 = *(BlockSrc + 192 * 1 ); + *(BlockDst + 320 * 1 ) = Weight2_1( _1, _4); + uint16_t _5 = *(BlockSrc + 192 * 1 + 1); + *(BlockDst + 320 * 1 + 1) = Weight2_1(Weight1_2( _1, _2), Weight1_2( _4, _5)); + *(BlockDst + 320 * 1 + 2) = Weight2_1( _2, _5); + uint16_t _6 = *(BlockSrc + 192 * 1 + 2); + *(BlockDst + 320 * 1 + 3) = Weight2_1( _3, _6); + uint16_t _B = *(BlockSrc + 192 * 1 + 3); + *(BlockDst + 320 * 1 + 4) = Weight2_1(Weight2_1( _3, _A), Weight2_1( _6, _B)); + + // -- Row 3 -- + *(BlockDst + 320 * 2 ) = _4; + *(BlockDst + 320 * 2 + 1) = Weight1_2( _4, _5); + *(BlockDst + 320 * 2 + 2) = _5; + *(BlockDst + 320 * 2 + 3) = _6; + *(BlockDst + 320 * 2 + 4) = Weight2_1( _6, _B); + + // -- Row 4 -- + uint16_t _7 = *(BlockSrc + 192 * 2 ); + *(BlockDst + 320 * 3 ) = Weight1_2( _4, _7); + uint16_t _8 = *(BlockSrc + 192 * 2 + 1); + *(BlockDst + 320 * 3 + 1) = Weight1_2(Weight1_2( _4, _5), Weight1_2( _7, _8)); + *(BlockDst + 320 * 3 + 2) = Weight1_2( _5, _8); + uint16_t _9 = *(BlockSrc + 192 * 2 + 2); + *(BlockDst + 320 * 3 + 3) = Weight1_2( _6, _9); + uint16_t _C = *(BlockSrc + 192 * 2 + 3); + *(BlockDst + 320 * 3 + 4) = Weight1_2(Weight2_1( _6, _B), Weight2_1( _9, _C)); + + // -- Row 5 -- + *(BlockDst + 320 * 4 ) = _7; + *(BlockDst + 320 * 4 + 1) = Weight1_2( _7, _8); + *(BlockDst + 320 * 4 + 2) = _8; + *(BlockDst + 320 * 4 + 3) = _9; + *(BlockDst + 320 * 4 + 4) = Weight2_1( _9, _C); + } + + BlockSrc += 3; + BlockDst += 5; + } + } +} + +/* Upscales a 160x144 image to 320x288 using a grid-looking upscaler algorithm. + * + * Input: + * src: A packed 160x144 pixel image. The pixel format of this image is RGB 565. + * gridcolor: An hexadecimal color. The format of this color is 0xRRGGBB. + * Output: + * dst: A packed 320x288 pixel image. The pixel format of this image is RGB 565. + */ + +void scale15x_2(uint32_t* dst, uint32_t* src) +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + + // There are 160 pixels horizontally, and 144 vertically. + // Each pixel becomes 2x2 with an added grid pattern. + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 144; BlockY++) + { + BlockSrc = Src16 + BlockY * 160 * 1; + BlockDst = Dst16 + BlockY * 428 * 2; + for (BlockX = 0; BlockX < 160; BlockX++) + { + // Before: After: + // (a) (1)(1) + // (1)(1) + + uint16_t _1 = *(BlockSrc); + + // -- Row 1 -- + *(BlockDst ) = _1; + *(BlockDst + 1) = _1; + + // -- Row 2 -- + *(BlockDst + 428 * 1 ) = _1; + *(BlockDst + 428 * 1 + 1) = _1; + + BlockSrc += 1; + BlockDst += 2; + } + } +} + +void scale166x_2(uint32_t* dst, uint32_t* src) +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + + // There are 160 pixels horizontally, and 144 vertically. + // Each pixel becomes 2x2 with an added grid pattern. + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 144; BlockY++) + { + BlockSrc = Src16 + BlockY * 160 * 1; + BlockDst = Dst16 + BlockY * 384 * 2; + for (BlockX = 0; BlockX < 160; BlockX++) + { + // Before: After: + // (a) (1)(1) + // (1)(1) + + uint16_t _1 = *(BlockSrc); + + // -- Row 1 -- + *(BlockDst ) = _1; + *(BlockDst + 1) = _1; + + // -- Row 2 -- + *(BlockDst + 384 * 1 ) = _1; + *(BlockDst + 384 * 1 + 1) = _1; + + BlockSrc += 1; + BlockDst += 2; + } + } +} + +void fullscreen_2(uint32_t* dst, uint32_t* src) +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + + // There are 160 pixels horizontally, and 144 vertically. + // Each pixel becomes 2x2 with an added grid pattern. + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 144; BlockY++) + { + BlockSrc = Src16 + BlockY * 160 * 1; + BlockDst = Dst16 + BlockY * 320 * 2; + for (BlockX = 0; BlockX < 160; BlockX++) + { + // Before: After: + // (a) (1)(1) + // (1)(1) + + uint16_t _1 = *(BlockSrc); + + // -- Row 1 -- + *(BlockDst ) = _1; + *(BlockDst + 1) = _1; + + // -- Row 2 -- + *(BlockDst + 320 * 1 ) = _1; + *(BlockDst + 320 * 1 + 1) = _1; + + BlockSrc += 1; + BlockDst += 2; + } + } +} + + +void scale15x_dotmatrix2(uint32_t* dst, uint32_t* src, const uint32_t gridcolor) +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + uint16_t gcolor = hexcolor_to_rgb565(gridcolor); + + // There are 160 pixels horizontally, and 144 vertically. + // Each pixel becomes 2x2 with an added grid pattern. + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 144; BlockY++) + { + BlockSrc = Src16 + BlockY * 160 * 1; + BlockDst = Dst16 + BlockY * 428 * 2; + for (BlockX = 0; BlockX < 160; BlockX++) + { + // Before: After: + // (a) (2)(1) + // (3)(2) + + uint16_t _1 = *(BlockSrc); + uint16_t _2 = Weight2_1( _1, gcolor); + uint16_t _3 = Weight1_1( _1, gcolor); + + // -- Row 1 -- + *(BlockDst ) = _2; + *(BlockDst + 1) = _1; + + // -- Row 2 -- + *(BlockDst + 428 * 1 ) = _3; + *(BlockDst + 428 * 1 + 1) = _2; + + BlockSrc += 1; + BlockDst += 2; + } + } +} + +void scale166x_dotmatrix2(uint32_t* dst, uint32_t* src, const uint32_t gridcolor) +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + uint16_t gcolor = hexcolor_to_rgb565(gridcolor); + + // There are 160 pixels horizontally, and 144 vertically. + // Each pixel becomes 2x2 with an added grid pattern. + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 144; BlockY++) + { + BlockSrc = Src16 + BlockY * 160 * 1; + BlockDst = Dst16 + BlockY * 384 * 2; + for (BlockX = 0; BlockX < 160; BlockX++) + { + // Before: After: + // (a) (2)(1) + // (3)(2) + + uint16_t _1 = *(BlockSrc); + uint16_t _2 = Weight2_1( _1, gcolor); + uint16_t _3 = Weight1_1( _1, gcolor); + + // -- Row 1 -- + *(BlockDst ) = _2; + *(BlockDst + 1) = _1; + + // -- Row 2 -- + *(BlockDst + 384 * 1 ) = _3; + *(BlockDst + 384 * 1 + 1) = _2; + + BlockSrc += 1; + BlockDst += 2; + } + } +} + +void fullscreen_dotmatrix2(uint32_t* dst, uint32_t* src, const uint32_t gridcolor) +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + uint16_t gcolor = hexcolor_to_rgb565(gridcolor); + + // There are 160 pixels horizontally, and 144 vertically. + // Each pixel becomes 2x2 with an added grid pattern. + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 144; BlockY++) + { + BlockSrc = Src16 + BlockY * 160 * 1; + BlockDst = Dst16 + BlockY * 320 * 2; + for (BlockX = 0; BlockX < 160; BlockX++) + { + // Before: After: + // (a) (2)(1) + // (3)(2) + + uint16_t _1 = *(BlockSrc); + uint16_t _2 = Weight2_1( _1, gcolor); + uint16_t _3 = Weight1_1( _1, gcolor); + + // -- Row 1 -- + *(BlockDst ) = _2; + *(BlockDst + 1) = _1; + + // -- Row 2 -- + *(BlockDst + 320 * 1 ) = _3; + *(BlockDst + 320 * 1 + 1) = _2; + + BlockSrc += 1; + BlockDst += 2; + } + } +} + +void scaleborder15x_2(uint32_t* dst, uint32_t* src) //212x160 to 424x320 +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 160; BlockY++) + { + BlockSrc = Src16 + BlockY * 214 * 1; + BlockDst = Dst16 + BlockY * 428 * 2; + for (BlockX = 0; BlockX < 214; BlockX++) + { + // Before: After: + // (a) (a)(a) + // (a)(a) + + uint16_t _1 = *(BlockSrc); + + // -- Row 1 -- + *(BlockDst ) = _1; + *(BlockDst + 1) = _1; + + // -- Row 2 -- + *(BlockDst + 428 * 1 ) = _1; + *(BlockDst + 428 * 1 + 1) = _1; + + BlockSrc += 1; + BlockDst += 2; + } + } +} -/* Upscales a 160x144 image to 320x288 using a grid-looking upscaler algorithm. +void scaleborder166x_2(uint32_t* dst, uint32_t* src) //192x144 to 384x288 +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 144; BlockY++) + { + BlockSrc = Src16 + BlockY * 192 * 1; + BlockDst = Dst16 + BlockY * 384 * 2; + for (BlockX = 0; BlockX < 192; BlockX++) + { + // Before: After: + // (a) (a)(a) + // (a)(a) + + uint16_t _1 = *(BlockSrc); + + // -- Row 1 -- + *(BlockDst ) = _1; + *(BlockDst + 1) = _1; + + // -- Row 2 -- + *(BlockDst + 384 * 1 ) = _1; + *(BlockDst + 384 * 1 + 1) = _1; + + BlockSrc += 1; + BlockDst += 2; + } + } +} + +/* Upscales a 160x144 image to 320x288 using a CRT-looking upscaler algorithm. * * Input: * src: A packed 160x144 pixel image. The pixel format of this image is RGB 565. @@ -881,14 +1344,14 @@ void scale166x_pseudobilinear(uint32_t* dst, uint32_t* src) * dst: A packed 320x288 pixel image. The pixel format of this image is RGB 565. */ -void scale2x_dotmatrix(uint32_t* dst, uint32_t* src, const uint32_t gridcolor) +void scale15x_crt2(uint32_t* dst, uint32_t* src) { uint16_t* Src16 = (uint16_t*) src; uint16_t* Dst16 = (uint16_t*) dst; - uint16_t gcolor = hexcolor_to_rgb565(gridcolor); + uint16_t gcolor = hexcolor_to_rgb565(0x000000); // There are 160 pixels horizontally, and 144 vertically. - // Each pixel becomes 2x2 with an added grid pattern. + // Each pixel becomes 2x2 with an added scanline pattern. uint8_t BlockX, BlockY; uint16_t* BlockSrc; @@ -896,24 +1359,23 @@ void scale2x_dotmatrix(uint32_t* dst, uint32_t* src, const uint32_t gridcolor) for (BlockY = 0; BlockY < 144; BlockY++) { BlockSrc = Src16 + BlockY * 160 * 1; - BlockDst = Dst16 + BlockY * 480 * 2; + BlockDst = Dst16 + BlockY * 428 * 2; for (BlockX = 0; BlockX < 160; BlockX++) { // Before: After: - // (a) (2)(1) - // (3)(2) + // (a) (1)(1) + // (2)(2) uint16_t _1 = *(BlockSrc); uint16_t _2 = Weight2_1( _1, gcolor); - uint16_t _3 = Weight1_1( _1, gcolor); // -- Row 1 -- - *(BlockDst ) = _2; + *(BlockDst ) = _1; *(BlockDst + 1) = _1; // -- Row 2 -- - *(BlockDst + 480 * 1 ) = _3; - *(BlockDst + 480 * 1 + 1) = _2; + *(BlockDst + 428 * 1 ) = _2; + *(BlockDst + 428 * 1 + 1) = _2; BlockSrc += 1; BlockDst += 2; @@ -921,16 +1383,46 @@ void scale2x_dotmatrix(uint32_t* dst, uint32_t* src, const uint32_t gridcolor) } } -/* Upscales a 160x144 image to 320x288 using a CRT-looking upscaler algorithm. - * - * Input: - * src: A packed 160x144 pixel image. The pixel format of this image is RGB 565. - * gridcolor: An hexadecimal color. The format of this color is 0xRRGGBB. - * Output: - * dst: A packed 320x288 pixel image. The pixel format of this image is RGB 565. - */ +void scale166x_crt2(uint32_t* dst, uint32_t* src) +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + uint16_t gcolor = hexcolor_to_rgb565(0x000000); + + // There are 160 pixels horizontally, and 144 vertically. + // Each pixel becomes 2x2 with an added scanline pattern. + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 144; BlockY++) + { + BlockSrc = Src16 + BlockY * 160 * 1; + BlockDst = Dst16 + BlockY * 384 * 2; + for (BlockX = 0; BlockX < 160; BlockX++) + { + // Before: After: + // (a) (1)(1) + // (2)(2) + + uint16_t _1 = *(BlockSrc); + uint16_t _2 = Weight2_1( _1, gcolor); + + // -- Row 1 -- + *(BlockDst ) = _1; + *(BlockDst + 1) = _1; + + // -- Row 2 -- + *(BlockDst + 384 * 1 ) = _2; + *(BlockDst + 384 * 1 + 1) = _2; -void scale2x_crt(uint32_t* dst, uint32_t* src) + BlockSrc += 1; + BlockDst += 2; + } + } +} + +void fullscreen_crt2(uint32_t* dst, uint32_t* src) { uint16_t* Src16 = (uint16_t*) src; uint16_t* Dst16 = (uint16_t*) dst; @@ -945,7 +1437,7 @@ void scale2x_crt(uint32_t* dst, uint32_t* src) for (BlockY = 0; BlockY < 144; BlockY++) { BlockSrc = Src16 + BlockY * 160 * 1; - BlockDst = Dst16 + BlockY * 480 * 2; + BlockDst = Dst16 + BlockY * 320 * 2; for (BlockX = 0; BlockX < 160; BlockX++) { // Before: After: @@ -960,8 +1452,8 @@ void scale2x_crt(uint32_t* dst, uint32_t* src) *(BlockDst + 1) = _1; // -- Row 2 -- - *(BlockDst + 480 * 1 ) = _2; - *(BlockDst + 480 * 1 + 1) = _2; + *(BlockDst + 320 * 1 ) = _2; + *(BlockDst + 320 * 1 + 1) = _2; BlockSrc += 1; BlockDst += 2; @@ -969,128 +1461,308 @@ void scale2x_crt(uint32_t* dst, uint32_t* src) } } -void scaleborder2x(uint32_t* dst, uint32_t* src) +void scaleborder15x_crt2(uint32_t* dst, uint32_t* src) //212x160 to 424x320 { uint16_t* Src16 = (uint16_t*) src; uint16_t* Dst16 = (uint16_t*) dst; + uint16_t gcolor = hexcolor_to_rgb565(0x000000); uint8_t BlockX, BlockY; uint16_t* BlockSrc; uint16_t* BlockDst; for (BlockY = 0; BlockY < 160; BlockY++) { - BlockSrc = Src16 + BlockY * 240 * 1; - BlockDst = Dst16 + BlockY * 480 * 2; - for (BlockX = 0; BlockX < 240; BlockX++) + BlockSrc = Src16 + BlockY * 214 * 1; + BlockDst = Dst16 + BlockY * 428 * 2; + for (BlockX = 0; BlockX < 214; BlockX++) { // Before: After: - // (a) (a)(a) - // (a)(a) + // (a) (1)(1) + // (2)(2) + + uint16_t _1 = *(BlockSrc); + uint16_t _2 = Weight2_1( _1, gcolor); + + // -- Row 1 -- + *(BlockDst ) = _1; + *(BlockDst + 1) = _1; + + // -- Row 2 -- + *(BlockDst + 428 * 1 ) = _2; + *(BlockDst + 428 * 1 + 1) = _2; + + BlockSrc += 1; + BlockDst += 2; + } + } +} + +void scaleborder166x_crt2(uint32_t* dst, uint32_t* src) //192x144 to 384x288 +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + uint16_t gcolor = hexcolor_to_rgb565(0x000000); + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 144; BlockY++) + { + BlockSrc = Src16 + BlockY * 192 * 1; + BlockDst = Dst16 + BlockY * 384 * 2; + for (BlockX = 0; BlockX < 192; BlockX++) + { + // Before: After: + // (a) (1)(1) + // (2)(2) + + uint16_t _1 = *(BlockSrc); + uint16_t _2 = Weight2_1( _1, gcolor); + + // -- Row 1 -- + *(BlockDst ) = _1; + *(BlockDst + 1) = _1; + + // -- Row 2 -- + *(BlockDst + 384 * 1 ) = _2; + *(BlockDst + 384 * 1 + 1) = _2; + + BlockSrc += 1; + BlockDst += 2; + } + } +} + +/* Upscales a 160x144 image to 480x432 using a grid-looking upscaler algorithm. + * + * Input: + * src: A packed 160x144 pixel image. The pixel format of this image is RGB 565. + * gridcolor: An hexadecimal color. The format of this color is 0xRRGGBB. + * Output: + * dst: A packed 480x432 pixel image. The pixel format of this image is RGB 565. + */ + +void scale15x_dotmatrix3(uint32_t* dst, uint32_t* src, const uint32_t gridcolor) +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + uint16_t gcolor = hexcolor_to_rgb565(gridcolor); + + // There are 160 pixels horizontally, and 144 vertically. + // Each pixel becomes 3x3 with an added grid pattern. + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 144; BlockY++) + { + BlockSrc = Src16 + BlockY * 160 * 1; + BlockDst = Dst16 + BlockY * 640 * 3; + for (BlockX = 0; BlockX < 160; BlockX++) + { + // Before: After: + // (a) (2)(1)(1) + // (2)(1)(1) + // (3)(2)(2) + + uint16_t _1 = *(BlockSrc); + uint16_t _2 = Weight3_2( _1, gcolor); + uint16_t _3 = Weight2_3( _1, gcolor); + + // -- Row 1 -- + *(BlockDst ) = _2; + *(BlockDst + 1) = _1; + *(BlockDst + 2) = _1; + + // -- Row 2 -- + *(BlockDst + 640 * 1 ) = _2; + *(BlockDst + 640 * 1 + 1) = _1; + *(BlockDst + 640 * 1 + 2) = _1; + + // -- Row 3 -- + *(BlockDst + 640 * 2 ) = _3; + *(BlockDst + 640 * 2 + 1) = _2; + *(BlockDst + 640 * 2 + 2) = _2; + + BlockSrc += 1; + BlockDst += 3; + } + } +} + +void scale166x_dotmatrix3(uint32_t* dst, uint32_t* src, const uint32_t gridcolor) +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + uint16_t gcolor = hexcolor_to_rgb565(gridcolor); + + // There are 160 pixels horizontally, and 144 vertically. + // Each pixel becomes 3x3 with an added grid pattern. + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 144; BlockY++) + { + BlockSrc = Src16 + BlockY * 160 * 1; + BlockDst = Dst16 + BlockY * 576 * 3; + for (BlockX = 0; BlockX < 160; BlockX++) + { + // Before: After: + // (a) (2)(1)(1) + // (2)(1)(1) + // (3)(2)(2) + + uint16_t _1 = *(BlockSrc); + uint16_t _2 = Weight3_2( _1, gcolor); + uint16_t _3 = Weight2_3( _1, gcolor); + + // -- Row 1 -- + *(BlockDst ) = _2; + *(BlockDst + 1) = _1; + *(BlockDst + 2) = _1; + + // -- Row 2 -- + *(BlockDst + 576 * 1 ) = _2; + *(BlockDst + 576 * 1 + 1) = _1; + *(BlockDst + 576 * 1 + 2) = _1; + + // -- Row 3 -- + *(BlockDst + 576 * 2 ) = _3; + *(BlockDst + 576 * 2 + 1) = _2; + *(BlockDst + 576 * 2 + 2) = _2; + + BlockSrc += 1; + BlockDst += 3; + } + } +} + +void fullscreen_dotmatrix3(uint32_t* dst, uint32_t* src, const uint32_t gridcolor) +{ + uint16_t* Src16 = (uint16_t*) src; + uint16_t* Dst16 = (uint16_t*) dst; + uint16_t gcolor = hexcolor_to_rgb565(gridcolor); + + // There are 160 pixels horizontally, and 144 vertically. + // Each pixel becomes 3x3 with an added grid pattern. + + uint8_t BlockX, BlockY; + uint16_t* BlockSrc; + uint16_t* BlockDst; + for (BlockY = 0; BlockY < 144; BlockY++) + { + BlockSrc = Src16 + BlockY * 160 * 1; + BlockDst = Dst16 + BlockY * 480 * 3; + for (BlockX = 0; BlockX < 160; BlockX++) + { + // Before: After: + // (a) (2)(1)(1) + // (2)(1)(1) + // (3)(2)(2) uint16_t _1 = *(BlockSrc); + uint16_t _2 = Weight3_2( _1, gcolor); + uint16_t _3 = Weight2_3( _1, gcolor); // -- Row 1 -- - *(BlockDst ) = _1; + *(BlockDst ) = _2; *(BlockDst + 1) = _1; + *(BlockDst + 2) = _1; // -- Row 2 -- - *(BlockDst + 480 * 1 ) = _1; + *(BlockDst + 480 * 1 ) = _2; *(BlockDst + 480 * 1 + 1) = _1; + *(BlockDst + 480 * 1 + 2) = _1; + + // -- Row 3 -- + *(BlockDst + 480 * 2 ) = _3; + *(BlockDst + 480 * 2 + 1) = _2; + *(BlockDst + 480 * 2 + 2) = _2; BlockSrc += 1; - BlockDst += 2; + BlockDst += 3; } } } -void scaleborder2x_crt(uint32_t* dst, uint32_t* src) +void scaleborder15x_3(uint32_t* dst, uint32_t* src) { uint16_t* Src16 = (uint16_t*) src; uint16_t* Dst16 = (uint16_t*) dst; - uint16_t gcolor = hexcolor_to_rgb565(0x000000); uint8_t BlockX, BlockY; uint16_t* BlockSrc; uint16_t* BlockDst; for (BlockY = 0; BlockY < 160; BlockY++) { - BlockSrc = Src16 + BlockY * 240 * 1; - BlockDst = Dst16 + BlockY * 480 * 2; - for (BlockX = 0; BlockX < 240; BlockX++) + BlockSrc = Src16 + BlockY * 212 * 1; + BlockDst = Dst16 + BlockY * 640 * 3; + for (BlockX = 0; BlockX < 212; BlockX++) { // Before: After: - // (a) (1)(1) - // (2)(2) + // (a) (a)(a)(a) + // (a)(a)(a) + // (a)(a)(a) uint16_t _1 = *(BlockSrc); - uint16_t _2 = Weight2_1( _1, gcolor); // -- Row 1 -- *(BlockDst ) = _1; *(BlockDst + 1) = _1; + *(BlockDst + 2) = _1; // -- Row 2 -- - *(BlockDst + 480 * 1 ) = _2; - *(BlockDst + 480 * 1 + 1) = _2; + *(BlockDst + 640 * 1 ) = _1; + *(BlockDst + 640 * 1 + 1) = _1; + *(BlockDst + 640 * 1 + 2) = _1; + + // -- Row 3 -- + *(BlockDst + 640 * 2 ) = _1; + *(BlockDst + 640 * 2 + 1) = _1; + *(BlockDst + 640 * 2 + 2) = _1; BlockSrc += 1; - BlockDst += 2; + BlockDst += 3; } } } -#elif VGA_SCREEN - -/* Upscales a 160x144 image to 480x432 using a grid-looking upscaler algorithm. - * - * Input: - * src: A packed 160x144 pixel image. The pixel format of this image is RGB 565. - * gridcolor: An hexadecimal color. The format of this color is 0xRRGGBB. - * Output: - * dst: A packed 480x432 pixel image. The pixel format of this image is RGB 565. - */ - -void scale3x_dotmatrix(uint32_t* dst, uint32_t* src, const uint32_t gridcolor) +void scaleborder166x_3(uint32_t* dst, uint32_t* src) //192x144 to 576x432 { uint16_t* Src16 = (uint16_t*) src; uint16_t* Dst16 = (uint16_t*) dst; - uint16_t gcolor = hexcolor_to_rgb565(gridcolor); - - // There are 160 pixels horizontally, and 144 vertically. - // Each pixel becomes 3x3 with an added grid pattern. uint8_t BlockX, BlockY; uint16_t* BlockSrc; uint16_t* BlockDst; for (BlockY = 0; BlockY < 144; BlockY++) { - BlockSrc = Src16 + BlockY * 160 * 1; - BlockDst = Dst16 + BlockY * 640 * 3; - for (BlockX = 0; BlockX < 160; BlockX++) + BlockSrc = Src16 + BlockY * 192 * 1; + BlockDst = Dst16 + BlockY * 576 * 3; + for (BlockX = 0; BlockX < 192; BlockX++) { // Before: After: - // (a) (2)(1)(1) - // (2)(1)(1) - // (3)(2)(2) + // (a) (a)(a)(a) + // (a)(a)(a) + // (a)(a)(a) uint16_t _1 = *(BlockSrc); - uint16_t _2 = Weight3_2( _1, gcolor); - uint16_t _3 = Weight2_3( _1, gcolor); // -- Row 1 -- - *(BlockDst ) = _2; + *(BlockDst ) = _1; *(BlockDst + 1) = _1; *(BlockDst + 2) = _1; // -- Row 2 -- - *(BlockDst + 640 * 1 ) = _2; - *(BlockDst + 640 * 1 + 1) = _1; - *(BlockDst + 640 * 1 + 2) = _1; + *(BlockDst + 576 * 1 ) = _1; + *(BlockDst + 576 * 1 + 1) = _1; + *(BlockDst + 576 * 1 + 2) = _1; // -- Row 3 -- - *(BlockDst + 640 * 2 ) = _3; - *(BlockDst + 640 * 2 + 1) = _2; - *(BlockDst + 640 * 2 + 2) = _2; + *(BlockDst + 576 * 2 ) = _1; + *(BlockDst + 576 * 2 + 1) = _1; + *(BlockDst + 576 * 2 + 2) = _1; BlockSrc += 1; BlockDst += 3; @@ -1107,7 +1779,7 @@ void scale3x_dotmatrix(uint32_t* dst, uint32_t* src, const uint32_t gridcolor) * dst: A packed 480x432 pixel image. The pixel format of this image is RGB 565. */ -void scale3x_crt(uint32_t* dst, uint32_t* src) +void scale15x_crt3(uint32_t* dst, uint32_t* src) { uint16_t* Src16 = (uint16_t*) src; uint16_t* Dst16 = (uint16_t*) dst; @@ -1155,7 +1827,7 @@ void scale3x_crt(uint32_t* dst, uint32_t* src) } } -void fullscreen_crt(uint32_t* dst, uint32_t* src) +void scale166x_crt3(uint32_t* dst, uint32_t* src) { uint16_t* Src16 = (uint16_t*) src; uint16_t* Dst16 = (uint16_t*) dst; @@ -1170,7 +1842,7 @@ void fullscreen_crt(uint32_t* dst, uint32_t* src) for (BlockY = 0; BlockY < 144; BlockY++) { BlockSrc = Src16 + BlockY * 160 * 1; - BlockDst = Dst16 + BlockY * 480 * 3; + BlockDst = Dst16 + BlockY * 576 * 3; for (BlockX = 0; BlockX < 160; BlockX++) { // Before: After: @@ -1188,14 +1860,14 @@ void fullscreen_crt(uint32_t* dst, uint32_t* src) *(BlockDst + 2) = _1; // -- Row 2 -- - *(BlockDst + 480 * 1 ) = _2; - *(BlockDst + 480 * 1 + 1) = _2; - *(BlockDst + 480 * 1 + 2) = _2; + *(BlockDst + 576 * 1 ) = _2; + *(BlockDst + 576 * 1 + 1) = _2; + *(BlockDst + 576 * 1 + 2) = _2; // -- Row 3 -- - *(BlockDst + 480 * 2 ) = _3; - *(BlockDst + 480 * 2 + 1) = _3; - *(BlockDst + 480 * 2 + 2) = _3; + *(BlockDst + 576 * 2 ) = _3; + *(BlockDst + 576 * 2 + 1) = _3; + *(BlockDst + 576 * 2 + 2) = _3; BlockSrc += 1; BlockDst += 3; @@ -1203,26 +1875,32 @@ void fullscreen_crt(uint32_t* dst, uint32_t* src) } } -void scaleborder3x(uint32_t* dst, uint32_t* src) +void fullscreen_crt3(uint32_t* dst, uint32_t* src) { uint16_t* Src16 = (uint16_t*) src; uint16_t* Dst16 = (uint16_t*) dst; + uint16_t gcolor = hexcolor_to_rgb565(0x000000); + + // There are 160 pixels horizontally, and 144 vertically. + // Each pixel becomes 3x3 with an added scanline pattern. uint8_t BlockX, BlockY; uint16_t* BlockSrc; uint16_t* BlockDst; - for (BlockY = 0; BlockY < 160; BlockY++) + for (BlockY = 0; BlockY < 144; BlockY++) { - BlockSrc = Src16 + BlockY * 212 * 1; - BlockDst = Dst16 + BlockY * 640 * 3; - for (BlockX = 0; BlockX < 212; BlockX++) + BlockSrc = Src16 + BlockY * 160 * 1; + BlockDst = Dst16 + BlockY * 480 * 3; + for (BlockX = 0; BlockX < 160; BlockX++) { // Before: After: // (a) (a)(a)(a) - // (a)(a)(a) - // (a)(a)(a) + // (x)(x)(x) + // (y)(y)(y) uint16_t _1 = *(BlockSrc); + uint16_t _2 = Weight4_1( _1, gcolor); + uint16_t _3 = Weight1_1( _1, gcolor); // -- Row 1 -- *(BlockDst ) = _1; @@ -1230,14 +1908,14 @@ void scaleborder3x(uint32_t* dst, uint32_t* src) *(BlockDst + 2) = _1; // -- Row 2 -- - *(BlockDst + 640 * 1 ) = _1; - *(BlockDst + 640 * 1 + 1) = _1; - *(BlockDst + 640 * 1 + 2) = _1; + *(BlockDst + 480 * 1 ) = _2; + *(BlockDst + 480 * 1 + 1) = _2; + *(BlockDst + 480 * 1 + 2) = _2; // -- Row 3 -- - *(BlockDst + 640 * 2 ) = _1; - *(BlockDst + 640 * 2 + 1) = _1; - *(BlockDst + 640 * 2 + 2) = _1; + *(BlockDst + 480 * 2 ) = _3; + *(BlockDst + 480 * 2 + 1) = _3; + *(BlockDst + 480 * 2 + 2) = _3; BlockSrc += 1; BlockDst += 3; @@ -1245,7 +1923,7 @@ void scaleborder3x(uint32_t* dst, uint32_t* src) } } -void scaleborder3x_crt(uint32_t* dst, uint32_t* src) +void scaleborder15x_crt3(uint32_t* dst, uint32_t* src) { uint16_t* Src16 = (uint16_t*) src; uint16_t* Dst16 = (uint16_t*) dst; @@ -1289,162 +1967,48 @@ void scaleborder3x_crt(uint32_t* dst, uint32_t* src) } } } -#endif - -//---------------- BORDER SCALERS ---------------------// -void scaleborder15x(uint32_t* dst, uint32_t* src) +void scaleborder166x_crt3(uint32_t* dst, uint32_t* src) //192x144 to 576x432 { uint16_t* Src16 = (uint16_t*) src; uint16_t* Dst16 = (uint16_t*) dst; + uint16_t gcolor = hexcolor_to_rgb565(0x000000); uint8_t BlockX, BlockY; uint16_t* BlockSrc; uint16_t* BlockDst; - for (BlockY = 0; BlockY < 80; BlockY++) + for (BlockY = 0; BlockY < 144; BlockY++) { - BlockSrc = Src16 + BlockY * 212 * 2; - BlockDst = Dst16 + BlockY * 320 * 3; - for (BlockX = 0; BlockX < 106; BlockX++) - { + BlockSrc = Src16 + BlockY * 192 * 1; + BlockDst = Dst16 + BlockY * 576 * 3; + for (BlockX = 0; BlockX < 192; BlockX++) + { + // Before: After: + // (a) (a)(a)(a) + // (x)(x)(x) + // (y)(y)(y) + + uint16_t _1 = *(BlockSrc); + uint16_t _2 = Weight4_1( _1, gcolor); + uint16_t _3 = Weight1_1( _1, gcolor); + // -- Row 1 -- - uint16_t _1 = *(BlockSrc ); *(BlockDst ) = _1; - uint16_t _2 = *(BlockSrc + 1); - *(BlockDst + 1) = Weight1_1( _1, _2); - *(BlockDst + 2) = _2; + *(BlockDst + 1) = _1; + *(BlockDst + 2) = _1; // -- Row 2 -- - uint16_t _3 = *(BlockSrc + 212 * 1 ); - *(BlockDst + 320 * 1 ) = Weight1_1( _1, _3); - uint16_t _4 = *(BlockSrc + 212 * 1 + 1); - *(BlockDst + 320 * 1 + 1) = Weight1_1_1_1( _1, _2, _3, _4); - *(BlockDst + 320 * 1 + 2) = Weight1_1( _2, _4); + *(BlockDst + 576 * 1 ) = _2; + *(BlockDst + 576 * 1 + 1) = _2; + *(BlockDst + 576 * 1 + 2) = _2; // -- Row 3 -- - *(BlockDst + 320 * 2 ) = _3; - *(BlockDst + 320 * 2 + 1) = Weight1_1( _3, _4); - *(BlockDst + 320 * 2 + 2) = _4; + *(BlockDst + 576 * 2 ) = _3; + *(BlockDst + 576 * 2 + 1) = _3; + *(BlockDst + 576 * 2 + 2) = _3; - BlockSrc += 2; + BlockSrc += 1; BlockDst += 3; } } } - -void scaleborder166x(uint32_t* dst, uint32_t* src) -{ - uint16_t* Src16 = (uint16_t*) src; - uint16_t* Dst16 = (uint16_t*) dst; - - uint8_t BlockX, BlockY; - uint16_t* BlockSrc; - uint16_t* BlockDst; - for (BlockY = 0; BlockY < 48; BlockY++) - { - BlockSrc = Src16 + BlockY * 192 * 3; - BlockDst = Dst16 + BlockY * 320 * 5; - for (BlockX = 0; BlockX < 64; BlockX++) - { - if(BlockX < 8){ - // -- Row 1 -- - uint16_t _1 = *(BlockSrc ); - *(BlockDst + 1) = _1; - uint16_t _2 = *(BlockSrc + 1); - *(BlockDst + 2) = _2; - uint16_t _3 = *(BlockSrc + 2); - *(BlockDst + 3) = Weight2_1( _2, _3); - *(BlockDst + 4) = _3; - uint16_t _A = *(BlockSrc + 3); - *(BlockDst + 5) = Weight1_2( _3, _A); - - // -- Row 2 -- - uint16_t _4 = *(BlockSrc + 192 * 1 ); - *(BlockDst + 320 * 1 + 1) = Weight2_1( _1, _4); - uint16_t _5 = *(BlockSrc + 192 * 1 + 1); - *(BlockDst + 320 * 1 + 2) = Weight2_1( _2, _5); - uint16_t _6 = *(BlockSrc + 192 * 1 + 2); - *(BlockDst + 320 * 1 + 3) = Weight2_1(Weight2_1( _2, _3), Weight2_1( _5, _6)); - *(BlockDst + 320 * 1 + 4) = Weight2_1( _3, _6); - uint16_t _B = *(BlockSrc + 192 * 1 + 3); - *(BlockDst + 320 * 1 + 5) = Weight2_1(Weight1_2( _3, _A), Weight1_2( _6, _B)); - - // -- Row 3 -- - *(BlockDst + 320 * 2 + 1) = _4; - *(BlockDst + 320 * 2 + 2) = _5; - *(BlockDst + 320 * 2 + 3) = Weight2_1( _5, _6); - *(BlockDst + 320 * 2 + 4) = _6; - *(BlockDst + 320 * 2 + 5) = Weight1_2( _6, _B); - - // -- Row 4 -- - uint16_t _7 = *(BlockSrc + 192 * 2 ); - *(BlockDst + 320 * 3 + 1) = Weight1_2( _4, _7); - uint16_t _8 = *(BlockSrc + 192 * 2 + 1); - *(BlockDst + 320 * 3 + 2) = Weight1_2( _5, _8); - uint16_t _9 = *(BlockSrc + 192 * 2 + 2); - *(BlockDst + 320 * 3 + 3) = Weight1_2(Weight2_1( _5, _6), Weight2_1( _8, _9)); - *(BlockDst + 320 * 3 + 4) = Weight1_2( _6, _9); - uint16_t _C = *(BlockSrc + 192 * 2 + 3); - *(BlockDst + 320 * 3 + 5) = Weight1_2(Weight1_2( _6, _B), Weight1_2( _9, _C)); - - // -- Row 5 -- - *(BlockDst + 320 * 4 + 1) = _7; - *(BlockDst + 320 * 4 + 2) = _8; - *(BlockDst + 320 * 4 + 3) = Weight2_1( _8, _9); - *(BlockDst + 320 * 4 + 4) = _9; - *(BlockDst + 320 * 4 + 5) = Weight1_2( _9, _C); - - } else if (BlockX > 55){ - // -- Row 1 -- - uint16_t _1 = *(BlockSrc ); - *(BlockDst ) = _1; - uint16_t _2 = *(BlockSrc + 1); - *(BlockDst + 1) = Weight1_2( _1, _2); - *(BlockDst + 2) = _2; - uint16_t _3 = *(BlockSrc + 2); - *(BlockDst + 3) = _3; - uint16_t _A = *(BlockSrc + 3); - *(BlockDst + 4) = Weight2_1( _3, _A); - - // -- Row 2 -- - uint16_t _4 = *(BlockSrc + 192 * 1 ); - *(BlockDst + 320 * 1 ) = Weight2_1( _1, _4); - uint16_t _5 = *(BlockSrc + 192 * 1 + 1); - *(BlockDst + 320 * 1 + 1) = Weight2_1(Weight1_2( _1, _2), Weight1_2( _4, _5)); - *(BlockDst + 320 * 1 + 2) = Weight2_1( _2, _5); - uint16_t _6 = *(BlockSrc + 192 * 1 + 2); - *(BlockDst + 320 * 1 + 3) = Weight2_1( _3, _6); - uint16_t _B = *(BlockSrc + 192 * 1 + 3); - *(BlockDst + 320 * 1 + 4) = Weight2_1(Weight2_1( _3, _A), Weight2_1( _6, _B)); - - // -- Row 3 -- - *(BlockDst + 320 * 2 ) = _4; - *(BlockDst + 320 * 2 + 1) = Weight1_2( _4, _5); - *(BlockDst + 320 * 2 + 2) = _5; - *(BlockDst + 320 * 2 + 3) = _6; - *(BlockDst + 320 * 2 + 4) = Weight2_1( _6, _B); - - // -- Row 4 -- - uint16_t _7 = *(BlockSrc + 192 * 2 ); - *(BlockDst + 320 * 3 ) = Weight1_2( _4, _7); - uint16_t _8 = *(BlockSrc + 192 * 2 + 1); - *(BlockDst + 320 * 3 + 1) = Weight1_2(Weight1_2( _4, _5), Weight1_2( _7, _8)); - *(BlockDst + 320 * 3 + 2) = Weight1_2( _5, _8); - uint16_t _9 = *(BlockSrc + 192 * 2 + 2); - *(BlockDst + 320 * 3 + 3) = Weight1_2( _6, _9); - uint16_t _C = *(BlockSrc + 192 * 2 + 3); - *(BlockDst + 320 * 3 + 4) = Weight1_2(Weight2_1( _6, _B), Weight2_1( _9, _C)); - - // -- Row 5 -- - *(BlockDst + 320 * 4 ) = _7; - *(BlockDst + 320 * 4 + 1) = Weight1_2( _7, _8); - *(BlockDst + 320 * 4 + 2) = _8; - *(BlockDst + 320 * 4 + 3) = _9; - *(BlockDst + 320 * 4 + 4) = Weight2_1( _9, _C); - } - - BlockSrc += 3; - BlockDst += 5; - } - } -} \ No newline at end of file diff --git a/gambatte_sdl/scaler.h b/gambatte_sdl/scaler.h index fb40568..d44e1d1 100644 --- a/gambatte_sdl/scaler.h +++ b/gambatte_sdl/scaler.h @@ -19,18 +19,34 @@ void fullscreen_upscale(uint32_t *to, uint32_t *from); void fullscreen_upscale_pseudobilinear(uint32_t* dst, uint32_t* src); void scaleborder15x(uint32_t* dst, uint32_t* src); void scaleborder166x(uint32_t* dst, uint32_t* src); -#ifdef OGA_SCREEN -void scale2x_dotmatrix(uint32_t* dst, uint32_t* src, const uint32_t gridcolor); -void scale2x_crt(uint32_t* dst, uint32_t* src); -void scaleborder2x(uint32_t* dst, uint32_t* src); -void scaleborder2x_crt(uint32_t* dst, uint32_t* src); -#elif VGA_SCREEN -void scale3x_dotmatrix(uint32_t* dst, uint32_t* src, const uint32_t gridcolor); -void scale3x_crt(uint32_t* dst, uint32_t* src); -void fullscreen_crt(uint32_t* dst, uint32_t* src); -void scaleborder3x(uint32_t* dst, uint32_t* src); -void scaleborder3x_crt(uint32_t* dst, uint32_t* src); -#endif + +void scale15x_2(uint32_t* dst, uint32_t* src); +void scale166x_2(uint32_t* dst, uint32_t* src); +void fullscreen_2(uint32_t* dst, uint32_t* src); + +void scale15x_dotmatrix2(uint32_t* dst, uint32_t* src, const uint32_t gridcolor); +void scale166x_dotmatrix2(uint32_t* dst, uint32_t* src, const uint32_t gridcolor); +void fullscreen_dotmatrix2(uint32_t* dst, uint32_t* src, const uint32_t gridcolor); +void scaleborder15x_2(uint32_t* dst, uint32_t* src); +void scaleborder166x_2(uint32_t* dst, uint32_t* src); + +void scale15x_crt2(uint32_t* dst, uint32_t* src); +void scale166x_crt2(uint32_t* dst, uint32_t* src); +void fullscreen_crt2(uint32_t* dst, uint32_t* src); +void scaleborder15x_crt2(uint32_t* dst, uint32_t* src); +void scaleborder166x_crt2(uint32_t* dst, uint32_t* src); + +void scale15x_dotmatrix3(uint32_t* dst, uint32_t* src, const uint32_t gridcolor); +void scale166x_dotmatrix3(uint32_t* dst, uint32_t* src, const uint32_t gridcolor); +void fullscreen_dotmatrix3(uint32_t* dst, uint32_t* src, const uint32_t gridcolor); +void scaleborder15x_3(uint32_t* dst, uint32_t* src); +void scaleborder166x_3(uint32_t* dst, uint32_t* src); + +void scale15x_crt3(uint32_t* dst, uint32_t* src); +void scale166x_crt3(uint32_t* dst, uint32_t* src); +void fullscreen_crt3(uint32_t* dst, uint32_t* src); +void scaleborder15x_crt3(uint32_t* dst, uint32_t* src); +void scaleborder166x_crt3(uint32_t* dst, uint32_t* src); #ifdef __cplusplus } diff --git a/gambatte_sdl/src/gambatte_sdl.cpp b/gambatte_sdl/src/gambatte_sdl.cpp index 24eaa41..9765ab7 100644 --- a/gambatte_sdl/src/gambatte_sdl.cpp +++ b/gambatte_sdl/src/gambatte_sdl.cpp @@ -1024,9 +1024,7 @@ bool GambatteSdl::handleEvents(BlitterWrapper &blitter) { case SDL_JOYAXISMOTION: jd.dev_num = e.jaxis.which; jd.num = e.jaxis.axis; - jd.dir = e.jaxis.value < -8192 - ? JoyData::dir_down - : (e.jaxis.value > 8192 ? JoyData::dir_up : JoyData::dir_centered); + jd.dir = e.jaxis.value < -8192 ? JoyData::dir_down : (e.jaxis.value > 8192 ? JoyData::dir_up : JoyData::dir_centered); for (std::pair range = jaMap.equal_range(jd); range.first != range.second; ++range.first) { diff --git a/gambatte_sdl/src/sdlblitter.cpp b/gambatte_sdl/src/sdlblitter.cpp index a5243a2..3c5a31d 100644 --- a/gambatte_sdl/src/sdlblitter.cpp +++ b/gambatte_sdl/src/sdlblitter.cpp @@ -131,7 +131,7 @@ void SdlBlitter::CheckIPU(){ } void SdlBlitter::SetVid(int w, int h, int bpp){ -#ifdef VERSION_OPENDINGUX +#ifdef VERSION_GCW0 screen = SDL_SetVideoMode(w, h, bpp, SDL_HWSURFACE | SDL_TRIPLEBUF); #elif VERSION_RETROFW screen = SDL_SetVideoMode(w, h, bpp, SDL_HWSURFACE | SDL_TRIPLEBUF); @@ -142,169 +142,237 @@ void SdlBlitter::SetVid(int w, int h, int bpp){ #endif } -void SdlBlitter::setBufferDimensions() { - - FILE* aspect_ratio_file = fopen(ipuscaling.c_str(), "w"); -#ifdef VGA_SCREEN - FILE* sharpness_file = fopen("/sys/devices/platform/jz-lcd.0/sharpness_upscaling", "w"); - if (sharpness_file) { - fwrite("1", 1, 1, sharpness_file); - fclose(sharpness_file); +void SdlBlitter::SetIPUAspectRatio(const char *ratiovalue){ + if (ipuscaling == "NEW_OD_IPU") { + if(ratiovalue == "0"){ + SDL_putenv("SDL_VIDEO_KMSDRM_SCALING_MODE=0"); + } else if(ratiovalue == "1"){ + SDL_putenv("SDL_VIDEO_KMSDRM_SCALING_MODE=1"); + } + return; } -#endif - switch(selectedscaler) { - case 0: /* no scaler */ - case 1: /* Ayla's 1.5x scaler */ - case 2: /* Bilinear 1.5x scaler */ - case 3: /* Fast 1.66x scaler */ - case 4: /* Bilinear 1.66x scaler */ - case 5: /* Ayla's fullscreen scaler */ - case 6: /* Bilinear fullscreen scaler */ - SetVid(320, 240, 16); - break; - case 7: /* Hardware 1.25x */ - if (aspect_ratio_file) { - fwrite("1", 1, 1, aspect_ratio_file); - fclose(aspect_ratio_file); - } - SetVid(256, 192, 16); - break; - case 8: /* Hardware 1.36x */ - if (aspect_ratio_file) { - fwrite("1", 1, 1, aspect_ratio_file); - fclose(aspect_ratio_file); - } - SetVid(224, 176, 16); - break; - case 9: /* Hardware 1.5x */ - if (aspect_ratio_file) { - fwrite("1", 1, 1, aspect_ratio_file); - fclose(aspect_ratio_file); - } - SetVid(208, 160, 16); - break; - case 10: /* Hardware 1.66x */ - if (aspect_ratio_file) { - fwrite("1", 1, 1, aspect_ratio_file); - fclose(aspect_ratio_file); - } - SetVid(192, 144, 16); - break; - case 11: /* Hardware Fullscreen */ - if (aspect_ratio_file) { - fwrite("0", 1, 1, aspect_ratio_file); - fclose(aspect_ratio_file); - } - SetVid(160, 144, 16); - break; -#ifdef VGA_SCREEN - case 12: /* Dot Matrix 3x */ - case 13: /* CRT 3x scaler */ - SetVid(640, 480, 16); - break; - case 14: /* CRT Fullscreen */ - if (aspect_ratio_file) { - fwrite("0", 1, 1, aspect_ratio_file); - fclose(aspect_ratio_file); - } - SetVid(480, 432, 16); - break; -#endif - default: - SetVid(320, 240, 16); - break; + FILE *aspect_ratio_file = NULL; + aspect_ratio_file = fopen(ipuscaling.c_str(), "r+"); + if (aspect_ratio_file != NULL) { + fclose(aspect_ratio_file); + aspect_ratio_file = fopen(ipuscaling.c_str(), "w"); + fwrite(ratiovalue, 1, 1, aspect_ratio_file); + fclose(aspect_ratio_file); } +} - menu_set_screen(screen); +void SdlBlitter::SetIPUSharpness(const char *svalue){ + if (ipuscaling == "NEW_OD_IPU") { + if(svalue == "0"){ + SDL_putenv("SDL_VIDEO_KMSDRM_SCALING_SHARPNESS=0"); + } else if(svalue == "1"){ + SDL_putenv("SDL_VIDEO_KMSDRM_SCALING_SHARPNESS=1"); + } else if(svalue == "2"){ + SDL_putenv("SDL_VIDEO_KMSDRM_SCALING_SHARPNESS=2"); + } else if(svalue == "3"){ + SDL_putenv("SDL_VIDEO_KMSDRM_SCALING_SHARPNESS=3"); + } else if(svalue == "4"){ + SDL_putenv("SDL_VIDEO_KMSDRM_SCALING_SHARPNESS=4"); + } else if(svalue == "5"){ + SDL_putenv("SDL_VIDEO_KMSDRM_SCALING_SHARPNESS=5"); + } else if(svalue == "6"){ + SDL_putenv("SDL_VIDEO_KMSDRM_SCALING_SHARPNESS=6"); + } else if(svalue == "7"){ + SDL_putenv("SDL_VIDEO_KMSDRM_SCALING_SHARPNESS=7"); + } else if(svalue == "8"){ + SDL_putenv("SDL_VIDEO_KMSDRM_SCALING_SHARPNESS=8"); + } + return; + } + FILE *sharpness_file = NULL; + sharpness_file = fopen("/sys/devices/platform/jz-lcd.0/sharpness_upscaling", "r+"); + if (sharpness_file != NULL) { + fclose(sharpness_file); + sharpness_file = fopen("/sys/devices/platform/jz-lcd.0/sharpness_upscaling", "w"); + fwrite(svalue, 1, 1, sharpness_file); + fclose(sharpness_file); + } +} +void SdlBlitter::setBufferDimensions() { + SetIPUSharpness("1"); + if (selectedscaler == "No Scaling" || + selectedscaler == "1.5x Fast" || + selectedscaler == "1.5x Smooth" || + selectedscaler == "Aspect 1.66x Fast" || + selectedscaler == "Aspect 1.66x Smooth" || + selectedscaler == "FullScreen Fast" || + selectedscaler == "FullScreen Smooth") + { + SetVid(320, 240, 16); + } + else if (selectedscaler == "1.5x IPU") + { + SetIPUSharpness("2"); + SetIPUAspectRatio("1"); + SetVid(208, 160, 16); + } + else if (selectedscaler == "Aspect IPU") + { + SetIPUSharpness("2"); + SetIPUAspectRatio("1"); + SetVid(192, 144, 16); + } + else if (selectedscaler == "FullScreen IPU") + { + SetIPUSharpness("2"); + SetIPUAspectRatio("0"); + SetVid(160, 144, 16); + } + else if (selectedscaler == "1.5x IPU-2x" || + selectedscaler == "1.5x DMG-2x" || + selectedscaler == "1.5x Scan-2x") + { + SetIPUSharpness("2"); + SetIPUAspectRatio("1"); + SetVid(428, 320, 16); + } + else if (selectedscaler == "Aspect IPU-2x" || + selectedscaler == "Aspect DMG-2x" || + selectedscaler == "Aspect Scan-2x") + { + SetIPUSharpness("2"); + SetIPUAspectRatio("1"); + SetVid(384, 288, 16); + } + else if (selectedscaler == "FullScreen IPU-2x" || + selectedscaler == "FullScreen DMG-2x" || + selectedscaler == "FullScreen Scan-2x") + { + SetIPUSharpness("2"); + SetIPUAspectRatio("0"); + SetVid(320, 288, 16); + } + else if (selectedscaler == "1.5x DMG-3x" || + selectedscaler == "1.5x Scan-3x") + { + SetVid(640, 480, 16); + } + else if (selectedscaler == "Aspect DMG-3x" || + selectedscaler == "Aspect Scan-3x") + { + SetIPUSharpness("7"); + SetIPUAspectRatio("1"); + SetVid(576, 432, 16); + } + else if (selectedscaler == "FullScreen DMG-3x" || + selectedscaler == "FullScreen Scan-3x") + { + SetIPUSharpness("7"); + SetIPUAspectRatio("0"); + SetVid(480, 432, 16); + } + else + { + SetVid(320, 240, 16); + } + menu_set_screen(screen); init_ghostframes(); } void SdlBlitter::setScreenRes() { - FILE* aspect_ratio_file = fopen(ipuscaling.c_str(), "w"); -#ifdef VGA_SCREEN - FILE* sharpness_file = fopen("/sys/devices/platform/jz-lcd.0/sharpness_upscaling", "w"); - if (sharpness_file) { - fwrite("1", 1, 1, sharpness_file); - fclose(sharpness_file); + SetIPUSharpness("1"); + if (selectedscaler == "No Scaling" || + selectedscaler == "1.5x Fast" || + selectedscaler == "1.5x Smooth" || + selectedscaler == "Aspect 1.66x Fast" || + selectedscaler == "Aspect 1.66x Smooth" || + selectedscaler == "FullScreen Fast" || + selectedscaler == "FullScreen Smooth") + { + if(screen->w != 320 || screen->h != 240) { + SetVid(320, 240, 16); + } } -#endif - switch(selectedscaler) { - case 0: /* no scaler */ - case 1: /* Ayla's 1.5x scaler */ - case 2: /* Bilinear 1.5x scaler */ - case 3: /* Fast 1.66x scaler */ - case 4: /* Bilinear 1.66x scaler */ - case 5: /* Ayla's fullscreen scaler */ - case 6: /* Bilinear fullscreen scaler */ - if(screen->w != 320 || screen->h != 240) - SetVid(320, 240, 16); - break; - case 7: /* Hardware 1.25x */ - if (aspect_ratio_file) { - fwrite("1", 1, 1, aspect_ratio_file); - fclose(aspect_ratio_file); - } - if(screen->w != 256 || screen->h != 192) { - SetVid(256, 192, 16); - } - break; - case 8: /* Hardware 1.36x */ - if (aspect_ratio_file) { - fwrite("1", 1, 1, aspect_ratio_file); - fclose(aspect_ratio_file); - } - if(screen->w != 224 || screen->h != 176) { - SetVid(224, 176, 16); - } - break; - case 9: /* Hardware 1.5x */ - if (aspect_ratio_file) { - fwrite("1", 1, 1, aspect_ratio_file); - fclose(aspect_ratio_file); - } - if(screen->w != 208 || screen->h != 160) { - SetVid(208, 160, 16); - } - break; - case 10: /* Hardware 1.66x */ - if (aspect_ratio_file) { - fwrite("1", 1, 1, aspect_ratio_file); - fclose(aspect_ratio_file); - } - if(screen->w != 192 || screen->h != 144) { - SetVid(192, 144, 16); - } - break; - case 11: /* Hardware Fullscreen */ - if (aspect_ratio_file) { - fwrite("0", 1, 1, aspect_ratio_file); - fclose(aspect_ratio_file); - } - if(screen->w != 160 || screen->h != 144) { - SetVid(160, 144, 16); - } - break; -#ifdef VGA_SCREEN - case 12: /* Dot Matrix 3x */ - case 13: /* CRT 3x scaler */ - if(screen->w != 640 || screen->h != 480) - SetVid(640, 480, 16); - break; - case 14: /* CRT Fullscreen */ - if (aspect_ratio_file) { - fwrite("0", 1, 1, aspect_ratio_file); - fclose(aspect_ratio_file); - } - if(screen->w != 480 || screen->h != 432) { - SetVid(480, 432, 16); - } - break; -#endif - default: - if(screen->w != 320 || screen->h != 240) - SetVid(320, 240, 16); - break; + else if (selectedscaler == "1.5x IPU") + { + SetIPUSharpness("2"); + SetIPUAspectRatio("1"); + if(screen->w != 208 || screen->h != 160) { + SetVid(208, 160, 16); + } + } + else if (selectedscaler == "Aspect IPU") + { + SetIPUSharpness("2"); + SetIPUAspectRatio("1"); + if(screen->w != 192 || screen->h != 144) { + SetVid(192, 144, 16); + } + } + else if (selectedscaler == "FullScreen IPU") + { + SetIPUSharpness("2"); + SetIPUAspectRatio("0"); + if(screen->w != 160 || screen->h != 144) { + SetVid(160, 144, 16); + } + } + else if (selectedscaler == "1.5x IPU-2x" || + selectedscaler == "1.5x DMG-2x" || + selectedscaler == "1.5x Scan-2x") + { + SetIPUSharpness("2"); + SetIPUAspectRatio("1"); + if(screen->w != 428 || screen->h != 320){ + SetVid(428, 320, 16); + } + } + else if (selectedscaler == "Aspect IPU-2x" || + selectedscaler == "Aspect DMG-2x" || + selectedscaler == "Aspect Scan-2x") + { + SetIPUSharpness("2"); + SetIPUAspectRatio("1"); + if(screen->w != 384 || screen->h != 288){ + SetVid(384, 288, 16); + } + } + else if (selectedscaler == "FullScreen IPU-2x" || + selectedscaler == "FullScreen DMG-2x" || + selectedscaler == "FullScreen Scan-2x") + { + SetIPUSharpness("2"); + SetIPUAspectRatio("0"); + if(screen->w != 320 || screen->h != 288) { + SetVid(320, 288, 16); + } + } + else if (selectedscaler == "1.5x DMG-3x" || + selectedscaler == "1.5x Scan-3x") + { + if(screen->w != 640 || screen->h != 480){ + SetVid(640, 480, 16); + } + } + else if (selectedscaler == "Aspect DMG-3x" || + selectedscaler == "Aspect Scan-3x") + { + SetIPUSharpness("7"); + SetIPUAspectRatio("1"); + if(screen->w != 576 || screen->h != 432){ + SetVid(576, 432, 16); + } + } + else if (selectedscaler == "FullScreen DMG-3x" || + selectedscaler == "FullScreen Scan-3x") + { + SetIPUSharpness("7"); + SetIPUAspectRatio("0"); + if(screen->w != 480 || screen->h != 432) { + SetVid(480, 432, 16); + } + } + else + { + if(screen->w != 320 || screen->h != 240) { + SetVid(320, 240, 16); + } } } @@ -438,6 +506,165 @@ void anim_textoverlay(SDL_Surface *surface) { } } +void SdlBlitter::applyScalerToSurface(SDL_Surface *sourcesurface) { + size_t offset; + if (selectedscaler == "No Scaling") + { + SDL_Rect dst; + dst.x = (screen->w - sourcesurface->w) / 2; + dst.y = (screen->h - sourcesurface->h) / 2; + dst.w = sourcesurface->w; + dst.h = sourcesurface->h; + SDL_BlitSurface(sourcesurface, NULL, screen, &dst); + } + else if (selectedscaler == "1.5x Fast") + { + offset = (2 * (320 - 240) / 2) + ((240 - 216) / 2) * screen->pitch; + scale15x((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "1.5x Smooth") + { + offset = (2 * (320 - 240) / 2) + ((240 - 216) / 2) * screen->pitch; + scale15x_pseudobilinear((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "Aspect 1.66x Fast") + { + offset = (2 * (320 - 266) / 2) + ((240 - 240) / 2) * screen->pitch; + scale166x_fast((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "Aspect 1.66x Smooth") + { + offset = (2 * (320 - 266) / 2) + ((240 - 240) / 2) * screen->pitch; + scale166x_pseudobilinear((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "FullScreen Fast") + { + fullscreen_upscale((uint32_t*)screen->pixels, (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "FullScreen Smooth") + { + fullscreen_upscale_pseudobilinear((uint32_t*)screen->pixels, (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "1.5x IPU-2x") + { + offset = (2 * (428 - 320) / 2) + ((320 - 288) / 2) * screen->pitch; + scale15x_2((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "1.5x DMG-2x") + { + offset = (2 * (428 - 320) / 2) + ((320 - 288) / 2) * screen->pitch; + if (gameiscgb == 1){ + scale15x_dotmatrix2((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels, menupalblack); + } else { + scale15x_dotmatrix2((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels, menupalwhite); + } + } + else if (selectedscaler == "1.5x Scan-2x") + { + offset = (2 * (428 - 320) / 2) + ((320 - 288) / 2) * screen->pitch; + scale15x_crt2((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "Aspect IPU-2x") + { + offset = (2 * (384 - 320) / 2) + ((288 - 288) / 2) * screen->pitch; + scale166x_2((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "Aspect DMG-2x") + { + offset = (2 * (384 - 320) / 2) + ((288 - 288) / 2) * screen->pitch; + if (gameiscgb == 1){ + scale166x_dotmatrix2((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels, menupalblack); + } else { + scale166x_dotmatrix2((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels, menupalwhite); + } + } + else if (selectedscaler == "Aspect Scan-2x") + { + offset = (2 * (384 - 320) / 2) + ((288 - 288) / 2) * screen->pitch; + scale166x_crt2((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "1.5x DMG-3x") + { + offset = (2 * (640 - 480) / 2) + ((480 - 432) / 2) * screen->pitch; + if (gameiscgb == 1){ + scale15x_dotmatrix3((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels, menupalblack); + } else { + scale15x_dotmatrix3((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels, menupalwhite); + } + } + else if (selectedscaler == "1.5x Scan-3x") + { + offset = (2 * (640 - 480) / 2) + ((480 - 432) / 2) * screen->pitch; + scale15x_crt3((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "Aspect DMG-3x") + { + offset = (2 * (576 - 480) / 2) + ((432 - 432) / 2) * screen->pitch; + if (gameiscgb == 1){ + scale166x_dotmatrix3((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels, menupalblack); + } else { + scale166x_dotmatrix3((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels, menupalwhite); + } + } + else if (selectedscaler == "Aspect Scan-3x") + { + offset = (2 * (576 - 480) / 2) + ((432 - 432) / 2) * screen->pitch; + scale166x_crt3((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "FullScreen IPU-2x") + { + fullscreen_2((uint32_t*)screen->pixels, (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "FullScreen DMG-2x") + { + if (gameiscgb == 1){ + fullscreen_dotmatrix2((uint32_t*)screen->pixels, (uint32_t*)sourcesurface->pixels, menupalblack); + } else { + fullscreen_dotmatrix2((uint32_t*)screen->pixels, (uint32_t*)sourcesurface->pixels, menupalwhite); + } + } + else if (selectedscaler == "FullScreen Scan-2x") + { + fullscreen_crt2((uint32_t*)screen->pixels, (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "FullScreen DMG-3x") + { + if (gameiscgb == 1){ + fullscreen_dotmatrix3((uint32_t*)screen->pixels, (uint32_t*)sourcesurface->pixels, menupalblack); + } else { + fullscreen_dotmatrix3((uint32_t*)screen->pixels, (uint32_t*)sourcesurface->pixels, menupalwhite); + } + } + else if (selectedscaler == "FullScreen Scan-3x") + { + fullscreen_crt3((uint32_t*)screen->pixels, (uint32_t*)sourcesurface->pixels); + } + else if (selectedscaler == "1.5x IPU" || + selectedscaler == "Aspect IPU" || + selectedscaler == "FullScreen IPU") + { + uint16_t *d = (uint16_t*)screen->pixels + (screen->w - sourcesurface->w) / 2 + (screen->h - sourcesurface->h) * screen->pitch / 4; + uint16_t *s = (uint16_t*)sourcesurface->pixels; + for (int y = 0; y < sourcesurface->h; y++) + { + memmove(d, s, sourcesurface->w * sizeof(uint16_t)); + s += sourcesurface->w; + d += screen->w; + } + } + else + { + uint16_t *d = (uint16_t*)screen->pixels + (screen->w - sourcesurface->w) / 2 + (screen->h - sourcesurface->h) * screen->pitch / 4; + uint16_t *s = (uint16_t*)sourcesurface->pixels; + for (int y = 0; y < sourcesurface->h; y++) + { + memmove(d, s, sourcesurface->w * sizeof(uint16_t)); + s += sourcesurface->w; + d += screen->w; + } + } +} + static int frames = 0; static clock_t old_time = 0; static int fps = 0; @@ -445,7 +672,6 @@ static int fps = 0; void SdlBlitter::draw() { clock_t cur_time; - size_t offset; ++frames; cur_time = SDL_GetTicks(); @@ -488,76 +714,7 @@ void SdlBlitter::draw() { }else if(menuin >= 0){ anim_menuin(surface); } - switch(selectedscaler) { - case 0: /* no scaler */ - SDL_Rect dst; - dst.x = (screen->w - surface->w) / 2; - dst.y = (screen->h - surface->h) / 2; - dst.w = surface->w; - dst.h = surface->h; - SDL_BlitSurface(surface, NULL, screen, &dst); - break; - case 1: /* Ayla's 1.5x scaler */ - offset = (2 * (320 - 240) / 2) + ((240 - 216) / 2) * screen->pitch; - scale15x((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)surface->pixels); - break; - case 2: /* Bilinear 1.5x scaler */ - offset = (2 * (320 - 240) / 2) + ((240 - 216) / 2) * screen->pitch; - scale15x_pseudobilinear((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)surface->pixels); - break; - case 3: /* Fast 1.66x scaler */ - offset = (2 * (320 - 266) / 2) + ((240 - 240) / 2) * screen->pitch; - scale166x_fast((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)surface->pixels); - break; - case 4: /* Bilinear 1.66x scaler */ - offset = (2 * (320 - 266) / 2) + ((240 - 240) / 2) * screen->pitch; - scale166x_pseudobilinear((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)surface->pixels); - break; - case 5: /* Ayla's fullscreen scaler */ - fullscreen_upscale((uint32_t*)screen->pixels, (uint32_t*)surface->pixels); - break; - case 6: /* Bilinear fullscreen scaler */ - fullscreen_upscale_pseudobilinear((uint32_t*)screen->pixels, (uint32_t*)surface->pixels); - break; -#ifdef VGA_SCREEN - case 12: /* Dot Matrix 3x scaler */ - offset = (2 * (640 - 480) / 2) + ((480 - 432) / 2) * screen->pitch; - if (gameiscgb == 1){ - scale3x_dotmatrix((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)surface->pixels, menupalblack); - } else { - scale3x_dotmatrix((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)surface->pixels, menupalwhite); - } - break; - case 13: /* CRT 3x scaler */ - offset = (2 * (640 - 480) / 2) + ((480 - 432) / 2) * screen->pitch; - scale3x_crt((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)surface->pixels); - break; - case 14: /* CRT Fullscreen */ - fullscreen_crt((uint32_t*)screen->pixels, (uint32_t*)surface->pixels); - break; -#endif - case 7: /* Hardware 1.25x */ - case 8: /* Hardware 1.36x */ - case 9: /* Hardware 1.5x */ - case 10: /* Hardware 1.66x */ - case 11: /* Hardware Fullscreen */ - default: - /*SDL_Rect dst2; - dst2.x = (screen->w - surface->w) / 2; - dst2.y = (screen->h - surface->h) / 2; - dst2.w = surface->w; - dst2.h = surface->h; - SDL_BlitSurface(surface, NULL, screen, &dst2);*/ - uint16_t *d = (uint16_t*)screen->pixels + (screen->w - surface->w) / 2 + (screen->h - surface->h) * screen->pitch / 4; - uint16_t *s = (uint16_t*)surface->pixels; - for (int y = 0; y < surface->h; y++) - { - memmove(d, s, surface->w * sizeof(uint16_t)); - s += surface->w; - d += screen->w; - } - break; - } + applyScalerToSurface(surface); } else if((ghosting == 3) || ((ghosting == 1) && (gameiscgb == 0)) || ((ghosting == 2) && (gameiscgb == 1))){ //Ghosting enabled for current system if(showoverlay >= 0){ anim_textoverlay(surface); @@ -569,90 +726,12 @@ void SdlBlitter::draw() { }else if(menuin >= 0){ anim_menuin(currframe); } - switch(selectedscaler) { - case 0: /* no scaler */ - SDL_Rect dst; - dst.x = (screen->w - currframe->w) / 2; - dst.y = (screen->h - currframe->h) / 2; - dst.w = currframe->w; - dst.h = currframe->h; - SDL_BlitSurface(currframe, NULL, screen, &dst); - break; - case 1: /* Ayla's 1.5x scaler */ - offset = (2 * (320 - 240) / 2) + ((240 - 216) / 2) * screen->pitch; - scale15x((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)currframe->pixels); - break; - case 2: /* Bilinear 1.5x scaler */ - offset = (2 * (320 - 240) / 2) + ((240 - 216) / 2) * screen->pitch; - scale15x_pseudobilinear((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)currframe->pixels); - break; - case 3: /* Fast 1.66x scaler */ - offset = (2 * (320 - 266) / 2) + ((240 - 240) / 2) * screen->pitch; - scale166x_fast((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)currframe->pixels); - break; - case 4: /* Bilinear 1.66x scaler */ - offset = (2 * (320 - 266) / 2) + ((240 - 240) / 2) * screen->pitch; - scale166x_pseudobilinear((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)currframe->pixels); - break; - case 5: /* Ayla's fullscreen scaler */ - fullscreen_upscale((uint32_t*)screen->pixels, (uint32_t*)currframe->pixels); - break; - case 6: /* Bilinear fullscreen scaler */ - fullscreen_upscale_pseudobilinear((uint32_t*)screen->pixels, (uint32_t*)currframe->pixels); - break; -#ifdef VGA_SCREEN - case 12: /* Dot Matrix 3x scaler */ - offset = (2 * (640 - 480) / 2) + ((480 - 432) / 2) * screen->pitch; - if (gameiscgb == 1){ - scale3x_dotmatrix((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)currframe->pixels, menupalblack); - } else { - scale3x_dotmatrix((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)currframe->pixels, menupalwhite); - } - break; - case 13: /* CRT 3x scaler */ - offset = (2 * (640 - 480) / 2) + ((480 - 432) / 2) * screen->pitch; - scale3x_crt((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)currframe->pixels); - break; - case 14: /* CRT Fullscreen */ - fullscreen_crt((uint32_t*)screen->pixels, (uint32_t*)currframe->pixels); - break; -#endif - case 7: /* Hardware 1.25x */ - case 8: /* Hardware 1.36x */ - case 9: /* Hardware 1.5x */ - case 10: /* Hardware 1.66x */ - case 11: /* Hardware Fullscreen */ - default: - /*SDL_Rect dst2; - dst2.x = (screen->w - currframe->w) / 2; - dst2.y = (screen->h - currframe->h) / 2; - dst2.w = currframe->w; - dst2.h = currframe->h; - SDL_BlitSurface(currframe, NULL, screen, &dst2);*/ - uint16_t *d = (uint16_t*)screen->pixels + (screen->w - currframe->w) / 2 + (screen->h - currframe->h) * screen->pitch / 4; - uint16_t *s = (uint16_t*)currframe->pixels; - for (int y = 0; y < currframe->h; y++) - { - memmove(d, s, currframe->w * sizeof(uint16_t)); - s += currframe->w; - d += screen->w; - } - break; - } - } - - /*if (surface_ && screen_) { - if (surface_->format->BitsPerPixel == 16) - swScale(); - else - swScale(); - }*/ - + applyScalerToSurface(currframe); + } show_fps(screen, fps); } void SdlBlitter::scaleMenu() { - size_t offset; if (!screen || !menuscreen) return; @@ -664,77 +743,7 @@ void SdlBlitter::scaleMenu() { } else { convert_bw_surface_colors(menuscreen, menuscreen, menupalblack, menupaldark, menupallight, menupalwhite, 1); //if game is DMG, then menu matches DMG palette } - - switch(selectedscaler) { - case 0: /* no scaler */ - SDL_Rect dst; - dst.x = (screen->w - menuscreen->w) / 2; - dst.y = (screen->h - menuscreen->h) / 2; - dst.w = menuscreen->w; - dst.h = menuscreen->h; - SDL_BlitSurface(menuscreen, NULL, screen, &dst); - break; - case 1: /* Ayla's 1.5x scaler */ - offset = (2 * (320 - 240) / 2) + ((240 - 216) / 2) * screen->pitch; - scale15x((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)menuscreen->pixels); - break; - case 2: /* Bilinear 1.5x scaler */ - offset = (2 * (320 - 240) / 2) + ((240 - 216) / 2) * screen->pitch; - scale15x_pseudobilinear((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)menuscreen->pixels); - break; - case 3: /* Fast 1.66x scaler */ - offset = (2 * (320 - 266) / 2) + ((240 - 240) / 2) * screen->pitch; - scale166x_fast((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)menuscreen->pixels); - break; - case 4: /* Bilinear 1.66x scaler */ - offset = (2 * (320 - 266) / 2) + ((240 - 240) / 2) * screen->pitch; - scale166x_pseudobilinear((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)menuscreen->pixels); - break; - case 5: /* Ayla's fullscreen scaler */ - fullscreen_upscale((uint32_t*)screen->pixels, (uint32_t*)menuscreen->pixels); - break; - case 6: /* Bilinear fullscreen scaler */ - fullscreen_upscale_pseudobilinear((uint32_t*)screen->pixels, (uint32_t*)menuscreen->pixels); - break; -#ifdef VGA_SCREEN - case 12: /* Dot Matrix 3x scaler */ - offset = (2 * (640 - 480) / 2) + ((480 - 432) / 2) * screen->pitch; - if (gameiscgb == 1){ - scale3x_dotmatrix((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)menuscreen->pixels, menupalblack); - } else { - scale3x_dotmatrix((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)menuscreen->pixels, menupalwhite); - } - break; - case 13: /* CRT 3x scaler */ - offset = (2 * (640 - 480) / 2) + ((480 - 432) / 2) * screen->pitch; - scale3x_crt((uint32_t*)((uint8_t *)screen->pixels + offset), (uint32_t*)menuscreen->pixels); - break; - case 14: /* CRT Fullscreen */ - fullscreen_crt((uint32_t*)screen->pixels, (uint32_t*)menuscreen->pixels); - break; -#endif - case 7: /* Hardware 1.25x */ - case 8: /* Hardware 1.36x */ - case 9: /* Hardware 1.5x */ - case 10: /* Hardware 1.66x */ - case 11: /* Hardware Fullscreen */ - default: - /*SDL_Rect dst2; - dst2.x = (screen->w - menuscreen->w) / 2; - dst2.y = (screen->h - menuscreen->h) / 2; - dst2.w = menuscreen->w; - dst2.h = menuscreen->h; - SDL_BlitSurface(menuscreen, NULL, screen, &dst2);*/ - uint16_t *d = (uint16_t*)screen->pixels + (screen->w - menuscreen->w) / 2 + (screen->h - menuscreen->h) * screen->pitch / 4; - uint16_t *s = (uint16_t*)menuscreen->pixels; - for (int y = 0; y < menuscreen->h; y++) - { - memmove(d, s, menuscreen->w * sizeof(uint16_t)); - s += menuscreen->w; - d += screen->w; - } - break; - } + applyScalerToSurface(menuscreen); } void SdlBlitter::present() { diff --git a/gambatte_sdl/src/sdlblitter.h b/gambatte_sdl/src/sdlblitter.h index 57b8f9a..98c9802 100644 --- a/gambatte_sdl/src/sdlblitter.h +++ b/gambatte_sdl/src/sdlblitter.h @@ -50,9 +50,12 @@ class SdlBlitter { void toggleFullScreen(); void CheckIPU(); void SetVid(int w, int h, int bpp); + void SetIPUAspectRatio(const char *ratiovalue); + void SetIPUSharpness(const char *svalue); void setBufferDimensions(); void setScreenRes(); void force320x240(); + void applyScalerToSurface(SDL_Surface *sourcesurface); void scaleMenu(); SDL_Surface *screen; SDL_Surface *surface; diff --git a/libgambatte/SConstruct b/libgambatte/SConstruct index 0ea21f1..8eed8d1 100644 --- a/libgambatte/SConstruct +++ b/libgambatte/SConstruct @@ -1,16 +1,14 @@ +# OPTIONAL DEFINES: +# -DROM_BROWSER: Enables internal rom browser (gb and gbc romdirs are hardcoded for each system) +# -DPOWEROFF: Replaces the "Quit" option with a "Power Off" option. + target = ARGUMENTS.get('target', 0) -if target == 'opendingux': - include_path = ' -I/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include' - bin_path = '/opt/gcw0-toolchain/usr/bin/mipsel-linux-' - version_defines = ' -DVERSION_OPENDINGUX' - extra_cflags = '' - print "Building Gambatte library with OpenDingux toolchain..." -elif target == 'rg350m': +if target == 'gcw0': include_path = ' -I/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include' bin_path = '/opt/gcw0-toolchain/usr/bin/mipsel-linux-' - version_defines = ' -DVERSION_OPENDINGUX -DVGA_SCREEN' + version_defines = ' -DVERSION_GCW0' extra_cflags = '' - print "Building Gambatte library with OpenDingux toolchain..." + print "Building Gambatte library with GCW0 toolchain..." elif target == 'retrofw': include_path = ' -I/opt/rs97-toolchain/mipsel-buildroot-linux-uclibc/sysroot/usr/include' bin_path = '/opt/rs97-toolchain/bin/mipsel-linux-'