forked from OoTRandomizer/OoT-Randomizer
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from TestRunnerSRL/Dev
Move Dev into my Fork
- Loading branch information
Showing
41 changed files
with
8,253 additions
and
7,636 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.