Subversion Repositories Games.Prince of Persia

Rev

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

Rev 2 Rev 6
Line 1670... Line 1670...
1670
int digi_unavailable = 0;
1670
int digi_unavailable = 0;
1671
void init_digi() {
1671
void init_digi() {
1672
        if (digi_unavailable) return;
1672
        if (digi_unavailable) return;
1673
        if (digi_audiospec != NULL) return;
1673
        if (digi_audiospec != NULL) return;
1674
        // Open the audio device. Called once.
1674
        // Open the audio device. Called once.
1675
        //printf("init_digi(): called\n");
1675
        //fprintf(stderr, "init_digi(): called\n");
1676
 
1676
 
1677
        SDL_AudioFormat desired_audioformat;
1677
        SDL_AudioFormat desired_audioformat;
1678
        SDL_version version;
1678
        SDL_version version;
1679
        SDL_GetVersion(&version);
1679
        SDL_GetVersion(&version);
1680
        //printf("SDL Version = %d.%d.%d\n", version.major, version.minor, version.patch);
1680
        //printf("SDL Version = %d.%d.%d\n", version.major, version.minor, version.patch);
Line 1712... Line 1712...
1712
                return;
1712
                return;
1713
        }
1713
        }
1714
        Mix_AllocateChannels(1);
1714
        Mix_AllocateChannels(1);
1715
        Mix_ChannelFinished(channel_finished);
1715
        Mix_ChannelFinished(channel_finished);
1716
        Mix_HookMusicFinished(music_finished);
1716
        Mix_HookMusicFinished(music_finished);
-
 
1717
//printf ("init_digi(): SETTING SOUND AND MUSIC VOLUME\n");
-
 
1718
   Mix_Volume (-1, is_sound_on ? MIX_VOLUME : 0);
-
 
1719
   Mix_VolumeMusic (is_sound_on ? MIX_VOLUME : 0);
1717
#endif
1720
#endif
1718
        digi_audiospec = desired;
1721
        digi_audiospec = desired;
1719
}
1722
}
1720
 
1723
 
1721
#ifdef USE_MIXER
1724
#ifdef USE_MIXER
Line 1819... Line 1822...
1819
        //if (!is_sound_on) return;
1822
        //if (!is_sound_on) return;
1820
        init_digi();
1823
        init_digi();
1821
        if (digi_unavailable) return;
1824
        if (digi_unavailable) return;
1822
        stop_sounds();
1825
        stop_sounds();
1823
        //printf("playing chunk sound %p\n", buffer);
1826
        //printf("playing chunk sound %p\n", buffer);
-
 
1827
//printf ("play_chunk_sound(): SETTING VOLUME\n");
-
 
1828
//   Mix_Volume (sound_channel, is_sound_on ? MIX_VOLUME : 0);
1824
        if (Mix_PlayChannel(sound_channel, buffer->chunk, 0) == -1) {
1829
   if (Mix_PlayChannel(sound_channel, buffer->chunk, 0) == -1) {
1825
                sdlperror("Mix_PlayChannel");
1830
                sdlperror("Mix_PlayChannel");
1826
        }
1831
        }
1827
        digi_playing = 1;
1832
        digi_playing = 1;
1828
}
1833
}
1829
 
1834
 
1830
void __pascal far play_music_sound(sound_buffer_type far *buffer) {
1835
void __pascal far play_music_sound(sound_buffer_type far *buffer) {
1831
        init_digi();
1836
        init_digi();
1832
        if (digi_unavailable) return;
1837
        if (digi_unavailable) return;
1833
        stop_sounds();
1838
        stop_sounds();
-
 
1839
//printf ("play_music_sound(): SETTING MUSIC VOLUME\n");
-
 
1840
//   Mix_VolumeMusic (is_sound_on ? MIX_VOLUME : 0);
1834
        if (Mix_PlayMusic(buffer->music, 0) == -1) {
1841
   if (Mix_PlayMusic(buffer->music, 0) == -1) {
1835
                sdlperror("Mix_PlayMusic");
1842
                sdlperror("Mix_PlayMusic");
1836
        }
1843
        }
1837
        digi_playing = 1;
1844
        digi_playing = 1;
1838
}
1845
}
1839
 
1846
 
Line 2026... Line 2033...
2026
        is_sound_on = new_state;
2033
        is_sound_on = new_state;
2027
        //if (!is_sound_on) stop_sounds();
2034
        //if (!is_sound_on) stop_sounds();
2028
#ifdef USE_MIXER
2035
#ifdef USE_MIXER
2029
        init_digi();
2036
        init_digi();
2030
        if (digi_unavailable) return;
2037
        if (digi_unavailable) return;
-
 
2038
//printf ("turn_sound_on_off(): SETTING SOUND AND MUSIC VOLUME\n");
2031
        Mix_Volume(-1, is_sound_on ? MIX_MAX_VOLUME : 0);
2039
        Mix_Volume(-1, is_sound_on ? MIX_VOLUME : 0);
2032
        Mix_VolumeMusic(is_sound_on ? MIX_MAX_VOLUME : 0);
2040
        Mix_VolumeMusic(is_sound_on ? MIX_VOLUME : 0);
2033
#endif
2041
#endif
2034
}
2042
}
2035
 
2043
 
2036
// seg009:7299
2044
// seg009:7299
2037
int __pascal far check_sound_playing() {
2045
int __pascal far check_sound_playing() {
Line 2051... Line 2059...
2051
                SDL_RenderSetIntegerScale(renderer_, makes_sense);
2059
                SDL_RenderSetIntegerScale(renderer_, makes_sense);
2052
        }
2060
        }
2053
#endif
2061
#endif
2054
}
2062
}
2055
 
2063
 
2056
void xbrz_scale24 (size_t factor, const uint32_t *src, uint32_t *trg, int srcWidth, int srcHeight, int yFirst, int yLast);
2064
void xbrz_scale (size_t factor, const uint32_t *src, uint32_t *trg, int srcWidth, int srcHeight, int yFirst, int yLast, bool has_alpha_channel);
2057
static void *hqx_pixels32 = NULL;
2065
static void *hqx_pixels32 = NULL;
2058
static void *hqx_resized_pixels32 = NULL;
2066
static void *hqx_resized_pixels32 = NULL;
2059
static void *hqx_resized_pixels24 = NULL;
2067
static void *hqx_resized_pixels24 = NULL;
2060
int filter_level = 1;
2068
int filter_level = 1;
2061
 
2069
 
Line 2157... Line 2165...
2157
                {
2165
                {
2158
                        uint8_t *hqx_24bpp_ptr;
2166
                        uint8_t *hqx_24bpp_ptr;
2159
                        uint8_t *hqx_32bpp_ptr;
2167
                        uint8_t *hqx_32bpp_ptr;
2160
 
2168
 
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; }
2169
                        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
                        xbrz_scale24 (filter_level, hqx_pixels32, hqx_resized_pixels32, 320, 200, 0, 200);
2170
                        xbrz_scale (filter_level, hqx_pixels32, hqx_resized_pixels32, 320, 200, 0, 200, false);
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++; }
2171
                        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
 
2172
 
2165
                        SDL_UpdateTexture(sdl_texture_, NULL, hqx_resized_pixels24, onscreen_surface_->pitch * filter_level);
2173
                        SDL_UpdateTexture(sdl_texture_, NULL, hqx_resized_pixels24, onscreen_surface_->pitch * filter_level);
2166
                }
2174
                }
2167
                else
2175
                else