Hx1ProgramNotes.txt Program Notes DLB 22-11-01 ------------- Utility routines in Prog7 ------------------------- When these are selected the routine number {1,2} is put in CommonRam2. When 'back' is selected from the routines (see menu), CommonRam2 is cleared, oldbtn put in CommonRam6 and Prog0 (Main) is RUN. Invoking other programs from Prog0 menu --------------------------------------- 0 is put in CommonRam0 as the calling program, the routine to do is put in CommonRam1 and the selected program is RUN. Invoking other programs from Prog1(Activities) or Prog2(US-behaviours) ---------------------------------------------------------------------- If a jump is required then the current program number (=CommonRam63) is put in CommonRam0 and the required program is RUN. If an 'include' (subroutine) call is selected then the current program number (=CommonRam63) is put in CommonRam0. Also for Activities the activity data pointer (Sptr) is put in the low three nibbles of arg, or for Behaviours the rule set number (usname) is put in the low byte of arg, then the current program number (=CommonRam63) is put into arg.lownib(3), then arg is put on the stack. ie nib3 nib2 nib1 nib0 Activities Prog --------Sptr-------- Behaviours Prog 0 rule-number Stack usage ----------- If an Activity or Behaviour is suspended by an Include, the current position is put on the stack. To return from an Include, the routine number in CommonRam1 is set to 0, then the calling program is RUN. Entry to the Activity or Behaviour programs with the routine number in CommonRam1 set to 0 forces the program to look on the stack by popping arg. If Prog is a different program then arg is put back on the stack and that program is RUN, if Prog is the running program then the Sptr or rule-number is used. An empty stack results in a jump to Prog0 as there is nothing else to do. If Prog0 is RUN with something on the stack then arg is popped to get Prog, if Prog<>0 then arg is put back on the stack and the relevant program is RUN. IR-Control routine in Prog7 --------------------------- This has an option to invoke US_wander. If US_wander is interupted by an IR signal or button press at 'usercmnd' then Prog0 is RUN. CommonRam2=(Utility routine number) will still be set to U_KirCon so Prog7 is RUN to get back to the IR-Control routine.