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

ex2.c

00001 /*=========================================================================
00002 
00003 GFX EXAMPLE CODE - #2
00004         "random faces"
00005 
00006 Copyright (C) 2004  Rafael de Oliveira Jannone
00007 
00008 This example's source code is Public Domain.
00009 
00010 WARNING: The author makes no guarantees and holds no responsibility for 
00011 any damage, injury or loss that may result from the use of this source 
00012 code. USE IT AT YOUR OWN RISK.
00013 
00014 Contact the author:
00015         by e-mail : rafael AT jannone DOT org
00016         homepage  : http://jannone.org/gfxlib
00017         ICQ UIN   : 10115284
00018 
00019 =========================================================================*/
00020 
00021 #include <stdlib.h>
00022 #include "gfx.h"
00023 
00024 main() {
00025         u_char g[8];
00026         u_int addr;
00027         int c;
00028         u_char buf[256];
00029 
00030         set_color(15, 1, 1);
00031 
00032         // set video mode to screen 2
00033         set_mode(mode_2);
00034 
00035         // define smiley face :)
00036         g[0] = 60;
00037         g[1] = 66;
00038         g[2] = 165;
00039         g[3] = 129;
00040         g[4] = 165;
00041         g[5] = 153;
00042         g[6] = 66;
00043         g[7] = 60;
00044 
00045         // draw the smiley shape over the entire buffer
00046         for (c=0; c<256; c++)
00047                 buf[c] = g[c & 7];
00048         
00049         // set whole screen to color black
00050         fill(0x2000, 0x11, MODE2_MAX);
00051 
00052         // blit the buffer for each "line", as a smiley pattern for the whole screen
00053         for (c = 0; c < 24; c++)
00054                 vwrite(buf, c * 256, 256);
00055 
00056         while (!get_trigger(0)) {
00057                 // randomly color one chosen smiley
00058                 c = rand() & 15;
00059                 addr = (rand() % MODE2_MAX) & ~(7);
00060                 fill(MODE2_ATTR + addr, c << 4, 8);
00061         }       
00062 
00063         set_mode(mode_0);
00064 }

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