summaryrefslogtreecommitdiff
path: root/engine/events/bug_contest
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2018-01-22 01:06:48 -0500
committerGitHub <noreply@github.com>2018-01-22 01:06:48 -0500
commitc60f1331fef22b886adf3472d2b4f348832cfaf7 (patch)
tree5a471fad61e406f5b3ca1aba67ced0186de01c52 /engine/events/bug_contest
parentf27f79488a460f0a89670f3611e1e9e175baf5d6 (diff)
parent7fba864883732ccecb1221ae7ff97492d112362a (diff)
Merge pull request #456 from Rangi42/master
OAM data documentation; move more content into data/; move palettes into gfx/; more code+script constants; consistent map naming
Diffstat (limited to 'engine/events/bug_contest')
-rwxr-xr-xengine/events/bug_contest/contest_2.asm29
-rw-r--r--engine/events/bug_contest/display_stats.asm10
-rwxr-xr-xengine/events/bug_contest/judging.asm37
3 files changed, 33 insertions, 43 deletions
diff --git a/engine/events/bug_contest/contest_2.asm b/engine/events/bug_contest/contest_2.asm
index 493c69d0c..7ade44815 100755
--- a/engine/events/bug_contest/contest_2.asm
+++ b/engine/events/bug_contest/contest_2.asm
@@ -2,7 +2,7 @@ Special_SelectRandomBugContestContestants: ; 139a8
; Select five random people to participate in the current contest.
; First we have to make sure that any old data is cleared away.
- ld c, 10 ; Number of people to choose from.
+ ld c, NUM_BUG_CONTESTANTS
ld hl, BugCatchingContestantEventFlagTable
.loop1
push bc
@@ -26,9 +26,9 @@ Special_SelectRandomBugContestContestants: ; 139a8
.next
; Choose a flag at uniform random to be set.
call Random
- cp 250
+ cp $ff / NUM_BUG_CONTESTANTS * NUM_BUG_CONTESTANTS
jr nc, .next
- ld c, 25
+ ld c, $ff / NUM_BUG_CONTESTANTS
call SimpleDivide
ld e, b
ld d, 0
@@ -59,7 +59,7 @@ Special_SelectRandomBugContestContestants: ; 139a8
Special_CheckBugContestContestantFlag: ; 139ed
; Checks the flag of the Bug Catching Contestant whose index is loaded in a.
-; Bug: If a >= 10 when this is called, it will read beyond the table.
+; Bug: If a >= NUM_BUG_CONTESTANTS when this is called, it will read beyond the table.
ld hl, BugCatchingContestantEventFlagTable
ld e, a
@@ -74,20 +74,9 @@ Special_CheckBugContestContestantFlag: ; 139ed
ret
; 139fe
-BugCatchingContestantEventFlagTable: ; 139fe
- dw EVENT_BUG_CATCHING_CONTESTANT_1A
- dw EVENT_BUG_CATCHING_CONTESTANT_2A
- dw EVENT_BUG_CATCHING_CONTESTANT_3A
- dw EVENT_BUG_CATCHING_CONTESTANT_4A
- dw EVENT_BUG_CATCHING_CONTESTANT_5A
- dw EVENT_BUG_CATCHING_CONTESTANT_6A
- dw EVENT_BUG_CATCHING_CONTESTANT_7A
- dw EVENT_BUG_CATCHING_CONTESTANT_8A
- dw EVENT_BUG_CATCHING_CONTESTANT_9A
- dw EVENT_BUG_CATCHING_CONTESTANT_10A
-; 13a12
+INCLUDE "data/bug_contest_flags.asm"
-ContestDropOffMons: ; 13a12
+Special_ContestDropOffMons: ; 13a12
ld hl, PartyMon1HP
ld a, [hli]
or [hl]
@@ -101,7 +90,7 @@ ContestDropOffMons: ; 13a12
ld a, [hl]
ld [wBugContestSecondPartySpecies], a
; ... and replacing it with the terminator byte
- ld [hl], $ff
+ ld [hl], -1
xor a
ld [ScriptVar], a
ret
@@ -112,13 +101,13 @@ ContestDropOffMons: ; 13a12
ret
; 13a31
-ContestReturnMons: ; 13a31
+Special_ContestReturnMons: ; 13a31
; Restore the species of the second mon.
ld hl, PartySpecies + 1
ld a, [wBugContestSecondPartySpecies]
ld [hl], a
; Restore the party count, which must be recomputed.
- ld b, $1
+ ld b, 1
.loop
ld a, [hli]
cp -1
diff --git a/engine/events/bug_contest/display_stats.asm b/engine/events/bug_contest/display_stats.asm
index d6ad3997e..92b89a38f 100644
--- a/engine/events/bug_contest/display_stats.asm
+++ b/engine/events/bug_contest/display_stats.asm
@@ -82,9 +82,9 @@ DisplayCaughtContestMonStats: ; cc000
.Health:
db "HEALTH@"
.Stock:
- db " STOCK ", $4a, " @"
+ db " STOCK <PKMN> @"
.This:
- db " THIS ", $4a, " @"
+ db " THIS <PKMN> @"
SwitchMonText: ; cc0c2
; Switch #MON?
@@ -101,7 +101,7 @@ DisplayAlreadyCaughtText: ; cc0c7
text_jump UnknownText_0x1c10dd
db "@"
-Predef2F:
-Predef38:
-Predef39: ; cc0d5
+DummyPredef2F:
+DummyPredef38:
+DummyPredef39: ; cc0d5
ret
diff --git a/engine/events/bug_contest/judging.asm b/engine/events/bug_contest/judging.asm
index 901ae88fa..a8cb80efe 100755
--- a/engine/events/bug_contest/judging.asm
+++ b/engine/events/bug_contest/judging.asm
@@ -1,6 +1,6 @@
_BugContestJudging: ; 1369d
call ContestScore
- farcall TrainerRankings_BugContestScore
+ farcall StubbedTrainerRankings_BugContestScore
call BugContest_JudgeContestants
ld a, [wBugContestThirdPlaceWinnerID]
call LoadContestantName
@@ -77,9 +77,8 @@ BugContest_ThirdPlaceScoreText: ; 0x1372b
; 0x13730
LoadContestantName: ; 13730
-
-; If a = 0, get your name.
- dec a
+; If a = 1, get your name.
+ dec a ; BUG_CONTEST_PLAYER
jr z, .player
; Find the pointer for the trainer class of the Bug Catching Contestant whose ID is in a.
ld c, a
@@ -141,11 +140,11 @@ INCLUDE "data/bug_contest_winners.asm"
BugContest_GetPlayersResult: ; 13807
ld hl, wBugContestThirdPlaceWinnerID
- ld de, -4
- ld b, 3
+ ld de, - BUG_CONTESTANT_SIZE
+ ld b, 3 ; 3rd, 2nd, or 1st
.loop
ld a, [hl]
- cp 1 ; Player
+ cp BUG_CONTEST_PLAYER
jr z, .done
add hl, de
dec b
@@ -159,7 +158,7 @@ BugContest_JudgeContestants: ; 13819
call ClearContestResults
call ComputeAIContestantScores
ld hl, wBugContestTempWinnerID
- ld a, 1 ; Player
+ ld a, BUG_CONTEST_PLAYER
ld [hli], a
ld a, [wContestMon]
ld [hli], a
@@ -190,11 +189,11 @@ DetermineContestWinners: ; 1383e
jr c, .not_first_place
ld hl, wBugContestSecondPlaceWinnerID
ld de, wBugContestThirdPlaceWinnerID
- ld bc, 4
+ ld bc, BUG_CONTESTANT_SIZE
call CopyBytes
ld hl, wBugContestFirstPlaceWinnerID
ld de, wBugContestSecondPlaceWinnerID
- ld bc, 4
+ ld bc, BUG_CONTESTANT_SIZE
call CopyBytes
ld hl, wBugContestFirstPlaceWinnerID
call CopyTempContestant
@@ -208,7 +207,7 @@ DetermineContestWinners: ; 1383e
jr c, .not_second_place
ld hl, wBugContestSecondPlaceWinnerID
ld de, wBugContestThirdPlaceWinnerID
- ld bc, 4
+ ld bc, BUG_CONTESTANT_SIZE
call CopyBytes
ld hl, wBugContestSecondPlaceWinnerID
call CopyTempContestant
@@ -230,7 +229,7 @@ DetermineContestWinners: ; 1383e
CopyTempContestant: ; 138a0
; Could've just called CopyBytes.
ld de, wBugContestTempWinnerID
-rept 3
+rept BUG_CONTESTANT_SIZE +- 1
ld a, [de]
inc de
ld [hli], a
@@ -264,6 +263,7 @@ ComputeAIContestantScores: ; 138b0
inc hl
inc hl
.loop2
+ ; 0, 1, or 2 for 1st, 2nd, or 3rd
call Random
and 3
cp 3
@@ -278,8 +278,9 @@ ComputeAIContestantScores: ; 138b0
ld a, [hli]
ld h, [hl]
ld l, a
+ ; randomly perturb score
call Random
- and 7
+ and %111
ld c, a
ld b, 0
add hl, bc
@@ -294,7 +295,7 @@ ComputeAIContestantScores: ; 138b0
.done
inc e
ld a, e
- cp 10
+ cp NUM_BUG_CONTESTANTS
jr nz, .loop
ret
; 13900
@@ -337,26 +338,26 @@ ContestScore: ; 13900
; DVs
ld a, [wContestMonDVs + 0]
ld b, a
- and 2
+ and %0010
add a
add a
ld c, a
swap b
ld a, b
- and 2
+ and %0010
add a
add c
ld d, a
ld a, [wContestMonDVs + 1]
ld b, a
- and 2
+ and %0010
ld c, a
swap b
ld a, b
- and 2
+ and %0010
srl a
add c
add c