Pass paint session to more ps functions

This commit is contained in:
Ted John 2017-09-02 23:22:19 +01:00
parent ae6c820662
commit 2980be0667
7 changed files with 32 additions and 38 deletions

View File

@ -109,7 +109,7 @@ static sint32 div_to_minus_infinity(sint32 a, sint32 b) {
return (a / b) - (a % b < 0); return (a / b) - (a % b < 0);
} }
static void scenery_multiple_sign_paint_line(const utf8 *str, rct_large_scenery_text *text, sint32 textImage, sint32 textColour, uint8 direction, sint32 y_offset) static void scenery_multiple_sign_paint_line(paint_session * session, const utf8 *str, rct_large_scenery_text *text, sint32 textImage, sint32 textColour, uint8 direction, sint32 y_offset)
{ {
const utf8 *fitStr = scenery_multiple_sign_fit_text(str, text, false); const utf8 *fitStr = scenery_multiple_sign_fit_text(str, text, false);
sint32 width = scenery_multiple_sign_text_width(fitStr, text); sint32 width = scenery_multiple_sign_text_width(fitStr, text);
@ -141,12 +141,12 @@ static void scenery_multiple_sign_paint_line(const utf8 *str, rct_large_scenery_
} }
sint32 image_id = (textImage + glyph_offset + glyph_type) | textColour; sint32 image_id = (textImage + glyph_offset + glyph_type) | textColour;
if (direction == 3) { if (direction == 3) {
paint_attach_to_previous_ps(image_id, x_offset, -div_to_minus_infinity(acc, 2)); paint_attach_to_previous_ps(session, image_id, x_offset, -div_to_minus_infinity(acc, 2));
} else { } else {
if (text->flags & LARGE_SCENERY_TEXT_FLAG_VERTICAL) { if (text->flags & LARGE_SCENERY_TEXT_FLAG_VERTICAL) {
paint_attach_to_previous_ps(image_id, x_offset, div_to_minus_infinity(acc, 2)); paint_attach_to_previous_ps(session, image_id, x_offset, div_to_minus_infinity(acc, 2));
} else { } else {
paint_attach_to_previous_attach(image_id, x_offset, div_to_minus_infinity(acc, 2)); paint_attach_to_previous_attach(session, image_id, x_offset, div_to_minus_infinity(acc, 2));
} }
} }
x_offset += scenery_multiple_sign_get_glyph(text, codepoint)->width; x_offset += scenery_multiple_sign_get_glyph(text, codepoint)->width;
@ -280,7 +280,7 @@ void scenery_multiple_paint(paint_session * session, uint8 direction, uint16 hei
while ((codepoint = utf8_get_next(fitStrPtr, &fitStrPtr)) != 0) { while ((codepoint = utf8_get_next(fitStrPtr, &fitStrPtr)) != 0) {
utf8 str[5] = {0}; utf8 str[5] = {0};
utf8_write_codepoint(str, codepoint); utf8_write_codepoint(str, codepoint);
scenery_multiple_sign_paint_line(str, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset - height2); scenery_multiple_sign_paint_line(session, str, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset - height2);
y_offset += scenery_multiple_sign_get_glyph(text, codepoint)->height * 2; y_offset += scenery_multiple_sign_get_glyph(text, codepoint)->height * 2;
} }
} else { } else {
@ -311,15 +311,15 @@ void scenery_multiple_paint(paint_session * session, uint8 direction, uint16 hei
*spacedst = 0; *spacedst = 0;
src = spacesrc; src = spacesrc;
} }
scenery_multiple_sign_paint_line(str1, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset); scenery_multiple_sign_paint_line(session, str1, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset);
y_offset += (scenery_multiple_sign_get_glyph(text, 'A')->height + 1) * 2; y_offset += (scenery_multiple_sign_get_glyph(text, 'A')->height + 1) * 2;
} }
} else { } else {
scenery_multiple_sign_paint_line(signString, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset); scenery_multiple_sign_paint_line(session, signString, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset);
} }
} else { } else {
// Draw one-line sign: // Draw one-line sign:
scenery_multiple_sign_paint_line(signString, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset); scenery_multiple_sign_paint_line(session, signString, entry->large_scenery.text, entry->large_scenery.text_image, textColour, direction, y_offset);
} }
} }
return; return;

View File

