Skip to content

Commit

Permalink
Updated the OSDK with the latest code of most of the tools.
Browse files Browse the repository at this point in the history
git-svn-id: http://miniserve.defence-force.org/svn/public/pc/tools/osdk/main@406 402f7f93-8821-40e0-b67c-5e0c390054f3
  • Loading branch information
dbug committed Sep 20, 2010
1 parent 7128b88 commit bac096f
Show file tree
Hide file tree
Showing 39 changed files with 1,814 additions and 1,312 deletions.
2 changes: 1 addition & 1 deletion MemMap/MemMap.vcproj
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
Filter="h;hpp;hxx;hm;inl"
>
<File
RelativePath="..\filepack\includes\infos.h"
RelativePath=".\includes\infos.h"
>
</File>
</Filter>
Expand Down
2 changes: 1 addition & 1 deletion MemMap/includes/infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@


#define TOOL_VERSION_MAJOR 0
#define TOOL_VERSION_MINOR 1
#define TOOL_VERSION_MINOR 2

14 changes: 13 additions & 1 deletion MemMap/sources/memmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,27 @@ int main(int argc,char *argv[])
"Author:\r\n"
" Pointier Mickael\r\n"
"\r\n"
"Switches:\r\n"
" -f Format\r\n"
" -f0 => XA (Oric) [default]\r\n"
" -f1 => Devpac (Atari ST)\r\n"
"\r\n"
);


INPUT_FORMAT inputFormat=INPUT_FORMAT_ATARI_DEVPAC; // 0=XA / 1=Devpac
INPUT_FORMAT inputFormat=INPUT_FORMAT_ORIC_XA; // 0=XA / 1=Devpac

ArgumentParser cArgumentParser(argc,argv);

while (cArgumentParser.ProcessNextArgument())
{
if (cArgumentParser.IsSwitch("-f"))
{
//format: [-f]
// 0 => XA (Oric)
// 1 => Devpac (Atari)
inputFormat=(INPUT_FORMAT)cArgumentParser.GetIntegerValue(INPUT_FORMAT_ORIC_XA);
}
}


Expand Down
3 changes: 3 additions & 0 deletions Osdk/_final_/documentation/doc_assembler.htm
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,9 @@ <h3> Preprocessor </h3>
<p>Here is the list of all releases with a short description of things that changed:
</p>

<p id=dateentry>2.2.1</p>
- hopefully fixed a problem of data corruption happening when a line parsed during pass1 generated more than 127 bytes of tokens for the pass2 to decode.

<p id=dateentry>2.1.7</p>
- removed the '-x' switch from XA code. I will progressively remove all the legacy stuff when replacement features already exist, in this case -o, -e and -l

Expand Down
1 change: 1 addition & 0 deletions common/includes/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ std::string get_string(const char *&ptr_arg);
//
bool LoadFile(const char* pcFileName,void* &pcBuffer,size_t &cBufferSize);
bool SaveFile(const char* pcFileName,const void* pcBuffer,size_t cBufferSize);
bool DeleteFile(const char* pcFileName);

bool LoadText(const char* pcFileName,std::vector<std::string>& cTextData);

Expand Down
5 changes: 5 additions & 0 deletions common/sources/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ bool SaveFile(const char* pcFileName,const void* pcBuffer,size_t cBufferSize)
return true;
}

bool DeleteFile(const char* pcFileName)
{
return _unlink(pcFileName);
}


