Implement miscellaneous HLL functions

Reduce console spam by implementing some commonly used functions.

DrawGraph.SetFontName
SACT2.Mouse_SetPos
SACT2.Sound_ReverseLR
This commit is contained in:
Nunuhara Cabbage
2020-08-16 19:57:46 -07:00
parent 92b58ad8a5
commit d9d8a201e8
8 changed files with 61 additions and 7 deletions
+1 -1
View File
@@ -66,7 +66,7 @@ int bgm_fade(int ch, int time, int volume, bool stop);
//int bgm_seek(int channel, int pos);
int wav_get_unused_channel(void);
int bgm_get_unused_channel(void);
//int wav_reverse_LR(int channel);
int wav_reverse_LR(int ch);
//int bgm_reverse_LR(int channel);
//int wav_get_volume(int channel);
//int bgm_get_volume(int channel);
+1
View File
@@ -171,6 +171,7 @@ bool gfx_get_font_underline(void);
bool gfx_get_font_strikeout(void);
int gfx_get_font_space(void);
SDL_Color gfx_get_font_color(void);
void gfx_set_font_name(const char *name);
int gfx_render_text(Texture *dst, Point pos, char *msg, struct text_metrics *tm, int char_space);
void gfx_draw_text_to_amap(Texture *dst, int x, int y, char *text);
+1
View File
@@ -141,6 +141,7 @@ void handle_events(void);
bool key_is_down(enum sact_keycode code);
void key_clear_flag(void);
void mouse_get_pos(int *x, int *y);
void mouse_set_pos(int x, int y);
void mouse_get_wheel(int *forward, int *back);
void mouse_clear_wheel(void);
void register_input_handler(void(*handler)(const char*));
+19 -1
View File
@@ -28,6 +28,7 @@ struct wav_slot {
Mix_Chunk *chunk;
int channel;
int no;
bool reverse;
};
struct bgm_slot {
@@ -135,6 +136,7 @@ static void wav_realloc(int new_size)
for (int i = wav.nr_slots; i < new_size; i++) {
wav.slots[i].chunk = NULL;
wav.slots[i].channel = -1;
wav.slots[i].reverse = false;
}
wav.nr_slots = new_size;
}
@@ -323,7 +325,11 @@ int wav_play(int ch)
return 1;
}
slot->channel = Mix_PlayChannel(-1, slot->chunk, 0);
return slot->channel >= 0;
if (slot->channel < 0)
return 0;
Mix_SetReverseStereo(slot->channel, slot->reverse);
return 1;
}
int bgm_play(int ch)
@@ -384,6 +390,18 @@ int bgm_fade(int ch, possibly_unused int time, possibly_unused int volume, bool
return 1;
}
int wav_reverse_LR(int ch)
{
struct wav_slot *slot = wav_get_slot(ch);
if (!slot)
return 0;
slot->reverse = true;
if (slot->channel >= 0) {
Mix_SetReverseStereo(slot->channel, 1);
}
return 1;
}
int wav_get_time_length(int ch)
{
struct wav_slot *slot = wav_get_slot(ch);
+5 -1
View File
@@ -155,6 +155,11 @@ bool DrawGraph_GetAlphaColor(int surface, int x, int y, int *a)
return true;
}
void DrawGraph_SetFontName(struct string *text)
{
gfx_set_font_name(text->text);
}
HLL_UNIMPLEMENTED(void, DrawGraph, CopyColorReverse, int dst, int dx, int dy, int src, int sx, int sy, int w, int h);
HLL_UNIMPLEMENTED(void, DrawGraph, Blend, int dst, int dx, int dy, int src, int sx, int sy, int w, int h, int alpha);
HLL_UNIMPLEMENTED(void, DrawGraph, BlendSrcBright, int dst, int dx, int dy, int src, int sx, int sy, int w, int h, int alpha, int rate);
@@ -185,7 +190,6 @@ HLL_UNIMPLEMENTED(void, DrawGraph, CopyStretchBlend, int dst, int dx, int dy, in
HLL_UNIMPLEMENTED(void, DrawGraph, CopyStretchBlendAMap, int dst, int dx, int dy, int dw, int dh, int src, int sx, int sy, int sw, int sh);
HLL_UNIMPLEMENTED(void, DrawGraph, CopyStretchInterp, int dst, int dx, int dy, int dw, int dh, int src, int sx, int sy, int sw, int sh);
HLL_UNIMPLEMENTED(void, DrawGraph, CopyStretchAMapInterp, int dst, int dx, int dy, int dw, int dh, int src, int sx, int sy, int sw, int sh);
HLL_WARN_UNIMPLEMENTED( , void, DrawGraph, SetFontName, struct string *text);
HLL_WARN_UNIMPLEMENTED(&EMPTY_STRING, struct string*, DrawGraph, GetFontName, void);
HLL_UNIMPLEMENTED(void, DrawGraph, CopyRotZoom2Bilinear, int dst, float cx, float cy, int src, float scx, float scy, float rot, float mag);
HLL_UNIMPLEMENTED(void, DrawGraph, CopyRotateY, int write, int dst, int src, int sx, int sy, int w, int h, float rot, float mag);
+14 -4
View File
@@ -63,6 +63,13 @@ int sact_Mouse_GetPos(int *x, int *y)
return mouse_focus && keyboard_focus;
}
int sact_Mouse_SetPos(int x, int y)
{
handle_events();
mouse_set_pos(x, y);
return mouse_focus && keyboard_focus;
}
void sact_Mouse_ClearWheel(void)
{
mouse_clear_wheel();
@@ -193,6 +200,11 @@ int sact_Sound_Fade(int ch, int time, int volume, int stop)
return wav_fade(ch, time, volume, stop);
}
int sact_Sound_ReverseLR(int ch)
{
return wav_reverse_LR(ch);
}
int sact_Sound_GetTimeLength(int ch)
{
return wav_get_time_length(ch);
@@ -241,7 +253,6 @@ HLL_UNIMPLEMENTED(int, SACT2, SP_CreateCustom, int sp);
HLL_UNIMPLEMENTED(int, SACT2, SP_TextBackSpace, int sp_no);
HLL_UNIMPLEMENTED(void, SACT2, GAME_MSG_Get, int index, struct string **text);
HLL_UNIMPLEMENTED(int, SACT2, StringPopFront, struct string **dst, struct string **src);
HLL_WARN_UNIMPLEMENTED(1, int, SACT2, Mouse_SetPos, int x, int y);
HLL_UNIMPLEMENTED(int, SACT2, Joypad_GetNumof, void);
HLL_WARN_UNIMPLEMENTED( , void, SACT2, JoypadQuake_Set, int num, int type, int magnitude);
HLL_UNIMPLEMENTED(int, SACT2, CSV_Load, struct string *filename);
@@ -274,7 +285,6 @@ HLL_UNIMPLEMENTED(int, SACT2, Sound_StopFade, int ch);
HLL_UNIMPLEMENTED(int, SACT2, Sound_IsFade, int ch);
HLL_UNIMPLEMENTED(int, SACT2, Sound_GetPos, int ch);
HLL_UNIMPLEMENTED(int, SACT2, Sound_GetLength, int ch);
HLL_WARN_UNIMPLEMENTED(1, int, SACT2, Sound_ReverseLR, int ch);
HLL_UNIMPLEMENTED(int, SACT2, Sound_GetVolume, int ch);
HLL_UNIMPLEMENTED(int, SACT2, Sound_GetGroupNum, int ch);
HLL_UNIMPLEMENTED(bool, SACT2, Sound_PrepareFromFile, int ch, struct string *filename);
@@ -353,7 +363,7 @@ HLL_LIBRARY(SACT2,
HLL_EXPORT(IntToHankaku, sact_IntToHankaku),
HLL_EXPORT(StringPopFront, SACT2_StringPopFront),
HLL_EXPORT(Mouse_GetPos, sact_Mouse_GetPos),
HLL_EXPORT(Mouse_SetPos, SACT2_Mouse_SetPos),
HLL_EXPORT(Mouse_SetPos, sact_Mouse_SetPos),
HLL_EXPORT(Mouse_ClearWheel, sact_Mouse_ClearWheel),
HLL_EXPORT(Mouse_GetWheel, sact_Mouse_GetWheel),
HLL_EXPORT(Joypad_ClearKeyDownFlag, sact_Joypad_ClearKeyDownFlag),
@@ -412,7 +422,7 @@ HLL_LIBRARY(SACT2,
HLL_EXPORT(Sound_IsFade, SACT2_Sound_IsFade),
HLL_EXPORT(Sound_GetPos, SACT2_Sound_GetPos),
HLL_EXPORT(Sound_GetLength, SACT2_Sound_GetLength),
HLL_EXPORT(Sound_ReverseLR, SACT2_Sound_ReverseLR),
HLL_EXPORT(Sound_ReverseLR, sact_Sound_ReverseLR),
HLL_EXPORT(Sound_GetVolume, SACT2_Sound_GetVolume),
HLL_EXPORT(Sound_GetTimeLength, sact_Sound_GetTimeLength),
HLL_EXPORT(Sound_GetGroupNum, SACT2_Sound_GetGroupNum),
+5
View File
@@ -54,6 +54,11 @@ void mouse_get_pos(int *x, int *y)
SDL_GetMouseState(x, y);
}
void mouse_set_pos(int x, int y)
{
SDL_WarpMouseInWindow(sdl.window, x, y);
}
static int wheel_dir = 0;
void mouse_get_wheel(int *forward, int *back)
+15
View File
@@ -203,6 +203,21 @@ SDL_Color gfx_get_font_color(void)
return font_metrics.color;
}
void gfx_set_font_name(const char *name)
{
static const char mincho_name[] = { 0x82, 0x6c, 0x82, 0x72, 0x20, 0x96, 0xbe, 0x92, 0xa9, 0 };
static const char gothic_name[] = { 0x82, 0x6c, 0x82, 0x72, 0x20, 0x83, 0x53, 0x83, 0x56, 0x83, 0x62, 0x83, 0x4e, 0 };
if (!strcmp(name, mincho_name)) {
font_metrics.face = FONT_MINCHO;
} else if (!strcmp(name, gothic_name)) {
font_metrics.face = FONT_GOTHIC;
} else {
char *u = sjis2utf(name, 0);
WARNING("Unhandled font name: \"%s\"", u);
free(u);
}
}
static void get_glyph(TTF_Font *f, Texture *dst, char *msg, SDL_Color color)
{
SDL_Surface *s = TTF_RenderUTF8_Blended(f, msg, color);