Author Topic: Key hooks  (Read 2326 times)

0 Members and 1 Guest are viewing this topic.

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Key hooks
« on: January 19, 2016, 04:31:32 pm »
Ok... I am probably getting in way over my head but, can anyone explain key hooks in z80 asm?
I have mimas installed and some basic knowledge of assembler.
I mostly code in Axe but have always thought hooks were REALLY cool.
Can anyone tell me how to use them? (they will probably be included as hex code in my Axe projects)
Even an example with some comments telling me what to change would be awesome!
(I don't care if it is in mimas or true asm)

Thanks for any help! (even if it is just to tell me that this is way beyond my limited ability)
I'm still around... kind of.

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Key hooks
« Reply #1 on: January 19, 2016, 04:35:50 pm »
If you are just looking for some documention, wikiti has some here: http://wikiti.brandonw.net/index.php?title=Category:83Plus:Hooks

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline E37

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 358
  • Rating: +23/-0
  • Trial and error is the best teacher
    • View Profile
Re: Key hooks
« Reply #2 on: January 19, 2016, 04:42:04 pm »
That seems helpful!  ;D
Are there any example programs?
I'm still around... kind of.

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Key hooks
« Reply #3 on: January 30, 2016, 10:07:16 pm »
You could check out programs with key hooks in them, such as zStart. Actually, i just found this: Key hooks tutorial in Axe. I dunno how accurate it is.

Here's some code that runs prgmU instead of loading the graph equation screen when you press Y=:
Code: [Select]
.nolist
#include "ti83plus.inc"
.list

.org UserMem-2
.db $BB,$6D

hook_addr = appBackupScreen

start:
ld hl, hook_start
ld de, hook_addr
push de
ld bc, hook_end-hook_start
ldir
pop hl
ld a, 1
bcall(_SetGetKeyHook)
ret
   
hook_start:
.db $83
bit editOpen, (iy+editFlags)
ret z
cp kYequ ;if y= wasn't pressed, check if we should uninstall hook
jr nz, disableHook
ld hl, hook_addr + varname - hook_start
bcall(_Mov9toOP1)
bcall(_ChkFindSym)
jr c, disableHook ;if prgm doesn't exist
ld hl,$0055
ld (saveSScreen),hl
ld (OP1+1),hl
ld hl,saveSScreen+4
ex de,hl
ld c,(hl)
inc hl
ld b,(hl)
inc hl
ld (saveSScreen+2),bc
ldir
ld a,5
ld (OP1),a
bcall(_ChkFindSym)
jr c,$+5
bcall(_DelVarArc)
ld a,5
ld hl,saveSScreen
bcall(_ExecuteNewPrgm)
ld a, 0
ret

disableHook:
cp kGraph
ret nz
bcall(_ClrRawKeyHook)
; ld a, 0 ;pressing Graph continues to the graph screen
ret
   
varname:
.db ProgObj, "U", 0, 0
hook_end: