Skip to content

Commit

Permalink
Go back to original PR and just move the counter up
Browse files Browse the repository at this point in the history
  • Loading branch information
GSKirox committed Jan 18, 2025
1 parent c0205ea commit 6f4d310
Show file tree
Hide file tree
Showing 10 changed files with 8,470 additions and 62,475 deletions.
682 changes: 341 additions & 341 deletions ASM/build/asm_symbols.txt

Large diffs are not rendered by default.

Binary file modified ASM/build/bundle.o
Binary file not shown.
640 changes: 318 additions & 322 deletions ASM/build/c_symbols.txt

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion ASM/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ void before_game_state_update() {
rando_display_buffer_reset();
handle_pending_items();
handle_dpad();
handle_lbutton_and_minimap_state();
update_misc_colors();
update_hud_colors();
process_extern_ctxt();
Expand Down
99 changes: 7 additions & 92 deletions ASM/c/triforce.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,95 +7,13 @@ static uint32_t render_triforce_flag = 0;
#define TRIFORCE_FRAMES_VISIBLE 100 // 20 Frames seems to be about 1 second
#define TRIFORCE_FRAMES_FADE_AWAY 80
#define TRIFORCE_FRAMES_FADE_INTO 5
uint8_t minimap_triforce_state = 0;

void set_triforce_render() {
render_triforce_flag = 1;
frames = frames > TRIFORCE_FRAMES_FADE_INTO ? TRIFORCE_FRAMES_FADE_INTO : frames;
}

void handle_lbutton_and_minimap_state() {
switch (minimap_triforce_state) {
case MINIMAP_ON_SCREEN:
R_MINIMAP_DISABLED = render_triforce_flag == 1;
if (z64_game.common.input[0].pad_pressed.l) {
minimap_triforce_state++;
if (minimap_triforce_state > NONE_ON_SCREEN) {
minimap_triforce_state = MINIMAP_ON_SCREEN;
}
PlaySFX(0x4820); //NA_SE_SY_DUMMY_32 (Notification)
R_MINIMAP_DISABLED = 0;
}
break;
case TRIFORCE_OR_SKULL_ON_SCREEN:
R_MINIMAP_DISABLED = 1;
if (z64_game.common.input[0].pad_pressed.l) {
minimap_triforce_state++;
if (minimap_triforce_state > NONE_ON_SCREEN) {
minimap_triforce_state = MINIMAP_ON_SCREEN;
}
PlaySFX(0x4813); //NA_SE_SY_CAMERA_ZOOM_UP
R_MINIMAP_DISABLED = 1;
}
break;
case NONE_ON_SCREEN:
R_MINIMAP_DISABLED = 1;
if (z64_game.common.input[0].pad_pressed.l) {
minimap_triforce_state++;
if (minimap_triforce_state > NONE_ON_SCREEN) {
minimap_triforce_state = MINIMAP_ON_SCREEN;
}
PlaySFX(0x4814); //NA_SE_SY_CAMERA_ZOOM_DOWN
R_MINIMAP_DISABLED = 1;
}
break;
default:
break;
}
}

void draw_skull_count(z64_disp_buf_t* db) {

if (!CAN_DRAW_TRIFORCE || !(minimap_triforce_state == TRIFORCE_OR_SKULL_ON_SCREEN)) {
return;
}

int pieces = z64_file.gs_tokens;

int pieces_digits = 0;
int pieces_copy = pieces;
while(pieces_copy >= 1) {
pieces_digits++;
pieces_copy /= 10;
}
pieces_digits = pieces_digits == 0 ? 1 : pieces_digits;

// Setup draw location
int str_len = pieces_digits;
int total_w = str_len * font_sprite.tile_w + triforce_sprite.tile_w * 0.9;
// Draw the counter symmetric to the rupee icon at (left, top) = (26, 206)
int draw_x = (Z64_SCREEN_WIDTH - 26) - total_w - 1;
int draw_y_text = 206;
int draw_y_skull = 206;
// Above Triforce counter if there is one.
if (TRIFORCE_HUNT_ENABLED) {
draw_y_text -= font_sprite.tile_h + 1;
draw_y_skull -= font_sprite.tile_h + 1;
}

// Call setup display list
gSPDisplayList(db->p++, &setup_db);
gDPPipeSync(db->p++);

colorRGBA8_t color = { 0xFF, 0xFF, 0xFF, 0xFF};
draw_int(db, z64_file.gs_tokens, draw_x, draw_y_text, color);
draw_x += str_len * font_sprite.tile_w + 1;

gDPPipeSync(db->p++);
gDPSetCombineMode(db->p++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
sprite_load(db, &quest_items_sprite, 11, 1);
sprite_draw(db, &quest_items_sprite, 0, draw_x, draw_y_skull, triforce_sprite.tile_w * 0.9, triforce_sprite.tile_h * 0.9);
}

void draw_triforce_count(z64_disp_buf_t* db) {

Expand All @@ -112,20 +30,13 @@ void draw_triforce_count(z64_disp_buf_t* db) {
} else {
// Do a fade in/out effect if not in pause screen
if (frames <= TRIFORCE_FRAMES_FADE_INTO) {
// Disable minimap until the counter is faded out.
if (minimap_triforce_state == MINIMAP_ON_SCREEN) {
R_MINIMAP_DISABLED = 1;
}
alpha = frames * 255 / TRIFORCE_FRAMES_FADE_INTO;
} else if (frames <= TRIFORCE_FRAMES_FADE_INTO + TRIFORCE_FRAMES_VISIBLE ) {
alpha = 255;
} else if (frames <= TRIFORCE_FRAMES_FADE_INTO + TRIFORCE_FRAMES_VISIBLE + TRIFORCE_FRAMES_FADE_AWAY) {
alpha = (frames - TRIFORCE_FRAMES_FADE_INTO - TRIFORCE_FRAMES_VISIBLE) * 255 / TRIFORCE_FRAMES_FADE_AWAY;
alpha = 255 - alpha;
} else {
if (minimap_triforce_state == MINIMAP_ON_SCREEN) {
R_MINIMAP_DISABLED = 0;
}
render_triforce_flag = 0;
frames = 0;
return;
Expand Down Expand Up @@ -156,8 +67,12 @@ void draw_triforce_count(z64_disp_buf_t* db) {
// Setup draw location
int str_len = required_digits + pieces_digits + 1;
int total_w = str_len * font_sprite.tile_w + triforce_sprite.tile_w;
// Draw the counter symmetric to the rupee icon at (left, top) = (26, 206)
int draw_x = (Z64_SCREEN_WIDTH - 26) - total_w;
// Draw the counter centered horizontally and at the bottom of CRT safe screen space.
int draw_x = Z64_SCREEN_WIDTH / 2 - total_w / 2;
// And on pause screen, keep the height but move it on the right, symmetric to the rupee icon.
if (z64_game.pause_ctxt.state > PAUSE_STATE_OFF) {
draw_x = (Z64_SCREEN_WIDTH - 26) - total_w;
}
int draw_y_text = 206;
int draw_y_triforce = 206;

Expand All @@ -182,7 +97,7 @@ void draw_triforce_count(z64_disp_buf_t* db) {
gDPSetCombineMode(db->p++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
gDPSetPrimColor(db->p++, 0, 0, 0xDA, 0xD3, 0x0B, alpha);

text_print(text , draw_x, draw_y_text);
text_print(db, text, draw_x, draw_y_text);
draw_x += str_len * font_sprite.tile_w;

gDPSetPrimColor(db->p++, 0, 0, 0xF4, 0xEC, 0x30, alpha);
Expand Down
9 changes: 0 additions & 9 deletions ASM/c/triforce.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ extern uint16_t TRIFORCE_HUNT_ENABLED;
extern uint16_t TRIFORCE_PIECES_REQUIRED;

void draw_triforce_count(z64_disp_buf_t* db);
void draw_skull_count(z64_disp_buf_t* db);
void set_triforce_render();
void handle_lbutton_and_minimap_state();

#define BLOCK_TRIFORCE (0x00000001 | \
0x00000002 | \
Expand All @@ -27,11 +25,4 @@ void handle_lbutton_and_minimap_state();
(z64_file.game_mode == 0) && \
((z64_event_state_1 & 0x20) == 0))

typedef enum
{
MINIMAP_ON_SCREEN,
TRIFORCE_OR_SKULL_ON_SCREEN,
NONE_ON_SCREEN,
} minimap_triforce_enum;

#endif
2 changes: 0 additions & 2 deletions ASM/c/z64.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@
#define BASE_REG(n, r) REG_EDITOR_DATA[(n)*REGS_PER_GROUP + (r)]
#define REG(r) BASE_REG(0, (r))
#define SREG(r) BASE_REG(1, (r))
#define WREG(r) BASE_REG(18, (r))
#define R_PAUSE_BG_PRERENDER_STATE SREG(94)
#define R_MINIMAP_DISABLED WREG(31)

#define ITEM_ICON_WIDTH 32
#define ITEM_ICON_HEIGHT 32
Expand Down
28 changes: 0 additions & 28 deletions ASM/src/hacks.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4113,34 +4113,6 @@ DemoEffect_DrawJewel_AfterHook:
jal ocarina_buttons
nop
;===================================================================================================
; Remove the minimap L button press functions to make our custom one for triforce counter
;===================================================================================================

.orga 0xAE2D0C
; Replaces jal func_800C806C
nop

.orga 0xAE2D28
; Replaces jal func_800C806C
nop

.orga 0xAE2D48
; Replaces sh t7, 0x0DD2(v1)
nop

.orga 0xAE34A0
; Replaces jal func_800C806C
nop

.orga 0xAE34C0
; Replaces jal func_800C806C
nop

.orga 0xAE34D8
; Replaces sh t7, 0x0DD2(v1)
nop

;===================================================================================================
; Overrides the function that gives Fairy Ocarina on the Lost Woods Bridge
;===================================================================================================
.orga 0xACCDFC
Expand Down
Loading

0 comments on commit 6f4d310

Please sign in to comment.