NewI\O API
/******************************************************************************
*
* nio_lib.c
*
* Copyright (C) 2002, 2005 Chris Nystrom
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lessor General Public License as published
* by the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but without any warranty whatsoever.
*
* For more license information see:
*
* http://www.gnu.org/copyleft/lessor.html
*
* Contact Author at:
*
* Chris Nystrom
* 11013 Prairie Dove Circle
* Austin, Texas 78758
*
* E-Mail: cnystrom@gmail.com
* Blog: http://conversazione.blogspot.com
* AIM: nystromchris
*
* Soli Deo Gloria
*
*/
#ifndef _NIO_LIB_H
#define _NIO_LIB_H
#include
#ifndef _TYPES_H
#include "types.h"
#endif
#ifndef _MOUSE_H
#include "mouse.h"
#endif
#ifndef _NIO_COLORS_H
#include "colors.h"
#endif
#ifndef _NIO_FONT_H
#include "nio_font.h"
#endif
#ifndef _ASCII_KEY_H
#include "ascii_key.h"
#endif
#define NIO_LIB_VER "0.04"
#ifndef EOF
#define EOF (0)
#endif
#define MAX_STR_LEN (256)
#define MAX_ALPHA (0)
#define NO_ALPHA (255)
#define NO_FILL (0)
#define FILL (1)
#define NO_UPDATE (0)
#define UPDATE (1)
#define CURRENT_MOUSE_LOC (-1)
// Useful typedefs
typedef char nio_string[MAX_STR_LEN];
typedef struct {
int x;
int y;
} nio_point;
// *********** NIO Routines **********
// Control Functions
void nio_app_init(const char *app_name, const char *app_ver);
void nio_exit(void);
// stdio Functions
void nio_char_to_stdout(int c);
void nio_string_to_stdout(const char *s);
void nio_int_to_stdout(int i);
void nio_printf_to_stdout(char *format, ...);
// I/O Functions
int nio_get_char(bool b);
int nio_get_key(void);
int nio_get_key_val(void);
void nio_put_char(int c, int update);
int nio_get_string(char *s, int lim);
void nio_print(const char *s, int update);
void nio_printf(int update, char *format, ...);
void nio_print_at(int x, int y, const char *s, int update);
void nio_printf_at(int x, int y, int update, char *format, ...);
void nio_input(const char *s1, char *s2, int str_len);
void nio_pause(const char *s);
// Mouse I/O functions
mouse_state nio_mouse_state(void);
mouse_state nio_mouse_click(void);
mouse_state nio_mouse_info(void);
// System Command Functions
void nio_system_local(const char *s);
void nio_system_remote(const char *s);
// Color Functions
color nio_get_color(const char *s);
color nio_get_color_rgb(int red, int green, int blue);
color nio_get_rand_color(void);
bool nio_color_equal(color c1, color c2);
// Font Functions
int nio_load_font(const char *filename, int point_size, int style,
color fg, color bg);
int nio_load_sys_font(int system_font, int point_size, int style,
color fg, color bg);
void nio_free_font(int font_num);
// Text Functions
void nio_draw_text(int font_num, int x, int y, const char *s, int update);
void nio_draw_textf(int font_num, int x, int y, int update, char *format,
...);
// Screen functions
nio_point nio_get_screen_size(void);
void nio_set_screen(int x, int y, color bg);
void nio_clear_screen(color bg, int update);
// Drawing functions
void nio_paint(void);
void nio_draw_rectangle(int x, int y, int width, int height,
const char *color, int alpha, bool fill, int update);
void nio_draw_rectangle_rgb(int x, int y, int width, int height, color c,
int alpha, bool fill, int update);
void nio_draw_rectangle_rand(int x, int y, int width, int height, int alpha,
bool fill, int update);
void nio_draw_point(int x, int y, const char *color, int update);
void nio_draw_point_rgb(int x, int y, color c, int update);
void nio_draw_point_rand(int x, int y, int update);
void nio_draw_line(int x1, int y1, int x2, int y2, const char *color,
int alpha, int update);
void nio_draw_line_rgb(int x1, int y1, int x2, int y2, color c,
int alpha, int update);
void nio_draw_line_rand(int x1, int y1, int x2, int y2, int alpha, int update);
void nio_draw_arc(int x, int y, int r, const char *color, int alpha, bool fill,
int update);
void nio_draw_arc_rgb(int x, int y, int r, color c, int alpha, bool fill,
int update);
void nio_draw_arc_rand(int x, int y, int r, int alpha, bool fill, int update);
// Sound functions
void nio_sound(int status);
void nio_beep(void);
void nio_load_music(const char *filename);
void nio_play_music(int loops);
void nio_stop_music(void);
bool nio_music_playing(void);
int nio_load_sound(const char *filename);
void nio_play_sound(int sound_num, int loops);
void nio_free_sound(int i);
// Movie functions
void nio_load_movie(const char *filename, int x, int y);
void nio_play_movie(void);
// Image functions
int nio_load_image(const char *filename);
int nio_load_image_colorkey(const char *filename, int color_key, color c);
void nio_draw_image(int image_num, int x, int y, int update);
void nio_free_image(int i);
void nio_term_init(int font_num, color c, int x_home, int y_home,
int maxrow, int maxcol);
void nio_cursor(int i);
/*********************/
/* NIO Rand Routines */
/*********************/
#ifndef RAND_MAX
#define RAND_MAX 32767
#endif
void randomize(void);
int nio_rand_int(int i);
bool nio_rand_bool(void);
// Tuneable
#define DEFAULT_WRITE_WAIT (20000)
PUBLIC void nio_set_write_wait(unsigned int i);
// Key/Button States
enum { PRESSED = 0x01, RELEASED = 0x00 };
// Sound status
enum { ON = 0x01, OFF = 0x00 };
void nio_start_ticks(void);
int nio_get_ticks(void);
#endif /* _NIO_LIB */
