To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.spyboticsOpen lugnet.robotics.spybotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / Spybotics / 229
228  |  230
Subject: 
FindWorld & ClearWorld Spybot NQC API additions
Newsgroups: 
lugnet.robotics.spybotics, lugnet.robotics.rcx.nqc
Date: 
Tue, 21 Oct 2003 00:13:20 GMT
Viewed: 
10930 times
  
Another addition to spy.nqh :

  #define REL_GT 0
  #define REL_LT 1
  #define REL_EQ 2
  #define REL_NE 3

  __nolist void FindWorld(int &v, const int relsrc, const int crit, const int&
thresh)
  {
    asm { 0xd5, &v : 0x3000001, 0x2a + relsrc, crit, &thresh : __ASM_SMALL_VALUE
};
  }
  __nolist void ClearWorld() { asm { 0x36 }; }


Now you can write loops using FindWorld to iterate through the world relation
table (as per the contrived example below).  Now if we can all just squeak
loudly enough perhaps we can persuade Dave Baum to add support for subroutines
which take parameters (using the stack) and that can call other subroutines to
NQC. :-)


#include "spy.nqh"

task main()
{
  int x = 40;
  int t = -1;
  ClearWorld();
  FindWorld(t, SPY_RANGE, REL_GT, RANGE_NOWHERE);
  while (t != -1)
  {
    SetTargetID(t);
    SetWorldNote(t, 40);
    SetTargetNote(x);
    GetWorld(SPY_SHORTID, t, x);
    x = Target(SPY_SHORTID);
    GetWorld(SPY_LINKID, t, x);
    x = Target(SPY_LINKID);
    GetWorld(SPY_RANGE, t, x);
    x = Target(SPY_RANGE);
    GetWorld(SPY_DIRECTION, t, x);
    x = Target(SPY_DIRECTION);
    GetWorld(SPY_ASPECT, t, x);
    x = Target(SPY_ASPECT);
    GetWorld(SPY_INFO, t, x);
    x = Target(SPY_INFO);
    GetWorld(SPY_NOTE, t, x);
    x = Target(SPY_NOTE);
    FindWorld(t, SPY_RANGE, REL_GT, RANGE_NOWHERE);
  }

}



Message has 2 Replies:
  Re: FindWorld & ClearWorld Spybot NQC API additions
 
This is an area of robotics that particularly interests me. Thank you for doing all this work! Now...how do I put all together? Do I simply add your programming to the bottom of spy.nqh or are there particular locations where pieces should go? Would (...) (21 years ago, 21-Oct-03, to lugnet.robotics.spybotics, lugnet.robotics.rcx.nqc)
  Re: FindWorld & ClearWorld Spybot NQC API additions
 
(...) SQUEAK!!! SQUEAK!!! SQUEAK!!! ;o) Philo (21 years ago, 21-Oct-03, to lugnet.robotics.spybotics, lugnet.robotics.rcx.nqc)

5 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR