84PCE:OS:VAT: Difference between revisions

From WikiTI
Jump to navigationJump to search
Created page with "Category:84PCE:OS_Information <pre>;-------------------------------------------- ; fdetect ; detects appvars, prot progs, and ; progs given a 0-terminated string ; po..."
 
No edit summary
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:84PCE:OS_Information]]
[[Category:84PCE:OS_Information]]
The VAT has remained pretty much the same, as has the structure of archived variables.


<pre>;--------------------------------------------  
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.
; fdetect  
 
; detects appvars, prot progs, and  
Traversing the VAT Example:
; progs given a 0-terminated string  
<pre>;-------------------------------------
; pointed to by ix.  
; fdetect
;--------------------------------------------  
; detects appvars, prot progs, and
; INPUTS:  
; progs given a 0-terminated string
; hl->place to start searching  
; pointed to by ix.
; ix->string to find  
;-------------------------------------
;  
; INPUTS:
; OUTPUTS:  
; hl->place to start searching
; hl->place stopped searching  
; ix->string to find
; de->file data after string
;
; bc=file size after string
; OUTPUTS:
; z flag set if found, nz if not found  
; hl->place stopped searching
;--------------------------------------------  
; de->program data
fdetect:  
; bc=program size
  ld de,(ptemp)  
; OP1 contains the name and type byte
  or a,a 
; z flag set if found
  sbc hl,de 
;-------------------------------------
add hl,de
fdetect:
  ld a,(hl)  
  ld de,(ptemp)
  jr nz,fcontinue  
  call _cphlde
  inc a  
  ld a,(hl)
  ret  
  ld (typeByte_SMC),a
fcontinue:  
  jr nz,fcontinue
  push hl  
  inc a
  cp appvarobj  
  ret
  jr z,fgoodtype  
fcontinue:
  cp protprogobj  
  push hl
  jr z,fgoodtype  
  cp appvarobj
  cp progobj  
  jr z,fgoodtype
  jr nz,fskip  
  cp protprogobj
fgoodtype:  
  jr z,fgoodtype
  dec hl  
  cp progobj
  dec hl  
  jr nz,fskip
  dec hl  
fgoodtype:
  ld e, (hl)  
  dec hl
  dec hl  
  dec hl
  ld d,(hl)  
  dec hl
  dec hl  
  ld e, (hl)
  ld a,(hl)  
  dec hl
  call _SetDEUtoA
  ld d,(hl)
  push de  
  dec hl
  pop hl  
  ld a,(hl)
  cp 0D0h
  call _SetDEUToA
  jr nc,finRAM  
  push de
  push ix  
  pop hl
  push de  
  cp $D0
  push hl  
  jr nc,finRAM
  pop ix  
  push ix
  ld a,10  
push de
  add a,(ix+9)  
  push hl
  ld de,0  
  pop ix
  ld e,a  
  ld a,10
  add hl,de  
  add a,(ix+9)
  ex (sp),hl  
  ld de,0
  add hl,de  
  ld e,a
  pop de  
  add hl,de
  ex de,hl  
  ex (sp),hl
  pop ix  
  add hl,de
finRAM:  
pop de
  inc de  
ex de,hl
  inc de  
  pop ix
  ld bc,0  
finRAM:
  ld c,(hl)  
  inc de
  inc hl  
  inc de
  ld b,(hl)  
  ld bc,0
  inc hl   ; hl -> data  
  ld c,(hl)
  push bc   ; bc = size  
  inc hl
  push ix  
  ld b,(hl)
  pop bc  
  inc hl ; hl -> data
fchkstr:  
  push bc ; bc = size
  ld a,(bc)  
push ix
  or a  
pop bc
  jr z,ffound  
fchkstr:
  cp (hl)  
ld a,(bc)
  inc bc  
or a,a
  inc de  
jr z,ffound
  inc hl  
cp (hl)
  jr z,fchkstr  
inc bc
  pop bc  
inc de
fskip:  
inc hl
  pop hl  
jr z,fchkstr
  call fbypassname  
pop bc
  jr fdetect  
fskip:
ffound:  
  pop hl
  push bc  
  call fbypassname
  pop hl  
  jr fdetect
  push ix  
ffound:
  pop bc  
push bc
  or a  
pop hl
  sbc hl,bc  
push ix
  push hl  
pop bc
  pop bc  
or a,a
  pop hl   ; size  
sbc hl,bc
  or a  
push hl
  sbc hl,bc  
pop bc
  push hl  
pop hl ; size
  pop bc  
or a,a
  pop hl     ; current search location  
sbc hl,bc
  push bc  
push hl
  call fbypassname  
pop bc
  pop bc  
  pop hl ; current search location
  xor a  
  push bc
  ret  
call fbypassname
fbypassname:  
  pop bc
  ld bc,-6  
  xor a
add hl,bc  
  ret
ld b,(hl)  
fbypassname:
dec hl
  push de
fbypassnameloop:  
  ld bc,-6
dec hl  
  add hl,bc
djnz fbypassnameloop  
  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</pre>
  ret</pre>

Latest revision as of 22: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