Commit Graph
67 Commits
Author SHA1 Message Date
Matthew Laux f89ff7f0a9 rename main_ram -> wram and video_ram -> vram, optimize dmg struct layout 2026-08-12 20:13:20 -05:00
Matthew Laux 4e424aeb4f rename zero_page to hram 2026-08-12 19:55:32 -05:00
Matthew Laux 8fdeb086fe track HRAM self modifying code... fixes DW3 textboxes, speed-- 2026-08-10 17:57:38 -05:00
Matthew Laux b9a4e32fbb remove unused 68020 mode 2026-08-08 00:25:48 -05:00
Matthew Laux 9142963262 migrate to 4k page size - bank switch optimization pt 2 2026-08-07 20:06:24 -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 91bfca6039 remove dead code 2026-08-04 17:39:06 -05:00
Matthew Laux ad1d7b392c fix noise being too loud, fix duty cycle of square waves, cache joypad value for fast read 2026-08-01 14:03:03 -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 4382e3f7ce version 2.1.0 2026-07-28 21:26:51 -05:00
Matthew Laux 985666d727 "deadline-gating budget_touch" omg 2026-07-27 16:49:53 -05:00
Matthew Laux f621a0d703 use GetKeys to avoid wasting time in GetNextEvent, use shared memory access helpers instead of inlining 2026-07-27 16:42:16 -05:00
Matthew Laux 42acc41a0d WIP compiler improvements 2026-07-27 11:24:31 -05:00
Matthew Laux ceeb2a6cc7 asm version of bg tile inner loop, optimize multiplies in audio 2026-07-24 22:03:40 -05:00
Matthew Laux 0b7c9e7501 fix spurious writes into the cgb_color_lut 2026-07-24 14:34:29 -05:00
Matthew Laux 5089339121 optimize memory usage by reclaiming unused block bytes 2026-07-12 18:48:03 -05:00
Matthew Laux 5464e0721f remove STAT throttling, add a menu option instead 2026-07-12 17:39:17 -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 a4293c0fd2 deadline scheduler for events, improve timer, and add no-op serial support - fix FFL, FFA, alleyway
カエルのために is now slower?
2026-07-12 00:14:56 -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
Matthew Laux 1eb1209097 optimize register usage for write, add patch system 2026-02-03 18:29:48 -06:00
Tanner Fokkens 39d9dcca74 Forgot to add other files... 2026-02-01 15:29:19 -08:00
Tanner Fokkens c5fb8064aa Fix CGB detection: set A=0x11 for CGB mode 2026-02-01 01:12:15 -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
Tanner Fokkens 9bb5705759 Add Game Boy Color support
- New CGB state management (cgb.c/cgb.h)
  - VRAM banking (VBK register)
  - WRAM banking (SVBK register, banks 1-7)
  - Speed switching (KEY1 register)
  - HDMA transfers (HDMA1-5 registers)
  - CGB palette registers (BCPS/BCPD, OCPS/OCPD)

- CGB rendering (lcd_cgb.c, lcd_mac_cgb.c)
  - Tile attributes from VRAM bank 1
  - Per-tile palettes, H/V flip, priority
  - 8 background and 8 sprite palettes
  - RGB555 to Mac indexed color conversion

- JIT initialization sets A=$11 for CGB mode detection

- UI: "Run as GBC" menu option, .gbc file filter

Working: Tetris DX, Pokemon Gold
Known issues: Crystal, SMB Deluxe, LADX hang at boot
2026-02-01 00:57:25 -08:00
Matthew Laux 2f23570674 fix SP init (fixes random crashes on exit) 2026-01-31 21:56:34 -06:00
Matthew Laux 77dd744b1e reset ly_read_cycle (fixes pokemon crystal infinite loop) 2026-01-31 20:44:24 -06:00
Matthew Laux 806728a708 remove unused cpu struct 2026-01-28 13:56:38 -06:00
Matthew Laux ebb343cdbd support stack in HRAM (fixes DK '94) 2026-01-25 19:03:28 -06:00
Matthew Laux 6d5ffbf7f7 recover from OOM on banked cache allocation 2026-01-24 23:26:21 -06:00
Matthew Laux 1cbad8b28f second round of polish. v1.2.0 2026-01-24 20:30:13 -06:00
Matthew Laux 8b78a9345b sync audio with GB execution - still not sure if i like this better 2026-01-24 02:20:26 -06:00
Matthew Laux 70ff0224cb convert machine code arrays to gcc inline assembler 2026-01-23 00:22:01 -06:00
Matthew Laux 0037fae05a fix instruction caching issue on 68040 2026-01-22 23:16:30 -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 230a9c929b write a README, add screenshots, audio tweaks with band limited square waves 2026-01-17 00:14:05 -06:00
Matthew Laux e9000a3c84 rewrite stack for the millionth time 2026-01-15 21:09:57 -06:00
Matthew Laux bf46e65f5a dumb "force draw sprites" that doesn't work 2026-01-15 19:27:44 -06:00
Matthew Laux f8e508ecd2 LY wait detection, fix block overflow bug, add new menus, MBC5 2026-01-15 16:46:17 -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 9abe1c4bb1 remove bogus O 2026-01-13 00:24:59 -06:00
Matthew Laux e0e8e5d967 remove timing hacks, add audio menu option, try to measure audio overhead 2026-01-13 00:20:52 -06:00