Hello everyone! I have been having some trouble with the old iondetect routine, and attempting to have it detect AppVars. It seems that the structure of the two are the same, so I am at a loss as to way iondetect is unable to find AppVars. I imagine that it has something to do with the header of the AppVar, but I am a little unsure as to what it could actually be.


Code:


   ; Setup Stuff
   ; More code

   ld   ix,Detection_String
   ld   hl,(progptr)
   call   detect
   ret

detect:
   ld   de,(ptemp)
   bcall(_cphlde)
   ld   a,(hl)
   jr   nz,detectContinue
   inc   a
   ret
detectContinue:
   push   hl
   and   $01
   jr   nz,detectSkip

   dec   hl
   dec   hl
   dec   hl   ; hl->lsb ptr
   ld   e,(hl)
   dec   hl
   ld   d,(hl)
   dec   hl   ; hl->page
   ld   a,(hl)
   or   a
   push   af
   ld   h,d
   ld   l,e   ; hl & de->program
   jr   z,detectNoMove
   push   hl
   bcall(_memfree)
   ld   bc,64
   sbc   hl,bc
   pop   hl
   jr   c,detectNotEnough
   ld   de,($9820)
   push   ix
   push   hl
   push   de
   bcall(_flashToRam)
   pop   hl
   push   hl
   pop   ix
   ld   a,10
   add   a,(ix+9)
   ld   e,a
   ld   d,0   ; de=flash offset
   add   hl,de
   ex   (sp),hl
   add   hl,de
   pop   de
   ex   de,hl   ; hl-temp, de-perm
   pop   ix
detectNoMove:
   inc   de
   inc   de
   ld   c,(hl)
   inc   hl
   ld   b,(hl)
   inc   hl   ; hl->data in ram
   push   bc
   push   ix
   pop   bc
detectCheck:
   ld   a,(bc)
   or   a
   jr   z,detectFound
   cp   (hl)
   inc   bc
   inc   de
   inc   hl
   jr   z,detectCheck
detectBad:
   pop   bc
detectNotEnough:
   pop   af
detectSkip:
   pop   hl
   ld   bc,-6
   add   hl,bc
   ld   b,(hl)
   dec   hl
detectNameLoop2:
   dec   hl
   djnz   detectNameLoop2
   jr   detect
detectFound:
   pop   hl
   ; hl=size, de->data
   pop   af   ; a=page, f=(or a)
   jr   z,detectInRam
   push   de   ; data
   push   af
   push   hl
   bcall(_enoughRam)
   pop   bc
   jr   c,detectBad
   pop   af
   pop   hl
   ld   de,($9820)   ; tempMem
   push   de
   bcall(_flashToRam)
   pop   de
detectInRam:   ; de->data in RAM
   pop   hl   ; hl->vat location
   ld   bc,-6
   add   hl,bc
   ld   b,(hl)
   inc   b
detectNameLoop1:
   dec   hl
   djnz   detectNameLoop1
   ex   de,hl
   xor   a
   ret

Detection_String:
   .db "Test",0


External Appvar data:


Code:

   .db "Test"
   ;Data


Does anyone have any ideas on why this is occurring? Anything would help!
What changes did you actually make to the routine? I'm thinking that the problem might be the and $01 \ jr nz,detectSkip, because appVarObj is equal to $15, and those variables will be completely skipped. Maybe you should replace the and $01 with a cp appVarObj.
That was indeed the issue! I really cannot believe that I did not notice that! Thanks!
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement