2018-06-24 07:09:41 -07:00
|
|
|
SwitchItemsInBag:
|
2015-12-13 11:15:16 -08:00
|
|
|
ld a, [wSwitchItem]
|
|
|
|
and a
|
|
|
|
jr z, .init
|
|
|
|
ld b, a
|
2015-12-17 14:51:32 -08:00
|
|
|
ld a, [wScrollingMenuCursorPosition]
|
2015-12-13 11:15:16 -08:00
|
|
|
inc a
|
|
|
|
cp b
|
|
|
|
jr z, .trivial
|
2015-12-17 14:51:32 -08:00
|
|
|
ld a, [wScrollingMenuCursorPosition]
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
ld a, [hl]
|
2015-12-23 11:00:29 -08:00
|
|
|
cp -1
|
2015-12-13 11:15:16 -08:00
|
|
|
ret z
|
|
|
|
ld a, [wSwitchItem]
|
|
|
|
dec a
|
|
|
|
ld [wSwitchItem], a
|
|
|
|
call Function249a7
|
|
|
|
jp c, Function249d1
|
2015-12-17 14:51:32 -08:00
|
|
|
ld a, [wScrollingMenuCursorPosition]
|
2015-12-13 11:15:16 -08:00
|
|
|
ld c, a
|
|
|
|
ld a, [wSwitchItem]
|
|
|
|
cp c
|
|
|
|
jr c, .asm_2497a
|
|
|
|
jr .asm_2494a
|
|
|
|
|
|
|
|
.init
|
2015-12-17 14:51:32 -08:00
|
|
|
ld a, [wScrollingMenuCursorPosition]
|
2015-12-13 11:15:16 -08:00
|
|
|
inc a
|
|
|
|
ld [wSwitchItem], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.trivial
|
|
|
|
xor a
|
|
|
|
ld [wSwitchItem], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_2494a
|
|
|
|
ld a, [wSwitchItem]
|
|
|
|
call Function24a40
|
2015-12-17 14:51:32 -08:00
|
|
|
ld a, [wScrollingMenuCursorPosition]
|
2015-12-13 11:15:16 -08:00
|
|
|
ld d, a
|
|
|
|
ld a, [wSwitchItem]
|
|
|
|
ld e, a
|
|
|
|
call Function24a6c
|
|
|
|
push bc
|
|
|
|
ld a, [wSwitchItem]
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
dec hl
|
|
|
|
push hl
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_ConvertSpacingToDW
|
2015-12-13 11:15:16 -08:00
|
|
|
add hl, bc
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
pop hl
|
|
|
|
pop bc
|
|
|
|
call Function24aab
|
2015-12-17 14:51:32 -08:00
|
|
|
ld a, [wScrollingMenuCursorPosition]
|
2015-12-13 11:15:16 -08:00
|
|
|
call Function24a4d
|
|
|
|
xor a
|
|
|
|
ld [wSwitchItem], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_2497a
|
|
|
|
ld a, [wSwitchItem]
|
|
|
|
call Function24a40
|
2015-12-17 14:51:32 -08:00
|
|
|
ld a, [wScrollingMenuCursorPosition]
|
2015-12-13 11:15:16 -08:00
|
|
|
ld d, a
|
|
|
|
ld a, [wSwitchItem]
|
|
|
|
ld e, a
|
|
|
|
call Function24a6c
|
|
|
|
push bc
|
|
|
|
ld a, [wSwitchItem]
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_ConvertSpacingToDW
|
2015-12-13 11:15:16 -08:00
|
|
|
add hl, bc
|
|
|
|
pop bc
|
|
|
|
call CopyBytes
|
2015-12-17 14:51:32 -08:00
|
|
|
ld a, [wScrollingMenuCursorPosition]
|
2015-12-13 11:15:16 -08:00
|
|
|
call Function24a4d
|
|
|
|
xor a
|
|
|
|
ld [wSwitchItem], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function249a7:
|
2015-12-13 11:15:16 -08:00
|
|
|
ld a, [wSwitchItem]
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2015-12-17 14:51:32 -08:00
|
|
|
ld a, [wScrollingMenuCursorPosition]
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
ld a, [de]
|
|
|
|
cp [hl]
|
|
|
|
jr nz, .asm_249cd
|
2015-12-17 14:51:32 -08:00
|
|
|
ld a, [wScrollingMenuCursorPosition]
|
2015-12-13 11:15:16 -08:00
|
|
|
call Function24a97
|
|
|
|
cp 99
|
|
|
|
jr z, .asm_249cd
|
|
|
|
ld a, [wSwitchItem]
|
|
|
|
call Function24a97
|
|
|
|
cp 99
|
|
|
|
jr nz, .asm_249cf
|
|
|
|
.asm_249cd
|
|
|
|
and a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_249cf
|
|
|
|
scf
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function249d1:
|
2015-12-13 11:15:16 -08:00
|
|
|
ld a, [wSwitchItem]
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
inc hl
|
|
|
|
push hl
|
2015-12-17 14:51:32 -08:00
|
|
|
ld a, [wScrollingMenuCursorPosition]
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
inc hl
|
|
|
|
ld a, [hl]
|
|
|
|
pop hl
|
|
|
|
add [hl]
|
|
|
|
cp 100
|
|
|
|
jr c, .asm_24a01
|
|
|
|
sub 99
|
|
|
|
push af
|
2015-12-17 14:51:32 -08:00
|
|
|
ld a, [wScrollingMenuCursorPosition]
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
inc hl
|
|
|
|
ld [hl], 99
|
|
|
|
ld a, [wSwitchItem]
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
inc hl
|
|
|
|
pop af
|
|
|
|
ld [hl], a
|
|
|
|
xor a
|
|
|
|
ld [wSwitchItem], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_24a01
|
|
|
|
push af
|
2015-12-17 14:51:32 -08:00
|
|
|
ld a, [wScrollingMenuCursorPosition]
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
inc hl
|
|
|
|
pop af
|
|
|
|
ld [hl], a
|
2018-01-23 13:08:43 -08:00
|
|
|
ld hl, wMenuData_ItemsPointerAddr
|
2015-12-13 11:15:16 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
ld a, [wSwitchItem]
|
|
|
|
cp [hl]
|
|
|
|
jr nz, .asm_24a25
|
|
|
|
dec [hl]
|
|
|
|
ld a, [wSwitchItem]
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
ld [hl], $ff
|
|
|
|
xor a
|
|
|
|
ld [wSwitchItem], a
|
|
|
|
ret
|
|
|
|
|
|
|
|
.asm_24a25
|
|
|
|
dec [hl]
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_ConvertSpacingToDW
|
2015-12-13 11:15:16 -08:00
|
|
|
push bc
|
|
|
|
ld a, [wSwitchItem]
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
pop bc
|
|
|
|
push hl
|
|
|
|
add hl, bc
|
|
|
|
pop de
|
|
|
|
.asm_24a34
|
|
|
|
ld a, [hli]
|
|
|
|
ld [de], a
|
|
|
|
inc de
|
|
|
|
cp $ff
|
|
|
|
jr nz, .asm_24a34
|
|
|
|
xor a
|
|
|
|
ld [wSwitchItem], a
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function24a40:
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
ld de, wd002
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_ConvertSpacingToDW
|
2015-12-13 11:15:16 -08:00
|
|
|
call CopyBytes
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function24a4d:
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
ld d, h
|
|
|
|
ld e, l
|
|
|
|
ld hl, wd002
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_ConvertSpacingToDW
|
2015-12-13 11:15:16 -08:00
|
|
|
call CopyBytes
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ItemSwitch_GetNthItem:
|
2015-12-13 11:15:16 -08:00
|
|
|
push af
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_ConvertSpacingToDW
|
2018-01-23 13:08:43 -08:00
|
|
|
ld hl, wMenuData_ItemsPointerAddr
|
2015-12-13 11:15:16 -08:00
|
|
|
ld a, [hli]
|
|
|
|
ld h, [hl]
|
|
|
|
ld l, a
|
|
|
|
inc hl
|
|
|
|
pop af
|
|
|
|
call AddNTimes
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function24a6c:
|
2015-12-13 11:15:16 -08:00
|
|
|
push hl
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_ConvertSpacingToDW
|
2015-12-13 11:15:16 -08:00
|
|
|
ld a, d
|
|
|
|
sub e
|
2015-12-23 11:00:29 -08:00
|
|
|
jr nc, .dont_negate
|
2015-12-13 11:15:16 -08:00
|
|
|
dec a
|
|
|
|
cpl
|
2015-12-23 11:00:29 -08:00
|
|
|
.dont_negate
|
2015-12-13 11:15:16 -08:00
|
|
|
ld hl, 0
|
|
|
|
call AddNTimes
|
|
|
|
ld b, h
|
|
|
|
ld c, l
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
ItemSwitch_ConvertSpacingToDW:
|
2015-12-23 11:00:29 -08:00
|
|
|
; This function is absolutely idiotic.
|
2015-12-13 11:15:16 -08:00
|
|
|
push hl
|
2018-01-23 13:08:43 -08:00
|
|
|
ld a, [wMenuData_ScrollingMenuSpacing]
|
2015-12-13 11:15:16 -08:00
|
|
|
ld c, a
|
|
|
|
ld b, 0
|
2015-12-23 11:00:29 -08:00
|
|
|
ld hl, .spacing_dws
|
2015-12-13 11:15:16 -08:00
|
|
|
add hl, bc
|
2016-05-04 08:46:23 -07:00
|
|
|
add hl, bc
|
2015-12-13 11:15:16 -08:00
|
|
|
ld c, [hl]
|
|
|
|
inc hl
|
|
|
|
ld b, [hl]
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
.spacing_dws
|
2015-12-13 11:15:16 -08:00
|
|
|
dw 0, 1, 2
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function24a97:
|
2015-12-13 11:15:16 -08:00
|
|
|
push af
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_ConvertSpacingToDW
|
2015-12-13 11:15:16 -08:00
|
|
|
ld a, c
|
2015-12-23 11:00:29 -08:00
|
|
|
cp 2
|
|
|
|
jr nz, .not_2
|
2015-12-13 11:15:16 -08:00
|
|
|
pop af
|
2015-12-23 11:00:29 -08:00
|
|
|
call ItemSwitch_GetNthItem
|
2015-12-13 11:15:16 -08:00
|
|
|
inc hl
|
|
|
|
ld a, [hl]
|
|
|
|
ret
|
|
|
|
|
2015-12-23 11:00:29 -08:00
|
|
|
.not_2
|
2015-12-13 11:15:16 -08:00
|
|
|
pop af
|
|
|
|
ld a, $1
|
|
|
|
ret
|
|
|
|
|
2018-06-24 07:09:41 -07:00
|
|
|
Function24aab:
|
2015-12-13 11:15:16 -08:00
|
|
|
.loop
|
|
|
|
ld a, [hld]
|
|
|
|
ld [de], a
|
|
|
|
dec de
|
|
|
|
dec bc
|
|
|
|
ld a, b
|
|
|
|
or c
|
|
|
|
jr nz, .loop
|
|
|
|
ret
|