Commit Graph

587 Commits

Author SHA1 Message Date
Rekai Nyangadzayi Musuka 4eb715a138 doc(emu): properly document + simply constants 2022-10-28 21:57:30 -03:00
Rekai Nyangadzayi Musuka 14b24787ab style: remove unnecessary imports 2022-10-28 21:56:55 -03:00
Rekai Nyangadzayi Musuka eb7ffa29f4 fix(apu): pause device on mute instead of writing silence 2022-10-27 09:11:08 -03:00
Rekai Nyangadzayi Musuka 4b8ed3cebb fix(io): resolve embarrasingly simple regression
introduced in 21eddac31e
2022-10-23 04:39:31 -03:00
Rekai Nyangadzayi Musuka 928ce674d9 fix(cpu): fix obscure LDRSH behaviour 2022-10-22 22:12:41 -03:00
Rekai Nyangadzayi Musuka 945dbec013 fix(open-bus): don't rotate result
Rotating misaligned reads is the responsibility of the CPU
2022-10-22 21:32:36 -03:00
Rekai Nyangadzayi Musuka a2868dfe9e feat(dma): Implement DMA Latch 2022-10-22 20:52:02 -03:00
Rekai Nyangadzayi Musuka 22979d9450 fix(bios): fix regression
was reading addr_latch + 8, which is a remnant from when I was faking
the pipeline
2022-10-22 15:33:36 -03:00
Rekai Nyangadzayi Musuka 16f8f4c953 feat: write default config.toml if it doesn't exist
also resolves panic on missing /zba or /zba/save directory by ensuring
those directories exist as soon as we know the data directory
2022-10-21 04:39:16 -03:00
Rekai Nyangadzayi Musuka eff52ac1bb fix(opengl): properly control whether vsync is enabled 2022-10-17 20:31:42 -03:00
Rekai Nyangadzayi Musuka e60b556f72 chore(ppu): remove BGR555 -> RGBA888 LUT
LUT probably couldn't fit in CPU cache anyways.

