How would that be constructed? Would the hook syntax be the same, starting from
"Interrupt:"

How would the hook be set up?
Well, the only way to create a reliable hook is to create the hook from a Flash App, not a regular assembly program. WikiTI has some example code for creating hooks.
1) Calling bcalls() inside interrupts is to be regarded with extreme caution
2) I'd strongly recommend against making an interrupt as one of your first ASM programs; it's a very frustrating process. I'd recommend something smaller and easier.
also, interrupts are not good for beginners because most newbies to interrupts make them way too large or long, and this can set the calculator into an endless loop of just interrupts, since right when the interrupt ends, the next one happens.

So take caution Wink

Code:
.nolist
#include   "ti83plus.inc"
.list
.org   $9D93
.db    t2ByteTok, tAsmCmp

      b_call(_ClrLCDFull)
   
Install:
      ld a,0
ld hl,RawKeyHook
      b_call(_EnableRawKeyHook)

RawKeyHook:
        .db 83h             ; Required for all hooks
        cp kClear        ; was Clear pressed?
        jr z,Display
        cp kPrgm            ; was Prgm pressed?
        jr z,Display
        cp kEnter         ;was Enter pressed?
        jr z,Display
        ret nz
   
Display:
      ld a,0
      ld (CurCol),a
      ld b,7
      ld (CurRow),b       
      ld hl,msg
      b_call(_PutS)
      ret
      
msg:
.db "Moron",0
.end
.end


This correct?
You have to try assembling and testing your programs, watch them crash, and then try to work through what's wrong. Smile It's obvious you haven't even tried assembling that, because the line "ld (CurRow),b" is invalid. Other than changing Display to:


Code:
Display:
      ld hl,(0*256)+7    ;curcol=0, currow=7
      ld (CurRow),hl
      ld hl,msg
      b_call(_PutS)
      ret
You need to have your hook in some safeRAM area; you can just point to the contents of your program, because as soon as your program finishes, it gets moved back to where it started (inside prgmBLAH).
I actually did compile it, and changed the source accordingly, but failed to change the post here. As for having the hook in SafeRAM, I did:


Code:
Install:
      ld a,0
      ld hl,RawKeyHook
      ld (AppBackupScreen),hl
      b_call(_EnableRawKeyHook)


The b_call requires the Flash page to be passed through a (0=RAM, right?), and a pointer to be passed through hl. So this should work. But I'm being told, upon compile, that pass 2 fails because b_call(_EnableRawKeyHook) is not recognized.
Well, _EnableRawKeyHook is $4F66, so you can add "_EnableRawKeyHook .equ $4F66" near the top of your code, before the .org. Yes, 0=RAM for the page, but you still have to find a way to put your hook in a piece of RAM that's not going to move or get overwritten, as I said.

Code:
.nolist
#include   "ti83plus.inc"
.list
_EnableRawKeyHook   .equ   $4F66
.org   $9D93
.db    t2ByteTok, tAsmCmp

      b_call(_ClrLCDFull)
   
Install:
      ld hl,AppVarName
      rst rMOV9TOOP1
      ld hl,200
      b_call(_CreateAppVar)
     ld hl,AppVarName
     rst rMOV9TOOP1
     bcall_ChkFindSym    ;pointer to appvar in de
     ld a,0
      ld hl,RawKeyHook
      ld (de),hl
      b_call(_EnableRawKeyHook)

RawKeyHook:
        .db 83h             ; Required for all hooks
        cp kClear        ; was Clear pressed?
        jr z,Display
        cp kPrgm            ; was Prgm pressed?
        jr z,Display
        cp kEnter         ;was Enter pressed?
        jr z,Display
        ret nz
   
Display:
      ld hl,(0*256)+7    ;curcol=0, currow=7
      ld (CurRow),hl
      ld hl,msg
      b_call(_PutS)
      ret

AppVarName:
   .db AppVarObj,"Moron",0
             
msg:
.db "Moron",0
.end
.end


this gives me an issue with "de" on compiling.
1) That's very clever, but AppVars still move around. Sad
2) Why the b_call(_ClrLCDFull) at the top?
3) " bcall_ChkFindSym ;pointer to appvar in de " should be "bcall(_ChkFindSym)
4) You should always do a chkfindsym before createappvar to make sure you're not making a duplicate
5) It doesn't look like you copy the content into the appvar.
6) This is not valid: "ld (de),hl "
1. What parts of RAM are static?
2. Cuz it looks nice. lol. jk. I always open by cleaning the screen.
3. I get a compiling error with parentheses.
4. Will do.
5. Why not? How would I copy to anywhere, then?
6. This is probably related to 5.
Are you using the Doors CS SDK to build this? If not, why not? You should also use the DCS include file as well, which will make parenthesis-enclosed bcalls() happy.


Code:
.nolist
#include   "ti83plus.inc"
#include "dcs7.inc"
.list


6) The only way to do that is:

Code:
ld a,l
ld (de),a
inc de
ld a,h
ld (de),a
If you don't care about keeping hl or de afterwards, you can do:


Code:
ex de,hl
ld (hl),e
inc hl
ld (hl),d
Yes, I am using the DCS sdk. Just forgot about the include file.
If you are, then bcall(_Routine) (no underscore in bcall) should work fine, I believe.
Ok. I compiled and sent it to WabbitEmu. It ran to completion, without crashing, but didn't seem to do anything.
Division in z80 just clicked for me. Just keep subtracting the dividend from the divisor until the carry flag is set. At that point, the accumulator plus the dividend equals the remainder. I feel sooo stupid.
ACagliano wrote:
Division in z80 just clicked for me. Just keep subtracting the dividend from the divisor until the carry flag is set. At that point, the accumulator plus the dividend equals the remainder. I feel sooo stupid.
Yes, but that's the slow, naive way to do it. 60,000/3? Gotta wait 20,000 iterations. I recommend that you use the routines from z80 bits:

http://baze.au.com/misc/z80bits.html
ACagliano wrote:
Division in z80 just clicked for me. Just keep subtracting the dividend from the divisor until the carry flag is set. At that point, the accumulator plus the dividend equals the remainder. I feel sooo stupid.


Don't feel stupid. The only math I don't understand for myself is division, and I can get along fine without it most of the time Smile I usually perform only really simple divisions with bit shifts, and when I do need to perform something like HL / 19, I look for a premade generic division routine, and manually mod it to work for 19 only to save cycles. Wink

In short, division is a hard to understand math compared to multiplication or simple modulus. I'd say even sine and cosine are easier if you do it a certain way Wink. So don't feel bad.
I don't think I agree with modifying the division routine for speed (unless you're writing a grayscale routine Wink) because code reuse is often better than saving a few cycles, depending on the program.
Is it possible to chain conditionals in z80? For example:

jr ncz (no carry and zero)

I think not, but its worth an ask.
  
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 2 of 4
» 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