Merge pull request #1 from IntelOrca/master

Test pull request
This commit is contained in:
Duncan 2014-06-16 09:40:52 +01:00
commit 38df54167e
7 changed files with 179 additions and 182 deletions

View File

@ -262,9 +262,16 @@
#define RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER 0x0141ED68 #define RCT2_ADDRESS_COMMON_STRING_FORMAT_BUFFER 0x0141ED68
#define RCT2_ADDRESS_WATER_RAISE_COST 0x0141F738 #define RCT2_ADDRESS_WATER_RAISE_COST 0x0141F738
#define RCT2_ADDRESS_WATER_LOWER_COST 0x0141F73C #define RCT2_ADDRESS_WATER_LOWER_COST 0x0141F73C
#define RCT2_ADDRESS_CURRENT_WINDOW_COLOUR_1 0x0141F740
#define RCT2_ADDRESS_CURRENT_WINDOW_COLOUR_2 0x0141F741
#define RCT2_ADDRESS_CURRENT_WINDOW_COLOUR_3 0x0141F742
#define RCT2_ADDRESS_CURRENT_WINDOW_COLOUR_4 0x0141F743
#define RCT2_ADDRESS_WINDOW_LIST 0x01420078 #define RCT2_ADDRESS_WINDOW_LIST 0x01420078
#define RCT2_ADDRESS_NEW_WINDOW_PTR 0x014234B8 #define RCT2_ADDRESS_NEW_WINDOW_PTR 0x014234B8
#define RCT2_ADDRESS_VIEWPORT_LIST 0x014234BC #define RCT2_ADDRESS_VIEWPORT_LIST 0x014234BC

293
src/gfx.c
View File

