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

ex6.c

00001 /*=========================================================================
00002 
00003 GFX EXAMPLE CODE - #6
00004         "mangled screen"
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 <stdio.h>
00022 #include "gfx.h"
00023 
00024 #asm
00025 psect data
00026 
00027 global _diamond
00028 _diamond:
00029         defb    00010000B
00030         defb    00111000B
00031         defb    01011100B
00032         defb    11111110B
00033         defb    01110100B
00034         defb    00111000B
00035         defb    00010000B
00036         defb    00000000B
00037 
00038 global _diamond_attr
00039 _diamond_attr:
00040         defb    070H
00041         defb    070H
00042         defb    070H
00043         defb    0F0H
00044         defb    050H
00045         defb    050H
00046         defb    050H
00047         defb    000H
00048 
00049 #endasm
00050 
00051 extern u_char diamond[8];
00052 extern u_char diamond_attr[8];
00053 
00054 main() {
00055         int d;
00056         int x, y;
00057 
00058         set_color(15, 1, 1);
00059         set_mangled_mode();
00060 
00061         set_sprite_mode(sprite_default);
00062 
00063         // set char '&' to a diamond shape WITH colors (attributes)
00064         set_char('&', diamond, diamond_attr, 0, place_all);
00065 
00066         // also set sprite 0 with the diamond shape
00067         set_sprite_8(0, diamond);
00068 
00069         // print the '&' in the middle of the screen
00070         vpoke(6144 + 32 * 12 + 16, '&');
00071 
00072         while (!get_trigger(0)) {
00073                 // show the sprite into whatever position the joystick is pointing
00074                 d = get_stick(0);
00075                 switch (d) {
00076                         case 0: x = 0; y = 0; break;
00077                         case 1: x = 0; y = -16; break;
00078                         case 2: x = 16; y = -16; break;
00079                         case 3: x = 16; y = 0; break;
00080                         case 4: x = 16; y = 16; break;
00081                         case 5: x = 0; y = 16; break;
00082                         case 6: x = -16; y = 16; break;
00083                         case 7: x = -16; y = 0; break;
00084                         case 8: x = -16; y = -16; break;
00085                 }
00086                 put_sprite_8(0, 128 + x, 96 + y, 0, 15);
00087         }
00088 
00089         set_mode(mode_0);
00090 }
00091 

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