start_menu.asm 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. DisplayStartMenu::
  2. ld a, BANK(StartMenu_Pokedex)
  3. ld [H_LOADEDROMBANK], a
  4. ld [MBC1RomBank], a
  5. ld a, [wWalkBikeSurfState] ; walking/biking/surfing
  6. ld [wWalkBikeSurfStateCopy], a
  7. ld a, SFX_START_MENU
  8. call PlaySound
  9. RedisplayStartMenu::
  10. callba DrawStartMenu
  11. callba PrintSafariZoneSteps ; print Safari Zone info, if in Safari Zone
  12. call UpdateSprites
  13. .loop
  14. call HandleMenuInput
  15. ld b, a
  16. .checkIfUpPressed
  17. bit 6, a ; was Up pressed?
  18. jr z, .checkIfDownPressed
  19. ld a, [wCurrentMenuItem] ; menu selection
  20. and a
  21. jr nz, .loop
  22. ld a, [wLastMenuItem]
  23. and a
  24. jr nz, .loop
  25. ; if the player pressed tried to go past the top item, wrap around to the bottom
  26. CheckEvent EVENT_GOT_POKEDEX
  27. ld a, 6 ; there are 7 menu items with the pokedex, so the max index is 6
  28. jr nz, .wrapMenuItemId
  29. dec a ; there are only 6 menu items without the pokedex
  30. .wrapMenuItemId
  31. ld [wCurrentMenuItem], a
  32. call EraseMenuCursor
  33. jr .loop
  34. .checkIfDownPressed
  35. bit 7, a
  36. jr z, .buttonPressed
  37. ; if the player pressed tried to go past the bottom item, wrap around to the top
  38. CheckEvent EVENT_GOT_POKEDEX
  39. ld a, [wCurrentMenuItem]
  40. ld c, 7 ; there are 7 menu items with the pokedex
  41. jr nz, .checkIfPastBottom
  42. dec c ; there are only 6 menu items without the pokedex
  43. .checkIfPastBottom
  44. cp c
  45. jr nz, .loop
  46. ; the player went past the bottom, so wrap to the top
  47. xor a
  48. ld [wCurrentMenuItem], a
  49. call EraseMenuCursor
  50. jr .loop
  51. .buttonPressed ; A, B, or Start button pressed
  52. call PlaceUnfilledArrowMenuCursor
  53. ld a, [wCurrentMenuItem]
  54. ld [wBattleAndStartSavedMenuItem], a ; save current menu selection
  55. ld a, b
  56. and %00001010 ; was the Start button or B button pressed?
  57. jp nz, CloseStartMenu
  58. call SaveScreenTilesToBuffer2 ; copy background from wTileMap to wTileMapBackup2
  59. CheckEvent EVENT_GOT_POKEDEX
  60. ld a, [wCurrentMenuItem]
  61. jr nz, .displayMenuItem
  62. inc a ; adjust position to account for missing pokedex menu item
  63. .displayMenuItem
  64. cp 0
  65. jp z, StartMenu_Pokedex
  66. cp 1
  67. jp z, StartMenu_Pokemon
  68. cp 2
  69. jp z, StartMenu_Item
  70. cp 3
  71. jp z, StartMenu_TrainerInfo
  72. cp 4
  73. jp z, StartMenu_SaveReset
  74. cp 5
  75. jp z, StartMenu_Option
  76. ; EXIT falls through to here
  77. CloseStartMenu::
  78. call Joypad
  79. ld a, [hJoyPressed]
  80. bit 0, a ; was A button newly pressed?
  81. jr nz, CloseStartMenu
  82. call LoadTextBoxTilePatterns
  83. jp CloseTextDisplay