Logo
~Apps~
~Projects~
~Contact~

asoft_detoken.c File Reference

#include <stdio.h>
#include <string.h>

Include dependency graph for asoft_detoken.c:

Go to the source code of this file.


Functions

int main (int argc, char **argv)

Variables

char applesoft_tokens [][8]

Function Documentation

int main int  argc,
char **  argv
 

Definition at line 142 of file asoft_detoken.c.

References applesoft_tokens.

00143 {
00144   FILE *fil;
00145   int ch1, i;
00146   unsigned char size1, size2;
00147   unsigned char line1, line2;
00148   unsigned char eight, line_length;
00149   short ifc = 0;
00150   short q = 0;
00151 
00152   if (argc > 1)
00153     fil = fopen(argv[1],"rb");
00154   else
00155     fil = stdin;
00156 
00157   // read size, first two bytes
00158   size1 = fgetc(fil);
00159   size2 = fgetc(fil);
00160   while (!feof(fil))
00161   {
00162     line_length = fgetc(fil);
00163     eight = fgetc(fil);  /* sometimes 8, sometimes 9? */
00164     if (eight == 0) 
00165     {
00166       break;
00167     }
00168     line1 = fgetc(fil);
00169     line2 = fgetc(fil);
00170     printf("%4d ", (((int)line2)<<8) + line1);
00171   
00172     while ( (ch1 = fgetc(fil)) != 0 )
00173     {
00174       if (ch1 >= 0x80)
00175       {
00176         fputc(' ', stdout);
00177         for (i = 0; i < strlen(applesoft_tokens[ch1-0x80]); i++)
00178         {
00179           fputc(applesoft_tokens[ch1 - 0x80][i], stdout);
00180         }
00181         fputc(' ', stdout);
00182         if (ch1 == 0xad)
00183         {
00184           ifc++;
00185         }
00186       }
00187       else
00188       if (ch1 == ':' && !ifc && !q)
00189       {
00190         printf("\n     ");
00191       }
00192       else
00193       {
00194         fputc(ch1, stdout);
00195         if (ch1 == '"')
00196         {
00197           q = !q;
00198         }
00199       }
00200     }
00201     printf("\n");
00202     ifc = 0;
00203   } // while (!feof)
00204   if (argc > 1)
00205     fclose(fil);
00206   return 0;
00207 }


Variable Documentation

char applesoft_tokens[][8]
 

Initial value:

{
 "END", "FOR", "NEXT", "DATA", "INPUT", "DEL", "DIM", "READ", 
 "GR", "TEXT", "PR #", "IN #", "CALL", "PLOT", "HLIN", "VLIN", 
 "HGR2", "HGR", "HCOLOR=", "HPLOT", "DRAW", "XDRAW", "HTAB", "HOME", 
 "ROT=", "SCALE=", "SHLOAD", "TRACE", "NOTRACE", "NORMAL", "INVERSE", "FLASH", 
 "COLOR=", "POP", "VTAB ", "HIMEM:", "LOMEM:", "ONERR", "RESUME", "RECALL", 
 "STORE", "SPEED=", "LET", "GOTO", "RUN", "IF", "RESTORE", "&", 
 "GOSUB", "RETURN", "REM", "STOP", "ON", "WAIT", "LOAD", "SAVE", 
 "DEF", "POKE", "PRINT", "CONT", "LIST", "CLEAR", "GET", "NEW", 
 "TAB (", "TO", "FN", "SPC(", "THEN", "AT", "NOT", "STEP", 
 "+", "-", "*", "/", "^", "AND", "OR", ">", 
 "=", "<", "SGN", "INT", "ABS", "USR", "FRE", "SCRN (", 
 "PDL", "POS", "SQR", "RND", "LOG", "EXP", "COS", "SIN", 
 "TAN", "ATN", "PEEK", "LEN", "STR$", "VAL", "ASC", "CHR$", 
 "LEFT$", "RIGHT$", "MID$", "", "", "", "", "", 
 "", "", "", "", "", "", "", "", 
 "", "", "", "", "", "(", "(", "("
}

Definition at line 6 of file asoft_detoken.c.

Page, code, and content Copyright (C) 2005 by Anders Hedström
Generated on Mon Aug 29 20:21:47 2005 for C++ Sockets by  doxygen 1.4.4