Working on GUI, side changes to the message passing
[tpg/acess2.git] / Usermode / Applications / axwin2_src / WM / video.c
1 /*
2  * Acess GUI (AxWin) Version 2
3  * By John Hodge (thePowersGang)
4  */
5 #include "common.h"
6 #include <acess/sys.h>
7 #include <acess/devices/terminal.h>
8
9 // === PROTOTYPES ===
10 void    Video_Setup();
11 void    Video_Update();
12
13 // === GLOBALS ===
14
15 // === CODE ===
16 void Video_Setup()
17 {
18          int    tmpInt;
19         
20         // Open terminal
21         giTerminalFD = open(gsTerminalDevice, OPENFLAG_READ|OPENFLAG_WRITE);
22         if( giTerminalFD == -1 )
23         {
24                 fprintf(stderr, "ERROR: Unable to open '%s' (%i)\n", gsTerminalDevice, _errno);
25                 exit(-1);
26         }
27         
28         // Set width
29         tmpInt = giScreenWidth;
30         tmpInt = ioctl( giTerminalFD, TERM_IOCTL_WIDTH, &tmpInt );
31         if(tmpInt != giScreenWidth)
32         {
33                 fprintf(stderr, "Warning: Selected width (%i) is invalid, clipped to %i\n",
34                         giScreenWidth, tmpInt);
35                 giScreenWidth = tmpInt;
36         }
37         
38         // Set height
39         tmpInt = giScreenHeight;
40         tmpInt = ioctl( giTerminalFD, TERM_IOCTL_HEIGHT, &tmpInt );
41         if(tmpInt != giScreenHeight)
42         {
43                 fprintf(stderr, "Warning: Selected height (%i) is invalid, clipped to %i\n",
44                         giScreenHeight, tmpInt);
45                 giScreenHeight = tmpInt;
46         }
47         
48         // Set mode to video
49         tmpInt = TERM_MODE_FB;
50         ioctl( giTerminalFD, TERM_IOCTL_MODETYPE, &tmpInt );
51         
52         // Force VT8 to be shown
53         ioctl( giTerminalFD, TERM_IOCTL_FORCESHOW, NULL );
54         
55         // Create local framebuffer (back buffer)
56         gpScreenBuffer = malloc( giScreenWidth*giScreenHeight*4 );
57         memset32( gpScreenBuffer, 0x8888FF, giScreenWidth*giScreenHeight );
58         Video_Update();
59 }
60
61 void Video_Update()
62 {
63         seek(giTerminalFD, 0, SEEK_SET);
64         write(giTerminalFD, giScreenWidth*giScreenHeight*4, gpScreenBuffer);
65 }

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