Commit graph

436 commits

Author SHA1 Message Date
Michel Heily 8f11bebd2b fix/performance/accuracy: Reimplement sysbus stall cycle counting.
Previously I did not account for gamepak 32-bit accesses being two 16bit (NSEQ+SEQ or SEQ+SEQ) accesses,
This resulted in less cycles being accounted for, resulting in more wasted CPU cycles per frame and was a huge performance hit.

I re-implemented this with look-up-tables also to speed up the cycle
count routing `SysBus::get_cycles` and also account for 32bit gamepak memory access.


Former-commit-id: fe6a9a570c843d40e38971a2a36e6511df1b8894
2020-04-04 13:55:40 +03:00
Michel Heily c4c8163b0e optimize/timers: Get rid of the while loop in Timer::update.
Profiling with 'perf' I discovered that too much time was spent inside
Timer::update when the prescalar was 0 (frequency of 1 cycle).
This was due to the while loop I used. I optimized this loop out and
there is an appearent performance increase.

Former-commit-id: d228450625fad003f054e3161f6eeee888245cac
2020-04-04 13:43:57 +03:00
Michel Heily f0aa671674 optimize/cpu: Pass Arm/Thumb Instruction and other large structs as references.
Also, get rid of unnecessary derive Copy.

Since the ArmInstruction (and Thumb) derived from Copy, the compiler
always saves them to the stack when they are passed by value to other
functions, thus making some unwanted performance overhead.

I removed the derive Copy, and also pass them as references. This
project has a lot of "derive Copy" everywhere, and I should take note if
this is happenning elsewhere aswell.


Former-commit-id: 2f94c6050fa26c5b777244bd26706d4e6e2f0dc9
2020-03-28 16:14:59 +03:00
Michel Heily 2af9249a6c optimize/arm: Force inlining.
This functions were not inlined by the optimizer


Former-commit-id: aa02a3f5e6d33f16c298bc655c8d3a244c2ef946
2020-03-28 16:14:59 +03:00
Michel Heily d9ce1c7d8d optimize/arm: Improve arm instruction condition check.
Obviously AL(always) instructions are the most common, so prioritize checking these first.


Former-commit-id: e236f1e116dbf65757a68dda9090645d220a1cee
2020-03-28 16:14:59 +03:00
Michel Heily 414c1b0557 optimize/gpu: Optimize read_pixel_index calls inside render loops.
Former-commit-id: 763b24a151ddd3dcb69afacabcb214b26ad03052
2020-03-28 16:14:59 +03:00
Michel Heily 699b2decd2 core/gpu/bugfix: Support firing HBlank IRQs during VBlank
This commit fixes #43


Former-commit-id: 6a4367282c673a35316643e16413f9a602094d9d
2020-03-13 16:29:12 +02:00
Michel Heily 7f34e8bd08 core/gpu/bugfix: Use correct bitmask when writing to DISPSTAT
Accidently used 5 (0b0101) instead of 7 (0b0111)


Former-commit-id: f690dd3f591bef10c5dd280d46be22cd339498a2
2020-03-13 16:29:12 +02:00
Michel Heily aa0f708302 chore: Update Cargo.lock
Former-commit-id: 4f4fae3b12ab027a34cc5080dd041d5e09ce3e64
2020-02-28 15:11:02 +02:00
Michel Heily 6344744414 feat/jni: More work on JNI bindings
Former-commit-id: 125f764bd17ee9add3221cd6b64cde6edb592255
2020-02-28 15:11:02 +02:00
Michel Heily 84db854a06 chore: Make GameBoyAdvance the the bios argument as boxed slice rather then a Vec
On windows, the Vec may sit on the stack..


Former-commit-id: b8aa77858291c1b7ee6bfbfbec92646f18e819de
2020-02-28 15:11:02 +02:00
Michel Heily c4e8c71d1f sysbus: Make BoxedMemory a transparent struct
Former-commit-id: fc07876e9f73928eb2aaa6fcd4cba081a35745b9
2020-02-28 15:11:02 +02:00
Michel Heily c5b9c68d5e feat/jni: Cleanup & Improve jni bindings
- Wrap static globals with a mutex.
- Implement InputInterface

Testing this on a standalone Java Console Application (without
rendering) shows sufficiant performanse for now (AVG fps of 180 in the bios)


Former-commit-id: cfbb9abb7e91b04258c41fc20e8a22c16d797386
2020-02-28 15:11:02 +02:00
Michel Heily c68b9502fe bugfix: Fix bad write impl of DISPSTAT again.
I should really pay more attention to the docs..
The previous fix (bb843ea5) was not enough as it caused vblank,hblank
and vcount-match flags to be overwritten when they really should have
just been ignored.

This caused Dragon Ball - Advance Adevnture to fail booting


Former-commit-id: 1810e32692a0abd79f2df385c7c822debf186c79
2020-02-28 15:05:06 +02:00
Michel Heily d938767430 feat/jni: Add rustboyadvance-jni crate to export some simple JNI bindings
Former-commit-id: d4e7a622a97215a8c1b7b50bb7f08d18cb9c5716
2020-02-23 00:30:38 +02:00
Michel Heily 778274b5ae refactor: split "plat" binaries into separate crates
Former-commit-id: 73554b0128e036279f7ac895acb57d8f89cb1c96
2020-02-23 00:30:38 +02:00
Michel Heily c50ab1ecd8 feat: Add basic gdbserver feature
Initially I began implementing the gdb protocol on my own, but I then found a
nice work-in-progress crate on https://github.com/daniel5151/gdbstub
that suited my needs.


Former-commit-id: f77557cbbd8652c2ed05ac439efc1956d8e99729
2020-02-21 22:12:58 +02:00
Michel Heily 96cacb5f4c chore: Update .travis.yml
Former-commit-id: c529a4740c8d81e09a7a65648d9d2d77905e1146
2020-02-21 22:07:06 +02:00
Michel Heily b333ae7f65 rustfmt
Former-commit-id: a73535e556d1fb44e30927f0ab1f6238a8df8739
2020-02-21 14:08:08 +02:00
Michel Heily 0476342278 bugfix: Fix a bug where sprites were not rendered in bitmap modes.
I misunderstood the docs ^^


Former-commit-id: 157ae0dec037be3718b7a28314ba3b2eeb85cca0
2020-02-19 01:39:47 +02:00
Michel Heily a585753dc2 fix: Allow writes to DirectSound FIFOs in 8bit granularity
This fixes audio in games that directly write to sound FIFO using STRB instructions.


Former-commit-id: 3efb686b28146c414d5fad289f958346a9a5db6e
2020-02-18 22:29:54 +02:00
MishMish 1a382b4cee Update README.md
Former-commit-id: e1ff263d66abf91ebedc7863148b9203466f424d
2020-02-17 23:57:51 +02:00
Michel Heily c96fa38a2d bugfix: Fix improper write to DISPSTAT register
For some reason, probably typing mistkae, I `or`ed the value being written to DISPSTAT,
causing bits to never actually turn off, affectivly making HBLANK/VBLANK
interrupts linger forever.

This probably has caused some nasty glitches that I don't even know of, but two confirm issues solved
by this are Mariokart and Pacman.

This commit fixes #14 and #13


Former-commit-id: 72ad6efcb9e8f6b582d9279c5daab2603d5a408e
2020-02-16 01:46:51 +02:00
Michel Heily 392ad1bd71 gpu: Refactor Gpu::bg to Gpu::background
Former-commit-id: 78aa4ad525ba9df0a4944dfac0c5723e35633390
2020-02-16 01:40:59 +02:00
Michel Heily aeab3a82a3 Return to rust stable, get rid of nightly features for now
Former-commit-id: 1550bc0f70218c8a012f0631502eabbdf835d0ab
2020-02-14 14:33:22 +02:00
Michel Heily 11fb9d7eda Fix panic when fs::create_dir fails for LOG_DIR when it already exists
Former-commit-id: a332a8aadc8322650beaf9ff7eead4ac162c6eec
2020-02-14 14:26:45 +02:00
Michel Heily b03fe3567e Fix all warnings during build
Ran cargo-fix to automatically fix most of the build warnings,
Cleaned up dead code, and fix the rest manually


Former-commit-id: f35faba46b40eaf9c047efb8ab1e77ffa24d41b6
2020-02-14 14:21:45 +02:00
Michel Heily 0c2da2ae46 refactor: Refactor instruction decoding to panic instead of returning a Result
flamegraph shows too much time is being spent 'unwraping' decoded
instructions


