Commit graph

215 commits

Author SHA1 Message Date
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
Michel Heily 7e98af80c2 Fixes to ALU, passing mGBA carry tests
Former-commit-id: 14a4293b2511c7c63a920e6344e89b209ca7c5ee
2019-11-16 18:17:53 +02:00
Michel Heily 88b908f2a0 Implemenet GBA Halt control
Former-commit-id: 1b09cb881b4e68f410abe6e1f6a161cd55a4626a
2019-11-12 18:55:26 +02:00
Michel Heily dcab1e6328 Improve GPU state machine.
This fixes the glitch in dma_demo.gba where the rendering of the circle
was off by a scanline.


Former-commit-id: 907fefd548b6557ce46e06a99d0bc6ab83a8f332
2019-11-12 18:22:00 +02:00
Michel Heily 2978fde0dc Add tasks.json
Former-commit-id: 602d0564b1fe77ff58c4ee00e22d0a7b2c2fab19
2019-11-12 18:22:00 +02:00
Michel Heily 1d088accb8 mGBA test suite now boots!
Fix tons of bug and reimplemented some of the core code.
Add a neat feature for debug builds:
When the cpu "swi 0x55" instruction, a breakpoint is triggered on the
host.


Former-commit-id: 959249df4374327d90b2503d7a45f8d5d27995a6
2019-11-12 18:22:00 +02:00
Michel Heily c117cbe924 Make the debugger work again, but currently breakpoints are not supported.
Added memory write command and the ability to pause the debugger with Ctrl-C


Former-commit-id: 83d141fa191dadefb84f7c9de163631a69af8324
2019-11-12 18:22:00 +02:00
Michel Heily bfee970592 Update Cargo.lock
Former-commit-id: 91eeaeccafc9eee20aee6b103176b4ee9d42c742
2019-11-09 19:44:55 +02:00
Michel Heily f898de8ddc Update launch.json for cppvsdbg
Former-commit-id: 6fc91daa80dd77bcefb82880217b4b1d85bfcdb5
2019-11-09 19:44:55 +02:00
Michel Heily c78a111ad4 Implement DMA, WIP
I have fought very hard against the rust ownership model,
In the end for DMA to play nice with my code, I had to resort to use
unsafe code for now..

The DMA implementation itself is not accurate to say the least, but will
have to do for now.

Tonc's dma_demo.gba plays but with a visual glitch.


Former-commit-id: 3b9cdcb2d09c78701290f2c48b77f9f3487e85c9
2019-11-09 19:44:55 +02:00
Michel Heily 3a1d5c10ce Fix many bugs, refactor many things..
Passing: Armwrestler, cpu_test by Dead_Body

Former-commit-id: 80d815d110c5341515dd01c476a0d7e25ecb66a8
2019-11-09 01:06:24 +02:00
Michel Heily 2bd8b56bc6 Fix that DAMN bug.
Long story short, I've been hunting this bug for a while now.
While passing armwresteler tests, I still had an emulation bug which
causeed libgcc's iprintf to produce bugged strings.

In order to find it, I've used https://github.com/fleroviux/NanoboyAdvance/
And patched it to produce a formatted log of every step of the execution
of iprintf:
{OPCODE} {PC} {R0} {R1} ... {R14} {FLAGS}
Did the same on my emulator and searched for differences.

Found out the a "CMP r3, #0x0" instruction turned off the carry flag
when it shouldn't. Found this sad function, the check I'm using for
carry flag is meaningless when done on signed integers. :sigh:


Former-commit-id: 871d2581921796dae9bf4f5fdaa45c6ad46aebec
2019-11-06 00:49:59 +02:00
Michel Heily 7cc1a50d12 Support zip files and add --no-framerate-limit
Former-commit-id: 62a7122fb0b3e832eeb3cbf347a0966e4cd32d50
2019-09-11 21:26:40 +03:00
Michel Heily fa211fa77e Fix thumb NEG instruction. Finally pass armwrestler!
This one took me quite a bit. :/


Former-commit-id: f08537dda5a62076c3faff31a898c0a585102526
2019-09-10 01:01:49 +03:00