Commit Graph

30 Commits

Author SHA1 Message Date
Arisotura
8fc403cdad update copyright headers 2024-06-15 17:01:19 +02:00
Jesse Talavera
8143f54956
Protect savestates while the threaded software renderer is running (#1864)
* First crack at ensuring the render thread doesn't touch GPU state while it's being serialized

* Get rid of the semaphore wait

* Add some extra fields into GPU3D's serialization

* Oops, TempVertexBuffer is already serialized

* Move vertex serialization into its own method

* Lock the GPU3D state when rendering on the render thread or serializing it

* Revert "Lock the GPU3D state when rendering on the render thread or serializing it"

This reverts commit 2f49a551c1.

* Add comments that describe the synchronization within GPU3D_Soft

- I need to understand it before I can solve my actual problem
- Now I do

* Revert "Revert "Lock the GPU3D state when rendering on the render thread or serializing it""

This reverts commit 1977566a6d.

* Let's try locking the GPU3D state throughout NDS::RunFrame

- Just to see what happens

* Slim down the lock's scope

* Narrow the lock's scope some more

* Remove the lock entirely

* Try protecting the GPU3D state with just a mutex

- I'll clean this up once I know it works

* Remove a duplicate method definition

* Add a missing `noexcept` specifier

* Remove an unused function

* Cut some non-hardware state from `GPU3D`'s savestate

* Assume that the next frame after loading a savestate won't be identical

* Actually, it _is_ worth it

* Don't serialize the clip matrix

- It's recalculated anyway

* Serialize `RenderPolygonRAM` as an array of indexes

* Clean up some comments

- I liked the dialogue style, but oh well

* Try restarting the render thread instead of using the lock

- Let's see what happens

* Put the lock back

* Fix some polygon and vertex indexes being saved incorrectly

- Taking the difference between two pointers results in the number of elements, not the number of bytes

* Remove `SoftRenderer::StateBusy` since it turns out we don't need it

- The real synchronization was the friends we made along the way
2024-01-07 23:39:43 +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
Arisotura
ac38faef14 update copyright years 2023-11-04 00:21:46 +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
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
391ad8c95e
Implement in-memory savestates (#1693)
* Refactor Savestate::Var{8,16,32,64}

- They now delegate to VarArray
- They're declared in the class header so they're likely to be inlined

* First crack at refactoring Savestate to work in-memory

- Well, third, but who's counting?

* Implement Savestate::Finish

* Remove the VersionMajor and VersionMinor fields

- Instead, pull their values directly from the savestate buffer

* Mark a new constructor as explicit

* Rename Reset to Rewind

* Fix a linebreak

* Implement Savestate::Rewind

* Add ROMManager::ClearBackupState

* Refactor ROMManager to use the refactored Savestate

* Capitalize "Least"

- It was driving me nuts

* Add a log call

* Increase default Savestate buffer length to 32MB

* Use C-style file I/O instead of C++-style

- Dumping bytes to a file with C++'s standard library is a MONSTROUS PAIN IN THE ASS

* Quote the savestate's file path for clarity

* Write the savestate's length into the header

* Add some extra logging calls

* Fix section-loading

* Remove the deprecated Savestate constructor

* Convert a char* to a u32 with memcpy, not a cast

* Fix section-handling in loads

* Include <cstring> in Savestate.h

- This was causing a build error on Linux
2023-06-12 23:56:09 +02:00
RSDuck
4b170b94d5 pointless micro optimisations 2023-04-28 17:05:34 +02:00
patata
35f4e504f1
Increase savestate major version (#1567) 2023-01-19 15:11:42 +01:00
Arisotura
35cc79787d update copyright headers 2022-01-09 02:15:50 +01:00
Arisotura
e665e25bd3
Custom path support (#1333)
also including:
* getting rid of shitty strings
* all new, cleaner ROM handling code
* base for DSi savestates
* GBA slot addons (for now, memory cart)
2022-01-07 14:00:43 +01:00
Arisotura
9514efe4a0 BAHAHAHAHAHAHAAAAA-+*~+ 2021-09-02 00:16:36 +02:00
Arisotura
1846a71265
Cart refactor (#1073)
complete cart-interface refactor, will make this code a lot easier to deal with
2021-04-25 00:48:02 +02:00
RSDuck
436b3c4c1d update copyright year and add missing GPL headers 2021-03-12 20:07:40 +01:00
SuuperW
d42ca1ec4b
Implement "lag frame" flag and counter (#949)
* Implement "lag frame" flag and counter, and expose flag and both frame counters. BizHawk wants these.

* Track frame count and lag frames while the system isn't running.
2021-01-21 21:26:27 +01:00
RSDuck
51b2671aa9 add cur vertex and light information to savestate 2020-12-09 19:18:42 +01:00
RSDuck
9772201345 remove some UB
- savestates used to read a four bytes from a single byte value
- a few unassigned variables
- some other things
- also make the ROR macro an inline function
2020-09-04 20:37:14 +02:00
Arisotura
33b4cdb077 GPU3D: implement zero-dot W limit (DISP_1DOT_DEPTH) 2020-04-12 14:01:43 +02:00
Arisotura
5f99a68151 detect whether we are running the game 2020-02-24 18:31:44 +01:00
Arisotura
83f8e11bc1 update copyright years 2020-02-14 20:18:08 +01:00
Arisotura
27f758d353 hack so that the GL renderer can render lines 2019-06-12 03:55:40 +02:00
Cameron Cawley
f91eb18152 Fix all -Wwrite-strings warnings 2019-05-04 14:07:02 +01:00
Arisotura
b0efde8bf7 also, update copyright name 2019-01-22 15:58:29 +01:00
StapleButter
669247e8c8 redesign main emu loop to use timestamps instead of being a trainwreck
* cleaner code
* faster in some cases
* more accurate (on-demand compensation for timers and GPU)
* less prone to desyncs
* overall betterer
2019-01-05 05:28:58 +01:00
StapleButter
3101bd595f add missing shit to savestates. bump the version up. 2018-12-11 21:50:28 +01:00
StapleButter
b1973014d3 add some missing shit to savestates 2018-11-25 22:40:08 +01:00
StapleButter
a9e7f8bc5b add proper support for GXFIFO stalls.
bad games that blast the GXFIFO and overflow it:
* Super Mario 64 DS
* Rayman RR2

latter seems to get its music streaming crapoed.
2018-11-23 22:21:41 +01:00
StapleButter
fa4fa164cb * store all 32 matrix stack entries in savestates instead of 31.
* bump savestate version up. will break compatibility, but the alternative would be guessing the missing matrix entries somehow, so blarg.
* avoid relocating the savefile if loading a savestate fails.
2018-11-05 16:14:48 +01:00
StapleButter
fea7955675 fixor copyright years. 2018-09-15 02:32:13 +02:00
StapleButter
aa59ee257e base for savestate crapo.
I'm not quite settled yet, so before I can get into the real meat, I figured I'd address some 'popular request' items.
2018-09-15 02:04:21 +02:00