Subversion Repositories NedoOS

Rev

Details | Last modification | View Log

Rev Author Line No. Line
1033 alone 1
        macro MASKBYTE
2
        ld a,(hl)
3
        and e
4
        or d
5
        ld (hl),a
6
        endm
7
        macro DOWNBYTE
8
        add hl,bc
9
        endm
10
 
11
prspr
12
;� 4000,8000 㦥 ����祭 ��࠭ (setpgsscr40008000)
13
;iy=sprite data+2 = spraddr+4
14
;e=x = -(sprmaxwid-1)..159 (��������� ��� x+(sprmaxwid-1))
15
;c=y = -(sprmaxhgt-1)..199 (��������� ��� ����)
16
;(iy-3)=sprhgt
17
;(iy-4)=sprwid
18
;�� x,y, �ਭ�, ���� ���� ���� �� ��࠭�, �㤠 �뢮��� ������� ���� �ࠩ�
19
;�ࠩ� ������ ����� � �ਭ� ������ ࠡ���� ���ᨬ��쭮 �����!
20
        ld a,scrwid+(sprmaxwid-1)
21
        sub e ;x ;a=����ﭨ� �� �ࠢ�� �࠭��� ��࠭�
22
        ld hx,a
23
        ;ld lx,0 ;�� 㬮�砭�� ��� 䠫�訢��� ��࠭�, ��室 �� �ࠢ�� �࠭�� ��࠭� �㤥� �ࠧ� ;��� ������ �ਭ� �� ���� - ��室 �㤥� �� ����砭�� �ࠩ�
24
         ;ld lx,0 ;��� �ࠩ� ������ �����, �����஢������ �ࠢ� - ��室 �ࠧ� �� �࠭��
25
        ld a,e ;x
26
        sub sprmaxwid-1
27
        jr nc,prsprnocropleft
28
;[���� ���� ��砫� ������� ��� �ࠩ�:]
29
;[᭠砫� �⮫��� (�ਡ����� hgt*2*�᫮ ������ �⮫�殢) ����� � 横��, �.�. �ய�� �⮫�殢 �뢠�� ।��]
30
;��� ������� 䠫�訢� ��࠭ � 0x4000,0x8000 � �������� ���� ��室� �� ��४��砫�� ��࠭��, ⠪ ����� ࠡ���� � �ࠩ⠬� ��楤�ன
31
;a=-�᫮ ��१����� ᫥�� �⮫�殢
32
;������� hx ��� �ࠢ��쭮�� ��室� �� 䠫�訢��� ��࠭�
33
;������� lx ��� �ࠢ��쭮�� ��室� �� �ࠩ� � y-�����஢����� �뢮�����
34
        ld l,a
35
        add a,(iy-4)
36
        ld lx,a ;sprwid-�᫮ ��१����� ᫥�� �⮫�殢
37
;�᫨ <=0, � �ࠩ� ��� �� ��࠭�!!! ��室��!!!
38
         ret m
39
         ret z
40
        xor a
41
        sub l
42
        ld hx,a ;�᫮ ��१����� ᫥�� �⮫�殢
43
        push bc
44
        ld a,(pgfake)
45
        ;ld (curpg4000),a
46
        SETPG16K
47
        ;ld (curpg8000),a
48
        SETPG32KLOW
49
;hl �㤥� ���᫥� � �訡��� +64
50
        pop bc
51
        ld a,l
52
        or a
53
prsprnocropleft
54
        ld (prsprqsp),sp
55
;NC
56
        ld b,0
57
        ld l,c ;y
58
        rra ;x bit 0
59
        ;ld h,0x40/32/2
60
        ;jr nc,$+4 ;x bit 0
61
        ; ld h,0x80/32/2
62
         ld h,b;0
63
         rl h
64
         inc h
65
        srl a ;x bit 1
66
         rl h ;0x40/32/2 ��� 0x80/32/2
67
        add hl,hl
68
        add hl,hl
69
        add hl,bc
70
        add hl,hl
71
        add hl,hl
72
        add hl,hl ;y*40+scrbase
73
         if scrbase&0xff
74
         add a,scrbase&0xff
75
         endif
76
;a=x/4
77
        add a,l
78
        ld l,a
79
        adc a,h
80
        sub l
81
        ld h,a ;hl=scr ;�� ����� ���� ��९������� �� ����⥫��� x? maxhl = 199*40 + 127 = 8087
82
        ld a,c ;y
83
        ;add a,sprmaxhgt-1
84
        ;sub sprmaxhgt-1
85
        ;jp c,prsprcroptop
86
         cp scrhgt
87
         jp nc,prsprcroptop
88
        add a,(iy-3) ;sprhgt
89
prspr_curscrhgtplus1=$+1
90
        cp scrhgt+1 ;200=OK, >200=crop
91
        jp nc,prsprcropbottom        
92
;hx=����ﭨ� �� �ࠢ�� �࠭��� ��࠭� (columns)
93
;x=156: hx=4
94
;x=157: hx=3
95
;x=158: hx=2
96
;x=159: hx=1
97
;�᫨ ��� �����஢���� �ࠢ�, � �� ����⭮� x � ��⭮� sprwid ���� ᤥ���� ��ண� hx>sprwid/2!
98
;lx ����� ⮫쪮 �� �����஢���� ᫥��
99
         ld a,hx
100
         inc a
101
         srl a
102
         ld hx,a ;lx �� ������뢠��, �� ����襭 � 2 ࠧ�, �� ��� � ������ �ࠩ� ���� ��室 �� �ਭ� ࠭��
103
;hx=����ﭨ� �� �ࠢ�� �࠭��� ��࠭� (double columns)
104
;x=156: hx=2
105
;x=157: hx=2
106
;x=158: hx=1
107
;x=159: hx=1
108
        ld c,40 ;b=0
109
;iy=sprite data+2
110
        ld e,(iy-2)
111
        ld d,(iy-1)
112
        ld sp,iy
113
;����� ���� � ����ᨬ��� �� sprhgt
114
        ld a,(iy-3) ;sprhgt
115
        cp 16
116
        jr z,prspr16
117
        jr nc,prspr24
118
prspr8
119
        ld a,prspr8column&0xff
120
        ld (prsprcolumnpatch),a
121
        ld (prsprcolumnpatch2),a
122
        jp prspr8column+1
123
prspr16
124
        ld a,prspr16column&0xff
125
        ld (prsprcolumnpatch),a
126
        ld (prsprcolumnpatch2),a
127
        jp prspr16column+1
128
prspr24
129
        cp 32
130
        jr z,prspr32
131
        ld a,prspr24column&0xff
132
        ld (prsprcolumnpatch),a
133
        ld (prsprcolumnpatch2),a
134
        jp prspr24column+1
135
prspr32
136
        ld a,prspr32column&0xff
137
        ld (prsprcolumnpatch),a
138
        ld (prsprcolumnpatch2),a
139
        jp prspr32column+1
140
        align 256
141
;�⤥�쭠� ��楤�� ��� �ࠩ� ������ �����, �.�. ⠬ �� ���� �� ������ �⮫�� ����⠢���� sp
142
prspr32column
143
        dup 8
144
        pop de
145
        MASKBYTE
146
        DOWNBYTE
147
        edup
148
prspr24column
149
        dup 8
150
        pop de
151
        MASKBYTE
152
        DOWNBYTE
153
        edup
154
prspr16column
155
        dup 8
156
        pop de
157
        MASKBYTE
158
        DOWNBYTE
159
        edup
160
prspr8column
161
        display prspr32column," HSB equal to ",$
162
        dup 7
163
        pop de
164
        MASKBYTE
165
        DOWNBYTE
166
        edup
167
        pop de
168
        MASKBYTE
169
;���� ���� ᫥���饣� �⮫�� �� ��࠭� ��� ���        
170
;4000,8000,[c000]6000,a000,[e001]4001... ;�����⢥���� �ᯮ������� ��� ⠪�� ������ (��-�� ����⠭�� 0xa0) (��㣮� ��ਠ�� - ����⠭� 0x60? ⮣�� ���� ��࠭ � 0000!!!)
171
;����� �ᯮ�짮���� ��ப�, ��� h=0xa0, �.�. ���孨� 7 ��ப (������� 193 ��ப�), ���� ���� ld a,0x9f...inc a (+2t)
172
        pop de ;������� ⮫쪮 ��� �ࠩ⮢ ������ ����� (�� �ப��� ���� �᫨ ������ pop ��� ������ �⮫��, �.�. ᤢ�� hl ࠧ�� - ࠧ�� �� � hl ᤢ����� �� �����஢����)
173
        ld a,0x9f;0xa0
174
        cp h
175
        adc hl,de ;de = 0x4000 - ((sprhgt-1)*40)
176
         ret c ;��室 �� �ਭ� �ࠩ�, ⠬ ���� ����⠭����� sp � ����⠭�� � �⥪�
