diff --git a/BESM6/besm6_disk.c b/BESM6/besm6_disk.c index b5febae9..40e5065c 100644 --- a/BESM6/besm6_disk.c +++ b/BESM6/besm6_disk.c @@ -28,6 +28,7 @@ * authorization from Leonid Broukhis and Serge Vakulenko. */ #include "besm6_defs.h" +#include /* * Управляющее слово обмена с магнитным диском. @@ -48,6 +49,11 @@ */ #define STATUS_GOOD 014000400 +/* + * Total size of a disk in blocks, including hidden blocks + */ +#define DISK_TOTBLK 01767 + /* * Параметры обмена с внешним устройством. */ @@ -160,10 +166,57 @@ t_stat disk_reset (DEVICE *dptr) t_stat disk_attach (UNIT *u, char *cptr) { t_stat s; + int32 saved_switches = sim_switches; + sim_switches |= SWMASK ('E'); - s = attach_unit (u, cptr); - if (s != SCPE_OK) - return s; + while (1) { + s = attach_unit (u, cptr); + if ((s == SCPE_OK) && (sim_switches & SWMASK ('N'))) { + t_value control[4]; /* block (zone) number, key, userid, checksum */ + int diskno, blkno, word; + char *pos; + /* Using the rightmost sequence of digits within the filename + * as a volume number, e.g. "/var/tmp/besm6/2052.bin" -> 2052 + */ + pos = cptr + strlen(cptr); + while (pos > cptr && !isdigit(*--pos)); + while (pos > cptr && isdigit(*pos)) --pos; + if (!isdigit(*pos)) ++pos; + diskno = atoi(pos); + if (diskno < 2048 || diskno > 4095) { + if (diskno == 0) + sim_printf ("%s: filename must contain volume number 2048..4095\n", sim_uname(u)); + else + sim_printf ("%s: disk volume %d from filename %s invalid (must be 2048..4095)\n", + sim_uname (u), diskno, cptr); + /* unlink (cptr); ??? */ + return SCPE_ARG; + } + if (!sim_quiet && !(sim_switches & SWMASK ('Q'))) + sim_printf ("%s: formatting disk volume %d\n", sim_uname (u), diskno); + + control[1] = SET_CONVOL(0, CONVOL_NUMBER); + control[2] = SET_CONVOL(0, CONVOL_NUMBER); + control[3] = SET_CONVOL(0, CONVOL_NUMBER); + + control[1] |= 01370707LL << 24; /* Magic mark */ + control[1] |= diskno << 12; + + for (blkno = 0; blkno < DISK_TOTBLK; ++blkno) { + control[0] = SET_CONVOL((t_value)(2*blkno) << 36, CONVOL_NUMBER); + fwrite(control, sizeof(t_value), 4, u->fileref); + control[0] = SET_CONVOL((t_value)(2*blkno+1) << 36, CONVOL_NUMBER); + fwrite(control, sizeof(t_value), 4, u->fileref); + for (word = 0; word < 02000; ++word) { + fwrite(control+2, sizeof(t_value), 1, u->fileref); + } + } + return SCPE_OK; + } + if (saved_switches & SWMASK ('E')) + return s; + sim_switches |= SWMASK ('N'); + } return SCPE_OK; } diff --git a/BESM6/besm6_tty.c b/BESM6/besm6_tty.c index ad80ec56..f260fe8b 100644 --- a/BESM6/besm6_tty.c +++ b/BESM6/besm6_tty.c @@ -617,7 +617,7 @@ void tt_print() */ static int unicode_to_koi7 (unsigned val) { - if ('_' <= val) return val; + if (val <= '_') return val; else if ('a' <= val && val <= 'z') return val + 'Z' - 'z'; else switch (val) { case 0x007f: return 0x7f; diff --git a/BESM6/dispak.ini b/BESM6/dispak.ini index d182d028..c812b662 100644 --- a/BESM6/dispak.ini +++ b/BESM6/dispak.ini @@ -16,13 +16,12 @@ attach drum1 drum2x.bin ; ; Создаем рабочий диск. ; -! ./formatdisk 2052 > 2052.bin +attach -n disk6 2052.bin ; ; Подключаем диски. ; attach -e disk7 sbor2053.bin -attach -e disk6 2052.bin attach -e disk5 krab2063.bin attach -e disk0 sbor2048.bin attach -e disk1 svs2048.bin diff --git a/BESM6/formatdisk.c b/BESM6/formatdisk.c deleted file mode 100644 index b72c7b86..00000000 --- a/BESM6/formatdisk.c +++ /dev/null @@ -1,63 +0,0 @@ -/* - * formatdisk.c - A utility to produce blank BESM-6 disk images. - * - * Copyright (c) 2014 Leonid Broukhis - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * SERGE VAKULENKO OR LEONID BROUKHIS BE LIABLE FOR ANY CLAIM, DAMAGES - * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE - * OR OTHER DEALINGS IN THE SOFTWARE. - * - * Except as contained in this notice, the name of Leonid Broukhis or - * Serge Vakulenko shall not be used in advertising or otherwise to promote - * the sale, use or other dealings in this Software without prior written - * authorization from Leonid Broukhis and Serge Vakulenko. - */ - -#include -#include -#include -#include "besm6_defs.h" - -#define TOTBLK 01767 - -int main(int argc, char ** argv) { - t_value control[4]; /* block (zone) number, key, userid, checksum */ - int diskno, blkno, word; - - if (argc != 2 || (diskno = atoi(argv[1])) < 2048 || diskno > 4095) { - fprintf(stderr, "Usage: formatdisk NNNN > diskNNNN.bin, where 2048 <= NNNN <= 4095\n"); - exit(1); - } - - control[1] = SET_CONVOL(0, CONVOL_NUMBER); - control[2] = SET_CONVOL(0, CONVOL_NUMBER); - control[3] = SET_CONVOL(0, CONVOL_NUMBER); - - control[1] |= 01370707LL << 24; /* Magic */ - control[1] |= diskno << 12; - - for (blkno = 0; blkno < TOTBLK; ++blkno) { - control[0] = SET_CONVOL((t_value)(2*blkno) << 36, CONVOL_NUMBER); - fwrite(control, sizeof(t_value), 4, stdout); - control[0] = SET_CONVOL((t_value)(2*blkno+1) << 36, CONVOL_NUMBER); - fwrite(control, sizeof(t_value), 4, stdout); - for (word = 0; word < 02000; ++word) { - fwrite(control+2, sizeof(t_value), 1, stdout); - } - } - exit(0); -} diff --git a/makefile b/makefile index 9e92b82c..0ac02237 100644 --- a/makefile +++ b/makefile @@ -1171,8 +1171,6 @@ BESM6 = ${BESM6D}/besm6_cpu.c ${BESM6D}/besm6_sys.c ${BESM6D}/besm6_mmu.c \ ${BESM6D}/besm6_tty.c ${BESM6D}/besm6_panel.c ${BESM6D}/besm6_printer.c \ ${BESM6D}/besm6_punch.c -FORMATDISK = ${BESM6D}/formatdisk.c - ifeq (,${VIDEO_LDFLAGS}) BESM6_OPT = -I ${BESM6D} -DUSE_INT64 else ifneq (,$(and $(findstring SDL2,${VIDEO_LDFLAGS}),$(call find_include,SDL2/SDL_ttf),$(call find_lib,SDL2_ttf))) @@ -1486,16 +1484,12 @@ ${BIN}ssem${EXE} : ${SSEM} ${SIM} ${MKDIRBIN} ${CC} ${SSEM} ${SIM} ${SSEM_OPT} $(CC_OUTSPEC) ${LDFLAGS} -besm6 : ${BIN}besm6${EXE} ${BIN}formatdisk${EXE} +besm6 : ${BIN}besm6${EXE} ${BIN}besm6${EXE} : ${BESM6} ${SIM} ${MKDIRBIN} ${CC} ${BESM6} ${SIM} ${BESM6_OPT} $(CC_OUTSPEC) ${LDFLAGS} -${BIN}formatdisk${EXE} : ${FORMATDISK} - ${MKDIRBIN} - ${CC} ${FORMATDISK} ${BESM6_OPT} $(CC_OUTSPEC) - sigma : ${BIN}sigma${EXE} ${BIN}sigma${EXE} : ${SIGMA} ${SIM}