Skip to content

Commit 1a354b5

Browse files
Update melonDS
1 parent acfc1f8 commit 1a354b5

File tree

5 files changed

+49
-20
lines changed

5 files changed

+49
-20
lines changed

Assets/dll/melonDS.wbx.zst

2.03 KB
Binary file not shown.

waterbox/melon/BizConsoleCreator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1518,6 +1518,7 @@ ECL_EXPORT melonDS::NDS* CreateConsole(ConsoleCreationArgs* args, char* error)
15181518
std::move(jitArgs),
15191519
bitDepth,
15201520
interpolation,
1521+
44100.0f,
15211522
std::nullopt,
15221523
std::move(renderer3d),
15231524
// dsi specific args
@@ -1541,6 +1542,7 @@ ECL_EXPORT melonDS::NDS* CreateConsole(ConsoleCreationArgs* args, char* error)
15411542
std::move(jitArgs),
15421543
bitDepth,
15431544
interpolation,
1545+
44100.0f,
15441546
std::nullopt,
15451547
std::move(renderer3d)
15461548
};

waterbox/melon/BizPlatform/BizFile.cpp

Lines changed: 44 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ struct FileHandle
1515
virtual bool ReadLine(char* str, int count) = 0;
1616
virtual bool Seek(s64 offset, FileSeekOrigin origin) = 0;
1717
virtual void Rewind() = 0;
18-
virtual size_t Read(void* data, u64 count) = 0;
18+
virtual size_t Read(void* data, u64 size, u64 count) = 0;
1919
virtual bool Flush() = 0;
20-
virtual size_t Write(const void* data, u64 count) = 0;
20+
virtual size_t Write(const void* data, u64 size, u64 count) = 0;
2121
virtual int WriteFormatted(const char* fmt, va_list args) = 0;
2222
virtual size_t Length() = 0;
23+
virtual size_t Position() = 0;
2324
};
2425

2526
struct MemoryFile final : FileHandle
@@ -87,25 +88,35 @@ struct MemoryFile final : FileHandle
8788
pos = 0;
8889
}
8990

90-
size_t Read(void* data_, u64 count)
91+
size_t Read(void* data_, u64 size_, u64 count)
9192
{
92-
count = std::min(count, (u64)(size - pos));
93-
memcpy(data_, &data[pos], count);
94-
pos += count;
95-
return count;
93+
u64 len = std::min(size_ * count, (u64)(size - pos) / size_ * size_);
94+
if (len == 0)
95+
{
96+
return 0;
97+
}
98+
99+
memcpy(data_, &data[pos], len);
100+
pos += len;
101+
return len / size_;
96102
}
97103

98104
bool Flush()
99105
{
100106
return true;
101107
}
102108

103-
size_t Write(const void* data_, u64 count)
109+
size_t Write(const void* data_, u64 size_, u64 count)
104110
{
105-
count = std::min(count, (u64)(size - pos));
106-
memcpy(&data[pos], data_, count);
107-
pos += count;
108-
return count;
111+
u64 len = std::min(size_ * count, (u64)(size - pos) / size_ * size_);
112+
if (len == 0)
113+
{
114+
return 0;
115+
}
116+
117+
memcpy(&data[pos], data_, len);
118+
pos += len;
119+
return len / size_;
109120
}
110121

111122
int WriteFormatted(const char* fmt, va_list args)
@@ -145,6 +156,11 @@ struct MemoryFile final : FileHandle
145156
return size;
146157
}
147158

159+
size_t Position()
160+
{
161+
return pos;
162+
}
163+
148164
private:
149165
std::unique_ptr<u8[]> data;
150166
size_t pos, size;
@@ -207,19 +223,19 @@ struct CFile final : FileHandle
207223
rewind(file);
208224
}
209225

210-
size_t Read(void* data, u64 count)
226+
size_t Read(void* data, u64 size, u64 count)
211227
{
212-
return fread(data, 1, count, file);
228+
return fread(data, size, count, file);
213229
}
214230

215231
bool Flush()
216232
{
217233
return fflush(file) == 0;
218234
}
219235

220-
size_t Write(const void* data, u64 count)
236+
size_t Write(const void* data, u64 size, u64 count)
221237
{
222-
return fwrite(data, 1, count, file);
238+
return fwrite(data, size, count, file);
223239
}
224240

225241
int WriteFormatted(const char* fmt, va_list args)
@@ -236,6 +252,11 @@ struct CFile final : FileHandle
236252
return len;
237253
}
238254

255+
size_t Position()
256+
{
257+
return ftell(file);
258+
}
259+
239260
private:
240261
FILE* file;
241262
};
@@ -334,6 +355,11 @@ bool FileReadLine(char* str, int count, FileHandle* file)
334355
return file->ReadLine(str, count);
335356
}
336357

358+
u64 FilePosition(FileHandle* file)
359+
{
360+
return file->Position();
361+
}
362+
337363
bool FileSeek(FileHandle* file, s64 offset, FileSeekOrigin origin)
338364
{
339365
return file->Seek(offset, origin);
@@ -346,7 +372,7 @@ void FileRewind(FileHandle* file)
346372

347373
u64 FileRead(void* data, u64 size, u64 count, FileHandle* file)
348374
{
349-
return file->Read(data, size * count);
375+
return file->Read(data, size, count);
350376
}
351377

352378
bool FileFlush(FileHandle* file)
@@ -356,7 +382,7 @@ bool FileFlush(FileHandle* file)
356382

357383
u64 FileWrite(const void* data, u64 size, u64 count, FileHandle* file)
358384
{
359-
return file->Write(data, size * count);
385+
return file->Write(data, size, count);
360386
}
361387

362388
u64 FileWriteFormatted(FileHandle* file, const char* fmt, ...)

waterbox/melon/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ TARGET = melonDS.wbx
1919

2020
CORE_SRCS = \
2121
ARCodeFile.cpp \
22+
ARDatabaseDAT.cpp \
2223
AREngine.cpp \
2324
ARM.cpp \
2425
ARMInterpreter.cpp \
@@ -117,7 +118,7 @@ MISC_SRCS = \
117118
sha1/sha1.c \
118119
tiny-AES-c/aes.c \
119120
xxhash/xxhash.c \
120-
blip_buf/blip_buf.c
121+
blip-buf/blip_buf.c
121122

122123
BIZPLATFORM_SRCS = \
123124
BizAAC.cpp \

waterbox/melon/melonDS

Submodule melonDS updated 77 files

0 commit comments

Comments
 (0)