-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmode6.c
More file actions
306 lines (257 loc) · 7.44 KB
/
Copy pathmode6.c
File metadata and controls
306 lines (257 loc) · 7.44 KB
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
/*
* This file is part of the V95bench distribution (https://github.com/viti95/V95bench).
* Copyright (c) 2022 Víctor Nieto.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "mode6.h"
#include "timer.h"
#include "file.h"
#include "messages.h"
#include <dos.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#define PREHEAT_LOOPS 100L
#define BENCH_TIME 5000L
unsigned long total_loops_mode6;
unsigned long timespent_w8_mode6;
unsigned long timespent_r8_mode6;
unsigned long timespent_w16_mode6;
unsigned long timespent_r16_mode6;
#ifdef __386__
unsigned long timespent_w32_mode6;
unsigned long timespent_r32_mode6;
#endif
void init_mode6(void)
{
union REGS regs;
// Set video mode 6
regs.w.ax = 0x06;
#ifdef __386__
int386(0x10, ®s, ®s);
#else
int86(0x10, ®s, ®s);
#endif
}
void preheat_mode6(unsigned long total_loops)
{
total_loops_mode6 = total_loops;
bench_w8_mode6();
}
void bench_w8_mode6(void)
{
#ifdef __386__
unsigned char *vram;
#else
unsigned char far *vram;
#endif
unsigned int num_loops = total_loops_mode6;
do
{
#ifdef __386__
for (vram = (unsigned char *)0xB8000; vram < (unsigned char *)0xB9F40; vram += 4)
#else
for (vram = MK_FP(0xB800, 0); vram < MK_FP(0xB800, 0x1F40); vram += 4)
#endif
{
*(vram) = 0x6B;
*(vram + 1) = 0x6B;
*(vram + 2) = 0x6B;
*(vram + 3) = 0x6B;
*(vram + 0x2000) = 0x6B;
*(vram + 0x2001) = 0x6B;
*(vram + 0x2002) = 0x6B;
*(vram + 0x2003) = 0x6B;
}
} while (num_loops-- != 0);
}
void bench_w16_mode6(void)
{
#ifdef __386__
unsigned short *vram;
#else
unsigned short far *vram;
#endif
unsigned int num_loops = total_loops_mode6;
do
{
#ifdef __386__
for (vram = (unsigned short *)0xB8000; vram < (unsigned short *)0xB9F40; vram += 4)
#else
for (vram = MK_FP(0xB800, 0); vram < MK_FP(0xB800, 0x1F40); vram += 4)
#endif
{
*(vram) = 0xB53A;
*(vram + 1) = 0xB53A;
*(vram + 2) = 0xB53A;
*(vram + 3) = 0xB53A;
*(vram + 0x1000) = 0xB53A;
*(vram + 0x1001) = 0xB53A;
*(vram + 0x1002) = 0xB53A;
*(vram + 0x1003) = 0xB53A;
}
} while (num_loops-- != 0);
}
#ifdef __386__
void bench_w32_mode6(void)
{
unsigned int *vram;
unsigned int num_loops = total_loops_mode6;
do
{
for (vram = (unsigned int *)0xB8000; vram < (unsigned int *)0xB9F40; vram += 4)
{
*(vram) = 0xBA860131;
*(vram + 1) = 0xBA860131;
*(vram + 2) = 0xBA860131;
*(vram + 3) = 0xBA860131;
*(vram + 0x800) = 0xBA860131;
*(vram + 0x801) = 0xBA860131;
*(vram + 0x802) = 0xBA860131;
*(vram + 0x803) = 0xBA860131;
}
} while (num_loops-- != 0);
}
#endif
void bench_r8_mode6(void)
{
#ifdef __386__
unsigned char *vram;
#else
unsigned char far *vram;
#endif
unsigned int num_loops = total_loops_mode6;
unsigned char read1, read2, read3, read4;
do
{
#ifdef __386__
for (vram = (unsigned char *)0xB8000; vram < (unsigned char *)0xB9F40; vram += 2)
#else
for (vram = MK_FP(0xB800, 0); vram < MK_FP(0xB800, 0x1F40); vram += 2)
#endif
{
read1 = *(vram);
read2 = *(vram + 1);
read3 = *(vram + 0x2000);
read4 = *(vram + 0x2001);
}
} while (num_loops-- != 0);
read_fix_8b_1 = read1;
read_fix_8b_2 = read2;
read_fix_8b_3 = read3;
read_fix_8b_4 = read4;
}
void bench_r16_mode6(void)
{
#ifdef __386__
unsigned short *vram;
#else
unsigned short far *vram;
#endif
unsigned int num_loops = total_loops_mode6;
unsigned short read1, read2, read3, read4;
do
{
#ifdef __386__
for (vram = (unsigned short *)0xB8000; vram < (unsigned short *)0xB9F40; vram += 2)
#else
for (vram = MK_FP(0xB800, 0); vram < MK_FP(0xB800, 0x1F40); vram += 2)
#endif
{
read1 = *(vram);
read2 = *(vram + 1);
read3 = *(vram + 0x1000);
read4 = *(vram + 0x1001);
}
} while (num_loops-- != 0);
read_fix_16b_1 = read1;
read_fix_16b_2 = read2;
read_fix_16b_3 = read3;
read_fix_16b_4 = read4;
}
#ifdef __386__
void bench_r32_mode6(void)
{
unsigned int *vram;
unsigned int num_loops = total_loops_mode6;
unsigned int read1, read2, read3, read4;
do
{
for (vram = (unsigned int *)0xB8000; vram < (unsigned int *)0xB9F40; vram += 2)
{
read1 = *(vram);
read2 = *(vram + 1);
read3 = *(vram + 0x800);
read4 = *(vram + 0x801);
}
} while (num_loops-- != 0);
read_fix_32b_1 = read1;
read_fix_32b_2 = read2;
read_fix_32b_3 = read3;
read_fix_32b_4 = read4;
}
#endif
void execute_bench_mode6(void)
{
unsigned long preheat_loops = PREHEAT_LOOPS;
// SET VIDEO MODE
init_mode6();
// PRE-HEAT
do
{
timespent_w8_mode6 = profile_function_loops(preheat_mode6, preheat_loops);
preheat_loops *= 2;
} while (timespent_w8_mode6 == 0);
preheat_loops /= 2;
total_loops_mode6 = preheat_loops * BENCH_TIME / timespent_w8_mode6;
#ifndef __386__
// Fix for 16-bit executables
if (total_loops_mode6 > 65535)
total_loops_mode6 = 65535;
#endif
// BENCHMARK
timespent_w8_mode6 = profile_function(bench_w8_mode6);
timespent_r8_mode6 = profile_function(bench_r8_mode6);
timespent_w16_mode6 = profile_function(bench_w16_mode6);
timespent_r16_mode6 = profile_function(bench_r16_mode6);
#ifdef __386__
timespent_w32_mode6 = profile_function(bench_w32_mode6);
timespent_r32_mode6 = profile_function(bench_r32_mode6);
#endif
}
void get_results_mode6(unsigned char to_file)
{
double total_result_w;
double total_result_r;
total_result_w = calc_kb_second(total_loops_mode6, 15.625, timespent_w8_mode6);
total_result_r = calc_kb_second(total_loops_mode6, 15.625, timespent_r8_mode6);
if (to_file)
fprintf(logFile, MSG_MODE6_8BIT, total_result_w, total_result_r);
else
printf(MSG_MODE6_8BIT, total_result_w, total_result_r);
total_result_w = calc_kb_second(total_loops_mode6, 15.625, timespent_w16_mode6);
total_result_r = calc_kb_second(total_loops_mode6, 15.625, timespent_r16_mode6);
if (to_file)
fprintf(logFile, MSG_GENERIC_16BIT + 8, total_result_w, total_result_r);
else
printf(MSG_GENERIC_16BIT + 8, total_result_w, total_result_r);
#ifdef __386__
total_result_w = calc_kb_second(total_loops_mode6, 15.625, timespent_w32_mode6);
total_result_r = calc_kb_second(total_loops_mode6, 15.625, timespent_r32_mode6);
if (to_file)
fprintf(logFile, MSG_GENERIC_32BIT + 8, total_result_w, total_result_r);
else
printf(MSG_GENERIC_32BIT + 8, total_result_w, total_result_r);
#endif
}