~ubuntu-branches/ubuntu/karmic/zsnes/karmic

« back to all changes in this revision

Viewing changes to src/video/newgfxb.mac

  • Committer: Bazaar Package Importer
  • Author(s): Joshua Kwan
  • Date: 2007-06-04 21:46:47 UTC
  • mfrom: (1.2.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070604214647-j5zowa8vplkug0yj
Tags: 1.510-1
* New upstream release - all patches merged. closes: #380734, #419270
* Add a .desktop file, thanks Nicholas Wheeler. closes: #367942
* Include a ton of documentation that ships with the tarball.
  closes: #392143 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
;Copyright (C) 1997-2005 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach )
2
 
;
3
 
;http://www.zsnes.com
4
 
;http://sourceforge.net/projects/zsnes
5
 
;
6
 
;This program is free software; you can redistribute it and/or
7
 
;modify it under the terms of the GNU General Public License
8
 
;as published by the Free Software Foundation; either
9
 
;version 2 of the License, or (at your option) any later
10
 
;version.
11
 
;
12
 
;This program is distributed in the hope that it will be useful,
13
 
;but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
;MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
;GNU General Public License for more details.
16
 
;
17
 
;You should have received a copy of the GNU General Public License
18
 
;along with this program; if not, write to the Free Software
19
 
;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
 
 
21
 
 
22
 
 
23
 
 
24
 
 
25
 
 
26
 
 
27
 
 
28
 
%macro Procbgpr0 5
29
 
    ; Draw BG 2
30
 
    ; Start line by line drawing/check
31
 
    mov esi,[vidbuffer]
32
 
    add esi,16
33
 
;    add esi,16+288
34
 
    xor ebx,ebx
35
 
%%nextline
36
 
    cmp byte[BGFB+ebx],0
37
 
    jne %%nogo
38
 
    test dword[BGMS1+ebx*2],%4
39
 
    jz %%nogo
40
 
    test dword[BGMS1+ebx*2],%5
41
 
    jnz %%nogo
42
 
    ; Check if at a tile alignment
43
 
    mov ecx,[BG1SYl+ebx*2+%1*512]
44
 
    and ecx,0FFFFh
45
 
    add ecx,ebx
46
 
    test ecx,07h
47
 
    jz %%tilecheck
48
 
%%proclinebyline
49
 
    ; process line by line
50
 
    call %2
51
 
%%nogo
52
 
    inc ebx
53
 
    add esi,288
54
 
    cmp [resolutn],bx
55
 
    jne %%nextline
56
 
    jmp %%donextbg
57
 
%%tilecheck
58
 
    mov eax,[BG1SXl+ebx*2+%1*512]
59
 
    cmp ax,[BG1SXl+ebx*2+2+%1*512]
60
 
    jne %%proclinebyline
61
 
    cmp eax,[BG1SXl+ebx*2+4+%1*512]
62
 
    jne %%proclinebyline
63
 
    cmp eax,[BG1SXl+ebx*2+8+%1*512]
64
 
    jne %%proclinebyline
65
 
    cmp eax,[BG1SXl+ebx*2+12+%1*512]
66
 
    jne %%proclinebyline
67
 
    mov eax,[BG1SYl+ebx*2+%1*512]
68
 
    cmp ax,[BG1SYl+ebx*2+2+%1*512]
69
 
    jne %%proclinebyline
70
 
    cmp eax,[BG1SYl+ebx*2+4+%1*512]
71
 
    jne %%proclinebyline
72
 
    cmp eax,[BG1SYl+ebx*2+8+%1*512]
73
 
    jne %%proclinebyline
74
 
    cmp eax,[BG1SYl+ebx*2+12+%1*512]
75
 
    jne %%proclinebyline
76
 
    test dword[BGMS1+ebx*2+14],%4
77
 
    jz near %%proclinebyline
78
 
    test dword[BGMS1+ebx*2+14],%5
79
 
    jnz near %%proclinebyline
80
 
    cmp ebx,[reslbyl]
81
 
    jae near %%proclinebyline
82
 
    mov eax,[BGMA+ebx]
83
 
    cmp eax,[BGMA+ebx+4]
84
 
    jne near %%proclinebyline
85
 
    mov eax,[BGOPT1+ebx*2+%1*512]
86
 
    cmp ax,[BGOPT1+ebx*2+2+%1*512]
87
 
    jne near %%proclinebyline
88
 
    cmp eax,[BGOPT1+ebx*2+4+%1*512]
89
 
    jne near %%proclinebyline
90
 
    cmp eax,[BGOPT1+ebx*2+8+%1*512]
91
 
    jne near %%proclinebyline
92
 
    cmp eax,[BGOPT1+ebx*2+12+%1*512]
93
 
    jne near %%proclinebyline
94
 
    mov eax,[BGPT1+ebx*2+%1*512]
95
 
    cmp ax,[BGPT1+ebx*2+2+%1*512]
96
 
    jne near %%proclinebyline
97
 
    cmp eax,[BGPT1+ebx*2+4+%1*512]
98
 
    jne near %%proclinebyline
99
 
    cmp eax,[BGPT1+ebx*2+8+%1*512]
100
 
    jne near %%proclinebyline
101
 
    cmp eax,[BGPT1+ebx*2+12+%1*512]
102
 
    jne near %%proclinebyline
103
 
    mov eax,[BGPT1X+ebx*2+%1*512]
104
 
    cmp ax,[BGPT1X+ebx*2+2+%1*512]
105
 
    jne near %%proclinebyline
106
 
    cmp eax,[BGPT1X+ebx*2+4+%1*512]
107
 
    jne near %%proclinebyline
108
 
    cmp eax,[BGPT1X+ebx*2+8+%1*512]
109
 
    jne near %%proclinebyline
110
 
    cmp eax,[BGPT1X+ebx*2+12+%1*512]
111
 
    jne near %%proclinebyline
112
 
    mov eax,[BGPT1Y+ebx*2+%1*512]
113
 
    cmp ax,[BGPT1Y+ebx*2+2+%1*512]
114
 
    jne near %%proclinebyline
115
 
    cmp eax,[BGPT1Y+ebx*2+4+%1*512]
116
 
    jne near %%proclinebyline
117
 
    cmp eax,[BGPT1Y+ebx*2+8+%1*512]
118
 
    jne near %%proclinebyline
119
 
    cmp eax,[BGPT1Y+ebx*2+12+%1*512]
120
 
    jne near %%proclinebyline
121
 
    mov eax,[BGMS1+ebx]
122
 
    cmp eax,[BGMS1+ebx+4]
123
 
    jne near %%proclinebyline
124
 
    cmp eax,[BGMS1+ebx+8]
125
 
    jne near %%proclinebyline
126
 
    cmp eax,[BGMS1+ebx+12]
127
 
    jne near %%proclinebyline
128
 
    mov eax,[BGFB+ebx]
129
 
    cmp eax,[BGFB+ebx+4]
130
 
    jne near %%proclinebyline
131
 
    mov eax,[t16x161+ebx+%1*256]
132
 
    cmp eax,[t16x161+ebx+4+%1*256]
133
 
    jne near %%proclinebyline
134
 
    cmp byte[BGMA+ebx],5
135
 
    jae near %%proclinebyline
136
 
    cmp byte[BGMA+ebx],2
137
 
    je near %%proclinebyline
138
 
    test dword[intrlng+ebx],01010101h
139
 
    jnz near %%proclinebyline
140
 
    test dword[intrlng+ebx+4],01010101h
141
 
    jnz near %%proclinebyline
142
 
    test byte[mosenng+ebx],1 << %1
143
 
    jnz %%mosaic
144
 
%%nomosaic
145
 
    call %3
146
 
    add ebx,8
147
 
    add esi,288*8
148
 
    cmp [resolutn],bx
149
 
    ja near %%nextline
150
 
    jmp %%donextbg
151
 
%%mosaic
152
 
    cmp byte[mosszng+ebx],0
153
 
    je %%nomosaic
154
 
    jmp %%proclinebyline
155
 
%%donextbg
156
 
%endmacro
157
 
 
158
 
%macro Procbg3pr0 5
159
 
    ; Draw BG 2
160
 
    ; Start line by line drawing/check
161
 
    mov esi,[vidbuffer]
162
 
    add esi,16
163
 
;    add esi,16+288
164
 
    xor ebx,ebx
165
 
%%nextline
166
 
    cmp byte[BGFB+ebx],0
167
 
    jne %%nogo
168
 
    test dword[BGMS1+ebx*2],%4
169
 
    jz %%nogo
170
 
    test dword[BGMS1+ebx*2],%5
171
 
    jnz %%nogo
172
 
    ; Check if at a tile alignment
173
 
    mov ecx,[BG1SYl+ebx*2+%1*512]
174
 
    and ecx,0FFFFh
175
 
    add ecx,ebx
176
 
    test ecx,07h
177
 
    jz %%tilecheck
178
 
%%proclinebyline
179
 
    ; process line by line
180
 
    call %2
181
 
%%nogo
182
 
    inc ebx
183
 
    add esi,288
184
 
    cmp [resolutn],bx
185
 
    jne %%nextline
186
 
    jmp %%donextbg
187
 
%%tilecheck
188
 
    mov eax,[BG1SXl+ebx*2+%1*512]
189
 
    cmp ax,[BG1SXl+ebx*2+2+%1*512]
190
 
    jne %%proclinebyline
191
 
    cmp eax,[BG1SXl+ebx*2+4+%1*512]
192
 
    jne %%proclinebyline
193
 
    cmp eax,[BG1SXl+ebx*2+8+%1*512]
194
 
    jne %%proclinebyline
195
 
    cmp eax,[BG1SXl+ebx*2+12+%1*512]
196
 
    jne %%proclinebyline
197
 
    mov eax,[BG1SYl+ebx*2+%1*512]
198
 
    cmp ax,[BG1SYl+ebx*2+2+%1*512]
199
 
    jne %%proclinebyline
200
 
    cmp eax,[BG1SYl+ebx*2+4+%1*512]
201
 
    jne %%proclinebyline
202
 
    cmp eax,[BG1SYl+ebx*2+8+%1*512]
203
 
    jne %%proclinebyline
204
 
    cmp eax,[BG1SYl+ebx*2+12+%1*512]
205
 
    jne %%proclinebyline
206
 
    test dword[BGMS1+ebx*2+14],%4
207
 
    jz near %%proclinebyline
208
 
    test dword[BGMS1+ebx*2+14],%5
209
 
    jnz near %%proclinebyline
210
 
    cmp ebx,[reslbyl]
211
 
    jae near %%proclinebyline
212
 
    mov eax,[BGMA+ebx]
213
 
    cmp eax,[BGMA+ebx+4]
214
 
    jne near %%proclinebyline
215
 
    mov eax,[BGOPT1+ebx*2+%1*512]
216
 
    cmp ax,[BGOPT1+ebx*2+2+%1*512]
217
 
    jne near %%proclinebyline
218
 
    cmp eax,[BGOPT1+ebx*2+4+%1*512]
219
 
    jne near %%proclinebyline
220
 
    cmp eax,[BGOPT1+ebx*2+8+%1*512]
221
 
    jne near %%proclinebyline
222
 
    cmp eax,[BGOPT1+ebx*2+12+%1*512]
223
 
    jne near %%proclinebyline
224
 
    mov eax,[BGPT1+ebx*2+%1*512]
225
 
    cmp ax,[BGPT1+ebx*2+2+%1*512]
226
 
    jne near %%proclinebyline
227
 
    cmp eax,[BGPT1+ebx*2+4+%1*512]
228
 
    jne near %%proclinebyline
229
 
    cmp eax,[BGPT1+ebx*2+8+%1*512]
230
 
    jne near %%proclinebyline
231
 
    cmp eax,[BGPT1+ebx*2+12+%1*512]
232
 
    jne near %%proclinebyline
233
 
    mov eax,[BGPT1X+ebx*2+%1*512]
234
 
    cmp ax,[BGPT1X+ebx*2+2+%1*512]
235
 
    jne near %%proclinebyline
236
 
    cmp eax,[BGPT1X+ebx*2+4+%1*512]
237
 
    jne near %%proclinebyline
238
 
    cmp eax,[BGPT1X+ebx*2+8+%1*512]
239
 
    jne near %%proclinebyline
240
 
    cmp eax,[BGPT1X+ebx*2+12+%1*512]
241
 
    jne near %%proclinebyline
242
 
    mov eax,[BGPT1Y+ebx*2+%1*512]
243
 
    cmp ax,[BGPT1Y+ebx*2+2+%1*512]
244
 
    jne near %%proclinebyline
245
 
    cmp eax,[BGPT1Y+ebx*2+4+%1*512]
246
 
    jne near %%proclinebyline
247
 
    cmp eax,[BGPT1Y+ebx*2+8+%1*512]
248
 
    jne near %%proclinebyline
249
 
    cmp eax,[BGPT1Y+ebx*2+12+%1*512]
250
 
    jne near %%proclinebyline
251
 
    mov eax,[BGMS1+ebx]
252
 
    cmp eax,[BGMS1+ebx+4]
253
 
    jne near %%proclinebyline
254
 
    cmp eax,[BGMS1+ebx+8]
255
 
    jne near %%proclinebyline
256
 
    cmp eax,[BGMS1+ebx+12]
257
 
    jne near %%proclinebyline
258
 
    mov eax,[BG3PRI+ebx]
259
 
    cmp eax,[BG3PRI+ebx+4]
260
 
    jne near %%proclinebyline
261
 
    mov eax,[BGFB+ebx]
262
 
    cmp eax,[BGFB+ebx+4]
263
 
    jne near %%proclinebyline
264
 
    mov eax,[t16x161+ebx+%1*256]
265
 
    cmp eax,[t16x161+ebx+4+%1*256]
266
 
    jne near %%proclinebyline
267
 
    test dword[intrlng+ebx],01010101h
268
 
    jnz near %%proclinebyline
269
 
    test dword[intrlng+ebx+4],01010101h
270
 
    jnz near %%proclinebyline
271
 
    test byte[mosenng+ebx],1 << %1
272
 
    jnz %%mosaic
273
 
%%nomosaic
274
 
    call %3
275
 
    add ebx,8
276
 
    add esi,288*8
277
 
    cmp [resolutn],bx
278
 
    ja near %%nextline
279
 
%%mosaic
280
 
    cmp byte[mosszng+ebx],0
281
 
    je %%nomosaic
282
 
    jmp %%proclinebyline
283
 
%%donextbg
284
 
%endmacro
285
 
 
286
 
%macro Procbgpr1 6
287
 
    ; Draw BG
288
 
    ; Start line by line drawing/check
289
 
    mov esi,[vidbuffer]
290
 
    add esi,16
291
 
;    add esi,16+288
292
 
    xor ebx,ebx
293
 
%%nextline
294
 
    cmp byte[BGFB+ebx],0
295
 
    jne %%nogo
296
 
    test dword[BGMS1+ebx*2],%5
297
 
    jz %%nogo
298
 
    test dword[BGMS1+ebx*2],%6
299
 
    jnz %%nogo
300
 
    ; Check if at a tile alignment
301
 
    cmp byte[%4+ebx],1
302
 
    je %%tile
303
 
%%proclinebyline
304
 
    ; process line by line
305
 
    call %2
306
 
%%nogo
307
 
    inc ebx
308
 
    add esi,288
309
 
    cmp [resolutn],bx
310
 
    jne %%nextline
311
 
    jmp %%donextbg
312
 
%%tile
313
 
    call %3
314
 
    add ebx,8
315
 
    add esi,288*8
316
 
    cmp [resolutn],bx
317
 
    ja %%nextline
318
 
%%donextbg
319
 
%endmacro
320
 
 
321
 
%macro Procbg3pr1 6
322
 
    ; Draw BG 2
323
 
    ; Start line by line drawing/check
324
 
    mov esi,[vidbuffer]
325
 
    add esi,16
326
 
    xor ebx,ebx
327
 
%%nextline
328
 
    cmp byte[BGFB+ebx],0
329
 
    jne %%nogo
330
 
    test dword[BGMS1+ebx*2],%5
331
 
    jz %%nogo
332
 
    test dword[BGMS1+ebx*2],%6
333
 
    jnz %%nogo
334
 
    cmp byte[BGMA+ebx],1
335
 
    jne %%nomode1
336
 
    cmp byte[BG3PRI+ebx],0
337
 
    jne %%nogo
338
 
%%nomode1
339
 
    ; Check if at a tile alignment
340
 
    cmp byte[%4+ebx],1
341
 
    je %%tile
342
 
%%proclinebyline
343
 
    ; process line by line
344
 
    call %2
345
 
%%nogo
346
 
    inc ebx
347
 
    add esi,288
348
 
    cmp [resolutn],bx
349
 
    jne %%nextline
350
 
    jmp %%donextbg
351
 
%%tile
352
 
    call %3
353
 
    add ebx,8
354
 
    add esi,288*8
