Use hardware.inc

This commit is contained in:
Electro 2025-07-22 11:24:53 +01:00
parent d9bac99019
commit 33aa25af7f
78 changed files with 5853 additions and 5006 deletions

View File

@ -124,11 +124,11 @@ Another important thing to document in many cases is the input and output parame
More examples below.
```asm
; copies b bytes of data to sp-$1f and to hl, and returns hl += BG_MAP_WIDTH
; copies b bytes of data to sp-$1f and to hl, and returns hl += TILEMAP_WIDTH
; d = value of byte 0
; e = value of byte b
; a = value of bytes [1, b-1]
; b is supposed to be BG_MAP_WIDTH or smaller, else the stack would get corrupted
; b is supposed to be TILEMAP_WIDTH or smaller, else the stack would get corrupted
CopyLine::
```
@ -277,7 +277,7 @@ A constant almost never comes alone. For example a single ``BULBASAUR`` or ``BUL
There are, however, other cases where individual constants also help improve the readability of the code (or data structure) that is going to use them. Sizes/lengths and maximum values are good examples of this. For example, ``MAX_BENCH_POKEMON``, ``MAX_PLAY_AREA_POKEMON``, ``DECK_SIZE``, or just a generic one like ``SCREEN_WIDTH``. Do this when there are multiple candidates to replace in the code. For example, if a specific feature drew a cursor in screen coordinates 8,9 and nothing else did it, it wouldn't make sense to create a constant like ``FEATURE_X_CURSOR_COORDS`` just to replace those very specific numbers (an inline comment near the instruction might be appropriate instead).
Speaking of generic constants, there are multiple constants already defined for dealing with close-to-hardware stuff that you should be looking to use when appropriate (button constants such as ``A_BUTTON`` are another good examples of this). The already defined text constants (and macros) help dealing with text-related code and data, and are particularly helpful for distinguishing between the different game fonts.
Speaking of generic constants, there are multiple constants already defined for dealing with close-to-hardware stuff that you should be looking to use when appropriate (button constants such as ``PAD_A`` are another good examples of this). The already defined text constants (and macros) help dealing with text-related code and data, and are particularly helpful for distinguishing between the different game fonts.
Constants for WRAM address offsets (i.e. for the likes of ``wAddressN - wAddress``) are sometimes a good idea as well, and typically follow the addresses defined in some WRAM macro. For example, look at the constants defined with the previously seen ``card_data_struct`` macro in mind:
@ -296,20 +296,19 @@ DEF PKMN_CARD_DATA_LENGTH EQU $41
Some constants make sense to have as both a value and a flag. Again, button constants are a good example of this. For these, the convention is to use ``CONSTANT_NAME`` for the value, and ``CONSTANT_NAME_F`` for the flag, so you can use either of them depending on the assembly instruction (e.g. ``and CONSTANT_NAME`` or ``bit CONSTANT_NAME_F, a``). For example:
```asm
DEF A_BUTTON_F EQU 0
DEF B_BUTTON_F EQU 1
const FIRE ; $00
const GRASS ; $01
(...)
DEF A_BUTTON EQU 1 << A_BUTTON_F ; $01
DEF B_BUTTON EQU 1 << B_BUTTON_F ; $02
DEF FIRE_F EQU $1 << FIRE ; $01
DEF GRASS_F EQU $1 << GRASS ; $02
(...)
```
Bit mask constants are also useful if they are used multiple times. Buttons again are a simple enough example to illustrate this:
Bit mask constants are also useful if they are used multiple times. Palette colors are an example to illustrate this:
```asm
DEF BUTTONS EQU A_BUTTON | B_BUTTON | SELECT | START ; $0f
DEF D_PAD EQU D_RIGHT | D_LEFT | D_UP | D_DOWN ; $f0
DEF PALRGB_WHITE EQU (31 << B_COLOR_BLUE) | (31 << B_COLOR_GREEN) | (31 << B_COLOR_RED)
```
Finally, note that constants that are exclusive to a specific feature or function should generally be local, and thus placed above the code that uses them. This is usually not the case, however, so you should usually be looking to declare them inside the constants/ directory as mentioned before. This kind of refactoring is also more appropriate when the disassembly is in a more advanced state as well.

View File

@ -624,38 +624,38 @@ Characters that are assigned the green NPC palette have incorrect profile frame
```diff
.data_a9459
db 4 ; size
- db 0, 0, 6, %011 | (1 << OAM_OBP_NUM)
+ db 0, 0, 12, %011 | (1 << OAM_OBP_NUM)
db 0, 8, 13, %011 | (1 << OAM_OBP_NUM)
db 8, 0, 14, %011 | (1 << OAM_OBP_NUM)
db 8, 8, 15, %011 | (1 << OAM_OBP_NUM)
- db 0, 0, 6, %011 | OAM_PAL1
+ db 0, 0, 12, %011 | OAM_PAL1
db 0, 8, 13, %011 | OAM_PAL1
db 8, 0, 14, %011 | OAM_PAL1
db 8, 8, 15, %011 | OAM_PAL1
.data_a946a
db 4 ; size
- db 0, 0, 8, %011 | (1 << OAM_OBP_NUM)
+ db 0, 0, 16, %011 | (1 << OAM_OBP_NUM)
db 0, 8, 17, %011 | (1 << OAM_OBP_NUM)
db 8, 0, 18, %011 | (1 << OAM_OBP_NUM)
db 8, 8, 19, %011 | (1 << OAM_OBP_NUM)
- db 0, 0, 8, %011 | OAM_PAL1
+ db 0, 0, 16, %011 | OAM_PAL1
db 0, 8, 17, %011 | OAM_PAL1
db 8, 0, 18, %011 | OAM_PAL1
db 8, 8, 19, %011 | OAM_PAL1
...
.data_a94ae
db 4 ; size
db 0, 0, 13, %011 | (1 << OAM_OBP_NUM) | (1 << OAM_X_FLIP)
db 8, 0, 15, %011 | (1 << OAM_OBP_NUM) | (1 << OAM_X_FLIP)
- db 0, 8, 6, %011 | (1 << OAM_OBP_NUM) | (1 << OAM_X_FLIP)
+ db 0, 8, 12, %011 | (1 << OAM_OBP_NUM) | (1 << OAM_X_FLIP)
db 8, 8, 14, %011 | (1 << OAM_OBP_NUM) | (1 << OAM_X_FLIP)
db 0, 0, 13, %011 | OAM_PAL1 | OAM_XFLIP
db 8, 0, 15, %011 | OAM_PAL1 | OAM_XFLIP
- db 0, 8, 6, %011 | OAM_PAL1 | OAM_XFLIP
+ db 0, 8, 12, %011 | OAM_PAL1 | OAM_XFLIP
db 8, 8, 14, %011 | OAM_PAL1 | OAM_XFLIP
.data_a94bf
db 4 ; size
db 0, 0, 17, %011 | (1 << OAM_OBP_NUM) | (1 << OAM_X_FLIP)
db 8, 0, 19, %011 | (1 << OAM_OBP_NUM) | (1 << OAM_X_FLIP)
- db 0, 8, 8, %011 | (1 << OAM_OBP_NUM) | (1 << OAM_X_FLIP)
+ db 0, 8, 16, %011 | (1 << OAM_OBP_NUM) | (1 << OAM_X_FLIP)
db 8, 8, 18, %011 | (1 << OAM_OBP_NUM) | (1 << OAM_X_FLIP)
db 0, 0, 17, %011 | OAM_PAL1 | OAM_XFLIP
db 8, 0, 19, %011 | OAM_PAL1 | OAM_XFLIP
- db 0, 8, 8, %011 | OAM_PAL1 | OAM_XFLIP
+ db 0, 8, 16, %011 | OAM_PAL1 | OAM_XFLIP
db 8, 8, 18, %011 | OAM_PAL1 | OAM_XFLIP
```
### Big Lightning animation has incorrect frame data
@ -666,8 +666,8 @@ One of the bolts from the "big lightning" duel animation has its topmost row of
```diff
.data_ab5fd
db 28 ; size
- db -72, -8, 0, (1 << OAM_X_FLIP)
+ db -72, 0, 0, (1 << OAM_X_FLIP)
- db -72, -8, 0, OAM_XFLIP
+ db -72, 0, 0, OAM_XFLIP
db -16, 32, 27, $0
...
db -56, 10, 42, $0
@ -678,10 +678,10 @@ The base of the lightning being cut-off is addressed below, though that specific
```diff
.data_ab5fd
- db 28 ; size
- db -72, -8, 0, (1 << OAM_X_FLIP)
- db -72, -8, 0, OAM_XFLIP
+ db 29 ; size
+ db -72, 0, 0, (1 << OAM_X_FLIP)
+ db -72, -8, 1, (1 << OAM_X_FLIP)
+ db -72, 0, 0, OAM_XFLIP
+ db -72, -8, 1, OAM_XFLIP
db -16, 32, 27, $0
...
db -56, 10, 42, $0
@ -696,16 +696,16 @@ The fire blasts from Dive Bomb's duel animation mistakenly reuse the same tile t
.data_ac685
db 19 ; size
...
db -8, 8, 11, (1 << OAM_X_FLIP)
db -8, 16, 10, (1 << OAM_X_FLIP)
- db 0, 24, 10, (1 << OAM_X_FLIP)
+ db 0, 24, 12, (1 << OAM_X_FLIP)
db 0, 16, 13, (1 << OAM_X_FLIP)
db 0, 8, 14, (1 << OAM_X_FLIP)
db 8, 8, 17, (1 << OAM_X_FLIP)
db 8, 16, 16, (1 << OAM_X_FLIP)
db 8, 24, 15, (1 << OAM_X_FLIP)
db 16, 24, 18, (1 << OAM_X_FLIP)
db -8, 8, 11, OAM_XFLIP
db -8, 16, 10, OAM_XFLIP
- db 0, 24, 10, OAM_XFLIP
+ db 0, 24, 12, OAM_XFLIP
db 0, 16, 13, OAM_XFLIP
db 0, 8, 14, OAM_XFLIP
db 8, 8, 17, OAM_XFLIP
db 8, 16, 16, OAM_XFLIP
db 8, 24, 15, OAM_XFLIP
db 16, 24, 18, OAM_XFLIP
.data_ac6d2
db 19 ; size
@ -724,16 +724,16 @@ The fire blasts from Dive Bomb's duel animation mistakenly reuse the same tile t
.data_ac71f
db 29 ; size
...
db -8, 8, 11, (1 << OAM_X_FLIP)
db -8, 16, 10, (1 << OAM_X_FLIP)
- db 0, 24, 10, (1 << OAM_X_FLIP)
+ db 0, 24, 12, (1 << OAM_X_FLIP)
db 0, 16, 13, (1 << OAM_X_FLIP)
db 0, 8, 14, (1 << OAM_X_FLIP)
db 8, 8, 17, (1 << OAM_X_FLIP)
db 8, 16, 16, (1 << OAM_X_FLIP)
db 8, 24, 15, (1 << OAM_X_FLIP)
db 16, 24, 18, (1 << OAM_X_FLIP)
db -8, 8, 11, OAM_XFLIP
db -8, 16, 10, OAM_XFLIP
- db 0, 24, 10, OAM_XFLIP
+ db 0, 24, 12, OAM_XFLIP
db 0, 16, 13, OAM_XFLIP
db 0, 8, 14, OAM_XFLIP
db 8, 8, 17, OAM_XFLIP
db 8, 16, 16, OAM_XFLIP
db 8, 24, 15, OAM_XFLIP
db 16, 24, 18, OAM_XFLIP
```
The flames of one of the blasts being cut-off is addressed below, though that specific fix will cause a byte overflow, forcing one to rearrange `anim2.asm`.
@ -743,17 +743,17 @@ The flames of one of the blasts being cut-off is addressed below, though that sp
- db 19 ; size
+ db 20 ; size
...
db -8, 8, 11, (1 << OAM_X_FLIP)
db -8, 16, 10, (1 << OAM_X_FLIP)
- db 0, 24, 10, (1 << OAM_X_FLIP)
+ db 0, 24, 12, (1 << OAM_X_FLIP)
db 0, 16, 13, (1 << OAM_X_FLIP)
db 0, 8, 14, (1 << OAM_X_FLIP)
db 8, 8, 17, (1 << OAM_X_FLIP)
db 8, 16, 16, (1 << OAM_X_FLIP)
db 8, 24, 15, (1 << OAM_X_FLIP)
+ db 16, 16, 19, (1 << OAM_X_FLIP)
db 16, 24, 18, (1 << OAM_X_FLIP)
db -8, 8, 11, OAM_XFLIP
db -8, 16, 10, OAM_XFLIP
- db 0, 24, 10, OAM_XFLIP
+ db 0, 24, 12, OAM_XFLIP
db 0, 16, 13, OAM_XFLIP
db 0, 8, 14, OAM_XFLIP
db 8, 8, 17, OAM_XFLIP
db 8, 16, 16, OAM_XFLIP
db 8, 24, 15, OAM_XFLIP
+ db 16, 16, 19, OAM_XFLIP
db 16, 24, 18, OAM_XFLIP
.data_ac6d2
- db 19 ; size
@ -774,16 +774,16 @@ The flames of one of the blasts being cut-off is addressed below, though that sp
.data_ac71f
db 29 ; size
...
db -8, 8, 11, (1 << OAM_X_FLIP)
db -8, 16, 10, (1 << OAM_X_FLIP)
- db 0, 24, 10, (1 << OAM_X_FLIP)
+ db 0, 24, 12, (1 << OAM_X_FLIP)
db 0, 16, 13, (1 << OAM_X_FLIP)
db 0, 8, 14, (1 << OAM_X_FLIP)
db 8, 8, 17, (1 << OAM_X_FLIP)
db 8, 16, 16, (1 << OAM_X_FLIP)
db 8, 24, 15, (1 << OAM_X_FLIP)
db 16, 24, 18, (1 << OAM_X_FLIP)
db -8, 8, 11, OAM_XFLIP
db -8, 16, 10, OAM_XFLIP
- db 0, 24, 10, OAM_XFLIP
+ db 0, 24, 12, OAM_XFLIP
db 0, 16, 13, OAM_XFLIP
db 0, 8, 14, OAM_XFLIP
db 8, 8, 17, OAM_XFLIP
db 8, 16, 16, OAM_XFLIP
db 8, 24, 15, OAM_XFLIP
db 16, 24, 18, OAM_XFLIP
```
## Text

View File

@ -106,13 +106,13 @@ Music1_f406f:
Music1_Init:
xor a
ldh [rNR52], a
ld a, $80
ldh [rNR52], a
ldh [rAUDENA], a
ld a, AUDENA_ON
ldh [rAUDENA], a
ld a, $77
ldh [rNR50], a
ld a, $ff
ldh [rNR51], a
ldh [rAUDVOL], a
ld a, AUDTERM_1_RIGHT | AUDTERM_2_RIGHT | AUDTERM_3_RIGHT | AUDTERM_4_RIGHT | AUDTERM_1_LEFT | AUDTERM_2_LEFT | AUDTERM_3_LEFT | AUDTERM_4_LEFT
ldh [rAUDTERM], a
ld a, $3d
ld [wCurSongBank], a
ld a, $80
@ -169,7 +169,7 @@ Music1_Update:
call Bankswitch3dTo3f
ld a, [wCurSongBank]
ldh [hBankROM], a
ld [MBC3RomBank], a
ld [rROMB], a
ld a, [wddf2]
cp $0
jr z, .update_channels
@ -215,35 +215,35 @@ Music1_StopAllChannels:
ld [wMusicIsPlaying], a
bit 0, d
jr nz, .stop_channel_2
ld a, $8
ldh [rNR12], a
swap a
ldh [rNR14], a
ld a, AUD1ENV_UP
ldh [rAUD1ENV], a
swap a ; AUD1HIGH_RESTART
ldh [rAUD1HIGH], a
.stop_channel_2
xor a
ld [wMusicIsPlaying + 1], a
bit 1, d
jr nz, .stop_channel_4
ld a, $8
ldh [rNR22], a
swap a
ldh [rNR24], a
ld a, AUD2ENV_UP
ldh [rAUD2ENV], a
swap a ; AUD2HIGH_RESTART
ldh [rAUD2HIGH], a
.stop_channel_4
xor a
ld [wMusicIsPlaying + 3], a
bit 3, d
jr nz, .stop_channel_3
ld a, $8
ldh [rNR42], a
swap a
ldh [rNR44], a
ld a, AUD4ENV_UP
ldh [rAUD4ENV], a
swap a ; AUD4GO_RESTART
ldh [rAUD4GO], a
.stop_channel_3
xor a
ld [wMusicIsPlaying + 2], a
bit 2, d
jr nz, .done
ld a, $0
ldh [rNR32], a
ld a, AUD3LEVEL_MUTE
ldh [rAUD3LEVEL], a
.done
ret
@ -257,7 +257,7 @@ Music1_BeginSong:
ld a, [hl]
ld [wCurSongBank], a
ldh [hBankROM], a
ld [MBC3RomBank], a
ld [rROMB], a
pop af
add a
ld c, a
@ -399,7 +399,7 @@ Music1_UpdateChannel1:
ld a, [wdd8c]
bit 0, a
jr nz, .asm_f42d4
ld hl, rNR12
ld hl, rAUD1ENV
ld a, [wMusicEcho]
ld [hli], a
inc hl
@ -428,10 +428,10 @@ Music1_UpdateChannel1:
ld a, [wdd8c]
bit 0, a
jr nz, .asm_f4309
ld a, $8
ldh [rNR12], a
swap a
ldh [rNR14], a
ld a, AUD1ENV_UP
ldh [rAUD1ENV], a
swap a ; AUD1HIGH_RESTART
ldh [rAUD1HIGH], a
.asm_f4309
ret
@ -452,7 +452,7 @@ Music1_UpdateChannel2:
ld a, [wdd8c]
bit 1, a
jr nz, .asm_f4339
ld hl, rNR22
ld hl, rAUD2ENV
ld a, [wMusicEcho + 1]
ld [hli], a
inc hl
@ -481,10 +481,10 @@ Music1_UpdateChannel2:
ld a, [wdd8c]
bit 1, a
jr nz, .asm_f436e
ld a, $8
ldh [rNR22], a
swap a
ldh [rNR24], a
ld a, AUD2ENV_UP
ldh [rAUD2ENV], a
swap a ; AUD2HIGH_RESTART
ldh [rAUD2HIGH], a
.asm_f436e
ret
@ -506,7 +506,7 @@ Music1_UpdateChannel3:
cp $1
jr z, .asm_f4398
ld a, [wMusicEcho + 2]
ldh [rNR32], a
ldh [rAUD3LEVEL], a
.asm_f4398
ld a, [wddbb + 2]
dec a
@ -530,10 +530,10 @@ Music1_UpdateChannel3:
ld a, [wdd8c]
bit 2, a
jr nz, .asm_f43cd
ld a, $0
ldh [rNR32], a
ld a, $80
ldh [rNR34], a
ld a, AUD3LEVEL_MUTE
ldh [rAUD3LEVEL], a
ld a, AUD3HIGH_RESTART
ldh [rAUD3HIGH], a
.asm_f43cd
ret
@ -568,10 +568,10 @@ Music1_UpdateChannel4:
jr nz, .asm_f4413
xor a
ld [wddef], a
ld a, $8
ldh [rNR42], a
swap a
ldh [rNR44], a
ld a, AUD4ENV_UP
ldh [rAUD4ENV], a
swap a ; AUD4GO_RESTART
ldh [rAUD4GO], a
.asm_f4413
ret
@ -1167,26 +1167,26 @@ Music1_f4714:
cp $80
jr z, .asm_f4733
ld a, [wMusicVolume]
ldh [rNR12], a
ld d, $80
ldh [rAUD1ENV], a
ld d, AUD1HIGH_RESTART
.asm_f4733
ld [hl], $2
ld a, $8
ldh [rNR10], a
ld a, AUD1SWEEP_DOWN
ldh [rAUD1SWEEP], a
ld a, [wMusicDuty1]
ldh [rNR11], a
ldh [rAUD1LEN], a
ld a, [wMusicCh1CurPitch]
ldh [rNR13], a
ldh [rAUD1LOW], a
ld a, [wMusicCh1CurOctave]
or d
ldh [rNR14], a
ldh [rAUD1HIGH], a
.asm_f4749
ret
.asm_f474a
ld hl, wMusicTie
ld [hl], $0
ld hl, rNR12
ld a, $8
ld hl, rAUD1ENV
ld a, AUD1ENV_UP
ld [hli], a
inc hl
swap a
@ -1206,24 +1206,24 @@ Music1_f475a:
cp $80
jr z, .asm_f4779
ld a, [wMusicVolume + 1]
ldh [rNR22], a
ld d, $80
ldh [rAUD2ENV], a
ld d, AUD2HIGH_RESTART
.asm_f4779
ld [hl], $2
ld a, [wMusicDuty2]
ldh [rNR21], a
ldh [rAUD2LEN], a
ld a, [wMusicCh2CurPitch]
ldh [rNR23], a
ldh [rAUD2LOW], a
ld a, [wMusicCh2CurOctave]
or d
ldh [rNR24], a
ldh [rAUD2HIGH], a
.asm_f478b
ret
.asm_f478c
ld hl, wMusicTie + 1
ld [hl], $0
ld hl, rNR22
ld a, $8
ld hl, rAUD2ENV
ld a, AUD2ENV_UP
ld [hli], a
inc hl
swap a
@ -1238,8 +1238,8 @@ Music1_f479c:
ld a, [wMusicWaveChange]
or a
jr z, .no_wave_change
xor a
ldh [rNR30], a
xor a ; AUD3ENA_OFF
ldh [rAUD3ENA], a
call Music1_LoadWaveInstrument
ld d, $80
.no_wave_change
@ -1251,28 +1251,28 @@ Music1_f479c:
cp $80
jr z, .asm_f47cc
ld a, [wMusicVolume + 2]
ldh [rNR32], a
xor a
ldh [rNR30], a
ld d, $80
ldh [rAUD3LEVEL], a
xor a ; AUD3ENA_OFF
ldh [rAUD3ENA], a
ld d, AUD3HIGH_RESTART
.asm_f47cc
ld [hl], $2
xor a
ldh [rNR31], a
ldh [rAUD3LEN], a
ld a, [wMusicCh3CurPitch]
ldh [rNR33], a
ld a, $80
ldh [rNR30], a
ldh [rAUD3LOW], a
ld a, AUD3ENA_ON
ldh [rAUD3ENA], a
ld a, [wMusicCh3CurOctave]
or d
ldh [rNR34], a
ldh [rAUD3HIGH], a
.asm_f47e0
ret
.asm_f47e1
ld hl, wMusicTie
ld [hl], $0
xor a
ldh [rNR30], a
xor a ; AUD3ENA_OFF
ldh [rAUD3ENA], a
ret
Music1_LoadWaveInstrument:
@ -1306,7 +1306,7 @@ Music1_f480a:
ld a, [wddba]
cp $0
jr z, .asm_f482a
ld de, rNR41
ld de, rAUD4LEN
ld hl, wddab
ld a, [hli]
ld [de], a
@ -1324,8 +1324,8 @@ Music1_f480a:
.asm_f482a
xor a
ld [wddef], a
ld hl, rNR42
ld a, $8
ld hl, rAUD4ENV
ld a, AUD4ENV_UP
ld [hli], a
inc hl
swap a
@ -1349,7 +1349,7 @@ Music1_f4839:
jr nz, .asm_f4853
jr Music1_f480a.asm_f482a
.asm_f4853
ldh [rNR43], a
ldh [rAUD4POLY], a
inc de
ld a, d
ld [hld], a
@ -1368,7 +1368,7 @@ Music1_f485a:
Music1_f4866:
ld a, [wMusicPanning]
ldh [rNR50], a
ldh [rAUDVOL], a
ld a, [wdd8c]
or a
ld hl, wMusicStereoPanning
@ -1397,7 +1397,7 @@ Music1_f4866:
swap e
or e
and d
ldh [rNR51], a
ldh [rAUDTERM], a
ret
Music1_UpdateVibrato:
@ -1495,13 +1495,13 @@ Music1_f490b:
bit 0, a
jr nz, .done
ld a, e
ldh [rNR13], a
ldh a, [rNR11]
and $c0
ldh [rNR11], a
ldh [rAUD1LOW], a
ldh a, [rAUD1LEN]
and ~AUD1LEN_TIMER
ldh [rAUD1LEN], a
ld a, d
and $3f
ldh [rNR14], a
ldh [rAUD1HIGH], a
ret
.not_channel_1
cp $1
@ -1513,12 +1513,12 @@ Music1_f490b:
bit 1, a
jr nz, .done
ld a, e
ldh [rNR23], a
ldh a, [rNR21]
and $c0
ldh [rNR21], a
ldh [rAUD2LOW], a
ldh a, [rAUD2LEN]
and ~AUD2LEN_TIMER
ldh [rAUD2LEN], a
ld a, d
ldh [rNR24], a
ldh [rAUD2HIGH], a
ret
.not_channel_2
cp $2
@ -1530,11 +1530,11 @@ Music1_f490b:
bit 2, a
jr nz, .done
ld a, e
ldh [rNR33], a
ldh [rAUD3LOW], a
xor a
ldh [rNR31], a
ldh [rAUD3LEN], a
ld a, d
ldh [rNR34], a
ldh [rAUD3HIGH], a
.done
ret
@ -1566,29 +1566,29 @@ Music1_f4980:
ld d, a
bit 0, d
jr nz, .asm_f4990
ld a, $8
ldh [rNR12], a
swap a
ldh [rNR14], a
ld a, AUD1ENV_UP
ldh [rAUD1ENV], a
swap a ; AUD1HIGH_RESTART
ldh [rAUD1HIGH], a
.asm_f4990
bit 1, d
jr nz, .asm_f499c
swap a
ldh [rNR22], a
swap a
ldh [rNR24], a
ldh [rAUD2ENV], a
swap a ; AUD2HIGH_RESTART
ldh [rAUD2HIGH], a
.asm_f499c
bit 3, d
jr nz, .asm_f49a8
swap a
ldh [rNR42], a
swap a
ldh [rNR44], a
ldh [rAUD4ENV], a
swap a ; AUD4GO_RESTART
ldh [rAUD4GO], a
.asm_f49a8
bit 2, d
jr nz, .asm_f49b0
ld a, $0
ldh [rNR32], a
ld a, AUD3LEVEL_MUTE
ldh [rAUD3LEVEL], a
.asm_f49b0
ret

View File

@ -106,13 +106,13 @@ Music2_f406f:
Music2_Init:
xor a
ldh [rNR52], a
ld a, $80
ldh [rNR52], a
ldh [rAUDENA], a
ld a, AUDENA_ON
ldh [rAUDENA], a
ld a, $77
ldh [rNR50], a
ld a, $ff
ldh [rNR51], a
ldh [rAUDVOL], a
ld a, AUDTERM_1_RIGHT | AUDTERM_2_RIGHT | AUDTERM_3_RIGHT | AUDTERM_4_RIGHT | AUDTERM_1_LEFT | AUDTERM_2_LEFT | AUDTERM_3_LEFT | AUDTERM_4_LEFT
ldh [rAUDTERM], a
ld a, $3d
ld [wCurSongBank], a
ld a, $80
@ -169,7 +169,7 @@ Music2_Update:
call Bankswitch3dTo3f
ld a, [wCurSongBank]
ldh [hBankROM], a
ld [MBC3RomBank], a
ld [rROMB], a
ld a, [wddf2]
cp $0
jr z, .update_channels
@ -215,35 +215,35 @@ Music2_StopAllChannels:
ld [wMusicIsPlaying], a
bit 0, d
jr nz, .stop_channel_2
ld a, $8
ldh [rNR12], a
swap a
ldh [rNR14], a
ld a, AUD1ENV_UP
ldh [rAUD1ENV], a
swap a ; AUD1HIGH_RESTART
ldh [rAUD1HIGH], a
.stop_channel_2
xor a
ld [wMusicIsPlaying + 1], a
bit 1, d
jr nz, .stop_channel_4
ld a, $8
ldh [rNR22], a
swap a
ldh [rNR24], a
ld a, AUD2ENV_UP
ldh [rAUD2ENV], a
swap a ; AUD2HIGH_RESTART
ldh [rAUD2HIGH], a
.stop_channel_4
xor a
ld [wMusicIsPlaying + 3], a
bit 3, d
jr nz, .stop_channel_3
ld a, $8
ldh [rNR42], a
swap a
ldh [rNR44], a
ld a, AUD4ENV_UP
ldh [rAUD4ENV], a
swap a ; AUD4GO_RESTART
ldh [rAUD4GO], a
.stop_channel_3
xor a
ld [wMusicIsPlaying + 2], a
bit 2, d
jr nz, .done
ld a, $0
ldh [rNR32], a
ld a, AUD3LEVEL_MUTE
ldh [rAUD3LEVEL], a
.done
ret
@ -257,7 +257,7 @@ Music2_BeginSong:
ld a, [hl]
ld [wCurSongBank], a
ldh [hBankROM], a
ld [MBC3RomBank], a
ld [rROMB], a
pop af
add a
ld c, a
@ -399,7 +399,7 @@ Music2_UpdateChannel1:
ld a, [wdd8c]
bit 0, a
jr nz, .asm_f42d4
ld hl, rNR12
ld hl, rAUD1ENV
ld a, [wMusicEcho]
ld [hli], a
inc hl
@ -428,10 +428,10 @@ Music2_UpdateChannel1:
ld a, [wdd8c]
bit 0, a
jr nz, .asm_f4309
ld a, $8
ldh [rNR12], a
swap a
ldh [rNR14], a
ld a, AUD1ENV_UP
ldh [rAUD1ENV], a
swap a ; AUD1HIGH_RESTART
ldh [rAUD1HIGH], a
.asm_f4309
ret
@ -452,7 +452,7 @@ Music2_UpdateChannel2:
ld a, [wdd8c]
bit 1, a
jr nz, .asm_f4339
ld hl, rNR22
ld hl, rAUD2ENV
ld a, [wMusicEcho + 1]
ld [hli], a
inc hl
@ -481,10 +481,10 @@ Music2_UpdateChannel2:
ld a, [wdd8c]
bit 1, a
jr nz, .asm_f436e
ld a, $8
ldh [rNR22], a
swap a
ldh [rNR24], a
ld a, AUD2ENV_UP
ldh [rAUD2ENV], a
swap a ; AUD2HIGH_RESTART
ldh [rAUD2HIGH], a
.asm_f436e
ret
@ -506,7 +506,7 @@ Music2_UpdateChannel3:
cp $1
jr z, .asm_f4398
ld a, [wMusicEcho + 2]
ldh [rNR32], a
ldh [rAUD3LEVEL], a
.asm_f4398
ld a, [wddbb + 2]
dec a
@ -530,10 +530,10 @@ Music2_UpdateChannel3:
ld a, [wdd8c]
bit 2, a
jr nz, .asm_f43cd
ld a, $0
ldh [rNR32], a
ld a, $80
ldh [rNR34], a
ld a, AUD3LEVEL_MUTE
ldh [rAUD3LEVEL], a
ld a, AUD3HIGH_RESTART
ldh [rAUD3HIGH], a
.asm_f43cd
ret
@ -568,10 +568,10 @@ Music2_UpdateChannel4:
jr nz, .asm_f4413
xor a
ld [wddef], a
ld a, $8
ldh [rNR42], a
swap a
ldh [rNR44], a
ld a, AUD4ENV_UP
ldh [rAUD4ENV], a
swap a ; AUD4GO_RESTART
ldh [rAUD4GO], a
.asm_f4413
ret
@ -1167,26 +1167,26 @@ Music2_f4714:
cp $80
jr z, .asm_f4733
ld a, [wMusicVolume]
ldh [rNR12], a
ld d, $80
ldh [rAUD1ENV], a
ld d, AUD1HIGH_RESTART
.asm_f4733
ld [hl], $2
ld a, $8
ldh [rNR10], a
ld a, AUD1SWEEP_DOWN
ldh [rAUD1SWEEP], a
ld a, [wMusicDuty1]
ldh [rNR11], a
ldh [rAUD1LEN], a
ld a, [wMusicCh1CurPitch]
ldh [rNR13], a
ldh [rAUD1LOW], a
ld a, [wMusicCh1CurOctave]
or d
ldh [rNR14], a
ldh [rAUD1HIGH], a
.asm_f4749
ret
.asm_f474a
ld hl, wMusicTie
ld [hl], $0
ld hl, rNR12
ld a, $8
ld hl, rAUD1ENV
ld a, AUD1ENV_UP
ld [hli], a
inc hl
swap a
@ -1206,24 +1206,24 @@ Music2_f475a:
cp $80
jr z, .asm_f4779
ld a, [wMusicVolume + 1]
ldh [rNR22], a
ld d, $80
ldh [rAUD2ENV], a
ld d, AUD2HIGH_RESTART
.asm_f4779
ld [hl], $2
ld a, [wMusicDuty2]
ldh [rNR21], a
ldh [rAUD2LEN], a
ld a, [wMusicCh2CurPitch]
ldh [rNR23], a
ldh [rAUD2LOW], a
ld a, [wMusicCh2CurOctave]
or d
ldh [rNR24], a
ldh [rAUD2HIGH], a
.asm_f478b
ret
.asm_f478c
ld hl, wMusicTie + 1
ld [hl], $0
ld hl, rNR22
ld a, $8
ld hl, rAUD2ENV
ld a, AUD2ENV_UP
ld [hli], a
inc hl
swap a
@ -1238,8 +1238,8 @@ Music2_f479c:
ld a, [wMusicWaveChange]
or a
jr z, .no_wave_change
xor a
ldh [rNR30], a
xor a ; AUD3ENA_OFF
ldh [rAUD3ENA], a
call Music2_LoadWaveInstrument
ld d, $80
.no_wave_change
@ -1251,28 +1251,28 @@ Music2_f479c:
cp $80
jr z, .asm_f47cc
ld a, [wMusicVolume + 2]
ldh [rNR32], a
xor a
ldh [rNR30], a
ld d, $80
ldh [rAUD3LEVEL], a
xor a ; AUD3ENA_OFF
ldh [rAUD3ENA], a
ld d, AUD3HIGH_RESTART
.asm_f47cc
ld [hl], $2
xor a
ldh [rNR31], a
ldh [rAUD3LEN], a
ld a, [wMusicCh3CurPitch]
ldh [rNR33], a
ld a, $80
ldh [rNR30], a
ldh [rAUD3LOW], a
ld a, AUD3ENA_ON
ldh [rAUD3ENA], a
ld a, [wMusicCh3CurOctave]
or d
ldh [rNR34], a
ldh [rAUD3HIGH], a
.asm_f47e0
ret
.asm_f47e1
ld hl, wMusicTie
ld [hl], $0
xor a
ldh [rNR30], a
xor a ; AUD3ENA_OFF
ldh [rAUD3ENA], a
ret
Music2_LoadWaveInstrument:
@ -1306,7 +1306,7 @@ Music2_f480a:
ld a, [wddba]
cp $0
jr z, .asm_f482a
ld de, rNR41
ld de, rAUD4LEN
ld hl, wddab
ld a, [hli]
ld [de], a
@ -1324,8 +1324,8 @@ Music2_f480a:
.asm_f482a
xor a
ld [wddef], a
ld hl, rNR42
ld a, $8
ld hl, rAUD4ENV
ld a, AUD4ENV_UP
ld [hli], a
inc hl
swap a
@ -1349,7 +1349,7 @@ Music2_f4839:
jr nz, .asm_f4853
jr Music2_f480a.asm_f482a
.asm_f4853
ldh [rNR43], a
ldh [rAUD4POLY], a
inc de
ld a, d
ld [hld], a
@ -1368,7 +1368,7 @@ Music2_f485a:
Music2_f4866:
ld a, [wMusicPanning]
ldh [rNR50], a
ldh [rAUDVOL], a
ld a, [wdd8c]
or a
ld hl, wMusicStereoPanning
@ -1397,7 +1397,7 @@ Music2_f4866:
swap e
or e
and d
ldh [rNR51], a
ldh [rAUDTERM], a
ret
Music2_UpdateVibrato:
@ -1495,13 +1495,13 @@ Music2_f490b:
bit 0, a
jr nz, .done
ld a, e
ldh [rNR13], a
ldh a, [rNR11]
and $c0
ldh [rNR11], a
ldh [rAUD1LOW], a
ldh a, [rAUD1LEN]
and ~AUD1LEN_TIMER
ldh [rAUD1LEN], a
ld a, d
and $3f
ldh [rNR14], a
ldh [rAUD1HIGH], a
ret
.not_channel_1
cp $1
@ -1513,12 +1513,12 @@ Music2_f490b:
bit 1, a
jr nz, .done
ld a, e
ldh [rNR23], a
ldh a, [rNR21]
and $c0
ldh [rNR21], a
ldh [rAUD2LOW], a
ldh a, [rAUD2LEN]
and ~AUD2LEN_TIMER
ldh [rAUD2LEN], a
ld a, d
ldh [rNR24], a
ldh [rAUD2HIGH], a
ret
.not_channel_2
cp $2
@ -1530,11 +1530,11 @@ Music2_f490b:
bit 2, a
jr nz, .done
ld a, e
ldh [rNR33], a
ldh [rAUD3LOW], a
xor a
ldh [rNR31], a
ldh [rAUD3LEN], a
ld a, d
ldh [rNR34], a
ldh [rAUD3HIGH], a
.done
ret
@ -1566,29 +1566,29 @@ Music2_f4980:
ld d, a
bit 0, d
jr nz, .asm_f4990
ld a, $8
ldh [rNR12], a
swap a
ldh [rNR14], a
ld a, AUD1ENV_UP
ldh [rAUD1ENV], a
swap a ; AUD1HIGH_RESTART
ldh [rAUD1HIGH], a
.asm_f4990
bit 1, d
jr nz, .asm_f499c
swap a
ldh [rNR22], a
swap a
ldh [rNR24], a
ldh [rAUD2ENV], a
swap a ; AUD2HIGH_RESTART
ldh [rAUD2HIGH], a
.asm_f499c
bit 3, d
jr nz, .asm_f49a8
swap a
ldh [rNR42], a
swap a
ldh [rNR44], a
ldh [rAUD4ENV], a
swap a ; AUD4GO_RESTART
ldh [rAUD4GO], a
.asm_f49a8
bit 2, d
jr nz, .asm_f49b0
ld a, $0
ldh [rNR32], a
ld a, AUD3LEVEL_MUTE
ldh [rAUD3LEVEL], a
.asm_f49b0
ret

