sprite_new

This commit is contained in:
PikalaxALT 2017-09-07 15:50:49 -04:00
parent f7742a68ae
commit 64ebd9b4fb
5 changed files with 67 additions and 178 deletions

View File

@ -5,184 +5,6 @@
.text
thumb_func_start sprite_new
sprite_new: @ 808DE0C
push {r4-r7,lr}
mov r7, r10
mov r6, r9
mov r5, r8
push {r5-r7}
sub sp, 0x20
adds r5, r0, 0
ldr r0, [sp, 0x40]
ldr r4, [sp, 0x44]
lsls r5, 24
lsrs r5, 24
lsls r1, 24
lsrs r1, 24
mov r9, r1
add r1, sp, 0x18
mov r8, r1
strh r2, [r1]
mov r6, sp
adds r6, 0x1A
strh r3, [r6]
lsls r0, 24
lsrs r7, r0, 24
lsls r4, 24
lsrs r4, 24
mov r10, r4
adds r0, r5, 0
bl GetFieldObjectGraphicsInfo
adds r4, r0, 0
ldr r1, =sub_8097AC8
add r3, sp, 0x1C
adds r0, r5, 0
mov r2, sp
bl MakeObjectTemplateFromFieldObjectGraphicsInfo
mov r1, sp
ldr r2, =0x0000ffff
adds r0, r2, 0
strh r0, [r1, 0x2]
mov r1, r8
movs r2, 0
ldrsh r0, [r1, r2]
adds r0, 0x7
strh r0, [r1]
movs r1, 0
ldrsh r0, [r6, r1]
adds r0, 0x7
strh r0, [r6]
mov r0, r8
adds r1, r6, 0
movs r2, 0x8
movs r3, 0x10
bl sub_80930E0
mov r2, r8
movs r0, 0
ldrsh r1, [r2, r0]
movs r0, 0
ldrsh r2, [r6, r0]
mov r0, sp
movs r3, 0
bl CreateSpriteAtEnd
lsls r0, 24
lsrs r6, r0, 24
cmp r6, 0x40
beq _0808DF6C
lsls r0, r6, 4
adds r0, r6
lsls r0, 2
ldr r1, =gSprites
adds r5, r0, r1
ldrh r0, [r4, 0x8]
lsls r0, 16
asrs r0, 17
negs r0, r0
adds r1, r5, 0
adds r1, 0x28
strb r0, [r1]
ldrh r0, [r4, 0xA]
lsls r0, 16
asrs r0, 17
negs r0, r0
adds r1, 0x1
strb r0, [r1]
movs r0, 0
ldrsb r0, [r1, r0]
ldrh r1, [r5, 0x22]
adds r0, r1
strh r0, [r5, 0x22]
ldrb r0, [r4, 0xC]
lsls r0, 28
lsrs r0, 24
ldrb r1, [r5, 0x5]
movs r3, 0xF
adds r2, r3, 0
ands r2, r1
orrs r2, r0
strb r2, [r5, 0x5]
lsls r1, r2, 24
lsrs r0, r1, 28
cmp r0, 0xF
bls _0808DEE4
subs r0, 0x10
lsls r0, 4
ands r2, r3
orrs r2, r0
strb r2, [r5, 0x5]
_0808DEE4:
adds r2, r5, 0
adds r2, 0x3E
ldrb r0, [r2]
movs r1, 0x2
orrs r0, r1
strb r0, [r2]
mov r2, r9
strh r2, [r5, 0x2E]
strh r7, [r5, 0x30]
ldrb r1, [r4, 0xC]
adds r0, r3, 0
ands r0, r1
cmp r0, 0xA
bne _0808DF18
ldrh r0, [r4, 0x2]
lsls r1, 28
lsrs r1, 28
bl npc_load_two_palettes__and_record
b _0808DF2C
.pool
_0808DF18:
lsls r1, 28
lsrs r0, r1, 28
cmp r0, 0xF
bls _0808DF2C
ldrh r0, [r4, 0x2]
lsrs r2, r1, 28
movs r1, 0xF0
orrs r1, r2
bl sub_808EAB0
_0808DF2C:
ldr r1, [sp, 0x1C]
cmp r1, 0
beq _0808DF48
adds r0, r5, 0
bl SetSubspriteTables
adds r2, r5, 0
adds r2, 0x42
ldrb r0, [r2]
movs r1, 0x3F
ands r1, r0
movs r0, 0x80
orrs r1, r0
strb r1, [r2]
_0808DF48:
adds r0, r5, 0
adds r1, r7, 0
bl InitObjectPriorityByZCoord
adds r0, r7, 0
adds r1, r5, 0
movs r2, 0x1
bl SetObjectSubpriorityByZCoord
mov r0, r10
bl FieldObjectDirectionToImageAnimId
adds r1, r0, 0
lsls r1, 24
lsrs r1, 24
adds r0, r5, 0
bl StartSpriteAnim
_0808DF6C:
adds r0, r6, 0
add sp, 0x20
pop {r3-r5}
mov r8, r3
mov r9, r4
mov r10, r5
pop {r4-r7}
pop {r1}
bx r1
thumb_func_end sprite_new
thumb_func_start SpawnFieldObjectsInView
@ void SpawnFieldObjectsInView(u16 movingCameraOffsetX, u16 movingCameraOffsetY)
SpawnFieldObjectsInView: @ 808DF80