@ -27,6 +27,7 @@
#include "gfx.h" #include "gfx.h"
#include "rct2.h" #include "rct2.h"
#include "string_ids.h" #include "string_ids.h"
#include "sprites.h"
#include "window.h" #include "window.h"
#include "osinterface.h" #include "osinterface.h"
@ -43,39 +44,6 @@ int gLastDrawStringY;
uint8 _screenDirtyBlocks[5120]; uint8 _screenDirtyBlocks[5120];
enum{
//The next byte specifies the X coordinate
CHAR_CONTROL_CODE_MOVE_X = 1,
//The next byte specifies the palette
CHAR_CONTROL_CODE_ADJUST_PALETTE_1 = 2,
//Jumps a fixed amount of pixels down and
//starts a new line
CHAR_CONTROL_CODE_NEW_LINE_FIXED = 5,
//Jumps less than the above
CHAR_CONTROL_CODE_NEW_LINE_FIXED_SMALLER = 6,
CHAR_CONTROL_CODE_FONT_2 = 7,
CHAR_CONTROL_CODE_FONT_3 = 8,
CHAR_CONTROL_CODE_FONT_1 = 9,
CHAR_CONTROL_CODE_FONT_0 = 0xA,
CHAR_CONTROL_CODE_FONT_FLAG_SET_BIT_1 = 0xB,
CHAR_CONTROL_CODE_FONT_FLAG_CLEAR_BIT_1 = 0xC,
//Adjusts the palette depending on a global var
CHAR_CONTROL_CODE_ADJUST_PALETTE_2 = 0xD,
CHAR_CONTROL_CODE_ADJUST_PALETTE_3 = 0xE,
CHAR_CONTROL_CODE_ADJUST_PALETTE_4 = 0xF,
//The next 2 bytes specify the X and Y coordinates
CHAR_CONTROL_CODE_NEW_LINE_X_Y = 0x11,
//The next 4 bytes specify the sprite
CHAR_CONTROL_CODE_SPRITE = 0x17
};
//Originally 0x9ABE0C, 12 elements from 0xF3 are the peep top colour, 12 elements from 0xCA are peep trouser colour //Originally 0x9ABE0C, 12 elements from 0xF3 are the peep top colour, 12 elements from 0xCA are peep trouser colour
uint8 peep_palette[0x100] = { uint8 peep_palette[0x100] = {
0x00, 0xF3, 0xF4, 0xF5, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00, 0xF3, 0xF4, 0xF5, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F,
@ -154,13 +122,13 @@ void gfx_load_character_widths(){
uint8* char_width_pointer = RCT2_ADDRESS(RCT2_ADDRESS_FONT_CHAR_WIDTH, uint8); uint8* char_width_pointer = RCT2_ADDRESS(RCT2_ADDRESS_FONT_CHAR_WIDTH, uint8);
for (int char_set_offset = 0; char_set_offset < 4*0xE0; char_set_offset+=0xE0){ for (int char_set_offset = 0; char_set_offset < 4*0xE0; char_set_offset+=0xE0){
for (uint8 c = 0; c < 0xE0; c++, char_width_pointer++){ for (uint8 c = 0; c < 0xE0; c++, char_width_pointer++){
rct_g1_element g1 = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[c + 0xF15 + char_set_offset]; rct_g1_element g1 = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[c + SPR_CHAR_START + char_set_offset];
int width; int width;
if (char_set_offset == 0xE0*3) width = g1.width + 1; if (char_set_offset == 0xE0*3) width = g1.width + 1;
else width = g1.width - 1; else width = g1.width - 1;
if (c >= 0x5B && c < 0x7F){ if (c >= (FORMAT_ARGUMENT_CODE_START - 0x20) && c < (FORMAT_COLOUR_CODE_END - 0x20)){
width = 0; width = 0;
} }
*char_width_pointer = (uint8)width; *char_width_pointer = (uint8)width;
@ -805,8 +773,6 @@ void gfx_bmp_sprite_to_buffer(uint8* palette_pointer, uint8* unknown_pointer, ui
/* /*
* rct2: 0x67AA18 transfers readied images onto buffers * rct2: 0x67AA18 transfers readied images onto buffers
* This function copies the sprite data onto the screen * This function copies the sprite data onto the screen
* I think its only used for bitmaps onto buttons but i am not sure.
* There is still a small bug with this code when it is in the choose park view.
*/ */
void gfx_rle_sprite_to_buffer(uint8* source_bits_pointer, uint8* dest_bits_pointer, uint8* palette_pointer, rct_drawpixelinfo *dpi, int image_type, int source_y_start, int height, int source_x_start, int width){ void gfx_rle_sprite_to_buffer(uint8* source_bits_pointer, uint8* dest_bits_pointer, uint8* palette_pointer, rct_drawpixelinfo *dpi, int image_type, int source_y_start, int height, int source_x_start, int width){
int zoom_level = dpi->zoom_level + 1; int zoom_level = dpi->zoom_level + 1;
@ -1024,7 +990,13 @@ void gfx_draw_sprite(rct_drawpixelinfo *dpi, int image_id, int x, int y)
} }
/* /*
* 0x67A46E * rct: 0x0067A46E
* image_id (ebx) and also (0x00EDF81C)
* palette_pointer (0x9ABDA4)
* unknown_pointer (0x9E3CDC)
* dpi (edi)
* x (cx)
* y (dx)
*/ */
void gfx_draw_sprite_palette_set(rct_drawpixelinfo *dpi, int image_id, int x, int y, uint8* palette_pointer, uint8* unknown_pointer){ void gfx_draw_sprite_palette_set(rct_drawpixelinfo *dpi, int image_id, int x, int y, uint8* palette_pointer, uint8* unknown_pointer){
int image_element = 0x7FFFF&image_id; int image_element = 0x7FFFF&image_id;
@ -1393,44 +1365,44 @@ int gfx_get_string_width(char* buffer)
continue; continue;
} }
switch(*curr_char) { switch(*curr_char) {
case CHAR_CONTROL_CODE_MOVE_X: case FORMAT_MOVE_X:
curr_char++; curr_char++;
width = *curr_char; width = *curr_char;
break; break;
case CHAR_CONTROL_CODE_ADJUST_PALETTE_1: case FORMAT_ADJUST_PALETTE:
case 3: case 3:
case 4: case 4:
curr_char++; curr_char++;
break; break;
case CHAR_CONTROL_CODE_NEW_LINE_FIXED: case FORMAT_NEWLINE:
case CHAR_CONTROL_CODE_NEW_LINE_FIXED_SMALLER: case FORMAT_NEWLINE_SMALLER:
continue; continue;
case CHAR_CONTROL_CODE_FONT_2: case FORMAT_TINYFONT:
*current_font_sprite_base = 0x1C0; *current_font_sprite_base = 0x1C0;
break; break;
case CHAR_CONTROL_CODE_FONT_3: case FORMAT_BIGFONT:
*current_font_sprite_base = 0x2A0; *current_font_sprite_base = 0x2A0;
break; break;
case CHAR_CONTROL_CODE_FONT_1: case FORMAT_MEDIUMFONT:
*current_font_sprite_base = 0x0E0; *current_font_sprite_base = 0x0E0;
break; break;
case CHAR_CONTROL_CODE_FONT_0: case FORMAT_SMALLFONT:
*current_font_sprite_base = 0; *current_font_sprite_base = 0;
break; break;
case CHAR_CONTROL_CODE_FONT_FLAG_SET_BIT_1: case FORMAT_OUTLINE:
case CHAR_CONTROL_CODE_FONT_FLAG_CLEAR_BIT_1: case FORMAT_OUTLINE_OFF:
case CHAR_CONTROL_CODE_ADJUST_PALETTE_2: case FORMAT_WINDOW_COLOUR_1:
case CHAR_CONTROL_CODE_ADJUST_PALETTE_3: case FORMAT_WINDOW_COLOUR_2:
case CHAR_CONTROL_CODE_ADJUST_PALETTE_4: case FORMAT_WINDOW_COLOUR_3:
case 0x10: case 0x10:
continue; continue;
case CHAR_CONTROL_CODE_SPRITE: case FORMAT_INLINE_SPRITE:
g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[*((uint32*)(curr_char+1))&0x7FFFF]; g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[*((uint32*)(curr_char+1))&0x7FFFF];
width += g1_element.width; width += g1_element.width;
curr_char += 4; curr_char += 4;
break; break;
default: default:
if (*curr_char <= 0x16) { //case 0x11? CHAR_CONTROL_CODE_NEW_LINE_X_Y if (*curr_char <= 0x16) { //case 0x11? FORMAT_NEW_LINE_X_Y
curr_char += 2; curr_char += 2;
continue; continue;
} }
@ -1476,44 +1448,44 @@ int gfx_clip_string(char* buffer, int width)
for (unsigned char* curr_char = buffer; *curr_char != (uint8)NULL; curr_char++) { for (unsigned char* curr_char = buffer; *curr_char != (uint8)NULL; curr_char++) {
if (*curr_char < 0x20) { if (*curr_char < 0x20) {
switch (*curr_char) { switch (*curr_char) {
case CHAR_CONTROL_CODE_MOVE_X: case FORMAT_MOVE_X:
curr_char++; curr_char++;
clipped_width = *curr_char; clipped_width = *curr_char;
continue; continue;
case CHAR_CONTROL_CODE_ADJUST_PALETTE_1: case FORMAT_ADJUST_PALETTE:
case 3: case 3:
case 4: case 4:
curr_char++; curr_char++;
continue; continue;
case CHAR_CONTROL_CODE_NEW_LINE_FIXED: case FORMAT_NEWLINE:
case CHAR_CONTROL_CODE_NEW_LINE_FIXED_SMALLER: case FORMAT_NEWLINE_SMALLER:
continue; continue;
case CHAR_CONTROL_CODE_FONT_2: case FORMAT_TINYFONT:
current_font_sprite_base = 0x1C0; current_font_sprite_base = 0x1C0;
break; break;
case CHAR_CONTROL_CODE_FONT_3: case FORMAT_BIGFONT:
current_font_sprite_base = 0x2A0; current_font_sprite_base = 0x2A0;
break; break;
case CHAR_CONTROL_CODE_FONT_1: case FORMAT_MEDIUMFONT:
current_font_sprite_base = 0x0E0; current_font_sprite_base = 0x0E0;
break; break;
case CHAR_CONTROL_CODE_FONT_0: case FORMAT_SMALLFONT:
current_font_sprite_base = 0; current_font_sprite_base = 0;
break; break;
case CHAR_CONTROL_CODE_FONT_FLAG_SET_BIT_1: case FORMAT_OUTLINE:
case CHAR_CONTROL_CODE_FONT_FLAG_CLEAR_BIT_1: case FORMAT_OUTLINE_OFF:
case CHAR_CONTROL_CODE_ADJUST_PALETTE_2: case FORMAT_WINDOW_COLOUR_1:
case CHAR_CONTROL_CODE_ADJUST_PALETTE_3: case FORMAT_WINDOW_COLOUR_2:
case CHAR_CONTROL_CODE_ADJUST_PALETTE_4: case FORMAT_WINDOW_COLOUR_3:
case 0x10: case 0x10:
continue; continue;
case CHAR_CONTROL_CODE_SPRITE: case FORMAT_INLINE_SPRITE:
g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[*((uint32*)(curr_char+1))&0x7FFFF]; g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[*((uint32*)(curr_char+1))&0x7FFFF];
clipped_width += g1_element.width; clipped_width += g1_element.width;
curr_char += 4; curr_char += 4;
continue; continue;
default: default:
if (*curr_char <= 0x16) { //case 0x11? CHAR_CONTROL_CODE_NEW_LINE_X_Y if (*curr_char <= 0x16) { //case 0x11? FORMAT_NEW_LINE_X_Y
curr_char += 2; curr_char += 2;
continue; continue;
} }
@ -1579,35 +1551,35 @@ int gfx_wrap_string(char* buffer, int width, int* num_lines, int* font_height)
if (*curr_char != 5) { if (*curr_char != 5) {
if (*curr_char < ' ') { if (*curr_char < ' ') {
switch(*curr_char) { switch(*curr_char) {
case CHAR_CONTROL_CODE_MOVE_X: case FORMAT_MOVE_X:
case CHAR_CONTROL_CODE_ADJUST_PALETTE_1: case FORMAT_ADJUST_PALETTE:
case 3: case 3:
case 4: case 4:
curr_char++; curr_char++;
continue; continue;
case CHAR_CONTROL_CODE_NEW_LINE_FIXED: case FORMAT_NEWLINE:
case CHAR_CONTROL_CODE_NEW_LINE_FIXED_SMALLER: case FORMAT_NEWLINE_SMALLER:
continue; continue;
case CHAR_CONTROL_CODE_FONT_2: case FORMAT_TINYFONT:
*font_height = 0x1C0; *font_height = 0x1C0;
continue; continue;
case CHAR_CONTROL_CODE_FONT_3: case FORMAT_BIGFONT:
*font_height = 0x2A0; *font_height = 0x2A0;
continue; continue;
case CHAR_CONTROL_CODE_FONT_1: case FORMAT_MEDIUMFONT:
*font_height = 0xE0; *font_height = 0xE0;
continue; continue;
case CHAR_CONTROL_CODE_FONT_0: case FORMAT_SMALLFONT:
*font_height = 0; *font_height = 0;
continue; continue;
case CHAR_CONTROL_CODE_FONT_FLAG_SET_BIT_1: case FORMAT_OUTLINE:
case CHAR_CONTROL_CODE_FONT_FLAG_CLEAR_BIT_1: case FORMAT_OUTLINE_OFF:
case CHAR_CONTROL_CODE_ADJUST_PALETTE_2: case FORMAT_WINDOW_COLOUR_1:
case CHAR_CONTROL_CODE_ADJUST_PALETTE_3: case FORMAT_WINDOW_COLOUR_2:
case CHAR_CONTROL_CODE_ADJUST_PALETTE_4: case FORMAT_WINDOW_COLOUR_3:
case 0x10: case 0x10:
continue; continue;
case CHAR_CONTROL_CODE_SPRITE: case FORMAT_INLINE_SPRITE:
g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[*((uint32*)(curr_char + 1)) & 0x7FFFF]; g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[*((uint32*)(curr_char + 1)) & 0x7FFFF];
line_width += g1_element.width; line_width += g1_element.width;
curr_char += 4; curr_char += 4;
@ -1893,41 +1865,43 @@ void gfx_draw_string_left(rct_drawpixelinfo *dpi, int format, void *args, int co
gfx_draw_string(dpi, buffer, colour, x, y); gfx_draw_string(dpi, buffer, colour, x, y);
} }
/* Changes the palette so that the next character changes colour
void colour_char(int al, uint16* current_font_flags) { */
void colour_char(uint8 colour, uint16* current_font_flags, uint8* palette_pointer) {
int eax; int eax;
rct_g1_element g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[0x1332]; rct_g1_element g1_element = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[0x1332];
eax = ((uint32*)g1_element.offset)[al & 0xFF]; eax = ((uint32*)g1_element.offset)[colour & 0xFF];
if (!(*current_font_flags & 2)) { if (!(*current_font_flags & 2)) {
eax = eax & 0x0FF0000FF; eax = eax & 0x0FF0000FF;
} }
// Adjust text palette. Store current colour? // Adjust text palette. Store current colour?
text_palette[1] = eax & 0xFF; palette_pointer[1] = eax & 0xFF;
text_palette[2] = (eax>>8) & 0xFF; palette_pointer[2] = (eax >> 8) & 0xFF;
text_palette[3] = (eax >> 16) & 0xFF; palette_pointer[3] = (eax >> 16) & 0xFF;
text_palette[4] = (eax >> 24) & 0xFF; palette_pointer[4] = (eax >> 24) & 0xFF;
RCT2_GLOBAL(0x009ABDA4, uint32) = (uint32)text_palette; RCT2_GLOBAL(0x009ABDA4, uint32) = (uint32)palette_pointer;
} }
/* Changes the palette so that the next character changes colour
void sub_682AC7(int ebp, uint16* current_font_flags) { * This is specific to changing to a predefined window related colour
*/
void colour_char_window(uint8 colour, uint16* current_font_flags,uint8* palette_pointer) {
int eax; int eax;
eax = RCT2_ADDRESS(0x0141FD45, uint8)[ebp * 8]; eax = RCT2_ADDRESS(0x0141FD45, uint8)[colour * 8];
if (*current_font_flags & 2) { if (*current_font_flags & 2) {
eax |= 0x0A0A00; eax |= 0x0A0A00;
} }
//Adjust text palette. Store current colour? //Adjust text palette. Store current colour?
text_palette[1] = eax & 0xFF; palette_pointer[1] = eax & 0xFF;
text_palette[2] = (eax >> 8) & 0xFF; palette_pointer[2] = (eax >> 8) & 0xFF;
text_palette[3] = (eax >> 16) & 0xFF; palette_pointer[3] = (eax >> 16) & 0xFF;
text_palette[4] = (eax >> 24) & 0xFF; palette_pointer[4] = (eax >> 24) & 0xFF;
RCT2_GLOBAL(0x009ABDA4, uint32) = (uint32)text_palette; RCT2_GLOBAL(0x009ABDA4, uint32) = (uint32)palette_pointer;
} }
@ -1954,6 +1928,8 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in
uint16* current_font_flags = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_FLAGS, uint16); 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); uint16* current_font_sprite_base = RCT2_ADDRESS(RCT2_ADDRESS_CURRENT_FONT_SPRITE_BASE, uint16);
uint8* palette_pointer = text_palette;
// Flag for skipping non-printing characters // Flag for skipping non-printing characters
int skip_char = 0; int skip_char = 0;
@ -1997,7 +1973,7 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in
skip_char = 0; skip_char = 0;
} }
} else { } else {
sub_682AC7(ebp, current_font_flags); colour_char_window(ebp, current_font_flags, palette_pointer);
} }
} else { } else {
*current_font_flags |= 1; *current_font_flags |= 1;
@ -2019,11 +1995,11 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in
eax = eax | RCT2_ADDRESS(0x0141FC48, uint8)[colour * 8]; eax = eax | RCT2_ADDRESS(0x0141FC48, uint8)[colour * 8];
} }
// Adjust text palette. Store current colour? ; // Adjust text palette. Store current colour? ;
text_palette[1] = eax & 0xFF; palette_pointer[1] = eax & 0xFF;
text_palette[2] = (eax >> 8) & 0xFF; palette_pointer[2] = (eax >> 8) & 0xFF;
text_palette[3] = (eax >> 16) & 0xFF; palette_pointer[3] = (eax >> 16) & 0xFF;
text_palette[4] = (eax >> 24) & 0xFF; palette_pointer[4] = (eax >> 24) & 0xFF;
RCT2_GLOBAL(0x009ABDA4, uint32) = (uint32)text_palette; RCT2_GLOBAL(0x009ABDA4, uint32) = (uint32)palette_pointer;
eax = 0; eax = 0;
} }
} }
@ -2040,9 +2016,8 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in
if (al < 0x20) { if (al < 0x20) {
// Control codes // Control codes
skip_char = 0; skip_char = 0;
} else if (al >= 0x8E && al < 0x9C) { } else if (al >= FORMAT_COLOUR_CODE_START && al <= FORMAT_COLOUR_CODE_END) {
// Colour codes // Colour codes
al -= 0x8E;
if (*current_font_flags == 1) { if (*current_font_flags == 1) {
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) { if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
skip_char = 1; skip_char = 1;
@ -2051,7 +2026,7 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in
} }
continue; continue;
} }
colour_char(al, current_font_flags); colour_char(al - FORMAT_COLOUR_CODE_START, current_font_flags, palette_pointer);
continue; continue;
} else { } else {
continue; continue;
@ -2060,15 +2035,11 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in
// Control codes // Control codes
switch (al) { switch (al) {
case CHAR_CONTROL_CODE_MOVE_X://Start New Line at start+buffer x, same y. (Overwrite?) case FORMAT_MOVE_X://Start New Line at start+buffer x, same y. (Overwrite?)
al = *(buffer+1); max_x = x + *++buffer;
buffer++;
max_x = x;
max_x += al;
break; break;
case CHAR_CONTROL_CODE_ADJUST_PALETTE_1: case FORMAT_ADJUST_PALETTE:
al = *(buffer + 1); al = *++buffer;
buffer++;
if (*current_font_flags & 1) { if (*current_font_flags & 1) {
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) { if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
skip_char = 1; skip_char = 1;
@ -2083,61 +2054,63 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in
ebx = ebx & 0xFF; ebx = ebx & 0xFF;
} }
palette_pointer[1] = ebx & 0xff;
palette_pointer[2] = (ebx >> 8) & 0xff;
//Adjust the text palette //Adjust the text palette
memcpy(&(text_palette[3]), &(g1_element->offset[0xF7]), 2); memcpy(palette_pointer + 3, &(g1_element->offset[0xF7]), 2);
memcpy(&(text_palette[5]), &(g1_element->offset[0xFA]), 2); memcpy(palette_pointer + 5, &(g1_element->offset[0xFA]), 2);
//Set the palette pointer //Set the palette pointer
RCT2_GLOBAL(0x009ABDA4, uint32) = (uint32)text_palette; RCT2_GLOBAL(0x009ABDA4, uint32) = (uint32)palette_pointer;
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) { if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
skip_char = 1; skip_char = 1;
} }
break; break;
case CHAR_CONTROL_CODE_NEW_LINE_FIXED://Start New Line at set y lower case FORMAT_NEWLINE://Start New Line at set y lower
max_x = x; max_x = x;
max_y += 0x0A; if (*current_font_sprite_base <= 0xE0) {
if (*current_font_sprite_base <= 0x0E) { max_y += 10;
break; break;
} }
max_y -= 4; else if (*current_font_sprite_base == 0x1C0) {
if (*current_font_sprite_base == 0x1C0) { max_y += 6;
break; break;
} }
max_y -= 0xFFF4; max_y += 18;
break; break;
case CHAR_CONTROL_CODE_NEW_LINE_FIXED_SMALLER://Start New Line at set y lower case FORMAT_NEWLINE_SMALLER://Start New Line at set y lower
max_x = x; max_x = x;
max_y += 5; if (*current_font_sprite_base <= 0xE0) {
if (*current_font_sprite_base <= 0x0E) { max_y += 5;
break; break;
} }
max_y -= 2; else if (*current_font_sprite_base == 0x1C0) {
if (*current_font_sprite_base == 0x1C0) { max_y += 3;
break; break;
} }
max_y -= 0xFFFA;//This does not look correct probably should be an add max_y += 9;
break; break;
case CHAR_CONTROL_CODE_FONT_2: case FORMAT_TINYFONT:
*current_font_sprite_base = 0x1C0; *current_font_sprite_base = 0x1C0;
break; break;
case CHAR_CONTROL_CODE_FONT_3: case FORMAT_BIGFONT:
*current_font_sprite_base = 0x2A0; *current_font_sprite_base = 0x2A0;
break; break;
case CHAR_CONTROL_CODE_FONT_1: case FORMAT_MEDIUMFONT:
*current_font_sprite_base = 0xE0; *current_font_sprite_base = 0xE0;
break; break;
case CHAR_CONTROL_CODE_FONT_0: case FORMAT_SMALLFONT:
*current_font_sprite_base = 0; *current_font_sprite_base = 0;
break; break;
case CHAR_CONTROL_CODE_FONT_FLAG_SET_BIT_1: case FORMAT_OUTLINE:
*current_font_flags |= 2; *current_font_flags |= 2;
break; break;
case CHAR_CONTROL_CODE_FONT_FLAG_CLEAR_BIT_1: case FORMAT_OUTLINE_OFF:
*current_font_flags &= 0x0FFFD; *current_font_flags &= 0x0FFFD;
break; break;
case CHAR_CONTROL_CODE_ADJUST_PALETTE_2: case FORMAT_WINDOW_COLOUR_1:
ebp = RCT2_GLOBAL(0x0141F740, uint8); ebp = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WINDOW_COLOUR_1, uint8);
if (*current_font_flags & 1) { if (*current_font_flags & 1) {
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) { if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
skip_char = 1; skip_char = 1;
@ -2147,10 +2120,10 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in
} }
break; break;
} }
sub_682AC7(ebp, current_font_flags); colour_char_window(ebp, current_font_flags, palette_pointer);
break; break;
case CHAR_CONTROL_CODE_ADJUST_PALETTE_3: case FORMAT_WINDOW_COLOUR_2:
ebp = RCT2_GLOBAL(0x0141F741, uint8); ebp = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WINDOW_COLOUR_2, uint8);
if (*current_font_flags & 1) { if (*current_font_flags & 1) {
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) { if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
skip_char = 1; skip_char = 1;
@ -2160,10 +2133,10 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in
} }
break; break;
} }
sub_682AC7(ebp, current_font_flags); colour_char_window(ebp, current_font_flags, palette_pointer);
break; break;
case CHAR_CONTROL_CODE_ADJUST_PALETTE_4: case FORMAT_WINDOW_COLOUR_3:
ebp = RCT2_GLOBAL(0x0141F742, uint8); ebp = RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WINDOW_COLOUR_3, uint8);
if (*current_font_flags & 1) { if (*current_font_flags & 1) {
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) { if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
skip_char = 1; skip_char = 1;
@ -2173,17 +2146,13 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in
} }
break; break;
} }
sub_682AC7(ebp, current_font_flags); colour_char_window(ebp, current_font_flags, palette_pointer);
break; break;
case CHAR_CONTROL_CODE_NEW_LINE_X_Y: //Start new line at specified x,y case FORMAT_NEWLINE_X_Y: //Start new line at specified x,y
eax = *((uint16*)(buffer+1)); max_x = x + *++buffer;
buffer += 2; max_y = y + *++buffer;
max_x = x;
max_x += (eax & 0xFF);
max_y = y;
max_y += (eax & 0xFF00) >> 8;
break; break;
case CHAR_CONTROL_CODE_SPRITE: case FORMAT_INLINE_SPRITE:
buffer += 4; buffer += 4;
if (max_x >= dpi->x + dpi->width) { if (max_x >= dpi->x + dpi->width) {
skip_char = 1; skip_char = 1;
@ -2199,7 +2168,7 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in
break; break;
default: default:
// Colour codes // Colour codes
if ((al >= 0x8E) && (al < 0x9C)){ if ((al >= FORMAT_COLOUR_CODE_START) && (al <= FORMAT_COLOUR_CODE_END)){
if (*current_font_flags == 1) { if (*current_font_flags == 1) {
if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) { if ((y + 0x13 <= dpi->y) || (dpi->y + dpi->height <= y)) {
@ -2209,7 +2178,7 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in
} }
continue; continue;
} }
colour_char(al-0x8E, current_font_flags); colour_char(al - FORMAT_COLOUR_CODE_START, current_font_flags, palette_pointer);
continue; continue;
} }
@ -2223,16 +2192,12 @@ void gfx_draw_string(rct_drawpixelinfo *dpi, char *buffer, int colour, int x, in
max_x = max_x + (RCT2_ADDRESS(RCT2_ADDRESS_FONT_CHAR_WIDTH, uint8)[ebx] & 0xFF); max_x = max_x + (RCT2_ADDRESS(RCT2_ADDRESS_FONT_CHAR_WIDTH, uint8)[ebx] & 0xFF);
continue; continue;
} }
ebx = al-0x20 + *current_font_sprite_base;
ecx = max_x; uint32 char_offset = al - 0x20 + *current_font_sprite_base;
max_x += (RCT2_ADDRESS(RCT2_ADDRESS_FONT_CHAR_WIDTH, uint8)[ebx] & 0xFF); RCT2_GLOBAL(0x00EDF81C, uint32) = (IMAGE_TYPE_USE_PALETTE << 28);
ebx += 0xF15;
RCT2_GLOBAL(0x00EDF81C, uint32) = 0x20000000;
gfx_draw_sprite_palette_set(dpi, 0x20000000 | ebx, ecx, max_y, RCT2_GLOBAL(0x9ABDA4, uint8*), NULL); gfx_draw_sprite_palette_set(dpi, (IMAGE_TYPE_USE_PALETTE << 28) | char_offset + SPR_CHAR_START, max_x, max_y, palette_pointer, NULL);
max_x += (RCT2_ADDRESS(RCT2_ADDRESS_FONT_CHAR_WIDTH, uint8)[char_offset] & 0xFF);
continue; continue;
} }
} }

