# 1 "main.c"
 













 


# 1 "global.h" 1
 













 
#pragma align 1




# 1 "mytypes.h" 1
 













 







typedef signed char INT8;
typedef unsigned char UINT8;
typedef signed short INT16;
typedef unsigned short UINT16;
typedef signed long INT32;
typedef unsigned long UINT32;

typedef UINT8 BYTE;
typedef UINT16 WORD;
typedef UINT32 DWORD;


# 21 "global.h" 2









































extern BYTE *memory;
extern char *progname;

void init_cpu(void);
void execute(void);
void exit_emu(void);








# 18 "main.c" 2


# 1 "/usr/include/string.h" 1
 









# 1 "/usr/include/common/feature.h" 1
 









 






















 


















 






# 74 "/usr/include/common/feature.h"



 











 


















 









 










# 11 "/usr/include/string.h" 2

# 1 "/usr/include/common/ccompat.h" 1
 









 






# 1 "/usr/include/common/_ccompat.h" 1
 









 
















# 1 "/usr/include/common/feature.h" 1
 






# 128 "/usr/include/common/feature.h"

# 28 "/usr/include/common/_ccompat.h" 2



 


























 










 












 








 

















# 159 "/usr/include/common/_ccompat.h"






# 180 "/usr/include/common/_ccompat.h"



 


















 






















 


























 


































 



















 




















 


















# 360 "/usr/include/common/_ccompat.h"




 























 






























 




























 




























 















































 










































 


























 




















 




















 














 





































 










 



























 
















 



























# 18 "/usr/include/common/ccompat.h" 2



# 12 "/usr/include/string.h" 2

# 1 "/usr/include/common/_size.h" 1
 









 










# 1 "/usr/include/common/feature.h" 1
 






# 128 "/usr/include/common/feature.h"

# 22 "/usr/include/common/_size.h" 2

# 1 "/usr/include/common/__size.h" 1
 









 











# 1 "/usr/include/common/feature.h" 1
 






# 128 "/usr/include/common/feature.h"

# 23 "/usr/include/common/__size.h" 2




typedef	unsigned	__size_t;


# 39 "/usr/include/common/__size.h"



# 23 "/usr/include/common/_size.h" 2




 






typedef	__size_t	size_t;






# 62 "/usr/include/common/_size.h"



# 13 "/usr/include/string.h" 2

# 1 "/usr/include/common/_null.h" 1
 









 









 



















# 14 "/usr/include/string.h" 2



 

void       *	memcpy		(void  * _s1,
					  const  void  * _s2,
					  size_t _n) ;
void       *	memmove		(void  * _s1,
					  const  void  * _s2,
					  size_t _n) ;
char	      *	strcpy		(char * _s1, const  char * _s2) ;
char	      *	strncpy		(char * _s1, const  char * _s2,
					  size_t _n) ;
char	      *	strcat		(char * _s1, const  char * _s2) ;
char	      *	strncat		(char * _s1, const  char * _s2,
					  size_t _n) ;
int		memcmp		(const  void  * _s1,
					  const  void  * _s2,
					  size_t _n) ;
int		strcmp		(const  char * _s1,
					  const  char * _s2) ;
int		strcoll		(const  char * _s1,
					  const  char * _s2) ;
int		strncmp		(const  char * _s1,
					  const  char * _s2, size_t _n) ;
size_t		strxfrm		(char * _s1, const  char * _s2,
					  size_t _n) ;
void       *	memchr		(const  void  * _s1, int _c,
					  size_t _n) ;
char	      *	strchr		(const  char * _s, int _c) ;
size_t		strcspn		(const  char * _s1,
					  const  char * _s2) ;
char	      *	strpbrk		(const  char * _s1,
					  const  char * _s2) ;
char	      *	strrchr		(const  char * _s1, int _c) ;
size_t		strspn		(const  char * _s1,
					  const  char * _s2) ;
char	      *	strstr		(const  char * _s1,
					  const  char * _s2) ;
char	      *	strtok		(char * _s1, const  char * _s2) ;
void       *	memset		(void  * _s, int _c, size_t _n) ;
char	      *	strerror	(int _errnum) ;
size_t		strlen		(const  char * _s) ;



void       *	memccpy		(void  * _s1,
					  const  void  * _s2, int _c,
					  size_t _n) ;
char	      *	strdup		(const  char * _s) ;


 




























 



void       *	alloca		(size_t _size) ;



 



 
extern	void	_memxchg();




# 20 "main.c" 2

# 1 "/usr/include/stdlib.h" 1
 





 







# 1 "/usr/include/common/ccompat.h" 1
 






