mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-08 06:47:23 -04:00
PS2: Fix max texture size being wrong
This commit is contained in:
parent
2751661a4e
commit
46d2e4124e
@ -55,7 +55,7 @@ void Audio_PlayStepSound(cc_uint8 type);
|
||||
cc_bool AudioBackend_Init(void);
|
||||
void AudioBackend_Tick(void);
|
||||
void AudioBackend_Free(void);
|
||||
void AudioBackend_LoadSounds();
|
||||
void AudioBackend_LoadSounds(void);
|
||||
|
||||
#define AUDIO_USAGE_BUFFER 0x01
|
||||
#define AUDIO_USAGE_STREAM 0x02
|
||||
@ -95,6 +95,13 @@ cc_result AudioPool_Play(struct AudioData* data);
|
||||
void AudioPool_Close(void);
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Sound context------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
/* Plays the given audio sound sample */
|
||||
cc_result SoundContext_Play(struct AudioContext* ctx, struct AudioData* data);
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*---------------------------------------------------------Sounds---------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
|
@ -308,7 +308,7 @@ void Gfx_DisableTextureOffset(void) {
|
||||
UpdateTextureMatrix();
|
||||
}
|
||||
|
||||
static CC_INLINE int FindInPalette(cc_uint16* pal, int pal_size, cc_uint16 color) {
|
||||
static CC_INLINE int FindInPalette(BitmapCol* pal, int pal_size, BitmapCol color) {
|
||||
if ((color >> 15) == 0) return 0;
|
||||
|
||||
for (int i = 1; i < pal_size; i++)
|
||||
@ -320,7 +320,7 @@ static CC_INLINE int FindInPalette(cc_uint16* pal, int pal_size, cc_uint16 color
|
||||
|
||||
static CC_INLINE int CalcPalette(cc_uint16* palette, struct Bitmap* bmp, int rowWidth) {
|
||||
int width = bmp->width, height = bmp->height;
|
||||
cc_uint16* row = bmp->scan0;
|
||||
BitmapCol* row = bmp->scan0;
|
||||
|
||||
int pal_count = 1;
|
||||
palette[0] = 0; // entry 0 is transparent colour
|
||||
@ -329,7 +329,7 @@ static CC_INLINE int CalcPalette(cc_uint16* palette, struct Bitmap* bmp, int row
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
cc_uint16 color = row[x];
|
||||
BitmapCol color = row[x];
|
||||
int idx = FindInPalette(palette, pal_count, color);
|
||||
if (idx >= 0) continue;
|
||||
|
||||
@ -349,7 +349,7 @@ GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags,
|
||||
tex->width = bmp->width;
|
||||
tex->height = bmp->height;
|
||||
|
||||
cc_uint16 palette[256];
|
||||
BitmapCol palette[256];
|
||||
int pal_count = CalcPalette(palette, bmp, rowWidth);
|
||||
int tex_size, tex_fmt;
|
||||
|
||||
@ -374,7 +374,7 @@ GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags,
|
||||
}
|
||||
|
||||
int offset = tex->texBase * TEX_BLOCK_SIZE;
|
||||
u16* addr = (u16*) ((u8*)VRAM_A + offset);
|
||||
u16* addr = (u16*)((u8*)VRAM_A + offset);
|
||||
u16* tmp_u16[128]; // 256 bytes
|
||||
char* tmp = (char*)tmp_u16;
|
||||
|
||||
@ -382,7 +382,7 @@ GfxResourceID Gfx_AllocTexture(struct Bitmap* bmp, int rowWidth, cc_uint8 flags,
|
||||
int stride;
|
||||
|
||||
int width = bmp->width, height = bmp->height;
|
||||
cc_uint16* row = bmp->scan0;
|
||||
BitmapCol* row = bmp->scan0;
|
||||
|
||||
if (tex_fmt == GL_RGB4) {
|
||||
stride = width >> 3;
|
||||
|
@ -152,7 +152,7 @@ void Gfx_Create(void) {
|
||||
Gfx.MinTexHeight = 4;
|
||||
Gfx.MaxTexWidth = 1024;
|
||||
Gfx.MaxTexHeight = 1024;
|
||||
Gfx.MaxTexSize = 512 * 512;
|
||||
Gfx.MaxTexSize = 256 * 256;
|
||||
Gfx.Created = true;
|
||||
|
||||
Gfx_RestoreState();
|
||||
|
@ -108,6 +108,24 @@ void Audio_FreeChunks(struct AudioChunk* chunks, int numChunks) {
|
||||
void AudioBackend_LoadSounds(void) { Sounds_LoadDefault(); }
|
||||
#endif
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*------------------------------------------------------Sound context------------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
#ifndef CC_BUILD_NOSOUNDS
|
||||
cc_result SoundContext_Play(struct AudioContext* ctx, struct AudioData* data) {
|
||||
cc_result res;
|
||||
Audio_SetVolume(ctx, data->volume);
|
||||
|
||||
if ((res = Audio_SetFormat(ctx, data->channels, data->sampleRate, data->rate))) return res;
|
||||
if ((res = Audio_QueueChunk(ctx, &data->chunk))) return res;
|
||||
if ((res = Audio_Play(ctx))) return res;
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*########################################################################################################################*
|
||||
*---------------------------------------------------Audio context code----------------------------------------------------*
|
||||
*#########################################################################################################################*/
|
||||
@ -116,16 +134,6 @@ struct AudioContext music_ctx;
|
||||
static struct AudioContext context_pool[POOL_MAX_CONTEXTS];
|
||||
|
||||
#ifndef CC_BUILD_NOSOUNDS
|
||||
static cc_result PlayAudio(struct AudioContext* ctx, struct AudioData* data) {
|
||||
cc_result res;
|
||||
Audio_SetVolume(ctx, data->volume);
|
||||
|
||||
if ((res = Audio_SetFormat(ctx, data->channels, data->sampleRate, data->rate))) return res;
|
||||
if ((res = Audio_QueueChunk(ctx, &data->chunk))) return res;
|
||||
if ((res = Audio_Play(ctx))) return res;
|
||||
return 0;
|
||||
}
|
||||
|
||||
cc_result AudioPool_Play(struct AudioData* data) {
|
||||
struct AudioContext* ctx;
|
||||
int inUse, i;
|
||||
@ -140,7 +148,7 @@ cc_result AudioPool_Play(struct AudioData* data) {
|
||||
if (inUse > 0) continue;
|
||||
|
||||
if (!Audio_FastPlay(ctx, data)) continue;
|
||||
return PlayAudio(ctx, data);
|
||||
return SoundContext_Play(ctx, data);
|
||||
}
|
||||
|
||||
/* Try again with all contexts, even if need to recreate one (expensive) */
|
||||
@ -151,7 +159,7 @@ cc_result AudioPool_Play(struct AudioData* data) {
|
||||
if (res) return res;
|
||||
if (inUse > 0) continue;
|
||||
|
||||
return PlayAudio(ctx, data);
|
||||
return SoundContext_Play(ctx, data);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user