From b602007bc53e7ee50475a8ebca8b2a41b54e33dc Mon Sep 17 00:00:00 2001 From: Alexander Batalov Date: Sat, 18 Jun 2022 19:09:17 +0300 Subject: [PATCH] Cleanup text_object.h See #42 --- src/text_object.cc | 48 +++++++++++++++++++++++++++++++++++----------- src/text_object.h | 36 ---------------------------------- 2 files changed, 37 insertions(+), 47 deletions(-) diff --git a/src/text_object.cc b/src/text_object.cc index 31e2b5d..3748833 100644 --- a/src/text_object.cc +++ b/src/text_object.cc @@ -12,32 +12,58 @@ #include +// The maximum number of text objects that can exist at the same time. +#define TEXT_OBJECTS_MAX_COUNT (20) + +typedef enum TextObjectFlags { + TEXT_OBJECT_MARKED_FOR_REMOVAL = 0x01, + TEXT_OBJECT_UNBOUNDED = 0x02, +} TextObjectFlags; + +typedef struct TextObject { + int flags; + Object* owner; + unsigned int time; + int linesCount; + int sx; + int sy; + int tile; + int x; + int y; + int width; + int height; + unsigned char* data; +} TextObject; + +static void textObjectsTicker(); +static void textObjectFindPlacement(TextObject* textObject); + // 0x51D944 -int gTextObjectsCount = 0; +static int gTextObjectsCount = 0; // 0x51D948 -unsigned int gTextObjectsBaseDelay = 3500; +static unsigned int gTextObjectsBaseDelay = 3500; // 0x51D94C -unsigned int gTextObjectsLineDelay = 1399; +static unsigned int gTextObjectsLineDelay = 1399; // 0x6681C0 -TextObject* gTextObjects[TEXT_OBJECTS_MAX_COUNT]; +static TextObject* gTextObjects[TEXT_OBJECTS_MAX_COUNT]; // 0x668210 -int gTextObjectsWindowWidth; +static int gTextObjectsWindowWidth; // 0x668214 -int gTextObjectsWindowHeight; +static int gTextObjectsWindowHeight; // 0x668218 -unsigned char* gTextObjectsWindowBuffer; +static unsigned char* gTextObjectsWindowBuffer; // 0x66821C -bool gTextObjectsEnabled; +static bool gTextObjectsEnabled; // 0x668220 -bool gTextObjectsInitialized; +static bool gTextObjectsInitialized; // 0x4B0130 int textObjectsInit(unsigned char* windowBuffer, int width, int height) @@ -306,7 +332,7 @@ int textObjectsGetCount() } // 0x4B07F8 -void textObjectsTicker() +static void textObjectsTicker() { if (!gTextObjectsEnabled) { return; @@ -355,7 +381,7 @@ void textObjectsTicker() // Finds best position for placing text object. // // 0x4B0954 -void textObjectFindPlacement(TextObject* textObject) +static void textObjectFindPlacement(TextObject* textObject) { int tileScreenX; int tileScreenY; diff --git a/src/text_object.h b/src/text_object.h index f9f10b3..4e088d7 100644 --- a/src/text_object.h +++ b/src/text_object.h @@ -4,40 +4,6 @@ #include "geometry.h" #include "obj_types.h" -// The maximum number of text objects that can exist at the same time. -#define TEXT_OBJECTS_MAX_COUNT (20) - -typedef enum TextObjectFlags { - TEXT_OBJECT_MARKED_FOR_REMOVAL = 0x01, - TEXT_OBJECT_UNBOUNDED = 0x02, -} TextObjectFlags; - -typedef struct TextObject { - int flags; - Object* owner; - unsigned int time; - int linesCount; - int sx; - int sy; - int tile; - int x; - int y; - int width; - int height; - unsigned char* data; -} TextObject; - -extern int gTextObjectsCount; -extern unsigned int gTextObjectsBaseDelay; -extern unsigned int gTextObjectsLineDelay; - -extern TextObject* gTextObjects[TEXT_OBJECTS_MAX_COUNT]; -extern int gTextObjectsWindowWidth; -extern int gTextObjectsWindowHeight; -extern unsigned char* gTextObjectsWindowBuffer; -extern bool gTextObjectsEnabled; -extern bool gTextObjectsInitialized; - int textObjectsInit(unsigned char* windowBuffer, int width, int height); int textObjectsReset(); void textObjectsFree(); @@ -48,8 +14,6 @@ void textObjectsSetLineDelay(double value); int textObjectAdd(Object* object, char* string, int font, int color, int a5, Rect* rect); void textObjectsRenderInRect(Rect* rect); int textObjectsGetCount(); -void textObjectsTicker(); -void textObjectFindPlacement(TextObject* textObject); void textObjectsRemoveByOwner(Object* object); #endif /* TEXT_OBJECT_H */