@ -445,7 +445,7 @@ static void viewport_surface_smoothen_edge(paint_session * session, enum edge_t
uint32 image_id = maskImageBase + byte_97B444[self.slope]; uint32 image_id = maskImageBase + byte_97B444[self.slope];
if (paint_attach_to_previous_ps(image_id, 0, 0)) { if (paint_attach_to_previous_ps(session, image_id, 0, 0)) {
attached_paint_struct * out = session->UnkF1AD2C; attached_paint_struct * out = session->UnkF1AD2C;
// set content and enable masking // set content and enable masking
out->colour_image_id = dword_97B804[neighbour.terrain] + cl; out->colour_image_id = dword_97B804[neighbour.terrain] + cl;
@ -456,7 +456,7 @@ static void viewport_surface_smoothen_edge(paint_session * session, enum edge_t
/** /**
* rct2: 0x0065F63B, 0x0065F77D * rct2: 0x0065F63B, 0x0065F77D
*/ */
static void viewport_surface_draw_land_side_top(enum edge_t edge, uint8 height, uint8 terrain, struct tile_descriptor self, struct tile_descriptor neighbour) static void viewport_surface_draw_land_side_top(paint_session * session, enum edge_t edge, uint8 height, uint8 terrain, struct tile_descriptor self, struct tile_descriptor neighbour)
{ {
registers regs; registers regs;
@ -509,7 +509,7 @@ static void viewport_surface_draw_land_side_top(enum edge_t edge, uint8 height,
uint32 image_id = _terrainEdgeSpriteIds[terrain][3] + (edge == EDGE_TOPLEFT ? 3 : 0) + incline; // var_c; uint32 image_id = _terrainEdgeSpriteIds[terrain][3] + (edge == EDGE_TOPLEFT ? 3 : 0) + incline; // var_c;
sint16 y = (regs.dl - regs.al) * 16; sint16 y = (regs.dl - regs.al) * 16;
paint_attach_to_previous_ps(image_id, 0, y); paint_attach_to_previous_ps(session, image_id, 0, y);
return; return;
} }
@ -1165,7 +1165,7 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, rct_
image_id |= SPR_TERRAIN_SELECTION_PATROL_AREA + byte_97B444[surfaceShape]; image_id |= SPR_TERRAIN_SELECTION_PATROL_AREA + byte_97B444[surfaceShape];
image_id |= patrolColour << 19; image_id |= patrolColour << 19;
paint_attach_to_previous_ps(image_id, 0, 0); paint_attach_to_previous_ps(session, image_id, 0, 0);
} }
} }
@ -1191,7 +1191,7 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, rct_
// loc_660E9A: // loc_660E9A:
if (mapElement->properties.surface.ownership & OWNERSHIP_OWNED) { if (mapElement->properties.surface.ownership & OWNERSHIP_OWNED) {
assert(surfaceShape < countof(byte_97B444)); assert(surfaceShape < countof(byte_97B444));
paint_attach_to_previous_ps(SPR_TERRAIN_SELECTION_SQUARE + byte_97B444[surfaceShape], 0, 0); paint_attach_to_previous_ps(session, SPR_TERRAIN_SELECTION_SQUARE + byte_97B444[surfaceShape], 0, 0);
} else if (mapElement->properties.surface.ownership & OWNERSHIP_AVAILABLE) { } else if (mapElement->properties.surface.ownership & OWNERSHIP_AVAILABLE) {
rct_xy16 pos = session->MapPosition; rct_xy16 pos = session->MapPosition;
paint_struct * backup = session->UnkF1AD28; paint_struct * backup = session->UnkF1AD28;
@ -1205,7 +1205,7 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, rct_
&& !(mapElement->properties.surface.ownership & OWNERSHIP_OWNED)) { && !(mapElement->properties.surface.ownership & OWNERSHIP_OWNED)) {
if (mapElement->properties.surface.ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED) { if (mapElement->properties.surface.ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_OWNED) {
assert(surfaceShape < countof(byte_97B444)); assert(surfaceShape < countof(byte_97B444));
paint_attach_to_previous_ps(SPR_TERRAIN_SELECTION_DOTTED + byte_97B444[surfaceShape], 0, 0); paint_attach_to_previous_ps(session, SPR_TERRAIN_SELECTION_DOTTED + byte_97B444[surfaceShape], 0, 0);
} else if (mapElement->properties.surface.ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_AVAILABLE) { } else if (mapElement->properties.surface.ownership & OWNERSHIP_CONSTRUCTION_RIGHTS_AVAILABLE) {
paint_struct * backup = session->UnkF1AD28; paint_struct * backup = session->UnkF1AD28;
rct_xy16 pos = session->MapPosition; rct_xy16 pos = session->MapPosition;
@ -1233,13 +1233,13 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, rct_
// loc_661089: // loc_661089:
uint32 eax = ((((mapSelectionType - 9) + rotation) & 3) + 0x21) << 19; uint32 eax = ((((mapSelectionType - 9) + rotation) & 3) + 0x21) << 19;
uint32 image_id = (SPR_TERRAIN_SELECTION_EDGE + byte_97B444[surfaceShape]) | eax | IMAGE_TYPE_REMAP; uint32 image_id = (SPR_TERRAIN_SELECTION_EDGE + byte_97B444[surfaceShape]) | eax | IMAGE_TYPE_REMAP;
paint_attach_to_previous_ps(image_id, 0, 0); paint_attach_to_previous_ps(session, image_id, 0, 0);
} else if (mapSelectionType >= MAP_SELECT_TYPE_QUARTER_0) { } else if (mapSelectionType >= MAP_SELECT_TYPE_QUARTER_0) {
// loc_661051:(no jump) // loc_661051:(no jump)
// Selection split into four quarter segments // Selection split into four quarter segments
uint32 eax = ((((mapSelectionType - MAP_SELECT_TYPE_QUARTER_0) + rotation) & 3) + 0x27) << 19; uint32 eax = ((((mapSelectionType - MAP_SELECT_TYPE_QUARTER_0) + rotation) & 3) + 0x27) << 19;
uint32 image_id = (SPR_TERRAIN_SELECTION_QUARTER + byte_97B444[surfaceShape]) | eax | IMAGE_TYPE_REMAP; uint32 image_id = (SPR_TERRAIN_SELECTION_QUARTER + byte_97B444[surfaceShape]) | eax | IMAGE_TYPE_REMAP;
paint_attach_to_previous_ps(image_id, 0, 0); paint_attach_to_previous_ps(session, image_id, 0, 0);
} else if (mapSelectionType <= MAP_SELECT_TYPE_FULL) { } else if (mapSelectionType <= MAP_SELECT_TYPE_FULL) {
// Corners // Corners
uint32 eax = mapSelectionType; uint32 eax = mapSelectionType;
@ -1249,7 +1249,7 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, rct_
eax = (eax + 0x21) << 19; eax = (eax + 0x21) << 19;
uint32 image_id = (SPR_TERRAIN_SELECTION_CORNER + byte_97B444[surfaceShape]) | eax | IMAGE_TYPE_REMAP; uint32 image_id = (SPR_TERRAIN_SELECTION_CORNER + byte_97B444[surfaceShape]) | eax | IMAGE_TYPE_REMAP;
paint_attach_to_previous_ps(image_id, 0, 0); paint_attach_to_previous_ps(session, image_id, 0, 0);
} else { } else {
sint32 local_surfaceShape = surfaceShape; sint32 local_surfaceShape = surfaceShape;
sint32 local_height = height; sint32 local_height = height;
@ -1298,7 +1298,7 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, rct_
} }
uint32 image_id = (SPR_TERRAIN_SELECTION_CORNER + byte_97B444[surfaceShape]) | colours | IMAGE_TYPE_REMAP; uint32 image_id = (SPR_TERRAIN_SELECTION_CORNER + byte_97B444[surfaceShape]) | colours | IMAGE_TYPE_REMAP;
paint_attach_to_previous_ps(image_id, 0, 0); paint_attach_to_previous_ps(session, image_id, 0, 0);
break; break;
} }
} }
@ -1325,7 +1325,7 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, rct_
base_image = byte_97B84A[terrain_type]; base_image = byte_97B84A[terrain_type];
} }
uint32 image_id = dword_97B7C8[base_image] + image_offset; uint32 image_id = dword_97B7C8[base_image] + image_offset;
paint_attach_to_previous_ps(image_id, 0, 0); paint_attach_to_previous_ps(session, image_id, 0, 0);
} }
if (!(gCurrentViewportFlags & VIEWPORT_FLAG_HIDE_VERTICAL)) { if (!(gCurrentViewportFlags & VIEWPORT_FLAG_HIDE_VERTICAL)) {
@ -1352,8 +1352,8 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, rct_
memcpy(backupRightTunnels, session->RightTunnels, sizeof(tunnel_entry) * TUNNEL_MAX_COUNT); memcpy(backupRightTunnels, session->RightTunnels, sizeof(tunnel_entry) * TUNNEL_MAX_COUNT);
#endif #endif
viewport_surface_draw_land_side_top(EDGE_TOPLEFT, height / 16, eax / 32, tileDescriptors[0], tileDescriptors[3]); viewport_surface_draw_land_side_top(session, EDGE_TOPLEFT, height / 16, eax / 32, tileDescriptors[0], tileDescriptors[3]);
viewport_surface_draw_land_side_top(EDGE_TOPRIGHT, height / 16, eax / 32, tileDescriptors[0], tileDescriptors[4]); viewport_surface_draw_land_side_top(session, EDGE_TOPRIGHT, height / 16, eax / 32, tileDescriptors[0], tileDescriptors[4]);
viewport_surface_draw_land_side_bottom(session, EDGE_BOTTOMLEFT, height / 16, eax / 32, tileDescriptors[0], tileDescriptors[1]); viewport_surface_draw_land_side_bottom(session, EDGE_BOTTOMLEFT, height / 16, eax / 32, tileDescriptors[0], tileDescriptors[1]);
viewport_surface_draw_land_side_bottom(session, EDGE_BOTTOMRIGHT, height / 16, eax / 32, tileDescriptors[0], tileDescriptors[2]); viewport_surface_draw_land_side_bottom(session, EDGE_BOTTOMRIGHT, height / 16, eax / 32, tileDescriptors[0], tileDescriptors[2]);
@ -1389,7 +1389,7 @@ void surface_paint(paint_session * session, uint8 direction, uint16 height, rct_
sint32 image_id = (SPR_WATER_MASK + image_offset) | IMAGE_TYPE_REMAP | IMAGE_TYPE_TRANSPARENT | PALETTE_WATER << 19; sint32 image_id = (SPR_WATER_MASK + image_offset) | IMAGE_TYPE_REMAP | IMAGE_TYPE_TRANSPARENT | PALETTE_WATER << 19;
sub_98196C(image_id, 0, 0, 32, 32, -1, waterHeight, rotation); sub_98196C(image_id, 0, 0, 32, 32, -1, waterHeight, rotation);
paint_attach_to_previous_ps(SPR_WATER_OVERLAY + image_offset, 0, 0); paint_attach_to_previous_ps(session, SPR_WATER_OVERLAY + image_offset, 0, 0);
// This wasn't in the original, but the code depended on globals that were only set in a different conditional // This wasn't in the original, but the code depended on globals that were only set in a different conditional
uint8 al_edgeStyle = mapElement->properties.surface.slope & 0xE0; uint8 al_edgeStyle = mapElement->properties.surface.slope & 0xE0;

View File

@ -520,12 +520,10 @@ paint_struct * sub_98199C(
* @param y (cx) * @param y (cx)
* @return (!CF) success * @return (!CF) success
*/ */
bool paint_attach_to_previous_attach(uint32 image_id, uint16 x, uint16 y) bool paint_attach_to_previous_attach(paint_session * session, uint32 image_id, uint16 x, uint16 y)
{ {
paint_session * session = &gPaintSession;
if (session->UnkF1AD2C == NULL) { if (session->UnkF1AD2C == NULL) {
return paint_attach_to_previous_ps(image_id, x, y); return paint_attach_to_previous_ps(session, image_id, x, y);
} }
if (session->NextFreePaintStruct >= session->EndOfPaintStructArray) { if (session->NextFreePaintStruct >= session->EndOfPaintStructArray) {
@ -557,10 +555,8 @@ bool paint_attach_to_previous_attach(uint32 image_id, uint16 x, uint16 y)
* @param y (cx) * @param y (cx)
* @return (!CF) success * @return (!CF) success
*/ */
bool paint_attach_to_previous_ps(uint32 image_id, uint16 x, uint16 y) bool paint_attach_to_previous_ps(paint_session * session, uint32 image_id, uint16 x, uint16 y)
{ {
paint_session * session = &gPaintSession;
if (session->NextFreePaintStruct >= session->EndOfPaintStructArray) { if (session->NextFreePaintStruct >= session->EndOfPaintStructArray) {
return false; return false;
} }
@ -598,10 +594,8 @@ bool paint_attach_to_previous_ps(uint32 image_id, uint16 x, uint16 y)
* @param y_offsets (di) * @param y_offsets (di)
* @param rotation (ebp) * @param rotation (ebp)
*/ */
void paint_floating_money_effect(money32 amount, rct_string_id string_id, sint16 y, sint16 z, sint8 y_offsets[], sint16 offset_x, uint32 rotation) void paint_floating_money_effect(paint_session * session, money32 amount, rct_string_id string_id, sint16 y, sint16 z, sint8 y_offsets[], sint16 offset_x, uint32 rotation)
{ {
paint_session * session = &gPaintSession;
if (session->NextFreePaintStruct >= session->EndOfPaintStructArray) { if (session->NextFreePaintStruct >= session->EndOfPaintStructArray) {
return; return;
} }

View File

@ -222,9 +222,9 @@ paint_struct * sub_98199C_rotated(uint8 direction, uint32 image_id, sint8 x_offs
void paint_util_push_tunnel_rotated(uint8 direction, uint16 height, uint8 type); void paint_util_push_tunnel_rotated(uint8 direction, uint16 height, uint8 type);
bool paint_attach_to_previous_attach(uint32 image_id, uint16 x, uint16 y); bool paint_attach_to_previous_attach(paint_session * session, uint32 image_id, uint16 x, uint16 y);
bool paint_attach_to_previous_ps(uint32 image_id, uint16 x, uint16 y); bool paint_attach_to_previous_ps(paint_session * session, uint32 image_id, uint16 x, uint16 y);
void paint_floating_money_effect(money32 amount, rct_string_id string_id, sint16 y, sint16 z, sint8 y_offsets[], sint16 offset_x, uint32 rotation); void paint_floating_money_effect(paint_session * session, money32 amount, rct_string_id string_id, sint16 y, sint16 z, sint8 y_offsets[], sint16 offset_x, uint32 rotation);
paint_session * paint_session_alloc(rct_drawpixelinfo * dpi); paint_session * paint_session_alloc(rct_drawpixelinfo * dpi);
void paint_session_free(paint_session *); void paint_session_free(paint_session *);

View File

@ -58,7 +58,7 @@ void misc_paint(paint_session * session, rct_sprite *misc, sint32 imageDirection
rct_money_effect * moneyEffect = &misc->money_effect; rct_money_effect * moneyEffect = &misc->money_effect;
money32 value; money32 value;
rct_string_id stringId = money_effect_get_string_id(moneyEffect, &value); rct_string_id stringId = money_effect_get_string_id(moneyEffect, &value);
paint_floating_money_effect(value, stringId, moneyEffect->y, moneyEffect->z, (sint8 *) &money_wave[moneyEffect->wiggle % 22], moneyEffect->offset_x, get_current_rotation()); paint_floating_money_effect(session, value, stringId, moneyEffect->y, moneyEffect->z, (sint8 *) &money_wave[moneyEffect->wiggle % 22], moneyEffect->offset_x, get_current_rotation());
break; break;
} }

View File

@ -43,7 +43,7 @@ static void paint_dodgems_roof(sint32 height, sint32 offset)
sub_98196C(image_id, 0, 0, 32, 32, 2, height, get_current_rotation()); sub_98196C(image_id, 0, 0, 32, 32, 2, height, get_current_rotation());
image_id = (SPR_DODGEMS_ROOF_GLASS + offset) | (PALETTE_DARKEN_3 << 19) | IMAGE_TYPE_TRANSPARENT; image_id = (SPR_DODGEMS_ROOF_GLASS + offset) | (PALETTE_DARKEN_3 << 19) | IMAGE_TYPE_TRANSPARENT;
paint_attach_to_previous_ps(image_id, 0, 0); paint_attach_to_previous_ps(&gPaintSession, image_id, 0, 0);
} }
static void paint_dodgems(uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement) static void paint_dodgems(uint8 rideIndex, uint8 trackSequence, uint8 direction, sint32 height, rct_map_element * mapElement)

View File

@ -385,7 +385,7 @@ paint_struct *sub_98199C(
); );
} }
bool paint_attach_to_previous_ps(uint32 image_id, uint16 x, uint16 y) { bool paint_attach_to_previous_ps(paint_session * session, uint32 image_id, uint16 x, uint16 y) {
return false; return false;
} }