2 ** $VER: MonED Release V3 (29.01.94)
4 ** Monitor Specs Editor , for changing monitor spec details such as syncs!
6 ** Programmed by : Raul A. Sobon.
8 ** (C) Copyright 1993 PRoJeCT-23, Inc.
17 #include <exec/types.h>
18 #include <exec/memory.h>
19 #include <exec/execbase.h>
22 #include <dos/dosextens.h>
23 #include <dos/stdio.h> // dos stdio
25 #include <graphics/gfxbase.h>
26 #include <graphics/monitor.h>
27 #include <graphics/modeid.h>
28 #include <intuition/classes.h>
29 #include <intuition/gadgetclass.h>
30 #include <intuition/intuitionbase.h>
32 #include "moned_globals.h" // my private data
34 #include <proto/exec.h> // use amiga library stuff
35 #include <proto/dos.h>
36 #include <proto/graphics.h>
37 #include <proto/intuition.h>
38 #include <proto/gadtools.h>
39 #include <proto/diskfont.h>
40 #include <proto/asl.h>
41 #include <proto/icon.h>
43 #include <stdio.h> // and the thing we all use!
53 #define TOOLS_IDCMP ARROWIDCMP | BUTTONIDCMP | CHECKBOXIDCMP |\
54 INTEGERIDCMP | LISTVIEWIDCMP | MXIDCMP |\
55 CYCLEIDCMP | PALETTEIDCMP | SCROLLERIDCMP |\
56 SLIDERIDCMP | STRINGIDCMP
58 BOOL Monitor_Editable
= TRUE
;
62 UWORD Qualifier
, Code
, Prev_Code
;
63 struct Gadget
*IObject
;
65 struct TextAttr thinpaz8
= {
66 ( STRPTR
)"thinpaz.font", 8, 0x00, 0x00 };
67 struct TextAttr Topaz80
= {
68 ( STRPTR
)"topaz.font", 8, 0x00, 0x00 };
70 struct Screen
*MainScreen
;
71 struct TextFont
*thinpazfont8
;
72 struct TextAttr
*default_font
;
74 struct MonitorSpec
*currmonitor
;
75 struct MonitorSpec oldmonitor
;
76 struct SpecialMonitor oldspecial
;
78 #include "moned_rev.h"
80 UBYTE verstr
[]={ VERSTAG
};
85 * --- All my requesters use these tags
87 struct TagItem ReqTags
[] = {
92 {WA_IDCMP
, IDCMP_CLOSEWINDOW
| TOOLS_IDCMP
| IDCMP_VANILLAKEY
| IDCMP_REFRESHWINDOW
},
93 {WA_Flags
, WFLG_DRAGBAR
| WFLG_DEPTHGADGET
| WFLG_CLOSEGADGET
| WFLG_ACTIVATE
| WFLG_RMBTRAP
| WFLG_SMART_REFRESH
| WFLG_GIMMEZEROZERO
},
96 {WA_AutoAdjust
, TRUE
},
97 {WA_CustomScreen
, 0l},
101 * --- window gadget ID's
112 #define GD_TOTCLKS 10
124 * --- Program gadget pointers that needs to be changed.
126 struct Window
*sp_Wnd
= NULL
;
139 struct Gadget
*sp_GList
= NULL
;
142 UBYTE
*sp_Title
= "MonitorSpec Ed V3a (Raul. A. Sobon)";
145 * --- TagItems for the slider gadgets.
147 struct TagItem sp_HsyncTags
[] = {
148 {GTSL_LevelFormat
, (IPTR
)"%03lx"},
149 {GTSL_MaxLevelLen
, 3L},
152 {GA_Disabled
, FALSE
},
155 struct TagItem sp_VsyncTags
[] = {
156 {GTSL_LevelFormat
, (IPTR
)"%04lx"},
157 {GTSL_MaxLevelLen
, 4L},
160 {GA_Disabled
, FALSE
},
163 struct TagItem sp_RowTags
[] = {
164 {GTSL_LevelFormat
, (IPTR
)"%03lx"},
165 {GTSL_MaxLevelLen
, 3L},
168 {GA_Disabled
, FALSE
},
171 struct TagItem sp_TotClkTags
[] = {
172 {GTSL_LevelFormat
, (IPTR
)"%03lx"},
173 {GTSL_MaxLevelLen
, 3L},
176 {GA_Disabled
, FALSE
},
188 VOID __stdargs
ShowFault(LONG code
,char *header
)
190 struct EasyStruct EasyStruct
;
192 char ErrorString
[80];
194 EasyStruct
.es_StructSize
= sizeof(struct EasyStruct
);
195 EasyStruct
.es_Flags
= 0;
196 EasyStruct
.es_Title
= "MonitorSpec Ed";
197 EasyStruct
.es_GadgetFormat
= "Ok";
200 EasyStruct
.es_TextFormat
= header
;
203 Fault(code
,header
,ErrorString
,80);
205 EasyStruct
.es_TextFormat
= ErrorString
;
208 EasyRequest(NULL
,&EasyStruct
,NULL
,NULL
);
213 void SetAllProps( void ){
215 if( currmonitor
->ms_Special
){
216 GT_SetGadgetAttrs( sp_HBSTRT
, sp_Wnd
, NULL
, GTSL_Level
, currmonitor
->ms_Special
->hblank
.asi_Start
, TAG_DONE
);
217 GT_SetGadgetAttrs( sp_HSSTRT
, sp_Wnd
, NULL
, GTSL_Level
, currmonitor
->ms_Special
->hsync
.asi_Start
, TAG_DONE
);
218 GT_SetGadgetAttrs( sp_HSSTOP
, sp_Wnd
, NULL
, GTSL_Level
, currmonitor
->ms_Special
->hsync
.asi_Stop
, TAG_DONE
);
219 GT_SetGadgetAttrs( sp_HBSTOP
, sp_Wnd
, NULL
, GTSL_Level
, currmonitor
->ms_Special
->hblank
.asi_Stop
, TAG_DONE
);
220 GT_SetGadgetAttrs( sp_VBSTRT
, sp_Wnd
, NULL
, GTSL_Level
, currmonitor
->ms_Special
->vblank
.asi_Start
, TAG_DONE
);
221 GT_SetGadgetAttrs( sp_VSSTRT
, sp_Wnd
, NULL
, GTSL_Level
, currmonitor
->ms_Special
->vsync
.asi_Start
, TAG_DONE
);
222 GT_SetGadgetAttrs( sp_VSSTOP
, sp_Wnd
, NULL
, GTSL_Level
, currmonitor
->ms_Special
->vsync
.asi_Stop
, TAG_DONE
);
223 GT_SetGadgetAttrs( sp_VBSTOP
, sp_Wnd
, NULL
, GTSL_Level
, currmonitor
->ms_Special
->vblank
.asi_Stop
, TAG_DONE
);
225 GT_SetGadgetAttrs( sp_TOTROWS
, sp_Wnd
, NULL
, GTSL_Level
,currmonitor
->total_rows
, TAG_DONE
);
226 GT_SetGadgetAttrs( sp_TOTCLKS
, sp_Wnd
, NULL
, GTSL_Level
,currmonitor
->total_colorclocks
, TAG_DONE
);
232 * --- Reads a message from the window message port.
233 * --- Returns TRUE if a message was read and puts the
234 * --- message data in the globals. Return FALSE if there
235 * --- was no message at the port.
237 long ReadIMsg( struct Window
*iwnd
)
239 struct IntuiMessage
*imsg
;
241 if ((imsg
= GT_GetIMsg( iwnd
->UserPort
))) {
242 IClass
= imsg
->Class
;
243 Qualifier
= imsg
->Qualifier
;
245 IObject
= imsg
->IAddress
;
246 DMSG(printf("Got message, IClass 0x%08X, Qualifier 0x%04X, Code %u, IObject %p\n", IClass
, Qualifier
, Code
, IObject
));
248 GT_ReplyIMsg( imsg
);
258 * --- Clears all message from a message port.
260 void ClearMsgPort( struct MsgPort
*mport
)
262 struct IntuiMessage
*msg
;
264 while ((msg
= GT_GetIMsg( mport
))) GT_ReplyIMsg( msg
);
272 * --- Open lots of libraries that I need.
274 long OpenLibraries( void ){
276 if ( !(IconBase
= (struct Library
*) OpenLibrary((UBYTE
*) "icon.library" , 36l ))) {
277 WriteStr("\ticon.library\n");
281 if ( !(GfxBase
= (struct GfxBase
*) OpenLibrary((UBYTE
*) "graphics.library" , 36l ))) {
282 WriteStr("\tgraphics.library\n");
286 if ( !(DosBase
= (struct DosBase
*) OpenLibrary((UBYTE
*) "dos.library", 36l ))) {
287 WriteStr("\tdos.library\n");
291 if ( !(IntuitionBase
= (struct IntuitionBase
*) OpenLibrary((UBYTE
*) "intuition.library", 36l ))) {
292 WriteStr("\tintuition.library\n");
296 if ( !(AslBase
= (struct Library
*) OpenLibrary((UBYTE
*) "asl.library", 37l ))) {
297 WriteStr("\tasl.library\n");
301 if ( !(GadToolsBase
= (struct Library
*) OpenLibrary((UBYTE
*) "gadtools.library", 36l ))) {
302 WriteStr("\tgadtools.library\n");
306 if ( !(DiskFontBase
= (struct Library
*) OpenLibrary((UBYTE
*) "diskfont.library", 36l ))) {
307 WriteStr("\tdiskfont.library\n");
318 * --- Close the libraries which are opened by me.
320 void CloseLibraries( void ){
321 if (DiskFontBase
) CloseLibrary( (struct Library
*) DiskFontBase
);
322 if (GadToolsBase
) CloseLibrary( (struct Library
*) GadToolsBase
);
323 if (AslBase
) CloseLibrary( (struct Library
*) AslBase
);
324 if (IntuitionBase
) CloseLibrary( (struct Library
*) IntuitionBase
);
325 if (DosBase
) CloseLibrary( (struct Library
*) DosBase
);
326 if (GfxBase
) CloseLibrary( (struct Library
*) GfxBase
);
327 if (IconBase
) CloseLibrary( (struct Library
*) IconBase
);
331 void SaveMonitor( void ){
333 CopyMem( currmonitor
, &oldmonitor
, sizeof( struct MonitorSpec
) );
334 if( currmonitor
->ms_Special
)
335 CopyMem( currmonitor
->ms_Special
, &oldspecial
, sizeof( struct SpecialMonitor
) );
340 void RestoreMonitor( void ){
342 CopyMem( &oldmonitor
, currmonitor
, sizeof( struct MonitorSpec
) );
343 if( currmonitor
->ms_Special
)
344 CopyMem( &oldspecial
, currmonitor
->ms_Special
, sizeof( struct SpecialMonitor
) );
353 static UBYTE mon
[16];
356 void SaveDetails( void ){
357 struct DiskObject
*diskobj
;
370 sprintf( monname
,"DEVS:Monitors/%s",mon
);
371 if ((diskobj
=GetDiskObject( monname
))){
372 oldtxtptrs
= diskobj
->do_ToolTypes
;
374 sprintf( &tt
[0][10],"%02x",currmonitor
->total_rows
);
375 sprintf( &tt
[1][10],"%02x",currmonitor
->total_colorclocks
);
376 txtptrs
[0] = &tt
[0][0];
377 txtptrs
[1] = &tt
[1][0];
379 if( currmonitor
->ms_Special
){
380 sprintf( &tt
[2][9],"%02x", currmonitor
->ms_Special
->hblank
.asi_Start
);
381 sprintf( &tt
[3][9],"%02x", currmonitor
->ms_Special
->hblank
.asi_Stop
);
382 sprintf( &tt
[4][9],"%02x", currmonitor
->ms_Special
->vblank
.asi_Start
);
383 sprintf( &tt
[5][9],"%02x", currmonitor
->ms_Special
->vblank
.asi_Stop
);
384 txtptrs
[2] = &tt
[2][0];
385 txtptrs
[3] = &tt
[3][0];
386 txtptrs
[4] = &tt
[4][0];
387 txtptrs
[5] = &tt
[5][0];
393 diskobj
->do_ToolTypes
= txtptrs
;
394 if( !PutDiskObject( monname
, diskobj
) )
395 ShowFault(IoErr(),"icon.library/PutDiskObject()");
397 diskobj
->do_ToolTypes
= oldtxtptrs
;
398 FreeDiskObject( diskobj
);
401 ShowFault(IoErr(),"icon.library/GetDiskObject()");
404 ShowFault(0, "Invalid monitor in use");
413 void UpDateMonitor( void ){
415 if( currmonitor
->ms_Special
){
416 if( currmonitor
->ms_Special
->do_monitor
) {
417 currmonitor
->ms_Special
->do_monitor(currmonitor
);
418 MakeScreen( (struct Screen
*)MainScreen
);
427 #define PICASSO_MONITOR_ID 0x000f1000
428 #define EGS24_MONITOR_ID 0x04001000
430 void UpDateDisplay( void ){
432 ULONG rows
=0,clks
=0,fps
,scan
,mode
;
435 rows
= currmonitor
->total_rows
;
436 clks
= currmonitor
->total_colorclocks
;
439 fps
= abs(1000000000/(rows
*clks
*280));
444 mode
= GetVPModeID(&IntuitionBase
->ActiveScreen
->ViewPort
)&MONITOR_ID_MASK
;
446 switch( (ULONG
)(mode
) ) {
447 case NTSC_MONITOR_ID
: sprintf(mon
,"NTSC");break;
448 case PAL_MONITOR_ID
: sprintf(mon
,"PAL");break;
449 case VGA_MONITOR_ID
: sprintf(mon
,"Multiscan");break;
450 case A2024_MONITOR_ID
: sprintf(mon
,"A2024");break;
451 case PROTO_MONITOR_ID
: sprintf(mon
,"PROTO");break;
452 case EURO72_MONITOR_ID
: sprintf(mon
,"EURO72");break;
453 case EURO36_MONITOR_ID
: sprintf(mon
,"EURO36");break;
454 case SUPER72_MONITOR_ID
: sprintf(mon
,"SUPER72");break;
455 case DBLNTSC_MONITOR_ID
:
456 if( version
>= 39 ) sprintf(mon
,"DBLNTSC"); else sprintf(mon
,"DoubleNTSC");
458 case DBLPAL_MONITOR_ID
:
459 if( version
>= 39 ) sprintf(mon
,"DBLPAL"); else sprintf(mon
,"DoublePAL");
461 case PICASSO_MONITOR_ID
: sprintf(mon
,"PICASSO");break;
462 case EGS24_MONITOR_ID
: sprintf(mon
,"EGS-SPECTRUM");break;
463 case DEFAULT_MONITOR_ID
: sprintf(mon
,"PAL");break;
464 default: sprintf(mon
,"CUSTOM(%4x)",mode
);break;
467 sprintf(tstr
,"%s: %02d.%02d Khz, %02d Hz ",mon
,scan
/1000,(scan
%1000)*10,fps
);
469 SetAPen( sp_Wnd
->RPort
, 2 );
470 Move( sp_Wnd
->RPort
, 9, 136 );
471 Text( sp_Wnd
->RPort
, tstr
, strlen(tstr
) );
472 // printf( "*** %s",tstr );
475 printf( "%s.\n", tstr
);
485 /**********************************************************************
488 * Description : just like normal bevelbox except inside color is selectable
489 * plus it looks MONUMENTAL!
490 * ¯¯¯¯¯¯¯¯¯¯¯
496 struct RastPort
*rp
, // window rastport to draw into
497 UWORD xpos
, // X coordinate to place MEGA-BEVEL
498 UWORD ypos
, // Y coordinate to place MEGA-BEVEL
499 UWORD xsize
, // X size of MEGA-BEVEL
500 UWORD ysize
, // X size of MEGA-BEVEL
501 UWORD shine_pen
, // top-left pen
502 UWORD body_pen
, // central pen
503 UWORD shadow_pen
// bot-right pen
506 #define LineDraw(x,y,x2,y2) Move( rp, x , y); \
511 if( body_pen
== 0xffff )
512 SetAPen( rp
, shine_pen
);
514 SetAPen( rp
, body_pen
);
515 RectFill( rp
, xpos
, ypos
, xpos
+xsize
, ypos
+ysize
);
518 LineDraw( xpos
, ypos
, xpos
+1, ypos
+1 );
519 LineDraw( xpos
+xsize
-1, ypos
+ysize
-1, xpos
+xsize
, ypos
+ysize
);
521 SetAPen( rp
, shine_pen
);
522 LineDraw( xpos
+0, ypos
+0, xpos
+xsize
-1, ypos
);
523 LineDraw( xpos
+0, ypos
+1, xpos
+xsize
-2, ypos
+1 );
524 LineDraw( xpos
+0, ypos
+0, xpos
, ypos
+ysize
-1 );
525 LineDraw( xpos
+1, ypos
+0, xpos
+1, ypos
+ysize
-2 );
527 SetAPen( rp
, shadow_pen
);
528 LineDraw( xpos
+1, ypos
+ysize
-0, xpos
+xsize
-1, ypos
+ysize
-0 );
529 LineDraw( xpos
+2, ypos
+ysize
-1, xpos
+xsize
-2, ypos
+ysize
-1 );
530 LineDraw( xpos
+xsize
-0, ypos
+1, xpos
+xsize
-0, ypos
+ysize
-1 );
531 LineDraw( xpos
+xsize
-1, ypos
+2, xpos
+xsize
-1, ypos
+ysize
-2 );
534 if( shine_pen
== shadow_pen
){
535 SetAPen( rp
, shine_pen
);
536 LineDraw( xpos
, ypos
+ysize
, xpos
+1, ypos
+ysize
-1 );
537 LineDraw( xpos
+xsize
-1, ypos
+1, xpos
+xsize
, ypos
);
540 if(shine_pen
> shadow_pen
){
541 LineDraw( xpos
+0, ypos
+0, xpos
+2, ypos
+0 );
542 LineDraw( xpos
+0, ypos
+0, xpos
+0, ypos
+2 );
545 LineDraw( xpos
+xsize
, ypos
+ysize
, xpos
+xsize
-2, ypos
+ysize
);
546 LineDraw( xpos
+xsize
, ypos
+ysize
, xpos
+xsize
-0, ypos
+ysize
-2 );
555 /**********************************************************************
558 * Description : just like normal line except its 3D (sorta!) (horizontal)
559 * plus it looks MONUMENTAL!
560 * ¯¯¯¯¯¯¯¯¯¯¯
566 struct RastPort
*rp
, // window rastport to draw into
567 UWORD xpos
, // X coordinate to place MEGA-BEVEL
568 UWORD ypos
, // Y coordinate to place MEGA-BEVEL
569 UWORD xsize
, // X size of MEGA-BEVEL
570 UWORD shine_pen
, // top-left pen
571 UWORD shadow_pen
// bot-right pen
576 SetAPen( rp
, shine_pen
);
577 LineDraw( xpos
+0, ypos
+0, xpos
+xsize
, ypos
+0 );
578 SetAPen( rp
, shadow_pen
);
579 LineDraw( xpos
+0, ypos
+1, xpos
+xsize
, ypos
+1 );
584 long OpenDisplay( void ){
587 ReqTags
[7].ti_Data
= (ULONG
)sp_Title
;
588 ReqTags
[9].ti_Data
= (Tag
)MainScreen
;
590 if ( ! (thinpazfont8
= OpenDiskFont( &thinpaz8
)) ) {
591 thinpazfont8
= OpenDiskFont( &Topaz80
);
592 default_font
= &Topaz80
;
594 default_font
= &thinpaz8
;
595 D(printf("Font: %p\n", thinpazfont8
));
597 currmonitor
= GfxBase
->current_monitor
;
598 D(printf("Current monitor: %p\n", currmonitor
));
603 sp_RowTags
[4].ti_Data
= FALSE
;
604 sp_TotClkTags
[4].ti_Data
= FALSE
;
605 Monitor_Editable
= TRUE
;
608 sp_RowTags
[4].ti_Data
= TRUE
;
609 sp_TotClkTags
[4].ti_Data
= TRUE
;
610 Monitor_Editable
= FALSE
;
613 if ( currmonitor
&& currmonitor
->ms_Special
){
614 sp_HsyncTags
[4].ti_Data
= FALSE
;
615 sp_VsyncTags
[4].ti_Data
= FALSE
;
616 Monitor_Editable
= TRUE
;
619 sp_HsyncTags
[4].ti_Data
= TRUE
;
620 sp_VsyncTags
[4].ti_Data
= TRUE
;
621 Monitor_Editable
= FALSE
;
624 D(printf("Monitor is editable: %d\n", Monitor_Editable
));
627 if ( ! ( MainVisualInfo
= GetVisualInfo( MainScreen
, TAG_DONE
)))
629 D(printf("VisualInfo %p\n", MainVisualInfo
));
633 if ((g
= CreateContext( &sp_GList
))) {
634 D(printf("GadTools context: %p\n", g
));
640 ng
.ng_GadgetText
= "HBSTRT: ";
641 ng
.ng_TextAttr
= default_font
;
642 ng
.ng_GadgetID
= GD_HBSTRT
;
643 ng
.ng_Flags
= PLACETEXT_LEFT
| NG_HIGHLABEL
;
644 ng
.ng_VisualInfo
= MainVisualInfo
;
645 ng
.ng_UserData
= NULL
;
646 sp_HBSTRT
= g
= CreateGadgetA( SLIDER_KIND
, g
, &ng
, sp_HsyncTags
);
647 D(printf("HBSTRT gadget: %p, at (%d, %d)\n", g
, ng
.ng_LeftEdge
, ng
.ng_TopEdge
));
649 ng
.ng_TopEdge
+= YSTEP
;
650 ng
.ng_GadgetText
= "HSSTRT: ";
651 ng
.ng_GadgetID
= GD_HSSTRT
;
652 sp_HSSTRT
= g
= CreateGadgetA( SLIDER_KIND
, g
, &ng
, sp_HsyncTags
);
653 D(printf("HSSTRT gadget: %p, at (%d, %d)\n", g
, ng
.ng_LeftEdge
, ng
.ng_TopEdge
));
655 ng
.ng_TopEdge
+= YSTEP
;
656 ng
.ng_GadgetText
= "HSSTOP: ";
657 ng
.ng_GadgetID
= GD_HSSTOP
;
658 sp_HSSTOP
= g
= CreateGadgetA( SLIDER_KIND
, g
, &ng
, sp_HsyncTags
);
659 D(printf("HSSTOP gadget: %p, at (%d, %d)\n", g
, ng
.ng_LeftEdge
, ng
.ng_TopEdge
));
661 ng
.ng_TopEdge
+= YSTEP
;
662 ng
.ng_GadgetText
= "HBSTOP: ";
663 ng
.ng_GadgetID
= GD_HBSTOP
;
664 sp_HBSTOP
= g
= CreateGadgetA( SLIDER_KIND
, g
, &ng
, sp_HsyncTags
);
665 D(printf("HBSTOP gadget: %p, at (%d, %d)\n", g
, ng
.ng_LeftEdge
, ng
.ng_TopEdge
));
667 ng
.ng_TopEdge
+= YSTEP
;
668 ng
.ng_GadgetText
= "TOTCLKS: ";
669 ng
.ng_GadgetID
= GD_TOTCLKS
;
670 sp_TOTCLKS
= g
= CreateGadgetA( SLIDER_KIND
, g
, &ng
, sp_TotClkTags
);
671 D(printf("TOTCLKS gadget: %p, at (%d, %d)\n", g
, ng
.ng_LeftEdge
, ng
.ng_TopEdge
));
673 ng
.ng_TopEdge
+= YSTEP
;
674 ng
.ng_GadgetText
= "VBSTRT: ";
675 ng
.ng_GadgetID
= GD_VBSTRT
;
676 sp_VBSTRT
= g
= CreateGadgetA( SLIDER_KIND
, g
, &ng
, sp_VsyncTags
);
677 D(printf("VBSTRT gadget: %p, at (%d, %d)\n", g
, ng
.ng_LeftEdge
, ng
.ng_TopEdge
));
679 ng
.ng_TopEdge
+= YSTEP
;
680 ng
.ng_GadgetText
= "VSSTRT: ";
681 ng
.ng_GadgetID
= GD_VSSTRT
;
682 sp_VSSTRT
= g
= CreateGadgetA( SLIDER_KIND
, g
, &ng
, sp_VsyncTags
);
683 D(printf("VSSTRT gadget: %p, at (%d, %d)\n", g
, ng
.ng_LeftEdge
, ng
.ng_TopEdge
));
685 ng
.ng_TopEdge
+= YSTEP
;
686 ng
.ng_GadgetText
= "VSSTOP: ";
687 ng
.ng_GadgetID
= GD_VSSTOP
;
688 sp_VSSTOP
= g
= CreateGadgetA( SLIDER_KIND
, g
, &ng
, sp_VsyncTags
);
689 D(printf("VSSTOP gadget: %p, at (%d, %d)\n", g
, ng
.ng_LeftEdge
, ng
.ng_TopEdge
));
691 ng
.ng_TopEdge
+= YSTEP
;
692 ng
.ng_GadgetText
= "VBSTOP: ";
693 ng
.ng_GadgetID
= GD_VBSTOP
;
694 sp_VBSTOP
= g
= CreateGadgetA( SLIDER_KIND
, g
, &ng
, sp_VsyncTags
);
695 D(printf("VBSTOP gadget: %p, at (%d, %d)\n", g
, ng
.ng_LeftEdge
, ng
.ng_TopEdge
));
697 ng
.ng_TopEdge
+= YSTEP
;
698 ng
.ng_GadgetText
= "TOTROWS: ";
699 ng
.ng_GadgetID
= GD_TOTROWS
;
700 sp_TOTROWS
= g
= CreateGadgetA( SLIDER_KIND
, g
, &ng
, sp_RowTags
);
701 D(printf("TOTROWS gadget: %p, at (%d, %d)\n", g
, ng
.ng_LeftEdge
, ng
.ng_TopEdge
));
704 y1
= ng
.ng_TopEdge
= 142;
705 x1
= ng
.ng_LeftEdge
= 89;
707 h
= ng
.ng_Height
= 14;
708 ng
.ng_Flags
= PLACETEXT_IN
;
709 ng
.ng_GadgetText
= "_USE";
710 ng
.ng_GadgetID
= GD_USE
;
711 g
= CreateGadget( BUTTON_KIND
, g
, &ng
, GT_Underscore
, (Tag
)'_', TAG_DONE
);
712 D(printf("USE gadget: %p, at (%d, %d)\n", g
, ng
.ng_LeftEdge
, ng
.ng_TopEdge
));
714 ng
.ng_LeftEdge
= 144;
715 ng
.ng_GadgetText
= "_SAVE";
716 ng
.ng_GadgetID
= GD_SAVE
;
717 g
= CreateGadget( BUTTON_KIND
, g
, &ng
, GT_Underscore
, (Tag
)'_', TAG_DONE
);
718 D(printf("SAVE gadget: %p, at (%d, %d)\n", g
, ng
.ng_LeftEdge
, ng
.ng_TopEdge
));
720 ng
.ng_LeftEdge
= 199;
721 ng
.ng_GadgetText
= "_CANCEL";
722 ng
.ng_GadgetID
= GD_CANCEL
;
723 g
= CreateGadget( BUTTON_KIND
, g
, &ng
, GT_Underscore
, (Tag
)'_', TAG_DONE
);
724 D(printf("CANCEL gadget: %p, at (%d, %d)\n", g
, ng
.ng_LeftEdge
, ng
.ng_TopEdge
));
726 ng
.ng_LeftEdge
= 254;
727 ng
.ng_GadgetText
= "_JUMP";
728 ng
.ng_GadgetID
= GD_JUMP
;
729 g
= CreateGadget( BUTTON_KIND
, g
, &ng
, GT_Underscore
, (Tag
)'_', TAG_DONE
);
730 D(printf("JUMP gadget: %p, at (%d, %d)\n", g
, ng
.ng_LeftEdge
, ng
.ng_TopEdge
));
734 //ReqTags[6].ti_Data = (Tag)sp_GList;
735 offy
= MainScreen
->WBorTop
+ MainScreen
->RastPort
.TxHeight
+ MainScreen
->WBorBottom
;
736 ReqTags
[3].ti_Data
= 164+offy
;
737 D(printf("Opening window, size %ld x %ld...\n", ReqTags
[2].ti_Data
, ReqTags
[3].ti_Data
));
738 if ((sp_Wnd
= OpenWindowTagList( NULL
, ReqTags
))) {
739 D(printf("Window %p\n", sp_Wnd
));
740 SetFont( sp_Wnd
->RPort
, thinpazfont8
);
741 if( MainScreen
->BitMap
.Depth
> 2 ) {
742 Draw3DBox( sp_Wnd
->RPort
, 0, 0, sp_Wnd
->Width
-sp_Wnd
->BorderLeft
-sp_Wnd
->BorderRight
,
743 sp_Wnd
->Height
-sp_Wnd
->BorderTop
-sp_Wnd
->BorderBottom
, 2, 3, 1 );
745 Draw3DLine( sp_Wnd
->RPort
, 1, 125,sp_Wnd
->Width
-sp_Wnd
->BorderLeft
-sp_Wnd
->BorderRight
-3, 1, 2 );
747 SetAPen( sp_Wnd
->RPort
, 2 );
748 SetBPen( sp_Wnd
->RPort
, 3 );
750 AddGList( sp_Wnd
, sp_GList
, 0, -1, NULL
);
751 RefreshGList( sp_GList
, sp_Wnd
, 0, 0);
752 GT_RefreshWindow( sp_Wnd
, NULL
);
756 Draw3DBox( sp_Wnd
->RPort
, x1
-2, y1
-2, w
+4, h
+4, 1, 0xffff, 1 );
769 void CloseDisplay( void ) {
772 CloseFont( thinpazfont8
);
774 if ( MainVisualInfo
) {
775 FreeVisualInfo( MainVisualInfo
);
776 MainVisualInfo
= NULL
;
778 if ( sp_Wnd
) CloseWindow( sp_Wnd
);
779 if ( sp_GList
) FreeGadgets( sp_GList
);
785 LONG
xtoi( UBYTE
*txt
){
788 sscanf( txt
,"%x",&n
);
796 // ----------------------------------------------------------------------------------------------
797 int main( int argc
,char *argv
[] )
802 if( !OpenLibraries() ) {
803 ShowFault(0, "Libraries cant be opened!");
808 version
=IntuitionBase
->LibNode
.lib_Version
;
810 MainScreen
= (struct Screen
*)(IntuitionBase
->ActiveScreen
);
814 currmonitor
= GfxBase
->current_monitor
;
817 if( *argv
[1] == '?' ){
818 puts( "Moned3a, © 1994 Raul Sobon / PRoJeCT-23");
819 puts( " moned HBSTRT=0xnnn HBSTOP=0xnnn HBSTOP=0xnnn");
820 puts( " HSSTRT=0xnnn HSSTOP=0xnnn VBSTRT=0xnnn");
821 puts( " VBSTOP=0xnnn VSSTRT=0xnnn VSSTOP=0xnnn");
822 // puts( " MAXOSC=0xnnn VIDOSC=0xnnn xxxxxx=0xnnn");
823 puts( "NOTE: each item is optional and can be in any order and nnn is a hex number.");
827 WORD count
= argc
,lp
=1;
833 //printf("str=<%s> n=<%s>=%d\n",cmd,num,xtoi( num ) );
834 if( currmonitor
->ms_Special
){
835 if( !strnicmp( "HBSTRT=0x", cmd
, 9 ) ) currmonitor
->ms_Special
->hblank
.asi_Start
=xtoi( num
);
836 else if( !strnicmp( "HBSTOP=0x", cmd
, 9 ) ) currmonitor
->ms_Special
->hblank
.asi_Stop
=xtoi( num
);
837 else if( !strnicmp( "HSSTRT=0x", cmd
, 9 ) ) currmonitor
->ms_Special
->hsync
.asi_Start
=xtoi( num
);
838 else if( !strnicmp( "HSSTOP=0x", cmd
, 9 ) ) currmonitor
->ms_Special
->hsync
.asi_Stop
=xtoi( num
);
839 else if( !strnicmp( "VBSTRT=0x", cmd
, 9 ) ) currmonitor
->ms_Special
->vblank
.asi_Start
=xtoi( num
);
840 else if( !strnicmp( "VBSTOP=0x", cmd
, 9 ) ) currmonitor
->ms_Special
->vblank
.asi_Stop
=xtoi( num
);
841 else if( !strnicmp( "VSSTRT=0x", cmd
, 9 ) ) currmonitor
->ms_Special
->vsync
.asi_Start
=xtoi( num
);
842 else if( !strnicmp( "VSSTOP=0x", cmd
, 9 ) ) currmonitor
->ms_Special
->vsync
.asi_Stop
=xtoi( num
);
845 if( !strnicmp( "TOTROW=0x", cmd
, 9 ) ) {
846 currmonitor
->total_rows
=xtoi( num
); update
= TRUE
; }
847 else if( !strnicmp( "TOTCLK=0x", cmd
, 9 ) ) {
848 currmonitor
->total_colorclocks
=xtoi( num
); update
= TRUE
; }
849 // else if( !strnicmp( "MAXOSC=0x", cmd , 9 ) ) {
850 // currmonitor->ms_maxoscan=xtoi( num ); update = TRUE; }
851 // else if( !strnicmp( "VIDOSC=0x", cmd , 9 ) ) {
852 // currmonitor->ms_videoscan=xtoi( num ); update = TRUE; }
858 // printf("Display updated.\n");
861 printf("argument <%s> invalid?\n",cmd
);
865 if( OpenDisplay() ) {
867 WaitPort( sp_Wnd
->UserPort
);
869 while ( ReadIMsg( sp_Wnd
)) {
873 case IDCMP_ACTIVEWINDOW
:
874 DIDCMP(printf("Window activate\n"));
875 ClearMsgPort( sp_Wnd
->UserPort
);
878 case IDCMP_REFRESHWINDOW
:
879 DIDCMP(printf("Window refresh\n"));
880 GT_BeginRefresh( sp_Wnd
);
881 GT_EndRefresh( sp_Wnd
, TRUE
);
884 case IDCMP_CLOSEWINDOW
:
885 DIDCMP(printf("Window close\n"));
889 case IDCMP_VANILLAKEY
:
890 DIDCMP(printf("Keypress\n"));
893 if( Monitor_Editable
){
894 GT_SetGadgetAttrs(sp_TOTCLKS
,sp_Wnd
,0,GTSL_Level
, --currmonitor
->total_colorclocks
,TAG_DONE
);
899 if( Monitor_Editable
){
900 GT_SetGadgetAttrs(sp_TOTCLKS
,sp_Wnd
,0,GTSL_Level
, ++currmonitor
->total_colorclocks
,TAG_DONE
);
906 if( Monitor_Editable
){
907 GT_SetGadgetAttrs(sp_TOTROWS
,sp_Wnd
,0,GTSL_Level
, --currmonitor
->total_rows
,TAG_DONE
);
912 if( Monitor_Editable
){
913 GT_SetGadgetAttrs(sp_TOTROWS
,sp_Wnd
,0,GTSL_Level
, ++currmonitor
->total_rows
,TAG_DONE
);
933 case IDCMP_MOUSEMOVE
:
934 DIDCMP(printf("Mouse move\n"));
935 switch ( IObject
->GadgetID
) {
937 if( currmonitor
->ms_Special
){
938 currmonitor
->ms_Special
->hblank
.asi_Start
= Code
;
943 if( currmonitor
->ms_Special
){
944 currmonitor
->ms_Special
->hsync
.asi_Start
= Code
;
949 if( currmonitor
->ms_Special
){
950 currmonitor
->ms_Special
->hsync
.asi_Stop
= Code
;
955 if( currmonitor
->ms_Special
){
956 currmonitor
->ms_Special
->hblank
.asi_Stop
= Code
;
962 if( currmonitor
->ms_Special
){
963 currmonitor
->ms_Special
->vblank
.asi_Start
= Code
;
968 if( currmonitor
->ms_Special
){
969 currmonitor
->ms_Special
->vsync
.asi_Start
= Code
;
974 if( currmonitor
->ms_Special
){
975 currmonitor
->ms_Special
->vsync
.asi_Stop
= Code
;
980 if( currmonitor
->ms_Special
){
981 currmonitor
->ms_Special
->vblank
.asi_Stop
= Code
;
987 currmonitor
->total_rows
= Code
;
991 currmonitor
->total_colorclocks
= Code
;
998 DIDCMP(printf("Gadget up\n"));
999 switch ( IObject
->GadgetID
) {
1002 if( Monitor_Editable
){
1024 MainScreen
= (struct Screen
*)(MainScreen
->NextScreen
);
1026 MainScreen
= (struct Screen
*)(IntuitionBase
->FirstScreen
);
1028 ScreenToFront( MainScreen
);