Skip to content

Commit ea42df9

Browse files
author
XorTroll
committed
Fixes in 0.6.1
1 parent 122e859 commit ea42df9

14 files changed

+666
-586
lines changed

Goldleaf/Icon.jpg

-79 Bytes
Loading

Goldleaf/Include/Types.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -108,5 +108,6 @@ bool HasKeyFile();
108108
bool IsAtmosphere();
109109
bool IsReiNX();
110110
bool IsSXOS();
111+
u64 GetCurrentApplicationId();
111112
u32 RandomFromRange(u32 Min, u32 Max);
112113
void EnsureDirectories();

Goldleaf/Include/usb/usb_Commands.hpp

+27-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ namespace usb
3737
static constexpr u32 InputMagic = 0x49434C47; // GLCI
3838
static constexpr u32 OutputMagic = 0x4F434C47; // GLCO
3939

40-
static constexpr size_t BlockSize = 0x2000;
40+
static constexpr size_t BlockSize = 0x1000;
4141

4242
struct BlockBase
4343
{
@@ -51,6 +51,7 @@ namespace usb
5151

5252
InCommandBlock(CommandId CmdId);
5353
void Write32(u32 Value);
54+
void Write64(u64 Value);
5455
void WriteString(std::string Value);
5556
void WriteBuffer(void *Buf, size_t Size);
5657
void Send();
@@ -66,6 +67,7 @@ namespace usb
6667
void Cleanup();
6768
bool IsValid();
6869
u32 Read32();
70+
u64 Read64();
6971
std::string ReadString();
7072
void ReadBuffer(void *Buf, size_t Size);
7173
};
@@ -103,6 +105,30 @@ namespace usb
103105
u32 &val;
104106
};
105107

108+
class In64 : public CommandArgument
109+
{
110+
public:
111+
In64(u64 Value);
112+
void ProcessIn(InCommandBlock &block);
113+
void ProcessAfterIn();
114+
void ProcessOut(OutCommandBlock &block);
115+
void ProcessAfterOut();
116+
private:
117+
u64 val;
118+
};
119+
120+
class Out64 : public CommandArgument
121+
{
122+
public:
123+
Out64(u64 &Value);
124+
void ProcessIn(InCommandBlock &block);
125+
void ProcessAfterIn();
126+
void ProcessOut(OutCommandBlock &block);
127+
void ProcessAfterOut();
128+
private:
129+
u64 &val;
130+
};
131+
106132
class InString : public CommandArgument
107133
{
108134
public:

Goldleaf/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ include $(DEVKITPRO)/libnx/switch_rules
99

1010
APP_TITLE := Goldleaf
1111
APP_AUTHOR := XorTroll
12-
APP_VERSION := 0.6
12+
APP_VERSION := 0.6.1
1313
APP_TITLEID := 050032A5CF12E000
1414

1515
TARGET := Goldleaf

Goldleaf/RomFs/MenuBanner.png

171 Bytes
Loading

Goldleaf/Source/Types.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,13 @@ bool IsSXOS()
117117
return false;
118118
}
119119

120+
u64 GetCurrentApplicationId()
121+
{
122+
u64 appid = 0;
123+
svcGetInfo(&appid, InfoType_TitleId, CUR_PROCESS_HANDLE, 0);
124+
return appid;
125+
}
126+
120127
u32 RandomFromRange(u32 Min, u32 Max)
121128
{
122129
u32 diff = Max - Min;

Goldleaf/Source/fs/fs_Explorer.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -696,8 +696,8 @@ namespace fs
696696
bool ex = false;
697697
std::string path = this->MakeFull(Path);
698698
u32 type = 0;
699-
u32 tmpfsz = 0;
700-
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(type), usb::Out32(tmpfsz));
699+
u64 tmpfsz = 0;
700+
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(type), usb::Out64(tmpfsz));
701701
ex = ((type == 1) || (type == 2));
702702
return ex;
703703
}
@@ -707,8 +707,8 @@ namespace fs
707707
bool ex = false;
708708
std::string path = this->MakeFull(Path);
709709
u32 type = 0;
710-
u32 tmpfsz = 0;
711-
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(type), usb::Out32(tmpfsz));
710+
u64 tmpfsz = 0;
711+
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(type), usb::Out64(tmpfsz));
712712
ex = (type == 1);
713713
return ex;
714714
}
@@ -718,8 +718,8 @@ namespace fs
718718
bool ex = false;
719719
std::string path = this->MakeFull(Path);
720720
u32 type = 0;
721-
u32 tmpfsz = 0;
722-
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(type), usb::Out32(tmpfsz));
721+
u64 tmpfsz = 0;
722+
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(type), usb::Out64(tmpfsz));
723723
ex = (type == 2);
724724
return ex;
725725
}
@@ -762,26 +762,26 @@ namespace fs
762762

