1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-26 05:29:30 +00:00

replaced 'int' by 'unsigned' where appropriate

git-svn-id: svn://svn.cc65.org/cc65/trunk@2040 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
izydorst 2003-04-04 21:16:15 +00:00
parent 32bb4dafa0
commit 3a536492ca
8 changed files with 82 additions and 77 deletions

View File

@ -50,17 +50,20 @@ changed between <tt/tgi_init/ and <tt/tgi_done/.
<p>
<tt/joy/ - JOY driver for GEOS supports only joystick, not current pointing device.
<p>
It is safe to use these standard includes and its contents:
It is safe to use these standard includes and their contents:
<tt/assert.h, conio.h, dio.h, errno.h, em.h, geos.h, joystick.h, modload.h, mouse.h, stdlib.h, string.h, tgi.h, time.h/
<p>
It was not tested enough, but functions from these includes might work under GEOS:
<tt/rs232.h, zlib.h/
<p>
Functions from the headers above are either standard C library functions or cc65-specific, in
either case they are not GEOS specific and so they are not described here.
<p>
I am an assembler programmer and GEOSLib was designed in such way that cc65 could emit the best
available code (well, the best as for machine :). Many of the <tt/void foo (void)/ functions are
just raw calls to Kernal (assembled just as <tt/jsr _foo/), look in <tt/gsym.h/, where you
will find many definitions of standard GEOS locations. Access to these addresses is optimized by
cc65 to simple <tt/lda/ and <tt/sta/. Don't be afraid to use the power of C.
cc65 to simple <tt/lda/ and <tt/sta/. Don't be afraid to use C syntax.
<sect1>Requirements
<p>
@ -159,9 +162,9 @@ series of <tt/lda/ and <tt/sta/, so you can't do it better :-).
Don't hesitate to use library functions. Everything was written with size and speed in mind. In
fact many calls are just redirections to GEOS kernal which results in simple <tt/jsr/.
<p>
You might wonder why I have chosen sometimes weird order of arguments in functions. It is because
I wanted to avoid unnecessary pushing and popping arguments from stack. cc65 can pass single <tt/int/
through CPU registers.
You might wonder why I have chosen sometimes weird order of arguments in functions. I just
wanted to avoid unnecessary pushing and popping arguments from stack because cc65 can pass single
<tt/unsigned int/ through CPU registers.
<p>
Do not try to compile in strict ANSI mode. Library uses cc65 extensions which are not available in
ANSI.
@ -248,27 +251,27 @@ horizontal lines.
<sect3>HorizontalLine
<p>
<tt/void HorizontalLine (char pattern, char y, int xStart, int xEnd)/
<tt/void HorizontalLine (char pattern, char y, unsigned xStart, unsigned xEnd)/
<p>
This function draws horizontal line using given pattern - here it is a true bit pattern, not
pattern set by <tt/SetPattern/.
<sect3>InvertLine
<p>
<tt/void InvertLine (char y, int xStart, int xEnd)/
<tt/void InvertLine (char y, unsigned xStart, unsigned xEnd)/
<p>
There is only horizontal version.
<sect3>RecoverLine
<p>
<tt/void RecoverLine (char y, int xStart, int xEnd)/
<tt/void RecoverLine (char y, unsigned xStart, unsigned xEnd)/
<p>
This function recovers only one line. It is utilized by <tt/RecoverRectangle/. See its description
for more details.
<sect3>VerticalLine
<p>
<tt/void VerticalLine (char pattern, char yStart, char yEnd, int x)/
<tt/void VerticalLine (char pattern, char yStart, char yEnd, unsigned x)/
<p>
This function draws vertical line using given pattern. Note that <tt/pattern/ is not a pattern
number as set in <tt/SetPattern/ but a true bit pattern.
@ -317,7 +320,7 @@ This function outputs single character using current style and font to screen.
<sect3>PutString
<p>
<tt/void PutString (char *myString, char y, int x)/
<tt/void PutString (char *myString, char y, unsigned x)/
<p>
Same as <tt/PutChar/ except the fact that you can output whole <tt/NULL/-terminated string.
See <tt/ggraph.h/ for list of tokens that you can also place in the string - like <tt/CBOLDON/ or
@ -325,7 +328,7 @@ See <tt/ggraph.h/ for list of tokens that you can also place in the string - lik
<sect3>PutDecimal
<p>
<tt/void PutDecimal (char parameter, int value, char y, int x)/
<tt/void PutDecimal (char parameter, int value, char y, unsigned x)/
<p>
This function converts <tt/value/ to its decimal representation and outputs it to the screen.
Depending on given <tt/parameter/ the string can be filled with zeroes (string always 5 characters
@ -370,7 +373,7 @@ structure. Note that you can only use packed GEOS bitmaps - simple Photo Scrap i
<sect3>BitmapClip
<p>
<tt/void BitmapClip (char skipLeft, char skipRight, int skipTop, struct iconpic *myPic)/
<tt/void BitmapClip (char skipLeft, char skipRight, unsigned skipTop, struct iconpic *myPic)/
<p>
This function acts similar to <tt/BitmapUp/ but you can also define which parts of the bitmap are
to be drawn - you give the number of columns (8-pixel) to skip on the right and left of the bitmap,
@ -378,7 +381,7 @@ and the number of rows to skip from the top if it.
<sect3>BitOtherClip
<p>
<tt/void BitOtherClip (void *proc1, void *proc2, char skipLeft, char skip Right, int skipTop,
<tt/void BitOtherClip (void *proc1, void *proc2, char skipLeft, char skip Right, unsigned skipTop,
struct iconpic *myPic)/
<p>
Similar to the previous one with some extension. <tt/proc1/ is called before reading a byte (it
@ -691,7 +694,7 @@ disk. Otherwise they will be lost. Operating area is the <tt/curDirHead/.
<sect3>CalcBlksFree
<p>
<tt/int CalcBlksFree (void)/
<tt/unsigned CalcBlksFree (void)/
<p>
This function returns the number of free blocks on current disk. It is counted using data in
<tt/curDirHead/ so you must initialize the disk before calling it.
@ -730,9 +733,9 @@ Anyway, I feel that this function is too low-level.
<sect3>BlkAlloc and NxtBlkAlloc
<p>
<tt/char BlkAlloc (struct tr_se output&lsqb;&rsqb, int length)/
<tt/char BlkAlloc (struct tr_se output&lsqb;&rsqb, unsigned length)/
<p>
<tt/char NxtBlkAlloc (struct tr_se *myTrSe, struct tr_se output&lsqb;&rsqb, int length)/
<tt/char NxtBlkAlloc (struct tr_se *myTrSe, struct tr_se output&lsqb;&rsqb, unsigned length)/
<p>
Both functions are allocating enough disk sectors to fit the number of <tt/length/ in them. You
will find output in <tt/output/ which is table of <tt/struct tr_se/. The last entry will have the
@ -757,11 +760,11 @@ Simply deallocates a block in BAM. You need to update BAM with <tt/PutDirHead/.
This function finds the first free sector starting from given track and sector and allocates it.
It might return the same argument if the given block is not allocated. I wanted it to be type
clean, but it made usage a bit tricky. To assign a value to own <tt/struct tr_se/ you have to
cast both variables to <tt/int/. E.g.
cast both variables to <tt/unsigned/. E.g.
<tscreen><verb>
struct tr_se myTrSe;
...
(int)myTrSe=(int)SetNextFree(&amp;otherTrSe);
(unsigned)myTrSe=(unsigned)SetNextFree(&amp;otherTrSe);
</verb></tscreen>
<p>
In this example <tt/otherTrSe/ can be replaced by <tt/myTrSe/.
@ -834,7 +837,7 @@ Functions described here are common for SEQ and VLIR structures.
<p>
These two functions are best suited for scanning whole directory for particular files. Note that
returned filehandles describes all file slots in the directory - even those with deleted files.
The return value can be obtained by casting both sides to <tt/int/ - as in <tt/SetNextFree/
The return value can be obtained by casting both sides to <tt/unsigned/ - as in <tt/SetNextFree/
function or read directly after call to those two functions from <tt/r5/. Current sector number
is in <tt/r1/ and sector data itself is in <tt/diskBlkBuf/.
@ -901,7 +904,7 @@ in system case. If you don't use it it is safe to pass <tt/NULL/ to this functio
<sect3>ReadFile
<p>
<tt/char ReadFile (struct tr_se *myTrSe, char *buffer, int fLength)/
<tt/char ReadFile (struct tr_se *myTrSe, char *buffer, unsigned fLength)/
<p>
This function reads at most <tt/fLength/ bytes into <tt/buffer/ from chained sectors starting at
<tt/myTrSe/.
@ -1027,9 +1030,9 @@ can be found in <tt/VLIRInfo.curRecord + 1/).
<sect3>ReadRecord and WriteRecord
<p>
<tt/char ReadRecord (char *buffer, int fLength)/
<tt/char ReadRecord (char *buffer, unsigned fLength)/
<p>
<tt/char WriteRecord (char *buffer, int fLength)/
<tt/char WriteRecord (char *buffer, unsigned fLength)/
<p>
This function will load or save at most <tt/fLength/ bytes from currently pointed record into or from
<tt/buffer/.
@ -1072,16 +1075,16 @@ characters - they are not treated as delimiters.
<sect2>CRC
<p>
<tt/int CRC (char *src, int length)/
<tt/unsigned CRC (char *src, unsigned length)/
<p>
This function calculates the CRC checksum for given memory range. I don't know if it is
compatible with standard CRC routines.
<sect2>FillRam and ClearRam
<p>
<tt/void FillRam (char *dest, char value, int length)/
<tt/void FillRam (char *dest, char value, unsigned length)/
<p>
<tt/void ClearRam (char *dest, int length)/
<tt/void ClearRam (char *dest, unsigned length)/
<p>
Both functions are filling given memory range. <tt/ClearRam/ fills with <tt/NULLs/, while
<tt/FillRam/ uses given <tt/value/. Be warned that these functions destroy <tt/r0, r1 and
@ -1089,7 +1092,7 @@ r2L/ registers. <tt/FillRam/ is an alias for <tt/memset/.
<sect2>MoveData
<p>
<tt/void MoveData (char *dest, char *src, int length)/
<tt/void MoveData (char *dest, char *src, unsigned length)/
<p>
This functions copies one memory region to another. There are checks for overlap and the
non-destructive method is chosen. Be warned that this function destroys contents of
@ -1105,13 +1108,13 @@ This is done with <tt/table/ where everything is defined. See structures chapter
<sect2>Stash, Fetch, Swap, and VerifyRAM
<p>
<tt/void StashRAM (char bank, int length, char *reuAddress, char *cpuAddress)/
<tt/void StashRAM (char bank, unsigned length, char *reuAddress, char *cpuAddress)/
<p>
<tt/void FetchRAM (char bank, int length, char *reuAddress, char *cpuAddress)/
<tt/void FetchRAM (char bank, unsigned length, char *reuAddress, char *cpuAddress)/
<p>
<tt/void SwapRAM (char bank, int length, char *reuAddress, char *cpuAddress)/
<tt/void SwapRAM (char bank, unsigned length, char *reuAddress, char *cpuAddress)/
<p>
<tt/ char VerifyRAM (char bank, int length, char *reuAddress, char *cpuAddress)/
<tt/ char VerifyRAM (char bank, unsigned length, char *reuAddress, char *cpuAddress)/
<p>
These functions are interface to REU - Ram Expansion Unit. I think that they are self-explanatory.
You can check for REU presence by taking value of <tt/ramExpSize/.
@ -1179,7 +1182,7 @@ This is not equal to <tt/RestartProcess/ as timers are not filled with initial v
<sect2>Sleep
<p>
<tt/void Sleep (int jiffies)/
<tt/void Sleep (unsigned jiffies)/
<p>
This function is multitasking sleep - the program is halted, but it doesn't block other functions.
The only argument here is the number of jiffies to wait until app will wake up.
@ -1256,7 +1259,7 @@ you don't need to check if the pointer is valid.
<sect2>GetSerialNumber
<p>
<tt/int GetSerialNumber (void)/
<tt/unsigned GetSerialNumber (void)/
<p>
This function returns the serial number of system. It might be used for copy-protection.
However, please remember that the Free Software is a true power and you are using it
@ -1403,9 +1406,9 @@ pair.
You should declare a table of that type to prepare data for <tt/InitProcesses/. The maximum number
of processes is 20, and the last entry has to be equal to <tt/&lcub;NULL,NULL&rcub;/, so this table may hold
only 21 entries. The first member of this structure (<tt/pointer/) holds the pointer to called
function (void returning void), you will probably have to cast that pointer into int. The second
field <tt/jiffies/ holds the amount of time between calls to that function. On PAL systems there
are 50 jiffies per second, while NTSC have 60 of them.
function (void returning void), you will probably have to cast that pointer into <tt/unsigned int/.
The second field <tt/jiffies/ holds the amount of time between calls to that function.
On PAL systems there are 50 jiffies per second, while NTSC have 60 of them.
<sect1>Few thing in detail...
<p>
@ -1522,7 +1525,7 @@ is variable. Consider following:
<tscreen><verb>
char text = "foo";
...
r15=(int)text; // in code just before call to DoDlgBox
r15=(unsigned)text; // in code just before call to DoDlgBox
...
DB_VARSTR (TXT_LN_X, TXT_LN_1_Y, &amp;r15),
...

View File

@ -21,19 +21,19 @@ char __fastcall__ ReadBlock(struct tr_se *myTrSe, char *buffer);
char __fastcall__ WriteBlock(struct tr_se *myTrSe, const char *buffer);
char __fastcall__ VerWriteBlock(struct tr_se *myTrSe, const char *buffer);
int __fastcall__ CalcBlksFree(void);
unsigned __fastcall__ CalcBlksFree(void);
char __fastcall__ ChkDkGEOS(void);
char __fastcall__ SetGEOSDisk(void);
char __fastcall__ NewDisk(void);
char __fastcall__ OpenDisk(void);
char __fastcall__ FindBAMBit(struct tr_se *myTrSe);
char __fastcall__ BlkAlloc(struct tr_se output[], int length);
char __fastcall__ BlkAlloc(struct tr_se output[], unsigned length);
char __fastcall__ NxtBlkAlloc(struct tr_se *startTrSe,
struct tr_se output[], int length);
struct tr_se output[], unsigned length);
char __fastcall__ FreeBlock(struct tr_se *myTrSe);
struct tr_se __fastcall__ SetNextFree(struct tr_se *myTrSe);
// above needs (int) casts on both sides of '='
// above needs (unsigned) casts on both sides of '='
char __fastcall__ GetDirHead(void);
char __fastcall__ PutDirHead(void);

View File

@ -17,9 +17,10 @@ struct filehandle *__fastcall__ GetNxtDirEntry(void);
char __fastcall__ FindFTypes(char *buffer, char ftype, char fmaxnum, const char *classtxt);
char __fastcall__ GetFile(char flag, const char *fname, const char *loadaddr, const char *datadname, char *datafname);
char __fastcall__ GetFile(char flag, const char *fname, const char *loadaddr,
const char *datadname, char *datafname);
char __fastcall__ FindFile(const char *fname);
char __fastcall__ ReadFile(struct tr_se *myTrSe, char *buffer, int flength);
char __fastcall__ ReadFile(struct tr_se *myTrSe, char *buffer, unsigned flength);
char __fastcall__ SaveFile(struct fileheader *myHeader);
char __fastcall__ FreeFile(struct tr_se myTable[]);
char __fastcall__ DeleteFile(const char *fname);
@ -38,8 +39,8 @@ char __fastcall__ PointRecord(char);
char __fastcall__ DeleteRecord(void);
char __fastcall__ InsertRecord(void);
char __fastcall__ AppendRecord(void);
char __fastcall__ ReadRecord(char *buffer, int flength);
char __fastcall__ WriteRecord(const char *buffer, int flength);
char __fastcall__ ReadRecord(char *buffer, unsigned flength);
char __fastcall__ WriteRecord(const char *buffer, unsigned flength);
char __fastcall__ UpdateRecordFile(void);
/* GEOS filetypes */

View File

@ -14,14 +14,14 @@
#endif
void __fastcall__ cpputs(char *s);
void __fastcall__ cpputsxy(int x, int y, char *s);
void __fastcall__ cpputsxy(unsigned x, unsigned y, char *s);
void __fastcall__ SetPattern(char newpattern);
void __fastcall__ HorizontalLine(char pattern, char y, int xstart, int xend);
void __fastcall__ InvertLine(char y, int xstart, int xend);
void __fastcall__ RecoverLine(char y, int xstart, int xend);
void __fastcall__ VerticalLine(char pattern, char ystart, char yend, int x);
void __fastcall__ HorizontalLine(char pattern, char y, unsigned xstart, unsigned xend);
void __fastcall__ InvertLine(char y, unsigned xstart, unsigned xend);
void __fastcall__ RecoverLine(char y, unsigned xstart, unsigned xend);
void __fastcall__ VerticalLine(char pattern, char ystart, char yend, unsigned x);
void __fastcall__ InitDrawWindow(struct window *myRectangle);
void __fastcall__ Rectangle(void);
@ -35,19 +35,19 @@ void __fastcall__ DrawLine(struct window *topBotCoords);
void __fastcall__ DrawPoint(struct pixel *myPixel);
char __fastcall__ TestPoint(struct pixel *myPixel);
void __fastcall__ PutChar(char character, char y, int x);
void __fastcall__ PutString(char *myString, char y, int x);
void __fastcall__ PutDecimal(char style, int value, char y, int x);
void __fastcall__ PutChar(char character, char y, unsigned x);
void __fastcall__ PutString(char *myString, char y, unsigned x);
void __fastcall__ PutDecimal(char style, int value, char y, unsigned x);
char __fastcall__ GetCharWidth(char character);
void __fastcall__ LoadCharSet(struct fontdesc *myFont);
void __fastcall__ UseSystemFont(void);
void __fastcall__ BitmapUp(struct iconpic *myIcon);
void __fastcall__ BitmapClip(char skipl, char skipr, int skiptop,
void __fastcall__ BitmapClip(char skipl, char skipr, unsigned skiptop,
struct iconpic *myIcon);
void __fastcall__ BitOtherClip(void *proc1, void *proc2, char skipl,
char skipr, int skiptop,
char skipr, unsigned skiptop,
struct iconpic *myIcon);
void __fastcall__ GraphicsString(char *myGfxString);

View File

@ -2,7 +2,8 @@
GEOS memory and string functions
ported to small C on 27.10.1999
by Maciej 'YTM/Alliance' Witkowiak
by Maciej 'YTM/Elysium' Witkowiak
04.04.2003 - updates
*/
#ifndef _GMEMORY_H
@ -17,17 +18,17 @@ char __fastcall__ CmpString(const char *dest, const char *source);
void __fastcall__ CopyFString(char len, char *dest, const char *source);
char __fastcall__ CmpFString(char len, char *dest, const char *source);
int __fastcall__ CRC(const char *buffer, int len);
void __fastcall__ ClearRam(char *dest, int len);
void __fastcall__ FillRam(char *dest, char what, int len);
unsigned __fastcall__ CRC(const char *buffer, unsigned len);
void __fastcall__ ClearRam(char *dest, unsigned len);
void __fastcall__ FillRam(char *dest, char what, unsigned len);
void __fastcall__ MoveData(char *dest, const char *source, int len);
void __fastcall__ MoveData(char *dest, const char *source, unsigned len);
void __fastcall__ InitRam(char *myInitTab);
void __fastcall__ StashRAM(char REUBank, int len, char *reuaddy, const char *cpuaddy);
void __fastcall__ FetchRAM(char REUBank, int len, const char *reuaddy, char *cpuaddy);
void __fastcall__ SwapRAM(char REUBank, int len, char *reuaddy, char *cpuaddy);
char __fastcall__ VerifyRAM(char REUBank, int len, const char *reuaddy, const char *cpuaddy);
void __fastcall__ StashRAM(char REUBank, unsigned len, char *reuaddy, const char *cpuaddy);
void __fastcall__ FetchRAM(char REUBank, unsigned len, const char *reuaddy, char *cpuaddy);
void __fastcall__ SwapRAM(char REUBank, unsigned len, char *reuaddy, char *cpuaddy);
char __fastcall__ VerifyRAM(char REUBank, unsigned len, const char *reuaddy, const char *cpuaddy);
#endif

View File

@ -20,6 +20,6 @@ void __fastcall__ UnBlockProcess(char number);
void __fastcall__ FreezeProcess(char number);
void __fastcall__ UnFreezeProcess(char number);
void __fastcall__ Sleep(int jiffies);
void __fastcall__ Sleep(unsigned jiffies);
#endif

View File

@ -46,9 +46,9 @@ struct fileheader { /* header block (like fileHeader) */
char dostype;
char type;
char structure;
int load_address;
int end_address;
int exec_address;
unsigned load_address;
unsigned end_address;
unsigned exec_address;
char class_name[19];
char column_flag;
char author[63];
@ -63,11 +63,11 @@ struct filehandle { /* filehandle in directory sectors */
char structure;
char type;
struct f_date date;
int size;
unsigned size;
};
struct pixel { /* describes point */
int x;
unsigned x;
char y;
};
@ -82,20 +82,20 @@ struct fontdesc { /* describes font */
struct window { /* describes screen region */
char top;
char bot;
int left;
int right;
unsigned left;
unsigned right;
};
struct VLIR_info { /* VLIR information */
char curRecord; /* currently only used in VLIR */
char usedRecords; /* as system info (curRecord is mainly of your interest */
char fileWritten;
int fileSize;
unsigned fileSize;
};
struct process { /* process info, declare table of that type */
int pointer; /* (like: struct process proctab[2]=... */
int jiffies; /* last entry HAVE TO BE {0,0} */
unsigned pointer; /* (like: struct process proctab[2]=... */
unsigned jiffies; /* last entry HAVE TO BE {0,0} */
};
@ -113,7 +113,7 @@ struct icondef { /* icon definition for DoIcons */
char y;
char width; /* of icon (in cards) */
char heigth; /* of icon in lines (pixels) */
int proc_ptr; /* pointer to function handling that icon */
unsigned proc_ptr; /* pointer to function handling that icon */
};
struct icontab {
@ -136,7 +136,7 @@ struct menu {
};
struct inittab { /* use struct inittab mytab[n] for initram */
int ptr; /* ptr to 1st byte */
unsigned ptr; /* ptr to 1st byte */
char number; /* number of following bytes */
char values[]; /* actual string of bytes */
};

View File

@ -18,7 +18,7 @@ void __fastcall__ Panic(void);
void __fastcall__ CallRoutine(void *myRoutine);
int __fastcall__ GetSerialNumber(void);
unsigned __fastcall__ GetSerialNumber(void);
char __fastcall__ GetRandom(void);
void __fastcall__ SetDevice(char newdev);