From 7d54bd2b4664f7c2f7d8366e6414f70149a13547 Mon Sep 17 00:00:00 2001 From: Matt Currie Date: Wed, 31 Dec 2025 12:17:08 +1300 Subject: [PATCH 1/6] Add PSW related registers --- HISTORY.md | 2 ++ README.md | 2 +- hardware.inc | 51 +++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 52 insertions(+), 3 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index fe87ed9..c42972d 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -113,3 +113,5 @@ - Added `JOYP_SGB_*` constants - Added more `BOOTUP_*` value constants - Corrected comments on some audio registers +- **Rev 5.4.0** - 2025-12-31 *(mattcurrie)* + - Added registers and constants for PSW diff --git a/README.md b/README.md index 63d44bc..de27c8e 100644 --- a/README.md +++ b/README.md @@ -24,5 +24,5 @@ Breaking changes increase the major version, backwards-compatible changes (typic * Carsten Sørensen (whose ideas Jeff based his file on) * Jeff Frohwein * AntonioND -* BlitterObjectBob, tobiasvl, ISSOtm, Rangi42, avivace, Eievui, QuinnPainter, rondnelson99, daid, Hacktix, sukus21, alvaro-cuesta, basxto +* BlitterObjectBob, tobiasvl, ISSOtm, Rangi42, avivace, Eievui, QuinnPainter, rondnelson99, daid, Hacktix, sukus21, alvaro-cuesta, basxto, mattcurrie * Probably lots of other people who have added to the file throughout the years diff --git a/hardware.inc b/hardware.inc index d0f6547..46a8632 100644 --- a/hardware.inc +++ b/hardware.inc @@ -22,7 +22,7 @@ endc ; Define the include guard and the current hardware.inc version ; (do this after the RGBDS version check since the `def` syntax depends on it) def HARDWARE_INC equ 1 -def HARDWARE_INC_VERSION equs "5.3.0" +def HARDWARE_INC_VERSION equs "5.4.0" ; Usage: rev_Check_hardware_inc ; Examples: @@ -689,7 +689,54 @@ def rWBK equ $FF70 def WBK_BANK equ %00000_111 ; mapped WRAM bank (0-7) [r/w] -; -- $FF71-$FF75 are unused --------------------------------------------------- +; -- PSW ($FF71) -------------------------------------------------------------- +; (CGB boot ROM only) Palette Selection Window and NMI control. [r/w CGB's DMG mode only] +; In the CGB's CGB mode reads return $FF and writes are ignored. +; Bits 1-6 are always 1. +def rPSW equ $FF71 + +def B_PSW_WINDOW equ 7 ; whether the Palette Selection Window is enabled [r/w CGB's DMG mode only] +def B_PSW_NMI equ 0 ; whether the NMI is enabled [r/w CGB's DMG mode only] + def PSW_WINDOW equ 1 << B_PSW_WINDOW + def PSW_WIN_OFF equ 0 << B_PSW_WINDOW + def PSW_WIN_ON equ 1 << B_PSW_WINDOW + def PSW_NMI equ 1 << B_PSW_NMI + def PSW_NMI_DISABLE equ 0 << B_PSW_NMI + def PSW_NMI_ENABLE equ 1 << B_PSW_NMI + +; -- PSWX ($FF72) ------------------------------------------------------------- +; (CGB boot ROM only) X coordinate of the Palette Selection Window's top-left pixel, plus 7 (7-166) [r/w] +; Readable and writable in both CGB and DMG mode. +def rPSWX equ $FF72 + +; -- PSWY ($FF73) ------------------------------------------------------------- +; (CGB boot ROM only) Y coordinate of the Palette Selection Window's top-left pixel (0-143) [r/w] +; Readable and writable in both CGB and DMG mode. +def rPSWY equ $FF73 + +; -- PSM ($FF74) -------------------------------------------------------------- +; (CGB boot ROM only) Set the Palette Selection Window button mask (triggers NMI when pressed) [r/w] +; Readable and writable in both CGB and DMG mode. +def rPSM equ $FF74 + +def B_PSM_START equ 7 +def B_PSM_SELECT equ 6 +def B_PSM_B equ 5 +def B_PSM_A equ 4 +def B_PSM_DOWN equ 3 +def B_PSM_UP equ 2 +def B_PSM_LEFT equ 1 +def B_PSM_RIGHT equ 0 + def PSM_START equ 1 << B_PSM_START + def PSM_SELECT equ 1 << B_PSM_SELECT + def PSM_B equ 1 << B_PSM_B + def PSM_A equ 1 << B_PSM_A + def PSM_DOWN equ 1 << B_PSM_DOWN + def PSM_UP equ 1 << B_PSM_UP + def PSM_LEFT equ 1 << B_PSM_LEFT + def PSM_RIGHT equ 1 << B_PSM_RIGHT + +; -- $FF75 is unused ---------------------------------------------------------- ; -- PCM12 ($FF76) ------------------------------------------------------------ ; Audio channels 1 and 2 output From 55e8c3b200204721c5752435d0fdf99603a0189b Mon Sep 17 00:00:00 2001 From: Matt Currie Date: Wed, 31 Dec 2025 13:18:54 +1300 Subject: [PATCH 2/6] Revert change to HISTORY.md Co-authored-by: Rangi <35663410+Rangi42@users.noreply.github.com> --- HISTORY.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index c42972d..fe87ed9 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -113,5 +113,3 @@ - Added `JOYP_SGB_*` constants - Added more `BOOTUP_*` value constants - Corrected comments on some audio registers -- **Rev 5.4.0** - 2025-12-31 *(mattcurrie)* - - Added registers and constants for PSW From f76574afe773580d10c4d3e52cb00b7365a0404e Mon Sep 17 00:00:00 2001 From: Matt Currie Date: Wed, 31 Dec 2025 13:19:07 +1300 Subject: [PATCH 3/6] Revert change to hardware.inc Co-authored-by: Rangi <35663410+Rangi42@users.noreply.github.com> --- hardware.inc | 1 - 1 file changed, 1 deletion(-) diff --git a/hardware.inc b/hardware.inc index 46a8632..4ad2bdc 100644 --- a/hardware.inc +++ b/hardware.inc @@ -22,7 +22,6 @@ endc ; Define the include guard and the current hardware.inc version ; (do this after the RGBDS version check since the `def` syntax depends on it) def HARDWARE_INC equ 1 -def HARDWARE_INC_VERSION equs "5.4.0" ; Usage: rev_Check_hardware_inc ; Examples: From 1a5a428936004f9f76dbb5ab7b2b62410c60a9ee Mon Sep 17 00:00:00 2001 From: Matt Currie Date: Wed, 31 Dec 2025 13:20:56 +1300 Subject: [PATCH 4/6] Adjust DMG mode commentry Co-authored-by: Rangi <35663410+Rangi42@users.noreply.github.com> --- hardware.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hardware.inc b/hardware.inc index 4ad2bdc..b7e6cc0 100644 --- a/hardware.inc +++ b/hardware.inc @@ -689,9 +689,9 @@ def rWBK equ $FF70 def WBK_BANK equ %00000_111 ; mapped WRAM bank (0-7) [r/w] ; -- PSW ($FF71) -------------------------------------------------------------- -; (CGB boot ROM only) Palette Selection Window and NMI control. [r/w CGB's DMG mode only] -; In the CGB's CGB mode reads return $FF and writes are ignored. +; (CGB boot ROM's DMG mode only) Palette Selection Window and NMI control. [r/w] ; Bits 1-6 are always 1. +; In CGB mode, reads return $FF and writes are ignored. def rPSW equ $FF71 def B_PSW_WINDOW equ 7 ; whether the Palette Selection Window is enabled [r/w CGB's DMG mode only] From 8e18fe83e01de20bfd2efa404563afd948c86471 Mon Sep 17 00:00:00 2001 From: Matt Currie Date: Wed, 31 Dec 2025 13:21:05 +1300 Subject: [PATCH 5/6] Adjust DMG mode commentry Co-authored-by: Rangi <35663410+Rangi42@users.noreply.github.com> --- hardware.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hardware.inc b/hardware.inc index b7e6cc0..4854295 100644 --- a/hardware.inc +++ b/hardware.inc @@ -694,8 +694,8 @@ def WBK_BANK equ %00000_111 ; mapped WRAM bank (0-7) [r/w] ; In CGB mode, reads return $FF and writes are ignored. def rPSW equ $FF71 -def B_PSW_WINDOW equ 7 ; whether the Palette Selection Window is enabled [r/w CGB's DMG mode only] -def B_PSW_NMI equ 0 ; whether the NMI is enabled [r/w CGB's DMG mode only] +def B_PSW_WINDOW equ 7 ; whether the Palette Selection Window is enabled [r/w] +def B_PSW_NMI equ 0 ; whether the NMI is enabled [r/w] def PSW_WINDOW equ 1 << B_PSW_WINDOW def PSW_WIN_OFF equ 0 << B_PSW_WINDOW def PSW_WIN_ON equ 1 << B_PSW_WINDOW From 865cf6fbcdf0c1260c5c88c6f5da9fde19724db5 Mon Sep 17 00:00:00 2001 From: Rangi <35663410+Rangi42@users.noreply.github.com> Date: Tue, 30 Dec 2025 19:24:45 -0500 Subject: [PATCH 6/6] Restore `HARDWARE_INC_VERSION` --- hardware.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/hardware.inc b/hardware.inc index 4854295..206f0e9 100644 --- a/hardware.inc +++ b/hardware.inc @@ -22,6 +22,7 @@ endc ; Define the include guard and the current hardware.inc version ; (do this after the RGBDS version check since the `def` syntax depends on it) def HARDWARE_INC equ 1 +def HARDWARE_INC_VERSION equs "5.3.0" ; Usage: rev_Check_hardware_inc ; Examples: