2 // a limited and redundant graphics system which allows placing text on the screen
3 // in the case of startup errors or before the real data files are extracted.
7 #include "safemode.fdh"
9 using namespace safemode
;
10 using namespace Graphics
;
13 static bool initilized
= false;
14 static SDL_Rect printrect
;
15 static NXColor
backcolor(0x20, 0x20, 0x20);
17 static bool have_status
= false;
18 static SDL_Rect statusrect
;
22 moveto(SM_UPPER_THIRD
);
28 void safemode::close()
40 void c------------------------------() {}
43 void safemode::moveto(int y
)
48 nexty
= (SCREEN_HEIGHT
/ 2) - (GetFontHeight() / 2);
52 nexty
= (SCREEN_HEIGHT
/ 4) - (GetFontHeight() / 2);
56 nexty
= (SCREEN_HEIGHT
/ 4) - (GetFontHeight() / 2);
57 nexty
= (SCREEN_HEIGHT
- nexty
);
61 nexty
= (SCREEN_HEIGHT
/ 2) - (GetFontHeight() / 2);
71 bool safemode::print(const char *fmt
, ...)
77 vsnprintf(buffer
, sizeof(buffer
), fmt
, ar
);
80 stat("safemode print: '%s'", buffer
);
82 int fontwidth
= GetFontWidth(buffer
, 0, false);
83 int fontheight
= GetFontHeight();
87 int x
= ((SCREEN_WIDTH
/ 2) - (fontwidth
/ 2));
91 printrect
.w
= fontwidth
;
92 printrect
.h
= fontheight
;
94 font_draw(x
, nexty
, buffer
, 0, &greenfont
);
100 nexty
+= (fontheight
+ 1);
104 void safemode::clear()
106 ClearScreen(backcolor
);
107 moveto(SM_UPPER_THIRD
);
111 int safemode::run_until_key(bool delay
)
113 stat("run_until_key()");
114 uint32_t start
= SDL_GetTicks();
122 if (delay
&& (SDL_GetTicks() - start
) < 500)
125 while(last_sdl_key
== -1);
127 stat("returning key %d", last_sdl_key
);
132 void safemode::status(const char *fmt
, ...)
138 vsnprintf(buffer
, sizeof(buffer
), fmt
, ar
);
145 statusrect
= printrect
;
149 void safemode::clearstatus()
153 FillRect(statusrect
.x
, statusrect
.y
, \
154 statusrect
.x
+ (statusrect
.w
- 1), \
155 statusrect
.y
+ (statusrect
.h
- 1),