Difference between revisions of "84PCE:OS:VAT"

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

Latest revision as of 15:00, 9 September 2015

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
  ld de,OP1
  push 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
typeByte_SMC: =$+1
   ld a,15h
  pop de
  ld (de),a
 pop de
 ret