Fixed GUI font rendering
[tpg/acess2.git] / Usermode / Applications / axwin2_src / WM / common.h
1 /*
2  * Acess GUI (AxWin) Version 2
3  * By John Hodge (thePowersGang)
4  */
5 #ifndef _COMMON_H_
6 #define _COMMON_H_
7
8 #include <stdlib.h>
9 #include <stdio.h>
10 #include <stdint.h>
11
12 #include "wm.h"
13 #include "image.h"
14 //#include "font.h"
15
16 typedef struct sFont    tFont;
17
18 // === MACROS ===
19 static inline uint32_t Video_AlphaBlend(uint32_t _orig, uint32_t _new, uint8_t _alpha)
20 {
21          int    ao,ro,go,bo;
22          int    an,rn,gn,bn;
23         if( _alpha == 0 )       return _orig;
24         if( _alpha == 255 )     return _new;
25         
26         ao = (_orig >> 24) & 0xFF;
27         ro = (_orig >> 16) & 0xFF;
28         go = (_orig >>  8) & 0xFF;
29         bo = (_orig >>  0) & 0xFF;
30         
31         an = (_new >> 24) & 0xFF;
32         rn = (_new >> 16) & 0xFF;
33         gn = (_new >>  8) & 0xFF;
34         bn = (_new >>  0) & 0xFF;
35
36         if( _alpha == 0x80 ) {
37                 ao = (ao + an) / 2;
38                 ro = (ro + rn) / 2;
39                 go = (go + gn) / 2;
40                 bo = (bo + bn) / 2;
41         }
42         else {
43                 ao = ao*(255-_alpha) + an*_alpha;
44                 ro = ro*(255-_alpha) + rn*_alpha;
45                 go = go*(255-_alpha) + gn*_alpha;
46                 bo = bo*(255-_alpha) + bn*_alpha;
47                 ao /= 255*2;
48                 ro /= 255*2;
49                 go /= 255*2;
50                 bo /= 255*2;
51         }
52
53         return (ao << 24) | (ro << 16) | (go << 8) | bo;
54 }
55
56 // === GLOBALS ===
57 extern char     *gsTerminalDevice;
58 extern char     *gsMouseDevice;
59
60 extern int      giScreenWidth;
61 extern int      giScreenHeight;
62 extern uint32_t *gpScreenBuffer;
63
64 extern int      giTerminalFD;
65 extern int      giMouseFD;
66
67 // === Functions ===
68 extern void     memset32(void *ptr, uint32_t val, size_t count);
69 // --- Video ---
70 extern void     Video_Update(void);
71 extern void     Video_FillRect(short X, short Y, short W, short H, uint32_t Color);
72 extern void     Video_DrawRect(short X, short Y, short W, short H, uint32_t Color);
73 extern int      Video_DrawText(short X, short Y, short W, short H, tFont *Font, uint32_t Color, char *Text);
74 extern void Video_DrawImage(short X, short Y, short W, short H, tImage *Image);
75 // --- Debug Hack ---
76 extern void     _SysDebug(const char *Format, ...);
77 #endif

UCC git Repository :: git.ucc.asn.au