Commit graph

556 commits

Author SHA1 Message Date
Michel Heily 626c5fa805 core: arm7tdmi: Fix new bug in LDR/STR introduced in b603904.
Of course only arm-wrestler caught it while mgba suite/eggvance did not :(


Former-commit-id: a5dcaa9b40c8a5a5d5fb1e531a601361869a041f
Former-commit-id: eb8d30a3c1cf9c39425b29e6d8386ac2b68a424b
2021-06-09 02:01:47 +03:00
Michel Heily 97704f2621 core: debugger: Fix traces
Former-commit-id: fbdaef86e2164ad1eeb5267041070958c024ceda
Former-commit-id: 643bcfe7ebccf77297d2371715490b3005e91d92
2021-06-09 02:01:42 +03:00
Michel Heily ff472db249 core: debugger: Use mut references for GameBoyAdvance
Former-commit-id: e1490c0777537e7d8eee4e9d1fbb53f8c957fdc7
Former-commit-id: f6be5b7940c4f3d517fa564830be607321ade534
2021-06-09 01:24:31 +03:00
Michel Heily f140e0f83b core: Fix broken debugger build
Former-commit-id: 0dcdb6d758e463eecc02faf5a0e7eff6c8c08899
Former-commit-id: 5e9d842158d573b10dc1ddb4c3621056282351ed
2021-06-09 01:08:42 +03:00
Michel Heily 2ec52fb722 sdl2: Add silent mode
Former-commit-id: b8e3a8809501f32f819b74a1e4dd094d77a4b367
Former-commit-id: 027be1f05ae9f274e6a3527d209ac5ff696d8c56
2021-06-09 00:54:09 +03:00
Michel Heily 67c071595a Add Dockerfile for android targets
Former-commit-id: 97d399e200cef304b1d76b099d7449b4a8f33a0b
Former-commit-id: 842c1a99e6ac83f4caf90560167b8ddb57c8c93d
2021-06-05 20:27:27 +03:00
Michel Heily 20506091cc [perf] arm: Improve performance with barrel shifter.
Instead of using a struct member to hold the last barrel shifter carry output, which is expansive as it needs to be saved/loaded from memory, I now pass the carry around as an INOUT parameter.
Using perf anotate really shows high perctile of samples being spent on reading/writing `self.bs_carry_out`

Since this is a rather "surgical" changeset, I have made sure to run it against eggvance test suite, mGBA test suite and some games as well.

I actually saw better improvements than what the benchmark measured, but 7% is decent enough :)

```
run_60_frames           time:   [180.18 ms 180.45 ms 180.77 ms]
                        change: [-7.2464% -6.9081% -6.6324%] (p = 0.00 < 0.05)
                        Performance has improved.
```


Former-commit-id: 7cd7105a07aa0b78cab9dc8bbae3682b02b7ab7c
Former-commit-id: c68514beb3fa6c34f5f65544acbead21e527dbb0
2021-06-05 18:54:46 +03:00
Michel Heily caf89d8532 Update tasks.json
Former-commit-id: 3dc52edc74606c31c80e2e1ffd0d5fbc74d47123
Former-commit-id: 982303e2a48fe5f7ea64d85bf480ce3df77d54bc
2021-06-05 18:45:05 +03:00
Michel Heily a51a0d4962 Build with debuginfo
Former-commit-id: 3fc245a05643baf60f10d08350baf9e72762d992
Former-commit-id: 14002ce5c901b926258677ed1062ded4f47e5920
2021-06-05 18:44:46 +03:00
Michel Heily 21708a3d58 [perf] sysbus: Improve add_cycls()
Fulfill TODO from long ago, I used perf-record (--call-graph dwarf)  and detected that add_cycles() was hot enough,
I added 2 optimizations:
- Removed bound checks from array accesses
- Increase the LUT size to include dummy entries for open-bus to eliminate the if check

run_60_frames           time:   [183.65 ms 183.69 ms 183.73 ms]
                        change: [-9.4414% -9.2849% -9.1315%] (p = 0.00 < 0.05)
                        Performance has improved.


Former-commit-id: 1cbb596b856e604ad6c48eb0d47771e7cee44d1e
Former-commit-id: 9f15e35237f343d0c816fd9d51d81081736d9e17
2021-06-05 17:31:10 +03:00
Michel Heily cb2b97e0c7 [perf] core: arm7tdmi: Re-arange some fields inside of CPU
Also, clean up some of the cfg(debug) mess

benchmark report:

run_60_frames           time:   [110.61 ms 111.01 ms 111.42 ms]
                        change: [-7.1171% -6.5425% -5.9132%] (p = 0.00 < 0.05)
                        Performance has improved.


Former-commit-id: 9cb82e483c8a78632d0deae20adca9fc1843a76b
Former-commit-id: 6d9be5ddaf72f2b9c02063fa067f2ffbaea4fdb6
2020-11-24 00:54:18 +02:00
Michel Heily 586a5bf16c core: arm7tdmi: Refactor display->disass.
Also, move core::disass into core::arm7tdmi::disass


Former-commit-id: 82f60cb814d6cf23e62565e34b61f8771e704525
Former-commit-id: 345ddaac674c78e77e62f106d7c0deda857fe5ed
2020-11-24 00:45:07 +02:00
Michel Heily 28a57a874a core: dma: Reduce logs
Former-commit-id: 6db019b583e195fcb6aedb134cf54482a6c72428
Former-commit-id: 9294c305aafac1d55f18f1bd5d2fb5c62db509c5
2020-11-06 06:26:00 -08:00
Michel Heily 7e2c9d040a [perf] core: gpu: Refactor to use unpacked mmio configuration during rendering
* Convert gpu bitfield!() registers to unpacked form, and defer pack/unpack to bus read/write operations


Former-commit-id: 26e7d7d62d6418ce7bcdb8e414cabe5ddb56333d
Former-commit-id: 716ddd9fe2b7b95b7613fc549a7bee406272478b
2020-11-06 06:26:00 -08:00
Michel Heily a413ebe891 [perf] core: arm7tdmi: inline arm7tdmi::Core::step function
run_60_frames           time:   [158.26 ms 160.84 ms 163.03 ms]
                        change: [-24.960% -18.808% -12.975%] (p = 0.00 < 0.05)
                        Performance has improved.

Wasn't expecting such an improvment tbh, but who am I to argue with results


Former-commit-id: a5ba74bffa26d962a232c0767a34a7d67ed8ccb4
Former-commit-id: 1b9b301ba9012e79e66822ac39af51df28c51fa4
2020-11-05 15:40:39 -08:00
Michel Heily 05b1ff10e3 [perf] core: gpu: optimize & clean finalize_scanline
Performance benchmark report improvement:
run_60_frames           time:   [176.85 ms 184.70 ms 191.47 ms]
                        change: [-11.727% -7.6991% -4.2923%] (p = 0.00 < 0.05)
                        Performance has improved.


Former-commit-id: ec91f286433c6798a848fa9727a12da38e62fc61
Former-commit-id: 8d0feea1e0d6b8230c71872bb4458aeec2f7d0e7
2020-11-05 15:40:39 -08:00
Michel Heily 22f544718a core: Add performance benchmark
Former-commit-id: 0fcda8fb5b8a506e22f74d0ef186a38708ed4def
Former-commit-id: fd390604a7e01d9a67ffa0a70c5e9863f65fc9f8
2020-11-05 15:40:39 -08:00
Michel Heily ebd58261ba core: sound: Use correct variable when logging new sample rates
Former-commit-id: 6f5ff96dae03b2be061bcf06a6d701fda7ca15cb
Former-commit-id: 2934a02dfd36de2e794e8861df8f5035daab3165
2020-11-05 02:37:28 +02:00
Michel Heily aaf1a71a9d android: Fix takePersistableUriPermission() error on Android 10
Used wrong Intent ACTION


Former-commit-id: 6a46248d5f9b977558b85ef4bab1939a5a08a9b3
Former-commit-id: dd086c794870474d8e4e49341bc868baae5c1696
2020-10-27 02:06:23 +02:00
Michel Heily efb1cdb4b6 core: Fix 8bit accesses to mgba log
Former-commit-id: 780e6b58b265ad5d586fe605f143e6c9d8b26c63
Former-commit-id: 5d2514c9a45d2f5c698272c9324575d7bddec4ac
2020-10-24 09:35:03 -07:00
Michel Heily fb32b9a671 core: Implement mGBA log support.
It's quite an handy way to log messages from ROMs, so I thought it'd be nice to add it.


Former-commit-id: 6869bdb58cfa883ac1ca6832f0bbeeab0edcf552
Former-commit-id: 89d7d826c7a906bbb68f9f4305bb92cd50bb2296
2020-10-24 05:59:48 -07:00
Michel Heily b28fc3108f Bump arrayvec to 0.5.2
Former-commit-id: c6fd55768ba8e1640bb46d35c76f7ccf8643bfe0
Former-commit-id: 28de793611b50a9f6fc2933d6d92543a92cc2cb1
2020-10-24 05:59:48 -07:00
Michel Heily 40e306349c core: arm7tdmi: Force address alignment in memory accesses
Fixes #148


Former-commit-id: 36f33c599cd9a3c51115bf20037bfdce9f581912
Former-commit-id: 24130ddb51ae3dff2c576289b74a8cbd7519593f
2020-10-23 01:31:58 +03:00
Michel Heily aeecd98757 core: Fix debug read of OAM memory
Former-commit-id: 49c79b74146b89197f2f3bc8ac58f26abb230146
Former-commit-id: acda49ed0fffc481fe4b77fee1ef99b7038215df
2020-10-22 23:59:19 +03:00
Michel Heily 27e530896e JNI/Android - Fix stupid copy-pasta bug
Former-commit-id: 72dafdfd370a56f6b311798f5b61037e5f9bdf11
Former-commit-id: 3c79536294f80f550f87c47e0a0e4280d5c4275a
2020-10-20 02:10:38 +03:00
Michel Heily 8f4b98b8e4 ci: Use ./gradelew assemble instead of build
I don't want to handle these lints right now


Former-commit-id: 0d7d4707346b0e47fb9de46dc774b9c02f7f4a95
Former-commit-id: 001a62161e1b4592fc9f6846fad3f1fdcfe4b750
2020-10-20 02:03:42 +03:00
Michel Heily 1c7f2359f3 ci: Add cargo cache steps to android apk build
Former-commit-id: 20e5f49e3e591de733e012edf9481ea7e9c93a39
Former-commit-id: 9134e6ccfedd969ea7d81bd7064d9c94b12ec421
2020-10-20 02:02:58 +03:00
Michel Heily 764adc4c69 android: chmod+x ./gradlew
Former-commit-id: b16df501eadeae7c27460b174d03adf5db8851b7
Former-commit-id: eac97645b01b35dfd6164d0c4050ec68dcdf5988
2020-10-20 01:59:00 +03:00
Michel Heily 4d3c8c6952 android: Set targetSdkVersion to 26
Former-commit-id: 647d36a6c84561063475819d1dad2c58a731d1c0
Former-commit-id: b3dcb6a1d72f0f1634e23e2b08e9d1d8c74d9790
2020-10-19 15:54:54 -07:00
Michel Heily 1eddea8a91 Build android APK from CI
Former-commit-id: fda1b7d5b1b6176fe1b599b2f22a51f9f6b78ab0
Former-commit-id: 6365f924aefda080e64354539f8cff3f47d38088
2020-10-19 15:54:54 -07:00
Michel Heily 4ea8d9ccba Adapt android build to new from_saved_sate changes
Former-commit-id: b6b225be3a9dd654c8f375b9f521950fa898969c
Former-commit-id: 3ec1e3134579e4c3204acd14e4e8a37adbc2d686
2020-10-19 15:54:54 -07:00
Michel Heily 6b8f4e8f51 core: Implement open bus (Reading from unused memory)
Former-commit-id: f0223556894a02ad1f85bb81abc18d47b7508445
Former-commit-id: e44b952867197467fa724022a05ba4579b1e2f03
2020-10-18 09:41:35 -07:00
Michel Heily 8afb443354 core: dma; Calculate address adjustment once
Former-commit-id: 4f988e337a809e21fdec936d504dbfa399b6c496
Former-commit-id: e46f9a6791ff162cad0b5d11f33c035620637514
2020-10-18 08:33:37 -07:00
Michel Heily fc7ad01cc0 Forgot to restore scheduler pointers when restoring savestate :)
Former-commit-id: c6968e6767f0aa996a908a1444ce63bafd8b427d
Former-commit-id: ce636212835f50745c7edeb32e1fed925850b7c8
2020-10-18 08:32:44 -07:00
Michel Heily b003dc950f core: Implement bios read protection when CPU is not executing from bios.
Fixes #109
Fixes #106
Fixes MegaMan email menu freezing and probably some more games


Former-commit-id: ed37520f2bc732b07334261dfe3d23cccf3fc04c
Former-commit-id: d7f206b0f405ffe09a3b36d90268f1d683a64cea
2020-10-18 06:59:06 -07:00
Michel Heily 1ca261e5c7 core: Get rid of that BoxedMemory nonsense
Just directly impl Bus trait for Box<[u8]>


Former-commit-id: 7b8a29972520afb7ff197708b9c2146b293a5f29
Former-commit-id: 0c528165ed899fad14b1e25995fdfe8ae004da2a
2020-10-17 16:58:52 -07:00
Michel Heily 130a7608e7 [WIP] Gamepak unused addresses
Former-commit-id: 7946d38faf49fc0f95aab8654611b94aae443949
Former-commit-id: b3654fd4750d472a20fe5db9de0019d774a4ee61
2020-10-17 06:53:28 -07:00
Michel Heily e14c5996d4 core: cartridge: Don't error when the checksum is invalid.
A lot of test ROMs i'm using don't bother to calculate the checksum :\


