Skip to content

Commit d0a2c33

Browse files
authored
Add several more flags, bit numbers, and offset constants (#14)
* Add bit numbers for flags in rSTAT * Add more flag definitions and define WX_OFS * Add offset constants for OAM X and Y coordinates
1 parent 72ec03f commit d0a2c33

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

hardware.inc

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
;* Rev 2.9 - 28-Feb-20 : Added utility rP1 constants
2727
;* Rev 3.0 - 27-Aug-20 : Register ordering, byte-based sizes, OAM additions, general cleanup (Blitter Object)
2828
;* Rev 4.0 - 03-May-21 : Updated to use RGBDS 0.5.0 syntax, changed IEF_LCDC to IEF_STAT (Eievui)
29+
;* Rev 4.1 - 16-Aug-21 : Added more flags, bit number defines, and offset constants for OAM and window positions (rondnelson99)
2930

3031
IF __RGBDS_MAJOR__ == 0 && __RGBDS_MINOR__ < 5
3132
FAIL "This version of 'hardware.inc' requires RGBDS version 0.5.0 or later."
@@ -39,7 +40,7 @@ DEF HARDWARE_INC EQU 1
3940
MACRO rev_Check_hardware_inc
4041
;NOTE: REVISION NUMBER CHANGES MUST BE ADDED
4142
;TO SECOND PARAMETER IN FOLLOWING LINE.
42-
IF \1 > 4.0 ;PUT REVISION NUMBER HERE
43+
IF \1 > 4.1 ;PUT REVISION NUMBER HERE
4344
WARN "Version \1 or later of 'hardware.inc' is required."
4445
ENDC
4546
ENDM
@@ -103,6 +104,13 @@ DEF rSB EQU $FF01
103104
; --
104105
DEF rSC EQU $FF02
105106

107+
DEF SCF_START EQU %10000000 ;Transfer Start Flag (1=Transfer in progress, or requested)
108+
DEF SCF_SPEED EQU %00000010 ;Clock Speed (0=Normal, 1=Fast) ** CGB Mode Only **
109+
DEF SCF_SOURCE EQU %00000001 ;Shift Clock (0=External Clock, 1=Internal Clock)
110+
111+
DEF SCB_START EQU 7
112+
DEF SCB_SPEED EQU 1
113+
DEF SCB_SOURCE EQU 0
106114

107115
; --
108116
; -- DIV ($FF04)
@@ -452,6 +460,12 @@ DEF STATF_OAM EQU %00000010 ; OAM-RAM is used by system
452460
DEF STATF_LCD EQU %00000011 ; Both OAM and VRAM used by system
453461
DEF STATF_BUSY EQU %00000010 ; When set, VRAM access is unsafe
454462

463+
DEF STATB_LYC EQU 6
464+
DEF STATB_MODE10 EQU 5
465+
DEF STATB_MODE01 EQU 4
466+
DEF STATB_MODE00 EQU 3
467+
DEF STATB_LYCF EQU 2
468+
DEF STATB_BUSY EQU 1
455469

456470
; --
457471
; -- SCY ($FF42)
@@ -542,6 +556,8 @@ DEF rWY EQU $FF4A
542556
; --
543557
DEF rWX EQU $FF4B
544558

559+
DEF WX_OFS EQU 7 ; add this to a screen position to get a WX position
560+
545561

546562
; --
547563
; -- SPEED ($FF4D)
@@ -696,6 +712,12 @@ DEF IEF_TIMER EQU %00000100 ; Timer Overflow
696712
DEF IEF_STAT EQU %00000010 ; STAT
697713
DEF IEF_VBLANK EQU %00000001 ; V-Blank
698714

715+
DEF IEB_HILO EQU 4
716+
DEF IEB_SERIAL EQU 3
717+
DEF IEB_TIMER EQU 2
718+
DEF IEB_STAT EQU 1
719+
DEF IEB_VBLANK EQU 0
720+
699721

700722
;***************************************************************************
701723
;*
@@ -879,12 +901,15 @@ DEF SCRN_VY_B EQU 32 ; Virtual height of screen in bytes
879901
; OAM attributes
880902
; each entry in OAM RAM is 4 bytes (sizeof_OAM_ATTRS)
881903
RSRESET
882-
DEF OAMA_Y RB 1 ; y pos
883-
DEF OAMA_X RB 1 ; x pos
904+
DEF OAMA_Y RB 1 ; y pos plus 16
905+
DEF OAMA_X RB 1 ; x pos plus 8
884906
DEF OAMA_TILEID RB 1 ; tile id
885907
DEF OAMA_FLAGS RB 1 ; flags (see below)
886908
DEF sizeof_OAM_ATTRS RB 0
887909

910+
DEF OAM_Y_OFS EQU 16 ; add this to a screen-relative Y position to get an OAM Y position
911+
DEF OAM_X_OFS EQU 8 ; add this to a screen-relative X position to get an OAM X position
912+
888913
DEF OAM_COUNT EQU 40 ; number of OAM entries in OAM RAM
889914

890915
; flags
@@ -919,4 +944,4 @@ ENDM
919944

920945
DEF IEF_LCDC EQU %00000010 ; LCDC (see STAT)
921946

922-
ENDC ;HARDWARE_INC
947+
ENDC ;HARDWARE_INC

0 commit comments

Comments
 (0)