This repository has been archived by the owner on Oct 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
progress.py
114 lines (90 loc) · 3.47 KB
/
progress.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
import os
def ReadAllLines(fileName):
lineList = list()
with open(fileName) as f:
lineList = f.readlines()
return lineList
def GetFiles(path):
files = []
for r, d, f in os.walk(path):
for file in f:
if '.s' in file:
files.append(os.path.join(r, file))
return files
def GetNonMatchingSize(path):
size = 0
asmFiles = GetFiles(path)
for asmFilePath in asmFiles:
asmLines = ReadAllLines(asmFilePath)
for asmLine in asmLines:
if (asmLine.startswith("/*")):
size += 4
return size
mapFile = ReadAllLines("build/z64.map")
src = 0
code = 0
boot = 0
ovl = 0
asm = 0
for line in mapFile:
lineSplit = list(filter(None, line.split(" ")))
if (len(lineSplit) == 4 and lineSplit[0].startswith(".")):
section = lineSplit[0]
size = int(lineSplit[2], 16)
objFile = lineSplit[3]
if (section == ".text"):
if (objFile.startswith("build/src")):
src += size
elif (objFile.startswith("build/asm")):
asm += size
if (objFile.startswith("build/src/code") or objFile.startswith("build/src/libultra_code")):
code += size
elif (objFile.startswith("build/src/boot") or objFile.startswith("build/src/libultra_boot")):
boot += size
elif (objFile.startswith("build/src/overlays")):
ovl += size
nonMatchingASM = GetNonMatchingSize("asm/non_matchings")
nonMatchingASMBoot = GetNonMatchingSize("asm/non_matchings/boot") + GetNonMatchingSize("asm/non_matchings/libultra_boot")
nonMatchingASMCode = GetNonMatchingSize("asm/non_matchings/code") + GetNonMatchingSize("asm/non_matchings/libultra_code")
nonMatchingASMOvl = GetNonMatchingSize("asm/non_matchings/overlays")
codeSize = 1004128 # 1.00mb
bootSize = 36752
#ovlSize = 3727584 # 3.727mb
ovlSize = 2812000 # .text section only
libultraSize = 40816 # This is temp
audioSize = 0 # This is temp
handwritten = 0 # This is temp
src -= nonMatchingASM
code -= nonMatchingASMCode
boot -= nonMatchingASMBoot
ovl -= nonMatchingASMOvl
asm += nonMatchingASM
#print(nonMatchingASM)
#asm = asm - (libultra_size + audio_size + handwritten - boot_size - code_size - ovl_size)
#asm = asm - (libultra_size + audio_size + handwritten)
#asm = -(libultra_size + audio_size + handwritten - boot_size - code_size - ovl_size)
#asm += codeSize
#asm += bootSize
#asm += ovlSize
#asm -= src
total = src + asm
srcPct = 100 * src / total
asmPct = 100 * asm / total
codePct = 100 * code / codeSize
bootPct = 100 * boot / bootSize
ovlPct = 100 * ovl / ovlSize
compiled_bytes = total
bytesPerHeartPiece = compiled_bytes / 80
print(str(total) + " total bytes of decompilable code\n")
print(str(src) + " bytes of code in src " + str(srcPct) + "%\n")
#print(str(asm) + " bytes of code in asm " + str(asmPct) + "%\n")
print(str(boot) + "/" + str(bootSize) + " bytes of code in boot " + str(bootPct) + "%\n")
print(str(code) + "/" + str(codeSize) + " bytes of code in code " + str(codePct) + "%\n")
print(str(ovl) + "/" + str(ovlSize) + " bytes of code in overlays " + str(ovlPct) + "%\n")
print("------------------------------------\n")
heartPieces = int(src / bytesPerHeartPiece)
rupees = int(((src % bytesPerHeartPiece) * 100) / bytesPerHeartPiece)
if (rupees > 0):
print("You have " + str(heartPieces) + "/80 heart pieces and " + str(rupees) + " rupee(s).\n")
else:
print("You have " + str(heartPieces) + "/80 heart pieces.\n")