📄 hpi32.lst
字号:
681 1 if((len%32)!=0)
682 1 return FALSE;
683 1 if((len+32)>DeviceInfo.BPB_BytesPerSec)
684 1 return FALSE;
685 1
686 1 ThisFile.bFileOpen=0;
687 1 ThisFile.FatSectorPointer=0;
688 1
689 1 cnum=GetFreeCusterNum32();
690 1 if(cnum<0x02)
691 1 return FALSE;
692 1
693 1 pBuffer[11]=0x10;
694 1 pBuffer[21]=(unsigned char)(cnum>>24);
695 1 pBuffer[20]=(unsigned char)(cnum>>16);
696 1 pBuffer[27]=(unsigned char)(cnum>>8);
697 1 pBuffer[26]=(unsigned char)(cnum);
698 1 pBuffer[28]=0;pBuffer[29]=0;pBuffer[30]=0;pBuffer[31]=0;
699 1 bstop=0;
700 1
701 1 NowCluster32=DirStartCluster32;
702 1 do
703 1 {
704 2 NowSector=FirstSectorofCluster32(NowCluster32);
705 2 ClusterPointer=NowCluster32;
706 2 for(sector=0;sector<DeviceInfo.BPB_SecPerClus;sector++)
707 2 {
708 3 if(!SdReadSector(NowSector+sector,1,DBUF))
709 3 return FALSE;
710 3 DirCount=0;bwrite=0;
711 3 for(i=0;i<DeviceInfo.BPB_BytesPerSec;i=i+32)
712 3 {
713 4 if(len==0)
714 4 {
715 5 if((DBUF[i]==0x00)||(DBUF[i]==0xE5))
716 5 {
717 6 for(j=0;j<32;j++)
718 6 DBUF[i+j]=*(pBuffer+j);
719 6 if(!SdWriteSector(NowSector+sector,1,DBUF))
720 6 return FALSE;
721 6 bstop=1;
722 6 break;
723 6 }
724 5 }
725 4 else
726 4 {
727 5 if(DirCount==0)
728 5 InByte=i;
729 5 if(DBUF[i]==0xE5)
730 5 DirCount++;
731 5 else if(DBUF[i]==0x00)
732 5 {
733 6 DirCount++;
734 6 DBUF[i]=0xE5;
735 6 bwrite=1;
736 6 }
737 5 else
C51 COMPILER V7.00 HPI32 02/15/2008 12:14:59 PAGE 13
738 5 DirCount=0;
739 5
740 5 if((DirCount*32)>=(len+32))
741 5 {
742 6 for(j=0;j<len;j++)
743 6 DBUF[InByte+j]=*(pName+j);
744 6 for(j=0;j<32;j++)
745 6 DBUF[InByte+len+j]=*(pBuffer+j);
746 6 if(!SdWriteSector(NowSector+sector,1,DBUF))
747 6 return FALSE;
748 6 bstop=1;
749 6 break;
750 6 }
751 5 }
752 4 }
753 3 if(bstop==1)break;
754 3 if((len!=0)&&(bwrite==1))
755 3 {
756 4 if(!SdWriteSector(NowSector+sector,1,DBUF))
757 4 return FALSE;
758 4 }
759 3 }
760 2 if(bstop==1)break;
761 2
762 2 NowCluster32=GetNextClusterNum32(NowCluster32);
763 2 if(NowCluster32>DeviceInfo.TotCluster)
764 2 {
765 3 NowCluster32=CreateClusterLink32(ClusterPointer);
766 3 if(NowCluster32==0x00)
767 3 return FALSE;
768 3 NowSector=FirstSectorofCluster32(NowCluster32);
769 3 for(i=0;i<DeviceInfo.BPB_BytesPerSec;i++) DBUF[i]=0x00;
770 3 for(sector=0;sector<DeviceInfo.BPB_SecPerClus;sector++)
771 3 {
772 4 if(!SdWriteSector(NowSector+sector,1,DBUF))
773 4 return FALSE;
774 4 }
775 3 }
776 2 }while(NowCluster32<=DeviceInfo.TotCluster);
777 1
778 1 if(NowCluster32>DeviceInfo.TotCluster)
779 1 return FALSE;
780 1 ////////////////////////////////////////////////////////////////
781 1 for(i=64;i<DeviceInfo.BPB_BytesPerSec;i++) DBUF[i]=0x00;
782 1
783 1 for(i=0;i<43;i++) DBUF[i]=0x20;
784 1
785 1 DBUF[0]=0x2e;
786 1 for(i=11;i<32;i++) DBUF[i]=pBuffer[i];
787 1
788 1 DBUF[32]=0x2e;DBUF[33]=0x2e;
789 1 for(i=43;i<64;i++) DBUF[i]=pBuffer[i-32];
790 1
791 1 if(DirStartCluster32==DeviceInfo.RootStartCluster) //Root Dir
792 1 {
793 2 DBUF[53]=0;DBUF[52]=0;DBUF[59]=0;DBUF[58]=0;
794 2 }
795 1 else
796 1 {
797 2 DBUF[53]=(unsigned char)(DirStartCluster32>>24);
798 2 DBUF[52]=(unsigned char)(DirStartCluster32>>16);
799 2 DBUF[59]=(unsigned char)(DirStartCluster32>>8);
C51 COMPILER V7.00 HPI32 02/15/2008 12:14:59 PAGE 14
800 2 DBUF[58]=(unsigned char)(DirStartCluster32);
801 2 }
802 1
803 1 NowSector=FirstSectorofCluster32(cnum);
804 1 if(!SdWriteSector(NowSector,1,DBUF))
805 1 return FALSE;
806 1
807 1 DirStartCluster32=cnum;
808 1 // ThisFile.ClusterPointer=DirStartCluster32;
809 1 ThisFile.ClusterPointer=0;
810 1 return TRUE;
811 1 }
812
813 unsigned char DownDir32(unsigned char *pBuffer)
814 {
815 1 unsigned int i;
816 1 unsigned char j,bstop,sector;
817 1
818 1 if(!bFlags.bits.SLAVE_IS_ATTACHED)
819 1 return FALSE;
820 1
821 1 ThisFile.bFileOpen=0;
822 1 bstop=0;
823 1
824 1 NowCluster32=DirStartCluster32;
825 1 do
826 1 {
827 2 NowSector=FirstSectorofCluster32(NowCluster32);
828 2 for(sector=0;sector<DeviceInfo.BPB_SecPerClus;sector++)
829 2 {
830 3 if(!SdReadSector(NowSector+sector,1,DBUF))
831 3 return FALSE;
832 3 for(i=0;i<DeviceInfo.BPB_BytesPerSec;i=i+32)
833 3 {
834 4 if(DBUF[i]==0x00)
835 4 return FALSE;
836 4 j=0;
837 4 while(DBUF[i+j]==*(pBuffer+j))
838 4 {
839 5 j=j+1;
840 5 if(j>10)
841 5 break;
842 5 }
843 4 if(j>10&&(DBUF[i+11]&0x10))
844 4 {bstop=1;break;}
845 4 }
846 3 if(bstop==1)break;
847 3 }
848 2 if(bstop==1)break;
849 2 NowCluster32=GetNextClusterNum32(NowCluster32);
850 2 }while(NowCluster32<=DeviceInfo.TotCluster);
851 1
852 1 if(NowCluster32>DeviceInfo.TotCluster)
853 1 return FALSE;
854 1
855 1 DirStartCluster32=LSwapINT32(DBUF[i+26],DBUF[i+27],DBUF[i+20],DBUF[i+21]);
856 1 // ThisFile.ClusterPointer=DirStartCluster32;
857 1 ThisFile.ClusterPointer=0;
858 1 return TRUE;
859 1 }
860
861 unsigned char UpDir32()
C51 COMPILER V7.00 HPI32 02/15/2008 12:14:59 PAGE 15
862 {
863 1 if(!bFlags.bits.SLAVE_IS_ATTACHED)
864 1 return FALSE;
865 1 if(DirStartCluster32==DeviceInfo.RootStartCluster) //Root Dir
866 1 return TRUE;
867 1
868 1 ThisFile.bFileOpen=0;
869 1
870 1 NowSector=FirstSectorofCluster32(DirStartCluster32);
871 1 if(!SdReadSector(NowSector,1,DBUF))
872 1 return FALSE;
873 1 if(DBUF[32]!=0x2e&&DBUF[33]!=0x2e) //..
874 1 return FALSE;
875 1
876 1 DirStartCluster32=LSwapINT32(DBUF[58],DBUF[59],DBUF[52],DBUF[53]);
877 1 if(DirStartCluster32==0) //Root Dir
878 1 DirStartCluster32=DeviceInfo.RootStartCluster;
879 1 // ThisFile.ClusterPointer=DirStartCluster32;
880 1 ThisFile.ClusterPointer=0;
881 1 return TRUE;
882 1 }
883
884 unsigned char UpRootDir32()
885 {
886 1 if(!bFlags.bits.SLAVE_IS_ATTACHED)
887 1 return FALSE;
888 1
889 1 ThisFile.bFileOpen=0;
890 1 DirStartCluster32=DeviceInfo.RootStartCluster; //Root Dir
891 1
892 1 return TRUE;
893 1 }
894
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 8673 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = 8 8
PDATA SIZE = ---- ----
DATA SIZE = ---- 136
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -