Hi. I was just discussing it on the chat, but its to complicated to im making a topic.

Basically what i wanted to be done is a program that:
1. When started once i loads an ISR and a program to saferam.
2. In ISR there is a key checkign function that when triggered turns on a program. Since the program requires user interaction it cannot be inside an interrupt because this would lead to an infinite loop. Thats why i thought i could just simply PUSH PC, then LDIR the program to 9D95 and JP there.

It came out that there is a better way to check for a key- A hook. From what i understand its running every time a key is pressed( But what i dont know is where and how to put it ( Im guessing i have to BCALL 4F66 and then put my key routine at 9B84).

It also came out that there is a better and a cleaner way to start a program. I couldn't find any info on the BCALL but its called _RunProg and accepts input in OP1. But to do this i would have to first declare my program in VAT.

Can anybody check if everything im saying is correct, and correct me if im wrong? Ow, and if you can, please don't give me allready written code, i want to do this myself Very Happy
jammasterz wrote:
Hi. I was just discussing it on the chat, but its to complicated to im making a topic.

Basically what i wanted to be done is a program that:
1. When started once i loads an ISR and a program to saferam.
2. In ISR there is a key checkign function that when triggered turns on a program. Since the program requires user interaction it cannot be inside an interrupt because this would lead to an infinite loop. Thats why i thought i could just simply PUSH PC, then LDIR the program to 9D95 and JP there.
That is such an over-simplification, because userRAM starts at $9d95. To execute a program there, you need to push the existing contents out of the way first, run your program, then pull it all back.

Quote:
It came out that there is a better way to check for a key- A hook. From what i understand its running every time a key is pressed( But what i dont know is where and how to put it ( Im guessing i have to BCALL 4F66 and then put my key routine at 9B84).
Nope. $9B84 is a four-byte slot that contains a pointer to your routine, wherever it happens to be. It can be at a fixed address on a Flash page, in which case you specify the page and two-byte address. It can be somewhere safe where nothing else will move or overwrite it in RAM (which is hard to guarantee), in which case you specify page=0. The bcall will help you store to that 4-byte slot.

Quote:
It also came out that there is a better and a cleaner way to start a program. I couldn't find any info on the BCALL but its called _RunProg and accepts input in OP1. But to do this i would have to first declare my program in VAT.
I would hope your program is already in the VAT somewhere. Smile _RunProg isn't bad, but I also suggested the Doors CS call RunProg.

Quote:
Can anybody check if everything im saying is correct, and correct me if im wrong? Ow, and if you can, please don't give me allready written code, i want to do this myself Very Happy
In summary, running a program from a hook is tenuous, but possible.
Thank you for the answer Smile

I just have one more question. Yesterday someone said that on the OS will expect the raw key hook routine i flash. But as i have no experience with flash what so ever could you tell me how to get it there?
Okay i just tried to test how the hooks work, and well i doesn't

Code:
.nolist
    #include    "ti83plus.inc"
.list
.org    $9D93
.db    t2ByteTok, tAsmCmp
Begin:
   LD DE, appbackUpScreen
   LD HL, Hookroutine
   LD BC, EndofHookRoutine - Hookroutine
   LDIR
EnableHook:
   LD HL, appBackUpScreen
   LD A, 0
   LD (9B84), A
   LD (9B86) , HL
   bcall($4F66)
HookRoutine:
    .db 84h
Is7:
   CP k7
   JR NZ, Is9
   LD A, k9
   JR Exit
Is9:
    CP k9
   JR NZ, Exit
   LD A, k7
   JR Exit
Exit:
    OR A
   RET
EndofHookRoutine:   
.end
.end

Code:
EnableHook:
   LD HL, appBackUpScreen
   LD A, 0
   LD (9B84), A
   LD (9B86) , HL
   bcall($4F66)
Two problems here. You don't need to load A and HL to the hook locations (the romcall does that for you), and you never return normally after installing the hook. In the degenerate case, just insert a 'ret' after the enable bcall.

Code:
HookRoutine:
    .db 84h
Is7:
Make that 0x83 and you're golden.
Just as a point of clarification, in case the reason you put the 84h is for the calculator mode, the 83h does not specify which calculator the hook applies to. Smile
Tari wrote:

Code:
EnableHook:
   LD HL, appBackUpScreen
   LD A, 0
   LD (9B84), A
   LD (9B86) , HL
   bcall($4F66)
Two problems here. You don't need to load A and HL to the hook locations (the romcall does that for you), and you never return normally after installing the hook. In the degenerate case, just insert a 'ret' after the enable bcall.

Thank you!

KermMartian wrote:
Just as a point of clarification, in case the reason you put the 84h is for the calculator mode, the 83h does not specify which calculator the hook applies to.

Missclick :O

Thanks for help everybody!
EDIT:
I just tested it and it still doesn't work. I also corrected a small newbie mistake:

Code:
.nolist
    #include    "ti83plus.inc"
.list
.org    $9D93
.db    t2ByteTok, tAsmCmp
Begin:
   LD DE, appbackUpScreen
   LD HL, Hookroutine
   LD BC, EndofHookRoutine - Hookroutine
   LDIR
EnableHook:
   LD HL, appBackUpScreen
   LD A, 0
   bcall($4F66)
   RET
HookRoutine:
    .db 83h
Is7:
   CP k7
   JR NZ, Is9
   LD A, k9
   JR Exit
Is9:
    CP k9
   JR NZ, Exit
   LD A, k7
Exit:
    OR A
   RET
EndofHookRoutine:   
.end
.end
Can you be any more specific about what doesn't work? Does it simply do nothing, or does it crash? Your code looks very similar to http://wikiti.brandonw.net/index.php?title=83Plus:Hooks:9B84#Example , so I would hope it would work. Your copy looks fine, and your setup with the $4F66 (enable_rawkeyhook) bcall looks okay to me. I'm currently flummoxed.
It doesn't work (nothing happens). What was really strange to me is that when i forgot RET in my first try- the calc didn't crash. May it be because of im testing on a TI-83+ emulator(not justified, i think its the official onecall flash debugger)?
jammasterz wrote:
It doesn't work (nothing happens). What was really strange to me is that when i forgot RET in my first try- the calc didn't crash. May it be because of im testing on a TI-83+ emulator(not justified, i think its the official onecall flash debugger)?
I've never been a fan of the official Flash Debugger emulator, but I think that BrandonW respects it, and I respect him, so therefore I won't quibble. Those symptoms would suggest to me that the hook isn't running at all, which would mean:
1) Something else overwrote the hook, or
2) The first byte (the 0x83) is wrong, or
3) The page/address passed to the enable bcall aren't correct
I just tested the last version of the code on Shelly and on another TI 84 calculator and it didn't work, just as on the TI Flash debugger. Any ideas? The code is based on what i read on the wiki so i don't think there should be anything that is overwriting the code.
Try using WabbitEmu or PindurTI and set a breakpoint at AppBackupScreen+1 to see if the hook is running at all, or if it never runs?
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement