Skip to content

Commit b9be424

Browse files
committed
Update hardware.inc to 5.3.0 and use its new constants
1 parent 74bdac9 commit b9be424

File tree

7 files changed

+65
-43
lines changed

7 files changed

+65
-43
lines changed

src/constants/gfx_constants.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ DEF palettes EQUS "* PAL_SIZE"
44
DEF NUM_BACKGROUND_PALETTES EQU 8
55
DEF NUM_OBJECT_PALETTES EQU 8
66

7-
DEF PALRGB_WHITE EQU (31 << B_COLOR_BLUE) | (31 << B_COLOR_GREEN) | (31 << B_COLOR_RED)
7+
DEF PALRGB_WHITE EQU (COLOR_CH_MAX << B_COLOR_BLUE) | (COLOR_CH_MAX << B_COLOR_GREEN) | (COLOR_CH_MAX << B_COLOR_RED)
88

99
; tile size
1010
DEF tiles EQUS "* TILE_SIZE"

src/constants/hardware.inc

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ endc
2222
; Define the include guard and the current hardware.inc version
2323
; (do this after the RGBDS version check since the `def` syntax depends on it)
2424
def HARDWARE_INC equ 1
25-
def HARDWARE_INC_VERSION equs "5.2.0"
25+
def HARDWARE_INC_VERSION equs "5.3.0"
2626

2727
; Usage: rev_Check_hardware_inc <min_ver>
2828
; Examples:
@@ -76,6 +76,14 @@ def B_JOYP_RIGHT equ 0 ; 0 = Right is pressed (if reading Control Pad) [ro]
7676
def JOYP_LEFT equ 1 << B_JOYP_LEFT
7777
def JOYP_RIGHT equ 1 << B_JOYP_RIGHT
7878

79+
; SGB command packet transfer uses for JOYP bits
80+
def B_JOYP_SGB_ONE equ 5 ; 0 = sending 1 bit
81+
def B_JOYP_SGB_ZERO equ 4 ; 0 = sending 0 bit
82+
def JOYP_SGB_START equ %00_00_0000 ; start SGB packet transfer
83+
def JOYP_SGB_ONE equ %00_01_0000 ; send 1 bit
84+
def JOYP_SGB_ZERO equ %00_10_0000 ; send 0 bit
85+
def JOYP_SGB_FINISH equ %00_11_0000 ; finish SGB packet transfer
86+
7987
; Combined input byte, with Control Pad in high nybble (conventional order)
8088
def B_PAD_DOWN equ 7
8189
def B_PAD_UP equ 6
@@ -96,7 +104,6 @@ def B_PAD_A equ 0
96104
def PAD_B equ 1 << B_PAD_B
97105
def PAD_A equ 1 << B_PAD_A
98106

99-
100107
; Combined input byte, with Control Pad in low nybble (swapped order)
101108
def B_PAD_SWAP_START equ 7
102109
def B_PAD_SWAP_SELECT equ 6
@@ -222,7 +229,7 @@ def AUD1ENV_PACE equ %00000_111 ; how long between envelope iterations
222229
; (in 64 Hz ticks, ~15.6 ms apart) [r/w]
223230

224231
; -- AUD1LOW / NR13 ($FF13) ---------------------------------------------------
225-
; Audio channel 1 period (low 8 bits) [r/w]
232+
; Audio channel 1 period (low 8 bits) [wo]
226233
def rAUD1LOW equ $FF13
227234

228235
; -- AUD1HIGH / NR14 ($FF14) --------------------------------------------------
@@ -266,7 +273,7 @@ def AUD2ENV_PACE equ %00000_111 ; how long between envelope iterations
266273
; (in 64 Hz ticks, ~15.6 ms apart) [r/w]
267274

268275
; -- AUD2LOW / NR23 ($FF18) ---------------------------------------------------
269-
; Audio channel 2 period (low 8 bits) [r/w]
276+
; Audio channel 2 period (low 8 bits) [wo]
270277
def rAUD2LOW equ $FF18
271278

272279
; -- AUD2HIGH / NR24 ($FF19) --------------------------------------------------
@@ -304,7 +311,7 @@ def AUD3LEVEL_VOLUME equ %0_11_00000 ; volume level [r/w]
304311
def AUD3LEVEL_25 equ %0_11_00000 ; 25%
305312

306313
; -- AUD3LOW / NR33 ($FF1D) ---------------------------------------------------
307-
; Audio channel 3 period (low 8 bits) [r/w]
314+
; Audio channel 3 period (low 8 bits) [wo]
308315
def rAUD3LOW equ $FF1D
309316