# 20 "/usr/include/common/ccompat.h"

# 15 "/usr/include/stdlib.h" 2

# 1 "/usr/include/common/xdebug.h" 1
 









 






# 1 "/usr/include/common/_xdebug.h" 1
 









# 1 "/usr/include/common/ccompat.h" 1
 






# 20 "/usr/include/common/ccompat.h"

# 11 "/usr/include/common/_xdebug.h" 2



 

























 


















 












 




# 89 "/usr/include/common/_xdebug.h"





# 121 "/usr/include/common/_xdebug.h"



 


















 





























































































 









 










# 272 "/usr/include/common/_xdebug.h"











 










 























# 18 "/usr/include/common/xdebug.h" 2



# 16 "/usr/include/stdlib.h" 2

# 1 "/usr/include/common/_size.h" 1
 






# 64 "/usr/include/common/_size.h"

# 17 "/usr/include/stdlib.h" 2

# 1 "/usr/include/common/_wchar.h" 1
 









 









# 1 "/usr/include/common/feature.h" 1
 






# 128 "/usr/include/common/feature.h"

# 21 "/usr/include/common/_wchar.h" 2




typedef	unsigned short	wchar_t;








# 18 "/usr/include/stdlib.h" 2

# 1 "/usr/include/common/_null.h" 1
 






# 40 "/usr/include/common/_null.h"

# 19 "/usr/include/stdlib.h" 2



 






 
typedef	struct { int quot; int rem; } div_t;	 
typedef	struct { long quot; long rem; } ldiv_t;	 


 






 

double		atof		(const  char * _nptr) ;
int		atoi		(const  char * _nptr) ;
long		atol		(const  char * _nptr) ;
double		strtod		(const  char * _nptr,
					  char ** _endptr) ;
long		strtol		(const  char * _nptr,
					  char ** _endptr, int _base) ;
unsigned long	strtoul		(const  char * _nptr,
					  char ** _endptr, int _base) ;
int		rand		(void) ;
void		srand		(unsigned _seed) ;
void       *	calloc		(size_t _nmemb, size_t _size) ;
void		free		(void  * _ptr) ;
void       *	malloc		(size_t _size) ;
void       *	realloc		(void  * _ptr, size_t _size) ;
volatile void 	abort		(void) ;
int		atexit		(void (* _func) (void)) ;
volatile void 	exit		(int _status) ;
char	      *	getenv		(const  char * _name) ;
int		system		(const  char * _string) ;
void       *	bsearch		(const  void  * _key,
					  const  void  * _base,
					  size_t _nmemb, size_t _size,
					  int (* _compar)
						(const  void  *,
						 const  void  *)) ;
void		qsort		(void  * _base, size_t _nmemb,
					  size_t _size,
					  int (* _compar)
						(const  void  *,
						 const  void  *)) ;
int		abs		(int _j) ;
div_t		div		(int _numer, int _denom) ;
long		labs		(long _j) ;
ldiv_t		ldiv		(long _numer, long _denom) ;

# 91 "/usr/include/stdlib.h"




int		putenv		(char * _name) ;



 



 
extern	int		_atexitn;
extern	void		(**_atexitfp)();
extern	double		_pow10	   ();






static  	__inline   div_t __div (int _numerator, int _denominator) {
	div_t		_result;
	__asm  ("cltd;idiv %3" :
			 "=a" (_result.quot), "=d" (_result.rem) :
			 "0" (_numerator), "c" (_denominator));
	return _result;
}

static  	__inline   ldiv_t __ldiv (long _numerator, long _denominator) {
	ldiv_t		_result;
	__asm  ("cltd;idiv %3" :
			 "=a" (_result.quot), "=d" (_result.rem) :
			 "0" (_numerator), "c" (_denominator));
	return _result;
}

# 138 "/usr/include/stdlib.h"









# 21 "main.c" 2

# 1 "/usr/include/stdio.h" 1
 





 







# 1 "/usr/include/common/feature.h" 1
 






# 128 "/usr/include/common/feature.h"

# 15 "/usr/include/stdio.h" 2

# 1 "/usr/include/common/ccompat.h" 1
 






# 20 "/usr/include/common/ccompat.h"

# 16 "/usr/include/stdio.h" 2

# 1 "/usr/include/common/__off.h" 1
 









 






typedef	long		__off_t;


# 17 "/usr/include/stdio.h" 2

# 1 "/usr/include/common/__valist.h" 1
 









 












typedef	char	      *	__va_list;


# 18 "/usr/include/stdio.h" 2

# 1 "/usr/include/common/_size.h" 1
 






# 64 "/usr/include/common/_size.h"

# 19 "/usr/include/stdio.h" 2

# 1 "/usr/include/common/_null.h" 1
 






# 40 "/usr/include/common/_null.h"

# 20 "/usr/include/stdio.h" 2

# 1 "/usr/include/common/whence.h" 1
 









 











# 21 "/usr/include/stdio.h" 2


 












 
typedef long		fpos_t;		 

 



typedef struct	FILE {
	int		_cc;		 
	unsigned char	*_cp;		 
	struct _FILE2	*_f2p;		 
	char		_ff1;		 
	char		_fd;		 
	char		_ff2;		 
	char		_mode;		 
}	FILE;
 
typedef	struct	_FILE2 {
	int		(*_gt)();	 
	int		(*_pt)();	 
	unsigned char	*_bp;		 
	unsigned char	*_dp;		 
	unsigned char	*_ep;		 
	char		*_nm;		 
	int		_uc;		 
}	_FILE2;

 






 



extern	FILE	_iob[3		];
extern	FILE	*_fp[	60		];




 




 



 




 







 







 

 

int		remove		(const  char * _filename) ;
int		rename		(const  char * _old,
					  const  char * _new) ;
FILE	      *	tmpfile		(void) ;
char	      *	tmpnam		(char * _s) ;
int		fclose		(FILE * _stream) ;
int		fflush		(FILE * _stream) ;
FILE	      *	fopen		(const  char * _filename,
					  const  char * _mode) ;
FILE	      *	freopen		(const  char * _filename,
					  const  char * _mode,
					  FILE * _stream) ;
void		setbuf		(FILE * _stream, char * _buf) ;
int		setvbuf		(FILE * _stream, char * _buf,
					  int _mode, size_t _size) ;
int		fprintf		(FILE * _stream,
					  const  char * _format, ...) 
				__attribute__ ((format (printf, 2,  3))) ;
int		fscanf		(FILE * _stream,
					  const  char * _format, ...) 
				__attribute__ ((format (scanf, 2,  3))) ;
int		printf		(const  char * _format, ...) 
				__attribute__ ((format (printf, 1,  2))) ;
int		scanf		(const  char * _format, ...) 
				__attribute__ ((format (scanf, 1,  2))) ;
int		sprintf		(char * _s,
					  const  char * _format, ...) 
				__attribute__ ((format (printf, 2,  3))) ;
int		sscanf		(const  char * _s,
					  const  char * _format, ...) 
				__attribute__ ((format (scanf, 2,  3))) ;
int		vfprintf	(FILE * _stream,
					  const  char * _format,
					  __va_list arg) ;
int		vprintf		(const  char * _format,
					  __va_list arg) ;
int		vsprintf	(char * _s,
					  const  char * _format,
					  __va_list arg) ;
int		fgetc		(FILE * _stream) ;
char	      *	fgets		(char * _s, int _n, FILE * _stream) ;
int		fputc		(int _c, FILE * _stream) ;
int		fputs		(const  char * _s,
					  FILE * _stream) ;
int		getc		(FILE * stream) ;
int		getchar		(void) ;
char	      *	gets		(char * _s) ;
int		putc		(int _c, FILE * _stream) ;
int		putchar		(int _c) ;
int		puts		(const  char * _s) ;
int		ungetc		(int _c, FILE * _stream) ;
size_t		fread		(void  * _cp , size_t _size,
					  size_t _nmemb, FILE * _stream) ;
size_t		fwrite		(const  void  * _cp ,
					  size_t _size, size_t _nmemb,
					  FILE * _stream) ;
int		fgetpos		(FILE * _stream, fpos_t * _pos) ;
int		fseek		(FILE * _stream, __off_t _offset,
					  int whence) ;
int		fsetpos		(FILE * _stream,
					  const  fpos_t * pos) ;
__off_t		ftell		(FILE * _stream) ;
void		rewind		(FILE * _stream) ;
void		clearerr	(void) ;
int		feof		(FILE * _stream) ;
int		ferror		(FILE * _stream) ;
void		perror		(const  char * _s) ;

char	      *	ctermid		(char * _s) ;



FILE	      *	fdopen		(int _fildes,
					  const  char * _type) ;
int		fileno		(FILE * _stream) ;



FILE	      *	popen		(const  char * _command,
					  const  char * _mode) ;
int		pclose		(FILE * _stream) ;




 

 










 



# 22 "main.c" 2

# 1 "/usr/include/memory.h" 1
 









 






# 1 "/usr/include/string.h" 1
 






# 113 "/usr/include/string.h"

# 18 "/usr/include/memory.h" 2



# 23 "main.c" 2


# 1 "bios.h" 1
 













 





