DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Rational R1000/400

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦33743debc⟧ TextFile

    Length: 8774 (0x2246)
    Types: TextFile
    Notes: R1k Text-file segment

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦5a81ac88f⟧ »Space Info Vol 1« 
        └─⟦ae1a08e28⟧ 
            └─⟦this⟧ 

TextFile

/*=================================================================
;  IRP MULHOUSE                           AVRIL 92
;-------------------------------------------------------------------
; PROJECT  : Z80 SIMULATOR               
; STUDENTS : MOREAUX & VERGER
;
; FILE     : Memory.c
==================================================================
; DESCRIPTION :
; Fichier source pour la gestion de la memoire avec l'interface 
; WINDOW SYSTEM
;----------------------------------------------------------------*/

/*----------- Inclusion -------------------------*/

#include "GUI_Interface.h"

#include <Xm/List.h>
#include <Xm/ListP.h>

/*----------- Definitions -----------------------*/

#define MAX_MEMORY     16
#define MAX_DUMP_X     48
#define MAX_DUMP_ASC_X 17

#define DUMP(x,y) avMemoryDump[(y)*MAX_DUMP_X + (x)]
#define DUMP_ASC(x,y) avMemoryDumpAscii[(y)*MAX_DUMP_ASC_X+ (x)]

/*----------- Globales -------------------------*/  

char     MemoryList[MAX_MEMORY*4+1];
Widget   wgMemoryList;
XmString *xmstrMemoryList;

int      nbMemoryPoint = 0;
int      Iterator = 0;

int      CntMemoryAddActivate = 0;

char     avMemoryInput[] = "0000";
char     avMemoryDump[ MAX_MEMORY*MAX_DUMP_X +1];
char     avMemoryDumpAscii[ MAX_MEMORY*MAX_DUMP_ASC_X +1];



/*-------------------------------------------------
   Gestion de l'affichage 
   ( Appels Internes )  
--------------------------------------------------*/

static void DeleteLine(int line)
{
int x;

 for ( x=0 ; x < MAX_DUMP_X-1 ; x++) DUMP(x,line) = ' ';
 DUMP(x,line) = '\n'; 

 for ( x=0 ; x < MAX_DUMP_ASC_X-1 ; x++) 
                           DUMP_ASC(x,line) = ' ';
 DUMP_ASC(x,line) = '\n';
}

static void DisplayDump()
{
  FmSetActiveValue (0,"MemoryDump");
  FmSetActiveValue (0,"MemoryDumpAscii");
}

static void DeleteDump()
{
int cntLine;
 for(cntLine=0 ; cntLine < MAX_MEMORY ; cntLine++)
     DeleteLine(cntLine);
}



/*-------------------------------------------------
   Initialisation
   ( Appel depuis C )
--------------------------------------------------*/

void MemoryInit (Widget TopLevel)
{
Arg    wargs [10];
int i;

   wgMemoryList = XtNameToWidget(TopLevel,"Memory.BB.FormList.MemoryList");

   xmstrMemoryList = (XmString *) XtMalloc (sizeof(XmString) * MAX_MEMORY);
   for (i=0; i<MAX_MEMORY; i++)
                xmstrMemoryList [i] = XmStringCreate ( "    ", XmSTRING_DEFAULT_CHARSET);

   XtSetArg (wargs[0], XmNitems, xmstrMemoryList); 
   XtSetArg (wargs[1], XmNitemCount,MAX_MEMORY); 
   XtSetValues ( wgMemoryList, wargs, 2);

   for (i=0 ; i < 4*MAX_MEMORY ; i++) MemoryList[i] = '#' ;
   MemoryList[4*MAX_MEMORY] = '\0';

   FmAttachAv ("MemoryInput", avMemoryInput);
   FmAttachAv ("MemoryDump",avMemoryDump);
   FmAttachAv ("MemoryDumpAscii",avMemoryDumpAscii);

   DeleteDump();

}


/*-------------------------------------------------
  Gestion des PushButtons Add,Delete,DeleteAll,+,-
  ( Appels depuis WINDOW )    
--------------------------------------------------*/

static Boolean isinAF(char hexa)
{
 char hexaUp = toupper(hexa);
 return ( (hexaUp >= 'A') && (hexaUp <= 'F') );
}

static Boolean ishexa(char hexa)
{
 return ( isdigit(hexa) || isinAF(hexa) );
}


static Boolean CheckInput ( int nb_car, char * string)
{
int i;
Boolean error_found = FALSE;

  if (strlen(string) != nb_car) 
      error_found = TRUE;

  else 
     {
     i = 0;
     while ( (i <  nb_car) && (! error_found) )
        {
         string[i] = toupper(string[i]);
         error_found = ! ishexa(string[i]);
        i++;
        }
     }

  if (error_found)
      {
      for ( i = 0; i < nb_car; i++ )
         string[i] = '0';
      SetMessage("INPUT ERROR : Hexa value expected !!!");
      FmBeep();
      return TRUE;
      }
  else
      {
      SetMessage("");
      string[3] = '0'; 
      return FALSE;   
      }  
}


static Boolean MemoryLower(char *Break1,char *Break2) 
{
 return ( strncmp(Break1,Break2,4) < 0 );
}

static Boolean MemoryEqual(char *Break1,char *Break2) 
{
 return ( strncmp(Break1,Break2,4) == 0 );
}

static int hexatoi(char *hexa)
{
 if ( isdigit(*hexa) ) return (int)(*hexa - '0');
 if ( isinAF(*hexa) )  return (int)( toupper(*hexa) - 'A') + 10 ; 
 return 0 ; 
}

