1 /*
2  * This file contains the code to display the rogue picture files
3  *
4  * load.c	1.42	(A.I. Design)	2/12/84
5  */
6 
7 #include	"rogue.h"
8 
9 #define MODESAVE  0x65
10 #define MODEREG   0x3d8
11 #define BWENABLE  0x4
12 #define COLREG	  0x3d9
13 #define HIGHENABLE 0x10
14 #define PALETTEBIT 0x20
15 
16 static char *store;
17 static int blksize = 0x4000, lfd;
18 
19 epyx_yuck()
20 {
21 	extern unsigned int tick;
22 	register int type = get_mode();
23 	char *sbrk();
24 
25 	if (type == 7 || (lfd = open("rogue.pic", 0)) < 0)
26 		return;
27 	while ((int) (store = sbrk(blksize)) == -1)
28 		blksize /= 2;
29 	video_mode(4);
30 	scr_load();
31 	tick = 0;
32 #ifdef LOGFILE
33 	while (tick < 18 * 10)
34 		;
35 #else
36 	while(no_char() && tick < 18 * 60 * 5)
37 		;
38 	if (!no_char())
39 		readchar();
40 #endif
41 	video_mode(type);
42 	brk(store);
43 	tick = 0;
44 }
45 
46 scr_load()
47 {
48 	int palette, background;
49 	int mode, burst;
50 
51 	bload(0xb800);
52 
53 	palette = peekb(8012,0xB800);
54 	background = peekb(8013,0xB800);
55 
56 	if (palette >= 3)
57 		background |= HIGHENABLE;
58 	burst   = 0;
59 	switch(palette)
60 	{
61 	case 2:
62 	case 5:
63 		burst = 1;
64 	case 0:
65 	case 3:
66 		palette = 1;
67 		break;
68 	case 1:
69 	case 4:
70 		palette = 0;
71 		break;
72 	}
73 
74 	out (COLREG,background);
75 	mode = peekb(MODESAVE,0x40) & (~BWENABLE);
76 	if (burst == 1)
77 		mode = mode | BWENABLE;
78 	pokeb(MODESAVE,0x40,mode);
79 	out(MODEREG,mode);
80 }
81 
82 bload(segment)
83 	unsigned segment;
84 {
85 	register unsigned offset = 0, rdcnt;
86 
87 	if (read(lfd,store,7) <= 0)				/* Ignore first seven bytes */
88 		lseek(lfd, 7L, 0);
89 	while ((rdcnt=read(lfd,store,blksize)) > 0) {
90 		dmaout(store,rdcnt/2,segment,offset);
91 		if ((offset += rdcnt) >= 16384)
92 			break;
93 	}
94 }
95 
96 find_drive()
97 {
98 	int drive = bdos(0x19);
99 	char spec = s_drive[0]; 
100 	char filename[30];
101 
102 	if (isalpha(spec))
103 	{
104 		if (isupper(spec))
105 			drive = spec - 'A';
106 		else
107 			drive = spec - 'a';
108 	}
109 	strcpy(filename,"a:jatgnas.8ys");
110 	filename[0] += (char)drive;
111 	access(filename);
112 	return drive;
113 }
114 