Priest of the Order of the Butterfly
Posts: 543 from 2007/8/6
From: Pending...
Thank you - that put me on the right track. I got this to compile without warnings.
Code:
/*
> gcc -W -Wall -nostartfiles -noixemul -nostdlib -s -O2 -D__NOLIBBASE__ -DUSE_INLINE_STDARG self_contained_mui.c
*/
#include <clib/alib_protos.h>
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/muimaster.h>
#include <dos/dos.h>
#include <emul/emulinterface.h>
#include <workbench/startup.h>
struct ExecBase *SysBase = 0;
struct Library *DOSBase = 0;
struct Library *IntuitionBase = 0;
struct Library *MUIMasterBase = 0;
ULONG __abox__ = 1;
ULONG Start(void)
{
struct Process *my_process = 0;
struct Message *ambient_message = 0;
ULONG return_code = RETURN_OK;
GETEMULHANDLE
// gg:os-include/emul/emulinterface.h
// #define GETEMULHANDLE register struct EmulHandle *MyEmulHandle __asm("r2");
SysBase = MyEmulHandle->SuperHandle->GlobalSysBase;
my_process = (struct Process *) FindTask(0);
if(my_process->pr_CLI)
{
if((DOSBase = OpenLibrary((STRPTR) "dos.library", 0)))
{
PutStr("Press Ctrl-C or the 'Hello World' window close button to exit.n");
CloseLibrary(DOSBase);
}
else return_code = RETURN_FAIL;
}
else
{
WaitPort(&my_process->pr_MsgPort);
ambient_message = GetMsg(&my_process->pr_MsgPort);
}
if((IntuitionBase = OpenLibrary((STRPTR) "intuition.library", 0)) &&
(MUIMasterBase = OpenLibrary((STRPTR) "muimaster.library", 0)))
{
Object *App, *Win;
App = MUI_NewObject(MUIC_Application,
MUIA_Application_Window, (IPTR) (Win = MUI_NewObject(MUIC_Window,
MUIA_Window_Title, (ULONG) "Hello World",
MUIA_Window_RootObject, (IPTR) MUI_NewObject(MUIC_Group,
MUIA_Group_Child, (IPTR) MUI_NewObject(MUIC_Text,
MUIA_Text_Contents, (ULONG) "Hello world!", TAG_END),
TAG_END),
TAG_END)),
TAG_END);
DoMethod(Win, MUIM_Notify, MUIA_Window_CloseRequest, TRUE, (ULONG) App, 2,
MUIM_Application_ReturnID, MUIV_Application_ReturnID_Quit);
set((APTR) Win, MUIA_Window_Open, TRUE);
ULONG signals = 0;
while(DoMethod(App, MUIM_Application_NewInput, (ULONG) &signals) != (ULONG) MUIV_Application_ReturnID_Quit)
{
signals = Wait(signals | SIGBREAKF_CTRL_C);
if(signals & SIGBREAKF_CTRL_C) break;
}
set((APTR) Win, MUIA_Window_Open, FALSE);
MUI_DisposeObject(App);
CloseLibrary(IntuitionBase);
CloseLibrary(MUIMasterBase);
}
else return_code = RETURN_FAIL;
if(ambient_message)
{
Forbid();
ReplyMsg(ambient_message);
}
return(return_code);
}
PPC assembly ain't so bad... ;)