mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-20 13:33:02 +01:00
@@ -249,6 +249,7 @@
|
||||
#define RCT2_ADDRESS_NEWS_ITEM_LIST 0x013CA754
|
||||
|
||||
#define RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE 0x013CE950
|
||||
#define RCT2_ADDRESS_CURRENT_FONT_FLAGS 0x013CE9A2
|
||||
|
||||
#define RCT2_ADDRESS_TILE_MAP_ELEMENT_POINTERS 0x013CE9A4
|
||||
#define RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT 0x0141E9AC
|
||||
@@ -257,6 +258,8 @@
|
||||
#define RCT2_ADDRESS_GAME_COMMAND_ERROR_STRING_ID 0x0141E9AE
|
||||
#define RCT2_ADDRESS_CURRENT_ROTATION 0x0141E9E0
|
||||
|
||||
#define RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER 0x0141ED68
|
||||
|
||||
#define RCT2_ADDRESS_WATER_RAISE_COST 0x0141F738
|
||||
#define RCT2_ADDRESS_WATER_LOWER_COST 0x0141F73C
|
||||
|
||||
|
||||
714
src/gfx.c
714
src/gfx.c
@@ -354,7 +354,7 @@ void gfx_fill_rect(rct_drawpixelinfo *dpi, int left, int top, int right, int bot
|
||||
|
||||
} else {
|
||||
// 00678B7E 00678C83
|
||||
if (dpi->pad_0E < 1) {
|
||||
if (dpi->zoom_level < 1) {
|
||||
// Location in screen buffer?
|
||||
uint8* pixel = top_ * (dpi->width + dpi->pitch) + left_ + dpi->bits;
|
||||
|
||||
@@ -372,10 +372,10 @@ void gfx_fill_rect(rct_drawpixelinfo *dpi, int left, int top, int right, int bot
|
||||
}
|
||||
pixel += length;
|
||||
}
|
||||
} else if (dpi->pad_0E > 1) {
|
||||
} else if (dpi->zoom_level > 1) {
|
||||
// 00678C8A 00678D57
|
||||
right_ = right;
|
||||
} else if (dpi->pad_0E == 1) {
|
||||
} else if (dpi->zoom_level == 1) {
|
||||
// 00678C88 00678CEE
|
||||
right = right;
|
||||
}
|
||||
@@ -750,12 +750,12 @@ void gfx_draw_sprite(rct_drawpixelinfo *dpi, int image_id, int x, int y)
|
||||
ebx &= 0x7FFFF;
|
||||
ebx <<= 4;
|
||||
ebx += RCT2_ADDRESS_G1_ELEMENTS;
|
||||
if (dpi->pad_0E >= 1){
|
||||
if (dpi->pad_0E == 1){
|
||||
if (dpi->zoom_level >= 1){
|
||||
if (dpi->zoom_level == 1){
|
||||
return;
|
||||
//jump into 0x67bd81
|
||||
}
|
||||
if (dpi->pad_0E >= 3){
|
||||
if (dpi->zoom_level >= 3){
|
||||
return;//jump into 0x67FAAE
|
||||
}
|
||||
//jump into 0x67DADA
|
||||
@@ -900,7 +900,22 @@ void gfx_transpose_palette(int pal, unsigned char product)
|
||||
*/
|
||||
void gfx_draw_string_centred(rct_drawpixelinfo *dpi, int format, int x, int y, int colour, void *args)
|
||||
{
|
||||
RCT2_CALLPROC_X(0x006C1D6C, colour, format, x, y, (int)args, (int)dpi, 0);
|
||||
char* buffer;
|
||||
short text_width;
|
||||
|
||||
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
format_string(buffer, format, args);
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 0xE0;
|
||||
|
||||
// Measure text width
|
||||
text_width = gfx_get_string_width(buffer);
|
||||
|
||||
// Draw the text centred
|
||||
if (text_width <= 0xFFF) {
|
||||
x -= text_width / 2;
|
||||
gfx_draw_string(dpi, buffer, colour, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1041,18 +1056,153 @@ void gfx_redraw_screen_rect(short left, short top, short right, short bottom)
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* Return the width of the string in buffer
|
||||
*
|
||||
* rct2: 0x006C2321
|
||||
* buffer (esi)
|
||||
*/
|
||||
int gfx_get_string_width(char *buffer)
|
||||
int gfx_get_string_width(char* buffer)
|
||||
{
|
||||
int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
// Current font sprites
|
||||
uint16* current_font_sprite_base;
|
||||
// Width of string
|
||||
int width;
|
||||
|
||||
esi = (int)buffer;
|
||||
RCT2_CALLFUNC_X(0x006C2321, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
current_font_sprite_base = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16);
|
||||
width = 0;
|
||||
|
||||
return ecx & 0xFFFF;
|
||||
for (char* curr_char = buffer; *curr_char != NULL; curr_char++) {
|
||||
|
||||
if (*curr_char >= 0x20) {
|
||||
width += RCT2_ADDRESS(0x0141E9E8, uint8)[*current_font_sprite_base + (*curr_char-0x20)];
|
||||
continue;
|
||||
}
|
||||
switch(*curr_char) {
|
||||
case 1:
|
||||
width = *curr_char;
|
||||
curr_char++;
|
||||
break;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
curr_char++;
|
||||
break;
|
||||
case 7:
|
||||
*current_font_sprite_base = 0x1C0;
|
||||
break;
|
||||
case 8:
|
||||
*current_font_sprite_base = 0x2A0;
|
||||
break;
|
||||
case 9:
|
||||
*current_font_sprite_base = 0x0E0;
|
||||
break;
|
||||
case 0x0A:
|
||||
*current_font_sprite_base = 0;
|
||||
break;
|
||||
case 0x17:
|
||||
width = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS + 4, uint16)[(*curr_char & 0x7FFFF) << 4];
|
||||
curr_char += 4;
|
||||
*curr_char = 0;
|
||||
break;
|
||||
default:
|
||||
if (*curr_char <= 0x10) {
|
||||
continue;
|
||||
}
|
||||
curr_char += 2;
|
||||
if (*curr_char <= 0x16) {
|
||||
continue;
|
||||
}
|
||||
curr_char += 2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return width;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clip the text in buffer to width, add ellipsis and return the new width of the clipped string
|
||||
*
|
||||
* rct2: 0x006C2460
|
||||
* buffer (esi)
|
||||
* width (edi)
|
||||
*/
|
||||
int gfx_clip_string(char* buffer, int width)
|
||||
{
|
||||
// Location of font sprites
|
||||
uint16* current_font_sprite_base;
|
||||
// Width the string has to fit into
|
||||
int max_width;
|
||||
// Character to change to ellipsis
|
||||
char* last_char;
|
||||
// Width of the string, including ellipsis
|
||||
int clipped_width;
|
||||
|
||||
if (width < 6) {
|
||||
*buffer = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
current_font_sprite_base = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16);
|
||||
max_width = width - (3 * RCT2_ADDRESS(0x141E9F6, uint8)[*current_font_sprite_base]);
|
||||
|
||||
clipped_width = 0;
|
||||
last_char = buffer;
|
||||
|
||||
for (char* curr_char = buffer; *curr_char != NULL; curr_char++) {
|
||||
if (*curr_char < 0x20) {
|
||||
switch(*curr_char) {
|
||||
case 1:
|
||||
width = *curr_char;
|
||||
curr_char++;
|
||||
continue;
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
curr_char++;
|
||||
continue;
|
||||
case 7:
|
||||
*current_font_sprite_base = 0x1C0;
|
||||
break;
|
||||
case 8:
|
||||
*current_font_sprite_base = 0x2A0;
|
||||
break;
|
||||
case 9:
|
||||
*current_font_sprite_base = 0x0E0;
|
||||
break;
|
||||
case 0x0A:
|
||||
*current_font_sprite_base = 0;
|
||||
break;
|
||||
case 0x17:
|
||||
clipped_width = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS + 4, uint16)[(*curr_char & 0x7FFFF) << 4];
|
||||
curr_char += 4;
|
||||
*curr_char = 0;
|
||||
continue;
|
||||
default:
|
||||
if (*curr_char <= 0x10) {
|
||||
continue;
|
||||
}
|
||||
curr_char += 2;
|
||||
if (*curr_char <= 0x16) {
|
||||
continue;
|
||||
}
|
||||
curr_char += 2;
|
||||
continue;
|
||||
}
|
||||
max_width = width - (3 * RCT2_ADDRESS(0x141E9F6, uint8)[*current_font_sprite_base]);
|
||||
}
|
||||
|
||||
clipped_width += RCT2_ADDRESS(0x0141E9E8, uint8)[*current_font_sprite_base + (*curr_char-0x20)];
|
||||
|
||||
if (clipped_width >= width) {
|
||||
RCT2_GLOBAL(last_char, uint32) = 0x2E2E2E;
|
||||
clipped_width = width;
|
||||
return clipped_width;
|
||||
}
|
||||
if (clipped_width <= max_width) {
|
||||
last_char = curr_char;
|
||||
}
|
||||
}
|
||||
return clipped_width;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1069,15 +1219,19 @@ int gfx_get_string_width(char *buffer)
|
||||
*/
|
||||
void gfx_draw_string_left_clipped(rct_drawpixelinfo* dpi, int format, void* args, int colour, int x, int y, int width)
|
||||
{
|
||||
RCT2_CALLPROC_X(0x006C1B83, colour, format, x, y, (int)args, (int)dpi, width);
|
||||
// RCT2_CALLPROC_X(0x006C1B83, colour, format, x, y, (int)args, (int)dpi, width);
|
||||
|
||||
//char* buffer;
|
||||
char* buffer;
|
||||
|
||||
//buffer = (char*)0x0141ED68;
|
||||
//format_string(buffer, format, args);
|
||||
//rctmem->current_font_sprite_base = 224;
|
||||
//clip_text(buffer, width);
|
||||
//gfx_draw_string(dpi, buffer, colour, x, y);
|
||||
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
format_string(buffer, format, args);
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 0xE0;
|
||||
|
||||
// Clip text - return value is not needed
|
||||
gfx_clip_string(buffer, width);
|
||||
|
||||
gfx_draw_string(dpi, buffer, colour, x, y);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1094,19 +1248,22 @@ void gfx_draw_string_left_clipped(rct_drawpixelinfo* dpi, int format, void* args
|
||||
*/
|
||||
void gfx_draw_string_centred_clipped(rct_drawpixelinfo *dpi, int format, void *args, int colour, int x, int y, int width)
|
||||
{
|
||||
RCT2_CALLPROC_X(0x006C1BBA, colour, format, x, y, (int)args, (int)dpi, width);
|
||||
char* buffer;
|
||||
short text_width;
|
||||
|
||||
//char* buffer;
|
||||
//short text_width;
|
||||
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
format_string(buffer, format, args);
|
||||
|
||||
//buffer = (char*)0x0141ED68;
|
||||
//format_string(buffer, format, args);
|
||||
//rctmem->current_font_sprite_base = 224;
|
||||
//text_width = clip_text(buffer, width);
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16) = 0xE0;
|
||||
|
||||
//// Draw the text centred
|
||||
//x -= (text_width - 1) / 2;
|
||||
//gfx_draw_string(dpi, buffer, colour, x, y);
|
||||
// Clip text
|
||||
text_width = gfx_clip_string(buffer, width);
|
||||
|
||||
// Draw the text centred
|
||||
if (text_width <= 0xFFF) {
|
||||
x -= (text_width - 1) / 2;
|
||||
gfx_draw_string(dpi, buffer, colour, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1125,7 +1282,7 @@ void gfx_draw_string_right(rct_drawpixelinfo* dpi, int format, void* args, int c
|
||||
char* buffer;
|
||||
short text_width;
|
||||
|
||||
buffer = (char*)0x0141ED68;
|
||||
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
format_string(buffer, format, args);
|
||||
|
||||
// Measure text width
|
||||
@@ -1150,15 +1307,62 @@ void gfx_draw_string_right(rct_drawpixelinfo* dpi, int format, void* args, int c
|
||||
int gfx_draw_string_centred_wrapped(rct_drawpixelinfo *dpi, void *args, int x, int y, int width, int format, int colour)
|
||||
{
|
||||
int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
// Location of font sprites
|
||||
uint16* current_font_sprite_base;
|
||||
// Location of font flags
|
||||
uint16 current_font_flags;
|
||||
|
||||
eax = colour;
|
||||
ebx = format;
|
||||
ecx = x;
|
||||
edx = y;
|
||||
esi = (int)args;
|
||||
edi = (int)dpi;
|
||||
ebp = width;
|
||||
RCT2_CALLFUNC_X(0x006C1E53, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
current_font_sprite_base = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16);
|
||||
*current_font_sprite_base = 0xE0;
|
||||
|
||||
char* buffer = RCT2_ADDRESS(0x009C383D, char);
|
||||
|
||||
gfx_draw_string(dpi, buffer, colour, dpi->x, dpi->y);
|
||||
|
||||
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
|
||||
format_string(buffer, format, args);
|
||||
|
||||
*current_font_sprite_base = 0xE0;
|
||||
|
||||
esi = buffer;
|
||||
edi = width;
|
||||
RCT2_CALLFUNC_X(0x006C21E2, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
ecx &= 0xFFFF;
|
||||
edi &= 0xFFFF;
|
||||
|
||||
RCT2_GLOBAL(0x00F43938, uint16) = 0x0A;
|
||||
|
||||
if (ebx > 0xE0) {
|
||||
RCT2_GLOBAL(0x00F43938, uint16) = 6;
|
||||
if (ebx != 0x1C0) {
|
||||
RCT2_GLOBAL(0x00F43938, uint16) = 0x12;
|
||||
}
|
||||
}
|
||||
|
||||
if (*buffer == 0x0B) {
|
||||
RCT2_GLOBAL(0x00F43938, uint16) = RCT2_GLOBAL(0x00F43938, uint16) + 1;
|
||||
}
|
||||
|
||||
ebx = (RCT2_GLOBAL(0x00F43938, uint16) / 2) * edi;
|
||||
edx = y - ebx;
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16) = 0;
|
||||
|
||||
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
|
||||
do {
|
||||
int new_width = gfx_get_string_width(buffer);
|
||||
new_width /= 2;
|
||||
gfx_draw_string(dpi, buffer, 0xFE, x - new_width, edx);
|
||||
|
||||
buffer += strlen(buffer) + 1;
|
||||
|
||||
edx += RCT2_GLOBAL(0x00F43938, uint16);
|
||||
eax = (RCT2_GLOBAL(0x00F43938, uint16) / 2) * edi;
|
||||
ebx -= eax;
|
||||
|
||||
} while (ebx > 0);
|
||||
|
||||
return (sint16)(edx & 0xFFFF) - y;
|
||||
}
|
||||
@@ -1177,17 +1381,78 @@ int gfx_draw_string_centred_wrapped(rct_drawpixelinfo *dpi, void *args, int x, i
|
||||
int gfx_draw_string_left_wrapped(rct_drawpixelinfo *dpi, void *args, int x, int y, int width, int format, int colour)
|
||||
{
|
||||
int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
|
||||
// eax = colour;
|
||||
// ebx = format;
|
||||
// ecx = x;
|
||||
// edx = y;
|
||||
// esi = (int)args;
|
||||
// edi = (int)dpi;
|
||||
// ebp = width;
|
||||
// RCT2_CALLFUNC_X(0x006C2105, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
// return (sint16)(edx & 0xFFFF) - y;
|
||||
|
||||
eax = colour;
|
||||
ebx = format;
|
||||
ecx = x;
|
||||
edx = y;
|
||||
esi = (int)args;
|
||||
edi = (int)dpi;
|
||||
ebp = width;
|
||||
RCT2_CALLFUNC_X(0x006C2105, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
// Location of font sprites
|
||||
uint16* current_font_sprite_base;
|
||||
// Location of font flags
|
||||
uint16 current_font_flags;
|
||||
|
||||
current_font_sprite_base = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16);
|
||||
*current_font_sprite_base = 0xE0;
|
||||
|
||||
char* buffer = RCT2_ADDRESS(0x009C383D, char);
|
||||
|
||||
gfx_draw_string(dpi, buffer, colour, dpi->x, dpi->y);
|
||||
|
||||
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
|
||||
format_string(buffer, format, args);
|
||||
|
||||
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
|
||||
*current_font_sprite_base = 0xE0;
|
||||
|
||||
// Add line breaks? Adds \0 rather than \n
|
||||
// not working for strings with colour code?
|
||||
esi = buffer;
|
||||
edi = width;
|
||||
RCT2_CALLFUNC_X(0x006C21E2, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
ecx &= 0xFFFF;
|
||||
edi &= 0xFFFF;
|
||||
|
||||
// Font height?
|
||||
RCT2_GLOBAL(0x00F43938, uint16) = 0x0A;
|
||||
|
||||
if (ebx > 0xE0) {
|
||||
RCT2_GLOBAL(0x00F43938, uint16) = 6;
|
||||
if (ebx != 0x1C0) {
|
||||
RCT2_GLOBAL(0x00F43938, uint16) = 0x12;
|
||||
}
|
||||
}
|
||||
|
||||
// Number of lines?
|
||||
ebx = (RCT2_GLOBAL(0x00F43938, uint16) / 2) * edi;
|
||||
|
||||
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16) = 0;
|
||||
|
||||
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
esi = buffer;
|
||||
|
||||
edx = y;
|
||||
|
||||
do {
|
||||
gfx_draw_string(dpi, buffer, 0xFE, x, edx);
|
||||
|
||||
buffer += strlen(buffer) + 1;
|
||||
|
||||
edx += RCT2_GLOBAL(0x00F43938, uint16);
|
||||
eax = (RCT2_GLOBAL(0x00F43938, uint16) / 2);
|
||||
ebx -= eax;
|
||||
|
||||
} while (ebx >= 0);
|
||||
|
||||
return (sint16)(edx & 0xFFFF) - y;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1204,33 +1469,362 @@ void gfx_draw_string_left(rct_drawpixelinfo *dpi, int format, void *args, int co
|
||||
{
|
||||
char* buffer;
|
||||
|
||||
buffer = (char*)0x0141ED68;
|
||||
buffer = RCT2_ADDRESS(RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER, char);
|
||||
format_string(buffer, format, args);
|
||||
gfx_draw_string(dpi, buffer, colour, x, y);
|
||||
}
|
||||
|
||||
|
||||
void colour_char(int al, uint16* current_font_flags) {
|
||||
|
||||
int eax;
|
||||
|
||||
rct_g1_element* g1_element = &(RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[0x1332]);
|
||||
eax = g1_element->offset[(al & 0xFF) * 4];
|
||||
|
||||
if (!(*current_font_flags & 2)) {
|
||||
eax = eax & 0x0FF0000FF;
|
||||
}
|
||||
// Store current colour?
|
||||
RCT2_GLOBAL(0x009ABE05, uint32) = eax;
|
||||
RCT2_GLOBAL(0x009ABDA4, uint32) = 0x009ABE04;
|
||||
}
|
||||
|
||||
|
||||
void sub_682AC7(int ebp, uint16* current_font_flags) {
|
||||
|
||||
int eax;
|
||||
|
||||
// loc_682AC7
|
||||
eax = RCT2_ADDRESS(0x0141FD45, uint8)[ebp * 8];
|
||||
if (*current_font_flags & 2) {
|
||||
eax |= 0x0A0A00;
|
||||
}
|
||||
//Store current colour?
|
||||
RCT2_GLOBAL(0x009ABE05, uint32) = eax;
|
||||
RCT2_GLOBAL(0x009ABDA4, uint32) = 0x009ABE04;
|
||||
eax = 0;
|
||||
// jmp loc_682842
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* rct2: 0x00682702
|
||||
* dpi (edi)
|
||||
* format (esi)
|
||||
* buffer (esi)
|
||||
* colour (al)
|
||||
* x (cx)
|
||||
* y (dx)
|
||||
*/
|
||||
void gfx_draw_string(rct_drawpixelinfo *dpi, char *format, int colour, int x, int y)
|
||||
void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, int y)
|
||||
{
|
||||
int eax, ebx, ecx, edx, esi, edi, ebp;
|
||||
rct_g1_element* g1_element;
|
||||
|
||||
eax = colour;
|
||||
ebx = 0;
|
||||
ecx = x;
|
||||
edx = y;
|
||||
esi = (int)format;
|
||||
edi = (int)dpi;
|
||||
ebp = 0;
|
||||
RCT2_CALLFUNC_X(0x00682702, &eax, &ebx, &ecx, &edx, &esi, &edi, &ebp);
|
||||
// Maximum length/height of string
|
||||
int max_x = x;
|
||||
int max_y = y;
|
||||
|
||||
// Store original x, y
|
||||
RCT2_GLOBAL(0x00EDF840, uint16) = x;
|
||||
RCT2_GLOBAL(0x00EDF842, uint16) = y;
|
||||
|
||||
//
|
||||
uint16* current_font_flags = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16);
|
||||
uint16* current_font_sprite_base = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16);
|
||||
|
||||
// Flag for skipping non-printing characters
|
||||
int skip_char = 0;
|
||||
|
||||
if (colour != 0xFE) {
|
||||
|
||||
if (x >= dpi->x + dpi->width)
|
||||
return;
|
||||
|
||||
if (x + 0x280 <= dpi->x)
|
||||
return;
|
||||
|
||||
if (y >= dpi->y + dpi->height)
|
||||
return;
|
||||
|
||||
if (y + 0x5A <= dpi->y) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (colour != 0xFF) {
|
||||
|
||||
// switch_colour:
|
||||
*current_font_flags = 0;
|
||||
if (*current_font_sprite_base < 0) {
|
||||
*current_font_flags |= 4;
|
||||
if (*current_font_sprite_base != 0xFFFF) {
|
||||
*current_font_flags |= 8;
|
||||
}
|
||||
*current_font_sprite_base = 0xE0;
|
||||
}
|
||||
if (colour & (1 << 5)) {
|
||||
*current_font_flags |= 2;
|
||||
}
|
||||
colour &= ~(1 << 5);
|
||||
|
||||
if (!(colour & 0x40)) {
|
||||
ebp = colour;
|
||||
if (*current_font_flags & 1) {
|
||||
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
|
||||
skip_char = 1;
|
||||
} else {
|
||||
skip_char = 0;
|
||||
}
|
||||
} else {
|
||||
sub_682AC7(ebp, current_font_flags);
|
||||
}
|
||||
} else {
|
||||
*current_font_flags |= 1;
|
||||
colour &= 0x1F;
|
||||
|
||||
if (*current_font_flags & 4) {
|
||||
if (*current_font_flags & 8) {
|
||||
eax = RCT2_ADDRESS(0x0141FC48, uint8)[colour * 8];
|
||||
eax = eax << 10;
|
||||
eax = eax | RCT2_ADDRESS(0x0141FC46, uint8)[colour * 8];
|
||||
} else {
|
||||
eax = RCT2_ADDRESS(0x0141FC49, uint8)[colour * 8];
|
||||
eax = eax << 10;
|
||||
eax = eax | RCT2_ADDRESS(0x0141FC47, uint8)[colour * 8];
|
||||
}
|
||||
} else {
|
||||
eax = RCT2_ADDRESS(0x0141FC4A, uint8)[colour * 8];
|
||||
eax = eax << 10;
|
||||
eax = eax | RCT2_ADDRESS(0x0141FC48, uint8)[colour * 8];
|
||||
}
|
||||
// Store current colour? ;
|
||||
RCT2_GLOBAL(0x009ABE05, uint32) = eax;
|
||||
RCT2_GLOBAL(0x009ABDA4, uint32) = 0x009ABE04;
|
||||
eax = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
|
||||
skip_char = 1;
|
||||
}
|
||||
|
||||
for (uint8 al = *buffer; al > 0; ++buffer, al = *buffer) {
|
||||
|
||||
// Skip to the next printing character
|
||||
if (skip_char) {
|
||||
if (al < 0x20) {
|
||||
// Control codes
|
||||
skip_char = 0;
|
||||
} else if (al >= 0x8E && al < 0x9C) {
|
||||
// Colour codes
|
||||
al -= 0x8E;
|
||||
if (*current_font_flags == 1) {
|
||||
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
|
||||
skip_char = 1;
|
||||
} else {
|
||||
skip_char = 0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
colour_char(al, current_font_flags);
|
||||
continue;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ((al >= 0x8E) && (al < 0x9C)){
|
||||
// Colour codes
|
||||
al -= 0x8E;
|
||||
if (*current_font_flags == 1) {
|
||||
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
|
||||
skip_char = 1;
|
||||
} else {
|
||||
skip_char = 0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
colour_char(al, current_font_flags);
|
||||
continue;
|
||||
} else {
|
||||
if (al < 0x20) {
|
||||
// Control codes
|
||||
al -= 0x20;
|
||||
switch (al) {
|
||||
case 0x0E5:
|
||||
max_x = RCT2_GLOBAL(0x0EDF840, uint16);
|
||||
max_y += 0x0A;
|
||||
if (*current_font_sprite_base <= 0x0E) {
|
||||
break;
|
||||
}
|
||||
max_y -= 4;
|
||||
if (*current_font_sprite_base == 0x1C0) {
|
||||
break;
|
||||
}
|
||||
max_y -= 0xFFF4;
|
||||
break;
|
||||
case 0x0E6:
|
||||
max_x = RCT2_GLOBAL(0x0EDF840, uint16);
|
||||
max_y += 5;
|
||||
if (*current_font_sprite_base <= 0x0E) {
|
||||
break;
|
||||
}
|
||||
max_y -= 2;
|
||||
if (*current_font_sprite_base == 0x1C0) {
|
||||
break;
|
||||
}
|
||||
max_y -= 0xFFFA;
|
||||
break;
|
||||
case 0x0E1:
|
||||
al = *buffer;
|
||||
buffer++;
|
||||
max_x = RCT2_GLOBAL(0x0EDF840, uint16);
|
||||
max_x += al;
|
||||
break;
|
||||
case 0x0F1:
|
||||
eax = *((uint16*)buffer);
|
||||
buffer += 2;
|
||||
max_x = RCT2_GLOBAL(0x0EDF840, uint16);
|
||||
max_x += (eax & 0xFF);
|
||||
max_y = RCT2_GLOBAL(0x0EDF842, uint16);
|
||||
max_y += (eax & 0xFF00) >> 8;
|
||||
break;
|
||||
case 0x0E7:
|
||||
*current_font_sprite_base = 0x1C0;
|
||||
break;
|
||||
case 0x0E8:
|
||||
*current_font_sprite_base = 0x2A0;
|
||||
break;
|
||||
case 0x0E9:
|
||||
*current_font_sprite_base = 0xE0;
|
||||
break;
|
||||
case 0x0EA:
|
||||
*current_font_sprite_base = 0;
|
||||
break;
|
||||
case 0x0EB:
|
||||
*current_font_flags |= 2;
|
||||
break;
|
||||
case 0x0EC:
|
||||
*current_font_flags &= 0x0FFFD;
|
||||
break;
|
||||
case 0x0ED:
|
||||
ebp = RCT2_GLOBAL(0x0141F740, uint8);
|
||||
if (*current_font_flags & 1) {
|
||||
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
|
||||
skip_char = 1;
|
||||
} else {
|
||||
skip_char = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
sub_682AC7(ebp, current_font_flags);
|
||||
break;
|
||||
case 0x0EE:
|
||||
ebp = RCT2_GLOBAL(0x0141F741, uint8);
|
||||
if (*current_font_flags & 1) {
|
||||
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
|
||||
skip_char = 1;
|
||||
} else {
|
||||
skip_char = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
sub_682AC7(ebp, current_font_flags);
|
||||
break;
|
||||
case 0x0EF:
|
||||
ebp = RCT2_GLOBAL(0x0141F742, uint8);
|
||||
if (*current_font_flags & 1) {
|
||||
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
|
||||
skip_char = 1;
|
||||
} else {
|
||||
skip_char = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
sub_682AC7(ebp, current_font_flags);
|
||||
break;
|
||||
case 0x0E2:
|
||||
al = *buffer;
|
||||
buffer++;
|
||||
if (*current_font_flags & 1) {
|
||||
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
|
||||
skip_char = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
eax = RCT2_ADDRESS(0x097FCBC, uint32)[al*4];
|
||||
g1_element = &(RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[eax]);
|
||||
ebx = g1_element->offset[0xF9] + (1 << 8);
|
||||
|
||||
if (!(*current_font_flags & 2)) {
|
||||
ebx = ebx & 0xFF;
|
||||
}
|
||||
RCT2_GLOBAL(0x09ABE05, uint16) = ebx;
|
||||
ebx = g1_element->offset[0xF7];
|
||||
RCT2_GLOBAL(0x09ABE07, uint16) = ebx;
|
||||
ebx = g1_element->offset[0xFA];
|
||||
RCT2_GLOBAL(0x09ABE09, uint16) = ebx;
|
||||
|
||||
RCT2_GLOBAL(0x09ABDA4, uint32) = RCT2_GLOBAL(0x09ABE04, uint32);
|
||||
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
|
||||
skip_char = 1;
|
||||
}
|
||||
break;
|
||||
case 0x0F7:
|
||||
buffer += 4;
|
||||
if (max_x >= dpi->x + dpi->width) {
|
||||
skip_char = 1;
|
||||
break;
|
||||
}
|
||||
ebx = *(buffer - 4);
|
||||
eax = ebx & 0x7FFFF;
|
||||
g1_element = &(RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS + 4, rct_g1_element)[eax]);
|
||||
|
||||
gfx_draw_sprite(dpi, ebx, max_x, max_y);
|
||||
|
||||
max_x = max_x + g1_element->offset;
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
al -= 0x20;
|
||||
if (max_x >= dpi->x + dpi->width) {
|
||||
skip_char = 1;
|
||||
}
|
||||
if (max_x + 0x1A < dpi->x) {
|
||||
ebx = al;
|
||||
ebx += *current_font_sprite_base;
|
||||
max_x = max_x + (RCT2_ADDRESS(0x0141E9E8, uint8)[ebx] & 0xFF);
|
||||
continue;
|
||||
}
|
||||
ebx = al + *current_font_sprite_base;
|
||||
|
||||
ecx = max_x;
|
||||
|
||||
max_x = max_x + (RCT2_ADDRESS(0x0141E9E8, uint8)[ebx] & 0xFF);
|
||||
|
||||
eax = (int)al;
|
||||
ebx += 0xF15;
|
||||
|
||||
edx = max_y;
|
||||
esi = (int)buffer;
|
||||
edi = (int)dpi;
|
||||
ebp = 0;
|
||||
|
||||
RCT2_GLOBAL(0x00EDF81C, uint32) = 0x20000000;
|
||||
|
||||
RCT2_CALLPROC_X(0x067A46E, eax, ebx, ecx, edx, esi, edi, ebp);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gLastDrawStringX = max_x;
|
||||
gLastDrawStringY = max_y;
|
||||
|
||||
gLastDrawStringX = ecx;
|
||||
gLastDrawStringY = edx;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user