View File

@ -170,7 +170,7 @@ SFX_frequency:
ld [hl], $0
or d
ld d, a
ld hl, rNR11
ld hl, rAUD1LEN
ld a, c
add a
add a
@ -203,7 +203,7 @@ SFX_envelope:
ld a, [hli]
ld e, a
push hl
ld hl, rNR12
ld hl, rAUD1ENV
ld a, c
add a
add a
@ -217,7 +217,7 @@ SFX_envelope:
SFX_duty:
swap a
ld e, a
ld hl, rNR11
ld hl, rAUD1LEN
ld a, c
add a
add a
@ -332,7 +332,7 @@ SFX_ApplyPitchOffset:
ld [hl], $0
or d
ld d, a
ld hl, rNR11
ld hl, rAUD1LEN
ld a, c
add a
add a
@ -381,7 +381,7 @@ Func_fc1cd:
ld [hl], $0
or e
ld e, a
ld hl, rNR41
ld hl, rAUD4LEN
xor a
ld [hli], a
inc hl
@ -400,8 +400,8 @@ SFX_wave:
ld a, [hli]
ld h, [hl]
ld l, a
ld a, $0
ldh [rNR30], a
ld a, AUD3ENA_OFF
ldh [rAUD3ENA], a
ld b, d
ld de, $ff30
.asm_fc215
@ -414,8 +414,8 @@ SFX_wave:
jr nz, .asm_fc215
ld a, $1
ld [wMusicWaveChange], a
ld a, $80
ldh [rNR30], a
ld a, AUD3ENA_ON
ldh [rAUD3ENA], a
ld b, $0
pop hl
jp ExecuteNextSFXCommand
@ -462,9 +462,9 @@ SFX_end:
add c
ld e, a
ld d, b ; 0
ld hl, rNR12
ld hl, rAUD1ENV
add hl, de
ld a, $8
ld a, AUD1ENV_UP
ld [hli], a
inc hl
swap a
@ -480,16 +480,18 @@ Func_fc26c:
ld [wCurSfxID], a
ret
; bug, these instructions are supposed to be
; loading to hardware registers, not loading from them
Func_fc279:
ld a, $8
ldh a, [rNR12]
ldh a, [rNR22]
ldh a, [rNR32]
ldh a, [rNR42]
ldh a, [rAUD1ENV]
ldh a, [rAUD2ENV]
ldh a, [rAUD3LEVEL]
ldh a, [rAUD4ENV]
ld a, $80
ldh a, [rNR14]
ldh a, [rNR24]
ldh a, [rNR44]
ldh a, [rAUD1HIGH]
ldh a, [rAUD2HIGH]
ldh a, [rAUD4GO]
xor a
ld [wdd8c], a
ret

View File

@ -1,3 +1,5 @@
INCLUDE "constants/hardware.inc"
INCLUDE "constants/booster_constants.asm"
INCLUDE "constants/card_constants.asm"
INCLUDE "constants/card_data_constants.asm"
@ -6,7 +8,6 @@ INCLUDE "constants/deck_constants.asm"
INCLUDE "constants/duel_constants.asm"
INCLUDE "constants/duel_interface_constants.asm"
INCLUDE "constants/gfx_constants.asm"
INCLUDE "constants/hardware_constants.asm"
INCLUDE "constants/map_constants.asm"
INCLUDE "constants/menu_constants.asm"
INCLUDE "constants/misc_constants.asm"

View File

@ -1,22 +1,12 @@
; screen size
DEF SCREEN_WIDTH EQU 20 ; tiles
DEF SCREEN_HEIGHT EQU 18 ; tiles
; background map size
DEF BG_MAP_WIDTH EQU 32 ; tiles
DEF BG_MAP_HEIGHT EQU 32 ; tiles
; cgb palette size
DEF CGB_PAL_SIZE EQU 8 ; bytes
DEF palettes EQUS "* CGB_PAL_SIZE"
DEF palettes EQUS "* PAL_SIZE"
DEF NUM_BACKGROUND_PALETTES EQU 8
DEF NUM_OBJECT_PALETTES EQU 8
DEF PALRGB_WHITE EQU (31 << 10 | 31 << 5 | 31)
DEF PALRGB_WHITE EQU (31 << B_COLOR_BLUE) | (31 << B_COLOR_GREEN) | (31 << B_COLOR_RED)
; tile size
DEF TILE_SIZE EQU 16 ; bytes
DEF tiles EQUS "* TILE_SIZE"
DEF TILE_SIZE_1BPP EQU 8 ; bytes

1065
src/constants/hardware.inc Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,200 +0,0 @@
; From http://bgb.bircd.org/pandocs.htm and https://github.com/tobiasvl/hardware.inc
DEF GBC EQU $11
; MBC3
DEF MBC3SRamEnable EQU $0000
DEF MBC3RomBank EQU $2000
DEF MBC3SRamBank EQU $4000
DEF MBC3LatchClock EQU $6000
DEF MBC3RTC EQU $a000
DEF SRAM_DISABLE EQU $00
DEF SRAM_ENABLE EQU $0a
DEF NUM_SRAM_BANKS EQU 4
DEF RTC_S EQU $08 ; Seconds 0-59 (0-3Bh)
DEF RTC_M EQU $09 ; Minutes 0-59 (0-3Bh)
DEF RTC_H EQU $0a ; Hours 0-23 (0-17h)
DEF RTC_DL EQU $0b ; Lower 8 bits of Day Counter (0-FFh)
DEF RTC_DH EQU $0c ; Upper 1 bit of Day Counter, Carry Bit, Halt Flag
; Bit 0 Most significant bit of Day Counter (Bit 8)
; Bit 6 Halt (0=Active, 1=Stop Timer)
; Bit 7 Day Counter Carry Bit (1=Counter Overflow)
; interrupt flags
DEF INT_VBLANK EQU 0
DEF INT_LCD_STAT EQU 1
DEF INT_TIMER EQU 2
DEF INT_SERIAL EQU 3
DEF INT_JOYPAD EQU 4
; OAM attribute flags
DEF OAM_PALETTE EQU %111
DEF OAM_TILE_BANK EQU 3
DEF OAM_OBP_NUM EQU 4 ; Non CGB Mode Only
DEF OAM_X_FLIP EQU 5
DEF OAM_Y_FLIP EQU 6
DEF OAM_PRIORITY EQU 7 ; 0: OBJ above BG, 1: OBJ behind BG (colors 1-3)
; Hardware registers
DEF rJOYP EQU $ff00 ; Joypad (R/W)
DEF P15 EQU %00100000
DEF JOY_BTNS_SELECT EQU P15
DEF P14 EQU %00010000
DEF JOY_DPAD_SELECT EQU P14
DEF JOY_INPUT_MASK EQU %00001111
DEF P13 EQU %00001000
DEF P12 EQU %00000100
DEF P11 EQU %00000010
DEF P10 EQU %00000001
DEF JOY_INPUT_DOWN EQU P13
DEF JOY_INPUT_UP EQU P12
DEF JOY_INPUT_LEFT EQU P11
DEF JOY_INPUT_RIGHT EQU P10
DEF JOY_INPUT_START EQU P13
DEF JOY_INPUT_SELECT EQU P12
DEF JOY_INPUT_B EQU P11
DEF JOY_INPUT_A EQU P10
DEF SNES_JOYPAD1 EQU $3 ; lower two bits
DEF SNES_JOYPAD2 EQU $2 ; lower two bits
DEF SNES_JOYPAD3 EQU $1 ; lower two bits
DEF SNES_JOYPAD4 EQU $0 ; lower two bits
DEF rSB EQU $ff01 ; Serial transfer data (R/W)
DEF rSC EQU $ff02 ; Serial Transfer Control (R/W)
DEF SC_START EQU $80
DEF SC_INTERNAL EQU $01
DEF SC_EXTERNAL EQU $00
DEF rDIV EQU $ff04 ; Divider Register (R/W)
DEF rTIMA EQU $ff05 ; Timer counter (R/W)
DEF rTMA EQU $ff06 ; Timer Modulo (R/W)
DEF rTAC EQU $ff07 ; Timer Control (R/W)
DEF TAC_START EQU $04
DEF TAC_STOP EQU $00
DEF TAC_4096_HZ EQU $00
DEF TAC_262144_HZ EQU $01
DEF TAC_65536_HZ EQU $02
DEF TAC_16384_HZ EQU $03
DEF rIF EQU $ff0f ; Interrupt Flag (R/W)
DEF rNR10 EQU $ff10 ; Channel 1 Sweep register (R/W)
DEF rNR11 EQU $ff11 ; Channel 1 Sound length/Wave pattern duty (R/W)
DEF rNR12 EQU $ff12 ; Channel 1 Volume Envelope (R/W)
DEF rNR13 EQU $ff13 ; Channel 1 Frequency lo (Write Only)
DEF rNR14 EQU $ff14 ; Channel 1 Frequency hi (R/W)
DEF rNR21 EQU $ff16 ; Channel 2 Sound Length/Wave Pattern Duty (R/W)
DEF rNR22 EQU $ff17 ; Channel 2 Volume Envelope (R/W)
DEF rNR23 EQU $ff18 ; Channel 2 Frequency lo data (W)
DEF rNR24 EQU $ff19 ; Channel 2 Frequency hi data (R/W)
DEF rNR30 EQU $ff1a ; Channel 3 Sound on/off (R/W)
DEF rNR31 EQU $ff1b ; Channel 3 Sound Length
DEF rNR32 EQU $ff1c ; Channel 3 Select output level (R/W)
DEF rNR33 EQU $ff1d ; Channel 3 Frequency's lower data (W)
DEF rNR34 EQU $ff1e ; Channel 3 Frequency's higher data (R/W)
DEF rNR41 EQU $ff20 ; Channel 4 Sound Length (R/W)
DEF rNR42 EQU $ff21 ; Channel 4 Volume Envelope (R/W)
DEF rNR43 EQU $ff22 ; Channel 4 Polynomial Counter (R/W)
DEF rNR44 EQU $ff23 ; Channel 4 Counter/consecutive; Initial (R/W)
DEF rNR50 EQU $ff24 ; Channel control / ON-OFF / Volume (R/W)
DEF rNR51 EQU $ff25 ; Selection of Sound output terminal (R/W)
DEF rNR52 EQU $ff26 ; Sound on/off
DEF rLCDC EQU $ff40 ; LCD Control (R/W)
DEF LCDC_OFF EQU %01111111 ; LCD Control Operation (and)
DEF LCDC_ON EQU %10000000 ; LCD Control Operation (ld/or)
DEF LCDC_ENABLE_F EQU 7
DEF LCDC_WIN9800 EQU %10111111 ; Window Tile Map Display Select (and)
DEF LCDC_WIN9C00 EQU %01000000 ; Window Tile Map Display Select (ld/or)
DEF LCDC_WINSELECT EQU LCDC_WIN9C00
DEF LCDC_WINOFF EQU %11011111 ; Window Display (and)
DEF LCDC_WINON EQU %00100000 ; Window Display (ld/or)
DEF LCDC_WINENABLE EQU LCDC_WINON
DEF LCDC_BG8800 EQU %11101111 ; BG & Window Tile Data Select (and)
DEF LCDC_BG8000 EQU %00010000 ; BG & Window Tile Data Select (ld/or)
DEF LCDC_BGTILEDATA EQU LCDC_BG8000
DEF LCDC_BG9800 EQU %11110111 ; BG Tile Map Display Select (and)
DEF LCDC_BG9C00 EQU %00001000 ; BG Tile Map Display Select (ld/or)
DEF LCDC_BGTILEMAP EQU LCDC_BG9C00
DEF LCDC_OBJ8 EQU %11111011 ; OBJ Construction (and)
DEF LCDC_OBJ16 EQU %00000100 ; OBJ Construction (ld/or)
DEF LCDC_OBJSIZE EQU LCDC_OBJ16
DEF LCDC_OBJOFF EQU %11111101 ; OBJ Display (and)
DEF LCDC_OBJON EQU %00000010 ; OBJ Display (ld/or)
DEF LCDC_OBJENABLE EQU LCDC_OBJON
DEF LCDC_BGOFF EQU %11111110 ; BG Display (and)
DEF LCDC_BGON EQU %00000001 ; BG Display (ld/or)
DEF LCDC_BGENABLE EQU LCDC_BGON
DEF rSTAT EQU $ff41 ; LCDC Status (R/W)
DEF STAT_LYC EQU 6 ; LYC=LY Coincidence
DEF STAT_MODE_OAM EQU 5 ; Mode 10 (OAM)
DEF STAT_MODE_VBLANK EQU 4 ; Mode 01 (V-Blank)
DEF STAT_MODE_HBLANK EQU 3 ; Mode 00 (H-Blank)
DEF STAT_LYCFLAG EQU 2 ; 0:LYC<>LY, 1:LYC=LY
DEF STAT_LCDC_STATUS EQU %00000011
DEF STAT_ON_HBLANK EQU %00000000 ; H-Blank
DEF STAT_ON_VBLANK EQU %00000001 ; V-Blank
DEF STAT_ON_OAM EQU %00000010 ; OAM-RAM is used by system
DEF STAT_ON_LCD EQU %00000011 ; Both OAM and VRAM used by system
DEF STAT_BUSY EQU 1 ; When set, VRAM and OAM access is unsafe
DEF rSCY EQU $ff42 ; Scroll Y (R/W)
DEF rSCX EQU $ff43 ; Scroll X (R/W)
DEF rLY EQU $ff44 ; LCDC Y-Coordinate (R)
DEF LY_VBLANK EQU 145
DEF rLYC EQU $ff45 ; LY Compare (R/W)
DEF rDMA EQU $ff46 ; DMA Transfer and Start Address (W)
DEF rBGP EQU $ff47 ; BG Palette Data (R/W) - Non CGB Mode Only
DEF rOBP0 EQU $ff48 ; Object Palette 0 Data (R/W) - Non CGB Mode Only
DEF rOBP1 EQU $ff49 ; Object Palette 1 Data (R/W) - Non CGB Mode Only
DEF rWY EQU $ff4a ; Window Y Position (R/W)
DEF rWX EQU $ff4b ; Window X Position minus 7 (R/W)
DEF rKEY1 EQU $ff4d ; CGB Mode Only - Prepare Speed Switch
DEF rVBK EQU $ff4f ; CGB Mode Only - VRAM Bank
DEF rHDMA1 EQU $ff51 ; CGB Mode Only - New DMA Source, High
DEF rHDMA2 EQU $ff52 ; CGB Mode Only - New DMA Source, Low
DEF rHDMA3 EQU $ff53 ; CGB Mode Only - New DMA Destination, High
DEF rHDMA4 EQU $ff54 ; CGB Mode Only - New DMA Destination, Low
DEF rHDMA5 EQU $ff55 ; CGB Mode Only - New DMA Length/Mode/Start
DEF rRP EQU $ff56 ; CGB Mode Only - Infrared Communications Port
DEF RPF_ENREAD EQU %11000000
DEF RPF_DATAIN EQU %00000010 ; 0=Receiving IR Signal, 1=Normal
DEF RPF_WRITE_HI EQU %00000001
DEF RPF_WRITE_LO EQU %00000000
DEF RPB_LED_ON EQU 0
DEF RPB_DATAIN EQU 1
DEF rBGPI EQU $ff68 ; CGB Mode Only - Background Palette Index
DEF rBGPD EQU $ff69 ; CGB Mode Only - Background Palette Data
DEF rOBPI EQU $ff6a ; CGB Mode Only - Sprite Palette Index
DEF rOBPD EQU $ff6b ; CGB Mode Only - Sprite Palette Data
DEF rUNKNOWN1 EQU $ff6c ; (FEh) Bit 0 (Read/Write) - CGB Mode Only
DEF rSVBK EQU $ff70 ; CGB Mode Only - WRAM Bank
DEF rUNKNOWN2 EQU $ff72 ; (00h) - Bit 0-7 (Read/Write)
DEF rUNKNOWN3 EQU $ff73 ; (00h) - Bit 0-7 (Read/Write)
DEF rUNKNOWN4 EQU $ff74 ; (00h) - Bit 0-7 (Read/Write) - CGB Mode Only
DEF rUNKNOWN5 EQU $ff75 ; (8Fh) - Bit 4-6 (Read/Write)
DEF rUNKNOWN6 EQU $ff76 ; (00h) - Always 00h (Read Only)
DEF rUNKNOWN7 EQU $ff77 ; (00h) - Always 00h (Read Only)
DEF rIE EQU $ffff ; Interrupt Enable (R/W)

View File