177
prsprcolumnpatch=$+1
178
        jp pe,prspr16column ;� �������� ��砥�
179
;8000->�000 (���� 6000) ��� a000->e001 (���� 4001)
180
         inc a
181
        xor h
182
        ld h,a
183
         dec hx
184
goprsprcolumn
185
         jp nz,prspr16column
186
prsprcolumnpatch2=$-2
187
         ;��室 �� �࠭�� ��࠭�
188
;10+11+15+14 = 40t (+5+9)
189
;�� ����� ���� �࠭�� 䠫�訢��� ��࠭�! ���� ����� ����������� �த������ (� hl-64 ��-�� �訡�� ���� �� ����⥫��� x?)
190
;        ld a,(pgfake)
191
;curpg4000=$+1
192
        ld a,(curpg16k) ;ok
193
pgfake2=$+1
194
        cp 0
195
        jp nz,prsprqright ;����⢨⥫쭮 ��室 �� �ࠢ�� �࠭��
196
;�� 䠫�訢� ��࠭ ��� �����஢���� �� ����� �࠭��, �த������ �� �����饬 ��࠭�
197
        ld hx,lx
198
        ld bc,-64
199
        add hl,bc ;��-�� �訡�� ���� �� ����⥫��� x
200
         dec c ;NZ!!!
201
;��� �� ������� �⥪? ���� �᫨ ��������� �맮�, ⠬ ����� ��� ࠢ�� rst
202
        ld (prsprmaybeqrightsp),sp
203
        ld sp,tempsp
204
        call setpgsscr40008000 ;�몫�砥� 䠫�訢� ��࠭, ����砥� �����騩
205
prsprmaybeqrightsp=$+1
206
        ld sp,0
207
        ld bc,40
208
        ;ld lx,b;0 ;��ன ࠧ �㤥� ����⢨⥫쭮 ��室
209
        jp goprsprcolumn ;NZ!!!
210
;����� � �� ᠬ�� ᤥ���� �� �ࠩ� ����� (���� �� �㦭�, de ��ᢠ����� ⮫쪮 �᫨ �������, 13-1 ���� (36.5t) ��譨� �� �⮫���, ��室 �� dec hx:ret z � ���� ret � ����)
211
;� ��� ������ �室 � �।���, �᫨ �ࠩ�� �����, � de ��ᢠ������� ⮫쪮 �� ���������? ᭠砫� �ᮢ��� � 䠫�訢� ��࠭ � ��४����� �� call z?
212
;�� �����஢���� �� y 㦥 ���� ������ � ����묨 �ࠩ�, � �� � ����� (�.�. �㦭� ����� �ࠩ� � ���� ������)
213
 
214
;��室 �� �ਭ� �ࠩ� (� ������ �� ret)
215
prsprqwid
216
;� ��� de ���� � ��諮�� ࠧ�, � ��ࠡ��稪 ���뢠��� ����� ������� �⥪
217
        ld hl,$
218
        push hl ;�᫨ �ந��諮 ���뢠���, � ⥯��� �⥪ � ���浪�
219
prsprqright
220
prsprqsp=$+1
221
        ld sp,0
222
        ret
223
 
224
 
225
;��� �뢮�� �ࠩ� �������� �����:
226
 
227
;�����஢���� ᭨��
228
prsprcropbottom
229
;a=sprbottom
230
;e?1=x = -(sprmaxwid-1)..159 (��������� ��� x+(sprmaxwid-1))
231
;c?2=y = -(sprmaxhgt-1)..199 (��������� ��� ����)
232
;(iy-3)?3=sprhgt
233
;(iy-4)?4=sprwid
234
;hl=scr
235
prspr_curscrhgt=$+1
236
        sub scrhgt;200
237
        ;sub (iy-3) ;sprhgt
238
         ld d,(iy-3) ;sprhgt
239
         sub d
240
        ld c,a ;-sprvisiblehgt = sprbottom-200-sprhgt
241
;�᫨ �����஢��� ᫥��, � ᥩ�� lx = sprwid-�᫮ ��१����� ᫥�� �⮫�殢
242
;���� lx �� ������
243
 
244
        ld a,(iy-4) ;sprwid
245
        cp hx ;����ﭨ� �� �ࠢ��� ��� ��࠭�
246
        ;jr nc,$
247
        jr nc,prsprcropygo;_cropx ;���� ����襥 �� sprwid � ����ﭨ� �� �ࠢ�� �࠭��� ��࠭�
