aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgameblabla2019-10-08 14:43:37 +0200
committergameblabla2019-10-08 14:43:37 +0200
commitcc878848a45db22abe284649c7e19f896a0abeb9 (patch)
tree8adc9d01f9fb6561beb86e9ef329d7c8cbd64c2f
parentd08ec6a5285e60c6a55c8f11117496be1b375559 (diff)
downloadsnesemu-cc878848a45db22abe284649c7e19f896a0abeb9.tar.gz
snesemu-cc878848a45db22abe284649c7e19f896a0abeb9.tar.bz2
snesemu-cc878848a45db22abe284649c7e19f896a0abeb9.zip
Fix up Retrostone support and other minor fixes.
-rw-r--r--Makefile.retrostone63
-rw-r--r--shell/headers/shared.h6
-rw-r--r--shell/menu/menu.c48
-rw-r--r--shell/video/retrostone/video_blit.c111
-rw-r--r--shell/video/sdl/video_blit.h9
5 files changed, 122 insertions, 115 deletions
diff --git a/Makefile.retrostone b/Makefile.retrostone
new file mode 100644
index 0000000..f0d41b8
--- /dev/null
+++ b/Makefile.retrostone
@@ -0,0 +1,63 @@
+PRGNAME = PocketSNES
+
+VIDEO_BACKEND = sdl
+INPUT_BACKEND = sdl
+SOUND_BACKEND = alsa
+PROFILE = 0
+
+# define regarding OS, which compiler to use
+CC = /opt/retrostone-toolchain/bin/arm-buildroot-linux-musleabihf-gcc
+
+# change compilation / linking flag options
+CFLAGS = -DLSB_FIRST -I. -Ilibretro-common/include -Isrc -DINLINE="inline" -DRIGHTSHIFT_IS_SAR
+CFLAGS += -Isource -I./shell/emu -I./shell/scalers -I./shell/emu -I./shell/audio -I./shell/menu -I./shell/video/sdl -I./shell/input -Ishell/headers
+
+CFLAGS += -Ofast -fsingle-precision-constant -fno-PIC -flto
+CFLAGS += -falign-functions=1 -falign-jumps=1 -falign-loops=1 -falign-labels=1
+
+CFLAGS += -DNDEBUG -DLAGFIX -DGIT_VERSION=\"" c9b3980"\" -fno-builtin -fno-exceptions -ffunction-sections -std=gnu99
+CFLAGS += -Wall -Wextra -pedantic -Wno-implicit-function-declaration -Wno-implicit-fallthrough -Wno-sign-compare -Wno-unused-variable -Wno-unused-function -Wno-uninitialized -Wno-strict-aliasing -Wno-overflow -fno-strict-overflow
+
+ifeq ($(PROFILE), YES)
+CFLAGS += -fprofile-generate=/home/useless/profile
+else ifeq ($(PROFILE), APPLY)
+CFLAGS += -fprofile-use -fbranch-probabilities
+endif
+
+#-fprofile-generate=/mnt/int_sd/profile
+LDFLAGS = -lc -lgcc -lm -lSDL -no-pie -Wl,--as-needed -Wl,--gc-sections -s -flto
+ifeq ($(SOUND_BACKEND), portaudio)
+LDFLAGS += -lasound -lportaudio
+endif
+ifeq ($(SOUND_BACKEND), libao)
+LDFLAGS += -lao
+endif
+ifeq ($(SOUND_BACKEND), alsa)
+LDFLAGS += -lasound
+endif
+ifeq ($(SOUND_BACKEND), pulse)
+LDFLAGS += -lpulse -lpulse-simple
+endif
+
+ifeq ($(PROFILE), YES)
+LDFLAGS += -lgcov
+endif
+
+# Files to be compiled
+SRCDIR = ./source ./shell/emu ./shell/scalers ./shell/audio/$(SOUND_BACKEND) ./shell/menu ./shell/video/$(VIDEO_BACKEND) ./shell/input/$(INPUT_BACKEND) ./shell/other
+VPATH = $(SRCDIR)
+SRC_C = $(foreach dir, $(SRCDIR), $(wildcard $(dir)/*.c))
+SRC_CP = $(foreach dir, $(SRCDIR), $(wildcard $(dir)/*.cpp))
+OBJ_C = $(notdir $(patsubst %.c, %.o, $(SRC_C)))
+OBJ_CP = $(notdir $(patsubst %.cpp, %.o, $(SRC_CP)))
+OBJS = $(OBJ_C) $(OBJ_CP)
+
+# Rules to make executable
+$(PRGNAME): $(OBJS)
+ $(CC) $(CFLAGS) -o $(PRGNAME) $^ $(LDFLAGS)
+
+$(OBJ_C) : %.o : %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+clean:
+ rm -f $(PRGNAME)$(EXESUFFIX) *.o
diff --git a/shell/headers/shared.h b/shell/headers/shared.h
index b173506..968b9a2 100644
--- a/shell/headers/shared.h
+++ b/shell/headers/shared.h
@@ -1,10 +1,6 @@
#ifndef SHARED_H
#define SHARED_H
-#define SOUND_OUTPUT_FREQUENCY 32000
-#define SOUND_SAMPLES_SIZE 1024
-
-/*
#if defined(BITTBOY)
#define SOUND_OUTPUT_FREQUENCY 22050
#define SOUND_SAMPLES_SIZE 1024
@@ -27,5 +23,5 @@
#define SOUND_OUTPUT_FREQUENCY 48000
#define SOUND_SAMPLES_SIZE 2048
#endif
-*/
+
#endif
diff --git a/shell/menu/menu.c b/shell/menu/menu.c
index 70096bf..a8f5950 100644
--- a/shell/menu/menu.c
+++ b/shell/menu/menu.c
@@ -132,35 +132,35 @@ static const char* Return_Text_Button(uint32_t button)
break;
/* A button */
case 306:
- return "A button";
+ return "A";
break;
/* B button */
case 308:
- return "B button";
+ return "B";
break;
/* X button */
case 304:
- return "X button";
+ return "X";
break;
/* Y button */
case 32:
- return "Y button";
+ return "Y";
break;
/* L button */
case 9:
- return "L button";
+ return "L";
break;
/* R button */
case 8:
- return "R button";
+ return "R";
break;
/* Power button */
case 279:
- return "L2 button";
+ return "L2";
break;
/* Brightness */
case 51:
- return "R2 button";
+ return "R2";
break;
/* Volume - */
case 38:
@@ -172,14 +172,14 @@ static const char* Return_Text_Button(uint32_t button)
break;
/* Start */
case 13:
- return "Start button";
+ return "Start";
break;
/* Select */
- case 1:
- return "Select button";
+ case 27:
+ return "Select";
break;
default:
- return "Unknown key";
+ return "Unknown";
break;
case 0:
return "...";
@@ -288,51 +288,51 @@ static void Input_Remapping()
print_string("Press [A] to map to a button", TextWhite, TextBlue, 50, 210, backbuffer->pixels);
print_string("Press [B] to Exit", TextWhite, TextBlue, 85, 225, backbuffer->pixels);
- snprintf(text, sizeof(text), "UP : %d\n", (option.config_buttons[controls_chosen][0]));
+ snprintf(text, sizeof(text), "UP : %s\n", Return_Text_Button(option.config_buttons[controls_chosen][0]));
if (currentselection == 1) print_string(text, TextRed, 0, 5, 25+2, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 25+2, backbuffer->pixels);
- snprintf(text, sizeof(text), "DOWN : %d\n", (option.config_buttons[controls_chosen][1]));
+ snprintf(text, sizeof(text), "DOWN : %s\n", Return_Text_Button(option.config_buttons[controls_chosen][1]));
if (currentselection == 2) print_string(text, TextRed, 0, 5, 45+2, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 45+2, backbuffer->pixels);
- snprintf(text, sizeof(text), "LEFT : %d\n", (option.config_buttons[controls_chosen][2]));
+ snprintf(text, sizeof(text), "LEFT : %s\n", Return_Text_Button(option.config_buttons[controls_chosen][2]));
if (currentselection == 3) print_string(text, TextRed, 0, 5, 65+2, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 65+2, backbuffer->pixels);
- snprintf(text, sizeof(text), "RIGHT : %d\n", (option.config_buttons[controls_chosen][3]));
+ snprintf(text, sizeof(text), "RIGHT: %s\n", Return_Text_Button(option.config_buttons[controls_chosen][3]));
if (currentselection == 4) print_string(text, TextRed, 0, 5, 85+2, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 85+2, backbuffer->pixels);
- snprintf(text, sizeof(text), "A : %d\n", (option.config_buttons[controls_chosen][4]));
+ snprintf(text, sizeof(text), "A : %s\n", Return_Text_Button(option.config_buttons[controls_chosen][4]));
if (currentselection == 5) print_string(text, TextRed, 0, 5, 105+2, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 105+2, backbuffer->pixels);
- snprintf(text, sizeof(text), "B : %d\n", (option.config_buttons[controls_chosen][5]));
+ snprintf(text, sizeof(text), "B : %s\n", Return_Text_Button(option.config_buttons[controls_chosen][5]));
if (currentselection == 6) print_string(text, TextRed, 0, 5, 125+2, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 125+2, backbuffer->pixels);
- snprintf(text, sizeof(text), "X : %d\n", (option.config_buttons[controls_chosen][6]));
+ snprintf(text, sizeof(text), "X : %s\n", Return_Text_Button(option.config_buttons[controls_chosen][6]));
if (currentselection == 7) print_string(text, TextRed, 0, 5, 145+2, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 145+2, backbuffer->pixels);
- snprintf(text, sizeof(text), "Y : %d\n", (option.config_buttons[controls_chosen][7]));
+ snprintf(text, sizeof(text), "Y : %s\n", Return_Text_Button(option.config_buttons[controls_chosen][7]));
if (currentselection == 8) print_string(text, TextRed, 0, 5, 165+2, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 165+2, backbuffer->pixels);
- snprintf(text, sizeof(text), "L : %d\n", (option.config_buttons[controls_chosen][8]));
+ snprintf(text, sizeof(text), "L : %s\n", Return_Text_Button(option.config_buttons[controls_chosen][8]));
if (currentselection == 9) print_string(text, TextRed, 0, 5, 185+2, backbuffer->pixels);
else print_string(text, TextWhite, 0, 5, 185+2, backbuffer->pixels);
- snprintf(text, sizeof(text), "R : %d\n", (option.config_buttons[controls_chosen][9]));
+ snprintf(text, sizeof(text), "R : %s\n", Return_Text_Button(option.config_buttons[controls_chosen][9]));
if (currentselection == 10) print_string(text, TextRed, 0, 165, 25+2, backbuffer->pixels);
else print_string(text, TextWhite, 0, 165, 25+2, backbuffer->pixels);
- snprintf(text, sizeof(text), "START : %d\n", (option.config_buttons[controls_chosen][10]));
+ snprintf(text, sizeof(text), "START : %s\n", Return_Text_Button(option.config_buttons[controls_chosen][10]));
if (currentselection == 11) print_string(text, TextRed, 0, 165, 45+2, backbuffer->pixels);
else print_string(text, TextWhite, 0, 165, 45+2, backbuffer->pixels);
- snprintf(text, sizeof(text), "SELECT : %d\n", (option.config_buttons[controls_chosen][11]));
+ snprintf(text, sizeof(text), "SELECT : %s\n", Return_Text_Button(option.config_buttons[controls_chosen][11]));
if (currentselection == 12) print_string(text, TextRed, 0, 165, 65+2, backbuffer->pixels);
else print_string(text, TextWhite, 0, 165, 65+2, backbuffer->pixels);
diff --git a/shell/video/retrostone/video_blit.c b/shell/video/retrostone/video_blit.c
index be84dd1..26bc298 100644
--- a/shell/video/retrostone/video_blit.c
+++ b/shell/video/retrostone/video_blit.c
@@ -24,22 +24,26 @@
#include <SDL/SDL.h>
#include <sys/time.h>
#include <sys/types.h>
-#include "mednafen.h"
-#include "mempatcher.h"
-#include "wswan/gfx.h"
-#include "wswan/wswan-memory.h"
-#include "wswan/sound.h"
-#include "wswan/interrupt.h"
-#include "wswan/v30mz.h"
-#include "wswan/rtc.h"
-#include "wswan/gfx.h"
-#include "wswan/eeprom.h"
+#include "main.h"
+#include "snes9x.h"
+#include "soundux.h"
+#include "memmap.h"
+#include "apu.h"
+#include "cheats.h"
+#include "display.h"
+#include "gfx.h"
+#include "cpuexec.h"
+#include "spc7110.h"
+#include "srtc.h"
+#include "sa1.h"
+#include "scaler.h"
#include "video_blit.h"
#include "scaler.h"
#include "config.h"
-SDL_Surface *sdl_screen, *backbuffer, *wswan_vs, *wswan_vs_rot;
+
+SDL_Surface *sdl_screen, *backbuffer;
uint32_t width_of_surface;
uint32_t* Draw_to_Virtual_Screen;
@@ -50,39 +54,25 @@ void Init_Video()
SDL_ShowCursor(0);
- sdl_screen = SDL_SetVideoMode(0, 0, 16, SDL_HWSURFACE);
+ sdl_screen = SDL_SetVideoMode(680, 448, 16, SDL_HWSURFACE);
backbuffer = SDL_CreateRGBSurface(SDL_SWSURFACE, HOST_WIDTH_RESOLUTION, HOST_HEIGHT_RESOLUTION, 16, 0,0,0,0);
-
- wswan_vs = SDL_CreateRGBSurface(SDL_SWSURFACE, INTERNAL_WSWAN_WIDTH, INTERNAL_WSWAN_HEIGHT, 16, 0,0,0,0);
-
- wswan_vs_rot = SDL_CreateRGBSurface(SDL_SWSURFACE, INTERNAL_WSWAN_HEIGHT, INTERNAL_WSWAN_WIDTH, 16, 0,0,0,0);
Set_Video_InGame();
}
void Set_Video_Menu()
{
- if (sdl_screen->w != HOST_WIDTH_RESOLUTION)
- {
- memcpy(wswan_vs->pixels, sdl_screen->pixels, (INTERNAL_WSWAN_WIDTH * INTERNAL_WSWAN_HEIGHT)*2);
- sdl_screen = SDL_SetVideoMode(HOST_WIDTH_RESOLUTION, HOST_HEIGHT_RESOLUTION, 16, SDL_HWSURFACE);
- }
}
void Set_Video_InGame()
{
- if (sdl_screen->w != HOST_WIDTH_RESOLUTION) sdl_screen = SDL_SetVideoMode(HOST_WIDTH_RESOLUTION, HOST_HEIGHT_RESOLUTION, 16, SDL_HWSURFACE);
- Draw_to_Virtual_Screen = wswan_vs->pixels;
- width_of_surface = INTERNAL_WSWAN_WIDTH;
}
void Video_Close()
{
if (sdl_screen) SDL_FreeSurface(sdl_screen);
if (backbuffer) SDL_FreeSurface(backbuffer);
- if (wswan_vs) SDL_FreeSurface(wswan_vs);
- if (wswan_vs_rot) SDL_FreeSurface(wswan_vs_rot);
SDL_Quit();
}
@@ -91,65 +81,26 @@ void Update_Video_Menu()
SDL_Flip(sdl_screen);
}
-static void rotate_90_ccw(uint16_t* restrict dst, uint16_t* restrict src)
-{
- int32_t h = 224, w = 144;
- src += w * h - 1;
- for (int32_t col = w - 1; col >= 0; --col)
- {
- uint16_t *outcol = dst + col;
- for(int32_t row = 0; row < h; ++row, outcol += w)
- {
- *outcol = *src--;
- }
- }
-}
-
void Update_Video_Ingame()
{
- uint32_t internal_width, internal_height, keep_aspect_width, keep_aspect_height;
- uint16_t* restrict source_graph;
+ uint32_t *s, *d;
+ uint32_t h, w;
+ uint8_t PAL = !!(Memory.FillRAM[0x2133] & 4);
- if ((Wswan_IsVertical() == 1 && option.orientation_settings != 2) || option.orientation_settings == 1)
- {
- rotate_90_ccw((uint16_t* restrict)wswan_vs_rot->pixels, (uint16_t* restrict)wswan_vs->pixels);
- internal_width = INTERNAL_WSWAN_HEIGHT;
- internal_height = INTERNAL_WSWAN_WIDTH;
- source_graph = (uint16_t* restrict)wswan_vs_rot->pixels;
- keep_aspect_width = ((HOST_HEIGHT_RESOLUTION / INTERNAL_WSWAN_HEIGHT) * INTERNAL_WSWAN_WIDTH) / 2;
- if (keep_aspect_width > HOST_WIDTH_RESOLUTION) keep_aspect_width -= HOST_WIDTH_RESOLUTION/2;
- keep_aspect_height = HOST_HEIGHT_RESOLUTION;
- }
- else
- {
- internal_width = INTERNAL_WSWAN_WIDTH;
- internal_height = INTERNAL_WSWAN_HEIGHT;
- source_graph = (uint16_t* restrict)wswan_vs->pixels;
- keep_aspect_width = HOST_WIDTH_RESOLUTION;
- keep_aspect_height = ((HOST_WIDTH_RESOLUTION / INTERNAL_WSWAN_WIDTH) * INTERNAL_WSWAN_HEIGHT);
- if (keep_aspect_height > HOST_HEIGHT_RESOLUTION) keep_aspect_height -= HOST_HEIGHT_RESOLUTION/4;
- }
+ SDL_LockSurface(sdl_screen);
- if (SDL_LockSurface(sdl_screen) == 0)
+ switch(option.fullscreen)
{
- switch(option.fullscreen)
- {
- // Fullscreen
- case 0:
- bitmap_scale(0,0,internal_width,internal_height,internal_width*2,internal_height*2,internal_width, HOST_WIDTH_RESOLUTION - (internal_width*2),(uint16_t* restrict)source_graph,(uint16_t* restrict)sdl_screen->pixels+(HOST_WIDTH_RESOLUTION-(internal_width*2))/2+(HOST_HEIGHT_RESOLUTION-(internal_height*2))/2*HOST_WIDTH_RESOLUTION);
- break;
- // Fullscreen
- case 1:
- bitmap_scale(0, 0, internal_width, internal_height, HOST_WIDTH_RESOLUTION, HOST_HEIGHT_RESOLUTION, internal_width, 0, (uint16_t* restrict)source_graph, (uint16_t* restrict)sdl_screen->pixels);
- break;
- case 2:
- bitmap_scale(0,0,internal_width,internal_height,keep_aspect_width,keep_aspect_height,internal_width, HOST_WIDTH_RESOLUTION - keep_aspect_width,(uint16_t* restrict)source_graph,(uint16_t* restrict)sdl_screen->pixels+(HOST_WIDTH_RESOLUTION-keep_aspect_width)/2+(HOST_HEIGHT_RESOLUTION-keep_aspect_height)/2*HOST_WIDTH_RESOLUTION);
- break;
- // Hqx
- case 3:
- break;
- }
- SDL_UnlockSurface(sdl_screen);
+ case 0:
+ bitmap_scale(0,0,IPPU.RenderedScreenWidth,IPPU.RenderedScreenHeight,IPPU.RenderedScreenWidth*2,sdl_screen->h, SNES_WIDTH*2, sdl_screen->w - (IPPU.RenderedScreenWidth*2),(uint16_t* restrict)GFX.Screen,(uint16_t* restrict)sdl_screen->pixels+(HOST_WIDTH_RESOLUTION-(IPPU.RenderedScreenWidth*2))/2+(HOST_HEIGHT_RESOLUTION-((HOST_HEIGHT_RESOLUTION)))/2*HOST_WIDTH_RESOLUTION);
+ break;
+ case 1:
+ case 2:
+ bitmap_scale(0, 0, IPPU.RenderedScreenWidth, IPPU.RenderedScreenHeight, sdl_screen->w, sdl_screen->h, SNES_WIDTH*2, 0, GFX.Screen, sdl_screen->pixels);
+ break;
}
+
+
+ SDL_UnlockSurface(sdl_screen);
SDL_Flip(sdl_screen);
}
diff --git a/shell/video/sdl/video_blit.h b/shell/video/sdl/video_blit.h
index ea28ba9..b34518b 100644
--- a/shell/video/sdl/video_blit.h
+++ b/shell/video/sdl/video_blit.h
@@ -3,13 +3,10 @@
#include <SDL/SDL.h>
-#define HOST_WIDTH_RESOLUTION 320
-#define HOST_HEIGHT_RESOLUTION 240
+#define HOST_WIDTH_RESOLUTION sdl_screen->w
+#define HOST_HEIGHT_RESOLUTION sdl_screen->h
-#define INTERNAL_SNES_WIDTH_NTSC 256
-#define INTERNAL_SNES_HEIGHT_NTSC 224
-
-extern SDL_Surface *screen, *backbuffer;
+extern SDL_Surface *sdl_screen, *backbuffer;
extern uint32_t width_of_surface;
extern uint32_t* Draw_to_Virtual_Screen;