Skip to content

Commit

Permalink
Merge pull request #1 from TestRunnerSRL/Dev
Browse files Browse the repository at this point in the history
Move Dev into my Fork
  • Loading branch information
ThomasJRyan authored Jan 25, 2020
2 parents 3f6a25c + 4757034 commit 66f78bc
Show file tree
Hide file tree
Showing 41 changed files with 8,253 additions and 7,636 deletions.
464 changes: 238 additions & 226 deletions ASM/build/asm_symbols.txt

Large diffs are not rendered by default.

Binary file modified ASM/build/bundle.o
Binary file not shown.
246 changes: 127 additions & 119 deletions ASM/build/c_symbols.txt

Large diffs are not rendered by default.

88 changes: 88 additions & 0 deletions ASM/c/agony.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include "agony.h"
#include "gfx.h"
#include "z64.h"

typedef struct {
unsigned char alpha_level : 8;
signed char pos : 2;
unsigned char next : 6;
} alpha_data_t;

static const alpha_data_t ALPHA_DATA[] = {
{0x00, 0, 0}, // 0 - Zero
{0x33, -1, 2}, // 1 - Fade in from zero
{0x66, 1, 3}, // 2
{0x99, -1, 4}, // 3
{0xCC, 1, 5}, // 4
{0xFF, -1, 6}, // 5 - Full intensity
{0xFF, 1, 7}, // 6
{0xFF, -1, 8}, // 7
{0xFF, 1, 9}, // 8
{0xE0, -1, 10}, // 9 - Fade out to hold
{0xC2, 1, 11}, // 10
{0xA3, -1, 12}, // 11
{0x85, 1, 13}, // 12
{0x66, 0, 13}, // 13 - Hold
{0x44, 0, 15}, // 14 - Fade out
{0x22, 0, 0}, // 15
{0x85, -1, 17}, // 16 - Fade in from hold
{0xA3, 1, 18}, // 17
{0xC2, -1, 19}, // 18
{0xE0, 1, 5} // 19
};

#define ALPHA_ANIM_TERMINATE 0
#define ALPHA_ANIM_START 1
#define ALPHA_ANIM_HOLD 13
#define ALPHA_ANIM_FADE 14
#define ALPHA_ANIM_INTERRUPT 16

static const alpha_data_t* alpha_frame = ALPHA_DATA + ALPHA_ANIM_TERMINATE;

void agony_inside_radius_setup() {
}

void agony_outside_radius_setup()
{
if (alpha_frame == ALPHA_DATA + ALPHA_ANIM_HOLD) {
alpha_frame = ALPHA_DATA + ALPHA_ANIM_FADE;
}
}

void agony_vibrate_setup() {
if (alpha_frame == ALPHA_DATA + ALPHA_ANIM_TERMINATE) {
alpha_frame = ALPHA_DATA + ALPHA_ANIM_START;
}
else {
alpha_frame = ALPHA_DATA + ALPHA_ANIM_INTERRUPT;
}
}

