Functions for high-level message buffer operations. More...
Functions | |
EZTR_MsgBuffer * | EZTR_MsgBuffer_Create () |
Creates a new message buffer object on the heap. | |
EZTR_MsgBuffer * | EZTR_MsgBuffer_CreateFromStr (char *src) |
Creates a new message buffer object on the heap, and copies src into it. | |
EZTR_MsgBuffer * | EZTR_MsgBuffer_CreateFromStrN (char *src, size_t len) |
Creates a new message buffer object on the heap, and copies src into it for up to len bytes. | |
void | EZTR_MsgBuffer_Destroy (EZTR_MsgBuffer *buf) |
Frees/destroys a message buffer. | |
u32 | EZTR_MsgBuffer_Copy (EZTR_MsgBuffer *dst, char *src) |
Copies data from src into the message buffer dst . | |
u32 | EZTR_MsgBuffer_NCopy (EZTR_MsgBuffer *dst, char *src, size_t len) |
Copies data from src into the message buffer dst , up to len bytes. | |
u32 | EZTR_MsgBuffer_Len (EZTR_MsgBuffer *buf) |
Gets the size of the message buffer's stored data, in bytes. | |
u32 | EZTR_MsgBuffer_ContentLen (EZTR_MsgBuffer *buf) |
Gets the size of the message buffer's content region, in bytes. | |
void | EZTR_MsgBuffer_WriteDefaultHeader (EZTR_MsgBuffer *buf) |
Sets a message buffer's header to default values. | |
void | EZTR_MsgBuffer_WriteHeader (EZTR_MsgBuffer *buf, u8 text_box_type, u8 text_box_y_pos, u8 display_icon, u16 next_message_id, u16 first_item_rupees, u16 second_item_rupees) |
u8 | EZTR_MsgBuffer_GetTextBoxType (EZTR_MsgBuffer *buf) |
Retrieves the text_box_type from a message buffer's header. | |
void | EZTR_MsgBuffer_SetTextBoxType (EZTR_MsgBuffer *buf, u8 type) |
Sets the text_box_type of the message buffer's header. | |
u8 | EZTR_MsgBuffer_GetTextBoxYPos (EZTR_MsgBuffer *buf) |
Retrieves the text_box_y_pos from a message buffer's header. | |
void | EZTR_MsgBuffer_SetTextBoxYPos (EZTR_MsgBuffer *buf, u8 pos) |
Sets the text_box_y_pos of the message buffer's header. | |
u8 | EZTR_MsgBuffer_GetTextBoxDisplayIcon (EZTR_MsgBuffer *buf) |
Retrieves the display_icon from a message buffer's header. | |
void | EZTR_MsgBuffer_SetTextBoxDisplayIcon (EZTR_MsgBuffer *buf, u8 icon) |
Sets the display_icon of the message buffer's header. | |
u16 | EZTR_MsgBuffer_GetNextMsg (EZTR_MsgBuffer *buf) |
Retrieves the next_message_id from a message buffer's header. | |
void | EZTR_MsgBuffer_SetNextMsg (EZTR_MsgBuffer *buf, u16 textId) |
Sets the next_message_id of the message buffer's header. | |
u16 | EZTR_MsgBuffer_GetFirstItemRupees (EZTR_MsgBuffer *buf) |
Retrieves the first_item_rupees from a message buffer's header. | |
void | EZTR_MsgBuffer_SetFirstItemRupees (EZTR_MsgBuffer *buf, u16 val) |
Sets the first_item_rupees of the message buffer's header. | |
u16 | EZTR_MsgBuffer_GetSecondItemRupees (EZTR_MsgBuffer *buf) |
Retrieves the second_item_rupees from a message buffer's header. | |
void | EZTR_MsgBuffer_SetSecondItemRupees (EZTR_MsgBuffer *buf, u16 val) |
Sets the second_item_rupees of the message buffer's header. | |
void | EZTR_MsgBuffer_Print (EZTR_MsgBuffer *buf) |
Prints the contents of a message buffer to the console. | |
void | EZTR_MsgBuffer_PrintCCode (EZTR_MsgBuffer *buf) |
Prints the contents of a message buffer to the console, formatted as a EZTR_Basic_ReplaceText call. | |
void | EZTR_MsgBuffer_PrintFull (EZTR_MsgBuffer *buf) |
Prints the contents of a message buffer to the console. | |
void | EZTR_MsgBuffer_PrintFullCCode (EZTR_MsgBuffer *buf) |
Prints the contents of a message buffer to the console, formatted as a EZTR_Basic_ReplaceText call. | |
char * | EZTR_MsgBuffer_GetContentPtr (EZTR_MsgBuffer *buf) |
Gets a pointer to the beginning of the content region for a desired message buffer. | |
Functions for high-level message buffer operations.
u32 EZTR_MsgBuffer_ContentLen | ( | EZTR_MsgBuffer * | buf | ) |
Gets the size of the message buffer's content region, in bytes.
Effectively EZTR_MsgBuffer_Len(buf) - 11
or EZTR_MsgSContent_Len(buf->partition.content)
. Does not include the termination character '\xBF'.
buf | The buffer to measure. |
u32 EZTR_MsgBuffer_Copy | ( | EZTR_MsgBuffer * | dst, |
char * | src ) |
Copies data from src
into the message buffer dst
.
Unlike something like strcoy()
, this method is safe as long as dst is a full-sized message buffer, as it will not copy beyond the message buffer size.
Because src
is expected to have a header region, the message termination characters '\xBF' are ignored for the first 11 bytes.
dst | The message buffer to copy into. |
src | The data to copy. If you want to copy from another message buffer, use src->raw.schar or typecast src as char* . |
EZTR_MsgBuffer * EZTR_MsgBuffer_Create | ( | ) |
Creates a new message buffer object on the heap.
The created buffer will be have a default header and an empty content region. You need to free any buffer you create using this function with EZTR_MsgBuffer_Destroy()
, or else you will create a memory leak.
EZTR_MsgBuffer * EZTR_MsgBuffer_CreateFromStr | ( | char * | src | ) |
Creates a new message buffer object on the heap, and copies src
into it.
Equivalent to buf = EZTR_MsgBuffer_Create(); EZTR_MsgBuffer_Copy(buf);
You need to free any buffer you create using this function with EZTR_MsgBuffer_Destroy()
, or else you will create a memory leak.
src | The content to copy into the buffer. Expected to have a header region, and be terminated with '\xBF'. |
EZTR_MsgBuffer * EZTR_MsgBuffer_CreateFromStrN | ( | char * | src, |
size_t | len ) |
Creates a new message buffer object on the heap, and copies src
into it for up to len
bytes.
Equivalent to buf = EZTR_MsgBuffer_Create(); EZTR_MsgBuffer_CopyN(buf, len);
You need to free any buffer you create using this function with EZTR_MsgBuffer_Destroy()
, or else you will create a memory leak.
src | The content to copy into the buffer. Expected to have a header region, and be terminated with '\xBF'. |
len | The maximum number of bytes to copy. If a '\xBFis encountered in the content region of src, the function will stop copying before len` is reached. |
void EZTR_MsgBuffer_Destroy | ( | EZTR_MsgBuffer * | buf | ) |
Frees/destroys a message buffer.
EZTR only expects you to destroy buffers that you create youself using one of the above functions. Buffers given to you by in MsgCallback
functions are created and destroyed by EZTR.
buf | A pointer to the message buffer to destroy. |
char * EZTR_MsgBuffer_GetContentPtr | ( | EZTR_MsgBuffer * | buf | ) |
Gets a pointer to the beginning of the content region for a desired message buffer.
Equivalent to buf->partition.content
, or buf->data.content
assuming EZTR_MsgBufferData is being packed correctly.
buf | The buffer to get the the content from. |
u16 EZTR_MsgBuffer_GetFirstItemRupees | ( | EZTR_MsgBuffer * | buf | ) |
Retrieves the first_item_rupees from a message buffer's header.
Useful if your compiler is having trouble with the __attribute_((packed))
on EZTR_MsgBufferData
, and the data isn't lining up correctly.
buf | The message buffer to read from. |
EZTR_MsgBufferData
is being packed correctly, this will be equivalent to buf->data.first_item_rupees
. u16 EZTR_MsgBuffer_GetNextMsg | ( | EZTR_MsgBuffer * | buf | ) |
Retrieves the next_message_id from a message buffer's header.
Useful if your compiler is having trouble with the __attribute_((packed))
on EZTR_MsgBufferData
, and the data isn't lining up correctly.
buf | The message buffer to read from. |
EZTR_MsgBufferData
is being packed correctly, this will be equivalent to buf->data.next_message_id
. u16 EZTR_MsgBuffer_GetSecondItemRupees | ( | EZTR_MsgBuffer * | buf | ) |
Retrieves the second_item_rupees from a message buffer's header.
Useful if your compiler is having trouble with the __attribute_((packed))
on EZTR_MsgBufferData
, and the data isn't lining up correctly.
buf | The message buffer to read from. |
EZTR_MsgBufferData
is being packed correctly, this will be equivalent to buf->data.second_item_rupees
. u8 EZTR_MsgBuffer_GetTextBoxDisplayIcon | ( | EZTR_MsgBuffer * | buf | ) |
Retrieves the display_icon from a message buffer's header.
Useful if your compiler is having trouble with the __attribute_((packed))
on EZTR_MsgBufferData
, and the data isn't lining up correctly.
buf | The message buffer to read from. |
EZTR_MsgBufferData
is being packed correctly, this will be equivalent to buf->data.display_icon
. u8 EZTR_MsgBuffer_GetTextBoxType | ( | EZTR_MsgBuffer * | buf | ) |
Retrieves the text_box_type from a message buffer's header.
Useful if your compiler is having trouble with the __attribute_((packed))
on EZTR_MsgBufferData
, and the data isn't lining up correctly.
buf | The message buffer to read from. |
EZTR_MsgBufferData
is being packed correctly, this will be equivalent to buf->data.text_box_type
. u8 EZTR_MsgBuffer_GetTextBoxYPos | ( | EZTR_MsgBuffer * | buf | ) |
Retrieves the text_box_y_pos from a message buffer's header.
Useful if your compiler is having trouble with the __attribute_((packed))
on EZTR_MsgBufferData
, and the data isn't lining up correctly.
buf | The message buffer to read from. |
EZTR_MsgBufferData
is being packed correctly, this will be equivalent to buf->data.text_box_y_pos
. u32 EZTR_MsgBuffer_Len | ( | EZTR_MsgBuffer * | buf | ) |
Gets the size of the message buffer's stored data, in bytes.
Does not include the termination character '\xBF'.
buf | The buffer to measure. |
u32 EZTR_MsgBuffer_NCopy | ( | EZTR_MsgBuffer * | dst, |
char * | src, | ||
size_t | len ) |
Copies data from src
into the message buffer dst
, up to len
bytes.
Because src
is expected to have a header region, the message termination characters '\xBF' are ignored for the first 11 bytes.
dst | The message buffer to copy into. |
src | The data to copy. If you want to copy from another message buffer, use src->raw.schar or typecast src as char* . |
len | The maximum number of bytes to copy. If a '\xBFis encountered in the content region of src, the function will stop copying before len` is reached. |
void EZTR_MsgBuffer_Print | ( | EZTR_MsgBuffer * | buf | ) |
Prints the contents of a message buffer to the console.
Each value in the header will be labeled. The content region will stop printing after the '\xBF' termination character.
buf | The message buffer to print. |
void EZTR_MsgBuffer_PrintCCode | ( | EZTR_MsgBuffer * | buf | ) |
Prints the contents of a message buffer to the console, formatted as a EZTR_Basic_ReplaceText
call.
The string literal for the content will end with the '\xBF' termination character.
buf | The message buffer to print. |
void EZTR_MsgBuffer_PrintFull | ( | EZTR_MsgBuffer * | buf | ) |
Prints the contents of a message buffer to the console.
Each value in the header will be labeled. The this function prints the entire 1279 bytes of the content region.
buf | The message buffer to print. |
void EZTR_MsgBuffer_PrintFullCCode | ( | EZTR_MsgBuffer * | buf | ) |
Prints the contents of a message buffer to the console, formatted as a EZTR_Basic_ReplaceText
call.
The this function prints the entire 1279 bytes of the content region.
buf | The message buffer to print. |
void EZTR_MsgBuffer_SetFirstItemRupees | ( | EZTR_MsgBuffer * | buf, |
u16 | val ) |
Sets the first_item_rupees of the message buffer's header.
Useful if your compiler is having trouble with the __attribute_((packed))
on EZTR_MsgBufferData
, and the data isn't lining up correctly.
buf | The message buffer to write to. |
value | The new first_item_rupees value. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.first_item_rupees = icon . |
void EZTR_MsgBuffer_SetNextMsg | ( | EZTR_MsgBuffer * | buf, |
u16 | textId ) |
Sets the next_message_id of the message buffer's header.
Useful if your compiler is having trouble with the __attribute_((packed))
on EZTR_MsgBufferData
, and the data isn't lining up correctly.
buf | The message buffer to write to. |
textId | The new display_icon value. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.next_message_id = icon . |
void EZTR_MsgBuffer_SetSecondItemRupees | ( | EZTR_MsgBuffer * | buf, |
u16 | val ) |
Sets the second_item_rupees of the message buffer's header.
Useful if your compiler is having trouble with the __attribute_((packed))
on EZTR_MsgBufferData
, and the data isn't lining up correctly.
buf | The message buffer to write to. |
value | The new second_item_rupees value. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.second_item_rupees = icon . |
void EZTR_MsgBuffer_SetTextBoxDisplayIcon | ( | EZTR_MsgBuffer * | buf, |
u8 | icon ) |
Sets the display_icon of the message buffer's header.
Useful if your compiler is having trouble with the __attribute_((packed))
on EZTR_MsgBufferData
, and the data isn't lining up correctly.
buf | The message buffer to write to. |
icon | The new display_icon value. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.display_icon = icon |
void EZTR_MsgBuffer_SetTextBoxType | ( | EZTR_MsgBuffer * | buf, |
u8 | type ) |
Sets the text_box_type of the message buffer's header.
Useful if your compiler is having trouble with the __attribute_((packed))
on EZTR_MsgBufferData
, and the data isn't lining up correctly.
buf | The message buffer to write to. |
type | The new text_box_type value. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.text_box_type = type |
void EZTR_MsgBuffer_SetTextBoxYPos | ( | EZTR_MsgBuffer * | buf, |
u8 | pos ) |
Sets the text_box_y_pos of the message buffer's header.
Useful if your compiler is having trouble with the __attribute_((packed))
on EZTR_MsgBufferData
, and the data isn't lining up correctly.
buf | The message buffer to write to. |
pos | The new text_box_y_pos value. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.text_box_y_pos = pos |
void EZTR_MsgBuffer_WriteDefaultHeader | ( | EZTR_MsgBuffer * | buf | ) |
Sets a message buffer's header to default values.
The default values for a message buffer header are:
buf | the message buffer to write to. |
void EZTR_MsgBuffer_WriteHeader | ( | EZTR_MsgBuffer * | buf, |
u8 | text_box_type, | ||
u8 | text_box_y_pos, | ||
u8 | display_icon, | ||
u16 | next_message_id, | ||
u16 | first_item_rupees, | ||
u16 | second_item_rupees ) |
buf | the message buffer to write to. |
text_box_type | The style of textbox to display. Use the EZTR_TextBoxType enum for more readable values. |
text_box_y_pos | The vertical position of the textbox on-screen. |
display_icon | Displays an icon in the textbox. Use the EZTR_TextBoxIcon enum for more readable values. Use EZTR_ICON_NO_ICON for no icon. |
next_message_id | The next message to display. If there is no next message, or the next message is determined by code, use 0xFFFF or EZTR_NO_VALUE . |
first_item_rupees | The price of the first item being offered for sale, if one exists. If there is no item, use 0xFFFF or EZTR_NO_VALUE . |
second_item_rupees | The price of the second item being offered for sale, if one exists. If there is no item, use 0xFFFF or EZTR_NO_VALUE . |