1 #include "../pico_int.h"
3 static void convert_pal555(int invert_prio)
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;
16 // place prio to LS green bit
17 for (i = 0x100/2; i > 0; i--, ps++, pd++) {
19 *pd = (((t & m1) << 11) | ((t & m2) << 1) | ((t & m3) >> 10)) ^ inv;
22 Pico32x.dirty_pal = 0;
25 void FinalizeLine32xRGB555(int sh, int line)
27 unsigned short *pd = DrawLineDest;
28 unsigned short *pal = Pico32xMem->pal_native;
29 unsigned char *pb = HighCol + 8;
30 unsigned short *dram, *ps, cram0;
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
37 Pico.cram[0] = Pico.cram[Pico.video.reg[7] & 0x3f];
39 FinalizeLineRGB555(sh, line);
42 if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 0)
45 // XXX: how is 32col mode hadled by real hardware?
46 if (!(Pico.video.reg[12] & 1))
49 if (!(PicoDrawMask & PDRAW_32X_ON))
52 dram = (void *)Pico32xMem->dram[Pico32x.vdp_regs[0x0a/2] & P32XV_FS];
53 ps = dram + dram[line];
55 if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 2) { // Direct Color Mode
56 int inv = (Pico32x.vdp_regs[0] & P32XV_PRI) ? 0x8000 : 0;
57 unsigned int m1 = 0x001f001f;
58 unsigned int m2 = 0x03e003e0;
59 unsigned int m3 = 0xfc00fc00;
61 for (i = 320; i > 0; i--, ps++, pd++, pb++) {
62 unsigned short t = *ps;
63 if (*pb != 0 && !((t ^ inv) & 0x8000))
66 *pd = ((t & m1) << 11) | ((t & m2) << 1) | ((t & m3) >> 10);
71 if (Pico32x.dirty_pal)
72 convert_pal555(Pico32x.vdp_regs[0] & P32XV_PRI);
74 if ((Pico32x.vdp_regs[0] & P32XV_Mx) == 1) { // Packed Pixel Mode
76 for (i = 320/2; i > 0; i--, ps++, pd += 2, pb += 2) {
78 if (pb[0] == 0 || (t & 0x20))
81 if (pb[1] == 0 || (t & 0x20))
85 else { // Run Length Mode
86 unsigned short len, t;
87 for (i = 320; i > 0; ps++) {
89 for (len = (*ps >> 8) + 1; len > 0 && i > 0; len--, i--, pd++, pb++)
90 if (*pb == 0 || (t & 0x20))