Commit Graph
29 Commits
Author SHA1 Message Date
Matthew Laux 8bfb3cf5bd clean up unused code and stale comments 2026-08-08 00:44:56 -05:00
Matthew Laux 084e45c920 WIP bank switch optimize 2026-08-07 19:25:35 -05:00
Matthew Laux 6ca1ae93be make cycles in the JIT count up again, counting down was more complicated and didn't help performance at all 2026-08-06 23:13:45 -05:00
Matthew Laux 9f4ffc0506 new folder structure, save list of compiled block addresses to precompile next time, 2.2.0 2026-07-30 22:14:28 -05:00
Matthew Laux 985666d727 "deadline-gating budget_touch" omg 2026-07-27 16:49:53 -05:00
Matthew Laux 42acc41a0d WIP compiler improvements 2026-07-27 11:24:31 -05:00
Matthew Laux a48ae61a82 SP correctness fixes 2026-07-12 19:40:34 -05:00
Matthew Laux ed37a7c185 half-remove cycles_per_exit, optimize STAT interrupts, but will remove 2026-07-12 17:18:06 -05:00
Matthew Laux 7610d3ce96 biased page tables, scaled index on 68020+, interrupt fixes (that may or may not have actually improved compatibility) 2026-07-08 20:12:32 -05:00
Tanner Fokkens 7caca2f056 Fix LY wait and HALT timing in CGB double speed mode
In double speed mode, dmg_sync_hw() halves CPU cycles before adding
to frame_cycles. The timing functions (compile_ly_wait, compile_ly_wait_reg,
compile_halt) compute D2 in PPU-domain units, but only half gets applied
to frame_cycles, causing the target LY to never be reached and an
infinite re-entry loop during game init.

Add effective_double_speed byte to JIT context and emit a runtime check
in all three timing functions to double D2 when double speed is active.
2026-02-06 16:06:36 -08:00
Tanner Fokkens 14e7b65dde Remove debug counters and optimize LY calculation
- Remove dmg_reads/dmg_writes debug counters that ran on every memory
  access, saving 2-4 cycles per read/write operation
- Replace O(n) LY calculation loop with O(1) division-based formula,
  eliminating up to 154 iterations for games that poll LY infrequently
2026-02-01 00:58:48 -08:00
Tanner Fokkens 3cbc9337f8 Fix stack corruption in CALL/RET/RST and add STOP instruction support
Major fixes:
- CALL, RET, RST, and their conditional variants now properly check
  stack_in_ram before accessing memory via A3. Previously they assumed
  A3 was always a valid native pointer, causing memory corruption when
  in slow mode (A3 held raw GB SP value like 0xFFFE).

- Fixed initial SP setup to use fast mode with A3 pointing to actual
  HRAM memory instead of holding the raw GB SP value.

- STOP instruction now calls runtime handler to check for CGB speed
  switch instead of immediately halting. Enables double-speed mode.

- HDMA cancellation: writing to HDMA5 with bit 7=0 while HDMA is active
  now cancels the transfer (fixes Pokemon Crystal).

Safety improvements:
- Added src_ptr bounds check to prevent m68k_offsets array overflow
- Added PC validation to reject execution in VRAM/external RAM
- Added PC history ring buffer for crash debugging

Tested: Klax, Link's Awakening DX, Wario Land 3 now boot successfully.
2026-02-01 00:58:48 -08:00
Matthew Laux 77dd744b1e reset ly_read_cycle (fixes pokemon crystal infinite loop) 2026-01-31 20:44:24 -06:00
Matthew Laux ebb343cdbd support stack in HRAM (fixes DK '94) 2026-01-25 19:03:28 -06:00
Matthew Laux 1cbad8b28f second round of polish. v1.2.0 2026-01-24 20:30:13 -06:00
Matthew Laux d627b7265b re-add SP range detection, avoid copying lcd pixels twice 2026-01-21 21:20:42 -06:00
Matthew Laux e9000a3c84 rewrite stack for the millionth time 2026-01-15 21:09:57 -06:00
Matthew Laux 14474a0197 use A5/A6 as page table pointers, UI polish 2026-01-15 01:27:50 -06:00
Matthew Laux 1927fc04db arena allocator for blocks, remove duplicate blocks by tracking backward branches 2026-01-14 23:48:19 -06:00
Matthew Laux fb9c430397 clean up externs, make indentation consistent in jit, add some comments 2026-01-14 17:33:01 -06:00
Matthew Laux 0ce2ffd60e simplify cb ops, basic HALT, fast path for dmg_read/write16 2026-01-14 17:06:15 -06:00
Matthew Laux 74f91d802e prepare for dmg_read/write16, rename functions, simplify interop 2026-01-13 22:37:04 -06:00
Matthew Laux 9f91bd7526 add 1x scale, audio refactor and fix wave frequency issue, remove crazy SP detection and always go through dmg_read/write 2026-01-13 21:47:25 -06:00
Matthew Laux c611c553ca fix flag bugs (wow that was hard to find), make DIV better, add color icons 2026-01-12 19:24:03 -06:00
Matthew Laux a36c1dd72e inline reads/writes for stuff in paged areas 2026-01-07 20:43:55 -06:00
Matthew Laux 68937eb3f3 patch blocks to jump directly to next block 2026-01-07 18:53:53 -06:00
Matthew Laux f3864fef08 keep track of cycles per instruction, remove Mac timing hack 2026-01-04 23:30:22 -06:00
Matthew Laux 698fe41688 more efficient context switch into JIT, remove old compiler files, fix vblank flag bug 2026-01-04 17:45:52 -06:00
Matthew Laux 3d6156fa57 split out jit harness into its own file 2026-01-03 15:49:56 -06:00