-
Notifications
You must be signed in to change notification settings - Fork 1
/
amiga.c
164 lines (133 loc) · 3.3 KB
/
amiga.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/* Amiga-specific additions and replacements for PSPZX81/sz81
* by Chris Young <chris@unsatisfactorysoftware.co.uk> 2008, 2010
*/
#include <string.h>
#include <stdio.h>
#include <malloc.h>
#include <stdlib.h>
#include "amiga.h"
#include "common.h"
#include "sdl.h"
#include "sdl_loadsave.h"
#include "sdl_resources.h"
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/icon.h>
#include <proto/asl.h>
struct Library *IconBase;
struct IconIFace *IIcon;
struct Library *AslBase;
struct AslIFace *IAsl;
BOOL amiga_update_drawer = TRUE;
static char USED ver[] = "\0$VER:sz81 " VERSION " (" DATE ")\0";
int amiga_open_libs(void)
{
int ret=1;
if((IconBase = IExec->OpenLibrary("icon.library",50)))
{
IIcon=(struct IconIFace *)IExec->GetInterface(IconBase,"main",1,NULL);
}
else
{
ret=0;
}
if((AslBase = IExec->OpenLibrary("asl.library",50)))
{
IAsl=(struct AslIFace *)IExec->GetInterface(AslBase,"main",1,NULL);
}
else
{
ret=0;
}
strcpy(amiga_data_dir, "PROGDIR:save");
return(ret);
}
void amiga_close_libs(void)
{
if(IconBase)
{
IExec->DropInterface((struct Interface *)IIcon);
IExec->CloseLibrary(IconBase);
}
if(AslBase)
{
IExec->DropInterface((struct Interface *)IAsl);
IExec->CloseLibrary(AslBase);
}
}
void amiga_read_tooltypes(struct WBStartup *WBenchMsg)
{
struct WBArg *wbarg;
char i;
int olddir;
struct DiskObject *dobj;
STRPTR *toolarray;
char *s;
for(i=0,wbarg=WBenchMsg->sm_ArgList;i<WBenchMsg->sm_NumArgs;i++,wbarg++)
{
olddir =-1;
if((wbarg->wa_Lock)&&(*wbarg->wa_Name))
olddir = IDOS->CurrentDir(wbarg->wa_Lock);
if((*wbarg->wa_Name) && (dobj=IIcon->GetIconTags(wbarg->wa_Name,NULL)))
{
toolarray = dobj->do_ToolTypes;
if((s = IIcon->FindToolType(toolarray,"FULLSCREEN")))
{
sdl_com_line.fullscreen=1;
}
if((s = IIcon->FindToolType(toolarray,"XRES")))
{
sdl_com_line.xres=atoi(s);
}
if((s = IIcon->FindToolType(toolarray,"YRES")))
{
sdl_com_line.yres=atoi(s);
}
if((s = IIcon->FindToolType(toolarray,"LOCALDATA")))
{
strcpy(amiga_data_dir, s);
}
if((s = IIcon->FindToolType(toolarray,"STATICLOADDIR")))
{
amiga_update_drawer = FALSE;
}
IIcon->FreeDiskObject(dobj);
}
if(olddir !=-1) IDOS->CurrentDir(olddir);
}
if(WBenchMsg->sm_NumArgs > 1)
{
wbarg--;
strcpy(sdl_com_line.filename, wbarg->wa_Name);
}
strcpy(load_file_dialog.dir, amiga_data_dir);
IDOS->AddPart(load_file_dialog.dir, LOCAL_PROGRM_DIR, sizeof(load_file_dialog.dir));
}
char *amiga_file_request(char *title, BOOL save)
{
int sel=0;
struct FileRequester *freq;
char pattern[20] = "#?.(p|81)";
static char fname[1024];
if(zx80) strcpy(pattern,"#?.(o|80)");
if((freq = (struct FileRequester *)IAsl->AllocAslRequest(ASL_FileRequest,NULL)))
{
if(IAsl->AslRequestTags(freq,
ASLFR_TitleText, title,
ASLFR_InitialPattern,&pattern,
ASLFR_InitialDrawer, load_file_dialog.dir,
ASLFR_DoPatterns,TRUE,
ASLFR_DoSaveMode, save,
TAG_DONE))
{
strlcpy(fname,freq->fr_Drawer,1024);
IDOS->AddPart(fname,freq->fr_File,1024);
sel=1;
if(amiga_update_drawer)
strcpy(load_file_dialog.dir, freq->fr_Drawer);
}
IAsl->FreeAslRequest(freq);
}
if(sel) return fname;
else return NULL;
}