@ -1,25 +1,3 @@
; buttons
DEF A_BUTTON_F EQU 0
DEF B_BUTTON_F EQU 1
DEF SELECT_F EQU 2
DEF START_F EQU 3
DEF D_RIGHT_F EQU 4
DEF D_LEFT_F EQU 5
DEF D_UP_F EQU 6
DEF D_DOWN_F EQU 7
DEF A_BUTTON EQU 1 << A_BUTTON_F ; $01
DEF B_BUTTON EQU 1 << B_BUTTON_F ; $02
DEF SELECT EQU 1 << SELECT_F ; $04
DEF START EQU 1 << START_F ; $08
DEF D_RIGHT EQU 1 << D_RIGHT_F ; $10
DEF D_LEFT EQU 1 << D_LEFT_F ; $20
DEF D_UP EQU 1 << D_UP_F ; $40
DEF D_DOWN EQU 1 << D_DOWN_F ; $80
DEF BUTTONS EQU A_BUTTON | B_BUTTON | SELECT | START ; $0f
DEF D_PAD EQU D_RIGHT | D_LEFT | D_UP | D_DOWN ; $f0
; console types (wConsole)
DEF CONSOLE_DMG EQU $00
DEF CONSOLE_SGB EQU $01
@ -62,6 +40,18 @@ DEF CARDPOP_NAME_LIST_SIZE EQUS "CARDPOP_NAME_LIST_MAX_ELEMS * NAME_BUFFER_LENGT
DEF NUM_CHALLENGE_MACHINE_OPPONENTS EQU 5
; rJOYP constants to read IR signals or SNES input
DEF P15 EQU %00100000
DEF P14 EQU %00010000
DEF P13 EQU %00001000
DEF P12 EQU %00000100
DEF P11 EQU %00000010
DEF P10 EQU %00000001
DEF SNES_JOYPAD1 EQU $3 ; lower two bits
DEF SNES_JOYPAD2 EQU $2 ; lower two bits
DEF SNES_JOYPAD3 EQU $1 ; lower two bits
DEF SNES_JOYPAD4 EQU $0 ; lower two bits
; commands transmitted through IR to be
; executed by the other device
; (see ExecuteReceivedIRCommands)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -202,7 +202,7 @@ LoadTilemap:
.next_row
pop de
ld hl, BG_MAP_WIDTH
ld hl, TILEMAP_WIDTH
add hl, de
ld e, l
ld d, h
@ -1391,7 +1391,7 @@ Func_80cd7:
call .HandleInput
call HandleAllSpriteAnimations
ldh a, [hKeysPressed]
and SELECT ; if select is pressed, exit
and PAD_SELECT ; if select is pressed, exit
jr z, .loop
ret
@ -1403,7 +1403,7 @@ Func_80cd7:
; these are not aligned with the regular NPC indices
.HandleInput
ldh a, [hKeysPressed]
and A_BUTTON
and PAD_A
jr z, .no_a_button
ld a, [wLoadNPCDirection]
inc a ; rotate NPC
@ -1413,17 +1413,17 @@ Func_80cd7:
call .DrawNPCSprite
.no_a_button
ldh a, [hKeysPressed]
and D_PAD
and PAD_CTRL_PAD
ret z
farcall GetDirectionFromDPad
ld hl, .func_table
jp JumpToFunctionInTable
.func_table
dw .up ; D_UP
dw .right ; D_RIGHT
dw .down ; D_DOWN
dw .left ; D_LEFT
dw .up ; PAD_UP
dw .right ; PAD_RIGHT
dw .down ; PAD_DOWN
dw .left ; PAD_LEFT
.up
ld a, 10
jr .decr_npc_id

View File

@ -17,7 +17,7 @@ PlayCreditsSequence::
cp $ff
jr nz, .loop_cmds
call WaitForSongToFinish
ld a, START
ld a, PAD_START
farcall WaitUntilKeysArePressed
ld a, MUSIC_STOP
call PlaySong
@ -68,20 +68,20 @@ Func_1d705:
ei
ld hl, rSTAT
set STAT_LYC, [hl]
set B_STAT_LYC, [hl]
xor a
ldh [rLYC], a
ld hl, rIE
set INT_LCD_STAT, [hl]
set B_IE_STAT, [hl]
pop hl
ret
Func_1d758:
push hl
ld hl, rSTAT
res STAT_LYC, [hl]
res B_STAT_LYC, [hl]
ld hl, rIE
res INT_LCD_STAT, [hl]
res B_IE_STAT, [hl]
pop hl
ret

View File

@ -6,7 +6,7 @@ Func_1c865:
; pressing B makes it scroll faster
Func_1c866: ; unreferenced
ldh a, [hKeysHeld]
and B_BUTTON
and PAD_B
call nz, .asm_1c86d ; executes following part twice
.asm_1c86d
ldh a, [hSCX]
@ -14,19 +14,19 @@ Func_1c866: ; unreferenced
ldh a, [hSCY]
ld c, a
ldh a, [hKeysHeld]
bit D_UP_F, a
bit B_PAD_UP, a
jr z, .check_d_down
inc c
.check_d_down
bit D_DOWN_F, a
bit B_PAD_DOWN, a
jr z, .check_d_left
dec c
.check_d_left
bit D_LEFT_F, a
bit B_PAD_LEFT, a
jr z, .check_d_right
inc b
.check_d_right
bit D_RIGHT_F, a
bit B_PAD_RIGHT, a
jr z, .asm_1c889
dec b
.asm_1c889

View File

@ -313,26 +313,26 @@ PrintDuelMenuAndHandleInput:
.handle_input
call DoFrame
ldh a, [hKeysHeld]
and B_BUTTON
and PAD_B
jr z, .b_not_held
ldh a, [hKeysPressed]
bit D_UP_F, a
bit B_PAD_UP, a
jr nz, DuelMenuShortcut_OpponentPlayArea
bit D_DOWN_F, a
bit B_PAD_DOWN, a
jr nz, DuelMenuShortcut_PlayerPlayArea
bit D_LEFT_F, a
bit B_PAD_LEFT, a
jr nz, DuelMenuShortcut_PlayerDiscardPile
bit D_RIGHT_F, a
bit B_PAD_RIGHT, a
jr nz, DuelMenuShortcut_OpponentDiscardPile
bit START_F, a
bit B_PAD_START, a
jp nz, DuelMenuShortcut_OpponentActivePokemon
.b_not_held
ldh a, [hKeysPressed]
and START
and PAD_START
jp nz, DuelMenuShortcut_PlayerActivePokemon
ldh a, [hKeysPressed]
bit SELECT_F, a
bit B_PAD_SELECT, a
jp nz, DuelMenuShortcut_BothActivePokemon
ld a, [wDebugSkipDuelMenuInput]
or a
@ -419,21 +419,21 @@ OpenTurnHolderHandScreen_Simple:
call CreateHandCardList
jr c, .no_cards_in_hand
call InitAndDrawCardListScreenLayout
ld a, START + A_BUTTON
ld a, PAD_START + PAD_A
ld [wNoItemSelectionMenuKeys], a
jp DisplayCardList
.no_cards_in_hand
ldtx hl, NoCardsInHandText
jp DrawWideTextBox_WaitForInput
; triggered by pressing B + START in the duel menu
; triggered by pressing B + PAD_START in the duel menu
DuelMenuShortcut_OpponentActivePokemon:
call SwapTurn
call OpenActivePokemonScreen
call SwapTurn
jp DuelMainInterface
; triggered by pressing START in the duel menu
; triggered by pressing PAD_START in the duel menu
DuelMenuShortcut_PlayerActivePokemon:
call OpenActivePokemonScreen
jp DuelMainInterface
@ -746,7 +746,7 @@ DuelMenu_Check:
call OpenDuelCheckMenu
jp DuelMainInterface
; triggered by pressing SELECT in the duel menu
; triggered by pressing PAD_SELECT in the duel menu
DuelMenuShortcut_BothActivePokemon:
call FinishQueuedAnimations
call OpenVariousPlayAreaScreens_FromSelectPresses
@ -768,7 +768,7 @@ OpenVariousPlayAreaScreens_FromSelectPresses:
ld [wPlayAreaSelectAction], a
call OpenPlayAreaScreenForViewing
ldh a, [hKeysPressed]
and B_BUTTON
and PAD_B
ret z
scf
ret
@ -1011,7 +1011,7 @@ DuelMenu_Attack:
.wait_for_input
call DoFrame
ldh a, [hKeysPressed]
and START
and PAD_START
jr nz, .display_selected_attack_info
call HandleMenuInput
jr nc, .wait_for_input
@ -1099,11 +1099,11 @@ OpenAttackPage:
call DoFrame
; switch page (see SwitchAttackPage) if Right or Left pressed
ldh a, [hDPadHeld]
and D_RIGHT | D_LEFT
and PAD_RIGHT | PAD_LEFT
jr nz, .open_page
; return to Attack menu if A or B pressed
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
jr z, .loop
ret
@ -2535,7 +2535,7 @@ DrawDuelHUD:
ld b, HP_BAR_LENGTH / 2 ; first row of the HP bar
call SafeCopyDataHLtoDE
pop de
ld hl, BG_MAP_WIDTH
ld hl, TILEMAP_WIDTH
add hl, de
ld e, l
ld d, h
@ -3094,7 +3094,7 @@ OpenDiscardPileScreen:
jr c, .discard_pile_empty
call InitAndDrawCardListScreenLayout
call SetDiscardPileScreenTexts
ld a, START + A_BUTTON
ld a, PAD_START + PAD_A
ld [wNoItemSelectionMenuKeys], a
call DisplayCardList
or a
@ -3154,7 +3154,7 @@ InitAndDrawCardListScreenLayout:
ld [hli], a
ld [hl], a
ld [wCardListItemSelectionMenuType], a
ld a, START
ld a, PAD_START
ld [wNoItemSelectionMenuKeys], a
ld hl, wCardListInfoBoxText
ldtx [hl], PleaseSelectHandText, & $ff
@ -3229,14 +3229,14 @@ DisplayCardList:
ld [hl], d
ldh a, [hKeysPressed]
ld b, a
bit SELECT_F, b
bit B_PAD_SELECT, b
jr nz, .select_pressed
bit B_BUTTON_F, b
bit B_PAD_B, b
jr nz, .b_pressed
ld a, [wNoItemSelectionMenuKeys]
and b
jr nz, .open_card_page
; display the item selection menu (PLAY|CHECK or SELECT|CHECK) for the selected card
; display the item selection menu (PLAY|CHECK or PAD_SELECT|CHECK) for the selected card
; open the card page if CHECK is selected
ldh a, [hCurMenuItem]
call GetCardInDuelTempList_OnlyDeckIndex
@ -3247,7 +3247,7 @@ DisplayCardList:
or a
ret
.select_pressed
; sort cards by ID if SELECT is pressed and return to the first item
; sort cards by ID if PAD_SELECT is pressed and return to the first item
ld a, [wSortCardListByID]
or a
jr nz, .wait_button
@ -3262,16 +3262,16 @@ DisplayCardList:
jr .reload_list
.open_card_page
; open the card page directly, without an item selection menu
; in this mode, D_UP and D_DOWN can be used to open the card page
; in this mode, PAD_UP and PAD_DOWN can be used to open the card page
; of the card above and below the current card
ldh a, [hCurMenuItem]
call GetCardInDuelTempList
call LoadCardDataToBuffer1_FromDeckIndex
call OpenCardPage_FromCheckHandOrDiscardPile
ldh a, [hDPadHeld]
bit D_UP_F, a
bit B_PAD_UP, a
jr nz, .up_pressed
bit D_DOWN_F, a
bit B_PAD_DOWN, a
jr nz, .down_pressed
; if B pressed, exit card page and reload the card list
call DrawCardListScreenLayout
@ -3306,7 +3306,7 @@ DisplayCardList:
.UpdateListOnDPadInput:
ldh a, [hDPadHeld]
and D_PAD
and PAD_CTRL_PAD
ret z
ld a, $01
ldh [hffb0], a
@ -3335,7 +3335,7 @@ PrintCardListHeaderAndInfoBoxTexts:
call PrintTextNoDelay
ret
; display the SELECT|CHECK or PLAY|CHECK menu when a card of a list is selected
; display the PAD_SELECT|CHECK or PLAY|CHECK menu when a card of a list is selected
; and handle input. return carry if b is pressed.
; input: wCardListItemSelectionMenuType
CardListItemSelectionMenu:
@ -3398,13 +3398,13 @@ CardListParameters:
; also return $ff unto hCurMenuItem if B is pressed.
CardListFunction:
ldh a, [hKeysPressed]
bit B_BUTTON_F, a
bit B_PAD_B, a
jr nz, .exit
and A_BUTTON | SELECT | START
and PAD_A | PAD_SELECT | PAD_START
jr nz, .action_button
ldh a, [hKeysReleased]
and D_PAD
jr nz, .reload_card_image ; jump if the D_PAD key was released this frame
and PAD_CTRL_PAD
jr nz, .reload_card_image ; jump if the PAD_CTRL_PAD key was released this frame
ret
.exit
ld a, $ff
@ -3457,10 +3457,10 @@ PrintSortNumberInCardList:
; draw the card page of the card at wLoadedCard1 and listen for input
; in order to switch the page or to exit.
; triggered by checking a hand card or a discard pile card in the Check menu.
; D_UP and D_DOWN exit the card page allowing the caller to load the card page
; PAD_UP and PAD_DOWN exit the card page allowing the caller to load the card page
; of the card above or below in the list.
OpenCardPage_FromCheckHandOrDiscardPile:
ld a, B_BUTTON | D_UP | D_DOWN
ld a, PAD_B | PAD_UP | PAD_DOWN
ld [wCardPageExitKeys], a
xor a ; CARDPAGETYPE_NOT_PLAY_AREA
jr OpenCardPage
@ -3469,7 +3469,7 @@ OpenCardPage_FromCheckHandOrDiscardPile:
; in order to switch the page or to exit.
; triggered by checking an arena card or a bench card in the Check menu.
OpenCardPage_FromCheckPlayArea:
ld a, B_BUTTON
ld a, PAD_B
ld [wCardPageExitKeys], a
ld a, CARDPAGETYPE_PLAY_AREA
jr OpenCardPage
@ -3478,7 +3478,7 @@ OpenCardPage_FromCheckPlayArea:
; in order to switch the page or to exit.
; triggered by checking a card in the Hand menu.
OpenCardPage_FromHand:
ld a, B_BUTTON
ld a, PAD_B
ld [wCardPageExitKeys], a
xor a ; CARDPAGETYPE_NOT_PLAY_AREA
; fallthrough
@ -3506,7 +3506,7 @@ OpenCardPage:
ld [wCardPageNumber], a
.load_next
call DisplayFirstOrNextCardPage
jr c, .done ; done if trying to advance past the last page with START or A_BUTTON
jr c, .done ; done if trying to advance past the last page with PAD_START or PAD_A
call EnableLCD
.input_loop
call DoFrame
@ -3515,29 +3515,29 @@ OpenCardPage:
ld a, [wCardPageExitKeys]
and b
jr nz, .done
; START and A_BUTTON advance to the next valid card page, but close it
; PAD_START and PAD_A advance to the next valid card page, but close it
; after trying to advance from the last page
ldh a, [hKeysPressed]
and START | A_BUTTON
and PAD_START | PAD_A
jr nz, .load_next
; D_RIGHT and D_LEFT advance to the next and previous valid card page respectively.
; however, unlike START and A_BUTTON, D_RIGHT past the last page goes back to the start.
; PAD_RIGHT and PAD_LEFT advance to the next and previous valid card page respectively.
; however, unlike PAD_START and PAD_A, PAD_RIGHT past the last page goes back to the start.
ldh a, [hKeysPressed]
and D_RIGHT | D_LEFT
and PAD_RIGHT | PAD_LEFT
jr z, .input_loop
call DisplayCardPageOnLeftOrRightPressed
jr .input_loop
.done
ret
; display the previous valid card page of the card at wLoadedCard1 if bit D_LEFT_F
; display the previous valid card page of the card at wLoadedCard1 if bit B_PAD_LEFT
; of a is set, and the first or next valid card page otherwise.
; DisplayFirstOrNextCardPage and DisplayPreviousCardPage only call DisplayCardPage
; when GoToFirstOrNextCardPage and GoToPreviousCardPage respectively return nc
; so the "call c, DisplayCardPage" instructions makes sure the card page switched
; to is always displayed.
DisplayCardPageOnLeftOrRightPressed:
bit D_LEFT_F, a
bit B_PAD_LEFT, a
jr nz, .left
;.right
call DisplayFirstOrNextCardPage
@ -3763,7 +3763,7 @@ GoToPreviousCardPage:
; check if the card page trying to switch to is valid for the card at wLoadedCard1
; return with the equivalent to one of these three actions:
; stay in card page trying to switch to (nc, nz)
; change to card page returned in a if D_LEFT/D_RIGHT pressed, or exit if A_BUTTON/START pressed (c)
; change to card page returned in a if PAD_LEFT/PAD_RIGHT pressed, or exit if PAD_A/PAD_START pressed (c)
; non-existent page, so skip to next/previous (nc, z)
SwitchCardPage:
ld hl, CardPageSwitchPointerTable
@ -3942,7 +3942,7 @@ SetBGP7OrSGB2ToCardPalette:
.sgb
ld hl, wCardPalette
ld de, wTempSGBPacket + 1 ; PAL Packet color #0 (PAL23's SGB2)
ld b, CGB_PAL_SIZE
ld b, PAL_SIZE
.copy_pal_loop
ld a, [hli]
ld [de], a
@ -3981,13 +3981,13 @@ SetOBP1OrSGB3ToCardPalette:
CopyCGBCardPalette:
add a
add a
add a ; a *= CGB_PAL_SIZE
add a ; a *= PAL_SIZE
ld e, a
ld d, $00
ld hl, wBackgroundPalettesCGB ; wObjectPalettesCGB - 8 palettes
add hl, de
ld de, wCardPalette
ld b, CGB_PAL_SIZE
ld b, PAL_SIZE
.copy_pal_loop
ld a, [de]
inc de
@ -4149,7 +4149,7 @@ SetDefaultConsolePalettes:
call .copy_de_to_hl
ld de, CGBDefaultPalettes
ld hl, wObjectPalettesCGB
ld c, CGB_PAL_SIZE
ld c, PAL_SIZE
call .copy_de_to_hl
call FlushAllPalettes
ret
@ -4922,11 +4922,11 @@ _HasAlivePokemonInPlayArea:
ret
OpenPlayAreaScreenForViewing:
ld a, START + A_BUTTON
ld a, PAD_START + PAD_A
jr DisplayPlayAreaScreen
OpenPlayAreaScreenForSelection:
ld a, START
ld a, PAD_START
; fallthrough
DisplayPlayAreaScreen:
@ -5038,9 +5038,9 @@ PlayAreaScreenMenuParameters_ActivePokemonExcluded:
PlayAreaScreenMenuFunction:
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON | START
and PAD_A | PAD_B | PAD_START
ret z
bit B_BUTTON_F, a
bit B_PAD_B, a
jr z, .start_or_a
ld a, $ff
ldh [hCurMenuItem], a
@ -5053,7 +5053,7 @@ SelectingBenchPokemonMenu:
or a
ret z ; menu not allowed
ldh a, [hKeysPressed]
and SELECT
and PAD_SELECT
ret z ; Select not pressed
ld a, [wPlayAreaSelectAction]
cp $02
@ -5068,7 +5068,7 @@ SelectingBenchPokemonMenu:
.loop_input
call DoFrame
ldh a, [hKeysPressed]
and A_BUTTON
and PAD_A
jr nz, .a_pressed
call .HandleInput
call RefreshMenuCursor
@ -5076,7 +5076,7 @@ SelectingBenchPokemonMenu:
call HandleSpecialDuelMainSceneHotkeys
jr nc, .loop_input
ldh a, [hKeysPressed]
and SELECT
and PAD_SELECT
jr z, .duel_main_scene
.back
call HasAlivePokemonInBench
@ -5101,15 +5101,15 @@ SelectingBenchPokemonMenu:
.HandleInput:
ldh a, [hDPadHeld]
bit B_BUTTON_F, a
bit B_PAD_B, a
ret nz
and D_RIGHT | D_LEFT
and PAD_RIGHT | PAD_LEFT
ret z
; right or left pressed
ld b, a
ld a, [wCurrentDuelMenuItem]
bit D_LEFT_F, b
bit B_PAD_LEFT, b
jr z, .right_pressed
dec a
bit 7, a
@ -5635,7 +5635,7 @@ DisplayPlayAreaScreenToUsePkmnPower:
jr z, .asm_649b
ld [wSelectedDuelSubMenuItem], a
ldh a, [hKeysPressed]
and START
and PAD_START
jr nz, .asm_649d
ldh a, [hCurMenuItem]
add a
@ -6215,7 +6215,7 @@ CheckSkipDelayAllowed:
or a
ret z
ldh a, [hKeysHeld]
and B_BUTTON
and PAD_B
ret z
scf
ret
@ -6280,7 +6280,7 @@ HandleWaitingLinkOpponentMenu:
call .HandleInput
call RefreshMenuCursor
ldh a, [hKeysPressed]
bit A_BUTTON_F, a
bit B_PAD_A, a
jr nz, .a_pressed
ld a, $01
call HandleSpecialDuelMainSceneHotkeys
@ -6301,9 +6301,9 @@ HandleWaitingLinkOpponentMenu:
.HandleInput:
ldh a, [hDPadHeld]
bit B_BUTTON_F, a
bit B_PAD_B, a
ret nz
and D_LEFT | D_RIGHT
and PAD_LEFT | PAD_RIGHT
ret z
call EraseCursor
ld hl, wCurrentDuelMenuItem
@ -6337,21 +6337,21 @@ HandleWaitingLinkOpponentMenu:
HandleSpecialDuelMainSceneHotkeys:
ld [wDuelMainSceneSelectHotkeyAction], a
ldh a, [hKeysPressed]
bit START_F, a
bit B_PAD_START, a
jr nz, .start_pressed
bit SELECT_F, a
bit B_PAD_SELECT, a
jr nz, .select_pressed
ldh a, [hKeysHeld]
and B_BUTTON
and PAD_B
ret z ; exit if no B btn
ldh a, [hKeysPressed]
bit D_DOWN_F, a
bit B_PAD_DOWN, a
jr nz, .down_pressed
bit D_LEFT_F, a
bit B_PAD_LEFT, a
jr nz, .left_pressed
bit D_UP_F, a
bit B_PAD_UP, a
jr nz, .up_pressed
bit D_RIGHT_F, a
bit B_PAD_RIGHT, a
jr nz, .right_pressed
or a
ret
@ -8143,15 +8143,15 @@ Func_7364:
ld b, a
; handle selection/cancellation buttons
and A_BUTTON | START
and PAD_A | PAD_START
jr nz, .select_opp
bit B_BUTTON_F, b
bit B_PAD_B, b
jr nz, .cancel
; handle D-pad inputs
; check right
ld a, [wOpponentDeckID]
bit D_RIGHT_F, b
bit B_PAD_RIGHT, b
jr z, .check_left
inc a ; next deck ID
cp NUM_DECK_IDS
@ -8159,7 +8159,7 @@ Func_7364:
xor a ; wrap around to first deck ID
.check_left
bit D_LEFT_F, b
bit B_PAD_LEFT, b
jr z, .check_up
or a
jr nz, .not_first_deck_id
@ -8169,7 +8169,7 @@ Func_7364:
dec a ; previous deck ID
.check_up
bit D_UP_F, b
bit B_PAD_UP, b
jr z, .check_down
add 10
cp NUM_DECK_IDS
@ -8177,7 +8177,7 @@ Func_7364:
xor a ; wrap around to first deck ID
.check_down
bit D_DOWN_F, b
bit B_PAD_DOWN, b
jr z, .got_deck_id
sub 10
jr nc, .got_deck_id
@ -8386,19 +8386,19 @@ Func_74dc:
ld b, a
ld a, [wPrizeCardSelectionFrameCounter]
; left
bit D_LEFT_F, b
bit B_PAD_LEFT, b
jr z, .right
dec a ; previous card
.right
bit D_RIGHT_F, b
bit B_PAD_RIGHT, b
jr z, .up
inc a ; next card
.up
bit D_UP_F, b
bit B_PAD_UP, b
jr z, .down
add 10
.down
bit D_DOWN_F, b
bit B_PAD_DOWN, b
jr z, .got_card_id
sub 10
@ -8407,7 +8407,7 @@ Func_74dc:
lb bc, 5, 5
bank1call WriteTwoByteNumberInTxSymbolFormat
ldh a, [hKeysPressed]
and START
and PAD_START
jr z, .wait_input
ld a, [wPrizeCardSelectionFrameCounter]
ld e, a
@ -8434,9 +8434,9 @@ DecideLinkDuelVariables:
.input_loop
call DoFrame
ldh a, [hKeysPressed]
bit B_BUTTON_F, a
bit B_PAD_B, a
jr nz, .link_cancel
and START
and PAD_START
call Func_0cc5
jr nc, .input_loop
ld hl, wPlayerDuelVariables

