hschumann2/TempleOS-Source-Code
0838
1 2//This is run in a #exe{}.3 4U8 *kernel_cfg_options="MemInit\0HeapInit\0VarInit\0StaffMode\0"5"HomeDir\0NoMP\0TextMode\0DontProbe\0MountIDEAuto\0DbgDistro\0Help\0";6 7#define CFG_MEM_INIT 08#define CFG_HEAP_INIT 19#define CFG_VAR_INIT 210#define CFG_STAFF_MODE 311#define CFG_HOME_DIR 412#define CFG_NO_MP 513#define CFG_TEXT_MODE 614#define CFG_DONT_PROBE 715#define CFG_MOUNT_IDE_AUTO 816#define CFG_DBG_DISTRO 917#define CFG_OPTIONS_NUM 1018 19#define CFG_HELP 1020 21class CKCfg22{23 U8 *dsk_cache_size_exp;24 CDoc *add_dev;25 U8 *dbg_distro_file,*dbg_distro_start;26 U8 *home_dir;27 Bool opts[CFG_OPTIONS_NUM];28 U8 mem_init_val,heap_init_val,var_init_val,29 boot_drv_let,mount_ide_auto_hd_let,mount_ide_auto_cd_let;30};31 32CDoc *KCfgAddDev(CKCfg *c)33{34 I64 ch;35 CDoc *doc=DocNew;36 "\n\nIn anticipation of the drives you will\n"37 "define shortly, enter the drive letter\n"38 "of the drive with the account directory.\n"39 "\n($PURPLE$<ENTER>$FG$ for cur drv) Boot Drv:";40 ch=Let2Let(GetChar);41 if ('A'<=ch<='Z')42 c->boot_drv_let=ch;43 else44 c->boot_drv_let=Drv2Let(Fs->cur_dv);45 "\n\n$BK,1$$PURPLE$Mount drives so they will be present when "46 "you boot.$FG$$BK,0$\n";47 Mount2(c->boot_drv_let,doc,FALSE);48 return doc;49}50 51U0 KCfgOptions(CKCfg *c)52{53 I64 i;54 U8 *st=NULL,*st2,*st3;55 Bool state;56 do {57 Free(st);58 for (i=0;i<CFG_OPTIONS_NUM;i++)59 if (i==CFG_HOME_DIR)60 "$PURPLE$%13tz$FG$:\"%s\"\n",i,kernel_cfg_options,c->home_dir;61 else62 "$PURPLE$%13tz$FG$:%Z\n",i,kernel_cfg_options,c->opts[i],"ST_OFF_ON";63 "\nType '$PURPLE$Help$FG$' for help.\n";64 st=GetStr("Option ($PURPLE$<ENTER>$FG$ when done):","");65 i=LstMatch(st,kernel_cfg_options,LMF_IGNORE_CASE);66 if (i==CFG_HELP)67 "\n"68 "$PURPLE$MemInit$FG$ Initializes memory above 0x100000 "69 "to a val at boot.\n"70 "$PURPLE$HeapInit$FG$ Initializes MAlloc() memory to a val.\n"71 "$PURPLE$VarInit$FG$ Initializes glbl var memory to a val.\n"72 "$PURPLE$HomeDir$FG$ Set home dir.\n"73 "$PURPLE$NoMP$FG$ No multicore.\n"74 "$PURPLE$TextMode$FG$ Text Mode (requires hard reboot).\n"75 "$PURPLE$DontProbe$FG$ Just prompt CD/DVD ports, don't probe.\n"76 "$PURPLE$MountIDEAuto$FG$ Auto Mount IDE drives to 'C' and 'T'.\n"77 "$PURPLE$DbgDistro$FG$ Include RAM Drv in Kernel.BIN.\n"78 "\n";79 else80 if (0<=i<CFG_OPTIONS_NUM) {81 state=c->opts[i]=!c->opts[i];82 switch (i) {83 case CFG_MEM_INIT:84 if (state)85 c->mem_init_val=GetI64("Val (0-255):",255,0,255);86 break;87 case CFG_HEAP_INIT:88 if (state)89 c->heap_init_val=GetI64("Val (0-255):",255,0,255);90 break;91 case CFG_VAR_INIT:92 if (state)93 c->var_init_val=GetI64("Val (0-255):",255,0,255);94 break;95 case CFG_HOME_DIR:96 st2=GetStr("Home Dir(\"%s\"):",c->home_dir);97 if (!*st2)98 st2=StrNew("::/Home");99 else if (st2[1]!=':') {100 st3=MStrPrint("::%s",st2);101 Free(st2);102 st2=st3;103 }104 Free(c->home_dir);105 c->home_dir=st2;106 if (StrCmp(c->home_dir,"::/Home"))107 c->opts[i]=TRUE;108 else109 c->opts[i]=FALSE;110 break;111 case CFG_MOUNT_IDE_AUTO:112 if (state) {113 "First HD Drive Let:";114 c->mount_ide_auto_hd_let=Let2Let(GetChar);115 if (!('A'<=c->mount_ide_auto_hd_let<='Z'))116 c->mount_ide_auto_hd_let=0;117 '\n';118 if (c->mount_ide_auto_hd_let)119 "First HD Drive:%C\n",c->mount_ide_auto_hd_let;120 else121 "First HD Drive:%C\n",'C';122 123 "First CD Drive Let:";124 c->mount_ide_auto_cd_let=Let2Let(GetChar);125 if (!('A'<=c->mount_ide_auto_cd_let<='Z'))126 c->mount_ide_auto_cd_let=0;127 '\n';128 if (c->mount_ide_auto_cd_let)129 "First CD Drive:%C\n",c->mount_ide_auto_cd_let;130 else131 "First CD Drive:%C\n",'T';132 } else {133 c->mount_ide_auto_hd_let=0;134 c->mount_ide_auto_cd_let=0;135 }136 break;137 case CFG_DBG_DISTRO:138 Free(c->dbg_distro_file);139 c->dbg_distro_file=0;140 c->dbg_distro_start=0;141 if (state) {142 c->dbg_distro_file=GetStr("Dbg Distro File:");143 c->dbg_distro_start=GetI64("Dbg Distro Start:");144 }145 break;146 }147 }148 } while (*st);149 Free(st);150}151 152CKCfg *KCfgNew()153{154 CKCfg *c=CAlloc(sizeof(CKCfg));155 156 c->add_dev=KCfgAddDev(c);157 c->home_dir=StrNew("::/Home");158 c->dsk_cache_size_exp=GetStr(159 "Disk Cache Size in Bytes,\n"160 "gets rounded-up funny,\n"161 "($PURPLE$<ENTER>$FG$ will use default.):",162 "Scale2Mem(0x80000,0x8000000)");163 KCfgOptions(c);164 return c;165}166 167U0 KCfgDel(CKCfg *c)168{169 DocDel(c->add_dev);170 Free(c->dbg_distro_file);171 Free(c->home_dir);172 Free(c->dsk_cache_size_exp);173 Free(c);174}175 