Yo there...

Here is where i need help :

I need to find a way to automatically open up the os prgm editor for a defined prgm, right after exiting the application i'm working on.
I precise i don't need to return back to the app code after doing so.
Also, the idea is to be able to make the cursor point to the location i want.
I already have the obj+name and error token address for the concerned prgm.
Before you ask, no need to call _jerror cause my app already displays its own error messages.

If you know "Axe", this is exactly how i want it to work (when [PRGM] is pressed if an error is encountered).
Unfortunately, its creator doesn't answer my call so i hope someone can around here...

Thx in advance =]
I actually just fixed that routine recently Laughing Maybe Kerm will fix it in DCS too if he didn't already, which I think he might of since that was over a year ago.

Anyway, here goes. There are 2 blanks that need to be filled in depending on which program, and where in the program you plan to jump to. Sorry its not commented...

Code:

EditorExit:
;'HL points to the name of the program to edit'
   ld   hl,_Your_Prgm_Name_
   ld   de,progToEdit
   ld   bc,8
   ldir
   xor   a
   ld   (de),a
   ld   a,kPrgmEd
   B_CALL(_NewContext)
;'BC should hold the offset you would like to jump to'
   ld   bc,_Your_Offset_
   ld   de,(editTop)
   ld   hl,(editTail)
   ldir
   ld   (editCursor),de
   ld   (editTail),hl
   ld   h,b
   ld   l,c
   push   hl
EditorLoop:
   ld   de,(editTop)
   or   a
   sbc   hl,de
   jr   z,EditorFound
   B_CALL(_BufLeft)
   ld   hl,(editCursor)
   ld   a,(hl)
   cp   tEnter
   jr   z,EditorFound
   pop   hl
   inc   hl
   push   hl
   jr   EditorLoop
EditorFound:
   B_CALL(_BufRight)
   B_CALL(_DispEOW)
   pop   hl
   ld   a,h
   or   l
   jr   z,EditorMon
EditorScroll:
   dec   hl
   ld   a,h
   or   l
   jr   z,EditorMon
   push   hl
   B_CALL(_CursorRight)
   pop   hl
   jr   EditorScroll
EditorMon:
   res   2,(iy+50)
   res   7,(iy+20)
   res   3,(iy+5)
   B_JUMP(_Mon)
Thx man...
I'll give it a try as soon as possible.
U rock =]
Just tried it.
It kinda works, except for 2 things :

1) It seems impossible to make the cursor point to a tenter token.
It'll automatically point to the next token instead.
2) It behaves very strangely if there is no tenter token before the inputted offset (in other words, if it's located in the first line of the prgm).

I'll try to figure out why...
Oh right, that's because its directly from the Axe source where those effects are what I desire. Remove the "B_CALL(_BufRight)" if you want to be able to put the cursor over a tEnter token. I think this might solve both problems, but I'm not sure.

EDIT: Also move the "jr z,EditorFound" to after the pop inc push thing.
While doing some tests, i figured out how the whole thing works so i'm gonna modify it to suit my needs.
I actually found a way to avoid both the bufleft and bufright bcalls.

Anyway, there's a place for you in my project credits.
Thx again =]
Glad you were able to get this resolved, The_Mad_Joob.
I'm glad you're glad.
Thx =]
the_mad_joob wrote:
While doing some tests, i figured out how the whole thing works so i'm gonna modify it to suit my needs.
I actually found a way to avoid both the bufleft and bufright bcalls.

Anyway, there's a place for you in my project credits.
Thx again =]


I know it's an old post but I was wondering if you could share that code. (If you still have it)
NonstickAtom785 wrote:
the_mad_joob wrote:
While doing some tests, i figured out how the whole thing works so i'm gonna modify it to suit my needs.
I actually found a way to avoid both the bufleft and bufright bcalls.

Anyway, there's a place for you in my project credits.
Thx again =]


I know it's an old post but I was wondering if you could share that code. (If you still have it)

