ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/AmigaOS/prefs_editor_amiga.cpp
(Generate patch)

Comparing BasiliskII/src/AmigaOS/prefs_editor_amiga.cpp (file contents):
Revision 1.3 by cebix, 1999-10-21T22:39:57Z vs.
Revision 1.16 by cebix, 2001-05-24T14:31:07Z

# Line 1 | Line 1
1   /*
2   *  prefs_editor_amiga.cpp - Preferences editor, AmigaOS implementation (using gtlayout.library)
3   *
4 < *  Basilisk II (C) 1997-1999 Christian Bauer
4 > *  Basilisk II (C) 1997-2001 Christian Bauer
5   *
6   *  This program is free software; you can redistribute it and/or modify
7   *  it under the terms of the GNU General Public License as published by
# Line 27 | Line 27
27   #include <libraries/asl.h>
28   #include <libraries/gtlayout.h>
29   #include <libraries/Picasso96.h>
30 + #include <cybergraphics/cybergraphics.h>
31   #include <graphics/displayinfo.h>
32   #include <devices/ahi.h>
33   #include <proto/exec.h>
# Line 37 | Line 38
38   #include <proto/graphics.h>
39   #include <proto/asl.h>
40   #include <proto/Picasso96.h>
41 + #include <proto/cybergraphics.h>
42   #include <proto/ahi.h>
43  
44   #include "sysdeps.h"
# Line 65 | Line 67 | const int GAD_CDROM_DEVICE = 0x0304;
67   const int GAD_CDROM_UNIT = 0x0305;
68   const int GAD_BOOTDRIVER = 0x0306;
69   const int GAD_NOCDROM = 0x0307;
70 + const int GAD_EXTFS = 0x0308;
71  
72   const int GAD_VOLUME_READONLY = 0x0310;         // "Add/Edit Volume" window
73   const int GAD_VOLUME_TYPE = 0x0311;
# Line 91 | Line 94 | const int GAD_SCSI3_UNIT = 0x0413;
94   const int GAD_SCSI4_UNIT = 0x0414;
95   const int GAD_SCSI5_UNIT = 0x0415;
96   const int GAD_SCSI6_UNIT = 0x0416;
97 + const int GAD_SCSI_MEMTYPE = 0x0420;
98  
99   const int GAD_VIDEO_TYPE = 0x0500;                      // "Graphics/Sound" pane
100   const int GAD_DISPLAY_X = 0x0501;
# Line 142 | Line 146 | static void read_settings(struct LayoutH
146   *  Locale hook - returns string for given ID
147   */
148  
145 #ifdef __GNUC__
149   static __saveds __attribute__((regparm(3))) const char *locale_hook_func(struct Hook *hook /*a0*/, void *id /*a1*/, struct LayoutHandle *h /*a2*/)
147 #else
148 static __saveds __regargs const char *locale_hook_func(struct Hook *hook /*a0*/, void *id /*a1*/, struct LayoutHandle *h /*a2*/)
149 #endif
150   {
151          return GetString((uint32)id);
152   }
# Line 355 | Line 355 | bool PrefsEditor(void)
355                                                  case GAD_BOOTDRIVER:
356                                                          switch (code) {
357                                                                  case 0:
358 <                                                                        PrefsReplaceInt16("bootdriver", 0);
358 >                                                                        PrefsReplaceInt32("bootdriver", 0);
359                                                                          break;
360                                                                  case 1:
361 <                                                                        PrefsReplaceInt16("bootdriver", CDROMRefNum);
361 >                                                                        PrefsReplaceInt32("bootdriver", CDROMRefNum);
362                                                                          break;
363                                                          }
364                                                          break;
365  
366 +                                                case GAD_SCSI_MEMTYPE:
367 +                                                        PrefsReplaceInt32("scsimemtype", code);
368 +                                                        break;
369 +
370                                                  case GAD_VIDEO_TYPE:
371                                                          ghost_graphics_gadgets(h);
372                                                          break;
# Line 429 | Line 433 | bool PrefsEditor(void)
433                                                  case GAD_SCSI6_DEVICE:
434                                                  case GAD_SERIALA_DEVICE:
435                                                  case GAD_SERIALB_DEVICE:
436 +                                                        if (dev_request) {
437 +                                                                LT_LockWindow(win);
438 +                                                                BOOL result = AslRequestTags(dev_request,
439 +                                                                        ASLFR_Window, (ULONG)win,
440 +                                                                        ASLFR_InitialDrawer, (ULONG) "Devs:",
441 +                                                                        TAG_END);
442 +                                                                LT_UnlockWindow(win);
443 +                                                                if (result) {
444 +                                                                        char *str;
445 +                                                                        GT_GetGadgetAttrs(gad, win, NULL, GTST_String, (ULONG)&str, TAG_END);
446 +                                                                        strncpy(str, dev_request->rf_File, 255);        // Don't copy the directory part. This is usually "DEVS:" and we don't need that.
447 +                                                                        str[255] = 0;
448 +                                                                        LT_SetAttributes(h, gad->GadgetID, GTST_String, (ULONG)str, TAG_END);
449 +                                                                }
450 +                                                        }
451 +                                                        break;
452 +
453                                                  case GAD_ETHER_DEVICE:
454                                                          if (dev_request) {
455                                                                  LT_LockWindow(win);
456 <                                                                BOOL result = AslRequestTags(dev_request, ASLFR_Window, (ULONG)win, TAG_END);
456 >                                                                BOOL result = AslRequestTags(dev_request,
457 >                                                                        ASLFR_Window, (ULONG)win,
458 >                                                                        ASLFR_InitialDrawer, (ULONG) "Devs:Networks",
459 >                                                                        TAG_END);
460                                                                  LT_UnlockWindow(win);
461                                                                  if (result) {
462                                                                          char *str;
# Line 514 | Line 538 | quit:
538          FreeAslRequest(dev_request);
539          FreeAslRequest(file_request);
540  
541 +        // Delete Menus
542 +        LT_DisposeMenu(menu);
543 +
544          // Delete handle
545          LT_DeleteHandle(h);
546  
# Line 528 | Line 555 | quit:
555   */
556  
557   static struct List disk_list;
558 < static char cdrom_name[256];
558 > static char cdrom_name[256], extfs_name[256];
559   static ULONG cdrom_unit, cdrom_flags, cdrom_start, cdrom_size, cdrom_bsize;
560   static BYTE bootdriver_num, nocdrom;
561  
# Line 552 | Line 579 | static void parse_volumes_prefs(void)
579  
580          bootdriver_num = 0;
581  
582 <        int bootdriver = PrefsFindInt16("bootdriver");
582 >        int bootdriver = PrefsFindInt32("bootdriver");
583          switch (bootdriver) {
584                  case 0:
585                          bootdriver_num = 0;
# Line 563 | Line 590 | static void parse_volumes_prefs(void)
590          }
591  
592          nocdrom = PrefsFindBool("nocdrom");
593 +
594 +        extfs_name[0] = 0;
595 +        str = PrefsFindString("extfs");
596 +        if (str)
597 +                strncpy(extfs_name, str, sizeof(extfs_name) - 1);
598   }
599  
600   // Ghost/unghost "Edit" and "Remove" buttons
# Line 869 | Line 901 | do_req:                                                if (req) {
901                  }
902          } while (!done);
903  
872        // Delete handle
873        LT_DeleteHandle(h);
874
904          // Update preferences and list view
905          if (ok_clicked) {
906                  char str[256];
# Line 909 | Line 938 | do_req:                                                if (req) {
938                  LT_SetAttributes(h2, GAD_DISK_LIST, GTLV_Labels, (ULONG)&disk_list, TAG_END);
939                  ghost_volumes_gadgets(h2);
940          }
941 +
942 +        // Delete handle
943 +        LT_DeleteHandle(h);
944   }
945  
946   // Remove volume from list
# Line 954 | Line 986 | static void read_volumes_settings(void)
986                  PrefsRemoveItem("cdrom");
987  
988          PrefsReplaceBool("nocdrom", nocdrom);
989 +
990 +        if (strlen(extfs_name))
991 +                PrefsReplaceString("extfs", extfs_name);
992   }
993  
994   // Create "Volumes" pane
# Line 969 | Line 1004 | static void create_volumes_pane(struct L
1004                          VGROUP;
1005                                  LT_New(h, LA_Type, LISTVIEW_KIND,
1006                                          LA_ID, GAD_DISK_LIST,
1007 +                                        LA_Chars, 20,
1008                                          GTLV_Labels, (ULONG)&disk_list,
1009                                          LALV_Lines, 6,
1010                                          LALV_Link, (ULONG)NIL_LINK,
# Line 1036 | Line 1072 | static void create_volumes_pane(struct L
1072                                  TAG_END
1073                          );
1074                  ENDGROUP;
1075 +                VGROUP;
1076 +                        LT_New(h, LA_Type, STRING_KIND,
1077 +                                LA_LabelID, STR_EXTFS_CTRL,
1078 +                                LA_ID, GAD_EXTFS,
1079 +                                LA_Chars, 20,
1080 +                                LA_STRPTR, (ULONG)extfs_name,
1081 +                                GTST_MaxChars, sizeof(extfs_name) - 1,
1082 +                                TAG_END
1083 +                        );
1084 +                ENDGROUP;
1085          ENDGROUP;
1086   }
1087  
# Line 1046 | Line 1092 | static void create_volumes_pane(struct L
1092  
1093   static char scsi_dev[6][256];
1094   static LONG scsi_unit[6];
1095 + static LONG scsi_memtype;
1096  
1097   // Read SCSI preferences
1098   static void parse_scsi_prefs(void)
# Line 1060 | Line 1107 | static void parse_scsi_prefs(void)
1107                  if (str)
1108                          sscanf(str, "%[^/]/%ld", scsi_dev[i], &scsi_unit[i]);
1109          }
1110 +
1111 +        scsi_memtype = PrefsFindInt32("scsimemtype");
1112   }
1113  
1114   // Read settings from gadgets and set preferences
# Line 1071 | Line 1120 | static void read_scsi_settings(void)
1120  
1121                  if (strlen(scsi_dev[i])) {
1122                          char str[256];
1123 <                        sprintf("%s/%ld", scsi_dev[i], scsi_unit[i]);
1123 >                        sprintf(str, "%s/%ld", scsi_dev[i], scsi_unit[i]);
1124                          PrefsReplaceString(prefs_name, str);
1125                  } else
1126                          PrefsRemoveItem(prefs_name);
# Line 1084 | Line 1133 | static void create_scsi_pane(struct Layo
1133          parse_scsi_prefs();
1134  
1135          VGROUP;
1136 <                for (int i=0; i<7; i++) {
1137 <                        HGROUP;
1138 <                                LT_New(h, LA_Type, TEXT_KIND,
1139 <                                        LA_LabelID, STR_SCSI_ID_0 + i,
1140 <                                        TAG_END
1141 <                                );
1142 <                                LT_New(h, LA_Type, STRING_KIND,
1143 <                                        LA_LabelID, STR_DEVICE_CTRL,
1144 <                                        LA_ID, GAD_SCSI0_DEVICE + i,
1145 <                                        LA_Chars, 20,
1146 <                                        LA_STRPTR, (ULONG)scsi_dev[i],
1147 <                                        GTST_MaxChars, sizeof(scsi_dev[i]) - 1,
1148 <                                        LAST_Picker, TRUE,
1149 <                                        TAG_END
1150 <                                );
1151 <                                LT_New(h, LA_Type, INTEGER_KIND,
1152 <                                        LA_LabelID, STR_UNIT_CTRL,
1153 <                                        LA_ID, GAD_SCSI0_UNIT + i,
1154 <                                        LA_Chars, 4,
1155 <                                        LA_LONG, (ULONG)&scsi_unit[i],
1156 <                                        LAIN_UseIncrementers, TRUE,
1157 <                                        GTIN_MaxChars, 8,
1158 <                                        TAG_END
1159 <                                );
1160 <                        ENDGROUP;
1161 <                }
1136 >                LT_New(h, LA_Type, VERTICAL_KIND,
1137 >                        LA_LabelID, STR_SCSI_DEVICES_CTRL,
1138 >                        TAG_END
1139 >                );
1140 >                        for (int i=0; i<7; i++) {
1141 >                                HGROUP;
1142 >                                        LT_New(h, LA_Type, TEXT_KIND,
1143 >                                                LA_LabelID, STR_SCSI_ID_0 + i,
1144 >                                                TAG_END
1145 >                                        );
1146 >                                        LT_New(h, LA_Type, STRING_KIND,
1147 >                                                LA_LabelID, STR_DEVICE_CTRL,
1148 >                                                LA_ID, GAD_SCSI0_DEVICE + i,
1149 >                                                LA_Chars, 20,
1150 >                                                LA_STRPTR, (ULONG)scsi_dev[i],
1151 >                                                GTST_MaxChars, sizeof(scsi_dev[i]) - 1,
1152 >                                                LAST_Picker, TRUE,
1153 >                                                TAG_END
1154 >                                        );
1155 >                                        LT_New(h, LA_Type, INTEGER_KIND,
1156 >                                                LA_LabelID, STR_UNIT_CTRL,
1157 >                                                LA_ID, GAD_SCSI0_UNIT + i,
1158 >                                                LA_Chars, 4,
1159 >                                                LA_LONG, (ULONG)&scsi_unit[i],
1160 >                                                LAIN_UseIncrementers, TRUE,
1161 >                                                GTIN_MaxChars, 8,
1162 >                                                TAG_END
1163 >                                        );
1164 >                                ENDGROUP;
1165 >                        }
1166 >                ENDGROUP;
1167 >                VGROUP;
1168 >                        LT_New(h, LA_Type, CYCLE_KIND,
1169 >                                LA_LabelID, STR_SCSI_MEMTYPE_CTRL,
1170 >                                LA_ID, GAD_SCSI_MEMTYPE,
1171 >                                LACY_FirstLabel, STR_MEMTYPE_CHIP_LAB,
1172 >                                LACY_LastLabel, STR_MEMTYPE_ANY_LAB,
1173 >                                LA_LONG, (ULONG)&scsi_memtype,
1174 >                                TAG_END
1175 >                        );
1176 >                ENDGROUP;
1177          ENDGROUP;
1178   }
1179  
# Line 1125 | Line 1189 | enum {
1189          DISPLAY_SCREEN
1190   };
1191  
1192 < static BYTE display_type;
1192 > static LONG display_type;
1193   static LONG dis_width, dis_height;
1194   static ULONG mode_id;
1195   static BYTE frameskip_num;
# Line 1169 | Line 1233 | static void parse_graphics_prefs(void)
1233  
1234          const char *str = PrefsFindString("screen");
1235          if (str) {
1236 <                if (sscanf(str, "win/%d/%d", &dis_width, &dis_height) == 2)
1236 >                if (sscanf(str, "win/%ld/%ld", &dis_width, &dis_height) == 2)
1237                          display_type = DISPLAY_WINDOW;
1238 <                else if (sscanf(str, "pip/%d/%d", &dis_width, &dis_height) == 2)
1238 >                else if (sscanf(str, "pip/%ld/%ld", &dis_width, &dis_height) == 2)
1239                          display_type = DISPLAY_PIP;
1240                  else if (sscanf(str, "scr/%08lx", &mode_id) == 1)
1241                          display_type = DISPLAY_SCREEN;
# Line 1223 | Line 1287 | static void ghost_graphics_gadgets(struc
1287   // Show screen mode requester
1288   static void screen_mode_req(struct Window *win, struct LayoutHandle *h)
1289   {
1290 <        if (P96Base == NULL)
1290 >        if (P96Base == NULL && CyberGfxBase == NULL)
1291                  return;
1292  
1293          LT_LockWindow(win);
1294 <        ULONG id = p96RequestModeIDTags(
1295 <                P96MA_MinDepth, 8,
1296 <                P96MA_FormatsAllowed, RGBFF_CLUT | RGBFF_R5G5B5 | RGBFF_A8R8G8B8,
1297 <                TAG_END
1298 <        );
1294 >
1295 >        ULONG id;
1296 >
1297 >        // Try P96 first, because it also provides a (fake) cybergraphics.library
1298 >        if (P96Base) {
1299 >                id = p96RequestModeIDTags(
1300 >                        P96MA_MinDepth, 8,
1301 >                        P96MA_FormatsAllowed, RGBFF_CLUT | RGBFF_R5G5B5 | RGBFF_A8R8G8B8,
1302 >                        TAG_END
1303 >                );
1304 >        } else {
1305 >                UWORD ModelArray[] = { PIXFMT_LUT8, PIXFMT_RGB15, PIXFMT_ARGB32, 0, ~0 };
1306 >                id = (ULONG) CModeRequestTags(NULL,
1307 >                        CYBRMREQ_MinDepth, 8,
1308 >                        CYBRMREQ_CModelArray, (ULONG) ModelArray,
1309 >                        TAG_END
1310 >                );
1311 >        }
1312          LT_UnlockWindow(win);
1313  
1314          if (id != INVALID_ID) {
# Line 1314 | Line 1391 | static void create_graphics_pane(struct
1391                                  LA_LabelID, STR_VIDEO_TYPE_CTRL,
1392                                  LA_ID, GAD_VIDEO_TYPE,
1393                                  LACY_LabelTable, (ULONG)labels,
1394 <                                LA_BYTE, (ULONG)&display_type,
1394 >                                LA_LONG, (ULONG)&display_type,
1395                                  TAG_END
1396                          );
1397                          LT_New(h, LA_Type, INTEGER_KIND,
# Line 1412 | Line 1489 | static void parse_serial_prefs(void)
1489          ether_unit = 0;
1490  
1491          const char *str = PrefsFindString("ether");
1492 <        if (str)
1493 <                sscanf(str, "%[^/]/%ld", ether_dev, &ether_unit);
1492 >        if (str) {
1493 >                const char *FirstSlash = strchr(str, '/');
1494 >                const char *LastSlash = strrchr(str, '/');
1495 >
1496 >                if (FirstSlash && FirstSlash && FirstSlash != LastSlash) {
1497 >                        // Device name contains path, i.e. "Networks/xyzzy.device"
1498 >                        const char *lp = str;
1499 >                        char *dp = ether_dev;
1500 >
1501 >                        while (lp != LastSlash)
1502 >                                *dp++ = *lp++;
1503 >                        *dp = '\0';
1504 >
1505 >                        sscanf(LastSlash, "/%ld", &ether_unit);
1506 >
1507 > //                      printf("dev=<%s> unit=%d\n", ether_dev, ether_unit);
1508 >                } else {
1509 >                        sscanf(str, "%[^/]/%ld", ether_dev, &ether_unit);
1510 >                }
1511 >        }
1512   }
1513  
1514   // Set serial preference item
# Line 1435 | Line 1530 | static void read_serial_settings(void)
1530  
1531          if (strlen(ether_dev)) {
1532                  char str[256];
1533 +
1534                  sprintf(str, "%s/%ld", ether_dev, ether_unit);
1535                  PrefsReplaceString("ether", str);
1536          } else

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines