1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-06 06:32:56 +01:00

move data into code, cleanup

This commit is contained in:
zsilencer
2015-05-18 17:25:58 -06:00
parent 9ee4b64fa1
commit 28c2451d97

View File

@@ -1402,6 +1402,15 @@ void game_command_change_surface_style(int* eax, int* ebx, int* ecx, int* edx, i
);
}
//0x00981A1E
const uint8 map_element_raise_styles[5][32] = {
{0x01, 0x1B, 0x03, 0x1B, 0x05, 0x21, 0x07, 0x21, 0x09, 0x1B, 0x0B, 0x1B, 0x0D, 0x21, 0x20, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x23, 0x18, 0x19, 0x1A, 0x3B, 0x1C, 0x29, 0x24, 0x1F},
{0x02, 0x03, 0x17, 0x17, 0x06, 0x07, 0x17, 0x17, 0x0A, 0x0B, 0x22, 0x22, 0x0E, 0x20, 0x22, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x37, 0x18, 0x19, 0x1A, 0x23, 0x1C, 0x28, 0x26, 0x1F},
{0x04, 0x05, 0x06, 0x07, 0x1E, 0x24, 0x1E, 0x24, 0x0C, 0x0D, 0x0E, 0x20, 0x1E, 0x24, 0x1E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x26, 0x18, 0x19, 0x1A, 0x21, 0x1C, 0x2C, 0x3E, 0x1F},
{0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x20, 0x1D, 0x1D, 0x28, 0x28, 0x1D, 0x1D, 0x28, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x22, 0x18, 0x19, 0x1A, 0x29, 0x1C, 0x3D, 0x2C, 0x1F},
{0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x22, 0x20, 0x20, 0x20, 0x21, 0x20, 0x28, 0x24, 0x20},
};
/**
*
* rct2: 0x0068C542
@@ -1417,7 +1426,7 @@ void game_command_raise_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, i
int by = (uint16)(*ebp >> 16);
uint16 selection_type = *edi;
int cost = MONEY32_UNDEFINED;
int cost = 0;
if(*ebx & GAME_COMMAND_FLAG_APPLY && RCT2_GLOBAL(0x009A8C28, uint8) == 1){
sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z);
@@ -1440,21 +1449,20 @@ void game_command_raise_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, i
rct_map_element* map_element = map_get_surface_element_at(xi / 32, yi / 32);
uint8 height = map_element->base_height;
if(height <= min_height){
uint8 dh = RCT2_ADDRESS(0x00981A1E, uint8)[(selection_type * 32) + (map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK)]; // lookup table
if(dh & 0x20){ // needs to be raised, otherwise just the slope type changes
uint8 new_style = map_element_raise_styles[selection_type][map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK];
if(new_style & 0x20){ // needs to be raised
height += 2;
dh &= ~0x20;
new_style &= ~0x20;
}
int ebx2 = *ebx;
int edx2 = (dh << 8) + height;
int edi2 = selection_type * 32;
int edx2 = (new_style << 8) | height;
int edi2 = selection_type << 5;
RCT2_CALLFUNC_X(0x0066397F, &xi, &ebx2, &yi, &edx2, (int*)&map_element, &edi2, ebp); // actually apply the change
if(ebx2 != MONEY32_UNDEFINED){
if(cost == MONEY32_UNDEFINED){
cost = ebx2;
}else{
cost += ebx2;
}
if(ebx2 == MONEY32_UNDEFINED){
*ebx = MONEY32_UNDEFINED;
return;
}else{
cost += ebx2;
}
}
}
@@ -1466,6 +1474,15 @@ void game_command_raise_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, i
*ebx = cost;
}
//0x00981ABE
const uint8 map_element_lower_styles[5][32] = {
{0x2E, 0x00, 0x2E, 0x02, 0x3E, 0x04, 0x3E, 0x06, 0x2E, 0x08, 0x2E, 0x0A, 0x3E, 0x0C, 0x3E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x06, 0x18, 0x19, 0x1A, 0x0B, 0x1C, 0x0C, 0x3E, 0x1F},
{0x2D, 0x2D, 0x00, 0x01, 0x2D, 0x2D, 0x04, 0x05, 0x3D, 0x3D, 0x08, 0x09, 0x3D, 0x3D, 0x0C, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x07, 0x18, 0x19, 0x1A, 0x09, 0x1C, 0x3D, 0x0C, 0x1F},
{0x2B, 0x3B, 0x2B, 0x3B, 0x00, 0x01, 0x02, 0x03, 0x2B, 0x3B, 0x2B, 0x3B, 0x08, 0x09, 0x0A, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x03, 0x18, 0x19, 0x1A, 0x3B, 0x1C, 0x09, 0x0E, 0x1F},
{0x27, 0x27, 0x37, 0x37, 0x27, 0x27, 0x37, 0x37, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x37, 0x18, 0x19, 0x1A, 0x03, 0x1C, 0x0D, 0x06, 0x1F},
{0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0B, 0x00, 0x0D, 0x0E, 0x00},
};
/**
*
* rct2: 0x0068C6D1
@@ -1481,7 +1498,7 @@ void game_command_lower_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, i
int by = (uint16)(*ebp >> 16);
uint16 selection_type = *edi;
int cost = MONEY32_UNDEFINED;
int cost = 0;
if(*ebx & GAME_COMMAND_FLAG_APPLY && RCT2_GLOBAL(0x009A8C28, uint8) == 1){
sound_play_panned(SOUND_PLACE_ITEM, 0x8001, x, y, z);
@@ -1518,21 +1535,20 @@ void game_command_lower_land(int* eax, int* ebx, int* ecx, int* edx, int* esi, i
}
if(height >= max_height){
height = map_element->base_height;
uint8 dh = RCT2_ADDRESS(0x00981ABE, uint8)[(selection_type * 32) + (map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK)]; // lookup table
if(dh & 0x20){ // needs to be lowered, otherwise just the slope type changes
uint8 new_style = map_element_lower_styles[selection_type][map_element->properties.surface.slope & MAP_ELEMENT_SLOPE_MASK];
if(new_style & 0x20){ // needs to be lowered
height -= 2;
dh &= ~0x20;
new_style &= ~0x20;
}
int ebx2 = *ebx;
int edx2 = (dh << 8) + height;
int edi2 = selection_type * 32;
int edx2 = (new_style << 8) | height;
int edi2 = selection_type << 5;
RCT2_CALLFUNC_X(0x0066397F, &xi, &ebx2, &yi, &edx2, (int*)&map_element, &edi2, ebp); // actually apply the change
if(ebx2 != MONEY32_UNDEFINED){
if(cost == MONEY32_UNDEFINED){
cost = ebx2;
}else{
cost += ebx2;
}
if(ebx2 == MONEY32_UNDEFINED){
*ebx = MONEY32_UNDEFINED;
return;
}else{
cost += ebx2;
}
}
}
@@ -1926,13 +1942,13 @@ void game_command_place_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi
bp += rotation;
bp &= 3;
bl = 0xBB;
bl = (bl << bp) | (bl >> (8 - bp)); //rol
bl = rol8(bl, bp);
bl &= 0xF;
}else{
bp += rotation;
bp &= 1;
bl = 0xA;
bl = (bl >> bp) | (bl << (8 - bp)); //ror
bl = ror8(bl, bp);
}
}
}else{
@@ -1940,7 +1956,7 @@ void game_command_place_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi
bp += rotation;
bp &= 3;
bl = 0x33;
bl = (bl << bp) | (bl >> (8 - bp)); //rol
bl = rol8(bl, bp);
bl &= 0xF;
}
if(z == 0){
@@ -1971,7 +1987,7 @@ void game_command_place_scenery(int* eax, int* ebx, int* ecx, int* edx, int* esi
new_map_element->flags |= 0x10;
}
map_invalidate_tile_full(x, y);
if(scenery_entry->small_scenery.flags & 0x10){
if(scenery_entry->small_scenery.flags & SMALL_SCENERY_FLAG_ANIMATED){
map_animation_create(2, x, y, new_map_element->base_height);
}
}