/**
* Transforms a raw ascii buffer (0 terminated)
Expand Down
9 changes: 8 additions & 1 deletion filepack/sources/filepack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

long LZ77_Compress(void *buf_src,void *buf_dest,long size_buf_src);
void LZ77_UnCompress(void *buf_src,void *buf_dest,long size);
long LZ77_ComputeDelta(void *buf_comp,long size_uncomp,long size_comp);
long LZ77_ComputeDelta(unsigned char *buf_comp,long size_uncomp,long size_comp);

extern unsigned char gLZ77_XorMask;

Expand Down Expand Up @@ -165,6 +165,13 @@ void main(int argc,char *argv[])
printf("\n");
exit(1);
}

// Compute delta
//long LZ77_ComputeDelta(unsigned char *buf_comp,long size_uncomp,long size_comp)
int delta=LZ77_ComputeDelta(ptr_buffer_dst,size_buffer_src,size_buffer_dst);
printf("\nDelta value: %d",delta);


//
// Create file header
//
Expand Down
78 changes: 77 additions & 1 deletion filepack/sources/lz_pack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,9 +390,84 @@ void LZ77_UnCompress(void* buf_src_void,void* buf_dest_void, long size)
}


long LZ77_ComputeDelta(unsigned char *buf_comp,long size_uncomp,long size_comp)
{
unsigned char *buf_src =(unsigned char*)buf_comp;
unsigned char *buf_dest=(unsigned char*)buf_comp+size_comp-size_uncomp;

unsigned char value;
unsigned char andvalue;
long offset,nb;

long LZ77_ComputeDelta(unsigned char *buf_comp,long size_uncomp,long size_comp)
long max_delta_space;

max_delta_space=0;
andvalue=0;
while (size_uncomp>0)
{
//
// Reload encoding type mask
//
if (!andvalue)
{
andvalue=1;
value=(*buf_src++);
}
if ((value^gLZ77_XorMask) & andvalue)
{
//
// Copy 1 unsigned char
//
//*buf_dest++=*buf_src++;
if (buf_dest>=buf_src)
{
max_delta_space=max(max_delta_space,buf_dest-buf_src);
}
buf_dest++;
buf_src++;

size_uncomp--;
}
else
{
//
// Copy with offset
//
// At this point, the source pointer points to a two byte
// value that actually contains a 4 bits counter, and a
// 12 bit offset to point back into the depacked stream.
// The counter is in the 4 high order bits.
//
offset = buf_src[0]; // Read 16 bits non alligned datas...
offset|=(buf_src[1]&0x0F)<<8;
offset+=1;

nb =(buf_src[1]>>4)+3;

buf_src+=2;

size_uncomp-=nb;
while (nb>0)
{
//*buf_dest++=*(buf_dest-offset);
if (buf_dest>=buf_src)
{
max_delta_space=max(max_delta_space,buf_dest-buf_src);
}
buf_dest++;

nb--;
}
}
andvalue<<=1;
}
return max_delta_space;
}




long LZ77_ComputeDeltaOld(unsigned char *buf_comp,long size_uncomp,long size_comp)
{
unsigned char value;
unsigned char andvalue;
Expand Down Expand Up @@ -458,3 +533,4 @@ long LZ77_ComputeDelta(unsigned char *buf_comp,long size_uncomp,long size_comp)
}



2 changes: 1 addition & 1 deletion link65/includes/infos.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@


#define TOOL_VERSION_MAJOR 0
#define TOOL_VERSION_MINOR 62
#define TOOL_VERSION_MINOR 63
115 changes: 106 additions & 9 deletions link65/sources/Link65.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,20 @@ List of modifications:
Originaly created by Vagelis Blathras
2003-05-27 [Mike] Handling of lines that have more than 180 characters
2009-02-14 [Mike] Version 0.63
(WIP) The old linked filtered out comments, need to implement this feature as well
Fixed a number of issues in the linker:
- removed some test code
- fixed the loading of symbols from the library index file
Fixed a problem of text file parsings. Mixed unix/dos cariage return would result in very long lines (containing many lines), leading to some crashes later on.
Also fixed a problem in reporting the parsed files.
2003-05-27 [Mike] Handling of lines that have more than 180 characters
2003-09-13 [Mike] Version 0.59
Corrected a bug that made it impossible to "link" only one source file
2003-09-13 [Mike] Version 0.57
Added '-B' option to suppress inclusion of HEADER and TAIL
Expand Down Expand Up @@ -80,9 +93,9 @@ class FileEntry_c
};


bool gFlagKeepComments=false; // Use -C option to control
bool gFlagIncludeHeader=true; // Use -B option to force to 0
bool gFlagEnableFileDirective=false; // Use -F option to enable (force to one)
bool gFlagInCommentBloc=false; // Used by the parser to know that we are currently parsing a bloc of comments
bool gFlagVerbose=false; // Use -V option to enable
bool gFlagQuiet=false; // Use -Q option to enable (note: seems to work the other way arround !)
bool gFlagLibrarian=false; // Use -L option to enable
Expand All @@ -107,17 +120,83 @@ bool ParseFile(const char* filename);



std::string FilterLine(const std::string& cSourceLine)
{
static bool flag_in_comment_bloc=false; // Used by the parser to know that we are currently parsing a bloc of comments

std::string outline;
outline.reserve(MAX_LINE_SIZE);

const char* source_line=cSourceLine.c_str();
while (char car=*source_line++)
{
if (flag_in_comment_bloc) // In a C block comment - that one may have been started on another line
{
if ( (car=='*') && (*source_line=='/') )
{
// Found end of C block comment
source_line++;
flag_in_comment_bloc=false;
}
}
else
{
if (car=='\"')
{
// Found start of quoted string
do
{
outline+=car;
car=*source_line++;
}
while (car && (car!='\"'));
if (car)
{
outline+=car;
}
}
else
if (car==';')
{
// Found start of assembler line comment - just stop here
return outline;
}
else
if ( (car=='/') && (*source_line=='*') )
{
// Found start of C block comment
source_line++;
flag_in_comment_bloc=true;
}
else
if ( (car=='/') && (*source_line=='/') )
{
// Found start of C++ line comment - just stop here
return outline;
}
else
{
// Any other character
outline+=car;
}
}
}
return outline;
}

#if 0
std::string FilterLine(const std::string& cSourceLine)
{
static bool flag_in_comment_bloc=false; // Used by the parser to know that we are currently parsing a bloc of comments

char inpline[MAX_LINE_SIZE+1];
assert(sizeof(inpline)>cSourceLine.size());
strcpy(inpline,cSourceLine.c_str());

//
// Checking for a end of C bloc comment
//
if (gFlagInCommentBloc)
if (flag_in_comment_bloc)
{
char *ptr_line=strstr(inpline,"*/");
if (ptr_line)
Expand All @@ -127,7 +206,7 @@ std::string FilterLine(const std::string& cSourceLine)
//
*ptr_line=0;
strcpy(inpline+2,ptr_line);
gFlagInCommentBloc=false;
flag_in_comment_bloc=false;
}
else
{
Expand Down Expand Up @@ -161,21 +240,21 @@ std::string FilterLine(const std::string& cSourceLine)
}

