Subversion Repositories SvarDOS

Rev

Rev 1911 | Rev 1928 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1911 Rev 1918
Line 39... Line 39...
39
 
39
 
40
/* keyboard layouts and locales */
40
/* keyboard layouts and locales */
41
#include "keylay.h"
41
#include "keylay.h"
42
#include "keyoff.h"
42
#include "keyoff.h"
43
 
43
 
44
/* prototype of the int24hdl() function defined in int24hdl.asm */
-
 
45
void int24hdl(void);
-
 
46
 
-
 
47
 
44
 
48
/* color scheme (preset for color) */
45
/* color scheme (preset for color) */
49
static unsigned char COLOR_TITLEBAR  = 0x70;
46
static unsigned char COLOR_TITLEBAR  = 0x70;
50
static unsigned char COLOR_TITLEVER  = 0x78;
47
static unsigned char COLOR_TITLEVER  = 0x78;
51
static unsigned char COLOR_BODY      = 0x17;
48
static unsigned char COLOR_BODY      = 0x17;
Line 78... Line 75...
78
  unsigned short keybid;
75
  unsigned short keybid;
79
  unsigned short countryid; /* 1=USA, 33=FR, 48=PL, etc */
76
  unsigned short countryid; /* 1=USA, 33=FR, 48=PL, etc */
80
};
77
};
81
 
78
 
82
 
79
 
-
 
80
/* install a dummy int24h handler that always fails. this is to avoid the
-
 
81
 * annoying "abort, retry, fail... DOS messages. */
-
 
82
static void install_int24(void) {
-
 
83
  static unsigned char handler[] = { /* contains machine code instructions */
-
 
84
    0xB0, 0x03,  /* mov al, 3   ; tell DOS the action has to FAIL   */
-
 
85
    0xCF};       /* ret         ; return from the interrupt handler */
-
 
86
  /* install the handler */
-
 
87
  _asm {
-
 
88
    push dx
-
 
89
    mov ax, 0x2524          /* set INT vector 0x24 (to DS:DX)   */
-
 
90
    mov dx, offset handler  /* DS:DX points at my dummy handler */
-
 
91
    int 0x21
-
 
92
    pop dx
-
 
93
  }
-
 
94
}
-
 
95
 
-
 
96
 
-
 
97
static void exec(const char *s) {
-
 
98
  system(s);
-
 
99
  install_int24(); /* reinstall my int24 handler, apparently system() reverts
-
 
100
                      the original (DOS) one */
-
 
101
}
-
 
102
 
-
 
103
 
