Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Identify hardware register bits #469

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions constants/hardware_constants.asm
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,14 @@ DEF rWave_d EQU $ff3d
DEF rWave_e EQU $ff3e
DEF rWave_f EQU $ff3f
DEF rLCDC EQU $ff40 ; LCD Control (R/W)
DEF rLCDC_ENABLE EQU 7
DEF rLCDC_ENABLE_MASK EQU 1 << rLCDC_ENABLE
DEF rLCDC_BG_PRIORITY EQU 0
DEF rLCDC_SPRITES_ENABLE EQU 1
DEF rLCDC_SPRITE_SIZE EQU 2
DEF rLCDC_BG_TILEMAP EQU 3
DEF rLCDC_TILE_DATA EQU 4
DEF rLCDC_WINDOW_ENABLE EQU 5
DEF rLCDC_WINDOW_TILEMAP EQU 6
DEF rLCDC_ENABLE EQU 7
DEF rSTAT EQU $ff41 ; LCDC Status (R/W)
DEF rSCY EQU $ff42 ; Scroll Y (R/W)
DEF rSCX EQU $ff43 ; Scroll X (R/W)
Expand Down Expand Up @@ -111,3 +117,8 @@ DEF rSVBK EQU $ff70 ; CGB Mode Only - WRAM Bank
DEF rPCM12 EQU $ff76 ; Channels 1 & 2 Amplitude (R)
DEF rPCM34 EQU $ff77 ; Channels 3 & 4 Amplitude (R)
DEF rIE EQU $ffff ; Interrupt Enable (R/W)
DEF rIE_VBLANK EQU 0
DEF rIE_LCD EQU 1
DEF rIE_TIMER EQU 2
DEF rIE_SERIAL EQU 3
DEF rIE_JOYPAD EQU 4
4 changes: 2 additions & 2 deletions engine/movie/hall_of_fame.asm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ AnimateHallOfFame:
call FillMemory
call EnableLCD
ld hl, rLCDC
set 3, [hl]
set rLCDC_BG_TILEMAP, [hl]
xor a
ld hl, wHallOfFame
ld bc, HOF_TEAM
Expand Down Expand Up @@ -88,7 +88,7 @@ AnimateHallOfFame:
xor a
ldh [hWY], a
ld hl, rLCDC
res 3, [hl]
res rLCDC_BG_TILEMAP, [hl]
ret

HallOfFameText:
Expand Down
4 changes: 2 additions & 2 deletions engine/movie/intro.asm
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ PlayShootingStar:
call LoadIntroGraphics
call EnableLCD
ld hl, rLCDC
res 5, [hl]
set 3, [hl]
res rLCDC_WINDOW_ENABLE, [hl]
set rLCDC_BG_TILEMAP, [hl]
ld c, 64
call DelayFrames
farcall AnimateShootingStar
Expand Down
4 changes: 2 additions & 2 deletions home/init.asm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ SoftReset::
Init::
; Program init.

DEF rLCDC_DEFAULT EQU %11100011
; * LCD enabled
; * Window tile map at $9C00
; * Window display enabled
Expand All @@ -17,6 +16,7 @@ DEF rLCDC_DEFAULT EQU %11100011
; * 8x8 OBJ size
; * OBJ display enabled
; * BG display enabled
DEF rLCDC_DEFAULT EQU (1 << rLCDC_ENABLE) | (1 << rLCDC_WINDOW_TILEMAP) | (1 << rLCDC_WINDOW_ENABLE) | (1 << rLCDC_SPRITES_ENABLE) | (1 << rLCDC_BG_PRIORITY)

di

Expand All @@ -35,7 +35,7 @@ DEF rLCDC_DEFAULT EQU %11100011
ldh [rOBP0], a
ldh [rOBP1], a

ld a, rLCDC_ENABLE_MASK
ld a, 1 << rLCDC_ENABLE
ldh [rLCDC], a
call DisableLCD

Expand Down
4 changes: 2 additions & 2 deletions home/lcd.asm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ DisableLCD::
ldh [rIF], a
ldh a, [rIE]
ld b, a
res 0, a
res rIE_VBLANK, a
ldh [rIE], a

.wait
Expand All @@ -12,7 +12,7 @@ DisableLCD::
jr nz, .wait

ldh a, [rLCDC]
and ~rLCDC_ENABLE_MASK
and ~(1 << rLCDC_ENABLE)
ldh [rLCDC], a
ld a, b
ldh [rIE], a
Expand Down
6 changes: 3 additions & 3 deletions home/load_font.asm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
LoadFontTilePatterns::
ldh a, [rLCDC]
bit 7, a ; is the LCD enabled?
bit rLCDC_ENABLE, a
jr nz, .on
.off
ld hl, FontGraphics
Expand All @@ -16,7 +16,7 @@ LoadFontTilePatterns::

LoadTextBoxTilePatterns::
ldh a, [rLCDC]
bit 7, a ; is the LCD enabled?
bit rLCDC_ENABLE, a
jr nz, .on
.off
ld hl, TextBoxGraphics
Expand All @@ -32,7 +32,7 @@ LoadTextBoxTilePatterns::

LoadHpBarAndStatusTilePatterns::
ldh a, [rLCDC]
bit 7, a ; is the LCD enabled?
bit rLCDC_ENABLE, a
jr nz, .on
.off
ld hl, HpBarAndStatusGraphics
Expand Down