00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include "net/ea/protocol.h"
00023
00024 #define LOBYTE(w) ((unsigned char)(w))
00025 #define HIBYTE(w) ((unsigned char)(((unsigned short)(w)) >> 8))
00026
00027 void set_coordinates(char *data,
00028 unsigned short x,
00029 unsigned short y,
00030 unsigned char direction)
00031 {
00032 short temp;
00033 temp = x;
00034 temp <<= 6;
00035 data[0] = 0;
00036 data[1] = 1;
00037 data[2] = 2;
00038 data[0] = HIBYTE(temp);
00039 data[1] = (unsigned char)(temp);
00040 temp = y;
00041 temp <<= 4;
00042 data[1] |= HIBYTE(temp);
00043 data[2] = LOBYTE(temp);
00044
00045
00046 switch (direction)
00047 {
00048 case 1:
00049 direction = 0;
00050 break;
00051 case 3:
00052 direction = 1;
00053 break;
00054 case 2:
00055 direction = 2;
00056 break;
00057 case 6:
00058 direction = 3;
00059 break;
00060 case 4:
00061 direction = 4;
00062 break;
00063 case 12:
00064 direction = 5;
00065 break;
00066 case 8:
00067 direction = 6;
00068 break;
00069 case 9:
00070 direction = 7;
00071 break;
00072 default:
00073
00074 direction = (unsigned char)-1;
00075 }
00076 data[2] |= direction;
00077 }