Main Page | Data Structures | File List | Data Fields | Globals

gfx.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003 GFX - a small graphics library 
00004 
00005 Copyright (C) 2004  Rafael de Oliveira Jannone
00006 
00007 This library is free software; you can redistribute it and/or
00008 modify it under the terms of the GNU Lesser General Public
00009 License as published by the Free Software Foundation; either
00010 version 2.1 of the License, or (at your option) any later version.
00011 
00012 This library is distributed in the hope that it will be useful,
00013 but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015 Lesser General Public License for more details.
00016 
00017 You should have received a copy of the GNU Lesser General Public
00018 License along with this library; if not, write to the Free Software
00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021 Contact the author:
00022         by e-mail : rafael AT jannone DOT org
00023         homepage  : http://jannone.org/gfxlib
00024         ICQ UIN   : 10115284
00025 
00026 See the License at http://www.gnu.org/copyleft/lesser.txt
00027 
00028 =========================================================================*/
00029 
00033 // GFX.H : main library functions (header)
00034 
00035 /* === WARNING ==
00036 
00037         This is a work-in-progress, meaning that most of this code is unstable
00038         and it's subject to future changes.  Also, most of it is very hackish,
00039         not properly cleaned up nor tested.
00040 
00041    === WARNING == */
00042 
00043 #ifndef GFX_H
00044 #define GFX_H
00045 
00046 #include "defs.h"
00047 
00048 // --- library functions / enums
00049 
00052 
00053 
00055 enum video_mode {
00056         mode_0 = 0x6C,
00057         mode_1 = 0x6F,
00058         mode_2 = 0x72,
00059         mode_3 = 0x75
00060 };
00061 
00063 enum screen_map {
00064         place_1 = 1,
00065         place_2 = 2,
00066         place_3 = 4,
00067         place_all = 255
00068 };
00069 
00071 #define MODE2_MAX       (256 * 24)
00072 
00074 #define MODE2_ATTR      (8192)
00075 
00077 #define MODE2_WIDTH     256
00078 
00080 #define MODE2_HEIGHT    192
00081 
00082 // VDP and VRAM functions
00083 
00085 extern void set_mode(u_int mode);
00086 
00088 extern void set_mangled_mode();
00089 
00091 extern void set_color(u_char front, u_char back, u_char border);
00092 
00094 extern void fill(u_int addr, u_char value, u_int count);
00095 
00097 extern void vpoke(u_int addr, u_char value);
00098 
00100 extern u_char vpeek(u_int addr);
00101 
00103 extern void vmerge(u_int addr, u_char value);
00104 
00106 extern void vwrite(void* source, u_int dest, u_int count);
00107 
00109 extern void vread(u_int source, void* dest, u_int count);
00110 
00112 extern void set_vdp(u_char reg, u_char value);
00113 
00115 extern u_char get_vdp(u_char reg);
00116 
00118 extern void locate(u_char x, u_char y);
00119 
00120 
00121 // primitives (not many yet :))
00122 
00124 extern void fill_v(u_int addr, u_char value, u_char count);
00125 
00127 extern void pset(int x, int y);
00128 
00129 
00130 // mangled mode chars
00131 
00133 void set_char_form(char c, void* form, u_char place);
00134 
00136 void set_char_attr(char c, void *attr, u_char place);
00137 
00139 void set_char_color(char c, u_char color, u_char place);
00140 
00141 // set char \a c shape, attributes and color, all in one
00142 void set_char(char c, void* form, void *attr, u_char color, u_char place);
00143 
00145 
00146 
00148 
00149 
00151 typedef struct {
00152         u_char y;       
00153         u_char x;       
00154         u_char handle;  
00155         u_char color;   
00156 } sprite_t;
00157 
00159 enum sprite_mode {
00160         sprite_default = 0,
00161         sprite_scaled = 1,
00162         sprite_large = 2
00163 };
00164 
00166 extern void set_sprite_mode(u_char mode);
00167 
00168 /*
00169 
00170 // this is not compiling... I suggest some #define's instead
00171 
00172 extern void *set_sprite(u_char, void*);
00173 extern void *put_sprite(u_char, int, int, u_char, u_char);
00174 */
00175 
00177 extern void set_sprite_8(u_char handle, void* data);
00178 
00180 extern void set_sprite_16(u_char handle, void* data);
00181 
00183 extern void put_sprite_8(u_char id, int x, int y, u_char handle, u_char color);
00184 
00186 extern void put_sprite_16(u_char id, int x, int y, u_char handle, u_char color);
00187 
00189 
00190 
00191 // surface
00192 // FIXME: this is not usable right now
00193 
00195 typedef struct {
00196         int width;
00197         int height;
00198         int type;
00199         union {
00200                 u_char* ram;    
00201                 u_int vram;
00202         } data;
00203 } surface_t;
00204 
00205 enum surface_type {
00206         surface_ram,
00207         surface_vram    
00208 };
00209 
00210 typedef struct {
00211         int x, y;
00212         int width, height;
00213 } rect_t; 
00214 
00215 extern void blit(surface_t *source, surface_t *dest, rect_t *from, rect_t *to);
00216 extern void blit_ram_vram(u_char* source, u_int dest, u_char w, u_char h, int sjmp, int djmp);
00217 extern void blit_fill_vram(u_int dest, u_char value, u_char w, u_char h, int djmp);
00218 
00219 
00221 
00222 
00223 enum stick_direction {
00224         st_up = 1,
00225         st_right = 2,
00226         st_down = 4,
00227         st_left = 8
00228 };
00229 
00230 extern u_char st_dir[];
00231 
00233 extern u_char get_stick(u_char id);
00234 
00236 extern bool get_trigger(u_char id);
00237 
00239 
00240 
00243 
00244 
00246 extern void seed_rnd(int seed);
00247 
00249 extern u_char get_rnd();
00250 
00252 
00255 
00256 
00258 #define sound(reg, value)       psg_set(reg, value)
00259 
00261 #define psgT(hz)                ((int)(111760.0 / (hz)))
00262 
00263 enum {  
00264         chanNone = 0,   
00265         chan0 = 1,      
00266         chan1 = 2,      
00267         chan2 = 4,      
00268         chanAll = 7     
00269 };
00270 
00272 enum {
00273         envD = 0,       
00274         envU = 4,       
00275         envDD = 8,      
00276         envDUD = 10,    
00277         envDH = 11,     
00278         envUU = 12,     
00279         envUH = 13,     
00280         envUDUD = 14    
00281 };
00282 
00284 void psg_set(u_char reg, u_char value);
00285 
00287 u_char psg_get(u_char reg);
00288 
00290 void psg_init();
00291 
00293 void psg_tone(u_char channel, int period);
00294 
00296 void psg_noise(u_char period);
00297 
00299 void psg_volume(u_char channel, u_char volume);
00300 
00302 void psg_envelope(u_char waveform, int period, u_char channels);
00303 
00305 void psg_channels(u_char tone_channels, u_char noise_channels);
00306 
00308 u_char psg_tone_channels();
00309 
00311 u_char psg_noise_channels();
00312 
00314 
00315 #endif
00316 

Generated on Thu Mar 3 19:55:02 2005 for GFX lib by  doxygen 1.4.1