|
|
1.1 root 1: /*
1.1.1.4 root 2: Hatari - misc.c
3:
4: This file is distributed under the GNU Public License, version 2 or at
5: your option any later version. Read the file gpl.txt for details.
1.1 root 6:
7: Misc functions
8: */
1.1.1.8 ! root 9: const char Misc_rcsid[] = "Hatari $Id: misc.c,v 1.15 2007/12/19 11:13:28 thothy Exp $";
1.1.1.4 root 10:
11: #include <ctype.h>
1.1 root 12:
13: #include "main.h"
14: #include "misc.h"
15:
1.1.1.5 root 16:
1.1.1.2 root 17: /*-----------------------------------------------------------------------*/
1.1.1.8 ! root 18: /**
! 19: * Remove 'white-space' from beginning of text string
! 20: */
1.1 root 21: void Misc_RemoveWhiteSpace(char *pszString,int Length)
22: {
1.1.1.8 ! root 23: while ((*pszString==' ') || (*pszString=='\t'))
! 24: {
! 25: /* Copy line left one character */
! 26: memmove(pszString, pszString+1, Length-1);
! 27: }
1.1 root 28: }
29:
1.1.1.2 root 30:
31: /*-----------------------------------------------------------------------*/
1.1.1.8 ! root 32: /**
! 33: * Convert a string to uppercase.
! 34: */
1.1.1.4 root 35: void Misc_strupr(char *pString)
36: {
1.1.1.8 ! root 37: while (*pString)
! 38: {
! 39: *pString = toupper(*pString);
! 40: pString++;
! 41: }
1.1.1.4 root 42: }
43:
44:
45: /*-----------------------------------------------------------------------*/
1.1.1.8 ! root 46: /**
! 47: * Limit integer between min/max range
! 48: */
1.1 root 49: int Misc_LimitInt(int Value, int MinRange, int MaxRange)
50: {
1.1.1.8 ! root 51: if (Value < MinRange)
! 52: Value = MinRange;
! 53: else if (Value > MaxRange)
! 54: Value = MaxRange;
1.1 root 55:
1.1.1.8 ! root 56: return Value;
1.1 root 57: }
58:
1.1.1.2 root 59:
60: /*-----------------------------------------------------------------------*/
1.1.1.8 ! root 61: /**
! 62: * Convert value to 2-digit BCD
! 63: */
1.1 root 64: unsigned char Misc_ConvertToBCD(unsigned short int Value)
65: {
1.1.1.8 ! root 66: return (((Value/10))<<4) | (Value%10);
1.1 root 67: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.