.,=====;          __   ,--
      ,==/'   ||         -"  _ /==+-.
      ||-.   |`|          _,-' ||-+ |
      ,|  \ /  `|       -='| .  `=/"
     ,/   /`-,  `:       _/--+\  /\  /.
     |;-="    \_ '. ,         _/" |.`-',:\
    /'            `='              `-=-''
                WIND SOUL

      A game programming library Base On DirectX

                By Cloud Wu 1999
 
       http://member.netease.com/~cloudwu
	   mailto:cloudwu@263.net

       Thanks 三维鹰 (haiyingxu@263.net) 
       translate this document into English 


WindSoul: User's Guide



Getting started

WindSoul recommend you to use Visual C++ 6.0. To use WindSoul programming base, please do as follows:

Installation:

  1. Please unpack the source code and catalog to a given directory (such as C:\WindSoul, next we will regard this as default)
  2. Open the workspace file(i.e. WS.DSW) in Visual C++ 6.0.
  3. Set the constants about VGA and your programing name etc in wssetup.h. Only high fullscreen mode is supported, so please don't modify other set parameters. Generally, the default values can be used.
  4. Compile the project WindSoul in DEBUG mode and RELEASE mode seperately.(To do this, choose from menu Build\Set Active Configuration, pick WindSoul, then press F7 to compile)
  5. Set the evironment in Visual C++ 6.0, add Include directory C:\WindSoul\Include in Tools/Options/Directories, add WindSoul lib directory .

How to use WindSoul:

  1. Reference to the additional examples. Create new project (File/New/Project/Win32 Application), set the needing linking libraries. In Debug version these are: wsdebug.lib user32.lib gid32.lib winmm.lib ddraw.lib dsound.lib dinput.lib dxguid.lib . In Release version, replace wsdebug.lib with windsoul.lib

    If you want the network support, please install DirectX 6.0 SDK, and link dplayx.lib, dplay.lib and ole32.lib in your program.

  2. In your program, there must be windsoul.h header file.
  3. create three function:

    wsInit() there are initializing code in it. You needn't initialize the hardware, however, you must finish the starting code of your game.

    wsMain() this is the main loop of your game. WindSoul will repeat calling it !!!! with every operation on screen, please operate the screen bitmap directly. At the end of this function, please call the funtion update_screen(), this will refresh the screen bitmap to actual screen. Of course, if you don't like the loop supporting by WindSoul library, you can create your loop in this function. When you want to end the program, please return a non-zero value. If the return value is zero, this function will be repeated.

    wsExit() when you return a non-zero value, this function will be executed to finish the work when you exit with your program, and then end the program.

  4. If you want to create your icon in the program, please add a .RC file in your project file with this: WS_ICON ICON windsoul.ico. then add windsoul.ico to your project file.

Back to Top

About the Programming Library

install (module name )

This is an important macro. You can load your own module with it without to worry about unusable module will be linked to your exe file. It can prevent your final program from having too many rabbish code. What's more, you can expand WindSoul.

Available modules now:

note: all the module loadings must be added prior to the function wsInit(). Some modules are related to each other, e.g. you must load input before load joystick.

If you want to expand WindSoul, your module must consist of three functions:

int init _module name(void) initializes the module, returning zero means successful.

void free_module name(void) to free the module

void active_module name(int) to do sth when you toggle your actions. If the parameter is non-zero, the status is active.

If you dont need free or active status, please define their macro to NULL.

void update_screen(void) display the bitmap in back buffer to screen.

void set_update_area(int start,int height) sets the range of refreshing( from the start to height)

void lock_screen(void) maps the screen to directscreen structure, then deal with the directscreen as general bitmap. Note: lock time can't be too long, and it's forbiden to call update_screen() when locking.

void unlock_screen(void) ends the operation on drawing to screen.

int show_fps(BMP *bmp, int r, int c) at the position (0,0) in bitmap bmp, displays current frame number (in color c), if r is 1, refreshes the fps value. If 0, continues calling the frame number, returning in last time and then stop the displaying (if you call after update_screen(), then it disappears in 1 second) note: if you set #define FPS in fps.c file, the frame number of every second during the program will be recorded at fps.txt file in the current directory.

char FailMsg(char *s) displays the error information, and end the program, return FALSE.

void set_window_title(char *s) sets the title of the window.

void set_update_mode(int mode) sets the refreshing mode value as follows:

CONSTANT:

BMP *screen back-buffer bitmap used by the library.

BMP *directscreen direct screen-mapping bitmap

int is555 if its value is 1, it means that the video card is RGB 555 mode.

int isMMX if its value is 1, it means that CPU supporting MMX instruct sets

Back to Top

Bitmap

WindSoul's graphics are based on bitmap structure. The structure definition is as follows:

typedef struct {
	int w,h,pitch;    
	int cl,ct,cr,cb;  
	                  
	PIXEL *line[1];   
} BMP;

You can directly visit the data in bitmaps, i.e.

   BMP *bmp;
   bmp->line[10][10] means the color of point (10,10).

The top-left corner of the bitmap is (0,0), bottom-right is (w-1,h-1). All the functions below are affected by a cliprectangel exept the functions noted. The cliprectangle is a rectangle between (cl,ct) and (cr,cb), including point (cl,ct) not (cr,cb). All operations out of this rectangle will be ignored, but you must make sure the cliprectangle is in the area of the actual bitmap.

BMP *create_bitmap(int w,int h) Creates a bitmap of size (w*h), return the point to this bitmap, if creation is failed, then return NULL.

BMP *create_sub_bitmap(BMP *fbmp,int x,int y,int w,int h) Creates a bitmap of size (w*h), it is a part of the parent bitmap fbmp from point (x,y), return the point of this bitmap. If failed, return NULL.

BMP *create_mirror_bitmap(int w,int h) Creates a structure of (w*h) bitmap without actual data room. return the point of this bitmap if success, else, return NULL.

void destory_bitmap(BMP *a)

Free the memory of bitmap.

 

void clear_bitmap_ex(BMP *bmp, int color)
  Fill the cliprectangle of the bitmap with color.

clear_bitmap(BMP *bmp) It's the simple calling macro of the above function, fill the bitmap with transparent color. Note: the transparent color is pink. Both 565 mode and 555 mode must be 0xf81f.

void blit_bitmap(BMP *src, BMP *des, int x1, int y1, int x2, int y2, int w, int h) Bitmap transportation. transport (x1,y1)-(x1+w,x2+h) of src to (x2,y2)-(x2+w,x2+h) of des. Note: (x1,y1)-(x2,y2) means including (x1,y1) not (x2,y2).

void blit_mask_bitmap(BMP *src, BMP *des, int x1, int y1, int x2, int y2, int w, int h) Examines the bitmap transportation in transparent color. Looks at the points on src, if it is transparent(pink), then it will not be copied to des.

void additive_blit(BMP *back, BMP *sprite, int x, int y) Transport a bitmap by ADDITIVE mode( Select the mode as draw_sprite)

void copy_bitmap(BMP *src, BMP *des)
  Copy a bitmap from src to des rapidly. des must be build before and has the same size with src. This function doesn't examine cliprectangle.

void clearall_bitmap(BMP *bmp)

Remove the bitmap to transpatent color in a quick way.

Back to Top

sprite

Normal sprite is a bitmap(BMP). WindSoul also support 16bit RLE sprite, it has compressed space in it, so it has quick operation speed. Its structure is straight forward:

typedef struct {
	int w,h;			
	int x,y;			
	unsigned short line[1]; 
} RLESPRITE;

All the sprite function are affected by transparent color.

void set_alpha(int a) Set the degree of the transparence for drawing sprite. If you want only half-transparent, then you needn't to control the level of transparence. In addition, ADDITIVE mode can be used to process the lighting(set_alpha(ADDITIVE)). as to the non-compressed sprite, it is recommended to replace it with additive_blit.

void draw_sprite(BMP *back, BMP *sprite, int x, int y)

Support the sprite drawing in opacity from level 0 to level 8. 0 represents opaque, 8 see nothing.

