Skip to content

Commit 1eaed32

Browse files
committed
Update patch.cpp, seqdrv.h, and ReloadScreenC.cpp
Changed patch.cpp to clear the cache of whatever address it's modifying. Changed seqdrv to use int32_t instead of uint32_t, as the values can sometimes be -1. Changed ReloadScreenC.cpp to not load the sequence until actually checking it.
1 parent 035049d commit 1eaed32

File tree

10 files changed

+108
-9
lines changed

10 files changed

+108
-9
lines changed

ttyd-tools/rel/include/ttyd.eu.lst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,27 @@
827827
// w_atan2.c
828828
80276394:atan2
829829

830+
// OSCache.c
831+
// 8029A84C:DCEnable
832+
// 8029A860:DCInvalidateRange
833+
8029A88C:DCFlushRange
834+
// 8029A8BC:DCStoreRange
835+
// 8029A8EC:DCFlushRangeNoSync
836+
// 8029A918:DCStoreRangeNoSync
837+
// 8029A944:DCZeroRange
838+
8029A970:ICInvalidateRange
839+
// 8029A9A4:ICFlashInvalidate
840+
// 8029A9B4:ICEnable
841+
// 8029A9C8:__LCEnable
842+
// 8029AA94:LCEnable
843+
// 8029AACC:LCDisable
844+
// 8029AAF4:LCStoreBlocks
845+
// 8029AB18:LCStoreData
846+
// 8029ABC4:LCQueueWait
847+
// 8029ABD8:L2GlobalInvalidate
848+
// 8029AC70:DMAErrorHandler
849+
// 8029ADD0:__OSCacheInit
850+
830851
// GXGeometry.c
831852
// 802B9A68:__GXSetDirtyState
832853
802B9AE8:GXBegin

ttyd-tools/rel/include/ttyd.jp.lst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,27 @@
824824
// w_atan2.c
825825
8026C588:atan2
826826

827+
// OSCache.c
828+
// 802909FC:DCEnable
829+
// 80290A10:DCInvalidateRange
830+
80290A3C:DCFlushRange
831+
// 80290A6C:DCStoreRange
832+
// 80290A9C:DCFlushRangeNoSync
833+
// 80290AC8:DCStoreRangeNoSync
834+
// 80290AF4:DCZeroRange
835+
80290B20:ICInvalidateRange
836+
// 80290B54:ICFlashInvalidate
837+
// 80290B64:ICEnable
838+
// 80290B78:__LCEnable
839+
// 80290C44:LCEnable
840+
// 80290C7C:LCDisable
841+
// 80290CA4:LCStoreBlocks
842+
// 80290CC8:LCStoreData
843+
// 80290D74:LCQueueWait
844+
// 80290D88:L2GlobalInvalidate
845+
// 80290E20:DMAErrorHandler
846+
// 80290F80:__OSCacheInit
847+
827848
// GXGeometry.c
828849
// 802AFBE8:__GXSetDirtyState
829850
802AFC68:GXBegin

ttyd-tools/rel/include/ttyd.us.lst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,6 +827,27 @@
827827
// w_atan2.c
828828
802725A0:atan2
829829

830+
// OSCache.c
831+
// 80296A14:DCEnable
832+
// 80296A28:DCInvalidateRange
833+
80296A54:DCFlushRange
834+
// 80296A84:DCStoreRange
835+
// 80296AB4:DCFlushRangeNoSync
836+
// 80296AE0:DCStoreRangeNoSync
837+
// unused:DCZeroRange
838+
80296B0C:ICInvalidateRange
839+
// 80296B40:ICFlashInvalidate
840+
// 80296B50:ICEnable
841+
// unused:__LCEnable
842+
// unused:LCEnable
843+
// 80296B64:LCDisable
844+
// unused:LCStoreBlocks
845+
// unused:LCStoreData
846+
// unused:LCQueueWait
847+
// 80296B8C:L2GlobalInvalidate
848+
// 80296C24:DMAErrorHandler
849+
// 80296D84:__OSCacheInit
850+
830851
// GXGeometry.c
831852
// 802B59EC:__GXSetDirtyState
832853
802B5A6C:GXBegin
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#pragma once
2+
3+
#include <cstdint>
4+
5+
namespace ttyd::OSCache {
6+
7+
extern "C" {
8+
9+
// DCEnable
10+
// DCInvalidateRange
11+
void DCFlushRange(void *startAddress, uint32_t numberOfBytesToFlush);
12+
// DCStoreRange
13+
// DCFlushRangeNoSync
14+
// DCStoreRangeNoSync
15+
// DCZeroRange
16+
void ICInvalidateRange(void *startAddress, uint32_t numberOfBytesToInvalidate);
17+
// ICFlashInvalidate
18+
// ICEnable
19+
// __LCEnable
20+
// LCEnable
21+
// LCDisable
22+
// LCStoreBlocks
23+
// LCStoreData
24+
// LCQueueWait
25+
// L2GlobalInvalidate
26+
// DMAErrorHandler
27+
// __OSCacheInit
28+
29+
}
30+
31+
}