355
 
    cmp [resolutn],bx
356
 
    ja %%nextline
357
 
%%donextbg
358
 
%endmacro
359
 
 
360
 
%macro Procbg3pr1b 6
361
 
    ; Draw BG 2
362
 
    ; Start line by line drawing/check
363
 
    mov esi,[vidbuffer]
364
 
    add esi,16
365
 
    xor ebx,ebx
366
 
%%nextline
367
 
    cmp byte[BGFB+ebx],0
368
 
    jne %%nogo
369
 
    test dword[BGMS1+ebx*2],%5
370
 
    jz %%nogo
371
 
    test dword[BGMS1+ebx*2],%6
372
 
    jnz %%nogo
373
 
    cmp byte[BGMA+ebx],1
374
 
    jne %%nogo
375
 
    cmp byte[BG3PRI+ebx],0
376
 
    je %%nogo
377
 
    ; Check if at a tile alignment
378
 
    cmp byte[%4+ebx],1
379
 
    je %%tile
380
 
%%proclinebyline
381
 
    ; process line by line
382
 
    call %2
383
 
%%nogo
384
 
    inc ebx
385
 
    add esi,288
386
 
    cmp [resolutn],bx
387
 
    jne %%nextline
388
 
    jmp %%donextbg
389
 
%%tile
390
 
    call %3
391
 
    add ebx,8
392
 
    add esi,288*8
393
 
    cmp [resolutn],bx
394
 
    ja %%nextline
395
 
%%donextbg
396
 
%endmacro
397
 
 
398
 
%macro Procsprng 2
399
 
    ; Draw BG 2
400
 
    ; Start line by line drawing/check
401
 
    mov esi,[vidbuffer]
402
 
    add esi,16+288
403
 
    mov ebx,1
404
 
%%nextline
405
 
    cmp byte[BGFB+ebx],0
406
 
    jne %%nogo
407
 
    test dword[BGMS1+ebx*2],%1
408
 
    jz %%nogo
409
 
    test dword[BGMS1+ebx*2],%2
410
 
    jnz %%nogo
411
 
    xor eax,eax
412
 
    mov al,[sprtlng+ebx]
413
 
    mov cl,byte[sprlefttot+ebx]
414
 
    mov [csprival],eax
415
 
    inc byte[sprtlng+ebx]
416
 
    test byte[sprleftpr+ebx*4+eax],1
417
 
    jz %%nogo
418
 
    or cl,cl
419
 
    jz %%nogo
420
 
    call drawsprng
421
 
    cmp byte[BGMA+ebx],5
422
 
    jb %%nogo
423
 
    cmp byte[res640],0
424
 
    je %%nogo
425
 
    add esi,75036
426
 
    mov cl,byte[sprlefttot+ebx]
427
 
    call drawsprng
428
 
    sub esi,75036
429
 
%%nogo
430
 
    inc ebx
431
 
    add esi,288
432
 
    cmp [resolutn],bx
433
 
    jne near %%nextline
434
 
%endmacro
435
 
 
436
 
%macro Procsprng01 2
437
 
    ; Draw BG 2
438
 
    ; Start line by line drawing/check
439
 
    mov esi,[vidbuffer]
440
 
    add esi,16+288
441
 
    mov ebx,1
442
 
%%nextline
443
 
    cmp byte[BGFB+ebx],0
444
 
    jne %%nogo
445
 
    test dword[BGMS1+ebx*2],%1
446
 
    jz %%nogo
447
 
    test dword[BGMS1+ebx*2],%2
448
 
    jnz %%nogo
449
 
    cmp byte[BGMA+ebx],1
450
 
    ja %%nogo
451
 
    xor eax,eax
452
 
    mov al,[sprtlng+ebx]
453
 
    mov cl,byte[sprlefttot+ebx]
454
 
    mov [csprival],eax
455
 
    inc byte[sprtlng+ebx]
456
 
    test byte[sprleftpr+ebx*4+eax],1
457
 
    jz %%nogo
458
 
    or cl,cl
459
 
    jz %%nogo
460
 
    call drawsprng
461
 
    cmp byte[BGMA+ebx],5
462
 
    jb %%nogo
463
 
    cmp byte[res640],0
464
 
    je %%nogo
465
 
    add esi,75036
466
 
    mov cl,byte[sprlefttot+ebx]
467
 
    call drawsprng
468
 
    sub esi,75036
469
 
%%nogo
470
 
    inc ebx
471
 
    add esi,288
472
 
    cmp [resolutn],bx
473
 
    jne near %%nextline
474
 
%endmacro
475
 
 
476
 
%macro Procsprng234567 2
477
 
    ; Draw BG 2
478
 
    ; Start line by line drawing/check
479
 
    mov esi,[vidbuffer]
480
 
    add esi,16+288
481
 
    mov ebx,1
482
 
%%nextline
483
 
    cmp byte[BGFB+ebx],0
484
 
    jne %%nogo
485
 
    test dword[BGMS1+ebx*2],%1
486
 
    jz %%nogo
487
 
    test dword[BGMS1+ebx*2],%2
488
 
    jnz %%nogo
489
 
    cmp byte[BGMA+ebx],1
490
 
    jbe %%nogo
491
 
    xor eax,eax
492
 
    mov al,[sprtlng+ebx]
493
 
    mov cl,byte[sprlefttot+ebx]
494
 
    mov [csprival],eax
495
 
    inc byte[sprtlng+ebx]
496
 
    test byte[sprleftpr+ebx*4+eax],1
497
 
    jz %%nogo
498
 
    or cl,cl
499
 
    jz %%nogo
500
 
    call drawsprng
501
 
    cmp byte[BGMA+ebx],5
502
 
    jb %%nogo
503
 
    cmp byte[res640],0
504
 
    je %%nogo
505
 
    add esi,75036
506
 
    mov cl,byte[sprlefttot+ebx]
507
 
    call drawsprng
508
 
    sub esi,75036
509
 
%%nogo
510
 
    inc ebx
511
 
    add esi,288
512
 
    cmp [resolutn],bx
513
 
    jne near %%nextline
514
 
%endmacro
515
 
 
516
 
%macro ProcMode7ng 2
517
 
    mov byte[winon],0
518
 
    ; Draw BG
519
 
    ; Start line by line drawing/check
520
 
    mov esi,[vidbuffer]
521
 
    add esi,16+288
522
 
    mov ebx,1
523
 
%%nextline
524
 
    cmp byte[BGFB+ebx],0
525
 
    jne near %%nogo
526
 
    cmp byte[BGMA+ebx],7
527
 
    jne near %%nogo
528
 
    test dword[BGMS1+ebx*2],%1
529
 
    jz near %%nogo
530
 
    test dword[BGMS1+ebx*2],%2
531
 
    jnz near %%nogo
532
 
    push ebx
533
 
    ; Process mosaic
534
 
    mov byte[curmosaicsz],1
535
 
    xor ecx,ecx
536
 
    test byte[mosenng+ebx],1
537
 
    jz %%nomosaic
538
 
    mov cl,[mosszng+ebx]
539
 
    or cl,cl
540
 
    jz %%nomosaic
541
 
    inc cl
542
 
    mov byte[curmosaicsz],cl
543
 
    xor edx,edx
544
 
    mov eax,ebx
545
 
    div cl
546
 
    xor edx,edx
547
 
    mul cl
548
 
    mov ebx,eax
549
 
%%nomosaic
550
 
    ; process line by line
551
 
    mov edx,[mode7ab+ebx*4]
552
 
    mov [mode7A],edx
553
 
    mov edx,[mode7cd+ebx*4]
554
 
    mov [mode7C],edx
555
 
    mov edx,[mode7xy+ebx*4]
556
 
    mov [mode7X0],edx
557
 
    mov edx,[mode7st+ebx]
558
 
    mov [mode7set],dl
559
 
    xor edx,edx
560
 
    mov eax,ebx
561
 
    test byte[mode7set],02h
562
 
    jz %%noflip
563
 
    mov eax,261
564
 
    sub eax,ebx
565
 
%%noflip
566
 
    mov dx,[BG1SXl+ebx*2]
567
 
    add ax,[BG1SYl+ebx*2]
568
 
    mov [curvidoffset],esi
569
 
    push esi
570
 
    call drawmode7
571
 
    pop esi
572
 
    pop ebx
573
 
%%nogo
574
 
    inc ebx
575
 
    add esi,288
576
 
    cmp [resolutn],bx
577
 
    jne near %%nextline
578
 
%endmacro
579
 
 
580
 
 
581
 
%macro preparet4ba 0
582
 
    shl cx,5
583
 
    add ecx,ecx
584
 
    add ecx,[vcache4b]
585
 
%endmacro
586
 
 
587
 
%macro preparet2ba 0
588
 
    shl cx,4
589
 
    shl ecx,2
590
 
    add ecx,[vcache2b]
591
 
%endmacro
592
 
 
593
 
%macro preparet8ba 0
594
 
    shl cx,6
595
 
    add ecx,[vcache8b]
596
 
%endmacro
597
 
 
598
 
%macro test4ba 0
599
 
    and ecx,2047
600
 
    test dword[vidmemch4+ecx*2],0FFFFh
601
 
%endmacro
602
 
 
603
 
%macro test2ba 0
604
 
    and ecx,4095
605
 
    add edx,dword[mode0add]
606
 
    test dword[vidmemch2+ecx],0FFh
607
 
%endmacro
608
 
 
609
 
%macro test8ba 0
610
 
    and ecx,1023
611
 
    test dword[vidmemch8+ecx*4],0FFFFFFFFh
612
 
%endmacro
613
 
 
614
 
%macro drawtileng 8
615
 
    ; tile value : bit 15 = flipy, bit 14 = flipx, bit 13 = priority value
616
 
    ;              bit 10-12 = palette, 0-9=tile#
617
 
    mov ebx,[ng16bbgval]
618
 
    mov dl,ch
619
 
    inc dword[bg1drwng+ebx*4]
620
 
    and ecx,3FFh
621
 
    and edx,1Fh
622
 
    add ecx,[ngptrdat2]
623
 
    mov edx,[%6+edx*4]
624
 
    %7
625
 
    jnz near %%docache
626
 
%%returnfromcache
627
 
    cmp byte[%1+ecx],2
628
 
    je near %5
629
 
    cmp byte[%1+ecx],0
630
 
    je near %%parttile
631
 
    %2
632
 
    ; start drawing from ecx
633
 
    test dword[vrama+eax],8000h
634
 
    jnz near %%flipyfull
635
 
    test dword[vrama+eax],4000h
636
 
    jnz near %%flipxfull
637
 
    mov ebx,[ecx]
638
 
    add ebx,edx
639
 
    mov [edi],ebx
640
 
    mov ebx,[ecx+4]
641
 
    add ebx,edx
642
 
    mov [edi+4],ebx
643
 
    mov ebx,[ecx+8]
644
 
    add ebx,edx
645
 
    mov [edi+288],ebx
646
 
    mov ebx,[ecx+12]
647
 
    add ebx,edx
648
 
    mov [edi+288+4],ebx
649
 
    mov ebx,[ecx+16]
650
 
    add ebx,edx
651
 
    mov [edi+288*2],ebx
652
 
    mov ebx,[ecx+20]
653
 
    add ebx,edx
654
 
    mov [edi+288*2+4],ebx
655
 
    mov ebx,[ecx+24]
656
 
    add ebx,edx
657
 
    mov [edi+288*3],ebx
658
 
    mov ebx,[ecx+28]
659
 
    add ebx,edx
660
 
    mov [edi+288*3+4],ebx
661
 
    mov ebx,[ecx+32]
662
 
    add ebx,edx
663
 
    mov [edi+288*4],ebx
664
 
    mov ebx,[ecx+36]
665
 
    add ebx,edx
666
 
    mov [edi+288*4+4],ebx
667
 
    mov ebx,[ecx+40]
668
 
    add ebx,edx
669
 
    mov [edi+288*5],ebx
670
 
    mov ebx,[ecx+44]
671
 
    add ebx,edx
672
 
    mov [edi+288*5+4],ebx
673
 
    mov ebx,[ecx+48]
674
 
    add ebx,edx
675
 
    mov [edi+288*6],ebx
676
 
    mov ebx,[ecx+52]
677
 
    add ebx,edx
678
 
    mov [edi+288*6+4],ebx
679
 
    mov ebx,[ecx+56]
680
 
    add ebx,edx
681
 
    mov [edi+288*7],ebx
682
 
    mov ebx,[ecx+60]
683
 
    add ebx,edx
684
 
    mov [edi+288*7+4],ebx
685
 
    jmp %5
686
 
%%flipxfull
687
 
    mov ebx,[ecx+4]
688
 
    bswap ebx
689
 
    add ebx,edx
690
 
    mov [edi],ebx
691
 
    mov ebx,[ecx]
692
 
    bswap ebx
693
 
    add ebx,edx
694
 
    mov [edi+4],ebx
695
 
    mov ebx,[ecx+12]
696
 
    bswap ebx
697
 
    add ebx,edx
698
 
    mov [edi+288],ebx
699
 
    mov ebx,[ecx+8]
700
 
    bswap ebx
701
 
    add ebx,edx
702
 
    mov [edi+288+4],ebx
703
 
    mov ebx,[ecx+20]
704
 
    bswap ebx
705
 
    add ebx,edx
706
 
    mov [edi+288*2],ebx
707
 
    mov ebx,[ecx+16]
708
 
    bswap ebx
709
 
    add ebx,edx
710
 
    mov [edi+288*2+4],ebx
711
 
    mov ebx,[ecx+28]
712
 
    bswap ebx
713
 
    add ebx,edx
714
 
    mov [edi+288*3],ebx
715
 
    mov ebx,[ecx+24]
716
 
    bswap ebx
717
 
    add ebx,edx
718
 
    mov [edi+288*3+4],ebx
719
 
    mov ebx,[ecx+36]
720
 
    bswap ebx
721
 
    add ebx,edx
722
 
    mov [edi+288*4],ebx
723
 
    mov ebx,[ecx+32]
724
 
    bswap ebx
725
 
    add ebx,edx
726
 
    mov [edi+288*4+4],ebx
727
 
    mov ebx,[ecx+44]
728
 
    bswap ebx
729
 
    add ebx,edx
730
 
    mov [edi+288*5],ebx
731
 
    mov ebx,[ecx+40]
732
 
    bswap ebx
733
 
    add ebx,edx
734
 
    mov [edi+288*5+4],ebx
735
 
    mov ebx,[ecx+52]
736
 
    bswap ebx
737
 
    add ebx,edx
738
 
    mov [edi+288*6],ebx
739
 
    mov ebx,[ecx+48]
740
 
    bswap ebx
741
 
    add ebx,edx
742
 
    mov [edi+288*6+4],ebx
743
 
    mov ebx,[ecx+60]
744
 
    bswap ebx
745
 
    add ebx,edx
746
 
    mov [edi+288*7],ebx
747
 
    mov ebx,[ecx+56]
748
 
    bswap ebx
749
 
    add ebx,edx
750
 
    mov [edi+288*7+4],ebx
751
 
    jmp %5
752
 
%%flipyfull
753
 
    test word[vrama+eax],4000h
754
 
    jnz near %%flipxyfull
755
 
    mov ebx,[ecx]
756
 
    add ebx,edx
757
 
    mov [edi+288*7],ebx
758
 
    mov ebx,[ecx+4]
759
 
    add ebx,edx
760
 
    mov [edi+288*7+4],ebx
761
 
    mov ebx,[ecx+8]
762
 
    add ebx,edx
763
 
    mov [edi+288*6],ebx
764
 
    mov ebx,[ecx+12]
765
 
    add ebx,edx
766
 
    mov [edi+288*6+4],ebx
767
 
    mov ebx,[ecx+16]
768
 
    add ebx,edx
769
 
    mov [edi+288*5],ebx
770
 
    mov ebx,[ecx+20]
771
 
    add ebx,edx
772
 
    mov [edi+288*5+4],ebx
773
 
    mov ebx,[ecx+24]
774
 
    add ebx,edx
775
 
    mov [edi+288*4],ebx
776
 
    mov ebx,[ecx+28]
777
 
    add ebx,edx
778
 
    mov [edi+288*4+4],ebx
779
 
    mov ebx,[ecx+32]
780
 
    add ebx,edx
781
 
    mov [edi+288*3],ebx
782
 
    mov ebx,[ecx+36]
783
 
    add ebx,edx
784
 
    mov [edi+288*3+4],ebx
785
 
    mov ebx,[ecx+40]
786
 
    add ebx,edx
787
 
    mov [edi+288*2],ebx
788
 
    mov ebx,[ecx+44]
789
 
    add ebx,edx
790
 
    mov [edi+288*2+4],ebx
791
 
    mov ebx,[ecx+48]
792
 
    add ebx,edx
793
 
    mov [edi+288],ebx
794
 
    mov ebx,[ecx+52]
795
 
    add ebx,edx
796
 
    mov [edi+288+4],ebx
797
 
    mov ebx,[ecx+56]
798
 
    add ebx,edx
799
 
    mov [edi],ebx
800
 
    mov ebx,[ecx+60]
801
 
    add ebx,edx
802
 
    mov [edi+4],ebx
803
 
    jmp %5
804
 
%%flipxyfull
805
 
    mov ebx,[ecx+4]
806
 
    bswap ebx
807
 
    add ebx,edx
808
 
    mov [edi+288*7],ebx
809
 
    mov ebx,[ecx]
810
 
    bswap ebx
811
 
    add ebx,edx
812
 
    mov [edi+288*7+4],ebx
813
 
    mov ebx,[ecx+12]
814
 
    bswap ebx
815
 
    add ebx,edx
816
 
    mov [edi+288*6],ebx
817
 
    mov ebx,[ecx+8]
818
 
    bswap ebx
819
 
    add ebx,edx
820
 
    mov [edi+288*6+4],ebx
821
 
    mov ebx,[ecx+20]
822
 
    bswap ebx
823
 
    add ebx,edx
824
 
    mov [edi+288*5],ebx
825
 
    mov ebx,[ecx+16]
826
 
    bswap ebx
827
 
    add ebx,edx
828
 
    mov [edi+288*5+4],ebx
829
 
    mov ebx,[ecx+28]
830
 
    bswap ebx
831
 
    add ebx,edx
832
 
    mov [edi+288*4],ebx
833
 
    mov ebx,[ecx+24]
834
 
    bswap ebx
835
 
    add ebx,edx
836
 
    mov [edi+288*4+4],ebx
837
 
    mov ebx,[ecx+36]
838
 
    bswap ebx
839
 
    add ebx,edx
840
 
    mov [edi+288*3],ebx
841
 
    mov ebx,[ecx+32]
842
 
    bswap ebx
843
 
    add ebx,edx
844
 
    mov [edi+288*3+4],ebx
845
 
    mov ebx,[ecx+44]
846
 
    bswap ebx
847
 
    add ebx,edx
848
 
    mov [edi+288*2],ebx
849
 
    mov ebx,[ecx+40]
850
 
    bswap ebx
851
 
    add ebx,edx
852
 
    mov [edi+288*2+4],ebx
853
 
    mov ebx,[ecx+52]
854
 
    bswap ebx
855
 
    add ebx,edx
856
 
    mov [edi+288],ebx
857
 
    mov ebx,[ecx+48]
858
 
    bswap ebx
859
 
    add ebx,edx
860
 
    mov [edi+288+4],ebx
861
 
    mov ebx,[ecx+60]
862
 
    bswap ebx
863
 
    add ebx,edx
864
 
    mov [edi],ebx
865
 
    mov ebx,[ecx+56]
866
 
    bswap ebx
867
 
    add ebx,edx
868
 
    mov [edi+4],ebx
869
 
    jmp %5
870
 
%%parttile
871
 
    %2
872
 
    ; start drawing from ecx to edi
873
 
    test word[vrama+eax],8000h
874
 
    jnz near %%flipypart
875
 
    test word[vrama+eax],4000h
876
 
    jnz near %%flipxpart
877
 
    mov dword[tleftnb],8
878
 
%%nextb
879
 
    mov ebx,[ecx]
880
 
    or ebx,ebx
881
 
    jz %%drawd
882
 
    add ebx,edx
883
 
    test bl,%8
884
 
    jz %%drawa
885
 
    mov [edi],bl
886
 
%%drawa
887
 
    test bh,%8
888
 
    jz %%drawb
889
 
    mov [edi+1],bh
890
 
%%drawb
891
 
    shr ebx,16
892
 
    test bl,%8
893
 
    jz %%drawc
894
 
    mov [edi+2],bl
895
 
%%drawc
896
 
    test bh,%8
897
 
    jz %%drawd
898
 
    mov [edi+3],bh
899
 
%%drawd
900
 
    mov ebx,[ecx+4]
901
 
    or ebx,ebx
902
 
    jz %%drawd2
903
 
    add ebx,edx
904
 
    test bl,%8
905
 
    jz %%drawa2
906
 
    mov [edi+4],bl
907
 
%%drawa2
908
 
    test bh,%8
909
 
    jz %%drawb2
910
 
    mov [edi+5],bh
911
 
%%drawb2
912
 
    shr ebx,16
913
 
    test bl,%8
914
 
    jz %%drawc2
915
 
    mov [edi+6],bl
916
 
%%drawc2
917
 
    test bh,%8
918
 
    jz %%drawd2
919
 
    mov [edi+7],bh
920
 
%%drawd2
921
 
    add ecx,8
922
 
    add edi,288
923
 
    dec dword[tleftnb]
924
 
    jnz %%nextb
925
 
    sub edi,288*8
926
 
    jmp %5
927
 
%%flipxpart
928
 
    mov dword[tleftnb],8
929
 
%%nextbf
930
 
    mov ebx,[ecx]
931
 
    or ebx,ebx
932
 
    jz %%drawdf
933
 
    add ebx,edx
934
 
    test bl,%8
935
 
    jz %%drawaf
936
 
    mov [edi+7],bl
937
 
%%drawaf
938
 
    test bh,%8
939
 
    jz %%drawbf
940
 
    mov [edi+6],bh
941
 
%%drawbf
942
 
    shr ebx,16
943
 
    test bl,%8
944
 
    jz %%drawcf
945
 
    mov [edi+5],bl
946
 
%%drawcf
947
 
    test bh,%8
948
 
    jz %%drawdf
949
 
    mov [edi+4],bh
950
 
%%drawdf
951
 
    mov ebx,[ecx+4]
952
 
    or ebx,ebx
953
 
    jz %%drawd2f
954
 
    add ebx,edx
955
 
    test bl,%8
956
 
    jz %%drawa2f
957
 
    mov [edi+3],bl
958
 
%%drawa2f
959
 
    test bh,%8
960
 
    jz %%drawb2f
961
 
    mov [edi+2],bh
962
 
%%drawb2f
963
 
    shr ebx,16
964
 
    test bl,%8
965
 
    jz %%drawc2f
966
 
    mov [edi+1],bl
967
 
%%drawc2f
968
 
    test bh,%8
969
 
    jz %%drawd2f
970
 
    mov [edi],bh
971
 
%%drawd2f
972
 
    add ecx,8
973
 
    add edi,288
974
 
    dec dword[tleftnb]
975
 
    jnz %%nextbf
976
 
    sub edi,288*8
977
 
    jmp %5
978
 
%%flipypart
979
 
    add edi,288*7
980
 
    test word[vrama+eax],4000h
981
 
    jnz near %%flipxypart
982
 
    mov dword[tleftnb],8
983
 
%%nextbm
984
 
    mov ebx,[ecx]
985
 
    or ebx,ebx
986
 
    jz %%drawdm
987
 
    add ebx,edx
988
 
    test bl,%8
989
 
    jz %%drawam
990
 
    mov [edi],bl
991
 
%%drawam
992
 
    test bh,%8
993
 
    jz %%drawbm
994
 
    mov [edi+1],bh
995
 
%%drawbm
996
 
    shr ebx,16
997
 
    test bl,%8
998
 
    jz %%drawcm
999
 
    mov [edi+2],bl
1000
 
%%drawcm
1001
 
    test bh,%8
1002
 
    jz %%drawdm
1003
 
    mov [edi+3],bh
1004
 
%%drawdm
1005
 
    mov ebx,[ecx+4]
1006
 
    or ebx,ebx
1007
 
    jz %%drawd2m
1008
 
    add ebx,edx
1009
 
    test bl,%8
1010
 
    jz %%drawa2m
1011
 
    mov [edi+4],bl
1012
 
%%drawa2m
1013
 
    test bh,%8
1014
 
    jz %%drawb2m
1015
 
    mov [edi+5],bh
1016
 
%%drawb2m
1017
 
    shr ebx,16
1018
 
    test bl,%8
1019
 
    jz %%drawc2m
1020
 
    mov [edi+6],bl
1021
 
%%drawc2m
1022
 
    test bh,%8
1023
 
    jz %%drawd2m
1024
 
    mov [edi+7],bh
1025
 
%%drawd2m
1026
 
    add ecx,8
1027
 
    sub edi,288
1028
 
    dec dword[tleftnb]
1029
 
    jnz %%nextbm
1030
 
    add edi,288
1031
 
    jmp %5
1032
 
%%flipxypart
1033
 
    mov dword[tleftnb],8
1034
 
%%nextbfm
1035
 
    mov ebx,[ecx]
1036
 
    or ebx,ebx
1037
 
    jz %%drawdfm
1038
 
    add ebx,edx
1039
 
    test bl,%8
1040
 
    jz %%drawafm
1041
 
    mov [edi+7],bl
1042
 
%%drawafm
1043
 
    test bh,%8
1044
 
    jz %%drawbfm
1045
 
    mov [edi+6],bh
1046
 
%%drawbfm
1047
 
    shr ebx,16
1048
 
    test bl,%8
1049
 
    jz %%drawcfm
1050
 
    mov [edi+5],bl
1051
 
%%drawcfm
1052
 
    test bh,%8
1053
 
    jz %%drawdfm
1054
 
    mov [edi+4],bh
1055
 
%%drawdfm
1056
 
    mov ebx,[ecx+4]
1057
 
    or ebx,ebx
1058
 
    jz %%drawd2fm
1059
 
    add ebx,edx
1060
 
    test bl,%8
1061
 
    jz %%drawa2fm
1062
 
    mov [edi+3],bl
1063
 
%%drawa2fm
1064
 
    test bh,%8
1065
 
    jz %%drawb2fm
1066
 
    mov [edi+2],bh
1067
 
%%drawb2fm
1068
 
    shr ebx,16
1069
 
    test bl,%8
1070
 
    jz %%drawc2fm
1071
 
    mov [edi+1],bl
1072
 
%%drawc2fm
1073
 
    test bh,%8
1074
 
    jz %%drawd2fm
1075
 
    mov [edi],bh
1076
 
%%drawd2fm
1077
 
    add ecx,8
1078
 
    sub edi,288
1079
 
    dec dword[tleftnb]
1080
 
    jnz %%nextbfm
1081
 
    add edi,288
1082
 
%5
1083
 
    mov ebx,[ng16bbgval]
1084
 
    add ax,2
1085
 
    inc dword[bg1totng+ebx*4]
1086
 
    add edi,8
1087
 
    test eax,03Fh
1088
 
    jz %%tileadd
1089
 
%%next
1090
 
    dec byte[tleftn]
1091
 
    jnz near %4
1092
 
    pop ebx
1093
 
    ret
1094
 
%%docache
1095
 
    call %3
1096
 
    jmp %%returnfromcache
1097
 
%%tileadd
1098
 
    add ax,[bgtxadd]
1099
 
    jmp %%next
1100
 
%endmacro
1101
 
 
1102
 
%macro drawtileng16x16 8
1103
 
    ; tile value : bit 15 = flipy, bit 14 = flipx, bit 13 = priority value
1104
 
    ;              bit 10-12 = palette, 0-9=tile#
1105
 
    mov ebx,[ng16bbgval]
1106
 
    mov dl,ch
1107
 
    inc dword[bg1drwng+ebx*4]
1108
 
    and ecx,3FFh
1109
 
    and edx,1Fh
1110
 
    add ecx,[ngptrdat2]
1111
 
    add cx,[taddnfy16x16]
1112
 
    test dword[vrama+eax],8000h
1113
 
    jz %%noflipy
1114
 
    add cx,[taddfy16x16]
1115
 
%%noflipy
1116
 
    test dword[vrama+eax],4000h
1117
 
    jz %%noflipx
1118
 
    inc cx
1119
 
%%noflipx
1120
 
%%nexttile
1121
 
    push ecx
1122
 
    push edx
1123
 
    mov edx,[%6+edx*4]
1124
 
    %7
1125
 
    jnz near %%docache
1126
 
%%returnfromcache
1127
 
    cmp byte[%1+ecx],2
1128
 
    je near %%done
1129
 
    cmp byte[%1+ecx],0
1130
 
    je near %%parttile
1131
 
    %2
1132
 
    ; start drawing from ecx
1133
 
    test dword[vrama+eax],8000h
1134
 
    jnz near %%flipyfull
1135
 
    test dword[vrama+eax],4000h
1136
 
    jnz near %%flipxfull
1137
 
    push eax
1138
 
    mov ebx,[ecx]
1139
 
    mov eax,[ecx+4]
1140
 
    add ebx,edx
1141
 
    add eax,edx
1142
 
    mov [edi],ebx
1143
 
    mov [edi+4],eax
1144
 
    mov ebx,[ecx+8]
1145
 
    mov eax,[ecx+12]
1146
 
    add ebx,edx
1147
 
    add eax,edx
1148
 
    mov [edi+288],ebx
1149
 
    mov [edi+288+4],eax
1150
 
    mov ebx,[ecx+16]
1151
 
    mov eax,[ecx+20]
1152
 
    add ebx,edx
1153
 
    add eax,edx
1154
 
    mov [edi+288*2],ebx
1155
 
    mov [edi+288*2+4],eax
1156
 
    mov ebx,[ecx+24]
1157
 
    mov eax,[ecx+28]
1158
 
    add ebx,edx
1159
 
    add eax,edx
1160
 
    mov [edi+288*3],ebx
1161
 
    mov [edi+288*3+4],eax
1162
 
    mov ebx,[ecx+32]
1163
 
    mov eax,[ecx+36]
1164
 
    add ebx,edx
1165
 
    add eax,edx
1166
 
    mov [edi+288*4],ebx
1167
 
    mov [edi+288*4+4],eax
1168
 
    mov ebx,[ecx+40]
1169
 
    mov eax,[ecx+44]
1170
 
    add ebx,edx
1171
 
    add eax,edx
1172
 
    mov [edi+288*5],ebx
1173
 
    mov [edi+288*5+4],eax
1174
 
    mov ebx,[ecx+48]
1175
 
    mov eax,[ecx+52]
1176
 
    add ebx,edx
1177
 
    add eax,edx
1178
 
    mov [edi+288*6],ebx
1179
 
    mov [edi+288*6+4],eax
1180
 
    mov ebx,[ecx+56]
1181
 
    mov eax,[ecx+60]
1182
 
    add ebx,edx
1183
 
    add eax,edx
1184
 
    mov [edi+288*7],ebx
1185
 
    mov [edi+288*7+4],eax
1186
 
    pop eax
1187
 
    jmp %%done
1188
 
%%flipxfull
1189
 
    push eax
1190
 
    mov ebx,[ecx+4]
1191
 
    mov eax,[ecx]
1192
 
    bswap ebx
1193
 
    bswap eax
1194
 
    add ebx,edx
1195
 
    add eax,edx
1196
 
    mov [edi],ebx
1197
 
    mov [edi+4],eax
1198
 
    mov ebx,[ecx+12]
1199
 
    mov eax,[ecx+8]
1200
 
    bswap ebx
1201
 
    bswap eax
1202
 
    add ebx,edx
1203
 
    add eax,edx
1204
 
    mov [edi+288],ebx
1205
 
    mov [edi+288+4],eax
1206
 
    mov ebx,[ecx+20]
1207
 
    mov eax,[ecx+16]
1208
 
    bswap ebx
1209
 
    bswap eax
1210
 
    add ebx,edx
1211
 
    add eax,edx
1212
 
    mov [edi+288*2],ebx
1213
 
    mov [edi+288*2+4],eax
1214
 
    mov ebx,[ecx+28]
1215
 
    mov eax,[ecx+24]
1216
 
    bswap ebx
1217
 
    bswap eax
1218
 
    add ebx,edx
1219
 
    add eax,edx
1220
 
    mov [edi+288*3],ebx
1221
 
    mov [edi+288*3+4],eax
1222
 
    mov ebx,[ecx+36]
1223
 
    mov eax,[ecx+32]
1224
 
    bswap ebx
1225
 
    bswap eax
1226
 
    add ebx,edx
1227
 
    add eax,edx
1228
 
    mov [edi+288*4],ebx
1229
 
    mov [edi+288*4+4],eax
1230
 
    mov ebx,[ecx+44]
1231
 
    mov eax,[ecx+40]
1232
 
    bswap ebx
1233
 
    bswap eax
1234
 
    add ebx,edx
1235
 
    add eax,edx
1236
 
    mov [edi+288*5],ebx
1237
 
    mov [edi+288*5+4],eax
1238
 
    mov ebx,[ecx+52]
1239
 
    mov eax,[ecx+48]
1240
 
    bswap ebx
1241
 
    bswap eax
1242
 
    add ebx,edx
1243
 
    add eax,edx
1244
 
    mov [edi+288*6],ebx
1245
 
    mov [edi+288*6+4],eax
1246
 
    mov ebx,[ecx+60]
1247
 
    mov eax,[ecx+56]
1248
 
    bswap ebx
1249
 
    bswap eax
1250
 
    add ebx,edx
