--- BasiliskII/src/AmigaOS/prefs_editor_amiga.cpp 1999/10/21 22:39:57 1.3 +++ BasiliskII/src/AmigaOS/prefs_editor_amiga.cpp 2001/05/24 14:31:07 1.16 @@ -1,7 +1,7 @@ /* * prefs_editor_amiga.cpp - Preferences editor, AmigaOS implementation (using gtlayout.library) * - * Basilisk II (C) 1997-1999 Christian Bauer + * Basilisk II (C) 1997-2001 Christian Bauer * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,7 @@ #include #include #include +#include #include #include "sysdeps.h" @@ -65,6 +67,7 @@ const int GAD_CDROM_DEVICE = 0x0304; const int GAD_CDROM_UNIT = 0x0305; const int GAD_BOOTDRIVER = 0x0306; const int GAD_NOCDROM = 0x0307; +const int GAD_EXTFS = 0x0308; const int GAD_VOLUME_READONLY = 0x0310; // "Add/Edit Volume" window const int GAD_VOLUME_TYPE = 0x0311; @@ -91,6 +94,7 @@ const int GAD_SCSI3_UNIT = 0x0413; const int GAD_SCSI4_UNIT = 0x0414; const int GAD_SCSI5_UNIT = 0x0415; const int GAD_SCSI6_UNIT = 0x0416; +const int GAD_SCSI_MEMTYPE = 0x0420; const int GAD_VIDEO_TYPE = 0x0500; // "Graphics/Sound" pane const int GAD_DISPLAY_X = 0x0501; @@ -142,11 +146,7 @@ static void read_settings(struct LayoutH * Locale hook - returns string for given ID */ -#ifdef __GNUC__ static __saveds __attribute__((regparm(3))) const char *locale_hook_func(struct Hook *hook /*a0*/, void *id /*a1*/, struct LayoutHandle *h /*a2*/) -#else -static __saveds __regargs const char *locale_hook_func(struct Hook *hook /*a0*/, void *id /*a1*/, struct LayoutHandle *h /*a2*/) -#endif { return GetString((uint32)id); } @@ -355,14 +355,18 @@ bool PrefsEditor(void) case GAD_BOOTDRIVER: switch (code) { case 0: - PrefsReplaceInt16("bootdriver", 0); + PrefsReplaceInt32("bootdriver", 0); break; case 1: - PrefsReplaceInt16("bootdriver", CDROMRefNum); + PrefsReplaceInt32("bootdriver", CDROMRefNum); break; } break; + case GAD_SCSI_MEMTYPE: + PrefsReplaceInt32("scsimemtype", code); + break; + case GAD_VIDEO_TYPE: ghost_graphics_gadgets(h); break; @@ -429,10 +433,30 @@ bool PrefsEditor(void) case GAD_SCSI6_DEVICE: case GAD_SERIALA_DEVICE: case GAD_SERIALB_DEVICE: + if (dev_request) { + LT_LockWindow(win); + BOOL result = AslRequestTags(dev_request, + ASLFR_Window, (ULONG)win, + ASLFR_InitialDrawer, (ULONG) "Devs:", + TAG_END); + LT_UnlockWindow(win); + if (result) { + char *str; + GT_GetGadgetAttrs(gad, win, NULL, GTST_String, (ULONG)&str, TAG_END); + strncpy(str, dev_request->rf_File, 255); // Don't copy the directory part. This is usually "DEVS:" and we don't need that. + str[255] = 0; + LT_SetAttributes(h, gad->GadgetID, GTST_String, (ULONG)str, TAG_END); + } + } + break; + case GAD_ETHER_DEVICE: if (dev_request) { LT_LockWindow(win); - BOOL result = AslRequestTags(dev_request, ASLFR_Window, (ULONG)win, TAG_END); + BOOL result = AslRequestTags(dev_request, + ASLFR_Window, (ULONG)win, + ASLFR_InitialDrawer, (ULONG) "Devs:Networks", + TAG_END); LT_UnlockWindow(win); if (result) { char *str; @@ -514,6 +538,9 @@ quit: FreeAslRequest(dev_request); FreeAslRequest(file_request); + // Delete Menus + LT_DisposeMenu(menu); + // Delete handle LT_DeleteHandle(h); @@ -528,7 +555,7 @@ quit: */ static struct List disk_list; -static char cdrom_name[256]; +static char cdrom_name[256], extfs_name[256]; static ULONG cdrom_unit, cdrom_flags, cdrom_start, cdrom_size, cdrom_bsize; static BYTE bootdriver_num, nocdrom; @@ -552,7 +579,7 @@ static void parse_volumes_prefs(void) bootdriver_num = 0; - int bootdriver = PrefsFindInt16("bootdriver"); + int bootdriver = PrefsFindInt32("bootdriver"); switch (bootdriver) { case 0: bootdriver_num = 0; @@ -563,6 +590,11 @@ static void parse_volumes_prefs(void) } nocdrom = PrefsFindBool("nocdrom"); + + extfs_name[0] = 0; + str = PrefsFindString("extfs"); + if (str) + strncpy(extfs_name, str, sizeof(extfs_name) - 1); } // Ghost/unghost "Edit" and "Remove" buttons @@ -869,9 +901,6 @@ do_req: if (req) { } } while (!done); - // Delete handle - LT_DeleteHandle(h); - // Update preferences and list view if (ok_clicked) { char str[256]; @@ -909,6 +938,9 @@ do_req: if (req) { LT_SetAttributes(h2, GAD_DISK_LIST, GTLV_Labels, (ULONG)&disk_list, TAG_END); ghost_volumes_gadgets(h2); } + + // Delete handle + LT_DeleteHandle(h); } // Remove volume from list @@ -954,6 +986,9 @@ static void read_volumes_settings(void) PrefsRemoveItem("cdrom"); PrefsReplaceBool("nocdrom", nocdrom); + + if (strlen(extfs_name)) + PrefsReplaceString("extfs", extfs_name); } // Create "Volumes" pane @@ -969,6 +1004,7 @@ static void create_volumes_pane(struct L VGROUP; LT_New(h, LA_Type, LISTVIEW_KIND, LA_ID, GAD_DISK_LIST, + LA_Chars, 20, GTLV_Labels, (ULONG)&disk_list, LALV_Lines, 6, LALV_Link, (ULONG)NIL_LINK, @@ -1036,6 +1072,16 @@ static void create_volumes_pane(struct L TAG_END ); ENDGROUP; + VGROUP; + LT_New(h, LA_Type, STRING_KIND, + LA_LabelID, STR_EXTFS_CTRL, + LA_ID, GAD_EXTFS, + LA_Chars, 20, + LA_STRPTR, (ULONG)extfs_name, + GTST_MaxChars, sizeof(extfs_name) - 1, + TAG_END + ); + ENDGROUP; ENDGROUP; } @@ -1046,6 +1092,7 @@ static void create_volumes_pane(struct L static char scsi_dev[6][256]; static LONG scsi_unit[6]; +static LONG scsi_memtype; // Read SCSI preferences static void parse_scsi_prefs(void) @@ -1060,6 +1107,8 @@ static void parse_scsi_prefs(void) if (str) sscanf(str, "%[^/]/%ld", scsi_dev[i], &scsi_unit[i]); } + + scsi_memtype = PrefsFindInt32("scsimemtype"); } // Read settings from gadgets and set preferences @@ -1071,7 +1120,7 @@ static void read_scsi_settings(void) if (strlen(scsi_dev[i])) { char str[256]; - sprintf("%s/%ld", scsi_dev[i], scsi_unit[i]); + sprintf(str, "%s/%ld", scsi_dev[i], scsi_unit[i]); PrefsReplaceString(prefs_name, str); } else PrefsRemoveItem(prefs_name); @@ -1084,32 +1133,47 @@ static void create_scsi_pane(struct Layo parse_scsi_prefs(); VGROUP; - for (int i=0; i<7; i++) { - HGROUP; - LT_New(h, LA_Type, TEXT_KIND, - LA_LabelID, STR_SCSI_ID_0 + i, - TAG_END - ); - LT_New(h, LA_Type, STRING_KIND, - LA_LabelID, STR_DEVICE_CTRL, - LA_ID, GAD_SCSI0_DEVICE + i, - LA_Chars, 20, - LA_STRPTR, (ULONG)scsi_dev[i], - GTST_MaxChars, sizeof(scsi_dev[i]) - 1, - LAST_Picker, TRUE, - TAG_END - ); - LT_New(h, LA_Type, INTEGER_KIND, - LA_LabelID, STR_UNIT_CTRL, - LA_ID, GAD_SCSI0_UNIT + i, - LA_Chars, 4, - LA_LONG, (ULONG)&scsi_unit[i], - LAIN_UseIncrementers, TRUE, - GTIN_MaxChars, 8, - TAG_END - ); - ENDGROUP; - } + LT_New(h, LA_Type, VERTICAL_KIND, + LA_LabelID, STR_SCSI_DEVICES_CTRL, + TAG_END + ); + for (int i=0; i<7; i++) { + HGROUP; + LT_New(h, LA_Type, TEXT_KIND, + LA_LabelID, STR_SCSI_ID_0 + i, + TAG_END + ); + LT_New(h, LA_Type, STRING_KIND, + LA_LabelID, STR_DEVICE_CTRL, + LA_ID, GAD_SCSI0_DEVICE + i, + LA_Chars, 20, + LA_STRPTR, (ULONG)scsi_dev[i], + GTST_MaxChars, sizeof(scsi_dev[i]) - 1, + LAST_Picker, TRUE, + TAG_END + ); + LT_New(h, LA_Type, INTEGER_KIND, + LA_LabelID, STR_UNIT_CTRL, + LA_ID, GAD_SCSI0_UNIT + i, + LA_Chars, 4, + LA_LONG, (ULONG)&scsi_unit[i], + LAIN_UseIncrementers, TRUE, + GTIN_MaxChars, 8, + TAG_END + ); + ENDGROUP; + } + ENDGROUP; + VGROUP; + LT_New(h, LA_Type, CYCLE_KIND, + LA_LabelID, STR_SCSI_MEMTYPE_CTRL, + LA_ID, GAD_SCSI_MEMTYPE, + LACY_FirstLabel, STR_MEMTYPE_CHIP_LAB, + LACY_LastLabel, STR_MEMTYPE_ANY_LAB, + LA_LONG, (ULONG)&scsi_memtype, + TAG_END + ); + ENDGROUP; ENDGROUP; } @@ -1125,7 +1189,7 @@ enum { DISPLAY_SCREEN }; -static BYTE display_type; +static LONG display_type; static LONG dis_width, dis_height; static ULONG mode_id; static BYTE frameskip_num; @@ -1169,9 +1233,9 @@ static void parse_graphics_prefs(void) const char *str = PrefsFindString("screen"); if (str) { - if (sscanf(str, "win/%d/%d", &dis_width, &dis_height) == 2) + if (sscanf(str, "win/%ld/%ld", &dis_width, &dis_height) == 2) display_type = DISPLAY_WINDOW; - else if (sscanf(str, "pip/%d/%d", &dis_width, &dis_height) == 2) + else if (sscanf(str, "pip/%ld/%ld", &dis_width, &dis_height) == 2) display_type = DISPLAY_PIP; else if (sscanf(str, "scr/%08lx", &mode_id) == 1) display_type = DISPLAY_SCREEN; @@ -1223,15 +1287,28 @@ static void ghost_graphics_gadgets(struc // Show screen mode requester static void screen_mode_req(struct Window *win, struct LayoutHandle *h) { - if (P96Base == NULL) + if (P96Base == NULL && CyberGfxBase == NULL) return; LT_LockWindow(win); - ULONG id = p96RequestModeIDTags( - P96MA_MinDepth, 8, - P96MA_FormatsAllowed, RGBFF_CLUT | RGBFF_R5G5B5 | RGBFF_A8R8G8B8, - TAG_END - ); + + ULONG id; + + // Try P96 first, because it also provides a (fake) cybergraphics.library + if (P96Base) { + id = p96RequestModeIDTags( + P96MA_MinDepth, 8, + P96MA_FormatsAllowed, RGBFF_CLUT | RGBFF_R5G5B5 | RGBFF_A8R8G8B8, + TAG_END + ); + } else { + UWORD ModelArray[] = { PIXFMT_LUT8, PIXFMT_RGB15, PIXFMT_ARGB32, 0, ~0 }; + id = (ULONG) CModeRequestTags(NULL, + CYBRMREQ_MinDepth, 8, + CYBRMREQ_CModelArray, (ULONG) ModelArray, + TAG_END + ); + } LT_UnlockWindow(win); if (id != INVALID_ID) { @@ -1314,7 +1391,7 @@ static void create_graphics_pane(struct LA_LabelID, STR_VIDEO_TYPE_CTRL, LA_ID, GAD_VIDEO_TYPE, LACY_LabelTable, (ULONG)labels, - LA_BYTE, (ULONG)&display_type, + LA_LONG, (ULONG)&display_type, TAG_END ); LT_New(h, LA_Type, INTEGER_KIND, @@ -1412,8 +1489,26 @@ static void parse_serial_prefs(void) ether_unit = 0; const char *str = PrefsFindString("ether"); - if (str) - sscanf(str, "%[^/]/%ld", ether_dev, ðer_unit); + if (str) { + const char *FirstSlash = strchr(str, '/'); + const char *LastSlash = strrchr(str, '/'); + + if (FirstSlash && FirstSlash && FirstSlash != LastSlash) { + // Device name contains path, i.e. "Networks/xyzzy.device" + const char *lp = str; + char *dp = ether_dev; + + while (lp != LastSlash) + *dp++ = *lp++; + *dp = '\0'; + + sscanf(LastSlash, "/%ld", ðer_unit); + +// printf("dev=<%s> unit=%d\n", ether_dev, ether_unit); + } else { + sscanf(str, "%[^/]/%ld", ether_dev, ðer_unit); + } + } } // Set serial preference item @@ -1435,6 +1530,7 @@ static void read_serial_settings(void) if (strlen(ether_dev)) { char str[256]; + sprintf(str, "%s/%ld", ether_dev, ether_unit); PrefsReplaceString("ether", str); } else