310317
; -- AUD3HIGH / NR34 ($FF1E) --------------------------------------------------
@@ -927,15 +934,18 @@ def TILE_HEIGHT equ 8 ; height of tile in pixels
927934
def TILE_SIZE equ 16 ; size of tile in bytes (2 bits/pixel)
928935

929936
def COLOR_SIZE equ 2 ; size of color in bytes (little-endian BGR555)
930-
def B_COLOR_RED equ 0 ; bits 4-0
931-
def B_COLOR_GREEN equ 5 ; bits 9-5
932-
def B_COLOR_BLUE equ 10 ; bits 14-10
937+
def PAL_COLORS equ 4 ; colors per palette
938+
def PAL_SIZE equ COLOR_SIZE * PAL_COLORS ; size of palette in bytes
939+
940+
def COLOR_CH_WIDTH equ 5 ; bits per RGB color channel
941+
def COLOR_CH_MAX equ (1 << COLOR_CH_WIDTH) - 1
942+
def B_COLOR_RED equ COLOR_CH_WIDTH * 0 ; bits 4-0
943+
def B_COLOR_GREEN equ COLOR_CH_WIDTH * 1 ; bits 9-5
944+
def B_COLOR_BLUE equ COLOR_CH_WIDTH * 2 ; bits 14-10
933945
def COLOR_RED equ %000_11111 ; for the low byte
934946
def COLOR_GREEN_LOW equ %111_00000 ; for the low byte
935947
def COLOR_GREEN_HIGH equ %0_00000_11 ; for the high byte
936948
def COLOR_BLUE equ %0_11111_00 ; for the high byte
937-
def PAL_COLORS equ 4 ; colors per palette
938-
def PAL_SIZE equ COLOR_SIZE * PAL_COLORS ; size of palette in bytes
939949

940950
; (DMG only) grayscale shade indexes for BGP, OBP0, and OBP1
941951
def SHADE_WHITE equ %00
@@ -1032,6 +1042,22 @@ def B_BOOTUP_B_AGB equ 0
10321042
def BOOTUP_B_CGB equ 0 << B_BOOTUP_B_AGB
10331043
def BOOTUP_B_AGB equ 1 << B_BOOTUP_B_AGB
10341044

1045+
; Register C = CPU qualifier
1046+
def BOOTUP_C_DMG equ $13
1047+
def BOOTUP_C_SGB equ $14
1048+
def BOOTUP_C_CGB equ $00 ; CGB or AGB
1049+
1050+
; Register D = color qualifier
1051+
def BOOTUP_D_MONO equ $00 ; DMG, MGB, SGB, or CGB or AGB in DMG mode
1052+
def BOOTUP_D_COLOR equ $FF ; CGB or AGB
1053+
1054+
; Register E = CPU qualifier (distinguishes DMG variants)
1055+
def BOOTUP_E_DMG0 equ $C1
1056+
def BOOTUP_E_DMG equ $C8
1057+
def BOOTUP_E_SGB equ $00
1058+
def BOOTUP_E_CGB_DMGMODE equ $08 ; CGB or AGB in DMG mode
1059+
def BOOTUP_E_CGB equ $56 ; CGB or AGB
1060+
10351061

10361062
;******************************************************************************
10371063
; Aliases

src/constants/misc_constants.asm

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ DEF CONSOLE_CGB EQU $02
55

66
; wReentrancyFlag bits
77
DEF IN_VBLANK EQU 0
8-
DEF IN_TIMER EQU 1
8+
DEF IN_TIMER EQU 1
99

1010
; wFlushPaletteFlags constants
1111
DEF FLUSH_ONE_PAL EQU %10000000
@@ -40,17 +40,13 @@ DEF CARDPOP_NAME_LIST_SIZE EQUS "CARDPOP_NAME_LIST_MAX_ELEMS * NAME_BUFFER_LENGT
4040

4141
DEF NUM_CHALLENGE_MACHINE_OPPONENTS EQU 5
4242

43-
; rJOYP constants to read IR signals or SNES input
44-
DEF P15 EQU %00100000
45-
DEF P14 EQU %00010000
46-
DEF P13 EQU %00001000
47-
DEF P12 EQU %00000100
48-
DEF P11 EQU %00000010
49-
DEF P10 EQU %00000001
50-
DEF SNES_JOYPAD1 EQU $3 ; lower two bits
51-
DEF SNES_JOYPAD2 EQU $2 ; lower two bits
52-
DEF SNES_JOYPAD3 EQU $1 ; lower two bits
53-
DEF SNES_JOYPAD4 EQU $0 ; lower two bits
43+
; rJOYP constants to read SNES input
44+
DEF JOYP_SGB_MLT_REQ EQU %00000011
45+
46+
; rJOYP constants to read IR signals
47+
DEF P14 EQU %00010000
48+
DEF P11 EQU %00000010
49+
DEF P10 EQU %00000001
5450