ttyd-tools/rel/include/ttyd/seqdrv.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace ttyd::seqdrv {
66

7-
enum class SeqIndex : uint32_t
7+
enum class SeqIndex : int32_t
88
{
99
kLogo = 0,
1010
kTitle,
@@ -19,7 +19,7 @@ enum class SeqIndex : uint32_t
1919
struct SeqInfo
2020
{
2121
SeqIndex seq;
22-
uint32_t state;
22+
int32_t state;
2323
const char *mapName;
2424
const char *beroName;
2525
uint32_t counter;
@@ -33,9 +33,9 @@ extern "C" {
3333
void seqInit_MARIOSTORY();
3434
void seqMain();
3535
void seqSetSeq(SeqIndex seq, const char *mapName, const char *beroName);
36-
uint32_t seqGetSeq();
37-
uint32_t seqGetPrevSeq();
38-
uint32_t seqGetNextSeq();
36+
int32_t seqGetSeq();
37+
int32_t seqGetPrevSeq();
38+
int32_t seqGetNextSeq();
3939
bool seqCheckSeq();
4040

4141
}

ttyd-tools/rel/source/codes/GameOverC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ void Mod::gameOver()
1313
{
1414
if ((ttyd::system::keyGetButton(0) & GameOverCombo) == (GameOverCombo))
1515
{
16-
uint32_t Logo = static_cast<uint32_t>(ttyd::seqdrv::SeqIndex::kLogo);
16+
int32_t Logo = static_cast<uint32_t>(ttyd::seqdrv::SeqIndex::kLogo);
1717
if (ttyd::seqdrv::seqGetNextSeq() != Logo)
1818
{
1919
// The game will crash if the following code runs during the Logo

ttyd-tools/rel/source/codes/ReloadScreenC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ void Mod::reloadScreen()
2525
uint32_t NextSeq = ttyd::seqdrv::seqGetNextSeq();
2626
uint32_t Game = static_cast<uint32_t>(ttyd::seqdrv::SeqIndex::kGame);
2727
uint32_t MapChange = static_cast<uint32_t>(ttyd::seqdrv::SeqIndex::kMapChange);
28-
uint32_t SystemLevel = ttyd::mariost::marioStGetSystemLevel();
2928

3029
if ((NextSeq >= Game) && (NextSeq <= MapChange))
3130
{
@@ -37,6 +36,7 @@ void Mod::reloadScreen()
3736
ttyd::string::strcpy(NewMap, NextMap);
3837
ttyd::seqdrv::seqSetSeq(ttyd::seqdrv::SeqIndex::kMapChange, NewMap, NewBero);
3938

39+
uint32_t SystemLevel = ttyd::mariost::marioStGetSystemLevel();
4040
if (SystemLevel != 0)
4141
{
4242
if (SystemLevel == 15)

ttyd-tools/rel/source/codes/SaveAnywhereC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ void Mod::saveAnywhere()
1919
// Save Script is not running
2020
if ((ttyd::system::keyGetButton(0) & SaveAnywhereCombo) == (SaveAnywhereCombo))
2121
{
22-
uint32_t Game = static_cast<uint32_t>(ttyd::seqdrv::SeqIndex::kGame);
22+
int32_t Game = static_cast<uint32_t>(ttyd::seqdrv::SeqIndex::kGame);
2323
if ((ttyd::seqdrv::seqGetNextSeq() == Game) && (ttyd::mariost::marioStGetSystemLevel() != 15))
2424
{
2525
// Not in the Pause Menu

ttyd-tools/rel/source/codes/SpawnItemC.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ void Mod::spawnItem()
2020
{
2121
if (!spawnItemDisable)
2222
{
23-
uint32_t Game = static_cast<uint32_t>(ttyd::seqdrv::SeqIndex::kGame);
23+
int32_t Game = static_cast<uint32_t>(ttyd::seqdrv::SeqIndex::kGame);
2424
if ((ttyd::seqdrv::seqGetNextSeq() == Game) && (ttyd::mariost::marioStGetSystemLevel() != 15))
2525
{
2626
// Not in pause menu

ttyd-tools/rel/source/patch.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include "patch.h"
22

3+
#include <ttyd/OSCache.h>
4+
35
#include <cstdint>
46

57
namespace mod::patch {
@@ -12,6 +14,9 @@ void writeBranch(void *ptr, void *destination)
1214

1315
uint32_t *p = reinterpret_cast<uint32_t *>(ptr);
1416
*p = value;
17+
18+
ttyd::OSCache::DCFlushRange(destination, sizeof(uint32_t));
19+
ttyd::OSCache::ICInvalidateRange(destination, sizeof(uint32_t));
1520
}
1621

1722
}

0 commit comments

Comments
 (0)