Commit graph

583 commits

Author SHA1 Message Date
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
sapir 8dee829e26 Avoid repeated background index sort
Former-commit-id: 5c7aab3a416cc1cfd9cbd6033457b111fe409d98
Former-commit-id: 0594872c527f57bfd77d0afd9635eed3b88f9be8
2020-10-10 11:08:26 -07:00
sapir 9d08ac13e6 Move backdrop color read out of compose_pixel
Former-commit-id: 20d5d8a35b5e7fa0ca46bea297b1b554ba98948d
Former-commit-id: f50dbe6b529fef91f5cf5a0a808d93b878f2adff
2020-10-10 11:08:26 -07:00
Michel Heily 529c9752c4 fix: Ignore top 4 bits of DMA addresses
Former-commit-id: 3a5e691ca617803ef61f7a534c70d1cf04f36cb9
Former-commit-id: 289fad7340cbb18c51ecccd43e44682b37c78a1a
2020-10-03 21:58:32 +03:00
Michel Heily 1ab22f2b52 Fix access violation for DebugRead in Gpu
Former-commit-id: 25d2da276a50f662dafb4634c7b3fb4ebcf239f4
Former-commit-id: 4134896128ef3c7ddd8bbd2804d8d1edc46c7a6c
2020-10-03 21:58:32 +03:00
Michel Heily 91c3b5321a platform/android: Add menu options to capture a screenshot as the library preview image
Former-commit-id: 59d0858d93cb2681bb3e4230c44858a2fe28f208
Former-commit-id: 41b094d2f7971c3ef9e53234bd0c65e56ef99e20
2020-10-01 01:56:32 +03:00
Michel Heily d1bf01d562 platform/android: Add option to import/export save files
Also some typos and reformatting parts of the code


Former-commit-id: 0f1de44fab44a09c49d08421a3c2032123d3023b
Former-commit-id: 810b6b1bce1f7feeee7c33bec5ff16915367db17
2020-10-01 01:56:32 +03:00
Michel Heily 3c6628138c platform: Minor fixes and adjustments from previous commit
Former-commit-id: b8e8f73c8202f93e4bb2a575ee3d1b3083ddabb1
Former-commit-id: 355c634b4da8fbea1d228da8fc95e37012237bbd
2020-09-30 00:47:30 +03:00
Michel Heily ba2eff82ac platform/android: Big re-write of native interface
Mainly convert mainloop and audio thread into native code for
performance increase. (Calling into JNI every frame was costy)

The code was cleaned up quite a bit, but I may have introduced new bugs
in this process :<


Former-commit-id: fdbc21b5ab39f3d2e36647fd1177dc9a84a16980
Former-commit-id: ac765dbee8c994e1b69cc694846511837c2685b9
2020-09-30 00:27:00 +03:00
Michel Heily 08a7cd966a core: add "no_video_interface" feature
Former-commit-id: 0b1462e3ef1ab65c37e2c0fce54bc7f5c2f9f2b5
Former-commit-id: 7b837be4dcb477b048f0118c4ab30f97eb445363
2020-09-30 00:10:47 +03:00
Michel Heily e25268f4d8 core: bump ringbuf to 0.2.2
Former-commit-id: a39789277cbc62b55ac4896a1dcee0a08eaa91c5
Former-commit-id: d9c94a5f42a11e59c816c1d756c5a2ea4e4dcad7
2020-09-30 00:09:54 +03:00
Michel Heily 554edd62b0 core: Properly set SharedInterruptFlags pointer for all interrupt generating devices when restoring state.
Serde doesn't like Rc that much :(

Fixes #142


