diff options
| author | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-11-04 15:16:20 -0500 |
|---|---|---|
| committer | Rangi <remy.oukaour+rangi42@gmail.com> | 2020-11-04 19:44:31 -0500 |
| commit | aae999f72bd81a3156c7e00da4ebf499f52da5a6 (patch) | |
| tree | 32fef70a31af3a0b5ad2b0d34042c312574fb42d /engine/events | |
| parent | 87131eaa1ba5dc898e64c7415b5bce61c6aa146d (diff) | |
Start reorganizing pokeyellow
Diffstat (limited to 'engine/events')
| -rwxr-xr-x | engine/events/diploma2.asm | 171 | ||||
| -rw-r--r-- | engine/events/hidden_objects/vermilion_gym_trash2.asm | 108 | ||||
| -rw-r--r-- | engine/events/pikachu_happiness.asm | 118 | ||||
| -rw-r--r-- | engine/events/pokecenter_chansey.asm | 11 | ||||
| -rw-r--r-- | engine/events/try_pikachu_movement.asm | 27 |
5 files changed, 435 insertions, 0 deletions
diff --git a/engine/events/diploma2.asm b/engine/events/diploma2.asm new file mode 100755 index 00000000..75ac104a --- /dev/null +++ b/engine/events/diploma2.asm @@ -0,0 +1,171 @@ +CIRCLE_TILE_ID EQU $10 + +_DisplayDiploma: + call GBPalWhiteOutWithDelay3 + call ClearScreen + ld de, SurfingPikachu3Graphics + ld hl, vChars2 + lb bc, BANK(SurfingPikachu3Graphics), (SurfingPikachu3GraphicsEnd - SurfingPikachu3Graphics) / $10 + call CopyVideoData + + hlcoord 0, 0 + call Func_e9bdf + + hlcoord 0, 0 + call Func_e9beb + + hlcoord 19, 0 + call Func_e9beb + + ld a, $00 + hlcoord 0, 0 + ld [hl], a + hlcoord 19, 0 + ld [hl], a + + ld de, String_e9a73 + hlcoord 5, 2 + call PlaceString + + ld de, String_e9a7d + hlcoord 3, 4 + call PlaceString + + ld de, wPlayerName + hlcoord 10, 4 + call PlaceString + + ld de, String_e9a84 + hlcoord 2, 6 + call PlaceString + + ld de, String_e9ac8 + hlcoord 9, 16 + call PlaceString + + ld b, SET_PAL_GENERIC + call RunPaletteCommand + ld a, $01 + ldh [hAutoBGTransferEnabled], a + call Delay3 + call GBPalNormal + ret + +String_e9a73: + db CIRCLE_TILE_ID, "Diploma", CIRCLE_TILE_ID, "@" + +String_e9a7d: + db "Player@" + +String_e9a84: + db "Congrats! This" + next "diploma certifies" + next "that you have" + next "completed your" + next "#DEX.@" + +String_e9ac8: + db "GAME FREAK@" + +Func_e9ad3: + call ClearScreen + hlcoord 0, 17 + call Func_e9bdf + hlcoord 0, 0 + call Func_e9beb + hlcoord 19, 0 + call Func_e9beb + ld a, $00 + hlcoord 0, 17 + ld [hl], a + hlcoord 19, 17 + ld [hl], a + ld de, Tilemap_e9b3e + hlcoord 6, 2 + lb bc, 10, 12 + call Diploma_Surfing_CopyBox + ld de, Tilemap_e9bb6 + hlcoord 5, 13 + lb bc, 1, 11 + call Diploma_Surfing_CopyBox + ld de, String_e9bd5 + hlcoord 2, 15 + call PlaceString + hlcoord 12, 15 + ld de, wPlayTimeHours + lb bc, $40 | 1, 3 + call PrintNumber + ld [hl], $16 + inc hl + ld de, wPlayTimeMinutes + lb bc, $80 | 1, 2 + call PrintNumber + ld a, [wNumSetBits] + cp 151 + ret nz + ld de, TileMap_e9bc1 + hlcoord 2, 0 + lb bc, 4, 5 + call Diploma_Surfing_CopyBox + ret + +Tilemap_e9b3e: + db $7f, $7f, $7f, $1a, $1b, $7f, $7f, $7f, $7f, $7f + db $7f, $7f, $7f, $7f, $7f, $1c, $1d, $1e, $1f, $20 + db $7f, $21, $22, $23, $7f, $24, $25, $26, $27, $28 + db $29, $2a, $2b, $2c, $2d, $2e, $2f, $30, $31, $32 + db $33, $34, $35, $36, $37, $38, $39, $3a, $3b, $3c + db $7f, $3d, $3e, $3f, $40, $41, $42, $43, $29, $44 + db $45, $46, $47, $48, $49, $4a, $4b, $29, $29, $4c + db $4d, $4e, $4f, $50, $51, $52, $53, $54, $55, $56 + db $57, $58, $59, $7f, $7f, $7f, $5a, $5b, $5c, $5d + db $5e, $5f, $60, $61, $62, $7f, $7f, $7f, $7f, $63 + db $64, $65, $66, $67, $68, $7f, $7f, $7f, $7f, $7f + db $7f, $69, $6a, $6b, $6c, $6d, $6e, $7f, $7f, $7f + +Tilemap_e9bb6: + db $05 + db $06 + db $07 + db $08 + db $09 + db $0a + db $0b + db $0c + db $0d + db $0e + db $0f + +TileMap_e9bc1: + db $70, $71, $7f, $72, $7f + db $73, $74, $75, $76, $77 + db $7f, $78, $11, $12, $13 + db $7f, $7f, $14, $15, $7f + +String_e9bd5: db "PLAY TIME@" + +Func_e9bdf: + ld c, 10 +.asm_e9be1 + ld [hl], $02 + inc hl + ld [hl], $01 + inc hl + dec c + jr nz, .asm_e9be1 + ret + +Func_e9beb: + ld c, 9 + ld de, SCREEN_WIDTH +.asm_e9bed + ld [hl], $04 + add hl, de + ld [hl], $03 + add hl, de + dec c + jr nz, .asm_e9bed + ret + +SurfingPikachu3Graphics: INCBIN "gfx/surfing_pikachu/surfing_pikachu_3.2bpp" +SurfingPikachu3GraphicsEnd: diff --git a/engine/events/hidden_objects/vermilion_gym_trash2.asm b/engine/events/hidden_objects/vermilion_gym_trash2.asm new file mode 100644 index 00000000..1bc0590b --- /dev/null +++ b/engine/events/hidden_objects/vermilion_gym_trash2.asm @@ -0,0 +1,108 @@ +TrashCanRandom: + ld d, 0 + ld hl, .Jumptable + add hl, de + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a + call JumpToAddress + ld e, a + ld d, 0 + ret + +.Jumptable: + dw .zero + dw .one + dw .two + dw .three + dw .four + +.zero +.one + ld a, 0 + ret + +.two + call Random + and $1 + ret + +.three ; should return to a, instead returns to b + call Random + swap a + cp 1 * $ff / 3 + ld b, 0 + ret c + cp 2 * $ff / 3 + ld b, 1 + ret c + ld b, 2 + ret + +.four + call Random + and $3 + ret + +Yellow_SampleSecondTrashCan: + ld hl, GymTrashCans3c + ld a, [wGymTrashCanIndex] + ld c, a + ld b, 0 + ld a, 9 + call AddNTimes + call AddNTimes ; ???? + ld a, [hli] + ldh [hGymTrashCanRandNumMask], a + ld e, a + push hl + call TrashCanRandom + pop hl + add hl, de + add hl, de + ld a, [hli] + ld [wSecondLockTrashCanIndex], a + ld a, [hl] + ld [wSecondLockTrashCanIndex + 1], a + ret + +GymTrashCans3c: +; First byte: number of trashcan entries +; Following four byte pairs: indices for the second trash can. +; BUG: Rows that have 3 trashcan entries are sampled incorrectly. +; The sampling occurs by taking a random number and seeing which +; third of the range 0-255 the number falls in. However, it returns +; that value to the wrong register, so the result is never used. +; Instead of using an offset in [0,1,2], the offset is instead +; in the full range 0-255. This results in truly random behavior. + db 4 + db 1,3, 3,1, 1,-1, 3,-1 + db 3 + db 0,2, 2,4, 4,0, -1,-1 + db 4 + db 1,5, 5,1, 1,-1, 5,-1 + db 3 + db 0,4, 4,6, 6,0, -1,-1 + db 4 + db 1,3, 3,1, 5,5, 7,7 + db 3 + db 2,4, 4,8, 8,2, -1,-1 + db 3 + db 3,7, 7,9, 9,3, -1,-1 + db 4 + db 4,8, 6,10, 8,4, 10,6 + db 3 + db 5,7, 7,11, 11,5, -1,-1 + db 3 + db 6,10, 10,12, 12,6, -1,-1 + db 4 + db 7,9, 9,7, 11,13, 13,11 + db 3 + db 8,10, 10,14, 14,8, -1,-1 + db 4 + db 9,13, 13,9, 9,-1, 13,-1 + db 3 + db 10,12, 12,14, 14,10, -1,-1 + db 4 + db 11,13, 13,11, 11,-1, 13,-1 diff --git a/engine/events/pikachu_happiness.asm b/engine/events/pikachu_happiness.asm new file mode 100644 index 00000000..0d79e32b --- /dev/null +++ b/engine/events/pikachu_happiness.asm @@ -0,0 +1,118 @@ +ModifyPikachuHappiness:: + ld a, d + cp PIKAHAPPY_GYMLEADER + jr z, .checkanywhereinparty + cp PIKAHAPPY_WALKING + jr z, .checkanywhereinparty + push de + callfar IsThisPartymonStarterPikachu_Party + pop de + ret nc + jr .proceed + +.checkanywhereinparty + push de + callfar IsStarterPikachuInOurParty + pop de + ret nc + +.proceed + push de + ; Divide [wPikachuHappiness] by 100. Hold the integer part in e. + ld e, $0 + ld a, [wPikachuHappiness] + cp 100 + jr c, .wPikachuHappiness_div_100 + inc e + cp 200 + jr c, .wPikachuHappiness_div_100 + inc e +.wPikachuHappiness_div_100 + ; Get the (d, e) entry from HappinessChangeTable. + ld c, d + dec c + ld b, $0 + ld hl, HappinessChangeTable + add hl, bc + add hl, bc + add hl, bc + ld d, $0 + add hl, de + ld a, [hl] + ; If [hl] is positive, take min(0xff, [hl] + [wPikachuHappiness]). + ; If [hl] is negative, take max(0x00, [hl] + [wPikachuHappiness]). + ; Inexplicably, we're using 100 as the threshold for comparison. + cp 100 + ld a, [wPikachuHappiness] + jr nc, .negative + add [hl] + jr nc, .okay + ld a, -1 + jr .okay + +.negative + add [hl] + jr c, .okay + xor a +.okay + ld [wPikachuHappiness], a + + ; Restore d and get the d'th entry in PikachuMoods. + pop de + dec d + ld hl, PikachuMoods + ld e, d + ld d, $0 + add hl, de + ld a, [hl] + ld b, a + ; Modify Pikachu's mood + cp $80 + jr z, .done + ld a, [wPikachuMood] + jr c, .decreased + cp b + jr nc, .done + ld a, [wd49c] + and a + jr nz, .done + jr .update_mood + +.decreased + cp b + jr c, .done +.update_mood + ld a, b + ld [wPikachuMood], a +.done + ret + +HappinessChangeTable: + ; Increase + db 5, 3, 2 ; Gained a level + db 5, 3, 2 ; HP restore + db 1, 1, 0 ; Used X item + db 3, 2, 1 ; Challenged Gym Leader + db 1, 1, 0 ; Teach TM/HM + db 2, 1, 1 ; Walking around + ; Decrease + db -3, -3, -5 ; Deposited + db -1, -1, -1 ; Fainted in battle + db -5, -5, -10 ; Fainted due to Poison outside of battle + db -5, -5, -10 ; Fainted to opponent at least 30 levels higher + db -10, -10, -20 ; Traded away + +PikachuMoods: + ; Increase + db $8a ; Gained a level + db $83 ; HP restore + db $80 ; Teach TM/HM + db $80 ; Challenged Gym Leader + db $94 ; Unknown (d = 5) + db $80 ; Unknown (d = 6) + ; Decrease + db $62 ; Deposited + db $6c ; Fainted + db $62 ; Unknown (d = 9) + db $6c ; Unknown (d = 10) + db $00 ; Unknown (d = 11) diff --git a/engine/events/pokecenter_chansey.asm b/engine/events/pokecenter_chansey.asm new file mode 100644 index 00000000..d7c3a95b --- /dev/null +++ b/engine/events/pokecenter_chansey.asm @@ -0,0 +1,11 @@ +PokecenterChanseyText:: + ld hl, NurseChanseyText + call PrintText + ld a, CHANSEY + call PlayCry + call WaitForSoundToFinish + ret + +NurseChanseyText: + text_far _NurseChanseyText + text_end diff --git a/engine/events/try_pikachu_movement.asm b/engine/events/try_pikachu_movement.asm new file mode 100644 index 00000000..70cf65b4 --- /dev/null +++ b/engine/events/try_pikachu_movement.asm @@ -0,0 +1,27 @@ +TryApplyPikachuMovementData:: + ld a, [wd472] + bit 7, a + ret z + ld a, [wWalkBikeSurfState] + and a + ret nz + push hl + push bc + callfar GetPikachuFacingDirectionAndReturnToE + pop bc + pop hl + ld a, b + cp e + ret nz + push hl + ld a, [wUpdateSpritesEnabled] + push af + ld a, $ff + ld [wUpdateSpritesEnabled], a + callfar LoadPikachuShadowIntoVRAM + pop af + ld [wUpdateSpritesEnabled], a + pop hl + call ApplyPikachuMovementData + callfar RefreshPikachuFollow + ret |
