-
Notifications
You must be signed in to change notification settings - Fork 17
/
vcache.asm
3436 lines (3246 loc) · 61.5 KB
/
vcache.asm
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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
;Copyright (C) 1997-2008 ZSNES Team ( zsKnight, _Demo_, pagefault, Nach )
;
;http://www.zsnes.com
;http://sourceforge.net/projects/zsnes
;https://zsnes.bountysource.com
;
;This program is free software; you can redistribute it and/or
;modify it under the terms of the GNU General Public License
;version 2 as published by the Free Software Foundation.
;
;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, write to the Free Software
;Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
%include "macros.mac"
EXTSYM vidmemch2
EXTSYM resolutn,curypos
EXTSYM oamram,objhipr,objptr,objptrn,objsize1,objsize2,spritetablea,sprleftpr
EXTSYM sprlefttot,vcache4b,objadds1,objadds2,objmovs1,objmovs2,tltype4b
EXTSYM vidmemch4,vram,bgptr,bgptrc,bgptrd,curtileptr,vcache2b,vcache8b,vidmemch8
EXTSYM sprcnt,sprstart,sprtilecnt,sprend,sprendx,interlval,offsetmshl,tltype2b
EXTSYM tltype8b
; Process stuff & Cache sprites
SECTION .data
ALIGN32
NEWSYM sprprifix, db 1
NEWSYM OMBGTestVal, dd 0
NEWSYM ngptrdat2, dd 0
NEWSYM ofshvaladd, dd 0
NEWSYM ofsmtptrs, dd 0
NEWSYM ofsmcptr2, dd 0
NEWSYM addr2add, dd 0
section .text
;*******************************************************
; Process Sprites
;*******************************************************
; Use oamram for object table
NEWSYM processsprites
; cmp byte[cbitmode],1
; je .skipnewspr
; cmp byte[newengen],1
; je .skipnewspr
cmp byte[sprprifix],0
jne near processspritesb
.skipnewspr
; set obj pointers
cmp byte[objsize1],1
jne .16dot1
mov ebx,.process8x8sprite
mov [.size1ptr],ebx
jmp .fin1
.16dot1
cmp byte[objsize1],4
jne .32dot1
mov ebx,.process16x16sprite
mov [.size1ptr],ebx
jmp .fin1
.32dot1
cmp byte[objsize1],16
jne .64dot1
mov ebx,.process32x32sprite
mov [.size1ptr],ebx
jmp .fin1
.64dot1
mov ebx,.process64x64sprite
mov [.size1ptr],ebx
.fin1
cmp byte[objsize2],1
jne .16dot2
mov ebx,.process8x8sprite
mov [.size2ptr],ebx
jmp .fin2
.16dot2
cmp byte[objsize2],4
jne .32dot2
mov ebx,.process16x16sprite
mov [.size2ptr],ebx
jmp .fin2
.32dot2
cmp byte[objsize2],16
jne .64dot2
mov ebx,.process32x32sprite
mov [.size2ptr],ebx
jmp .fin2
.64dot2
mov ebx,.process64x64sprite
mov [.size2ptr],ebx
.fin2
; set pointer adder
xor eax,eax
xor ebx,ebx
mov al,[objhipr]
shl ax,2
mov ebx,eax
sub bx,4
and bx,01FCh
mov dword[addr2add],0
mov byte[.prileft],4
mov byte[.curpri],0
; do 1st priority
mov ecx,[objptr]
shl ecx,1
mov [.objvramloc],ecx
mov ecx,[objptrn]
sub ecx,[objptr]
shl ecx,1
mov [.objvramloc2],ecx
push ebp
mov ebp,[spritetablea]
.startobject
mov byte[.objleft],128
.objloop
xor ecx,ecx
mov cx,[oamram+ebx+2]
mov dl,ch
shr dl,4
and dl,03h
cmp dl,[.curpri]
jne near .nextobj
; get object information
push ebx
mov dl,[oamram+ebx+1] ; y
inc dl
; set up pointer to esi
mov dh,ch
and ch,01h
shr dh,1
shl ecx,6
add ecx,[.objvramloc]
test byte[oamram+ebx+3],01h
jz .noloc2
add ecx,[.objvramloc2]
.noloc2
and ecx,01FFFFh
add ecx,[vcache4b]
mov esi,ecx
; get x
mov al,[oamram+ebx] ; x
; get double bits
mov cl,bl
shr ebx,4 ; /16
shr cl,1
and cl,06h
mov ah,[oamram+ebx+512]
shr ah,cl
and ah,03h
mov ch,ah
and ch,01h
mov cl,al
; process object
; esi = pointer to 8-bit object, dh = stats (1 shifted to right)
; cx = x position, dl = y position
cmp cx,384
jb .noadder
add cx,65535-511
.noadder
cmp cx,256
jge .returnfromptr
cmp cx,-64
jle .returnfromptr
test ah,02h
jz .size1
jmp dword near [.size2ptr]
.size1
jmp dword near [.size1ptr]
.returnfromptr
pop ebx
; next object
.nextobj
sub bx,4
and bx,01FCh
dec byte[.objleft]
jnz near .objloop
add dword[addr2add],256
inc byte[.curpri]
dec byte[.prileft]
jnz near .startobject
pop ebp
ret
SECTION .bss
.objvramloc resd 1
.objvramloc2 resd 1
.curpri resd 1
.trypri resd 1
.objleft resd 1
.prileft resd 1
.size1ptr resd 1
.size2ptr resd 1
SECTION .text
.reprocesssprite
cmp cx,-8
jle .next
cmp cx,256
jge .next
add cx,8
.reprocessspriteb
cmp dl,[resolutn]
ja .overflow
xor ebx,ebx
mov bl,dl
xor eax,eax
cmp bx,[curypos]
jb .overflow
mov al,[sprlefttot+ebx]
cmp al,45
ja near .overflow
inc byte[sprlefttot+ebx]
add ebx,[addr2add]
inc byte[sprleftpr+ebx]
sub ebx,[addr2add]
shl ebx,9
shl eax,3
add ebx,eax
mov [ebp+ebx],cx
mov [ebp+ebx+2],esi
mov al,[.statusbit]
mov [ebp+ebx+6],dh
mov [ebp+ebx+7],al
.overflow
inc dl
add esi,8
dec byte[.numleft2do]
jnz .reprocessspriteb
sub cx,8
ret
.next
add dl,8
add esi,64
ret
.reprocessspriteflipy
cmp cx,-8
jle .nextb
cmp cx,256
jge .nextb
add cx,8
.reprocessspriteflipyb
cmp dl,[resolutn]
ja .overflow2
xor ebx,ebx
xor eax,eax
mov bl,dl
cmp bx,[curypos]
jb .overflow2
mov al,[sprlefttot+ebx]
cmp al,45
ja near .overflow2
inc byte[sprlefttot+ebx]
add ebx,[addr2add]
inc byte[sprleftpr+ebx]
sub ebx,[addr2add]
shl ebx,9
shl eax,3
add ebx,eax
mov [ebp+ebx],cx
mov [ebp+ebx+2],esi
mov al,[.statusbit]
mov [ebp+ebx+6],dh
mov [ebp+ebx+7],al
.overflow2
inc dl
sub esi,8
dec byte[.numleft2do]
jnz .reprocessspriteflipyb
sub cx,8
ret
.nextb
add dl,8
sub esi,64
ret
section .bss
.statusbit resb 1
section .text
.process8x8sprite:
test dh,40h
jnz .8x8flipy
mov [.statusbit],dh
and dh,07h
mov byte[.numleft2do],8
shl dh,4
add dh,128
call .reprocesssprite
jmp .returnfromptr
.8x8flipy
mov [.statusbit],dh
and dh,07h
mov byte[.numleft2do],8
shl dh,4
add dh,128
add esi,56
call .reprocessspriteflipy
jmp .returnfromptr
section .bss
.numleft2do resb 1
section .text
;*******************************************************
; Sprite increment/draw macros
;*******************************************************
%macro add_x 0
mov eax,[sprt_char]
shr eax,2
add al,64>>2
shl eax,2
mov [sprt_char],eax
mov esi,[objloc]
add esi,eax
%endmacro
%macro add_y 1
mov eax,[sprt_char]
shr eax,2
sub al,(64>>2)*%1
shl eax,2
add eax,64*10h
and eax,3FFFh
mov [sprt_char],eax
mov esi,[objloc]
add esi,eax
%endmacro
%macro nextsprite2right 0
sub dl,8
add cx,8
mov byte[.numleft2do],8
call .reprocesssprite
%endmacro
%macro nextsprite2rightflipy 0
add esi,56
sub dl,8
add cx,8
mov byte[.numleft2do],8
call .reprocessspriteflipy
%endmacro
%macro nextsprite2rightflipx 0
sub dl,8
sub cx,8
mov byte[.numleft2do],8
call .reprocesssprite
%endmacro
%macro nextsprite2rightflipyx 0
add esi,56
sub dl,8
sub cx,8
mov byte[.numleft2do],8
call .reprocessspriteflipy
%endmacro
;*******************************************************
; 16x16 sprites routines
;*******************************************************
%macro nextline16x16 0
sub cx,8
add_y 2
mov byte[.numleft2do],8
call .reprocesssprite
nextsprite2right
%endmacro
.process16x16sprite:
mov [.statusbit],dh
test dh,20h
jnz near .16x16flipx
test dh,40h
jnz .16x16flipy
and dh,07h
mov byte[.numleft2do],8
shl dh,4
add dh,128
call .reprocesssprite
nextsprite2right
nextline16x16
jmp .returnfromptr
%macro nextline16x16flipy 0
sub cx,8
add_y 2
add esi,56
sub dl,16
mov byte[.numleft2do],8
call .reprocessspriteflipy
nextsprite2rightflipy
%endmacro
.16x16flipy
and dh,07h
mov byte[.numleft2do],8
shl dh,4
add dh,128
add dl,8
add esi,56
call .reprocessspriteflipy
nextsprite2rightflipy
nextline16x16flipy
jmp .returnfromptr
%macro nextline16x16flipx 0
add cx,8
add_y 2
mov byte[.numleft2do],8
call .reprocesssprite
nextsprite2rightflipx
%endmacro
.16x16flipx
test dh,40h
jnz .16x16flipyx
and dh,07h
mov byte[.numleft2do],8
shl dh,4
add dh,128
add cx,8
call .reprocesssprite
nextsprite2rightflipx
nextline16x16flipx
jmp .returnfromptr
%macro nextline16x16flipyx 0
add cx,8
add_y 2
add esi,56
sub dl,16
mov byte[.numleft2do],8
call .reprocessspriteflipy
nextsprite2rightflipyx
%endmacro
.16x16flipyx
and dh,07h
mov byte[.numleft2do],8
shl dh,4
add dh,128
add cx,8
add dl,8
add esi,56
call .reprocessspriteflipy
nextsprite2rightflipyx
nextline16x16flipyx
jmp .returnfromptr
;*******************************************************
; 32x32 sprites routines
;*******************************************************
%macro nextline32x32 0
sub cx,24
add_y 4
mov byte[.numleft2do],8
call .reprocesssprite
nextsprite2right
nextsprite2right
nextsprite2right
%endmacro
.process32x32sprite:
mov [.statusbit],dh
test dh,20h
jnz near .32x32flipx
test dh,40h
jnz near .32x32flipy
and dh,07h
mov byte[.numleft2do],8
shl dh,4
add dh,128
call .reprocesssprite
nextsprite2right
nextsprite2right
nextsprite2right
nextline32x32
nextline32x32
nextline32x32
jmp .returnfromptr
%macro nextline32x32flipy 0
sub cx,24
add_y 4
add esi,56
sub dl,16
mov byte[.numleft2do],8
call .reprocessspriteflipy
nextsprite2rightflipy
nextsprite2rightflipy
nextsprite2rightflipy
%endmacro
.32x32flipy
and dh,07h
mov byte[.numleft2do],8
shl dh,4
add dh,128
add dl,24
add esi,56
call .reprocessspriteflipy
nextsprite2rightflipy
nextsprite2rightflipy
nextsprite2rightflipy
nextline32x32flipy
nextline32x32flipy
nextline32x32flipy
jmp .returnfromptr
%macro nextline32x32flipx 0
add cx,24
add_y 4
mov byte[.numleft2do],8
call .reprocesssprite
nextsprite2rightflipx
nextsprite2rightflipx
nextsprite2rightflipx
%endmacro
.32x32flipx
test dh,40h
jnz near .32x32flipyx
and dh,07h
mov byte[.numleft2do],8
shl dh,4
add dh,128
add cx,24
call .reprocesssprite
nextsprite2rightflipx
nextsprite2rightflipx
nextsprite2rightflipx
nextline32x32flipx
nextline32x32flipx
nextline32x32flipx
jmp .returnfromptr
%macro nextline32x32flipyx 0
add cx,24
add_y 4
add esi,56
sub dl,16
mov byte[.numleft2do],8
call .reprocessspriteflipy
nextsprite2rightflipyx
nextsprite2rightflipyx
nextsprite2rightflipyx
%endmacro
.32x32flipyx
and dh,07h
mov byte[.numleft2do],8
shl dh,4
add dh,128
add cx,24
add dl,24
add esi,56
call .reprocessspriteflipy
nextsprite2rightflipyx
nextsprite2rightflipyx
nextsprite2rightflipyx
nextline32x32flipyx
nextline32x32flipyx
nextline32x32flipyx
jmp .returnfromptr
;*******************************************************
; 64x64 sprites routines
;*******************************************************
%macro nextline64x64 0
sub cx,56
add_y 8
mov byte[.numleft2do],8
call .reprocesssprite
nextsprite2right
nextsprite2right
nextsprite2right
nextsprite2right
nextsprite2right
nextsprite2right
nextsprite2right
%endmacro
.process64x64sprite:
mov [.statusbit],dh
test dh,20h
jnz near .64x64flipx
test dh,40h
jnz near .64x64flipy
and dh,07h
mov byte[.numleft2do],8
shl dh,4
add dh,128
call .reprocesssprite
nextsprite2right
nextsprite2right
nextsprite2right
nextsprite2right
nextsprite2right
nextsprite2right
nextsprite2right
nextline64x64
nextline64x64
nextline64x64
nextline64x64
nextline64x64
nextline64x64
nextline64x64
jmp .returnfromptr
%macro nextline64x64flipy 0
sub cx,56
add_y 8
add esi,56
sub dl,16
mov byte[.numleft2do],8
call .reprocessspriteflipy
nextsprite2rightflipy
nextsprite2rightflipy
nextsprite2rightflipy
nextsprite2rightflipy
nextsprite2rightflipy
nextsprite2rightflipy
nextsprite2rightflipy
%endmacro
.64x64flipy
and dh,07h
mov byte[.numleft2do],8
shl dh,4
add dh,128
add dl,56
add esi,56
call .reprocessspriteflipy
nextsprite2rightflipy
nextsprite2rightflipy
nextsprite2rightflipy
nextsprite2rightflipy
nextsprite2rightflipy
nextsprite2rightflipy
nextsprite2rightflipy
nextline64x64flipy
nextline64x64flipy
nextline64x64flipy
nextline64x64flipy
nextline64x64flipy
nextline64x64flipy
nextline64x64flipy
jmp .returnfromptr
%macro nextline64x64flipx 0
add cx,56
add_y 8
mov byte[.numleft2do],8
call .reprocesssprite
nextsprite2rightflipx
nextsprite2rightflipx
nextsprite2rightflipx
nextsprite2rightflipx
nextsprite2rightflipx
nextsprite2rightflipx
nextsprite2rightflipx
%endmacro
.64x64flipx
test dh,40h
jnz near .64x64flipyx
and dh,07h
mov byte[.numleft2do],8
shl dh,4
add dh,128
add cx,56
call .reprocesssprite
nextsprite2rightflipx
nextsprite2rightflipx
nextsprite2rightflipx
nextsprite2rightflipx
nextsprite2rightflipx
nextsprite2rightflipx
nextsprite2rightflipx
nextline64x64flipx
nextline64x64flipx
nextline64x64flipx
nextline64x64flipx
nextline64x64flipx
nextline64x64flipx
nextline64x64flipx
jmp .returnfromptr
%macro nextline64x64flipyx 0
add cx,56
add_y 8
add esi,56
sub dl,16
mov byte[.numleft2do],8
call .reprocessspriteflipy
nextsprite2rightflipyx
nextsprite2rightflipyx
nextsprite2rightflipyx
nextsprite2rightflipyx
nextsprite2rightflipyx
nextsprite2rightflipyx
nextsprite2rightflipyx
%endmacro
.64x64flipyx
and dh,07h
mov byte[.numleft2do],8
shl dh,4
add dh,128
add cx,56
add dl,56
add esi,56
call .reprocessspriteflipy
nextsprite2rightflipyx
nextsprite2rightflipyx
nextsprite2rightflipyx
nextsprite2rightflipyx
nextsprite2rightflipyx
nextsprite2rightflipyx
nextsprite2rightflipyx
nextline64x64flipyx
nextline64x64flipyx
nextline64x64flipyx
nextline64x64flipyx
nextline64x64flipyx
nextline64x64flipyx
nextline64x64flipyx
jmp .returnfromptr
;*******************************************************
; Process Sprites B - Process
;*******************************************************
; Use oamram for object table
%macro do_RTO 2
cmp cx,-%1
jle .returnfromptr_rto
xor ebx,ebx
mov bl,dl
mov al,%2
%%loop
cmp bx,[resolutn]
ja %%no
cmp bx,[curypos]
jb %%no
inc byte[sprcnt+ebx]
cmp byte[sprcnt+ebx],32
jne %%no
mov dl,[.objleft]
mov [sprstart+ebx],dl
%%no
inc bl
dec al
jnz %%loop
jmp .returnfromptr_rto
%endmacro
%macro do_RTO2 2
cmp cx,-%1
jle .returnfromptr_rto2
xor ebx,ebx
mov bl,dl
mov ax,%2
%%loopy
mov dh,128+1
sub dh,[.objleft]
cmp [sprstart+ebx],dh
ja %%noy
cmp bx,[resolutn]
ja %%noy
cmp bx,[curypos]
jb %%noy
mov dl,%1>>3
push ecx
%%loopx
cmp word[.obj_x],256
je %%doit
cmp cx,-8
jle %%nox
cmp cx,256
jge %%nox
%%doit
inc byte[sprtilecnt+ebx]
cmp byte[sprtilecnt+ebx],34
jne %%nox
mov [sprend+ebx],dh
mov [sprendx+ebx*2],cx
add word[sprendx+ebx*2],8
%%nox
add cx,8
dec dl
jnz %%loopx
pop ecx
%%noy
inc bl
dec ax
jnz %%loopy
jmp .returnfromptr_rto2
%endmacro
section .bss
sprt_char resd 1
objloc resd 1
section .text
NEWSYM processspritesb
; set obj pointers
cmp byte[objsize1],1
jne .16dot1
mov ebx,.process8x8sprite
mov [.size1ptr],ebx
mov ebx,.process8x8sprite_rto
mov [.size1ptr_rto],ebx
mov ebx,.process8x8sprite_rto2
mov [.size1ptr_rto2],ebx
jmp .fin1
.16dot1
cmp byte[objsize1],4
jne .32dot1
.do16dot1
mov ebx,.process16x16sprite
mov [.size1ptr],ebx
mov ebx,.process16x16sprite_rto
mov [.size1ptr_rto],ebx
mov ebx,.process16x16sprite_rto2
mov [.size1ptr_rto2],ebx
jmp .fin1
.32dot1
cmp byte[objsize1],16
jne .64dot1
mov ebx,.process32x32sprite
mov [.size1ptr],ebx
mov ebx,.process32x32sprite_rto
mov [.size1ptr_rto],ebx
mov ebx,.process32x32sprite_rto2
mov [.size1ptr_rto2],ebx
jmp .fin1
.64dot1
cmp byte[objsize1],64
jne .16x32dot1
mov ebx,.process64x64sprite
mov [.size1ptr],ebx
mov ebx,.process64x64sprite_rto
mov [.size1ptr_rto],ebx
mov ebx,.process64x64sprite_rto2
mov [.size1ptr_rto2],ebx
jmp .fin1
.16x32dot1
test byte[interlval],2
jnz .do16dot1
mov ebx,.process16x32sprite
mov [.size1ptr],ebx
mov ebx,.process16x32sprite_rto
mov [.size1ptr_rto],ebx
mov ebx,.process16x32sprite_rto2
mov [.size1ptr_rto2],ebx
.fin1
cmp byte[objsize2],1
jne .16dot2
mov ebx,.process8x8sprite
mov [.size2ptr],ebx
mov ebx,.process8x8sprite_rto
mov [.size2ptr_rto],ebx
mov ebx,.process8x8sprite_rto2
mov [.size2ptr_rto2],ebx
jmp .fin2
.16dot2
cmp byte[objsize2],4
jne .32dot2
mov ebx,.process16x16sprite
mov [.size2ptr],ebx
mov ebx,.process16x16sprite_rto
mov [.size2ptr_rto],ebx
mov ebx,.process16x16sprite_rto2
mov [.size2ptr_rto2],ebx
jmp .fin2
.32dot2
cmp byte[objsize2],16
jne .64dot2
mov ebx,.process32x32sprite
mov [.size2ptr],ebx
mov ebx,.process32x32sprite_rto
mov [.size2ptr_rto],ebx
mov ebx,.process32x32sprite_rto2
mov [.size2ptr_rto2],ebx
jmp .fin2
.64dot2
cmp byte[objsize2],64
jne .32x64dot2
mov ebx,.process64x64sprite
mov [.size2ptr],ebx
mov ebx,.process64x64sprite_rto
mov [.size2ptr_rto],ebx
mov ebx,.process64x64sprite_rto2
mov [.size2ptr_rto2],ebx
jmp .fin2
.32x64dot2
mov ebx,.process32x64sprite
mov [.size2ptr],ebx
mov ebx,.process32x64sprite_rto
mov [.size2ptr_rto],ebx
mov ebx,.process32x64sprite_rto2
mov [.size2ptr_rto2],ebx
.fin2
; set pointer adder
xor eax,eax
xor ebx,ebx
mov al,[objhipr]
shl ax,2
mov ebx,eax
and bx,01FCh
mov dword[addr2add],0
; do 1st priority
mov ecx,[objptr]
shl ecx,1
mov [.objvramloc],ecx
mov ecx,[objptrn]
sub ecx,[objptr]
shl ecx,1
mov [.objvramloc2],ecx
push ebp
mov ebp,[spritetablea]
.startobject
mov byte[.objleft],128
.objloop_rto
; get object information
push ebx
mov dl,[oamram+ebx+1] ; y
inc dl
; get x
mov al,[oamram+ebx] ; x
; get double bits
mov cl,bl
shr ebx,4 ; /16
shr cl,1
and cl,06h
mov ah,[oamram+ebx+512]
shr ah,cl
and ah,03h
mov ch,ah
and ch,01h
mov cl,al
; process object
; esi = pointer to 8-bit object, dh = stats (1 shifted to right)
; cx = x position, dl = y position
cmp cx,384
jb .noadder_rto
add cx,65535-511
.noadder_rto
cmp cx,256
jg .returnfromptr_rto
test ah,02h
jz .size1_rto
jmp dword near [.size2ptr_rto]
.size1_rto
jmp dword near [.size1ptr_rto]
.returnfromptr_rto
pop ebx
add bx,4
and bx,01FCh
dec byte[.objleft]
jnz near .objloop_rto
sub bx,4
and bx,01FCh
mov byte[.objleft],128
.objloop_rto2
; get object information
push ebx
mov dl,[oamram+ebx+1] ; y
inc dl
mov dh,[oamram+ebx+3]
shr dh,1
; get x
mov al,[oamram+ebx] ; x
; get double bits
mov cl,bl
shr ebx,4 ; /16
shr cl,1
and cl,06h
mov ah,[oamram+ebx+512]
shr ah,cl
and ah,03h
mov ch,ah