Fix StoatSpriteEngine.SP_SetDrawMethod

The method parameter of this function has a different meaning from that
of SACT2.SP_SetDrawMethod.

I've only checked it in Widenyo, but it seems 0 and 1 are valid values
and 1 is additive blending.
This commit is contained in:
kichikuou
2022-03-25 10:49:25 +09:00
parent 6d34f0e18d
commit ba1dcd6e21
6 changed files with 57 additions and 17 deletions
+4 -4
View File
@@ -27,10 +27,10 @@ struct cg;
struct text_metrics;
enum draw_method {
DRAW_METHOD_NORMAL = 0,
DRAW_METHOD_SCREEN = 1,
DRAW_METHOD_MULTIPLY = 2,
NR_DRAW_METHODS
DRAW_METHOD_NORMAL,
DRAW_METHOD_SCREEN,
DRAW_METHOD_MULTIPLY,
DRAW_METHOD_ADDITIVE,
};
typedef struct texture {
+2 -2
View File
@@ -72,8 +72,8 @@ static inline void sprite_set_z2(struct sact_sprite *sp, int z, int z2) { scene_
int sprite_get_blend_rate(struct sact_sprite *sp);
void sprite_set_blend_rate(struct sact_sprite *sp, int rate);
static inline void sprite_set_show(struct sact_sprite *sp, bool show) { scene_set_sprite_show(&sp->sp, show); }
int sprite_set_draw_method(struct sact_sprite *sp, int method);
int sprite_get_draw_method(struct sact_sprite *sp);
int sprite_set_draw_method(struct sact_sprite *sp, enum draw_method method);
enum draw_method sprite_get_draw_method(struct sact_sprite *sp);
static inline int sprite_exists_alpha(struct sact_sprite *sp) { return sp->sp.has_alpha; }
static inline int sprite_get_pos_x(struct sact_sprite *sp) { return sp->rect.x; }
static inline int sprite_get_pos_y(struct sact_sprite *sp) { return sp->rect.y; }
+17 -3
View File
@@ -337,15 +337,29 @@ int sact_SP_SetDrawMethod(int sp_no, int method)
{
struct sact_sprite *sp = sact_get_sprite(sp_no);
if (!sp) return 0;
return sprite_set_draw_method(sp, method);
return 1;
switch (method) {
case 0: return sprite_set_draw_method(sp, DRAW_METHOD_NORMAL);
case 1: return sprite_set_draw_method(sp, DRAW_METHOD_SCREEN);
case 2: return sprite_set_draw_method(sp, DRAW_METHOD_MULTIPLY);
default:
WARNING("unknown draw method: %d", method);
return 0;
}
}
int sact_SP_GetDrawMethod(int sp_no)
{
struct sact_sprite *sp = sact_try_get_sprite(sp_no);
if (!sp) return DRAW_METHOD_NORMAL;
return sprite_get_draw_method(sp);
int method = sprite_get_draw_method(sp);
switch (method) {
case DRAW_METHOD_NORMAL: return 0;
case DRAW_METHOD_SCREEN: return 1;
case DRAW_METHOD_MULTIPLY: return 2;
default:
WARNING("unknown draw method: %d", method);
return 0;
}
}
int sact_SP_IsUsing(int sp_no)
+29 -2
View File
@@ -44,6 +44,33 @@ HLL_WARN_UNIMPLEMENTED( , void, StoatSpriteEngine, SetVolumeMixerSEGroupNum, int
HLL_WARN_UNIMPLEMENTED( , void, StoatSpriteEngine, SetVolumeMixerBGMGroupNum, int n);
HLL_WARN_UNIMPLEMENTED(0, int, StoatSpriteEngine, Sound_GetGroupNumFromDataNum, int n);
static int StoatSpriteEngine_SP_SetDrawMethod(int sp_no, int method)
{
struct sact_sprite *sp = sact_get_sprite(sp_no);
if (!sp) return 0;
switch (method) {
case 0: return sprite_set_draw_method(sp, DRAW_METHOD_NORMAL);
case 1: return sprite_set_draw_method(sp, DRAW_METHOD_ADDITIVE);
default:
WARNING("unknown draw method: %d", method);
return 0;
}
}
static int StoatSpriteEngine_SP_GetDrawMethod(int sp_no)
{
struct sact_sprite *sp = sact_try_get_sprite(sp_no);
if (!sp) return DRAW_METHOD_NORMAL;
int method = sprite_get_draw_method(sp);
switch (method) {
case DRAW_METHOD_NORMAL: return 0;
case DRAW_METHOD_ADDITIVE: return 1;
default:
WARNING("unknown draw method: %d", method);
return 0;
}
}
struct text_metrics text_sprite_tm = {
.color = { .r = 255, .g = 255, .b = 255, .a = 255 },
.outline_color = { .r = 0, .g = 0, .b = 0, .a = 255 },
@@ -793,7 +820,7 @@ HLL_LIBRARY(StoatSpriteEngine,
HLL_EXPORT(SP_SetZ, sact_SP_SetZ),
HLL_EXPORT(SP_SetBlendRate, sact_SP_SetBlendRate),
HLL_EXPORT(SP_SetShow, sact_SP_SetShow),
HLL_EXPORT(SP_SetDrawMethod, sact_SP_SetDrawMethod),
HLL_EXPORT(SP_SetDrawMethod, StoatSpriteEngine_SP_SetDrawMethod),
HLL_EXPORT(SP_IsUsing, sact_SP_IsUsing),
HLL_EXPORT(SP_ExistAlpha, sact_SP_ExistsAlpha),
HLL_EXPORT(SP_GetPosX, sact_SP_GetPosX),
@@ -803,7 +830,7 @@ HLL_LIBRARY(StoatSpriteEngine,
HLL_EXPORT(SP_GetZ, sact_SP_GetZ),
HLL_EXPORT(SP_GetBlendRate, sact_SP_GetBlendRate),
HLL_EXPORT(SP_GetShow, sact_SP_GetShow),
HLL_EXPORT(SP_GetDrawMethod, sact_SP_GetDrawMethod),
HLL_EXPORT(SP_GetDrawMethod, StoatSpriteEngine_SP_GetDrawMethod),
HLL_EXPORT(SP_SetTextHome, sact_SP_SetTextHome),
HLL_EXPORT(SP_SetTextLineSpace, sact_SP_SetTextLineSpace),
HLL_EXPORT(SP_SetTextCharSpace, sact_SP_SetTextCharSpace),
+2 -6
View File
@@ -179,18 +179,14 @@ void sprite_set_blend_rate(struct sact_sprite *sp, int rate)
sprite_dirty(sp);
}
int sprite_set_draw_method(struct sact_sprite *sp, int method)
int sprite_set_draw_method(struct sact_sprite *sp, enum draw_method method)
{
if (method < 0 || method >= NR_DRAW_METHODS) {
WARNING("unknown draw method: %d", method);
return 0;
}
sprite_get_texture(sp)->draw_method = method;
sprite_dirty(sp);
return 1;
}
int sprite_get_draw_method(struct sact_sprite *sp)
enum draw_method sprite_get_draw_method(struct sact_sprite *sp)
{
return sprite_get_texture(sp)->draw_method;
}
+3
View File
@@ -419,6 +419,9 @@ void gfx_render_texture(struct texture *t, Rectangle *r)
case DRAW_METHOD_MULTIPLY:
glBlendFuncSeparate(GL_DST_COLOR, GL_ZERO, GL_ZERO, GL_ONE);
break;
case DRAW_METHOD_ADDITIVE:
glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE, GL_ZERO, GL_ONE);
break;
default:
// FIXME: why doesn't this work?
//if (t->alpha_mod != 255) {