1251
 
    add eax,edx
1252
 
    mov [edi+288*7],ebx
1253
 
    mov [edi+288*7+4],eax
1254
 
    pop eax
1255
 
    jmp %%done
1256
 
%%flipyfull
1257
 
    test word[vrama+eax],4000h
1258
 
    jnz near %%flipxyfull
1259
 
    push eax
1260
 
    mov ebx,[ecx]
1261
 
    mov eax,[ecx+4]
1262
 
    add ebx,edx
1263
 
    add eax,edx
1264
 
    mov [edi+288*7],ebx
1265
 
    mov [edi+288*7+4],eax
1266
 
    mov ebx,[ecx+8]
1267
 
    mov eax,[ecx+12]
1268
 
    add ebx,edx
1269
 
    add eax,edx
1270
 
    mov [edi+288*6],ebx
1271
 
    mov [edi+288*6+4],eax
1272
 
    mov ebx,[ecx+16]
1273
 
    mov eax,[ecx+20]
1274
 
    add ebx,edx
1275
 
    add eax,edx
1276
 
    mov [edi+288*5],ebx
1277
 
    mov [edi+288*5+4],eax
1278
 
    mov ebx,[ecx+24]
1279
 
    mov eax,[ecx+28]
1280
 
    add ebx,edx
1281
 
    add eax,edx
1282
 
    mov [edi+288*4],ebx
1283
 
    mov [edi+288*4+4],eax
1284
 
    mov ebx,[ecx+32]
1285
 
    mov eax,[ecx+36]
1286
 
    add ebx,edx
1287
 
    add eax,edx
1288
 
    mov [edi+288*3],ebx
1289
 
    mov [edi+288*3+4],eax
1290
 
    mov ebx,[ecx+40]
1291
 
    mov eax,[ecx+44]
1292
 
    add ebx,edx
1293
 
    add eax,edx
1294
 
    mov [edi+288*2],ebx
1295
 
    mov [edi+288*2+4],eax
1296
 
    mov ebx,[ecx+48]
1297
 
    mov eax,[ecx+52]
1298
 
    add ebx,edx
1299
 
    add eax,edx
1300
 
    mov [edi+288],ebx
1301
 
    mov [edi+288+4],eax
1302
 
    mov ebx,[ecx+56]
1303
 
    mov eax,[ecx+60]
1304
 
    add ebx,edx
1305
 
    add eax,edx
1306
 
    mov [edi],ebx
1307
 
    mov [edi+4],eax
1308
 
    pop eax
1309
 
    jmp %%done
1310
 
%%flipxyfull
1311
 
    push eax
1312
 
    mov ebx,[ecx+4]
1313
 
    mov eax,[ecx]
1314
 
    bswap ebx
1315
 
    bswap eax
1316
 
    add ebx,edx
1317
 
    add eax,edx
1318
 
    mov [edi+288*7],ebx
1319
 
    mov [edi+288*7+4],eax
1320
 
    mov ebx,[ecx+12]
1321
 
    mov eax,[ecx+8]
1322
 
    bswap ebx
1323
 
    bswap eax
1324
 
    add ebx,edx
1325
 
    add eax,edx
1326
 
    mov [edi+288*6],ebx
1327
 
    mov [edi+288*6+4],eax
1328
 
    mov ebx,[ecx+20]
1329
 
    mov eax,[ecx+16]
1330
 
    bswap ebx
1331
 
    bswap eax
1332
 
    add ebx,edx
1333
 
    add eax,edx
1334
 
    mov [edi+288*5],ebx
1335
 
    mov [edi+288*5+4],eax
1336
 
    mov ebx,[ecx+28]
1337
 
    mov eax,[ecx+24]
1338
 
    bswap ebx
1339
 
    bswap eax
1340
 
    add ebx,edx
1341
 
    add eax,edx
1342
 
    mov [edi+288*4],ebx
1343
 
    mov [edi+288*4+4],eax
1344
 
    mov ebx,[ecx+36]
1345
 
    mov eax,[ecx+32]
1346
 
    bswap ebx
1347
 
    bswap eax
1348
 
    add ebx,edx
1349
 
    add eax,edx
1350
 
    mov [edi+288*3],ebx
1351
 
    mov [edi+288*3+4],eax
1352
 
    mov ebx,[ecx+44]
1353
 
    mov eax,[ecx+40]
1354
 
    bswap ebx
1355
 
    bswap eax
1356
 
    add ebx,edx
1357
 
    add eax,edx
1358
 
    mov [edi+288*2],ebx
1359
 
    mov [edi+288*2+4],eax
1360
 
    mov ebx,[ecx+52]
1361
 
    mov eax,[ecx+48]
1362
 
    bswap ebx
1363
 
    bswap eax
1364
 
    add ebx,edx
1365
 
    add eax,edx
1366
 
    mov [edi+288],ebx
1367
 
    mov [edi+288+4],eax
1368
 
    mov ebx,[ecx+60]
1369
 
    mov eax,[ecx+56]
1370
 
    bswap ebx
1371
 
    bswap eax
1372
 
    add ebx,edx
1373
 
    add eax,edx
1374
 
    mov [edi],ebx
1375
 
    mov [edi+4],eax
1376
 
    pop eax
1377
 
    jmp %%done
1378
 
%%parttile
1379
 
    %2
1380
 
    ; start drawing from ecx to edi
1381
 
    test word[vrama+eax],8000h
1382
 
    jnz near %%flipypart
1383
 
    test word[vrama+eax],4000h
1384
 
    jnz near %%flipxpart
1385
 
    mov dword[tleftnb],8
1386
 
%%nextb
1387
 
    mov ebx,[ecx]
1388
 
    or ebx,ebx
1389
 
    jz %%drawd
1390
 
    add ebx,edx
1391
 
    test bl,%8
1392
 
    jz %%drawa
1393
 
    mov [edi],bl
1394
 
%%drawa
1395
 
    test bh,%8
1396
 
    jz %%drawb
1397
 
    mov [edi+1],bh
1398
 
%%drawb
1399
 
    shr ebx,16
1400
 
    test bl,%8
1401
 
    jz %%drawc
1402
 
    mov [edi+2],bl
1403
 
%%drawc
1404
 
    test bh,%8
1405
 
    jz %%drawd
1406
 
    mov [edi+3],bh
1407
 
%%drawd
1408
 
    mov ebx,[ecx+4]
1409
 
    or ebx,ebx
1410
 
    jz %%drawd2
1411
 
    add ebx,edx
1412
 
    test bl,%8
1413
 
    jz %%drawa2
1414
 
    mov [edi+4],bl
1415
 
%%drawa2
1416
 
    test bh,%8
1417
 
    jz %%drawb2
1418
 
    mov [edi+5],bh
1419
 
%%drawb2
1420
 
    shr ebx,16
1421
 
    test bl,%8
1422
 
    jz %%drawc2
1423
 
    mov [edi+6],bl
1424
 
%%drawc2
1425
 
    test bh,%8
1426
 
    jz %%drawd2
1427
 
    mov [edi+7],bh
1428
 
%%drawd2
1429
 
    add ecx,8
1430
 
    add edi,288
1431
 
    dec dword[tleftnb]
1432
 
    jnz %%nextb
1433
 
    sub edi,288*8
1434
 
    jmp %%done
1435
 
%%flipxpart
1436
 
    mov dword[tleftnb],8
1437
 
%%nextbf
1438
 
    mov ebx,[ecx]
1439
 
    or ebx,ebx
1440
 
    jz %%drawdf
1441
 
    add ebx,edx
1442
 
    test bl,%8
1443
 
    jz %%drawaf
1444
 
    mov [edi+7],bl
1445
 
%%drawaf
1446
 
    test bh,%8
1447
 
    jz %%drawbf
1448
 
    mov [edi+6],bh
1449
 
%%drawbf
1450
 
    shr ebx,16
1451
 
    test bl,%8
1452
 
    jz %%drawcf
1453
 
    mov [edi+5],bl
1454
 
%%drawcf
1455
 
    test bh,%8
1456
 
    jz %%drawdf
1457
 
    mov [edi+4],bh
1458
 
%%drawdf
1459
 
    mov ebx,[ecx+4]
1460
 
    or ebx,ebx
1461
 
    jz %%drawd2f
1462
 
    add ebx,edx
1463
 
    test bl,%8
1464
 
    jz %%drawa2f
1465
 
    mov [edi+3],bl
1466
 
%%drawa2f
1467
 
    test bh,%8
1468
 
    jz %%drawb2f
1469
 
    mov [edi+2],bh
1470
 
%%drawb2f
1471
 
    shr ebx,16
1472
 
    test bl,%8
1473
 
    jz %%drawc2f
1474
 
    mov [edi+1],bl
1475
 
%%drawc2f
1476
 
    test bh,%8
1477
 
    jz %%drawd2f
1478
 
    mov [edi],bh
1479
 
%%drawd2f
1480
 
    add ecx,8
1481
 
    add edi,288
1482
 
    dec dword[tleftnb]
1483
 
    jnz %%nextbf
1484
 
    sub edi,288*8
1485
 
    jmp %%done
1486
 
%%flipypart
1487
 
    add edi,288*7
1488
 
    test word[vrama+eax],4000h
1489
 
    jnz near %%flipxypart
1490
 
    mov dword[tleftnb],8
1491
 
%%nextbm
1492
 
    mov ebx,[ecx]
1493
 
    or ebx,ebx
1494
 
    jz %%drawdm
1495
 
    add ebx,edx
1496
 
    test bl,%8
1497
 
    jz %%drawam
1498
 
    mov [edi],bl
1499
 
%%drawam
1500
 
    test bh,%8
1501
 
    jz %%drawbm
1502
 
    mov [edi+1],bh
1503
 
%%drawbm
1504
 
    shr ebx,16
1505
 
    test bl,%8
1506
 
    jz %%drawcm
1507
 
    mov [edi+2],bl
1508
 
%%drawcm
1509
 
    test bh,%8
1510
 
    jz %%drawdm
1511
 
    mov [edi+3],bh
1512
 
%%drawdm
1513
 
    mov ebx,[ecx+4]
1514
 
    or ebx,ebx
1515
 
    jz %%drawd2m
1516
 
    add ebx,edx
1517
 
    test bl,%8
1518
 
    jz %%drawa2m
1519
 
    mov [edi+4],bl
1520
 
%%drawa2m
1521
 
    test bh,%8
1522
 
    jz %%drawb2m
1523
 
    mov [edi+5],bh
1524
 
%%drawb2m
1525
 
    shr ebx,16
1526
 
    test bl,%8
1527
 
    jz %%drawc2m
1528
 
    mov [edi+6],bl
1529
 
%%drawc2m
1530
 
    test bh,%8
1531
 
    jz %%drawd2m
1532
 
    mov [edi+7],bh
1533
 
%%drawd2m
1534
 
    add ecx,8
1535
 
    sub edi,288
1536
 
    dec dword[tleftnb]
1537
 
    jnz %%nextbm
1538
 
    add edi,288
1539
 
    jmp %%done
1540
 
%%flipxypart
1541
 
    mov dword[tleftnb],8
1542
 
%%nextbfm
1543
 
    mov ebx,[ecx]
1544
 
    or ebx,ebx
1545
 
    jz %%drawdfm
1546
 
    add ebx,edx
1547
 
    test bl,%8
1548
 
    jz %%drawafm
1549
 
    mov [edi+7],bl
1550
 
%%drawafm
1551
 
    test bh,%8
1552
 
    jz %%drawbfm
1553
 
    mov [edi+6],bh
1554
 
%%drawbfm
1555
 
    shr ebx,16
1556
 
    test bl,%8
1557
 
    jz %%drawcfm
1558
 
    mov [edi+5],bl
1559
 
%%drawcfm
1560
 
    test bh,%8
1561
 
    jz %%drawdfm
1562
 
    mov [edi+4],bh
1563
 
%%drawdfm
1564
 
    mov ebx,[ecx+4]
1565
 
    or ebx,ebx
1566
 
    jz %%drawd2fm
1567
 
    add ebx,edx
1568
 
    test bl,%8
1569
 
    jz %%drawa2fm
1570
 
    mov [edi+3],bl
1571
 
%%drawa2fm
1572
 
    test bh,%8
1573
 
    jz %%drawb2fm
1574
 
    mov [edi+2],bh
1575
 
%%drawb2fm
1576
 
    shr ebx,16
1577
 
    test bl,%8
1578
 
    jz %%drawc2fm
1579
 
    mov [edi+1],bl
1580
 
%%drawc2fm
1581
 
    test bh,%8
1582
 
    jz %%drawd2fm
1583
 
    mov [edi],bh
1584
 
%%drawd2fm
1585
 
    add ecx,8
1586
 
    sub edi,288
1587
 
    dec dword[tleftnb]
1588
 
    jnz %%nextbfm
1589
 
    add edi,288
1590
 
%%done
1591
 
    pop edx
1592
 
    pop ecx
1593
 
    inc cx
1594
 
    test dword[vrama+eax],4000h
1595
 
    jz %%noflipxb
1596
 
    sub cx,2
1597
 
%%noflipxb
1598
 
    add edi,8
1599
 
    xor dword[switch16x16],1
1600
 
    jnz near %%nexttile
1601
 
%%ntile
1602
 
    mov ebx,[ng16bbgval]
1603
 
    add ax,2
1604
 
    inc dword[bg1totng+ebx*4]
1605
 
    test eax,03Fh
1606
 
    jz %%tileadd
1607
 
%%next
1608
 
    dec byte[tleftn]
1609
 
    jnz near %4
1610
 
    pop ebx
1611
 
    ret
1612
 
%5
1613
 
    add edi,16
1614
 
    jmp %%ntile
1615
 
%%docache
1616
 
    call %3
1617
 
    jmp %%returnfromcache
1618
 
%%tileadd
1619
 
    add ax,[bgtxadd]
1620
 
    jmp %%next
1621
 
%endmacro
1622
 
 
1623
 
%macro drawbgtileng 2
1624
 
    mov dword[ng16bprval],0
1625
 
    mov dword[ng16bbgval],%1
1626
 
    cmp byte[t16x161+ebx+%1*256],1
1627
 
    je near .tiles16x16
1628
 
    push ebx
1629
 
    mov eax,[BGPT1+ebx*2+%1*512]
1630
 
    test ecx,100h
1631
 
    jz .noyinc
1632
 
    add eax,[BGPT1Y+ebx*2+%1*512]
1633
 
.noyinc
1634
 
    lea ecx,[ecx*8]
1635
 
    and ecx,07C0h      ; 1Fh*40h
1636
 
    add eax,ecx
1637
 
    mov ecx,[BG1SXl+ebx*2+%1*512]
1638
 
    mov edx,[BGPT1X+ebx*2+%1*512]
1639
 
    test ecx,100h
1640
 
    jz .noxinc
1641
 
    add eax,edx
1642
 
    neg dx
1643
 
.noxinc
1644
 
    mov edi,ecx
1645
 
    sub dx,64
1646
 
    and ecx,0F8h
1647
 
    and eax,0FFFFh
1648
 
    shr ecx,2
1649
 
    mov [bgtxadd],edx
1650
 
    mov [bgtxad+ebx*2+%2*512],dx
1651
 
    add eax,ecx
1652
 
    mov ecx,[BGOPT1+ebx*2+%1*512]
1653
 
    mov edx,[BGMA+ebx]
1654
 
    and edi,07h
1655
 
    and edx,07h
1656
 
    and ecx,0FFFFh
1657
 
    mov edx,[colormodedef+edx*4+%1]
1658
 
    neg edi
1659
 
    cmp dl,2
1660
 
    jne near .no4bit
1661
 
    shr ecx,5
1662
 
    add edi,esi
1663
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
1664
 
    mov [ngptrdat2],ecx
1665
 
    mov [ngceax+%2*1024+ebx*4],eax
1666
 
    mov [ngcedi+%2*1024+ebx*4],edi
1667
 
    ; eax = pointer to beginning of tile area
1668
 
    jmp drawtileng4b
1669
 
.no4bit
1670
 
    cmp dl,1
1671
 
    jne near .no2bit
1672
 
    shr ecx,4
1673
 
    add edi,esi
1674
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
1675
 
    mov [ngptrdat2],ecx
1676
 
    mov [ngceax+%2*1024+ebx*4],eax
1677
 
    mov [ngcedi+%2*1024+ebx*4],edi
1678
 
    ; eax = pointer to beginning of tile area
1679
 
    mov dword[mode0add],0
1680
 
    cmp byte[BGMA+ebx],0
1681
 
    jne .nomode0
1682
 
    mov ebx,[mode0ads]
1683
 
    mov [mode0add],ebx
1684
 
.nomode0
1685
 
    jmp drawtileng2b
1686
 
.no2bit
1687
 
    cmp dl,3
1688
 
    jne near .no8bit
1689
 
    shr ecx,6
1690
 
    add edi,esi
1691
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
1692
 
    mov [ngptrdat2],ecx