void draw_agony_graphic(int offset, unsigned char alpha) {
// terminate if alpha level prohibited (changed areas)
unsigned char maxalpha = (unsigned char)z64_game.hud_alpha_channels.minimap;
if (maxalpha == 0xAA) maxalpha = 0xFF;

if (alpha > maxalpha) {
alpha = maxalpha;
}

z64_disp_buf_t *db = &(z64_ctxt.gfx->overlay);
gSPDisplayList(db->p++, &setup_db);
gDPPipeSync(db->p++);
gDPSetCombineMode(db->p++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
gDPSetPrimColor(db->p++, 0, 0, 0xFF, 0xFF, 0xFF, alpha);
sprite_load(db, &quest_items_sprite, 9, 1);
sprite_draw(db, &quest_items_sprite, 0, 27+offset, 189, 16, 16);
gDPPipeSync(db->p++);
}

void draw_agony() {
if (alpha_frame != ALPHA_DATA + ALPHA_ANIM_TERMINATE) {
unsigned char alpha = alpha_frame->alpha_level;
int offset = alpha_frame->pos;
alpha_frame = ALPHA_DATA + alpha_frame->next;
draw_agony_graphic(offset, alpha);
}
}

9 changes: 9 additions & 0 deletions ASM/c/agony.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef AGONY_H
#define AGONY_H

void agony_inside_radius_setup();
void agony_outside_radius_setup();
void agony_vibrate_setup();
void draw_agony();

#endif
2 changes: 1 addition & 1 deletion ASM/c/item_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ item_row_t item_table[] = {
[0xB6] = ITEM_ROW(0x53, 3, 0x41, 0x00A0, 0x00AA, 0x02, no_upgrade, give_small_key, FORT_ID, -1), // Gerudo Fortress Small Key
[0xB7] = ITEM_ROW(0x53, 3, 0x41, 0x00A1, 0x00AA, 0x02, no_upgrade, give_small_key, CASTLE_ID, -1), // Ganon's Castle Small Key

[0xB8] = ITEM_ROW(0x53, 0, 0x41, 0x00E9, 0x00BD, 0x13, no_upgrade, give_defense, -1, -1), // Double Defense
[0xB8] = ITEM_ROW(0x53, 0, 0x41, 0x00E9, 0x0194, 0x13, no_upgrade, give_defense, -1, -1), // Double Defense
[0xB9] = ITEM_ROW(0x53, 0, 0x41, 0x00E4, 0x00CD, 0x1E, no_upgrade, give_magic, -1, -1), // Magic Meter
[0xBA] = ITEM_ROW(0x53, 0, 0x41, 0x00E8, 0x00CD, 0x1F, no_upgrade, give_double_magic, -1, -1), // Double Magic

Expand Down
9 changes: 6 additions & 3 deletions ASM/c/z64.h
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ struct z64_actor_s
char unk_01_[0x0002]; /* 0x001A */
uint16_t variable; /* 0x001C */
uint8_t alloc_index; /* 0x001E */
char unk_02_; /* 0x001F */
char navi_tgt_dist; /* 0x001F */
uint16_t sound_effect; /* 0x0020 */
char unk_03_[0x0002]; /* 0x0022 */
z64_xyzf_t pos_2; /* 0x0024 */
Expand All @@ -730,9 +730,12 @@ struct z64_actor_s
float min_vel_y; /* 0x0070 */
void *unk_08_; /* 0x0074 */
z64_col_poly_t *floor_poly; /* 0x0078 */
char unk_0A_[0x000C]; /* 0x007C */
char unk_09_[0x000C]; /* 0x007C */
uint16_t unk_flags_00; /* 0x0088 */
char unk_0B_[0x000E]; /* 0x0090 */
int16_t unk_roty; /* 0x008A */
float distsq_from_link; /* 0x008C */
float xzdist_from_link; /* 0x0090 */
float ydist_from_link; /* 0x0094 */
void *damage_table; /* 0x0098 */
z64_xyzf_t vel_2; /* 0x009C */
char unk_0C_[0x0006]; /* 0x00A8 */
Expand Down
72 changes: 72 additions & 0 deletions ASM/src/agony.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
agony_distance_hook:
; called as SoA code computes distance from Link to grotto
addiu sp, sp, -0x30
sw ra, 0x001C(sp)
sw a0, 0x0020(sp)
sw a1, 0x0024(sp)
swc1 f0, 0x0028(sp)
c.lt.s f0, f2 ; check if close to grotto
nop
bc1t @@outside_radius
nop
@@inside_radius:
jal agony_inside_radius_setup
nop
b @@done
nop
@@outside_radius:
jal agony_outside_radius_setup
nop
@@done:
; reset registers
li a2, 0x0014
li a3, 0x000A
mtc1 r0, f2
lwc1 f0, 0x0028(sp)
lw a1, 0x0024(sp)
lw a0, 0x0020(sp)
lw ra, 0x001C(sp)
c.lt.s f0, f2 ; displaced
addiu sp, sp, 0x30
jr ra
nop


agony_vibrate_hook:
; called when SoA code checks to see if it should command a vibration
addiu sp, sp, -0x30
sw ra, 0x001C(sp)
sw a0, 0x0020(sp)
sw a1, 0x0024(sp)
swc1 f4, 0x0028(sp)
swc1 f6, 0x002C(sp)
c.lt.s f4, f6
nop
bc1f @@done ; check 4000000.0 < agony vibe counter
nop
jal agony_vibrate_setup
nop
@@done:
; reset registers
li a2, 0x0014
li a3, 0x000A
mtc1 r0, f2
lwc1 f6, 0x002C(sp)
lwc1 f4, 0x0028(sp)
lw a1, 0x0024(sp)
lw a0, 0x0020(sp)
lw ra, 0x001C(sp)
c.lt.s f4, f6 ; displaced
addiu sp, sp, 0x30
jr ra
nop


agony_post_hook:
; called every frame at the end of SoA code
jal draw_agony
nop
lw ra, 0x001C(sp)
addiu sp, sp, 0x0020 ; displaced
jr ra
nop
1 change: 1 addition & 0 deletions ASM/src/build.asm
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ RANDO_CONTEXT:
.include "deku_mouth_condition.asm"
.include "audio.asm"
.include "king_zora.asm"
.include "agony.asm"
.importobj "../build/bundle.o"
.align 8
FONT_TEXTURE:
Expand Down
21 changes: 21 additions & 0 deletions ASM/src/hacks.asm
Original file line number Diff line number Diff line change
Expand Up @@ -963,6 +963,27 @@ skip_GS_BGS_text:
jal dpad_draw
nop

;==================================================================================================
; Stone of Agony indicator
;==================================================================================================

; Replaces:
; c.lt.s f0, f2
.orga 0xBE4A14
jal agony_distance_hook

; Replaces:
; c.lt.s f4, f6
.orga 0xBE4A40
jal agony_vibrate_hook

; Replaces:
; addiu sp, sp, 0x20
; jr ra
.orga 0xBE4A60
j agony_post_hook
nop

;==================================================================================================
; Correct Chest Sizes
;==================================================================================================
Expand Down
19 changes: 19 additions & 0 deletions Cosmetics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import random
import Music as music
import Sounds as sfx
import IconManip as icon

from collections import namedtuple
Color = namedtuple('Color', ' R G B')
Expand Down Expand Up @@ -192,6 +193,19 @@ def patch_music(rom, settings, log, symbols):
music.restore_music(rom)


def patch_tunic_icon(rom, tunic, color):
# patch tunic icon colors
icon_locations = {
'Kokiri Tunic': 0x007FE000,
'Goron Tunic': 0x007FF000,
'Zora Tunic': 0x00800000,
}

tunic_icon = icon.generate_tunic_icon(color)

rom.write_bytes(icon_locations[tunic], tunic_icon)


def patch_tunic_colors(rom, settings, log, symbols):
# patch tunic colors
tunics = [
Expand All @@ -216,6 +230,11 @@ def patch_tunic_colors(rom, settings, log, symbols):
color = list(int(tunic_option[i:i+2], 16) for i in (0, 2 ,4))
tunic_option = 'Custom'
rom.write_bytes(address, color)

# patch the tunic icon
if [tunic, tunic_option] not in [['Kokiri Tunic', 'Kokiri Green'], ['Goron Tunic', 'Goron Red'], ['Zora Tunic', 'Zora Blue']]:
patch_tunic_icon(rom, tunic, color)

log.tunic_colors[tunic] = dict(option=tunic_option, color=''.join(['{:02X}'.format(c) for c in color]))


Expand Down
Loading

0 comments on commit 66f78bc

Please sign in to comment.