763763
u64 USBPCDriveExplorer::ReadFileBlock(std::string Path, u64 Offset, u64 Size, u8 *Out)
764764
{
765-
u32 rsize = 0;
765+
u64 rsize = 0;
766766
std::string path = this->MakeFull(Path);
767-
usb::ProcessCommand<usb::CommandId::ReadFile>(usb::InString(path), usb::In32((u32)Offset), usb::In32((u32)Size), usb::Out32(rsize), usb::OutBuffer(Out, Size));
768-
return (u64)rsize;
767+
usb::ProcessCommand<usb::CommandId::ReadFile>(usb::InString(path), usb::In64(Offset), usb::In64(Size), usb::Out64(rsize), usb::OutBuffer(Out, Size));
768+
return rsize;
769769
}
770770

771771
u64 USBPCDriveExplorer::WriteFileBlock(std::string Path, u8 *Data, u64 Size)
772772
{
773773
std::string path = this->MakeFull(Path);
774-
usb::ProcessCommand<usb::CommandId::WriteFile>(usb::InString(path), usb::In32((u32)Size), usb::InBuffer(Data, Size));
774+
usb::ProcessCommand<usb::CommandId::WriteFile>(usb::InString(path), usb::In64(Size), usb::InBuffer(Data, Size));
775775
return Size;
776776
}
777777

778778
u64 USBPCDriveExplorer::GetFileSize(std::string Path)
779779
{
780-
u32 sz = 0;
780+
u64 sz = 0;
781781
std::string path = this->MakeFull(Path);
782782
u32 tmptype = 0;
783-
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(tmptype), usb::Out32(sz));
784-
return (u64)sz;
783+
usb::ProcessCommand<usb::CommandId::StatPath>(usb::InString(path), usb::Out32(tmptype), usb::Out64(sz));
784+
return sz;
785785
}
786786

787787
u64 USBPCDriveExplorer::GetTotalSpace()

Goldleaf/Source/nsp/nsp_Installer.cpp

+6-14
Original file line numberDiff line numberDiff line change
@@ -264,21 +264,11 @@ namespace nsp
264264
ncm::CreatePlaceHolder(&cst, &curid, &curid, ncasize);
265265
u64 noff = 0;
266266
u64 szrem = ncasize;
267-
u64 tmpwritten = 0;
268-
u64 bsec = 0;
269-
auto t1 = std::chrono::steady_clock::now();
270267
while(szrem)
271268
{
272-
auto t2 = std::chrono::steady_clock::now();
273-
u64 diff = std::chrono::duration_cast<std::chrono::seconds>(t2 - t1).count();
274-
if(diff >= 1)
275-
{
276-
t1 = t2;
277-
bsec = tmpwritten;
278-
tmpwritten = 0;
279-
}
280269
u64 rbytes = 0;
281270
u64 rsize = std::min(szrem, reads);
271+
auto t1 = std::chrono::steady_clock::now();
282272
switch(rnca.Type)
283273
{
284274
case ncm::ContentType::Meta:
@@ -287,13 +277,15 @@ namespace nsp
287277
break;
288278
default:
289279
rbytes = nspentry.ReadFromFile(idxncaname, noff, rsize, rdata);
290-
break;
280+
break;
291281
}
292282
ncm::WritePlaceHolder(&cst, &curid, noff, rdata, rbytes);
293283
noff += rbytes;
294-
tmpwritten += (double)rbytes;
295284
szrem -= rbytes;
296-
OnContentWrite(rnca, i, ncas.size(), (double)noff, (double)ncasize, bsec);
285+
auto t2 = std::chrono::steady_clock::now();
286+
u64 diff = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - t1).count();
287+
double bsec = (1000.0f / (double)diff) * rbytes; // By elapsed time and written bytes, compute how much data has been written in 1sec.
288+
OnContentWrite(rnca, i, ncas.size(), (double)noff, (double)ncasize, (u64)bsec);
297289
}
298290
ncmContentStorageRegister(&cst, &curid, &curid);
299291
ncm::DeletePlaceHolder(&cst, &curid);

Goldleaf/Source/ui/ui_MainMenuLayout.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ namespace ui
7474

7575
void MainMenuLayout::webMenuItem_Click()
7676
{
77-
if(GetLaunchMode() != LaunchMode::Application)
77+
if(GetCurrentApplicationId() != GOLDLEAF_APPID)
7878
{
79-
mainapp->CreateShowDialog(set::GetDictionaryEntry(5), set::GetDictionaryEntry(37), { set::GetDictionaryEntry(234) }, true);
79+
mainapp->CreateShowDialog(set::GetDictionaryEntry(5), set::GetDictionaryEntry(292), { set::GetDictionaryEntry(234) }, true);
8080
return;
8181
}
8282
std::string out = AskForText(set::GetDictionaryEntry(38), "https://");

0 commit comments

Comments
 (0)