//
// Checking for a begining of C bloc comment
// Checking for a beginning of C bloc comment
//
if (!gFlagInCommentBloc)
if (!flag_in_comment_bloc)
{
char *ptr_line=strstr(inpline,"/*");
if (ptr_line)
{
*ptr_line=0;
gFlagInCommentBloc=true;
flag_in_comment_bloc=true;
}
}

return std::string(inpline);
}

#endif


/*
Expand Down Expand Up @@ -568,6 +647,7 @@ int main(int argc,char **argv)
" -q : Quiet mode.\r\n"
" -b : Bare linking (don't include header and tail).\r\n"
" -f : Insert #file directives (require expanded XA assembler).\r\n"
" -cn: Defines if comments should be kept (-c1) or removed (-c0) [Default]. \r\n"
);


Expand Down Expand Up @@ -667,6 +747,14 @@ int main(int argc,char **argv)
gInputFileList.push_back(cFileEntry);
}
else
if (cArgumentParser.IsSwitch("-c"))
{
//comments: [-c]
// 0 => remove comments
// 1 => keep comments
gFlagKeepComments=cArgumentParser.GetBooleanValue(false);
}
else
{
// Unknown argument
printf("Invalid option %s \n",cArgumentParser.GetRemainingStuff());
Expand Down Expand Up @@ -872,6 +960,7 @@ int main(int argc,char **argv)
fprintf(gofile,"#file \"%s\\%s.s\"\r\n",current_directory,filename);
}

// Mike: The code should really reuse the previously loaded/parsed files
std::vector<std::string> cTextData;
if (!LoadText(gInputFileList[k].m_cFileName.c_str(),cTextData))
{
Expand All @@ -885,7 +974,15 @@ int main(int argc,char **argv)
{
// Get line file and parse it
const std::string& cCurrentLine=*cItText;
fprintf(gofile,"%s\r\n",cCurrentLine.c_str());
if (gFlagKeepComments)
{
fprintf(gofile,"%s\r\n",cCurrentLine.c_str());
}
else
{
std::string cFilteredLine=FilterLine(cCurrentLine);
fprintf(gofile,"%s\r\n",cFilteredLine.c_str());
}
++cItText;
}
}
Expand Down
Loading

0 comments on commit bac096f

Please sign in to comment.