sdk-world v2026.11.05
PS2 SDK - world tier (copyleft-allowed, non-essential packages)
Loading...
Searching...
No Matches
aaflush.c
1
2#include <stdio.h>
3#include "aalib.h"
4
5#define HIDEMOUSE if(!hidden&&cursor&&c->mousedriver!=NULL&&(c->mousedriver->flags&AA_HIDECURSOR)) \
6 aa_hidemouse(c),hidden=1;
7static void aa_display(aa_context * c, int x1, int y1, int x2, int y2)
8{
9 int x, y, pos, attr, p;
10 unsigned char str[80];
11 int cursor=c->mousemode,hidden=0;
12 if (x2 < 0 || y2 < 0 || x1 > aa_scrwidth(c) || y1 > aa_scrheight(c))
13 return;
14 if (x2 >= aa_scrwidth(c))
15 x2 = aa_scrwidth(c);
16 if (y2 >= aa_scrheight(c))
17 y2 = aa_scrheight(c);
18 if (x1 < 0)
19 x1 = 0;
20 if (y1 < 0)
21 y1 = 0;
22 if (c->driver->print == NULL)
23 return;
24 pos = 0;
25 for (y = y1; y < y2; y++) {
26 pos = y * aa_scrwidth(c) + x1;
27 c->driver->gotoxy(c, x1, y);
28 for (x = x1; x < x2;) {
29 p = 0;
30 attr = c->attrbuffer[pos];
31 while (p < 79 && x < x2 && c->attrbuffer[pos] == attr) {
32 str[p] = c->textbuffer[pos];
33 pos++;
34 p++;
35 x++;
36 }
37 str[p] = 0;
38 HIDEMOUSE
39 c->driver->setattr(c, attr);
40 c->driver->print(c, (char *)str);
41 }
42 c->driver->gotoxy(c, c->cursorx, c->cursory);
43 }
44 if(hidden&&cursor)
45 aa_showmouse(c);
46}
47void aa_hidemouse(aa_context *c)
48{
49 if(c->mousemode) {
50 c->mousemode=0;
51 if(c->mousedriver!=NULL&&c->mousedriver->cursormode!=NULL) c->mousedriver->cursormode(c,0);
52 }
53}
54void aa_showmouse(aa_context *c)
55{
56 if(!c->mousemode) {
57 c->mousemode=1;
58 if(c->mousedriver!=NULL&&c->mousedriver->cursormode!=NULL) c->mousedriver->cursormode(c,1);
59 }
60}
61
62void aa_flush(aa_context * c)
63{
64 if (c->driver->print != NULL)
65 aa_display(c, 0, 0, aa_imgwidth(c), aa_imgheight(c));
66 if (c->driver->flush != NULL)
67 { int cursor=c->mousemode;
68 if(cursor&&c->mousedriver!=NULL&&(c->mousedriver->flags&AA_HIDECURSOR))
69 aa_hidemouse(c);
70 c->driver->flush(c);
71 if(cursor&&c->mousedriver!=NULL&&(c->mousedriver->flags&AA_HIDECURSOR))
72 aa_showmouse(c);
73 }
74}