Commit Graph

450 Commits

Author SHA1 Message Date
Rekai Nyangadzayi Musuka 55dada243e chore: add debug keybinds for scheduler capacity + event count 2022-10-21 05:12:45 -03:00
Rekai Nyangadzayi Musuka 78e7c0bc3f perf: don't check scheduler every iteration of runFrame loop
~20fps gain in Pokemon Emerald, nice
2022-10-21 05:12:45 -03:00
Rekai Nyangadzayi Musuka 9134456229 chore: simplify 4bpp palette code 2022-10-21 05:12:45 -03:00
Rekai Nyangadzayi Musuka 0ef71ecb49 perf: convert BGR555 to RGBA8888 at compile-time, access w/ lookup table
Compile speed isn't slowed down by that much + there's a ~20fps gain in
Pokemon emerald, though this isn't anything exact
2022-10-21 05:12:45 -03:00
Rekai Nyangadzayi Musuka 3d18685d36 chore: modify type signature of util.sext 2022-10-21 05:12:45 -03:00
Rekai Nyangadzayi Musuka f194bee4eb chore: cleanup main 2022-10-21 05:12:44 -03:00
Rekai Nyangadzayi Musuka f373d8e17c chore: emu audio sync code to emu.zig 2022-10-21 05:12:44 -03:00
Rekai Nyangadzayi Musuka 1b7d15e7d2 chore: redo apu sampling 2022-10-21 05:12:44 -03:00
Rekai Nyangadzayi Musuka 89d8c08cd1 chore: implement apu u16 reads 2022-10-21 05:12:44 -03:00
Rekai Nyangadzayi Musuka 3cd02a44cf fix: clean up frequency timer implementations 2022-10-21 05:12:44 -03:00
Rekai Nyangadzayi Musuka 87eb0cc808 Revert "fix: resolve off-by-one errors when scheduling freq timer expirations"
This reverts commit c9b0030b4b.
2022-10-21 05:12:43 -03:00
Rekai Nyangadzayi Musuka 8313210ddc fix: resolve off-by-one errors when scheduling freq timer expirations 2022-10-21 05:12:43 -03:00
Rekai Nyangadzayi Musuka 2664f5cf20 chore: improve APU accuracy + scheduler refactoring 2022-10-21 05:12:43 -03:00
Rekai Nyangadzayi Musuka 29ee225c1f feat: stub Affine BG registers 2022-10-21 05:12:43 -03:00
Rekai Nyangadzayi Musuka ff6d2517be fix: resolve out-of-bounds error with 8bpp tall / horizontal sprites
Boot ROM is now enabled by default as well
2022-10-21 05:12:43 -03:00
Rekai Nyangadzayi Musuka 242bf08cf2 chore: improve audio accuracy 2022-10-21 05:12:42 -03:00
Rekai Nyangadzayi Musuka 996de65688 chore: reintroduce thread sleeping + simplify fps counter 2022-10-21 05:12:42 -03:00
Rekai Nyangadzayi Musuka b97b66927f feat: implement double buffering 2022-10-21 05:12:42 -03:00
Rekai Nyangadzayi Musuka 628d4cfb68 chore: clean up DMA code 2022-10-21 05:12:42 -03:00
Rekai Nyangadzayi Musuka ff002f18c6 feat: handle DMA IRQs (maybe?) 2022-10-21 05:12:42 -03:00
Rekai Nyangadzayi Musuka 5d5d3827fb chore: contain Timers in a tuple rather than a struct 2022-10-21 05:12:42 -03:00
Rekai Nyangadzayi Musuka 8826242bf3 chore: contain DMA Controllers in a tuple rather than a struct 2022-10-21 05:12:41 -03:00
Rekai Nyangadzayi Musuka 570ff8536c chore: resolve incorrect memory mirror in VRAM
+ stub GPIO registers on ROM Write
2022-10-21 05:12:41 -03:00
Rekai Nyangadzayi Musuka 2c0d2b64a2 chore: stub a few I/O registers 2022-10-21 05:12:41 -03:00
Rekai Nyangadzayi Musuka 1750c0a26e chore: allow 8-bit IO to BG0CNT and BG1CNT
BG0CNT and and BG1CNT now work properly in mario kart
2022-10-21 05:12:41 -03:00
Rekai Nyangadzayi Musuka a102d68e99 chore: define affine sprite attributes 2022-10-21 05:12:41 -03:00
Rekai Nyangadzayi Musuka 61483b93e8 feat: stub mode 1 and 2 2022-10-21 05:12:40 -03:00
Rekai Nyangadzayi Musuka 192d7645eb feat: implement mode 5
I wonder which obscure game makes heavy use of this mode
2022-10-21 05:12:40 -03:00
Rekai Nyangadzayi Musuka f1c68fb0de chore: comment ARM MSR code + Audio issues 2022-10-21 05:12:40 -03:00
Rekai Nyangadzayi Musuka cb74bfd280 chore: pass destoer's cond_invalid test 2022-10-21 05:12:40 -03:00
Rekai Nyangadzayi Musuka 0d1717538b chore: misc print message improvements 2022-10-21 05:12:40 -03:00
Rekai Nyangadzayi Musuka 896ae0935a chore: improvements to APU accuracy 2022-10-21 05:12:39 -03:00
Rekai Nyangadzayi Musuka 1a23073424 fix: incorrect order-of-operations in ARM BL impl 2022-10-21 05:12:39 -03:00
Rekai Nyangadzayi Musuka 36f3b0d381 chore: special case saving for ROMS without titles 2022-10-21 05:12:39 -03:00
Rekai Nyangadzayi Musuka c2f3790dc3 feat: pass DenSinH's eeprom-test 2022-10-21 05:12:39 -03:00
Rekai Nyangadzayi Musuka 746c28004f feat: implement EEPROM 2022-10-21 05:12:38 -03:00
Rekai Nyangadzayi Musuka 084d4b28dd chore: implement I/O regsister for Minish Cap 2022-10-21 05:12:38 -03:00
Rekai Nyangadzayi Musuka ed6e83b121 chore: change default window scale to 4x 2022-10-21 05:12:38 -03:00
Rekai Nyangadzayi Musuka b827ba3a1c chore: write more debug log messages for unimplemented registers 2022-10-21 05:12:38 -03:00
Rekai Nyangadzayi Musuka 0f343f0b74 chore: only sync to audio for now 2022-10-21 05:12:38 -03:00
Rekai Nyangadzayi Musuka 7a670c6ed9 feat: panic on unimplemented I/O in ReleaseSafe/Debug but not ReleaseFast 2022-10-21 05:12:38 -03:00
Rekai Nyangadzayi Musuka e690f88cda chore: misc improvements 2022-10-21 05:12:37 -03:00
Rekai Nyangadzayi Musuka c7f537959b fix: improper lifetime for *Arm7tdmi ptr in Bus
*Arm7tdmi ptr is now assigned one scope up so that it lives as least
as long as Bus does
2022-10-21 05:12:37 -03:00
Rekai Nyangadzayi Musuka f074b703b3 feat: implement Noise
Kirby & The Amazing Mirror crashes only in ReleaseSafe / ReleaseBug.

TODO: Figure out why
2022-10-21 05:12:37 -03:00
Rekai Nyangadzayi Musuka f8159645e0 feat: implement ch3 2022-10-21 05:12:37 -03:00
Rekai Nyangadzayi Musuka cccb83a926 feat: implement ch2 2022-10-21 05:12:37 -03:00
Rekai Nyangadzayi Musuka af8fe66c43 feat: implement ch1
TODO: It's really loud
2022-10-21 05:12:36 -03:00
Rekai Nyangadzayi Musuka 1f23aff22c chore: broken impl of ch1 2022-10-21 05:12:36 -03:00
Rekai Nyangadzayi Musuka e580b78020 feat: add audio resampler
Also implement extremely naive audio sync
2022-10-21 05:12:36 -03:00
Rekai Nyangadzayi Musuka a87a5ce273 chore: calculate apu sample rate a bit better 2022-10-21 05:12:36 -03:00
Rekai Nyangadzayi Musuka af1887e0a6 feat: schedule audio sampling on scheduler
DMA sound in games like Pokemon Emerald, Chobits, Love Hina, and Kirby:
Nightmare in Dream Land sound great save for conerns about resampling
2022-10-21 05:12:36 -03:00
Rekai Nyangadzayi Musuka 14bb2f6fbe chore: improve timer behaviour 2022-10-21 05:12:36 -03:00
Rekai Nyangadzayi Musuka d144973acf chore: move some init code to functions 2022-10-21 05:12:35 -03:00
Rekai Nyangadzayi Musuka eecd78a008 feat: impelemt THUMB open bus 2022-10-21 05:12:35 -03:00
Rekai Nyangadzayi Musuka c03c142b14 feat: implement ARM read open bus 2022-10-21 05:12:35 -03:00
Rekai Nyangadzayi Musuka 40f3600de2 fix: remove accidental rotation in ldrsh instructions 2022-10-21 05:12:35 -03:00
Rekai Nyangadzayi Musuka c08e331f77 chore: move log statement 2022-10-21 05:12:35 -03:00
Rekai Nyangadzayi Musuka a92989ed24 chore: remove magic numbers 2022-10-21 05:12:35 -03:00
Rekai Nyangadzayi Musuka 6c61eb3537 chore: remove unnecessary 32MB allocation 2022-10-21 05:12:34 -03:00
Rekai Nyangadzayi Musuka 05c1274ec1 chore: define more I/O read/writes 2022-10-21 05:12:34 -03:00
Rekai Nyangadzayi Musuka 27ad8772ea feat: pass jsmolka memory.gba 2022-10-21 05:12:34 -03:00
Rekai Nyangadzayi Musuka 135987745c chore: ignore instead of logging errors for perf reasons 2022-10-21 05:12:34 -03:00
Rekai Nyangadzayi Musuka f039c891c7 feat: Initial Implementation of DMA Audio 2022-10-21 05:12:33 -03:00
Rekai Nyangadzayi Musuka e69f4cfafe chore: tick scheduler on memory access 2022-10-21 05:12:33 -03:00
Rekai Nyangadzayi Musuka a4020400da chore: log error on open bus in page 0x00 and 0x01 2022-10-21 05:12:33 -03:00
Rekai Nyangadzayi Musuka d4aac22e34 chore: rewrite I/O read/writes 2022-10-21 05:12:33 -03:00
Rekai Nyangadzayi Musuka 601e717850 chore: reimplement bus read/writes 2022-10-21 05:12:33 -03:00
Rekai Nyangadzayi Musuka 886b9abf3d fix: force align reads/writes in memory bus rather than in CPU 2022-10-21 05:12:32 -03:00
Rekai Nyangadzayi Musuka 9c87b9820e fix: pass none.gba and kind of sram.gba from jsmolka test suite 2022-10-21 05:12:32 -03:00
Rekai Nyangadzayi Musuka 1fe332a44f feat: implement GamePak out-of-bounds reads 2022-10-21 05:12:32 -03:00
Rekai Nyangadzayi Musuka b6d2084c96 chore: run zigfmt 2022-10-21 05:12:32 -03:00
Rekai Nyangadzayi Musuka ed896d976d chore: change implementation of rotr 2022-10-21 05:12:32 -03:00
Rekai Nyangadzayi Musuka 677eecad41 chore: rewrite read/write methods for remainig Bus devices 2022-10-21 05:12:32 -03:00
Rekai Nyangadzayi Musuka 74b6fa2ecc chore: mirror VRAM 2022-10-21 05:12:31 -03:00
Rekai Nyangadzayi Musuka effb6315e9 chore: write generic read/write for VRAM 2022-10-21 05:12:31 -03:00
Rekai Nyangadzayi Musuka 3c8390a248 Merge branch 'main' of ssh://musuka.dev:2222/paoda/zba 2022-10-21 05:12:31 -03:00
Rekai Nyangadzayi Musuka 8337a6dcd9 chore: update dependencies 2022-10-21 05:12:31 -03:00
Rekai Nyangadzayi Musuka 2d8fa9c2f7 fix: don't create un-needed save file
If we don't know if we support a game's save type yet, avoid
creating a file for it.
2022-10-21 05:12:30 -03:00
Rekai Nyangadzayi Musuka b76481b34c chore: don't assume 1cpi when stepping by a frame 2022-10-21 05:12:30 -03:00
Rekai Nyangadzayi Musuka 147f6ac9ec Revert "chore: tick on memory access instead of 1cpi"
This reverts commit 7f555095f2.
2022-10-21 05:12:30 -03:00
Rekai Nyangadzayi Musuka 84273cbdad chore: tick on memory access instead of 1cpi 2022-10-21 05:12:30 -03:00
Rekai Nyangadzayi Musuka 885f92beeb feat: implement Flash backup cartrige kinds 2022-10-21 05:12:30 -03:00
Rekai Nyangadzayi Musuka f12800f2d0 chore: stub more apu I/O addresses 2022-10-21 05:12:30 -03:00
Rekai Nyangadzayi Musuka a93b335dea fix: account for subset of disallowed chars in save file names 2022-10-21 05:12:29 -03:00
Rekai Nyangadzayi Musuka ad9463dcb9 feat: implement SRAM saving and loading 2022-10-21 05:12:29 -03:00
Rekai Nyangadzayi Musuka 242627199b chore: properly deallocate OAM buffer 2022-10-21 05:12:29 -03:00
Rekai Nyangadzayi Musuka 22a8f67d81 fix: speed percentage in title is now accurate
We now properly account for full speed being 59.97Hz not, 59Hz or 60Hz
2022-10-21 05:12:29 -03:00
Rekai Nyangadzayi Musuka 4ee0eed2e5 chore: make some variables const 2022-10-21 05:12:29 -03:00
Rekai Nyangadzayi Musuka 20f39176c6 feat: minor performance improvements 2022-10-21 05:12:29 -03:00
Rekai Nyangadzayi Musuka ed792d71d3 feat: switch from BGR555 to RGBA8888 2022-10-21 05:12:28 -03:00
Rekai Nyangadzayi Musuka c3ae727ed1 fix: improve perf of instructions w/ rotr 2022-10-21 05:12:28 -03:00
Rekai Nyangadzayi Musuka 0116dcdbe1 fix: improve frame limiting and fps counting 2022-10-21 05:12:28 -03:00
Rekai Nyangadzayi Musuka 5ecbcc9f33 fix: implement proper SRAM mirroring and stub Flash 2022-10-21 05:12:28 -03:00
Rekai Nyangadzayi Musuka 2d16e4a4e6 chore: move DMA and Timers from io to bus 2022-10-21 05:12:28 -03:00
Rekai Nyangadzayi Musuka bb9dc45e0c feat: define APU registers 2022-10-21 05:12:27 -03:00
Rekai Nyangadzayi Musuka 9dcecc0d58 fix: move code in scheduler to ppu 2022-10-21 05:12:27 -03:00
Rekai Nyangadzayi Musuka 92e63f5dd6 chore: create different types of emuloops 2022-10-21 05:12:27 -03:00
Rekai Nyangadzayi Musuka 74cda6a1d0 fix: resolve relative sprite priority issues 2022-10-21 05:12:27 -03:00
Rekai Nyangadzayi Musuka d7354cca33 chore: improve accuracy of frame limiter 2022-10-21 05:12:27 -03:00
Rekai Nyangadzayi Musuka 7684cf0f4a chore: improve accuracy of thread sleep in emu thread 2022-10-21 05:12:27 -03:00
Rekai Nyangadzayi Musuka 3994c2c7c8 feat: implement video sync 2022-10-21 05:12:26 -03:00
Rekai Nyangadzayi Musuka a768d28e7c chore: organize io switch statements 2022-10-21 05:12:26 -03:00
Rekai Nyangadzayi Musuka efd99f16e0 fix: mirror SRAM
SRAM is mirrored in 64K chunks
TODO: According to GBATEK SRAM chips are 32K and mirrored
2022-10-21 05:12:26 -03:00
Rekai Nyangadzayi Musuka 61d6288fec chore: don't panic on unknown bus and io writes/reads
This will lead to emulation bugs due to devices I've yet to implement but by
doing this a lot of games become playable "by default" such as Doom or
Kirby: Nightmare in Dream Land.

