diff --git a/Makefile b/Makefile index 50e6d47..618b750 100644 --- a/Makefile +++ b/Makefile @@ -28,6 +28,7 @@ $(PROJECT).vpk: eboot.bin param.sfo TEST_OUTPUT = bin/*.S out/$(PROJECT).elf out/$(PROJECT).velf bin/*.o lib/*.a lib/*.o lib/*.S # lib/Makefile LIBS = -lvita2d -lm -lSceLibKernel_stub -lSceTouch_stub -lSceDisplay_stub -lSceGxm_stub -lSceCtrl_stub -lSceRtc_stub -lScePower_stub -lSceSysmodule_stub -lSceCommonDialog_stub -lSceAudio_stub + debugnet: CFLAGS += -DUSE_DEBUGNET -g debugnet: LIBS := -ldebugnet -lSceNet_stub -lSceNetCtl_stub $(LIBS) debugnet: all @@ -36,6 +37,7 @@ eboot.bin: out/$(PROJECT).velf vita-make-fself -s out/$(PROJECT).velf out/eboot.bin param.sfo: + mkdir out || true vita-mksfoex -s TITLE_ID="$(PROJECT_TITLEID)" "$(PROJECT_TITLE)" out/param.sfo out/$(PROJECT).velf: out/$(PROJECT).elf @@ -44,7 +46,7 @@ out/$(PROJECT).velf: out/$(PROJECT).elf out/$(PROJECT).elf: $(HOMEBREW_OBJS) mkdir -p out - $(CC) -Wl,-q $(LDFLAGS) $(HOMEBREW_OBJS) $(LIBS) -o $@ + $(CCP) -Wl,-q $(LDFLAGS) $(HOMEBREW_OBJS) $(LIBS) -o $@ bin/%.o: src/%.c mkdir -p bin diff --git a/src/PSP2.c b/src/PSP2.c index 93b6827..f977a0d 100644 --- a/src/PSP2.c +++ b/src/PSP2.c @@ -1,15 +1,13 @@ - #include #include #include #include +#include "PSP2.h" #include -#include "PSP.h" - #include "doomdef.h" const unsigned char msx_font[] __attribute((aligned(4))) = @@ -64,7 +62,7 @@ const unsigned char msx_font[] __attribute((aligned(4))) = "\x70\x88\x80\x80\x88\x70\x20\x60\x90\x00\x00\x90\x90\x90\x68\x00"; -vita2d_texture *pal_tex, *font_tex; +vita2d_texture *pal_tex = NULL, *font_tex = NULL; byte *paltex_data; uint32_t *palette_data, *font_data; @@ -151,10 +149,8 @@ void ScreenFlash(uint32_t color) sceKernelDelayThread(1000 * 100); } -void PSP2_Video_Init(int screen_scale) +void PSP2_Video_Init(int screen_scale, boolean bilinear_enabled) { - vita2d_init(); - //ScreenFlash(RGBA8(255, 0, 0, 255)); //ScreenFlash(RGBA8(0, 255, 0, 255)); //ScreenFlash(RGBA8(0, 0, 255, 255)); @@ -165,11 +161,17 @@ void PSP2_Video_Init(int screen_scale) { case SCREEN_SCALE_NONE: break; - case SCREEN_SCALE_FIT: - screen_x = 150; + case SCREEN_SCALE_FIT_4_TO_3: + screen_scale_h = (float)SCREEN_H/(float)SCREENHEIGHT; + screen_scale_w = screen_scale_h*((float)SCREENHEIGHT/(float)SCREENWIDTH)*(4.0f/3.0f); + screen_x = ((float)SCREEN_W-screen_scale_w*(float)SCREENWIDTH)/2.0f; + screen_y = 0; + break; + case SCREEN_SCALE_FIT_16_TO_10: + screen_scale_h = (float)SCREEN_H/(float)SCREENHEIGHT; + screen_scale_w = screen_scale_h*((float)SCREENHEIGHT/(float)SCREENWIDTH)*(16.0f/10.0f); + screen_x = ((float)SCREEN_W-screen_scale_w*(float)SCREENWIDTH)/2.0f; screen_y = 0; - screen_scale_w = 2; - screen_scale_h = SCREEN_H/(float)SCREENHEIGHT; break; case SCREEN_SCALE_ORIG: screen_x = 150; @@ -184,13 +186,24 @@ void PSP2_Video_Init(int screen_scale) screen_scale_h = SCREEN_H/(float)SCREENHEIGHT; break; } + if (font_tex == NULL) { + vita2d_init(); + font_tex = vita2d_create_empty_texture(SCREEN_W, SCREEN_H); + font_data = (uint32_t*) vita2d_texture_get_datap(font_tex); + + pal_tex = vita2d_create_empty_texture_format(SCREENWIDTH, SCREENHEIGHT, SCE_GXM_TEXTURE_FORMAT_P8_1BGR); + paltex_data = (byte*) vita2d_texture_get_datap(pal_tex); + palette_data = (uint32_t *)vita2d_texture_get_palette(pal_tex); + } - font_tex = vita2d_create_empty_texture(SCREEN_W, SCREEN_H); - font_data = (uint32_t*) vita2d_texture_get_datap(font_tex); - - pal_tex = vita2d_create_empty_texture_format(SCREENWIDTH, SCREENHEIGHT, SCE_GXM_TEXTURE_FORMAT_P8_1BGR); - paltex_data = (byte*) vita2d_texture_get_datap(pal_tex); - palette_data = (uint32_t *)vita2d_texture_get_palette(pal_tex); + if (bilinear_enabled == true) + { + vita2d_texture_set_filters(pal_tex, SCE_GXM_TEXTURE_FILTER_POINT, SCE_GXM_TEXTURE_FILTER_LINEAR); + } + else + { + vita2d_texture_set_filters(pal_tex, SCE_GXM_TEXTURE_FILTER_POINT, SCE_GXM_TEXTURE_FILTER_POINT); + } } void PSP2_Video_FillScreen(uint32_t size) diff --git a/src/PSP.h b/src/PSP2.h similarity index 87% rename from src/PSP.h rename to src/PSP2.h index 9340462..641d88a 100644 --- a/src/PSP.h +++ b/src/PSP2.h @@ -1,5 +1,5 @@ -#ifndef __PSP_H__ -#define __PSP_H__ +#ifndef __PSP2_H__ +#define __PSP2_H__ #ifdef __cplusplus extern "C" { @@ -31,8 +31,9 @@ extern "C" { #define SCREEN_SCALE_NONE 0 #define SCREEN_SCALE_FULL 1 -#define SCREEN_SCALE_FIT 2 -#define SCREEN_SCALE_ORIG 3 +#define SCREEN_SCALE_FIT_4_TO_3 2 +#define SCREEN_SCALE_FIT_16_TO_10 3 +#define SCREEN_SCALE_ORIG 4 #define RED RGBA8(255,0,0,255) #define GREEN RGBA8(0,255,0,255) @@ -42,8 +43,8 @@ extern "C" { //#define sceCtrlPeekBufferPositive sceCtrlReadBufferPositive -void PSP2_Video_Init(int scr_scale); -void PSP2_Video_FillScreen(); +void PSP2_Video_Init(int scr_scale, boolean bilinear_enabled); +void PSP2_Video_FillScreen(uint32_t size); void PSP2_Video_DrawBuffer(); void font_draw_char(int x, int y, uint32_t color, char c); @@ -92,9 +93,11 @@ unsigned short num2elisa(unsigned short c); void Draw_Char_Hankaku(int x,int y,unsigned char ch,int col,int backcol,int fill); void Draw_Char_Zenkaku(int x,int y,unsigned char u,unsigned char d,int col,int backcol,int fill); void mh_print(int x, int y, unsigned char *str, uint32_t col, int backcol, int fill); -void pgInit(); +void pgInit(int scale, boolean bilinear_enabled); void pgScreenFrame(long mode,long frame); void Change_Resolution(); +uint32_t* PSP2_GetPalettePtr(); +byte* PSP2_Video_GetVideoPtr(); #define PSP2_DIR(path) "ux0:data/" path diff --git a/src/d_main.c b/src/d_main.c index 328f1fc..5265b7b 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -86,7 +86,7 @@ static int access(char *file, int mode) #include "d_main.h" -#include "PSP.h" +#include "PSP2.h" #define MAXPATH 0x108 char *doomwaddir; diff --git a/src/i_main.c b/src/i_main.c index 9c488f1..40de5f3 100644 --- a/src/i_main.c +++ b/src/i_main.c @@ -32,7 +32,7 @@ rcsid[] = "$Id: i_main.c,v 1.4 1997/02/03 22:45:10 b1 Exp $"; #include "m_argv.h" #include "d_main.h" -#include "PSP.h" +#include "PSP2.h" #include "fontb.h" long pg_screenmode; @@ -51,7 +51,8 @@ SceCtrlData ctl; #define PATHLIST_H 20 #define REPEAT_TIME 0x40000 #define BUFSIZE 65536 -#define DEFAULT_SCREEN_SCALE SCREEN_SCALE_FULL +#define DEFAULT_SCREEN_SCALE SCREEN_SCALE_FIT_4_TO_3 +#define DEFAULT_BILINEAR_ENABLED true dirent_t dlist[MAXDIRNUM]; int dlist_num; @@ -66,6 +67,7 @@ int now_depth; char buf[BUFSIZE]; int screen_res; boolean analog_enabled; +boolean bilinear_enabled; int debug_res = 0x0; @@ -101,10 +103,12 @@ int main(int argc, char** argv) sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG); analog_enabled = 0; + + bilinear_enabled = DEFAULT_BILINEAR_ENABLED; //SetupCallbacks(); screen_res = DEFAULT_SCREEN_SCALE; - pgInit(screen_res); + pgInit(screen_res, bilinear_enabled); pgScreenFrame(2,0); pgFillvram(0); @@ -135,9 +139,9 @@ switch(Control()) { } -void pgInit(int scale) +void pgInit(int scale, boolean bilinear_enabled) { - PSP2_Video_Init(scale); + PSP2_Video_Init(scale, bilinear_enabled); //sceDisplaySetMode(0,SCREEN_WIDTH,SCREEN_HEIGHT); pgScreenFrame(0,0); @@ -341,24 +345,37 @@ void Draw_All(void) { switch (screen_res) { case SCREEN_SCALE_FULL: - mh_print(0, 500, "Screen Resolution (press select to change): Fullscreen", rgb2col(255, 255, 0), 0, 0); + mh_print(0, 450, "Screen Resolution (press select to change): Fullstretch", rgb2col(255, 255, 0), 0, 0); + break; + case SCREEN_SCALE_FIT_4_TO_3: + mh_print(0, 450, "Screen Resolution (press select to change): Fit 4:3", rgb2col(255, 255, 0), 0, 0); break; - case SCREEN_SCALE_FIT: - mh_print(0, 500, "Screen Resolution (press select to change): Fit to Screen", rgb2col(255, 255, 0), 0, 0); + case SCREEN_SCALE_FIT_16_TO_10: + mh_print(0, 450, "Screen Resolution (press select to change): Fit 16:10", rgb2col(255, 255, 0), 0, 0); break; case SCREEN_SCALE_ORIG: - mh_print(0, 500, "Screen Resolution (press select to change): Original", rgb2col(255, 255, 0), 0, 0); + mh_print(0, 450, "Screen Resolution (press select to change): Original", rgb2col(255, 255, 0), 0, 0); break; } + + //Bilinear Filtering (Image Smoothing) + if (bilinear_enabled) + { + mh_print(0, 500, "Screen Filter (press start to change): Linear", rgb2col(255, 255, 0), 0, 0); + } + else + { + mh_print(0, 500, "Screen Filter (press start to change): Point", rgb2col(255, 255, 0), 0, 0); + } // Controller mode if (analog_enabled) { - mh_print(0, 450, "Controller Mode (press triangle to change): Analog Stick", rgb2col(255, 255, 0), 0, 0); + mh_print(0, 400, "Controller Mode (press triangle to change): Analog Stick", rgb2col(255, 255, 0), 0, 0); } else { - mh_print(0, 450, "Controller Mode (press triangle to change): D-Pad", rgb2col(255, 255, 0), 0, 0); + mh_print(0, 400, "Controller Mode (press triangle to change): D-Pad", rgb2col(255, 255, 0), 0, 0); } if (dlist_num == 0) @@ -505,6 +522,9 @@ int Control(void) { if (new_pad & SCE_CTRL_TRIANGLE) { Change_Controller_Mode(); } + if (new_pad & SCE_CTRL_START) { + Change_Filtering(); + } return 0; } @@ -519,16 +539,19 @@ void Change_Resolution() switch(screen_res) { case SCREEN_SCALE_FULL: - screen_res = SCREEN_SCALE_FIT; + screen_res = SCREEN_SCALE_FIT_4_TO_3; + break; + case SCREEN_SCALE_FIT_4_TO_3: + screen_res = SCREEN_SCALE_FIT_16_TO_10; break; - case SCREEN_SCALE_FIT: + case SCREEN_SCALE_FIT_16_TO_10: screen_res = SCREEN_SCALE_ORIG; break; case SCREEN_SCALE_ORIG: screen_res = SCREEN_SCALE_FULL; break; } - pgInit(screen_res); + pgInit(screen_res, bilinear_enabled); } void Change_Controller_Mode() @@ -541,6 +564,16 @@ void Change_Controller_Mode() I_SetControlMode(analog_enabled); } +void Change_Filtering() +{ + if (bilinear_enabled == true) { + bilinear_enabled = false; + } else { + bilinear_enabled = true; + } + pgInit(screen_res, bilinear_enabled); +} + void Vita_Audio_Thread() { int size = 256; int freq = 48000; diff --git a/src/i_system.c b/src/i_system.c index 48bb852..d103456 100644 --- a/src/i_system.c +++ b/src/i_system.c @@ -42,7 +42,7 @@ rcsid[] = "$Id: m_bbox.c,v 1.1 1997/02/03 22:45:10 b1 Exp $"; #endif #include "i_system.h" -#include "PSP.h" +#include "PSP2.h" int mb_used = 6; diff --git a/src/i_video.c b/src/i_video.c index 78abc8d..324c249 100644 --- a/src/i_video.c +++ b/src/i_video.c @@ -36,8 +36,7 @@ rcsid[] = "$Id: i_x.c,v 1.6 1997/02/03 22:45:10 b1 Exp $"; #include "doomdef.h" -#include "PSP.h" - +#include "PSP2.h" #define BUF_WIDTH (512) #define SCR_WIDTH (480) @@ -54,6 +53,7 @@ int controls_set = 0; int d_clist_start = 0; int d_clist_curpos = 0; boolean analog = 0; +extern bilinear_enabled; extern SceCtrlData ctl; @@ -1171,7 +1171,7 @@ void I_InitGraphics(void) video_h = h = 200; video_bpp = 8; - PSP2_Video_Init(SCREEN_SCALE_NONE); + PSP2_Video_Init(SCREEN_SCALE_NONE, bilinear_enabled); screens[0] = PSP2_Video_GetVideoPtr(); //(unsigned char *) malloc(SCREENWIDTH * SCREENHEIGHT);