shithub: pokecrystal

Download patch

ref: 1dc88cb5854a15337997c6236aed01021a9d46f7
parent: ce16317f33fc534a6724f5ccfd0901bf2888862b
author: mid-kid <esteve.varela@gmail.com>
date: Sun Jan 16 18:50:50 EST 2022

Enumerate MobileAPI function constants

--- a/constants/mobile_constants.asm
+++ b/constants/mobile_constants.asm
@@ -1,3 +1,40 @@
+; MobileAPI calls (see lib/mobile/main.asm:_MobileAPI)
+	const_def 0, 2
+	const MOBILEAPI_00
+	const MOBILEAPI_01
+	const MOBILEAPI_02
+	const MOBILEAPI_03
+	const MOBILEAPI_04
+	const MOBILEAPI_05
+	const MOBILEAPI_06
+	const MOBILEAPI_07
+	const MOBILEAPI_08
+	const MOBILEAPI_09
+	const MOBILEAPI_0A
+	const MOBILEAPI_0B
+	const MOBILEAPI_0C
+	const MOBILEAPI_0D
+	const MOBILEAPI_0E
+	const MOBILEAPI_0F
+	const MOBILEAPI_10
+	const MOBILEAPI_11
+	const MOBILEAPI_12
+	const MOBILEAPI_13
+	const MOBILEAPI_14
+	const MOBILEAPI_15
+	const MOBILEAPI_16
+	const MOBILEAPI_17
+	const MOBILEAPI_SETTIMER
+	const MOBILEAPI_19
+	const MOBILEAPI_1A
+	const MOBILEAPI_1B
+	const MOBILEAPI_1C
+	const MOBILEAPI_1D
+	const MOBILEAPI_1E
+	const MOBILEAPI_1F
+	const MOBILEAPI_20
+	const MOBILEAPI_21
+
 ; MobileEZChatCategoryPointers indexes (see mobile/fixed_words.asm)
 	const_def
 	const EZCHAT_POKEMON
--- a/home/mobile.asm
+++ b/home/mobile.asm
@@ -1,7 +1,7 @@
-Function3e32::
+MobileAPI::
 ; Mobile
 	cp $2
-	ld [wc988], a
+	ld [wMobileAPIIndex], a
 	ld a, l
 	ld [wc986], a
 	ld a, h
@@ -22,19 +22,19 @@
 	set 6, [hl]
 	ldh a, [hROMBank]
 	push af
-	ld a, BANK(Function110030)
+	ld a, BANK(_MobileAPI)
 	ld [wc981], a
 	rst Bankswitch
 
-	jp Function110030
+	jp _MobileAPI
 
-Function3e60::
-; Return from Function110030
+ReturnMobileAPI::
+; Return from _MobileAPI
 	ld [wc986], a
 	ld a, l
 	ld [wc987], a
 	ld a, h
-	ld [wc988], a
+	ld [wMobileAPIIndex], a
 
 	pop bc
 	ld a, b
--- a/lib/mobile/main.asm
+++ b/lib/mobile/main.asm
@@ -88,22 +88,22 @@
 	ld [hl], a
 	ret
 
-Function110030::
-; Use the byte at wc988 as a parameter
+_MobileAPI::
+; Use the byte at wMobileAPIIndex as a parameter
 ; for a dw.
-; If [wc988] not in {12, 14, 16},
+; If [wMobileAPIIndex] not in {MOBILEAPI_06, MOBILEAPI_07, MOBILEAPI_08},
 ; clear [wc835].
 	push de
-	ld a, [wc988]
-	cp $0c
+	ld a, [wMobileAPIIndex]
+	cp MOBILEAPI_06
 	jr z, .noreset
-	cp $0e
+	cp MOBILEAPI_07
 	jr z, .noreset
-	cp $10
+	cp MOBILEAPI_08
 	jr z, .noreset
 	xor a
 	ld [wc835], a
-	ld a, [wc988]
+	ld a, [wMobileAPIIndex]
 .noreset
 	; Get the pointer
 	ld d, 0
@@ -110,18 +110,18 @@
 	ld e, a
 	ld hl, .dw
 	add hl, de
-	; Store the low byte in [wc988]
+	; Store the low byte in [wMobileAPIIndex]
 	ld a, [hli]
-	ld [wc988], a
+	ld [wMobileAPIIndex], a
 	ld a, [hl]
 	; restore de
 	pop de
-	ld hl, Function3e60 ; return here
+	ld hl, ReturnMobileAPI ; return here
 	push hl
 	; If the destination function is not Function110236,
 	; call Function1100b4.
 	ld h, a
-	ld a, [wc988]
+	ld a, [wMobileAPIIndex]
 	ld l, a
 	push hl
 	ld a, LOW(Function110236)
@@ -135,7 +135,7 @@
 	ld a, [hli]
 	ld h, [hl]
 	ld l, a
-	ret ; indirectly jump to the function loaded from the dw, which returns to Function3e60.
+	ret ; indirectly jump to the function loaded from the dw, which returns to ReturnMobileAPI.
 
 .dw
 	dw Function110115
@@ -162,7 +162,7 @@
 	dw Function110ddd
 	dw Function1111fe
 	dw Function1113fe
-	dw Function1100dc
+	dw MobileAPI_SetTimer
 	dw Function111541
 	dw Function111596
 	dw Function11162d
@@ -201,7 +201,7 @@
 	pop bc
 	ret
 
-Function1100dc:
+MobileAPI_SetTimer:
 	xor a
 	ldh [rTAC], a
 	ld e, c
@@ -231,10 +231,10 @@
 	ld a, [hl]
 	ld [wc820], a
 	ld [wc815], a
-	ld c, $7
-	ld a, $2
+	ld c, LOW(rTAC)
+	ld a, rTAC_65536_HZ
 	ldh [c], a
-	ld a, $6
+	ld a, 1 << rTAC_ON | rTAC_65536_HZ
 	ldh [c], a
 	ret
 
@@ -413,7 +413,7 @@
 	nop
 
 Function110236:
-	ld a, [wc988]
+	ld a, [wMobileAPIIndex]
 	push af
 	push bc
 	push hl
@@ -453,7 +453,7 @@
 	xor a
 	ld [wc819], a
 	ld c, $c
-	call Function1100dc
+	call MobileAPI_SetTimer
 	call Function1104b0
 	pop af
 	cp $35
@@ -505,7 +505,7 @@
 	ld [hl], a
 	ld a, [wc870]
 	ld c, a
-	call Function1100dc
+	call MobileAPI_SetTimer
 	ld hl, wc829
 	ld a, $72
 	ld [hli], a
@@ -590,7 +590,7 @@
 	ld [hl], a
 	ld a, [wc870]
 	ld c, a
-	call Function1100dc
+	call MobileAPI_SetTimer
 	ld de, wMobileSDK_PacketBuffer
 	ld b, 6 ; header size
 	ld hl, MobilePacket_ReadConfigurationDataPart1
@@ -676,7 +676,7 @@
 	ld [wc97a], a
 	ld a, [wc870]
 	ld c, a
-	call Function1100dc
+	call MobileAPI_SetTimer
 	ld hl, wc829
 	ld a, $80
 	ld [hli], a
@@ -741,7 +741,7 @@
 	ld [wc97a], a
 	ld a, [wc870]
 	ld c, a
-	call Function1100dc
+	call MobileAPI_SetTimer
 	ld hl, wc98f
 	ld a, $81
 	ld [hli], a
@@ -929,7 +929,7 @@
 	ld [wc819], a
 	ld a, [wc870]
 	ld c, a
-	call Function1100dc
+	call MobileAPI_SetTimer
 	ld hl, wc829
 	ld a, $80
 	ld [hli], a
