Paper Mario DX
Paper Mario (N64) modding
 
Loading...
Searching...
No Matches
SaveBlock.c
Go to the documentation of this file.
1#include "common.h"
2#include "vars_access.h"
3#include "fio.h"
4#include "ld_addrs.h"
5#include "entity.h"
6#include "message_ids.h"
7
8#if VERSION_JP // TODO remove once segments are split
9extern Addr entity_model_SaveBlock_ROM_END;
10extern Addr entity_model_SaveBlock_ROM_START;
11#endif
12
13extern Mtx Entity_SaveBlock_Mtx;
17
19
24
25#if VERSION_PAL
26extern Gfx Entity_SaveBlock_RenderBlock_es[];
27extern s32 gCurrentLanguage;
28#endif
29
31 Gfx* gfxPos = gMainGfxPos;
33 Entity* entity = get_entity_by_index(index);
34 SaveBlockData* blockData = entity->dataBuf.saveBlock;
35 s32 alpha = 128;
36 Matrix4f sp18;
37 Matrix4f sp58;
38
39 guMtxL2F(sp18, ENTITY_ADDR(entity, Mtx*, &Entity_SaveBlock_Mtx));
40 sp18[3][1] += 12.5f;
41 guRotateF(sp58, blockData->angle, 0.0f, 1.0f, 0.0f);
42 guMtxCatF(sp58, sp18, sp58);
44
45 gSPMatrix(gfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
46 gDPSetRenderMode(gfxPos++, G_RM_ZB_CLD_SURF, G_RM_ZB_CLD_SURF2);
47 gDPSetCombineMode(gfxPos++, PM_CC_01, PM_CC_02);
48 gDPSetPrimColor(gfxPos++, 0, 0, 0, 0, 0, alpha);
49 gSPDisplayList(gfxPos++, dlist);
50 gSPPopMatrix(gfxPos++, G_MTX_MODELVIEW);
51
52#if VERSION_PAL
53 switch (gCurrentLanguage) {
54 default:
55 dlist = ENTITY_ADDR(entity, Gfx*, Entity_SaveBlock_RenderBlock);
56 break;
57
58 case LANGUAGE_ES:
59 dlist = ENTITY_ADDR(entity, Gfx*, Entity_SaveBlock_RenderBlock_es);
60 break;
61 }
62#else
63 dlist = ENTITY_ADDR(entity, Gfx*, Entity_SaveBlock_RenderBlock);
64#endif
65 guMtxL2F(sp58, ENTITY_ADDR(entity, Mtx*, &Entity_SaveBlock_Mtx));
66 sp58[3][1] += 12.5f;
67 gDPPipeSync(gfxPos++);
69
70 gSPMatrix(gfxPos++, &gDisplayContext->matrixStack[gMatrixListPos++], G_MTX_PUSH | G_MTX_MUL | G_MTX_MODELVIEW);
71 gDPSetRenderMode(gfxPos++, G_RM_AA_XLU_SURF | Z_CMP, G_RM_AA_XLU_SURF2 | Z_CMP);
72 gDPSetCombineMode(gfxPos++, PM_CC_01, PM_CC_02);
73 gDPSetPrimColor(gfxPos++, 0, 0, 0, 0, 0, alpha);
74 gSPDisplayList(gfxPos++, dlist);
75 gSPPopMatrix(gfxPos++, G_MTX_MODELVIEW);
76
77 gMainGfxPos = gfxPos;
78}
79
81 SaveBlockData* data;
82
83 data = entity->dataBuf.saveBlock;
84 data->angle = clamp_angle(data->angle + 6);
86}
87
93
98
105
117
123
130
135
141
152
154 SaveBlockData* data = entity->dataBuf.saveBlock;
155
158 data->angle = 8;
159}
160
181
188
190
193 .typeDataSize = sizeof(SaveBlockData),
194 .renderCommandList = Entity_SaveBlock_RenderScript,
195 .modelAnimationNodes = 0,
196 .fpInit = entity_SaveBlock_init,
197 .updateEntityScript = Entity_SaveBlock_Script,
198 .fpHandleCollision = entity_block_handle_collision,
199 { .dma = ENTITY_ROM(SaveBlock) },
200 .entityType = ENTITY_TYPE_SAVE_POINT,
201 .aabbSize = { 25, 25, 25 }
202};
void entity_SaveBlock_wait_for_close_tutorial(Entity *entity)
Definition SaveBlock.c:118
BSS MessagePrintState * SaveBlockResultPrinter
Definition SaveBlock.c:23
Mtx Entity_SaveBlock_Mtx
Definition SaveBlock.c:67
s32 Entity_SaveBlock_ScriptResume[]
Definition SaveBlock.c:182
void entity_SaveBlock_wait_for_close_choice(Entity *entity)
Definition SaveBlock.c:142
Gfx Entity_SaveBlock_RenderNone[]
Definition SaveBlock.c:203
EntityModelScript Entity_SaveBlock_RenderScript
Definition SaveBlock.c:189
void entity_SaveBlock_setupGfx(s32 index)
Definition SaveBlock.c:30
void entity_SaveBlock_save_data(void)
Definition SaveBlock.c:99
void entity_SaveBlock_pause_game(void)
Definition SaveBlock.c:88
void entity_SaveBlock_resume_game(void)
Definition SaveBlock.c:94
EntityScript Entity_SaveBlock_Script
Definition SaveBlock.c:161
void entity_SaveBlock_wait_for_close_result(Entity *entity)
Definition SaveBlock.c:136
void entity_SaveBlock_init(Entity *entity)
Definition SaveBlock.c:153
Gfx Entity_SaveBlock_RenderContent[]
Definition SaveBlock.c:184
EntityBlueprint Entity_SavePoint
Definition SaveBlock.c:191
Gfx Entity_SaveBlock_RenderBlock[]
Definition SaveBlock.c:189
void entity_SaveBlock_idle(Entity *entity)
Definition SaveBlock.c:80
void entity_SaveBlock_show_tutorial_message(Entity *entity)
Definition SaveBlock.c:106
void entity_SaveBlock_show_result_message(void)
Definition SaveBlock.c:131
BSS MessagePrintState * SaveBlockTutorialPrinter
Definition SaveBlock.c:22
void entity_SaveBlock_show_choice_message(void)
Definition SaveBlock.c:124
BSS s32 SaveBlockTutorialPrinterClosed
Definition SaveBlock.c:20
BSS s32 SaveBlockResultPrinterClosed
Definition SaveBlock.c:21
Mtx matrixStack[0x200]
struct SaveBlockData * saveBlock
f32 Matrix4f[4][4]
#define guRotateF
#define guMtxF2L
#define guMtxCatF
#define clamp_angle
s32 EntityModelScript[]
Definition entity.h:7
#define es_Call(func)
Definition entity.h:37
#define es_Restart
Definition entity.h:40
#define STANDARD_ENTITY_MODEL_SCRIPT(gfx, renderMode)
Definition entity.h:56
#define ENTITY_ADDR(entity, type, data)
Definition entity.h:64
#define es_SetCallback(func, time)
Definition entity.h:38
#define ENTITY_ROM(name)
Definition entity.h:65
s32 EntityScript[]
Definition entity.h:6
#define es_End
Definition entity.h:35
#define es_PlaySound(soundId)
Definition entity.h:45
#define es_Jump(script)
Definition entity.h:36
@ LANGUAGE_ES
Definition enums.h:6403
@ ENTITY_TYPE_SAVE_POINT
Definition enums.h:2575
@ TIME_FREEZE_PARTIAL
Definition enums.h:3465
@ TIME_FREEZE_NONE
Definition enums.h:3464
@ SOUND_HIT_BLOCK
Definition enums.h:768
@ SOUND_SAVE_CONFIRM
Definition enums.h:561
@ RENDER_MODE_SURFACE_XLU_LAYER3
Definition enums.h:3299
@ ENTITY_FLAG_FIXED_SHADOW_SIZE
Definition enums.h:2622
@ ENTITY_FLAG_4000
Definition enums.h:2627
void fio_save_game(s32 saveSlot)
Definition fio.c:184
Entity * get_entity_by_index(s32 index)
Definition entity.c:530
s32 disable_player_input(void)
Definition 77480.c:990
void close_message(MessagePrintState *msgPrintState)
Definition msg.c:1568
void entity_block_hit_animate_scale(Entity *entity)
Definition Block.c:90
s32 enable_player_input(void)
Definition 77480.c:998
MessagePrintState * msg_get_printer_for_msg(s32 msgID, s32 *a1)
Definition msg.c:1424
s32 entity_base_block_idle(Entity *entity)
Definition Block.c:195
void set_entity_commandlist(Entity *entity, s32 *entityScript)
Definition entity.c:235
void exec_entity_commandlist(Entity *entity)
Definition entity.c:313
void entity_base_block_init(Entity *entity)
Definition Block.c:213
f32 entity_block_hit_init_scale(Entity *entity)
Definition Block.c:75
void set_time_freeze_mode(s32)
Time freeze modes: 0: none 1: NPCs move, can't be interacted with 2: NPCs don't move,...
Definition main_loop.c:358
s32 msg_printer_load_msg(s32 msgID, MessagePrintState *printer)
Definition msg.c:1474
s32 entity_block_handle_collision(Entity *entity)
Definition Block.c:334
void sfx_play_sound(s32 soundID)
Definition sfx.c:517
@ GF_Tutorial_SaveBlock
#define BSS
Definition macros.h:7
#define PM_CC_01
Definition macros.h:276
#define PM_CC_02
Definition macros.h:277
void(* renderSetupFunc)(s32)
EntityData dataBuf
u8 Addr[]
Linker symbol address, as in ld_addrs.h.
Definition types.h:16
PlayerStatus * gPlayerStatusPtr
#define gCurrentLanguage
Definition variables.h:115
GameStatus * gGameStatusPtr
Definition main_loop.c:32
Gfx * gMainGfxPos
Definition cam_main.c:15
u16 gMatrixListPos
Definition main_loop.c:45
DisplayContext * gDisplayContext
Definition cam_main.c:16
s32 set_global_flag(s32 index)
Definition vars_access.c:65
s32 get_global_flag(s32 index)
Definition vars_access.c:89