From 4ee4655e72c770be3f0451f4f249b61376f4f71c Mon Sep 17 00:00:00 2001 From: xCrystal Date: Sun, 27 Aug 2023 16:27:11 +0200 Subject: [PATCH] constants for rSTAT register --- constants/hardware_constants.asm | 11 +++++++++++ engine/gfx/dma_transfer.asm | 6 +++--- engine/menus/savemenu_copytilemapatonce.asm | 2 +- engine/phone/phonering_copytilemapatonce.asm | 2 +- home/init.asm | 2 +- 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/constants/hardware_constants.asm b/constants/hardware_constants.asm index cf696d84e..577889bd8 100644 --- a/constants/hardware_constants.asm +++ b/constants/hardware_constants.asm @@ -131,6 +131,17 @@ DEF rLCDC_WINDOW_TILEMAP EQU 6 ; 0=9800-9BFF, 1=9C00-9FFF DEF rLCDC_ENABLE EQU 7 ; 0=Off, 1=On DEF LCDC_DEFAULT EQU (1 << rLCDC_ENABLE) | (1 << rLCDC_WINDOW_TILEMAP) | (1 << rLCDC_WINDOW_ENABLE) | (1 << rLCDC_SPRITES_ENABLE) | (1 << rLCDC_BG_PRIORITY) DEF rSTAT EQU $ff41 ; LCDC Status (R/W) +DEF rSTAT_STATUS_FLAGS EQU %00000011 ; LCD controller status (Read Only) +DEF rSTAT_HBLANK_MASK EQU %00000000 ; In H-Blank (Read Only) +DEF rSTAT_VBLANK_MASK EQU %00000001 ; In V-Blank (Read Only) +DEF rSTAT_OAM_MASK EQU %00000010 ; OAM is used by system (Read Only) +DEF rSTAT_LCD_MASK EQU %00000011 ; Both OAM and VRAM used by system (Read Only) +DEF rSTAT_BUSY EQU 1 ; When set, VRAM access is unsafe (Read Only) +DEF rSTAT_LYC EQU 2 ; LYC=LY (0=Different, 1=Equal) (Read Only) +DEF rSTAT_INT_HBLANK EQU 3 ; Mode 00: H-Blank (Selectable) +DEF rSTAT_INT_VBLANK EQU 4 ; Mode 01: V-Blank (Selectable) +DEF rSTAT_INT_OAM EQU 5 ; Mode 02: OAM (Selectable) +DEF rSTAT_INT_LYC EQU 6 ; LYC=LY Coincidence (Selectable) DEF rSCY EQU $ff42 ; Scroll Y (R/W) DEF rSCX EQU $ff43 ; Scroll X (R/W) DEF rLY EQU $ff44 ; LCDC Y-Coordinate (R) diff --git a/engine/gfx/dma_transfer.asm b/engine/gfx/dma_transfer.asm index 98912aa80..959438cae 100644 --- a/engine/gfx/dma_transfer.asm +++ b/engine/gfx/dma_transfer.asm @@ -194,7 +194,7 @@ HDMATransfer_NoDI: ; while not [rSTAT] & 3: pass .loop2 ldh a, [rSTAT] - and $3 + and rSTAT_STATUS_FLAGS jr z, .loop2 ; load the 5th byte of HDMA ld a, b @@ -253,12 +253,12 @@ _continue_HDMATransfer: ; while [rSTAT] & 3: pass .rstat_loop_1 ldh a, [rSTAT] - and $3 + and rSTAT_STATUS_FLAGS jr nz, .rstat_loop_1 ; while not [rSTAT] & 3: pass .rstat_loop_2 ldh a, [rSTAT] - and $3 + and rSTAT_STATUS_FLAGS jr z, .rstat_loop_2 ; load the 5th byte of HDMA ld a, e diff --git a/engine/menus/savemenu_copytilemapatonce.asm b/engine/menus/savemenu_copytilemapatonce.asm index 17f7c7312..1d755a330 100644 --- a/engine/menus/savemenu_copytilemapatonce.asm +++ b/engine/menus/savemenu_copytilemapatonce.asm @@ -47,7 +47,7 @@ SaveMenu_CopyTilemapAtOnce: ld l, 0 ld a, SCREEN_HEIGHT ldh [hTilesPerCycle], a - ld b, 1 << 1 ; not in v/hblank + ld b, 1 << rSTAT_BUSY ; not in v/hblank ld c, LOW(rSTAT) .loop diff --git a/engine/phone/phonering_copytilemapatonce.asm b/engine/phone/phonering_copytilemapatonce.asm index 6cbeecf20..a8b2d266f 100644 --- a/engine/phone/phonering_copytilemapatonce.asm +++ b/engine/phone/phonering_copytilemapatonce.asm @@ -51,7 +51,7 @@ PhoneRing_CopyTilemapAtOnce: ld l, 0 ld a, SCREEN_HEIGHT ldh [hTilesPerCycle], a - ld b, 1 << 1 ; not in v/hblank + ld b, 1 << rSTAT_BUSY ; not in v/hblank ld c, LOW(rSTAT) .loop diff --git a/home/init.asm b/home/init.asm index 05b86316e..47d4da79e 100644 --- a/home/init.asm +++ b/home/init.asm @@ -108,7 +108,7 @@ Init:: ldh [hSCY], a ldh [rJOYP], a - ld a, $8 ; HBlank int enable + ld a, 1 << rSTAT_INT_HBLANK ldh [rSTAT], a ld a, $90