Main Page   Modules   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

display-raw.h

00001 /* display-raw.h -- Graphics Display Manager
00002    Copyright 2003 Free Software Foundation, Inc.
00003    Written by Stephane Carrez (stcarrez@nerim.fr)
00004 
00005 This file is part of GEL.
00006 
00007 GEL is free software; you can redistribute it and/or modify
00008 it under the terms of the GNU General Public License as published by
00009 the Free Software Foundation; either version 2, or (at your option)
00010 any later version.
00011 
00012 GEL 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
00015 GNU General Public License for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with GEL; see the file COPYING.  If not, write to
00019 the Free Software Foundation, 59 Temple Place - Suite 330,
00020 Boston, MA 02111-1307, USA.  */
00021 
00022 #ifndef _GEL_DISPLAY_RAW_H
00023 #define _GEL_DISPLAY_RAW_H
00024 
00025 #include <sys/param.h>
00026 #include <stddef.h>
00027 
00028 #ifdef __cplusplus
00029 extern "C" {
00030 #endif
00031 
00037 
00038 extern const gdm_mask _gdm_bitmask[];
00039 
00040 extern const gdm_mask _gdm_start_mask[];
00041 
00042 extern const gdm_mask _gdm_end_mask[];
00043 
00044 extern const gdm_mask _gdm_ibitmask[];
00045 
00046 
00047 extern void _gdm_plot (struct gdm_display* dp, unsigned short x,
00048                        unsigned short y);
00049 
00050 extern void _gdm_fill_rectangle (struct gdm_display* dp, unsigned short x,
00051                                  unsigned short y, unsigned short width,
00052                                  unsigned short height);
00053 
00054 extern void _gdm_touch_line (gdm_line* l, unsigned short x);
00055 
00056 extern inline void _gdm_touch_line (gdm_line* l, unsigned short x)
00057 {
00058   l->touched |= _gdm_bitmask[x >> 4];
00059 }
00060 
00061 extern void _gdm_do_refresh (struct gdm_display* dp, struct gdm_line* l,
00062                              unsigned short x_first, unsigned short x_last);
00063 
00064 extern int _gdm_refresh_line (gdm_display* dp, gdm_line* l, gdm_line* screen);
00065 
00066 
00067 extern gdm_line* _gdm_get_raw_line (gdm_display* dp, unsigned short y);
00068 
00069 extern inline gdm_line* _gdm_get_raw_line (gdm_display* dp, unsigned short y)
00070 {
00071   return dp->lines[y >> 3];
00072 }
00073 
00083 extern void _gdm_raw_plot (gdm_display* dp, unsigned char* data,
00084                            unsigned char mask);
00085 
00086 extern void inline _gdm_raw_plot (gdm_display* dp, unsigned char* data,
00087                                   unsigned char mask)
00088 {
00089   /* The asm instruction performs:
00090 
00091      data[0] = ((data[0] | mask) & or_mode)
00092              + ((data[0] ^ mask) & xor_mode)
00093              + ((data[0] & ~mask) & and_mode)
00094 
00095      It allows to support all the graphical context modes without
00096      any test.  The asm gets the display manager pointer and access
00097      to the 'mask' and 'xxx_mode' within it.  The offsets of these
00098      data members are passed as a constant to the asm (see @b offsetof).  */
00099   dp->mask = mask;
00100   __asm__ __volatile__ ("ldab   0,%0        ; Get data[0]\n"
00101                         "\torab %a2,%1      ; Or operation\n"
00102                         "\tandb %a3,%1      ; restrict to or_mode\n"
00103                         "\tldaa 0,%0\n"
00104                         "\teora %a2,%1      ; Xor operation\n"
00105                         "\tanda %a4,%1      ; restrict to xor_mode\n"
00106                         "\taba              ; Merge xor and or results\n"
00107                         "\tldab %a2,%1\n"
00108                         "\tcomb\n"
00109                         "\tandb 0,%0        ; And operation\n"
00110                         "\tandb %a5,%1\n"
00111                         "\taba              ; Merge with others\n"
00112                         "\tstaa 0,%0        ; Save in data[0]"
00113                         : : "A"(data), "A"(dp),
00114                         "i"(offsetof(gdm_display, mask)),
00115                         "i"(offsetof(gdm_display, or_mask)),
00116                         "i"(offsetof(gdm_display, xor_mask)),
00117                         "i"(offsetof(gdm_display, and_mask))
00118                         : "d");
00119 }
00120 
00121 
00122 #ifdef __cplusplus
00123 };
00124 #endif
00125 #endif