-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathmsgbox_os4.c
133 lines (111 loc) · 3.39 KB
/
msgbox_os4.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*
** Oricutron
** Copyright (C) 2009-2014 Peter Gordon
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License
** as published by the Free Software Foundation, version 2
** of the License.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**
** Amiga OS4.x message box
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <dirent.h>
#include <sys/stat.h>
#include <classes/requester.h>
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/requester.h>
#include "system.h"
#include "6502.h"
#include "via.h"
#include "8912.h"
#include "gui.h"
#include "disk.h"
#include "monitor.h"
#include "6551.h"
#include "machine.h"
#include "msgbox.h"
struct Library *IntuitionBase = NULL;
struct Library *RequesterBase = NULL;
struct IntuitionIFace *IIntuition = NULL;
struct RequesterIFace *IRequester = NULL;
SDL_bool init_msgbox( struct machine *oric )
{
IntuitionBase = IExec->OpenLibrary( "intuition.library", 51 );
if( !IntuitionBase )
{
printf( "Unable to open intuition.library v51+\n" );
return SDL_FALSE;
}
IIntuition = (struct IntuitionIFace *)IExec->GetInterface( IntuitionBase, "main", 1, NULL );
if( !IIntuition )
{
printf( "Unable to obtain main interface for intuition.library\n" );
return SDL_FALSE;
}
RequesterBase = IExec->OpenLibrary( "requester.class", 51 );
if( !RequesterBase )
{
printf( "Unable to open requester.class v51+\n" );
return SDL_FALSE;
}
IRequester = (struct RequesterIFace *)IExec->GetInterface( RequesterBase, "main", 1, NULL );
if( !IRequester )
{
printf( "Unable to obtain main interface for requester.library\n" );
return SDL_FALSE;
}
return SDL_TRUE;
}
void shut_msgbox( struct machine *oric )
{
if( IRequester ) IExec->DropInterface( (struct Interface *)IRequester );
if( RequesterBase ) IExec->CloseLibrary( RequesterBase );
if( IIntuition ) IExec->DropInterface( (struct Interface *)IIntuition );
if( IntuitionBase ) IExec->CloseLibrary( IntuitionBase );
}
SDL_bool msgbox( struct machine *oric, int type, char *msg )
{
Object *req_obj;
int32 result, imgtype=REQIMAGE_INFO;
STRPTR btns = "huh?!";
switch( type )
{
case MSGBOX_YES_NO:
btns = "Yes|No";
imgtype = REQIMAGE_QUESTION;
break;
case MSGBOX_OK_CANCEL:
btns = "OK|Cancel";
imgtype = REQIMAGE_QUESTION;
break;
case MSGBOX_OK:
btns = "OK";
imgtype = REQIMAGE_INFO;
break;
}
req_obj = (Object *)IIntuition->NewObject( IRequester->REQUESTER_GetClass(), NULL,
REQ_TitleText, "Oricutron Request",
REQ_BodyText, msg,
REQ_GadgetText, btns,
REQ_Image, imgtype,
TAG_DONE );
if( !req_obj ) return SDL_TRUE; // Oh well
result = IIntuition->IDoMethod( req_obj, RM_OPENREQ, NULL, NULL, NULL );
IIntuition->DisposeObject( req_obj );
if( type == MSGBOX_OK ) return SDL_TRUE;
return result ? SDL_TRUE : SDL_FALSE;
}