To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.nqcOpen lugnet.robotics.rcx.nqc in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / NQC / 1482
1481  |  1483
Subject: 
spyutils.nqh
Newsgroups: 
lugnet.robotics.spybotics, lugnet.robotics.rcx.nqc, lugnet.robotics
Date: 
Fri, 17 Jan 2003 04:49:22 GMT
Viewed: 
414 times
  
I have attached to the end of this message the spyutils.nqh file I've
been compiling.  It's not got a lot in there yet, just the routines
defined as "utility" in the Lego Spybotics ROM SDK plus the
SendRCXMessage.  I'm aiming toward this file being ROM routines that
don't need access to the variable and timer space.

There are a whole bunch of interesting routines that do require access
to this space, and I'm working on a spyengine.nqh for those routines.

I'm assuming that these function definitions are implemented like
standand C macros, ie, inline code that doesn't take up code space
unless actually called.

What I'd like to get to get a working API for are the routines and
access to the world tables.  I keep meaning to get time to work no
that, but that hasn't yet.

So enjoy, and please add to this work with more Spybotics information!


/*
** Spybotics API for NQC
**
** This file implements the API for access to some of the Spybotics
ROM
** routines that do NOT need variable or timer space.
**
** Translated from the Lego Spybotics ROM documentation to NQC
** by Mark Ferris (markdf2001@yahoo.com)
**
*/

#if defined(__SPY)

// The following routines are defined in this file
//SendRCXMessgae
//Action
//BasicMove
//FancyMove
//RandomMove
//SlowDownMove
//SpeedUpMove
//Disp


// Sends an RCX PBMessage to RCX or Scout
// nMessage = 1 - 255
__nolist void SendRCXMessage (const int nMessage)
{
  asm { 0xe3, &nMessage };
  asm { 0x17, 37 };
  asm { 0x01, 1 };
}

// nSound is 0-79, -1 = no sound
// nDisplay is LED animation (0-15) to play, -1 = no animation
// nMovement is from the *Move routines defined below, -1 = no move
// nRepeat is number of times to repeat motion
// ntime is in 10ms steps
__nolist void Action (const int nSound, const int nDisplay,
                      const int nMovement, const int nRepeat,
                      const int nTime)
{
  asm { 0xe3, &nSound };
  asm { 0xe3, &nDisplay };
  asm { 0xe3, &nMovement };
  asm { 0xe3, &nRepeat };
  asm { 0xe3, &nTime };
  asm { 0x17, 44 };
  asm { 0x01, 5 };
}

// defines for move
#define moveForward    0x0101
#define moveBackward   0x0102
#define moveSpinLeft   0x0103
#define moveSpinRight  0x0104
#define moveTurnLeft   0x0105
#define moveTurnRight  0x0106
#define moveAvoidLeft  0x0107
#define moveAvoidRight 0x0108
#define moveRest       0x0109
#define moveStop       0x010a
// time is in 10ms steps
__nolist void BasicMove (const int move, const int time)
{
  asm { 0xe3, &move };
  asm { 0xe3, &time };
  asm { 0x17, 43 };
  asm { 0x01, 2 };
}

// defines for move
#define moveZigZag      0x0301
#define moveShake       0x0302
#define moveScan        0x0303
#define moveStep        0x0304
#define moveStepBack    0x0305
#define moveSearch      0x0306
#define moveFakeLeft    0x0307
#define moveRakeRight   0x0308
#define moveBugForward  0x0309
#define moveLazy        0x030a
#define moveWalk        0x030b
#define moveWalkBack    0x030c
#define moveDance       0x030d
// time is in 10ms steps
__nolist void FancyMove (const int move, const int time)
{
  asm { 0xe3, &move };
  asm { 0xe3, &time };
  asm { 0x17, 47 };
  asm { 0x01, 2 };
}

// defines for move
#define moveRandomForward      0x0201
#define moveRandomBackward     0x0202
#define moveRandomSpinLeft     0x0203
#define moveRandomSpinRight    0x0204
#define moveRandomTurnLeft     0x0205
#define moveRandomTurnRight    0x0206
#define moveRandomRest         0x0207
// time is in 10ms steps
__nolist void RandomMove (const int move, const int time)
{
  asm { 0xe3, &move };
  asm { 0xe3, &time };
  asm { 0x17, 46 };
  asm { 0x01, 2 };
}

// defines for move
#define moveForwardSlowDown     0x0401
#define moveBackwardSlowDown    0x0402
#define moveSpinLeftSlowDown    0x0403
#define moveSpinRightSlowDown   0x0204
// time is in 10ms steps
__nolist void SlowDownMove (const int move, const int time)
{
  asm { 0xe3, &move };
  asm { 0xe3, &time };
  asm { 0x17, 48 };
  asm { 0x01, 2 };
}

// defines for move
#define moveForwardSpeedUp      0x0501
#define moveBackwardSpeedUp     0x0502
#define moveSpinLeftSpeedUp     0x0503
#define moveSpinRightSpeedUp    0x0504
// time is in 10ms steps
__nolist void SpeedUpMove (const int move, const int time)
{
  asm { 0xe3, &move };
  asm { 0xe3, &time };
  asm { 0x17, 49 };
  asm { 0x01, 2 };
}

__nolist void Disp (const int nDisplay)
{
  asm { 0xe3, &nDisplay } ;
  asm { 0x17, 42 };
  asm { 0x01, 1 };
}
#endif



1 Message 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