84PCE:OS:VAT

From WikiTI
Revision as of 20:51, 9 September 2015 by MateoConLechuga (talk | contribs)
Jump to navigationJump to search

The VAT has remained pretty much the same, as has the structure of archived variables.

One important thing to note is that the ROM page offset is now a part of the whole address, which is nice in order to maintain backwards compatibility.

Traversing the VAT Example:

;-------------------------------------
; fdetect
; detects appvars, prot progs, and
; progs given a 0-terminated string
; pointed to by ix.
;-------------------------------------
; INPUTS:
; hl->place to start searching
; ix->string to find
;
; OUTPUTS:
; hl->place stopped searching
; de->program data
; bc=program size
; OP1 contains the name and type byte
; z flag set if found
;-------------------------------------
fdetect:
 ld de,(ptemp)
 call _cphlde
 ld a,(hl)
 ld (typeByte_SMC),a
 jr nz,fcontinue
 inc a
 ret
fcontinue:
 push hl
 cp appvarobj
 jr z,fgoodtype
 cp protprogobj
 jr z,fgoodtype
 cp progobj
 jr nz,fskip
fgoodtype:
 dec hl
 dec hl
 dec hl
 ld e, (hl)
 dec hl
 ld d,(hl)
 dec hl
 ld a,(hl)
 call _SetDEUToA
 push de
 pop hl
 cp $D0
 jr nc,finRAM
 push ix
 push de
  push hl
  pop ix
  ld a,10
  add a,(ix+9)
  ld de,0
  ld e,a
  add hl,de
  ex (sp),hl
  add hl,de
 pop de
 ex de,hl
 pop ix
finRAM:
 inc de
 inc de
 ld bc,0
 ld c,(hl)
 inc hl
 ld b,(hl)
 inc hl ; hl -> data
 push bc ; bc = size
 push ix
 pop bc
fchkstr:
 ld a,(bc)
 or a,a
 jr z,ffound
 cp (hl)
 inc bc
 inc de
 inc hl
 jr z,fchkstr
 pop bc
fskip:
 pop hl
 call fbypassname
 jr fdetect
ffound:
 push bc
 pop hl
 push ix
 pop bc
 or a,a
 sbc hl,bc
 push hl
 pop bc
 pop hl ; size
 or a,a
 sbc hl,bc
 push hl
 pop bc
 pop hl ; current search location
 push bc
 call fbypassname
 pop bc
 xor a
 ret
fbypassname:
 push de
  ld bc,-6
  add hl,bc
typeByte_SMC: =$+1
  ld a,15h
  ld de,OP1
  ld (de),a
  inc de
  ld b,(hl)		; Name to OP1 -> For things like archiving/deleting
  inc b
fbypassnameloop:
  ld a,(hl)
  ld (de),a
  inc de
  dec hl
  djnz fbypassnameloop
  xor a
  ld (de),a
 pop de
 ret