Hello there =]
I believe i can get my hands on that piece of code.
Understanding it is another story cause i coded it a bit ago, but from what i remember, it's not that huge.
Stay tuned, gonna take a look ASAP.
Cheers.

EDIT :

So, i took a look at the code, and i believe i can adapt it a bit.
However, it's worth mentioning that my method does not return (once the prgm editor opens, you're out of your own code for good).
Let me know if you're ok with that restriction, so that i know if i should adapt it or not.
Also, do you want to open the editor from a program or from an application ?
Alright, i took some time to recode the whole thing, in a more universal way.
It's compatible with all TI-8X+ models (monochrome screen, at least).
It's larger than quigibo's orginal code (which has probably been updated since), but it doesn't cause any stack leak.
You'll have to manually unarchive the program first if it's not already in RAM.

Code:
;prgmedita - app variant

;DESCRIPTION
;Exits the application, opens the program editor for the specified program, and
;   sets the cursor to the specified location.
;This code is to be simply executed, not called.
;Inspired by quigibo's code.

;IN
;target program type : unprotected
;target program location : RAM
;bc = target line offset (see NOTES)
;de = target cursor offset (see NOTES)
;hl = target program name address (0-terminated if not 8 bytes long)
;iy = flags

;NOTES
;bc = line first address - program first address (right after size word)
;de = cursor address - line first address
;It's not allowed to point to the second byte of a word token.
;It's allowed to point to the address right after the last token of the program.
;If the program is empty, both offsets must be equal to zero.

prgmedita

   ld (appbackupscreen),bc
   ld (appbackupscreen+2),de
   ld (appbackupscreen+4),hl
   ld de,appbackupscreen+6
   ld hl,flags+hookflags2
   ld a,(hl)
   ld (de),a
   or %00000001
   ld (hl),a
   ld bc,3
   inc de
   ld hl,getkeyhookptr
   ldir
   ld hl,prgmedita_hook
   ld (getkeyhookptr),hl
   in a,($06)
   ld (getkeyhookptr+2),a

   bcall(_jforcecmdnochar)

prgmedita_hook

.db $83

   di
   in a,($02)

   rla
   jr nc,prgmedita_initialise

   ld a,$01
   out ($20),a

prgmedita_initialise

   bcall(_cursoroff)

   di
   ld a,cxprgmedit
   ld bc,8
   ld de,progtoedit
   ld hl,(appbackupscreen+4)
   ldir
   ld c,4
   ld de,flags+hookflags2
   ld hl,appbackupscreen+6
   ldi
   ld de,getkeyhookptr
   ldir

   bcall(_newcontext0)

   di
   ld bc,(appbackupscreen)
   ld a,b

   or c
   jr z,prgmedita_line_start

   ld de,(edittop)
   ld hl,(edittail)
   ldir
   ld (editcursor),de
   ld (edittail),hl

prgmedita_line_start

   ld de,(editcursor)
   ld ix,(appbackupscreen+2)
   ld iy,0
   in a,($02)
   and %00100000
   ld a,10

   jr z,prgmedita_ready

   inc a

prgmedita_ready

   ex af,af'

   jp prgmedita_check_counter_a

prgmedita_next_token

   ld a,(de)
   ex af,af'
   ld c,a
   ex af,af'
   inc de
   ld hl,prgmedita_word_tokens
   dec ix
   inc iy

   cpir
   jr nz,prgmedita_check_counter_a

   inc de
   dec ix

prgmedita_check_counter_a

   ld a,ixh

   or ixl
   jp nz,prgmedita_next_token

   push iy
   ld iy,flags

   bcall(_dispeow)

   di

   jp prgmedita_check_counter_b

prgmedita_advance_cursor

   dec bc
   push bc

   bcall(_cursorright)

   di

prgmedita_check_counter_b

   pop bc
   ld a,b

   or c
   jp nz,prgmedita_advance_cursor

   ld (kbdscancode),a

   ret

prgmedita_word_tokens

.db tvarmat,tvarlst,tvarequ,tvarpict,tvargdb,tvarout,tvarsys,tgformat,tvarstrng
.db t2bytetok,tunused01

