-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawing.c
executable file
·2521 lines (2251 loc) · 76 KB
/
drawing.c
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
/*
* UAE - The Un*x Amiga Emulator
*
* Screen drawing functions
*
* Copyright 1995-2000 Bernd Schmidt
* Copyright 1995 Alessandro Bissacco
* Copyright 2000,2001 Toni Wilen
*/
/* There are a couple of concepts of "coordinates" in this file.
- DIW coordinates
- DDF coordinates (essentially cycles, resolution lower than lores by a factor of 2)
- Pixel coordinates
* in the Amiga's resolution as determined by BPLCON0 ("Amiga coordinates")
* in the window resolution as determined by the preferences ("window coordinates").
* in the window resolution, and with the origin being the topmost left corner of
the window ("native coordinates")
One note about window coordinates. The visible area depends on the width of the
window, and the centering code. The first visible horizontal window coordinate is
often _not_ 0, but the value of VISIBLE_LEFT_BORDER instead.
One important thing to remember: DIW coordinates are in the lowest possible
resolution.
To prevent extremely bad things (think pixels cut in half by window borders) from
happening, all ports should restrict window widths to be multiples of 16 pixels. */
#include "sysconfig.h"
#include "sysdeps.h"
#include <ctype.h>
#include <assert.h>
#include "options.h"
#include "threaddep/thread.h"
#include "uae.h"
#include "memory.h"
#include "custom.h"
#include "newcpu.h"
#include "xwin.h"
#include "autoconf.h"
#include "gui.h"
#include "picasso96.h"
#include "drawing.h"
#ifdef JIT
# include "compemu.h"
#endif
#include "savestate.h"
//ric
#include "profiling.h"
#define PROFILINGINDEX 200
#undef PROFILING
//end ric
int lores_factor, lores_shift;
/* The shift factor to apply when converting between Amiga coordinates and window
coordinates. Zero if the resolution is the same, positive if window coordinates
have a higher resolution (i.e. we're stretching the image), negative if window
coordinates have a lower resolution (i.e. we're shrinking the image). */
static int res_shift;
static int interlace_seen = 0;
#define AUTO_LORES_FRAMES 10
static int can_use_lores = 0;
/* Lookup tables for dual playfields. The dblpf_*1 versions are for the case
that playfield 1 has the priority, dbplpf_*2 are used if playfield 2 has
priority. If we need an array for non-dual playfield mode, it has no number. */
/* The dbplpf_ms? arrays contain a shift value. plf_spritemask is initialized
to contain two 16 bit words, with the appropriate mask if pf1 is in the
foreground being at bit offset 0, the one used if pf2 is in front being at
offset 16. */
static int dblpf_ms1[256], dblpf_ms2[256], dblpf_ms[256];
static int dblpf_ind1[256], dblpf_ind2[256];
static int dblpf_2nd1[256], dblpf_2nd2[256];
static int dblpfofs[] = { 0, 2, 4, 8, 16, 32, 64, 128 };
static int sprite_offs[256];
static uae_u32 clxtab[256];
/* Video buffer description structure. Filled in by the graphics system
* dependent code. */
struct vidbuf_description gfxvidinfo;
/* OCS/ECS color lookup table. */
xcolnr xcolors[4096];
#ifdef AGA
static uae_u8 spriteagadpfpixels[MAX_PIXELS_PER_LINE * 2]; /* AGA dualplayfield sprite */
/* AGA mode color lookup tables */
unsigned int xredcolors[256], xgreencolors[256], xbluecolors[256];
static int dblpf_ind1_aga[256], dblpf_ind2_aga[256];
#else
static uae_u8 spriteagadpfpixels[1];
static int dblpf_ind1_aga[1], dblpf_ind2_aga[1];
#endif
struct color_entry colors_for_drawing __attribute__((__section__(".sdata")));
/* The size of these arrays is pretty arbitrary; it was chosen to be "more
than enough". The coordinates used for indexing into these arrays are
almost, but not quite, Amiga coordinates (there's a constant offset). */
union {
/* Let's try to align this thing. */
double uupzuq;
long int cruxmedo;
uae_u8 apixels[MAX_PIXELS_PER_LINE * 2];
uae_u16 apixels_w[MAX_PIXELS_PER_LINE * 2 / 2];
uae_u32 apixels_l[MAX_PIXELS_PER_LINE * 2 / 4];
} pixdata;
#ifdef OS_WITHOUT_MEMORY_MANAGEMENT
uae_u16 *spixels;
#else
uae_u16 spixels[2 * MAX_SPR_PIXELS];
#endif
/* Eight bits for every pixel. */
union sps_union spixstate;
static uae_u32 ham_linebuf[MAX_PIXELS_PER_LINE * 2];
uae_u8 *xlinebuffer;
static int *amiga2aspect_line_map, *native2amiga_line_map;
static uae_u8 *row_map[MAX_VIDHEIGHT + 1];
static int max_drawn_amiga_line __attribute__((__section__(".sdata")));
/* line_draw_funcs: pfield_do_linetoscr, pfield_do_fill_line, decode_ham */
typedef void (*line_draw_func)(int, int);
#define LINE_UNDECIDED 1
#define LINE_DECIDED 2
#define LINE_DECIDED_DOUBLE 3
#define LINE_AS_PREVIOUS 4
#define LINE_BLACK 5
#define LINE_REMEMBERED_AS_BLACK 6
#define LINE_DONE 7
#define LINE_DONE_AS_PREVIOUS 8
#define LINE_REMEMBERED_AS_PREVIOUS 9
static char linestate[(MAXVPOS + 1)*2 + 1];
uae_u8 line_data[(MAXVPOS + 1) * 2][MAX_PLANES * MAX_WORDS_PER_LINE * 2];
/* Centering variables. */
int min_diwstart __attribute__((__section__(".sdata")));
int max_diwstop __attribute__((__section__(".sdata"))); //ric - needed for auto zoom
/* The visible window: VISIBLE_LEFT_BORDER contains the left border of the visible
area, VISIBLE_RIGHT_BORDER the right border. These are in window coordinates. */
static int visible_left_border __attribute__((__section__(".sdata")));
static int visible_right_border __attribute__((__section__(".sdata")));
static int linetoscr_x_adjust_bytes __attribute__((__section__(".sdata")));
static int thisframe_y_adjust __attribute__((__section__(".sdata")));
static int thisframe_y_adjust_real __attribute__((__section__(".sdata")));
static int max_ypos_thisframe __attribute__((__section__(".sdata")));
static int min_ypos_for_screen __attribute__((__section__(".sdata")));
static int extra_y_adjust __attribute__((__section__(".sdata")));
int thisframe_first_drawn_line __attribute__((__section__(".sdata")));
int thisframe_last_drawn_line __attribute__((__section__(".sdata")));
/* A frame counter that forces a redraw after at least one skipped frame in
interlace mode. */
static int last_redraw_point __attribute__((__section__(".sdata")));
static int first_drawn_line __attribute__((__section__(".sdata")));
static int last_drawn_line __attribute__((__section__(".sdata")));
static int first_block_line __attribute__((__section__(".sdata")));
static int last_block_line __attribute__((__section__(".sdata")));
#define NO_BLOCK -3
/* These are generated by the drawing code from the line_decisions array for
each line that needs to be drawn. These are basically extracted out of
bit fields in the hardware registers. */
static int bplehb __attribute__((__section__(".sdata")));
static int bplham __attribute__((__section__(".sdata")));
static int bpldualpf __attribute__((__section__(".sdata")));
static int bpldualpfpri __attribute__((__section__(".sdata")));
static int bpldualpf2of __attribute__((__section__(".sdata")));
static int bplplanecnt __attribute__((__section__(".sdata")));
static int bplres __attribute__((__section__(".sdata")));
static int plf1pri __attribute__((__section__(".sdata")));
static int plf2pri __attribute__((__section__(".sdata")));
static uae_u32 plf_sprite_mask __attribute__((__section__(".sdata")));
static int sbasecol[2] __attribute__((__section__(".sdata"))) = { 16, 16 };
static int brdsprt __attribute__((__section__(".sdata")));
static int brdblank __attribute__((__section__(".sdata")));
int picasso_requested_on;
int picasso_on;
uae_sem_t gui_sem;
int inhibit_frame;
int framecnt = 0;
static int frame_redraw_necessary;
static int picasso_redraw_necessary;
#ifdef ADVANCED_FS
// ric new frameskip logic
// This logic decides how many frames out of 50 that should be shown
// and tries to distribute them as evenly as possible
// it uses the following table to decide if a certain frame should be drawn
unsigned char frameskipTable[50][50] =
{
{1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, //1
{0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, //2
{0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, //3
{0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1}, //4
{0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,1,1,1}, //5
{0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1}, //6
{0,1,1,1,1,1,1,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,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0},
{1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
{1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
};
STATIC_INLINE void count_frame (void)
{
framecnt++;
if (framecnt == 50)
{
framecnt = 0;
}
}
#else
STATIC_INLINE void count_frame (void)
{
framecnt++;
if (framecnt >= currprefs.gfx_framerate)
framecnt = 0;
}
#endif
int coord_native_to_amiga_x (int x)
{
x += visible_left_border;
x <<= (1 - lores_shift);
return x + 2*DISPLAY_LEFT_SHIFT - 2*DIW_DDF_OFFSET;
}
int coord_native_to_amiga_y (int y)
{
return native2amiga_line_map[y] + thisframe_y_adjust - minfirstline;
}
STATIC_INLINE int res_shift_from_window (int x)
{
if (res_shift >= 0)
return x >> res_shift;
return x << -res_shift;
}
STATIC_INLINE int res_shift_from_amiga (int x)
{
if (res_shift >= 0)
return x >> res_shift;
return x << -res_shift;
}
void notice_screen_contents_lost (void)
{
picasso_redraw_necessary = 1;
frame_redraw_necessary = 2;
}
static struct decision *dp_for_drawing;
static struct draw_info *dip_for_drawing;
/* Record DIW of the current line for use by centering code. */
void record_diw_line (int first, int last)
{
if (last > max_diwstop)
max_diwstop = last;
if (first < min_diwstart)
min_diwstart = first;
}
/*
* Screen update macros/functions
*/
/* The important positions in the line: where do we start drawing the left border,
where do we start drawing the playfield, where do we start drawing the right border.
All of these are forced into the visible window (VISIBLE_LEFT_BORDER .. VISIBLE_RIGHT_BORDER).
PLAYFIELD_START and PLAYFIELD_END are in window coordinates. */
static int playfield_start __attribute__((__section__(".sdata")));
static int playfield_end __attribute__((__section__(".sdata")));
static int real_playfield_start __attribute__((__section__(".sdata")));
static int real_playfield_end __attribute__((__section__(".sdata")));
static int pixels_offset __attribute__((__section__(".sdata")));
static int src_pixel __attribute__((__section__(".sdata")));
/* How many pixels in window coordinates which are to the left of the left border. */
static int unpainted __attribute__((__section__(".sdata")));
/* Initialize the variables necessary for drawing a line.
* This involves setting up start/stop positions and display window
* borders. */
#ifdef ADVANCED_DRAW
STATIC_INLINE void pfield_init_linetoscr (void)
#else
static void pfield_init_linetoscr (void)
#endif
{
/* First, get data fetch start/stop in DIW coordinates. */
int ddf_left = dp_for_drawing->plfleft * 2 + DIW_DDF_OFFSET;
int ddf_right = dp_for_drawing->plfright * 2 + DIW_DDF_OFFSET;
/* Compute datafetch start/stop in pixels; native display coordinates. */
int native_ddf_left = coord_hw_to_window_x (ddf_left);
int native_ddf_right = coord_hw_to_window_x (ddf_right);
int linetoscr_diw_start = dp_for_drawing->diwfirstword;
int linetoscr_diw_end = dp_for_drawing->diwlastword;
if (dip_for_drawing->nr_sprites == 0) {
if (linetoscr_diw_start < native_ddf_left)
linetoscr_diw_start = native_ddf_left;
if (linetoscr_diw_end > native_ddf_right)
linetoscr_diw_end = native_ddf_right;
}
/* Perverse cases happen. */
if (linetoscr_diw_end < linetoscr_diw_start)
linetoscr_diw_end = linetoscr_diw_start;
playfield_start = linetoscr_diw_start;
playfield_end = linetoscr_diw_end;
if (playfield_start < visible_left_border)
playfield_start = visible_left_border;
if (playfield_start > visible_right_border)
playfield_start = visible_right_border;
if (playfield_end < visible_left_border)
playfield_end = visible_left_border;
if (playfield_end > visible_right_border)
playfield_end = visible_right_border;
real_playfield_end = playfield_end;
real_playfield_start = playfield_start;
#ifdef AGA
if (brdsprt && dip_for_drawing->nr_sprites) {
int min = visible_right_border, max = visible_left_border, i;
for (i = 0; i < dip_for_drawing->nr_sprites; i++) {
int x;
x = curr_sprite_entries[dip_for_drawing->first_sprite_entry + i].pos;
if (x < min) min = x;
x = curr_sprite_entries[dip_for_drawing->first_sprite_entry + i].max;
if (x > max) max = x;
}
min += (DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) << (2 - lores_shift);
max += (DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) << (2 - lores_shift);
if (min < playfield_start)
playfield_start = min;
if (playfield_start < visible_left_border)
playfield_start = visible_left_border;
if (max > playfield_end)
playfield_end = max;
if (playfield_end > visible_right_border)
playfield_end = visible_right_border;
}
#endif
/* Now, compute some offsets. */
res_shift = lores_shift - bplres;
ddf_left -= DISPLAY_LEFT_SHIFT;
ddf_left <<= bplres;
pixels_offset = MAX_PIXELS_PER_LINE - ddf_left;
unpainted = visible_left_border < playfield_start ? 0 : visible_left_border - playfield_start;
src_pixel = MAX_PIXELS_PER_LINE + res_shift_from_window (playfield_start - native_ddf_left + unpainted);
if (dip_for_drawing->nr_sprites == 0)
return;
/* Must clear parts of apixels. */
if (linetoscr_diw_start < native_ddf_left) {
int size = res_shift_from_window (native_ddf_left - linetoscr_diw_start);
linetoscr_diw_start = native_ddf_left;
memset (pixdata.apixels + MAX_PIXELS_PER_LINE - size, 0, size);
}
if (linetoscr_diw_end > native_ddf_right) {
int pos = res_shift_from_window (native_ddf_right - native_ddf_left);
int size = res_shift_from_window (linetoscr_diw_end - native_ddf_right);
linetoscr_diw_start = native_ddf_left;
memset (pixdata.apixels + MAX_PIXELS_PER_LINE + pos, 0, size);
}
}
//ric
static void fill_line_16 (uae_u8 *buf, int start, int stop)
{
uae_u16 *b = (uae_u16 *)buf;
int i;
xcolnr col = brdblank ? 0 : colors_for_drawing.acolors[0];
for (i = start; i < stop; i++)
b[i] = (uae_u16)col;
}
//end ric
STATIC_INLINE void fill_line (void)
{
#ifdef PROFILING
PROFILINGBEGIN
#endif
int nints, nrem;
int *start;
xcolnr val;
/* gno: 16bit
int shift;
shift = 0;
if (gfxvidinfo.pixbytes == 2)
shift = 1;
if (gfxvidinfo.pixbytes == 4)
shift = 2;
nints = gfxvidinfo.width >> (2-shift);
nrem = nints & 7;
nints &= ~7;
start = (int *)(((char *)xlinebuffer) + (visible_left_border << shift));
*/
nints = 240;
start = (int *)(((char *)xlinebuffer) + (visible_left_border << 1));
#ifdef AGA
val = brdblank ? 0 : colors_for_drawing.acolors[0];
#else
val = colors_for_drawing.acolors[0];
#endif
for (; nints > 0; nints -= 8, start += 8) {
*start = val;
*(start+1) = val;
*(start+2) = val;
*(start+3) = val;
*(start+4) = val;
*(start+5) = val;
*(start+6) = val;
*(start+7) = val;
}
/* gno: no reminders :)
switch (nrem) {
case 7:
*start++ = val;
case 6:
*start++ = val;
case 5:
*start++ = val;
case 4:
*start++ = val;
case 3:
*start++ = val;
case 2:
*start++ = val;
case 1:
*start = val;
}
*/
#ifdef PROFILING
PROFILINGEND(PROFILINGINDEX)
#endif
}
#include "linetoscr.c"
static void pfield_do_linetoscr (int start, int stop)
{
#ifdef PROFILING
PROFILINGBEGIN
#endif
#ifdef AGA
if (currprefs.chipset_mask & CSMASK_AGA) {
if (res_shift == 0)
switch (gfxvidinfo.pixbytes) {
case 1: src_pixel = linetoscr_8_aga (src_pixel, start, stop); break;
case 2: src_pixel = linetoscr_16_aga (src_pixel, start, stop); break;
case 4: src_pixel = linetoscr_32_aga (src_pixel, start, stop); break;
}
else if (res_shift > 0)
switch (gfxvidinfo.pixbytes) {
case 1: src_pixel = linetoscr_8_stretch1_aga (src_pixel, start, stop); break;
case 2: src_pixel = linetoscr_16_stretch1_aga (src_pixel, start, stop); break;
case 4: src_pixel = linetoscr_32_stretch1_aga (src_pixel, start, stop); break;
}
else if (res_shift < 0)
switch (gfxvidinfo.pixbytes) {
case 1: src_pixel = linetoscr_8_shrink1_aga (src_pixel, start, stop); break;
case 2: src_pixel = linetoscr_16_shrink1_aga (src_pixel, start, stop); break;
case 4: src_pixel = linetoscr_32_shrink1_aga (src_pixel, start, stop); break;
}
} else {
#endif
if (res_shift == 0) {
//switch (gfxvidinfo.pixbytes) {
//case 1: src_pixel = linetoscr_8 (src_pixel, start, stop); break;
//case 2: src_pixel = linetoscr_16 (src_pixel, start, stop); break;
//case 4: src_pixel = linetoscr_32 (src_pixel, start, stop); break;
src_pixel = linetoscr_16 (src_pixel, start, stop);
}
else if (res_shift > 0) {
//switch (gfxvidinfo.pixbytes) {
//case 1: src_pixel = linetoscr_8_stretch1 (src_pixel, start, stop); break;
//case 2: src_pixel = linetoscr_16_stretch1 (src_pixel, start, stop); break;
//case 4: src_pixel = linetoscr_32_stretch1 (src_pixel, start, stop); break;
src_pixel = linetoscr_16_stretch1 (src_pixel, start, stop);
}
else if (res_shift < 0) {
//switch (gfxvidinfo.pixbytes) {
//case 1: src_pixel = linetoscr_8_shrink1 (src_pixel, start, stop); break;
//case 2: src_pixel = linetoscr_16_shrink1 (src_pixel, start, stop); break;
//case 4: src_pixel = linetoscr_32_shrink1 (src_pixel, start, stop); break;
src_pixel = linetoscr_16_shrink1 (src_pixel, start, stop);
}
#ifdef AGA
}
#endif
#ifdef PROFILING
PROFILINGEND(PROFILINGINDEX+1)
#endif
}
static void pfield_do_fill_line (int start, int stop)
{
#ifdef PROFILING
PROFILINGBEGIN
#endif
//switch (gfxvidinfo.pixbytes) {
//case 1: fill_line_8 (xlinebuffer, start, stop); break;
//case 2: fill_line_16 (xlinebuffer, start, stop); break;
//case 4: fill_line_32 (xlinebuffer, start, stop); break;
//}
fill_line_16 (xlinebuffer, start, stop);
#ifdef PROFILING
PROFILINGEND(PROFILINGINDEX+2)
#endif
}
static void dummy_worker (int start, int stop)
{
}
static unsigned int ham_lastcolor __attribute__((__section__(".sdata")));
static int ham_decode_pixel __attribute__((__section__(".sdata")));
/* Decode HAM in the invisible portion of the display (left of VISIBLE_LEFT_BORDER),
but don't draw anything in. This is done to prepare HAM_LASTCOLOR for later,
when decode_ham runs. */
static void init_ham_decoding (void)
{
int unpainted_amiga = res_shift_from_window (unpainted);
ham_decode_pixel = src_pixel;
ham_lastcolor = color_reg_get (&colors_for_drawing, 0);
if (! bplham || (bplplanecnt != 6 && ((currprefs.chipset_mask & CSMASK_AGA) == 0 || bplplanecnt != 8))) {
if (unpainted_amiga > 0) {
int pv = pixdata.apixels[ham_decode_pixel + unpainted_amiga - 1];
#ifdef AGA
if (currprefs.chipset_mask & CSMASK_AGA)
ham_lastcolor = colors_for_drawing.color_regs_aga[pv];
else
#endif
ham_lastcolor = colors_for_drawing.color_regs_ecs[pv];
}
#ifdef AGA
} else if (currprefs.chipset_mask & CSMASK_AGA) {
if (bplplanecnt == 8) { /* AGA mode HAM8 */
while (unpainted_amiga-- > 0) {
int pv = pixdata.apixels[ham_decode_pixel++];
switch (pv & 0x3) {
case 0x0: ham_lastcolor = colors_for_drawing.color_regs_aga[pv >> 2]; break;
case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pv & 0xFC); break;
case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pv & 0xFC) << 16; break;
case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pv & 0xFC) << 8; break;
}
}
} else if (bplplanecnt == 6) { /* AGA mode HAM6 */
while (unpainted_amiga-- > 0) {
int pv = pixdata.apixels[ham_decode_pixel++];
switch (pv & 0x30) {
case 0x00: ham_lastcolor = colors_for_drawing.color_regs_aga[pv]; break;
case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= (pv & 0xF) << 4; break;
case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= (pv & 0xF) << 20; break;
case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= (pv & 0xF) << 12; break;
}
}
}
#endif
} else {
if (bplplanecnt == 6) { /* OCS/ECS mode HAM6 */
while (unpainted_amiga-- > 0) {
int pv = pixdata.apixels[ham_decode_pixel++];
switch (pv & 0x30) {
case 0x00: ham_lastcolor = colors_for_drawing.color_regs_ecs[pv]; break;
case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break;
case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break;
case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break;
}
}
}
}
}
static void decode_ham (int pix, int stoppos)
{
#ifdef PROFILING
PROFILINGBEGIN
#endif
int todraw_amiga = res_shift_from_window (stoppos - pix);
if (! bplham || (bplplanecnt != 6 && ((currprefs.chipset_mask & CSMASK_AGA) == 0 || bplplanecnt != 8))) {
while (todraw_amiga-- > 0) {
int pv = pixdata.apixels[ham_decode_pixel];
#ifdef AGA
if (currprefs.chipset_mask & CSMASK_AGA)
ham_lastcolor = colors_for_drawing.color_regs_aga[pv];
else
#endif
ham_lastcolor = colors_for_drawing.color_regs_ecs[pv];
ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
}
#ifdef AGA
} else if (currprefs.chipset_mask & CSMASK_AGA) {
if (bplplanecnt == 8) { /* AGA mode HAM8 */
while (todraw_amiga-- > 0) {
int pv = pixdata.apixels[ham_decode_pixel];
switch (pv & 0x3) {
case 0x0: ham_lastcolor = colors_for_drawing.color_regs_aga[pv >> 2]; break;
case 0x1: ham_lastcolor &= 0xFFFF03; ham_lastcolor |= (pv & 0xFC); break;
case 0x2: ham_lastcolor &= 0x03FFFF; ham_lastcolor |= (pv & 0xFC) << 16; break;
case 0x3: ham_lastcolor &= 0xFF03FF; ham_lastcolor |= (pv & 0xFC) << 8; break;
}
ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
}
} else if (bplplanecnt == 6) { /* AGA mode HAM6 */
while (todraw_amiga-- > 0) {
int pv = pixdata.apixels[ham_decode_pixel];
switch (pv & 0x30) {
case 0x00: ham_lastcolor = colors_for_drawing.color_regs_aga[pv]; break;
case 0x10: ham_lastcolor &= 0xFFFF00; ham_lastcolor |= (pv & 0xF) << 4; break;
case 0x20: ham_lastcolor &= 0x00FFFF; ham_lastcolor |= (pv & 0xF) << 20; break;
case 0x30: ham_lastcolor &= 0xFF00FF; ham_lastcolor |= (pv & 0xF) << 12; break;
}
ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
}
}
#endif
} else {
if (bplplanecnt == 6) { /* OCS/ECS mode HAM6 */
while (todraw_amiga-- > 0) {
int pv = pixdata.apixels[ham_decode_pixel];
switch (pv & 0x30) {
case 0x00: ham_lastcolor = colors_for_drawing.color_regs_ecs[pv]; break;
case 0x10: ham_lastcolor &= 0xFF0; ham_lastcolor |= (pv & 0xF); break;
case 0x20: ham_lastcolor &= 0x0FF; ham_lastcolor |= (pv & 0xF) << 8; break;
case 0x30: ham_lastcolor &= 0xF0F; ham_lastcolor |= (pv & 0xF) << 4; break;
}
ham_linebuf[ham_decode_pixel++] = ham_lastcolor;
}
}
}
#ifdef PROFILING
PROFILINGEND(PROFILINGINDEX+3)
#endif
}
static void gen_pfield_tables (void)
{
int i;
/* For now, the AGA stuff is broken in the dual playfield case. We encode
* sprites in dpf mode by ORing the pixel value with 0x80. To make dual
* playfield rendering easy, the lookup tables contain are made linear for
* values >= 128. That only works for OCS/ECS, though. */
for (i = 0; i < 256; i++) {
int plane1 = (i & 1) | ((i >> 1) & 2) | ((i >> 2) & 4) | ((i >> 3) & 8);
int plane2 = ((i >> 1) & 1) | ((i >> 2) & 2) | ((i >> 3) & 4) | ((i >> 4) & 8);
dblpf_2nd1[i] = plane1 == 0 ? (plane2 == 0 ? 0 : 2) : 1;
dblpf_2nd2[i] = plane2 == 0 ? (plane1 == 0 ? 0 : 1) : 2;
#ifdef AGA
dblpf_ind1_aga[i] = plane1 == 0 ? plane2 : plane1;
dblpf_ind2_aga[i] = plane2 == 0 ? plane1 : plane2;
#endif
dblpf_ms1[i] = plane1 == 0 ? (plane2 == 0 ? 16 : 8) : 0;
dblpf_ms2[i] = plane2 == 0 ? (plane1 == 0 ? 16 : 0) : 8;
dblpf_ms[i] = i == 0 ? 16 : 8;
if (plane2 > 0)
plane2 += 8;
dblpf_ind1[i] = i >= 128 ? i & 0x7F : (plane1 == 0 ? plane2 : plane1);
dblpf_ind2[i] = i >= 128 ? i & 0x7F : (plane2 == 0 ? plane1 : plane2);
sprite_offs[i] = (i & 15) ? 0 : 2;
clxtab[i] = ((((i & 3) && (i & 12)) << 9)
| (((i & 3) && (i & 48)) << 10)
| (((i & 3) && (i & 192)) << 11)
| (((i & 12) && (i & 48)) << 12)
| (((i & 12) && (i & 192)) << 13)
| (((i & 48) && (i & 192)) << 14));
}
}
#define SPRITE_DEBUG 0
/* When looking at this function and the ones that inline it, bear in mind
what an optimizing compiler will do with this code. All callers of this
function only pass in constant arguments (except for E). This means
that many of the if statements will go away completely after inlining. */
STATIC_INLINE void draw_sprites_1 (struct sprite_entry *e, int ham, int dualpf,
int doubling, int skip, int has_attach, int aga)
{
int *shift_lookup = dualpf ? (bpldualpfpri ? dblpf_ms2 : dblpf_ms1) : dblpf_ms;
uae_u16 *buf = spixels + e->first_pixel;
uae_u8 *stbuf = spixstate.bytes + e->first_pixel;
int pos, window_pos;
#ifdef AGA
uae_u8 xor_val = (uae_u8)(dp_for_drawing->bplcon4 >> 8);
#endif
buf -= e->pos;
stbuf -= e->pos;
window_pos = e->pos + ((DIW_DDF_OFFSET - DISPLAY_LEFT_SHIFT) << (aga ? 1 : 0));
if (skip)
window_pos >>= 1;
else if (doubling)
window_pos <<= 1;
window_pos += pixels_offset;
for (pos = e->pos; pos < e->max; pos += 1 << skip) {
int maskshift, plfmask;
unsigned int v = buf[pos];
/* The value in the shift lookup table is _half_ the shift count we
need. This is because we can't shift 32 bits at once (undefined
behaviour in C). */
maskshift = shift_lookup[pixdata.apixels[window_pos]];
plfmask = (plf_sprite_mask >> maskshift) >> maskshift;
v &= ~plfmask;
if (v != 0 || SPRITE_DEBUG) {
unsigned int vlo, vhi, col;
unsigned int v1 = v & 255;
/* OFFS determines the sprite pair with the highest priority that has
any bits set. E.g. if we have 0xFF00 in the buffer, we have sprite
pairs 01 and 23 cleared, and pairs 45 and 67 set, so OFFS will
have a value of 4.
2 * OFFS is the bit number in V of the sprite pair, and it also
happens to be the color offset for that pair. */
int offs;
if (v1 == 0)
offs = 4 + sprite_offs[v >> 8];
else
offs = sprite_offs[v1];
/* Shift highest priority sprite pair down to bit zero. */
v >>= offs * 2;
v &= 15;
#if SPRITE_DEBUG > 0
v ^= 8;
#endif
if (has_attach && (stbuf[pos] & (3 << offs))) {
col = v;
if (aga)
col += sbasecol[1];
else
col += 16;
} else {
/* This sequence computes the correct color value. We have to select
either the lower-numbered or the higher-numbered sprite in the pair.
We have to select the high one if the low one has all bits zero.
If the lower-numbered sprite has any bits nonzero, (VLO - 1) is in
the range of 0..2, and with the mask and shift, VHI will be zero.
If the lower-numbered sprite is zero, (VLO - 1) is a mask of
0xFFFFFFFF, and we select the bits of the higher numbered sprite
in VHI.
This is _probably_ more efficient than doing it with branches. */
vlo = v & 3;
vhi = (v & (vlo - 1)) >> 2;
col = (vlo | vhi);
if (aga) {
if (vhi > 0)
col += sbasecol[1];
else
col += sbasecol[0];
} else {
col += 16;
}
col += (offs * 2);
}
if (dualpf) {
#ifdef AGA
if (aga) {
spriteagadpfpixels[window_pos] = col;
if (doubling)
spriteagadpfpixels[window_pos + 1] = col;
} else {
#endif
col += 128;
if (doubling)
pixdata.apixels_w[window_pos >> 1] = col | (col << 8);
else
pixdata.apixels[window_pos] = col;
#ifdef AGA
}
#endif
} else if (ham) {
col = color_reg_get (&colors_for_drawing, col);
#ifdef AGA
if (aga)
col ^= xor_val;
#endif
ham_linebuf[window_pos] = col;
if (doubling)
ham_linebuf[window_pos + 1] = col;
} else {
#ifdef AGA
if (aga)
col ^= xor_val;
#endif
if (doubling)
pixdata.apixels_w[window_pos >> 1] = col | (col << 8);
else
pixdata.apixels[window_pos] = col;
}
}
window_pos += 1 << doubling;
}
}
/* See comments above. Do not touch if you don't know what's going on.
* (We do _not_ want the following to be inlined themselves). */
/* lores bitplane, lores sprites */
static void NOINLINE draw_sprites_normal_sp_lo_nat (struct sprite_entry *e) { draw_sprites_1 (e, 0, 0, 0, 0, 0, 0); }
static void NOINLINE draw_sprites_normal_dp_lo_nat (struct sprite_entry *e) { draw_sprites_1 (e, 0, 1, 0, 0, 0, 0); }
static void NOINLINE draw_sprites_ham_sp_lo_nat (struct sprite_entry *e) { draw_sprites_1 (e, 1, 0, 0, 0, 0, 0); }
static void NOINLINE draw_sprites_normal_sp_lo_at (struct sprite_entry *e) { draw_sprites_1 (e, 0, 0, 0, 0, 1, 0); }
static void NOINLINE draw_sprites_normal_dp_lo_at (struct sprite_entry *e) { draw_sprites_1 (e, 0, 1, 0, 0, 1, 0); }
static void NOINLINE draw_sprites_ham_sp_lo_at (struct sprite_entry *e) { draw_sprites_1 (e, 1, 0, 0, 0, 1, 0); }
/* hires bitplane, lores sprites */
static void NOINLINE draw_sprites_normal_sp_hi_nat (struct sprite_entry *e) { draw_sprites_1 (e, 0, 0, 1, 0, 0, 0); }
static void NOINLINE draw_sprites_normal_dp_hi_nat (struct sprite_entry *e) { draw_sprites_1 (e, 0, 1, 1, 0, 0, 0); }
static void NOINLINE draw_sprites_ham_sp_hi_nat (struct sprite_entry *e) { draw_sprites_1 (e, 1, 0, 1, 0, 0, 0); }
static void NOINLINE draw_sprites_normal_sp_hi_at (struct sprite_entry *e) { draw_sprites_1 (e, 0, 0, 1, 0, 1, 0); }
static void NOINLINE draw_sprites_normal_dp_hi_at (struct sprite_entry *e) { draw_sprites_1 (e, 0, 1, 1, 0, 1, 0); }
static void NOINLINE draw_sprites_ham_sp_hi_at (struct sprite_entry *e) { draw_sprites_1 (e, 1, 0, 1, 0, 1, 0); }
#ifdef AGA
/* not very optimized */
STATIC_INLINE void draw_sprites_aga (struct sprite_entry *e)
{
int diff = RES_HIRES - bplres;
if (diff > 0)
draw_sprites_1 (e, dp_for_drawing->ham_seen, bpldualpf, 0, diff, e->has_attached, 1);
else
draw_sprites_1 (e, dp_for_drawing->ham_seen, bpldualpf, -diff, 0, e->has_attached, 1);
}
#endif
STATIC_INLINE void draw_sprites_ecs (struct sprite_entry *e)
{
#ifdef PROFILING
PROFILINGBEGIN
#endif
if (e->has_attached)
if (bplres == 1)
if (dp_for_drawing->ham_seen)
draw_sprites_ham_sp_hi_at (e);
else
if (bpldualpf)
draw_sprites_normal_dp_hi_at (e);
else
draw_sprites_normal_sp_hi_at (e);
else
if (dp_for_drawing->ham_seen)
draw_sprites_ham_sp_lo_at (e);
else
if (bpldualpf)
draw_sprites_normal_dp_lo_at (e);
else
draw_sprites_normal_sp_lo_at (e);
else
if (bplres == 1)
if (dp_for_drawing->ham_seen)
draw_sprites_ham_sp_hi_nat (e);
else
if (bpldualpf)
draw_sprites_normal_dp_hi_nat (e);
else
draw_sprites_normal_sp_hi_nat (e);
else
if (dp_for_drawing->ham_seen)
draw_sprites_ham_sp_lo_nat (e);
else
if (bpldualpf)
draw_sprites_normal_dp_lo_nat (e);
else
draw_sprites_normal_sp_lo_nat (e);
#ifdef PROFILING
PROFILINGEND(PROFILINGINDEX+4)
#endif
}
#ifdef AGA
/* clear possible bitplane data outside DIW area */
static void clear_bitplane_border_aga (void)
{
int len, shift = lores_shift - bplres;
uae_u8 v = 0;
if (shift < 0) {
shift = -shift;
len = (real_playfield_start - playfield_start) << shift;
memset (pixdata.apixels + pixels_offset + (playfield_start << shift), v, len);
len = (playfield_end - real_playfield_end) << shift;
memset (pixdata.apixels + pixels_offset + (real_playfield_end << shift), v, len);
} else {
len = (real_playfield_start - playfield_start) >> shift;
memset (pixdata.apixels + pixels_offset + (playfield_start >> shift), v, len);
len = (playfield_end - real_playfield_end) >> shift;
memset (pixdata.apixels + pixels_offset + (real_playfield_end >> shift), v, len);
}
}
#endif
/* emulate OCS/ECS only undocumented "SWIV" hardware feature */
static void weird_bitplane_fix (void)
{
int i, shift = lores_shift - bplres;
if (shift < 0) {
shift = -shift;
for (i = playfield_start << lores_shift; i < playfield_end << lores_shift; i++) {
if (pixdata.apixels[pixels_offset + i] > 16)
pixdata.apixels[pixels_offset + i] = 16;
}
} else {
for (i = playfield_start >> lores_shift; i < playfield_end >> lores_shift; i++) {
if (pixdata.apixels[pixels_offset + i] > 16)
pixdata.apixels[pixels_offset + i] = 16;
}
}
}
#define MERGE(a,b,mask,shift) do {\
uae_u32 tmp = mask & (a ^ (b >> shift)); \