                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ( CFDOS ColorForth DOS reader load block )                      EMPTY  DECIMAL   ( +CREATE )                                                                                                    : VERSION   ." colorForth DOS reader V4.0 2005 Jan 23 " ;       CR  VERSION                                                                                                                     10 +P 59 +P THRU                                                FLUSH  ( Turnkey ) 60 +P LOAD                                                                                                   CR  .( HERE = ) HERE .X  CR                                                                                                                                                                                                                                                                                                                                                                                                                                     ( User interaction )                                            : \MES   23 0 TAB  80 SPACES  23 0 TAB ;                        : .X ( u )   BASE @ >R  HEX  U.  R> BASE ! ;                                                                                    : Y/N-EXIT  KEY 223 AND [CHAR] Y - IF  R> DROP EXIT  THEN ;                                                                     : ?IMAGE.PNG ( - )   S" IMAGE.PNG" >ASCIZ PAD match 0= ;                                                                        : GET-IMAGE.PNG   7 UNMAP                                          ?IMAGE.PNG 0= IF  S" IMAGE.PNG" >ASCIZ FCREATE                     ELSE  S" IMAGE.PNG" >ASCIZ  R/W FOPEN  THEN                  >R  1024. R@ FSIZE  R> FCLOSE                                   4200 7 S" IMAGE.PNG" ?FILE ;  EXIT                              7 OFSET 2+ @ FSIZE? 1024. D< IF                                    1024. 7 OFSET 2+ @ FSIZE  THEN ;                                                                                          ( Floppy disk BIOS access)  HEX                                 0 CONSTANT DRIVE#                                                                                                               CODE FLRESET   0000 # 0 MOV   DRIVE# # 2 MOV   13 INT  NEXT                                                                     CODE FLSTATUS ( - b)   0100 # 0 MOV   13 INT   0 0 HI XCHG B       0FF # 0 AND   0 PUSH   NEXT                                                                                                  CODE flread ( head t+s buff - f )                                  ( set ES to our CS )  0 IS SSG   0 ES LSG                       0 ( Ax ) POP  1 ( Cx ) POP   2 ( Dx ) POP                       U ( Bx ) PUSH   0 U ( Bx ) MOV   0202 # 0 ( Ax ) MOV   13 INT   U ( Bx ) POP   0 0 HI XCHG B  0FF # 0 AND   0 PUSH  NEXT                                                                                                                                                                                                     ( Floppy disk BIOS access)  HEX                                                                                                 CODE flwrite ( head t+s buff - f )                                 ( set ES to our CS )  0 IS SSG   0 ES LSG                       0 ( Ax ) POP  1 ( Cx ) POP   2 ( Dx ) POP                       U ( Bx ) PUSH   0 U ( Bx ) MOV   0302 # 0 ( Ax ) MOV   13 INT   U ( Bx ) POP   0 0 HI XCHG B  0FF # 0 AND   0 PUSH  NEXT                                                                     CODE flverify ( head t+s buff - f )                                ( set ES to our CS )  0 IS SSG   0 ES LSG                       0 ( Ax ) POP  1 ( Cx ) POP   2 ( Dx ) POP                       U ( Bx ) PUSH   0 U ( Bx ) MOV   0402 # 0 ( Ax ) MOV   13 INT   U ( Bx ) POP   0 0 HI XCHG B  0FF # 0 AND   0 PUSH  NEXT                                                                                                                                                                                                        ( 1.44MByte Floppy disk access)  HEX                         : SECTOR ( sector# - sector head track )  12 /MOD  2 /MOD  ;                                                                    : FLREAD ( block# buff - f )   >R  2* SECTOR                       >R  ><  DRIVE# OR  SWAP  R>   ( head' sector track - )          SWAP 1+ SWAP  >< OR  R>  flread  ;                                                                                           : FLWRITE ( block# buff - f )   >R  2* SECTOR                      >R  ><  DRIVE# OR  SWAP  R>   ( head' sector track - )          SWAP 1+ SWAP  >< OR  R>  flwrite  ;                                                                                          : FLVERIFY ( block# - f )  0 >R  2* SECTOR                         >R  ><  DRIVE# OR  SWAP  R>   ( head' sector track - )          SWAP 1+ SWAP  >< OR  R>  flverify  ;                                                                                                                                                            ( Floppy disk BIOS block access)  HEX                        : .FL-ERR ( errorcode - )   CR ." BIOS error : "  >R  R@ .X        R@ 0F AND CASE                                                     01 OF  ."  Illegal command"  ENDOF                              02 OF  ."  Bad sector"  ENDOF                                   03 OF  ."  Write protected"  ENDOF                              04 OF  ."  Sector not found"  ENDOF                             06 OF  ."  Disk changed"  ENDOF                                 08 OF  ."  DMA overrun"  ENDOF                                  09 OF  ."  DMA >64K"  ENDOF                                     0C OF  ."  Invalid media"  ENDOF                             ENDCASE  R@ 10 AND IF  ."  CRC error"  THEN                     R@ 20 AND IF  ."  Controller error"  THEN                       R@ 40 AND IF  ."  Seek"  THEN                                   R> 80 AND IF  ."  Timeout"  THEN ;                                                                                              ( Floppy disk BIOS block access)                             : FL>BLK ( from to )   BLOCK  UPDATE                               2DUP FLREAD IF                                                     FLRESET  2DUP FLREAD IF                                            FLRESET  2DUP FLREAD  ?DUP IF  .FL-ERR  ABORT  THEN          THEN                                                         THEN  2DROP ;                                                                                                                : BLK>FL ( from to )   SWAP  BLOCK  2DUP                           FLWRITE IF                                                         FLRESET  2DUP FLWRITE IF                                           FLRESET  FLWRITE  ?DUP IF  .FL-ERR  ABORT                    ELSE  2DROP  THEN                                            ELSE  2DROP  THEN  2DROP  THEN  ;                                                                                                                                                               ( Floppy disk BIOS block access) DECIMAL                     2VARIABLE MYFILE  2VARIABLE MYFILESIZE                          2400 CONSTANT MYBLOCKS  4 CONSTANT MYPART                       : TSTZ   DUP 642 BLOCK FLREAD  >R  UPDATE  642 LIST                642 BLOCK  HEX 64 DUMP   DECIMAL                                CR  R>  ?DUP IF  ." Failed : "  .X  ELSE  ." ok "  THEN         ." Floppy block # "  . ;                                                                                                     2VARIABLE #TRANSFER                                                                                                             : UPLOAD   #TRANSFER 2@ DO  I  I MYBLOCKS + FL>BLK  LOOP ;                                                                      : DOWNLOAD   #TRANSFER 2@ DO  I MYBLOCKS + I BLK>FL  LOOP ;                                                                     : UP-DISK    MYPART UNMAP  1440 0 #TRANSFER 2!  UPLOAD ;        : DOWN-DISK  MYPART UNMAP  1440 0 #TRANSFER 2!  DOWNLOAD ;      ( BLK file info )                                               : BINFO   2417 LIST  CR CR  ." Edit lines 12 to 15 of block 17, then type FLUSH !BINFO RUN "  CR  ." Line 12 should contain author and date."  EDITOR  QUIT ;                                   : !BINFO   2417 17 BLK>FL  CR ." Block info stored to blk 17 ."    CR ." Type RUN to continue : "  ;                            : GET-PNG-SIZE ( - d)   270 4200 FL>BLK    \ get the first block   4200 BLOCK 93 + 2@ >< SWAP >< SWAP  118. D+  1024. DMAX ;    : GET-PNG   \MES  ." Press Y to upload the PNG file from floppy block 270 to IMAGE.PNG :" Y/N-EXIT  \MES ." Reading data..."       GET-IMAGE.PNG  GET-PNG-SIZE  4200 BLOCK 2@ 1351173966. D= 0=    IF  \MES ." Not a PNG file!" 7 UNMAP 2DROP 3000 MS EXIT  THEN   ."  Size = "  2DUP D. ." octets"                                2DUP  1023. D+ 1024 M/ DUP 1024 M* 7 OFSET 2+ @ FSIZE           DUP 1 > IF  1 DO 270 I + 4200 I + FL>BLK LOOP  ELSE DROP THEN   FLUSH   7 OFSET 2+ @ FSIZE  FLUSH  7 UNMAP ;                 ( variables )                                                   VARIABLE NV-DATA  1022 ALLOT                                    : NVAR  CREATE , DOES>  @ NV-DATA + ;                           0 NVAR BLOK                                                     2 NVAR LAST-BLOK                                                4 NVAR DOC                                                      6 NVAR COLOURBLIND                                              8 NVAR LINE#                                                    10 NVAR HIGHL#                                                  12 NVAR FIRST#                                                  14 NVAR TOTAL#                                                                                                                  32 NVAR THE-FILE                                                                                                                64 NVAR FILE-TYPE                                                                                                               ( Colours )                                                     VARIABLE IP                                                                                                                     : \IP  ( a - )  IP ! ;                                                                                                          : IP@ ( - d )   IP @ 2@  SWAP  4 IP +! ;                                                                                        : IP0? ( - f )   IP @ 2@ OR 0= ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ( Colours )  HEX                                                VARIABLE EXT-STATE                                              VARIABLE EXT-COLOUR                                             VARIABLE EXT-BASE                                                                                                               CREATE COLOURS  0 C,  0E C,  0E C,  0C C,  0A C,  0A C,  0A C,     0B C,  0E C,  0F C,  0F C,  0F C,  0D C,  00 C,  00 ,        CREATE COLOURS-CB 0 C,  E0 C,  E0 C,  0C C,  0A C,  0A C,  0A C,   B0 C,  E0 C,  0F C,  0F C,  0F C,  0D C,  00 C,  00 ,                                                                        : SET-COLOUR ( c )  ?DUP IF 0F AND  DUP EXT-COLOUR !               COLOURBLIND  @ IF  COLOURS-CB + C@ 7F AND  ELSE                    COLOURS + C@  THEN                                           DUP 0A = EXT-BASE @ AND IF  DROP 02  THEN                    ATTRIBUTE ! THEN ;                                                                                                                 ( block display - Huffman decoding )  HEX                    CODE DLSHIFT ( d - d' )   0 # 0 MOV  0 ROL   2 POP  0 POP          0 SHL  2 RCL   0 PUSH   2 PUSH  NEXT                         : DLSHIFTS ( d n - d' )  0 DO  DLSHIFT  LOOP ;                  CODE DLROTATE ( d - d' )  0 # 0 MOV 0 ROL 1 POP  0 POP  1 2 MOV    0 RCL  1 RCL  2 2 OR 0< IF  1 # 0 OR  THEN   0 PUSH   1 PUSH    NEXT                                                         : DLROTATES ( d n - d' )   0 DO  DLROTATE LOOP ;                : K ( d  - d' )  HEX  DLROTATE 2DUP U. U.  ;                    5550000B. 2CONSTANT TOK                                                                                                         CREATE HUFFMAN                                    CHAR " STRING  rtoeanismcylgfwdvpbhxuq0123456789j-k.z/;:!+@*,? RTOEANISMCYLGFWDVPBHXUQ0123456789J_K.Z/;:!+@*,?"                                                                                                                                                                   ( block display - Huffman decoding )  HEX                   : BACKSPACE  -1 +CP ;                                                                                                           CODE DRSHIFT ( d - d' )   0 # 0 MOV  0 ROL   2 POP  0 POP          2 SHR  0 RCR   0 PUSH   2 PUSH  NEXT                         : DRSHIFTS ( d n - d' )  0 DO  DRSHIFT  LOOP ;                                                                                  VARIABLE CAPITALS  0 CAPITALS !                                                                                                 : CF-EMIT ( c)                                                     CAPITALS @ IF  30 +  THEN                                       HUFFMAN 1+ + C@ EMIT                                            CAPITALS @ 1 = IF  0 CAPITALS !  THEN ;                                                                                                                                                                                                                         ( block display - Huffman decoding )  HEX                    : .HF0   2DUP  3 DLROTATES  OVER 7 AND  CF-EMIT                    2DROP  3 DLSHIFTS ;                                          : .HF1   2DUP  3 DLROTATES  OVER 7 AND  8 +  CF-EMIT               2DROP  3 DLSHIFTS ;                                          : .HF2   2DUP  5 DLROTATES  OVER 1F AND  10 + CF-EMIT              2DROP  5 DLSHIFTS ;                                                                                                          : .HF ( d - d' )                                                   DUP 8000 AND 0= IF  DLSHIFT .HF0  EXIT  THEN  DLSHIFT           DUP 8000 AND 0= IF  DLSHIFT .HF1  EXIT  THEN  DLSHIFT           .HF2 ;                                                       : TOK>HUF ( tok - tok' )   SWAP FFF0 AND SWAP ;                                                                                 : .HUF ( d )   TOK>HUF                                             BEGIN  .HF  2DUP OR 0= UNTIL  SPACE  2DROP ;                    ( block display )  HEX                                       : TOK>COL ( tok - tok n )   OVER  0F AND ;                                                                                      : TOK>BASE ( tok - tok n )   OVER  10 AND ;                                                                                     : TOK>NUM ( tok - tok )   5 DRSHIFTS                               DUP 0400 AND IF ( Sign extend) FC00 OR  THEN ;                                                                               : SET-BASE ( tok - tok )   TOK>BASE  EXT-BASE ! ;                                                                               : .NUM ( tok)   BASE @ >R                                          EXT-BASE @ IF  HEX                                                 COLOURBLIND @ IF  ." 0x"  THEN  ELSE  DECIMAL  THEN          D.  R> BASE ! ;                                                                                                                                                                                 ( block display - Huffman decoding )  HEX                    : SRC? ( - f )   DOC @ 0= ;                                                                                                     : COL-EXTENS ( tok)  2DROP ;                                    : COL-EXECUTE ( tok)   .HUF ;                                   : COL-LARGE-YELLOW ( tok)  2DROP IP@ .NUM ;                     : COL-DEFINE-RED ( tok)   EXT-STATE @ 0= IF                        C# @ 51 = IF  C# 2@  SWAP 1- SWAP TAB  THEN  \  C# @ ." >>> "      -1 +CP  CR                                                      COLOURBLIND @ SRC? AND IF  ." : "  THEN  THEN  .HUF ;                                                                     : COL-COMPILE-GREEN ( tok)   .HUF ;                             : COL-LARGE-GREEN ( tok)   2DROP IP@ .NUM ;                     : COL-NUMBER-GREEN ( tok)  TOK>NUM .NUM ;                       : COL-COMPILE-CYAN ( tok)   .HUF ;                              : COL-NUM-YELLOW ( tok)   TOK>NUM .NUM ;                           ( block display - Huffman decoding )  HEX                    VARIABLE LAST-COLOUR                                            : COMMENT? ( n - f)   9 0C WITHIN ;                             : END-COMMENT ( - f)  COMMENT? NOT LAST-COLOUR @ COMMENT? AND ; : START-COMMENT ( - f) COMMENT? LAST-COLOUR @ COMMENT? NOT AND ;                                                                : (? ( c)   START-COMMENT COLOURBLIND @ AND SRC? AND IF            ATTRIBUTE @ 0F ATTRIBUTE !  ." ( "   ATTRIBUTE !  THEN ;     : )? ( c)   END-COMMENT COLOURBLIND @ AND SRC? AND IF              ATTRIBUTE @ 0F ATTRIBUTE !  ." ) "   ATTRIBUTE !  THEN ;     : .COMMENT ( n )   CAPITALS !  .HUF ;                           : COL-comment ( tok)   0 .COMMENT ;                             : COL-Comment ( tok)   1 .COMMENT ;                             : COL-COMMENT ( tok)   2 .COMMENT ;                             : COL-MAGENTA ( tok)   .HUF  IP@ .NUM ;                                                                                            ( block display )                                            CREATE COL-ACTIONS                                                ' COL-EXTENS ,      ' COL-EXECUTE ,       ' COL-LARGE-YELLOW ,  ' COL-DEFINE-RED ,  ' COL-COMPILE-GREEN , ' COL-LARGE-GREEN ,   ' COL-NUMBER-GREEN , ' COL-COMPILE-CYAN , ' COL-NUM-YELLOW ,    ' COL-comment ,     ' COL-Comment ,       ' COL-COMMENT ,       ' COL-MAGENTA ,     ' 2DROP ,  ' 2DROP ,  ' 2DROP ,                                                                           : CFSHOW ( tok - )    SET-BASE  TOK>COL  DUP SET-COLOUR            DUP 0=  DUP EXT-STATE !  IF ( Extension token )  DROP              EXT-COLOUR @  DUP 10 = IF  1-  THEN                             BACKSPACE   ELSE  0 CAPITALS !                               DUP (?  DUP )?  DUP LAST-COLOUR !  THEN                         2* COL-ACTIONS + @EXECUTE                                    ;                                                                                                                                  ( block display )                                            : CFLIST ( addr -- )  IP !                                         1024 0 DO                                                          IP@  CFSHOW                                                     IP0? IF  LEAVE  THEN  LOOP                                   -1 )? ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      (  )                                                            : LST ( n)   BLOK !  ATTRIBUTE @ >R                                15 ATTRIBUTE !  0  LAST-COLOUR !  0 EXT-COLOUR !                PAGE  BLOK @  DOC @ IF  1+  THEN                                DUP MYBLOCKS + BLOCK  CFLIST  15 ATTRIBUTE !                    24 60 TAB THE-FILE COUNT TYPE ."  : " .                         R> ATTRIBUTE ! ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ( Upload and Download )                                         : .FLOPPY-ID   ( read sector 0 )  0 1206 FL>BLK                    \MES  ." Floppy sector 0 ID = "                                 ATTRIBUTE @ >R   49 ATTRIBUTE !                                 1206 BLOCK 3 + 8 TYPE  R> ATTRIBUTE ! ;                                                                                      : $. ( a )   COUNT TYPE ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ( Upload and Download )                                      HEX 6D636663. 2CONSTANT CF-MAGIC  DECIMAL                                                                                       : ?UPLOAD ( first n )   #TRANSFER 2!                               \MES  ." Press Y to Upload " #TRANSFER  2@ 2DUP - . ." blocks from block "  .  DROP                                            ." of the floppy to file " THE-FILE $.  ."  : "  Y/N-EXIT       .FLOPPY-ID  1206 BLOCK 3 + 2@  CF-MAGIC D= NOT IF               CR ." This may not be a colorForth floppy! Press Y to continue :"  Y/N-EXIT  THEN                                            ."     Reading the floppy disk... "  UPLOAD ;                                                                                                                                                                                                                                                                                                                                                       ( Upload and Download )                                      16 CONSTANT STRING-SIZE                                         : $! ( a n a)                                                      >R  STRING-SIZE MIN  DUP I C!  R> 1+  SWAP MOVE ;                                                                            : ?DOWNLOAD ( first n )   #TRANSFER 2!                             \MES  ." Press Y to Download "  #TRANSFER  2@ 2DUP - .          ." blocks from block "   .  DROP                                ." of the file "  THE-FILE $. ."  to the floppy: "   Y/N-EXIT   \MES  ." WARNING! This will overwrite the floppy and make it not readable by DOS/Windows."                                      24 0 TAB  ."  Press Y to continue :"  Y/N-EXIT                  ."  Writing to the floppy disk... "  DOWNLOAD ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ( Constants )                                                   4 CONSTANT TOPLINE#                                             10 CONSTANT #LINES                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ( misc )  DECIMAL                                                1808 ( 1262 ) CONSTANT  DATA-BLOCK                                                                                             : SAVE-DATA  NV-DATA DATA-BLOCK BLOCK 1024 MOVE  UPDATE ;                                                                       : RESTORE-DATA   DATA-BLOCK BLOCK NV-DATA 1024 MOVE ;                                                                           : \\RUN   NV-DATA 1024 ERASE                                       18 BLOK !  64 LAST-BLOK !                                       0 DOC !  0 COLOURBLIND !  0 LINE# !  0 HIGHL# !  0 FIRST# !     S" CFDOS4.BLK" THE-FILE $!                                   \    S" PCITEST.BLK" THE-FILE $!                                   S" *.BL*"  FILE-TYPE $!                                         SAVE-DATA ;                                                                                                                  : \\\RUN   S" BSCLIENT.BLK" THE-FILE $!  SAVE-DATA ;            ( misc )                                                        : FKEY ( - u )   KEY DROP  'KEY @ ;                             : ?BYE   \MES ." Press Y to exit : "  Y/N-EXIT  ' BYE 'IDLE !      SAVE-DATA  FLUSH  UNMAP-ALL  BYE ;                           : LOGO   CR 19 SPACES  ." Howerd Oakford   www.inventio.co.uk" ;                                                                : HELPS+   ATTRIBUTE @ >R  49 ATTRIBUTE !                          HELPS  CR CR  18 SPACES  VERSION  LOGO  R> ATTRIBUTE ! ;     1800 ( 1254 ) CONSTANT HELP-BLOCKS                              : HELP   BEGIN  HELP-BLOCKS HELPS+                                 FKEY 15104 - IF  EXIT  THEN  HELP-BLOCKS 1 + HELPS+             FKEY 15104 - IF  EXIT  THEN  HELP-BLOCKS 2 + HELPS+             FKEY 15104 - IF  EXIT THEN HELP-BLOCKS 3 +                      HELPS+ FKEY 15104 - UNTIL ;                                                                                                  : TOGGLE ( a )   >R  R@ @ 0= R> ! ;                             ( step through blocks )                                         VARIABLE THE-FILE-SIZE                                                                                                          : +BLK ( n )                                                       BLOK @ >R                                                       DUP 0< IF ( down )                                                 R@ + DUP 18 <  R@ 17 > AND IF  DROP  18  THEN                ELSE                                                               R@ + DUP THE-FILE-SIZE @ 1- >  R@ THE-FILE-SIZE @ < AND IF         DROP  THE-FILE-SIZE @ 1-  0 MAX  THEN                     THEN                                                            R> DROP                                                         0 MAX  1439 MIN  BLOK !                                      ;                                                                                                                               : DOC-TOGGLE   BLOK @ 1 AND IF  -1  ELSE  1  THEN  +BLK ;       ( Calendar - days since 01/01/1900)                             VARIABLE FILEHDR 256 ALLOT                                                                                                      HERE 2-  0 ,  31 ,  59 ,  90 ,  120 ,  151 ,                         181 ,  212 ,  243 ,  273 ,  304 ,  334 ,  367 ,            : MONTH ( n - n)   2* LITERAL + @ ;                                                                                             365 4 * 1+ CONSTANT DAYS/YEAR                                   : D.M.Y ( d m y - n)   >R  MONTH 31 OVER < IF  I 3 AND 0= - THEN   +  R> 3 + DAYS/YEAR 4 */MOD  SWAP DROP + 1096 - ;                                                                            : FileDate ( - n)   FILEHDR 24 + @  32 /MOD  16 /MOD  80 +         D.M.Y ;                                                                                                                      : FileTime ( - d)   FILEHDR 22 + @  0 32 U/  64 /MOD  60 * +       1092 U* ;                                                       ( File access)  HEX                                          : GETS ( a n fh - n)   {D !FH  !EXT !DATA  3F DOS  RCODE D} ;                                                                   : PUTS ( a n fh - n)   {D !FH  !EXT !DATA  40 DOS  RCODE D} ;                                                                   : APPEND ( fh)  {D !FH  2 !FC  0. !EXT !DATA  42 DOS D} ;                                                                       : POINT ( d fh - d)  {D !FH  0 !FC  !EXT !DATA  42 DOS             RCODE  PARAMS 4 + @  D} ;                                                                                                    : MATCH ( $z - f)   {D  !DATA 02 !EXT 4E -DOS  0 DISK 2+ !  D} ;                                                                ~ : FILE-OPEN ( $a - fh | 0)   COUNT  >ASCIZ  DUP  MATCH           IF  FCREATE  ELSE  R/W FOPEN  THEN                              DISK 2+ @ IF  DROP 0  THEN ;                                                                                                 ( Virtual memory)                                               2VARIABLE >VC@   2VARIABLE >VC!  : \VCS  0. >VC@ 2! 0. >VC! 2! ;                                                                : VC@ ( - c)   >VC@ 2@ 1024 U/MOD  MYBLOCKS + BLOCK + C@           >VC@ 2@ 1 M+ MYFILESIZE 2@ DMIN >VC@ 2! ;                    : V@ ( - n)   VC@ VC@ >< OR ;                                                                                                   : VC! ( c)   >VC! 2@ 1024 U/MOD  MYBLOCKS + BLOCK + C! UPDATE      >VC! 2@ 1 M+ MYFILESIZE 2@ DMIN >VC! 2! ;                                                                                    : SMALLCHK   \VCS  1152. MYFILESIZE 2@ DMIN >VC@ 2!                0  512 0 DO  V@ +  2 +LOOP ;                                                                                                 : BIGCHK ( - d)   0.  MYFILESIZE 2@ OR 0= IF  EXIT  THEN  \VCS     BEGIN  V@ 0 D+ >VC@ 2@ MYFILESIZE 2@ D< NOT UNTIL ;                                                                             ( Directory Listing)   HEX                                   VARIABLE FILEINFO 256 ALLOT                                     VARIABLE FILENAME 10 ALLOT                                                                                                      : XNAME ( - )  FILEHDR 1E + >COUNTED DUP 0D SWAP - SPACES TYPE ;                                                                : .SIZE ( - )  FILEHDR  1A + 2@ SWAP  2DUP 400 U/                  DUP 0= IF                                                          DROP  DROP 4 U.R SPACE                                       ELSE                                                               4 U.R  ." K"  2DROP                                          THEN ;                                                                                                                                                                                                                                                                                                                          ( Directory Listing)                                         : MAP-FILE ( a n -)   MYPART UNMAP                                 MYBLOCKS MYPART 2SWAP MAP SWAP MODIFY                           MYPART OFSET 2+ @ FSIZE? 2DUP MYFILESIZE 2!                     1024 M/ DUP THE-FILE-SIZE !                                     DUP 20 < IF                                                        1- 0 MAX  -2 AND  BLOK @  MIN  BLOK !                        ELSE                                                               DROP  18 BLOK !                                              THEN ;                                                                                                                       : MAP-THE-FILE   THE-FILE COUNT MAP-FILE ;                                                                                                                                                                                                                                                                                         ( Directory Listing)  HEX                                    : .FILE ( - )                                                      FILEHDR 1E + >COUNTED  2DUP MAP-FILE                            DUP  0D SWAP - 0 MAX  SPACES  TYPE  2 SPACES                    .SIZE  2 SPACES  FileDate .DATE                                 2 SPACES  FileTime .TIME  2 SPACES                              MYFILESIZE 2@ 12 400 M* D< IF  20 SPACES  EXIT  THEN            PAD 108 20 FILL                                                 12 400 M* 100. D- >VC@ 2!  100 0 DO  VC@ PAD I + C!  LOOP       PAD 20 0 MAX  20 MIN TYPE  4F C# @ - 0 MAX  SPACES              3. >VC@ 2!  8 0 DO  VC@  PAD 100 + I + C!  LOOP              ;                                                                                                                                                                                                                                                                                                                                  ( Directory Listing)  HEX                                    : .FILE+  LINE# TALLY                                              LINE# @ 1- FIRST# @ < IF  EXIT  THEN                            CR  LINE# @ 1- HIGHL# @ = IF  PAD 100 ERASE                        ATTRIBUTE @ >R  =MARK C@ ATTRIBUTE !  .FILE R> ATTRIBUTE !   PAD FILEINFO 108 MOVE  FILEHDR 1E + >COUNTED FILENAME $!        FILENAME DUP C@ 1+  THE-FILE  SWAP CMOVE                        ELSE  .FILE  THEN ;  DECIMAL                                 : CHKBLK ( n - d)  0.  ROT  BLOCK                                  1024 OVER + SWAP DO  I @ 0 D+  2 +LOOP ;                     : BIGCHK2 ( - d)    0.                                             MYFILESIZE 2@ OR 0= IF  EXIT  THEN                              MYFILESIZE 2@ 1024 U/MOD  SWAP >R  DUP 1024 U* >VC@ 2!          ?DUP IF   0 DO  MYBLOCKS I + CHKBLK D+  LOOP  THEN              R> IF  BEGIN  V@ 0 D+ >VC@ 2@ MYFILESIZE 2@ D< NOT UNTIL        THEN ;                                                          ( Directory Listing)                                         : +ATT ( colour)  ATTRIBUTE ! ;                                 : -ATT  15 ATTRIBUTE !  ;                                                                                                       : .HEX ( d)  BASE @ >R HEX  <# #S [CHAR] x HOLD  [CHAR] 0 HOLD     #> TYPE  R> BASE ! ;                                                                                                         : .INFO                                                            MAP-THE-FILE                                                    4 0 DO  I 18 + 0 TAB  2 SPACES                                  FILEINFO I 64 * + 64 TYPE  LOOP                                 CR  ."   File sector 0 ID = " ATTRIBUTE @ >R   49 ATTRIBUTE !   FILEINFO 256 + 8 TYPE  R> ATTRIBUTE !                           ."  File cksum = "  14 +ATT  BIGCHK2 .HEX  -ATT                 ."  Kernel = "  14 +ATT  SMALLCHK 0 .HEX  -ATT ;             : ZZ   0 MYFILESIZE 2!  CR  BIGCHK .HEX  ."  " BIGCHK2 .HEX ;      ( Directory Listing)                                         : (DIR)   FILE-TYPE COUNT  0 LINE# !                               >ASCIZ FILEHDR match  ABORT" File not found"                    BEGIN   .FILE+                                                     FILEHDR +match                                               LINE# @ FIRST# @ - #LINES >  OR  UNTIL ;                                                                                     : DIR   TOPLINE# 0 TAB                                             ." List of "  FILE-TYPE COUNT TYPE                              1000 TOTAL# !  1000 FIRST# !  (DIR)                             LINE# @ TOTAL# !  0 FIRST# !                                    2 SPACES  TOTAL# @  3 U.R  ."  files :"                         TOPLINE# 0 TAB  (DIR)  .INFO ;                                                                                                                                                                                                                                  ( Directory Listing)                                         : DOWN   HIGHL# @ 1 + TOTAL# @ 1- MIN  HIGHL# !                    HIGHL# @ FIRST# @  #LINES + > IF  1 FIRST# +!  THEN             TOPLINE# 0 TAB (DIR)  .INFO ;                                                                                                : UP   HIGHL# @ 1- 0 MAX  HIGHL# !                                 HIGHL# @ FIRST# @  < IF  -1 FIRST# +!  THEN                     TOPLINE# 0 TAB (DIR)  .INFO ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ( Directory Listing)                                        VARIABLE SAVED-THE-FILE 32 ALLOT                                                                                                : SAVE-THE-FILE  THE-FILE SAVED-THE-FILE 32 CMOVE ;                                                                             : RESTORE-THE-FILE  SAVED-THE-FILE THE-FILE 32 CMOVE               MAP-THE-FILE ;                                                                                                               : COPY-SELECTED                                                    FILENAME COUNT THE-FILE $!  MAP-THE-FILE                     EXIT                                                               TOPLINE# 0 TAB (DIR) .INFO ;                                                                                                                                                                                                                                                                                                    ( Directory Listing)                                         : (SELECT) ( n)   CASE                                                8454 ( ctrlF ) OF  SAVE-DATA  CR  ."  ok "  QUIT  ENDOF         18688 OF  UP  ENDOF                                             18432 OF  UP  ENDOF                                             20480 OF  DOWN  ENDOF                                           20736 OF  DOWN  ENDOF                                           7181 OF ( enter )  COPY-SELECTED  R> DROP  EXIT  ENDOF          283 OF ( Esc )  RESTORE-THE-FILE  R> DROP  EXIT  ENDOF          20224 OF  R> DROP  EXIT  ENDOF                                  5897 ( ctrlI ) OF  BINFO  ENDOF                                 8454 ( ctrlF ) OF  SAVE-DATA  CR  ."  ok "  QUIT  ENDOF         15104 ( F1 ) OF  HELP  ENDOF  16896 ( F8 ) OF  ?BYE  ENDOF   ENDCASE ;                                                                                                                                                                                       ( Directory Listing)                                         : SELECT   PAGE   ." Esc to return, Up and Down arrows to highlight the file, Enter to select : "                                  SAVE-THE-FILE                                                   DIR                                                             BEGIN                                                           2 0 TAB ." Current file : " SAVED-THE-FILE COUNT TYPE           10 SPACES  FKEY (SELECT)  AGAIN ;                                                                                            : .VALS CR ." First, Line, Highl :" FIRST# ? LINE# ? HIGHL# ? ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ( Number input)                                              CODE *DIGIT ( d a n - d a)   W POP   2 POP   0 POP   1 POP         2 PUSH   BASE U) MUL   1 0 XCHG   BASE U) MUL                   W 0 ADD   2 1 ADC   2 POP   0 PUSH   1 PUSH   2 PUSH   NEXT                                                                  \ : CONVERT ( d a - d a)   BEGIN  ?DIGIT  WHILE                 \       *DIGIT  1 PTR +!  REPEAT ;                                                                                              : MYNUMBER ( a - n )   -1025 PTR !  DUP 1+ C@  45 =                DUP >R -  0 DUP ROT  BEGIN  CONVERT DUP C@  DUP 43 48 WITHIN    SWAP 58 =  +  WHILE  0 PTR !  REPEAT                            C@ 32 - IF  123 THROW  THEN                                     R> IF  DNEGATE  THEN ( PTR @ 0< IF )  'NUMBER 2+ ! ( THEN ) ;                                                                                                                                                                                                ( ENTER-BLOK )                                                  VARIABLE NUM-PAD 10 ALLOT                                                                                                       : (ENTER-BLOK)                                                     \MES  ." Enter Block number : "  ATTRIBUTE @ >R                 79 ATTRIBUTE !                                                  NUM-PAD 6 32 FILL NUM-PAD 5 EXPECT  NUM-PAD 1- MYNUMBER         0 MAX 1439 MIN  BLOK @ LAST-BLOK !  BLOK !                      R> ATTRIBUTE ! ;                                                                                                             : ENTER-BLOK  ['] (ENTER-BLOK) CATCH IF                               \MES  ." Not a number!"  1000 MS  124 THROW  THEN  ;                                                                      : OTHER-BLOK  LAST-BLOK @ BLOK @   SWAP  BLOK ! LAST-BLOK ! ;   : BLOCK-ERASE ( block)   BLOCK 1024 ERASE  UPDATE ;             : #UNDO ( block)   BLOCK DROP  BMAX 2OFFSET 2@ D- 2IDENTIFY ;   ( RUN )                                                         DECIMAL                                                         : (RUN1) ( fkey)   CASE                                            18688 ( pageUp) OF 2 +BLK ENDOF 13615 ( / ) OF 2 +BLK ENDOF     20736 ( pgeDown) OF -2 +BLK ENDOF                               12877 ( M) OF -2 +BLK ENDOF    12909 ( m) OF -2 +BLK ENDOF      18176 ( Home ) OF   18 BLOK !  0 DOC !  ENDOF                   6480 ( P) OF  DOC-TOGGLE  ENDOF                                 6512 ( p) OF  DOC-TOGGLE  ENDOF                                 14624 ( Space) OF  DOC-TOGGLE  ENDOF                            15104 ( F1 ) OF  HELP  ENDOF  16896 ( F8 ) OF   ?BYE   ENDOF    20224 ( End ) OF   ?BYE   ENDOF   283 ( End ) OF  ?BYE  ENDOF   15872 ( F4 ) OF   COLOURBLIND TOGGLE  ENDOF                     6223 ( O ) OF  OTHER-BLOK  ENDOF                                6225 ( o ) OF  OTHER-BLOK  ENDOF                                ENDCASE  ;                                                   ( RUN )  : (RUN2) ( fkey)   CASE                                   5653 ( ctrlU ) OF  18 0  ?UPLOAD  ENDOF                         8196 ( ctrlD ) OF  18 0 ?DOWNLOAD  ENDOF                        6416 ( ctrlP ) OF  1440 0  ?UPLOAD  ENDOF                       6159 ( ctrlO ) OF  1440 0  ?DOWNLOAD  ENDOF                     5717 ( U) OF 256 0 ?UPLOAD ENDOF 5749 OF 256 0 ?UPLOAD ENDOF 8260 ( D) OF 256 0 ?DOWNLOAD ENDOF 8292 OF 256 0 ?DOWNLOAD ENDOF   5961 ( I ) OF  .FLOPPY-ID  FKEY DROP  ENDOF                     8454 ( ctrlF ) OF  SAVE-DATA CR ."  ok "  +ERRORS  QUIT ENDOF   16384 ( F6 ) OF  SELECT  ENDOF                                  16640 ( F7 ) OF  GET-PNG  ENDOF                                 5897 ( ctrlI ) OF  BINFO  ENDOF                                 12354 ( B ) OF  ENTER-BLOK  ENDOF                               12386 ( b ) OF  ENTER-BLOK  ENDOF                               11544 ( ctrlX ) OF  BLOK @ MYBLOCKS + BLOCK-ERASE  ENDOF        11290 ( ctrlZ ) OF  BLOK @ MYBLOCKS + #UNDO  ENDOF  ENDCASE ;   ( RUN )                                                      : (RUN)   BLOK @ LST  FKEY ( -33 AND ) DUP (RUN1) (RUN2) ;                                                                      : MAP-THE-FILE+                                                       BEGIN  ['] MAP-THE-FILE CATCH IF  SELECT  0  ELSE -1  THEN   UNTIL ;                                                                                                                      : RUN   -CREATE  15 ATTRIBUTE !    MAP-FILES                       BEGIN  PAUSE  ['] RESTORE-DATA  CATCH 0= UNTIL                  HELP  MAP-THE-FILE+                                             'KEY @ (RUN2)                                                   BEGIN  ['] (RUN) CATCH  DROP  AGAIN ;                                                                                        TURNKEY LOAD STARTER RUN PROGRAM                                   ( GETB )  \\RUN  ( \\\RUN )  FLUSH                                                                                           EXIT  CR  .( Turnkey )                                          TURNKEY LOAD STARTER RUN PROGRAM                                   GETB  \\RUN  ( \\\RUN )  FLUSH                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               ( Binary checksum)  EMPTY                                       DECIMAL                                                         : +ATT ( colour)  ATTRIBUTE ! ;                                 : -ATT  15 ATTRIBUTE !  ;                                       : VERSION                                                          ." Chk.com V2.0 2004 Oct 08 16 Bit sum of 512 bytes from 1152 to 1663" ;                                                     : VERSION+   80 +ATT  VERSION -ATT ;                                                                                                                                                            ( Binary checksum)  1 +B 5 +B THRU                                                                                                                                                                                                                                                                                                                                                                 ( Binary checksum)                                           2VARIABLE MYFILE  2VARIABLE MYFILESIZE                          3000 CONSTANT MYBLOCKS  5 CONSTANT MYPART                                                                                       : .MYFILE   CR  ." File : "  14 +ATT                               MYFILE 2@  0 MAX  60 MIN  TYPE   -ATT   SPACE                   ."  Size = "  14 +ATT  MYPART OFSET 2+ @ FSIZE? 2DUP D. -ATT    ." octets. "  MYFILESIZE 2! ;                                                                                                : ARG1                                                             MYPART UNMAP                                                    128 C@ IF                                                          128 COUNT  SWAP DROP  130  SWAP  1- 0 MAX                    ELSE                                                               S" CFDOS4.BLK"  \ 2DROP  S" BAK.BAT"                         THEN  MYFILE 2! MYBLOCKS MYPART MYFILE 2@ ?FILE ;            ( Virtual memory)                                               2VARIABLE >VC@   2VARIABLE >VC!  : \VCS  0. >VC@ 2! 0. >VC! 2! ;                                                                : VC@ ( - c)   >VC@ 2@ 1024 U/MOD  MYBLOCKS + BLOCK + C@           >VC@ 2@ 1 M+ MYFILESIZE 2@ DMIN >VC@ 2! ;                    : V@ ( - n)   VC@ VC@ >< OR ;                                                                                                   : VC! ( c)   >VC! 2@ 1024 U/MOD  MYBLOCKS + BLOCK + C! UPDATE      >VC! 2@ 1 M+ MYFILESIZE 2@ DMIN >VC! 2! ;                                                                                    : SMALLCHK   \VCS  1152. MYFILESIZE 2@ DMIN >VC@ 2!                0  512 0 DO  V@ +  2 +LOOP ;                                                                                                 : BIGCHK ( - d)   0.  MYFILESIZE 2@ OR 0= IF  EXIT  THEN  \VCS     BEGIN  V@ 0 D+ >VC@ 2@ MYFILESIZE 2@ D< NOT UNTIL ;                                                                             ( Directory Listing)                                         : CHKBLK ( n - d)  0.  ROT  BLOCK                                  1024 OVER + SWAP DO  I @ 0 D+  2 +LOOP ;                                                                                     : BIGCHK2 ( - d)    0.                                             MYFILESIZE 2@ OR 0= IF  EXIT  THEN                              MYFILESIZE 2@ 1024 U/MOD  SWAP >R  DUP 1024 U* >VC@ 2!          ?DUP IF   0 DO  MYBLOCKS I + CHKBLK D+  LOOP  THEN              R> IF  BEGIN  V@ 0 D+ >VC@ 2@ MYFILESIZE 2@ D< NOT UNTIL        THEN ;                                                                                                                                                                                                                                                                                                                                                                                                                                                          ( Binary checksum)                                           : .HEX ( d)  BASE @ >R HEX  <# #S [CHAR] x HOLD  [CHAR] 0 HOLD     #> TYPE  R> BASE ! ;                                                                                                         : V1CHK ( - n)   0  512 0 DO                                          MYBLOCKS 1 + BLOCK I + 128 +  @ + LOOP ;                                                                                  : (CHK) ( PAGE )  CR  VERSION+  ARG1   .MYFILE                     ."   ID = "  14 +ATT  MYBLOCKS BLOCK 3 + 8 TYPE  -ATT           CR  ." File checksum   = "  14 +ATT  BIGCHK2 HEX  .HEX  -ATT    MYFILESIZE 2@ 1664. D< IF  EXIT  THEN                           CR  ." Kernel checksum = " 14 +ATT SMALLCHK HEX  0 .HEX  -ATT   ."       ( V1.0 " V1CHK  0 .HEX ."  ) "  CR ;                                                                                : RUNCHK   ['] BYE 'IDLE !  ['] (BLOCK) 'BLOCK ! (CHK)             UNMAP-ALL BYE ;                                                 ( Binary checksum)                                                                                                           : TARGET.COM   S" CHK.COM" ;                                    TURNKEY LOAD                                                    STARTER RUNCHK     PROGRAM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      : ASD   BEGIN  PAUSE  ['] RESTORE-DATA  CATCH 0= UNTIL ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Line 1 stops all tasks in a tidy way before reloading the       program                                                                                                                         VERSION  displays this program's version                                                                                                                                                        \MES  clears the message line and sets the cursor there                                                                         Y/N-EXIT  asks for a "Y", else exits current word                                                                               .X  displays u as a hexadecimal number.                                                                                                                                                                                                                                                                                         Useful words to display and ask for used info.                                                                                  \MES  clears the message line and sets the cursor there                                                                         .X  displays u as a hexadecimal number.                                                                                         Y/N-EXIT  asks for a "Y", else exits current word                                                                               GET-IMAGE.PNG  maps the file IMAGE.PNG to block 3000                                                                            : GET-IMAGE.PNG   BEGIN  PAUSE  ['] (GET-IMAGE.PNG) CATCH             0= UNTIL ;                                                                                                                                                                                                                                                                                                                BIOS functions                                                                                                                  DRIVE#  selects drive A ( 0 ) or B ( 1 )                        If you have, and want to use, drive B, change this to a 1 and   recompile.                                                                                                                      FLRESET  sets a BIOS flag to reset the floppy drive on the next   access                                                                                                                        FLSTATUS  return the floppy drive's status                                                                                      flread  reads two contiguous 512 byte sectors into buff           Returns 0 for success. See next block for argument details.                                                                   Useful hex display of the top three stack items :               : flread   HEX  >R  SWAP . . R> .  0  DECIMAL ;                 BIOS functions                                                                                                                  flwrite  writes two contiguous 512 byte sectors from buff         Returns 0 for success.                                                                                                        flverify  verifies two contiguous 512 byte sectors                Returns 0 for success.                                                                                                        Argument details :                                              head = 0 or 1 to select the side of the disk to access          t+s = track and sector ( track in high byte, sector in low )    buff = address of buffer to use for the data transfer           See the BIOS Int 0x13 call spec for details.                                                                                                                                                                                                                    SECTOR  returns the head, sector offset and track for the given   sector number.                                                A 1.44 MByte floppy has 80 tracks, with two heads ( top and      bottom ) and 18 x 512 byte sectors per track.                  The sectors are arranged as :                                   Cylinder 1 :   0 - 17 ( head 0 ),  1 - 35 ( head 1 )            Cylinder 2 :  36 - 53 ( head 0 ), 54 - 71 ( head 1 )            etc...                                                          Note that the sector number passed to BIOS is from 1 to 18, not  0 to 17 , hence the 1+ .                                       FLREAD  arranges the head, sector offset and track values         into the correct format for the BIOS call and makes the call.   1024 Bytes are read from sector# and sector#+1 into buff.     FLWRITE  as FLREAD , but writes from buff to the sectors.       FLVERIFY  verifies a 1024 byte block on the floppy disk.          Returns 0 for success.                                                                                                        .FL-ERR  displays the error reported by the BIOS calls.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         FL>BLK  copies one block from the floppy to "normal" disk block.                                                                BLK>FL  copies one block from a "normal" disk block to the        floppy disk.                                                                                                                  In each case the access is retried up to three times in the       event of failure. Some BIOS's fail because they do not          allow enough time for the disk to spin up. The reset and        retry corrects this.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          TSTZ  is a test word to check the basic functionality of the     BIOS calls. Edit as required.                                                                                                  #TRANSFER  holds the arguments for data transfer.                                                                               UPLOAD  copies the first 252 blocks of the floppy to CFDOS.BLK                                                                  DOWNLOAD  copies CFDOS.BLK to the first 252 blocks of the floppy                                                                UPDISK , DOWNDISK  transfer an entire floppy from/to a file     Use these from the command line.                                                                                                                                                                                                                                                                                                                                                                BINFO  edits the Block INFOrmation                              This is 256 bytes at the end of the 18K byte system binary.     The whole of block 17 is not occupied in current systems.                                                                       !BINFO  copies the Block INFOrmation to the floppy                                                                              GET-PNG  gets a PNG image from block 270 on the floppy and       copies it to file IMAGE.PNG                                     The file format created by colorForth is required, with the     variable data length at offset 93 in BigEndian format, and a    total of 118 header bytes.                                      The file size is adjusted first for whole numbers of blocks,    then the exact byte size is setup.                              The FLUSHs are to help WinXP DOS emulation work.                                                                                                                                               NV-DATA  is an array of data which is stored on disk                                                                            NVAR defines a non volatile variable                            BLOK  is the current block number ( BLK and BLOCK are already    used )  LAST-BLK hold the history of the last block displayed. DOC is true when displaying odd ( documentation ) blocks.       COLOURBLIND is true when displaying in conventional, non-colour  mode                                                           LINE# HIGHL# FIRST#hold the current line number, highlit line     and first line of the display.                                TOTAL# holds the total number of lines displayed.                                                                               THE-FILE holds the current active file name                     FILE-TYPE  holds the file type to display                                                                                                                                                                                                                       IP is the instruction pointer                                                                                                   IP@  gets the next instruction and increments the pointer        Note : pf86 uses little endian 16 bit values but has            32 bit values in big-endian order on the stack ( biggest        on top ). Hence the SWAP to convert to full 32 bit little       endian like the Pentium in 32 bit mode.                          i.e.  pf86 stores hex 12345678 in the order 34127856 .                                                                        IP0?  returns true if the opcode is 0                                                                                                                                                                                                                                                                                                                                                           GREEN    0A                                                     CYAN     0B                                                     RED      0C                                                     MAGENTA  0D                                                     YELLOW   0E                                                     WHITE    0F                                                     DK-GREEN 02                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ( block display - Huffman decoding )  HEX                    CODE DLSHIFT ( d - d' )   0 # 0 MOV  0 ROL   2 POP  0 POP          0 SHL  2 RCL   0 PUSH   2 PUSH  NEXT                         : DLSHIFTS ( d n - d' )  0 DO  DLSHIFT  LOOP ;                  CODE DLROTATE ( d - d' )  0 # 0 MOV 0 ROL 1 POP  0 POP  1 2 MOV    0 RCL  1 RCL  2 2 OR 0< IF  1 # 0 OR  THEN   0 PUSH   1 PUSH    NEXT                                                         : DLROTATES ( d n - d' )   0 DO  DLROTATE LOOP ;                : K ( d  - d' )  HEX  DLROTATE 2DUP U. U.  ;                    5550000B. 2CONSTANT TOK                                         CREATE HUFFMAN0                                  ASCII " STRING  rtoeani"                                                       CREATE HUFFMAN1                                  ASCII " STRING smcylgfw"                                                       CREATE HUFFMAN2                                  ASCII " STRING dvpbhxuq0123456789j-k.z/;:!+@*,?"                                                                                               LROTATE1  cyclicly rotates a 32 bit number one bit to the left    00000001. LROTATE1 0000002. , 80000000. LROTATE1 00000001.                                                                    LROTATE  cyclicly rotates a 32 bit numbbits to the left                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ( block display - Huffman decoding )  HEX                    : .HF0   2DUP  3 DLROTATES  OVER 7 AND  HUFFMAN0 1+ + C@ EMIT      2DROP  3 DLSHIFTS ;                                          : .HF1   2DUP  3 DLROTATES  OVER 7 AND  HUFFMAN1 1+ + C@ EMIT      2DROP  3 DLSHIFTS ;                                          : .HF2   2DUP  5 DLROTATES  OVER 0F AND  HUFFMAN2 1+ + C@ EMIT     2DROP  5 DLSHIFTS ;                                                                                      DUP 8000 AND 0= IF  DLSHIFT .HF0  EXIT  THEN  DLSHIFT           DUP 8000 AND 0= IF  DLSHIFT .HF1  EXIT  THEN  DLSHIFT           DUP 8000 AND 0= IF  DLSHIFT .HF2  EXIT  THEN  ;                                                                              : .HUF ( d )   SWAP  FFF0 AND  SWAP                                BEGIN  .HF  2DUP OR 0= UNTIL  .HF  2DROP ;                                          : .SPACE ATTRIBUTE @ 0F ATTRIBUTE ! SPACE ATTRIBUTE ! ;                                                                         EXIT    ( block display )                                       : CFSHOW ( tok -- )                                                OVER  15 AND  DUP >R  COLOUR  >R                                R@ 3 = IF ( red )   CR  COLOURBLIND @ IF  ." : "  THEN  THEN    R@ 0= IF  -1 +CP  THEN  \  R@ ." >>" . ." <<"                   R> R@ SWAP >R 5 = IF  2DROP  ELSE                                  R@ 5 = IF  D.HEX  ELSE                                             R@ 6 = R@ 8 = OR  R@ 2 = OR                                        IF  .NUM  ELSE  .HUF  THEN  THEN  THEN                 R@ 12 = IF ( Magenta variable ) IP@ D.HEX  THEN                 2R> 2DROP ;                                                                                                                                                                                                                                                                                                                                                                                     ( block display - Huffman decoding )  HEX                    : .HF0   2DUP  3 DLROTATES  OVER 7 AND  HUFFMAN0 1+ + C@ EMIT      2DROP  3 DLSHIFTS ;                                          : .HF1   2DUP  3 DLROTATES  OVER 7 AND  HUFFMAN1 1+ + C@ EMIT      2DROP  3 DLSHIFTS ;                                          : .HF2   2DUP  5 DLROTATES  OVER 0F AND  HUFFMAN2 1+ + C@ EMIT     2DROP  5 DLSHIFTS ;                                                                                      DUP 8000 AND 0= IF  DLSHIFT .HF0  EXIT  THEN  DLSHIFT           DUP 8000 AND 0= IF  DLSHIFT .HF1  EXIT  THEN  DLSHIFT           DUP 8000 AND 0= IF  DLSHIFT .HF2  EXIT  THEN  ;                                                                              : .HUF ( d )   SWAP  FFF0 AND  SWAP                                BEGIN  .HF  2DUP OR 0= UNTIL  .HF  2DROP ;                                                                                                                                                                             ( block display - Huffman decoding )  HEX                    : .HF0   2DUP  3 DLROTATES  OVER 7 AND  HUFFMAN0 1+ + C@ EMIT      2DROP  3 DLSHIFTS ;                                          : .HF1   2DUP  3 DLROTATES  OVER 7 AND  HUFFMAN1 1+ + C@ EMIT      2DROP  3 DLSHIFTS ;                                          : .HF2   2DUP  5 DLROTATES  OVER 0F AND  HUFFMAN2 1+ + C@ EMIT     2DROP  5 DLSHIFTS ;                                                                                      DUP 8000 AND 0= IF  DLSHIFT .HF0  EXIT  THEN  DLSHIFT           DUP 8000 AND 0= IF  DLSHIFT .HF1  EXIT  THEN  DLSHIFT           DUP 8000 AND 0= IF  DLSHIFT .HF2  EXIT  THEN  ;                                                                              : .HUF ( d )   SWAP  FFF0 AND  SWAP                                BEGIN  .HF  2DUP OR 0= UNTIL  .HF  2DROP ;                                                                                                                                                                          EXIT    ( block display )                                       : CFSHOW ( tok -- )                                                OVER  15 AND  DUP >R  COLOUR  >R                                R@ 3 = IF ( red )   CR  COLOURBLIND @ IF  ." : "  THEN  THEN    R@ 0= IF  -1 +CP  THEN  \  R@ ." >>" . ." <<"                   R> R@ SWAP >R 5 = IF  2DROP  ELSE                                  R@ 5 = IF  D.HEX  ELSE                                             R@ 6 = R@ 8 = OR  R@ 2 = OR                                        IF  .NUM  ELSE  .HUF  THEN  THEN  THEN                 R@ 12 = IF ( Magenta variable ) IP@ D.HEX  THEN                 2R> 2DROP ;                                                                                                                                                                                                                                                                                                                                                                                                                                                  LROTATE1  cyclicly rotates a 32 bit number one bit to the left    00000001. LROTATE1 0000002. , 80000000. LROTATE1 00000001.                                                                    LROTATE  cyclicly rotates a 32 bit number u bits to the left                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    LST  displays block n as colorForth source ( like LIST )                                                                        DUP 643 FL>BLK  643 BLOCK  CFLIST  15 ATTRIBUTE !                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               .ATTRIBUTES  is passed a directory entry address and prints the    file attributes from it.  These are:                            R = read only  H = hidden  S = system  D = directory            A = archive                                                  .Date displays the date a file was last altered.                .HEADING  displays the heading at the top of the page.          +CR  prints a carriage return.  If at the bottom of the screen,    waits for the user to respond with a 'Y' or 'y'.             .FILE  displays a single line of information on a file.                                                                         DIR <name>  displays a directory of <name> on the screen.          Note that if you want a directory of a subdirectory,            use  DIR <name>\ .                                                                                                           DIR  typed on its own returns the text of the current directory.                                                                                                                                DATA-BLOCK  assigns a block to hold non-volatile data                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           MONTH converts month to days from Jan 1. It does not deal with   leap years.                                                                                                                    D.M.Y  converts day month and year to days from 1900 Jan 1       including leap years                                                                                                           Filedata calculates the file's creation date from the info in    the DOS header                                                                                                                 Filetime : ditto the time.                                                                                                                                                                                                                                                                                                                                                                      This a simple example of how to use DOS from FORTH.  A file        is opened and read, displaying it on the terminal.  After,      the file is closed.                                          #PAD  returns the number of bytes free at  PAD .                GETS  is passed a buffer address, a file handle, an a count of     characters to read.  It reads the file, and returns the         number of characters actually read.  This number is zero if     the end of the file has been reached.                        PUTS  is the converse of  GETS .  It writes a number of            characters into a file.                                      SHOW  takes a filename from the input stream and opens it for      reading only.  It then repeatedly calls DOS to get each         buffer full and display it until the end of the file.           512 bytes are used at  PAD  for this purpose.                FCOPY  copies one file to another in  #PAD  sized chunks.                                                                                                                                                                                                       : .Z  ." >VC@, >VC! : "  >VC@ 2@ D.  >VC! 2@ D. ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               FILEHDR  holds the currently selected file header info          This is the DOS file header.                                                                                                    FILEINFO holds the currently selected file "block 17.75" info   This is the file info that is added to describe the file.       it resides in the last 256 bytes ( 4 x 64 byte lines )          of block 17,.                                                                                                                   FILENAME holds the currently selected file name                                                                                 .NAME  displays the file name                                                                                                   .SIZE  displays the file size                                                                                                                                                                                                                                   .FILE+  shows file info and highlights the selected file.        It also copies the selected file's info into the info array.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   .FILE  displays detailed file information                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       .FILE+  shows file info and highlights the selected file.        It also copies the selected file's info into the info array.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   .INFO  displays four lines of file information                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  (DIR) displays some of the file list available for selection                                                                    DIR  displays some of the file list and full info on the         selected file.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 DOWN  displays the next file down the list                                                                                      UP  displays the next file up the list                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          MAP-THE-FILE  maps the selected file to block 2400                                                                              COPY-SELECTED  copies the selected file name into THE-FILE and   maps it to block 2100                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          (SELECT) defines the key actions for SELECT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     SELECT allows the user to select the file to use for data       transfers.                                                                                                                                                                                                                                                      .VALS  displays values for testing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             *DIGIT accumulates digit n into d                                                                                               CONVERT  converts a string to binary, leaving the address of the   first un-convertable digit and length of the remainder.                                                                      MYNUMBER  converts the string at a-1 to a single number                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         NUM-PAD  holds the number string to convert                                                                                     (ENTER-BLOK) asks for a block number                                                                                            ENTER-BLOK  handles an invalid string.                                                                                          OTHER-BLOK  returns to the previously displayed block                                                                           BLOK-UNDO  restores the currently viewed block to its saved       state.                                                                                                                                                                                                                                                                                                                                                                                                                                                        (RUN1)  defines some of the key actions for RUN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 (RUN2)  defines the rest of the key actions for RUN                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             (RUN)  defines the key actions for RUN                                                                                          MAP-THE-FILE+ handles file access errors                                                                                        RUN  runs the CFDOS program                                                                                                     The turnkey CFDOS.com is created.                                                                                               The text in CFDOS.cfg is copied to the end of CFDOS.com.        This avoids having two files ( .com and .cfg ) to deal with.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    ARG1  gets argument 1 from the DOS input stream, else uses        a default filename                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            : .Z  ." >VC@, >VC! : "  >VC@ 2@ D.  >VC! 2@ D. ;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               .FILE+  shows file info and highlights the selected file.        It also copies the selected file's info into the info array.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   