void draw_sprite(BMP *back, BMP *sprite, int x, int y) In fact, this function is the same as blit_bitmap(sprite,back,0,0,x,y,sprite->w,sprite->h). That is, after set_alpha(0) , calling draw_sprite() .

RLESPRITE * create_rlesprite(BMP *sprite)
Create a RLE sprite, then copy the bitmap of this sprite in.

void destroy_rlesprite(RLESPRITE *a) Destroy a RLE sprite.

void draw_rlesprite(BMP *back, RLESPRITE *sprite, int x, int y); Drawing a RLE sprite with the opacity from 0 to 8.

void _draw_rlesprite(BMP *back, RLESPRITE *sprite, int x, int y);

opaque RLE sprite, equals draw_rlesprite() in level 0.

Back to Top

Edge

Edge is a special data structure to describe the alpha value along the outline of sprite. It is from the objects created with 3DS MAX, processed with antialising, get the alpha channel in the image. With the alpha-edge technology, the image in Windsoul will look more elegent.

EDGE structure is straight forward:

typedef struct {
	int w,h;		
	int x,y;		
	unsigned short *line[1];
} EDGE;

In data, a point is described by 4 bytes, the two first bytes is alpha level (32) and offset, the two last is the color data of points. Note: This structure is fit for describing curves, as to shadow with big area. Although reflected in the alpha channel, using the SHADOW structure is recommended.

EDGE *create_edge(BMP *bmp,BMP *alphabmp) You can create the sprite in WindSoul with 3DS MAX. Render the image to .TGA with the black background, and select the alpha channel. Now you have two images, one is solid, the other is alpha channel. Input the two bitmap to this function, you will get the EDGE structure. Meanwhile, the background of the solid bitmap will be transfered to MASKCOLOR for next time to create sprite with create_rlesprite() .

void destroy_edge(EDGE *a) Destroy an edge.

void draw_alphaedge(BMP *back, EDGE *sprite, int x, int y) Draw an alpha edge.

void draw_edge(BMP *back, EDGE *sprite, int x, int y, unsigned color) Draw an edge with color.

EDGE *load_ege(char *filename) loads an edge from files ( .ege)

int save_ege(EDGE *ege,char *name) save an edge to a file. Return 0 if success.

Back to Top

Shadow

SHADOW is actually a RLE sprite only with data header. It needs small memory with quick processing speed. Its structure is straight forward:

typedef struct {
	int w,h;			
	int x,y;			
	unsigned char *line[1];
} SHADOW;

SHADOW *create_shadow(BMP *bmp) Create a SHADOW structure, the need of source bitmap is the same with RLE sprite except for the color of point information.

void destroy_shadow(SHADOW *a) Destroy a SHADOW structure.

void draw_shadow(BMP *back, SHADOW *sprite, int x, int y) Draw an shadow, alpha=50%

void draw_lightshadow(SHADOW *sprite,int x,int y,int dark)

Draw a shadow in a light image (the light module must be loaded), can control the level of light. The smaller the dark value, the lighter the shadow.

SHADOW *load_sdw(char *filename) Load a shadow from a file (.sdw)

int save_sdw(SHADOW *sdw,char *name)

Save a shadow to a file, return 0 if success.

Back to Top

Lighting

Before using this, you must load install(light). To toggle to lighting refresh mode with set_update_mode(LIGHT_UPDATE).

The structure of lightmap is straight forward:

typedef struct {
	int w,h; 
	unsigned char *line[1];
} LIGHTMAP;

The width of the lightmap is only the half of the bitmap. The screen has a screen_lightmap(SCREENW/2,SCREENH). It will be added to the screen when it is refreshed.

LIGHTMAP *create_lightmap(int,int); Create a lightmap with the same width and height.

void destroy_lightmap(LIGHTMAP *a); Destroy a lightmap.

void draw_lightsprite(LIGHTMAP *sprite,int x,int y) Add the lightmap sprite on the screen lightmap.

void clear_lightmap(int light) Clear the screen with one light value.

LIGHTMAP *load_lmp(char *filename) Load a lightmap file(.lmp)