1693
 
    mov [ngceax+%2*1024+ebx*4],eax
1694
 
    mov [ngcedi+%2*1024+ebx*4],edi
1695
 
    ; eax = pointer to beginning of tile area
1696
 
    jmp drawtileng8b
1697
 
.no8bit
1698
 
    pop ebx
1699
 
    ret
1700
 
 
1701
 
.tiles16x16
1702
 
    mov dword[taddnfy16x16],0
1703
 
    mov dword[taddfy16x16],16
1704
 
    test ecx,08h
1705
 
    jz .nobottomy
1706
 
    mov dword[taddnfy16x16],16
1707
 
    mov dword[taddfy16x16],-16
1708
 
.nobottomy
1709
 
    push ebx
1710
 
    mov eax,[BGPT1+ebx*2+%1*512]
1711
 
    test ecx,200h
1712
 
    jz .noyinc2
1713
 
    add eax,[BGPT1Y+ebx*2+%1*512]
1714
 
.noyinc2
1715
 
    lea ecx,[ecx*4]
1716
 
    and ecx,07C0h      ; 1Fh*40h
1717
 
    add eax,ecx
1718
 
    mov ecx,[BG1SXl+ebx*2+%1*512]
1719
 
    mov edx,[BGPT1X+ebx*2+%1*512]
1720
 
    test ecx,200h
1721
 
    jz .noxinc2
1722
 
    add eax,edx
1723
 
    neg dx
1724
 
.noxinc2
1725
 
    mov edi,ecx
1726
 
    sub dx,64
1727
 
    and ecx,1F0h
1728
 
    and eax,0FFFFh
1729
 
    shr ecx,3
1730
 
    mov [bgtxadd],edx
1731
 
    mov [bgtxad+ebx*2+%2*512],dx
1732
 
    add eax,ecx
1733
 
    mov ecx,[BGOPT1+ebx*2+%1*512]
1734
 
    mov edx,[BGMA+ebx]
1735
 
    and edi,0Fh
1736
 
    and edx,07h
1737
 
    and ecx,0FFFFh
1738
 
    mov edx,[colormodedef+edx*4+%1]
1739
 
    neg edi
1740
 
    cmp dl,2
1741
 
    jne near .no4bit2
1742
 
    shr ecx,5
1743
 
    add edi,esi
1744
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
1745
 
    mov [ngptrdat2],ecx
1746
 
    mov [ngceax+%2*1024+ebx*4],eax
1747
 
    mov [ngcedi+%2*1024+ebx*4],edi
1748
 
    ; eax = pointer to beginning of tile area
1749
 
    jmp drawtileng16x164b
1750
 
.no4bit2
1751
 
    cmp dl,1
1752
 
    jne near .no2bit2
1753
 
    shr ecx,4
1754
 
    add edi,esi
1755
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
1756
 
    mov [ngptrdat2],ecx
1757
 
    mov [ngceax+%2*1024+ebx*4],eax
1758
 
    mov [ngcedi+%2*1024+ebx*4],edi
1759
 
    ; eax = pointer to beginning of tile area
1760
 
    mov dword[mode0add],0
1761
 
    cmp byte[BGMA+ebx],0
1762
 
    jne .nomode02
1763
 
    mov ebx,[mode0ads]
1764
 
    mov [mode0add],ebx
1765
 
.nomode02
1766
 
    jmp drawtileng16x162b
1767
 
.no2bit2
1768
 
    cmp dl,3
1769
 
    jne near .no8bit
1770
 
    shr ecx,6
1771
 
    add edi,esi
1772
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
1773
 
    mov [ngptrdat2],ecx
1774
 
    mov [ngceax+%2*1024+ebx*4],eax
1775
 
    mov [ngcedi+%2*1024+ebx*4],edi
1776
 
    ; eax = pointer to beginning of tile area
1777
 
    jmp drawtileng16x168b
1778
 
.no8bit2
1779
 
    pop ebx
1780
 
    ret
1781
 
%endmacro
1782
 
 
1783
 
%macro drawbgtilengpr1 2
1784
 
    mov dword[ng16bprval],2000h
1785
 
    mov dword[ng16bbgval],%1
1786
 
    cmp byte[t16x161+ebx+%1*256],1
1787
 
    je near .tiles16x16
1788
 
    push ebx
1789
 
    mov edx,[BGMA+ebx]
1790
 
    mov ecx,[bgtxad+ebx*2+%2*512]
1791
 
    and edx,07h
1792
 
    mov [bgtxadd],cx
1793
 
    mov ecx,[ngptrdat+%2*1024+ebx*4]
1794
 
    mov edx,[colormodedef+edx*4+%1]
1795
 
    mov [ngptrdat2],ecx
1796
 
    mov eax,[ngceax+%2*1024+ebx*4]
1797
 
    mov edi,[ngcedi+%2*1024+ebx*4]
1798
 
    cmp dl,2
1799
 
    jne near .no4bit
1800
 
    ; eax = pointer to beginning of tile area
1801
 
    jmp drawtileng4b
1802
 
.no4bit
1803
 
    cmp dl,1
1804
 
    jne near .no2bit
1805
 
    ; eax = pointer to beginning of tile area
1806
 
    mov dword[mode0add],0
1807
 
    cmp byte[BGMA+ebx],0
1808
 
    jne .nomode0
1809
 
    mov ebx,[mode0ads]
1810
 
    mov [mode0add],ebx
1811
 
.nomode0
1812
 
    jmp drawtileng2b
1813
 
.no2bit
1814
 
    cmp dl,3
1815
 
    jne near .no8bit
1816
 
    ; eax = pointer to beginning of tile area
1817
 
    jmp drawtileng8b
1818
 
.no8bit
1819
 
    pop ebx
1820
 
    ret
1821
 
.tiles16x16
1822
 
    mov ecx,[BG1SYl+ebx*2+%1*512]
1823
 
    and ecx,0FFFFh
1824
 
    mov dword[taddnfy16x16],0
1825
 
    add ecx,ebx
1826
 
    mov dword[taddfy16x16],16
1827
 
    test ecx,08h
1828
 
    jz .nobottomy
1829
 
    mov dword[taddnfy16x16],16
1830
 
    mov dword[taddfy16x16],-16
1831
 
.nobottomy
1832
 
    push ebx
1833
 
    mov edx,[BGMA+ebx]
1834
 
    mov ecx,[bgtxad+ebx*2+%2*512]
1835
 
    and edx,07h
1836
 
    mov [bgtxadd],cx
1837
 
    mov ecx,[ngptrdat+%2*1024+ebx*4]
1838
 
    mov edx,[colormodedef+edx*4+%1]
1839
 
    mov [ngptrdat2],ecx
1840
 
    mov eax,[ngceax+%2*1024+ebx*4]
1841
 
    mov edi,[ngcedi+%2*1024+ebx*4]
1842
 
    cmp dl,2
1843
 
    jne near .no4bit2
1844
 
    ; eax = pointer to beginning of tile area
1845
 
    jmp drawtileng16x164b
1846
 
.no4bit2
1847
 
    cmp dl,1
1848
 
    jne near .no2bit2
1849
 
    ; eax = pointer to beginning of tile area
1850
 
    mov dword[mode0add],0
1851
 
    cmp byte[BGMA+ebx],0
1852
 
    jne .nomode02
1853
 
    mov ebx,[mode0ads]
1854
 
    mov [mode0add],ebx
1855
 
.nomode02
1856
 
    jmp drawtileng16x162b
1857
 
.no2bit2
1858
 
    cmp dl,3
1859
 
    jne near .no8bit2
1860
 
    ; eax = pointer to beginning of tile area
1861
 
    jmp drawtileng16x168b
1862
 
.no8bit2
1863
 
    pop ebx
1864
 
    ret
1865
 
%endmacro
1866
 
 
1867
 
%macro drawlineng 8
1868
 
    ; tile value : bit 15 = flipy, bit 14 = flipx, bit 13 = priority value
1869
 
    ;              bit 10-12 = palette, 0-9=tile#
1870
 
    mov ebx,[ng16bbgval]
1871
 
    mov dl,ch
1872
 
    inc dword[bg1drwng+ebx*4]
1873
 
    and ecx,3FFh
1874
 
    and edx,1Fh
1875
 
    add ecx,[ngptrdat2]
1876
 
    mov edx,[%6+edx*4]
1877
 
    %7
1878
 
    jnz near %%docache
1879
 
%%returnfromcache
1880
 
    cmp byte[%1+ecx],2
1881
 
    je near %5
1882
 
    cmp byte[%1+ecx],0
1883
 
    je near %%parttile
1884
 
    %2
1885
 
    ; start drawing from ecx
1886
 
    test dword[vrama+eax],8000h
1887
 
    jnz near %%flipyfull
1888
 
    add ecx,[yposng]
1889
 
    test dword[vrama+eax],4000h
1890
 
    jnz near %%flipxfull
1891
 
    mov ebx,[ecx]
1892
 
    add ebx,edx
1893
 
    mov [edi],ebx
1894
 
    mov ebx,[ecx+4]
1895
 
    add ebx,edx
1896
 
    mov [edi+4],ebx
1897
 
    jmp %5
1898
 
%%flipxfull
1899
 
    mov ebx,[ecx+4]
1900
 
    bswap ebx
1901
 
    add ebx,edx
1902
 
    mov [edi],ebx
1903
 
    mov ebx,[ecx]
1904
 
    bswap ebx
1905
 
    add ebx,edx
1906
 
    mov [edi+4],ebx
1907
 
    jmp %5
1908
 
%%flipyfull
1909
 
    add ecx,[flipyposng]
1910
 
    test word[vrama+eax],4000h
1911
 
    jnz near %%flipxyfull
1912
 
    mov ebx,[ecx]
1913
 
    add ebx,edx
1914
 
    mov [edi],ebx
1915
 
    mov ebx,[ecx+4]
1916
 
    add ebx,edx
1917
 
    mov [edi+4],ebx
1918
 
    jmp %5
1919
 
%%flipxyfull
1920
 
    mov ebx,[ecx+4]
1921
 
    bswap ebx
1922
 
    add ebx,edx
1923
 
    mov [edi],ebx
1924
 
    mov ebx,[ecx]
1925
 
    bswap ebx
1926
 
    add ebx,edx
1927
 
    mov [edi+4],ebx
1928
 
    jmp %5
1929
 
%%parttile
1930
 
    %2
1931
 
    ; start drawing from ecx to edi
1932
 
    test word[vrama+eax],8000h
1933
 
    jnz near %%flipypart
1934
 
    add ecx,[yposng]
1935
 
    test word[vrama+eax],4000h
1936
 
    jnz near %%flipxpart
1937
 
    mov ebx,[ecx]
1938
 
    or ebx,ebx
1939
 
    jz %%drawd
1940
 
    add ebx,edx
1941
 
    test bl,%8
1942
 
    jz %%drawa
1943
 
    mov [edi],bl
1944
 
%%drawa
1945
 
    test bh,%8
1946
 
    jz %%drawb
1947
 
    mov [edi+1],bh
1948
 
%%drawb
1949
 
    shr ebx,16
1950
 
    test bl,%8
1951
 
    jz %%drawc
1952
 
    mov [edi+2],bl
1953
 
%%drawc
1954
 
    test bh,%8
1955
 
    jz %%drawd
1956
 
    mov [edi+3],bh
1957
 
%%drawd
1958
 
    mov ebx,[ecx+4]
1959
 
    or ebx,ebx
1960
 
    jz %%drawd2
1961
 
    add ebx,edx
1962
 
    test bl,%8
1963
 
    jz %%drawa2
1964
 
    mov [edi+4],bl
1965
 
%%drawa2
1966
 
    test bh,%8
1967
 
    jz %%drawb2
1968
 
    mov [edi+5],bh
1969
 
%%drawb2
1970
 
    shr ebx,16
1971
 
    test bl,%8
1972
 
    jz %%drawc2
1973
 
    mov [edi+6],bl
1974
 
%%drawc2
1975
 
    test bh,%8
1976
 
    jz %%drawd2
1977
 
    mov [edi+7],bh
1978
 
%%drawd2
1979
 
    jmp %5
1980
 
 
1981
 
%%flipxpart
1982
 
    mov ebx,[ecx]
1983
 
    or ebx,ebx
1984
 
    jz %%drawdf
1985
 
    add ebx,edx
1986
 
    test bl,%8
1987
 
    jz %%drawaf
1988
 
    mov [edi+7],bl
1989
 
%%drawaf
1990
 
    test bh,%8
1991
 
    jz %%drawbf
1992
 
    mov [edi+6],bh
1993
 
%%drawbf
1994
 
    shr ebx,16
1995
 
    test bl,%8
1996
 
    jz %%drawcf
1997
 
    mov [edi+5],bl
1998
 
%%drawcf
1999
 
    test bh,%8
2000
 
    jz %%drawdf
2001
 
    mov [edi+4],bh
2002
 
%%drawdf
2003
 
    mov ebx,[ecx+4]
2004
 
    or ebx,ebx
2005
 
    jz %%drawd2f
2006
 
    add ebx,edx
2007
 
    test bl,%8
2008
 
    jz %%drawa2f
2009
 
    mov [edi+3],bl
2010
 
%%drawa2f
2011
 
    test bh,%8
2012
 
    jz %%drawb2f
2013
 
    mov [edi+2],bh
2014
 
%%drawb2f
2015
 
    shr ebx,16
2016
 
    test bl,%8
2017
 
    jz %%drawc2f
2018
 
    mov [edi+1],bl
2019
 
%%drawc2f
2020
 
    test bh,%8
2021
 
    jz %%drawd2f
2022
 
    mov [edi],bh
2023
 
%%drawd2f
2024
 
    jmp %5
2025
 
 
2026
 
%%flipypart
2027
 
    add ecx,[flipyposng]
2028
 
    test word[vrama+eax],4000h
2029
 
    jnz near %%flipxypart
2030
 
    mov ebx,[ecx]
2031
 
    or ebx,ebx
2032
 
    jz %%drawdm
2033
 
    add ebx,edx
2034
 
    test bl,%8
2035
 
    jz %%drawam
2036
 
    mov [edi],bl
2037
 
%%drawam
2038
 
    test bh,%8
2039
 
    jz %%drawbm
2040
 
    mov [edi+1],bh
2041
 
%%drawbm
2042
 
    shr ebx,16
2043
 
    test bl,%8
2044
 
    jz %%drawcm
2045
 
    mov [edi+2],bl
2046
 
%%drawcm
2047
 
    test bh,%8
2048
 
    jz %%drawdm
2049
 
    mov [edi+3],bh
2050
 
%%drawdm
2051
 
    mov ebx,[ecx+4]
2052
 
    or ebx,ebx
2053
 
    jz %%drawd2m
2054
 
    add ebx,edx
2055
 
    test bl,%8
2056
 
    jz %%drawa2m
2057
 
    mov [edi+4],bl
2058
 
%%drawa2m
2059
 
    test bh,%8
2060
 
    jz %%drawb2m
2061
 
    mov [edi+5],bh
2062
 
%%drawb2m
2063
 
    shr ebx,16
2064
 
    test bl,%8
2065
 
    jz %%drawc2m
2066
 
    mov [edi+6],bl
2067
 
%%drawc2m
2068
 
    test bh,%8
2069
 
    jz %%drawd2m
2070
 
    mov [edi+7],bh
2071
 
%%drawd2m
2072
 
    jmp %5
2073
 
 
2074
 
%%flipxypart
2075
 
    mov ebx,[ecx]
2076
 
    or ebx,ebx
2077
 
    jz %%drawdfm
2078
 
    add ebx,edx
2079
 
    test bl,%8
2080
 
    jz %%drawafm
2081
 
    mov [edi+7],bl
2082
 
%%drawafm
2083
 
    test bh,%8
2084
 
    jz %%drawbfm
2085
 
    mov [edi+6],bh
2086
 
%%drawbfm
2087
 
    shr ebx,16
2088
 
    test bl,%8
2089
 
    jz %%drawcfm
2090
 
    mov [edi+5],bl
2091
 
%%drawcfm
2092
 
    test bh,%8
2093
 
    jz %%drawdfm
2094
 
    mov [edi+4],bh
2095
 
%%drawdfm
2096
 
    mov ebx,[ecx+4]
2097
 
    or ebx,ebx
2098
 
    jz %%drawd2fm
2099
 
    add ebx,edx
2100
 
    test bl,%8
2101
 
    jz %%drawa2fm
2102
 
    mov [edi+3],bl
2103
 
%%drawa2fm
2104
 
    test bh,%8
2105
 
    jz %%drawb2fm
2106
 
    mov [edi+2],bh
2107
 
%%drawb2fm
2108
 
    shr ebx,16
2109
 
    test bl,%8
2110
 
    jz %%drawc2fm
2111
 
    mov [edi+1],bl
2112
 
%%drawc2fm
2113
 
    test bh,%8
2114
 
    jz %%drawd2fm