View File

@ -29,6 +29,13 @@ enum {
SPR_HOT_AND_DRY = 3292, SPR_HOT_AND_DRY = 3292,
SPR_COLD = 3293, SPR_COLD = 3293,
// This is the start of every character there are
// 224 characters per font (first 32 are control codes hence why it doesn't go to 255)
// 4 fonts
// = 896 sprites
SPR_CHAR_START = 3861,
SPR_CHAR_END = 4757,
SPR_RESIZE = 5058, SPR_RESIZE = 5058,
SPR_HEARING_VIEWPORT = 5166, SPR_HEARING_VIEWPORT = 5166,

View File

@ -29,17 +29,41 @@ void reset_saved_strings();
enum { enum {
// Font format codes // Font format codes
FORMAT_TINYFONT = 7,
// The next byte specifies the X coordinate
FORMAT_MOVE_X = 1,
// The next byte specifies the palette
FORMAT_ADJUST_PALETTE,
// Moves to the next line
FORMAT_NEWLINE = 5,
// Moves less than NEWLINE
FORMAT_NEWLINE_SMALLER,
FORMAT_TINYFONT,
FORMAT_BIGFONT, FORMAT_BIGFONT,
FORMAT_MEDIUMFONT, FORMAT_MEDIUMFONT,
FORMAT_SMALLFONT, FORMAT_SMALLFONT,
FORMAT_OUTLINE, FORMAT_OUTLINE,
FORMAT_OUTLINE_OFF,
// Changes the colour of the text to a predefined window colour.
FORMAT_WINDOW_COLOUR_1,
FORMAT_WINDOW_COLOUR_2,
FORMAT_WINDOW_COLOUR_3,
// The next 2 bytes specify the X and Y coordinates
FORMAT_NEWLINE_X_Y = 17,
// The next 4 bytes specify the sprite
FORMAT_INLINE_SPRITE = 23,
// Non ascii-characters // Non ascii-characters
FORMAT_ENDQUOTES = 34, FORMAT_ENDQUOTES = 34,
// Argument format codes // Argument format codes
FORMAT_ARGUMENT_CODE_START = 123,
FORMAT_COMMA32 = 123, FORMAT_COMMA32 = 123,
FORMAT_INT32, FORMAT_INT32,
FORMAT_COMMA2DP32, FORMAT_COMMA2DP32,
@ -61,6 +85,7 @@ enum {
FORMAT_SPRITE, FORMAT_SPRITE,
// Colour format codes // Colour format codes
FORMAT_COLOUR_CODE_START = 142,
FORMAT_BLACK = 142, FORMAT_BLACK = 142,
FORMAT_GREY, FORMAT_GREY,
FORMAT_WHITE, FORMAT_WHITE,
@ -75,6 +100,7 @@ enum {
FORMAT_LIGHTPINK, FORMAT_LIGHTPINK,
FORMAT_PEARLAQUA, FORMAT_PEARLAQUA,
FORMAT_PALESILVER, FORMAT_PALESILVER,
FORMAT_COLOUR_CODE_END = FORMAT_PALESILVER,
// Extra non-ascii characters // Extra non-ascii characters
FORMAT_AMINUSCULE = 159, FORMAT_AMINUSCULE = 159,

View File

@ -244,14 +244,10 @@ static void DrawOpenRCT2(int x, int y)
gfx_fill_rect_inset(dpi, x, y, x + 128, y + 20, 0x80 | 12, 0x8); gfx_fill_rect_inset(dpi, x, y, x + 128, y + 20, 0x80 | 12, 0x8);
// Format text (name and version) // Format text (name and version)
sprintf(buffer, "%c%c%s, v%s", FORMAT_MEDIUMFONT, FORMAT_BLACK, OPENRCT2_NAME, OPENRCT2_VERSION); sprintf(buffer, "%c%c%c%s, v%s", FORMAT_MEDIUMFONT, FORMAT_OUTLINE, FORMAT_WHITE, OPENRCT2_NAME, OPENRCT2_VERSION);
// Draw shadow // Draw Text
gfx_draw_string(dpi, buffer, 0, x + 5, y + 5); gfx_draw_string(dpi, buffer, 0, x + 5, y + 5);
// Draw text
buffer[1] = FORMAT_WHITE;
gfx_draw_string(dpi, buffer, 0, x + 4, y + 4);
} }

View File

@ -999,10 +999,10 @@ void window_draw(rct_window *w, int left, int top, int right, int bottom)
RCT2_GLOBAL(0x01420070, sint32) = v->x; RCT2_GLOBAL(0x01420070, sint32) = v->x;
// Text colouring // Text colouring
RCT2_GLOBAL(0x0141F740, uint8) = v->colours[0] & 0x7F; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WINDOW_COLOUR_1, uint8) = v->colours[0] & 0x7F;
RCT2_GLOBAL(0x0141F741, uint8) = v->colours[1] & 0x7F; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WINDOW_COLOUR_2, uint8) = v->colours[1] & 0x7F;
RCT2_GLOBAL(0x0141F742, uint8) = v->colours[2] & 0x7F; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WINDOW_COLOUR_3, uint8) = v->colours[2] & 0x7F;
RCT2_GLOBAL(0x0141F743, uint8) = v->colours[3] & 0x7F; RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_WINDOW_COLOUR_4, uint8) = v->colours[3] & 0x7F;
// Invalidate the window // Invalidate the window
RCT2_CALLPROC_X(v->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)v, 0, 0); RCT2_CALLPROC_X(v->event_handlers[WE_INVALIDATE], 0, 0, 0, 0, (int)v, 0, 0);