# 1 "mytypes.h" 1
 













 



# 34 "mytypes.h"

# 21 "bios.h" 2




void init_bios(void);
void init_timer(void);
void bios_off(void);
void set_int(unsigned, BYTE *, unsigned, void (*)(void), BYTE *, unsigned);

void disable(void);
void enable(void);

void put_scancode(BYTE *code, int count);

BYTE read_port60(void);

void loc(void);

char *set_boot_file(char *);
char *set_boot_type(int);


# 25 "main.c" 2

# 1 "vga.h" 1
 













 







extern int mono;

void init_vga(void);
void vga_off(void);


# 26 "main.c" 2

# 1 "xstuff.h" 1
 
















void start_X(void);
void end_X(void);
void process_Xevents(void);
void flush_X(void);

void copy(unsigned, unsigned, unsigned, unsigned, unsigned, unsigned);
void draw_char(unsigned, unsigned, char, BYTE);
void draw_line(unsigned, unsigned, char *, unsigned, BYTE);
void clear_screen(void);
void window_size(unsigned, unsigned);

void new_cursor(int, int);
void put_cursor(unsigned, unsigned);
void unput_cursor(void);

extern int graphics,blink;

# 27 "main.c" 2

# 1 "hardware.h" 1
 
















# 1 "mytypes.h" 1
 













 



# 34 "mytypes.h"

# 18 "hardware.h" 2







int port60_buffer_ok(int);
void put_scancode(BYTE *, int);
void init_timer(void);

void disable(void);
void enable(void);

void starttimer(void);
void stoptimer(void);

BYTE read_port(unsigned);
void write_port(unsigned, BYTE);


# 28 "main.c" 2

# 1 "vgahard.h" 1
 













 





# 1 "mytypes.h" 1
 













 



# 34 "mytypes.h"

# 21 "vgahard.h" 2


void new_screen(unsigned, unsigned, BYTE *);
void refresh(void);
void update_display(void);
void displaychar(void);
void move_cursor(unsigned, unsigned);
void set_cursor_height(int, int);
void init_hardware(void);
void finish_hardware(void);
void copy_text(unsigned, unsigned, unsigned, unsigned, unsigned, unsigned);

void vga_interrupt(void);

char *set_update_rate(int);
char *set_cursor_rate(int);


# 29 "main.c" 2


BYTE *memory;
char *progname;

void exit_emu(void)
{
    disable();
    bios_off();
    vga_off();
    exit(0);
}


void check_error(char *msg, int line)
{
    if (msg)
        fprintf((&_iob[2]) ,"%s, line %d\n", msg, line);
}


void read_pcemurc(void)
{          
    FILE *f1;
    char buffer[1024];   
    char keyword[1024];
    char value[1024];
    int line = 0;
    int tmp;

     

    if ((f1 = fopen(".pcemurc","r")) == 0 )
    {            
        sprintf(buffer,"%s/.pcemurc", getenv("HOME"));
        if ((f1 = fopen(buffer,"r")) == 0 )
        {
            printf("Warning: .pcemurc not found - using compile time defaults\n");
            return;
        }
    }

    while (fgets(buffer,sizeof buffer,f1) != 0 )
    {
        line++;
        tmp = sscanf(buffer," %s %s", keyword, value);

        if (tmp == 0 || keyword[0] == '#')
            continue;
        if (tmp != 2)
        {
            check_error("Syntax error in .pcemu file", line);
            continue;
        }

        if (strcasecmp(keyword,"bootfile") == 0)
            check_error(set_boot_file(value), line);
        else if (strcasecmp(keyword,"boottype") == 0)
            check_error(set_boot_type(strtol(value, 0 ,10)), line);
        else if (strcasecmp(keyword,"updatespeed") == 0)
            check_error(set_update_rate(strtol(value, 0 ,10)), line);
        else if (strcasecmp(keyword,"cursorspeed") == 0)
            check_error(set_cursor_rate(strtol(value, 0 ,10)), line);
        else
            check_error("Syntax error in .pcemu file", line);
    }
    fclose(f1);
}           


void main(int argc, char **argv)
{
    progname = (progname = strrchr(argv[0],'/')) ? progname : argv[0];









    if (!(memory = (BYTE *)malloc((1024*1024+65536) )))
    {
        fprintf((&_iob[2]) ,"Insufficient available memory\n");
        exit(1);
    }

    memset(memory,0, (1024*1024+65536) );
# 128 "main.c"


    read_pcemurc();
    disable();

    start_X();
    init_cpu();
    init_bios();
    init_vga();
    init_timer();

    enable();

    execute();
    
     
}



