merge with newest update

This commit is contained in:
JimB16
2015-10-26 03:26:53 +01:00
446 changed files with 17108 additions and 16475 deletions

View File

@@ -1,11 +1,11 @@
AI_SwitchOrTryItem: ; 38000
and a
ld a, [IsInBattle]
ld a, [wBattleMode]
dec a
ret z
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
ret nz
@@ -732,7 +732,7 @@ AI_Switch: ; 3846c
callba Function3d57a
xor a
ld [wd264], a
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
ret nz
scf

View File

@@ -237,16 +237,16 @@ Functioncc220: ; cc220
; Appears to be unused.
xor a
ld [hBGMapMode], a
ld a, $80
ld a, (VBGMap0 tile $28) % $100
ld [hBGMapAddress], a
ld a, $9a
ld a, (VBGMap0 tile $28) / $100
ld [hBGMapAddress + 1], a
call Function3200
ld a, $60
ld [hWY], a
xor a
ld [hBGMapAddress], a
ld a, $98
ld a, VBGMap0 / $100
ld [hBGMapAddress + 1], a
call BattleAnimDelayFrame
ret
@@ -709,7 +709,7 @@ BattleAnimCmd_D5: ; cc485 (33:4485)
rept 4
add hl, hl
endr
ld de, $8310
ld de, VTiles0 tile $31
add hl, de
ld a, [BattleAnimByte]
call Functionce846
@@ -817,13 +817,13 @@ endr
ld a, $49
ld [hl], a
ld hl, $8730
ld de, $9060
ld hl, VTiles0 tile $73
ld de, VTiles2 tile $06
ld a, $70
ld [BattleAnimTemps], a
ld a, $7
call Functioncc561
ld de, $9310
ld de, VTiles2 tile $31
ld a, $60
ld [BattleAnimTemps], a
ld a, $6
@@ -873,13 +873,13 @@ endr
ld a, $43
ld [hl], a
ld hl, $8660
ld de, $9050
ld hl, VTiles0 tile $66
ld de, VTiles2 tile $05
ld a, $70
ld [BattleAnimTemps], a
ld a, $7
call Functioncc5b3
ld de, $9310
ld de, VTiles2 tile $31
ld a, $60
ld [BattleAnimTemps], a
ld a, $6
@@ -932,7 +932,7 @@ BattleAnimCmd_DC: ; cc5dc (33:45dc)
ld [CurPartySpecies], a ; CurPartySpecies
ld hl, BattleMonDVs ; BattleMonDVs
predef GetUnownLetter
ld de, $8000
ld de, VTiles0 tile $00
predef GetFrontpic
jr .done
@@ -941,7 +941,7 @@ BattleAnimCmd_DC: ; cc5dc (33:45dc)
ld [CurPartySpecies], a ; CurPartySpecies
ld hl, EnemyMonDVs ; EnemyMonDVs
predef GetUnownLetter
ld de, $8000
ld de, VTiles0 tile $00
predef GetBackpic
.done
@@ -953,19 +953,19 @@ BattleAnimCmd_DC: ; cc5dc (33:45dc)
BattleAnimCmd_E8: ; cc622 (33:4622)
ld de, $8000
ld de, VTiles0 tile $00
ld a, [hBattleTurn] ; $ff00+$e4
and a
jr z, .player
ld hl, $9000
ld hl, VTiles2 tile $00
ld b, 0
ld c, $31
call Request2bpp
ret
.player
ld hl, $9310
ld hl, VTiles2 tile $31
ld b, 0
ld c, $24
call Request2bpp
@@ -1009,7 +1009,7 @@ GetSubstitutePic: ; cc64c
ld de, sScratch + $1b0
call CopyMonsterSpriteTile
ld hl, $9000
ld hl, VTiles2 tile $00
ld de, sScratch
lb bc, BANK(GetSubstitutePic), 7 * 7
call Request2bpp
@@ -1029,7 +1029,7 @@ GetSubstitutePic: ; cc64c
ld de, sScratch + $170
call CopyMonsterSpriteTile
ld hl, $9310
ld hl, VTiles2 tile $31
ld de, sScratch
lb bc, BANK(GetSubstitutePic), 6 * 6
call Request2bpp
@@ -1077,7 +1077,7 @@ GetMinimizePic: ; cc6e7 (33:46e7)
ld de, sScratch + $1a0
call CopyMinimizePic
ld hl, $9000
ld hl, VTiles2 tile $00
ld de, sScratch
lb bc, BANK(GetMinimizePic), $31
ret
@@ -1085,7 +1085,7 @@ GetMinimizePic: ; cc6e7 (33:46e7)
.player
ld de, sScratch + $160
call CopyMinimizePic
ld hl, $9310
ld hl, VTiles2 tile $31
ld de, sScratch
lb bc, BANK(GetMinimizePic), $24
ret
@@ -1110,7 +1110,7 @@ BattleAnimCmd_E9: ; cc735 (33:4735)
xor a
call GetSRAMBank
call GetMinimizePic
ld hl, $8000
ld hl, VTiles0 tile $00
call Request2bpp
call CloseSRAM
pop af
@@ -1159,14 +1159,14 @@ BattleAnimCmd_E6: ; cc776 (33:4776)
ld hl, BattleMonDVs ; BattleMonDVs
predef GetUnownLetter
ld de, $9000
ld de, VTiles2 tile $00
predef GetFrontpic
jr .done
.player
ld hl, EnemyMonDVs ; EnemyMonDVs
predef GetUnownLetter
ld de, $9310
ld de, VTiles2 tile $31
predef GetBackpic
.done

File diff suppressed because it is too large Load Diff

View File

@@ -12,7 +12,7 @@ DoPlayerTurn: ; 34000
DoEnemyTurn: ; 3400a
call SetEnemyTurn
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
jr z, DoTurn
@@ -696,7 +696,7 @@ BattleCommand02: ; 343db
; No obedience in link battles
; (since no handling exists for enemy)
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
ret nz
@@ -1080,7 +1080,7 @@ endr
jr z, .asm_345a4
; skip this part entirely if wildbattle
ld a, [IsInBattle]
ld a, [wBattleMode]
dec a
jr z, .asm_345c5
@@ -3520,7 +3520,7 @@ Function3534d: ; 3534d
inc l
.asm_3536b
ld a, [InLinkBattle]
ld a, [wLinkMode]
cp 3
jr z, .done
@@ -3834,11 +3834,11 @@ BattleCommanda1: ; 35461
sub b
ld [DefaultFlypoint], a
.asm_3550d
ld a, [IsInBattle]
ld a, [wBattleMode]
dec a
jr z, .asm_3556b
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
jr nz, .asm_35532
@@ -4825,7 +4825,7 @@ BattleCommand46: ; 35a74
call Function372d8
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
jr z, .asm_35a83
call AnimateFailedMove
@@ -4888,7 +4888,7 @@ BattleCommand46: ; 35a74
ld a, [hBattleTurn]
and a
jr z, .asm_35af6
ld a, [IsInBattle]
ld a, [wBattleMode]
dec a
jr nz, .asm_35af6
ld a, [hl]
@@ -5180,7 +5180,7 @@ endr
ld a, [hBattleTurn]
and a
jr nz, .asm_35c81
ld a, [IsInBattle]
ld a, [wBattleMode]
dec a
jr nz, .asm_35c81
ld hl, wc739
@@ -5585,7 +5585,7 @@ Function35ece: ; 35ece
jr z, .asm_35eec
; Not in link battle
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
jr nz, .asm_35eec
@@ -5683,7 +5683,7 @@ BattleCommand2f: ; 35f2c
and a
jr z, .asm_35f89
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
jr nz, .asm_35f89
@@ -6331,7 +6331,7 @@ BattleCommand1d: ; 362e3
and a
jr z, .DidntMiss
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
jr nz, .DidntMiss
@@ -7124,7 +7124,7 @@ BattleCommanda0: ; 36778
ld a, [hBattleTurn]
and a
jr nz, .asm_367bf
ld a, [IsInBattle]
ld a, [wBattleMode]
dec a
jr nz, .failed
ld a, [CurPartyLevel]
@@ -7149,7 +7149,7 @@ BattleCommanda0: ; 36778
jp PrintButItFailed
.asm_367bf
ld a, [IsInBattle]
ld a, [wBattleMode]
dec a
jr nz, .failed
ld a, [BattleMonLevel]
@@ -7188,10 +7188,10 @@ BattleCommanda0: ; 36778
Function36804: ; 36804
ld a, [wd0ee]
ld a, [wBattleResult]
and $c0
or $2
ld [wd0ee], a
ld [wBattleResult], a
ret
; 3680f
@@ -7214,7 +7214,7 @@ BattleCommand23: ; 3680f
ld a, [AttackMissed]
and a
jr nz, .asm_36852 ; 36830 $20
ld a, [IsInBattle]
ld a, [wBattleMode]
dec a
jr nz, .asm_36869 ; 36836 $31
ld a, [CurPartyLevel]
@@ -7300,7 +7300,7 @@ BattleCommand23: ; 3680f
and a
jr nz, .asm_368f3
ld a, [IsInBattle]
ld a, [wBattleMode]
dec a
jr nz, .asm_36908
@@ -7496,7 +7496,7 @@ BattleCommand24: ; 369b6
dec a
jr .asm_36a3a
.asm_36a0b
ld a, [IsInBattle]
ld a, [wBattleMode]
cp $1
jp z, .asm_36a1e
ld a, [OTPartyCount]
@@ -8177,7 +8177,7 @@ BattleCommand30: ; 36dc7
and a
jr z, .asm_36e0e
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
jr nz, .asm_36e0e
@@ -8519,7 +8519,7 @@ BattleCommand35: ; 36f9d
BattleCommand36: ; 36fe1
call AnimateCurrentMove
callba Function1060e5
callba MobileFn_1060e5
jp PrintNothingHappened
; 36fed
@@ -9152,7 +9152,7 @@ CheckSubstituteOpp: ; 37378
BattleCommand1a: ; 37380
callba Function10610d
callba MobileFn_10610d
ld a, $4
ld [wcfca], a
ld c, $3
@@ -9281,7 +9281,7 @@ BattleCommand53: ; 37563
and a
jr z, .party
ld a, [IsInBattle]
ld a, [wBattleMode]
dec a
jr z, .done
@@ -9493,7 +9493,7 @@ BattleCommand60: ; 3784b
BattleCommand61: ; 37874
; present
ld a, [InLinkBattle]
ld a, [wLinkMode]
cp $3
jr z, .asm_3787d
push bc
@@ -9502,7 +9502,7 @@ BattleCommand61: ; 37874
call BattleCommand_CalcDamageTypeMultiplier
ld a, [InLinkBattle]
ld a, [wLinkMode]
cp $3
jr z, .asm_37889
pop de
@@ -9765,7 +9765,7 @@ BattleCommand67: ; 379c9
.Enemy
; Wildmons don't have anything to switch to
ld a, [IsInBattle]
ld a, [wBattleMode]
dec a ; WILDMON
jp z, FailedBatonPass
@@ -9800,7 +9800,7 @@ BattleCommand67: ; 379c9
BatonPass_LinkPlayerSwitch: ; 37a67
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
ret z
@@ -9819,7 +9819,7 @@ BatonPass_LinkPlayerSwitch: ; 37a67
BatonPass_LinkEnemySwitch: ; 37a82
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
ret z
@@ -10057,7 +10057,7 @@ BattleCommand6a6c: ; 37b7e
jr z, .Full
; Don't factor in time of day in link battles.
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
jr nz, .Weather

