Main Page | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

petscii.c

Go to the documentation of this file.
00001 /*
00002  *      This program is free software; you can redistribute it and/or
00003  *      modify it under the terms of the GNU General Public License
00004  *      as published by the Free Software Foundation; either version
00005  *      2 of the License, or (at your option) any later version.
00006  *
00007  *  Copyright 1999-2005 Michael Klein <michael(dot)klein(at)puffin(dot)lb(dot)shuttle(dot)de>
00008  *  Copyright 2001-2005 Spiro Trikaliotis
00009  *
00010  *  Parts are Copyright
00011  *      Jouko Valta <jopi(at)stekt(dot)oulu(dot)fi>
00012  *      Andreas Boose <boose(at)linux(dot)rz(dot)fh-hannover(dot)de>
00013 */
00014 
00025 #define DBG_USERMODE
00026 
00028 #define DBG_PROGNAME "OPENCBM.DLL"
00029 
00030 #include "debug.h"
00031 
00032 #include <ctype.h>
00033 #include <stdlib.h>
00034 
00036 #define DLL
00037 #include "opencbm.h"
00038 
00039 /*-------------------------------------------------------------------*/
00040 /*--------- ASCII <-> PETSCII CONVERSION FUNCTIONS ------------------*/
00041 /*
00042  * 
00043  *  These functions are taken from VICE's charset.c,
00044  *  Copyright
00045  *      Jouko Valta <jopi(at)stekt(dot)oulu(dot)fi>
00046  *      Andreas Boose <boose(at)linux(dot)rz(dot)fh-hannover(dot)de>
00047  *
00048  *  You can get VICE from http://www.viceteam.org/
00049  */
00050 
00064 char CBMAPIDECL 
00065 cbm_petscii2ascii_c(char Character)
00066 {
00067     switch (Character & 0xff) {
00068       case 0x0a:
00069       case 0x0d:
00070           return '\n';
00071       case 0x40:
00072       case 0x60:
00073         return Character;
00074       case 0xa0:                                /* CBM: Shifted Space */
00075       case 0xe0:
00076         return ' ';
00077       default:
00078         switch (Character & 0xe0) {
00079           case 0x40: /* 41 - 7E */
00080           case 0x60:
00081             return (Character ^ 0x20);
00082 
00083           case 0xc0: /* C0 - DF */
00084             return (Character ^ 0x80);
00085 
00086       }
00087     }
00088 
00089     return ((isprint(Character) ? Character : '.'));
00090 }
00091 
00092 
00105 char CBMAPIDECL
00106 cbm_ascii2petscii_c(char Character)
00107 {
00108     if ((Character >= 0x5b) && (Character <= 0x7e))
00109     {
00110         return Character ^ 0x20;
00111     }
00112     else if ((Character >= 'A') && (Character <= 'Z'))          /* C0 - DF */
00113     {
00114         return Character | 0x80;
00115     }
00116     return Character;
00117 }
00118 
00119 
00136 char * CBMAPIDECL
00137 cbm_petscii2ascii(char *Str)
00138 {
00139     char *p;
00140     for (p = Str; *p; p++) 
00141     {
00142         *p = cbm_petscii2ascii_c(*p);
00143     }
00144     return Str;
00145 }
00146 
00160 char * CBMAPIDECL 
00161 cbm_ascii2petscii(char *Str)
00162 {
00163     char *p;
00164     for (p = Str; *p; p++)
00165     {
00166         *p = cbm_ascii2petscii_c(*p);
00167     }
00168     return Str;
00169 }

Generated on Sun Apr 30 18:45:56 2006 for opencbm by  doxygen 1.4.2