2115
 
    mov [edi],bh
2116
 
%%drawd2fm
2117
 
%5
2118
 
    mov ebx,[ng16bbgval]
2119
 
    add ax,2
2120
 
    inc dword[bg1totng+ebx*4]
2121
 
    add edi,8
2122
 
    test eax,03Fh
2123
 
    jz %%tileadd
2124
 
%%next
2125
 
    dec byte[tleftn]
2126
 
    jnz near %4
2127
 
    pop ebx
2128
 
    cmp byte[curmosaicsz],1
2129
 
    jne near domosaicng
2130
 
    ret
2131
 
%%docache
2132
 
    call %3
2133
 
    jmp %%returnfromcache
2134
 
%%tileadd
2135
 
    add ax,[bgtxadd]
2136
 
    jmp %%next
2137
 
%endmacro
2138
 
 
2139
 
%macro drawlineng16x16 8
2140
 
    ; tile value : bit 15 = flipy, bit 14 = flipx, bit 13 = priority value
2141
 
    ;              bit 10-12 = palette, 0-9=tile#
2142
 
    mov ebx,[ng16bbgval]
2143
 
    mov dl,ch
2144
 
    inc dword[bg1drwng+ebx*4]
2145
 
    and ecx,3FFh
2146
 
    and edx,1Fh
2147
 
    add ecx,[ngptrdat2]
2148
 
    add cx,[taddnfy16x16]
2149
 
    test dword[vrama+eax],8000h
2150
 
    jz %%noflipy
2151
 
    add cx,[taddfy16x16]
2152
 
%%noflipy
2153
 
    test dword[vrama+eax],4000h
2154
 
    jz %%noflipx
2155
 
    inc cx
2156
 
%%noflipx
2157
 
%%nexttile
2158
 
    push ecx
2159
 
    push edx
2160
 
    mov edx,[%6+edx*4]
2161
 
    %7
2162
 
    jnz near %%docache
2163
 
%%returnfromcache
2164
 
    cmp byte[%1+ecx],2
2165
 
    je near %%done
2166
 
    cmp byte[%1+ecx],0
2167
 
    je near %%parttile
2168
 
    %2
2169
 
    ; start drawing from ecx
2170
 
    test dword[vrama+eax],8000h
2171
 
    jnz near %%flipyfull
2172
 
    add ecx,[yposng]
2173
 
    test dword[vrama+eax],4000h
2174
 
    jnz near %%flipxfull
2175
 
    mov ebx,[ecx]
2176
 
    add ebx,edx
2177
 
    mov [edi],ebx
2178
 
    mov ebx,[ecx+4]
2179
 
    add ebx,edx
2180
 
    mov [edi+4],ebx
2181
 
    jmp %%done
2182
 
%%flipxfull
2183
 
    mov ebx,[ecx+4]
2184
 
    bswap ebx
2185
 
    add ebx,edx
2186
 
    mov [edi],ebx
2187
 
    mov ebx,[ecx]
2188
 
    bswap ebx
2189
 
    add ebx,edx
2190
 
    mov [edi+4],ebx
2191
 
    jmp %%done
2192
 
%%flipyfull
2193
 
    add ecx,[flipyposng]
2194
 
    test word[vrama+eax],4000h
2195
 
    jnz near %%flipxyfull
2196
 
    mov ebx,[ecx]
2197
 
    add ebx,edx
2198
 
    mov [edi],ebx
2199
 
    mov ebx,[ecx+4]
2200
 
    add ebx,edx
2201
 
    mov [edi+4],ebx
2202
 
    jmp %%done
2203
 
%%flipxyfull
2204
 
    mov ebx,[ecx+4]
2205
 
    bswap ebx
2206
 
    add ebx,edx
2207
 
    mov [edi],ebx
2208
 
    mov ebx,[ecx]
2209
 
    bswap ebx
2210
 
    add ebx,edx
2211
 
    mov [edi+4],ebx
2212
 
    jmp %%done
2213
 
%%parttile
2214
 
    %2
2215
 
    ; start drawing from ecx to edi
2216
 
    test word[vrama+eax],8000h
2217
 
    jnz near %%flipypart
2218
 
    add ecx,[yposng]
2219
 
    test word[vrama+eax],4000h
2220
 
    jnz near %%flipxpart
2221
 
    mov ebx,[ecx]
2222
 
    or ebx,ebx
2223
 
    jz %%drawd
2224
 
    add ebx,edx
2225
 
    test bl,%8
2226
 
    jz %%drawa
2227
 
    mov [edi],bl
2228
 
%%drawa
2229
 
    test bh,%8
2230
 
    jz %%drawb
2231
 
    mov [edi+1],bh
2232
 
%%drawb
2233
 
    shr ebx,16
2234
 
    test bl,%8
2235
 
    jz %%drawc
2236
 
    mov [edi+2],bl
2237
 
%%drawc
2238
 
    test bh,%8
2239
 
    jz %%drawd
2240
 
    mov [edi+3],bh
2241
 
%%drawd
2242
 
    mov ebx,[ecx+4]
2243
 
    or ebx,ebx
2244
 
    jz %%drawd2
2245
 
    add ebx,edx
2246
 
    test bl,%8
2247
 
    jz %%drawa2
2248
 
    mov [edi+4],bl
2249
 
%%drawa2
2250
 
    test bh,%8
2251
 
    jz %%drawb2
2252
 
    mov [edi+5],bh
2253
 
%%drawb2
2254
 
    shr ebx,16
2255
 
    test bl,%8
2256
 
    jz %%drawc2
2257
 
    mov [edi+6],bl
2258
 
%%drawc2
2259
 
    test bh,%8
2260
 
    jz %%drawd2
2261
 
    mov [edi+7],bh
2262
 
%%drawd2
2263
 
    jmp %%done
2264
 
 
2265
 
%%flipxpart
2266
 
    mov ebx,[ecx]
2267
 
    or ebx,ebx
2268
 
    jz %%drawdf
2269
 
    add ebx,edx
2270
 
    test bl,%8
2271
 
    jz %%drawaf
2272
 
    mov [edi+7],bl
2273
 
%%drawaf
2274
 
    test bh,%8
2275
 
    jz %%drawbf
2276
 
    mov [edi+6],bh
2277
 
%%drawbf
2278
 
    shr ebx,16
2279
 
    test bl,%8
2280
 
    jz %%drawcf
2281
 
    mov [edi+5],bl
2282
 
%%drawcf
2283
 
    test bh,%8
2284
 
    jz %%drawdf
2285
 
    mov [edi+4],bh
2286
 
%%drawdf
2287
 
    mov ebx,[ecx+4]
2288
 
    or ebx,ebx
2289
 
    jz %%drawd2f
2290
 
    add ebx,edx
2291
 
    test bl,%8
2292
 
    jz %%drawa2f
2293
 
    mov [edi+3],bl
2294
 
%%drawa2f
2295
 
    test bh,%8
2296
 
    jz %%drawb2f
2297
 
    mov [edi+2],bh
2298
 
%%drawb2f
2299
 
    shr ebx,16
2300
 
    test bl,%8
2301
 
    jz %%drawc2f
2302
 
    mov [edi+1],bl
2303
 
%%drawc2f
2304
 
    test bh,%8
2305
 
    jz %%drawd2f
2306
 
    mov [edi],bh
2307
 
%%drawd2f
2308
 
    jmp %%done
2309
 
 
2310
 
%%flipypart
2311
 
    add ecx,[flipyposng]
2312
 
    test word[vrama+eax],4000h
2313
 
    jnz near %%flipxypart
2314
 
    mov ebx,[ecx]
2315
 
    or ebx,ebx
2316
 
    jz %%drawdm
2317
 
    add ebx,edx
2318
 
    test bl,%8
2319
 
    jz %%drawam
2320
 
    mov [edi],bl
2321
 
%%drawam
2322
 
    test bh,%8
2323
 
    jz %%drawbm
2324
 
    mov [edi+1],bh
2325
 
%%drawbm
2326
 
    shr ebx,16
2327
 
    test bl,%8
2328
 
    jz %%drawcm
2329
 
    mov [edi+2],bl
2330
 
%%drawcm
2331
 
    test bh,%8
2332
 
    jz %%drawdm
2333
 
    mov [edi+3],bh
2334
 
%%drawdm
2335
 
    mov ebx,[ecx+4]
2336
 
    or ebx,ebx
2337
 
    jz %%drawd2m
2338
 
    add ebx,edx
2339
 
    test bl,%8
2340
 
    jz %%drawa2m
2341
 
    mov [edi+4],bl
2342
 
%%drawa2m
2343
 
    test bh,%8
2344
 
    jz %%drawb2m
2345
 
    mov [edi+5],bh
2346
 
%%drawb2m
2347
 
    shr ebx,16
2348
 
    test bl,%8
2349
 
    jz %%drawc2m
2350
 
    mov [edi+6],bl
2351
 
%%drawc2m
2352
 
    test bh,%8
2353
 
    jz %%drawd2m
2354
 
    mov [edi+7],bh
2355
 
%%drawd2m
2356
 
    jmp %%done
2357
 
 
2358
 
%%flipxypart
2359
 
    mov ebx,[ecx]
2360
 
    or ebx,ebx
2361
 
    jz %%drawdfm
2362
 
    add ebx,edx
2363
 
    test bl,%8
2364
 
    jz %%drawafm
2365
 
    mov [edi+7],bl
2366
 
%%drawafm
2367
 
    test bh,%8
2368
 
    jz %%drawbfm
2369
 
    mov [edi+6],bh
2370
 
%%drawbfm
2371
 
    shr ebx,16
2372
 
    test bl,%8
2373
 
    jz %%drawcfm
2374
 
    mov [edi+5],bl
2375
 
%%drawcfm
2376
 
    test bh,%8
2377
 
    jz %%drawdfm
2378
 
    mov [edi+4],bh
2379
 
%%drawdfm
2380
 
    mov ebx,[ecx+4]
2381
 
    or ebx,ebx
2382
 
    jz %%drawd2fm
2383
 
    add ebx,edx
2384
 
    test bl,%8
2385
 
    jz %%drawa2fm
2386
 
    mov [edi+3],bl
2387
 
%%drawa2fm
2388
 
    test bh,%8
2389
 
    jz %%drawb2fm
2390
 
    mov [edi+2],bh
2391
 
%%drawb2fm
2392
 
    shr ebx,16
2393
 
    test bl,%8
2394
 
    jz %%drawc2fm
2395
 
    mov [edi+1],bl
2396
 
%%drawc2fm
2397
 
    test bh,%8
2398
 
    jz %%drawd2fm
2399
 
    mov [edi],bh
2400
 
%%drawd2fm
2401
 
%%done
2402
 
    pop edx
2403
 
    pop ecx
2404
 
    inc cx
2405
 
    test dword[vrama+eax],4000h
2406
 
    jz %%noflipxb
2407
 
    sub cx,2
2408
 
%%noflipxb
2409
 
    add edi,8
2410
 
    xor dword[switch16x16],1
2411
 
    jnz near %%nexttile
2412
 
%%ntile
2413
 
    mov ebx,[ng16bbgval]
2414
 
    add ax,2
2415
 
    inc dword[bg1totng+ebx*4]
2416
 
    test eax,03Fh
2417
 
    jz %%tileadd
2418
 
%%next
2419
 
    dec byte[tleftn]
2420
 
    jnz near %4
2421
 
    pop ebx
2422
 
    cmp byte[curmosaicsz],1
2423
 
    jne near domosaicng
2424
 
    ret
2425
 
%5
2426
 
    add edi,16
2427
 
    jmp %%ntile
2428
 
%%docache
2429
 
    call %3
2430
 
    jmp %%returnfromcache
2431
 
%%tileadd
2432
 
    add ax,[bgtxadd]
2433
 
    jmp %%next
2434
 
%endmacro
2435
 
 
2436
 
%macro drawbglineng 2
2437
 
    mov dword[ng16bprval],0
2438
 
    mov dword[ng16bbgval],%1
2439
 
    cmp byte[bgmode],5
2440
 
    jb %%nointerl
2441
 
    test byte[intrlng+ebx],01h
2442
 
    jz %%nointerl
2443
 
    add ecx,ebx
2444
 
    add ecx,[cfieldad]
2445
 
%%nointerl
2446
 
    push ebx
2447
 
    mov byte[curmosaicsz],1
2448
 
    xor eax,eax
2449
 
    test byte[mosenng+ebx],1 << %1
2450
 
    jz %%nomosaic
2451
 
    mov al,[mosszng+ebx]
2452
 
    or al,al
2453
 
    jz %%nomosaic
2454
 
    inc al
2455
 
    mov byte[curmosaicsz],al
2456
 
    mov cl,al
2457
 
    mov al,bl
2458
 
    div cl
2459
 
    mul cl
2460
 
    mov ebx,eax
2461
 
    mov [pesimpng],esi
2462
 
    mov edi,xtravbuf+16
2463
 
    mov ecx,64
2464
 
    xor eax,eax
2465
 
    mov esi,xtravbuf+16
2466
 
    rep stosd
2467
 
    or ebx,ebx
2468
 
    jnz %%nozeroline
2469
 
    inc ebx
2470
 
%%nozeroline
2471
 
    mov ecx,[BG1SYl+ebx*2+%1*512]
2472
 
    and ecx,0FFFFh
2473
 
    add ecx,ebx
2474
 
    jmp %%yesmosaic
2475
 
%%nomosaic
2476
 
    cmp byte[BGMA+ebx],5
2477
 
    jae near .tiles16x8
2478
 
%%yesmosaic
2479
 
    cmp byte[t16x161+ebx+%1*256],1
2480
 
    je near .tiles16x16
2481
 
    cmp byte[BGMA+ebx],2
2482
 
    je near .offsetm
2483
 
;    cmp byte[BGMA+ebx],4
2484
 
;    je near .offsetm2
2485
 
    mov eax,[BGPT1+ebx*2+%1*512]
2486
 
    test ecx,100h
2487
 
    jz .noyinc
2488
 
    add eax,[BGPT1Y+ebx*2+%1*512]
2489
 
.noyinc
2490
 
    lea ecx,[ecx*8]
2491
 
    mov edx,ecx
2492
 
    and ecx,07C0h      ; 1Fh*40h
2493
 
    and edx,38h
2494
 
    add eax,ecx
2495
 
    mov [yposng],edx
2496
 
    xor edx,38h
2497
 
    mov ecx,[BG1SXl+ebx*2+%1*512]
2498
 
    mov [flipyposng],edx
2499
 
    mov edx,[BGPT1X+ebx*2+%1*512]
2500
 
    test ecx,100h
2501
 
    jz .noxinc
2502
 
    add eax,edx
2503
 
    neg dx
2504
 
.noxinc
2505
 
    mov edi,ecx
2506
 
    sub dx,64
2507
 
    and ecx,0F8h
2508
 
    and eax,0FFFFh
2509
 
    shr ecx,2
2510
 
    mov [bgtxadd],edx
2511
 
    mov [bgtxad+ebx*2+%2*512],dx
2512
 
    add eax,ecx
2513
 
    mov ecx,[BGOPT1+ebx*2+%1*512]
2514
 
    mov edx,[BGMA+ebx]
2515
 
    and edi,07h
2516
 
    and edx,07h
2517
 
    and ecx,0FFFFh
2518
 
    mov edx,[colormodedef+edx*4+%1]
2519
 
    neg edi
2520
 
    cmp dl,2
2521
 
    jne near .no4bit
2522
 
    shr ecx,5
2523
 
    add edi,esi
2524
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
2525
 
    mov [ngptrdat2],ecx
2526
 
    mov [ngceax+%2*1024+ebx*4],eax
2527
 
    mov [ngcedi+%2*1024+ebx*4],edi
2528
 
    ; eax = pointer to beginning of tile area
2529
 
    jmp drawlineng4b
2530
 
.no4bit
2531
 
    cmp dl,1
2532
 
    jne near .no2bit
2533
 
    shr ecx,4
2534
 
    add edi,esi
2535
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
2536
 
    mov [ngptrdat2],ecx
2537
 
    mov [ngceax+%2*1024+ebx*4],eax
2538
 
    mov [ngcedi+%2*1024+ebx*4],edi
2539
 
    ; eax = pointer to beginning of tile area
2540
 
    mov dword[mode0add],0
2541
 
    cmp byte[BGMA+ebx],0
2542
 
    jne .nomode0
2543
 
    mov ebx,[mode0ads]
2544
 
    mov [mode0add],ebx
2545
 
.nomode0
2546
 
    jmp drawlineng2b
2547
 
.no2bit
2548
 
    cmp dl,3
2549
 
    jne near .no8bit
2550
 
    shr ecx,6
2551
 
    add edi,esi
2552
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
2553
 
    mov [ngptrdat2],ecx
2554
 
    mov [ngceax+%2*1024+ebx*4],eax
2555
 
    mov [ngcedi+%2*1024+ebx*4],edi
