ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/Frodo4/Src/AmigaGUI.c
Revision: 1.1
Committed: 2003-07-01T17:15:15Z (19 years, 7 months ago) by cebix
Content type: text/plain
Branch: MAIN
CVS Tags: VERSION_4_2, HEAD
Log Message:
imported files

File Contents

# User Rev Content
1 cebix 1.1 /*
2     * Source machine generated by GadToolsBox V2.0b
3     * which is (c) Copyright 1991-1993 Jaba Development
4     *
5     * GUI Designed by : Christian Bauer
6     */
7    
8     #include <exec/types.h>
9     #include <intuition/intuition.h>
10     #include <intuition/classes.h>
11     #include <intuition/classusr.h>
12     #include <intuition/imageclass.h>
13     #include <intuition/gadgetclass.h>
14     #include <libraries/gadtools.h>
15     #include <graphics/displayinfo.h>
16     #include <graphics/gfxbase.h>
17     #include <clib/exec_protos.h>
18     #include <clib/intuition_protos.h>
19     #include <clib/gadtools_protos.h>
20     #include <clib/graphics_protos.h>
21     #include <clib/utility_protos.h>
22     #include <string.h>
23     #include "AmigaGUI.h"
24    
25     struct Screen *Scr = NULL;
26     UBYTE *PubScreenName = NULL;
27     APTR VisualInfo = NULL;
28     struct Window *PrefsWnd = NULL;
29     struct Gadget *PrefsGList = NULL;
30     struct Menu *PrefsMenus = NULL;
31     struct IntuiMessage PrefsMsg;
32     UWORD PrefsZoom[4];
33     struct Gadget *PrefsGadgets[31];
34     UWORD PrefsLeft = 0;
35     UWORD PrefsTop = 16;
36     UWORD PrefsWidth = 561;
37     UWORD PrefsHeight = 238;
38     UBYTE *PrefsWdt = (UBYTE *)"Frodo Preferences";
39     struct TextAttr *Font, Attr;
40     UWORD FontX, FontY;
41     UWORD OffX, OffY;
42    
43     UBYTE *SIDType0Labels[] = {
44     (UBYTE *)"None",
45     (UBYTE *)"Digital (AHI)",
46     (UBYTE *)"SID Card",
47     NULL };
48    
49     UBYTE *REUSize0Labels[] = {
50     (UBYTE *)"None",
51     (UBYTE *)"128K",
52     (UBYTE *)"256K",
53     (UBYTE *)"512K",
54     NULL };
55    
56     UBYTE *DriveType80Labels[] = {
57     (UBYTE *)"DIR",
58     (UBYTE *)"D64",
59     (UBYTE *)"T64",
60     NULL };
61    
62     UBYTE *DriveType90Labels[] = {
63     (UBYTE *)"DIR",
64     (UBYTE *)"D64",
65     (UBYTE *)"T64",
66     NULL };
67    
68     UBYTE *DriveType100Labels[] = {
69     (UBYTE *)"DIR",
70     (UBYTE *)"D64",
71     (UBYTE *)"T64",
72     NULL };
73    
74     UBYTE *DriveType110Labels[] = {
75     (UBYTE *)"DIR",
76     (UBYTE *)"D64",
77     (UBYTE *)"T64",
78     NULL };
79    
80     struct IntuiText PrefsIText[] = {
81     2, 0, JAM1,34, 115, NULL, (UBYTE *)"Drive", NULL };
82    
83     #define Prefs_TNUM 1
84    
85     struct NewMenu PrefsNewMenu[] = {
86     NM_TITLE, (STRPTR)"Preferences", NULL, 0, NULL, NULL,
87     NM_ITEM, (STRPTR)"Open...", (STRPTR)"O", 0, 0L, (APTR)PrefsOpen,
88     NM_ITEM, (STRPTR)"Save", (STRPTR)"S", 0, 0L, (APTR)PrefsSave,
89     NM_ITEM, (STRPTR)"Save As...", (STRPTR)"A", 0, 0L, (APTR)PrefsSaveAs,
90     NM_ITEM, (STRPTR)"Revert", (STRPTR)"R", 0, 0L, (APTR)PrefsRevert,
91     NM_ITEM, (STRPTR)NM_BARLABEL, NULL, 0, 0L, NULL,
92     NM_ITEM, (STRPTR)"OK", NULL, 0, 0L, (APTR)PrefsOK,
93     NM_ITEM, (STRPTR)"Cancel", NULL, 0, 0L, (APTR)PrefsCancel,
94     NM_END, NULL, NULL, 0, 0L, NULL };
95    
96     UWORD PrefsGTypes[] = {
97     CHECKBOX_KIND,
98     CHECKBOX_KIND,
99     CHECKBOX_KIND,
100     CHECKBOX_KIND,
101     CHECKBOX_KIND,
102     CHECKBOX_KIND,
103     CHECKBOX_KIND,
104     CHECKBOX_KIND,
105     INTEGER_KIND,
106     INTEGER_KIND,
107     INTEGER_KIND,
108     INTEGER_KIND,
109     INTEGER_KIND,
110     CYCLE_KIND,
111     CYCLE_KIND,
112     STRING_KIND,
113     CYCLE_KIND,
114     STRING_KIND,
115     CYCLE_KIND,
116     STRING_KIND,
117     CYCLE_KIND,
118     STRING_KIND,
119     CYCLE_KIND,
120     CHECKBOX_KIND,
121     CHECKBOX_KIND,
122     BUTTON_KIND,
123     BUTTON_KIND,
124     BUTTON_KIND,
125     BUTTON_KIND,
126     BUTTON_KIND,
127     BUTTON_KIND
128     };
129    
130     struct NewGadget PrefsNGad[] = {
131     8, 4, 26, 11, (UBYTE *)"Sprite display", NULL, GD_SpritesOn, PLACETEXT_RIGHT, NULL, (APTR)SpritesOnClicked,
132     8, 16, 26, 11, (UBYTE *)"Sprite collisions", NULL, GD_SpriteCollisions, PLACETEXT_RIGHT, NULL, (APTR)SpriteCollisionsClicked,
133     8, 28, 26, 11, (UBYTE *)"Joystick connected", NULL, GD_Joystick2On, PLACETEXT_RIGHT, NULL, (APTR)Joystick2OnClicked,
134     8, 40, 26, 11, (UBYTE *)"Map joystick to port 1", NULL, GD_JoystickSwap, PLACETEXT_RIGHT, NULL, (APTR)JoystickSwapClicked,
135     8, 52, 26, 11, (UBYTE *)"Limit speed", NULL, GD_LimitSpeed, PLACETEXT_RIGHT, NULL, (APTR)LimitSpeedClicked,
136     8, 64, 26, 11, (UBYTE *)"Fast reset", NULL, GD_FastReset, PLACETEXT_RIGHT, NULL, (APTR)FastResetClicked,
137     8, 76, 26, 11, (UBYTE *)"Clear CIA ICR on write", NULL, GD_CIAIRQHack, PLACETEXT_RIGHT, NULL, (APTR)CIAIRQHackClicked,
138     8, 88, 26, 11, (UBYTE *)"SID filters", NULL, GD_SIDFilters, PLACETEXT_RIGHT, NULL, (APTR)SIDFiltersClicked,
139     490, 4, 65, 14, (UBYTE *)"Cycles per line (CPU)", NULL, GD_NormalCycles, PLACETEXT_LEFT, NULL, (APTR)NormalCyclesClicked,
140     490, 19, 65, 14, (UBYTE *)"Cycles per Bad Line (CPU)", NULL, GD_BadLineCycles, PLACETEXT_LEFT, NULL, (APTR)BadLineCyclesClicked,
141     490, 34, 65, 14, (UBYTE *)"Cycles per line (CIA)", NULL, GD_CIACycles, PLACETEXT_LEFT, NULL, (APTR)CIACyclesClicked,
142     490, 49, 65, 14, (UBYTE *)"Cycles per line (1541)", NULL, GD_FloppyCycles, PLACETEXT_LEFT, NULL, (APTR)FloppyCyclesClicked,
143     490, 64, 65, 14, (UBYTE *)"Draw every n-th frame", NULL, GD_SkipFrames, PLACETEXT_LEFT, NULL, (APTR)SkipFramesClicked,
144     426, 79, 129, 14, (UBYTE *)"SID emulation type", NULL, GD_SIDType, PLACETEXT_LEFT, NULL, (APTR)SIDTypeClicked,
145     426, 94, 129, 14, (UBYTE *)"REU size", NULL, GD_REUSize, PLACETEXT_LEFT, NULL, (APTR)REUSizeClicked,
146     47, 123, 401, 14, (UBYTE *)"8", NULL, GD_DrivePath8, PLACETEXT_LEFT, NULL, (APTR)DrivePath8Clicked,
147     470, 123, 65, 14, NULL, NULL, GD_DriveType8, 0, NULL, (APTR)DriveType8Clicked,
148     47, 138, 401, 14, (UBYTE *)"9", NULL, GD_DrivePath9, PLACETEXT_LEFT, NULL, (APTR)DrivePath9Clicked,
149     470, 138, 65, 14, NULL, NULL, GD_DriveType9, 0, NULL, (APTR)DriveType9Clicked,
150     47, 153, 401, 14, (UBYTE *)"10", NULL, GD_DrivePath10, PLACETEXT_LEFT, NULL, (APTR)DrivePath10Clicked,
151     470, 153, 65, 14, NULL, NULL, GD_DriveType10, 0, NULL, (APTR)DriveType10Clicked,
152     47, 168, 401, 14, (UBYTE *)"11", NULL, GD_DrivePath11, PLACETEXT_LEFT, NULL, (APTR)DrivePath11Clicked,
153     470, 168, 65, 14, NULL, NULL, GD_DriveType11, 0, NULL, (APTR)DriveType11Clicked,
154     20, 186, 26, 11, (UBYTE *)"Map '/'<->'\' in filenames", NULL, GD_MapSlash, PLACETEXT_RIGHT, NULL, (APTR)MapSlashClicked,
155     20, 198, 26, 11, (UBYTE *)"Enable 1541 processor emulation", NULL, GD_Emul1541Proc, PLACETEXT_RIGHT, NULL, (APTR)Emul1541ProcClicked,
156     61, 218, 81, 16, (UBYTE *)"_OK", NULL, GD_OK, PLACETEXT_IN, NULL, (APTR)OKClicked,
157     416, 218, 81, 16, (UBYTE *)"_Cancel", NULL, GD_Cancel, PLACETEXT_IN, NULL, (APTR)CancelClicked,
158     448, 123, 20, 14, (UBYTE *)"", NULL, GD_GetDrive8, PLACETEXT_IN, NULL, (APTR)GetDrive8Clicked,
159     448, 138, 20, 14, (UBYTE *)"", NULL, GD_GetDrive9, PLACETEXT_IN, NULL, (APTR)GetDrive9Clicked,
160     448, 153, 20, 14, (UBYTE *)"", NULL, GD_GetDrive10, PLACETEXT_IN, NULL, (APTR)GetDrive10Clicked,
161     448, 168, 20, 14, (UBYTE *)"", NULL, GD_GetDrive11, PLACETEXT_IN, NULL, (APTR)GetDrive11Clicked
162     };
163    
164     ULONG PrefsGTags[] = {
165     (TAG_DONE),
166     (TAG_DONE),
167     (TAG_DONE),
168     (TAG_DONE),
169     (TAG_DONE),
170     (TAG_DONE),
171     (TAG_DONE),
172     (TAG_DONE),
173     (GTIN_Number), 0, (GTIN_MaxChars), 10, (STRINGA_Justification), (GACT_STRINGRIGHT), (TAG_DONE),
174     (GTIN_Number), 0, (GTIN_MaxChars), 10, (STRINGA_Justification), (GACT_STRINGRIGHT), (TAG_DONE),
175     (GTIN_Number), 0, (GTIN_MaxChars), 10, (STRINGA_Justification), (GACT_STRINGRIGHT), (TAG_DONE),
176     (GTIN_Number), 0, (GTIN_MaxChars), 10, (STRINGA_Justification), (GACT_STRINGRIGHT), (TAG_DONE),
177     (GTIN_Number), 0, (GTIN_MaxChars), 10, (STRINGA_Justification), (GACT_STRINGRIGHT), (TAG_DONE),
178     (GTCY_Labels), (ULONG)&SIDType0Labels[ 0 ], (TAG_DONE),
179     (GTCY_Labels), (ULONG)&REUSize0Labels[ 0 ], (TAG_DONE),
180     (GTST_MaxChars), 256, (TAG_DONE),
181     (GTCY_Labels), (ULONG)&DriveType80Labels[ 0 ], (TAG_DONE),
182     (GTST_MaxChars), 256, (TAG_DONE),
183     (GTCY_Labels), (ULONG)&DriveType90Labels[ 0 ], (TAG_DONE),
184     (GTST_MaxChars), 256, (TAG_DONE),
185     (GTCY_Labels), (ULONG)&DriveType100Labels[ 0 ], (TAG_DONE),
186     (GTST_MaxChars), 256, (TAG_DONE),
187     (GTCY_Labels), (ULONG)&DriveType110Labels[ 0 ], (TAG_DONE),
188     (TAG_DONE),
189     (TAG_DONE),
190     (GT_Underscore), '_', (TAG_DONE),
191     (GT_Underscore), '_', (TAG_DONE),
192     (TAG_DONE),
193     (TAG_DONE),
194     (TAG_DONE),
195     (TAG_DONE)
196     };
197    
198     static UWORD ComputeX( UWORD value )
199     {
200     return(( UWORD )((( FontX * value ) + 4 ) / 8 ));
201     }
202    
203     static UWORD ComputeY( UWORD value )
204     {
205     return(( UWORD )((( FontY * value ) + 4 ) / 8 ));
206     }
207    
208     static void ComputeFont( UWORD width, UWORD height )
209     {
210     Font = &Attr;
211     Font->ta_Name = (STRPTR)Scr->RastPort.Font->tf_Message.mn_Node.ln_Name;
212     Font->ta_YSize = FontY = Scr->RastPort.Font->tf_YSize;
213     FontX = Scr->RastPort.Font->tf_XSize;
214    
215     OffX = Scr->WBorLeft;
216     OffY = Scr->RastPort.TxHeight + Scr->WBorTop + 1;
217    
218     if ( width && height ) {
219     if (( ComputeX( width ) + OffX + Scr->WBorRight ) > Scr->Width )
220     goto UseTopaz;
221     if (( ComputeY( height ) + OffY + Scr->WBorBottom ) > Scr->Height )
222     goto UseTopaz;
223     }
224     return;
225    
226     UseTopaz:
227     Font->ta_Name = (STRPTR)"topaz.font";
228     FontX = FontY = Font->ta_YSize = 8;
229     }
230    
231     int SetupScreen( void )
232     {
233     if ( ! ( Scr = LockPubScreen( PubScreenName )))
234     return( 1L );
235    
236     ComputeFont( 0, 0 );
237    
238     if ( ! ( VisualInfo = GetVisualInfo( Scr, TAG_DONE )))
239     return( 2L );
240    
241     return( 0L );
242     }
243    
244     void CloseDownScreen( void )
245     {
246     if ( VisualInfo ) {
247     FreeVisualInfo( VisualInfo );
248     VisualInfo = NULL;
249     }
250    
251     if ( Scr ) {
252     UnlockPubScreen( NULL, Scr );
253     Scr = NULL;
254     }
255     }
256    
257     void PrefsRender( void )
258     {
259     struct IntuiText it;
260     UWORD cnt;
261    
262     ComputeFont( PrefsWidth, PrefsHeight );
263    
264    
265     for ( cnt = 0; cnt < Prefs_TNUM; cnt++ ) {
266     CopyMem(( char * )&PrefsIText[ cnt ], ( char * )&it, (long)sizeof( struct IntuiText ));
267     it.ITextFont = Font;
268     it.LeftEdge = OffX + ComputeX( it.LeftEdge ) - ( IntuiTextLength( &it ) >> 1 );
269     it.TopEdge = OffY + ComputeY( it.TopEdge ) - ( Font->ta_YSize >> 1 );
270     PrintIText( PrefsWnd->RPort, &it, 0, 0 );
271     }
272     }
273    
274     int HandlePrefsIDCMP( void )
275     {
276     struct IntuiMessage *m;
277     struct MenuItem *n;
278     int (*func)();
279     BOOL running = TRUE;
280    
281     while( m = GT_GetIMsg( PrefsWnd->UserPort )) {
282    
283     CopyMem(( char * )m, ( char * )&PrefsMsg, (long)sizeof( struct IntuiMessage ));
284    
285     GT_ReplyIMsg( m );
286    
287     switch ( PrefsMsg.Class ) {
288    
289     case IDCMP_REFRESHWINDOW:
290     GT_BeginRefresh( PrefsWnd );
291     PrefsRender();
292     GT_EndRefresh( PrefsWnd, TRUE );
293     break;
294    
295     case IDCMP_VANILLAKEY:
296     running = PrefsVanillaKey();
297     break;
298    
299     case IDCMP_GADGETUP:
300     func = ( void * )(( struct Gadget * )PrefsMsg.IAddress )->UserData;
301     running = func();
302     break;
303    
304     case IDCMP_MENUPICK:
305     while( PrefsMsg.Code != MENUNULL ) {
306     n = ItemAddress( PrefsMenus, PrefsMsg.Code );
307     func = (void *)(GTMENUITEM_USERDATA( n ));
308     running = func();
309     PrefsMsg.Code = n->NextSelect;
310     }
311     break;
312     }
313     }
314     return( running );
315     }
316    
317     int OpenPrefsWindow( void )
318     {
319     struct NewGadget ng;
320     struct Gadget *g;
321     UWORD lc, tc;
322     UWORD wleft = PrefsLeft, wtop = PrefsTop, ww, wh;
323    
324     ComputeFont( PrefsWidth, PrefsHeight );
325    
326     ww = ComputeX( PrefsWidth );
327     wh = ComputeY( PrefsHeight );
328    
329     if (( wleft + ww + OffX + Scr->WBorRight ) > Scr->Width ) wleft = Scr->Width - ww;
330     if (( wtop + wh + OffY + Scr->WBorBottom ) > Scr->Height ) wtop = Scr->Height - wh;
331    
332     if ( ! ( g = CreateContext( &PrefsGList )))
333     return( 1L );
334    
335     for( lc = 0, tc = 0; lc < Prefs_CNT; lc++ ) {
336    
337     CopyMem((char * )&PrefsNGad[ lc ], (char * )&ng, (long)sizeof( struct NewGadget ));
338    
339     ng.ng_VisualInfo = VisualInfo;
340     ng.ng_TextAttr = Font;
341     ng.ng_LeftEdge = OffX + ComputeX( ng.ng_LeftEdge );
342     ng.ng_TopEdge = OffY + ComputeY( ng.ng_TopEdge );
343     ng.ng_Width = ComputeX( ng.ng_Width );
344     ng.ng_Height = ComputeY( ng.ng_Height);
345    
346     PrefsGadgets[ lc ] = g = CreateGadgetA((ULONG)PrefsGTypes[ lc ], g, &ng, ( struct TagItem * )&PrefsGTags[ tc ] );
347    
348     while( PrefsGTags[ tc ] ) tc += 2;
349     tc++;
350    
351     if ( NOT g )
352     return( 2L );
353     }
354    
355     if ( ! ( PrefsMenus = CreateMenus( PrefsNewMenu, GTMN_FrontPen, 0L, TAG_DONE )))
356     return( 3L );
357    
358     LayoutMenus( PrefsMenus, VisualInfo, TAG_DONE );
359    
360     PrefsZoom[0] = PrefsZoom[1] = 0;
361     if ( PrefsWdt )
362     PrefsZoom[2] = TextLength( &Scr->RastPort, (UBYTE *)PrefsWdt, strlen((char *)PrefsWdt )) + 80;
363     else
364     PrefsZoom[2] = 80L;
365     PrefsZoom[3] = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
366    
367     if ( ! ( PrefsWnd = OpenWindowTags( NULL,
368     WA_Left, wleft,
369     WA_Top, wtop,
370     WA_Width, ww + OffX + Scr->WBorRight,
371     WA_Height, wh + OffY + Scr->WBorBottom,
372     WA_IDCMP, CHECKBOXIDCMP|INTEGERIDCMP|CYCLEIDCMP|STRINGIDCMP|BUTTONIDCMP|IDCMP_MENUPICK|IDCMP_VANILLAKEY|IDCMP_REFRESHWINDOW,
373     WA_Flags, WFLG_DRAGBAR|WFLG_DEPTHGADGET|WFLG_SMART_REFRESH|WFLG_SIMPLE_REFRESH|WFLG_ACTIVATE,
374     WA_Gadgets, PrefsGList,
375     WA_Title, PrefsWdt,
376     WA_ScreenTitle, "Frodo C64 Emulator",
377     WA_PubScreen, Scr,
378     WA_Zoom, PrefsZoom,
379     TAG_DONE )))
380     return( 4L );
381    
382     SetMenuStrip( PrefsWnd, PrefsMenus );
383     GT_RefreshWindow( PrefsWnd, NULL );
384    
385     PrefsRender();
386    
387     return( 0L );
388     }
389    
390     void ClosePrefsWindow( void )
391     {
392     if ( PrefsMenus ) {
393     ClearMenuStrip( PrefsWnd );
394     FreeMenus( PrefsMenus );
395     PrefsMenus = NULL; }
396    
397     if ( PrefsWnd ) {
398     CloseWindow( PrefsWnd );
399     PrefsWnd = NULL;
400     }
401    
402     if ( PrefsGList ) {
403     FreeGadgets( PrefsGList );
404     PrefsGList = NULL;
405     }
406     }
407