Commit Graph

2215 Commits

Author SHA1 Message Date
Adrian Siekierka c84cb17462
DSi_SD: implement command 17, 24 (#1877) 2023-11-26 20:07:31 +01:00
Jaklyy ad7b1a8c61
only fill edges when translucent if blending is enabled (#1882) 2023-11-25 18:40:07 +01:00
Jesse Talavera-Greenberg 346dd4006e
Move all core types into namespaces (#1886)
* Reorganize namespaces

- Most types are now moved into the `melonDS` namespace
- Only good chance to do this for a while, since a big refactor is next

* Fix the build
2023-11-25 18:32:09 +01:00
Jesse Talavera-Greenberg 651b0f680c
Use Platform::File calls in NDS::debug (#1888) 2023-11-24 19:17:22 +01:00
Rayyan Ansari 679c37ddce
Add support for saving animated icons
Add support for exporting animated DSi icons as GIF using the
header-only gif.h library.
2023-11-23 18:50:23 +00:00
Jesse Talavera-Greenberg 544fefa27f
Refactor the JIT to be object-oriented (#1879)
* Move TinyVector to a new file

- So it's less sensitive to #include ordering

* Forgot to include assert.h

* Refactor ARMJIT_Memory into an object

* Oops, forgot a declaration

* Refactor ARMJIT to be contained in an object

* Remove an unused function declaration

* Add a missing #include

* Remove a now-unused global

* Use ARMJIT_Memory's own memory access functions

* Fix some omissions in the ARM JIT

* Move libandroid to be a member of ARMJIT_Memory instead of a global

* Default-initialize most fields in ARMJIT_Compiler.h

* Define NOOP_IF_NO_JIT

* Finish refactoring the JIT to be object-oriented
2023-11-18 16:40:54 +01:00
Nadia Holmquist Pedersen f2d7a29015 fix forgotten <array> include 2023-11-15 17:26:01 +01:00
orbea e63e29ca91 DSi_Camera: fix gcc-14 build issue
melonDS/src/DSi_Camera.cpp:190:23: error: 'clamp' is not a member of 'std'
  190 |             r1 = std::clamp(r1, 0, 255); g1 = std::clamp(g1, 0, 255); b1 = std::clamp(b1, 0, 255);
      |                       ^~~~~
2023-11-11 19:53:00 +01:00
Jesse Talavera-Greenberg 4558be0d8e
Refactor the GPU to be object-oriented (#1873)
* Refactor GPU3D to be an object

- Who has two thumbs and is the sworn enemy of global state? This guy!

* Refactor GPU itself to be an object

- Wow, it's used in a lot of places
- Also introduce a new `Melon` namespace for a few classes
- I expect other classes will be moved into `Melon` over time

* Change signature of Renderer3D::SetRenderSettings

- Make it noexcept, and its argument const

* Remove some stray whitespace
2023-11-09 21:54:51 +01:00
Jesse Talavera-Greenberg 88072a02c5
Move NDSCart-related global state into objects (#1871)
* Move NDSCart-related global state into objects

- RAII will now do the heavy lifting
- Mark some methods as const or noexcept

* Move GBACart-related global state into objects (#1870)

- RAII will now do the heavy lifting
- Mark some methods as const or noexcept
- Once the `NDS` object is finalized, most of these `assert`s can go away

* Make AREngine::RunCheat public (#1872)

- I use it directly in melonDS DS to apply single cheats without using ARCodeFile
- Before the AREngine refactor I could just redeclare the function in my code
- Now I can't
2023-11-09 18:57:16 +01:00
Jesse Talavera-Greenberg 3d3e4240a0
Make AREngine::RunCheat public (#1872)
- I use it directly in melonDS DS to apply single cheats without using ARCodeFile
- Before the AREngine refactor I could just redeclare the function in my code
- Now I can't
2023-11-08 22:21:30 +01:00
Jesse Talavera-Greenberg 8b47178add
Move GBACart-related global state into objects (#1870)
- RAII will now do the heavy lifting
- Mark some methods as const or noexcept
- Once the `NDS` object is finalized, most of these `assert`s can go away
2023-11-08 22:21:21 +01:00
Jaklyy b4ff911fa3
Fix regression caused by change to front face polygon culling (#1820)
* fix regression with facing view

Only the check for a polygon being counter-clockwise is supposed to be <=

* only use dot < 0 for 'cull front face' polygons

this is the fix.
2023-11-07 21:22:25 +01:00
Nadia Holmquist Pedersen 24a33e505e Also exclude .note.GNU-stack section on Windows arm64 2023-11-07 10:53:01 +01:00
Rayyan Ansari 8fa9705079
ArchiveUtil: use signed return type instead of unsigned
The ExtractFileFromArchive function can sometimes return -1 on error,
however the function's return type was specified as u32, which would
mean that it would instead be represented as the maximum value.
Change the function's return type to the signed s32 instead, and
correct uses.
2023-11-06 21:27:09 +00:00
Rayyan Ansari 2b3bba512e
Fix some memory leaks
Free some objects that were allocated with new but not deleted, and in
one case, do not set a pointer to nullptr before deleting, as this
results in a memory leak due to memory allocated not being freed.
2023-11-06 20:25:32 +00:00
Rayyan Ansari 0e4d082361
ROMManager: initialise filedata to nullptr
If a user manages to open a file as a ROM that is greater than 1 GiB,
it will cause a segmentation fault (a crash) in LoadROM due to a delete
being called on an uninitialised pointer, which is undefined behaviour.

Initialise filedata to nullptr to prevent this, as deleting a null
pointer is defined as a no-op.
2023-11-05 20:21:16 +00:00
Rayyan Ansari df571078cf
CameraManager: wait for camera to be loaded
In QCamera in Qt 5, the camera is required to have been loaded before
querying its settings and resolutions. Doing so without loading being
finished would result in the returned list being empty.
See https://doc.qt.io/qt-5.15/qcamera.html#supportedViewfinderSettings

Add a QEventLoop that waits for the state to change from Loading to
Loaded before supportedViewfinderSettings() is called to ensure that
valid information is returned.

(Fixes my camera being blank in preview, same issue also presumed
to occur when camera is needed in game, fix tested on a USB camera on
a Linux system and Qt 5.)
2023-11-05 15:52:13 +00:00
Arisotura 0aff9471c5 fuck every aspect of this 2023-11-05 15:38:22 +01:00
Arisotura 11c22f077d convert DSP 2023-11-05 11:58:50 +01:00
Arisotura 54ebf1b1b2 convert DSi I2C and camera 2023-11-04 19:42:36 +01:00
Arisotura 7837c169a1 convert AES 2023-11-04 17:46:52 +01:00
Arisotura 8f1b0d4a05 convert AREngine 2023-11-04 17:28:16 +01:00
Arisotura 2bd09eafeb convert Wifi and WifiAP 2023-11-04 17:00:12 +01:00
Arisotura 76976fef30 convert SPU to OOP 2023-11-04 14:20:58 +01:00
Arisotura ac38faef14 update copyright years 2023-11-04 00:21:46 +01:00
Arisotura f188c2cf1a hopefully get the compiler to shut up 2023-11-03 21:33:13 +01:00
Arisotura e4f4e94694 convert RTC to OOP 2023-11-03 21:20:09 +01:00
Arisotura 440b356674 get this started: refactor SPI in OOP 2023-11-03 20:17:00 +01:00
Arisotura 70c6750561 better, less hacky, more OOP-friendly scheduler design 2023-11-02 21:04:09 +01:00
Arisotura 5ccd3916ff better be safe than sorry 2023-11-02 15:46:35 +01:00
Arisotura 2959d089fe fix weird hang when returning to the DSi menu 2023-11-02 15:31:26 +01:00
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