248
        ld hx,a
249
        jp prsprcropygo
250
 
251
prsprcroptop
252
;a=sprtop
253
;e?1=x = -(sprmaxwid-1)..159 (��������� ��� x+(sprmaxwid-1))
254
;c?2=y = -(sprmaxhgt-1)..199 (��������� ��� ����)
255
;(iy-3)?3=sprhgt
256
;(iy-4)?4=sprwid
257
;hl=scr ������ (��� ��࠭�)
258
 
259
        neg ;a=number of lines to crop
260
         ld d,(iy-3) ;sprhgt
261
         sub d
262
;a = -sprvisiblehgt = -(sprtop+sprhgt) = linestocrop-sprhgt
263
;�᫨ sprvisiblehgt<=0, � �ࠩ� ��� �� ��࠭�!!! ��室��!!!
264
         ret p
265
        ld c,a ;-sprvisiblehgt = -(sprtop+sprhgt) = linestocrop-sprhgt
266
 
267
;�᫨ �����஢��� ᫥��, � ᥩ�� lx = sprwid-�᫮ ��१����� ᫥�� �⮫�殢
268
;���� lx �� ������
269
 
270
        ld a,(iy-4) ;sprwid
271
        cp hx ;����ﭨ� �� �ࠢ��� ��� ��࠭�
272
        jr nc,prsprcropygo_cropx ;���� ����襥 �� sprwid � ����ﭨ� �� �ࠢ�� �࠭��� ��࠭�
273
        ld hx,a
274
prsprcropygo_cropx
275
 
276
         ld a,c
277
         add a,d ;a=number of lines to crop
278
        add a,a
279
;�ਡ����� 2*�᫮ ������ ��ப � �����
280
        add a,ly
281
        ld ly,a
282
        jr nc,$+4
283
        inc hy
284
 
285
        ld a,e ;x
286
        sub sprmaxwid-1 ;NC ��� ������⥫��� x
287
        srl a
288
        ld h,0x40
289
        jr nc,$+4 ;x bit 0
290
         ld h,0x80
291
        srl a
292
        jr nc,$+4 ;x bit 1
293
         set 5,h
294
       if scrbase&0xff
295
       add a,scrbase&0xff
296
       endif
297
        ld l,a
298
 
299
prsprcropygo
300
;d=(iy-3)?3=sprhgt
301
;(iy-4)?4=sprwid
302
        ld a,d ;sprhgt
303
        ;add a,c ;-sprvisiblehgt
304
        ; add a,3 ;inc a
305
        ;add a,a
306
        ;ld (prsprNspraddpatch),a ;2*(sprhgt-sprvisiblehgt)+2 +4
307
         inc a
308
         add a,a
309
        ld (prsprNspraddpatch),a ;2*sprhgt+2
310
 
311
        ld a,c ;-sprvisiblehgt
312
        add a,a
313
        add a,c
314
        add a,a
315
        ld (prsprNpatch),a ;PRSPR24 � �.�. (�� 6 ����)        
316
 
317
        ex de,hl
318
         ;ld b,-1 ;���� �� ���� ��६�饭�� ld h
319
         ;ld h,0x40/32-1
320
         inc c
321
        ld l,c ;-sprvisiblehgt
322
        add hl,hl
323
        add hl,hl
324
         ld h,0x40/8-1 -1
325
         jr nz,$+4
326
         ld h,0x40/8 ;��� sprvisiblehgt-1 == 0
327
        add hl,bc
328
        add hl,hl
329
        add hl,hl
330
        add hl,hl
331
        ld (prsprNscraddpatch),hl ;0x4000 - ((sprvisiblehgt-1)*40)
332
        ex de,hl
333
 
334
;hl=scr
335
        ;ld c,40
336
        jp prsprN
337
 
338
;��ࠢ������� �� �㦭� ����訩 ���� ����:
339
_lowaddr=256-(sprmaxhgt*6)
340
        ds (_lowaddr-$)&0xff
341
;����訩 ���� ���� ࠢ�� 256-(sprvisiblehgt*6)
342
PRSPR32
343
        dup 8
344
        MASKBYTE
345
        DOWNBYTE
346
        pop de
347
        edup
348
PRSPR24
349
        MASKBYTE
350
        DOWNBYTE
351
        pop de
352
PRSPR23
353
        MASKBYTE
354
        DOWNBYTE
355
        pop de
356
PRSPR22
357
        MASKBYTE
358
        DOWNBYTE
359
        pop de
360
PRSPR21
361
        MASKBYTE
362
        DOWNBYTE
363
        pop de
364
PRSPR20
365
        MASKBYTE
366
        DOWNBYTE
367
        pop de
368
PRSPR19
369
        MASKBYTE
370
        DOWNBYTE
371
        pop de
372
PRSPR18
373
        MASKBYTE
374
        DOWNBYTE
375
        pop de
376
PRSPR17
377
        MASKBYTE
378
        DOWNBYTE
379
        pop de
380
PRSPR16
381
        MASKBYTE
382
        DOWNBYTE
383
        pop de
384
PRSPR15
385
        MASKBYTE
386
        DOWNBYTE
387
        pop de
388
PRSPR14
389
        MASKBYTE
390
        DOWNBYTE
391
        pop de
392
PRSPR13
393
        MASKBYTE
394
        DOWNBYTE
395
        pop de
396
PRSPR12
397
        MASKBYTE
398
        DOWNBYTE
399
        pop de
400
PRSPR11
401
        MASKBYTE
402
        DOWNBYTE
403
        pop de
404
PRSPR10
405
        MASKBYTE
406
        DOWNBYTE
407
        pop de
408
PRSPR9
409
        MASKBYTE
410
        DOWNBYTE
411
        pop de
412
PRSPR8
413
        MASKBYTE
414
        DOWNBYTE
415
        pop de
416
PRSPR7
417
        MASKBYTE
418
        DOWNBYTE
419
        pop de
420
PRSPR6
421
        MASKBYTE
422
        DOWNBYTE
423
        pop de
424
PRSPR5
425
        MASKBYTE
426
        DOWNBYTE
427
        pop de
428
PRSPR4
429
        MASKBYTE
430
        DOWNBYTE
431
        pop de
432
PRSPR3
433
        MASKBYTE
434
        DOWNBYTE
435
        pop de
436
PRSPR2
437
        MASKBYTE
438
        DOWNBYTE
439
        pop de
440
PRSPR1
441
        display PRSPR32," HSB equal to ",$
442
        MASKBYTE
443
 
444
;���� ���� ᫥���饣� �⮫�� �� ��࠭� ��� ���        
445
;4000,8000,[c000]6000,a000,[e001]4001...
446
;����⠭����� ��砫�� hl
447
prsprNscraddpatch=$+1
448
        ld bc,0 ;bc = 0x4000 - ((sprvisiblehgt-1)*40)
449
        ld a,0x9f;0xa0
450
        cp h
451
        adc hl,bc
452
        jp pe,prsprNcolumnq ;� �������� ��砥�
453
;8000->�000 (���� 6000) ��� a000->e001 (���� 4001)
454
         inc a
455
        xor h
456
        ld h,a
457
prsprNcolumnq
458
        dec hx
459
        jp z,prsprNmaybeqright ;�� ����� ���� �࠭�� 䠫�訢��� ��࠭�! ���� ����� ����������� �த������ (� hl-64 ��-�� �訡�� ���� �� ����⥫��� x?)
460
prsprNcolumnqq
461
;���� ���� ������ ᫥���饣� �⮫�� �ࠩ�
462
;����� ���� ᤥ���� ����� ������ pop de, �.�. �ய�� ��ப �뢠�� ।��
463
prsprNspraddpatch=$+1
464
        ld bc,0 ;bc = 2*(sprhgt-sprvisiblehgt)+2
465
        add iy,bc
466
prsprN
467
;iy=sprite data
468
        ld c,40
469
        ld sp,tempsp ;�⮡� �� �������� ���� de � ����� ������
470
        ld e,(iy-2)
471
        ld d,(iy-1)
472
        ld sp,iy
473
prsprNpatch=$+1
474
        jp PRSPR24
475
 
476
prsprNmaybeqright
477
;curpg8000=$+1
478
;        ld a,0
479
        ld a,(curpg32klow) ;ok
480
pgfake=$+1
481
        cp 0
482
        jp nz,prsprqright ;����⢨⥫쭮 ��室
483
        ld hx,lx
484
        ld bc,-64
485
        add hl,bc ;��-�� �訡�� ���� �� ����⥫��� x
486
        ld sp,tempsp
487
        call setpgsscr40008000 ;�몫�砥� 䠫�訢� ��࠭, ����砥� �����騩
488
        ;ld bc,40
489
        ;ld lx,b;0 ;��ன ࠧ �㤥� ����⢨⥫쭮 ��室
490
        jp prsprNcolumnqq