This repository has been archived by the owner on Jan 3, 2019. It is now read-only.
forked from mtuomi/SecondReality
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDOLOOP.OK
executable file
·155 lines (144 loc) · 3.13 KB
/
DOLOOP.OK
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#include <stdio.h>
#include <conio.h>
#include <stdarg.h>
int depth=2;
int bail=150;
int group=150;
FILE *f1;
void P(char *str,...)
{
char out[256];
va_list argp;
va_start(argp,str);
vsprintf(out,str,argp);
fprintf(f1,"%s\n",out);
va_end(argp);
}
long weirdflip(unsigned long l)
{
long m,lo,hi;
lo=l&0xffff;
hi=l>>16;
m=(lo<<16)+hi;
return(m);
}
main()
{
int i,j,jm,y,a;
long l;
f1=fopen("theloop.inc","wt");
P(";Register usage: ");
P(";eax low... ray heigth ");
P(";ebx - p->screen ");
P(";ecx low... ray direction (always negative)");
P(";edx - scenary heigth ");
P(";esi - xsin ");
P(";edi - ysin ");
P(";ebp - p->ray_dir_table");
P(";ds ->codesegment");
P(";es ->screenbuffer");
P(";fs ->wavetable");
P(";gs -");
P("");
P("ALIGN 16 ;following should stay in cache");
P("theloop_waveseg dw 0");
P("theloop_xsina dw 0");
P("theloop_ysina dw 0");
P("theloop_heigth dw 0");
P("theloop_raydir LABEL DWORD");
for(y=0;y<200;y++)
{
a=(199-y)-100;
l=-(long)a*10L*256L*depth;
l=weirdflip(l);
P("dd 0%08lXh",l);
}
P("");
P(";entry: es=videbuf");
P("; bp=pointer to bottom of current column in videbuf");
P("; fs=waveXsegment");
P("; gs=waveYsegment");
P("; si=waveXpos");
P("; di=waveYpos");
P("; cx=waveXadd");
P("; dx=waveYadd");
P("; ax=camera heigth adder");
P("theloop PROC FAR");
P("mov bx,bp");
P("mov cs:theloop_xsina,cx");
P("mov cs:theloop_ysina,dx");
P("mov cs:theloop_heigth,ax");
P("mov bp,OFFSET theloop_raydir");
P("mov ax,cs");
P("mov ds,ax");
P("xor eax,eax");
P("mov ecx,ds:[bp]");
P("add bp,4");
for(i=0;i<bail;i+=group)
{
jm=i+group; if(jm>bail) jm=bail;
for(j=i;j<jm;j++)
{
printf("%i\r",j);
P("_@seek%i:",j);
P("add si,ds:theloop_xsina");
P("xor dh,dh");
P("mov dl,fs:[si]");
P("add di,ds:theloop_ysina");
P("add dl,gs:[di]");
P("add dx,ds:theloop_heigth");
P("cmp ax,dx");
P("jge short _@seeko%i",j);
l=j*10L*256*depth;
l=weirdflip(l);
P("_@hit%i:",j);
P("add eax,0%08lXh",l);
P("adc ax,0");
P("mov es:[bx],dl");
P("cmp ax,dx");
P("jge short _@seek1a%i",j);
P("add eax,0%08lXh",l);
P("adc ax,0");
P("mov es:[bx-320],dl");
P("cmp ax,dx");
P("jge short _@seek2a%i",j);
P("add eax,0%08lXh",l);
P("adc ax,0");
P("mov es:[bx-640],dl");
P("cmp ax,dx");
P("jge short _@seek3a%i",j);
P("add eax,0%08lXh",l);
P("adc ax,0");
P("mov es:[bx-960],dl");
P("add bp,4*4");
P("sub bx,320*4");
P("cmp ax,dx");
P("jge short _@seek0a%i",j);
P("jmp _@hit%i",j);
P("_@seek3a%i:",j);
P("add bp,4");
P("sub bx,320");
P("_@seek2a%i:",j);
P("add bp,4");
P("sub bx,320");
P("_@seek1a%i:",j);
P("add bp,4");
P("sub bx,320");
P("_@seek0a%i:",j);
P("mov ecx,ds:[bp]");
P("_@seeko%i:",j);
P("add eax,ecx");
P("adc ax,-1");
}
if(jm>=bail)
{
P("_@seek%i:",bail);
P("_@seekr%i:",bail);
P("ret");
}
else P("jmp _@seek%i",jm);
}
P("theloop ENDP");
printf(" \r",i);
fclose(f1);
}