Code:
;prgmeditb - prgm variant

;DESCRIPTION
;Exits the program, opens the program editor for the specified program, and sets
;   the cursor to the specified location.
;This code is to be simply executed, not called.
;This code is expected to be executed from a program that was properly loaded
;   from the homescreen (shells unsupported).
;Inspired by quigibo's code.

;IN
;interrupts : disabled
;target program type : unprotected
;target program location : RAM
;bc = target line offset (see NOTES)
;de = target cursor offset (see NOTES)
;hl = target program name address (0-terminated if not 8 bytes long)
;iy = flags

;NOTES
;bc = line first address - program first address (right after size word)
;de = cursor address - line first address
;It's not allowed to point to the second byte of a word token.
;It's allowed to point to the address right after the last token of the program.
;If the program is empty, both offsets must be equal to zero.

prgmeditb

   res oninterrupt,(iy+onflags)
   ld (appbackupscreen),bc
   ld (appbackupscreen+2),de
   ld bc,8
   ld de,appbackupscreen+4
   ldir
   ld hl,flags+hookflags2
   ld a,(hl)
   ld (de),a
   or %00000001
   ld (hl),a
   ld c,3
   inc de
   ld hl,getkeyhookptr
   ldir
   ld (getkeyhookptr),de
   dec hl
   ld (hl),$01
   ld c,prgmeditb_hook_end-prgmeditb_hook_start
   ld hl,prgmeditb_hook_start
   ldir
   in a,($02)

   and %00100000
   ret nz

   ld a,10
   ld (prgmeditb_variable-prgmeditb_hook_start+appbackupscreen+16),a

   ret

prgmeditb_hook_start

.db $83

   di
   in a,($02)

   rla
   jr nc,prgmeditb_initialise

   ld a,$01
   out ($20),a

prgmeditb_initialise

   bcall(_cursoroff)

   di
   ld a,cxprgmedit
   ld bc,8
   ld de,progtoedit
   ld hl,appbackupscreen+4
   ldir
   ld c,4
   ld de,flags+hookflags2
   ldi
   ld de,getkeyhookptr
   ldir

   bcall(_newcontext0)

   di
   ld bc,(appbackupscreen)
   ld a,b

   or c
   jr z,prgmeditb_line_start

   ld de,(edittop)
   ld hl,(edittail)
   ldir
   ld (editcursor),de
   ld (edittail),hl

prgmeditb_line_start

   ld de,(editcursor)
   ld ix,(appbackupscreen+2)
   ld iy,0

   jp prgmeditb_check_counter_a-prgmeditb_hook_start+appbackupscreen+16

prgmeditb_next_token

   ld a,(de)

.db $0E ; ld c,* first half

prgmeditb_variable

.db 11 ; ld c,* second half

   inc de
   ld hl,prgmeditb_word_tokens-prgmeditb_hook_start+appbackupscreen+16
   dec ix
   inc iy

   cpir
   jr nz,prgmeditb_check_counter_a

   inc de
   dec ix

prgmeditb_check_counter_a

   ld a,ixh

   or ixl
   jp nz,prgmeditb_next_token-prgmeditb_hook_start+appbackupscreen+16

   push iy
   ld iy,flags

   bcall(_dispeow)

   di

   jp prgmeditb_check_counter_b-prgmeditb_hook_start+appbackupscreen+16

prgmeditb_advance_cursor

   dec bc
   push bc

   bcall(_cursorright)

   di

prgmeditb_check_counter_b

   pop bc
   ld a,b

   or c
   jp nz,prgmeditb_advance_cursor-prgmeditb_hook_start+appbackupscreen+16

   ld (kbdscancode),a

   ret

prgmeditb_word_tokens

.db tvarmat,tvarlst,tvarequ,tvarpict,tvargdb,tvarout,tvarsys,tgformat,tvarstrng
.db t2bytetok,tunused01

prgmeditb_hook_end
  
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