modemenu.z80 2.1 KB

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