Former-commit-id: e89072e6cf648e83f87d8c01891f50474246a36b
2020-02-14 13:05:14 +02:00
Michel Heily 69aadb9d92 Fix broken tests due to recent arm7tdmi changes
Former-commit-id: e1a5ec4ce3cb4c61bf6f511babfa8da8efd7321f
2020-02-14 13:02:56 +02:00
Michel Heily 84004ddb5c windows: Add file icon to build targets
Former-commit-id: 2dae2e7818d86ddf9470afafd0404f0e7e021718
2020-02-12 22:18:58 +02:00
Michel Heily 32a20d2cbb ptimize: CPU Pipeline optimization part 3
Move reload_pipeline calls inside instructions.
This commit yeilds yet another 5% performance improvment.

The next step is to move `advance_pc` into the instructions themselves
and save the `match result` per executed instruction


Former-commit-id: 42193ffc48fda9943665e6a74e873186627a0b4a
2020-02-11 02:26:17 +02:00
Michel Heily 6beec306c2 optimize: CPU Pipeline optimization part 2
Optimize redundent pipeline stages
About 5% performance gain.

Also rustfmt..


Former-commit-id: 2f5fc95798e97eb963fea976866bbeaf637084b0
2020-02-11 02:26:17 +02:00
Michel Heily 1f79205f51 optimize: CPU Pipeline optimization part 1
In preperation for later optimization in the CPU pipeline
implementation, this commit refactors the arm/thumb exec functions to return a
CpuAction (Whether to advance the program counter or to flush the
pipeline)

Currently, a lot of host cycles are wasted in the arm7tdmi pipeline
Refill1 & Refill2 states. Optimizing these steps out would make the CPU
a bit faster.


Former-commit-id: 9be7966eaad22cceeb443fcc5823bbd945284027
2020-02-11 02:26:17 +02:00
Michel Heily 7736154b50 fix: Use flush_pipeline16 when branch exchange changes CPU to thumb mode
Former-commit-id: 6f9c01c6f7ad7be2889a18ca66f7d310fcaa7c35
2020-02-11 02:26:17 +02:00
Michel Heily c7a484fda5 Move creation of arm7tdmi core into the GameBoyAdvance
Former-commit-id: d4a43df2ea3d737cc8284b84cea0285c8818ef32
2020-02-11 02:26:17 +02:00
Michel Heily 1a46bec3f9 feat: Fix & improve debugger, Add commands to save/load the state
Former-commit-id: cfbead1ad64c8b029bf7265f7fd975014744b287
2020-02-11 02:26:17 +02:00
Michel Heily ae7bf63d3f arm7tdmi/optimize: Optimize and cleanup CPU, roughly about 10% fps improvement.
This commit removes the error handling (CpuResult<>) in order to reduce
overhead in the cpu implementation.
Also, some cleanup of warning messages.

Notice: this commit breaks '--feature debugger' for now

Former-commit-id: d4484047c3f5d509eff89cef7090aa88b07a8d17
2020-02-09 20:17:46 +02:00
Michel Heily 48eb2a4104 Bump gba-suite git submodule
Notice: This change breaks master due to failing the added tests

