Path: blob/master/engine/events/hidden_objects/cinnabar_gym_quiz.asm
1271 views
PrintCinnabarQuiz:1ld a, [wSpritePlayerStateData1FacingDirection]2cp SPRITE_FACING_UP3ret nz4call EnableAutoTextBoxDrawing5tx_pre_jump CinnabarGymQuiz67CinnabarGymQuiz::8text_asm9xor a10ld [wOpponentAfterWrongAnswer], a11ld a, [wHiddenObjectFunctionArgument]12push af13and $f14ldh [hGymGateIndex], a15pop af16and $f017swap a18ldh [hGymGateAnswer], a19ld hl, CinnabarGymQuizIntroText20call PrintText21ldh a, [hGymGateIndex]22dec a23add a24ld d, 025ld e, a26ld hl, CinnabarQuizQuestions27add hl, de28ld a, [hli]29ld h, [hl]30ld l, a31call PrintText32ld a, 133ld [wDoNotWaitForButtonPressAfterDisplayingText], a34call CinnabarGymQuiz_AskQuestion35jp TextScriptEnd3637CinnabarGymQuizIntroText:38text_far _CinnabarGymQuizIntroText39text_end4041CinnabarQuizQuestions:42dw CinnabarQuizQuestionsText143dw CinnabarQuizQuestionsText244dw CinnabarQuizQuestionsText345dw CinnabarQuizQuestionsText446dw CinnabarQuizQuestionsText547dw CinnabarQuizQuestionsText64849CinnabarQuizQuestionsText1:50text_far _CinnabarQuizQuestionsText151text_end5253CinnabarQuizQuestionsText2:54text_far _CinnabarQuizQuestionsText255text_end5657CinnabarQuizQuestionsText3:58text_far _CinnabarQuizQuestionsText359text_end6061CinnabarQuizQuestionsText4:62text_far _CinnabarQuizQuestionsText463text_end6465CinnabarQuizQuestionsText5:66text_far _CinnabarQuizQuestionsText567text_end6869CinnabarQuizQuestionsText6:70text_far _CinnabarQuizQuestionsText671text_end7273CinnabarGymGateFlagAction:74EventFlagAddress hl, EVENT_CINNABAR_GYM_GATE0_UNLOCKED75predef_jump FlagActionPredef7677CinnabarGymQuiz_AskQuestion:78call YesNoChoice79ldh a, [hGymGateAnswer]80ld c, a81ld a, [wCurrentMenuItem]82cp c83jr nz, .wrongAnswer84ld hl, wCurrentMapScriptFlags85set BIT_CUR_MAP_LOADED_1, [hl]86ldh a, [hGymGateIndex]87ldh [hBackupGymGateIndex], a88ld hl, CinnabarGymQuizCorrectText89call PrintText90ldh a, [hBackupGymGateIndex]91AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 092ld c, a93ld b, FLAG_SET94call CinnabarGymGateFlagAction95jp UpdateCinnabarGymGateTileBlocks_96.wrongAnswer97call WaitForSoundToFinish98ld a, SFX_DENIED99call PlaySound100call WaitForSoundToFinish101ld hl, CinnabarGymQuizIncorrectText102call PrintText103ldh a, [hGymGateIndex]104add $2105AdjustEventBit EVENT_BEAT_CINNABAR_GYM_TRAINER_0, 2106ld c, a107ld b, FLAG_TEST108EventFlagAddress hl, EVENT_BEAT_CINNABAR_GYM_TRAINER_0109predef FlagActionPredef110ld a, c111and a112ret nz113ldh a, [hGymGateIndex]114add $2115ld [wOpponentAfterWrongAnswer], a116ret117118CinnabarGymQuizCorrectText:119sound_get_item_1120text_far _CinnabarGymQuizCorrectText121text_promptbutton122text_asm123124ldh a, [hBackupGymGateIndex]125AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0126ld c, a127ld b, FLAG_TEST128call CinnabarGymGateFlagAction129ld a, c130and a131jp nz, TextScriptEnd132call WaitForSoundToFinish133ld a, SFX_GO_INSIDE134call PlaySound135call WaitForSoundToFinish136jp TextScriptEnd137138CinnabarGymQuizIncorrectText:139text_far _CinnabarGymQuizIncorrectText140text_end141142UpdateCinnabarGymGateTileBlocks_::143; Update the overworld map with open floor blocks or locked gate blocks144; depending on event flags.145ld a, 6146ldh [hGymGateIndex], a147.loop148ldh a, [hGymGateIndex]149dec a150add a151add a152ld d, 0153ld e, a154ld hl, CinnabarGymGateCoords155add hl, de156ld a, [hli]157ld b, [hl]158ld c, a159inc hl160ld a, [hl]161ld [wGymGateTileBlock], a162push bc163ldh a, [hGymGateIndex]164ldh [hBackupGymGateIndex], a165AdjustEventBit EVENT_CINNABAR_GYM_GATE0_UNLOCKED, 0166ld c, a167ld b, FLAG_TEST168call CinnabarGymGateFlagAction169ld a, c170and a171jr nz, .unlocked172ld a, [wGymGateTileBlock]173jr .next174.unlocked175ld a, $e176.next177pop bc178ld [wNewTileBlockID], a179predef ReplaceTileBlock180ld hl, hGymGateIndex181dec [hl]182jr nz, .loop183ret184185MACRO gym_gate_coord186db \1, \2, \3, 0187ENDM188189DEF HORIZONTAL_GATE_BLOCK EQU $54190DEF VERTICAL_GATE_BLOCK EQU $5f191192CinnabarGymGateCoords:193; x coord, y coord, block id194gym_gate_coord 9, 3, HORIZONTAL_GATE_BLOCK195gym_gate_coord 6, 3, HORIZONTAL_GATE_BLOCK196gym_gate_coord 6, 6, HORIZONTAL_GATE_BLOCK197gym_gate_coord 3, 8, VERTICAL_GATE_BLOCK198gym_gate_coord 2, 6, HORIZONTAL_GATE_BLOCK199gym_gate_coord 2, 3, HORIZONTAL_GATE_BLOCK200201202