mirror of https://github.com/zeldaret/tmc.git
				
				
				
			some cleanup
This commit is contained in:
		
							parent
							
								
									c0ad5c6e3e
								
							
						
					
					
						commit
						a6dc937fbb
					
				| 
						 | 
					@ -2,6 +2,7 @@
 | 
				
			||||||
#include "enemy.h"
 | 
					#include "enemy.h"
 | 
				
			||||||
#include "audio.h"
 | 
					#include "audio.h"
 | 
				
			||||||
#include "random.h"
 | 
					#include "random.h"
 | 
				
			||||||
 | 
					#include "object.h"
 | 
				
			||||||
#include "functions.h"
 | 
					#include "functions.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sub_0803B538(Entity*);
 | 
					void sub_0803B538(Entity*);
 | 
				
			||||||
| 
						 | 
					@ -182,7 +183,7 @@ void sub_0803A274(Entity* this) {
 | 
				
			||||||
            pEVar1 = CreateEnemy(0x44, 2);
 | 
					            pEVar1 = CreateEnemy(0x44, 2);
 | 
				
			||||||
            pEVar1->parent = this;
 | 
					            pEVar1->parent = this;
 | 
				
			||||||
            *(Entity**)&this->field_0x74 = pEVar1;
 | 
					            *(Entity**)&this->field_0x74 = pEVar1;
 | 
				
			||||||
            pEVar1 = CreateObject(0x7e, 1, 0);
 | 
					            pEVar1 = CreateObject(OBJECT_7E, 1, 0);
 | 
				
			||||||
            pEVar1->parent = this;
 | 
					            pEVar1->parent = this;
 | 
				
			||||||
            pEVar1->attachedEntity = this->attachedEntity;
 | 
					            pEVar1->attachedEntity = this->attachedEntity;
 | 
				
			||||||
            PositionRelative(this->parent, this, 0x100000, 0x200000);
 | 
					            PositionRelative(this->parent, this, 0x100000, 0x200000);
 | 
				
			||||||
| 
						 | 
					@ -193,7 +194,7 @@ void sub_0803A274(Entity* this) {
 | 
				
			||||||
            pEVar1 = CreateEnemy(0x44, 3);
 | 
					            pEVar1 = CreateEnemy(0x44, 3);
 | 
				
			||||||
            pEVar1->parent = this;
 | 
					            pEVar1->parent = this;
 | 
				
			||||||
            *(Entity**)&this->field_0x74 = pEVar1;
 | 
					            *(Entity**)&this->field_0x74 = pEVar1;
 | 
				
			||||||
            pEVar1 = CreateObject(0x7e, 2, 0);
 | 
					            pEVar1 = CreateObject(OBJECT_7E, 2, 0);
 | 
				
			||||||
            pEVar1->parent = this;
 | 
					            pEVar1->parent = this;
 | 
				
			||||||
            pEVar1->attachedEntity = this->attachedEntity;
 | 
					            pEVar1->attachedEntity = this->attachedEntity;
 | 
				
			||||||
            this->spriteSettings.b.flipX = 1;
 | 
					            this->spriteSettings.b.flipX = 1;
 | 
				
			||||||
| 
						 | 
					@ -214,7 +215,6 @@ void sub_0803A274(Entity* this) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sub_0803A364(Entity* this) {
 | 
					void sub_0803A364(Entity* this) {
 | 
				
			||||||
    u8 uVar1;
 | 
					    u8 uVar1;
 | 
				
			||||||
    int iVar2;
 | 
					 | 
				
			||||||
    Entity* pEVar3;
 | 
					    Entity* pEVar3;
 | 
				
			||||||
    u32 index;
 | 
					    u32 index;
 | 
				
			||||||
    s8* ptr;
 | 
					    s8* ptr;
 | 
				
			||||||
| 
						 | 
					@ -244,8 +244,7 @@ void sub_0803A364(Entity* this) {
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            break;
 | 
					            break;
 | 
				
			||||||
        case 5:
 | 
					        case 5:
 | 
				
			||||||
            iVar2 = sub_0803B4E4(this);
 | 
					            if (sub_0803B4E4(this) == 0) {
 | 
				
			||||||
            if (iVar2 == 0) {
 | 
					 | 
				
			||||||
                sub_0806F69C(this);
 | 
					                sub_0806F69C(this);
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
| 
						 | 
					@ -375,7 +374,6 @@ void sub_0803A60C(Entity* this) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sub_0803A660(Entity* this) {
 | 
					void sub_0803A660(Entity* this) {
 | 
				
			||||||
    s32 sVar1;
 | 
					 | 
				
			||||||
    u32 uVar2;
 | 
					    u32 uVar2;
 | 
				
			||||||
    u8* pbVar3;
 | 
					    u8* pbVar3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -406,7 +404,7 @@ void sub_0803A660(Entity* this) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sub_0803A6E8(Entity* this) {
 | 
					void sub_0803A6E8(Entity* this) {
 | 
				
			||||||
    s32 iVar1;
 | 
					    s32 y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (sub_0803B610(this)) {
 | 
					    if (sub_0803B610(this)) {
 | 
				
			||||||
        this->action = 8;
 | 
					        this->action = 8;
 | 
				
			||||||
| 
						 | 
					@ -414,28 +412,26 @@ void sub_0803A6E8(Entity* this) {
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        sub_0803B63C(this);
 | 
					        sub_0803B63C(this);
 | 
				
			||||||
        sub_0806F69C(this);
 | 
					        sub_0806F69C(this);
 | 
				
			||||||
        iVar1 = this->parent->y.HALF.HI + 8;
 | 
					        y = this->parent->y.HALF.HI + 8;
 | 
				
			||||||
        if (iVar1 > this->y.HALF.HI) {
 | 
					        if (y > this->y.HALF.HI) {
 | 
				
			||||||
            this->y.HALF.HI = iVar1;
 | 
					            this->y.HALF.HI = y;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sub_0803A720(Entity* this) {
 | 
					void sub_0803A720(Entity* this) {
 | 
				
			||||||
    this->actionDelay--;
 | 
					    if (--this->actionDelay == 0) {
 | 
				
			||||||
    if (this->actionDelay == 0) {
 | 
					 | 
				
			||||||
        this->action = 9;
 | 
					        this->action = 9;
 | 
				
			||||||
        sub_0803B8E8(this, 0x16);
 | 
					        sub_0803B8E8(this, 0x16);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sub_0803A740(Entity* this) {
 | 
					void sub_0803A740(Entity* this) {
 | 
				
			||||||
    u16 uVar1;
 | 
					    u16 height;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // TODO this is bad, but it matches
 | 
					    height = this->height.HALF.HI + 4;
 | 
				
			||||||
    uVar1 = this->height.HALF.HI + 4;
 | 
					 | 
				
			||||||
    this->height.HALF.HI += 4;
 | 
					    this->height.HALF.HI += 4;
 | 
				
			||||||
    if (-1 < uVar1 * 0x10000) {
 | 
					    if (-1 < height * 0x10000) {
 | 
				
			||||||
        this->height.HALF.HI = 0;
 | 
					        this->height.HALF.HI = 0;
 | 
				
			||||||
        this->action = 10;
 | 
					        this->action = 10;
 | 
				
			||||||
        this->actionDelay = 10;
 | 
					        this->actionDelay = 10;
 | 
				
			||||||
| 
						 | 
					@ -986,8 +982,8 @@ void sub_0803B1B8(Entity* this) {
 | 
				
			||||||
            temp->action = 0xb;
 | 
					            temp->action = 0xb;
 | 
				
			||||||
            temp->actionDelay = 0x78;
 | 
					            temp->actionDelay = 0x78;
 | 
				
			||||||
            temp->field_0x20 = 0;
 | 
					            temp->field_0x20 = 0;
 | 
				
			||||||
            *(u16*)(*(int*)&temp->field_0x74 + 0x7e) = val = 0x708;
 | 
					            (*(Entity**)&temp->field_0x74)->field_0x7c.HALF_U.HI = 0x708;
 | 
				
			||||||
            *(u16*)(*(int*)&temp->field_0x78 + 0x7e) = val;
 | 
					            (*(Entity**)&temp->field_0x78)->field_0x7c.HALF_U.HI = 0x708;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
        if (--this->field_0x7c.HALF.HI == 0) {
 | 
					        if (--this->field_0x7c.HALF.HI == 0) {
 | 
				
			||||||
| 
						 | 
					@ -997,28 +993,28 @@ void sub_0803B1B8(Entity* this) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sub_0803B2D0(Entity* this) {
 | 
					void sub_0803B2D0(Entity* this) {
 | 
				
			||||||
    Entity* temp;
 | 
					    Entity* entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    GetNextFrame(this);
 | 
					    GetNextFrame(this);
 | 
				
			||||||
    if ((this->frames.all & 0x80) != 0) {
 | 
					    if ((this->frames.all & 0x80) != 0) {
 | 
				
			||||||
        this->action = 0x2d;
 | 
					        this->action = 0x2d;
 | 
				
			||||||
        this->spriteSettings.b.draw = 0;
 | 
					        this->spriteSettings.b.draw = 0;
 | 
				
			||||||
        temp = *(Entity**)&this->field_0x74;
 | 
					        entity = *(Entity**)&this->field_0x74;
 | 
				
			||||||
        temp->action = 2;
 | 
					        entity->action = 2;
 | 
				
			||||||
        temp->field_0x74.HALF.LO = 0;
 | 
					        entity->field_0x74.HALF.LO = 0;
 | 
				
			||||||
        temp->field_0x78.HWORD = 0;
 | 
					        entity->field_0x78.HWORD = 0;
 | 
				
			||||||
        InitializeAnimation(temp, 3);
 | 
					        InitializeAnimation(entity, 3);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sub_0803B30C(Entity* this) {
 | 
					void sub_0803B30C(Entity* this) {
 | 
				
			||||||
    Entity* pEVar1;
 | 
					    Entity* entity;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    pEVar1 = *(Entity**)&this->field_0x74;
 | 
					    entity = *(Entity**)&this->field_0x74;
 | 
				
			||||||
    if ((pEVar1->frames.all & 0x80) != 0) {
 | 
					    if ((entity->frames.all & 0x80) != 0) {
 | 
				
			||||||
        this->action = 0x2e;
 | 
					        this->action = 0x2e;
 | 
				
			||||||
        sub_0803B8E8(this, 0x13);
 | 
					        sub_0803B8E8(this, 0x13);
 | 
				
			||||||
        InitializeAnimation(pEVar1, 0);
 | 
					        InitializeAnimation(entity, 0);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -123,7 +123,6 @@ void sub_08033F1C(Entity* this) {
 | 
				
			||||||
void sub_08033F3C(Entity* this) {
 | 
					void sub_08033F3C(Entity* this) {
 | 
				
			||||||
    Entity* pEVar1;
 | 
					    Entity* pEVar1;
 | 
				
			||||||
    Entity* pEVar2;
 | 
					    Entity* pEVar2;
 | 
				
			||||||
    u8* pbVar3;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (gEntCount < 0x43) {
 | 
					    if (gEntCount < 0x43) {
 | 
				
			||||||
        if (gScreenTransition.field_0x38 != 0) {
 | 
					        if (gScreenTransition.field_0x38 != 0) {
 | 
				
			||||||
| 
						 | 
					@ -378,7 +377,7 @@ void sub_08034420(Entity* this) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sub_0803442C(Entity* this, u32 unk) {
 | 
					void sub_0803442C(Entity* this, u32 unk) {
 | 
				
			||||||
    this->action = 4;
 | 
					    this->action = 4;
 | 
				
			||||||
    this->actionDelay = (u8)unk;
 | 
					    this->actionDelay = unk;
 | 
				
			||||||
    this->field_0x7c.BYTES.byte1 = 3;
 | 
					    this->field_0x7c.BYTES.byte1 = 3;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -82,10 +82,7 @@ void sub_08034CC4(Entity* this) {
 | 
				
			||||||
        this->field_0x78.HWORD = 0x4b0;
 | 
					        this->field_0x78.HWORD = 0x4b0;
 | 
				
			||||||
        sub_08034F70(this);
 | 
					        sub_08034F70(this);
 | 
				
			||||||
        InitializeAnimation(this, this->type);
 | 
					        InitializeAnimation(this, this->type);
 | 
				
			||||||
        SetTile(0x4022,
 | 
					        SetTile(0x4022, COORD_TO_TILE(this), this->collisionLayer);
 | 
				
			||||||
                ((this->x.HALF.HI - gRoomControls.roomOriginX) >> 4 & 0x3f) |
 | 
					 | 
				
			||||||
                    (((this->y.HALF.HI - gRoomControls.roomOriginY) >> 4 & 0x3f) << 6),
 | 
					 | 
				
			||||||
                this->collisionLayer);
 | 
					 | 
				
			||||||
        entity = CreateEnemy(0x37, 2);
 | 
					        entity = CreateEnemy(0x37, 2);
 | 
				
			||||||
        if (entity != NULL) {
 | 
					        if (entity != NULL) {
 | 
				
			||||||
            this->attachedEntity = entity;
 | 
					            this->attachedEntity = entity;
 | 
				
			||||||
| 
						 | 
					@ -102,7 +99,7 @@ void sub_08034D4C(Entity* this) {
 | 
				
			||||||
    if (--this->field_0x78.HWORD == 0) {
 | 
					    if (--this->field_0x78.HWORD == 0) {
 | 
				
			||||||
        if ((this->field_0xf < 8) && (entity = CreateEnemy(0x4b, 0), entity != (Entity*)0x0)) {
 | 
					        if ((this->field_0xf < 8) && (entity = CreateEnemy(0x4b, 0), entity != (Entity*)0x0)) {
 | 
				
			||||||
            entity->direction = (s32)Random() % 5 + 0xc;
 | 
					            entity->direction = (s32)Random() % 5 + 0xc;
 | 
				
			||||||
            entity->x.HALF.HI = (gRoomControls.width >> 1) + gRoomControls.roomOriginX;
 | 
					            entity->x.HALF.HI = (gRoomControls.width / 2) + gRoomControls.roomOriginX;
 | 
				
			||||||
            entity->y.HALF.HI = gRoomControls.roomOriginY + 8;
 | 
					            entity->y.HALF.HI = gRoomControls.roomOriginY + 8;
 | 
				
			||||||
            entity->collisionLayer = 3;
 | 
					            entity->collisionLayer = 3;
 | 
				
			||||||
            entity->parent = this;
 | 
					            entity->parent = this;
 | 
				
			||||||
| 
						 | 
					@ -118,9 +115,7 @@ void sub_08034D4C(Entity* this) {
 | 
				
			||||||
void sub_08034DC8(Entity* this) {
 | 
					void sub_08034DC8(Entity* this) {
 | 
				
			||||||
    if (gScreenTransition.field_0x39 == 0) {
 | 
					    if (gScreenTransition.field_0x39 == 0) {
 | 
				
			||||||
        CreateFx(this, 0x51, 0);
 | 
					        CreateFx(this, 0x51, 0);
 | 
				
			||||||
        sub_0807BA8C(((this->x.HALF.HI - gRoomControls.roomOriginX) >> 4 & 0x3fU) |
 | 
					        sub_0807BA8C(COORD_TO_TILE(this), this->collisionLayer);
 | 
				
			||||||
                         (((this->y.HALF.HI - gRoomControls.roomOriginY) >> 4 & 0x3fU) << 6),
 | 
					 | 
				
			||||||
                     this->collisionLayer);
 | 
					 | 
				
			||||||
        DeleteThisEntity();
 | 
					        DeleteThisEntity();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					@ -139,7 +134,7 @@ void sub_08034E30(Entity* this) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void sub_08034E68(Entity* this) {
 | 
					void sub_08034E68(Entity* this) {
 | 
				
			||||||
    ScriptExecutionContext* pSVar2;
 | 
					    ScriptExecutionContext* scriptExecutionContext;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (this->parent->next == NULL) {
 | 
					    if (this->parent->next == NULL) {
 | 
				
			||||||
        if (this->spriteSettings.b.draw != 0) {
 | 
					        if (this->spriteSettings.b.draw != 0) {
 | 
				
			||||||
| 
						 | 
					@ -149,8 +144,8 @@ void sub_08034E68(Entity* this) {
 | 
				
			||||||
        if (gScreenTransition.field_0x39 == 0) {
 | 
					        if (gScreenTransition.field_0x39 == 0) {
 | 
				
			||||||
            if (sub_08079F8C() != 0) {
 | 
					            if (sub_08079F8C() != 0) {
 | 
				
			||||||
                this->action = 3;
 | 
					                this->action = 3;
 | 
				
			||||||
                pSVar2 = StartCutscene(this, (u16*)script_08012E20);
 | 
					                scriptExecutionContext = StartCutscene(this, (u16*)script_08012E20);
 | 
				
			||||||
                *(ScriptExecutionContext**)&this->cutsceneBeh = pSVar2;
 | 
					                *(ScriptExecutionContext**)&this->cutsceneBeh = scriptExecutionContext;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
            DeleteThisEntity();
 | 
					            DeleteThisEntity();
 | 
				
			||||||
| 
						 | 
					@ -269,7 +264,7 @@ u32 sub_08035084(Entity* this) {
 | 
				
			||||||
            entity->y.HALF.HI = gRoomControls.roomOriginY + *(coords + 1);
 | 
					            entity->y.HALF.HI = gRoomControls.roomOriginY + *(coords + 1);
 | 
				
			||||||
            entity->collisionLayer = 1;
 | 
					            entity->collisionLayer = 1;
 | 
				
			||||||
            UpdateSpriteForCollisionLayer(entity);
 | 
					            UpdateSpriteForCollisionLayer(entity);
 | 
				
			||||||
        };
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue