EZ Text Replacer for Zelda64Recompiled 2.2.0
 
Loading...
Searching...
No Matches
MsgBuffer

Functions for high-level message buffer operations. More...

Functions

EZTR_MsgBufferEZTR_MsgBuffer_Create ()
 Creates a new message buffer object on the heap.
 
EZTR_MsgBufferEZTR_MsgBuffer_CreateFromStr (char *src)
 Creates a new message buffer object on the heap, and copies src into it.
 
EZTR_MsgBufferEZTR_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.
 

Detailed Description

Functions for high-level message buffer operations.

Function Documentation

◆ EZTR_MsgBuffer_ContentLen()

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'.

Parameters
bufThe buffer to measure.
Returns
u32 The number of bytes the message buffer's content takes up.

◆ EZTR_MsgBuffer_Copy()

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.

Parameters
dstThe message buffer to copy into.
srcThe data to copy. If you want to copy from another message buffer, use src->raw.schar or typecast src as char*.
Returns
u32 The number of bytes copied.

◆ EZTR_MsgBuffer_Create()

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.

Returns
MsgBuffer* A pointer to the buffer you created.

◆ EZTR_MsgBuffer_CreateFromStr()

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.

Parameters
srcThe content to copy into the buffer. Expected to have a header region, and be terminated with '\xBF'.
Returns
MsgBuffer* A pointer to the buffer you created.

◆ EZTR_MsgBuffer_CreateFromStrN()

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.

Parameters
srcThe content to copy into the buffer. Expected to have a header region, and be terminated with '\xBF'.
lenThe maximum number of bytes to copy. If a '\xBFis encountered in the content region ofsrc, the function will stop copying beforelen` is reached.
Returns
MsgBuffer* A pointer to the buffer you created.

◆ EZTR_MsgBuffer_Destroy()

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.

Parameters
bufA pointer to the message buffer to destroy.

◆ EZTR_MsgBuffer_GetContentPtr()

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.

Parameters
bufThe buffer to get the the content from.
Returns
char* The beginning of the message buffer's content region.

◆ EZTR_MsgBuffer_GetFirstItemRupees()

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.

Parameters
bufThe message buffer to read from.
Returns
u16 The first_item_rupees of the message buffer. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.first_item_rupees.

◆ EZTR_MsgBuffer_GetNextMsg()

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.

Parameters
bufThe message buffer to read from.
Returns
u16 The display_icon of the message buffer. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.next_message_id.

◆ EZTR_MsgBuffer_GetSecondItemRupees()

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.

Parameters
bufThe message buffer to read from.
Returns
u16 The second_item_rupees of the message buffer. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.second_item_rupees.

◆ EZTR_MsgBuffer_GetTextBoxDisplayIcon()

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.

Parameters
bufThe message buffer to read from.
Returns
u8 The display_icon of the message buffer. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.display_icon.

◆ EZTR_MsgBuffer_GetTextBoxType()

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.

Parameters
bufThe message buffer to read from.
Returns
u8 The text_box_type of the message buffer. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.text_box_type.

◆ EZTR_MsgBuffer_GetTextBoxYPos()

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.

Parameters
bufThe message buffer to read from.
Returns
u8 The text_box_y_pos of the message buffer. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.text_box_y_pos.

◆ EZTR_MsgBuffer_Len()

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'.

Parameters
bufThe buffer to measure.
Returns
u32 The number of bytes the message buffer's data takes up.

◆ EZTR_MsgBuffer_NCopy()

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.

Parameters
dstThe message buffer to copy into.
srcThe data to copy. If you want to copy from another message buffer, use src->raw.schar or typecast src as char*.
lenThe maximum number of bytes to copy. If a '\xBFis encountered in the content region ofsrc, the function will stop copying beforelen` is reached.
Returns
u32 The number of bytes copied.

◆ EZTR_MsgBuffer_Print()

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.

Parameters
bufThe message buffer to print.

◆ EZTR_MsgBuffer_PrintCCode()

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.

Parameters
bufThe message buffer to print.

◆ EZTR_MsgBuffer_PrintFull()

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.

Parameters
bufThe message buffer to print.

◆ EZTR_MsgBuffer_PrintFullCCode()

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.

Parameters
bufThe message buffer to print.

◆ EZTR_MsgBuffer_SetFirstItemRupees()

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.

Parameters
bufThe message buffer to write to.
valueThe new first_item_rupees value. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.first_item_rupees = icon.

◆ EZTR_MsgBuffer_SetNextMsg()

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.

Parameters
bufThe message buffer to write to.
textIdThe new display_icon value. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.next_message_id = icon.

◆ EZTR_MsgBuffer_SetSecondItemRupees()

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.

Parameters
bufThe message buffer to write to.
valueThe new second_item_rupees value. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.second_item_rupees = icon.

◆ EZTR_MsgBuffer_SetTextBoxDisplayIcon()

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.

Parameters
bufThe message buffer to write to.
iconThe new display_icon value. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.display_icon = icon

◆ EZTR_MsgBuffer_SetTextBoxType()

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.

Parameters
bufThe message buffer to write to.
typeThe new text_box_type value. If EZTR_MsgBufferData is being packed correctly, this will be equivalent to buf->data.text_box_type = type

◆ EZTR_MsgBuffer_SetTextBoxYPos()

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.

Parameters
bufThe message buffer to write to.
posThe 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

◆ EZTR_MsgBuffer_WriteDefaultHeader()

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:

  • text_box_type = EZTR_STANDARD_TEXT_BOX_I (0)
  • text_box_y_pos = 0
  • display_icon = EZTR_ICON_NO_ICON (0xFE)
  • next_message_id = EZTR_NO_VALUE (0xFFFF)
  • first_item_rupees = EZTR_NO_VALUE (0xFFFF)
  • second_item_rupees = EZTR_NO_VALUE (0xFFFF)
Parameters
bufthe message buffer to write to.

◆ EZTR_MsgBuffer_WriteHeader()

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 )
Parameters
bufthe message buffer to write to.
text_box_typeThe style of textbox to display. Use the EZTR_TextBoxType enum for more readable values.
text_box_y_posThe vertical position of the textbox on-screen.
display_iconDisplays an icon in the textbox. Use the EZTR_TextBoxIcon enum for more readable values. Use EZTR_ICON_NO_ICON for no icon.
next_message_idThe 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_rupeesThe 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_rupeesThe price of the second item being offered for sale, if one exists. If there is no item, use 0xFFFF or EZTR_NO_VALUE.