static int hexabytoi(char *hexa)
{
 return hexatoi(hexa)*16 + hexatoi(hexa+1); 
}

static int hexaddtoi(char *hexa)
{
 return hexabytoi(hexa)*256 + hexabytoi(hexa+2);
}


/*-- PushButton Add -------------------*/


void MemoryAddActivate()
{
 int InsertPos,i,j;
 
 if (nbMemoryPoint < MAX_MEMORY ) 
   {
    FmGetActiveValue ( 0, "MemoryInput");

    if (!CheckInput(4,avMemoryInput))
      { 
       if (nbMemoryPoint)
             {
                for (InsertPos=0; InsertPos <= (nbMemoryPoint -1 ) ; InsertPos++ ) 
                                   {
                                    if (MemoryEqual( avMemoryInput,&MemoryList[InsertPos*4] )) 
                                           { 
                                             FmBeep(); 
                                             return;
                                            } 

                                    if (MemoryLower( avMemoryInput,&MemoryList[InsertPos*4] )) break;   
                                   }
               
                if( nbMemoryPoint != InsertPos )
                     for(i= (nbMemoryPoint*4)-1 ; i >= InsertPos*4 ; i--)  MemoryList[i+4] = MemoryList[i];  
  
             }  else  InsertPos = 0; 

      for ( i = InsertPos*4,j=0 ; i < (InsertPos+1)*4  ; j++,i ++ )  MemoryList[i] = avMemoryInput[j];

      XmListAddItemUnselected (wgMemoryList, XmStringCreate (avMemoryInput,XmSTRING_DEFAULT_CHARSET), InsertPos+1);
    
      CntMemoryAddActivate++;
      nbMemoryPoint ++;
     }

   } else FmBeep();
}


/*-- PushButton Delete -------------------*/


void MemoryDeleteActivate()
{
 int i,j,pos; 
 int delta = 0;
 int *position_list,position_count;

   if (XmListGetSelectedPos (wgMemoryList, &position_list, &position_count)) 
   {
       for (i=0; i<position_count; i++) 
        {
         pos = position_list[i] - delta ; 
         XmListDeletePos(wgMemoryList, pos);

         for (j=4*(pos-1) ; j <= 4*(nbMemoryPoint-1) ; j++) 
             MemoryList[j] = MemoryList[j+4];

         for (j = (nbMemoryPoint-1)*4 ; j < nbMemoryPoint*4 ; j++)
             MemoryList[j] = '#';      

         delta++;
         }
    nbMemoryPoint -= position_count;    
    XtFree((char *)position_list);
    CntMemoryAddActivate++;
  }
}

/*-- PushButton DeleteAll -------------------*/

void MemoryDeleteAllActivate()
{
 XmListWidget  l = (XmListWidget) wgMemoryList;
 int   cntmax = l->list.itemCount;
 int   cnt,i;

   for (cnt=0; cnt < cntmax; cnt++) 
      {
       XmListDeletePos( wgMemoryList, 1);
      }
  nbMemoryPoint = 0;
  for(i=0; i < 4*MAX_MEMORY ; i++) MemoryList[i] = '#'; 
  DeleteDump();
  DisplayDump();
} 

/*-------------------------------------------------
   Gestion du Dump 
   ( Appels depuis Ada )  
--------------------------------------------------*/

int GetCntMemoryAddActivate()
{
 return CntMemoryAddActivate;
}

void DisplayMemoryDump()
{
 DisplayDump();
}

void DeleteMemoryDump()
{
 DeleteDump();
}

void SetMemoryLine(char *MemoryLine)
{
int i,j;
int x,line;
int hexa;
char adresse[]="0000";

 strncpy(adresse ,MemoryLine,4); 

 for (line = 0 ; line < nbMemoryPoint ; line++ )
     if (strncmp(&MemoryList[line*4],adresse,4)==0) break;

 line--;
 for ( i=0 , x=0 ; i < 16 ; i++ , x+=3 )
      { 
       DUMP(x,line) = MemoryLine[4+(i*2)];
       DUMP(x+1,line) = MemoryLine[5+(i*2)];
       DUMP(x+2,line) = ' ';
      }

 DUMP(MAX_DUMP_X-1,line) ='\n'; 


 for ( i=0 ; i< MAX_DUMP_ASC_X ; i++)
     {
      hexa = hexabytoi(&MemoryLine[4+ i*2]);       
      DUMP_ASC(i,line) = (isprint(hexa) ? (char)hexa: '.');  
     }

 DUMP_ASC(MAX_DUMP_ASC_X-1,line) = '\n';

}




/*-------------------------------------------------
    Iterateur pour la lecture des pointeurs
   ( Appels depuis C )  
--------------------------------------------------*/

void MemoryListIterInit()
{
  Iterator = 0;
}

void MemoryListIterNext ()
{
  Iterator++;
}


Boolean MemoryListIterDone ()
{
  return (Iterator == strlen (MemoryList));
}

char MemoryListIterValue()
{
  return MemoryList[Iterator];
}


/*-------------------------------------------------
    Iterateur pour la lecture du dump memoire
   ( Appels depuis C )  
--------------------------------------------------*/

void MemoryDumpIterInit()
{
  FmGetActiveValue(0,"MemoryDump");
  Iterator = 0;
}

void MemoryDumpIterNext ()
{
  Iterator++;
}


Boolean MemoryDumpIterDone ()
{
  return (Iterator == strlen (avMemoryDump));
}

char MemoryDumpIterValue()
{
  return toupper(avMemoryDump[Iterator]);
}



/*================= FIN DU FICHIER ======================================*/