View File

@@ -30,11 +30,11 @@ BattleCommand50: ; 37492
and a
ret nz
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
jr z, .stealenemyitem
ld a, [IsInBattle]
ld a, [wBattleMode]
dec a
ret z

215
battle/magikarp_length.asm Normal file
View File

@@ -0,0 +1,215 @@
CalcMagikarpLength: ; fbbfc
; Return Magikarp's length (in mm) at MagikarpLength (big endian).
;
; input:
; de: EnemyMonDVs
; bc: PlayerID
; This function is poorly commented.
; In short, it generates a value between 190 and 1786 using
; a Magikarp's DVs and its trainer ID. This value is further
; filtered in LoadEnemyMon to make longer Magikarp even rarer.
; The value is generated from a lookup table.
; The index is determined by the dv xored with the player's trainer id.
; bc = rrc(dv[0]) ++ rrc(dv[1]) ^ rrc(id)
; if bc < 10: [MagikarpLength] = c + 190
; if bc >= $ff00: [MagikarpLength] = c + 1370
; else: [MagikarpLength] = z * 100 + (bc - x) / y
; X, Y, and Z depend on the value of b as follows:
; if b = 0: x = 310, y = 2, z = 3
; if b = 1: x = 710, y = 4, z = 4
; if b = 2-9: x = 2710, y = 20, z = 5
; if b = 10-29: x = 7710, y = 50, z = 6
; if b = 30-68: x = 17710, y = 100, z = 7
; if b = 69-126: x = 32710, y = 150, z = 8
; if b = 127-185: x = 47710, y = 150, z = 9
; if b = 186-224: x = 57710, y = 100, z = 10
; if b = 225-243: x = 62710, y = 50, z = 11
; if b = 244-251: x = 64710, y = 20, z = 12
; if b = 252-253: x = 65210, y = 5, z = 13
; if b = 254: x = 65410, y = 2, z = 14
; bc = rrc(dv[0]) ++ rrc(dv[1]) ^ rrc(id)
; id
ld h, b
ld l, c
ld a, [hli]
ld b, a
ld c, [hl]
rrc b
rrc c
; dv
ld a, [de]
inc de
rrca
rrca
xor b
ld b, a
ld a, [de]
rrca
rrca
xor c
ld c, a
; if bc < 10:
; de = bc + 190
; break
ld a, b
and a
jr nz, .no
ld a, c
cp 10
jr nc, .no
ld hl, 190
add hl, bc
ld d, h
ld e, l
jr .done
.no
ld hl, .Lengths
ld a, 2
ld [wd265], a
.read
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
call .BCLessThanDE
jr nc, .next
; c = (bc - de) / [hl]
call .BCMinusDE
ld a, b
ld [hDividend + 0], a
ld a, c
ld [hDividend + 1], a
ld a, [hl]
ld [hDivisor], a
ld b, 2
call Divide
ld a, [hQuotient + 2]
ld c, a
; de = c + 100 * (2 + i)
xor a
ld [hMultiplicand + 0], a
ld [hMultiplicand + 1], a
ld a, 100
ld [hMultiplicand + 2], a
ld a, [wd265]
ld [hMultiplier], a
call Multiply
ld b, 0
ld a, [hProduct + 3]
add c
ld e, a
ld a, [hProduct + 2]
adc b
ld d, a
jr .done
.next
inc hl ; align to next triplet
ld a, [wd265]
inc a
ld [wd265], a
cp 16
jr c, .read
call .BCMinusDE
ld hl, 1600
add hl, bc
ld d, h
ld e, l
.done
; hl = de * 10
ld h, d
ld l, e
rept 2
add hl, hl
endr
add hl, de
add hl, hl
; hl = hl / 254
ld de, -254
ld a, -1
.div_254
inc a
add hl, de
jr c, .div_254
; d, e = hl / 12, hl % 12
ld d, 0
.mod_12
cp 12
jr c, .ok
sub 12
inc d
jr .mod_12
.ok
ld e, a
ld hl, MagikarpLength
ld [hl], d
inc hl
ld [hl], e
ret
; fbc9a
.BCLessThanDE: ; fbc9a
; Intention: Return bc < de.
; Reality: Return b < d.
ld a, b
cp d
ret c
ret nc ; whoops
ld a, c
cp e
ret
; fbca1
.BCMinusDE: ; fbca1
; bc -= de
ld a, c
sub e
ld c, a
ld a, b
sbc d
ld b, a
ret
; fbca8
.Lengths: ; fbca8
; ????, divisor
dwb 110, 1
dwb 310, 2
dwb 710, 4
dwb 2710, 20
dwb 7710, 50
dwb 17710, 100
dwb 32710, 150
dwb 47710, 150
dwb 57710, 100
dwb 62710, 50
dwb 64710, 20
dwb 65210, 5
dwb 65410, 2
dwb 65510, 1 ; not used
; fbcd2

View File

@@ -161,7 +161,7 @@ endr
DoBadgeTypeBoosts: ; fbe24
ld a, [InLinkBattle]
ld a, [wLinkMode]
and a
ret nz