Use hram constants for remaining joypad variables.

This commit is contained in:
yenatch 2014-08-30 19:48:49 -07:00
parent 365ae68d80
commit 8f49e37b82
8 changed files with 71 additions and 68 deletions

View file

@ -537,7 +537,7 @@ TradeCenter_SelectMon:
ld [wTileMap + $141], a
.asm_574a
call JoypadLowSensitivity
ld a, [$ffb5]
ld a, [hJoy5]
and a
jr z, .asm_574a ; 0x5750 $f8
bit 0, a
@ -896,7 +896,7 @@ Func_5a5f: ; 5a5f (1:5a5f)
ld [W_GRASSRATE], a ; W_GRASSRATE
inc a
ld [W_ISLINKBATTLE], a ; W_ISLINKBATTLE
ld [$ffb5], a
ld [hJoy5], a
ld a, $a
ld [wMusicHeaderPointer], a
ld a, BANK(Music_Celadon)

View file

@ -140,7 +140,7 @@ asm_7befa: ; 7befa (1e:7efa)
call DelayFrame
push bc
call JoypadLowSensitivity
ld a, [$ffb5]
ld a, [hJoy5]
pop bc
and $2
jr nz, .asm_7bf0d

View file

@ -307,7 +307,7 @@ Func_5d5f: ; 5d5f (1:5d5f)
xor a
ld [hJoyPressed], a
ld [hJoyHeld], a
ld [$ffb5], a
ld [hJoy5], a
ld [wd72d], a
ld hl, wd732
set 0, [hl]
@ -461,7 +461,7 @@ DisplayOptionMenu: ; 5e8a (1:5e8a)
call SetOptionsFromCursorPositions
.getJoypadStateLoop
call JoypadLowSensitivity
ld a,[$ffb5]
ld a,[hJoy5]
ld b,a
and a,%11111011 ; any key besides select pressed?
jr z,.getJoypadStateLoop

View file

@ -10,7 +10,7 @@ ShowPokedexMenu: ; 40000 (10:4000)
ld [wLastMenuItem],a
inc a
ld [wd11e],a
ld [$ffb7],a
ld [hJoy7],a
.setUpGraphics
ld b,$08
call GoPAL_SET
@ -35,7 +35,7 @@ ShowPokedexMenu: ; 40000 (10:4000)
ld [wcc37],a
ld [wCurrentMenuItem],a
ld [wLastMenuItem],a
ld [$ffb7],a
ld [hJoy7],a
ld [wcd3a],a
ld [wcd3b],a
pop af
@ -550,7 +550,7 @@ ShowPokedexDataInternal: ; 402e2 (10:42e2)
ld [$fff4],a
.waitForButtonPress
call JoypadLowSensitivity
ld a,[$ffb5]
ld a,[hJoy5]
and a,%00000011 ; A button and B button
jr z,.waitForButtonPress
pop af

View file

@ -797,7 +797,7 @@ SlotMachine_3784e: ; 3784e (d:784e)
SlotMachine_37882: ; 37882 (d:7882)
call DelayFrame
call JoypadLowSensitivity
ld a, [$ffb5]
ld a, [hJoy5]
and $1
ret z
ld hl, wTrainerSpriteOffset

View file

@ -6,7 +6,7 @@ DisplayTownMap: ; 70e3e (1c:4e3e)
ld [hl], $ff
push hl
ld a, $1
ld [$ffb7], a
ld [hJoy7], a
ld a, [W_CURMAP] ; W_CURMAP
push af
ld b, $0
@ -66,7 +66,7 @@ Func_70e92: ; 70e92 (1c:4e92)
.asm_70ec8
call Func_716c6
call JoypadLowSensitivity
ld a, [$ffb5]
ld a, [hJoy5]
ld b, a
and $c3
jr z, .asm_70ec8
@ -78,7 +78,7 @@ Func_70e92: ; 70e92 (1c:4e92)
jr nz, .asm_70f01
xor a
ld [wd09b], a
ld [$ffb7], a
ld [hJoy7], a
ld [W_SUBANIMTRANSFORM], a ; W_SUBANIMTRANSFORM
call Func_711ab
pop hl
@ -188,7 +188,7 @@ LoadTownMap_Fly: ; 70f90 (1c:4f90)
push hl
call DelayFrame
call JoypadLowSensitivity
ld a, [$ffb5]
ld a, [hJoy5]
ld b, a
pop hl
and $c3

View file

@ -102,34 +102,34 @@ Start::
INCLUDE "home/joypad.asm"
INCLUDE "data/map_header_pointers.asm"
INCLUDE "home/overworld.asm"
; this is used to check if the player wants to interrupt the opening sequence at several points
; XXX is this used anywhere else?
; INPUT:
; c = number of frames to wait
; sets carry if Up+Select+B, Start, or A is pressed within c frames
; unsets carry otherwise
CheckForUserInterruption:: ; 12f8 (0:12f8)
; Return carry if Up+Select+B, Start or A are pressed in c frames.
; Used only in the intro and title screen.
call DelayFrame
push bc
call JoypadLowSensitivity
pop bc
ld a,[hJoyHeld] ; currently pressed buttons
cp a,%01000110 ; Up, Select button, B button
jr z,.setCarry ; if all three keys are pressed
ld a,[$ffb5] ; either newly pressed buttons or currently pressed buttons at low sampling rate
and a,%00001001 ; Start button, A button
jr nz,.setCarry ; if either key is pressed
ld a, [hJoyHeld]
cp D_UP + SELECT + B_BUTTON
jr z, .input
ld a, [hJoy5]
and START | A_BUTTON
jr nz, .input
dec c
jr nz,CheckForUserInterruption
.unsetCarry
jr nz, CheckForUserInterruption
and a
ret
.setCarry
.input
scf
ret
@ -1347,7 +1347,7 @@ DisplayListMenuID:: ; 2be6 (0:2be6)
xor a
ld [H_AUTOBGTRANSFERENABLED],a ; disable auto-transfer
ld a,1
ld [$ffb7],a ; joypad state update flag
ld [hJoy7],a ; joypad state update flag
ld a,[W_BATTLETYPE]
and a ; is it the Old Man battle?
jr nz,.specialBattleType
@ -1501,7 +1501,7 @@ DisplayListMenuIDLoop:: ; 2c53 (0:2c53)
ld a,[wCurrentMenuItem]
ld [wd12d],a
xor a
ld [$ffb7],a ; joypad state update flag
ld [hJoy7],a ; joypad state update flag
ld hl,wd730
res 6,[hl] ; turn on letter printing delay
jp BankswitchBack
@ -1662,7 +1662,7 @@ ExitListMenu:: ; 2e3b (0:2e3b)
ld [wd12e],a
ld [wcc37],a
xor a
ld [$ffb7],a
ld [hJoy7],a
ld hl,wd730
res 6,[hl]
call BankswitchBack
@ -3347,29 +3347,29 @@ CopyString:: ; 3829 (0:3829)
ret
; this function is used when lower button sensitivity is wanted (e.g. menus)
; OUTPUT: [$ffb5] = pressed buttons in usual format
; there are two flags that control its functionality, [$ffb6] and [$ffb7]
; OUTPUT: [hJoy5] = pressed buttons in usual format
; there are two flags that control its functionality, [hJoy6] and [hJoy7]
; there are esentially three modes of operation
; 1. Get newly pressed buttons only
; ([$ffb7] == 0, [$ffb6] == any)
; Just copies [hJoyPressed] to [$ffb5].
; ([hJoy7] == 0, [hJoy6] == any)
; Just copies [hJoyPressed] to [hJoy5].
; 2. Get currently pressed buttons at low sample rate with delay
; ([$ffb7] == 1, [$ffb6] != 0)
; ([hJoy7] == 1, [hJoy6] != 0)
; If the user holds down buttons for more than half a second,
; report buttons as being pressed up to 12 times per second thereafter.
; If the user holds down buttons for less than half a second,
; report only one button press.
; 3. Same as 2, but report no buttons as pressed if A or B is held down.
; ([$ffb7] == 1, [$ffb6] == 0)
; ([hJoy7] == 1, [hJoy6] == 0)
JoypadLowSensitivity:: ; 3831 (0:3831)
call Joypad
ld a,[$ffb7] ; flag
ld a,[hJoy7] ; flag
and a ; get all currently pressed buttons or only newly pressed buttons?
ld a,[hJoyPressed] ; newly pressed buttons
jr z,.storeButtonState
ld a,[hJoyHeld] ; all currently pressed buttons
.storeButtonState
ld [$ffb5],a
ld [hJoy5],a
ld a,[hJoyPressed] ; newly pressed buttons
and a ; have any buttons been newly pressed since last check?
jr z,.noNewlyPressedButtons
@ -3383,18 +3383,18 @@ JoypadLowSensitivity:: ; 3831 (0:3831)
jr z,.delayOver
.delayNotOver
xor a
ld [$ffb5],a ; report no buttons as pressed
ld [hJoy5],a ; report no buttons as pressed
ret
.delayOver
; if [$ffb6] = 0 and A or B is pressed, report no buttons as pressed
; if [hJoy6] = 0 and A or B is pressed, report no buttons as pressed
ld a,[hJoyHeld]
and a,%00000011 ; A and B buttons
jr z,.setShortDelay
ld a,[$ffb6] ; flag
ld a,[hJoy6] ; flag
and a
jr nz,.setShortDelay
xor a
ld [$ffb5],a
ld [hJoy5],a
.setShortDelay
ld a,5 ; 1/12 of a second delay
ld [H_FRAMECOUNTER],a
@ -3421,7 +3421,7 @@ WaitForTextScrollButtonPress:: ; 3865 (0:3865)
pop hl
call JoypadLowSensitivity
predef Func_5a5f
ld a, [$ffb5]
ld a, [hJoy5]
and A_BUTTON | B_BUTTON
jr z, .asm_3872
pop af
@ -3888,7 +3888,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2)
.getJoypadState
pop hl
call JoypadLowSensitivity
ld a,[$ffb5]
ld a,[hJoy5]
and a ; was a key pressed?
jr nz,.keyPressed
push hl
@ -3911,7 +3911,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2)
.keyPressed
xor a
ld [wcc4b],a
ld a,[$ffb5]
ld a,[hJoy5]
ld b,a
bit 6,a ; pressed Up key?
jr z,.checkIfDownPressed
@ -3953,7 +3953,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2)
and b ; does the menu care about any of the pressed keys?
jp z,.loop1
.checkIfAButtonOrBButtonPressed
ld a,[$ffb5]
ld a,[hJoy5]
and a,%00000011 ; pressed A button or B button?
jr z,.skipPlayingSound
.AButtonOrBButtonPressed
@ -3971,7 +3971,7 @@ HandleMenuInputPokemonSelection:: ; 3ac2 (0:3ac2)
ld [H_DOWNARROWBLINKCNT1],a ; restore previous values
xor a
ld [wMenuWrappingEnabled],a ; disable menu wrapping
ld a,[$ffb5]
ld a,[hJoy5]
ret
.noWrappingAround
ld a,[wcc37]

View file

@ -1,8 +1,8 @@
H_SPRITEWIDTH EQU $FF8B ; in bytes
H_SPRITEWIDTH EQU $FF8B ; in tiles
H_SPRITEINTERLACECOUNTER EQU $FF8B
H_SPRITEHEIGHT EQU $FF8C ; in bytes
H_SPRITEOFFSET EQU $FF8D
H_SPRITEHEIGHT EQU $FF8C ; in tiles
H_SPRITEOFFSET EQU $FF8D
hSoftReset EQU $FF8A
; Initialized to 16.
@ -14,28 +14,31 @@ hSoftReset EQU $FF8A
H_DOWNARROWBLINKCNT1 EQU $FF8B
H_DOWNARROWBLINKCNT2 EQU $FF8C
; Note: the following multiplication and division addresses are used for multiple purposes
; and so they overlap with each other
; Multiplcation and division variables are meant
; to overlap for back-to-back usage. Big endian.
H_MULTIPLICAND EQU $FF96 ; 3 bytes, big endian order
H_MULTIPLICAND EQU $FF96 ; 3 bytes
H_MULTIPLIER EQU $FF99 ; 1 byte
H_PRODUCT EQU $FF95 ; 4 bytes, big endian order
H_PRODUCT EQU $FF95 ; 4 bytes
H_DIVIDEND EQU $FF95 ; 4 bytes, big endian order
H_DIVIDEND EQU $FF95 ; 4 bytes
H_DIVISOR EQU $FF99 ; 1 byte
H_QUOTIENT EQU $FF95 ; 4 bytes, big endian order
H_QUOTIENT EQU $FF95 ; 4 bytes
H_REMAINDER EQU $FF99 ; 1 byte
; used to convert numbers to decimal
H_PASTLEADINGZEROES EQU $FF95 ; flag to indicate that a nonzero digit has been printed
H_NUMTOPRINT EQU $FF96 ; 3 bytes, big endian order
H_POWEROFTEN EQU $FF99 ; 3 bytes, big endian order
H_SAVEDNUMTOPRINT EQU $FF9C ; 3 bytes, big endian order (to back out of a subtraction)
; PrintNumber (big endian).
H_PASTLEADINGZEROES EQU $FF95 ; last char printed
H_NUMTOPRINT EQU $FF96 ; 3 bytes
H_POWEROFTEN EQU $FF99 ; 3 bytes
H_SAVEDNUMTOPRINT EQU $FF9C ; 3 bytes
hJoyHeldLast EQU $FFB1
hJoyReleased EQU $FFB2
hJoyPressed EQU $FFB3
hJoyHeld EQU $FFB4
hJoyHeldLast EQU $FFB1
hJoyReleased EQU $FFB2
hJoyPressed EQU $FFB3
hJoyHeld EQU $FFB4
hJoy5 EQU $FFB5
hJoy6 EQU $FFB6
hJoy7 EQU $FFB7
H_LOADEDROMBANK EQU $FFB8