974fdb5b |
1 | #include "../pico_int.h" |
2 | |
5e49c3a8 |
3 | static void convert_pal555(int invert_prio) |
974fdb5b |
4 | { |
5 | unsigned int *ps = (void *)Pico32xMem->pal; |
6 | unsigned int *pd = (void *)Pico32xMem->pal_native; |
7 | unsigned int m1 = 0x001f001f; |
8 | unsigned int m2 = 0x03e003e0; |
9 | unsigned int m3 = 0xfc00fc00; |
5e49c3a8 |
10 | unsigned int inv = 0; |
974fdb5b |
11 | int i; |
12 | |
5e49c3a8 |
13 | if (invert_prio) |
14 | inv = 0x00200020; |
15 | |
974fdb5b |
16 | // place prio to LS green bit |
17 | for (i = 0x100/2; i > 0; i--, ps++, pd++) { |
18 | unsigned int t = *ps; |
5e49c3a8 |
19 | *pd = (((t & m1) << 11) | ((t & m2) << 1) | ((t & m3) >> 10)) ^ inv; |
974fdb5b |
20 | } |
21 | |
22 | Pico32x.dirty_pal = 0; |
23 | } |
24 | |
25 | void FinalizeLine32xRGB555(int sh, int line) |
26 | { |
27 | unsigned short *pd = DrawLineDest; |
28 | unsigned short *pal = Pico32xMem->pal_native; |
29 | unsigned char *pb = HighCol + 8; |
266c6afa |
30 | unsigned short *dram, *ps, cram0; |
31 | int i; |
974fdb5b |
32 | |
33 | // this is a bit hackish: |
34 | // we swap cram color 0 with color that is used for background, |
35 | // as bg is forced to 0 when we do 32X |
36 | cram0 = Pico.cram[0]; |
37 | Pico.cram[0] = Pico.cram[Pico.video.reg[7] & 0x3f]; |
38 | |
39 | FinalizeLineRGB555(sh, line); |
40 | Pico.cram[0] = cram0; |
41 | |
5e49c3a8 |
42 | if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 0) |
974fdb5b |
43 | return; // blanking |
44 | |
5e49c3a8 |
45 | if (!(PicoDrawMask & PDRAW_32X_ON)) |
46 | return; |
47 | |
266c6afa |
48 | dram = (void *)Pico32xMem->dram[Pico32x.vdp_regs[0x0a/2] & P32XV_FS]; |
49 | ps = dram + dram[line]; |
50 | |
51 | if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 2) { // Direct Color Mode |
52 | int inv = (Pico32x.vdp_regs[0] & P32XV_PRI) ? 0x8000 : 0; |
53 | unsigned int m1 = 0x001f001f; |
54 | unsigned int m2 = 0x03e003e0; |
55 | unsigned int m3 = 0xfc00fc00; |
56 | |
57 | for (i = 320; i > 0; i--, ps++, pd++, pb++) { |
58 | unsigned short t = *ps; |
59 | if (*pb != 0 && !((t ^ inv) & 0x8000)) |
60 | continue; |
61 | |
62 | *pd = ((t & m1) << 11) | ((t & m2) << 1) | ((t & m3) >> 10); |
63 | } |
64 | return; |
65 | } |
66 | |
974fdb5b |
67 | if (Pico32x.dirty_pal) |
5e49c3a8 |
68 | convert_pal555(Pico32x.vdp_regs[0] & P32XV_PRI); |
974fdb5b |
69 | |
266c6afa |
70 | if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 1) { // Packed Pixel Mode |
974fdb5b |
71 | unsigned short t; |
974fdb5b |
72 | for (i = 320/2; i > 0; i--, ps++, pd += 2, pb += 2) { |
73 | t = pal[*ps >> 8]; |
74 | if (pb[0] == 0 || (t & 0x20)) |
75 | pd[0] = t; |
76 | t = pal[*ps & 0xff]; |
77 | if (pb[1] == 0 || (t & 0x20)) |
78 | pd[1] = t; |
79 | } |
80 | } |
266c6afa |
81 | else { // Run Length Mode |
82 | |
83 | } |
974fdb5b |
84 | } |
85 | |