int save_lmp(LIGHTMAP *lmp,char *name) Save a lightmap to a file. If successful, return zero.

void draw_spritelum(RLESPRITE *sprite,int x,int y,int lum) Draw a RLE sprite with light value lum on the lightmap.

void draw_spriteshade(RLESPRITE *sprite,int x,int y,char *shade) Draw a RLE sprite with gradient light value on the lightmap. The gradient data is saved in array shade. The height of the RLE sprite is the half of the width.

Back to Top

Basic drawing function

void drawing_mode(int mode) Set the mode for drawing points (only available for basic drawing function, not for operation on blit, draw_sprite etc).

The value of mode is straight forward:

void xor_mode(void) toggle to the mode of xor.

void solid_mode(void) toggle to the mode of solid.

void trans_mode(void) toggle to the mode of trans.

void additive_mode(void) toggle to the mode of additive.

void vline(BMP *bmp, int x,int y1,int y2,unsigned color) draw a vertical line from (x,y1) to (x,y2) with the color of color.

void _vline(BMP *bmp, int x,int y1,int y2,unsigned color) the vline version that not affected by drawing mode.

void hline(BMP *bmp, int x1,int y,int x2,unsigned color) draw a horizontal line from (x1,y) to (x2,y) with the color of color.

void _hline(BMP *bmp, int x1,int y,int x2,unsigned color) the hline version that not affected by drawing mode.

void rect(BMP *bmp, int x1,int y1,int x2,int y2,unsigned color) draw a rectangle with the color of color.

void rectfill(BMP *bmp, int x1,int y1,int x2,int y2,unsigned color) fill a rectangle with the color of color. (x1,y1) is the top-left corner, (x2,y2) is the bottom-right corner. the operation includes these two points

void _rectfill(BMP *bmp, int x1,int y1,int x2,int y2,unsigned color) the rectfill version that not affected by drawing mode.

get_pixel(bmp,x,y) the macro same with (bmp)->line[(y)][(x)] ,so you must process trim yourself.

_put_pixel(bmp,x,y,c) the macro same with (bmp)->line[(y)][(x)]=(c) , so you must process trim yourself.

void put_pixel(BMP *bmp,int x,int y,int color) the function of drawing points to process trim.

void do_line(int x1, int y1, int x2, int y2, void (*proc)()) call proc() at each point along the line from (x1,y1) to (x2,y2). the parameters input to proc(int x, int y) are a set of ordinates.

void line(BMP *bmp,int x1, int y1, int x2, int y2,int color) draw a line from (x1,y1) to (x2,y2)

Back to Top

Keyboard Management

WindSoul has two ways to manage keyboard, one is real-time mode, the other is buffer mode.

int readkey() read a keyboard input in buffer mode, if the buffer is null, return zero, otherwise return the keyboard value. In the real-time mode, WindSoul created another thread to save the status of keyboard to keystat[256] by 20Hz. If one key is pressed down, you set 1 to the high position. Otherwise set 0. for example:

	if (keystat[KEY_ESC]&0x80) 
		FailMsg("ESC was pressed down");

The macro definition on key input is writed in the file windsoul.h

Back to Top

Mouse Management

MOUSECURSOR *create_cursor(int n,BMP **frame,int x,int y,int speed) Create a cursor. The cursor can be animatable, n describes the number of frame, x,y point out the hotsite of the cursor, speed definites the speed of playing animation.(the bigger the value, the slower the speed.)

void set_cursor(MOUSECURSOR *mc) Set mc as the current cursor, turn off the cursor with set_cursor(NULL) .

void destroy_cursor(MOUSECURSOR *mc) Destroy a cursor struture.

void autoshow_mouse(int a) If a is zero, then turn off the cursor automatically. Otherwise the cursor is turned on (this function is not available).

void show_mouse() You can use it to display the cursor immediatly. If the auto-display mode is off, system will update the cursor when update_screen(). Now only one way for mouse management is available, that is the real-time way. You can examine the global variable int mouse_x,mouse_y to get the position of the cursor at any time. unsigned char mouse_b0,mouse_b1 the high location represents the status (same with keyboard).

Back to Top

Joystick Management

Two structures are available in joystick management:

typedef struct JOYDATA{
	int Type;
	int Offset;
	unsigned long Data;
	unsigned long Time;
	unsigned long Number;
} JOYDATA;

typedef struct JOYSTATE{
	long x;
	long y;
	int button;
	unsigned char buttons[32];
} JOYSTATE;

int Joystick; This constant describes the number of joystick supported in WindSoul.

void GetJoystickInfo(int,struct JOYSTICKINFO *); Get the information about joystick.

int UseJoystick(int,int,int); Get supporting for one joystick.

void UnUseJoystick(int); Free one joystick. You neednt call it in the end of the program.

void GetJoyState(int,struct JOYSTATE *); Get the status about joystick.

void JoyPoll(int); Poll the joystick.

int GetJoyData(int,struct JOYDATA *); Get the data about the joystick.

void ClearJoyBuffer(int); Clear the buffer of joystick.

Back to Top

Bitmap Loading

BMP *load_bmp(char *filename) Load a non-compressed .bmp file with 24bit color or a 256 color pallete.

int save_bmp(BMP * bmp, char * name) Save a BMP structure bitmap to a .bmp file in 24bit true color mode. Return 0 when successful, else return -1.

BMP *load_b16(char *filename) Load a non-conpressed .bmp file in 16bit color.

int save_b16(BMP * bmp, char *filename) Save a BMP structure in 16bit true color mode. Return 0 if success, else return -1.

RLESPRITE *load_rle(char *filename) Load a RLE sprite file (.RLE).

int save_rle(RLESPRITE * sprite, char *filename) Save a RLE sprite to a file(.RLE)

unsigned short ture2hi(unsigned long) Transfer 24bit true color to high color, process 555 and 565 mode automatically referring to your video card.

unsigned short hi2ture(unsigned long) Transfer high color to 24bit true color.

Now only 8bit and 24bit non-compressed .bmp file is available , because WindSoul thinks that more formats are not suitable for this game.

Back to Top

Text Output

void set_fontcolor(unsigned color) Set the color for fonts.(given in 24bit mode)

int load_hzk(char *hzk) Load the Chinese font library (see the annex of WindSoul.) Return 0 if success, else return an negative value. If this function is not called, then the room for the Chinese font library will not been located.

void textout(BMP *bmp, char *buf, int x, int y, unsigned c) Output a character string.

void textprintf(BMP *bmp, int x, int y, unsigned color, char *format, ...) Output a character string in printf format.

void draw_hz(BMP *bmp,unsigned char *c,int x,int y) Draw a Chinese character at the position (x,y) on a bitmap. c is the pointer to Chinese font.

void draw_asc(BMP *bmp,char c,int x,int y) Draw a ASCII character c at the position (x,y) on a bitmap.

Global Variable:

unsigned short font_color=0xffff;

when initialized, it is 0xffff(white).

Back to Top

Sound Management

WindSoul has two sound: MUSIC and SAMPLE, but it doesnt support MIDI, so these sound actually are wave sound. Only one diffrence is that MUSIC is a sound stream and the data is saved in outter memory . MUSIC is read while it is played. SAMPLE is put into memory when loaded.

WindSoul must fix the format of WAV as 16bit 22khz stereo (next version will support one sound channel). The supporting of ADPCM 1:4 sound compressed will put into the next version.

Some constants are defined as follow:

SAMPLE* load_wav(char * name); Load a .wav file.

MUSIC* load_music(char *name);

Prepare a background sound file (also .wav file).

void destroy_sample(SAMPLE * wd); Destroy a SAMPLE.

void destroy_music(MUSIC * wd); Destroy a MUSIC.

int play_sample(SAMPLE *lpwave,int loop,int Pan,int Vol); Play a SAMPLE, loop is PLAYLOOP(repeat playing), Pan represent the position of left and right channel, Vol is the attenuation of sound volume(0 represents original sound).

void play_music(MUSIC *lpswave,int loop,long Pan,long Vol); Play a MUSIC, parameters is the same with play_sample.

void stop_sample(SAMPLE *lpwave); Stop playing a SAMPLE.

void stop_music(void); Stop playing the background sound.

void adjust_vol(long Vol); Adjust the total sound volume.

int adjust_sample(SAMPLE *lpwave,long Pan,long Volume); Adjust the Pan and Volume value of a SAMPLE.

int adjust_music(long Pan,long Volume); Adjust the Pan and Volume value of the background sound.

void sound_on(void); Turn off the sound.

void sound_off(void); Turn on the sound.

void music_on(void); Turn on the music.

void music_off(void); Turn off the music.

You can query the value of sound_init to know whether the sound setting is available in now system.

Back to Top

Data Package Management

WindSoul provides the management of data package for the data in this game. You can compress all the data in this game to a data file. You can process data package through this file as convenient as common file. If there is a single file with the same name out of this data file, data-package manager will process it as a common file in advance. The files in data package are located in 32bit ID . Searched by dimidiate method, so it has rapid speed.

DATAFILE *open_datafile(char *fname) Open a data file and set it current.

void close_datafile(DATAFILE *df) Close a data file. The parameter is the pointer of a data file.

void set_datafile(DATAFILE *df) Configue the current data file.

NOTE: WindSoul can open multiple data files at the same time, but only one file is active. This activation can tell you how to search files in opening operation. However, the opened compressed file can attach to the correct data package by itself. It will not be affected by active status.

void chvdir(char *s) You can save compressed files according to a virtual directory in data package file. This function can change the virtual directory.

PACKFILE *pack_fopen(char *filename) Open a compressed file. First, you must search to see if there is a single file with the same name in current diretory; Secondly, you can search in the active data package file. So when you don't use data packaging, you are recommended to use it to replace with fopen() in the condition of only reading.

void pack_fclose(PACKFILE *pf) Close a compressed file (the same with fclose() ).

unsigned pack_fread(void *buffer, unsigned size, PACKFILE *f) Read data from compressed files. It is the same with fread() except a parameter. This parameter is removed in this function. You can be told to read bytes.

unsigned pack_ftell(PACKFILE *f) Return the read pointer of compressed files(the same with ftell() )

void pack_fseek(PACKFILE *f, int offset, int org) Locate the read pointer of compressed files(the same with fseek() )

int pack_fsize(PACKFILE *f) Return the size of the file.

_________________________________________________________________________________

Follows are for friends that want further development:

void adjust_path(char *s) Adjust diretory( remove .., change\ to /, all in lower-case, only support .. to return the father directory, dont support ...)

void adjust_filename(char *s) Adjust the file name(add the virtual diretory auto)

unsigned filename2id(char *name) Change the file name to 32bit ID.

note: The original file name in data package is not remained but replaced by a 32bit ID. Before calling it, please adjust the filename with adjust_filename().

