Pull a lot of engine out of main.asm

This commit is contained in:
U-Fish-PC\Daniel 2014-05-22 18:13:20 -04:00
parent ea3ba4cde3
commit 15427f5320
110 changed files with 39093 additions and 38990 deletions

51
engine/items/itemfinder.asm Executable file
View file

@ -0,0 +1,51 @@
HiddenItemNear: ; 7481f (1d:481f)
ld hl, HiddenItemCoords
ld b, $0
.asm_74824
ld de, $0003
ld a, [W_CURMAP]
call IsInArrayCummulativeCount
ret nc ; return if current map has no hidden items
push bc
push hl
ld hl, $d6f0
ld c, b
ld b, $2
ld a, $10
call Predef ; indirect jump to HandleBitArray (f666 (3:7666))
ld a, c
pop hl
pop bc
inc b
and a
inc hl
ld d, [hl]
inc hl
ld e, [hl]
inc hl
jr nz, .asm_74824 ; 0x74845 $dd
ld a, [W_YCOORD]
call Func_7486b
cp d
jr nc, .asm_74824 ; 0x7484e $d4
ld a, [W_YCOORD]
add $4
cp d
jr c, .asm_74824 ; 0x74856 $cc
ld a, [W_XCOORD]
call Func_7486b
cp e
jr nc, .asm_74824 ; 0x7485f $c3
ld a, [W_XCOORD]
add $5
cp e
jr c, .asm_74824 ; 0x74867 $bb
scf
ret
Func_7486b: ; 7486b (1d:486b)
sub $5
cp $f0
ret c
xor a
ret

2889
engine/items/items.asm Executable file

File diff suppressed because it is too large Load diff

23
engine/items/tm_prices.asm Executable file
View file

@ -0,0 +1,23 @@
GetMachinePrice: ; 7bf86 (1e:7f86)
ld a, [$cf91]
sub TM_01
ret c
ld d, a
ld hl, TechnicalMachinePrices ; $7fa7
srl a
ld c, a
ld b, 0
add hl, bc
ld a, [hl]
srl d
jr nc, .asm_7bf9d
swap a
.asm_7bf9d
and $f0
ld [H_DOWNARROWBLINKCNT2], a ; $ff8c
xor a
ld [H_DOWNARROWBLINKCNT1], a ; $ff8b
ld [$ff8d], a
ret
INCLUDE "data/tm_prices.asm"

26
engine/items/tmhm.asm Executable file
View file

@ -0,0 +1,26 @@
; checks if the mon in wWhichPokemon already knows the move in $d0e0
CheckIfMoveIsKnown: ; 2fe18 (b:7e18)
ld a, [wWhichPokemon]
ld hl, W_PARTYMON1_MOVE1
ld bc, $2c
call AddNTimes
ld a, [$d0e0]
ld b, a
ld c, $4 ; nubmer of moves
.loop
ld a, [hli]
cp b
jr z, .alreadyKnown ; found a match
dec c
jr nz, .loop
and a
ret
.alreadyKnown
ld hl, AlreadyKnowsText
call PrintText
scf
ret
AlreadyKnowsText: ; 2fe3b (b:7e3b)
TX_FAR _AlreadyKnowsText
db "@"

37
engine/items/tms.asm Executable file
View file

@ -0,0 +1,37 @@
; tests if mon [$cf91] can learn move [$d0e0]
TestMonMoveCompatibility: ; 1373e (4:773e)
ld a, [$cf91]
ld [$d0b5], a
call GetMonHeader
ld hl, W_MONHLEARNSET
push hl
ld a, [$d0e0]
ld b, a
ld c, $0
ld hl, TechnicalMachines
.findTMloop
ld a, [hli]
cp b
jr z, .TMfoundLoop
inc c
jr .findTMloop
.TMfoundLoop
pop hl
ld b, $2 ; read corresponding bit from TM compatibility array
ld a, $10
jp Predef ; indirect jump to HandleBitArray (f666 (3:7666))
; converts TM/HM number in $d11e into move number
; HMs start at 51
TMToMove: ; 13763 (4:7763)
ld a, [$d11e]
dec a
ld hl, TechnicalMachines
ld b, $0
ld c, a
add hl, bc
ld a, [hl]
ld [$d11e], a
ret
INCLUDE "data/tms.asm"