Commit graph

528 commits

Author SHA1 Message Date
Michel Heily 3687161b98 Make the debugger into an optional build option.
This module is written purely and always breaks when changes are being
made into the 'core' module, so as long as I don't use it, I don't feel
like maintaining it.


Former-commit-id: f5b18ba54a27d22e8a195dd0912ec9c8f29fa830
2019-12-29 23:44:34 +02:00
Michel Heily b00fbfb38c gpu: refactor: Big refactor preparations
1) Decouple SysBus from Gpu
2) Split Gpu rendering function into separate modules
3) Cleanup


Former-commit-id: 0435ad1c9c1de72ed50769fabfea7c5f33b670e0
2019-12-29 23:44:34 +02:00
Michel Heily 885bce2aa4 gpu: refactor: Give the Gpu a handle to the video device.
Use it to render to the screen instead of doing it in the outer Gba


Former-commit-id: ea1ed5f4d7b00d1542ce1130f96ccb1bdb87cb3e
2019-12-29 21:32:53 +02:00
Michel Heily 118beeb4b7 gpu: refactor: Move Rgb15 to its own module
Former-commit-id: d83748802435594573255171ae888efd6f406ad3
2019-12-29 21:32:53 +02:00
Michel Heily 615515fcea gpu: bugfix: Fix objects with priority 3 not being rendered
This was apparent in Dragon Ball Z - Legacy of Goku II, where the save
point sprites were not rendered at all.


Former-commit-id: 156356ebe2f2a4879602019a1fe2c18fe2b8a395
2019-12-28 21:14:21 +02:00
Michel Heily b22388252b gpu: Cleanup #1
Former-commit-id: a40fca25eae76afb4d581d8da1404a5d52c9efab
2019-12-28 21:13:44 +02:00
Michel Heily b13c3026c8 gpu: Refactor Gpu::current_scanline -> Gpu::vcount
Former-commit-id: fe17235bd7e953195e6348e4670bf0520a78270a
2019-12-28 20:25:27 +02:00
Michel Heily cc4f328691 timers: Fix wrong irq number
Timers were triggering DMA interrupts, wonder why.. ><


Former-commit-id: 4fd2781a4bf71d0c0ebc1badae003d76a781ee75
2019-12-28 17:03:59 +02:00
Michel Heily d8545dd8cd sdl2: Use callbacks with ring buffer instead of audio queue.
Better latencies, and also fast-forward (aka Turbo mode) sounds normal
this way.


Former-commit-id: d1075087e847c765a871157a7973c897575ef4d7
2019-12-28 17:03:59 +02:00
Michel Heily cb54f4d1a3 cosmetic: Notify vblank/hblank DMA inside of Gpu
Former-commit-id: de53e1ed3e2c1df19ef878c4b84893b92ee46064
2019-12-27 16:31:18 +02:00
Michel Heily 445835eac8 Update Cargo.lock
Former-commit-id: e88adeb5cdf40bf3a4fe1e19b22af590518de180
2019-12-27 16:30:09 +02:00
Michel Heily 5acd7ddd71 Solve the sound clicking issue in Kirby!
The symptom of the problem was in the form of a rythmic click sound popping in the left channel.

Diving deep into Kirby's binary, I found out that channel B and channel
A are playing too different pcm buffers simultationsly: A is enabled for
the right channel and B is enabled for the left.

I found out that the game's sound driver was using VCOUNT in order to syncornize the audio,
but in some occassions the fifo DMA was not disabled in time, causing the DMA to
fill the fifo in additional 16 bytes of garbage residing next to channel
B's pcmBuffer.

After a thorough check-up of the GPU state machine, I find out that I
stay in VBLANK for 1 line too long, and that's what caused the audio
buffer to de-sync with the gpu emulation.

This commit fixes this issue.


Former-commit-id: e0f20bd01b8abf62da486e2501cff197a9a22763
2019-12-27 15:28:06 +02:00
Michel Heily a01e3ed9cd Make sdl2 run as default for "cargo run"
Former-commit-id: 11c411582fa10e8391d1a9ce528e876b3da7cb22
2019-12-27 13:12:03 +02:00
Michel Heily c9e80f4f60 Remove dead code
Former-commit-id: 5d5768ca6b73060197d9bacda61cba4c03804ad0
2019-12-27 12:41:36 +02:00
Michel Heily c2ac3c5a10 Improve DMA code
Former-commit-id: 8fdb6195ceb323aebd8a26da98fe286d89ef8363
2019-12-27 12:37:32 +02:00
Michel Heily b026ad4ed3 Add simple resampling using cosine interpolation, seems to work~ish.
Still have clicks & delays in my audio output.


Former-commit-id: 46707fc773d8083fbba1ec614e3e0a3e53866b98
2019-12-23 01:37:45 +02:00
Michel Heily ac9a17713b Fix address alignment bug in IoDevices::write_8
Former-commit-id: b89d469e9f2d11f21df3af2b4299cf9928abbd59
2019-12-23 01:37:45 +02:00
Michel Heily 10d0934f82 GameBoyAdvance: Use dyn traits instead of generic types
"Performance hit" is not significient


Former-commit-id: 809dea4cdbf9579d8e9d18de95b3c9a05723c68f
2019-12-23 01:37:45 +02:00
Michel Heily 398e66b723 More work. DMA sound seems to work, but sounds very crappy.
Former-commit-id: cc9f2877f9ccc1b05163af3fd35ff07efa8e3067
2019-12-23 01:37:45 +02:00
Michel Heily fefeddbc40 Continue working on DMA sound.
Cleanup timer.rs
run cargo fmt
restore debugging continue&frame commands
Fix bug introduced in previous commit causing the bios animation to
hang


Former-commit-id: 188acaa1121503a97f2d3be816f6f57835e17fe1
2019-12-23 01:37:45 +02:00
Michel Heily 70cb99161d Start working on DMA sound
Former-commit-id: 066210a86a7836b6ae1dfd5ce229d050cbe00ca4
2019-12-23 01:37:45 +02:00
Michel Heily 38e504515b rba-sdl2: Trying spin_sleep crate
Former-commit-id: 1c6a36a1a61be3949080a8c86915235aaf25d0e5
2019-12-20 19:02:33 +02:00
Michel Heily 31eb12cb6a Add "press SPACE to turbo" to sdl2 binary, like in old-school emulators :P
Former-commit-id: 95dfddfac193ac846f179ec607a8f7c3fc0e21a4
2019-12-20 18:11:14 +02:00
Michel Heily cb630ffb8e Optimise SDL2 rendering code
Former-commit-id: 4a0e4f57a97c98bc8a930901bd1ba2125d96138b
2019-12-20 17:48:24 +02:00
Michel Heily 3c7a734270 Add minifb based binary, currently it has better performance than the SDL2.
SDL2 rendering is really bottlenecking currently..


Former-commit-id: 8e04b799f248209a138990b2389e740b0d1d9f0f
2019-12-20 16:31:26 +02:00
Michel Heily 385016f24a Use Rc<RefCell<T>> to have the GameboyAdvance struct hold references to platform video,audio,input combo
Former-commit-id: bfe233a333790fe1bad1038bd553a3fe244e57fa
2019-12-20 15:11:26 +02:00
Michel Heily aee86d85c8 Start Sdl2AudioPlayer
Former-commit-id: 905b846d751db577bc213f1ca38a4c0e72558cfa
2019-12-20 15:11:26 +02:00
Michel Heily 04d2edfc01 Refactor "backend" concept
See plat/sdl2


Former-commit-id: 5f7c9625467003d5b73307959095eb5365db523e
2019-12-20 15:11:26 +02:00
Michel Heily 326bb06e82 Move rom file loading logic to Cartridge
Former-commit-id: 29045310d380657819529333b5231a98be5fa8c1
2019-12-20 15:11:26 +02:00
Yonatan Goldschmidt 763ee217d8 Add WIP sound controller and backend
Former-commit-id: 50e5bb71a620ac138a880872ae1f13f1c0c0604c
2019-12-20 15:11:26 +02:00
Yonatan Goldschmidt 7cfa4bb07d Remove some unused imports
Former-commit-id: 64bd0e7419cd374f6321fcc3bd9fdee7a241592b
2019-12-20 15:11:26 +02:00
Yonatan Goldschmidt 60c77869df Add cpal extern crate
I really hope all these additions to Cargo.lock are actually its deps...


Former-commit-id: 7c85f330ea3c27f8ebae7020dc4a46d7d557affd
2019-12-20 15:11:26 +02:00
Yonatan Goldschmidt 41deb1631c Print read/writes to unhandled sound registers
Former-commit-id: f63a98b61866c872ef52dd972db3ef28054be432
2019-12-20 15:11:26 +02:00
Michel Heily 29df4231e9 Protect unused bits from being set in window flags
Former-commit-id: a618b4775de7276618dd11ace2e140d200fb066b
2019-12-20 15:07:23 +02:00
Michel Heily cb36db688e Fix LSR#0
Former-commit-id: 7cfcc0b8f6e0849c9090148f2cc381b3419abd39
2019-12-20 15:06:21 +02:00
Michel Heily 11219dab7e tmpfix: Reset scanline in scanline_aff_bg placeholder
Former-commit-id: a4f910210bfa186611d771202a4ef96e97fe75b7
2019-11-21 17:46:51 +02:00
Michel Heily 42904782f7 Fix bios infinite loop caused by changes in f5a8ca8de8a5b007ace879f50fb97ead3e976347 [formerly e885e9ff1393dd14f5e4132c71a7641d658399cb]
This commit removed the dummy iomem buffer, and the bios busy waits on
REG_SOUNDBIAS in order to proceed.


Former-commit-id: 1fb8e2b621bed22da55781adcaae748aaaf845b9
2019-11-21 17:36:58 +02:00
Michel Heily 9856f04e05 Implement affine sprites. Displaying TONC affine sprites demos correctly.
Former-commit-id: 6f8aaec9cb844a685a1b07f7d09a0535039133b8
2019-11-20 06:25:38 +02:00
Michel Heily 64a877369d Reorganize sprite rendering code
This commit contains changes I forgot to push way earlier.


Former-commit-id: 793bfc2bde25f2299136e6b196f2770ee1db8d19
2019-11-20 05:33:51 +02:00
Michel Heily bb08b2f48e Improve timers
Former-commit-id: 02985b13aec6ac4ce52952b9bc505e48ebbb94e6
2019-11-20 05:20:46 +02:00
Michel Heily 3c3129c73c Minor fixes
Fix LSR integer underflow.
Change SWI LR calculation


Former-commit-id: 6a298719e380c3a01f70c3b05d9f3507638398d5
2019-11-20 05:04:54 +02:00
Michel Heily 3c3e8c35b4 Fix wrong sprite size calculation
This solve many graphical glitches with normal sprites in:

- Kirby - Nightmare in Dreamland
- DragonBall Advanced Adventure
- DragonBall Supersonic Warriors


Former-commit-id: aa7813720ca86c0ff0a3111f245d35765112d750
2019-11-16 20:18:28 +02:00
Michel Heily 49ef59b8e9 fixup! Improve the debugger
Former-commit-id: 9ca33bd4f8273a6be66cec6a8218664a7aada376
2019-11-16 18:48:24 +02:00
Michel Heily 4c3862543e Fix bug in MODE0 where BG3 would not be rendered due to inconclusive range, thank you Rust.
Former-commit-id: 6dd8ce110d212083cba394f08488d4fffdf6d015
2019-11-16 18:17:53 +02:00
Michel Heily 46931a1f6a Fix CPU bugs, KIRBY BOOTS!
- Bad LSR emulation caused an edge-case making allmost all of the game I tested fail to boot past intro.
- Incorrect sign extension of offset5 in THUMB caused bad address calculation.

Kirby boots with rendering glitches, I played past the first 2 boses
without crashes.


Former-commit-id: 8ea0ad6eb0f70e6dc23d1f2fcc44c8c0b3448fba
2019-11-16 18:17:53 +02:00
Michel Heily ccfff31123 Improve DMA
According to GBATEK:
The SAD, DAD, and CNT_L registers are holding the initial start
addresses, and initial length. The hardware does NOT change the content
of these registers during or after the transfer.

The actual transfer takes place by using internal pointer/counter
registers. The initial values are copied into internal regs under the
following circumstances:

Upon DMA Enable (Bit 15) changing from 0 to 1: Reloads SAD, DAD, CNT_L.

Upon Repeat: Reloads CNT_L, and optionally DAD (Increment+Reload).


Former-commit-id: 1e606dc88603a4600a79a341ef17fe8ccb482871
2019-11-16 18:17:53 +02:00
Michel Heily 4f2fbc2af2 More memory map bug fixes (Wrong ROM masks and more)
Former-commit-id: 4149a16965d111fb95629e8381269eae4f84c0c4
2019-11-16 18:17:53 +02:00
Michel Heily f7dc417e94 Fix accesses outside of IO region
Former-commit-id: dc874b6d28370cf7256156f2502bd2dc56a0a3fd
2019-11-16 18:17:53 +02:00
Michel Heily b9d0857acc Don't allow IRQs when pipeline is reloading
Former-commit-id: a51d3671dfabab422f2ad880b3cbe1bac65d442b
2019-11-16 18:17:53 +02:00
Michel Heily b288625b9a Improve the debugger
- Add tracing of opcodes and potentially more stuff
- Add option to run a script file at the beginnig (I use it to redirect
traces to a file)
- Support breakpoints again


Former-commit-id: 4e988d6bc1a59456c96547f0320a6d9abedcae00
2019-11-16 18:17:53 +02:00