* added compilers lcc and bcc (linux86)
[mascara-docs.git] / compilers / linux86-0.16.17 / bootblocks / makeboot.c
blobfa3773ffc735921541fb54ad2ef564bd7f1b0794
2 #include <stdio.h>
3 #include <ctype.h>
4 #include <time.h>
5 #include <string.h>
7 #include "sysboot.v"
8 #include "noboot.v"
9 #include "msdos.v"
10 #include "msdos16.v"
11 #include "skip.v"
12 #include "killhd.v"
13 #include "tarboot.v"
14 #include "minix.v"
15 #include "minixhd.v"
16 #include "mbr.v"
18 unsigned char buffer[1024];
20 #define FS_NONE 0 /* Bootsector is complete */
21 #define FS_DOS 1 /* Bootsector needs 'normal' DOS FS */
22 #define FS_ADOS 2 /* Bootsector likes any DOS FS */
23 #define FS_TAR 3 /* Bootsector needs GNU-tar volume label */
24 #define FS_STAT 4 /* Any bootsector is checked */
25 #define FS_ZERO 5 /* Boot sector must be already Zapped */
26 #define FS_MBR 6 /* Boot sector is an MBR */
28 #ifndef __MSDOS__
29 #define X_HAS_2M20
30 #endif
32 struct bblist {
33 char * name;
34 char * desc;
35 char * data;
36 int size;
37 int name_type;
38 int boot_name;
39 int fstype;
40 int fsmod;
41 } bblocks[] = {
42 { "tar", "Bootable GNU tar volume lable",
43 tarboot_data, tarboot_size, 0, 0, FS_TAR},
44 { "dos12","Boot file BOOTFILE.SYS from dos floppy",
45 msdos_data, msdos_size,
46 1, msdos_boot_name-msdos_start, FS_DOS, 12},
47 { "dos16","Boot file BOOTFILE.SYS from FAT16 hard disk or floppy",
48 msdos16_data, msdos16_size,
49 1, msdos16_boot_name-msdos16_start, FS_DOS, 16},
50 { "none", "No OS bootblock, just display message",
51 noboot_data, noboot_size,
52 2, noboot_boot_message-noboot_start, FS_ADOS},
53 { "skip", "Bypasses floppy boot with message",
54 skip_data, skip_size,
55 2, skip_mesg-skip_start, FS_ADOS},
56 { "minix","Minix floppy FS booter",
57 minix_data, minix_size,
58 2, minix_bootfile-minix_start, FS_ZERO},
59 { "hdmin","Minix Hard disk FS booter",
60 minixhd_data, minixhd_size,
61 2, minixhd_bootfile-minixhd_start, FS_ZERO},
62 { "killhd", "Deletes MBR from hard disk when booted",
63 killhd_data, killhd_size,
64 2, killhd_boot_message-killhd_start, FS_ADOS},
65 #if __STDC__
66 { "mbr", "Master boot record for HD"
67 #if defined(mbr_Banner) || mbr_diskman || mbr_linear || mbr_mbrkey || mbr_preboot
68 ", Options:"
69 #ifdef mbr_Banner
70 " Banner"
71 #endif
72 #if mbr_diskman
73 " DiskMan"
74 #endif
75 #if mbr_linear
76 " LBA"
77 #if !mbr_useCHS
78 "-Only"
79 #endif
80 #endif
81 #if mbr_mbrkey
82 " BootKeys"
83 #endif
84 #if mbr_preboot
85 " PreBoot"
86 #endif
87 #endif
89 mbr_data,mbr_size,
90 #ifdef mbr_Banner
91 2, mbr_Banner-mbr_start, FS_MBR},
92 #else
93 0, 0, FS_MBR},
94 #endif
95 #else
96 { "mbr", "Master boot record for HD",
97 mbr_data,mbr_size, 0, 0, FS_MBR},
98 #endif
99 { "stat", "Display dosfs superblock",
100 0, 0, 0, 0, FS_STAT},
101 { "copy", "Copy boot block to makeboot.sav or named file",
102 0, 0, 0, 0, FS_STAT},
103 { "Zap", "Clear boot block to NULs",
104 0, 1024, 0, 0, FS_NONE},
108 char * progname = "";
110 int disktype = 0;
111 FILE * diskfd;
113 int disk_sect = 63; /* These are initilised to the maximums */
114 int disk_head = 256; /* Set to the correct values when an MSDOS disk is */
115 int disk_trck = 256; /* successfully identified */
117 int force = 0;
118 int write_zero = 1; /* Write sector 0 */
119 int write_one = 0; /* Write sector 1 */
120 int bs_offset = 0; /* Offset of _real_ bootsector for 2m floppies */
122 char * boot_id = 0;
124 main(argc, argv)
125 int argc;
126 char ** argv;
128 FILE * fd;
129 struct bblist *ptr;
130 int i;
132 progname = argv[0];
134 if( argc == 4 && strcmp(argv[1], "-f") == 0 )
136 argv++; argc--; force++;
138 if( argc != 3 ) Usage();
140 boot_id = strchr(argv[1], '=');
141 if( boot_id )
142 *boot_id++ = '\0';
144 if( (i=strlen(argv[1])) < 2 ) Usage();
145 for(ptr = bblocks; ptr->name; ptr++)
146 if( strncmp(argv[1], ptr->name, i) == 0 ) break;
147 if( ptr->name == 0 ) Usage();
149 open_disk(argv[2]);
150 if( read_sector(0, buffer) != 0 )
151 exit(1);
152 read_sector(1, buffer+512);
154 write_zero = (ptr->size >= 512);
155 write_one = (ptr->size >= 1024);
157 switch(ptr->fstype)
159 case FS_NONE: /* override */
160 case FS_STAT:
161 case FS_ADOS:
162 break;
163 case FS_DOS:
164 check_msdos();
165 if(ptr->fsmod) check_simpledos(ptr->fsmod);
166 break;
167 case FS_TAR:
168 check_tar();
169 break;
170 case FS_ZERO:
171 check_zapped();
172 break;
173 case FS_MBR:
174 check_mbr();
175 break;
177 default:
178 fprintf(stderr, "Program error, unknown filesystem requirement\n");
179 exit(2);
182 switch(ptr->fstype)
184 case FS_STAT:
185 if( strcmp(ptr->name, "copy") == 0 )
186 save_super(buffer);
187 else
188 print_super(buffer);
189 close_disk();
190 exit(0);
191 case FS_DOS:
192 case FS_ADOS:
193 for(i=0; i<sysboot_dosfs_stat; i++)
194 buffer[i] = ptr->data[i];
195 for(i=sysboot_codestart; i<512; i++)
196 buffer[i] = ptr->data[i];
197 break;
199 case FS_TAR:
200 copy_tarblock();
201 break;
203 case FS_MBR:
204 copy_mbr(ptr->data);
205 break;
207 case FS_ZERO:
208 case FS_NONE:
209 if( ptr->data )
210 memcpy(buffer, ptr->data, ptr->size);
211 else
213 memset(buffer, '\0', 1024);
214 write_one = 1;
216 break;
219 if( boot_id ) switch(ptr->name_type)
221 case 1:
222 set_dosname(ptr->boot_name);
223 break;
224 case 2:
225 set_asciz(ptr->boot_name);
226 break;
227 default:
228 fprintf(stderr, "Cannot specify boot name for this block\n");
229 exit(1);
232 if( bs_offset )
234 if( write_zero ) do_2m_write();
235 /* Don't write 1 ever! */
237 else
239 if( write_zero ) write_sector(0, buffer);
240 if( write_one ) write_sector(1, buffer+512);
242 close_disk();
243 exit(0);
246 Usage()
248 struct bblist *ptr = bblocks;
250 if( progname == 0 || *progname == 0 || progname[1] == 0 )
251 progname = "makeboot";
253 #ifdef __MSDOS__
254 fprintf(stderr, "Usage: %s [-f] bootblock[=bootname] a:\n\n", progname);
255 fprintf(stderr, "The 'a:' can be any drive or file or @: for the MBR.\n");
256 #else
257 fprintf(stderr, "Usage: %s [-f] bootblock[=bootname] /dev/fd0\n\n", progname);
258 #endif
259 fprintf(stderr, "The bootname is a filename or message to use with the block,\n");
260 fprintf(stderr, "the blocks are:\n");
261 for(;ptr->name; ptr++)
262 fprintf(stderr, "\t%s\t%s\n", ptr->name, ptr->desc);
263 exit(1);
266 /**************************************************************************/
269 open_disk(diskname)
270 char * diskname;
272 #ifdef __MSDOS__
273 /* Freedos fix */
274 if( diskname[2] == '\r' ) diskname[2] = 0;
276 if( diskname[2] == 0 && diskname[1] == ':' )
278 if (isalpha(diskname[0])) {
279 disktype = toupper(diskname[0])-'A'+1;
280 return 0;
282 if (diskname[0] =='@') {
283 disktype = 129;
284 return 0;
287 #endif
288 disktype = 0;
289 diskfd = fopen(diskname, "r+b");
290 if( diskfd == 0 ) diskfd = fopen(diskname, "rb");
291 if( diskfd == 0 && force ) diskfd = fopen(diskname, "w+b");
292 if( diskfd == 0 )
294 fprintf(stderr, "Cannot open '%s'\n", diskname);
295 exit(1);
297 return 0;
300 close_disk()
302 if( diskfd && disktype == 0 ) fclose(diskfd);
303 diskfd = 0;
304 disktype = 0;
308 write_sector(sectno, loadaddr)
309 int sectno;
310 char * loadaddr;
312 #ifdef __MSDOS__
313 if( disktype == 1 || disktype == 2 || disktype == 129 )
315 int tries, rv;
316 int s,h,c;
317 s = sectno%disk_sect + 1;
318 h = sectno/disk_sect%disk_head;
319 c = sectno/disk_sect/disk_head;
321 for(tries=0; tries<6; tries++)
322 if( (rv = bios_sect_write(disktype-1, c, h, s, loadaddr)) == 0 )
323 break;
324 if( rv )
326 if (rv/256 == 3)
327 fprintf(stderr, "Write protect error writing sector %d\n", sectno);
328 else
329 fprintf(stderr, "Error writing sector %d, (%d)\n", sectno, rv/256);
330 return -1;
332 return 0;
334 if( disktype )
336 int tries, rv;
338 for(tries=0; tries<6; tries++)
339 if( (rv = dos_sect_write(disktype-1, sectno, loadaddr)) == 0 )
340 break;
341 if( rv )
343 fprintf(stderr, "Error writing sector %d, (0x%04d)\n", sectno, rv);
344 memset(loadaddr, '\0', 512);
345 return -1;
347 return 0;
349 #endif
350 if( disktype )
352 fprintf(stderr, "Cannot write sector %d\n", sectno);
353 return -1;
355 fseek(diskfd, (long)sectno*512, 0);
356 if( fwrite(loadaddr, 512, 1, diskfd) != 1 )
358 fprintf(stderr, "Cannot write sector %d\n", sectno);
359 return -1;
361 printf("Wrote sector %d\n", sectno);
362 return 0;
366 read_sector(sectno, loadaddr)
367 int sectno;
368 char * loadaddr;
370 int cc;
371 #ifdef __MSDOS__
372 if( disktype == 1 || disktype == 2 || disktype == 129 )
374 int tries, rv;
375 int s,h,c;
376 s = sectno%disk_sect + 1;
377 h = sectno/disk_sect%disk_head;
378 c = sectno/disk_sect/disk_head;
380 for(tries=0; tries<6; tries++)
381 if( (rv = bios_sect_read(disktype-1, c, h, s, loadaddr)) == 0 )
382 break;
383 if( rv )
385 fprintf(stderr, "Error reading sector %d, (%d)\n", sectno, rv/256);
386 memset(loadaddr, '\0', 512);
387 return -1;
389 return 0;
391 if( disktype )
393 int tries, rv;
395 for(tries=0; tries<6; tries++)
396 if( (rv = dos_sect_read(disktype-1, sectno, loadaddr)) == 0 )
397 break;
398 if( rv )
400 fprintf(stderr, "Error reading sector %d, (0x%04d)\n", sectno, rv);
401 memset(loadaddr, '\0', 512);
402 return -1;
404 return 0;
406 #endif
407 if( disktype )
409 fprintf(stderr, "Cannot read sector %d\n", sectno);
410 return -1;
412 fseek(diskfd, (long)sectno*512, 0);
413 if( (cc=fread(loadaddr, 1, 512, diskfd)) != 512 )
415 fprintf(stderr, "Cannot read sector %d, clearing\n", sectno);
416 if(cc<0) cc=0;
417 memset(loadaddr+cc, '\0', 512-cc);
419 return 0;
422 /**************************************************************************/
424 #ifdef __MSDOS__
425 bios_sect_read(drv, track, head, sector, loadaddr)
427 #asm
428 push bp
429 mov bp,sp
431 push ds
432 pop es
434 mov dh,[bp+2+_bios_sect_read.head]
435 mov dl,[bp+2+_bios_sect_read.drv]
436 mov cl,[bp+2+_bios_sect_read.sector]
437 mov ch,[bp+2+_bios_sect_read.track]
439 mov bx,[bp+2+_bios_sect_read.loadaddr]
441 mov ax,#$0201
442 int $13
443 jc bios_read_err
444 mov ax,#0
445 bios_read_err:
447 pop bp
448 #endasm
451 bios_sect_write(drv, track, head, sector, loadaddr)
453 #asm
454 push bp
455 mov bp,sp
457 push ds
458 pop es
460 mov dh,[bp+2+_bios_sect_write.head]
461 mov dl,[bp+2+_bios_sect_write.drv]
462 mov cl,[bp+2+_bios_sect_write.sector]
463 mov ch,[bp+2+_bios_sect_write.track]
465 mov bx,[bp+2+_bios_sect_write.loadaddr]
467 mov ax,#$0301
468 int $13
469 jc bios_write_err
470 mov ax,#0
471 bios_write_err:
473 pop bp
474 #endasm
476 #endif
478 /**************************************************************************/
480 #ifdef __MSDOS__
482 /* All this mess just to read one sector!! */
484 struct disk_packet {
485 long sector;
486 int count;
487 long addr;
488 } disk_packet;
490 dos_sect_read(drv, sector, loadaddr)
492 #asm
493 push bp
494 mov bp,sp
496 mov al,[bp+2+_dos_sect_read.drv]
497 mov cx,#1
498 mov dx,[bp+2+_dos_sect_read.sector]
499 mov bx,[bp+2+_dos_sect_read.loadaddr]
501 int $25
502 pop bx
503 jnc dos_read_ok
505 mov bp,sp
507 ! Fill the disk packet
508 mov ax,[bp+2+_dos_sect_read.sector]
509 mov [_disk_packet],ax
510 xor ax,ax
511 mov [_disk_packet+2],ax
512 inc ax
513 mov [_disk_packet+4],ax
514 mov ax,[bp+2+_dos_sect_read.loadaddr]
515 mov [_disk_packet+6],ax
516 mov ax,ds
517 mov [_disk_packet+8],ax
519 mov dl,[bp+2+_dos_sect_read.drv]
520 inc dl
521 mov bx,#_disk_packet
522 mov cx,#0xFFFF
523 mov si,#0
524 mov ax,#0x7305
526 int $21
528 jc dos_read_err
529 dos_read_ok:
530 mov ax,#0
531 dos_read_err:
533 pop bp
534 #endasm
537 dos_sect_write(drv, sector, loadaddr)
539 #asm
540 push bp
541 mov bp,sp
543 mov al,[bp+2+_dos_sect_write.drv]
544 mov cx,#1
545 mov dx,[bp+2+_dos_sect_write.sector]
546 mov bx,[bp+2+_dos_sect_write.loadaddr]
548 int $26
549 pop bx
550 jnc dos_write_ok
552 mov bp,sp
554 ! Fill the disk packet
555 mov ax,[bp+2+_dos_sect_write.sector]
556 mov [_disk_packet],ax
557 xor ax,ax
558 mov [_disk_packet+2],ax
559 inc ax
560 mov [_disk_packet+4],ax
561 mov ax,[bp+2+_dos_sect_write.loadaddr]
562 mov [_disk_packet+6],ax
563 mov ax,ds
564 mov [_disk_packet+8],ax
566 mov dl,[bp+2+_dos_sect_write.drv]
567 inc dl
568 mov bx,#_disk_packet
569 mov cx,#0xFFFF
570 mov si,#1
571 mov ax,#0x7305
573 int $21
575 jc dos_write_err
576 dos_write_ok:
577 mov ax,#0
578 dos_write_err:
580 pop bp
581 #endasm
583 #endif
584 /**************************************************************************/
586 check_zapped()
588 int i;
589 for(i=0; i<512; i++)
590 if( buffer[i] )
591 break;
593 if( i != 512 )
595 fprintf(stderr, "Boot block isn't empty, zap it first\n");
596 if(!force) exit(1);
600 /**************************************************************************/
602 struct tar_head {
603 char name[100];
604 char mode[8];
605 char uid[8];
606 char gid[8];
607 char size[12];
608 char mtime[12];
609 char chksum[8];
610 char linkflag;
611 char linkname[100];
612 char magic[8];
613 char uname[32];
614 char gname[32];
615 char devmajor[8];
616 char devminor[8];
617 char padding[167];
620 #define buff_tar (*(struct tar_head*) buffer)
621 #define boot_tar (*(struct tar_head*) tarboot_data)
623 unsigned int oct(s)
624 char *s;
626 unsigned int val = 0;
627 int i;
628 for(i=0; i<8; i++) if( s[i] >= '0' && s[i] <= '7' )
629 val = (val<<3) + s[i] - '0';
630 return val;
633 check_tar()
635 char vbuf[100];
636 unsigned char *p;
637 unsigned int csum = 0;
638 long osum = -1;
640 for(p=buffer; p<buffer+512; p++)
641 if( *p ) goto not_zapped;
642 /* Block zapped, ok */
643 return 0;
644 not_zapped:
646 osum = oct(buff_tar.chksum);
647 memset(buff_tar.chksum, ' ', sizeof(buff_tar.chksum));
649 for(p=buffer; p<buffer+512; p++)
650 csum += (*p & 0xFF);
652 if( csum != osum )
654 fprintf(stderr, "TAR file checksum failed, this isn't a tar file.\n");
655 if(!force) exit(9);
657 write_one = 1;
658 memset(buffer, '\0', 1024);
660 if( buff_tar.linkflag != 'V' )
662 fprintf(stderr, "Tar file doesn't start with a volume label\n");
663 if(!force) exit(8);
666 strcpy(vbuf, boot_tar.name); strcat(vbuf, " Volume 1");
667 if( strcmp(boot_tar.name, buff_tar.name) != 0
668 && strcmp(vbuf, buff_tar.name) != 0 )
670 fprintf(stderr, "WARNING: Volume is labeled as '%s' not '%s'\n",
671 buff_tar.name, boot_tar.name);
673 return 0;
676 copy_tarblock()
678 char lbuf[20];
679 unsigned char * p;
680 unsigned int csum = 0;
681 int i;
683 struct tar_head temp;
685 temp = boot_tar;
687 /* Copy preserved fields
689 if( buff_tar.name[0] )
691 memcpy(temp.mtime, buff_tar.mtime, sizeof(temp.mtime));
693 memset(temp.name, 0x90, 16);
694 for(i=0; buff_tar.name[i] && buff_tar.name[i] != ' ' && i<14; i++)
696 int ch = buff_tar.name[i];
697 if( islower(ch) ) ch = toupper(ch);
698 if( strchr("/?@ABCDEFGHIJKLMNO", ch) == 0 )
699 ch = '?';
700 temp.name[i] = ch;
702 temp.name[i++] = 0;
703 temp.name[i] = 0xC0;
705 else
706 sprintf(temp.mtime, "%11lo", time((void*)0));
708 buff_tar = temp;
710 /* Re-calculate the checksum */
711 memset(buff_tar.chksum, ' ', sizeof(buff_tar.chksum));
713 for(p=buffer; p<buffer+512; p++)
714 csum += (*p & 0xFF);
716 sprintf(buff_tar.chksum, "%7o", csum);
718 printf("Boot block installed");
719 if( ((struct tar_head*)buffer)[1].name[0] )
720 printf(" to boot file '%s'\n",
721 ((struct tar_head*)buffer)[1].name);
722 else
723 printf(", use 'tar -r' to add executable\n");
726 /**************************************************************************/
728 #define DOS_SYSID 0
729 #define DOS_SECT 1
730 #define DOS_CLUST 2
731 #define DOS_RESV 3
732 #define DOS_NFAT 4
733 #define DOS_NROOT 5
734 #define DOS_MAXSECT 6
735 #define DOS_MEDIA 7
736 #define DOS_FATLEN 8
737 #define DOS_SPT 9
738 #define DOS_HEADS 10
739 #define DOS_HIDDEN 11
741 #define DOS4_MAXSECT 12
742 #define DOS4_PHY_DRIVE 13
743 #define DOS4_SERIAL 14
744 #define DOS4_LABEL 15
745 #define DOS4_FATTYPE 16
747 #define DOS7_MAXSECT 17
748 #define DOS7_FAT32LEN 18
749 #define DOS7_FLAGS 19
750 #define DOS7_VERSION 20
751 #define DOS7_ROOT_CLUST 21
752 #define DOS7_INFO_SECT 22
753 #define DOS7_BOOT2 23
755 struct bootfields {
756 int offset;
757 int length;
758 unsigned value;
759 long lvalue;
761 dosflds[] =
763 { 0x03, 8, 0},
764 { 0x0B, 2, 0},
765 { 0x0D, 1, 0},
766 { 0x0E, 2, 0},
767 { 0x10, 1, 0},
768 { 0x11, 2, 0},
769 { 0x13, 2, 0},
770 { 0x15, 1, 0},
771 { 0x16, 2, 0},
772 { 0x18, 2, 0},
773 { 0x1A, 2, 0},
774 { 0x1C, 4, 0},
776 { 0x20, 4, 0}, /* DOS4+ */
777 { 0x24, 1, 0},
778 { 0x27, 4, 0},
779 { 0x2B, 11, 0},
780 { 0x36, 8, 0},
782 { 0x20, 4, 0}, /* DOS7 FAT32 */
783 { 0x24, 4, 0},
784 { 0x28, 2, 0},
785 { 0x2A, 2, 0},
786 { 0x2C, 4, 0},
787 { 0x30, 2, 0},
788 { 0x32, 2, 0},
790 { 0x40, 1, 0},
791 { 0x43, 4, 0},
792 { 0x47, 11, 0},
793 { 0x52, 8, 0},
795 { 0x3e8, 4, 0},
796 { 0x3ec, 4, 0},
798 { -1,0,0}
801 print_super(bootsect)
802 char * bootsect;
804 static char * fieldnames[] = {
805 "System ID",
806 "Sector size",
807 "Cluster size",
808 "Reserved sectors",
809 "FAT count",
810 "Root dir entries",
811 "Sector count",
812 "Media code",
813 "FAT length",
814 "Sect/Track",
815 "Heads",
816 "Hidden sectors (Partition offset)",
818 "Large Filesystem sector count",
819 "Phys drive",
820 "Serial number",
821 "Disk Label (DOS 4+)",
822 "FAT type",
824 "Large Filesystem sector count",
825 "FAT32 FAT length",
826 "FAT32 Flags",
827 "FAT32 version",
828 "FAT32 Root Cluster",
829 "FAT32 Info Sector",
830 "FAT32 Backup Boot",
832 "FAT32 Phys Drive",
833 "FAT32 Serial number",
834 "FAT32 Disk Label",
835 "FAT32 FAT Type",
837 "FAT32 Free clusters",
838 "FAT32 Next free cluster",
842 int i;
843 long numclust = 0xFFFF;
844 int fatbits = 0;
845 int fat_len = -1;
847 for(i=0; dosflds[i].offset >= 0; i++)
849 if( i>= DOS4_MAXSECT && (fat_len==0) != (i>=DOS7_MAXSECT) )
850 continue;
852 if( dosflds[i].length <= 4 )
854 long v = 0; int j;
855 for(j=dosflds[i].length-1; j>=0; j--)
857 v = v*256 + (0xFF&( bootsect[dosflds[i].offset+j] ));
860 if( i==DOS_FATLEN )
861 fat_len = v;
863 if (v==0 &&
864 (i==DOS_FATLEN || i==DOS_MAXSECT || i==DOS4_MAXSECT || i==DOS_NROOT))
865 continue;
867 printf("%-35s%ld\n", fieldnames[i], v);
869 if (i==DOS_SECT && v!=512 && v!=1024 && v!=2048)
870 break;
872 else
874 int ch, j;
875 printf("%-35s", fieldnames[i]);
876 for(j=0; j<dosflds[i].length; j++)
878 ch = bootsect[dosflds[i].offset+j];
879 if( ch < ' ' || ch > '~' ) putchar('.');
880 else putchar(ch);
882 putchar('\n');
887 decode_super(bootsect)
888 char * bootsect;
890 int i;
892 for(i=0; dosflds[i].offset >= 0; i++)
894 if( i>= DOS4_MAXSECT &&
895 (dosflds[DOS_FATLEN].value==0) != (i>=DOS7_MAXSECT) )
897 dosflds[i].lvalue = dosflds[i].value = 0;
898 continue;
901 if( dosflds[i].length <= 4 )
903 long v = 0; int j;
904 for(j=dosflds[i].length-1; j>=0; j--)
906 v = v*256 + (0xFF&( bootsect[dosflds[i].offset+j] ));
908 dosflds[i].value = v;
909 dosflds[i].lvalue = v;
911 else
912 dosflds[i].lvalue = dosflds[i].value = 0;
916 save_super(bootsect)
917 char * bootsect;
919 FILE * fd;
920 char * fname = "makeboot.sav";
921 if( boot_id ) fname = boot_id;
923 printf("Copying boot block to '%s'\n", fname);
924 fd = fopen(fname, "wb");
925 fwrite(bootsect, 1024, 1, fd);
926 fclose(fd);
929 /**************************************************************************/
931 check_msdos()
933 decode_super(buffer);
934 if( dosflds[DOS_CLUST].value == 0 ) /* MSDOS v1.0 */
935 dosflds[DOS_CLUST].value = 1;
937 if( dosflds[DOS_MEDIA].value < 0xF0 )
939 if (!force)
940 fprintf(stderr, "Dos media descriptor is invalid\n");
942 else if( dosflds[DOS_MEDIA].value != (0xFF&buffer[512])
943 && dosflds[DOS_RESV].value == 1 )
944 fprintf(stderr, "Dos media descriptor check failed\n");
945 else
947 disk_sect = dosflds[DOS_SPT].value;
948 disk_head = dosflds[DOS_HEADS].value;
949 if( disk_sect > 0 && disk_head > 0 )
950 disk_trck = dosflds[DOS_MAXSECT].value/disk_head/disk_sect;
952 #ifndef __MSDOS__
953 if( bs_offset == 0 &&
954 memcmp(buffer+dosflds[DOS_SYSID].offset, "2M-STV0", 7) == 0)
956 printf("Floppy is in 2M format - reading 2nd boot block\n");
957 bs_offset = dosflds[DOS_RESV].value + dosflds[DOS_FATLEN].value;
958 if( read_sector(bs_offset, buffer) != 0 )
959 exit(1);
961 decode_super(buffer);
962 if( dosflds[DOS_MEDIA].value < 0xF0 ||
963 ( dosflds[DOS_MEDIA].value != (0xFF&buffer[512])
964 && dosflds[DOS_RESV].value == 1 ) )
966 if( force )
968 printf("Bad 2nd boot block - reloading first\n");
969 if( read_sector(0, buffer) != 0 )
970 exit(1);
972 else
974 printf("Bad 2nd boot block\n");
975 exit(1);
978 check_msdos();
980 #endif
981 return;
983 if(!force) exit(2);
986 check_simpledos(bb_fatbits)
987 int bb_fatbits;
989 long numclust = 0xFFFF;
990 char * err = 0;
991 int fatbits = 0;
993 /* Work out how many real clusters there are */
994 if( dosflds[DOS_MAXSECT].value + 2 > 2 )
995 numclust = ( dosflds[DOS_MAXSECT].value
996 - dosflds[DOS_RESV].value
997 - dosflds[DOS_NFAT].value * dosflds[DOS_FATLEN].value
998 - ((dosflds[DOS_NROOT].value+15)/16)
999 ) / dosflds[DOS_CLUST].value + 2;
1000 else if( dosflds[DOS4_MAXSECT].value > 0 )
1001 numclust = ( dosflds[DOS4_MAXSECT].lvalue
1002 - dosflds[DOS_RESV].value
1003 - dosflds[DOS_NFAT].value * dosflds[DOS_FATLEN].value
1004 - ((dosflds[DOS_NROOT].value+15)/16)
1005 ) / dosflds[DOS_CLUST].value + 2;
1006 else
1007 numclust = ( dosflds[DOS7_MAXSECT].lvalue
1008 - dosflds[DOS_RESV].value
1009 - dosflds[DOS_NFAT].value * dosflds[DOS7_FAT32LEN].value
1010 ) / dosflds[DOS_CLUST].value;
1012 if( memcmp(buffer+dosflds[DOS4_FATTYPE].offset, "FAT12", 5) == 0 )
1013 fatbits=12;
1014 else if( memcmp(buffer+dosflds[DOS4_FATTYPE].offset, "FAT16", 5) == 0 )
1015 fatbits=16;
1016 else
1017 fatbits=12+4*(numclust > 0xFF0) + 16*(numclust > 0xFFF0L);
1019 if( dosflds[DOS_NFAT].value > 2 )
1020 err = "Too many fat copies on disk";
1021 else if( dosflds[DOS_NROOT].value < 15 )
1022 err = "Root directory has unreasonable size.";
1023 else if( dosflds[DOS_SECT].value != 512 )
1024 err = "Drive sector size isn't 512 bytes sorry no-go.";
1025 else if( fatbits == 16 && numclust < 0xFF0 )
1026 err = "Weirdness, FAT16 but less than $FF0 clusters";
1027 else if( fatbits != bb_fatbits )
1028 err = "Filesystem has the wrong fat type for this bootblock.";
1029 else if( numclust * dosflds[DOS_CLUST].lvalue /
1030 dosflds[DOS_SPT].value > 65535 )
1031 err = "Boot sector untested with more than 65535 tracks";
1033 if( !err && bb_fatbits == 12 )
1035 if( dosflds[DOS4_PHY_DRIVE].value != 0 )
1036 err = "This boot sector is only for floppies";
1037 else if( (0x7C00-msdos_start-512)/512 < dosflds[DOS_FATLEN].value )
1038 err = "The FAT is too large to load in the available space.";
1039 else if( dosflds[DOS_RESV].value + dosflds[DOS_FATLEN].value >
1040 dosflds[DOS_SPT].value )
1041 err = "The bootblock needs all of fat1 on the first track.";
1042 else if( msdos_heads == 2 && dosflds[DOS_HEADS].value != 2 )
1043 err = "Drive doesn't have two heads, this is required.";
1044 else if( dosflds[DOS_HIDDEN].lvalue != 0 )
1045 err = "MSDOS floppies shouldn't have hidden sectors.";
1048 if( err )
1050 fprintf(stderr, "ERROR: %s\n\n", err);
1051 print_super(buffer);
1052 if(!force) exit(2);
1056 set_dosname(boot_name)
1057 int boot_name;
1059 char dos_name[20];
1060 int i,j;
1062 strcpy(dos_name, " ");
1064 for(i=0; boot_id[i] && boot_id[i] != '.' && i<16; i++)
1065 dos_name[i] = toupper(boot_id[i]);
1067 if( boot_id[i] == '.' )
1069 for(j=8,i++; boot_id[i] && boot_id[i] != '.' && j<16; i++,j++)
1070 dos_name[j] = toupper(boot_id[i]);
1073 printf("Bootfile set to '%11.11s'\n", dos_name);
1075 memcpy(buffer+boot_name, dos_name, 11);
1078 set_asciz(boot_name)
1079 int boot_name;
1081 int i, j;
1083 for(i=boot_name; buffer[i]; i++) ;
1084 for( ; !buffer[i]; i++) ;
1085 i = i - boot_name -1;
1087 if( strlen(boot_id) > i )
1089 fprintf(stderr, "Name '%s' is too long for bootblock\n");
1090 exit(1);
1092 else
1094 for(i=0,j=boot_name; boot_id[i]; i++)
1096 if( boot_id[i] == '\\' && boot_id[i+1] )
1098 i++;
1099 switch(boot_id[i])
1101 case 'n': buffer[j++] = '\n'; break;
1102 case 'r': buffer[j++] = '\r'; break;
1103 case 'b': buffer[j++] = '\b'; break;
1104 case 't': buffer[j++] = '\t'; break;
1105 case 'a': buffer[j++] = '\007'; break;
1106 case 'e': buffer[j++] = '\033'; break;
1107 default: buffer[j++] = boot_id[i]; break;
1110 #ifdef __MSDOS__
1111 else if(boot_id[i] == '_') buffer[j++] = ' ';
1112 else if(boot_id[i] == '^') { buffer[j++] = '\r'; buffer[j++] = '\n'; }
1113 #endif
1114 else buffer[j++] = boot_id[i];
1116 buffer[j] = 0;
1120 check_mbr()
1122 int i = 0;
1124 if( buffer[510] == 0x55 && buffer[511] == 0xAA )
1125 i = 512;
1127 for(; i<512; i++)
1128 if( buffer[i] )
1129 break;
1131 /* Check for Disk Manager partition tables */
1132 if( buffer[252] == 0x55 && buffer[253] == 0xAA )
1134 if( (unsigned char)mbr_data[252] != 0x55 ||
1135 (unsigned char)mbr_data[253] != 0xAA )
1136 i = 252;
1139 if( i != 512 )
1141 if(force)
1142 fprintf(stderr, "That doesn't look like a compatible MBR but ...\n");
1143 else
1145 fprintf(stderr, "That doesn't look like a compatible MBR\n");
1146 exit(1);
1151 copy_mbr(mbr_data)
1152 char * mbr_data;
1154 if( buffer[252] != 0xAA || buffer[253] != 0x55 ||
1155 (unsigned char)mbr_data[252] != 0xAA || mbr_data[253] != 0x55 )
1156 memcpy(buffer, mbr_data, 446);
1157 else
1158 memcpy(buffer, mbr_data, 254);
1160 buffer[510] = 0x55;
1161 buffer[511] = 0xAA;
1162 write_zero = 1;
1165 /**************************************************************************/
1167 #ifdef HAS_2M20
1169 char boot_sector_2m_23_82[] = {
1170 0xe9,0x7d,0x00,0x32,0x4d,0x2d,0x53,0x54,0x56,0x30,0x34,0x00,0x02,0x01,0x01,0x00,
1171 0x02,0xe0,0x00,0xbc,0x0e,0xfa,0x0b,0x00,0x17,0x00,0x02,0x00,0x00,0x00,0x00,0x00,
1172 0x00,0x00,0x00,0x00,0x00,0x00,0x29,0x45,0xb8,0x25,0x51,0x4e,0x4f,0x20,0x4e,0x41,
1173 0x4d,0x45,0x20,0x20,0x20,0x20,0x46,0x41,0x54,0x31,0x32,0x20,0x20,0x20,0x00,0x3f,
1174 0x07,0x01,0x00,0x00,0x80,0x00,0x4c,0x00,0x61,0x00,0x79,0x00,0x13,0x46,0x01,0x02,
1175 0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,
1176 0x13,0x40,0x03,0x07,0x81,0x04,0x04,0x8c,0x01,0x04,0x97,0x05,0x04,0xa2,0x02,0x04,
1177 0xad,0x06,0x03,0xb3,0x03,0x04,0xbe,0x07,0x02,0x04,0x04,0x04,0x04,0x04,0x03,0x02,
1178 0xfa,0x33,0xc0,0x8e,0xd0,0xbc,0x00,0x7c,0xb8,0xc0,0x07,0x50,0x05,0x20,0x00,0x50,
1179 0x07,0x1f,0x33,0xf6,0x33,0xff,0xb9,0x00,0x01,0xfc,0xf3,0xa5,0x8b,0x1e,0x44,0x00,
1180 0x8d,0x47,0x26,0x06,0x50,0xcb,0xfb,0xbe,0x1a,0x01,0xe8,0xd9,0x00,0xbb,0x78,0x00,
1181 0x36,0xc5,0x37,0x1e,0x56,0x33,0xff,0x36,0x89,0x3f,0x36,0x8c,0x47,0x02,0xb9,0x0b,
1182 0x00,0xf3,0xa4,0x06,0x1f,0xa0,0x18,0x00,0x88,0x45,0xf9,0x33,0xc0,0x8e,0xc0,0xbb,
1183 0x00,0x7c,0x26,0x89,0x87,0xfe,0x01,0xb8,0x01,0x02,0x8b,0x0e,0x16,0x00,0x83,0xc1,
1184 0x02,0x33,0xd2,0x83,0xf9,0x0a,0x72,0x1f,0x51,0xcd,0x13,0x59,0x36,0x8b,0x1e,0x13,
1185 0x04,0x83,0xeb,0x05,0xb8,0x40,0x00,0xf7,0xe3,0x8e,0xc0,0x53,0x33,0xdb,0xb8,0x05,
1186 0x02,0x41,0x33,0xd2,0xcd,0x13,0x5b,0x36,0x8f,0x06,0x78,0x00,0x36,0x8f,0x06,0x7a,
1187 0x00,0x26,0x81,0x3e,0xfe,0x09,0x55,0xaa,0x75,0x60,0x36,0x89,0x1e,0x13,0x04,0x06,
1188 0xb4,0x08,0xb3,0x00,0xb2,0x00,0xcd,0x13,0x8a,0xc3,0xb4,0x00,0x80,0xfa,0x02,0x72,
1189 0x0c,0x50,0xb4,0x08,0xb3,0x00,0xb2,0x01,0xcd,0x13,0x58,0x8a,0xe3,0x07,0x26,0x8c,
1190 0x06,0xfe,0x09,0x26,0xff,0x1e,0xfc,0x09,0xb8,0x01,0x02,0x33,0xd2,0x8e,0xc2,0xb9,
1191 0x01,0x00,0xbb,0x00,0x80,0x50,0xcd,0x13,0x58,0xbb,0x00,0x7c,0x06,0x53,0x26,0x81,
1192 0x7f,0x03,0x32,0x4d,0x75,0x04,0xb2,0x80,0xcd,0x13,0x26,0x81,0x3e,0xfe,0x7d,0x55,
1193 0xaa,0x75,0x03,0x33,0xd2,0xcb,0x22,0xd2,0x74,0xec,0xbe,0x2f,0x01,0xe8,0x06,0x00,
1194 0xb4,0x00,0xcd,0x16,0xcd,0x19,0x03,0x36,0x44,0x00,0xfc,0xac,0x22,0xc0,0x74,0x09,
1195 0xb4,0x0e,0xbb,0x07,0x00,0xcd,0x10,0xeb,0xf1,0xc3,0x0d,0x0a,0x32,0x4d,0x20,0x53,
1196 0x75,0x70,0x65,0x72,0x42,0x4f,0x4f,0x54,0x20,0x32,0x2e,0x30,0x0d,0x0a,0x00,0x0d,
1197 0x0a,0xad,0x4e,0x6f,0x20,0x62,0x6f,0x74,0x61,0x62,0x6c,0x65,0x21,0x0d,0x0a,0x00,
1198 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1199 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1200 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1201 0x4d,0x61,0x64,0x65,0x20,0x69,0x6e,0x20,0x53,0x70,0x61,0x69,0x6e,0x00,0x55,0xaa
1204 char boot_sector_2m_22_82[] = {
1205 0xe9,0x6e,0x00,0x32,0x4d,0x2d,0x53,0x54,0x56,0x30,0x38,0x00,0x02,0x01,0x01,0x00,
1206 0x02,0xe0,0x00,0x18,0x0e,0xfa,0x0b,0x00,0x16,0x00,0x02,0x00,0x00,0x00,0x00,0x00,
1207 0x00,0x00,0x00,0x00,0x00,0x00,0x29,0xcc,0x9b,0xe1,0xd4,0x4e,0x4f,0x20,0x4e,0x41,
1208 0x4d,0x45,0x20,0x20,0x20,0x20,0x46,0x41,0x54,0x31,0x32,0x20,0x20,0x20,0x00,0x04,
1209 0x07,0x00,0x00,0x00,0x71,0x00,0x4c,0x00,0x61,0x00,0x66,0x00,0x13,0x46,0x01,0x02,
1210 0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10,0x11,0x12,
1211 0x13,0x0b,0x28,0x03,0x01,0x02,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,0x03,
1212 0x03,0xfa,0x33,0xc0,0x8e,0xd0,0xbc,0x00,0x7c,0xb8,0xc0,0x07,0x50,0x05,0x20,0x00,
1213 0x50,0x07,0x1f,0x33,0xf6,0x33,0xff,0xb9,0x00,0x01,0xfc,0xf3,0xa5,0x8b,0x1e,0x44,
1214 0x00,0x8d,0x47,0x26,0x06,0x50,0xcb,0xfb,0xbe,0x1a,0x01,0xe8,0xd9,0x00,0xbb,0x78,
1215 0x00,0x36,0xc5,0x37,0x1e,0x56,0x33,0xff,0x36,0x89,0x3f,0x36,0x8c,0x47,0x02,0xb9,
1216 0x0b,0x00,0xf3,0xa4,0x06,0x1f,0xa0,0x18,0x00,0x88,0x45,0xf9,0x33,0xc0,0x8e,0xc0,
1217 0xbb,0x00,0x7c,0x26,0x89,0x87,0xfe,0x01,0xb8,0x01,0x02,0x8b,0x0e,0x16,0x00,0x83,
1218 0xc1,0x02,0x33,0xd2,0x83,0xf9,0x0a,0x72,0x1f,0x51,0xcd,0x13,0x59,0x36,0x8b,0x1e,
1219 0x13,0x04,0x83,0xeb,0x05,0xb8,0x40,0x00,0xf7,0xe3,0x8e,0xc0,0x53,0x33,0xdb,0xb8,
1220 0x05,0x02,0x41,0x33,0xd2,0xcd,0x13,0x5b,0x36,0x8f,0x06,0x78,0x00,0x36,0x8f,0x06,
1221 0x7a,0x00,0x26,0x81,0x3e,0xfe,0x09,0x55,0xaa,0x75,0x60,0x36,0x89,0x1e,0x13,0x04,
1222 0x06,0xb4,0x08,0xb3,0x00,0xb2,0x00,0xcd,0x13,0x8a,0xc3,0xb4,0x00,0x80,0xfa,0x02,
1223 0x72,0x0c,0x50,0xb4,0x08,0xb3,0x00,0xb2,0x01,0xcd,0x13,0x58,0x8a,0xe3,0x07,0x26,
1224 0x8c,0x06,0xfe,0x09,0x26,0xff,0x1e,0xfc,0x09,0xb8,0x01,0x02,0x33,0xd2,0x8e,0xc2,
1225 0xb9,0x01,0x00,0xbb,0x00,0x80,0x50,0xcd,0x13,0x58,0xbb,0x00,0x7c,0x06,0x53,0x26,
1226 0x81,0x7f,0x03,0x32,0x4d,0x75,0x04,0xb2,0x80,0xcd,0x13,0x26,0x81,0x3e,0xfe,0x7d,
1227 0x55,0xaa,0x75,0x03,0x33,0xd2,0xcb,0x22,0xd2,0x74,0xec,0xbe,0x2f,0x01,0xe8,0x06,
1228 0x00,0xb4,0x00,0xcd,0x16,0xcd,0x19,0x03,0x36,0x44,0x00,0xfc,0xac,0x22,0xc0,0x74,
1229 0x09,0xb4,0x0e,0xbb,0x07,0x00,0xcd,0x10,0xeb,0xf1,0xc3,0x0d,0x0a,0x32,0x4d,0x20,
1230 0x53,0x75,0x70,0x65,0x72,0x42,0x4f,0x4f,0x54,0x20,0x32,0x2e,0x30,0x0d,0x0a,0x00,
1231 0x0d,0x0a,0xad,0x4e,0x6f,0x20,0x62,0x6f,0x74,0x61,0x62,0x6c,0x65,0x21,0x0d,0x0a,
1232 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1233 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1234 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1235 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1236 0x4d,0x61,0x64,0x65,0x20,0x69,0x6e,0x20,0x53,0x70,0x61,0x69,0x6e,0x00,0x55,0xaa
1240 char program_2m_vsn_20[] = {
1241 0x2b,0x00,0x43,0x00,0x32,0x30,0x32,0x4d,0x2d,0x53,0x54,0x56,0x00,0x00,0x00,0x00,
1242 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x0a,0x00,0x00,0x00,0x00,0x00,
1243 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x46,0x4a,0x42,0x00,0x00,0x01,0x00,0x00,
1244 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1245 0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1246 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xfb,0xfc,0x9c,0x56,0x80,
1247 0xfa,0x02,0x73,0x3d,0xe8,0x41,0x00,0x2e,0x80,0x3c,0x02,0x74,0x04,0x2e,0x80,0x3c,
1248 0x04,0x72,0x2e,0x80,0xfc,0x02,0x72,0x29,0x80,0xfc,0x05,0x77,0x24,0x75,0x05,0xe8,
1249 0x36,0x00,0xeb,0x1d,0xe8,0x85,0x00,0x73,0x09,0x5e,0x9d,0xf9,0xb8,0x00,0x06,0xca,
1250 0x02,0x00,0x2e,0x80,0x7c,0x01,0x00,0x74,0x08,0x5e,0x9d,0xe8,0x3c,0x02,0xca,0x02,
1251 0x00,0x5e,0x9d,0x2e,0xff,0x2e,0xfc,0x09,0x9c,0x53,0x8a,0xda,0xb7,0x00,0xd1,0xe3,
1252 0x2e,0x8b,0xb7,0x00,0x00,0x5b,0x9d,0xc3,0x60,0xe8,0xec,0xff,0xb0,0x01,0x72,0x02,
1253 0xb0,0x00,0x2e,0x88,0x44,0x01,0x61,0xc3,0x50,0xa0,0x12,0x00,0x0a,0x06,0x11,0x00,
1254 0x58,0xc3,0x60,0x1e,0x6a,0x40,0x1f,0xb0,0x01,0x8a,0xca,0xd2,0xe0,0x84,0x06,0x3f,
1255 0x00,0x75,0x04,0xf8,0xe8,0xef,0x05,0x8a,0xe2,0xc0,0xe4,0x04,0x0a,0xe0,0xc0,0xe0,
1256 0x04,0x0c,0x0c,0x0a,0xc2,0xba,0xf2,0x03,0xfa,0x88,0x26,0x3f,0x00,0xee,0x83,0xc2,
1257 0x05,0xeb,0x00,0xeb,0x00,0xec,0xfb,0xa8,0x80,0x1f,0x61,0xc3,0x60,0xe8,0x98,0xff,
1258 0x2e,0x80,0x7c,0x02,0x01,0x2e,0xc6,0x44,0x02,0x00,0x74,0x08,0xe8,0xb3,0xff,0x75,
1259 0x03,0x61,0xf8,0xc3,0xf8,0xe8,0x90,0xff,0x1e,0x06,0xbb,0x90,0x00,0x02,0xda,0x6a,
1260 0x40,0x1f,0x80,0x27,0xef,0x0e,0x0e,0x1f,0x07,0x88,0x16,0x0c,0x00,0xf9,0xe8,0x29,
1261 0x05,0xc6,0x06,0x11,0x00,0x01,0xc6,0x06,0x12,0x00,0x00,0xe8,0xa1,0x05,0xfe,0x0e,
1262 0x11,0x00,0xe8,0x9a,0x05,0xf8,0xe8,0x7d,0x05,0xe8,0x76,0xff,0x74,0x07,0xc6,0x44,
1263 0x02,0x01,0xf8,0xeb,0x68,0x1e,0x6a,0x40,0x1f,0xc6,0x06,0x41,0x00,0x06,0x1f,0xc6,
1264 0x06,0x1b,0x00,0xff,0xc6,0x44,0x08,0x14,0xb9,0x03,0x00,0x51,0x83,0xf9,0x02,0xe8,
1265 0xe8,0x04,0xc6,0x44,0x06,0x00,0xc6,0x06,0x11,0x00,0x00,0xc6,0x06,0x12,0x00,0x00,
1266 0xc6,0x06,0x13,0x00,0x01,0xc6,0x06,0x16,0x00,0x00,0xc6,0x06,0x17,0x00,0x01,0xc6,
1267 0x06,0x27,0x00,0x46,0x8b,0x3e,0x19,0x00,0xe8,0x7f,0x02,0x75,0x0b,0x59,0x8b,0x1e,
1268 0x19,0x00,0xe8,0x1c,0x00,0xf8,0xeb,0x14,0x8a,0x44,0x06,0x40,0x3c,0x03,0x77,0x05,
1269 0x88,0x44,0x06,0xeb,0xc1,0xc6,0x44,0x06,0x00,0x59,0xe2,0xaf,0xf9,0x07,0x1f,0x61,
1270 0xc3,0x60,0xe8,0x88,0x00,0x72,0x5c,0x88,0x44,0x05,0x88,0x4c,0x03,0x8a,0x16,0x0c,
1271 0x00,0xf9,0xe8,0xd3,0xfe,0x26,0x8a,0x47,0x16,0x88,0x44,0x17,0x26,0x8a,0x4f,0x41,
1272 0x88,0x4c,0x04,0x26,0x8b,0x47,0x42,0x89,0x44,0x06,0x26,0x8a,0x47,0x18,0x88,0x44,
1273 0x09,0x26,0x8b,0x7f,0x48,0x26,0x8a,0x41,0x01,0x8a,0xe0,0x22,0xc9,0x74,0x0a,0x80,
1274 0xc4,0xbe,0xb0,0x0b,0xf6,0xe4,0x2d,0x3e,0x08,0xd0,0xe8,0x88,0x44,0x08,0xb9,0x0d,
1275 0x00,0x26,0x8b,0x7f,0x4a,0x03,0xfb,0x8d,0x5c,0x0a,0x26,0x8a,0x05,0x88,0x07,0x43,
1276 0x47,0xe2,0xf7,0x8a,0x44,0x06,0xc0,0xe0,0x06,0x0c,0x17,0x80,0x3c,0x02,0x77,0x0a,
1277 0x24,0xf8,0x0c,0x05,0xa8,0x40,0x74,0x02,0x34,0x21,0x1e,0xbb,0x90,0x00,0x02,0x1e,
1278 0x0c,0x00,0x6a,0x40,0x1f,0x80,0x27,0x08,0x08,0x07,0x1f,0x61,0xc3,0x56,0x57,0x8d,
1279 0x7f,0x03,0xbe,0x06,0x00,0xb9,0x06,0x00,0xf3,0xa6,0xf9,0x75,0x19,0x33,0xc0,0x26,
1280 0x8a,0x4f,0x40,0x80,0xf9,0x06,0x72,0x0d,0x26,0x8b,0x7f,0x44,0x4f,0x26,0x02,0x01,
1281 0x83,0xff,0x3f,0x77,0xf7,0xf8,0x5f,0x5e,0xc3,0x50,0x73,0x37,0x80,0x3e,0x1f,0x00,
1282 0x00,0x75,0x2f,0xa0,0x21,0x00,0xd0,0xe0,0xb4,0x04,0x72,0x22,0xc0,0xe0,0x02,0xb4,
1283 0x10,0x72,0x1b,0xd0,0xe0,0xb4,0x08,0x72,0x15,0xc0,0xe0,0x02,0xb4,0x04,0x72,0x0e,
1284 0xd0,0xe0,0xb4,0x03,0x72,0x08,0xd0,0xe0,0xb4,0x02,0x72,0x02,0xb4,0x20,0x08,0x26,
1285 0x1f,0x00,0xf9,0x58,0xc3,0x9c,0x60,0x06,0x6a,0x40,0x07,0xbf,0x41,0x00,0xbe,0x1f,
1286 0x00,0xb9,0x04,0x00,0xf3,0xa5,0x07,0x61,0x9d,0xc3,0x1e,0x60,0x0e,0x1f,0x88,0x16,
1287 0x0c,0x00,0xe8,0xc3,0xfd,0x80,0x7c,0x05,0x00,0x74,0x08,0xc6,0x06,0x1f,0x00,0x40,
1288 0xe9,0xbb,0x00,0x50,0xb4,0x00,0xa3,0x0d,0x00,0x8a,0xc5,0xd0,0xe0,0x8a,0xd6,0x80,
1289 0xe6,0x7f,0x02,0xc6,0xf6,0x64,0x09,0x02,0xc1,0x80,0xd4,0x00,0x48,0xa3,0x0f,0x00,
1290 0x8b,0xfb,0x5b,0x8a,0xdf,0xb7,0x00,0x8a,0x8f,0x26,0x00,0x88,0x0e,0x27,0x00,0xd0,
1291 0xe2,0x72,0x73,0x23,0xc0,0x75,0x2c,0x80,0x7c,0x03,0x07,0x72,0x19,0x8a,0x44,0x17,
1292 0x40,0xb9,0x01,0x00,0xe8,0x9b,0x00,0x75,0x6e,0xff,0x0e,0x0d,0x00,0xff,0x06,0x0f,
1293 0x00,0xa1,0x0f,0x00,0xeb,0x0d,0x80,0x3e,0x27,0x00,0x4a,0x75,0x06,0x81,0xc7,0x00,
1294 0x02,0xeb,0xe6,0x8a,0x4c,0x17,0xb5,0x00,0x3b,0xc1,0x77,0x0f,0xe8,0x5d,0x00,0xe8,
1295 0x70,0x00,0x75,0x43,0x83,0x3e,0x0d,0x00,0x00,0x74,0x3c,0xa1,0x0f,0x00,0x8a,0x4c,
1296 0x17,0xb5,0x00,0xd1,0xe1,0x3b,0xc1,0x77,0x1d,0xe8,0x40,0x00,0x80,0x3e,0x27,0x00,
1297 0x4a,0x75,0x07,0xc1,0xe1,0x09,0x03,0xf9,0xeb,0x0c,0x8a,0x54,0x17,0xb6,0x00,0x2b,
1298 0xc2,0xe8,0x3e,0x00,0x75,0x11,0x83,0x3e,0x0d,0x00,0x00,0x74,0x0a,0xa1,0x0f,0x00,
1299 0x8b,0x0e,0x0d,0x00,0xe8,0x2b,0x00,0xf8,0xe8,0x2b,0x03,0xe8,0x17,0xff,0x61,0x8a,
1300 0x26,0x1f,0x00,0x1f,0x22,0xe4,0x74,0x03,0xf9,0xb0,0x00,0xc3,0x2b,0xc8,0x41,0x3b,
1301 0x0e,0x0d,0x00,0x76,0x04,0x8b,0x0e,0x0d,0x00,0x29,0x0e,0x0d,0x00,0x01,0x0e,0x0f,
1302 0x00,0xc3,0x8b,0xd8,0x88,0x0e,0x17,0x00,0xf6,0x74,0x09,0xfe,0xc4,0x88,0x26,0x13,
1303 0x00,0xd0,0xe8,0xa2,0x11,0x00,0xd0,0xd0,0x24,0x01,0xa2,0x12,0x00,0xa0,0x13,0x00,
1304 0x02,0x06,0x17,0x00,0x72,0x06,0x48,0x3a,0x44,0x09,0x76,0x07,0xc6,0x06,0x1f,0x00,
1305 0x04,0xeb,0x77,0x8a,0xc4,0x98,0xe8,0xbf,0xfc,0x74,0x18,0x8d,0x5c,0x09,0x48,0x43,
1306 0xfe,0xc4,0x8a,0x0f,0x80,0xe9,0x02,0xb5,0x01,0xd2,0xe5,0x2a,0xc5,0x73,0xf0,0x02,
1307 0xc5,0x86,0xe0,0xa2,0x13,0x00,0x88,0x26,0x16,0x00,0xe8,0xe8,0x01,0xb4,0x00,0x88,
1308 0x26,0x15,0x00,0xe8,0x92,0xfc,0x75,0x09,0xa0,0x17,0x00,0x88,0x26,0x17,0x00,0xeb,
1309 0x28,0x38,0x64,0x04,0x75,0x28,0x38,0x26,0x16,0x00,0x74,0x05,0xe8,0x31,0x00,0x72,
1310 0x29,0x38,0x26,0x17,0x00,0x74,0x23,0xe8,0x9b,0x01,0x8a,0xc8,0xa0,0x17,0x00,0xf6,
1311 0xf1,0x22,0xc0,0x74,0x09,0x88,0x26,0x17,0x00,0xe8,0x82,0x00,0x72,0x0c,0x80,0x3e,
1312 0x17,0x00,0x00,0x74,0x05,0xe8,0x08,0x00,0x73,0xf4,0x80,0x3e,0x1f,0x00,0x00,0xc3,
1313 0x50,0x80,0x3e,0x27,0x00,0x4a,0x74,0x16,0x80,0x3e,0x27,0x00,0x42,0x74,0x3b,0xe8,
1314 0xbb,0x00,0x73,0x05,0xe8,0xdb,0x00,0x72,0x48,0xe8,0x6f,0x00,0xeb,0x43,0x80,0x3e,
1315 0x16,0x00,0x00,0x75,0x09,0xe8,0x4d,0x01,0x38,0x06,0x17,0x00,0x73,0x14,0xe8,0x9c,
1316 0x00,0x73,0x0f,0xc6,0x06,0x27,0x00,0x46,0xe8,0xb7,0x00,0xc6,0x06,0x27,0x00,0x4a,
1317 0x72,0x1f,0xe8,0x46,0x00,0xe8,0xaa,0x00,0xeb,0x17,0x53,0x8a,0x1e,0x16,0x00,0xe8,
1318 0x23,0x01,0xfe,0x0e,0x17,0x00,0x74,0x05,0x43,0x3a,0xd8,0x72,0xf5,0x5b,0xe8,0x91,
1319 0x00,0x9c,0xfe,0x06,0x13,0x00,0xc6,0x06,0x16,0x00,0x00,0x9d,0x58,0xc3,0x50,0x22,
1320 0xc0,0x74,0x16,0x8a,0x26,0x13,0x00,0x88,0x26,0x14,0x00,0x02,0xc4,0x48,0xa2,0x15,
1321 0x00,0xfe,0xc0,0xe8,0x6c,0x00,0xa2,0x13,0x00,0x58,0xc3,0x50,0x53,0x51,0x56,0x8a,
1322 0x1e,0x16,0x00,0xe8,0xdf,0x00,0x53,0xc1,0xe3,0x09,0x03,0x1e,0x19,0x00,0x8b,0xf3,
1323 0xb9,0x00,0x01,0xe8,0x16,0x00,0xf3,0xa5,0xe8,0x11,0x00,0x5b,0xfe,0x0e,0x17,0x00,
1324 0x74,0x05,0x43,0x3a,0xd8,0x72,0xdf,0x5e,0x59,0x5b,0x58,0xc3,0x2e,0x80,0x3e,0x27,
1325 0x00,0x4a,0x74,0x02,0xf8,0xc3,0x87,0xf7,0x06,0x1e,0x07,0x1f,0xc3,0x50,0xa0,0x1b,
1326 0x00,0x3a,0x06,0x0c,0x00,0x75,0x18,0xa0,0x11,0x00,0x8a,0x26,0x12,0x00,0x3b,0x06,
1327 0x1c,0x00,0x75,0x0b,0xa0,0x1e,0x00,0x3a,0x06,0x13,0x00,0x75,0x02,0x58,0xc3,0xf9,
1328 0x58,0xc3,0x50,0x53,0xe8,0x78,0x01,0x73,0x0f,0x80,0x3e,0x1f,0x00,0x00,0x75,0x05,
1329 0x80,0x0e,0x1f,0x00,0x40,0xf9,0xeb,0x6a,0xe8,0x3d,0xfb,0xb0,0x02,0x74,0x0d,0x8d,
1330 0x5c,0x0a,0x02,0x1e,0x13,0x00,0x80,0xd7,0x00,0x8a,0x47,0xff,0xa2,0x18,0x00,0x80,
1331 0x3e,0x15,0x00,0x00,0x74,0x0b,0xe8,0x5c,0x02,0xc6,0x06,0x15,0x00,0x00,0x9c,0xeb,
1332 0x3d,0x06,0x57,0x0e,0x07,0x8b,0x3e,0x19,0x00,0xa0,0x13,0x00,0xa2,0x14,0x00,0xa2,
1333 0x15,0x00,0xe8,0x40,0x02,0xc6,0x06,0x15,0x00,0x00,0x5f,0x07,0x9c,0xb0,0xff,0x72,
1334 0x0a,0x80,0x3e,0x27,0x00,0x42,0x74,0x16,0xa0,0x0c,0x00,0xa2,0x1b,0x00,0xa0,0x11,
1335 0x00,0x8a,0x26,0x12,0x00,0xa3,0x1c,0x00,0xa0,0x13,0x00,0xa2,0x1e,0x00,0x9d,0xe8,
1336 0x97,0xfc,0x5b,0x58,0xc3,0xe8,0xd0,0xfa,0xb0,0x01,0x74,0x18,0x53,0x51,0x8d,0x5c,
1337 0x0a,0x02,0x1e,0x13,0x00,0x80,0xd7,0x00,0x8a,0x4f,0xff,0x80,0xe9,0x02,0xb0,0x01,
1338 0xd2,0xe0,0x59,0x5b,0xc3,0x60,0x1e,0xbb,0x40,0x00,0x53,0x1f,0xb5,0xed,0xfa,0x2e,
1339 0x8a,0x0e,0x0c,0x00,0xb0,0x01,0xd2,0xe0,0x84,0x47,0xff,0x74,0x04,0x38,0x2f,0x76,
1340 0x33,0x08,0x47,0xff,0x80,0x67,0xff,0xcf,0x8a,0xc1,0xc0,0xe0,0x04,0x08,0x47,0xff,
1341 0xc6,0x07,0xff,0xfb,0xba,0xf2,0x03,0x80,0xc1,0x04,0xb0,0x01,0xd2,0xe0,0x2e,0x0a,
1342 0x06,0x0c,0x00,0x0c,0x0c,0xee,0xb8,0xfd,0x90,0xf8,0xcd,0x15,0x72,0x06,0xb8,0xe8,
1343 0x03,0xe8,0x48,0x03,0x88,0x2f,0xfb,0x1f,0x61,0xc3,0x60,0xe8,0x68,0x00,0x8a,0x0e,
1344 0x0c,0x00,0x8a,0xc1,0xc0,0xe0,0x02,0x0c,0x01,0xd2,0xe0,0x1e,0x6a,0x40,0x1f,0xfa,
1345 0xa2,0x3f,0x00,0x80,0x26,0x3e,0x00,0x70,0x1f,0xc0,0xe0,0x04,0x0a,0xc1,0x0c,0x08,
1346 0xba,0xf2,0x03,0xee,0xe8,0x08,0x03,0x0c,0x04,0xee,0xe8,0x1a,0x02,0xb0,0x08,0xe8,
1347 0xc3,0x02,0xe8,0x82,0x02,0xe8,0x7f,0x02,0xe8,0x02,0x00,0x61,0xc3,0x50,0x1e,0x6a,
1348 0x40,0x1f,0x8a,0x26,0x8b,0x00,0x1f,0xb0,0x03,0xe8,0xa9,0x02,0xb0,0xbf,0x80,0xe4,
1349 0xc0,0x74,0x09,0xb0,0xaf,0x80,0xfc,0xc0,0x74,0x02,0xb0,0xdf,0xe8,0x96,0x02,0xb0,
1350 0x02,0xe8,0x91,0x02,0x58,0xc3,0x60,0x1e,0xb0,0xff,0x72,0x0a,0x6a,0x00,0x1f,0xc5,
1351 0x1e,0x78,0x00,0x8a,0x47,0x02,0x6a,0x40,0x1f,0xa2,0x40,0x00,0x1f,0x61,0xc3,0x60,
1352 0xe8,0x87,0x00,0xe8,0xb7,0xff,0xb4,0x01,0x8a,0x0e,0x0c,0x00,0xd2,0xe4,0x1e,0x6a,
1353 0x40,0x1f,0x84,0x26,0x3e,0x00,0x1f,0x75,0x05,0xe8,0xa6,0x00,0x72,0x69,0xbb,0x94,
1354 0x00,0x02,0x1e,0x0c,0x00,0xa0,0x11,0x00,0x1e,0x6a,0x40,0x1f,0x08,0x26,0x3e,0x00,
1355 0x8a,0x26,0x41,0x00,0x3a,0x07,0x88,0x07,0x1f,0x75,0x05,0x80,0xfc,0x40,0x75,0x44,
1356 0xb0,0x0f,0xe8,0x30,0x02,0x72,0x40,0xa0,0x12,0x00,0xc0,0xe0,0x02,0x0a,0x06,0x0c,
1357 0x00,0xe8,0x21,0x02,0xa0,0x11,0x00,0xe8,0x1b,0x02,0xe8,0x6a,0x01,0x72,0x28,0xb0,
1358 0x08,0xe8,0x11,0x02,0x72,0x21,0xe8,0xce,0x01,0x72,0x1c,0x8a,0xe0,0xe8,0xc7,0x01,
1359 0xf6,0xc4,0xc0,0x75,0x12,0xb0,0x0f,0x80,0x3e,0x27,0x00,0x4a,0x74,0x02,0xb0,0x01,
1360 0x98,0xe8,0x38,0x02,0x61,0xf8,0xc3,0x61,0xf9,0xc3,0x60,0xe8,0x4a,0xf9,0x8b,0x44,
1361 0x06,0x74,0x02,0x8a,0xc4,0x1e,0x6a,0x40,0x1f,0x8a,0x26,0x8b,0x00,0xc0,0xec,0x06,
1362 0x3a,0xc4,0x74,0x10,0xba,0xf7,0x03,0xee,0xc0,0xe0,0x06,0x80,0x26,0x8b,0x00,0x3f,
1363 0x08,0x06,0x8b,0x00,0x1f,0xbf,0x1f,0x00,0xb9,0x08,0x00,0x88,0x2d,0x47,0xe2,0xfb,
1364 0x61,0xc3,0x60,0xbb,0x94,0x00,0x02,0x1e,0x0c,0x00,0x1e,0x6a,0x40,0x1f,0x88,0x3f,
1365 0x1f,0xb9,0x02,0x00,0xb0,0x07,0xe8,0x9c,0x01,0x72,0x35,0xa0,0x12,0x00,0xc0,0xe0,
1366 0x02,0x0a,0x06,0x0c,0x00,0xe8,0x8d,0x01,0x72,0x26,0xe8,0xda,0x00,0x72,0x21,0xb0,
1367 0x08,0xe8,0x81,0x01,0x72,0x1a,0xe8,0x3e,0x01,0x72,0x15,0x8a,0xe0,0xe8,0x37,0x01,
1368 0x80,0xf4,0x20,0xf6,0xc4,0xf0,0x75,0x08,0xb8,0x01,0x00,0xe8,0xae,0x01,0xeb,0x03,
1369 0xe2,0xc2,0xf9,0x61,0xc3,0x50,0x53,0x51,0x52,0x8a,0x0e,0x18,0x00,0xb5,0x00,0xf9,
1370 0xd2,0xd5,0xb1,0x00,0xa0,0x15,0x00,0x2a,0x06,0x14,0x00,0x40,0x98,0xf7,0xe1,0x8b,
1371 0xd0,0x8b,0xc8,0x49,0x8c,0xc0,0xe8,0x72,0x00,0x72,0x6a,0xa0,0x27,0x00,0xe8,0xb7,
1372 0x00,0x3c,0x4a,0xb0,0xc5,0x74,0x02,0xb0,0xe6,0xe8,0x29,0x01,0x72,0x57,0xa0,0x12,
1373 0x00,0xc0,0xe0,0x02,0x0a,0x06,0x0c,0x00,0xe8,0x1a,0x01,0xa0,0x11,0x00,0xe8,0x14,
1374 0x01,0xa0,0x12,0x00,0xe8,0x0e,0x01,0xa0,0x14,0x00,0xe8,0x08,0x01,0xa0,0x18,0x00,
1375 0xe8,0x02,0x01,0xa0,0x15,0x00,0xe8,0xfc,0x00,0x8a,0x44,0x08,0xe8,0xf6,0x00,0xb0,
1376 0x80,0xe8,0xf1,0x00,0xe8,0x40,0x00,0x9c,0xbb,0x20,0x00,0xb9,0x07,0x00,0xe8,0xa6,
1377 0x00,0x88,0x07,0x43,0xe2,0xf8,0x9d,0x72,0x0c,0xf6,0x06,0x20,0x00,0xc0,0x75,0x05,
1378 0x03,0xfa,0xf8,0xeb,0x01,0xf9,0x5a,0x59,0x5b,0x58,0xc3,0x52,0xbb,0x10,0x00,0xf7,
1379 0xe3,0x03,0xc7,0x83,0xd2,0x00,0x8b,0xd8,0x8a,0xe2,0x8b,0xd1,0x03,0xd3,0x73,0x05,
1380 0xc6,0x06,0x1f,0x00,0x09,0x5a,0xc3,0xfb,0x60,0x1e,0x6a,0x40,0x1f,0xb8,0x01,0x90,
1381 0xf8,0xcd,0x15,0xba,0x80,0x02,0xbb,0x3e,0x00,0x72,0x0f,0x33,0xc9,0x84,0x17,0x75,
1382 0x0f,0xe8,0xf6,0x00,0xe2,0xf7,0xfe,0xce,0x75,0xf1,0x2e,0x08,0x16,0x1f,0x00,0xf9,
1383 0x9c,0x80,0x27,0x7f,0x9d,0x1f,0x61,0xc3,0x50,0xfa,0xe6,0x0b,0xb0,0x00,0xeb,0x00,
1384 0xeb,0x00,0xe6,0x0c,0x8a,0xc3,0xeb,0x00,0xeb,0x00,0xe6,0x04,0x8a,0xc7,0xeb,0x00,
1385 0xeb,0x00,0xe6,0x04,0xeb,0x00,0xeb,0x00,0x8a,0xc4,0xe6,0x81,0x8a,0xc1,0xeb,0x00,
1386 0xeb,0x00,0xe6,0x05,0x8a,0xc5,0xeb,0x00,0xeb,0x00,0xe6,0x05,0xfb,0xb0,0x02,0xeb,
1387 0x00,0xeb,0x00,0xe6,0x0a,0x58,0xc3,0x51,0x52,0x50,0xe8,0x72,0x00,0xba,0xf4,0x03,
1388 0xb9,0x85,0x00,0xeb,0x00,0xeb,0x00,0xec,0x24,0xc0,0x3c,0xc0,0x74,0x1c,0xeb,0x00,
1389 0xeb,0x00,0xe4,0x61,0x24,0x10,0x3a,0xc4,0x74,0xe9,0x8a,0xe0,0xe2,0xe5,0x58,0x5a,
1390 0x59,0x80,0x0e,0x1f,0x00,0x80,0xb0,0x00,0xf9,0xc3,0x58,0x42,0xeb,0x00,0xeb,0x00,
1391 0xec,0x5a,0x59,0xf8,0xc3,0x51,0x52,0x50,0xe8,0x34,0x00,0xba,0xf4,0x03,0xb9,0x85,
1392 0x00,0xeb,0x00,0xeb,0x00,0xec,0xa8,0x80,0x75,0x1a,0xeb,0x00,0xeb,0x00,0xe4,0x61,
1393 0x24,0x10,0x3a,0xc4,0x74,0xeb,0x8a,0xe0,0xe2,0xe7,0x58,0x5a,0x59,0x80,0x0e,0x1f,
1394 0x00,0x80,0xf9,0xc3,0x42,0x58,0xeb,0x00,0xeb,0x00,0xee,0x5a,0x59,0xf8,0xc3,0x50,
1395 0x51,0xb9,0x04,0x00,0xe8,0x23,0x00,0xe2,0xfb,0x59,0x58,0xc3,0x9c,0x60,0xba,0x4a,
1396 0x42,0xf7,0xe2,0x8a,0xcc,0x8a,0xea,0x8a,0xd6,0xb6,0x00,0xe8,0x0c,0x00,0xe2,0xfb,
1397 0x23,0xd2,0x74,0x03,0x4a,0xeb,0xf4,0x61,0x9d,0xc3,0xeb,0x00,0xeb,0x00,0xe4,0x61,
1398 0x24,0x10,0x3a,0xc4,0x74,0xf4,0x8a,0xe0,0xc3,0x1e,0x16,0x1f,0x26,0xa2,0x2b,0x00,
1399 0x26,0x88,0x26,0x43,0x00,0xbf,0xfc,0x09,0xbe,0x4c,0x00,0xfc,0xfa,0xa5,0xa5,0xc7,
1400 0x44,0xfc,0x5b,0x00,0x8c,0x44,0xfe,0xfb,0x1f,0xcb,0x00,0x00,0xd9,0x09,0x55,0xaa
1402 #endif
1404 char program_2m_magic[] = {
1405 0x2b,0x00,0x43,0x00,0x32,0x30,0x32,0x4d,0x2d,0x53,0x54,0x56,0x00,0x00,0x00,0x00
1408 do_2m_write()
1410 int i;
1411 char * mbr;
1413 if( read_sector(bs_offset+1, buffer+512) != 0 )
1414 exit(1);
1416 if( memcmp(buffer+512, program_2m_magic, 16) == 0 )
1418 /* Seems to be properly formatted already */
1420 write_sector(bs_offset, buffer);
1421 return;
1423 #ifdef HAS_2M20
1424 else if( disk_trck != 82 || disk_sect != 22 )
1426 fprintf(stderr, "To be bootable a 2M disk must be 22 sectors 82 tracks or formatted with DOS 2m.\n");
1427 if( !force ) exit(1);
1428 fprintf(stderr, "But I'll try it\n");
1430 write_sector(bs_offset, buffer);
1432 /* This needs to be altered to allow for the disk format description to
1433 be copied from the old boot sector */
1435 if( disk_sect == 23 ) mbr = boot_sector_2m_23_82;
1436 else mbr = boot_sector_2m_22_82;
1438 for(i=0; i<sysboot_dosfs_stat; i++)
1439 buffer[i] = mbr[i];
1440 for(i=sysboot_codestart; i<512; i++)
1441 buffer[i] = mbr[i];
1443 write_sector(0, buffer);
1445 for(i=0; i<sizeof(program_2m_vsn_20); i+=512)
1447 write_sector(bs_offset+i/512+1, program_2m_vsn_20+i);
1449 #else
1450 fprintf(stderr, "To be bootable a 2M disk must be formatted with the DOS 2m driver.\n");
1451 exit(1);
1452 #endif