Former-commit-id: da02a70271c34bc26e560ea18b3f5052ee171a65
Former-commit-id: 332d917e47b268ae649574844d14cab2da65197d
2020-10-17 06:52:45 -07:00
Michel Heily a3546cbe07 Run cargo-fmt
Former-commit-id: b0a8fe8948fe8affe3377acf0c72af8d78717789
Former-commit-id: fee6919ea7cf16c5bf6e1bd21b993770cc08998f
2020-10-17 06:36:02 -07:00
Michel Heily 44c9e2c875 core: dma: Count cycles passed in DMA transfers
Former-commit-id: 751f2e42f9c5c19f2fcc901754950d1e3797303b
Former-commit-id: 30d31be99daec4324532d4663390945a55f641b1
2020-10-17 06:36:02 -07:00
Michel Heily b6e2d55550 Everyday I'm ~~shuffeling~~ refactoring.
Some big refactors:
* improve scheduler performance by using a BinaryHeap
* refactor the scheduler API
* arm7tdmi
	* Change struct arm7tdmi::Core struct layout so frequently accesses fields would benefit from CPU cache
	* Simplify and cleanup cycle counting by implementing a MemoryInterface trait
	* Still not passing many cycle accuracy tests, but I believe it's because I don't have the prefetch buffer yet.
* Timer overflows are now scheduled
	* This fixes #111 and fixes #112
*


Former-commit-id: 17989e841a1ea88c2a7e14f4c99b31790a43c023
Former-commit-id: 109d98d824a464de347f6590a6ffe9af86b4b4ea
2020-10-17 06:36:02 -07:00
Michel Heily 85db28dac6 core: debuggger: load symbols from elf files
Former-commit-id: 3b20be6ecff9d540f7ba0c76d9762f87fac81998
Former-commit-id: 8b08fb90c5c163479c8318dd01f1f92fab475efc
2020-10-17 06:36:02 -07:00
Michel Heily 3fa858f969 core: bus: Change read_x methods of Bus trait to take &mut self
Former-commit-id: ee95b949585420e1daf95ea50939b1a8c9b77349
Former-commit-id: 651203037284fc46eb669cd0e40dc2ebd85bd96b
2020-10-17 06:36:02 -07:00
Michel Heily 85bef5a1c0 Update Cargo.lock
Former-commit-id: 97f7ebf59c7eb2c9846d6d029f0ffcc288aea9ad
Former-commit-id: 14d6b235bb4b12964a04750a418641e05d020c86
2020-10-17 06:36:02 -07:00
Michel Heily bce4456f42 [breaking-change] Remove game ROM and bios from savestate file.
This breaks the API of GameBoyAdvanvce::save_state and restore_state methods.
Currently as WIP only SDL2 frontend will adjust.


Former-commit-id: 1df15c8697fef0f6adddb07a6d653947c622ba12
Former-commit-id: 2ea339dc6a0d1e7539d167c4df29694b408303da
2020-10-17 06:36:02 -07:00
Michel Heily 97101d7bc1 core: dma: Delay DMA by 3 cycles
Former-commit-id: 06426b01a3e9e9084c97cd8f3a3de3b3c2b207e6
Former-commit-id: 2dee7bc2a2a3a3e69c7afa878f2d03208f330752
2020-10-17 06:36:02 -07:00
Michel Heily 0de8a60006 core: Start working on a scheduler
A more robust cycle aware event scheduling, to easily implement serial-io, dmg audio channels and improve accuracy.
This brings a slight performance hit :/

I also ran dos2unix on some of the files :D


Former-commit-id: 62f4ba33e3a083b7976d6512ba6f5720ec493aa0
Former-commit-id: a4b3a92cd1eb156bbe9fd0ef77fbb0e7a45660cb
2020-10-17 06:36:02 -07:00
Michel Heily b68c73819a Fix cfg_if dependency
Former-commit-id: 5b9f830edcda0fad9321a26f74a5e85ec1b7b104
Former-commit-id: dd77520fae5c74c92921779a20870da38b607924
2020-10-14 21:11:00 +03:00
Michel Heily dc7cd24e8d [perf] Refactor&Optimize inner core::arm7tdmi APIs.
Avoid passing ArmInstruction struct to handlers, as accesses to its fields can result in memory operations.


Former-commit-id: 6ea1719e36a0fefa1b30bdae4d6e8ab4dbf3af1a
Former-commit-id: e5855b8258f98d3f4c0819f3aec2fd0f47fef545
2020-10-10 11:08:26 -07:00
Michel Heily bf601404fa Optimize cartridge Bus reads
The `if let Some(gpio) = &self.gpio` causes a memory read of `self.gpio` for every Bus::read/write_16.
It is better to reverse the order since `is_gpio_access` does not generate and memory reads and thus less costly.


Former-commit-id: bcce7d9c3a2b159a7f6b291d7b08ccf9c4d0db14
Former-commit-id: 69c12db503c9e612faa7cd8a57f6d862694c8370
2020-10-10 11:08:26 -07:00