1 /* aNetHack 0.0.1 winreq.c $ANH-Date: 1432512796 2015/05/25 00:13:16 $ $ANH-Branch: master $:$ANH-Revision: 1.8 $ */
2 /* Copyright (c) Gregg Wonderly, Naperville, Illinois, 1991,1992,1993. */
3 /* aNetHack may be freely redistributed. See license for details. */
5 #include "NH:sys/amiga/windefs.h"
6 #include "NH:sys/amiga/winext.h"
7 #include "NH:sys/amiga/winproto.h"
13 #define GADCOLCANCEL 6
16 UBYTE UNDOBUFFER
[300];
17 SHORT BorderVectors1
[] = { 0, 0, 57, 0, 57, 11, 0, 11, 0, 0 };
18 struct Border Border1
= { -1, -1, 3, 0, JAM1
, 5, BorderVectors1
, NULL
};
19 struct IntuiText IText1
= { 3, 0, JAM1
, 4, 1, NULL
, (UBYTE
*) "Cancel",
21 struct Gadget Gadget2
= { NULL
, 9, 15, 56, 10, NULL
, RELVERIFY
, BOOLGADGET
,
22 (APTR
) &Border1
, NULL
, &IText1
, NULL
, NULL
, 1,
24 UBYTE StrStringSIBuff
[300];
25 struct StringInfo StrStringSInfo
= { StrStringSIBuff
, UNDOBUFFER
, 0, 300, 0,
26 0, 0, 0, 0, 0, 0, 0, NULL
};
27 SHORT BorderVectors2
[] = { 0, 0, 439, 0, 439, 11, 0, 11, 0, 0 };
28 struct Border Border2
= { -1, -1, 3, 0, JAM1
, 5, BorderVectors2
, NULL
};
29 struct Gadget String
= { &Gadget2
, 77, 15, 438, 10, NULL
,
30 RELVERIFY
+ STRINGCENTER
, STRGADGET
, (APTR
) &Border2
,
31 NULL
, NULL
, NULL
, (APTR
) &StrStringSInfo
, 2, NULL
};
34 ((char *) (((struct StringInfo *) (String.SpecialInfo))->Buffer))
36 struct NewWindow StrWindow
= {
37 57, 74, 526, 31, 0, 1, GADGETUP
+ CLOSEWINDOW
+ ACTIVEWINDOW
+ VANILLAKEY
,
38 WINDOWDRAG
+ WINDOWDEPTH
+ WINDOWCLOSE
+ ACTIVATE
+ NOCAREREFRESH
,
39 &String
, NULL
, NULL
, NULL
, NULL
, 5, 5, 0xffff, 0xffff, CUSTOMSCREEN
42 #include "NH:sys/amiga/colorwin.c"
51 #include "NH:sys/amiga/clipwin.c"
53 void ClearCol(struct Window
*w
);
58 extern char configfile
[];
59 int i
, done
= 0, okay
= 0;
60 long code
, qual
, class;
61 register struct Gadget
*gd
, *dgad
;
62 register struct Window
*nw
;
63 register struct IntuiMessage
*imsg
;
64 register struct PropInfo
*pip
;
65 register struct Screen
*scrn
;
68 int curcol
= 0, drag
= 0;
69 int bxorx
, bxory
, bxxlen
, bxylen
;
70 static UWORD colors
[AMII_MAXCOLORS
];
71 static UWORD svcolors
[AMII_MAXCOLORS
];
77 Col_NewWindowStructure1
.Width
+= 300;
78 Col_NewWindowStructure1
.Height
+= 20;
79 Col_NewWindowStructure1
.LeftEdge
-= 150;
80 Col_BluePen
.Width
+= 300;
81 Col_RedPen
.Width
+= 300;
82 Col_GreenPen
.Width
+= 300;
83 Col_Cancel
.LeftEdge
+= 300;
84 Col_Okay
.LeftEdge
+= 150;
85 Col_Cancel
.TopEdge
+= 20;
86 Col_Save
.TopEdge
+= 20;
87 Col_Okay
.TopEdge
+= 20;
90 SetBorder(&Col_Cancel
);
95 bxylen
= Col_NewWindowStructure1
.Height
96 - (Col_BluePen
.TopEdge
+ Col_BluePen
.Height
+ 6);
97 bxxlen
= Col_BluePen
.Width
;
98 bxorx
= Col_BluePen
.LeftEdge
;
99 bxory
= Col_BluePen
.TopEdge
+ Col_BluePen
.Height
+ 2;
101 /* Save the current colors */
102 for (i
= 0; i
< amii_numcolors
; ++i
)
103 svcolors
[i
] = colors
[i
] = GetRGB4(scrn
->ViewPort
.ColorMap
, i
);
105 Col_NewWindowStructure1
.Screen
= scrn
;
106 #ifdef INTUI_NEW_LOOK
107 if (IntuitionBase
->LibNode
.lib_Version
>= 37) {
108 ((struct PropInfo
*) Col_BluePen
.SpecialInfo
)->Flags
|= PROPNEWLOOK
;
109 ((struct PropInfo
*) Col_RedPen
.SpecialInfo
)->Flags
|= PROPNEWLOOK
;
110 ((struct PropInfo
*) Col_GreenPen
.SpecialInfo
)->Flags
|= PROPNEWLOOK
;
113 if (WINVERS_AMIV
|| WINVERS_AMII
) {
114 #ifdef INTUI_NEW_LOOK
115 Col_NewWindowStructure1
.Extension
= wintags
;
116 Col_NewWindowStructure1
.Flags
|= WFLG_NW_EXTENDED
;
118 fillhook
.h_Entry
= (void *) &LayerFillHook
;
120 fillhook
.h_Entry
= (ULONG (*) ()) LayerFillHook
;
122 fillhook
.h_Data
= (void *) -2;
123 fillhook
.h_SubEntry
= 0;
127 nw
= OpenWindow((void *) &Col_NewWindowStructure1
);
134 PrintIText(nw
->RPort
, &Col_IntuiTextList1
, 0, 0);
137 DrawCol(nw
, curcol
, colors
);
139 WaitPort(nw
->UserPort
);
141 while (imsg
= (struct IntuiMessage
*) GetMsg(nw
->UserPort
)) {
142 gd
= (struct Gadget
*) imsg
->IAddress
;
145 qual
= imsg
->Qualifier
;
149 ReplyMsg((struct Message
*) imsg
);
153 if (code
== 'v' && qual
== AMIGALEFT
)
155 else if (code
== 'b' && qual
== AMIGALEFT
)
157 else if (code
== 'o' || code
== 'O')
159 else if (code
== 'c' || code
== 'C')
169 if (gd
->GadgetID
== GADREDPEN
|| gd
->GadgetID
== GADBLUEPEN
170 || gd
->GadgetID
== GADGREENPEN
) {
171 pip
= (struct PropInfo
*) gd
->SpecialInfo
;
172 aidx
= pip
->HorizPot
/ (MAXPOT
/ 15);
173 if (gd
->GadgetID
== GADREDPEN
) {
175 (colors
[curcol
] & ~0xf00) | (aidx
<< 8);
176 LoadRGB4(&scrn
->ViewPort
, colors
, amii_numcolors
);
177 } else if (gd
->GadgetID
== GADBLUEPEN
) {
178 colors
[curcol
] = (colors
[curcol
] & ~0xf) | aidx
;
179 LoadRGB4(&scrn
->ViewPort
, colors
, amii_numcolors
);
180 } else if (gd
->GadgetID
== GADGREENPEN
) {
182 (colors
[curcol
] & ~0x0f0) | (aidx
<< 4);
183 LoadRGB4(&scrn
->ViewPort
, colors
, amii_numcolors
);
185 DispCol(nw
, curcol
, colors
);
186 } else if (gd
->GadgetID
== GADCOLOKAY
) {
189 } else if (gd
->GadgetID
== GADCOLSAVE
) {
191 char buf
[300], nname
[300], oname
[300];
194 fp
= fopen(configfile
, "r");
196 pline("can't find aNetHack.cnf");
200 strcpy(oname
, dirname((char *) configfile
));
201 if (oname
[strlen(oname
) - 1] != ':') {
202 sprintf(nname
, "%s/New_aNetHack.cnf", oname
);
204 strcat(oname
, "Old_aNetHack.cnf");
206 sprintf(nname
, "%sNew_aNetHack.cnf", oname
);
207 strcat(oname
, "Old_aNetHack.cnf");
210 nfp
= fopen(nname
, "w");
212 pline("can't write to New_aNetHack.cnf");
216 while (fgets(buf
, sizeof(buf
), fp
)) {
217 if (strncmp(buf
, "PENS=", 5) == 0) {
220 for (i
= 0; i
< amii_numcolors
; ++i
) {
221 fprintf(nfp
, "%03x", colors
[i
]);
222 if ((i
+ 1) < amii_numcolors
)
231 /* If none in the file yet, now write it */
234 for (i
= 0; i
< amii_numcolors
; ++i
) {
235 fprintf(nfp
, "%03x", colors
[i
]);
236 if ((i
+ 1) < amii_numcolors
)
244 if (filecopy((char *) configfile
, oname
) == 0)
245 if (filecopy(nname
, (char *) configfile
) == 0)
249 } else if (gd
->GadgetID
== GADCOLCANCEL
) {
263 pip
= (struct PropInfo
*) dgad
->SpecialInfo
;
264 aidx
= pip
->HorizPot
/ (MAXPOT
/ 15);
265 if (dgad
->GadgetID
== GADREDPEN
) {
266 colors
[curcol
] = (colors
[curcol
] & ~0xf00) | (aidx
<< 8);
267 LoadRGB4(&scrn
->ViewPort
, colors
, amii_numcolors
);
268 } else if (dgad
->GadgetID
== GADBLUEPEN
) {
269 colors
[curcol
] = (colors
[curcol
] & ~0xf) | aidx
;
270 LoadRGB4(&scrn
->ViewPort
, colors
, amii_numcolors
);
271 } else if (dgad
->GadgetID
== GADGREENPEN
) {
272 colors
[curcol
] = (colors
[curcol
] & ~0x0f0) | (aidx
<< 4);
273 LoadRGB4(&scrn
->ViewPort
, colors
, amii_numcolors
);
275 DispCol(nw
, curcol
, colors
);
279 if (code
== SELECTDOWN
) {
280 if (msy
> bxory
&& msy
< bxory
+ bxylen
- 1 && msx
> bxorx
281 && msx
< bxorx
+ bxxlen
- 1) {
282 curcol
= (msx
- bxorx
) / (bxxlen
/ amii_numcolors
);
283 if (curcol
>= 0 && curcol
< amii_numcolors
)
284 DrawCol(nw
, curcol
, colors
);
293 for (i
= 0; i
< (amii_numcolors
); ++i
)
294 sysflags
.amii_curmap
[i
] = colors
[i
];
295 LoadRGB4(&scrn
->ViewPort
, sysflags
.amii_curmap
, amii_numcolors
);
297 LoadRGB4(&scrn
->ViewPort
, svcolors
, amii_numcolors
);
302 ShowClipValues(struct Window
*nw
)
307 SetAPen(nw
->RPort
, 5);
308 SetBPen(nw
->RPort
, amii_otherBPen
);
309 SetDrMd(nw
->RPort
, JAM2
);
311 sprintf(buf
, "%d ", mxsize
);
313 Move(nw
->RPort
, gd
->LeftEdge
+ (nw
->Width
+ gd
->Width
) + 8,
314 gd
->TopEdge
+ nw
->RPort
->TxBaseline
);
315 Text(nw
->RPort
, buf
, strlen(buf
));
317 sprintf(buf
, "%d ", mysize
);
319 Move(nw
->RPort
, gd
->LeftEdge
+ (nw
->Width
+ gd
->Width
) + 8,
320 gd
->TopEdge
+ nw
->RPort
->TxBaseline
);
321 Text(nw
->RPort
, buf
, strlen(buf
));
323 sprintf(buf
, "%d ", xclipbord
);
325 Move(nw
->RPort
, gd
->LeftEdge
+ (nw
->Width
+ gd
->Width
) + 8,
326 gd
->TopEdge
+ nw
->RPort
->TxBaseline
);
327 Text(nw
->RPort
, buf
, strlen(buf
));
329 sprintf(buf
, "%d ", yclipbord
);
331 Move(nw
->RPort
, gd
->LeftEdge
+ (nw
->Width
+ gd
->Width
) + 8,
332 gd
->TopEdge
+ nw
->RPort
->TxBaseline
);
333 Text(nw
->RPort
, buf
, strlen(buf
));
341 static int sizes
[] = { 8, 16, 20, 24, 28, 32, 36 };
343 int done
= 0, okay
= 0;
344 long code
, qual
, class;
345 register struct Gadget
*gd
, *dgad
;
346 register struct Window
*nw
;
347 register struct IntuiMessage
*imsg
;
348 register struct PropInfo
*pip
;
349 register struct Screen
*scrn
;
351 int lmxsize
= mxsize
, lmysize
= mysize
;
352 int lxclipbord
= xclipbord
, lyclipbord
= yclipbord
;
360 SetBorder(&ClipOkay
);
361 SetBorder(&ClipCancel
);
364 ClipNewWindowStructure1
.Screen
= scrn
;
365 #ifdef INTUI_NEW_LOOK
366 if (IntuitionBase
->LibNode
.lib_Version
>= 37) {
367 ((struct PropInfo
*) ClipXSIZE
.SpecialInfo
)->Flags
|= PROPNEWLOOK
;
368 ((struct PropInfo
*) ClipYSIZE
.SpecialInfo
)->Flags
|= PROPNEWLOOK
;
369 ((struct PropInfo
*) ClipXCLIP
.SpecialInfo
)->Flags
|= PROPNEWLOOK
;
370 ((struct PropInfo
*) ClipYCLIP
.SpecialInfo
)->Flags
|= PROPNEWLOOK
;
373 if (WINVERS_AMIV
|| WINVERS_AMII
) {
374 #ifdef INTUI_NEW_LOOK
375 ClipNewWindowStructure1
.Extension
= wintags
;
376 ClipNewWindowStructure1
.Flags
|= WFLG_NW_EXTENDED
;
378 fillhook
.h_Entry
= (void *) &LayerFillHook
;
380 fillhook
.h_Entry
= (ULONG (*) ()) LayerFillHook
;
382 fillhook
.h_Data
= (void *) -2;
383 fillhook
.h_SubEntry
= 0;
387 nw
= OpenWindow((void *) &ClipNewWindowStructure1
);
395 mflags
= AUTOKNOB
| FREEHORIZ
;
396 #ifdef INTUI_NEW_LOOK
397 if (IntuitionBase
->LibNode
.lib_Version
>= 37) {
398 mflags
|= PROPNEWLOOK
;
402 for (i
= 0; i
< 7; ++i
) {
403 if (mxsize
<= sizes
[i
])
406 NewModifyProp(&ClipXSIZE
, nw
, NULL
, mflags
, (i
* MAXPOT
) / 6, 0,
408 for (i
= 0; i
< 7; ++i
) {
409 if (mysize
<= sizes
[i
])
412 NewModifyProp(&ClipYSIZE
, nw
, NULL
, mflags
, (i
* MAXPOT
) / 6, 0,
415 NewModifyProp(&ClipXCLIP
, nw
, NULL
, mflags
,
416 ((xclipbord
- 2) * MAXPOT
) / 6, 0, MAXPOT
/ 6, 0, 1);
417 NewModifyProp(&ClipYCLIP
, nw
, NULL
, mflags
,
418 ((yclipbord
- 2) * MAXPOT
) / 6, 0, MAXPOT
/ 6, 0, 1);
421 WaitPort(nw
->UserPort
);
423 while (imsg
= (struct IntuiMessage
*) GetMsg(nw
->UserPort
)) {
424 gd
= (struct Gadget
*) imsg
->IAddress
;
427 qual
= imsg
->Qualifier
;
431 ReplyMsg((struct Message
*) imsg
);
437 else if (code
== 'v' && qual
== AMIGALEFT
)
439 else if (code
== 'b' && qual
== AMIGALEFT
)
441 else if (code
== 'o' || code
== 'O')
443 else if (code
== 'c' || code
== 'C')
453 if (gd
->GadgetID
== XSIZE
|| gd
->GadgetID
== YSIZE
454 || gd
->GadgetID
== XCLIP
|| gd
->GadgetID
== YCLIP
) {
455 pip
= (struct PropInfo
*) gd
->SpecialInfo
;
456 aidx
= pip
->HorizPot
/ (MAXPOT
/ 6);
457 if (gd
->GadgetID
== XSIZE
) {
458 mxsize
= sizes
[aidx
];
459 } else if (gd
->GadgetID
== YSIZE
) {
460 mysize
= sizes
[aidx
];
461 } else if (gd
->GadgetID
== XCLIP
) {
462 xclipbord
= aidx
+ 2;
463 } else if (gd
->GadgetID
== YCLIP
) {
464 yclipbord
= aidx
+ 2;
470 } else if (gd
->GadgetID
== GADOKAY
) {
473 } else if (gd
->GadgetID
== GADCANCEL
) {
480 flush_glyph_buffer(amii_wins
[WIN_MAP
]->win
);
493 pip
= (struct PropInfo
*) dgad
->SpecialInfo
;
494 aidx
= pip
->HorizPot
/ (MAXPOT
/ 6);
496 dgad
->LeftEdge
+ (nw
->Width
+ dgad
->Width
) + 8,
497 dgad
->TopEdge
+ nw
->RPort
->TxBaseline
);
498 if (dgad
->GadgetID
== XSIZE
) {
499 mxsize
= sizes
[aidx
];
500 sprintf(buf
, "%d ", lmxsize
);
501 } else if (dgad
->GadgetID
== YSIZE
) {
502 mysize
= sizes
[aidx
];
503 sprintf(buf
, "%d ", mysize
);
504 } else if (dgad
->GadgetID
== XCLIP
) {
505 xclipbord
= aidx
+ 2;
506 sprintf(buf
, "%d ", xclipbord
);
507 } else if (dgad
->GadgetID
== YCLIP
) {
508 yclipbord
= aidx
+ 2;
509 sprintf(buf
, "%d ", yclipbord
);
511 SetAPen(nw
->RPort
, 5);
512 SetBPen(nw
->RPort
, amii_otherBPen
);
513 SetDrMd(nw
->RPort
, JAM2
);
514 Text(nw
->RPort
, buf
, strlen(buf
));
525 /* Restore oldvalues if cancelled. */
529 xclipbord
= lxclipbord
;
530 yclipbord
= lyclipbord
;
539 static char dir
[300];
541 t
= strrchr(str
, '/');
543 t
= strrchr(str
, ':');
561 t
= strrchr(str
, '/');
563 t
= strrchr(str
, ':');
571 filecopy(from
, to
) char *from
, *to
;
576 buf
= (char *) alloc(strlen(to
) + strlen(from
) + 20);
578 sprintf(buf
, "c:copy \"%s\" \"%s\" clone", from
, to
);
580 /* Check SysBase instead? Shouldn't matter */
581 #ifdef INTUI_NEW_LOOK
582 if (IntuitionBase
->LibNode
.lib_Version
>= 37)
583 i
= System(buf
, NULL
);
586 Execute(buf
, NULL
, NULL
);
594 /* The colornames, and the default values for the pens */
595 static struct COLDEF
{
598 struct COLDEF amii_colnames
[AMII_MAXCOLORS
] = {
599 "Black", "(000)", "White", "(fff)", "Brown", "(830)", "Cyan", "(7ac)",
600 "Green", "(181)", "Magenta", "(c06)", "Blue", "(23e)", "Red", "(c00)",
603 struct COLDEF amiv_colnames
[AMII_MAXCOLORS
] = {
604 "Black", "(000)", "White", "(fff)", "Cyan", "(0bf)",
605 "Orange", "(f60)", "Blue", "(00f)", "Green", "(090)",
606 "Grey", "(69b)", "Red", "(f00)", "Light Green", "(6f0)",
607 "Yellow", "(ff0)", "Magenta", "(f0f)", "Brown", "(940)",
608 "Grey Blue", "(466)", "Light Brown", "(c40)", "Light Grey", "(ddb)",
609 "Peach", "(fb9)", "Col 16", "(222)", "Col 17", "(eee)",
610 "Col 18", "(000)", "Col 19", "(ccc)", "Col 20", "(bbb)",
611 "Col 21", "(aaa)", "Col 22", "(999)", "Col 23", "(888)",
612 "Col 24", "(777)", "Col 25", "(666)", "Col 26", "(555)",
613 "Col 27", "(444)", "Col 28", "(333)", "Col 29", "(18f)",
614 "Col 30", "(f81)", "Col 31", "(fff)",
618 ClearCol(struct Window
*w
)
620 int bxorx
, bxory
, bxxlen
, bxylen
;
623 bxylen
= Col_Okay
.TopEdge
- (Col_BluePen
.TopEdge
+ Col_BluePen
.Height
) - 1
625 bxxlen
= Col_BluePen
.Width
- 2;
626 bxorx
= Col_BluePen
.LeftEdge
+ 1;
627 bxory
= Col_BluePen
.TopEdge
+ Col_BluePen
.Height
+ 2;
629 incx
= bxxlen
/ amii_numcolors
;
636 SetAPen(w
->RPort
, C_WHITE
);
637 SetDrMd(w
->RPort
, JAM1
);
638 RectFill(w
->RPort
, bxorx
, bxory
, bxorx
+ bxxlen
+ 1, bxory
+ bxylen
);
640 SetAPen(w
->RPort
, C_BLACK
);
641 RectFill(w
->RPort
, bxorx
+ 1, bxory
+ 1, bxorx
+ bxxlen
,
646 DrawCol(w
, idx
, colors
)
651 int bxorx
, bxory
, bxxlen
, bxylen
;
652 int i
, incx
, incy
, r
, g
, b
;
655 bxylen
= Col_Okay
.TopEdge
- (Col_BluePen
.TopEdge
+ Col_BluePen
.Height
) - 1
657 bxxlen
= Col_BluePen
.Width
- 2;
658 bxorx
= Col_BluePen
.LeftEdge
+ 1;
659 bxory
= Col_BluePen
.TopEdge
+ Col_BluePen
.Height
+ 2;
661 incx
= bxxlen
/ amii_numcolors
;
668 for (i
= 0; i
< amii_numcolors
; ++i
) {
670 x
= bxorx
+ 2 + (i
* incx
);
674 SetAPen(w
->RPort
, sysflags
.amii_dripens
[SHADOWPEN
]);
675 Move(w
->RPort
, x
, y
+ bxylen
- 4);
676 Draw(w
->RPort
, x
, y
);
677 Draw(w
->RPort
, x
+ incx
- 1, y
);
679 Move(w
->RPort
, x
+ 1, y
+ bxylen
- 5);
680 Draw(w
->RPort
, x
+ 1, y
+ 1);
681 Draw(w
->RPort
, x
+ incx
- 2, y
+ 1);
683 SetAPen(w
->RPort
, sysflags
.amii_dripens
[SHINEPEN
]);
684 Move(w
->RPort
, x
+ incx
- 1, y
+ 1);
685 Draw(w
->RPort
, x
+ incx
- 1, y
+ bxylen
- 4);
686 Draw(w
->RPort
, x
, y
+ bxylen
- 4);
688 Move(w
->RPort
, x
+ incx
- 2, y
+ 2);
689 Draw(w
->RPort
, x
+ incx
- 2, y
+ bxylen
- 5);
690 Draw(w
->RPort
, x
+ 1, y
+ bxylen
- 5);
692 SetAPen(w
->RPort
, C_BLACK
);
693 Move(w
->RPort
, x
, y
);
694 Draw(w
->RPort
, x
+ incx
- 1, y
);
695 Draw(w
->RPort
, x
+ incx
- 1, y
+ bxylen
- 4);
696 Draw(w
->RPort
, x
, y
+ bxylen
- 4);
697 Draw(w
->RPort
, x
, y
);
698 SetAPen(w
->RPort
, C_BLACK
);
699 Move(w
->RPort
, x
+ 1, y
+ 1);
700 Draw(w
->RPort
, x
+ incx
- 2, y
+ 1);
701 Draw(w
->RPort
, x
+ incx
- 2, y
+ bxylen
- 6);
702 Draw(w
->RPort
, x
+ 1, y
+ bxylen
- 6);
703 Draw(w
->RPort
, x
+ 1, y
+ 1);
706 SetAPen(w
->RPort
, i
);
707 RectFill(w
->RPort
, x
+ 3, y
+ 3, x
+ incx
- 4, y
+ bxylen
- 6);
710 DispCol(w
, idx
, colors
);
712 r
= (colors
[idx
] & 0xf00) >> 8;
713 g
= (colors
[idx
] & 0x0f0) >> 4;
714 b
= colors
[idx
] & 0x00f;
716 mflags
= AUTOKNOB
| FREEHORIZ
;
717 #ifdef INTUI_NEW_LOOK
718 if (IntuitionBase
->LibNode
.lib_Version
>= 37) {
719 mflags
|= PROPNEWLOOK
;
722 NewModifyProp(&Col_RedPen
, w
, NULL
, mflags
, (r
* MAXPOT
) / 15, 0,
724 NewModifyProp(&Col_GreenPen
, w
, NULL
, mflags
, (g
* MAXPOT
) / 15, 0,
726 NewModifyProp(&Col_BluePen
, w
, NULL
, mflags
, (b
* MAXPOT
) / 15, 0,
731 DispCol(w
, idx
, colors
)
737 char *colname
, *defval
;
740 colname
= amiv_colnames
[idx
].name
;
741 defval
= amiv_colnames
[idx
].defval
;
743 colname
= amii_colnames
[idx
].name
;
744 defval
= amii_colnames
[idx
].defval
;
747 if (colname
== NULL
) {
751 Move(w
->RPort
, Col_Save
.LeftEdge
, Col_Save
.TopEdge
- 7);
752 sprintf(buf
, "%s=%03x default=%s%s", colname
, colors
[idx
], defval
,
753 " " + strlen(colname
) + 1);
754 SetAPen(w
->RPort
, C_RED
);
755 SetBPen(w
->RPort
, amii_otherBPen
);
756 SetDrMd(w
->RPort
, JAM2
);
757 Text(w
->RPort
, buf
, strlen(buf
));
761 amii_setpens(int count
)
763 #ifdef INTUI_NEW_LOOK
764 struct EasyStruct ea
= { sizeof(struct EasyStruct
), 0l, "aNetHack Request",
765 "Number of pens requested(%ld) not correct",
766 "Use default pens|Use requested pens" };
767 struct EasyStruct ea2
= { sizeof(struct EasyStruct
), 0l,
769 "Number of pens requested(%ld) not\ncompatible "
770 "with game configuration(%ld)",
771 "Use default pens|Use requested pens" };
773 /* If the pens in amii_curmap are
774 * more pens than in amii_numcolors, then we choose to ignore
777 #ifdef INTUI_NEW_LOOK
778 if (IntuitionBase
&& IntuitionBase
->LibNode
.lib_Version
>= 39) {
779 if (count
!= amii_numcolors
) {
782 args
[1] = amii_numcolors
;
783 if (EasyRequest(NULL
, &ea2
, NULL
, args
) == 1) {
784 memcpy(sysflags
.amii_curmap
, amii_initmap
,
785 amii_numcolors
* sizeof(amii_initmap
[0]));
788 } else if (IntuitionBase
&& IntuitionBase
->LibNode
.lib_Version
>= 37) {
789 if (count
!= amii_numcolors
) {
790 if (EasyRequest(NULL
, &ea
, NULL
, NULL
) == 1) {
791 memcpy(sysflags
.amii_curmap
, amii_initmap
,
792 amii_numcolors
* sizeof(amii_initmap
[0]));
797 if (count
!= amii_numcolors
) {
798 memcpy(sysflags
.amii_curmap
, amii_initmap
,
799 amii_numcolors
* sizeof(amii_initmap
[0]));
802 /* If the pens are set in aNetHack.cnf, we can get called before
803 * HackScreen has been opened.
805 if (HackScreen
!= NULL
) {
806 LoadRGB4(&HackScreen
->ViewPort
, sysflags
.amii_curmap
, amii_numcolors
);
810 /* Generate a requester for a string value. */
813 amii_getlin(prompt
, bufp
)
817 getlind(prompt
, bufp
, 0);
820 /* and with default */
822 getlind(prompt
, bufp
, dflt
)
828 register struct Window
*cwin
;
829 register struct IntuiMessage
*imsg
;
830 register long class, code
, qual
;
831 register int aredone
= 0;
832 register struct Gadget
*gd
;
837 strcpy(StrString
, dflt
);
838 StrWindow
.Title
= (UBYTE
*) prompt
;
839 StrWindow
.Screen
= HackScreen
;
844 (HackScreen
->Width
/ 2) - (StrWindow
.Width
/ 2);
845 if (amii_wins
[WIN_MAP
]) {
846 StrWindow
.TopEdge
= amii_wins
[WIN_MAP
]->win
->TopEdge
;
849 (HackScreen
->Height
/ 2) - (StrWindow
.Height
/ 2);
857 if (WINVERS_AMIV
|| WINVERS_AMII
) {
858 #ifdef INTUI_NEW_LOOK
859 StrWindow
.Extension
= wintags
;
860 StrWindow
.Flags
|= WFLG_NW_EXTENDED
;
862 fillhook
.h_Entry
= (void *) &LayerFillHook
;
864 fillhook
.h_Entry
= (ULONG (*) ()) LayerFillHook
;
866 fillhook
.h_Data
= (void *) -2;
867 fillhook
.h_SubEntry
= 0;
871 if ((cwin
= OpenWindow((void *) &StrWindow
)) == NULL
) {
876 WaitPort(cwin
->UserPort
);
877 while ((imsg
= (void *) GetMsg(cwin
->UserPort
)) != NULL
) {
880 qual
= imsg
->Qualifier
;
881 gd
= (struct Gadget
*) imsg
->IAddress
;
886 && (qual
& (IEQUALIFIER_LALT
| IEQUALIFIER_RALT
887 | IEQUALIFIER_LCOMMAND
888 | IEQUALIFIER_RCOMMAND
)) == 0) {
895 ActivateGadget(&String
, cwin
, NULL
);
900 ActivateGadget(&String
, cwin
, NULL
);
904 switch (gd
->GadgetID
) {
908 strcpy(bufp
, StrString
);
929 ReplyMsg((struct Message
*) imsg
);
935 struct amii_WinDesc
*cw
;
940 amii_clear_nhwindow(WIN_MESSAGE
);
941 amii_putstr(WIN_MESSAGE
, 0, prompt
);
942 cw
= amii_wins
[WIN_MESSAGE
];
944 ocolx
= colx
= strlen(prompt
) + 1;
947 cursor_on(WIN_MESSAGE
);
948 while ((c
= WindowGetchar()) != EOF
) {
949 cursor_off(WIN_MESSAGE
);
950 amii_curs(WIN_MESSAGE
, colx
, 0);
955 } else if (c
== '\b') {
958 amii_curs(WIN_MESSAGE
, --colx
, 0);
959 Text(w
->RPort
, "\177 ", 2);
960 amii_curs(WIN_MESSAGE
, colx
, 0);
963 } else if (c
== '\n' || c
== '\r') {
967 } else if (' ' <= c
&& c
< '\177') {
968 /* avoid isprint() - some people don't have it
969 ' ' is not always a printing char */
973 Text(w
->RPort
, bufp
, 1);
974 Text(w
->RPort
, "\177", 1);
975 if (bufp
- obufp
< BUFSZ
- 1 && bufp
- obufp
< COLNO
) {
979 } else if (c
== ('X' - 64) || c
== '\177') {
980 amii_curs(WIN_MESSAGE
, ocolx
, 0);
984 amii_curs(WIN_MESSAGE
, colx
= ocolx
, 0);
987 cursor_on(WIN_MESSAGE
);
989 cursor_off(WIN_MESSAGE
);
995 amii_change_color(pen
, val
, rev
)
1000 sysflags
.amii_curmap
[pen
] = ~val
;
1002 sysflags
.amii_curmap
[pen
] = val
;
1005 LoadRGB4(&HackScreen
->ViewPort
, sysflags
.amii_curmap
, amii_numcolors
);
1009 amii_get_color_string()
1013 static char buf
[BUFSZ
];
1016 for (i
= 0; i
< min(32, amii_numcolors
); ++i
) {
1017 sprintf(s
, "%s%03lx", i
? "/" : "", (long) sysflags
.amii_curmap
[i
]);