When implementing feature and/or debuggin make sure to set:
panic_on_und_bus and panic_on_und_io to true so that the emu crashes
on unknown reads/writes
2022-10-21 05:12:26 -03:00
Rekai Nyangadzayi Musuka e3e45cd129 feat: implement Timers 2022-10-21 05:12:26 -03:00
Rekai Nyangadzayi Musuka 15191aedca fix: implement sprite coord overflow behaviour 2022-10-21 05:12:26 -03:00
Rekai Nyangadzayi Musuka 63486f13f2 fix: resolve issues with sprite mirroring 2022-10-21 05:12:25 -03:00
Rekai Nyangadzayi Musuka 17455e40d1 feat: Implement MVP of Mode 0 Sprites 2022-10-21 05:12:25 -03:00
Rekai Nyangadzayi Musuka d54e593276 chore: clean up io 2022-10-21 05:12:25 -03:00
Rekai Nyangadzayi Musuka c6a544a824 feat: fix tile flipping issue 2022-10-21 05:12:25 -03:00
Rekai Nyangadzayi Musuka e3ae3635bc chore: add some type definitions for sprites 2022-10-21 05:12:25 -03:00
Rekai Nyangadzayi Musuka 6723bfb364 feat: improve DMA Transfer support 2022-10-21 05:12:25 -03:00
Rekai Nyangadzayi Musuka 12c628e82c chore(ppu): resolve integer overflow regression 2022-10-21 05:12:24 -03:00
Rekai Nyangadzayi Musuka 5f9abf69d3 feat(ppu): implement bg priority and transparency 2022-10-21 05:12:24 -03:00
Rekai Nyangadzayi Musuka 68b0601a42 chore: replace unnecessarily complex sign extension implementation 2022-10-21 05:12:24 -03:00
Rekai Nyangadzayi Musuka 9455ffe837 feat: pass beeg yoshi 2022-10-21 05:12:24 -03:00
Rekai Nyangadzayi Musuka 02d2ff3e0c fix: palette id is a u16 not a u8 2022-10-21 05:12:24 -03:00
Rekai Nyangadzayi Musuka 02572dd15c feat: DMA Transfer MVP 2022-10-21 05:12:23 -03:00
Rekai Nyangadzayi Musuka 6d253cc74e feat(ppu): implement transparency + backdrop in mode 0 2022-10-21 05:12:23 -03:00
Rekai Nyangadzayi Musuka 4885a86833 chore(io): replace some bitfields with enums 2022-10-21 05:12:23 -03:00
Rekai Nyangadzayi Musuka fd9ffb20b4 fix: better emulate behaviour of IO reads 2022-10-21 05:12:23 -03:00
Rekai Nyangadzayi Musuka 56ef2b077a chore: document select unimplmented I/O registers
These registers are written to / read from Kirby: Nightmare in Dream Land
2022-10-21 05:12:23 -03:00
Rekai Nyangadzayi Musuka d4c7cfdf8b feat: impelement a barebones SRAM 2022-10-21 05:12:23 -03:00
Rekai Nyangadzayi Musuka 4d75d156e5 feat: pass retAddr.gba 2022-10-21 05:12:22 -03:00
Rekai Nyangadzayi Musuka d30a4d7ee5 feat: implement Hblank and Vcount Interrupts
Also implemented unique behaviour when writing to IF
2022-10-21 05:12:22 -03:00
Rekai Nyangadzayi Musuka d1fce8ba75 chore: improve Bus log + panic messages 2022-10-21 05:12:22 -03:00
Rekai Nyangadzayi Musuka 0f74e4fcf9 chore: improve io.zig 2022-10-21 05:12:22 -03:00
Rekai Nyangadzayi Musuka 4afcbd0957 feat: implement mirroring for IWRAM EWRAM, OAM and PALRAM
Also realized I confused IWRAM and EWRAM. This is also fixed
TODO: Implemnt Mirroring for VRRAM
2022-10-21 05:12:22 -03:00
Rekai Nyangadzayi Musuka 50dc31447d fix: resolve integer overflow in BG0 Drawing 2022-10-21 05:12:22 -03:00
Rekai Nyangadzayi Musuka acf1a10f91 chore: don't panic on 32-bit I/O 2022-10-21 05:12:21 -03:00
Rekai Nyangadzayi Musuka 606f9b959a chore: stub CPU HALTing 2022-10-21 05:12:21 -03:00
Rekai Nyangadzayi Musuka f19b42baf3 chore: correct logic errors in map size 1 and 3 2022-10-21 05:12:21 -03:00
Rekai Nyangadzayi Musuka 2a3d0c8b0d chore: properly write to VOFS and HOFS in 32-bit bus 2022-10-21 05:12:21 -03:00
Rekai Nyangadzayi Musuka 4405fa6bbf feat: implement hofs and vofs on io bus 2022-10-21 05:12:21 -03:00
Rekai Nyangadzayi Musuka e2b2bf882a feat: implement scrolling 2022-10-21 05:12:21 -03:00
Rekai Nyangadzayi Musuka 08e4eb1bf1 feat: add support for multiple BGs in Mode 0 2022-10-21 05:12:20 -03:00
Rekai Nyangadzayi Musuka f4b176a813 feat: document mode 0 2022-10-21 05:12:20 -03:00
Rekai Nyangadzayi Musuka efc7d817db feat: Mode 0 MVP 2022-10-21 05:12:20 -03:00
Rekai Nyangadzayi Musuka 1b17b1eb0c chore: use zig slices for fun 2022-10-21 05:12:20 -03:00
Rekai Nyangadzayi Musuka fab6d4c2a2 chore: give DISPCNT DISPSTAT and VCOUNT to PPU struct 2022-10-21 05:12:20 -03:00
Rekai Nyangadzayi Musuka 223a3403c0 chore: give io read/write functions access to the entire Bus 2022-10-21 05:12:20 -03:00
Rekai Nyangadzayi Musuka dfd0d064de feat: implement BG Scrolling Registers 2022-10-21 05:12:19 -03:00
Rekai Nyangadzayi Musuka 0c4882e658 feat: impelemnt BG0,1,2CNT and IF 2022-10-21 05:12:19 -03:00
Rekai Nyangadzayi Musuka bfdad9fa32 feat: implement OAM 2022-10-21 05:12:19 -03:00
Rekai Nyangadzayi Musuka 37fd8dab84 chore: squash bugs preventing swi_demo.gba from working 2022-10-21 05:12:19 -03:00
Rekai Nyangadzayi Musuka c143aefb01 chore(cpu): reimplement bank switching logic 2022-10-21 05:12:19 -03:00
Rekai Nyangadzayi Musuka 05bf245b5a fix: don't mask away MSB in THUMB.5 add 2022-10-21 05:12:19 -03:00
Rekai Nyangadzayi Musuka f9e7128061 fix: properly decode format 11 instructions 2022-10-21 05:12:18 -03:00
Rekai Nyangadzayi Musuka 603e4b6fdf chore: make use of scoped logging 2022-10-21 05:12:18 -03:00
Rekai Nyangadzayi Musuka 599a1f2973 chore: remove TODOs and some useless imports 2022-10-21 05:12:18 -03:00