]> Shamusworld >> Repos - virtualjaguar/blobdiff - src/gui.cpp
Changes for the upcoming 1.0.5 release
[virtualjaguar] / src / gui.cpp
index 17e522c9b7074ee6ed8ef272450c393f5ec42850..bf4c30e941d24d5e8a743c13dc1d04199999e9a3 100644 (file)
@@ -5,8 +5,10 @@
 // by James L. Hammons
 //
 
+#include <string.h>
 #include "types.h"
 #include "tom.h"
+#include "font1.h"
 #include "gui.h"
 
 void InitGUI(void)
@@ -17,7 +19,31 @@ void GUIDone(void)
 {
 }
 
-void DrawText(uint16 * screen, uint32 x, uint32 y, const char * string)
+void DrawText(int16 * screen, uint32 x, uint32 y, const char * text, ...)
 {
-       uint32 pitch = TOMGetSDLScreenPitch();
+       char string[4096];
+       va_list arg;
+
+       va_start(arg, text);
+       vsprintf(string, text, arg);
+       va_end(arg);
+
+       uint32 pitch = TOMGetSDLScreenPitch() / 2;              // Returns pitch in bytes but we need words...
+       uint32 length = strlen(string), address = x + (y * pitch);
+
+       for(uint32 i=0; i<length; i++)
+       {
+               uint32 fontAddr = (uint32)string[i] * 64;
+
+               for(uint32 yy=0; yy<8; yy++)
+               {
+                       for(uint32 xx=0; xx<8; xx++)
+                       {
+                               if (font1[fontAddr++])
+                                       *(screen + address + xx + (yy * pitch)) = 0xFE00;
+                       }
+               }
+
+               address += 8;
+       }
 }