summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2013-01-31 04:19:18 +0100
committerTreeki <treeki@gmail.com>2013-01-31 04:19:18 +0100
commit6b12a531091c032c9299a1a260a22eacf226c598 (patch)
treeadda327442dba6f62038ff27a9240478d37d4870 /src
parent5269d426aea072c714f68517079db024a2e3dec7 (diff)
downloadkamek-6b12a531091c032c9299a1a260a22eacf226c598.tar.gz
kamek-6b12a531091c032c9299a1a260a22eacf226c598.zip
file select's exit counter now ignores non-levels
Diffstat (limited to 'src')
-rw-r--r--src/fileselect.S87
-rw-r--r--src/newer.cpp38
2 files changed, 52 insertions, 73 deletions
diff --git a/src/fileselect.S b/src/fileselect.S
index 4d6ce85..86e7856 100644
--- a/src/fileselect.S
+++ b/src/fileselect.S
@@ -56,6 +56,7 @@ DFNiceTitle:
.extern findTextBoxByName__Q23m2d17EmbedLayoutBase_cCFPCc
.extern findPictureByName__Q23m2d17EmbedLayoutBase_cCFPCc
.extern InsertIntIntoTextBox1
+.extern GrabExitInfoForFileSelect
.global DFNiceWorldName
DFNiceWorldName:
stwu r1, -0x30(r1)
@@ -65,9 +66,6 @@ DFNiceWorldName:
stw r21, 0x28(r1)
stw r22, 0x24(r1)
# r1+0x20 is reserved for the stupid ints in textboxes
- stw r23, 0x1C(r1)
- stw r24, 0x18(r1)
- stw r25, 0x14(r1)
mr r20, r4
# Savefile is in r31
@@ -120,78 +118,20 @@ chosenWName:
stw r4, 0xE0(r3)
stw r4, 0xE4(r3)
- # While we're at it, take care of some other things
- # r21 shall hold our star coin count; r22 shall hold our exit count
- # r23 shall hold the level pointer
- # r24 shall hold the world number, and r25 the level number
-
- li r21, 0
- li r22, 0
- addi r23, r31, 0x6C
- li r24, 0
- li r25, 0
-
- # Loop through ALL levels
-
-levelLoop:
- lwz r4, 0(r23)
-
- cmpwi r25, 38
- beq ignoreStartPoint
-
- clrlwi. r0, r4, 31
- beq noCoin1
- addi r21, r21, 1
-noCoin1:
- extrwi. r0, r4, 1,30
- beq noCoin2
- addi r21, r21, 1
-noCoin2:
- extrwi. r0, r4, 1,29
- beq noCoin3
- addi r21, r21, 1
-noCoin3:
-
- extrwi. r0, r4, 1,27
- beq noNormalExit
- addi r22, r22, 1
-
-# lis r3, NormalExitStr@h
-# ori r3, r3, NormalExitStr@l
-# addi r4, r24, 1
-# addi r5, r25, 1
-# crclr 4*cr1+eq
-# bl OSReport
-noNormalExit:
- lwz r4, 0(r23)
- extrwi. r0, r4, 1,26
- beq noSecretExit
- addi r22, r22, 1
-
-# lis r3, SecretExitStr@h
-# ori r3, r3, SecretExitStr@l
-# addi r4, r24, 1
-# addi r5, r25, 1
-# crclr 4*cr1+eq
-# bl OSReport
-noSecretExit:
-
-ignoreStartPoint:
-
- addi r23, r23, 4
- addi r25, r25, 1
- cmpwi r25, 42
- blt levelLoop
- # next world
- addi r24, r24, 1
- li r25, 0
- cmpwi r24, 10
- blt levelLoop
+ lis r3, Out_Stuff@h
+ ori r3, r3, Out_Stuff@l
+ mr r4, r31
+ bl GrabExitInfoForFileSelect
+ lwz r21, 0(r3)
+ lwz r22, 4(r3)
# Now, subtract the paid star coins
lhz r3, 0x66(r31)
sub r21, r21, r3
+ # r21: Star Coin Count
+ # r22: Exit Count
+
# And write everything ...
addi r3, r30, 0x74
lis r4, ExitCount@h
@@ -215,9 +155,6 @@ ignoreStartPoint:
li r5, 0
bl InsertIntIntoTextBox1
- lwz r25, 0x14(r1)
- lwz r24, 0x18(r1)
- lwz r23, 0x1C(r1)
lwz r22, 0x24(r1)
lwz r21, 0x28(r1)
lwz r20, 0x2C(r1)
@@ -361,6 +298,10 @@ StarCoinCount: .string "StarCoinCount"
ExitCount: .string "ExitCount"
Picture_00: .string "Picture_00"
+.global Out_Stuff
+Out_Stuff:
+.long 0, 0
+
.align 4
DFTitle:
.short 'F','i','l','e',' ','X',0
diff --git a/src/newer.cpp b/src/newer.cpp
index 50fc1d1..3635c09 100644
--- a/src/newer.cpp
+++ b/src/newer.cpp
@@ -1,5 +1,6 @@
#include <game.h>
#include <newer.h>
+#include "levelinfo.h"
int lastLevelIDs[] = {
-1, /*no world*/
@@ -91,3 +92,40 @@ int getStarCoinCount() {
return coinsEarned;
}
+
+
+struct GEIFS {
+ int starCoins, exits;
+};
+extern "C" GEIFS *GrabExitInfoForFileSelect(GEIFS *out, SaveBlock *save) {
+ out->starCoins = 0;
+ out->exits = 0;
+
+ for (int i = 0; i < dLevelInfo_c::s_info.sectionCount(); i++) {
+ dLevelInfo_c::section_s *section = dLevelInfo_c::s_info.getSectionByIndex(i);
+
+ for (int j = 0; j < section->levelCount; j++) {
+ dLevelInfo_c::entry_s *l = &section->levels[j];
+ if (l->flags & 2) {
+ //OSReport("Checking %d-%d...\n", l->worldSlot+1, l->levelSlot+1);
+ u32 cond = save->GetLevelCondition(l->worldSlot, l->levelSlot);
+ if ((l->flags & 0x10) && (cond & COND_NORMAL))
+ out->exits++;
+ if ((l->flags & 0x20) && (cond & COND_SECRET))
+ out->exits++;
+ if (cond & COND_COIN1)
+ out->starCoins++;
+ if (cond & COND_COIN2)
+ out->starCoins++;
+ if (cond & COND_COIN3)
+ out->starCoins++;
+ }
+ }
+ }
+
+ OSReport("Done, got %d coins and %d exits\n", out->starCoins, out->exits);
+
+ return out;
+}
+
+