Commit Graph

2183 Commits

Author SHA1 Message Date
Arisotura bff7a0d114 make linebreaks in text files not weird 2023-11-02 12:40:49 +01:00
Arisotura eb13bce6e7 RTC: add the DSi alarm expansion registers 2023-11-02 12:21:59 +01:00
Jesse Talavera-Greenberg d11ba63bb0
Fix compilation with the GDB stub disabled (#1863) 2023-11-01 16:02:15 +01:00
Arisotura 3b4fdea376 minor cleanup 2023-11-01 12:03:35 +01:00
Nadia Holmquist Pedersen b8963b0738 use a grid layout in the date/time dialog so Qt will behave 2023-10-30 19:37:39 +01:00
Arisotura e89b8a871b fdsfd 2023-10-30 18:40:26 +01:00
Arisotura 9a450f5f28
RTC revamp (#1867)
* get this started

* implement DSi RTC commands

* set up RTC clock timer. lay down basic idea of a clock.

* make the date/time registers writable

* move RTC state to its own structure, to make it easier to deal with

* more RTC work
lay base for date/time dialog

* get the bulk of the RTC functionality going

* much simpler design for RTC stuff

* aha, that is what it is

* start working on the RTC IRQ

* implement all types of RTC IRQ

* start refining sleep mode. code still kinda sucks.

* implement keypad IRQ

* refine it some more

* shut the fuck uuuuuupppppppppppppp
2023-10-30 18:37:49 +01:00
Jesse Talavera-Greenberg 21590b0709
Miscellaneous DSi NAND fixes (#1852)
* Replace some standard I/O calls with Platform equivalents

- I missed a spot when I submitted that PR a few months ago

* Include <memory> in DSi_NAND.h

- Because it uses unique_ptr

* Split DSi_NAND::ReadHardwareInfo into ReadSerialData and ReadHardwareInfoN

* Add a RegionMask enum

* Move DSi NAND patching to the frontend

* Add DSiSupportedLanguageMask

- Not currently used by the frontend, but I use it in melonDS DS

* Remove some Platform::ConfigEntry values

- The core no longer needs to know about them
- The corresponding Config values are unchanged

* Mark NANDMount's destructor as noexcept
2023-10-24 23:28:14 +02:00
Jesse Talavera-Greenberg 8c4e5af737
Slight polish to DMA (#1856)
* Slight polish to DMA

- Default-initialize members explicitly
- Mark some methods as const noexcept
- Initialize DMA::MRAMBurstTable to DMATiming::MRAMDummy
- Use the default destructor

* Move DMA_Timings definitions to a source file

- To ensure constant and unique addresses

* Include some extra DMA members in the savestate

* Simplify serializing the DMA table

- Extend the dummy table to 256 bytes (same length as the real ones)

* Revert the type change to DMA::DoSavestate

* Keep the MRAMBurstTable inside the DMA class, instead of using a pointer

- If we use a pointer to an external table, then we can't use it in savestates (else that external table gets overwritten)
2023-10-24 23:27:55 +02:00
Jesse Talavera-Greenberg bf81b87a60
Generalize a path in .gitignore (#1862)
- Covers all of CLion's default CMake build paths
2023-10-24 21:49:36 +02:00
PoroCYon 3ab752b8ca
GDB stub (#1583)
* gdbstub beginnings

* gdbstub: finish gdb impl things, next up is integration with melonDS

* holy fuck the gdbstub works

* gdb breakpoints work, but there's a mysterious crash on continue

* fix memory corruption that sometimes happened, and make resetting the console thru gdb work

* remove some gdb debug printing

* fix things in gdbstub

* separate option for enabling gdbstub

* add mode-dependent CPU registers

* C++ize the GDBstub code

* add gdbstub config in emu settings dialog

* make sure gdb is disabled when jit is enabled

* Remove unnecessary compiler flags, mark ARMJIT assembly code as no-execute-stack

This hardens the binary a little bit against common exploitation methods

* add option to wait for debugger attach on startup

* only insert GNU stack notes on linux

* disable gdbstub enable checkbox when jit is enabled

* fix non-linux incompatibilities

* enable gdbstub by default

* fix issues with gdbstub settings disable stuff

* format stuff

* update gdb test code

* Fix segfault when calling StubCallbacks->GetCPU()

C++ overrides are hard. Please I'm just a lowly C programmer.

* fix packet size not being sent correctly

Thanks to @GlowingUmbreon on Github for troubleshooting this

* fix select(2) calls (i should read docs more properly)

* fix GDB command sequencing/parsing issue (hopefully)

* [GDB] implement no-ack mode

* fix sending ack on handshake

* get lldb to work
2023-10-22 15:35:31 +02:00
RSDuck 3d58a338a1 store pc+12 when storing r15 2023-10-22 15:21:03 +02:00
Jesse Talavera-Greenberg d4e51f8060
Refactor DSi_NAND (#1844)
* Refactor diskio's contents

- Change ff_disk_read_cb/write_cb into a std::function instead of a raw pointer
- Add const specifiers as needed

* Refactor DSi_NAND to manage the file system's mounted lifetime with RAII

* Split NANDMount into NANDMount and NANDImage

- NANDImage is used for information about the NAND that doesn't require decryption or filesystem access
- NANDMount is used to actually access the file system
- Both classes manage their respective resources (the NAND file handle and the NAND's mount) with RAII
- Also split the file loading into another function that I will remove in a later PR

* Make NANDMount immovable

* Remove NAND-loading code that I had sectioned off into a function

- Incomplete copypasta
- I must have gotten distracted

* Tidy up NANDImage's initialization

- Don't unmount the disk image if the constructor fails (that's NANDMount's job now)
- Only assign CurFile if the constructor succeeds

* Add some const-correctness

* Move DSi NAND initialization to the frontend

- The NANDImage is now installed via a unique_ptr in DSi

* Remove Platform::DSi_NANDPath

- Not Config::DSiNANDPath; that can still be configured as usual
- The core no longer needs to care
2023-10-11 17:20:05 +02:00
Jesse Talavera-Greenberg b2fcff97c1
Add some structs for files that DSi_NAND reads (#1842)
* Add DSiFirmwareSystemSettings

* Replace DSiFirmwareSystemSettings::TouchCalibration fields with std::arrays

- So assignment can be done in one line

* Make DSiFirmwareSystemSettings a union

- So its bytes can be accessed

* Add a comment

* Use DSiFirmwareSystemSettings instead of raw byte offsets

* Add definitions for DSiSerialData and DSiHardwareInfoN

* Move DSiFirmwareSystemSettings's hash update logic into its own method
2023-10-02 17:54:17 +02:00
Jesse Talavera-Greenberg bb09ce7d70
Replace DSi_NAND's uses of sprintf with snprintf (#1841)
- Now clang oughta stop complaining
2023-10-01 21:58:56 +02:00
Jesse Talavera-Greenberg f8fdc77e43
Wrap CurGLCompositor cleanup in an #ifdef (#1837) 2023-09-24 18:48:37 +02:00
Jesse Talavera-Greenberg 9d9ba83731
Clean up some rendering-related resources in DeInit (#1836)
- The unique_ptr destructors will take care of the cleanup
2023-09-24 18:33:14 +02:00
Jesse Talavera-Greenberg 7d4a7969d9
Ensure that the new firmware is installed when resetting (#1834)
- It might have been changed in the settings
2023-09-21 13:54:17 +02:00
RSDuck 6ca02aab2c only recalculate extended access point checksum when firmware is a DSi one 2023-09-20 19:17:26 +02:00
Jesse Talavera-Greenberg 5bfe51e670
Refactor the core's handling of firmware and BIOS images to rely less on the file system (#1826)
* Introduce firmware-related structs

* Fix some indents

* Move the generated firmware identifier to a constant

* Document the WifiAccessPoint constructors

* Add some constants

* Remove a stray comment

* Implement Firmware::UserData

* Add Firmware::Mask

* Document Firmware::Buffer

* Add a Firmware constructor that uses a FileHandle

* Set the default username in UserData

* Update the UserData checksum

* Forgot to include Platform.h

* Remove some redundant assignments in the default Firmware constructor

* const-ify CRC16

* Replace the plain Firmware buffer with a Firmware object

- Remove some functions that were reimplemented in the Firmware constructors

* Fix some crashes due to undefined behavior

* Fix the user data initialization

- Initialize both user data objects to default
- Set both user data objects to the same touch screen calibration

* Follow the DS logic in determining which user data section is current

* Remove an unneeded include

* Remove another unneeded include

* Initialize FirmwareMask in Firmware::Firmware

* Use the DEFAULT_SSID constant

* Add SPI_Firmware::InstallFirmware and SPI_Firmware::RemoveFirmware

* Move a logging call to after the file is written

* Add a SaveManager for the firmware

* Touch up the SPI_Firmware::Firmware declaration

* Move all firmware loading and customization to the frontend

* Call Platform::WriteFirmware when it's time to write the firmware back to disk

* Fix some missing stuff

* Remove the Get* functions from SPI_Firmware in favor of GetFirmware()

* Implement SPI_Firmware::DeInit in terms of RemoveFirmware

* Add Firmware::UpdateChecksums

* Fix an incorrect length

* Update all checksums in the firmware after setting touch screen calibration data

* Use the Firmware object's Position methods

* Remove register fields from the Firmware object

* Install the firmware before seeing if direct boot is necessary

* Install the firmware before calling NDS::Reset in LoadROM

* Slight cleanup in ROMManager

* Fix the default access point name

* Shorten the various getters in Firmware

* Add qualifiers for certain uses of firmware types

- GCC can get picky if -fpermissive isn't defined

* Add an InstallFirmware overload that takes a unique_ptr

* Log when firmware is added or removed

* Don't clear the firmware in SPI_Firmware::Init

- The original code didn't, it just set the pointer to nullptr

* Fix a typo

* Write back the full firmware if it's not generated

* Move the FreeBIOS to an external file

* Load wfcsettings.bin into the correct part of the generated firmware blob

* Load BIOS files in the frontend, not in the core

* Fix logging the firmware ID

* Add some utility functions

* Mark Firmware's constructors as explicit

* Remove obsolete ConfigEntry values

* Include <locale> explicitly in ROMManager

* Fix up some includes

* Add Firmware::IsBootable()

* Add a newline to a log entry

- Whoops

* Log the number of bytes written out in SaveManager

* Mark FirmwareHeader's constructor as explicit

* Clean up GenerateDefaultFirmware and LoadFirmwareFromFile

- Now they return a pair instead of two by-ref values

* Refactor SaveManager a little bit

- Manage its buffers as unique_ptrs to mitigate leaks
- Reallocate the internal buffer if SetPath is asked to reload the file (and the new length is different)

* Remove some stray parens

* Fix some firmware-related bugs I introduced

- Firmware settings are now properly saved to disk (beforehand I misunderstood when the firmware blob was written)
- Firmware is no longer overwritten by contents of wfcsettings.bin

* Slight cleanup
2023-09-18 21:09:11 +02:00
Jesse Talavera-Greenberg db963aa002
Make the NDS teardown more robust (#1798)
* Make cleanup a little more robust to mitigate undefined behavior

- Add some null checks before cleaning up the GPU3D renderer
- Make sure that all deleted objects are null
- Move cleanup logic out of an assert call
- Note that deleting a null pointer is a no-op, so there's no need to check for null beforehand
- Use RAII for GLCompositor instead of Init/DeInit methods

* Replace a DeInit call that I missed

* Make ARMJIT_Memory less likely to generate errors

- Set FastMem7/9Start to nullptr at the end
- Only close and unmap the file if it's initialized

* Make Renderer3D manage its resources with RAII

* Don't try to deallocate frontend resources that aren't loaded

* Make ARMJIT_Memory::DeInit more robust on the Switch

* Reset MemoryFile on Windows to INVALID_HANDLE_VALUE, not nullptr

- There is a difference

* Don't explicitly store a Valid state in GLCompositor or the 3D renderers

- Instead, create them with static methods while making the actual constructors private

* Make initialization of OpenGL resources fail if OpenGL isn't loaded

* assert that OpenGL is loaded instead of returning failure
2023-09-15 15:31:05 +02:00
RSDuck 1aaf22d181 fix last commit 2023-09-02 18:56:58 +02:00
jdp_ 2a3a071216
Reduce code stink (#1818)
CRC32.cpp:
Make table initialization compile time

DSi_NAND.cpp:
Fix file close / unmount / disk close on error
~L427: Remove redundant calls, as they are immediately rendered useless by `rem` being overwritten

NDS.cpp / FreeBIOS.h:
Remove unneeded size values in header
Remove unneeded memset's as they are initialized anyway

sha1.c / sha1.h:
Fix useless warning

Wifi.cpp:
Remove unneeded includes

DSi.cpp:
Reduce ugly casts
Deduplicate code

qt_sdl/main.cpp:
silence clang switch statement warning

qt_sdl/main.h:
fix override warnings

dolphin/BitSet.h:
use msvc extensions only when appropriate, fix broken bit set count under _WIN32
2023-08-28 20:01:15 +02:00
Tuffy b4aa7fafc9
Updated README.md (#1681)
inserted missing dependency in dynamic build instructions (qt5-tools)
2023-08-27 13:49:13 +02:00
xenticore b4756c5944
Update macOS icon (#1609)
* Add SVG icon

* Update macOS icon

* Don't force change the application icon at runtime on macOS
2023-08-27 13:37:42 +02:00
StraDaMa bc71618457
remove AR code size limit (#1802)
Co-authored-by: Arisotura <thetotalworm@gmail.com>
2023-08-27 13:34:11 +02:00
Jaklyy 2bd12669b2
Edge fill rules for swapped polygons + a few minor fixes to edge cases (#1815)
* fix edge fill rules for swapped polygons

also fixes translucent polygons not being always edge filled.

* fix right edge fill rule

* fix right edge fill rule for realsies

* fix a few more glitchy polygons

specifically quads similar to: (-67,40) (64, 160) (192, 160), (8, 111)

* fix one edge case pixel

i hate this so much

* fix "flat bottom" edge fill

* fix regression + apply changes to shadow masks

fix a regression with certain line polygons not rendering; there seems to be an exception made by the ds'  gpu in order for these polygons to render properly.
also apply these changes to shadow masks because i forgot to

* forgot to remove a line

---------

Co-authored-by: Arisotura <thetotalworm@gmail.com>
2023-08-27 13:32:31 +02:00
Mireille a571fe19c3
Make sprite mosaic (more) accurate (#1687)
* Make horizontal sprite mosaic (more) accurate

* Vertical sprite mosaic should not extend the sprite's bounding area

* Vertical sprite mosaic should not extend the sprite's bounding area (2)

* OBJIndex is no longer needed
2023-08-27 13:29:23 +02:00
Jaklyy d69745b3a8
Fix Incorrect Polygon Swapping Behavior and Implement Correct Rules for Shifting Right Edges Left (#1816)
* fix polygons being swapped incorrectly

"borrowed" this from noods
needs verification that the >= and <= signs aren't actually supposed to be > and <

* proper rules for moving vertical right slopes left

* nvm most of that was actually pointless

that's on me for not checking
2023-08-27 13:29:12 +02:00
Jaklyy dc8efb62b8
Fix aa being upside down on swapped y-major slopes (#1803)
* fix aa being upside down on swapped y-major slopes

* further improvements to swapped aa

in addition to fixing swapped y-major slope aa, now fixes:
swapped x-major slope aa
swapped vertical slope aa

* use templates instead + style/comment tweaks

should force the compiler to precompile if statements like i want it to do, instead of just hoping it does so on its own
2023-08-27 13:28:44 +02:00
Jaklyy d7369857c3
Small Fix to Anti-Aliasing + Edge Marking Behavior (#1680)
* Anti-Alias All Edges

Changing a bunch of 0x3s to 0xF since I figure if they're checking the left and right edge they wanna be checking the top and bottom too now that they're gonna be aa'd. also copy that if statement over since otherwise there won't be anything to blend with.

* small optimization

its probably a tiny bit faster?
idk id need actual benchmarking tools.
doesn't break anything at least.
2023-08-27 13:28:26 +02:00
Jaklyy 758b5ee7a1
fix aa calc for 1px tall 0px wide slopes (#1795) 2023-08-27 13:27:42 +02:00
Jesse Talavera-Greenberg ee55677086
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
2023-08-18 22:50:57 +02:00
Jaklyy f454eba3c3
check lower pixel when top pixel ignores fog (#1808) 2023-08-13 05:38:26 +02:00
Jaklyy 5f9e7e19f3
Improve Interpolation Accuracy (#1686)
* Fix Up Y Interp Inputs

* Change Linear Interp Formula

Fixes a handful of pixels.
Still not perfect.

* Cleanup

remove some unnecessary code and parentheses
2023-08-10 18:00:40 +02:00
RSDuck 7731f66e55 fix some UB 2023-08-01 03:00:41 +02:00
RSDuck 3efbf1b813 a bit of frontend refactoring 2023-07-29 21:27:28 +02:00
Arisotura 8fd46e5f8c wifi: attempt two at optimizing the sync mechanism. this time it should be far less prone to problems. 2023-07-28 10:14:33 +02:00
Arisotura 9c5cde8109 wifi: implement CMD retries 2023-07-27 21:54:30 +02:00
Arisotura c3943b29ec wifi:
* rework and clean up frame transfer code
* disable melonAP during local multiplayer comm
2023-07-27 21:11:30 +02:00
Arisotura b04c250e2f cancel CMD transfer if there isn't enough time left 2023-07-25 23:45:10 +02:00
Arisotura a87dc83279 wifi: mystery ack value is CMD_COUNT 2023-07-25 20:50:07 +02:00
Arisotura c7afa8d3f6 keep that one extra line in, tho
(remind me to rename these with the proper reg names)
2023-07-25 20:32:54 +02:00
Arisotura 193c7ed97b Revert "attempt at making local multiplayer faster"
This reverts commit 8772258fe7.
2023-07-25 20:32:01 +02:00
Nadia Holmquist Pedersen 75ae38ec7b codesign the final universal macOS app bundle
otherwise the code signature in it will be invalid, and macOS won't run
it witohout manually removing xattrs
2023-07-24 11:29:43 +02:00
Nadia Holmquist Pedersen e6cc4b14b0 Work around a strange bug in Qt5 that causes melonDS to crash on launch
...but only with LTO enabled
...but only on some UNIX systems
...but only with some additional build options except when it breaks
   without any as well
2023-07-16 15:49:51 +02:00
PoroCYon fbb41bd73d
DSi: add option to boot the full boot ROMs (#1581)
* DSi: add option to boot the full boot ROMs

added a config option for this so that this can be enabled or disabled

also added IO regs for DSi GPIO, but those don't do anything yet.

* reset GPIO regs on reset
2023-07-16 02:40:50 +02:00
Arisotura cf7375f9ea Merge branch 'master' of github.com:Arisotura/melonDS 2023-07-15 01:16:46 +02:00
Arisotura 8772258fe7 attempt at making local multiplayer faster 2023-07-15 01:16:31 +02:00
TGP17 24a4cacaae
Add AppImage Builds (#1670)
* Create build-appimage.yml

* Update build-appimage.yml

This Adds the new Dependencies for MelonDS
2023-07-14 22:40:35 +02:00