From 10ab0030ae19005708dd3cf6503f1ea0325cbb89 Mon Sep 17 00:00:00 2001 From: Tom van der Kleij Date: Thu, 4 Sep 2014 22:10:53 +0200 Subject: [PATCH 1/2] Decompiled peep_create (0x0069EC6B) --- src/peep.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ src/peep.h | 1 + src/staff.c | 11 +++++------ 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/peep.c b/src/peep.c index ea85a117e4..56fa5dd5e9 100644 --- a/src/peep.c +++ b/src/peep.c @@ -410,6 +410,53 @@ rct_peep *peep_generate(int x, int y, int z) return (rct_peep*)esi; } +/* +* rct2: 69EC6B +* bl: unclear what this does +*/ +rct_peep *peep_create(uint8 bl) +{ + rct_peep *peep = NULL; + + int ecx = 0xA; + + if ((bl & 2 != 0)) + { + // 69EC96; + uint16 cx = 0x12C - RCT2_GLOBAL(0x13573CE, uint16); + if (cx >= RCT2_GLOBAL(0x13573C8, uint16)) + { + return NULL; + } + + ecx = 6; + } + else if (RCT2_GLOBAL(0x13573C8, uint16) <= 0) + { + return NULL; + } + + peep = &g_sprite_list[RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)]; + + RCT2_CALLPROC_X(0x0069ED0B, 0, 0, ecx, 0, (int)peep, 0, 0); + + peep->x = SPRITE_LOCATION_NULL; + peep->y = SPRITE_LOCATION_NULL; + peep->z = 0; + peep->name_string_idx = 0; + peep->var_14 = 0x10; + peep->var_09 = 0x14; + peep->var_15 = 0x8; + peep->var_0C = 0x0; + peep->var_16 = SPRITE_LOCATION_NULL; + + uint16 oldGlobal = RCT2_GLOBAL(0xF3EF60, uint16); + RCT2_GLOBAL(0xF3EF60, uint16) = peep->sprite_index; + peep->var_02 = oldGlobal; + + return peep; +} + /** * rct2: 0x00698B0D * peep.sprite_index (eax) diff --git a/src/peep.h b/src/peep.h index 3f18e5d587..306ff82551 100644 --- a/src/peep.h +++ b/src/peep.h @@ -443,6 +443,7 @@ void peep_problem_warnings_update(); void peep_update_crowd_noise(); void peep_applause(); rct_peep *peep_generate(int x, int y, int z); +rct_peep *peep_create(uint8 bl); void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argument_2); void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2); diff --git a/src/staff.c b/src/staff.c index 1e0bc041cb..7ec082a5c1 100644 --- a/src/staff.c +++ b/src/staff.c @@ -111,14 +111,13 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, int newStaffId = i; - int _eax, _ebx, _ecx = _cx, _edx, _esi, _edi, _ebp; - _esi = 0; + int _eax, _ebx, _ecx = _cx, _edx, _edi, _ebp; + int _esi; _ebx = _bl; - RCT2_CALLFUNC_X(0x0069EC6B, &_eax, &_ebx, &_ecx, &_edx, &_esi, &_edi, &_ebp); - rct_peep* newPeep = (rct_peep*)_esi; - //if ((newPeep = create_peep_sprite(_bl)) == NULL) - if (_esi == 0) + rct_peep* newPeep = peep_create(_bl); + + if (newPeep == 0) { *ebx = 0x80000000; RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_PEOPLE_IN_GAME; From c9f081e5d2bfd41bf471e1ed03bf9f8dd86cc48d Mon Sep 17 00:00:00 2001 From: Tom van der Kleij Date: Thu, 4 Sep 2014 23:21:17 +0200 Subject: [PATCH 2/2] Renamed peep_create --> create_sprite + minor changes from feedback --- src/peep.c | 47 ----------------------------------------------- src/peep.h | 1 - src/sprite.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ src/sprite.h | 8 ++++++-- src/staff.c | 5 ++--- 5 files changed, 52 insertions(+), 53 deletions(-) diff --git a/src/peep.c b/src/peep.c index 56fa5dd5e9..ea85a117e4 100644 --- a/src/peep.c +++ b/src/peep.c @@ -410,53 +410,6 @@ rct_peep *peep_generate(int x, int y, int z) return (rct_peep*)esi; } -/* -* rct2: 69EC6B -* bl: unclear what this does -*/ -rct_peep *peep_create(uint8 bl) -{ - rct_peep *peep = NULL; - - int ecx = 0xA; - - if ((bl & 2 != 0)) - { - // 69EC96; - uint16 cx = 0x12C - RCT2_GLOBAL(0x13573CE, uint16); - if (cx >= RCT2_GLOBAL(0x13573C8, uint16)) - { - return NULL; - } - - ecx = 6; - } - else if (RCT2_GLOBAL(0x13573C8, uint16) <= 0) - { - return NULL; - } - - peep = &g_sprite_list[RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)]; - - RCT2_CALLPROC_X(0x0069ED0B, 0, 0, ecx, 0, (int)peep, 0, 0); - - peep->x = SPRITE_LOCATION_NULL; - peep->y = SPRITE_LOCATION_NULL; - peep->z = 0; - peep->name_string_idx = 0; - peep->var_14 = 0x10; - peep->var_09 = 0x14; - peep->var_15 = 0x8; - peep->var_0C = 0x0; - peep->var_16 = SPRITE_LOCATION_NULL; - - uint16 oldGlobal = RCT2_GLOBAL(0xF3EF60, uint16); - RCT2_GLOBAL(0xF3EF60, uint16) = peep->sprite_index; - peep->var_02 = oldGlobal; - - return peep; -} - /** * rct2: 0x00698B0D * peep.sprite_index (eax) diff --git a/src/peep.h b/src/peep.h index 306ff82551..3f18e5d587 100644 --- a/src/peep.h +++ b/src/peep.h @@ -443,7 +443,6 @@ void peep_problem_warnings_update(); void peep_update_crowd_noise(); void peep_applause(); rct_peep *peep_generate(int x, int y, int z); -rct_peep *peep_create(uint8 bl); void get_arguments_from_action(rct_peep* peep, uint32 *argument_1, uint32* argument_2); void get_arguments_from_thought(rct_peep_thought thought, uint32* argument_1, uint32* argument_2); diff --git a/src/sprite.c b/src/sprite.c index c2c80cb5dd..96dbdc4596 100644 --- a/src/sprite.c +++ b/src/sprite.c @@ -104,4 +104,48 @@ void reset_0x69EBE4(){ spr->unknown.var_02 = ax; } } +} + +/* +* rct2: 0x0069EC6B +* bl: unclear what this does +*/ +rct_sprite *create_sprite(uint8 bl) +{ + int ecx = 0xA; + + if ((bl & 2 != 0)) + { + // 69EC96; + uint16 cx = 0x12C - RCT2_GLOBAL(0x13573CE, uint16); + if (cx >= RCT2_GLOBAL(0x13573C8, uint16)) + { + return NULL; + } + + ecx = 6; + } + else if (RCT2_GLOBAL(0x13573C8, uint16) <= 0) + { + return NULL; + } + + rct_unk_sprite *sprite = &g_sprite_list[RCT2_GLOBAL(RCT2_ADDRESS_SPRITES_NEXT_INDEX, uint16)]; + + RCT2_CALLPROC_X(0x0069ED0B, 0, 0, ecx, 0, (int)sprite, 0, 0); + + sprite->x = SPRITE_LOCATION_NULL; + sprite->y = SPRITE_LOCATION_NULL; + sprite->z = 0; + sprite->name_string_idx = 0; + sprite->var_14 = 0x10; + sprite->pad_09 = 0x14; + sprite->var_15 = 0x8; + sprite->pad_0C[0] = 0x0; + sprite->var_16 = SPRITE_LOCATION_NULL; + + sprite->var_02 = RCT2_GLOBAL(0xF3EF60, uint16); + RCT2_GLOBAL(0xF3EF60, uint16) = sprite->sprite_index; + + return sprite; } \ No newline at end of file diff --git a/src/sprite.h b/src/sprite.h index 701d448cbc..81f6955956 100644 --- a/src/sprite.h +++ b/src/sprite.h @@ -49,12 +49,15 @@ typedef struct { sint16 x; // 0x0E sint16 y; // 0x10 sint16 z; // 0x12 - uint16 pad_14; + uint8 var_14; // 0x14 + uint8 var_15; // 0x15 sint16 var_16; //x related sint16 var_18; //y related sint16 var_1A; //x related sint16 var_1C; //y related - uint8 sprite_direction; //direction of sprite? + uint8 sprite_direction; //direction of sprite? 0x1e + uint8 pad_1F[3]; // 0x1f + uint16 name_string_idx; // 0x22 } rct_unk_sprite; typedef struct { @@ -86,6 +89,7 @@ typedef union { extern rct_sprite* g_sprite_list; void create_balloon(int x, int y, int z, int colour); +rct_sprite *create_sprite(uint8 bl); void reset_sprite_list(); void reset_0x69EBE4(); diff --git a/src/staff.c b/src/staff.c index 7ec082a5c1..4fe6e6eb68 100644 --- a/src/staff.c +++ b/src/staff.c @@ -112,12 +112,11 @@ void game_command_hire_new_staff_member(int* eax, int* ebx, int* ecx, int* edx, int newStaffId = i; int _eax, _ebx, _ecx = _cx, _edx, _edi, _ebp; - int _esi; _ebx = _bl; - rct_peep* newPeep = peep_create(_bl); + rct_peep* newPeep = create_sprite(_bl); - if (newPeep == 0) + if (newPeep == NULL) { *ebx = 0x80000000; RCT2_GLOBAL(RCT2_ADDRESS_GAME_COMMAND_ERROR_TEXT, uint16) = STR_TOO_MANY_PEOPLE_IN_GAME;