2556
 
    ; eax = pointer to beginning of tile area
2557
 
    jmp drawlineng8b
2558
 
.no8bit
2559
 
    pop ebx
2560
 
    ret
2561
 
 
2562
 
.tiles16x16
2563
 
    mov dword[taddnfy16x16],0
2564
 
    mov dword[taddfy16x16],16
2565
 
    test ecx,08h
2566
 
    jz .nobottomy
2567
 
    mov dword[taddnfy16x16],16
2568
 
    mov dword[taddfy16x16],-16
2569
 
.nobottomy
2570
 
    mov eax,[BGPT1+ebx*2+%1*512]
2571
 
    test ecx,200h
2572
 
    jz .noyinc2
2573
 
    add eax,[BGPT1Y+ebx*2+%1*512]
2574
 
.noyinc2
2575
 
    lea edx,[ecx*8]
2576
 
    lea ecx,[ecx*4]
2577
 
    and edx,38h
2578
 
    and ecx,07C0h      ; 1Fh*40h
2579
 
    mov [yposng],edx
2580
 
    xor edx,38h
2581
 
    add eax,ecx
2582
 
    mov [flipyposng],edx
2583
 
    mov ecx,[BG1SXl+ebx*2+%1*512]
2584
 
    mov edx,[BGPT1X+ebx*2+%1*512]
2585
 
    test ecx,200h
2586
 
    jz .noxinc2
2587
 
    add eax,edx
2588
 
    neg dx
2589
 
.noxinc2
2590
 
    mov edi,ecx
2591
 
    sub dx,64
2592
 
    and ecx,1F0h
2593
 
    and eax,0FFFFh
2594
 
    shr ecx,3
2595
 
    mov [bgtxadd],edx
2596
 
    mov [bgtxad+ebx*2+%2*512],dx
2597
 
    add eax,ecx
2598
 
    mov ecx,[BGOPT1+ebx*2+%1*512]
2599
 
    mov edx,[BGMA+ebx]
2600
 
    and edi,0Fh
2601
 
    and edx,07h
2602
 
    and ecx,0FFFFh
2603
 
    mov edx,[colormodedef+edx*4+%1]
2604
 
    neg edi
2605
 
    cmp dl,2
2606
 
    jne near .no4bit2
2607
 
    shr ecx,5
2608
 
    add edi,esi
2609
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
2610
 
    mov [ngptrdat2],ecx
2611
 
    mov [ngceax+%2*1024+ebx*4],eax
2612
 
    mov [ngcedi+%2*1024+ebx*4],edi
2613
 
    ; eax = pointer to beginning of tile area
2614
 
    jmp drawlineng16x164b
2615
 
.no4bit2
2616
 
    cmp dl,1
2617
 
    jne near .no2bit2
2618
 
    shr ecx,4
2619
 
    add edi,esi
2620
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
2621
 
    mov [ngptrdat2],ecx
2622
 
    mov [ngceax+%2*1024+ebx*4],eax
2623
 
    mov [ngcedi+%2*1024+ebx*4],edi
2624
 
    ; eax = pointer to beginning of tile area
2625
 
    mov dword[mode0add],0
2626
 
    cmp byte[BGMA+ebx],0
2627
 
    jne .nomode02
2628
 
    mov ebx,[mode0ads]
2629
 
    mov [mode0add],ebx
2630
 
.nomode02
2631
 
    jmp drawlineng16x162b
2632
 
.no2bit2
2633
 
    cmp dl,3
2634
 
    jne near .no8bit
2635
 
    shr ecx,6
2636
 
    add edi,esi
2637
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
2638
 
    mov [ngptrdat2],ecx
2639
 
    mov [ngceax+%2*1024+ebx*4],eax
2640
 
    mov [ngcedi+%2*1024+ebx*4],edi
2641
 
    ; eax = pointer to beginning of tile area
2642
 
    jmp drawlineng16x168b
2643
 
.no8bit2
2644
 
    pop ebx
2645
 
    ret
2646
 
 
2647
 
.tiles16x8
2648
 
    cmp byte[t16x161+ebx+%1*256],1
2649
 
    je .tiles16x16hr
2650
 
    mov dword[taddnfy16x16],0
2651
 
    mov dword[taddfy16x16],0
2652
 
    mov eax,[BGPT1+ebx*2+%1*512]
2653
 
    test ecx,100h
2654
 
    jz .noyinc2c
2655
 
    add eax,[BGPT1Y+ebx*2+%1*512]
2656
 
.noyinc2c
2657
 
    lea ecx,[ecx*8]
2658
 
    mov edx,ecx
2659
 
    and ecx,07C0h      ; 1Fh*40h
2660
 
    and edx,38h
2661
 
    jmp .tiles16x8hr
2662
 
.tiles16x16hr
2663
 
    mov dword[taddnfy16x16],0
2664
 
    mov dword[taddfy16x16],16
2665
 
    test ecx,08h
2666
 
    jz .nobottomy2
2667
 
    mov dword[taddnfy16x16],16
2668
 
    mov dword[taddfy16x16],-16
2669
 
.nobottomy2
2670
 
    mov eax,[BGPT1+ebx*2+%1*512]
2671
 
    test ecx,200h
2672
 
    jz .noyinc2b
2673
 
    add eax,[BGPT1Y+ebx*2+%1*512]
2674
 
.noyinc2b
2675
 
    lea edx,[ecx*8]
2676
 
    lea ecx,[ecx*4]
2677
 
    and edx,38h
2678
 
    and ecx,07C0h      ; 1Fh*40h
2679
 
.tiles16x8hr
2680
 
    mov [yposng],edx
2681
 
    xor edx,38h
2682
 
    add eax,ecx
2683
 
    mov [flipyposng],edx
2684
 
    mov ecx,[BG1SXl+ebx*2+%1*512]
2685
 
    add ecx,ecx
2686
 
    mov edx,[BGPT1X+ebx*2+%1*512]
2687
 
    test ecx,200h
2688
 
    jz .noxinc2b
2689
 
    add eax,edx
2690
 
    neg dx
2691
 
.noxinc2b
2692
 
    mov edi,ecx
2693
 
    sub dx,64
2694
 
    and ecx,01F0h
2695
 
    and eax,0FFFFh
2696
 
    shr ecx,3
2697
 
    mov [bgtxadd],edx
2698
 
    mov [bgtxad+ebx*2+%2*512],dx
2699
 
    add eax,ecx
2700
 
    mov ecx,[BGOPT1+ebx*2+%1*512]
2701
 
    mov edx,[BGMA+ebx]
2702
 
    and edi,0Fh
2703
 
    and edx,07h
2704
 
    and ecx,0FFFFh
2705
 
    shr edi,1
2706
 
    mov edx,[colormodedef+edx*4+%1]
2707
 
    neg edi
2708
 
    cmp dl,2
2709
 
    jne near .no4bit2b
2710
 
    shr ecx,5
2711
 
    add edi,esi
2712
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
2713
 
    mov [ngptrdat2],ecx
2714
 
    mov [ngceax+%2*1024+ebx*4],eax
2715
 
    mov [ngcedi+%2*1024+ebx*4],edi
2716
 
    ; eax = pointer to beginning of tile area
2717
 
    mov byte[tleftn],33
2718
 
.loop2b
2719
 
    mov cx,[vrama+eax]
2720
 
    test ecx,2000h
2721
 
    jnz near .fintile2b
2722
 
    drawlineng16x8 tltype4b, preparet4ba, cachesingle4bng,.loop2b,.fintile2b,ngpalcon4b,test4ba,0Fh,%1
2723
 
.no4bit2b
2724
 
    cmp dl,1
2725
 
    jne near .no2bit2b
2726
 
    shr ecx,4
2727
 
    add edi,esi
2728
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
2729
 
    mov [ngptrdat2],ecx
2730
 
    mov [ngceax+%2*1024+ebx*4],eax
2731
 
    mov [ngcedi+%2*1024+ebx*4],edi
2732
 
    ; eax = pointer to beginning of tile area
2733
 
    mov dword[mode0add],0
2734
 
    mov byte[tleftn],33
2735
 
.loopb2b
2736
 
    mov cx,[vrama+eax]
2737
 
    test ecx,2000h
2738
 
    jnz near .fintileb2b
2739
 
    drawlineng16x8 tltype2b, preparet2ba, cachesingle2bng,.loopb2b,.fintileb2b,ngpalcon2b,test2ba,03h,%1
2740
 
.no2bit2b
2741
 
    pop ebx
2742
 
    ret
2743
 
 
2744
 
    ; Offsetmode calculation : <b2-7,2109>*1024+<b3-7,2112>*32+<b3-7,2111>
2745
 
.offsetm
2746
 
    xor edx,edx
2747
 
    mov dx,[BG3SYl+ebx*2]
2748
 
    and dx,0F8h
2749
 
    shr edx,3
2750
 
    shl edx,6
2751
 
    xor eax,eax
2752
 
    mov ax,[BGPT3+ebx*2]
2753
 
    add ax,dx
2754
 
    xor edx,edx
2755
 
    mov dx,[BG3SXl+ebx*2]
2756
 
    and dx,0F8h
2757
 
    mov [ofsmcyps],ebx
2758
 
    shr edx,3
2759
 
    shl edx,1
2760
 
    add ax,dx
2761
 
    add eax,40h
2762
 
    mov edx,eax
2763
 
    and edx,0FFFFFFC0h
2764
 
    add edx,[vram]
2765
 
    mov [ofsmcptr],edx
2766
 
    and eax,3Fh
2767
 
    mov [ofsmcptr2],eax
2768
 
    mov eax,[BGPT1Y+ebx*2+%1*512]
2769
 
    mov [ofsmady],eax
2770
 
    mov eax,[BGPT1X+ebx*2+%1*512]
2771
 
    mov [ofsmadx],eax
2772
 
    mov eax,[BGPT1+ebx*2+%1*512]
2773
 
    mov [ofsmtptr],eax
2774
 
    mov [ofsmtptrs],eax
2775
 
    test ecx,100h
2776
 
    jz .noyincd
2777
 
    add eax,[BGPT1Y+ebx*2+%1*512]
2778
 
.noyincd
2779
 
    lea ecx,[ecx*8]
2780
 
    mov edx,ecx
2781
 
    and ecx,07C0h      ; 1Fh*40h
2782
 
    and edx,38h
2783
 
    add eax,ecx
2784
 
    mov [yposng],edx
2785
 
    mov [yposngom],edx
2786
 
    xor edx,38h
2787
 
    mov ecx,[BG1SXl+ebx*2+%1*512]
2788
 
    mov [flipyposng],edx
2789
 
    mov [flipyposngom],edx
2790
 
    mov edx,[BGPT1X+ebx*2+%1*512]
2791
 
    test ecx,100h
2792
 
    jz .noxincd
2793
 
    add eax,edx
2794
 
    add [ofsmtptr],edx
2795
 
    neg dx
2796
 
.noxincd
2797
 
    mov edi,ecx
2798
 
    sub dx,64
2799
 
    and ecx,0F8h
2800
 
    and eax,0FFFFh
2801
 
    shr ecx,2
2802
 
    mov [bgtxadd],edx
2803
 
    mov [bgtxad+ebx*2+%2*512],dx
2804
 
    add eax,ecx
2805
 
    add [ofsmtptr],ecx
2806
 
    mov [ofsmmptr],eax
2807
 
    mov dword[ofshvaladd],0
2808
 
    mov ecx,[BGOPT1+ebx*2+%1*512]
2809
 
    mov edx,[BGMA+ebx]
2810
 
    and edi,07h
2811
 
    and edx,07h
2812
 
    and ecx,0FFFFh
2813
 
    mov edx,[colormodedef+edx*4+%1]
2814
 
    neg edi
2815
 
    cmp dl,2
2816
 
    jne near .no4bitd
2817
 
    shr ecx,5
2818
 
    add edi,esi
2819
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
2820
 
    mov [ngptrdat2],ecx
2821
 
    mov [ngceax+%2*1024+ebx*4],eax
2822
 
    mov [ngcedi+%2*1024+ebx*4],edi
2823
 
    ; eax = pointer to beginning of tile area
2824
 
    mov byte[tleftn],33
2825
 
.loopd
2826
 
    mov cx,[vrama+eax]
2827
 
    test ecx,2000h
2828
 
    jnz near .fintiled
2829
 
    drawlinengom  tltype4b, preparet4ba, cachesingle4bng,.loopd,.fintiled,ngpalcon4b,test4ba,0Fh,%1
2830
 
.no4bitd
2831
 
    pop ebx
2832
 
    ret
2833
 
 
2834
 
.offsetm2
2835
 
    xor edx,edx
2836
 
    mov dx,[BG3SYl+ebx*2]
2837
 
    and dx,0F8h
2838
 
    shr edx,3
2839
 
    shl edx,6
2840
 
    xor eax,eax
2841
 
    mov ax,[BGPT3+ebx*2]
2842
 
    add ax,dx
2843
 
    xor edx,edx
2844
 
    mov dx,[BG3SXl+ebx*2]
2845
 
    and dx,0F8h
2846
 
    mov [ofsmcyps],ebx
2847
 
    shr edx,3
2848
 
    shl edx,1
2849
 
    add ax,dx
2850
 
    add eax,40h
2851
 
    mov edx,eax
2852
 
    and edx,0FFFFFFC0h
2853
 
    add edx,[vram]
2854
 
    mov [ofsmcptr],edx
2855
 
    and eax,3Fh
2856
 
    mov [ofsmcptr2],eax
2857
 
    mov eax,[BGPT1Y+ebx*2+%1*512]
2858
 
    mov [ofsmady],eax
2859
 
    mov eax,[BGPT1X+ebx*2+%1*512]
2860
 
    mov [ofsmadx],eax
2861
 
    mov eax,[BGPT1+ebx*2+%1*512]
2862
 
    mov [ofsmtptr],eax
2863
 
    mov [ofsmtptrs],eax
2864
 
    test ecx,100h
2865
 
    jz .noyincdn
2866
 
    add eax,[BGPT1Y+ebx*2+%1*512]
2867
 
.noyincdn
2868
 
    lea ecx,[ecx*8]
2869
 
    mov edx,ecx
2870
 
    and ecx,07C0h      ; 1Fh*40h
2871
 
    and edx,38h
2872
 
    add eax,ecx
2873
 
    mov [yposng],edx
2874
 
    mov [yposngom],edx
2875
 
    xor edx,38h
2876
 
    mov ecx,[BG1SXl+ebx*2+%1*512]
2877
 
    mov [flipyposng],edx
2878
 
    mov [flipyposngom],edx
2879
 
    mov edx,[BGPT1X+ebx*2+%1*512]
2880
 
    test ecx,100h
2881
 
    jz .noxincdn
2882
 
    add eax,edx
2883
 
    add [ofsmtptr],edx
2884
 
    neg dx
2885
 
.noxincdn
2886
 
    mov edi,ecx
2887
 
    sub dx,64
2888
 
    and ecx,0F8h
2889
 
    and eax,0FFFFh
2890
 
    shr ecx,2
2891
 
    mov [bgtxadd],edx
2892
 
    mov [bgtxad+ebx*2+%2*512],dx
2893
 
    add eax,ecx
2894
 
    add [ofsmtptr],ecx
2895
 
    mov [ofsmmptr],eax
2896
 
    mov dword[ofshvaladd],0
2897
 
    mov ecx,[BGOPT1+ebx*2+%1*512]
2898
 
    mov edx,[BGMA+ebx]
2899
 
    and edi,07h
2900
 
    and edx,07h
2901
 
    and ecx,0FFFFh
2902
 
    mov edx,[colormodedef+edx*4+%1]
2903
 
    neg edi
2904
 
    cmp dl,1
2905
 
    jne near .no2bitdn
2906
 
    ; eax = pointer to beginning of tile area
2907
 
    shr ecx,4
2908
 
    add edi,esi
2909
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
2910
 
    mov [ngptrdat2],ecx
2911
 
    mov [ngceax+%2*1024+ebx*4],eax
2912
 
    mov [ngcedi+%2*1024+ebx*4],edi
2913
 
    ; eax = pointer to beginning of tile area
2914
 
    mov dword[mode0add],0
2915
 
    mov byte[tleftn],33
2916
 
.loopdn
2917
 
    mov cx,[vrama+eax]
2918
 
    test cx,2000h
2919
 
    jnz near .fintiledn
2920
 
    drawlinengom2 tltype2b, preparet2ba, cachesingle2bng,.loopdn,.fintiledn,ngpalcon2b,test2ba,03h,%1
2921
 
.no2bitdn
2922
 
    cmp dl,3
2923
 
    jne near .no8bitdn
2924
 
    ; eax = pointer to beginning of tile area
2925
 
    shr ecx,6
2926
 
    add edi,esi
2927
 
    mov [ngptrdat+%2*1024+ebx*4],ecx
2928
 
    mov [ngptrdat2],ecx
2929
 
    mov [ngceax+%2*1024+ebx*4],eax