View File

@ -812,9 +812,9 @@ HandleDefendingPokemonAttackSelection:
.loop_input
call DoFrame
ldh a, [hKeysPressed]
bit B_BUTTON_F, a
bit B_PAD_B, a
jr nz, .set_carry
and START
and PAD_START
jr nz, .open_atk_page
call HandleMenuInput
jr nc, .loop_input
@ -4708,7 +4708,7 @@ Prophecy_PlayerSelectEffect:
ldtx hl, PleaseSelectTheDeckText
call TwoItemHorizontalMenu
ldh a, [hKeysHeld]
and B_BUTTON
and PAD_B
jr nz, Prophecy_PlayerSelectEffect ; loop back to start
ldh a, [hCurMenuItem]
@ -5163,7 +5163,7 @@ DevolutionBeam_PlayerSelectEffect:
ldtx hl, PleaseSelectThePlayAreaText
call TwoItemHorizontalMenu
ldh a, [hKeysHeld]
and B_BUTTON
and PAD_B
jr nz, .set_carry
; a Play Area was selected
@ -6855,7 +6855,7 @@ Gigashock_PlayerSelectEffect:
inc a
call DrawPlayAreaScreenToShowChanges
ldh a, [hKeysPressed]
and B_BUTTON
and PAD_B
jr nz, .try_cancel
call SwapTurn
call GetNextPositionInTempList
@ -10382,7 +10382,7 @@ LassEffect:
ldtx hl, ChooseTheCardYouWishToExamineText
ldtx de, DuelistHandText
bank1call SetCardListHeaderText
ld a, A_BUTTON | START
ld a, PAD_A | PAD_START
ld [wNoItemSelectionMenuKeys], a
bank1call DisplayCardList
ret

View File

@ -17,7 +17,7 @@ GameLoop::
ei
farcall StubbedUnusedSaveDataValidation
ldh a, [hKeysHeld]
cp A_BUTTON | B_BUTTON
cp PAD_A | PAD_B
jr z, .ask_erase_backup_ram
farcall _GameLoop
jr GameLoop

View File

@ -22,7 +22,7 @@ LoadConsolePaletteData:
FadeScreenToWhite:
ld a, [wLCDC]
bit LCDC_ENABLE_F, a
bit B_LCDC_ENABLE, a
jr z, .lcd_off
ld a, [wConsolePaletteData]
ld [wTempBGP], a
@ -94,7 +94,7 @@ RestoreFirstColorInOBPals:
inc de
ld a, [hl]
ld [de], a
ld bc, CGB_PAL_SIZE - 1
ld bc, PAL_SIZE - 1
add hl, bc
ld a, c
add e

View File

@ -104,7 +104,7 @@ InputPlayerName:
call DoFrame
call UpdateRNGSources
ldh a, [hDPadHeld]
and START
and PAD_START
jr z, .else
; the Start button was pressed.
ld a, $01
@ -301,17 +301,17 @@ PlayerNamingScreen_CheckButtonState:
ld h, a
ld a, [wNamingScreenCursorY]
ld l, a
bit D_UP_F, b
bit B_PAD_UP, b
jr z, .asm_692c
; up
dec a
bit D_DOWN_F, a
bit B_PAD_DOWN, a
jr z, .asm_69a7
ld a, c
dec a
jr .asm_69a7
.asm_692c
bit D_DOWN_F, b
bit B_PAD_DOWN, b
jr z, .asm_6937
; down
inc a
@ -323,7 +323,7 @@ PlayerNamingScreen_CheckButtonState:
ld a, [wNamingScreenNumColumns]
ld c, a
ld a, h
bit D_LEFT_F, b
bit B_PAD_LEFT, b
jr z, .asm_6974
; left
ld d, a
@ -360,13 +360,13 @@ PlayerNamingScreen_CheckButtonState:
jr .asm_69aa
.asm_696b
dec a
bit D_DOWN_F, a
bit B_PAD_DOWN, a
jr z, .asm_69aa
ld a, c
dec a
jr .asm_69aa
.asm_6974
bit D_RIGHT_F, b
bit B_PAD_RIGHT, b
jr z, .no_press
ld d, a
ld a, $06
@ -441,9 +441,9 @@ PlayerNamingScreen_CheckButtonState:
ld [wMenuInputSFX], a
.no_press
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
jr z, .asm_69ef
and A_BUTTON
and PAD_A
jr nz, .asm_69e5
; the B button was pressed.
ld a, -1
@ -1027,7 +1027,7 @@ InputDeckName:
call UpdateRNGSources
ldh a, [hDPadHeld]
and START
and PAD_START
jr z, .else
; the Start button was pressed.
@ -1243,17 +1243,17 @@ DeckNamingScreen_CheckButtonState:
ld h, a
ld a, [wNamingScreenCursorY]
ld l, a
bit D_UP_F, b
bit B_PAD_UP, b
jr z, .asm_6f1f
; up
dec a
bit D_DOWN_F, a
bit B_PAD_DOWN, a
jr z, .asm_6f4b
ld a, c
dec a
jr .asm_6f4b
.asm_6f1f
bit D_DOWN_F, b
bit B_PAD_DOWN, b
jr z, .asm_6f2a
; down
inc a
@ -1267,16 +1267,16 @@ DeckNamingScreen_CheckButtonState:
ld a, [wNamingScreenNumColumns]
ld c, a
ld a, h
bit D_LEFT_F, b
bit B_PAD_LEFT, b
jr z, .asm_6f40
dec a
bit D_DOWN_F, a
bit B_PAD_DOWN, a
jr z, .asm_6f4e
ld a, c
dec a
jr .asm_6f4e
.asm_6f40
bit D_RIGHT_F, b
bit B_PAD_RIGHT, b
jr z, .asm_6f73
inc a
cp c
@ -1311,9 +1311,9 @@ DeckNamingScreen_CheckButtonState:
ld [wMenuInputSFX], a
.asm_6f73
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
jr z, .asm_6f89
and A_BUTTON
and PAD_A
jr nz, .asm_6f7f
; B button was pressed
ld a, -1

View File

@ -22,7 +22,7 @@ PlayIntroSequence:
call DoFrameIfLCDEnabled
call UpdateRNGSources
ldh a, [hKeysPressed]
and A_BUTTON | START
and PAD_A | PAD_START
jr nz, .jump_to_title_screen
ld a, [wIntroSequencePalsNeedUpdate]
or a

View File

@ -5,13 +5,13 @@
; - return
TransmitIRBit:
jr c, .delay_once
ld [hl], RPF_WRITE_HI | RPF_ENREAD
ld [hl], RP_WRITE_HIGH | RP_ENABLE
ld a, 5
jr .loop_delay_1 ; jump to possibly to add more cycles?
.loop_delay_1
dec a
jr nz, .loop_delay_1
ld [hl], RPF_WRITE_LO | RPF_ENREAD
ld [hl], RP_WRITE_LOW | RP_ENABLE
ld a, 14
jr .loop_delay_2 ; jump to possibly to add more cycles?
.loop_delay_2
@ -78,7 +78,7 @@ ReceiveByteThroughIR:
ld b, 0
ld hl, rRP
.wait_ir
bit RPB_DATAIN, [hl]
bit B_RP_DATA_IN, [hl]
jr z, .ok
dec b
jr nz, .wait_ir
@ -112,11 +112,11 @@ ReceiveByteThroughIR:
; if in any of the checks it is unset,
; then a is set to 0
; this is done a total of 9 times
bit RPB_DATAIN, [hl]
bit B_RP_DATA_IN, [hl]
jr nz, .asm_196ec
xor a
.asm_196ec
bit RPB_DATAIN, [hl]
bit B_RP_DATA_IN, [hl]
jr nz, .asm_196f1
xor a
.asm_196f1
@ -244,23 +244,23 @@ StartIRCommunications:
call SwitchToCGBNormalSpeed
ld a, P14
ldh [rJOYP], a
ld a, RPF_ENREAD
ld a, RP_ENABLE
ldh [rRP], a
ret
; reenables interrupts, and switches CGB back to double speed
CloseIRCommunications:
ld a, P14 | P15
ld a, JOYP_GET_NONE
ldh [rJOYP], a
.wait_vblank_on
ldh a, [rSTAT]
and STAT_LCDC_STATUS
cp STAT_ON_VBLANK
and STAT_MODE
cp STAT_VBLANK
jr z, .wait_vblank_on
.wait_vblank_off
ldh a, [rSTAT]
and STAT_LCDC_STATUS
cp STAT_ON_VBLANK
and STAT_MODE
cp STAT_VBLANK
jr nz, .wait_vblank_off
call SwitchToCGBDoubleSpeed
ei

View File

@ -81,10 +81,10 @@ PrepareSendCardOrDeckConfigurationThroughIR:
.loop_frame
call DoFrame
ldh a, [hKeysPressed]
bit B_BUTTON_F, a
bit B_PAD_B, a
jr nz, .b_btn
ldh a, [hKeysHeld]
bit A_BUTTON_F, a
bit B_PAD_A, a
jr z, .loop_frame
; a btn
call TrySendIRRequest

View File

@ -153,7 +153,7 @@ _SetUpAndStartLinkDuel:
ldh a, [hDPadHeld]
ld b, a
ld a, [wNPCDuelPrizes]
bit D_LEFT_F, b
bit B_PAD_LEFT, b
jr z, .check_d_right
dec a
cp PRIZES_2
@ -162,7 +162,7 @@ _SetUpAndStartLinkDuel:
jr .got_prize_count
.check_d_right
bit D_RIGHT_F, b
bit B_PAD_RIGHT, b
jr z, .check_a_btn
inc a
cp PRIZES_6 + 1
@ -174,6 +174,6 @@ _SetUpAndStartLinkDuel:
ld [wPrizeCardSelectionFrameCounter], a
.check_a_btn
bit A_BUTTON_F, b
bit B_PAD_A, b
jr z, .loop_input
ret

View File

@ -345,7 +345,7 @@ TryInitPrinterCommunications:
.wait_input
call DoFrame
ldh a, [hKeysHeld]
and B_BUTTON
and PAD_B
jr nz, .b_button
ld bc, 0
lb de, PRINTERPKT_NUL, FALSE
@ -680,7 +680,7 @@ _PrintCardList:
; even if it's not marked as seen in the collection
ld e, FALSE
ldh a, [hKeysHeld]
and SELECT
and PAD_SELECT
jr z, .no_select
inc e ; TRUE
.no_select

View File

@ -36,7 +36,7 @@ _OpenBoosterPack:
ldtx hl, ChooseTheCardYouWishToExamineText
ldtx de, BoosterPackText
bank1call SetCardListHeaderText
ld a, A_BUTTON | START
ld a, PAD_A | PAD_START
ld [wNoItemSelectionMenuKeys], a
bank1call DisplayCardList
ret

View File

@ -503,14 +503,14 @@ HandleCardAlbumCardPage:
.handle_input
ldh a, [hDPadHeld]
ld b, a
and BUTTONS
and PAD_BUTTONS
jp nz, .exit
xor a ; FALSE
ld [wMenuInputSFX], a
ld a, [wCardListNumCursorPositions]
ld c, a
ld a, [wCardListCursorPos]
bit D_UP_F, b
bit B_PAD_UP, b
jr z, .check_d_down
push af
@ -536,7 +536,7 @@ HandleCardAlbumCardPage:
jr .got_new_pos
.check_d_down
bit D_DOWN_F, b
bit B_PAD_DOWN, b
jr z, .asm_a8d6
push af
@ -585,12 +585,12 @@ HandleCardAlbumCardPage:
ld a, [wced2]
or a
jr z, .open_card_page
bit D_LEFT_F, b
bit B_PAD_LEFT, b
jr z, .check_d_right
call RemoveCardFromDeck
jr .open_card_page
.check_d_right
bit D_RIGHT_F, b
bit B_PAD_RIGHT, b
jr z, .open_card_page
call TryAddCardToDeck
@ -664,7 +664,7 @@ CardAlbum:
.loop_input_2
call DoFrame
ldh a, [hKeysPressed]
and B_BUTTON
and PAD_B
jr z, .loop_input_2
ld a, $ff
call PlaySFXConfirmOrCancel
@ -698,7 +698,7 @@ CardAlbum:
call HandleLeftRightInCardList
jr c, .loop_input_3
ldh a, [hDPadHeld]
and START
and PAD_START
jr z, .loop_input_3
.open_card_page
ld a, $01

View File

@ -32,13 +32,13 @@ _PauseMenu_Config:
inc [hl]
call ConfigScreenHandleDPadInput
ldh a, [hKeysPressed]
and B_BUTTON | START
and PAD_B | PAD_START
jr nz, .asm_105ab
ld a, [wConfigCursorYPos]
cp $02
jr nz, .asm_10588
ldh a, [hKeysPressed]
and A_BUTTON
and PAD_A
jr z, .asm_10588
.asm_105ab
ld a, SFX_CONFIRM
@ -230,7 +230,7 @@ ExitSettingsCursorPosition:
ConfigScreenHandleDPadInput:
ldh a, [hDPadHeld]
and D_PAD
and PAD_CTRL_PAD
ret z
farcall GetDirectionFromDPad
ld hl, ConfigScreenDPadHandlers

View File

@ -115,7 +115,7 @@ DebugStandardBGCharacter:
lb bc, 16, 16
lb hl, 1, 16
call FillRectangle
ld a, BUTTONS | D_PAD
ld a, PAD_BUTTONS | PAD_CTRL_PAD
call WaitUntilKeysArePressed
scf
ret

View File