int compress ( void *in , unsigned in_len, void *out) Compress in_len bytes pointed by in to out and return the length after compressed. (maybe the data compressed is more than original data, so the buffer must retain 65/64+19 bytes of the length of the original data.

int decompress ( void *in , unsigned in_len, void *out) Decompress in_len bytes pointed by in to out. Return the length of data decompressed.

About data-packing:

There is only a simple packing program included in WindSoul. While packing, wspack needs to write the name of file to be packed in a .lst file. After that, pls run wsp datafile.dat listfile.lst to finish the packing procedure.

Friend MuFeng writed a wonderful data package management program. You can use it to manage the data package conveniently.

Friend LaoWang Created a beautiful interface for it.

These two program are not put in WindSoul. You can download them from my homepage:

Back to Top

Timer

Timer is used to optimize codes. It is so exact to record the time of 8.38e-6 s. Small timer is only 54ms (if you want to measure the frame number in game, lower than 18fps will not be usable)

Long timer can measure the time of one hour and be the same exact( the precision is decided by the clock in your mainboard, but there will be a relay to start long timer, maximum to 54ms)

void timer_on(void) Begin to time.

unsigned short timer_off(void) Stop time( return the time,not processed)

void ltimer_on(void) Begin to timer (long timer)

unsigned int ltimer_off(void) Stop time with long timer(return the time , not processed)

TIMER2MS(timer) a macro to transfer the time returned by timer_off to microsecond.

void cputimer_on(void) Turn on the Pentium clock timer.

__int64 cputimer_off(void) Turn off the clock timer( get 64bit integer)

Back to Top

Network Support

It's a scraft by Tdlife Peng

Structure and Constants:

struct NETDCONNAME{
	char * Name;
	int Type;
};

struct NETMESSAGE{
	DWORD dwType;
	union{
		DWORD Flags;
		DWORD size;
	};
	PLAYERID idFrom,idTo;
	DWORD dwCurrentPlayers;
	union{
		LPVOID data;
		char * message;
		char * ShortName;
	};
	union{
		char * LongName;
		LPDPSESSIONDESC2 desc;
	};
};

int NetDReady(int,struct NETDCONNAME **,int *); Get ready ( the ID of game, the list of connect name etc). Return 0 when success.

int NetDSetConnect(int); Select the way to connect, begin with 1. Return 0 when success.

int NetDUNConnect(void); Cut the connection. It is used in modem connecting.

int NetDGetSessions(char ***,int *); Get the current talking ( list of talking name, talking number) . Return 0 when success, returning 1 represents in connection. You must repeat calling this function until the return value <=0 .

int NetDJoinSession(int,PLAYERID *,char *,char *,int (* MessageProc)(struct NETMESSAGE *)); Add to talking( talking number, ID of gammer, shortname, fullname, pointer of message receiver) . Return 0 when success.

int NetDSend(struct NETMESSAGE *); Send the ID of message to the ID of gammer receiving message, data is address of message, size is the length of message. Return 0 when success.

int NetDSendChat(struct NETMESSAGE *); Send the ID of character message to the ID of gammer receiving message. message is a character string ending with 0. Return 0 when success.

int NetDClose(void); Close/quit talking. Return 0 when success.

int NetDEndJoin(void); Keep new gammer from adding . It is used by talking host. Return 0 when success.

int NetDEnumPlayer(int,void (*)(PLAYERID,char *,char *)); Search gammer( talking number, function pointer for calling ) .Search current talking if talking number is not yet used. NetDGetSessions() gets the talking range. Return 0 when success.

int NetDCreateSession(char *,int,PLAYERID *,char *,char *,void *); Create new talking (talking name, maximum gammer, ID of gammer, shortname, fullname, pointer of receiving message). Return 0 when success.

int NetDPlayerName(char *,char *); Change the name of gammer ( shortname, fullname) . Return 0 when success.

int NetDSessionName(char *); Change the name of talking. It is used by talking host. Return 0 when success.

void NetDSetPhone(char *); Set the phonecall number when connecting with modem.

void NetDSetIPAddress(char *); Set the address when connecting with TCP/IP.

void NetDSetComPort(int,int); Set the serial number when connecting with serial port. For example, 1 represents COM1, 2 represents COM2 etc.

supporting speed:

Back to Top

Debug

DEBUGINFO(int p,char *format,...)

If p is not 0, transfer the debug information out to wsdebug.txt (using the fprintf format).

As default, the Debug mode will get wsdebug.txt, DEBUGINFO is valid; In Release mode, DEBUGINFO is invalid. You can set in internal.h :

#define DEBUGINFOON

to force to open the Debug information out.

In the first line in ddraw.h, you can add :

#define OFFDD

To shield all the operations corresponding to DirectDraw and change to GUI screen. It is very easy for debugging. If your video card is 565 mode and you want to test if there is bug in 555 mode, you can add :

#define DEBUG555

and you can immunate 555 mode.

In other files, you also can set (in debug mode, this is opened automatically)

#define _DEBUG

then, the debug partion in these files will be opened, and the operation will be examined strictly to find faults in the program for you. For example, you open DEBUG in blit.c, if you want to operate a non existing bitmap, the system will tell you so by popping up the error information.

You can add in ddraw.c:

#define FPS

After ending your program, there will be a record of the number of fps in the same directory with exe file.

Back to Top

Power by云风工作室