Former-commit-id: e1e8a96b4867e351d103fb7d92d71b0434e8fc31
Former-commit-id: 28366bbb36b3e93b574f397b103a483844fd8131
2020-09-27 15:44:17 +03:00
Tibor Nagy 4050dcdf2f core: Add error handling to cartridge header parsing
Former-commit-id: 4e65ccd597bc082f259788f0870287254e852a2f
Former-commit-id: ebb62516936dc0f27dc9761aeb6bb6faa8ec58b5
2020-05-30 15:35:12 +03:00
Michel Heily 1b1b855702 core/gpu: Impl bitmap mode 5 and properly handle wraparound for bitmap modes.
resolves #90


Former-commit-id: 633580870e2d44d95a8b53b6311232f0fad48bd9
Former-commit-id: aa2ba32116900f635f12f9dcc9d29344367711eb
2020-05-30 14:32:03 +03:00
Michel Heily 90e492d81a core/sysbus: Get rid of memory_map! macro
While saving code re-use, it won't allow flexibility for special casing
specific size bus accesses which are much needed in order to emulate
open-bus and bios reads


Former-commit-id: 952a30a130612d61b3f5047b1f1c3cbda9bd58a8
Former-commit-id: ad3a25c012853399591d79f4f1a4423ea9e6645e
2020-05-30 13:44:37 +03:00
Michel Heily 24f6ad61c1 Add DebugRead trait
Former-commit-id: 4c9339dc0f2057152dcb6faccd78f058bc58676f
Former-commit-id: 7bf052ace6b5b12eca3c74f64f4d61d4ae6ac18e
2020-05-30 13:44:27 +03:00
Michel Heily b888fc0c95 Move BoxedMemory to core::util
Former-commit-id: 99a04859982f39f0062c781d9f61b2a55f8e5c10
Former-commit-id: 1ae7808c64116347410b52770edf132f3beec817
2020-05-30 13:44:00 +03:00
Michel Heily 6e39780b43 util: Add WeakPointer helper for passing around raw pointers
Former-commit-id: eaab1057cf7bf8132ba7b59f6c5315e873064c30
Former-commit-id: 94f947733463b528dd3775d2bc6f55adebc36a2d
2020-05-30 13:43:49 +03:00
Michel Heily 879374a9b0 Refactor dir rustboyadvance-core -> core
Former-commit-id: 5af970f6d56d321472f2b91885e41ca113390986
Former-commit-id: 748e222a36362eb5ac8909068c32f2d3f98ca536
2020-05-30 13:43:37 +03:00
Michel Heily f65e22cc41 core/gpu: Fix bitmap mode displaying invalid sprites
fixes #107


Former-commit-id: 4b307c80f0519a5034dad1188d285cb44a2c8eeb
Former-commit-id: 8879aababad1aef0690adb0a88cdeb36368c024a
2020-05-30 13:41:10 +03:00
Michel Heily dc59d7f71f core/gpu: Optimize VRAM accesses all over the place
Former-commit-id: a14fc75968c5ce6016acc88fe2cc24eaac8b305b
Former-commit-id: 41f3142ea586c981cd5ccc7eb5a69f49bdcc591d
2020-05-30 13:13:25 +03:00
Michel Heily 71074c9c87 core/gpu: Implement forced blanking
fixes #102


Former-commit-id: 8d0557a63121eab20f7299d75c4c7e577d5f5612
Former-commit-id: 668c728b5ebd6103bf9d15115cb3912ea8c6f4b6
2020-05-26 18:06:02 +03:00
Michel Heily 441f5ad906 Refactor IRQ signaling
Use Rc<Cell> instead of passing `&mut irqs` all around.

The runtime impact is two additional size_t's per each holder of the
shared pointer.


Former-commit-id: afd3188c31608ebcf062256a7ad51575dbc90d8b
Former-commit-id: 22e0e01953968cee592b5408677e557059669c31
2020-05-26 01:49:25 +03:00
Michel Heily 63cbf9bccf chore: Update Cargo.lock
Former-commit-id: 4cf345e1f2ea09577889552a6644cb53b5900e25
Former-commit-id: b460b1f567643cc85fef0bfe815abb842c2dc0f0
2020-05-26 01:49:16 +03:00