@@ -956,7 +956,7 @@
 	ldh [rTAC], a
 	ld a, [wc870]
 	ld c, a
-	call Function1100dc
+	call MobileAPI_SetTimer
 	ld hl, wc98f
 	ld a, $81
 	ld [hli], a
@@ -3252,7 +3252,7 @@
 	ld hl, MobilePacket_TelephoneStatus
 	call PacketSendEmptyBody
 .asm_11156f
-	ld a, [wc988]
+	ld a, [wMobileAPIIndex]
 	cp $40
 	jr nz, .asm_11157a
 	ld a, $2c
@@ -3270,7 +3270,7 @@
 	ldh [rTAC], a
 	ld a, [wc870]
 	ld c, a
-	call Function1100dc
+	call MobileAPI_SetTimer
 	call Function1104b0
 	ld a, $1
 	ld [wc86b], a
@@ -4926,13 +4926,13 @@
 .End
 
 Unknown_112089:
-	db $ec, $14, $c9
-	db $e4, $0f, $0e
-	db $e0, $0c, $53
-	db $c4, $07, $94
-	db $b0, $05, $ee
-	db $ec, $10, $b4
-	db $e4, $0c, $dd
+	db -20, $14, $c9
+	db -28, $0f, $0e
+	db -32, $0c, $53
+	db -60, $07, $94
+	db -80, $05, $ee
+	db -20, $10, $b4
+	db -28, $0c, $dd
 
 Unknown_11209e:
 	db "HELO ", 0
--- a/mobile/mobile_40.asm
+++ b/mobile/mobile_40.asm
@@ -481,8 +481,8 @@
 	ret
 
 .asm_10036a
-	ld a, 0
-	call Function3e32
+	ld a, MOBILEAPI_00
+	call MobileAPI
 	ld [wcd2c], a
 	ld a, h
 	ld [wcd2d], a
@@ -505,14 +505,14 @@
 
 Function10038a:
 	ld hl, wccb4
-	ld a, $2e
-	call Function3e32
+	ld a, MOBILEAPI_17
+	call MobileAPI
 	ret
 
 Function100393:
 	ld hl, wcc60
-	ld a, $3a
-	call Function3e32
+	ld a, MOBILEAPI_1D
+	call MobileAPI
 	ret
 
 Function10039c:
@@ -3138,8 +3138,8 @@
 	ld de, wcd30
 	ld hl, $40
 	ld bc, $40
-	ld a, $02
-	call Function3e32
+	ld a, MOBILEAPI_01
+	call MobileAPI
 	ld a, [wMobileCommsJumptableIndex]
 	inc a
 	ld [wMobileCommsJumptableIndex], a
@@ -3146,8 +3146,8 @@
 	ret
 
 Function10151d: ; unreferenced
-	ld a, $34
-	call Function3e32
+	ld a, MOBILEAPI_1A
+	call MobileAPI
 	ld a, [wMobileCommsJumptableIndex]
 	inc a
 	ld [wMobileCommsJumptableIndex], a
@@ -3154,8 +3154,8 @@
 	ret
 
 Function10152a:
-	ld a, $36
-	call Function3e32
+	ld a, MOBILEAPI_1B
+	call MobileAPI
 	ld a, [wMobileCommsJumptableIndex]
 	inc a
 	ld [wMobileCommsJumptableIndex], a
@@ -3162,8 +3162,8 @@
 	ret
 
 Function101537:
-	ld a, $0a
-	call Function3e32
+	ld a, MOBILEAPI_05
+	call MobileAPI
 	ld a, [wMobileCommsJumptableIndex]
 	inc a
 	ld [wMobileCommsJumptableIndex], a
@@ -3171,8 +3171,8 @@
 
 Function101544:
 	farcall StartMobileInactivityTimer
-	ld a, $12
-	call Function3e32
+	ld a, MOBILEAPI_09
+	call MobileAPI
 	ld a, [wMobileCommsJumptableIndex]
 	inc a
 	ld [wMobileCommsJumptableIndex], a
@@ -3181,8 +3181,8 @@
 Function101557:
 	farcall StartMobileInactivityTimer
 	ld hl, wcd53
-	ld a, $08
-	call Function3e32
+	ld a, MOBILEAPI_04
+	call MobileAPI
 	ld a, [wMobileCommsJumptableIndex]
 	inc a
 	ld [wMobileCommsJumptableIndex], a
--- a/mobile/mobile_41.asm
+++ b/mobile/mobile_41.asm
@@ -865,8 +865,8 @@
 	ld de, wcd30
 	ld hl, $41
 	ld bc, $41
-	ld a, $40
-	call Function3e32
+	ld a, MOBILEAPI_20
+	call MobileAPI
 	ld a, [wMobileCommsJumptableIndex]
 	inc a
 	ld [wMobileCommsJumptableIndex], a
@@ -935,8 +935,8 @@
 
 Function1063f3:
 	ld de, wcd31
-	ld a, $32
-	call Function3e32
+	ld a, MOBILEAPI_19
+	call MobileAPI
 	ld a, [wMobileCommsJumptableIndex]
 	inc a
 	ld [wMobileCommsJumptableIndex], a
@@ -983,8 +983,8 @@
 	ret
 
 Function106442:
-	ld a, $36
-	call Function3e32
+	ld a, MOBILEAPI_1B
+	call MobileAPI
 	xor a
 	ldh [hMobile], a
 	ldh [hMobileReceive], a
--- a/mobile/mobile_46.asm
+++ b/mobile/mobile_46.asm
@@ -910,15 +910,15 @@
 	ret c
 	ret
 .asm_1187af
-	ld a, $0
-	call Function3e32
+	ld a, MOBILEAPI_00
+	call MobileAPI
 	ld [wMobileErrorCodeBuffer], a
 	ld a, l
 	ld [wMobileErrorCodeBuffer + 1], a
 	ld a, h
 	ld [wMobileErrorCodeBuffer + 2], a
-	ld a, $a
-	call Function3e32
+	ld a, MOBILEAPI_05
+	call MobileAPI
 	ld a, [wc3f0]
 	ld [wc319], a
 	ld a, [wcd34]
@@ -940,18 +940,18 @@
 	jr c, .asm_1187fd
 	sla a
 	jr c, .asm_1187f5
-	ld a, $24
+	ld a, MOBILEAPI_12
 	jr .asm_1187ff
 .asm_1187f5
-	ld a, $28
+	ld a, MOBILEAPI_14
 	jr .asm_1187ff
 .asm_1187f9
-	ld a, $2a
+	ld a, MOBILEAPI_15
 	jr .asm_1187ff
 .asm_1187fd
-	ld a, $2c
+	ld a, MOBILEAPI_16
 .asm_1187ff
-	call Function3e32
+	call MobileAPI
 	ret
 .asm_118803
 	ld a, $d3
@@ -961,8 +961,8 @@
 	xor a
 	ld [wMobileErrorCodeBuffer + 1], a
 	ld [wMobileErrorCodeBuffer + 2], a
-	ld a, $a
-	call Function3e32
+	ld a, MOBILEAPI_05
+	call MobileAPI
 	ld a, [wc3f0]
 	ld [wc319], a
 	ld a, [wcd34]
@@ -978,9 +978,9 @@
 	ldh a, [hJoyDown]
 	cp $5
 	jr nz, .asm_11884a
+	ld a, MOBILEAPI_05
+	call MobileAPI
 	ld a, $a
-	call Function3e32
-	ld a, $a
 	ld [wMobileErrorCodeBuffer], a
 	ld a, [wc3f0]
 	ld [wc319], a
@@ -996,9 +996,9 @@
 	ldh a, [hJoyDown]
 	cp $5
 	jr nz, .asm_118864
+	ld a, MOBILEAPI_05
+	call MobileAPI
 	ld a, $a
-	call Function3e32
-	ld a, $a
 	ld [wMobileErrorCodeBuffer], a
 	ld a, [wcd34]
 	ld [wBattleTowerRoomMenuJumptableIndex], a
@@ -1036,7 +1036,7 @@
 	ld [wc807], a
 	ld de, wcd81
 	ld hl, $46
-	ld a, $2
+	ld a, MOBILEAPI_01
 	jp Function119e2b
 
 Function118896: ; unreferenced
@@ -1049,7 +1049,7 @@
 	jr z, .asm_1188aa
 
 .asm_1188a5
-	ld a, $34
+	ld a, MOBILEAPI_1A
 	jp Function119e2b
 
 .asm_1188aa
@@ -1058,17 +1058,17 @@
 
 Function1188b0:
 	ld de, wc346
-	ld a, $c
+	ld a, MOBILEAPI_06
 	jp Function119e2b
 
 Function1188b8:
 	ld de, wc3ac
-	ld a, $e
+	ld a, MOBILEAPI_07
 	jp Function119e2b
 
 Function1188c0:
 	ld de, wc3cd
-	ld a, $10
+	ld a, MOBILEAPI_08
 	jp Function119e2b
 
 Function1188c8:
@@ -1085,7 +1085,7 @@
 	call Function119eb4
 	call Function119ec2
 	ld hl, wc708
-	ld a, $6
+	ld a, MOBILEAPI_03
 	jp Function119e2b
 
 Function1188e7:
@@ -1394,7 +1394,7 @@
 	call Function118b24
 	pop de
 	pop bc
-	ld a, $2a
+	ld a, MOBILEAPI_15
 	jp Function119e2b
 
 Function118b10:
@@ -1406,7 +1406,7 @@
 	call Function118b24
 	pop bc
 	pop de
-	ld a, $2a
+	ld a, MOBILEAPI_15
 	jp Function119e2b
 
 Function118b24:
@@ -1602,7 +1602,7 @@
 	ld hl, w3_d800
 	ld de, w3_de00
 	ld bc, $200
-	ld a, $2c
+	ld a, MOBILEAPI_16
 	jp Function119e2b
 
 Function118ded:
@@ -1697,7 +1697,7 @@
 Function118e6d:
 	xor a
 	ld [wcd65], a
-	ld a, $a
+	ld a, MOBILEAPI_05
 	jp Function119e2b
 
 Function118e76:
@@ -1709,7 +1709,7 @@
 Function118e7e:
 	call BattleTowerRoomMenu2
 	ret c
-	ld a, $36
+	ld a, MOBILEAPI_1B
 	jp Function119e2b
 
 BattleTowerRoomMenu_CallRoomMenu2:
@@ -1857,7 +1857,7 @@
 	ld hl, wc346
 	ld de, w3_de00
 	ld bc, $200
-	ld a, $2c
+	ld a, MOBILEAPI_16
 	jp Function119e2b
 
 .asm_118fba
@@ -1937,7 +1937,7 @@
 	ld hl, wc346
 	ld de, w3_d000
 	ld bc, $1000
-	ld a, $2c
+	ld a, MOBILEAPI_16
 	jp Function119e2b
 
 Function119054:
@@ -2471,7 +2471,7 @@
 	ld hl, wc346
 	ld de, w3_de00
 	ld bc, $200
-	ld a, $2c
+	ld a, MOBILEAPI_16
 	jp Function119e2b
 
 Function1193e3:
@@ -2856,7 +2856,7 @@
 	call Function118b24
 	ld de, w3_d000
 	ld bc, $1000
-	ld a, $2a
+	ld a, MOBILEAPI_15
 	jp Function119e2b
 
 Function119665:
@@ -3147,7 +3147,7 @@
 	call Function118b24
 	ld de, w3_d000
 	ld bc, $1000
-	ld a, $2a
+	ld a, MOBILEAPI_15
 	jp Function119e2b
 
 Function119800:
@@ -3287,7 +3287,7 @@
 	ld hl, w3_d800
 	ld de, w3_de00
 	ld bc, $200
-	ld a, $2c
+	ld a, MOBILEAPI_16
 	jp Function119e2b
 
 Function119937:
@@ -3328,7 +3328,7 @@
 	jr nz, .asm_119962
 	call Function119ec2
 	ld hl, wc608
-	ld a, $1e
+	ld a, MOBILEAPI_0F
 	jp Function119e2b
 
 Function119973:
@@ -3338,7 +3338,7 @@
 	ld [wcf65], a
 	ld [w3_d090], a
 	ld de, w3_d000
-	ld a, $20
+	ld a, MOBILEAPI_10
 	jp Function119e2b
 
 Function119987:
@@ -3351,7 +3351,7 @@
 	ld a, [wcf65]
 	ld h, a
 	ld de, wBGPals2
-	ld a, $22
+	ld a, MOBILEAPI_11
 	jp Function119e2b
 
 .asm_1199a0
@@ -3389,7 +3389,7 @@
 	ld h, a
 	ld de, w3_d100
 	ld bc, $0700
-	ld a, $28
+	ld a, MOBILEAPI_14
 	jp Function119e2b
 
 Function1199e2:
@@ -3555,7 +3555,7 @@
 	ld h, a
 	ld de, w3_d100
 	ld bc, $0700
-	ld a, $24
+	ld a, MOBILEAPI_12
 	jp Function119e2b
 
 Function119b3b:
@@ -3572,7 +3572,7 @@
 	ld h, a
 
 asm_119b4d:
-	ld a, $26
+	ld a, MOBILEAPI_13
 	jp Function119e2b
 
 Function119b52:
@@ -3586,7 +3586,7 @@
 	call CloseSRAM
 
 .asm_119b66
-	ld a, $1c
+	ld a, MOBILEAPI_0E
 	jp Function119e2b
 
 Function119b6b:
@@ -3993,7 +3993,7 @@
 	ret
 
 Function119e2b:
-	call Function3e32
+	call MobileAPI
 
 BattleTowerRoomMenu_IncrementJumptable:
 	ld hl, wBattleTowerRoomMenuJumptableIndex
--- a/mobile/mobile_5c.asm
+++ b/mobile/mobile_5c.asm
@@ -371,15 +371,15 @@
 	jp Function171c66
 
 .asm_171a6a
-	ld a, $0
-	call Function3e32
+	ld a, MOBILEAPI_00
+	call MobileAPI
 	ld [wMobileErrorCodeBuffer], a
 	ld a, l
 	ld [wMobileErrorCodeBuffer + 1], a
 	ld a, h
 	ld [wMobileErrorCodeBuffer + 2], a
-	ld a, $a
-	call Function3e32
+	ld a, MOBILEAPI_05
+	call MobileAPI
 	ldh a, [rSVBK]
 	push af
 	ld a, $1
@@ -407,8 +407,8 @@
 Function171ac9:
 	ld de, wcd81
 	ld hl, $5c
-	ld a, $2
-	call Function3e32
+	ld a, MOBILEAPI_01
+	call MobileAPI
 	jp Function171c66
 
 Function171ad7:
@@ -417,8 +417,8 @@
 	ld bc, $66
 	call ByteFill
 	ld de, $c608
-	ld a, $c
-	call Function3e32
+	ld a, MOBILEAPI_06
+	call MobileAPI
 	jp Function171c66
 
 Function171aec:
--- a/wram.asm
+++ b/wram.asm
@@ -1195,7 +1195,7 @@
 wc985:: db
 wc986:: db
 wc987:: db
-wc988:: db
+wMobileAPIIndex:: db
 wc989:: db
 wc98a:: db
 wc98b:: db