974fdb5b |
1 | #include "../pico_int.h" |
2 | |
3 | static void convert_pal555(void) |
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; |
10 | int i; |
11 | |
12 | // place prio to LS green bit |
13 | for (i = 0x100/2; i > 0; i--, ps++, pd++) { |
14 | unsigned int t = *ps; |
15 | *pd = ((t & m1) << 11) | ((t & m2) << 1) | ((t & m3) >> 10); |
16 | } |
17 | |
18 | Pico32x.dirty_pal = 0; |
19 | } |
20 | |
21 | void FinalizeLine32xRGB555(int sh, int line) |
22 | { |
23 | unsigned short *pd = DrawLineDest; |
24 | unsigned short *pal = Pico32xMem->pal_native; |
25 | unsigned char *pb = HighCol + 8; |
26 | unsigned short cram0; |
27 | |
28 | // this is a bit hackish: |
29 | // we swap cram color 0 with color that is used for background, |
30 | // as bg is forced to 0 when we do 32X |
31 | cram0 = Pico.cram[0]; |
32 | Pico.cram[0] = Pico.cram[Pico.video.reg[7] & 0x3f]; |
33 | |
34 | FinalizeLineRGB555(sh, line); |
35 | Pico.cram[0] = cram0; |
36 | |
37 | if ((Pico32x.vdp_regs[0] & 3) == 0) |
38 | return; // blanking |
39 | |
40 | if (Pico32x.dirty_pal) |
41 | convert_pal555(); |
42 | |
43 | if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 1) { |
44 | unsigned short *dram = (void *)Pico32xMem->dram[Pico32x.vdp_regs[0x0a/2] & P32XV_FS]; |
45 | unsigned short *ps = dram + dram[line]; |
46 | unsigned short t; |
47 | int i; |
48 | for (i = 320/2; i > 0; i--, ps++, pd += 2, pb += 2) { |
49 | t = pal[*ps >> 8]; |
50 | if (pb[0] == 0 || (t & 0x20)) |
51 | pd[0] = t; |
52 | t = pal[*ps & 0xff]; |
53 | if (pb[1] == 0 || (t & 0x20)) |
54 | pd[1] = t; |
55 | } |
56 | } |
57 | } |
58 | |