1 | /* xscreensaver, Copyright (c) 1998-2003 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 | |
---|
21 | typedef struct apple2_state { |
---|
22 | u_char hireslines[192][40]; |
---|
23 | u_char textlines[24][40]; |
---|
24 | int gr_text; |
---|
25 | enum { |
---|
26 | A2_GR_FULL=1, |
---|
27 | A2_GR_LORES=2, |
---|
28 | A2_GR_HIRES=4 |
---|
29 | } gr_mode; |
---|
30 | int cursx; |
---|
31 | int cursy; |
---|
32 | int blink; |
---|
33 | |
---|
34 | } apple2_state_t; |
---|
35 | |
---|
36 | |
---|
37 | typedef 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 | 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 | } apple2_sim_t; |
---|
65 | |
---|
66 | |
---|
67 | enum { |
---|
68 | A2_HCOLOR_BLACK=0, |
---|
69 | A2_HCOLOR_GREEN=1, |
---|
70 | A2_HCOLOR_PURPLE=2, |
---|
71 | A2_HCOLOR_WHITE=3, |
---|
72 | A2_HCOLOR_ALTBLACK=4, |
---|
73 | A2_HCOLOR_RED=5, |
---|
74 | A2_HCOLOR_BLUE=6, |
---|
75 | A2_HCOLOR_ALTWHITE=7 |
---|
76 | }; |
---|
77 | |
---|
78 | enum { |
---|
79 | A2CONTROLLER_DONE=-1, |
---|
80 | A2CONTROLLER_FREE=-2 |
---|
81 | }; |
---|
82 | |
---|
83 | extern void |
---|
84 | apple2(Display *dpy, Window window, int delay, |
---|
85 | void (*)(apple2_sim_t *sim, int *stepno, double *next_actiontime)); |
---|
86 | |
---|
87 | |
---|
88 | void a2_poke(apple2_state_t *st, int addr, int val); |
---|
89 | void a2_goto(apple2_state_t *st, int r, int c); |
---|
90 | void a2_cls(apple2_state_t *st); |
---|
91 | void a2_invalidate(apple2_state_t *st); |
---|
92 | |
---|
93 | void a2_add_disk_item(apple2_state_t *st, char *name, u_char *data, |
---|
94 | int len, char type); |
---|
95 | void a2_scroll(apple2_state_t *st); |
---|
96 | void a2_printc(apple2_state_t *st, char c); |
---|
97 | void a2_prints(apple2_state_t *st, char *s); |
---|
98 | void a2_goto(apple2_state_t *st, int r, int c); |
---|
99 | void a2_cls(apple2_state_t *st); |
---|
100 | void a2_clear_hgr(apple2_state_t *st); |
---|
101 | void a2_clear_gr(apple2_state_t *st); |
---|
102 | void a2_invalidate(apple2_state_t *st); |
---|
103 | void a2_poke(apple2_state_t *st, int addr, int val); |
---|
104 | void a2_display_image_loading(apple2_state_t *st, unsigned char *image, |
---|
105 | int lineno); |
---|
106 | void a2_init_memory_active(apple2_sim_t *sim); |
---|
107 | void a2_hplot(apple2_state_t *st, int hcolor, int x, int y); |
---|
108 | void a2_hline(apple2_state_t *st, int hcolor, int x1, int y1, int x2, int y2); |
---|
109 | void a2_plot(apple2_state_t *st, int color, int x, int y); |
---|
110 | |
---|
111 | #endif /* __XSCREENSAVER_APPLE_II__ */ |
---|