View File

@ -320,21 +320,17 @@ static void window_cheats_paint()
if (w->page == WINDOW_CHEATS_PAGE_MONEY){ if (w->page == WINDOW_CHEATS_PAGE_MONEY){
char buffer[256]; char buffer[256];
// Format text (name and version) // Format text
sprintf(buffer, "%c%c%s", FORMAT_MEDIUMFONT, FORMAT_BLACK, "Increases your money by 1,000."); sprintf(buffer, "%c%c%s", FORMAT_MEDIUMFONT, FORMAT_BLACK, "Increases your money by 1,000.");
// Draw shadow // Draw shadow
gfx_draw_string(dpi, buffer, 0, w->x + 4, w->y + 50); gfx_draw_string(dpi, buffer, 0, w->x + 4, w->y + 50);
} }
else if (w->page == WINDOW_CHEATS_PAGE_GUESTS){ else if (w->page == WINDOW_CHEATS_PAGE_GUESTS){
char buffer[256]; char buffer[256];
// Format text (name and version) // Format text
sprintf(buffer, "%c%c%s", FORMAT_MEDIUMFONT, FORMAT_BLACK, "Increases every peeps happiness "); sprintf(buffer, "%c%c%s%c%s", FORMAT_MEDIUMFONT, FORMAT_BLACK, "Increases every peeps happiness ", FORMAT_NEWLINE, "to max.");
// Draw shadow // Draw shadow
gfx_draw_string(dpi, buffer, 0, w->x + 4, w->y + 50); gfx_draw_string(dpi, buffer, 0, w->x + 4, w->y + 50);
// Format text (name and version)
sprintf(buffer, "%c%c%s", FORMAT_MEDIUMFONT, FORMAT_BLACK, "to max.");
// Draw shadow
gfx_draw_string(dpi, buffer, 0, w->x + 4, w->y + 60);
} }
} }