5551
; commands transmitted through IR to be
5652
; executed by the other device

src/engine/link/ir_core.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Func_19705:
145145
ld hl, rRP
146146
.loop
147147
ldh a, [rJOYP]
148-
bit 1, a
148+
bit 1, a ; P11
149149
jr z, ReturnZFlagUnsetAndCarryFlagSet
150150
ld a, $aa ; request
151151
call TransmitByteThroughIR
@@ -162,7 +162,7 @@ Func_1971e:
162162
ld hl, rRP
163163
.asm_19721
164164
ldh a, [rJOYP]
165-
bit 1, a
165+
bit 1, a ; P11
166166
jr z, ReturnZFlagUnsetAndCarryFlagSet
167167
call ReceiveByteThroughIR_ZeroIfUnsuccessful
168168
cp $aa ; request

src/home/double_speed.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ CGBSpeedSwitch::
2626
xor a
2727
ldh [rIF], a
2828
ldh [rIE], a
29-
ld a, $30
29+
ld a, JOYP_GET_NONE
3030
ldh [rJOYP], a
3131
stop
3232
call SetupTimer

src/home/input.asm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Reset::
4848
SaveButtonsHeld::
4949
ld a, c
5050
ldh [hKeysHeld], a
51-
ld a, JOYP_GET_CTRL_PAD | JOYP_GET_BUTTONS
51+
ld a, JOYP_GET_NONE
5252
ldh [rJOYP], a
5353
ret
5454

src/home/sgb.asm

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,32 +121,32 @@ SendSGB::
121121
ld c, LOW(rJOYP)
122122
.send_packets_loop
123123
push bc
124-
ld a, $0
124+
ld a, JOYP_SGB_START
125125
ld [$ff00+c], a
126-
ld a, P15 | P14
126+
ld a, JOYP_SGB_FINISH
127127
ld [$ff00+c], a
128128
ld b, SGB_PACKET_SIZE
129129
.send_packet_loop
130-
ld e, $8
130+
ld e, 8
131131
ld a, [hli]
132132
ld d, a
133133
.read_byte_loop
134134
bit 0, d
135-
ld a, P14 ; '1' bit
135+
ld a, JOYP_SGB_ONE
136136
jr nz, .transfer_bit
137-
ld a, P15 ; '0' bit
137+
ld a, JOYP_SGB_ZERO
138138
.transfer_bit
139139
ld [$ff00+c], a
140-
ld a, P15 | P14
140+
ld a, JOYP_SGB_FINISH
141141
ld [$ff00+c], a
142142
rr d
143143
dec e
144144
jr nz, .read_byte_loop
145145
dec b
146146
jr nz, .send_packet_loop
147-
ld a, P15 ; stop bit
147+
ld a, JOYP_SGB_ZERO
148148
ld [$ff00+c], a
149-
ld a, P15 | P14
149+
ld a, JOYP_SGB_FINISH
150150
ld [$ff00+c], a
151151
pop bc
152152
dec b
@@ -163,31 +163,31 @@ DetectSGB::
163163
ld hl, MltReq2Packet
164164
call SendSGB
165165
ldh a, [rJOYP]
166-
and %11
167-
cp SNES_JOYPAD1
166+
and JOYP_SGB_MLT_REQ
167+
cp JOYP_SGB_MLT_REQ
168168
jr nz, .sgb
169-
ld a, P15
169+
ld a, JOYP_SGB_ZERO
170170
ldh [rJOYP], a
171171
ldh a, [rJOYP]
172172
ldh a, [rJOYP]
173-
ld a, P15 | P14
173+
ld a, JOYP_SGB_FINISH
174174
ldh [rJOYP], a
175-
ld a, P14
175+
ld a, JOYP_SGB_ONE
176176
ldh [rJOYP], a
177177
ldh a, [rJOYP]
178178
ldh a, [rJOYP]
179179
ldh a, [rJOYP]
180180
ldh a, [rJOYP]
181181
ldh a, [rJOYP]
182182
ldh a, [rJOYP]
183-
ld a, P15 | P14
183+
ld a, JOYP_SGB_FINISH
184184
ldh [rJOYP], a
185185
ldh a, [rJOYP]
186186
ldh a, [rJOYP]
187187
ldh a, [rJOYP]
188188
ldh a, [rJOYP]
189-
and %11
190-
cp SNES_JOYPAD1
189+
and JOYP_SGB_MLT_REQ
190+
cp JOYP_SGB_MLT_REQ
191191
jr nz, .sgb
192192
ld hl, MltReq1Packet
193193
call SendSGB

0 commit comments

Comments
 (0)