display_text_id_init.asm 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ; function that performs initialization for DisplayTextID
  2. DisplayTextIDInit:
  3. xor a
  4. ld [wListMenuID], a
  5. ld a, [wAutoTextBoxDrawingControl]
  6. bit 0, a
  7. jr nz, .skipDrawingTextBoxBorder
  8. ld a, [hSpriteIndexOrTextID] ; text ID (or sprite ID)
  9. and a
  10. jr nz, .notStartMenu
  11. ; if text ID is 0 (i.e. the start menu)
  12. ; Note that the start menu text border is also drawn in the function directly
  13. ; below this, so this seems unnecessary.
  14. CheckEvent EVENT_GOT_POKEDEX
  15. ; start menu with pokedex
  16. coord hl, 10, 0
  17. ld b, $0e
  18. ld c, $08
  19. jr nz, .drawTextBoxBorder
  20. ; start menu without pokedex
  21. coord hl, 10, 0
  22. ld b, $0c
  23. ld c, $08
  24. jr .drawTextBoxBorder
  25. ; if text ID is not 0 (i.e. not the start menu) then do a standard dialogue text box
  26. .notStartMenu
  27. coord hl, 0, 12
  28. ld b, $04
  29. ld c, $12
  30. .drawTextBoxBorder
  31. call TextBoxBorder
  32. .skipDrawingTextBoxBorder
  33. ld hl, wFontLoaded
  34. set 0, [hl]
  35. ld hl, wFlags_0xcd60
  36. bit 4, [hl]
  37. res 4, [hl]
  38. jr nz, .skipMovingSprites
  39. call UpdateSprites
  40. .skipMovingSprites
  41. ; loop to copy C1X9 (direction the sprite is facing) to C2X9 for each sprite
  42. ; this is done because when you talk to an NPC, they turn to look your way
  43. ; the original direction they were facing must be restored after the dialogue is over
  44. ld hl, wSpriteStateData1 + $19
  45. ld c, $0f
  46. ld de, $0010
  47. .spriteFacingDirectionCopyLoop
  48. ld a, [hl]
  49. inc h
  50. ld [hl], a
  51. dec h
  52. add hl, de
  53. dec c
  54. jr nz, .spriteFacingDirectionCopyLoop
  55. ; loop to force all the sprites in the middle of animation to stand still
  56. ; (so that they don't like they're frozen mid-step during the dialogue)
  57. ld hl, wSpriteStateData1 + 2
  58. ld de, $0010
  59. ld c, e
  60. .spriteStandStillLoop
  61. ld a, [hl]
  62. cp $ff ; is the sprite visible?
  63. jr z, .nextSprite
  64. ; if it is visible
  65. and $fc
  66. ld [hl], a
  67. .nextSprite
  68. add hl, de
  69. dec c
  70. jr nz, .spriteStandStillLoop
  71. ld b, $9c ; window background address
  72. call CopyScreenTileBufferToVRAM ; transfer background in WRAM to VRAM
  73. xor a
  74. ld [hWY], a ; put the window on the screen
  75. call LoadFontTilePatterns
  76. ld a, $01
  77. ld [H_AUTOBGTRANSFERENABLED], a ; enable continuous WRAM to VRAM transfer each V-blank
  78. ret