View File

@ -11,5 +11,6 @@
// Exported ROM declarations
void SetObjectSubpriorityByZCoord(u8, struct Sprite *, u8);
void InitObjectPriorityByZCoord(struct Sprite *, u8);
#endif //POKEEMERALD_FIELD_GROUND_EFFECT_H

View File

@ -23,6 +23,7 @@ void npc_load_two_palettes__and_record(u16, u8);
void sub_808EAB0(u16, u8);
void sub_8092FF0(s16, s16, s16 *, s16 *);
u8 FieldObjectDirectionToImageAnimId(u8);
void sub_80930E0(s16 *, s16 *, u8, u8);
// Exported data declarations

15
include/map_obj_8097404.h Normal file
View File

@ -0,0 +1,15 @@
//
// Created by scott on 9/7/2017.
//
#ifndef POKEEMERALD_MAP_OBJ_8097404_H
#define POKEEMERALD_MAP_OBJ_8097404_H
// Exported type declarations
// Exported RAM declarations
// Exported ROM declarations
void sub_8097AC8(struct Sprite *);
#endif //POKEEMERALD_MAP_OBJ_8097404_H

View File

@ -9,6 +9,7 @@
#include "rom_818CFC8.h"
#include "rom_81BE66C.h"
#include "field_ground_effect.h"
#include "map_obj_8097404.h"
#include "field_map_obj.h"
#define NUM_FIELD_MAP_OBJECT_TEMPLATES 0x51
@ -645,3 +646,52 @@ u8 AddPseudoFieldObject(u16 graphicsId, void (*callback)(struct Sprite *), s16 x
}
return spriteIdx;
}
u8 sprite_new(u8 graphicsId, u8 a1, s16 x, s16 y, u8 z, u8 direction)
{
const struct MapObjectGraphicsInfo *graphicsInfo;
struct SpriteTemplate spriteTemplate;
const struct SubspriteTable *subspriteTables;
u8 spriteId;
struct Sprite *sprite;
graphicsInfo = GetFieldObjectGraphicsInfo(graphicsId);
MakeObjectTemplateFromFieldObjectGraphicsInfo(graphicsId, sub_8097AC8, &spriteTemplate, &subspriteTables);
*(u16 *)&spriteTemplate.paletteTag = 0xffff;
x += 7;
y += 7;
sub_80930E0(&x, &y, 8, 16);
spriteId = CreateSpriteAtEnd(&spriteTemplate, x, y, 0);
if (spriteId != MAX_SPRITES)
{
sprite = &gSprites[spriteId];
sprite->centerToCornerVecX = -(graphicsInfo->width >> 1);
sprite->centerToCornerVecY = -(graphicsInfo->height >> 1);
sprite->pos1.y += sprite->centerToCornerVecY;
sprite->oam.paletteNum = graphicsInfo->paletteSlot;
if (sprite->oam.paletteNum >= 16)
{
sprite->oam.paletteNum -= 16;
}
sprite->coordOffsetEnabled = TRUE;
sprite->data0 = a1;
sprite->data1 = z;
if (graphicsInfo->paletteSlot == 10)
{
npc_load_two_palettes__and_record(graphicsInfo->paletteTag1, graphicsInfo->paletteSlot);
}
else if (graphicsInfo->paletteSlot >= 16)
{
sub_808EAB0(graphicsInfo->paletteTag1, graphicsInfo->paletteSlot | 0xf0);
}
if (subspriteTables != NULL)
{
SetSubspriteTables(sprite, subspriteTables);
sprite->subspriteMode = 2;
}
InitObjectPriorityByZCoord(sprite, z);
SetObjectSubpriorityByZCoord(z, sprite, 1);
StartSpriteAnim(sprite, FieldObjectDirectionToImageAnimId(direction));
}
return spriteId;
}