Former-commit-id: e3fde1c37e85a5e1e88e9fa82b1152ef1bce4493
2020-02-07 17:36:32 +02:00
Michel Heily 984cb2f0c4 chore: rust-fmt
Former-commit-id: 8bb31056864e64bcad6877f3c2c1000464cce82e
2020-02-07 17:16:52 +02:00
Michel Heily 374c429d16 optimization: Avoid bound checking twice in Cartridge::read_8
Former-commit-id: fb9db936f7d7a89b467c3c3dfd290c43b5324da6
2020-02-07 17:13:05 +02:00
dependabot-preview[bot] 3a488e4487 build(deps): bump ansi_term from 0.11.0 to 0.12.1
Bumps [ansi_term](https://github.com/ogham/rust-ansi-term) from 0.11.0 to 0.12.1.
- [Release notes](https://github.com/ogham/rust-ansi-term/releases)
- [Commits](https://github.com/ogham/rust-ansi-term/compare/v0.11.0...v0.12.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Former-commit-id: 702534f36b62f34f48c13c64e0db1d195206c215
2020-02-07 17:10:21 +02:00
dependabot-preview[bot] 66d7f0f7f2 build(deps): bump zip from 0.5.3 to 0.5.4
Bumps [zip](https://github.com/mvdnes/zip-rs) from 0.5.3 to 0.5.4.
- [Release notes](https://github.com/mvdnes/zip-rs/releases)
- [Commits](https://github.com/mvdnes/zip-rs/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Former-commit-id: 2c546f001f0e53ab6936f382ba9a9a40698337dd
2020-02-07 17:10:14 +02:00
dependabot-preview[bot] 9b06928e2e build(deps): bump flexi_logger from 0.14.6 to 0.14.8
Bumps [flexi_logger](https://github.com/emabee/flexi_logger) from 0.14.6 to 0.14.8.
- [Release notes](https://github.com/emabee/flexi_logger/releases)
- [Changelog](https://github.com/emabee/flexi_logger/blob/master/CHANGELOG.md)
- [Commits](https://github.com/emabee/flexi_logger/commits)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Former-commit-id: 638bc4021e6feabbb9f944aabb731175486609b6
2020-02-07 17:05:20 +02:00
dependabot-preview[bot] 6c879136f1 build(deps): bump colored from 1.8.0 to 1.9.2
Bumps [colored](https://github.com/mackwic/colored) from 1.8.0 to 1.9.2.
- [Release notes](https://github.com/mackwic/colored/releases)
- [Changelog](https://github.com/mackwic/colored/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mackwic/colored/compare/v1.8.0...v1.9.2)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Former-commit-id: 1b24d07dd253bedd15df2eba727118cbb01ef44b
2020-02-07 17:05:13 +02:00
dependabot-preview[bot] afa22aaa38 build(deps): bump byteorder from 1.3.2 to 1.3.4
Bumps [byteorder](https://github.com/BurntSushi/byteorder) from 1.3.2 to 1.3.4.
- [Release notes](https://github.com/BurntSushi/byteorder/releases)
- [Changelog](https://github.com/BurntSushi/byteorder/blob/master/CHANGELOG.md)
- [Commits](https://github.com/BurntSushi/byteorder/compare/1.3.2...1.3.4)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Former-commit-id: 28acac0def9bbb220bae601d2c397ff26ee04f28
2020-02-07 17:05:00 +02:00
dependabot-preview[bot] 194b9a0b2a build(deps): bump time from 0.1.42 to 0.2.6
Bumps [time](https://github.com/time-rs/time) from 0.1.42 to 0.2.6.
- [Release notes](https://github.com/time-rs/time/releases)
- [Commits](https://github.com/time-rs/time/commits/v0.2.6)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Former-commit-id: 9a9533684df743a5441be6ed0d0cd40633189c6b
2020-02-07 17:02:24 +02:00
dependabot-preview[bot] 9d383fa2c5 build(deps): bump num from 0.2.0 to 0.2.1
Bumps [num](https://github.com/rust-num/num) from 0.2.0 to 0.2.1.
- [Release notes](https://github.com/rust-num/num/releases)
- [Changelog](https://github.com/rust-num/num/blob/master/RELEASES.md)
- [Commits](https://github.com/rust-num/num/compare/num-0.2.0...num-0.2.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Former-commit-id: ba192b84e744980c2edb3969f94b25fc0974a1bb
2020-02-07 17:01:55 +02:00
dependabot-preview[bot] 26f016182b build(deps): bump bitflags from 1.1.0 to 1.2.1
Bumps [bitflags](https://github.com/bitflags/bitflags) from 1.1.0 to 1.2.1.
- [Release notes](https://github.com/bitflags/bitflags/releases)
- [Changelog](https://github.com/bitflags/bitflags/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bitflags/bitflags/compare/1.1.0...1.2.1)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Former-commit-id: 741a46a69dddb03d423776d760c933dab4076426
2020-02-07 17:01:35 +02:00
dependabot-preview[bot] 2a9f2270da build(deps): bump rustyline from 5.0.6 to 6.0.0
Bumps [rustyline](https://github.com/kkawakam/rustyline) from 5.0.6 to 6.0.0.
- [Release notes](https://github.com/kkawakam/rustyline/releases)
- [Commits](https://github.com/kkawakam/rustyline/compare/v5.0.6...v6.0.0)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Former-commit-id: 138a28066ed7d421ac4d6cf54b5710f45bc02c4b
2020-02-07 16:59:55 +02:00
dependabot-preview[bot] 23e0d1dfa7 build(deps): bump num-traits from 0.2.8 to 0.2.11
Bumps [num-traits](https://github.com/rust-num/num-traits) from 0.2.8 to 0.2.11.
- [Release notes](https://github.com/rust-num/num-traits/releases)
- [Changelog](https://github.com/rust-num/num-traits/blob/master/RELEASES.md)
- [Commits](https://github.com/rust-num/num-traits/compare/num-traits-0.2.8...num-traits-0.2.11)

Signed-off-by: dependabot-preview[bot] <support@dependabot.com>
Former-commit-id: de2d638031688498136038e7776edc34cd60169e
2020-02-07 16:59:39 +02:00