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