Subversion Repositories Games.Prince of Persia

Rev

Rev 1 | Rev 6 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1 Rev 2
Line 2051... Line 2051...
2051
                SDL_RenderSetIntegerScale(renderer_, makes_sense);
2051
                SDL_RenderSetIntegerScale(renderer_, makes_sense);
2052
        }
2052
        }
2053
#endif
2053
#endif
2054
}
2054
}
2055
 
2055
 
2056
extern void hqx_32 (int level, uint32_t *src_pixels, uint32_t *dest_pixels, int src_width, int src_height);
2056
void xbrz_scale24 (size_t factor, const uint32_t *src, uint32_t *trg, int srcWidth, int srcHeight, int yFirst, int yLast);
2057
static void *hqx_pixels32 = NULL;
2057
static void *hqx_pixels32 = NULL;
2058
static void *hqx_resized_pixels32 = NULL;
2058
static void *hqx_resized_pixels32 = NULL;
2059
static void *hqx_resized_pixels24 = NULL;
2059
static void *hqx_resized_pixels24 = NULL;
2060
int hqx_level = 1;
2060
int filter_level = 1;
2061
 
2061
 
2062
// seg009:38ED
2062
// seg009:38ED
2063
void __pascal far set_gr_mode(byte grmode) {
2063
void __pascal far set_gr_mode(byte grmode) {
2064
        if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE |
2064
        if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE |
2065
                     SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC ) != 0) {
2065
                     SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC ) != 0) {
Line 2117... Line 2117...
2117
         * */
2117
         * */
2118
        onscreen_surface_ = SDL_CreateRGBSurface(0, 320, 200, 24, 0xFF, 0xFF << 8, 0xFF << 16, 0) ;
2118
        onscreen_surface_ = SDL_CreateRGBSurface(0, 320, 200, 24, 0xFF, 0xFF << 8, 0xFF << 16, 0) ;
2119
 
2119
 
2120
        hqx_pixels32 = (void *) malloc (320 * 200 * 4);
2120
        hqx_pixels32 = (void *) malloc (320 * 200 * 4);
2121
        if (hqx_pixels32 == NULL) { sdlperror ("hqx original 32bpp image buffer allocation failure"); quit (1); }
2121
        if (hqx_pixels32 == NULL) { sdlperror ("hqx original 32bpp image buffer allocation failure"); quit (1); }
2122
        hqx_resized_pixels32 = (void *) realloc (hqx_resized_pixels32, 4 * 320 * 4 * 200 * 4);
2122
        hqx_resized_pixels32 = (void *) realloc (hqx_resized_pixels32, 6 * 320 * 6 * 200 * 4);
2123
        if (hqx_resized_pixels32 == NULL) { sdlperror ("hqx resized 32bpp image buffer allocation failure"); quit (1); }
2123
        if (hqx_resized_pixels32 == NULL) { sdlperror ("hqx resized 32bpp image buffer allocation failure"); quit (1); }
2124
        hqx_resized_pixels24 = (void *) realloc (hqx_resized_pixels24, 4 * 320 * 4 * 200 * 3);
2124
        hqx_resized_pixels24 = (void *) realloc (hqx_resized_pixels24, 6 * 320 * 6 * 200 * 3);
2125
        if (hqx_resized_pixels24 == NULL) { sdlperror ("hqx resized 24bpp image buffer allocation failure"); quit (1); }
2125
        if (hqx_resized_pixels24 == NULL) { sdlperror ("hqx resized 24bpp image buffer allocation failure"); quit (1); }
2126
 
2126
 
2127
        sdl_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGB24, SDL_TEXTUREACCESS_STREAMING, 320 * hqx_level, 200 * hqx_level);
2127
        sdl_texture_ = SDL_CreateTexture(renderer_, SDL_PIXELFORMAT_RGB24, SDL_TEXTUREACCESS_STREAMING, 320 * filter_level, 200 * filter_level);
2128
        screen_updates_suspended = 0;
2128
        screen_updates_suspended = 0;
2129
 
2129
 
