Subject:
|
Yet another NQC spybot API submission
|
Newsgroups:
|
lugnet.robotics.rcx.nqc
|
Date:
|
Thu, 16 Oct 2003 01:05:31 GMT
|
Viewed:
|
5558 times
|
| |
| |
Here is another submission to the NQC spybot API. I haven't properly tested
this against an actual Spybot but I have compared the NQC output code to what is
generated by MindScript and documented in the VPB help file.
#define SOUNDEFFECT __res 2
#define GateOn(o, p) 0x62, p, o
#define GateOff 0x70
#define Glide(s, p, t) 0x45, t, s >> 8, s & 0xFF, p >> 8, p & 0xFF
#define Vibrato(s, p, t) 0x55, t, s >> 8, s & 0xFF, p >> 8, p & 0xFF
#define WaitEffect(t) 0x21, t
#define FixedWaitEffect(t) 0x81, t
#define Tone(f, t) 0x33, t, f >> 8, f & 0xFF
#define FixedTone(f, t) 0x93, t, f >> 8, f & 0xFF
#define RepeatEffect 0x10
#define AnimateLED(f, t) f, t
#define RepeatAnimation 0xFF, 0
#define EffectSound() @(0x350000) // Sound Effects control registers (0,1)
#define EffectTime() @(0x350001)
__nolist void SetEffectSound(const int &s) { Set(EffectSound(), s); }
__nolist void SetEffectTime(const int &t) { Set(EffectTime(), t); }
Adding the above to spy.nqh lets you write a program that looks like this:
#include "spy.nqh"
SOUNDEFFECT my_effect {
GateOn(1, 10),
Glide(294, 660, 60),
GateOff,
RepeatEffect
};
SOUNDEFFECT trill {
GateOn(1, 10),
Tone(1000, 50),
GateOn(1, 5),
Tone(2000, 50),
RepeatEffect
};
SOUNDEFFECT beep {
Tone(440, 5),
WaitEffect(5),
FixedTone(880, 5)
};
ANIMATION my_animation {
AnimateLED(nLedRed1, 10) ,
AnimateLED(nLedRed2, 10) ,
AnimateLED(nLedRed3, 10) ,
AnimateLED(nLedRed2, 10) ,
RepeatAnimation
};
ANIMATION animation2 {
AnimateLED(nLedRed1, 10) , // nLedRed1 = 0x01
AnimateLED(nLedRed2, 10) , // nLedRed2 = 0x02
AnimateLED(nLedRed3, 10) , // nLedRed3 = 0x04
AnimateLED(nLedRed2, 10)
};
task main()
{
SetAnimation(my_animation);
// PlaySound(my_effect);
// PlaySound(trill);
SetEffectSound(100);
PlaySound(beep); Wait(200);
SetEffectSound(200);
PlaySound(beep); Wait(200);
}
Try it out if you get a chance and let me know what you think.
John Hansen
|
|
Message has 2 Replies: | | Re: Yet another NQC spybot API submission
|
| I forgot to cross-post this to the spybotics newsgroup. My apologies for the double post. Here is another submission to the NQC spybot API. I haven't properly tested this against an actual Spybot but I have compared the NQC output code to what is (...) (21 years ago, 16-Oct-03, to lugnet.robotics.spybotics)
|
6 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|