modemenu.z80 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. modemenu:
  2. ;Set the font to the pixel-aligned font
  3. ld a,2
  4. ld (textmode),a
  5. ld hl,modemenu_header+5
  6. ld de,mode_menu_header_RAM+5
  7. ld bc,6
  8. ld a,c
  9. ld (font_height),a
  10. lddr
  11. ld (menutopinit),bc
  12. ld (menudefault),bc
  13. ld hl,menu_header_getter
  14. ld (menu_header_get),hl
  15. ex de,hl
  16. inc hl
  17. ld bc,$120D
  18. ld de,$3B27
  19. ld ix,modemenu_getselect
  20. call menuroutine
  21. xor a
  22. ld (textmode),a
  23. ret
  24. mode_menu_header_getter:
  25. or a
  26. jr z,$+4
  27. xor a
  28. ret
  29. ld hl,mode_menu_header_RAM
  30. or h
  31. ret
  32. modemenu_getselect:
  33. jr nc,modemenu_opt
  34. ; If the user pressed [Enter], then we need to re-enter!
  35. ld a,(k_save)
  36. sub 9
  37. ret nz
  38. call +_
  39. jp menu_render
  40. _:
  41. ld a,(menucur)
  42. dec a
  43. jp z,toggle_token_hook
  44. ld a,(flags+appLwrCaseFlag)
  45. xor 1<<lwrCaseActive
  46. ld (flags+appLwrCaseFlag),a
  47. ret
  48. modemenu_opt:
  49. ld a,c
  50. cp 2
  51. ccf
  52. ret c
  53. dec a
  54. jr nz,+_
  55. ld hl,s_Token_Hook
  56. ld de,mode_menu_scrap
  57. ld bc,11
  58. ldir
  59. bit tokenHookActive,(iy+hookflags3)
  60. jr z,s_onoff
  61. ;verify it is the same page as Grammer
  62. ld hl,(tokenHookPtr+2)
  63. in a,(6)
  64. cp l
  65. ld hl,s_Off
  66. jr nz,$+5
  67. ld hl,s_On
  68. call mov4
  69. ld hl,mode_menu_scrap
  70. or a
  71. ret
  72. _:
  73. ld hl,s_Lowercase
  74. ld de,mode_menu_scrap
  75. ld bc,10
  76. ldir
  77. bit lwrCaseActive,(iy+appLwrCaseFlag)
  78. s_onoff:
  79. ; z means OFF, nz means ON
  80. ld hl,s_On
  81. jr nz,$+5
  82. ld hl,s_Off
  83. call mov4
  84. ld hl,mode_menu_scrap
  85. ret
  86. toggle_token_hook:
  87. ;Gotta toggle the token hook
  88. ;Point to the page and load the token hook page in A
  89. ld hl,tokenHookPtr+2
  90. in a,(6)
  91. ;If token hook is inactive, we need to set it to Grammer's
  92. bit tokenHookActive,(iy+hookflags3)
  93. jr z,tokenhook_on
  94. ;The token hook is active.
  95. ;If it is Grammer's, need to reset
  96. cp (hl)
  97. jr z,resetTokenHook
  98. tokenhook_on:
  99. ;Now we have to actually set the hook
  100. ;We'll do it manually, I still have flashbacks to thepenguin77's April Fools Joke of 2011
  101. ;HL already points to where the page should be written, and A is the page
  102. ld (hl),a
  103. ld hl,TokenHook
  104. ld (tokenHookPtr),hl
  105. set tokenHookActive,(iy+hookflags3)
  106. ;now reset the tokenhook opt-out
  107. call p1_FindGVarData
  108. or a
  109. ret nz
  110. res tokenhook_optout,(hl)
  111. ret
  112. resetTokenHook:
  113. res tokenHookActive,(iy+hookflags3)
  114. ;now set the tokenhook opt-out
  115. call p1_FindGVarData
  116. or a
  117. ret nz
  118. set tokenhook_optout,(hl)
  119. ret
  120. modemenu_header:
  121. .db "MODES",0
  122. s_Lowercase:
  123. .db "LOWERCASE",$29,0
  124. s_Token_Hook:
  125. .db "TOKEN",$29,"HOOK",$29,0
  126. s_On:
  127. .db "ON",0
  128. s_Off:
  129. .db "OFF",0