// helloText.c - GS/OS app that draws text on the SHR screen via the
// real ROM Font Manager + QuickDraw DrawString.  Uses the full desktop
// startup (which includes InitCursor — see feedback_drawmenubar_hang
// for why that's load-bearing) and waits for any key.

#include "iigs/toolbox.h"
#include "iigs/desktop.h"


// Pascal-counted strings (length byte + chars).
static const unsigned char line1[] = "\x13" "Hello from llvm816!";
static const unsigned char line2[] = "\x2B" "Clang-compiled C running on the Apple IIgs.";
static const unsigned char line3[] = "\x16" "Press any key to exit.";


int main(void) {
    unsigned short userId = startdesk(640);
    (void)userId;

    paintDesktopBackdrop();
    ShowCursor();

    SetForeColor(0);
    SetBackColor(15);

    MoveTo(40, 40);  DrawString((void *)line1);
    MoveTo(40, 60);  DrawString((void *)line2);
    MoveTo(40, 80);  DrawString((void *)line3);

    for (volatile unsigned long s = 0; s < 400000UL; s++) { }

    short evt[8];
    while (1) {
        if (GetNextEvent(0xFFFF, evt) && evt[0] == 3) {
            break;
        }
    }

    SysBeep();
    *(volatile unsigned char *)0x70 = 0x99;
    return 0;
}