@ -17,9 +17,9 @@ HandleCheckMenuInput:
ldh a, [hDPadHeld]
or a
jr z, .no_pad
bit D_LEFT_F, a
bit B_PAD_LEFT, a
jr nz, .horizontal
bit D_RIGHT_F, a
bit B_PAD_RIGHT, a
jr z, .check_vertical
; handle horizontal input
@ -29,9 +29,9 @@ HandleCheckMenuInput:
ld d, a
jr .okay
.check_vertical
bit D_UP_F, a
bit B_PAD_UP, a
jr nz, .vertical
bit D_DOWN_F, a
bit B_PAD_DOWN, a
jr z, .no_pad
; handle vertical input
@ -58,9 +58,9 @@ HandleCheckMenuInput:
ld [wCheckMenuCursorBlinkCounter], a
.no_pad
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
jr z, .no_input
and A_BUTTON
and PAD_A
jr nz, .a_press
ld a, $ff ; cancel
call PlaySFXConfirmOrCancel

View File

@ -402,7 +402,7 @@ HandleDeckBuildScreen:
.wait_input
call DoFrame
ldh a, [hDPadHeld]
and START
and PAD_START
jr z, .no_start_btn_1
ld a, $01
call PlaySFXConfirmOrCancel
@ -427,7 +427,7 @@ HandleDeckBuildScreen:
.check_down_btn
ldh a, [hDPadHeld]
and D_DOWN
and PAD_DOWN
jr z, .no_down_btn
call ConfirmSelectionAndReturnCarry
jr .jump_to_list
@ -470,7 +470,7 @@ HandleDeckBuildScreen:
.loop_input
call DoFrame
ldh a, [hDPadHeld]
and START
and PAD_START
jr z, .no_start_btn_2
ld a, $01
call PlaySFXConfirmOrCancel
@ -1689,7 +1689,7 @@ HandleCardSelectionInput:
ld a, [wCardListNumCursorPositions]
ld c, a
ld a, [wCardListCursorPos]
bit D_LEFT_F, b
bit B_PAD_LEFT, b
jr z, .check_d_right
dec a
bit 7, a
@ -1699,7 +1699,7 @@ HandleCardSelectionInput:
dec a
jr .got_cursor_pos
.check_d_right
bit D_RIGHT_F, b
bit B_PAD_RIGHT, b
jr z, .handle_ab_btns
inc a
cp c
@ -1720,9 +1720,9 @@ HandleCardSelectionInput:
ld a, [wCardListCursorPos]
ld [hffb3], a
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
jr z, HandleCardSelectionCursorBlink
and A_BUTTON
and PAD_A
jr nz, ConfirmSelectionAndReturnCarry
; b button
ld a, $ff
@ -1806,7 +1806,7 @@ HandleDeckCardSelectionList:
ld a, [wCardListNumCursorPositions]
ld c, a
ld a, [wCardListCursorPos]
bit D_UP_F, b
bit B_PAD_UP, b
jr z, .check_d_down
push af
ld a, SFX_CURSOR
@ -1830,7 +1830,7 @@ HandleDeckCardSelectionList:
jr .asm_9b8f
.check_d_down
bit D_DOWN_F, b
bit B_PAD_DOWN, b
jr z, .asm_9b9d
push af
ld a, SFX_CURSOR
@ -1873,13 +1873,13 @@ HandleDeckCardSelectionList:
or a
jr z, .asm_9bb9
bit D_LEFT_F, b
bit B_PAD_LEFT, b
jr z, .check_d_right
call GetSelectedVisibleCardID
call RemoveCardFromDeckAndUpdateCount
jr .asm_9bb9
.check_d_right
bit D_RIGHT_F, b
bit B_PAD_RIGHT, b
jr z, .asm_9bb9
call GetSelectedVisibleCardID
call AddCardToDeckAndUpdateCount
@ -1913,9 +1913,9 @@ HandleDeckCardSelectionList:
.handle_ab_btns
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
jr z, .check_sfx
and A_BUTTON
and PAD_A
jr nz, .select_card
ld a, $ff
ld [hffb3], a
@ -2003,7 +2003,7 @@ OpenCardPageFromCardList:
.handle_input
ldh a, [hDPadHeld]
ld b, a
and A_BUTTON | B_BUTTON | SELECT | START
and PAD_A | PAD_B | PAD_SELECT | PAD_START
jp nz, .exit
; check d-pad
@ -2015,7 +2015,7 @@ OpenCardPageFromCardList:
ld a, [wCardListNumCursorPositions]
ld c, a
ld a, [wCardListCursorPos]
bit D_UP_F, b
bit B_PAD_UP, b
jr z, .check_d_down
push af
ld a, SFX_CURSOR
@ -2033,7 +2033,7 @@ OpenCardPageFromCardList:
jr .reopen_card_page
.check_d_down
bit D_DOWN_F, b
bit B_PAD_DOWN, b
jr z, .handle_regular_card_page_input
push af
ld a, SFX_CURSOR
@ -2402,7 +2402,7 @@ HandleDeckConfirmationMenu:
call HandleLeftRightInCardList
jr c, .loop_input
ldh a, [hDPadHeld]
and START
and PAD_START
jr z, .loop_input
.selected_card
@ -2447,9 +2447,9 @@ HandleLeftRightInCardList:
ld a, [wCardListVisibleOffset]
ld c, a
ldh a, [hDPadHeld]
cp D_RIGHT
cp PAD_RIGHT
jr z, .right
cp D_LEFT
cp PAD_LEFT
jr z, .left
or a
ret
@ -2496,9 +2496,9 @@ HandleSelectUpAndDownInList:
ld a, [wCardListVisibleOffset]
ld c, a
ldh a, [hDPadHeld]
cp SELECT | D_DOWN
cp PAD_SELECT | PAD_DOWN
jr z, .sel_down
cp SELECT | D_UP
cp PAD_SELECT | PAD_UP
jr z, .sel_up
or a
ret
@ -2542,7 +2542,7 @@ ShowDeckInfoHeaderAndWaitForBButton:
.wait_input
call DoFrame
ldh a, [hKeysPressed]
and B_BUTTON
and PAD_B
jr z, .wait_input
ld a, $ff
call PlaySFXConfirmOrCancel
@ -3124,7 +3124,7 @@ HandlePlayersCardsScreen:
ld [wCardListNumCursorPositions], a
.check_d_down
ldh a, [hDPadHeld]
and D_DOWN
and PAD_DOWN
jr z, .no_d_down
call ConfirmSelectionAndReturnCarry
jr .jump_to_list
@ -3168,7 +3168,7 @@ HandlePlayersCardsScreen:
call HandleDeckCardSelectionList
jr c, .asm_a36a
ldh a, [hDPadHeld]
and START
and PAD_START
jr z, .loop_input
; start btn pressed

View File

@ -62,7 +62,7 @@ HandleDeckMissingCardsList:
call HandleLeftRightInCardList
jr c, .loop_input
ldh a, [hDPadHeld]
and START
and PAD_START
jr z, .loop_input
.open_card_pge
@ -263,7 +263,7 @@ GiftCenter_ReceiveCard:
call HandleLeftRightInCardList
jr c, .asm_afe2
ldh a, [hDPadHeld]
and START
and PAD_START
jr z, .asm_afe2
.asm_aff5
ld a, $01
@ -658,7 +658,7 @@ HandleDeckMachineSelection:
call .HandleListJumps
jr c, .start
ldh a, [hDPadHeld]
and START
and PAD_START
jr z, .start
; start btn
@ -725,9 +725,9 @@ HandleDeckMachineSelection:
ld a, [wCardListVisibleOffset]
ld c, a
ldh a, [hDPadHeld]
cp D_RIGHT
cp PAD_RIGHT
jr z, .d_right
cp D_LEFT
cp PAD_LEFT
jr z, .d_left
or a
ret
@ -1909,13 +1909,13 @@ HandleAutoDeckMenu:
; the following lines do nothing
ldh a, [hDPadHeld]
and D_UP | D_DOWN
and PAD_UP | PAD_DOWN
jr z, .asm_ba4e
.asm_ba4e
; check whether to show deck confirmation list
ldh a, [hDPadHeld]
and START
and PAD_START
jr z, .wait_input
ld a, [wCardListVisibleOffset]

View File

@ -149,13 +149,13 @@ DeckSelectionMenu:
db SYM_SPACE ; tile behind cursor
dw NULL ; function pointer if non-0
; handles START button press when in deck selection menu
; does nothing if START button isn't pressed
; handles PAD_START button press when in deck selection menu
; does nothing if PAD_START button isn't pressed
; if a press was handled, returns carry
; prints "There is no deck here!" if the selected deck is empty
HandleStartButtonInDeckSelectionMenu:
ldh a, [hDPadHeld]
and START
and PAD_START
ret z ; skip
; set menu item as current deck

View File

@ -1232,9 +1232,9 @@ HandleCheckMenuInput_YourOrOppPlayArea:
and %10000000
ldh a, [hDPadHeld]
jr nz, .check_vertical
bit D_LEFT_F, a ; test left button
bit B_PAD_LEFT, a ; test left button
jr nz, .horizontal
bit D_RIGHT_F, a ; test right button
bit B_PAD_RIGHT, a ; test right button
jr z, .check_vertical
; handle horizontal input
@ -1264,9 +1264,9 @@ HandleCheckMenuInput_YourOrOppPlayArea:
jr .erase
.check_vertical
bit D_UP_F, a
bit B_PAD_UP, a
jr nz, .vertical
bit D_DOWN_F, a
bit B_PAD_DOWN, a
jr z, .skip
; handle vertical input
@ -1299,9 +1299,9 @@ HandleCheckMenuInput_YourOrOppPlayArea:
.skip
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
jr z, .sfx
and A_BUTTON
and PAD_A
jr nz, .a_pressed
; B pressed
@ -1722,7 +1722,7 @@ YourOrOppPlayAreaScreen_HandleInput:
inc hl
inc hl
bit D_UP_F, a
bit B_PAD_UP, a
jr z, .else_if_down
; up
@ -1731,7 +1731,7 @@ YourOrOppPlayAreaScreen_HandleInput:
.else_if_down
inc hl
bit D_DOWN_F, a
bit B_PAD_DOWN, a
jr z, .else_if_right
; down
@ -1740,7 +1740,7 @@ YourOrOppPlayAreaScreen_HandleInput:
.else_if_right
inc hl
bit D_RIGHT_F, a
bit B_PAD_RIGHT, a
jr z, .else_if_left
; right
@ -1749,7 +1749,7 @@ YourOrOppPlayAreaScreen_HandleInput:
.else_if_left
inc hl
bit D_LEFT_F, a
bit B_PAD_LEFT, a
jr z, .check_button
; left
@ -1785,9 +1785,9 @@ YourOrOppPlayAreaScreen_HandleInput:
; check if one of the dpad, left or right, is pressed.
; if not, just go back to the start.
ldh a, [hDPadHeld]
bit D_RIGHT_F, a
bit B_PAD_RIGHT, a
jr nz, .left_or_right
bit D_LEFT_F, a
bit B_PAD_LEFT, a
jr z, YourOrOppPlayAreaScreen_HandleInput
.left_or_right
@ -1833,10 +1833,10 @@ YourOrOppPlayAreaScreen_HandleInput:
ld [wCheckMenuCursorBlinkCounter], a
.check_button
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
jr z, .return
and A_BUTTON
and PAD_A
jr nz, .a_button
ld a, -1 ; cancel

View File

@ -19,7 +19,7 @@ OpenGlossaryScreen:
ld [wVBlankOAMCopyToggle], a
call DoFrame
ldh a, [hKeysPressed]
and SELECT
and PAD_SELECT
jr nz, .on_select
farcall YourOrOppPlayAreaScreen_HandleInput
@ -182,7 +182,7 @@ OpenGlossaryScreen:
.loop
call DoFrame
ldh a, [hKeysPressed]
and B_BUTTON
and PAD_B
jr z, .loop
ld a, -1

View File

@ -11,7 +11,7 @@ InitMenuScreen:
ldh [hSCX], a
ldh [hSCY], a
ld a, [wLCDC]
bit LCDC_ENABLE_F, a
bit B_LCDC_ENABLE, a
jr nz, .skip_clear_scroll
xor a
ldh [rSCX], a

View File

@ -47,7 +47,7 @@ _PCMenu_ReadMail:
call PCMailHandleDPadInput
call PCMailHandleAInput
ldh a, [hKeysPressed]
and B_BUTTON
and PAD_B
jr z, .asm_1079c
ld a, SFX_CANCEL
call PlaySFX
@ -74,7 +74,7 @@ MailScreenLabels:
PCMailHandleDPadInput:
ldh a, [hDPadHeld]
and D_PAD
and PAD_CTRL_PAD
ret z
farcall GetDirectionFromDPad
ld [wPCLastDirectionPressed], a
@ -135,7 +135,7 @@ PCMailTransitionTable:
PCMailHandleAInput:
ldh a, [hKeysPressed]
and A_BUTTON
and PAD_A
ret z
ld a, SFX_CONFIRM
call PlaySFX

View File

@ -30,7 +30,7 @@ OpenInPlayAreaScreen::
call DoFrame
ldh a, [hDPadHeld]
and START
and PAD_START
jr nz, .selection
; if this function's been called from 'select' button,
@ -40,7 +40,7 @@ OpenInPlayAreaScreen::
jr z, .handle_input ; if it's from the Check menu, jump.
ldh a, [hDPadHeld]
and SELECT
and PAD_SELECT
jr nz, .skip_input
.handle_input
@ -343,14 +343,14 @@ OpenInPlayAreaScreen_TransitionTable1:
in_play_area_cursor_transition $30, $6c, $00, OPP_ACTIVE, PLAYER_BENCH_1, PLAYER_DISCARD_PILE, PLAYER_DISCARD_PILE
in_play_area_cursor_transition $78, $80, $00, PLAYER_DISCARD_PILE, PLAYER_BENCH_1, PLAYER_ACTIVE, PLAYER_ACTIVE
in_play_area_cursor_transition $78, $70, $00, OPP_ACTIVE, PLAYER_HAND, PLAYER_ACTIVE, PLAYER_ACTIVE
in_play_area_cursor_transition $78, $34, 1 << OAM_X_FLIP, OPP_BENCH_1, PLAYER_ACTIVE, OPP_DISCARD_PILE, OPP_DISCARD_PILE
in_play_area_cursor_transition $30, $20, 1 << OAM_X_FLIP, OPP_BENCH_1, OPP_DISCARD_PILE, OPP_ACTIVE, OPP_ACTIVE
in_play_area_cursor_transition $30, $38, 1 << OAM_X_FLIP, OPP_BENCH_1, PLAYER_ACTIVE, OPP_ACTIVE, OPP_ACTIVE
in_play_area_cursor_transition $90, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_5, OPP_BENCH_2
in_play_area_cursor_transition $78, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_1, OPP_BENCH_3
in_play_area_cursor_transition $60, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_2, OPP_BENCH_4
in_play_area_cursor_transition $48, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_3, OPP_BENCH_5
in_play_area_cursor_transition $30, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_4, OPP_BENCH_1
in_play_area_cursor_transition $78, $34, OAM_XFLIP, OPP_BENCH_1, PLAYER_ACTIVE, OPP_DISCARD_PILE, OPP_DISCARD_PILE
in_play_area_cursor_transition $30, $20, OAM_XFLIP, OPP_BENCH_1, OPP_DISCARD_PILE, OPP_ACTIVE, OPP_ACTIVE
in_play_area_cursor_transition $30, $38, OAM_XFLIP, OPP_BENCH_1, PLAYER_ACTIVE, OPP_ACTIVE, OPP_ACTIVE
in_play_area_cursor_transition $90, $14, OAM_XFLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_5, OPP_BENCH_2
in_play_area_cursor_transition $78, $14, OAM_XFLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_1, OPP_BENCH_3
in_play_area_cursor_transition $60, $14, OAM_XFLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_2, OPP_BENCH_4
in_play_area_cursor_transition $48, $14, OAM_XFLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_3, OPP_BENCH_5
in_play_area_cursor_transition $30, $14, OAM_XFLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_4, OPP_BENCH_1
assert_table_length NUM_INPLAYAREA_POSITIONS
OpenInPlayAreaScreen_TransitionTable2:
@ -363,14 +363,14 @@ OpenInPlayAreaScreen_TransitionTable2:
in_play_area_cursor_transition $30, $6c, $00, OPP_ACTIVE, PLAYER_BENCH_1, PLAYER_DISCARD_PILE, PLAYER_DISCARD_PILE
in_play_area_cursor_transition $78, $80, $00, PLAYER_DISCARD_PILE, PLAYER_BENCH_1, PLAYER_ACTIVE, PLAYER_ACTIVE
in_play_area_cursor_transition $78, $70, $00, OPP_ACTIVE, PLAYER_HAND, PLAYER_ACTIVE, PLAYER_ACTIVE
in_play_area_cursor_transition $78, $34, 1 << OAM_X_FLIP, OPP_BENCH_1, PLAYER_ACTIVE, OPP_DISCARD_PILE, OPP_DISCARD_PILE
in_play_area_cursor_transition $30, $20, 1 << OAM_X_FLIP, OPP_BENCH_1, OPP_DISCARD_PILE, OPP_ACTIVE, OPP_ACTIVE
in_play_area_cursor_transition $30, $38, 1 << OAM_X_FLIP, OPP_HAND, PLAYER_ACTIVE, OPP_ACTIVE, OPP_ACTIVE
in_play_area_cursor_transition $90, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_5, OPP_BENCH_2
in_play_area_cursor_transition $78, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_1, OPP_BENCH_3
in_play_area_cursor_transition $60, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_2, OPP_BENCH_4
in_play_area_cursor_transition $48, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_3, OPP_BENCH_5
in_play_area_cursor_transition $30, $14, 1 << OAM_X_FLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_4, OPP_BENCH_1
in_play_area_cursor_transition $78, $34, OAM_XFLIP, OPP_BENCH_1, PLAYER_ACTIVE, OPP_DISCARD_PILE, OPP_DISCARD_PILE
in_play_area_cursor_transition $30, $20, OAM_XFLIP, OPP_BENCH_1, OPP_DISCARD_PILE, OPP_ACTIVE, OPP_ACTIVE
in_play_area_cursor_transition $30, $38, OAM_XFLIP, OPP_HAND, PLAYER_ACTIVE, OPP_ACTIVE, OPP_ACTIVE
in_play_area_cursor_transition $90, $14, OAM_XFLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_5, OPP_BENCH_2
in_play_area_cursor_transition $78, $14, OAM_XFLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_1, OPP_BENCH_3
in_play_area_cursor_transition $60, $14, OAM_XFLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_2, OPP_BENCH_4
in_play_area_cursor_transition $48, $14, OAM_XFLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_3, OPP_BENCH_5
in_play_area_cursor_transition $30, $14, OAM_XFLIP, OPP_PLAY_AREA, OPP_ACTIVE, OPP_BENCH_4, OPP_BENCH_1
assert_table_length NUM_INPLAYAREA_POSITIONS
OpenInPlayAreaScreen_HandleInput:
@ -395,7 +395,7 @@ OpenInPlayAreaScreen_HandleInput:
inc hl
; check d-pad
bit D_UP_F, a
bit B_PAD_UP, a
jr z, .else_if_down
; up
@ -404,7 +404,7 @@ OpenInPlayAreaScreen_HandleInput:
.else_if_down
inc hl
bit D_DOWN_F, a
bit B_PAD_DOWN, a
jr z, .else_if_right
; down
@ -413,7 +413,7 @@ OpenInPlayAreaScreen_HandleInput:
.else_if_right
inc hl
bit D_RIGHT_F, a
bit B_PAD_RIGHT, a
jr z, .else_if_left
; right
@ -422,7 +422,7 @@ OpenInPlayAreaScreen_HandleInput:
.else_if_left
inc hl
bit D_LEFT_F, a
bit B_PAD_LEFT, a
jr z, .check_button
; left
@ -463,7 +463,7 @@ OpenInPlayAreaScreen_HandleInput:
; handle index overflow
ldh a, [hDPadHeld]
bit D_RIGHT_F, a
bit B_PAD_RIGHT, a
jr z, .on_left
xor a
@ -494,7 +494,7 @@ OpenInPlayAreaScreen_HandleInput:
jr c, .next
ldh a, [hDPadHeld]
bit D_LEFT_F, a
bit B_PAD_LEFT, a
jr z, .on_right
ld a, INPLAYAREA_OPP_BENCH_1
@ -512,10 +512,10 @@ OpenInPlayAreaScreen_HandleInput:
ld [wCheckMenuCursorBlinkCounter], a
.check_button
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
jr z, .return
and A_BUTTON
and PAD_A
jr nz, .a_button
; pressed b button

