Crosspost from https://ourl.ca/21803


Ever dreamed about being able to do vectorial math on your z80 calculator? Well, I started making an app for that!
So far it only features the scalar (dot) product, lol. You can switch between the different product types by hitting the multiply key multiple times.

Since you asked about making a menu in ASM, let me direct you to the dialog context. It's quite a weird context to use, and my experience is that looking at a lot of example code before you dive in helps a lot, but I think it's what you need. Feel free to ask follow-up questions. Smile
Um yeah I like can't get it working properly....

Code:
Menu:
   res indicrun,(iy+indicflags)
   res apptextsave,(iy+appflags)
   
   
   ld hl,rawKeyHookPtr
   ld de,appBackUpScreen
   ld bc,4
   ldir
   ld a,(flags+34h)
   ld (de),a
   
   
   ld hl,cmdShadow
   ld de,appBackUpScreen+5
   ld bc,128
   ldir
   
   
   ld hl,structStart
   ld de,ramCode
   ld bc,structEnd-structStart
   ldir
   ld hl,dialogCallback
   in a,(6)
   bcall(_DialogInit)
   bcall(_runIndicOff)
   bcall(_StartDialog)
   
;   bcall(_CursorOff)
;   bcall(_ClrLCDFull)
   
   res appCurWord,(iy+appFlags)
   
   ld hl,appBackUpScreen+5
   ld de,cmdShadow
   ld bc,128
   ldir
   
   ld a,kQuit ; homescreen
   ld (cxCurApp),a
   
   ld hl,appBackUpScreen
   ld de,rawKeyHookPtr
   ld bc,4
   ldir
   ld a,(hl)
   ld (flags+34h),a
   
   xor a
   bcall(_GetDialogNumOP1)
   ld a,9
   bcall(_DispOP1a)
   xor a
   ret
dialogCallback:
   xor a
   ret

structStart:
   .db 1
   .db 1
   .db 1
   .dw sOptions-structStart
   .db 5
   .db 1
   .db 1
   .dw sItem1-structStart
   .db 5
   .db 1
   .db 2
   .dw sItem2-structStart
   .db 0
sOptions:
   .db 7,"VECTORS"
sItem1:
   .db 4,"abs("
sItem2:
   .db 5,"norm("
structEnd:


When exiting it like exits back into the stat menu (where it was before it got called) but I want it to exit to the homescreen and I can't find any way of getting which option was pushed
How do i insert tokens the correct way?

Doing
ld de,tAbs \ bcall(_BufReplace)
gives me this:


EDIT: This snipped by chickendude seems to be working Very Happy http://pastebin.com/fEpTzgpb


EDIT2:
Somehow when using my custom menu in the programming editor my keyhook gets deleted afterwards, even though i back it up etc.



Code:

Menu:
   res indicrun,(iy+indicflags)
   res apptextsave,(iy+appflags)
   
   
   ld hl,rawKeyHookPtr
   ld de,appBackUpScreen
   ld bc,4
   ldir
   ld a,(flags+34h)
   ld (de),a
   
   ld hl,textShadow
   ld de,appBackUpScreen+4
   ld bc,128
   ldir
   
   
   
   
   ld hl,structStart
   ld de,ramCode
   ld bc,structEnd-structStart
   ldir
   
   ld hl,dialogCallback
   in a,(6)
   bcall(_DialogInit)
   bcall(_runIndicOff)
   bcall(_StartDialog)
   
   ld a,(cxCurApp)
   push af
      
      res appCurWord,(iy+appFlags)
      
      ld hl,cmdShadow
      ld (hl),' '
      ld de,cmdShadow+1
      ld bc,127
      ldir
      
      
      
      ld hl,appBackUpScreen
      ld de,rawKeyHookPtr
      ld bc,4
      ldir
      
      ld a,(hl)
      ld (flags+34h),a
      
      ld de,textShadow
      ld bc,128
      ldir
   pop af
   jp nz,ReturnNZ
   
   ld hl,appData+6 ; menu option
   ld e,(hl)
   ld d,0
   ld hl,menuJumpTable-2 ; minus two because offsets start at 1
   add hl,de
   add hl,de
   ld e,(hl)
   inc hl
   ld d,(hl)
   ex de,hl
   jp (hl)
   
dialogCallback:
   xor a
   ret