83
/* put a string on screen and fill it until w chars with white space */
104
/* put a string on screen and fill it until w chars with white space */
84
static void video_putstringfix(unsigned char y, unsigned char x, unsigned char attr, const char *s, unsigned char w) {
105
static void video_putstringfix(unsigned char y, unsigned char x, unsigned char attr, const char *s, unsigned char w) {
85
  unsigned char i;
106
  unsigned char i;
86
 
107
 
87
  /* print the string up to w characters */
108
  /* print the string up to w characters */
Line 595... Line 616...
595
      list[3] = NULL;
616
      list[3] = NULL;
596
      snprintf(buff, sizeof(buff), svarlang_strid(0x0300), cselecteddrive, SVARDOS_DISK_REQ); /* "ERROR: Drive %c: could not be found. Note, that SvarDOS requires at least %d MiB of available disk space */
617
      snprintf(buff, sizeof(buff), svarlang_strid(0x0300), cselecteddrive, SVARDOS_DISK_REQ); /* "ERROR: Drive %c: could not be found. Note, that SvarDOS requires at least %d MiB of available disk space */
597
      switch (menuselect(6 + putstringwrap(4, 1, COLOR_BODY, buff), 3, list, -1)) {
618
      switch (menuselect(6 + putstringwrap(4, 1, COLOR_BODY, buff), 3, list, -1)) {
598
        case 0:
619
        case 0:
599
          sprintf(buff, "FDISK /PRI:MAX %d", driveid);
620
          sprintf(buff, "FDISK /PRI:MAX %d", driveid);
600
          system(buff);
621
          exec(buff);
601
          break;
622
          break;
602
        case 1:
623
        case 1:
603
          mdr_cout_cls(0x07);
624
          mdr_cout_cls(0x07);
604
          mdr_cout_locate(0, 0);
625
          mdr_cout_locate(0, 0);
605
          sprintf(buff, "FDISK %d", driveid);
626
          sprintf(buff, "FDISK %d", driveid);
606
          system(buff);
627
          exec(buff);
607
          break;
628
          break;
608
        case 2:
629
        case 2:
609
          return(MENUQUIT);
630
          return(MENUQUIT);
610
        default:
631
        default:
611
          return(-1);
632
          return(-1);
612
      }
633
      }
613
      /* write a temporary MBR which only skips the drive (in case BIOS would
634
      /* write a temporary MBR which only skips the drive (in case BIOS would
614
       * try to boot off the not-yet-ready C: disk) */
635
       * try to boot off the not-yet-ready C: disk) */
615
      sprintf(buff, "FDISK /LOADIPL %d", driveid);
636
      sprintf(buff, "FDISK /LOADIPL %d", driveid);
616
      system(buff); /* writes BOOT.MBR into actual MBR */
637
      exec(buff); /* writes BOOT.MBR into actual MBR */
617
      newscreen(2);
638
      newscreen(2);
618
      putstringnls(10, 10, COLOR_BODY, 3, 1); /* "Your computer will reboot now." */
639
      putstringnls(10, 10, COLOR_BODY, 3, 1); /* "Your computer will reboot now." */
619
      putstringnls(12, 10, COLOR_BODY, 0, 5); /* "Press any key..." */
640
      putstringnls(12, 10, COLOR_BODY, 0, 5); /* "Press any key..." */
620
      mdr_dos_getkey();
641
      mdr_dos_getkey();
621
      reboot();
642
      reboot();
Line 638... Line 659...
638
      if (choice < 0) return(MENUPREV);
659
      if (choice < 0) return(MENUPREV);
639
      if (choice == 1) return(MENUQUIT);
660
      if (choice == 1) return(MENUQUIT);
640
      mdr_cout_cls(0x07);
661
      mdr_cout_cls(0x07);
641
      mdr_cout_locate(0, 0);
662
      mdr_cout_locate(0, 0);
642
      snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVARDOS", cselecteddrive);
663
      snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVARDOS", cselecteddrive);
643
      system(buff);
664
      exec(buff);
644
      continue;
665
      continue;
645
    }
666
    }
646
    /* check total disk space */
667
    /* check total disk space */
647
    ds = disksize(selecteddrive);
668
    ds = disksize(selecteddrive);
