summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2013-01-31 04:17:37 +0100
committerTreeki <treeki@gmail.com>2013-01-31 04:17:37 +0100
commitb9f9eeb73d6e3f4ebbd5d45c5997f73478425779 (patch)
tree4f25550df84b7cb77601c699d7ce4d4858a2f9f9
parent26f0eac040ac5cdbd2dd57ef8fb56c54066f40d1 (diff)
downloadkamek-b9f9eeb73d6e3f4ebbd5d45c5997f73478425779.tar.gz
kamek-b9f9eeb73d6e3f4ebbd5d45c5997f73478425779.zip
add replays as an on/off thing
-rw-r--r--NewerProjectKP.yaml2
-rw-r--r--kamek_pal.x7
-rw-r--r--replay.yaml33
-rw-r--r--src/koopatlas/starcoin.cpp12
-rw-r--r--src/replay.S71
5 files changed, 99 insertions, 26 deletions
diff --git a/NewerProjectKP.yaml b/NewerProjectKP.yaml
index a8369d8..e49f7ea 100644
--- a/NewerProjectKP.yaml
+++ b/NewerProjectKP.yaml
@@ -32,7 +32,7 @@ modules:
- processed/switchblock.yaml
- processed/eventblock.yaml
- processed/msgbox.yaml
-# - processed/replay.yaml
+ - processed/replay.yaml
- processed/growup.yaml
- processed/eventlooper.yaml
- processed/spritespawner.yaml
diff --git a/kamek_pal.x b/kamek_pal.x
index 98b7881..33e5401 100644
--- a/kamek_pal.x
+++ b/kamek_pal.x
@@ -1,4 +1,6 @@
SECTIONS {
+ isReplayEnabled = 0x80002EEE;
+
UpdateSelectCursor = 0x800B44D0;
HideSelectCursor = 0x8010C890;
SelectCursorPointer = 0x8042A5A8;
@@ -1577,11 +1579,16 @@ SECTIONS {
continueFromReplayHookStart = 0x809246E4;
continueFromReplayEndHook = 0x8010223C;
returnFromRecorder = 0x800B60C0;
+ dontSkipReplayPrepare = 0x8091F6EC;
+ doSkipReplayPrepare = 0x8091F90C;
GetSomeGlobalClass = 0x80109450;
SomeUnknownClass5408 = 0x8042A578;
SomeWipeClass = 0x8042A720;
QueryGlobal5758 = 0x800B3B50;
+ Crsin_EffectResWaitProc = 0x809A1DA8;
+ Crsin_ReplayResWaitProc = 0x809A1D68;
+
SoundClassRelated = 0x8042a03c;
BufferToCheckIfPlaying = 0x8042a768;
StopSoundBasic = 0x801955E0;
diff --git a/replay.yaml b/replay.yaml
index 0dc9084..c60d848 100644
--- a/replay.yaml
+++ b/replay.yaml
@@ -1,4 +1,4 @@
-source_files: [replay.S]
+source_files: [../src/replay.S]
hooks:
- name: ReplayHookStart
type: branch_insn
@@ -15,25 +15,28 @@ hooks:
branch_type: b
src_addr_pal: 0x8006A1B4
target_func: 'replayRecord'
- - name: LuigiOverride
- type: branch_insn
- branch_type: b
- src_addr_pal: 0x800E50B4
- target_func: 'luigiOverride'
+# - name: LuigiOverride
+# type: branch_insn
+# branch_type: b
+# src_addr_pal: 0x800E50B4
+# target_func: 'luigiOverride'
- name: GetAndSaveRandomSeed
type: branch_insn
branch_type: b
src_addr_pal: 0x8091F930
target_func: 'getAndSaveRandomSeed'
- name: ReplayInitPatch1
- type: patch
- addr_pal: 0x80920124
- data: '38841D68' # might not work on NTSC
+ type: branch_insn
+ branch_type: bl
+ src_addr_pal: 0x80920124
+ target_func: 'ChooseReplayStateIfNeeded'
- name: ReplayInitPatch2
- type: patch
- addr_pal: 0x8092016C
- data: '38841D68' # might not work on NTSC
+ type: branch_insn
+ branch_type: bl
+ src_addr_pal: 0x8092016C
+ target_func: 'ChooseReplayStateIfNeeded'
- name: ReplayPrepareSkip
- type: patch
- addr_pal: 0x8091F6EC
- data: '48000220' # branches past most of the function
+ type: branch_insn
+ branch_type: b
+ src_addr_pal: 0x8091F6E8
+ target_func: 'SkipReplayPrepareIfNeeded'
diff --git a/src/koopatlas/starcoin.cpp b/src/koopatlas/starcoin.cpp
index a0def97..a7a019a 100644
--- a/src/koopatlas/starcoin.cpp
+++ b/src/koopatlas/starcoin.cpp
@@ -373,6 +373,7 @@ static const int secretCode[] = {
static const int secretCodeButtons = WPAD_UP|WPAD_DOWN|WPAD_LEFT|WPAD_RIGHT|WPAD_ONE|WPAD_TWO;
static int secretCodeIndex = 0;
extern bool enableDebugMode;
+extern u8 isReplayEnabled;
void dWMStarCoin_c::beginState_ShowWait() {
visible = true;
@@ -413,8 +414,15 @@ void dWMStarCoin_c::executeState_Wait() {
if (secretCode[secretCodeIndex] == 0) {
secretCodeIndex = 0;
MapSoundPlayer(SoundRelatedClass, SE_VOC_MA_THANK_YOU, 1);
- enableDebugMode = !enableDebugMode;
- OSReport("Debug mode toggled!\n");
+ //enableDebugMode = !enableDebugMode;
+ //OSReport("Debug mode toggled!\n");
+ if (isReplayEnabled != 100) {
+ isReplayEnabled = 100;
+ OSReport("Replay Recording enabled!\n");
+ } else {
+ isReplayEnabled = 0;
+ OSReport("Replay Recording disabled!\n");
+ }
}
return;
} else {
diff --git a/src/replay.S b/src/replay.S
index 89868cf..b4345dc 100644
--- a/src/replay.S
+++ b/src/replay.S
@@ -1,5 +1,7 @@
# Fucking Nintendo, how do they work
+.extern isReplayEnabled
+
.extern IOS_Open
.extern IOS_Close
.extern IOS_Read
@@ -34,6 +36,8 @@
.extern WiimotePtr1
.extern Player_ID
.extern RandomSeed
+.extern dontSkipReplayPrepare
+.extern doSkipReplayPrepare
.set sp, 1
@@ -46,14 +50,14 @@
.global replayEnd
.global replayRecord
-.global luigiOverride
-luigiOverride:
- #blr
- lis r3, Player_ID@h
- ori r3, r3, Player_ID@l
- li r4, 1
- stw r4, 0(r3)
- blr
+#.global luigiOverride
+#luigiOverride:
+# #blr
+# lis r3, Player_ID@h
+# ori r3, r3, Player_ID@l
+# li r4, 1
+# stw r4, 0(r3)
+# blr
.global getAndSaveRandomSeed
getAndSaveRandomSeed: # b from 8091F930
@@ -77,6 +81,12 @@ getAndSaveRandomSeed: # b from 8091F930
replayStart: # b from 809246E0
+ lis r3, isReplayEnabled@h
+ ori r3, r3, isReplayEnabled@l
+ lbz r3, 0(r3)
+ cmpwi r3, 100
+ bne justSkipReplayStart
+
bl OSGetTime
lis r5, replayTime@h
ori r5, r5, replayTime@l
@@ -262,6 +272,7 @@ startNextReplay:
blt replayStartLoop
# and done!
+justSkipReplayStart:
li r3, 1
b continueFromReplayHookStart # 809246E4
@@ -387,6 +398,12 @@ done_flag_8:
replayEnd: # bl from 80102238
+ lis r4, isReplayEnabled@h
+ ori r4, r4, isReplayEnabled@l
+ lbz r4, 0(r4)
+ cmpwi r4, 100
+ bnelr
+
stwu sp, -0x20(sp)
mflr r0
stw r0, 0x24(sp)
@@ -490,6 +507,12 @@ justLeave:
replayRecord:
+ lis r3, isReplayEnabled@h
+ ori r3, r3, isReplayEnabled@l
+ lbz r3, 0(r3)
+ cmpwi r3, 100
+ bnelr
+
# fun shit.
stwu sp, -0x10(sp)
mflr r0
@@ -656,6 +679,38 @@ leaveRecordLoop:
blr
+
+.global ChooseReplayStateIfNeeded
+ChooseReplayStateIfNeeded:
+ lis r5, isReplayEnabled@h
+ ori r5, r5, isReplayEnabled@l
+ lbz r5, 0(r5)
+ cmpwi r5, 100
+ beq useReplayState
+ lis r4, Crsin_EffectResWaitProc@h
+ ori r4, r4, Crsin_EffectResWaitProc@l
+ blr
+useReplayState:
+ lis r4, Crsin_ReplayResWaitProc@h
+ ori r4, r4, Crsin_ReplayResWaitProc@l
+ blr
+
+.extern Crsin_EffectResWaitProc
+.extern Crsin_ReplayResWaitProc
+
+.global SkipReplayPrepareIfNeeded
+SkipReplayPrepareIfNeeded:
+ mr r24, r3
+ lis r5, isReplayEnabled@h
+ ori r5, r5, isReplayEnabled@l
+ lbz r5, 0(r5)
+ cmpwi r5, 100
+ beq yesSkipIt
+ b dontSkipReplayPrepare
+yesSkipIt:
+ b doSkipReplayPrepare
+
+
.data
replayFlags: .short 1, 1, 1, 1