pokecrystal/event/kurt.asm

414 lines
5.8 KiB
NASM
Raw Normal View History

2015-10-16 17:35:43 +00:00
Kurt_PrintTextWhichApricorn: ; 88000
2015-12-19 01:07:09 +00:00
ld hl, .Text
2015-10-16 17:35:43 +00:00
call PrintText
ret
; 88007
2015-12-19 01:07:09 +00:00
.Text: ; 0x88007
2015-10-16 17:35:43 +00:00
; Which APRICORN should I use?
text_jump UnknownText_0x1bc06b
db "@"
; 0x8800c
Kurt_PrintTextHowMany: ; 8800c
2015-12-19 01:07:09 +00:00
ld hl, .Text
2015-10-16 17:35:43 +00:00
call PrintText
ret
; 88013
2015-12-19 01:07:09 +00:00
.Text: ; 0x88013
2015-10-16 17:35:43 +00:00
; How many should I make?
text_jump UnknownText_0x1bc089
db "@"
; 0x88018
Special_SelectApricornForKurt: ; 88018
2015-11-11 21:11:08 +00:00
call LoadStandardMenuDataHeader
2015-10-16 17:35:43 +00:00
ld c, $1
xor a
2015-11-23 21:04:53 +00:00
ld [wMenuScrollPosition], a
2015-10-24 14:34:19 +00:00
ld [wKurtApricornQuantity], a
2015-10-16 17:35:43 +00:00
.loop
push bc
call Kurt_PrintTextWhichApricorn
pop bc
ld a, c
ld [MenuSelection], a
call Kurt_SelectApricorn
ld a, c
ld [ScriptVar], a
and a
jr z, .done
ld [CurItem], a
2015-12-15 23:59:49 +00:00
ld a, [wMenuCursorY]
2015-10-16 17:35:43 +00:00
ld c, a
push bc
call Kurt_PrintTextHowMany
call Kurt_SelectQuantity
pop bc
jr nc, .loop
2015-11-01 23:13:31 +00:00
ld a, [wItemQuantityChangeBuffer]
2015-10-24 14:34:19 +00:00
ld [wKurtApricornQuantity], a
2015-10-16 17:35:43 +00:00
call Kurt_GiveUpSelectedQuantityOfSelectedApricorn
.done
2015-10-26 02:26:53 +00:00
call Call_ExitMenu
2015-10-16 17:35:43 +00:00
ret
; 88055
Kurt_SelectApricorn: ; 88055
2017-12-24 17:47:30 +00:00
farcall FindApricornsInBag
2015-10-16 17:35:43 +00:00
jr c, .nope
ld hl, .MenuDataHeader
call CopyMenuDataHeader
ld a, [MenuSelection]
2015-11-01 17:44:30 +00:00
ld [wMenuCursorBuffer], a
2015-10-16 17:35:43 +00:00
xor a
ld [hBGMapMode], a
2015-11-17 20:54:03 +00:00
call InitScrollingMenu
2015-10-16 17:35:43 +00:00
call UpdateSprites
2015-12-18 03:31:16 +00:00
call ScrollingMenu
2015-12-15 23:59:49 +00:00
ld a, [wMenuJoypad]
2015-12-19 01:07:09 +00:00
cp B_BUTTON
2015-10-16 17:35:43 +00:00
jr z, .nope
ld a, [MenuSelection]
cp -1
jr nz, .done
.nope
xor a
.done
ld c, a
ret
; 88086
.MenuDataHeader: ; 0x88086
db $40 ; flags
db 01, 01 ; start coords
db 10, 13 ; end coords
dw .MenuData2
db 1 ; default option
; 0x8808e
db 0
.MenuData2: ; 0x8808f
db $10 ; flags
db 4, 7
db 1
dbw 0, Buffer1
2015-11-04 00:43:47 +00:00
dba .Name
dba .Quantity
dba NULL
2015-10-16 17:35:43 +00:00
.Name: ; 8809f
ld a, [MenuSelection]
and a
ret z
2017-12-24 17:47:30 +00:00
farcall PlaceMenuItemName
2015-10-16 17:35:43 +00:00
ret
; 880ab
.Quantity: ; 880ab
ld a, [MenuSelection]
ld [CurItem], a
call Kurt_GetQuantityOfApricorn
ret z
2015-11-01 23:13:31 +00:00
ld a, [wItemQuantityChangeBuffer]
2015-12-18 03:31:16 +00:00
ld [MenuSelectionQuantity], a
2017-12-24 17:47:30 +00:00
farcall PlaceMenuItemQuantity
2015-10-16 17:35:43 +00:00
ret
; 880c2
Kurt_SelectQuantity: ; 880c2
ld a, [CurItem]
ld [MenuSelection], a
call Kurt_GetQuantityOfApricorn
jr z, .done
2015-11-01 23:13:31 +00:00
ld a, [wItemQuantityChangeBuffer]
ld [wItemQuantityBuffer], a
2015-10-16 17:35:43 +00:00
ld a, $1
2015-11-01 23:13:31 +00:00
ld [wItemQuantityChangeBuffer], a
2015-10-16 17:35:43 +00:00
ld hl, .MenuDataHeader
call LoadMenuDataHeader
.loop
xor a
ld [hBGMapMode], a
2015-11-04 19:02:11 +00:00
call MenuBox
2015-10-16 17:35:43 +00:00
call UpdateSprites
call .PlaceApricornName
call PlaceApricornQuantity
2015-11-25 15:16:29 +00:00
call ApplyTilemap
2017-12-24 17:47:30 +00:00
farcall Kurt_SelectQuantity_InterpretJoypad
2015-10-16 17:35:43 +00:00
jr nc, .loop
push bc
call PlayClickSFX
pop bc
ld a, b
cp -1
jr z, .done
2015-11-01 23:13:31 +00:00
ld a, [wItemQuantityChangeBuffer]
ld [wItemQuantityChangeBuffer], a ; What is the point of this operation?
2015-10-16 17:35:43 +00:00
scf
.done
call CloseWindow
2015-10-16 17:35:43 +00:00
ret
; 8810d
.MenuDataHeader: ; 0x8810d
db $40 ; flags
db 09, 06 ; start coords
db 12, 19 ; end coords
db 0, 0, -1, 0 ; XXX
.PlaceApricornName: ; 88116
call MenuBoxCoord2Tile
2015-12-19 01:07:09 +00:00
ld de, SCREEN_WIDTH + 1
2015-10-16 17:35:43 +00:00
add hl, de
ld d, h
ld e, l
2017-12-24 17:47:30 +00:00
farcall PlaceMenuItemName
2015-10-16 17:35:43 +00:00
ret
; 88126
PlaceApricornQuantity: ; 88126
call MenuBoxCoord2Tile
2015-12-19 01:07:09 +00:00
ld de, 2 * SCREEN_WIDTH + 10
2015-10-16 17:35:43 +00:00
add hl, de
ld [hl], "×"
inc hl
2015-11-01 23:13:31 +00:00
ld de, wItemQuantityChangeBuffer
2015-10-16 17:35:43 +00:00
lb bc, PRINTNUM_LEADINGZEROS | 1, 2
jp PrintNum
; 88139
Kurt_GetQuantityOfApricorn: ; 88139
push bc
ld hl, NumItems
ld a, [CurItem]
ld c, a
ld b, $0
.loop
inc hl
ld a, [hli]
cp -1
jr z, .done
cp c
jr nz, .loop
ld a, [hl]
add b
ld b, a
jr nc, .loop
ld b, -1
.done
ld a, b
sub 99
jr c, .done2
ld b, 99
.done2
ld a, b
2015-11-01 23:13:31 +00:00
ld [wItemQuantityChangeBuffer], a
2015-10-16 17:35:43 +00:00
and a
pop bc
ret
; 88161
Kurt_GiveUpSelectedQuantityOfSelectedApricorn: ; 88161
; Get the quantity of Apricorns of type [CurItem]
; in the bag. Compatible with multiple stacks.
; Initialize the search.
push de
push bc
ld hl, NumItems
ld a, [CurItem]
ld c, a
ld e, $0
xor a
2015-12-18 03:31:16 +00:00
ld [CurItemQuantity], a
2015-10-16 17:35:43 +00:00
ld a, -1
2015-12-19 01:07:09 +00:00
ld [wApricorns], a
2015-10-16 17:35:43 +00:00
; Search for [CurItem] in the bag.
.loop1
; Increase the total count.
2015-12-18 03:31:16 +00:00
ld a, [CurItemQuantity]
2015-10-16 17:35:43 +00:00
inc a
2015-12-18 03:31:16 +00:00
ld [CurItemQuantity], a
2015-10-16 17:35:43 +00:00
; Get the index of the next item.
inc hl
ld a, [hli]
; If we've reached the end of the pocket, break.
cp -1
jr z, .okay1
; If we haven't found what we're looking for, continue.
cp c
jr nz, .loop1
; Increment the result counter and store the bag index of the match.
ld d, $0
push hl
2015-12-19 01:07:09 +00:00
ld hl, wApricorns
2015-10-16 17:35:43 +00:00
add hl, de
inc e
2015-12-18 03:31:16 +00:00
ld a, [CurItemQuantity]
2015-10-16 17:35:43 +00:00
dec a
ld [hli], a
ld a, -1
ld [hl], a
pop hl
jr .loop1
.okay1
; How many stacks have we found?
ld a, e
and a
jr z, .done
dec a
jr z, .OnlyOne
2015-12-19 01:07:09 +00:00
ld hl, wApricorns
2015-10-16 17:35:43 +00:00
.loop2
ld a, [hl]
ld c, a
push hl
.loop3
inc hl
ld a, [hl]
cp -1
jr z, .okay2
ld b, a
ld a, c
call Kurt_GetAddressOfApricornQuantity
ld e, a
ld a, b
call Kurt_GetAddressOfApricornQuantity
sub e
jr z, .equal
jr c, .less
jr .loop3
.equal
ld a, c
sub b
jr nc, .loop3
.less
ld a, c
ld c, b
ld [hl], a
ld a, c
pop hl
ld [hl], a
push hl
jr .loop3
.okay2
pop hl
inc hl
ld a, [hl]
cp -1
jr nz, .loop2
.OnlyOne:
2015-12-19 01:07:09 +00:00
ld hl, wApricorns
2015-10-16 17:35:43 +00:00
.loop4
ld a, [hl]
cp -1
jr z, .done
push hl
2015-12-18 03:31:16 +00:00
ld [CurItemQuantity], a
2015-10-16 17:35:43 +00:00
call Kurt_GetRidOfItem
pop hl
2015-11-01 23:13:31 +00:00
ld a, [wItemQuantityChangeBuffer]
2015-10-16 17:35:43 +00:00
and a
jr z, .done
push hl
ld a, [hli]
ld c, a
.loop5
ld a, [hli]
cp -1
jr z, .okay3
cp c
jr c, .loop5
dec a
dec hl
ld [hli], a
jr .loop5
.okay3
pop hl
inc hl
jr .loop4
.done
2015-11-01 23:13:31 +00:00
ld a, [wItemQuantityChangeBuffer]
2015-10-16 17:35:43 +00:00
and a
pop bc
pop de
ret
; 88201
Kurt_GetAddressOfApricornQuantity: ; 88201
push hl
push bc
ld hl, NumItems
inc hl
ld c, a
ld b, $0
add hl, bc
add hl, bc
2015-10-16 17:35:43 +00:00
inc hl
ld a, [hl]
pop bc
pop hl
ret
; 88211
Kurt_GetRidOfItem: ; 88211
push bc
ld hl, NumItems
2015-12-18 03:31:16 +00:00
ld a, [CurItemQuantity]
2015-10-16 17:35:43 +00:00
ld c, a
ld b, $0
inc hl
add hl, bc
add hl, bc
2015-10-16 17:35:43 +00:00
ld a, [CurItem]
ld c, a
ld a, [hli]
cp -1
jr z, .done
cp c
jr nz, .done
2015-11-01 23:13:31 +00:00
ld a, [wItemQuantityChangeBuffer]
2015-10-16 17:35:43 +00:00
ld c, a
ld a, [hl]
sub c
ld b, c
jr nc, .okay
add c
ld b, a
.okay
push bc
ld hl, NumItems
ld a, b
2015-11-01 23:13:31 +00:00
ld [wItemQuantityChangeBuffer], a
2015-10-16 17:35:43 +00:00
call TossItem
pop bc
ld a, c
sub b
.done
2015-11-01 23:13:31 +00:00
ld [wItemQuantityChangeBuffer], a
2015-10-16 17:35:43 +00:00
pop bc
ret
; 88248