structStart:
   .db 1
   .db 1
   .db 1
   .dw sOptions-structStart
   .db 5
   .db 1
   .db 1
   .dw sItem1-structStart
   .db 5
   .db 1
   .db 2
   .dw sItem2-structStart
   .db 0
sOptions:
   .db 7,"VECTORS"
sItem1:
   .db 4,"abs("
sItem2:
   .db 5,"norm("
structEnd:

menuJumpTable:
   .dw insertTokenAbs
   .dw insertTokenNorm

insertTokenAbs:
   ld hl,absTok
   ld bc,1
   call insertTok
   
   ld a,kQuit
   jp ReturnNZ
insertTokenNorm:
   ld hl,normTok
   ld bc,2
   call insertTok
   
   ld a,kQuit
   jp ReturnNZ

absTok:
   .db tAbs

normTok:
   .db customTokenPrefix
   .db tNormLower

insertTok:
; hl - tok
; bc - len (bytes)
   push bc
      ld de,appBackUpScreen
      ldir
   pop bc
   ld hl,appBackUpScreen
   ld (rclQueue),hl
   add hl,bc
   ld (rclQueueEnd),hl
   set 7, (iy+0Eh)
   set 2, (iy+33h)
   ret
It looks like you're not advancing the cursor properly to me. But I'm glad that chickendude had it covered!

Edit: For your second problem, you overwrite your flag storage in the fifth byte of AppBackupScreen:
Code:
   ld de,appBackUpScreen+4
Also, out of curiosity, is ld a,(flags+34h) really better than ld a,(iy+34h)? I believe it's one byte smaller, but may be slightly less clear.
Yay, it's working now, thanks!

But there is a new issue, hehe. The screen isn't updated in the editor, so i can still see the menu and the cursor flashing where i was editing before, moving around updates the screen in those areas.

Also about the iy......that results in copying example code.

EDIT: Also, is there any way to exit that menu when hitting Clear?
Sorunome wrote:
EDIT: Also, is there any way to exit that menu when hitting Clear?
I suppose you could add a separate keyhook that detects kClear and turns it into kQuit.
the key hook isn't been triggered during that bcall

EDIT: Also seems like my calculator doesn't like inserting a token when in the program editor Sad
Sorunome wrote:
the key hook isn't been triggered during that bcall
Did you try both kinds of key hooks, the RawKeyHook and the GetkeyHook?
I only tried the RawKeyHook. I guess i'll try the other one, too

EDIT: After some debugging the spectacular crash above i think it is something wrong with the insertTok routine.
What led me to that conclusion is that if i get me to edit another menu instead of exiting it won't trigger that gltich unless i went back to the actual programming editor. Also exiting the custom menu without having to insert a token doesn't result in a glitch either.
How about calculating the distance between two points? Or, the distance between a line and a point?

Bored with three dimensions? This works in n dimensions!
Wow, I just found this! So it adds commands to the actual TI-OS? That's really useful. Smile Can it do all like dot and cross product and things?
Yes, you hit the multiply sign multiple times Razz
Check out the screenie in the first post




Soooo,
implemented features:
[*] scalar product
[*] cross product *
[*] absolute value of vector
[*] normalize a vector
[*] distance point - point
[*] distance point - line
[*] distance line - line
[*] angle vector -vector

Will implement:
[*] distance point-plain *
[*] distance line-plain *
[*] distance plain-plain *
[*] converting plains between the different notations *
[*] angle line-line
[*] angle line-plain *
[*] check if point is on line
[*] check if point is on plain *
[*] check if line is in plain *
[*] tensor product *

the start (*) indicates that that function is, due to definition stuff, only possible in three dimensions (stuff with plains)

Any other ideas?
Sooooo, as you may have noticed in the screenshots above every time i have a line as an answer i just display <LINE>. I want to be able to display the line as {a,b,c}+t*{x,y,z}.
I store a line into a list as
{<tag>,a,x,b,y,c,z} and i already wrote me routines to fetch {a,b,c} and {x,y,z} out of that.
Now, in order to get that displayed correctly i need a tokenized string to be able to return OP1 for the HomeScreen hook and thus change the answer been displayed.
KermM pointed me the other day to http://wikiti.brandonw.net/index.php?title=83Plus:BCALLs:49A5 but I can't seem to get the edit buffer working at all, any help would be appreciated!
  
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 GMT - 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