487 Commits

Author SHA1 Message Date
Toxa
ff0e55bd3b GB/SMS/GG: remove obsolete EMU_profiler_message() support which caused problems when building with --debug and have no sense anymore 2026-02-04 19:23:36 +03:00
Toxa
a51b4e04cc GB: fix the crash_handler 2026-01-04 00:21:34 +03:00
Toxa
04f758bba4 force linking EMU_profiler_message when including emu_debug.h 2026-01-04 00:19:14 +03:00
bbbbbr
29e436c835 Docs: Update changelog / migration through Dec 5, 2025
- Enable readable anchors in doxyfile
- Minor MegaDuck printer docs updates
- ZX0 compression updates
2025-12-06 02:19:42 -08:00
Toxa
0f5160316f GB: refactor get_bkg_xy_addr()/get_win_xy_addr() 2025-11-23 02:11:19 +03:00
Aaron Baker
6e7b094c7a gbdk-lib: Copied the definition of NULL from stddef.h into types.h, replacing the existing definition. Including types.h after stddef.h results in multiple definition, and the version in stddef.h is truer to the STD since it is a ptr type. 2025-10-15 15:44:07 -04:00
Toxa
d59bd395a8 SMS/GG: fix parameter order on the set_tile_submap/set_tile_submap_compat 2025-09-12 15:37:28 +03:00
Toxa
a2de13022e GB, SMS, MSX: include ZX0 decompressor into the library 2025-09-11 15:03:44 +03:00
VetriTheRetri
51f39d5fb1 Fix typo in fill_bkg_rect/fill_win_rect description: 0-31 -> 1-32 width/height range (#814)
* address typo in fill_bkg_rect/fill_win_rect description: 0-31 -> 1-32 width/height range
2025-09-05 16:32:52 -07:00
bbbbbr
04bac46997 Duck: changes resulting from printer research and example work (#807)
- Rework printer status functions
- Add printer query function
2025-08-11 16:55:57 -07:00
Toxa
6e5eb4421a raise version to 4.5 2025-08-01 16:58:27 +03:00
bbbbbr
cd459e8e0b Docs: Minor edits for updated APA mode ISRs, SMS/GG VDP migration note 2025-07-25 01:04:21 -07:00
Toxa
33139f4345 minor style 2025-07-21 11:46:54 +03:00
Toxa
99c2e580b7 GG: rename the "not interrupt" link port control bit 2025-07-19 23:11:39 +03:00
Michel Iwaniec
62de8abb87 NES: Add support for various tilemap layout (mirroring) configurations (#783)
* NES: Add support for various tilemap layout (mirroring) configurations

- Introduce platform configuration, mainly to define tilemap layout NES_TILEMAP_[F|H|V|S] in platform_cfg.s
  + Add NES_TILEMAP_S|H|V|F setting for tilemap layout, and hard-code to NES_TILEMAP_S for now
  + Add NES_LOMEM setting to enable current default of using part of stack instead of BSS for attribute shadow buffer
  + Edit Makefile to copy platform_cfg.s (if it exists) to platform directory after build

- Updates to attribute shadow buffer and dirty bits:
  + Add NUM_NT define for number of nametables used by a layout, and AT_SHADOW_WIDTH/_HEIGHT to denote the variable dimensions
  + Add convenience defines NT_2W / NT_2H to quickly test whether tilemap layout is two screens wide / high
  + Define _attribute_shadow and _attribute_row/_column_dirty in terms of NUM_NT
  + Update flush_attributes to support all layouts
  + Update get_bkg_xy_addr / set_bkg_tile_xy to support all layouts
  + Update set_bkg_attribute_xy[_nes16x16] to support all layouts
  + Update set_bkg_attributes[_nes16x16] to support all layouts, and correctly wrap to next AT in both directions
  + Update set_bkg_submap_attributes[_nes16x16] to support all layouts
  + Update set_bkg_submap to support all layouts, and contain common inner subroutine .set_bkg_common
  + Replace set_bkg_tiles with simpler implementation calling .set_bkg_common, and correctly wraps to next NT in both directions
  + Add set_bkg_based_tiles / set_bkg_based_submap implementations using the new common subroutine

- Updates to C include files:
  + Define DEVICE_SCREEN_BUFFER_WIDTH/_HEIGHT based on NES_TILEMAP_ setting, doubling high-level size of WIDTH / HEIGHT conditionally
  + Add typedefs scroll_x_t / scroll_y_t as uint8_t or uint16_t based on NES_TILEMAP_ setting
  + Make move_bkg use scroll_x/y_t typedefs, set 9th scroll bit in shadow_PPUCTRL where needed, and compensate for 239->0 y wrapping

- Updates to examples:
  + Update large_map example to use platform-agnostic settings for scroll wrapping and offset
  + Update rle_map to use a uint16_t for scroll position, to support NES_TILEMAP_H and NES_TILEMAP_F settings
2025-05-19 12:44:45 +01:00
Michel Iwaniec
5acc7cfbae NES: Improve TIMER interrupt emulation (#774)
- Move TIM ISR emulation to dedicated function .tim_emulation and dedicated file timer_isr.s

- Make TIM ISR emulation save entirety of ALL_REGTEMPS_BEGIN to ALL_REGTEMPS_END

- Improve emulation to allow average TIM rate to be faster compared to vblank rate

- Add support for consistent average TIM rate on PAL, for a less system-dependent timer

- Add support for different base dividers defined by GB-like TAC_REG variable

- Add defines values for "vblank parity mode" to global.s and nes.h

- Update crt0 init code to set TMA_REG to vblank parity mode correctly for PAL/Dendy

- Update documentation, describing the improved GB TIM emulation and vblank parity mode

- Update cross-platform IRQ example to better showcase the emulation
2025-05-06 11:40:17 +01:00
bbbbbr
83fd407006 Merge pull request #763 from bbbbbr/version_4_4_0
Build: Update gbdk version to 4.4.0
2025-04-27 15:23:55 -07:00
bbbbbr
0f073ab408 Docs: text changelog, other minor updates 2025-04-25 00:04:39 -07:00
Michel Iwaniec
03613b5550 NES: Make sure TIM ISR handlers are thread-safe (#760)
* NES: Make sure TIM ISR handlers are thread-safe

- Backup and restore REGTEMP area when calling TIM ISR in vblank

- Update irq example to use #pragma nooverlay for tim handler

- Add warning and explanation about having to use #pragma for TIM handlers in NES section of docs

- Add @anchor to docs, and a code example for #pragma nooverlay

- Update irq.c with `#pragma nooverlay` only being applied if NINTENDO_NES is defined

- Add more detailed comment of `#pragma nooverlay` in irq.c

- Add reference to docs in gb.h

- Add similar reference to nes.h
2025-04-22 08:36:41 +01:00
bbbbbr
d83ba2aff5 Build: Update gbdk version to 4.4.0 2025-04-21 03:05:02 -07:00
Michel Iwaniec
ac571c1dab NES: Align coordinates and scanline counting in LCD ISR implementation with GB, add SCX / SCY / LYC defines (#755)
NES: Align coordinates and scanline counting in LCD ISR implementation with GB, add SCX / SCY / LYC defines

- Change definition of _lcd_scanline to be -1 less than current, aligning with GB LYC register

- Change definition of _bkg_scroll_y to match GB's SCY, being relative to current scanline

- Refactor do_hblank_writes, delay_fractional and delay_to_scanline subroutines in crt0

- Add "#define LYC_REG" and "#define LY_REG" as aliases of _lcd_scanline

- Add #defines for SCX and SCY to alias _bkg_scroll_x / _bkg_scroll_y shadow variables

- Change text scroller example to use LYC_REG / SCX / SCY instead of _lcd_scanline / move_bkg, remove redundant #ifdefs

- Add subtle shake in y direction to text scroller example, to check that GB / NES coordinates match

- Update "From Game Boy to NES" section's descriptions of LCD handlers

- Update "Migrating to new GBDK versions" with a short description of bkg_scroll_y changing from absolute to relative Y coordinates for 4.4.0
2025-03-30 23:43:39 +01:00
bbbbbr
a2aa923973 Merge pull request #749 from bbbbbr/megaduck/laptop_io_updates
MegaDuck: Updated on duck laptop IO commands, expose a few vars
- Printer command labeled and some query commands for the init result
- Run cart command labeled
2025-03-13 01:59:15 -07:00
bbbbbr
692aec8b2d MegaDuck: Updated on duck laptop IO commands, expose a few vars
- Printer command labeled and some query commands for the init result
- Run cart command labeled
2025-03-13 01:55:39 -07:00
Michel Iwaniec
37186a5b7a NES: Timer interrupt emulation + support for set_interrupts(...)
- Add add_TIM / remove_TIM functions to nes.h

- Refactor implementation in lcd.s to support add_TIM / remove_TIM

- Add TMA_REG / TIMA_REG / TAC_REG vars to emulate GB hardware timer register

- Add call to TIM function at end of NMI handler in crt0.s, and make it use TMA_REG / TIMA_REG vars

- Add implementation for set_interrupts in lcd.s, replacing JMP instruction with RTS when disabled

- Enable NES target in examples/cross-platform/irq and replace delay(1000) call with 60 vsyncs

- Update examples/cross-platform/scroller and examples/cross-platform/irq to use set_interrupts

- Update documentation to describe use-cases and limitations of TIM handler
2025-03-09 03:07:44 +00:00
Toxa
e8c732dfe0 Merge branch 'develop' of https://github.com/gbdk-2020/gbdk-2020 into develop 2025-02-24 23:02:47 +03:00
Toxa
bd99d4ce69 SMS/GG: Timer interrupt emulation 2025-02-24 23:02:36 +03:00
bbbbbr
459dbfbff4 Docs: EMU_printf: Note %c vars should not be cast when passing
- Improve EMU_printf in example with more detailed version
2025-01-23 01:48:47 -08:00
Toxa
2d32eedb6e SMS/GG: Improve metasprite clipping by Y, change coordinate type to signed int16 2024-12-17 22:39:10 +03:00
Toxa
c2a3488821 SM83/Z80: register usage hints for the RNG functions 2024-11-13 17:33:43 +03:00
bbbbbr
2dba64d663 Merge pull request #723 from bbbbbr/examples/mbc7_accelerometer
Examples: MBC7 support and example
2024-10-23 03:11:49 -07:00
bbbbbr
cd9be14784 Export _vbl_done for z80 platforms as well
- Also fix incorrect flag state comment for gb version
2024-10-23 03:05:34 -07:00
bbbbbr
0e2243641b Examples: MBC7 support and example 2024-10-23 01:47:38 -07:00
Michel Iwaniec
fbd7653313 NES: Fix bugs with non-multiple-of-2 (/4) map width in set_bkg_submap_attributes (#722)
* Add +1 before shift in inline function set_bkg_submap_attributes
* Add-with carry after right-shift of width in set_bkg_submap_attributes_nes16x16
2024-10-20 00:59:54 +01:00
Michel Iwaniec
94793354ab NES: Add reset function for compatibility (#719) 2024-10-16 00:57:33 +01:00
bbbbbr
2b1bfdc841 Examples: MegaDuck Laptop: Speech example
- Also fix up missing end of file lines in makefile.targets for other two examples
2024-10-05 22:31:22 -07:00
bbbbbr
70c90bdf9f MegaDuck laptop examples (kbd, rtc) 2024-10-02 03:25:50 -07:00
Tempestro
52279b5cb5 Added leading \li's 2024-05-27 11:59:30 -07:00
Tempestro
340e851d1a probably looks better 2024-05-27 11:59:30 -07:00
Tempestro
dec16ab22e Mention that HIDE_BKG/SHOW_BKG don't work on CGB
Adds a mention to the docs that HIDE_BKG and SHOW_BKG do not work while running in CGB mode, the relevant bit instead overrides all background/window priority over the sprite layer, see Pandocs 4.4
2024-05-27 11:59:30 -07:00
Michel Iwaniec
54dbf0722e NES: Add BCD support
* Copy gbdk-lib/include/gb/bcd.h to gbdk-lib/include/nes/bcd.h
* Add bcd asm implementation in libc/asm/mos6502/bcd.s
* Update bcd.h to accept NES target
* Update examples/cross-platform/bcd to build for nes
2024-05-18 02:09:44 +01:00
Michel Iwaniec
0b424fafc7 NES: Add deferred hblank system for fake LCD ISRs
* Refactor .delay_to_lcd_scanline to not use Y register. Remove outdated comments.
* Move .jmp_to_LCD_isr call to vsync routine, and have it copy shadow PPU register values to a buffer
* Add MAX_LCD_ISR_CALLS define to limit the deferred PPU register write buffer size
* Add .do_lcd_ppu_reg_writes for writing buffer aligned to hblank, and calls to .delay_to_lcd_scanline
* Make .do_lcd_ppu_reg_write restore Y-scroll for start-of-frame after every update, to mitigate glitches in lag frames
* Have LCD at scanline#0 be treated as a special-case, where VBL shadow values are replaced without adding to the buffer
* Re-introduce variable to skip NMI as __crt0_disableNMI, and set it in vsync during buffer building

Update text_scroller example:
* Fix NES-version of code to do multiple splits like the other platforms do
* Fill nametable with '*' to make splits more visible
* TODO: Find out why fill_bkg_rect isn't working on GB
2024-05-14 23:54:55 +01:00
Toxa
ac368f922e SMS/GG: fix joypad()/waitpad()/waitpadup() definitions; add delay required for reading the 3 and 6-button Genesis controller in waitpad()/waitpadup() for the SMS 2024-05-09 15:41:48 +03:00
Toxa
ae0adcb633 Z80/SM83: convert abs() to the new calling convention; use REENTRANT macro in stdlib.h 2024-05-07 18:05:23 +03:00
bbbbbr
ea8ff534b3 Docs: 4.3.0: first pass at Release Notes, Changelog, Migration notes 2024-05-06 00:38:56 -07:00
bbbbbr
e26b3b37d6 Build: Update gbdk version to 4.3.0 2024-05-05 23:47:15 -07:00
bbbbbr
21c52a02fa Docs: comments for AUD* register constants 2024-04-30 03:28:12 -07:00
Michel Iwaniec
350c221b22 Changes in response to PR review:
* Name change for consistency with other platforms: _system_bits -> _SYSTEM
* Add _SYSTEM extern to msx.h and sms.h
* Make all platforms have SYSTEM_60HZ and 0x00 and SYSTEM_50HZ as 0x01
* Make _SYSTEM have uint8_t type instead of UBYTE
2024-04-28 17:55:32 +01:00
Michel Iwaniec
9f8103ad4d NES: Add PAL support
* Add new zeropage variable _system_bits to indicate NTSC/PAL/Dendy system
* Modify init code to detect NTSC/PAL/Dendy via cycle counting, storing result in _system_bits
* Modify fake-LCD-ISR delays in NMI handler to accommodate PAL timings

Cross-platform:
* Change existing SYSTEM_NTSC / SYSTEM_PAL defines in sms.h to SYSTEM_60HZ / SYSTEM_50HZ, and copy them to gb.h / nes.h / msx.h
* Add new cross-platform function get_system for all ports, to query whether running on a 60Hz or 50Hz system
* Add minimal cross-platform display_system example to exercise get_system
2024-04-28 00:54:55 +01:00
Toxa
ccc8ed1bf6 SMS/GG refactor joypad polling: support 3 and 6 button controller in joypad() 2024-04-26 11:33:48 +03:00
Toxa
d094af07c7 MSXDOS: implement _SYSTEM variable which tells whether system is PAL or NTSC (no real detection yet, returns NTSC), remove useless artifacts from the SMS port 2024-04-26 11:28:48 +03:00