Author Topic: Archiving/Unarchiving a VAT pointer - request  (Read 7383 times)

0 Members and 2 Guests are viewing this topic.

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Archiving/Unarchiving a VAT pointer - request
« 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).


Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Archiving/Unarchiving a VAT pointer - request
« Reply #1 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?

Offline nemo

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1203
  • Rating: +95/-11
    • View Profile
Re: Archiving/Unarchiving a VAT pointer - request
« Reply #2 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.
« Last Edit: November 18, 2010, 05:45:48 pm by nemo »


Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Archiving/Unarchiving a VAT pointer - request
« Reply #3 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

zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline FloppusMaximus

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 290
  • Rating: +57/-5
    • View Profile
Re: Archiving/Unarchiving a VAT pointer - request
« Reply #4 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. ;)
« Last Edit: November 18, 2010, 06:57:37 pm by FloppusMaximus »