2930
 
    mov [ngcedi+%2*1024+ebx*4],edi
2931
 
    ; eax = pointer to beginning of tile area
2932
 
    mov byte[tleftn],33
2933
 
.loopdn2
2934
 
    mov cx,[vrama+eax]
2935
 
    test cx,2000h
2936
 
    jnz near .fintiledn2
2937
 
    drawlinengom2 tltype8b, preparet8ba, cachesingle8bng,.loopdn2,.fintiledn2,ngpalcon8b,test8ba,0FFh,%1
2938
 
.no8bitdn
2939
 
    pop ebx
2940
 
    ret
2941
 
%endmacro
2942
 
 
2943
 
%macro mosender 1
2944
 
.nodraw
2945
 
    add edi,%1
2946
 
    add esi,%1
2947
 
    dec ecx
2948
 
    jnz .next
2949
 
    pop esi
2950
 
    mov dword[ignor512],0
2951
 
    ret
2952
 
%endmacro
2953
 
 
2954
 
%macro drawbglinengpr1 2
2955
 
    mov dword[ng16bprval],2000h
2956
 
    mov dword[ng16bbgval],%1
2957
 
    push ebx
2958
 
    mov byte[curmosaicsz],1
2959
 
    xor eax,eax
2960
 
    test byte[mosenng+ebx],1 << %1
2961
 
    jz %%nomosaic
2962
 
    mov al,[mosszng+ebx]
2963
 
    or al,al
2964
 
    jz %%nomosaic
2965
 
    inc al
2966
 
    mov byte[curmosaicsz],al
2967
 
    mov cl,al
2968
 
    mov al,bl
2969
 
    div cl
2970
 
    mul cl
2971
 
    mov ebx,eax
2972
 
    mov [pesimpng],esi
2973
 
    mov edi,xtravbuf+16
2974
 
    mov ecx,64
2975
 
    xor eax,eax
2976
 
    mov esi,xtravbuf+16
2977
 
    rep stosd
2978
 
    or ebx,ebx
2979
 
    jnz %%nomosaic
2980
 
    inc ebx
2981
 
    jmp %%yesmosaic
2982
 
%%nomosaic
2983
 
    cmp byte[BGMA+ebx],5
2984
 
    jae near .tiles16x8
2985
 
%%yesmosaic
2986
 
    cmp byte[t16x161+ebx+%1*256],1
2987
 
    je near .tiles16x16
2988
 
    cmp byte[BGMA+ebx],2
2989
 
    je near .offsetm
2990
 
;    cmp byte[BGMA+ebx],4
2991
 
;    je near .offsetm2
2992
 
    mov eax,[BG1SYl+ebx*2+%1*512]
2993
 
    and eax,0FFFFh
2994
 
    add eax,ebx
2995
 
    lea eax,[eax*8]
2996
 
    and eax,38h
2997
 
    mov [yposng],eax
2998
 
    xor eax,38h
2999
 
    mov [flipyposng],eax
3000
 
 
3001
 
    mov edx,[BGMA+ebx]
3002
 
    mov ecx,[bgtxad+ebx*2+%2*512]
3003
 
    and edx,07h
3004
 
    mov [bgtxadd],cx
3005
 
    mov ecx,[ngptrdat+%2*1024+ebx*4]
3006
 
    mov edx,[colormodedef+edx*4+%1]
3007
 
    mov [ngptrdat2],ecx
3008
 
    mov eax,[ngceax+%2*1024+ebx*4]
3009
 
    mov edi,[ngcedi+%2*1024+ebx*4]
3010
 
    cmp dl,2
3011
 
    jne near .no4bit
3012
 
    ; eax = pointer to beginning of tile area
3013
 
    jmp drawlineng4b
3014
 
.no4bit
3015
 
    cmp dl,1
3016
 
    jne near .no2bit
3017
 
    ; eax = pointer to beginning of tile area
3018
 
    mov dword[mode0add],0
3019
 
    cmp byte[BGMA+ebx],0
3020
 
    jne .nomode0
3021
 
    mov ebx,[mode0ads]
3022
 
    mov [mode0add],ebx
3023
 
.nomode0
3024
 
    jmp drawlineng2b
3025
 
.no2bit
3026
 
    cmp dl,3
3027
 
    jne near .no8bit
3028
 
    ; eax = pointer to beginning of tile area
3029
 
    jmp drawlineng8b
3030
 
.no8bit
3031
 
    pop ebx
3032
 
    ret
3033
 
 
3034
 
.tiles16x16
3035
 
    mov ecx,[BG1SYl+ebx*2+%1*512]
3036
 
    and ecx,0FFFFh
3037
 
    mov dword[taddnfy16x16],0
3038
 
    add ecx,ebx
3039
 
    mov dword[taddfy16x16],16
3040
 
    test ecx,08h
3041
 
    jz .nobottomy
3042
 
    mov dword[taddnfy16x16],16
3043
 
    mov dword[taddfy16x16],-16
3044
 
.nobottomy
3045
 
 
3046
 
    lea eax,[ecx*8]
3047
 
    and eax,38h
3048
 
    mov [yposng],eax
3049
 
    xor eax,38h
3050
 
    mov [flipyposng],eax
3051
 
 
3052
 
    mov edx,[BGMA+ebx]
3053
 
    mov ecx,[bgtxad+ebx*2+%2*512]
3054
 
    and edx,07h
3055
 
    mov [bgtxadd],cx
3056
 
    mov ecx,[ngptrdat+%2*1024+ebx*4]
3057
 
    mov edx,[colormodedef+edx*4+%1]
3058
 
    mov [ngptrdat2],ecx
3059
 
    mov eax,[ngceax+%2*1024+ebx*4]
3060
 
    mov edi,[ngcedi+%2*1024+ebx*4]
3061
 
    cmp dl,2
3062
 
    jne near .no4bit2
3063
 
    ; eax = pointer to beginning of tile area
3064
 
    jmp drawlineng16x164b
3065
 
.no4bit2
3066
 
    cmp dl,1
3067
 
    jne near .no2bit2
3068
 
    ; eax = pointer to beginning of tile area
3069
 
    mov dword[mode0add],0
3070
 
    cmp byte[BGMA+ebx],0
3071
 
    jne .nomode02
3072
 
    mov ebx,[mode0ads]
3073
 
    mov [mode0add],ebx
3074
 
.nomode02
3075
 
    jmp drawlineng16x162b
3076
 
.no2bit2
3077
 
    cmp dl,3
3078
 
    jne near .no8bit2
3079
 
    ; eax = pointer to beginning of tile area
3080
 
    jmp drawlineng16x168b
3081
 
.no8bit2
3082
 
    pop ebx
3083
 
    ret
3084
 
 
3085
 
.tiles16x8
3086
 
    mov ecx,[BG1SYl+ebx*2+%1*512]
3087
 
    and ecx,0FFFFh
3088
 
    add ecx,ebx
3089
 
    mov dword[taddnfy16x16],0
3090
 
    mov dword[taddfy16x16],16
3091
 
    test ecx,08h
3092
 
    jz .nobottomyb
3093
 
    mov dword[taddnfy16x16],16
3094
 
    mov dword[taddfy16x16],-16
3095
 
.nobottomyb
3096
 
    cmp byte[t16x161+ebx+%1*256],1
3097
 
    je near .tiles16x16hr
3098
 
    mov dword[taddnfy16x16],0
3099
 
    mov dword[taddfy16x16],0
3100
 
.tiles16x16hr
3101
 
 
3102
 
    lea eax,[ecx*8]
3103
 
    and eax,38h
3104
 
    mov [yposng],eax
3105
 
    xor eax,38h
3106
 
    mov [flipyposng],eax
3107
 
 
3108
 
    mov edx,[BGMA+ebx]
3109
 
    mov ecx,[bgtxad+ebx*2+%2*512]
3110
 
    and edx,07h
3111
 
    mov [bgtxadd],cx
3112
 
    mov ecx,[ngptrdat+%2*1024+ebx*4]
3113
 
    mov edx,[colormodedef+edx*4+%1]
3114
 
    mov [ngptrdat2],ecx
3115
 
    mov eax,[ngceax+%2*1024+ebx*4]
3116
 
    mov edi,[ngcedi+%2*1024+ebx*4]
3117
 
    cmp dl,2
3118
 
    jne near .no4bit2b
3119
 
    ; eax = pointer to beginning of tile area
3120
 
    mov byte[tleftn],33
3121
 
.loop2b
3122
 
    mov cx,[vrama+eax]
3123
 
    test cx,2000h
3124
 
    jz near .fintile2b
3125
 
    drawlineng16x8 tltype4b, preparet4ba, cachesingle4bng,.loop2b,.fintile2b,ngpalcon4b,test4ba,0Fh,%1
3126
 
    pop ebx
3127
 
    ret
3128
 
.no4bit2b
3129
 
    cmp dl,1
3130
 
    jne near .no2bit2b
3131
 
    ; eax = pointer to beginning of tile area
3132
 
    mov dword[mode0add],0
3133
 
    mov byte[tleftn],33
3134
 
.loopb2b
3135
 
    mov cx,[vrama+eax]
3136
 
    test ecx,2000h
3137
 
    jz near .fintileb2b
3138
 
    drawlineng16x8 tltype2b, preparet2ba, cachesingle2bng,.loopb2b,.fintileb2b,ngpalcon2b,test2ba,03h,%1
3139
 
    pop ebx
3140
 
    ret
3141
 
.no2bit2b
3142
 
    pop ebx
3143
 
    ret
3144
 
 
3145
 
.offsetm
3146
 
    xor edx,edx
3147
 
    mov dx,[BG3SYl+ebx*2]
3148
 
;    and dx,0F8h
3149
 
    shr edx,3
3150
 
    shl edx,6
3151
 
    xor eax,eax
3152
 
    mov ax,[BGPT3+ebx*2]
3153
 
    add ax,dx
3154
 
    xor edx,edx
3155
 
    mov dx,[BG3SXl+ebx*2]
3156
 
    and dx,0F8h
3157
 
    mov [ofsmcyps],ebx
3158
 
    shr edx,3
3159
 
    shl edx,1
3160
 
    add ax,dx
3161
 
    mov edx,eax
3162
 
    add edx,40h
3163
 
    and edx,0FFC0h
3164
 
    add edx,[vram]
3165
 
    mov [ofsmcptr],edx
3166
 
    and eax,3Fh
3167
 
    mov [ofsmcptr2],eax
3168
 
    mov eax,[BGPT1Y+ebx*2+%1*512]
3169
 
    mov [ofsmady],eax
3170
 
    mov eax,[BGPT1X+ebx*2+%1*512]
3171
 
    mov [ofsmadx],eax
3172
 
    mov eax,[BGPT1+ebx*2+%1*512]
3173
 
    mov [ofsmtptr],eax
3174
 
    mov [ofsmtptrs],eax
3175
 
    mov ecx,[BG1SXl+ebx*2+%1*512]
3176
 
    mov edx,[BGPT1X+ebx*2+%1*512]
3177
 
    test ecx,100h
3178
 
    jz .noxincdd
3179
 
    add [ofsmtptr],edx
3180
 
.noxincdd
3181
 
    and ecx,0F8h
3182
 
    shr ecx,2
3183
 
    add [ofsmtptr],ecx
3184
 
    mov eax,[BG1SYl+ebx*2+%1*512]
3185
 
    and eax,0FFFFh
3186
 
    add eax,ebx
3187
 
    lea eax,[eax*8]
3188
 
    and eax,38h
3189
 
    mov [yposng],eax
3190
 
    mov [yposngom],eax
3191
 
    xor eax,38h
3192
 
    mov [flipyposng],eax
3193
 
    mov [flipyposngom],eax
3194
 
    mov edx,[BGMA+ebx]
3195
 
    mov ecx,[bgtxad+ebx*2+%2*512]
3196
 
    and edx,07h
3197
 
    mov [bgtxadd],cx
3198
 
    mov ecx,[ngptrdat+%2*1024+ebx*4]
3199
 
    mov edx,[colormodedef+edx*4+%1]
3200
 
    mov [ngptrdat2],ecx
3201
 
    mov eax,[ngceax+%2*1024+ebx*4]
3202
 
    mov edi,[ngcedi+%2*1024+ebx*4]
3203
 
    mov [ofsmmptr],eax
3204
 
    mov dword[ofshvaladd],0
3205
 
    cmp dl,2
3206
 
    jne near .no4bitd
3207
 
    ; eax = pointer to beginning of tile area
3208
 
    mov byte[tleftn],33
3209
 
.loopd
3210
 
    mov cx,[vrama+eax]
3211
 
    test cx,2000h
3212
 
    jz near .fintiled
3213
 
    drawlinengom tltype4b, preparet4ba, cachesingle4bng,.loopd,.fintiled,ngpalcon4b,test4ba,0Fh,%1
3214
 
.no4bitd
3215
 
    pop ebx
3216
 
    ret
3217
 
 
3218
 
.offsetm2
3219
 
    xor edx,edx
3220
 
    mov dx,[BG3SYl+ebx*2]
3221
 
    and dx,0F8h
3222
 
    shr edx,3
3223
 
    shl edx,6
3224
 
    xor eax,eax
3225
 
    mov ax,[BGPT3+ebx*2]
3226
 
    add ax,dx
3227
 
    xor edx,edx
3228
 
    mov dx,[BG3SXl+ebx*2]
3229
 
    and dx,0F8h
3230
 
    mov [ofsmcyps],ebx
3231
 
    shr edx,3
3232
 
    shl edx,1
3233
 
    add ax,dx
3234
 
    mov edx,eax
3235
 
    add edx,40h
3236
 
    and edx,0FFC0h
3237
 
    add edx,[vram]
3238
 
    mov [ofsmcptr],edx
3239
 
    and eax,3Fh
3240
 
    mov [ofsmcptr2],eax
3241
 
    mov eax,[BGPT1Y+ebx*2+%1*512]
3242
 
    mov [ofsmady],eax
3243
 
    mov eax,[BGPT1X+ebx*2+%1*512]
3244
 
    mov [ofsmadx],eax
3245
 
    mov eax,[BGPT1+ebx*2+%1*512]
3246
 
    mov [ofsmtptr],eax
3247
 
    mov [ofsmtptrs],eax
3248
 
    mov ecx,[BG1SXl+ebx*2+%1*512]
3249
 
    mov edx,[BGPT1X+ebx*2+%1*512]
3250
 
    test ecx,100h
3251
 
    jz .noxincddn
3252
 
    add [ofsmtptr],edx
3253
 
.noxincddn
3254
 
    and ecx,0F8h
3255
 
    shr ecx,2
3256
 
    add [ofsmtptr],ecx
3257
 
    mov eax,[BG1SYl+ebx*2+%1*512]
3258
 
    and eax,0FFFFh
3259
 
    add eax,ebx
3260
 
    lea eax,[eax*8]
3261
 
    and eax,38h
3262
 
    mov [yposng],eax
3263
 
    mov [yposngom],eax
3264
 
    xor eax,38h
3265
 
    mov [flipyposng],eax
3266
 
    mov [flipyposngom],eax
3267
 
    mov edx,[BGMA+ebx]
3268
 
    mov ecx,[bgtxad+ebx*2+%2*512]
3269
 
    and edx,07h
3270
 
    mov [bgtxadd],cx
3271
 
    mov ecx,[ngptrdat+%2*1024+ebx*4]
3272
 
    mov edx,[colormodedef+edx*4+%1]
3273
 
    mov [ngptrdat2],ecx
3274
 
    mov eax,[ngceax+%2*1024+ebx*4]
3275
 
    mov edi,[ngcedi+%2*1024+ebx*4]
3276
 
    mov [ofsmmptr],eax
3277
 
    mov dword[ofshvaladd],0
3278
 
    cmp dl,1
3279
 
    jne near .no2bitdn
3280
 
    ; eax = pointer to beginning of tile area
3281
 
    mov byte[tleftn],33
3282
 
.loopdn
3283
 
    mov cx,[vrama+eax]
3284
 
    test cx,2000h
3285
 
    jz near .fintiledn
3286
 
    drawlinengom2 tltype2b, preparet2ba, cachesingle2bng,.loopdn,.fintiledn,ngpalcon2b,test2ba,03h,%1
3287
 
.no2bitdn
3288
 
    cmp dl,3
3289
 
    jne near .no8bitdn
3290
 
    ; eax = pointer to beginning of tile area
3291
 
    mov byte[tleftn],33
3292
 
.loopdn2
3293
 
    mov cx,[vrama+eax]
3294
 
    test cx,2000h
3295
 
    jz near .fintiledn2
3296
 
    drawlinengom2 tltype8b, preparet8ba, cachesingle8bng,.loopdn2,.fintiledn2,ngpalcon8b,test8ba,0FFh,%1
3297
 
.no8bitdn
3298
 
    pop ebx
3299
 
    ret
3300
 
%endmacro
3301
 
 
3302