Omnimaga

Calculator Community => TI Calculators => ASM => Topic started by: nemo on November 18, 2010, 05:33:16 pm

Title: Archiving/Unarchiving a VAT pointer - request
Post by: nemo on November 18, 2010, 05:33:16 pm
hello ASM programmers. this should probably be a simple BCall or something, but i'm looking for two pieces of hex code. one that will take a pointer to a VAT entry in HL and unarchive it, and one that will take a pointer to a VAT entry in HL and archive it. i do not need error checking to see if the variable exists. if it results in more optimized code, know that the VAT entry will always be of type 5 or 6, (a program or protected program, respectfully).
Title: Re: Archiving/Unarchiving a VAT pointer - request
Post by: Xeda112358 on November 18, 2010, 05:43:52 pm
Okay, so do you want to just unarchive a program? Do you have a pointer already pointing to the VAT?
Title: Re: Archiving/Unarchiving a VAT pointer - request
Post by: nemo on November 18, 2010, 05:45:21 pm
yes, i have a pointer pointing to the VAT. i think i can just unarchive it by setting one of the bytes to zero, correct? or will that mess anything up? but i have a feeling archiving is a bit harder.

edit: i want code to both unarchive and archive a program.
Title: Re: Archiving/Unarchiving a VAT pointer - request
Post by: thepenguin77 on November 18, 2010, 06:43:12 pm
Instead of me writing it, I might as well tell you how to write it so you get the experience. Since you've already found the VAT entry I don't see why you can't do this.

1. Copy the name to OP1.
2. Put a zero after the name, (you don't have to if it's 8 chars long)
2. bcall(_chkFindSym) to check if it exists, (but if it has a vat entry it exists, you don't need to do this)
3. bcall(_arc_unarc) it archives an unarchived file and vise versa

Title: Re: Archiving/Unarchiving a VAT pointer - request
Post by: FloppusMaximus on November 18, 2010, 06:52:37 pm
The system routines for archiving and unarchiving variables require the variable's name in OP1.  So you need to convert a VAT entry into a variable name.  Here's a routine that does that:
Code: [Select]
;; VATEntryToOP1:
;;
;; Copy a program, appvar, group, or list variable name from the VAT
;; to OP1.
;;
;; Input:
;; - HL = address of type byte of VAT entry
;;
;; Output:
;; - OP1 = variable name
;;
;; Destroys:
;; - AF, BC, DE, HL

VATEntryToOP1:
ex de,hl
BCALL _ZeroOP1
ld a,(de)
ld hl,-6
add hl,de
ld b,(hl)
inc b
ld de,OP1
VATEntryToOP1_CopyNameLoop:
ld (de),a
inc de
dec hl
ld a,(hl)
djnz VATEntryToOP1_CopyNameLoop
ld a,(OP1 + 1)
sub tVarLst
ret nz
dec de
ld (de),a
ret
After calling VATEntryToOP1, you can call Arc_Unarc (or one of the undocumented archiving/unarchiving routines, but those are somewhat tricky to use correctly and safely.)

Edit: Whoops, didn't see thepenguin77's reply.  Yeah, you should try to see if you can write the routine yourself.  Practice is good for you. ;)