1 /*
2
3 HI demo for the XTile Graphics manager
4
5 COPYRIGHT (C) 1992 Erich P Gatejen All Rights Reserved
6
7
8 File: HI.C Written for the Turbo C compiler
9
10
11 This demo shows several of the features of XTile.
12 The file HI.DAT must be in the same directory as hi.exe.
13
14
15 */
16
17
18 #include<stdio.h>
19 #include<alloc.h>
20 #include<dos.h>
21 #include"xtile.h"
22
23
24 unsigned char *Screen; /* Input buffer for the background screen */
25 unsigned char *Hello; /* Input buffer for 'HIMOM' message */
26 unsigned char *Mask; /* Input buffer for 'HIMOM' mask */
27 unsigned char *Palette; /* Input buffer for palette data */
28
29
30 int Init() {
31
32
33 FILE *in;
34
35 /* Load data from "hi.dat" file into buffers */
36 if ((in = fopen ( "hi.dat", "rb" )) == NULL) return(1);
37
38 Screen = farmalloc( 64000 );
39 Hello = farmalloc( 4144 );
40 Mask = farmalloc( 1036 );
41 Palette = farmalloc( 768 );
42
43 if (( Screen == NULL) || ( Hello == NULL) || ( Mask == NULL ) ||
44 ( Palette == NULL) ) return(1);
45
46
47 fread ( Screen, sizeof( unsigned char ), 64000, in );
48 fread ( Hello, sizeof( unsigned char ), 4144, in );
49 fread ( Palette, sizeof( unsigned char ), 768, in );
50 fread ( Mask, sizeof( unsigned char ), 1036, in );
51
52 fclose ( in );
53
54
55 /* Set Mode X, load palette, and clear the screen */
56 Init_Mode_X();
57
58 Set_Pal_Color ( 218, 0, 0, 0 );
59
60 MSD_Clear( 218 );
61
62 Set_Pal_Block ( 0, 256, Palette );
63 Set_Pal_Color ( 218, 0, 0, 0 );
64
65 /* Upload the 'HIMOM */
66 MD_Upload_Tile( STORE, 4144, Hello );
67
68 /* Load screen to PAGE1 and the BACKGROUND */
69 Set_Display_Page( PAGE0 );
70 Set_Write_Page( BACKGROUND );
71 MS_Put_Tile( 0,40, 320, 200, Screen );
72 Set_Write_Page( PAGE1 );
73 MS_Put_Tile( 0,40, 320, 200, Screen );
74
75 return(0);
76
77
78 }; /* end Init */
79
80
81 void DoIt() {
82
83 int Red, Green, Blue;
84
85 unsigned int Step, PageF;
86
87 Red = 0;
88 Green = 0;
89
90 PageF = 1; /* PageF is current displayed screen */
91
92 /* Fade in back color */
93 for ( Blue = 0; Blue < 64; Blue++ ) {
94 Set_Pal_Color( 218, Red, Green, Blue );
95 Red++;
96 Green++;
97 if( Red > 52 ) Red = 52;
98 if( Green > 31 ) Green = 31;
99 };
100
101
102 /* Scroll to PAGE1 */
103 Screen_Scroll ( FORWARD, 120, 2 );
104
105 Set_Write_Page( PAGE0 );
106 MS_Put_Tile( 0,40, 320, 200, Screen );
107
108 delay( 2000 );
109
110 SD_Paste_Tile_M ( 86, 106, 148, 28, STORE, Mask );
111
112
113 /* Put 'HIMOM' on screen */
114 for ( Step = 1; Step < 14; Step++ ) {
115
116
117 SD_BKG_Restore( 86, 106, 148, ( 14 - Step )); /* Top */
118 SD_BKG_Restore( 86, (120 + Step), 148, 16 - Step ); /* Bottom */
119
120 if ( PageF == 0 ) {
121 Set_Write_Page( PAGE0 );
122 Set_Display_Page( PAGE1 );
123 PageF = 1;
124 } else {
125 Set_Write_Page( PAGE1 );
126 Set_Display_Page( PAGE0 );
127 PageF = 0;
128 };
129
130 delay( 2 );
131
132 SD_Paste_Tile_M ( 86, 106, 148, 28, STORE, Mask );
133 };
134
135 if ( PageF == 0 ) {
136 Set_Write_Page( PAGE0 );
137 Set_Display_Page( PAGE1 );
138 PageF = 1;
139 } else {
140 Set_Write_Page( PAGE1 );
141 Set_Display_Page( PAGE0 );
142 PageF = 0;
143 };
144
145
146 delay( 2100 );
147
148 /* Remove 'HIMOM' from screen */
149 for ( Step = 1; Step < 14; Step++ ) {
150
151
152 SD_BKG_Restore( 86, 106, 148, Step ); /* Top */
153 SD_BKG_Restore( 86, (134 - Step), 148, Step ); /* Bottom */
154
155 if ( PageF == 0 ) {
156 Set_Write_Page( PAGE0 );
157 Set_Display_Page( PAGE1 );
158 PageF = 1;
159 } else {
160 Set_Write_Page( PAGE1 );
161 Set_Display_Page( PAGE0 );
162 PageF = 0;
163 };
164
165 delay( 4 );
166
167 };
168
169 SD_BKG_Restore( 86, 106, 148, 28 ); /* All */
170
171 if ( PageF == 0 ) {
172 Set_Write_Page( PAGE0 );
173 Set_Display_Page( PAGE1 );
174 PageF = 1;
175 } else {
176 Set_Write_Page( PAGE1 );
177 Set_Display_Page( PAGE0 );
178 PageF = 0;
179 };
180 SD_BKG_Restore( 86, 106, 148, 28 ); /* All */
181
182 if ( PageF == 0 ) {
183 Set_Write_Page( PAGE0 );
184 Set_Display_Page( PAGE1 );
185 PageF = 1;
186 } else {
187 Set_Write_Page( PAGE1 );
188 Set_Display_Page( PAGE0 );
189 PageF = 0;
190 };
191
192 Set_Display_Page( PAGE1 );
193 Set_Write_Page( PAGE0 );
194
195 MS_Set_Box ( 0,0, 320, 240, 218 );
196
197 delay( 2500 );
198
199 Screen_Scroll ( BACK, 120, 2 );
200
201 Red = 52;
202 Green = 31;
203 /* Fade in back color */
204 for ( Blue = 63; Blue >= 0; Blue-- ) {
205 Set_Pal_Color( 218, Red, Green, Blue );
206 Red--;
207 Green--;
208 if( Red < 0 ) Red = 0;
209 if( Green < 0 ) Green = 0;
210 };
211
212 delay( 500 );
213
214
215 }; /* end DoIt */
216
217
218 void Done() {
219
220 union REGS in, out;
221
222 /* Return screen to text mode */
223 in.x.ax = 3;
224 int86( 16, &in, &out );
225
226
227 }; /* end Done */
228
229
230 void main () {
231
232 int Status;
233
234 Status = Init();
235 if ( Status == 0 ) DoIt();
236 Done();
237
238
239 };
|