2130
        if (onscreen_surface_ == NULL) {
2130
        if (onscreen_surface_ == NULL) {
2131
                sdlperror("SDL_SetVideoMode");
2131
                sdlperror("SDL_SetVideoMode");
2132
                quit(1);
2132
                quit(1);
Line 2151... Line 2151...
2151
 
2151
 
2152
#ifdef USE_REPLAY
2152
#ifdef USE_REPLAY
2153
        if (replaying && skipping_replay) return;
2153
        if (replaying && skipping_replay) return;
2154
#endif
2154
#endif
2155
        if (!screen_updates_suspended) {
2155
        if (!screen_updates_suspended) {
2156
                if (hqx_level > 1)
2156
                if (filter_level > 1)
2157
                {
2157
                {
2158
                        uint8_t *hqx_24bpp_ptr;
2158
                        uint8_t *hqx_24bpp_ptr;
2159
                        uint8_t *hqx_32bpp_ptr;
2159
                        uint8_t *hqx_32bpp_ptr;
2160
 
2160
 
2161
                        hqx_24bpp_ptr = onscreen_surface_->pixels; hqx_32bpp_ptr = hqx_pixels32; for (int hqx_pixel_index = 0; hqx_pixel_index < 320 * 200; hqx_pixel_index++) { *hqx_32bpp_ptr++ = *hqx_24bpp_ptr++; *hqx_32bpp_ptr++ = *hqx_24bpp_ptr++; *hqx_32bpp_ptr++ = *hqx_24bpp_ptr++; *hqx_32bpp_ptr++ = 0xFF; }
2161
                        hqx_24bpp_ptr = onscreen_surface_->pixels; hqx_32bpp_ptr = hqx_pixels32; for (int hqx_pixel_index = 0; hqx_pixel_index < 320 * 200; hqx_pixel_index++) { *hqx_32bpp_ptr++ = *hqx_24bpp_ptr++; *hqx_32bpp_ptr++ = *hqx_24bpp_ptr++; *hqx_32bpp_ptr++ = *hqx_24bpp_ptr++; *hqx_32bpp_ptr++ = 0xFF; }
2162
                        hqx_32 (hqx_level, hqx_pixels32, hqx_resized_pixels32, 320, 200);
2162
                        xbrz_scale24 (filter_level, hqx_pixels32, hqx_resized_pixels32, 320, 200, 0, 200);
2163
                        hqx_32bpp_ptr = hqx_resized_pixels32; hqx_24bpp_ptr = hqx_resized_pixels24; for (int hqx_pixel_index = 0; hqx_pixel_index < hqx_level * 320 * hqx_level * 200; hqx_pixel_index++) { *hqx_24bpp_ptr++ = *hqx_32bpp_ptr++; *hqx_24bpp_ptr++ = *hqx_32bpp_ptr++; *hqx_24bpp_ptr++ = *hqx_32bpp_ptr++; hqx_32bpp_ptr++; }
2163
                        hqx_32bpp_ptr = hqx_resized_pixels32; hqx_24bpp_ptr = hqx_resized_pixels24; for (int hqx_pixel_index = 0; hqx_pixel_index < filter_level * 320 * filter_level * 200; hqx_pixel_index++) { *hqx_24bpp_ptr++ = *hqx_32bpp_ptr++; *hqx_24bpp_ptr++ = *hqx_32bpp_ptr++; *hqx_24bpp_ptr++ = *hqx_32bpp_ptr++; hqx_32bpp_ptr++; }
2164
 
2164
 
2165
                        SDL_UpdateTexture(sdl_texture_, NULL, hqx_resized_pixels24, onscreen_surface_->pitch * hqx_level);
2165
                        SDL_UpdateTexture(sdl_texture_, NULL, hqx_resized_pixels24, onscreen_surface_->pitch * filter_level);
2166
                }
2166
                }
2167
                else
2167
                else
2168
                        SDL_UpdateTexture(sdl_texture_, NULL, onscreen_surface_->pixels, onscreen_surface_->pitch);
2168
                        SDL_UpdateTexture(sdl_texture_, NULL, onscreen_surface_->pixels, onscreen_surface_->pitch);
2169
 
2169
 
2170
                SDL_RenderClear(renderer_);
2170
                SDL_RenderClear(renderer_);