648
    if (ds < SVARDOS_DISK_REQ) {
669
    if (ds < SVARDOS_DISK_REQ) {
Line 671... Line 692...
671
      if (choice < 0) return(MENUPREV);
692
      if (choice < 0) return(MENUPREV);
672
      if (choice == 1) return(MENUQUIT);
693
      if (choice == 1) return(MENUQUIT);
673
      mdr_cout_cls(0x07);
694
      mdr_cout_cls(0x07);
674
      mdr_cout_locate(0, 0);
695
      mdr_cout_locate(0, 0);
675
      snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVARDOS", cselecteddrive);
696
      snprintf(buff, sizeof(buff), "FORMAT %c: /Q /U /Z:seriously /V:SVARDOS", cselecteddrive);
676
      system(buff);
697
      exec(buff);
677
      continue;
698
      continue;
678
    } else {
699
    } else {
679
      /* final confirmation */
700
      /* final confirmation */
680
      const char *list[3];
701
      const char *list[3];
681
      list[0] = svarlang_strid(0x0001); /* Install SvarDOS */
702
      list[0] = svarlang_strid(0x0001); /* Install SvarDOS */
Line 685... Line 706...
685
      mdr_cout_str(7, 40 - (strlen(buff) / 2), buff, COLOR_BODY, 80);
706
      mdr_cout_str(7, 40 - (strlen(buff) / 2), buff, COLOR_BODY, 80);
686
      choice = menuselect(10, 2, list, -1);
707
      choice = menuselect(10, 2, list, -1);
687
      if (choice < 0) return(MENUPREV);
708
      if (choice < 0) return(MENUPREV);
688
      if (choice == 1) return(MENUQUIT);
709
      if (choice == 1) return(MENUQUIT);
689
      snprintf(buff, sizeof(buff), "SYS %c: %c: > NUL", sourcedrv, cselecteddrive);
710
      snprintf(buff, sizeof(buff), "SYS %c: %c: > NUL", sourcedrv, cselecteddrive);
690
      system(buff);
711
      exec(buff);
691
      sprintf(buff, "FDISK /MBR %d", driveid);
712
      sprintf(buff, "FDISK /MBR %d", driveid);
692
      system(buff);
713
      exec(buff);
693
      snprintf(buff, sizeof(buff), "%c:\\TEMP", cselecteddrive);
714
      snprintf(buff, sizeof(buff), "%c:\\TEMP", cselecteddrive);
694
      mkdir(buff);
715
      mkdir(buff);
695
      return(cselecteddrive);
716
      return(cselecteddrive);
696
    }
717
    }
697
  }
718
  }
Line 991... Line 1012...
991
  if (locales->egafile == 1) {
1012
  if (locales->egafile == 1) {
992
    snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%u) EGA.CPX) > NUL", locales->codepage);
1013
    snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%u) EGA.CPX) > NUL", locales->codepage);
993
  } else {
1014
  } else {
994
    snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%u) EGA%d.CPX) > NUL", locales->codepage, locales->egafile);
1015
    snprintf(buff, sizeof(buff), "MODE CON CP PREP=((%u) EGA%d.CPX) > NUL", locales->codepage, locales->egafile);
995
  }
1016
  }
996
  system(buff);
1017
  exec(buff);
997
  snprintf(buff, sizeof(buff), "MODE CON CP SEL=%u > NUL", locales->codepage);
1018
  snprintf(buff, sizeof(buff), "MODE CON CP SEL=%u > NUL", locales->codepage);
998
  system(buff);
1019
  exec(buff);
999
  /* below I re-init the video controller - apparently this is required if
1020
  /* below I re-init the video controller - apparently this is required if
1000
   * I want the new glyph symbols to be actually applied, at least some
1021
   * I want the new glyph symbols to be actually applied, at least some
1001
   * (broken?) BIOSes, like VBox, apply glyphs only at next video mode change */
1022
   * (broken?) BIOSes, like VBox, apply glyphs only at next video mode change */
1002
  _asm {
1023
  _asm {
1003
    push bx
1024
    push bx
Line 1018... Line 1039...
1018
  int sourcedrv;
1039
  int sourcedrv;
1019
  int action;
1040
  int action;
1020
 
1041
 
1021
  /* setup an internal int 24h handler ("always fail") so DOS does not output
1042
  /* setup an internal int 24h handler ("always fail") so DOS does not output
1022
   * the ugly "abort, retry, fail" messages */
1043
   * the ugly "abort, retry, fail" messages */
1023
  int24hdl();
1044
  install_int24();
1024
 
1045
 
1025
  /* read the svardos build revision (from floppy label) */
1046
  /* read the svardos build revision (from floppy label) */
1026
  {
1047
  {
1027
    const char *fspec = "*.*";
1048
    const char *fspec = "*.*";
1028
    const char *res = (void*)0x9E; /* default DTA is at PSP:80h, field 1Eh of DTA is the ASCIZ file name */
1049
    const char *res = (void*)0x9E; /* default DTA is at PSP:80h, field 1Eh of DTA is the ASCIZ file name */