TODO: Consider whether LUTs for separate channels (size 32 * 3 * 3
instead of std.math.maxInt(u15))
2022-10-17 20:31:42 -03:00
Rekai Nyangadzayi Musuka 4b4bc7f894 chore: remove unnecessary ptr cast 2022-10-17 20:31:42 -03:00
Rekai Nyangadzayi Musuka 325208d460 feat: implement better Colour Emulation 2022-10-17 20:31:42 -03:00
Rekai Nyangadzayi Musuka f44a1a49fd fix: lower required OpenGL version + resolve offset bug 2022-10-17 20:31:42 -03:00
Rekai Nyangadzayi Musuka 1575f517a9 feat: use opengl
TODO:
- Texture isn't scaling properly
- I need to reverse the colours in the frag shader
2022-10-17 20:31:42 -03:00
Rekai Nyangadzayi Musuka 26dba16789 chore(gpio): add missing errdefer 2022-10-17 20:01:50 -03:00
Rekai Nyangadzayi Musuka b133880064 chore(main): report errors slightly better 2022-10-17 18:30:40 -03:00
Rekai Nyangadzayi Musuka 2474daa3ae chore(config): add log message 2022-10-17 17:39:02 -03:00
Rekai Nyangadzayi Musuka fc53a40b3c feat(config): add option to skip BIOS 2022-10-17 17:31:07 -03:00
Rekai Nyangadzayi Musuka 7097e21361 feat(cli): Add option to skip BIOS 2022-10-17 17:25:04 -03:00
Rekai Nyangadzayi Musuka f38c840d32 Merge pull request 'Draft: Implement Instruction Pipeline' (#3) from pipeline into main
Reviewed-on: #3
2022-10-17 19:42:42 +00:00
Rekai Nyangadzayi Musuka 19e70c39d1 feat(config): add config option to mute ZBA 2022-10-13 00:54:15 -03:00
Rekai Nyangadzayi Musuka 5a72a8e7f3 chore(config): add example config file 2022-10-13 00:46:18 -03:00
Rekai Nyangadzayi Musuka 7b146ad7ca fix(bios): set addr_latch even if bios is skipped 2022-10-13 00:35:22 -03:00
Rekai Nyangadzayi Musuka 822eed1f3a fix(bus): make open bus impl aware of CPU pipeline 2022-10-13 00:35:22 -03:00
Rekai Nyangadzayi Musuka b37a14900c style(bus): cpu ptr doesn't need to be optional 2022-10-13 00:35:22 -03:00
Rekai Nyangadzayi Musuka f5bd20bc2a style: code cleanup 2022-10-13 00:35:22 -03:00
Rekai Nyangadzayi Musuka d3514b14f3 fix: resolve timing regressions
make sure to use fetch timings when fetching instructions
2022-10-13 00:35:20 -03:00
Rekai Nyangadzayi Musuka 06c60dad74 fix: rename Pipline to Pipeline 2022-10-13 00:34:18 -03:00
Rekai Nyangadzayi Musuka 870e991862 feat: working pipeline implementation 2022-10-13 00:34:18 -03:00
Rekai Nyangadzayi Musuka 5bb5bdf389 chore: refactor ARM/THUMB data processing instructions 2022-10-13 00:34:18 -03:00
Rekai Nyangadzayi Musuka a3996cbc58 fix: don't flush pipeline when reloading CPSR in ARM Data Processing 2022-10-13 00:34:18 -03:00
Rekai Nyangadzayi Musuka a948c6f900 chore: don't write to CPSR + swap with SPSR at the same time 2022-10-13 00:34:18 -03:00
Rekai Nyangadzayi Musuka e4451738b5 fix: advance r15, even when the pipeline is reloaded from the scheduler
The PC would fall behind whenever an IRQ was called because the pipeline
was reloaded (+8 to PC), however that was never actually done by any code

Now, the PC is always incremented when the pipeline is reloaded
2022-10-13 00:33:13 -03:00
Rekai Nyangadzayi Musuka 48b81c8e7a chore: dump pipeline state on cpu panic 2022-10-13 00:33:13 -03:00
Rekai Nyangadzayi Musuka 3cf1bf54e9 fix: reimpl THUMB.5 instructions
pipeline branch now passes arm.gba and thumb.gba again

(TODO: Stop rewriting my commits away)
2022-10-13 00:33:13 -03:00
Rekai Nyangadzayi Musuka 1f9eeedfe8 fix: impl workaround for stage2 miscompilation 2022-10-13 00:33:13 -03:00
Rekai Nyangadzayi Musuka 72a63eeb98 chore: instantly refill the pipeline on flush
I believe this to be necessary in order to get hardware interrupts
working.

thumb.gba test 108 fails but I'm committing anyways (despite the
regression) because this is kind of rebase/merge hell and I have
something that at least sort of works rn
2022-10-13 00:33:13 -03:00
Rekai Nyangadzayi Musuka 2799c3f202 fix: reimpl handleInterrupt code 2022-10-13 00:33:13 -03:00
Rekai Nyangadzayi Musuka b3ada64e64 feat: implement basic pipeline
passes arm.gba, thumb.gb and armwrestler, fails in actual games
TODO: run FuzzARM debug specific titles
2022-10-13 00:33:11 -03:00
Rekai Nyangadzayi Musuka 62162ba492 feat: resolve off-by-{word, halfword} errors when printing debug info 2022-10-13 00:31:47 -03:00
Rekai Nyangadzayi Musuka aa100de581 feat: reimplement cpu logging 2022-10-13 00:31:47 -03:00
Rekai Nyangadzayi Musuka 97f48c730e chore(emu): refactor code 2022-10-13 00:29:51 -03:00
Rekai Nyangadzayi Musuka 293fbd9f55 feat(config): add support for (and read from) TOML config file 2022-10-13 00:29:48 -03:00
Rekai Nyangadzayi Musuka 622f479e07 feat: parse config.toml in data folder
Also took the chance to rework parts of the logic that determines
ZBA's save path
2022-10-13 00:27:18 -03:00
Rekai Nyangadzayi Musuka 21eddac31e style: improve code quality 2022-10-13 00:23:58 -03:00
Rekai Nyangadzayi Musuka 785135a074 feat: rewrite device ticks 2022-10-13 00:23:58 -03:00
Rekai Nyangadzayi Musuka fd38fd6506 style(scheduler): rename scheduler event handlers 2022-10-13 00:23:58 -03:00
Rekai Nyangadzayi Musuka bcacac64df style: code refactoring 2022-10-13 00:23:58 -03:00
Rekai Nyangadzayi Musuka dc7cad9691 style(apu): split apu.zig into multiple files + refactor 2022-10-13 00:23:58 -03:00
Rekai Nyangadzayi Musuka b5d8a65e69 style(backup): refactor code 2022-10-10 12:01:49 -03:00
Rekai Nyangadzayi Musuka 8028394105 style(flash): move flash code into it's own file 2022-10-10 12:01:49 -03:00
Rekai Nyangadzayi Musuka cb0eb67e4b style(eeprom): move eeprom code to it's own file 2022-10-10 12:00:45 -03:00
Rekai Nyangadzayi Musuka 13f6ee8ec4 style(bus): refactor several hardware abstractions 2022-10-10 11:57:57 -03:00
Rekai Nyangadzayi Musuka 92cfc763c0 chore: move util.zig 2022-09-19 16:07:19 -03:00
Rekai Nyangadzayi Musuka e192c6712f chore: disable audio sync by default
forgot SDL2 AudioStream doesn't work well for my use-case
2022-09-18 09:20:01 -03:00
Rekai Nyangadzayi Musuka 3466bf6c0a chore: change default settings 2022-09-18 06:30:39 -03:00
Rekai Nyangadzayi Musuka fbe3de0eb3 chore: reimpl util.escape
should make use of stdlib when I can
2022-09-18 06:23:30 -03:00
Rekai Nyangadzayi Musuka 4af144fca2 fix: Detect FRAM ROMs 2022-09-18 06:19:05 -03:00
Rekai Nyangadzayi Musuka 9a8aaba1ab chore: improve util and Gui API 2022-09-18 05:55:15 -03:00
Rekai Nyangadzayi Musuka fa3b9c21b9 chore: move Gpio and Clock structs to separate file 2022-09-18 00:37:45 -03:00
Rekai Nyangadzayi Musuka 50adb5fbac feat: add option to force-enable RTC 2022-09-17 20:27:17 -03:00
Rekai Nyangadzayi Musuka 19d78b9292 feat: auto-detect RTC in commercial ROMS 2022-09-17 20:23:49 -03:00
Rekai Nyangadzayi Musuka a2e702c366 fix: account for lateness in RTC scheduler event 2022-09-17 09:07:31 -03:00
Rekai Nyangadzayi Musuka 12c138364d fix: RTC day is 6 bits wide, not 3 2022-09-16 10:59:41 -03:00
Rekai Nyangadzayi Musuka 7783c11fac feat: put RTC Sync on Scheduler
TODO: Database to see what games have what GPIO devices
2022-09-16 10:39:02 -03:00
Rekai Nyangadzayi Musuka 3fc3366c8a chore: import datetime library + default time for RTC 2022-09-16 10:39:02 -03:00
Rekai Nyangadzayi Musuka d6b182f245 fix: ignore RTC Time/DateTime writes
this falls in-line with better emulators
2022-09-16 10:39:02 -03:00
Rekai Nyangadzayi Musuka 3857c44e68 chore: use Clock.Writer for Command parsing, delete Clock.Command 2022-09-16 10:39:02 -03:00
Rekai Nyangadzayi Musuka 089c5fa025 feat: implement RTC Read/Writes 2022-09-16 10:39:02 -03:00
Rekai Nyangadzayi Musuka c977f3f965 feat: implement force irqs for GPIO/RTC 2022-09-16 10:38:51 -03:00
Rekai Nyangadzayi Musuka 92417025e9 fix: properly resovle stack UAF 2022-09-16 02:10:41 -03:00
Rekai Nyangadzayi Musuka 1c52c0bf91 chore: shorten `orelse @panic` to `.?` 2022-09-16 02:10:41 -03:00
Rekai Nyangadzayi Musuka 617f7f4690 fix: update GpioData extern union
u4's are no longer supported in extern unions :\
2022-09-16 02:10:41 -03:00
Rekai Nyangadzayi Musuka 434a0dfac9 tmp: incomplete impl of GPIO + RTC 2022-09-16 02:10:41 -03:00
Rekai Nyangadzayi Musuka 4ec8dab460 chore: Guilty Gear X expects these I/O Registers 2022-09-14 11:38:26 -03:00
Rekai Nyangadzayi Musuka 59c9ff910e feat: implement open bus for unmapped i/o 2022-09-12 23:18:29 -03:00
Rekai Nyangadzayi Musuka 0027d3f8a3 chore: comment open bus impl 2022-09-11 07:38:55 -03:00
Rekai Nyangadzayi Musuka 65cfc97f28 feat: reimplement audio sync
APU will now drop samples if the Audio Queue is already full, therefore
creating a "sped-up" effect when the emulator runs faster than 100%
2022-09-08 20:38:42 -03:00
Rekai Nyangadzayi Musuka fa862f095a chore: move arm/thumb lut idx functions 2022-09-06 23:58:24 -03:00
Rekai Nyangadzayi Musuka 3fb7f2f814 chore: better conform to zig idioms 2022-09-03 18:30:48 -03:00
Rekai Nyangadzayi Musuka 59669ba3a5 chore: rename arm7tdmi variables to just cpu
Less verbose, specifying arm7tdmi doesn't really do much when there's
no other CPU in the system
2022-09-03 17:56:37 -03:00
Rekai Nyangadzayi Musuka 6a798d2c9d chore: allocate sprite array on heap
Each Sprite optional is 10 bytes meaning I'm allocating 1.28Kb on the
stack which isn't necessary.
2022-08-29 01:07:25 -05:00
Rekai Nyangadzayi Musuka 5f8c6833f4 chore: improve init/deinit methods 2022-08-29 01:07:25 -05:00
Rekai Nyangadzayi Musuka aa52bb5917 chore: reorganize some code 2022-08-26 14:13:49 -05:00
Rekai Nyangadzayi Musuka e57f918856 chore: pass the allocator as an argument more often
As of right now, I think the only cases where I shouldn't explicitly pass an allocator
are in read/write functions and deinits
2022-08-26 13:54:38 -05:00
Rekai Nyangadzayi Musuka e5b7441740 fix: resolve use-afer-free in backup.zig
This worked fine on stage1, and works fine in debug in stage3.
However, stage3 ReleaseSafe would panic due to what I assume must
have been an undefined behaviour optimization.

While I'm happy that I was quickly made aware of the issue thanks to
the safety checks in ReleaseSafe I do wish that this issue showed itself
in Debug, since I *am* using the GPA
2022-08-26 13:04:09 -05:00
Rekai Nyangadzayi Musuka 2ab8769b7a feat: Get ZBA working on Zig's new stage2/stage3 compiler 2022-08-21 12:28:31 -05:00
Rekai Nyangadzayi Musuka 3c3c0d32dd chore: move window scale const to emu.zig 2022-08-08 11:03:23 +02:00
Rekai Nyangadzayi Musuka 739db99c83 fix: reimpl debug reads w/out throwing away *const Self 2022-08-07 05:11:29 -05:00
Rekai Nyangadzayi Musuka 2c8616f610 feat: reimplement cpu logging 2022-07-27 14:50:28 -03:00
Rekai Nyangadzayi Musuka 53eec5c3ff chore: don't init bus in Arm7tdmi init 2022-07-27 13:44:24 -03:00
Rekai Nyangadzayi Musuka c397b7069d feat: move arm instr decoding to module 2022-07-27 13:23:29 -03:00
Rekai Nyangadzayi Musuka 9d037fdc3e feat: move thumb instr decoding to module 2022-07-27 13:10:58 -03:00
Rekai Nyangadzayi Musuka 53191b0eeb chore: change directory structure 2022-07-22 21:11:19 -03:00
Rekai Nyangadzayi Musuka c7c4a90948 fix: reimplement halt fast-forwarding 2022-07-21 11:25:49 -03:00
Rekai Nyangadzayi Musuka 03ded099d2 chore: move audio sync, video sync variables 2022-07-21 11:05:49 -03:00
Rekai Nyangadzayi Musuka 3b3eb52c48 feat: impl WININ, WINOUT, WIN{N}H and WIN{N}V 2022-06-29 14:56:48 -03:00
Rekai Nyangadzayi Musuka d798aea6ea fix: force align DMA transfers 2022-06-29 04:31:02 -03:00
Rekai Nyangadzayi Musuka 5d37c212e2 fix: resolve bugs in VRAM unpredictable read/writes 2022-06-29 03:59:14 -03:00
Rekai Nyangadzayi Musuka 887bd89668 fix: don't start HDMA in vblank 2022-06-23 05:45:52 -03:00
Rekai Nyangadzayi Musuka 81c669fe64 feat: implement brightness increase/decrease 2022-06-23 04:50:04 -03:00
Rekai Nyangadzayi Musuka 265234ee97 feat: implement object blending 2022-06-23 02:49:56 -03:00
Rekai Nyangadzayi Musuka 02534c5c19 feat: implement background alpha blending 2022-06-19 22:10:56 -03:00
Rekai Nyangadzayi Musuka 5e4fb7b952 feat: implement BLDCNT, BLDALPHA, BLDY 2022-06-19 01:27:14 -03:00
Rekai Nyangadzayi Musuka c9ea80e03b chore: rename + remove some code 2022-06-18 22:01:17 -03:00
Rekai Nyangadzayi Musuka 4cd722e447 fix: properly fire DMA IRQs
This resolves Sound DMA Timing issues present in DOOM
2022-06-18 21:13:12 -03:00
Rekai Nyangadzayi Musuka adfb23fab4 chore: rename Dma.active to Dma.in_progress 2022-06-18 19:15:34 -03:00
Rekai Nyangadzayi Musuka 5bbbdc3469 chore: rewrite info log message 2022-06-18 18:46:40 -03:00
Rekai Nyangadzayi Musuka 47adc0c5ae feat: implement NR10 obscure behaviour 2022-06-18 18:16:29 -03:00
Rekai Nyangadzayi Musuka 601b0b2aae feat: handle all I/O when using Cult-Of-GBA BIOS 2022-06-18 17:50:11 -03:00
Rekai Nyangadzayi Musuka 3becd790cf chore: 32-bit reads for PSG audio 2022-06-18 17:35:52 -03:00
Rekai Nyangadzayi Musuka 460f8308a7 chore: implement more than just 1 cycle per mem access 2022-06-16 22:35:42 -03:00
Rekai Nyangadzayi Musuka cc8c1c1e21 fix: implement register reads for Yoshi's Island 2022-06-16 02:32:31 -03:00
Rekai Nyangadzayi Musuka f5e401a4ee fix: reimplement DMA ticking 2022-06-16 01:46:37 -03:00
Rekai Nyangadzayi Musuka dba8873f76 chore(cpu): add inline fn isHalted() 2022-06-16 00:49:37 -03:00
Rekai Nyangadzayi Musuka db08edbdb9 chore: attempt to debug Rhythm Heaven 2022-06-16 00:03:51 -03:00
Rekai Nyangadzayi Musuka 35dba63b94 fix: impl BG?{X,Y} RefPoint write behaviour outside of Vblank
With this fix Mode 7-like games now properly render their backgrounds
2022-06-15 01:34:34 -03:00
Rekai Nyangadzayi Musuka a753912cb5 chore: change priority of some logs 2022-06-15 01:18:45 -03:00
Rekai Nyangadzayi Musuka 7441af9582 chore: mess with debug statements + mask APU I/O reads 2022-06-15 01:08:43 -03:00
Rekai Nyangadzayi Musuka 708f64035f chore: move timer, apu and dma i/o addr matching outside of io.zig 2022-06-15 00:05:36 -03:00
Rekai Nyangadzayi Musuka e4bbd33a49 chore: separate render code for affine sprites 2022-06-04 20:07:20 -03:00
Rekai Nyangadzayi Musuka 25d13722f7 chore: reimplement object rendering
TODO: implement affine sprites
2022-06-04 13:55:31 -03:00
Rekai Nyangadzayi Musuka 4eb0d469b3 chore: small changes to normal background drawing code 2022-06-04 10:21:03 -03:00
Rekai Nyangadzayi Musuka ce2271100b feat: implement affine backgrounds 2022-06-04 09:49:34 -03:00
Rekai Nyangadzayi Musuka e226a59a2f chore: stub 8-bit window registers 2022-06-04 09:48:59 -03:00
Rekai Nyangadzayi Musuka 7ff5f3b8e7 chore: remove code that pretends to remove DC offset 2022-06-04 09:47:58 -03:00
Rekai Nyangadzayi Musuka b6f5517c89 fix: replace affine bg register bitfields with signed integers 2022-06-03 19:26:52 -03:00
Rekai Nyangadzayi Musuka 2dc3864dca chore: use stdlib endian-aware integer read/write functions 2022-06-03 13:26:55 -03:00
Rekai Nyangadzayi Musuka 38afb567b9 chore: misc style improvements 2022-05-27 22:09:15 -03:00
Rekai Nyangadzayi Musuka 4006888629 chore: rename method in FpsTracker 2022-05-27 21:50:16 -03:00
Rekai Nyangadzayi Musuka 413ff02ad9 fix(backup): resolve banking issue in flash impl 2022-05-27 21:17:50 -03:00
Rekai Nyangadzayi Musuka 517ed7a835 chore: remove awful ptr casts in backup.zig and bios.zig 2022-05-27 20:24:09 -03:00
Rekai Nyangadzayi Musuka d4bc1f2cd0 feat: pass jsmolka's bios.gba 2022-05-27 20:08:09 -03:00
Rekai Nyangadzayi Musuka c6ce810afe fix: play right samples in right channel 2022-05-27 18:47:34 -03:00
Rekai Nyangadzayi Musuka 1170673447 fix: resolve issue when handling event sooner than expected 2022-05-26 17:11:02 -03:00
Rekai Nyangadzayi Musuka c007bf4d8e fix: remove DC offset from audio output 2022-05-26 17:10:10 -03:00
Rekai Nyangadzayi Musuka 697ec46cf1 chore: add debug keybinds for scheduler capacity + event count 2022-05-25 15:13:57 -03:00
Rekai Nyangadzayi Musuka 41ee32b118 perf: don't check scheduler every iteration of runFrame loop
~20fps gain in Pokemon Emerald, nice
2022-05-25 14:17:44 -03:00
Rekai Nyangadzayi Musuka 8f5d054195 chore: simplify 4bpp palette code 2022-05-25 10:10:57 -03:00
Rekai Nyangadzayi Musuka c907552864 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-05-24 13:55:50 -03:00
Rekai Nyangadzayi Musuka ff3f79801c chore: modify type signature of util.sext 2022-05-23 14:48:52 -03:00
Rekai Nyangadzayi Musuka f130d1991c chore: cleanup main 2022-05-23 12:50:01 -03:00
Rekai Nyangadzayi Musuka 24a8905c29 chore: emu audio sync code to emu.zig 2022-05-23 12:05:57 -03:00
Rekai Nyangadzayi Musuka e70fe73899 chore: redo apu sampling 2022-05-23 11:25:28 -03:00
Rekai Nyangadzayi Musuka a2d2a84850 chore: implement apu u16 reads 2022-05-21 15:09:32 -03:00
Rekai Nyangadzayi Musuka 109561310e fix: clean up frequency timer implementations 2022-05-21 14:21:50 -03:00
Rekai Nyangadzayi Musuka 5164aa961d Revert "fix: resolve off-by-one errors when scheduling freq timer expirations"
This reverts commit c9b0030b4b.
2022-05-21 13:46:46 -03:00
Rekai Nyangadzayi Musuka c9b0030b4b fix: resolve off-by-one errors when scheduling freq timer expirations 2022-05-21 13:34:14 -03:00
Rekai Nyangadzayi Musuka af2ad6c924 chore: improve APU accuracy + scheduler refactoring 2022-05-20 16:01:12 -03:00