ref: 2341bb148ad651ca20e09ee6e48abd16c6aaee38
parent: dd11c22b316681b0c6e5dac69d519439163efc53
author: yenatch <[email protected]>
date: Thu Aug 29 15:10:06 EDT 2013
move more joypad code from main.asm into engine/joypad.asm
--- a/engine/joypad.asm
+++ b/engine/joypad.asm
@@ -273,3 +273,219 @@
ret
; a1b
+
+Functiona1b: ; a1b
+
+ call DelayFrame
+
+ push bc
+ call Functiona57
+ pop bc
+
+ ld a, [hJoyDown]
+ cp D_UP | SELECT | BUTTON_B
+ jr z, .asm_a34
+
+ ld a, [$ffa9]
+ and START | BUTTON_A
+ jr nz, .asm_a34
+
+ dec c
+ jr nz, Functiona1b
+
+ and a
+ ret
+
+.asm_a34
+ scf
+ ret
+; a36
+
+
+Functiona36: ; a36
+ call DelayFrame
+ call GetJoypadPublic
+ ld a, [hJoyPressed]
+ and BUTTON_A | BUTTON_B
+ ret nz
+ call RTC
+ jr Functiona36
+; a46
+
+Functiona46: ; a46
+ ld a, [hOAMUpdate]
+ push af
+ ld a, 1
+ ld [hOAMUpdate], a
+ call WaitBGMap
+ call Functiona36
+ pop af
+ ld [hOAMUpdate], a
+ ret
+; a57
+
+Functiona57: ; a57
+ call GetJoypadPublic
+ ld a, [$ffaa]
+ and a
+ ld a, [hJoyPressed]
+ jr z, .asm_a63
+ ld a, [hJoyDown]
+.asm_a63
+ ld [$ffa9], a
+ ld a, [hJoyPressed]
+ and a
+ jr z, .asm_a70
+ ld a, 15
+ ld [TextDelayFrames], a
+ ret
+
+.asm_a70
+ ld a, [TextDelayFrames]
+ and a
+ jr z, .asm_a7a
+ xor a
+ ld [$ffa9], a
+ ret
+
+.asm_a7a
+ ld a, 5
+ ld [TextDelayFrames], a
+ ret
+; a80
+
+Functiona80: ; a80
+ ld a, [$ffaf]
+ push af
+ ld a, [$ffb0]
+ push af
+ xor a
+ ld [$ffaf], a
+ ld a, $6
+ ld [$ffb0], a
+.asm_a8d
+ push hl
+ ld hl, $c606
+ call Functionb06
+ pop hl
+ call Functiona57
+ ld a, [$ffa9]
+ and $3
+ jr z, .asm_a8d
+ pop af
+ ld [$ffb0], a
+ pop af
+ ld [$ffaf], a
+ ret
+; aa5
+
+Functionaa5: ; aa5
+ call Functiona57
+ ld a, [$ffa9]
+ and BUTTON_A | BUTTON_B
+ jr z, Functionaa5
+ ret
+; aaf
+
+Functionaaf: ; aaf
+ ld a, [InLinkBattle]
+ and a
+ jr nz, .asm_ac1
+ call Functionac6
+ push de
+ ld de, SFX_READ_TEXT_2
+ call StartSFX
+ pop de
+ ret
+
+.asm_ac1
+ ld c, 65
+ jp DelayFrames
+; ac6
+
+Functionac6: ; ac6
+ ld a, [hOAMUpdate]
+ push af
+ ld a, $1
+ ld [hOAMUpdate], a
+ ld a, [InputType]
+ or a
+ jr z, .asm_ad9
+ callba Function1de28a
+.asm_ad9
+ call Functionaf5
+ call Functiona57
+ ld a, [hJoyPressed]
+ and $3
+ jr nz, .asm_af1
+ call RTC
+ ld a, $1
+ ld [hBGMapMode], a
+ call DelayFrame
+ jr .asm_ad9
+
+.asm_af1
+ pop af
+ ld [hOAMUpdate], a
+ ret
+; af5
+
+Functionaf5: ; af5
+ ld a, [$ff9b]
+ and $10
+ jr z, .asm_aff
+ ld a, $ee
+ jr .asm_b02
+
+.asm_aff
+ ld a, [$c605]
+
+.asm_b02
+ ld [$c606], a
+ ret
+; b06
+
+Functionb06: ; b06
+ push bc
+ ld a, [hl]
+ ld b, a
+ ld a, $ee
+ cp b
+ pop bc
+ jr nz, .asm_b27
+ ld a, [$ffaf]
+ dec a
+ ld [$ffaf], a
+ ret nz
+ ld a, [$ffb0]
+ dec a
+ ld [$ffb0], a
+ ret nz
+ ld a, $7a
+ ld [hl], a
+ ld a, $ff
+ ld [$ffaf], a
+ ld a, $6
+ ld [$ffb0], a
+ ret
+
+.asm_b27
+ ld a, [$ffaf]
+ and a
+ ret z
+ dec a
+ ld [$ffaf], a
+ ret nz
+ dec a
+ ld [$ffaf], a
+ ld a, [$ffb0]
+ dec a
+ ld [$ffb0], a
+ ret nz
+ ld a, $6
+ ld [$ffb0], a
+ ld a, $ee
+ ld [hl], a
+ ret
+; b40
+
--- a/main.asm
+++ b/main.asm
@@ -838,222 +838,6 @@
INCLUDE "engine/joypad.asm"
-Functiona1b: ; a1b
-
- call DelayFrame
-
- push bc
- call Functiona57
- pop bc
-
- ld a, [hJoyDown]
- cp D_UP | SELECT | BUTTON_B
- jr z, .asm_a34
-
- ld a, [$ffa9]
- and START | BUTTON_A
- jr nz, .asm_a34
-
- dec c
- jr nz, Functiona1b
-
- and a
- ret
-
-.asm_a34
- scf
- ret
-; a36
-
-
-Functiona36: ; a36
- call DelayFrame
- call GetJoypadPublic
- ld a, [hJoyPressed]
- and BUTTON_A | BUTTON_B
- ret nz
- call RTC
- jr Functiona36
-; a46
-
-Functiona46: ; a46
- ld a, [hOAMUpdate]
- push af
- ld a, 1
- ld [hOAMUpdate], a
- call WaitBGMap
- call Functiona36
- pop af
- ld [hOAMUpdate], a
- ret
-; a57
-
-Functiona57: ; a57
- call GetJoypadPublic
- ld a, [$ffaa]
- and a
- ld a, [hJoyPressed]
- jr z, .asm_a63
- ld a, [hJoyDown]
-.asm_a63
- ld [$ffa9], a
- ld a, [hJoyPressed]
- and a
- jr z, .asm_a70
- ld a, 15
- ld [TextDelayFrames], a
- ret
-
-.asm_a70
- ld a, [TextDelayFrames]
- and a
- jr z, .asm_a7a
- xor a
- ld [$ffa9], a
- ret
-
-.asm_a7a
- ld a, 5
- ld [TextDelayFrames], a
- ret
-; a80
-
-Functiona80: ; a80
- ld a, [$ffaf]
- push af
- ld a, [$ffb0]
- push af
- xor a
- ld [$ffaf], a
- ld a, $6
- ld [$ffb0], a
-.asm_a8d
- push hl
- ld hl, $c606
- call Functionb06
- pop hl
- call Functiona57
- ld a, [$ffa9]
- and $3
- jr z, .asm_a8d
- pop af
- ld [$ffb0], a
- pop af
- ld [$ffaf], a
- ret
-; aa5
-
-Functionaa5: ; aa5
- call Functiona57
- ld a, [$ffa9]
- and BUTTON_A | BUTTON_B
- jr z, Functionaa5
- ret
-; aaf
-
-Functionaaf: ; aaf
- ld a, [InLinkBattle]
- and a
- jr nz, .asm_ac1
- call Functionac6
- push de
- ld de, SFX_READ_TEXT_2
- call StartSFX
- pop de
- ret
-
-.asm_ac1
- ld c, 65
- jp DelayFrames
-; ac6
-
-Functionac6: ; ac6
- ld a, [hOAMUpdate]
- push af
- ld a, $1
- ld [hOAMUpdate], a
- ld a, [InputType]
- or a
- jr z, .asm_ad9
- callba Function1de28a
-.asm_ad9
- call Functionaf5
- call Functiona57
- ld a, [hJoyPressed]
- and $3
- jr nz, .asm_af1
- call RTC
- ld a, $1
- ld [hBGMapMode], a
- call DelayFrame
- jr .asm_ad9
-
-.asm_af1
- pop af
- ld [hOAMUpdate], a
- ret
-; af5
-
-Functionaf5: ; af5
- ld a, [$ff9b]
- and $10
- jr z, .asm_aff
- ld a, $ee
- jr .asm_b02
-
-.asm_aff
- ld a, [$c605]
-
-.asm_b02
- ld [$c606], a
- ret
-; b06
-
-Functionb06: ; b06
- push bc
- ld a, [hl]
- ld b, a
- ld a, $ee
- cp b
- pop bc
- jr nz, .asm_b27
- ld a, [$ffaf]
- dec a
- ld [$ffaf], a
- ret nz
- ld a, [$ffb0]
- dec a
- ld [$ffb0], a
- ret nz
- ld a, $7a
- ld [hl], a
- ld a, $ff
- ld [$ffaf], a
- ld a, $6
- ld [$ffb0], a
- ret
-
-.asm_b27
- ld a, [$ffaf]
- and a
- ret z
- dec a
- ld [$ffaf], a
- ret nz
- dec a
- ld [$ffaf], a
- ld a, [$ffb0]
- dec a
- ld [$ffb0], a
- ret nz
- ld a, $6
- ld [$ffb0], a
- ld a, $ee
- ld [hl], a
- ret
-; b40
-
-
INCLUDE "engine/decompress.asm"