http://slackware.bholcomb.com/slackware/slackware-11.0/source/xap/xscreensaver/xscree...
[xscreensaver] / hacks / apple2.h
1 /* xscreensaver, Copyright (c) 1998-2004 Jamie Zawinski <jwz@jwz.org>
2  *
3  * Permission to use, copy, modify, distribute, and sell this software and its
4  * documentation for any purpose is hereby granted without fee, provided that
5  * the above copyright notice appear in all copies and that both that
6  * copyright notice and this permission notice appear in supporting
7  * documentation.  No representations are made about the suitability of this
8  * software for any purpose.  It is provided "as is" without express or 
9  * implied warranty.
10  *
11  * Apple ][ CRT simulator, by Trevor Blackwell <tlb@tlb.org>
12  * with additional work by Jamie Zawinski <jwz@jwz.org>
13  */
14
15 #ifndef __XSCREENSAVER_APPLE_II__
16 #define __XSCREENSAVER_APPLE_II__
17
18 #include "analogtv.h"
19
20 typedef struct apple2_state {
21   unsigned char hireslines[192][40];
22   unsigned char textlines[24][40];
23   int gr_text;
24   enum {
25     A2_GR_FULL=1,
26     A2_GR_LORES=2,
27     A2_GR_HIRES=4
28   } gr_mode;
29   int cursx;
30   int cursy;
31   int blink;
32
33 } apple2_state_t;
34
35
36 typedef struct apple2_sim_s apple2_sim_t;
37 struct apple2_sim_s {
38   
39   void *controller_data;
40
41   apple2_state_t *st;
42
43   analogtv *dec;
44   analogtv_input *inp;
45   analogtv_reception reception;
46
47   const char *typing;
48   char typing_buf[1024];
49   double typing_rate;
50
51   char *printing;
52   char printing_buf[1024];
53
54   char prompt;
55
56   Display *dpy;
57   Window window;
58   XWindowAttributes xgwa;
59   XImage *text_im;
60
61   struct timeval basetime_tv;
62   double curtime;
63   double delay;
64
65   int stepno;
66   double next_actiontime;
67   void (*controller)(apple2_sim_t *sim,
68                      int *stepno,
69                      double *next_actiontime);
70
71 };
72
73
74 enum {
75   A2_HCOLOR_BLACK=0,
76   A2_HCOLOR_GREEN=1,
77   A2_HCOLOR_PURPLE=2,
78   A2_HCOLOR_WHITE=3,
79   A2_HCOLOR_ALTBLACK=4,
80   A2_HCOLOR_RED=5,
81   A2_HCOLOR_BLUE=6,
82   A2_HCOLOR_ALTWHITE=7
83  };
84
85 enum {
86   A2CONTROLLER_DONE=-1,
87   A2CONTROLLER_FREE=-2
88 };
89
90
91 extern apple2_sim_t * apple2_start (Display *, Window, int delay,
92                                     void (*)(apple2_sim_t *, int *stepno,
93                                              double *next_actiontime));
94 extern int apple2_one_frame (apple2_sim_t *);
95
96
97 void a2_poke(apple2_state_t *st, int addr, int val);
98 void a2_goto(apple2_state_t *st, int r, int c);
99 void a2_cls(apple2_state_t *st);
100 void a2_invalidate(apple2_state_t *st);
101
102 void a2_add_disk_item(apple2_state_t *st, char *name, unsigned char *data,
103                       int len, char type);
104 void a2_scroll(apple2_state_t *st);
105 void a2_printc(apple2_state_t *st, char c);
106 void a2_printc_noscroll(apple2_state_t *st, char c);
107 void a2_prints(apple2_state_t *st, char *s);
108 void a2_goto(apple2_state_t *st, int r, int c);
109 void a2_cls(apple2_state_t *st);
110 void a2_clear_hgr(apple2_state_t *st);
111 void a2_clear_gr(apple2_state_t *st);
112 void a2_invalidate(apple2_state_t *st);
113 void a2_poke(apple2_state_t *st, int addr, int val);
114 void a2_display_image_loading(apple2_state_t *st, unsigned char *image,
115                               int lineno);
116 void a2_init_memory_active(apple2_sim_t *sim);
117 void a2_hplot(apple2_state_t *st, int hcolor, int x, int y);
118 void a2_hline(apple2_state_t *st, int hcolor, int x1, int y1, int x2, int y2);
119 void a2_plot(apple2_state_t *st, int color, int x, int y);
120
121 #endif /* __XSCREENSAVER_APPLE_II__ */