mirror of
https://github.com/melonDS-emu/melonDS.git
synced 2025-07-25 23:29:55 -06:00
Assorted portability enhancements (#1800)
* Introduce some Platform calls for managing dynamic libraries * Add Platform::WriteFATSectors * Introduce some Platform calls for managing dynamic libraries * Add Platform::WriteFATSectors * Change includes of "../types.h" to "types.h" - Makes it easier to directly include these headers in downstream projects * Change an include of "../Wifi.h" to "Wifi.h" * Allow CommonFuncs.cpp to compile on Android * Tidy up some logging calls - Use Platform::Log in LAN_Socket.cpp - Soften some warnings to Debug logs (since they don't necessarily represent problems) * Add Platform::EnterGBAMode - Gracefully stop the emulator if trying to enter GBA mode * Soften some logs that most players won't care about * Soften some more logs * Introduce Platform wrappers for file operations * Fix pointer spacing * Fix more style nits * Log the errno when ftruncate fails * Fix FileSeek offset argument - With an s32 offset, we couldn't access files larger than 2GB * Revise Platform::StopEmu to address feedback - Remove Platform::EnterGBAMode in favor of adding a reason to Platform::StopEmu - Also rename Platform::StopEmu to Platform::SignalStop - Add an optional argument to NDS::Stop - Use the new argument everywhere that the console stops itself * Rename FileGetString to FileReadLine - It conveys the meaning better * Rename FileSeekOrigin::Set to Start - It conveys the meaning better * Change definition of FileGetString to FileReadLine - Oops, almost forgot it * Rename FlushFile to FileFlush - To remain consistent with the other File functions * Add a FileType usage * Fix line break in FileSeekOrigin * Document Platform::DeInit * Clarify that StopReason::Unknown doesn't always mean an error * Move and document FileType::HostFile * Remove Platform::OpenDataFile - Nothing currently uses it * Refactor Platform::OpenFile and Platform::OpenLocalFile to accept a FileMode enum instead of a string - The enum is converted to fopen flags under the hood - The file type is used to decide whether to add the "b" flag - Some helper functions are exposed for the benefit of consistent behavior among frontends - Equivalent behavior is maintained * Fix a tab that should be spaces * Use Windows' 64-bit implementations of fseek/ftell * Move Platform::IsBinaryFile to Platform.cpp - It could vary by frontend * Remove an unused FileType * Rename an enum constant * Document various Platform items * Use Platform::DynamicLibrary to load libandroid - And clean it up at the end * Fix a typo * Pass the correct filetype to FATStorage - Since it can be used for DSI NAND images or for SD cards * Remove Platform::FileType
This commit is contained in:

committed by
GitHub

parent
f454eba3c3
commit
ee55677086
@ -24,6 +24,7 @@
|
||||
#include "Wifi.h"
|
||||
#include "LAN_Socket.h"
|
||||
#include "FIFO.h"
|
||||
#include "Platform.h"
|
||||
|
||||
#include <slirp/libslirp.h>
|
||||
|
||||
@ -40,6 +41,9 @@
|
||||
namespace LAN_Socket
|
||||
{
|
||||
|
||||
using Platform::Log;
|
||||
using Platform::LogLevel;
|
||||
|
||||
const u32 kSubnet = 0x0A400000;
|
||||
const u32 kServerIP = kSubnet | 0x01;
|
||||
const u32 kDNSIP = kSubnet | 0x02;
|
||||
@ -87,7 +91,7 @@ void RXEnqueue(const void* buf, int len)
|
||||
|
||||
if (!RXBuffer.CanFit(totallen >> 2))
|
||||
{
|
||||
printf("slirp: !! NOT ENOUGH SPACE IN RX BUFFER\n");
|
||||
Log(LogLevel::Warn, "slirp: !! NOT ENOUGH SPACE IN RX BUFFER\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -101,11 +105,11 @@ ssize_t SlirpCbSendPacket(const void* buf, size_t len, void* opaque)
|
||||
{
|
||||
if (len > 2048)
|
||||
{
|
||||
printf("slirp: packet too big (%zu)\n", len);
|
||||
Log(LogLevel::Warn, "slirp: packet too big (%zu)\n", len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
printf("slirp: response packet of %zu bytes, type %04X\n", len, ntohs(((u16*)buf)[6]));
|
||||
Log(LogLevel::Debug, "slirp: response packet of %zu bytes, type %04X\n", len, ntohs(((u16*)buf)[6]));
|
||||
|
||||
RXEnqueue(buf, len);
|
||||
|
||||
@ -114,7 +118,7 @@ ssize_t SlirpCbSendPacket(const void* buf, size_t len, void* opaque)
|
||||
|
||||
void SlirpCbGuestError(const char* msg, void* opaque)
|
||||
{
|
||||
printf("SLIRP: error: %s\n", msg);
|
||||
Log(LogLevel::Error, "SLIRP: error: %s\n", msg);
|
||||
}
|
||||
|
||||
int64_t SlirpCbClockGetNS(void* opaque)
|
||||
@ -139,7 +143,7 @@ void SlirpCbTimerMod(void* timer, int64_t expire_time, void* opaque)
|
||||
|
||||
void SlirpCbRegisterPollFD(int fd, void* opaque)
|
||||
{
|
||||
printf("Slirp: register poll FD %d\n", fd);
|
||||
Log(LogLevel::Debug, "Slirp: register poll FD %d\n", fd);
|
||||
|
||||
/*if (FDListSize >= FDListMax)
|
||||
{
|
||||
@ -158,7 +162,7 @@ void SlirpCbRegisterPollFD(int fd, void* opaque)
|
||||
|
||||
void SlirpCbUnregisterPollFD(int fd, void* opaque)
|
||||
{
|
||||
printf("Slirp: unregister poll FD %d\n", fd);
|
||||
Log(LogLevel::Debug, "Slirp: unregister poll FD %d\n", fd);
|
||||
|
||||
/*if (FDListSize < 1)
|
||||
{
|
||||
@ -178,7 +182,7 @@ void SlirpCbUnregisterPollFD(int fd, void* opaque)
|
||||
|
||||
void SlirpCbNotify(void* opaque)
|
||||
{
|
||||
printf("Slirp: notify???\n");
|
||||
Log(LogLevel::Debug, "Slirp: notify???\n");
|
||||
}
|
||||
|
||||
SlirpCb cb =
|
||||
@ -283,7 +287,7 @@ void HandleDNSFrame(u8* data, int len)
|
||||
u16 numauth = ntohs(*(u16*)&dnsbody[8]);
|
||||
u16 numadd = ntohs(*(u16*)&dnsbody[10]);
|
||||
|
||||
printf("DNS: ID=%04X, flags=%04X, Q=%d, A=%d, auth=%d, add=%d\n",
|
||||
Log(LogLevel::Debug, "DNS: ID=%04X, flags=%04X, Q=%d, A=%d, auth=%d, add=%d\n",
|
||||
id, flags, numquestions, numanswers, numauth, numadd);
|
||||
|
||||
// for now we only take 'simple' DNS requests
|
||||
@ -429,7 +433,7 @@ int SendPacket(u8* data, int len)
|
||||
|
||||
if (len > 2048)
|
||||
{
|
||||
printf("LAN_SendPacket: error: packet too long (%d)\n", len);
|
||||
Log(LogLevel::Error, "LAN_SendPacket: error: packet too long (%d)\n", len);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -461,7 +465,7 @@ int SlirpCbAddPoll(int fd, int events, void* opaque)
|
||||
{
|
||||
if (PollListSize >= PollListMax)
|
||||
{
|
||||
printf("slirp: POLL LIST FULL\n");
|
||||
Log(LogLevel::Error, "slirp: POLL LIST FULL\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user