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 / 401
400  |  402
Subject: 
Re: Problems with FindWorld() function
Newsgroups: 
lugnet.robotics.spybotics
Date: 
Thu, 9 Jun 2005 21:20:45 GMT
Viewed: 
8052 times
  
In lugnet.robotics.spybotics, John Hansen wrote:
In lugnet.robotics.spybotics, John Hansen wrote:
In lugnet.robotics.spybotics, Wolfgang Heinrich wrote:
I'm not sure if this is a bug in NQC (or in the firmware ?!?) or if I do
something wrong. Can anybody help?

The code generated by NQC appears to be correct.

Nope.  NQC is definitely generating bad code.  My apologies.  I will fix it
right away.


The Spybot LASM Opcode documentation for this opcode is just plain wrong.  It
says that the command structure is 6 bytes.  The first byte is the opcode 0xd5.
The second byte is the variable number.  The third byte is the "find source"
(relation table sources 43-49).  The fourth byte is the "find criteria" and it
says 0 is '>', 1 is '<', 2 is '=', and 3 is '<>'.  The fifth byte is "find
threshold" source and the sixth byte is "find threshold" value.

If that is how this opcode really worked then the NQC code generation would be
correct.  In reality, this opcode combines the fourth and fifth bytes together
and uses two bytes for the "find threshold" value.  The fourth byte has 0x00 for
'>', 0x40 for '<', 0x80 for '=', and 0xc0 for '<>'.  These values are logically
ANDed with the "find threshold" source value (which is less than 0x3f).

I can get it to work for constant or variable threshold values quite easily so
that will be my initial change.  While you wait for a fixed API function you can
use this one instead:

__nolist void FindWorldFixed(int &v, const int relsrc, const int crit, const
int& thresh)
{
  asm { 0xd5, $v : 0x3000001, 0x2a + relsrc, (crit * 0x40) + __type(thresh),
$thresh : __ASM_NO_TYPE };
}

John Hansen
P.S. a fixed NQC (3.1r2) is at http://bricxcc.sourceforge.net/swan_test.zip



Message is in Reply To:
  Re: Problems with FindWorld() function
 
(...) Nope. NQC is definitely generating bad code. My apologies. I will fix it right away. John Hansen (19 years ago, 9-Jun-05, to lugnet.robotics.spybotics)

4 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