View File

@ -30,7 +30,7 @@ PrinterMenu_PokemonCards:
ld [wCardListNumCursorPositions], a
.handle_input
ldh a, [hDPadHeld]
and D_DOWN
and PAD_DOWN
jr z, .asm_abca
; d_down
call ConfirmSelectionAndReturnCarry
@ -75,7 +75,7 @@ PrinterMenu_PokemonCards:
call HandleDeckCardSelectionList
jr c, .asm_ac60
ldh a, [hDPadHeld]
and START
and PAD_START
jr z, .loop_frame_2
; start btn
ld a, $01

View File

@ -45,7 +45,7 @@ HandleTitleScreen:
.check_keys
ldh a, [hKeysPressed]
and A_BUTTON | START
and PAD_A | PAD_START
jr z, .loop
ld a, SFX_CONFIRM
call PlaySFX

View File

@ -17,7 +17,7 @@ _PauseMenu_Status:
lb bc, 13, 6
call PrintPlayTime
call FlashWhiteScreen
ld a, A_BUTTON | B_BUTTON | START
ld a, PAD_A | PAD_B | PAD_START
call WaitUntilKeysArePressed
pop af
ld [wd291], a

View File

@ -9,9 +9,9 @@ Func_18661: ; unreferenced
or a
jr z, .check_button
; check input from dpad
bit D_LEFT_F, a
bit B_PAD_LEFT, a
jr nz, .left_or_right
bit D_RIGHT_F, a
bit B_PAD_RIGHT, a
jr z, .check_up_and_down
.left_or_right
; swap the lsb of x position value.
@ -21,9 +21,9 @@ Func_18661: ; unreferenced
jr .cursor_moved
.check_up_and_down
bit D_UP_F, a
bit B_PAD_UP, a
jr nz, .up_or_down
bit D_DOWN_F, a
bit B_PAD_DOWN, a
jr z, .check_button
.up_or_down
ld a, e
@ -43,9 +43,9 @@ Func_18661: ; unreferenced
ld [wCheckMenuCursorBlinkCounter], a
.check_button
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
jr z, .check_cursor_moved
and A_BUTTON
and PAD_A
jr nz, .a_button
; b button
@ -78,7 +78,7 @@ Func_18661: ; unreferenced
and %00001111
ret nz
ld a, SYM_CURSOR_R
bit D_RIGHT_F, [hl]
bit B_PAD_RIGHT, [hl]
jr z, .draw_tile
.draw_blank_cursor
ld a, SYM_SPACE

View File

@ -14,10 +14,10 @@ Func_1c003: ; unreferenced
ldh a, [hKeysHeld]
ld b, a
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
cp b
jr nz, JumpSetWindowOff
and B_BUTTON
and PAD_B
jr z, JumpSetWindowOff
ld bc, $20
@ -32,14 +32,14 @@ Func_1c003: ; unreferenced
ldh [hWY], a
ldh a, [hKeysPressed]
and A_BUTTON
and PAD_A
jr z, .skip_load_scene
ld a, SCENE_COLOR_PALETTE
lb bc, 0, 33
call LoadScene
.skip_load_scene
ldh a, [hKeysHeld]
and A_BUTTON
and PAD_A
jr z, .set_wd_on
ld a, $67
ldh [hWX], a

View File

@ -760,7 +760,7 @@ HandlePlayerMoveMode:
.not_moving
ldh a, [hKeysPressed]
and START
and PAD_START
call nz, OpenPauseMenu
ret
@ -833,7 +833,7 @@ Func_c58b:
HandlePlayerMoveModeInput:
ldh a, [hKeysHeld]
and D_PAD
and PAD_CTRL_PAD
jr z, .skip_moving
call UpdatePlayerDirectionFromDPad
call AttemptPlayerMovementFromDirection
@ -842,7 +842,7 @@ HandlePlayerMoveModeInput:
jr nz, .done
.skip_moving
ldh a, [hKeysPressed]
and A_BUTTON
and PAD_A
jr z, .done
call FindNPCOrObject
jr .done
@ -963,7 +963,7 @@ Func_c66c:
push bc
ld c, $1
ldh a, [hKeysHeld]
bit B_BUTTON_F, a
bit B_PAD_B, a
jr z, .asm_c67e
ld a, [wd338]
cp $2

View File

@ -50,7 +50,7 @@ OverworldMap_Update:
; or finalize the selection if the A button is pressed
OverworldMap_HandleKeyPress:
ldh a, [hKeysPressed]
and D_PAD
and PAD_CTRL_PAD
jr z, .no_d_pad
farcall GetDirectionFromDPad
ld [wPlayerDirection], a
@ -58,7 +58,7 @@ OverworldMap_HandleKeyPress:
jr .done
.no_d_pad
ldh a, [hKeysPressed]
and A_BUTTON
and PAD_A
jr z, .done
ld a, SFX_CONFIRM
call PlaySFX

View File

@ -201,8 +201,8 @@ Func_70136:
call SendSGB
call DisableLCD
ld a, [wLCDC]
and LCDC_BGENABLE | LCDC_WINSELECT
or LCDC_BGON
and LCDC_BG | LCDC_WIN_MAP
or LCDC_BG_ON
ld [wLCDC], a
ld a, %11100100
ldh [rBGP], a

View File

@ -15,7 +15,7 @@ UnusedCopyrightScreen: ; unreferenced
call UpdateRNGSources
pop bc
ldh a, [hKeysPressed]
and START
and PAD_START
jr nz, .exit
dec bc
ld a, b

View File

@ -57,13 +57,13 @@ UnusedSaveDataValidation: ; unreferenced
call SetupText
ldtx hl, YourDataWasDestroyedSomehowText
bank1call DrawWholeScreenTextBox
ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
xor a
ldh [hBankSRAM], a
ld [MBC3SRamBank], a
ld [MBC3RTC], a
ld [MBC3SRamEnable], a
ld [rRAMB], a
ld [rRTCREG], a
ld [rRAMG], a
jp Reset
ret
@ -86,8 +86,8 @@ UnusedCalculateSaveDataValidationByte: ; unreferenced
ld a, c
or b
jr nz, .loop_xor
ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
ld a, e
ld [sUnusedSaveDataValidationByte], a
pop bc

View File

@ -5,7 +5,7 @@ Bankswitch3dTo3f::
push af
ld a, $3f
ldh [hBankROM], a
ld [MBC3RomBank], a
ld [rROMB], a
pop af
ld bc, .bankswitch3d
push bc
@ -13,5 +13,5 @@ Bankswitch3dTo3f::
.bankswitch3d
ld a, $3d
ldh [hBankROM], a
ld [MBC3RomBank], a
ld [rROMB], a
ret

View File

@ -48,7 +48,7 @@ WriteDataBlockToBGMap0::
add hl, bc ; point to next structure
ret
; writes a to [v*BGMap0 + BG_MAP_WIDTH * c + b]
; writes a to [v*BGMap0 + TILEMAP_WIDTH * c + b]
WriteByteToBGMap0::
push af
ld a, [wLCDC]
@ -70,7 +70,7 @@ WriteByteToBGMap0::
pop af
; fallthrough
; writes a to [v*BGMap0 + BG_MAP_WIDTH * c + b] during hblank
; writes a to [v*BGMap0 + TILEMAP_WIDTH * c + b] during hblank
HblankWriteByteToBGMap0::
push hl
push de

View File

@ -192,7 +192,7 @@ LoadCardGfx::
res 7, h
set 6, h ; $4000 ≤ hl ≤ $7fff
call CopyGfxData
ld b, CGB_PAL_SIZE
ld b, PAL_SIZE
ld de, wCardPalette
.copy_card_palette
ld a, [hli]

View File

@ -2,8 +2,8 @@
SwitchToCGBNormalSpeed::
call CheckForCGB
ret c
ld hl, rKEY1
bit 7, [hl]
ld hl, rSPD
bit B_SPD_DOUBLE, [hl]
ret z
jr CGBSpeedSwitch
@ -11,8 +11,8 @@ SwitchToCGBNormalSpeed::
SwitchToCGBDoubleSpeed::
call CheckForCGB
ret c
ld hl, rKEY1
bit 7, [hl]
ld hl, rSPD
bit B_SPD_DOUBLE, [hl]
ret nz
; fallthrough
@ -22,7 +22,7 @@ CGBSpeedSwitch::
push af
xor a
ldh [rIE], a
set 0, [hl]
set B_SPD_PREPARE, [hl]
xor a
ldh [rIF], a
ldh [rIE], a

View File

@ -21,7 +21,7 @@ AttrBlkPacket_EmptyScreen::
ds 6 ; data set 2
ds 2 ; data set 3
; returns v*BGMap0 + BG_MAP_WIDTH * c + b in de.
; returns v*BGMap0 + TILEMAP_WIDTH * c + b in de.
; used to map coordinates at bc to a BGMap0 address.
BCCoordToBGMap0Address::
ld l, c

View File

@ -9,7 +9,7 @@ DoAFrames::
ret
; updates background, sprites and other game variables, halts until vblank, and reads user input
; if wDebugPauseAllowed is not 0, the game can be paused (and resumed) by pressing the SELECT button
; if wDebugPauseAllowed is not 0, the game can be paused (and resumed) by pressing the PAD_SELECT button
DoFrame::
push af
push hl
@ -24,14 +24,14 @@ DoFrame::
or a
jr z, .done
ldh a, [hKeysPressed]
and SELECT
and PAD_SELECT
jr z, .done
.game_paused_loop
call WaitForVBlank
call ReadJoypad
call HandleDPadRepeat
ldh a, [hKeysPressed]
and SELECT
and PAD_SELECT
jr z, .game_paused_loop
.done
pop bc
@ -45,11 +45,11 @@ DoFrame::
HandleDPadRepeat::
ldh a, [hKeysHeld]
ldh [hDPadHeld], a
and D_PAD
and PAD_CTRL_PAD
jr z, .done
ld hl, hDPadRepeat
ldh a, [hKeysPressed]
and D_PAD
and PAD_CTRL_PAD
jr z, .dpad_key_held
ld [hl], 24
ret
@ -60,6 +60,6 @@ HandleDPadRepeat::
ret
.done
ldh a, [hKeysPressed]
and BUTTONS
and PAD_BUTTONS
ldh [hDPadHeld], a
ret

View File

@ -5,12 +5,12 @@ HblankCopyDataHLtoDE::
ei
di
ldh a, [rSTAT] ;
and STAT_LCDC_STATUS ;
and STAT_MODE ;
jr nz, .loop ; assert hblank
ld a, [hl]
ld [de], a
ldh a, [rSTAT] ;
and STAT_LCDC_STATUS ;
and STAT_MODE ;
jr nz, .loop ; assert still in hblank
ei
inc hl
@ -27,12 +27,12 @@ HblankCopyDataDEtoHL::
ei
di
ldh a, [rSTAT] ;
and STAT_LCDC_STATUS ;
and STAT_MODE ;
jr nz, .loop ; assert hblank
ld a, [de]
ld [hl], a
ldh a, [rSTAT] ;
and STAT_LCDC_STATUS ;
and STAT_MODE ;
jr nz, .loop ; assert still in hblank
ei
inc hl

View File

@ -1,15 +1,15 @@
; read joypad data to refresh hKeysHeld, hKeysPressed, and hKeysReleased
; the A + B + Start + Select combination resets the game
ReadJoypad::
ld a, JOY_BTNS_SELECT
ld a, JOYP_GET_CTRL_PAD
ldh [rJOYP], a
ldh a, [rJOYP]
ldh a, [rJOYP]
cpl
and JOY_INPUT_MASK
and JOYP_INPUTS
swap a
ld b, a ; buttons data
ld a, JOY_DPAD_SELECT
ld a, JOYP_GET_BUTTONS
ldh [rJOYP], a
ldh a, [rJOYP]
ldh a, [rJOYP]
@ -18,7 +18,7 @@ ReadJoypad::
ldh a, [rJOYP]
ldh a, [rJOYP]
cpl
and JOY_INPUT_MASK
and JOYP_INPUTS
or b
ld c, a ; dpad data
cpl
@ -33,8 +33,8 @@ ReadJoypad::
ld b, a
ldh [hKeysPressed], a
ldh a, [hKeysHeld]
and BUTTONS
cp BUTTONS
and PAD_BUTTONS
cp PAD_BUTTONS
jr nz, SaveButtonsHeld
; A + B + Start + Select: reset game
call ResetSerial
@ -48,7 +48,7 @@ Reset::
SaveButtonsHeld::
ld a, c
ldh [hKeysHeld], a
ld a, JOY_BTNS_SELECT | JOY_DPAD_SELECT
ld a, JOYP_GET_CTRL_PAD | JOYP_GET_BUTTONS
ldh [rJOYP], a
ret

View File

@ -1,37 +1,37 @@
; enable timer interrupt
EnableInt_Timer::
ldh a, [rIE]
or 1 << INT_TIMER
or IE_TIMER
ldh [rIE], a
ret
; enable vblank interrupt
EnableInt_VBlank::
ldh a, [rIE]
or 1 << INT_VBLANK
or IE_VBLANK
ldh [rIE], a
ret
; enable lcdc interrupt on hblank mode
EnableInt_HBlank::
ldh a, [rSTAT]
or 1 << STAT_MODE_HBLANK
or STAT_MODE_0
ldh [rSTAT], a
xor a
ldh [rIF], a
ldh a, [rIE]
or 1 << INT_LCD_STAT
or IE_STAT
ldh [rIE], a
ret
; disable lcdc interrupt and the hblank mode trigger
DisableInt_HBlank::
ldh a, [rSTAT]
and ~(1 << STAT_MODE_HBLANK)
and ~STAT_MODE_0
ldh [rSTAT], a
xor a
ldh [rIF], a
ldh a, [rIE]
and ~(1 << INT_LCD_STAT)
and ~IE_STAT
ldh [rIE], a
ret

View File

@ -2,7 +2,7 @@
WaitForVBlank::
push hl
ld a, [wLCDC]
bit LCDC_ENABLE_F, a
bit B_LCDC_ENABLE, a
jr z, .lcd_off
ld hl, wVBlankCounter
ld a, [hl]
@ -18,7 +18,7 @@ WaitForVBlank::
; turn LCD on
EnableLCD::
ld a, [wLCDC] ;
bit LCDC_ENABLE_F, a ;
bit B_LCDC_ENABLE, a ;
ret nz ; assert that LCD is off
or LCDC_ON ;
ld [wLCDC], a ;
@ -30,21 +30,21 @@ EnableLCD::
; wait for vblank, then turn LCD off
DisableLCD::
ldh a, [rLCDC] ;
bit LCDC_ENABLE_F, a ;
bit B_LCDC_ENABLE, a ;
ret z ; assert that LCD is on
ldh a, [rIE]
ld [wIE], a
res INT_VBLANK, a ;
res B_IE_VBLANK, a ;
ldh [rIE], a ; disable vblank interrupt
.wait_vblank
ldh a, [rLY] ;
cp LY_VBLANK ;
cp LY_VBLANK + 1 ;
jr nz, .wait_vblank ; wait for vblank
ldh a, [rLCDC] ;
and LCDC_OFF ;
and LOW(~LCDC_ON) ;
ldh [rLCDC], a ;
ld a, [wLCDC] ;
and LCDC_OFF ;
and LOW(~LCDC_ON) ;
ld [wLCDC], a ; turn LCD off
xor a
ldh [rBGP], a
@ -57,27 +57,27 @@ DisableLCD::
; set OBJ size: 8x8
Set_OBJ_8x8::
ld a, [wLCDC]
and LCDC_OBJ8
and ~LCDC_OBJ_16
ld [wLCDC], a
ret
; set OBJ size: 8x16
Set_OBJ_8x16::
ld a, [wLCDC]
or LCDC_OBJ16
or LCDC_OBJ_16
ld [wLCDC], a
ret
; set Window Display on
SetWindowOn::
ld a, [wLCDC]
or LCDC_WINON
or LCDC_WIN_ON
ld [wLCDC], a
ret
; set Window Display off
SetWindowOff::
ld a, [wLCDC]
and LCDC_WINOFF
and ~LCDC_WIN_ON
ld [wLCDC], a
ret

View File

@ -1,7 +1,7 @@
DoFrameIfLCDEnabled::
push af
ldh a, [rLCDC]
bit LCDC_ENABLE_F, a
bit B_LCDC_ENABLE, a
jr z, .done
push bc
push de

View File

@ -56,7 +56,7 @@ DrawSpriteAnimationFrame::
dec b
.beginY
ld a, [wCurrSpriteAttributes]
bit OAM_Y_FLIP, a
bit B_OAM_YFLIP, a
jr z, .unflippedY
ld a, [hl]
add 8 ; size of a tile
@ -86,7 +86,7 @@ DrawSpriteAnimationFrame::
dec b
.beginX
ld a, [wCurrSpriteAttributes]
bit OAM_X_FLIP, a
bit B_OAM_XFLIP, a
jr z, .unflippedX
ld a, [hl]
add 8 ; size of a tile
@ -116,11 +116,11 @@ DrawSpriteAnimationFrame::
inc hl
ld a, [wCurrSpriteAttributes]
add [hl]
and OAM_PALETTE | (1 << OAM_OBP_NUM)
and OAM_PALETTE | OAM_PAL1
ld b, a
ld a, [wCurrSpriteAttributes]
xor [hl]
and (1 << OAM_X_FLIP) | (1 << OAM_Y_FLIP) | (1 << OAM_PRIORITY)
and OAM_XFLIP | OAM_YFLIP | OAM_PRIO
or b
ld b, a
inc hl ; unnecessary

View File

@ -83,7 +83,7 @@ HandleMenuInput::
ld a, [wNumMenuItems]
ld c, a
ld a, [wCurMenuItem]
bit D_UP_F, b
bit B_PAD_UP, b
jr z, .not_up
dec a
bit 7, a
@ -92,7 +92,7 @@ HandleMenuInput::
dec a ; wrapping around, so load the bottommost item
jr .handle_up_or_down
.not_up
bit D_DOWN_F, b
bit B_PAD_DOWN, b
jr z, .up_down_done
inc a
cp c
@ -131,9 +131,9 @@ HandleMenuInput::
ret
.check_A_or_B
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
jr z, RefreshMenuCursor_CheckPlaySFX
and A_BUTTON
and PAD_A
jr nz, .A_pressed_draw_cursor
; B button pressed
ld a, [wCurMenuItem]
@ -223,7 +223,7 @@ SetMenuItem::
ret
; handle input for the 2-row 3-column duel menu.
; only handles input not involving the B, START, or SELECT buttons, that is,
; only handles input not involving the B, PAD_START, or PAD_SELECT buttons, that is,
; navigating through the menu or selecting an item with the A button.
; other input in handled by PrintDuelMenuAndHandleInput.handle_input
HandleDuelMenuInput::
@ -232,13 +232,13 @@ HandleDuelMenuInput::
jr z, .blink_cursor
ld b, a
ld hl, wCurMenuItem
and D_UP | D_DOWN
and PAD_UP | PAD_DOWN
jr z, .check_left
ld a, [hl]
xor 1 ; move to the other menu item in the same column
jr .dpad_pressed
.check_left
bit D_LEFT_F, b
bit B_PAD_LEFT, b
jr z, .check_right
ld a, [hl]
sub 2
@ -248,7 +248,7 @@ HandleDuelMenuInput::
add 4
jr .dpad_pressed
.check_right
bit D_RIGHT_F, b
bit B_PAD_RIGHT, b
jr z, .dpad_not_pressed
ld a, [hl]
add 2
@ -269,7 +269,7 @@ HandleDuelMenuInput::
jr .blink_cursor
.dpad_not_pressed
ldh a, [hDPadHeld]
and A_BUTTON
and PAD_A
jp nz, HandleMenuInput.A_pressed
.blink_cursor
; blink cursor every 16 frames
@ -433,7 +433,7 @@ CardListMenuFunction::
dec a
ld c, a
ld a, [wCurMenuItem]
bit D_UP_F, b
bit B_PAD_UP, b
jr z, .not_up
cp c
jp nz, .continue
@ -448,7 +448,7 @@ CardListMenuFunction::
call ReloadCardListItems
jp .continue
.not_up
bit D_DOWN_F, b
bit B_PAD_DOWN, b
jr z, .not_down
or a
jr nz, .not_last_visible_item
@ -479,7 +479,7 @@ CardListMenuFunction::
ld [wRefreshMenuCursorSFX], a
jp .continue
.not_down
bit D_LEFT_F, b
bit B_PAD_LEFT, b
jr z, .not_left
ld a, [wListScrollOffset]
or a
@ -508,7 +508,7 @@ CardListMenuFunction::
call ReloadCardListItems
jr .continue
.not_left
bit D_RIGHT_F, b
bit B_PAD_RIGHT, b
jr z, .continue
ld a, [wNumMenuItems]
ld hl, wNumListItems
@ -581,9 +581,9 @@ CardListMenuFunction::
jp hl ; execute the function at wListFunctionPointer
.no_list_function
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
ret z
and B_BUTTON
and PAD_B
jr nz, .pressed_b
scf
ret
@ -717,9 +717,9 @@ WaitForButtonAorB::
call DoFrame
call RefreshMenuCursor
ldh a, [hKeysPressed]
bit A_BUTTON_F, a
bit B_PAD_A, a
jr nz, .a_pressed
bit B_BUTTON_F, a
bit B_PAD_B, a
jr z, WaitForButtonAorB
call EraseCursor
scf
@ -816,7 +816,7 @@ DrawNarrowTextBox_WaitForInput::
call DoFrame
call RefreshMenuCursor
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
jr z, .wait_A_or_B_loop
ret
@ -852,7 +852,7 @@ WaitForWideTextBoxInput::
call DoFrame
call RefreshMenuCursor
ldh a, [hKeysPressed]
and A_BUTTON | B_BUTTON
and PAD_A | PAD_B
jr z, .wait_A_or_B_loop
call EraseCursor
ret
@ -920,10 +920,10 @@ HandleYesOrNoMenu::
call DoFrame
call RefreshMenuCursor
ldh a, [hKeysPressed]
bit A_BUTTON_F, a
bit B_PAD_A, a
jr nz, .a_pressed
ldh a, [hDPadHeld]
and D_RIGHT | D_LEFT
and PAD_RIGHT | PAD_LEFT
jr z, .wait_button_loop
; left or right pressed, so switch to the other menu item
ld a, SFX_CURSOR

View File

@ -5,7 +5,7 @@ SetManyObjectsAttributes::
ld a, [wOAMOffset]
ld c, a
ld b, HIGH(wOAM)
cp 40 * 4
cp OAM_SIZE
jr nc, .beyond_oam
pop hl
ld a, [hli] ; [hl] = how many obj?
@ -26,7 +26,7 @@ SetManyObjectsAttributes::
ld [bc], a ; Attributes/Flags <- [hl + 4 + 4*i]
inc bc
ld a, c
cp 40 * 4
cp OAM_SIZE
jr nc, .beyond_oam
pop af
dec a
@ -42,13 +42,13 @@ SetManyObjectsAttributes::
jr .done
; for the sprite at wOAM + [wOAMOffset] / 4, set its attributes from registers e, d, c, b
; return carry if [wOAMOffset] > 40 * 4 (beyond the end of wOAM)
; return carry if [wOAMOffset] > OAM_SIZE (beyond the end of wOAM)
SetOneObjectAttributes::
push hl
ld a, [wOAMOffset]
ld l, a
ld h, HIGH(wOAM)
cp 40 * 4
cp OAM_SIZE
jr nc, .beyond_oam
ld [hl], e ; Y Position
inc hl
@ -73,7 +73,7 @@ ZeroObjectPositions::
xor a
ld [wOAMOffset], a
ld hl, wOAM
ld c, 40
ld c, OAM_COUNT
xor a
.loop
ld [hli], a

View File

@ -73,7 +73,7 @@ FlushPalettesIfRequested::
ld a, [wFlushPaletteFlags]
bit FLUSH_ALL_PALS_F, a
jr nz, FlushAllCGBPalettes
ld b, CGB_PAL_SIZE
ld b, PAL_SIZE
call CopyCGBPalettes
jr .done
@ -83,7 +83,7 @@ FlushAllCGBPalettes::
ld b, 8 palettes
call CopyCGBPalettes
; flush 8 OBP palettes
ld a, CGB_PAL_SIZE
ld a, PAL_SIZE
ld b, 8 palettes
call CopyCGBPalettes
jr FlushPalettesIfRequested.done
@ -111,7 +111,7 @@ CopyCGBPalettes::
inc c
.wait
ldh a, [rSTAT]
and 1 << STAT_BUSY ; wait until hblank or vblank
and STAT_BUSY ; wait until hblank or vblank
jr nz, .wait
ld a, [hl]
ld [$ff00+c], a

View File

@ -139,7 +139,7 @@ PrintScrollableText::
jr nc, .apply_delay
; if text speed is 1, pressing b ignores it
ldh a, [hKeysHeld]
and B_BUTTON
and PAD_B
jr nz, .skip_delay
.apply_delay
push bc
@ -458,7 +458,7 @@ PrintText::
cp 3
jr nc, .apply_delay
; if text speed is 1, pressing b ignores it
bit B_BUTTON_F, b
bit B_PAD_B, b
jr nz, .skip_delay
jr .apply_delay
.text_delay_loop

View File

@ -116,7 +116,7 @@ ProcessSpecialTextCharacter::
xor a
ldh [hTextLineCurPos], a
ldh a, [hTextHorizontalAlign]
add BG_MAP_WIDTH
add TILEMAP_WIDTH
ld b, a
; get current line's starting BGMap0 address
ldh a, [hTextBGMap0Address]

View File

@ -62,7 +62,7 @@ ApplyBackgroundScroll::
push hl
call DisableInt_LYCoincidence
ld hl, rSTAT
res STAT_LYCFLAG, [hl] ; reset coincidence flag
res B_STAT_LYCF, [hl] ; reset coincidence flag
ei
ld hl, wApplyBGScroll
ld a, [hl]
@ -85,7 +85,7 @@ ApplyBackgroundScroll::
call GetNextBackgroundScroll
ld hl, rSTAT
.wait_hblank_or_vblank
bit STAT_BUSY, [hl]
bit B_STAT_BUSY, [hl]
jr nz, .wait_hblank_or_vblank
ldh [rSCX], a
ldh a, [rLY]
@ -147,10 +147,10 @@ GetNextBackgroundScroll::
EnableInt_LYCoincidence::
push hl
ld hl, rSTAT
set STAT_LYC, [hl]
set B_STAT_LYC, [hl]
xor a
ld hl, rIE
set INT_LCD_STAT, [hl]
set B_IE_STAT, [hl]
pop hl
ret
@ -158,9 +158,9 @@ EnableInt_LYCoincidence::
DisableInt_LYCoincidence::
push hl
ld hl, rSTAT
res STAT_LYC, [hl]
res B_STAT_LYC, [hl]
xor a
ld hl, rIE
res INT_LCD_STAT, [hl]
res B_IE_STAT, [hl]
pop hl
ret

View File

@ -375,17 +375,17 @@ Func_0e8e::
ld a, SC_START | SC_EXTERNAL
ldh [rSC], a ; use external clock, set transfer start flag
ldh a, [rIF]
and ~(1 << INT_SERIAL)
and ~IE_SERIAL
ldh [rIF], a ; clear serial interrupt flag
ldh a, [rIE]
or 1 << INT_SERIAL ; enable serial interrupt
or IE_SERIAL ; enable serial interrupt
ldh [rIE], a
ret
; disable serial interrupt, and clear rSB, rSC, and serial registers in WRAM
ResetSerial::
ldh a, [rIE]
and ~(1 << INT_SERIAL)
and ~IE_SERIAL
ldh [rIE], a
xor a
ldh [rSB], a

View File

@ -22,19 +22,19 @@ SetupRegisters::
ld [hl], LOW(NoOp) ;
inc hl ; load `jp NoOp`
ld [hl], HIGH(NoOp) ;
ld a, LCDC_BGON | LCDC_OBJON | LCDC_OBJ16 | LCDC_WIN9C00
ld a, LCDC_BG_ON | LCDC_OBJ_ON | LCDC_OBJ_16 | LCDC_WIN_9C00
ld [wLCDC], a
ld a, $1
ld [MBC3LatchClock], a
ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a
ld [rRTCLATCH], a
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
NoOp::
ret
; sets wConsole and, if CGB, selects WRAM bank 1 and switches to double speed mode
DetectConsole::
ld b, CONSOLE_CGB
cp GBC
cp BOOTUP_A_CGB
jr z, .got_console
call DetectSGB
ld b, CONSOLE_DMG
@ -47,7 +47,7 @@ DetectConsole::
cp CONSOLE_CGB
ret nz
ld a, $01
ldh [rSVBK], a
ldh [rWBK], a
call SwitchToCGBDoubleSpeed
ret
@ -70,7 +70,7 @@ SetupPalettes::
ld c, 16
.copy_pals_loop
ld hl, InitialPalette
ld b, CGB_PAL_SIZE
ld b, PAL_SIZE
.copy_bytes_loop
ld a, [hli]
ld [de], a

View File

@ -217,9 +217,9 @@ Func_0bcb::
push de
.wait_vblank
ldh a, [rLY]
cp LY_VBLANK + 3
cp LY_VBLANK + 4
jr nz, .wait_vblank
ld a, LCDC_BGON | LCDC_OBJON | LCDC_WIN9C00
ld a, LCDC_BG_ON | LCDC_OBJ_ON | LCDC_WIN_9C00
ldh [rLCDC], a
ld a, %11100100
ldh [rBGP], a
@ -247,7 +247,7 @@ Func_0bcb::
add hl, de
dec c
jr nz, .bgmap_outer_loop
ld a, LCDC_BGON | LCDC_OBJON | LCDC_WIN9C00 | LCDC_ON
ld a, LCDC_BG_ON | LCDC_OBJ_ON | LCDC_WIN_9C00 | LCDC_ON
ldh [rLCDC], a
pop hl
call SendSGB

View File

@ -2,24 +2,24 @@
BankswitchSRAM::
push af
ldh [hBankSRAM], a
ld [MBC3SRamBank], a
ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a
ld [rRAMB], a
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
pop af
ret
; enable external RAM (SRAM)
EnableSRAM::
push af
ld a, SRAM_ENABLE
ld [MBC3SRamEnable], a
ld a, RAMG_SRAM_ENABLE
ld [rRAMG], a
pop af
ret
; disable external RAM (SRAM)
DisableSRAM::
push af
xor a ; SRAM_DISABLE
ld [MBC3SRamEnable], a
xor a ; RAMG_SRAM_DISABLE
ld [rRAMG], a
pop af
ret

View File

@ -89,5 +89,5 @@ BankpopROM::
; switch ROM bank to a
BankswitchROM::
ldh [hBankROM], a
ld [MBC3RomBank], a
ld [rROMB], a
ret

View File

@ -3,7 +3,7 @@
; if LCD on, copy during h-blank only
SafeCopyDataDEtoHL::
ld a, [wLCDC] ;
bit LCDC_ENABLE_F, a ;
bit B_LCDC_ENABLE, a ;
jr nz, .lcd_on ; assert that LCD is on
.lcd_off_loop
ld a, [de]
@ -15,7 +15,7 @@ SafeCopyDataDEtoHL::
.lcd_on
jp HblankCopyDataDEtoHL
; returns v*BGMap0 + BG_MAP_WIDTH * e + d in hl.
; returns v*BGMap0 + TILEMAP_WIDTH * e + d in hl.
; used to map coordinates at de to a BGMap0 address.
DECoordToBGMap0Address::
ld l, e
@ -182,13 +182,13 @@ ContinueDrawingTextBoxDMGorSGB::
lb de, SYM_BOX_BTM_L, SYM_BOX_BTM_R
; fallthrough
; copies b bytes of data to sp-$1f and to hl, and returns hl += BG_MAP_WIDTH
; copies b bytes of data to sp-$1f and to hl, and returns hl += TILEMAP_WIDTH
; d = value of byte 0
; e = value of byte b
; a = value of bytes [1, b-1]
; b is supposed to be BG_MAP_WIDTH or smaller, else the stack would get corrupted
; b is supposed to be TILEMAP_WIDTH or smaller, else the stack would get corrupted
CopyLine::
add sp, -BG_MAP_WIDTH
add sp, -TILEMAP_WIDTH
push hl
push bc
ld hl, sp+$4
@ -212,10 +212,10 @@ CopyLine::
call SafeCopyDataDEtoHL
pop bc
pop de
; advance pointer BG_MAP_WIDTH positions and restore stack pointer
ld hl, BG_MAP_WIDTH
; advance pointer TILEMAP_WIDTH positions and restore stack pointer
ld hl, TILEMAP_WIDTH
add hl, de
add sp, BG_MAP_WIDTH
add sp, TILEMAP_WIDTH
ret
; DrawRegularTextBox branches here on CGB console

View File

@ -7,7 +7,7 @@ FillRectangle::
push de
push af
push hl
add sp, -BG_MAP_WIDTH
add sp, -TILEMAP_WIDTH
call DECoordToBGMap0Address
.next_row
push hl
@ -38,7 +38,7 @@ FillRectangle::
ld [hl], a
pop bc
pop de
ld hl, BG_MAP_WIDTH
ld hl, TILEMAP_WIDTH
add hl, de
dec c
jr nz, .next_row

View File

@ -71,16 +71,16 @@ SetupTimer::
ld b, -68 ; Value for Normal Speed
call CheckForCGB
jr c, .set_timer
ldh a, [rKEY1]
and $80
ldh a, [rSPD]
and SPD_DOUBLE
jr z, .set_timer
ld b, $100 - 2 * 68 ; Value for CGB Double Speed
.set_timer
ld a, b
ldh [rTMA], a
ld a, TAC_16384_HZ
ld a, TAC_16KHZ
ldh [rTAC], a
ld a, TAC_START | TAC_16384_HZ
ld a, TAC_START | TAC_16KHZ
ldh [rTAC], a
ret

View File

@ -170,7 +170,7 @@ wc900:: ; c900
SECTION "WRAM0 1", WRAM0
wOAM:: ; ca00
ds $a0
ds OAM_SIZE
; 16-byte buffer to store text, usually a name or a number
; used by TX_RAM1 but not exclusively
@ -496,12 +496,12 @@ wPlayAreaSelectAction:: ; cbd4
wTempRetreatCostCardsPos:: ; cbd5
ds $1
; in a card list, which keys (among START and A_BUTTON) do not open the item selection
; in a card list, which keys (among PAD_START and PAD_A) do not open the item selection
; menu when a card is selected, directly "submitting" the selected card instead.
wNoItemSelectionMenuKeys:: ; cbd6
ds $1
; when viewing a card page, which keys (among B_BUTTON, D_UP, and D_DOWN) will exit the page,
; when viewing a card page, which keys (among PAD_B, PAD_UP, and PAD_DOWN) will exit the page,
; either to go back to the previous menu or list, or to load the card page of the card above/below it
wCardPageExitKeys:: ; cbd7
ds $1
@ -1340,7 +1340,7 @@ wEffectFunctionsBank:: ; ce22
; LoadCardGfx loads the card's palette here
wCardPalette:: ; ce23
ds CGB_PAL_SIZE
ds PAL_SIZE
; information about the text being currently processed, including font width,
; the rom bank, and the memory address of the next character to be printed.

View File

@ -14,15 +14,15 @@ def getOAMFlagStr(flags):
if (flags & 0b111 != 0):
strings.append('%{:03b}'.format(flags & 0b111))
if (flags & (1 << 3) != 0):
strings.append('(1 << OAM_TILE_BANK)')
strings.append('OAM_BANK1')
if (flags & (1 << 4) != 0):
strings.append('(1 << OAM_OBP_NUM)')
strings.append('OAM_PAL1')
if (flags & (1 << 5) != 0):
strings.append('(1 << OAM_X_FLIP)')
strings.append('OAM_XFLIP')
if (flags & (1 << 6) != 0):
strings.append('(1 << OAM_Y_FLIP)')
strings.append('OAM_YFLIP')
if (flags & (1 << 7) != 0):
strings.append('(1 << OAM_PRIORITY)')
strings.append('OAM_PRIO')
return ' | '.join(s for s in strings)