Skip to content

Commit

Permalink
Vita: merge latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
usineur committed Jan 6, 2018
2 parents 1c2277d + 14e5cfe commit 13a2b61
Show file tree
Hide file tree
Showing 25 changed files with 58 additions and 23 deletions.
7 changes: 7 additions & 0 deletions SDLPoP.ini
Expand Up @@ -42,6 +42,13 @@ pop_window_height = default
; NB. Works best using a high resolution.
use_correct_aspect_ratio = false

; Enable pixel perfect scaling. That is, make all pixels the same size by forcing integer scale factors.
; Note: If you enable both integer scaling and the 4:3 aspect ratio setting above,
; then integer scaling will be disabled, unless the window is at least 1600 x 1200 pixels (without the border).
; Integer scaling will also be disabled if the window is smaller than 320 x 200 pixels.
; Note: You need to compile with SDL 2.0.5 or newer for this.
use_integer_scaling = false

; If using a controller with a rumble motor, provide haptic feedback when the kid is hurt.
enable_controller_rumble = true

Expand Down
1 change: 1 addition & 0 deletions doc/ChangeLog.txt
Expand Up @@ -482,3 +482,4 @@ FIXED: Removed redefinition of SDL_COMPILE_TIME_ASSERT.
FIXED: Add (back) SDL_Joystick interface because not all joysticks are SDL_Controller compatible. (implemented by @vanfanel)
DONE: Convert waves to mixer sounds when they are loaded, not when they are first played. (suggested by @vanfanel)
FIXED: Updated Readme.txt - fix macOS instructions.
DONE: Added option to force pixel perfect scaling (integer scale factors).
2 changes: 1 addition & 1 deletion src/GPLv3.h
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/common.h
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/config.h
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/data.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
3 changes: 2 additions & 1 deletion src/data.h
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -676,6 +676,7 @@ extern byte fix_loose_left_of_potion INIT(= 1);
extern byte fix_guard_following_through_closed_gates INIT(= 1);
extern byte fix_safe_landing_on_spikes INIT(= 1);
extern byte use_correct_aspect_ratio INIT(= 0);
extern byte use_integer_scaling INIT(= 0);
extern byte enable_remember_guard_hp INIT(= 1);
extern byte fix_glide_through_wall INIT(= 1);
extern byte fix_drop_through_tapestry INIT(= 1);
Expand Down
2 changes: 1 addition & 1 deletion src/lighting.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/main.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
3 changes: 2 additions & 1 deletion src/options.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -193,6 +193,7 @@ static int global_ini_callback(const char *section, const char *name, const char
process_word("pop_window_width", &pop_window_width, NULL);
process_word("pop_window_height", &pop_window_height, NULL);
process_boolean("use_correct_aspect_ratio", &use_correct_aspect_ratio);
process_boolean("use_integer_scaling", &use_integer_scaling);
process_boolean("enable_controller_rumble", &enable_controller_rumble);
process_boolean("joystick_only_horizontal", &joystick_only_horizontal);
process_int("joystick_threshold", &joystick_threshold, NULL);
Expand Down
2 changes: 1 addition & 1 deletion src/proto.h
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/replay.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/screenshot.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/seg000.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/seg001.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/seg002.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/seg003.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/seg004.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/seg005.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/seg006.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/seg007.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/seg008.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
27 changes: 26 additions & 1 deletion src/seg009.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -2143,6 +2143,21 @@ int __pascal far check_sound_playing() {
return speaker_playing || digi_playing || midi_playing;
}

void window_resized() {
#if SDL_VERSION_ATLEAST(2,0,5) // SDL_RenderSetIntegerScale
if (use_integer_scaling) {
int window_width, window_height;
SDL_GetWindowSize(window_, &window_width, &window_height);
int render_width, render_height;
SDL_RenderGetLogicalSize(renderer_, &render_width, &render_height);
// Disable integer scaling if it would result in downscaling.
// Because then the only suitable integer scaling factor is zero, i.e. the picture disappears.
SDL_bool makes_sense = (window_width >= render_width && window_height >= render_height);
SDL_RenderSetIntegerScale(renderer_, makes_sense);
}
#endif
}

// seg009:38ED
void __pascal far set_gr_mode(byte grmode) {
#ifdef VITA
Expand Down Expand Up @@ -2174,6 +2189,13 @@ void __pascal far set_gr_mode(byte grmode) {
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
pop_window_width, pop_window_height, flags);
renderer_ = SDL_CreateRenderer(window_, -1 , SDL_RENDERER_ACCELERATED );
if (use_integer_scaling) {
#if SDL_VERSION_ATLEAST(2,0,5) // SDL_RenderSetIntegerScale
SDL_RenderSetIntegerScale(renderer_, SDL_TRUE);
#else
printf("Warning: You need to compile with SDL 2.0.5 or newer for the use_integer_scaling option.\n");
#endif
}

SDL_Surface* icon = IMG_Load(locate_file("data/icon.png"));
if (icon == NULL) {
Expand All @@ -2191,6 +2213,8 @@ void __pascal far set_gr_mode(byte grmode) {
}
#endif

window_resized();

/* Migration to SDL2: everything is still blitted to onscreen_surface_, however:
* SDL2 renders textures to the screen instead of surfaces; so for now, every screen
* update causes the onscreen_surface_ to be copied into sdl_texture_, which is
Expand Down Expand Up @@ -3049,6 +3073,7 @@ void idle() {
*/
switch (event.window.event) {
case SDL_WINDOWEVENT_SIZE_CHANGED:
window_resized();
//case SDL_WINDOWEVENT_MOVED:
//case SDL_WINDOWEVENT_RESTORED:
case SDL_WINDOWEVENT_EXPOSED:
Expand Down
2 changes: 1 addition & 1 deletion src/seqtbl.c
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down
2 changes: 1 addition & 1 deletion src/types.h
@@ -1,6 +1,6 @@
/*
SDLPoP, a port/conversion of the DOS game Prince of Persia.
Copyright (C) 2013-2017 Dávid Nagy
Copyright (C) 2013-2018 Dávid Nagy
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down

0 comments on commit 13a2b61

Please sign in to comment.