fl : disp_cluster \ display first sector of cluster number 0 tmp W! ." Input Cluster Number(hex) > " begin key dup 30 < if d = if tmp W@ 0> if 1 else 0 then else 0 then else dup 3a 40 between if drop 0 else dup 47 60 between if drop 0 else dup 66 > if drop 0 else dup emit tmp W@ 4 = if 5 0 do drop loop 0 tmp W! ." incorect input" cr ." Input Cluster Number(hex) > " 0 else todigit tmp dup W@ 1+ swap W! 0 then then then then then until cr tmp W@ 1 > if tmp W@ 1- 0 do swap i 1+ 4 * lshift or loop then \ convert data dup 2 < if ." start cluster is from 2. Display Cluster 0x2 instead of 0x" dup . cr cr 2 then ." Cluster:0x" dup . ." Sector:0x" cluster_to_sector dup . ." Address:0x" byte/sector W@ * dup . cr cr sdhc W@ if ccs W@ if byte/sector W@ u/ then then Block ; \ (n1 -- n2 ) n1 = sector offset from FAT-start n2 = address(SDSC & SDHC[scc=0]) or sector(SDHC[scc=1]) : target_FAT_read first_sector L@ + reserve_sector W@ + sdhc W@ 0= if 200 * then ; : cluster_chain \ display cluster-chain for sdsc (cluster-number -- ) dup . begin sdhc W@ if 4 * dup else 2 * dup then \ get offset from FAT start address byte/sector W@ u/ dup \ get offset sector from FAT target_FAT_read block_read 200 * - \ get offset from target sector sdhc W@ if sd_buf W@ + L@ dup dup fffffff and fffffff = if 2drop 1 else . 0 then else sd_buf W@ + W@ dup dup ffff = if 2drop 1 else . 0 then then until ; : prev_sector \ get previous sector value sdhc W@ if ccs W@ 0 = if 200 * then else byte/sector W@ * then ; \ display characters inside LFN's entry : disp_char \ ( RED-entry-address charcter-number offset -- ) rot + swap 0 do dup C@ dup ff < if emit else drop then 2+ loop drop ; : longname \ ( RDE-entry-address -- ) display LFN begin 20 - dup sd_buf W@ < if tmp W@ 2- prev_sector RDE_addr L@ + block_read drop sd_buf W@ 1e0 + then \ read out previous sector dup 5 1 disp_char dup 6 e disp_char dup 2 1c disp_char dup C@ 40 and 40 = until drop tmp W@ 1- prev_sector RDE_addr L@ + block_read \ read original-sector ; : file_detail \ (RDE-entry-address on sd_buf -- ) dup dup \ DIR_Name ." Name " c + C@ 8 and 0= if 8 bounds do i C@ dup 20 = if drop else emit then loop \ upper else 8 bounds do i C@ dup 20 = if drop else 20 or emit then loop \ lower then ." ." dup dup 8 + swap c + C@ 10 and 0= if 3 bounds do i C@ dup 20 = if drop else emit then loop \ upper else 3 bounds do i C@ dup 20 = if drop else 20 or emit then loop \ lower then dup 6 + C@ 7e = if cr ." LFN: " dup longname then cr cr dup b + \ get attribute's address \ DIR_Attr ." Attribute " C@ dup 1 and 1 = if ." READ_ONLY " then dup 2 and 2 = if ." HIDDEN " then dup 4 and 4 = if ." SYSTEM " then dup 8 and 8 = if ." VOLUME_ID " then dup 10 and 10 = if ." DIRECTORY " then dup 20 and 20 = if ." ARCHIVE " then cr cr ." Type " 10 and 10 = if ." Directory" else ." File" then cr cr \ DIR_CrtTime ." Create Time " dup e + W@ dup f800 and b rshift dup 0= if ." 00" drop else dup a < if ." 0" then to_decimal then ." :" dup 7e0 and 5 rshift dup 0= if ." 00" drop else dup a < if ." 0" then to_decimal then ." :" dup d + C@ 63 > if 1 else 0 then swap 1f and 2 * + dup 0= if ." 00" drop else dup a < if ." 0" then to_decimal then ." ." dup d + C@ dup 63 > if 64 - then to_decimal cr cr \ DIR_CtrDate ." Create date " dup 10 + W@ dup fe00 and 9 rshift 7bc + to_decimal ." /" dup 1e0 and 5 rshift to_decimal ." /" 1f and dup 0= if ." 00" drop else to_decimal then cr cr \ DIR_LastAccDate ." Last Access Date " dup 12 + W@ dup fe00 and 9 rshift 7bc + to_decimal ." /" dup 1e0 and 5 rshift to_decimal ." /" 1f and dup 0= if ." 00" drop else to_decimal then cr cr \ DIR_WrtTime ." Update Write time " dup 16 + W@ dup f800 and b rshift dup 0= if ." 00" drop else dup a < if ." 0" then to_decimal then ." :" dup 7e0 and 5 rshift dup 0= if ." 00" drop else dup a < if ." 0" then to_decimal then ." :" 1f and 2 * dup 0= if ." 00" drop else dup a < if ." 0" then to_decimal then cr cr \ DIR_WrtDate ." Update Write date " dup 18 + W@ dup fe00 and 9 rshift 7bc + to_decimal ." /" dup 1e0 and 5 rshift to_decimal ." /" 1f and dup 0= if ." 00" drop else to_decimal then cr cr \ DIR_FileSize ." File Size " dup 1c + L@ conversion cr cr \ DIR_FileSize \ DIR_FirstCluster ." Cluster chain(hex) " 1a + W@ dup 0> if cluster_chain else drop then cr cr ; : next_sector \ get next sector value sdhc W@ if ccs W@ 0 = if 200 * then else byte/sector W@ * then ; : search \ search file's line number RDE_addr L@ block_read 1 tmp W! \ tmp1 \ input line number sd_buf W@ begin dup C@ e5 = if 20 + dup sd_buf W@ 1ff + > if drop tmp W@ next_sector RDE_addr L@ + \ byte/sector W@ * RDE_addr L@ + block_read tmp dup W@ 1+ swap W! sd_buf W@ then 0 else dup b + C@ f <> if tmp1 W@ 1 = if file_detail 1 else tmp1 dup W@ 1- swap W! 20 + dup sd_buf W@ 1ff + > if \ drop tmp W@ byte/sector W@ * RDE_addr L@ + drop tmp W@ next_sector RDE_addr L@ + block_read tmp dup W@ 1+ swap W! sd_buf W@ then 0 then else 20 + dup sd_buf W@ 1ff + > if \ drop tmp W@ \ byte/sector W@ * RDE_addr L@ + drop tmp W@ next_sector RDE_addr L@ + block_read tmp dup W@ 1+ swap W! sd_buf W@ then 0 then then until ; : file \ display file-list RDE_addr L@ block_read 1 tmp W! \ line number 1 tmp1 W! sd_buf W@ begin dup C@ e5 = if 20 + dup sd_buf W@ 1ff + > if drop tmp1 W@ next_sector RDE_addr L@ + \ byte/sector W@ * RDE_addr L@ + block_read tmp1 dup W@ 1+ swap W! sd_buf W@ then 0 else dup C@ 0= if 1 else dup b + C@ f <> if tmp dup W@ dup to_decimal ." " 1+ swap W! dup file_name cr then 20 + dup sd_buf W@ 1ff + > if \ drop tmp1 W@ \ byte/sector W@ * RDE_addr L@ + drop tmp1 W@ next_sector RDE_addr L@ + block_read tmp1 dup W@ 1+ swap W! sd_buf W@ then 0 then then until drop \ tmp is input line_number+1 if 1, then no file tmp W@ dup 1 > if cr ." Input file number > " 0 tmp1 W! begin dup begin key dup 30 < if d = if tmp1 W@ 0> if 1 else ." Input file number > " 0 then else 0 then else dup 39 > if drop 0 else dup emit tmp1 W@ 2 = if 3 0 do drop loop 0 tmp1 W! ." incorect input" cr ." Input file number > " 0 else todigit tmp1 dup W@ 1+ swap W! 0 then then then until tmp1 W@ 2 = if swap a * + then dup tmp1 W! > if tmp1 W@ 0= if ." zero is NG!!" cr ." Input file number > " 0 tmp1 W! 0 else drop 1 then else ." not match" cr ." Input file number > " 0 tmp1 W! 0 then until cr cr search else ." no file" cr drop then ;