|
|
1.1 root 1: /*
2: Hatari - med640x16_spec.c
3:
4: This file is distributed under the GNU Public License, version 2 or at your
5: option any later version. Read the file gpl.txt for details.
6:
7: Screen Conversion, Medium Res Spec512 to 640x16Bit
8: */
9:
10: static void ConvertMediumRes_640x16Bit_Spec(void)
11: {
12: Uint32 *edi, *ebp;
13: Uint16 *esi;
14: Uint32 eax;
15: int y;
16:
17: Spec512_StartFrame(); /* Start frame, track palettes */
18:
19: for (y = STScreenStartHorizLine; y < STScreenEndHorizLine; y++)
20: {
21: eax = STScreenLineOffset[y] + STScreenLeftSkipBytes; /* Offset for this line + Amount to skip on left hand side */
22: edi = (Uint32 *)((Uint8 *)pSTScreen + eax); /* ST format screen 4-plane 16 colors */
23: ebp = (Uint32 *)((Uint8 *)pSTScreenCopy + eax); /* Previous ST format screen */
24: esi = (Uint16 *)pPCScreenDest; /* PC format screen */
25:
26: if (HBLPaletteMasks[y] & 0x00030000) /* Test resolution */
27: Line_ConvertMediumRes_640x16Bit_Spec(edi, ebp, esi, eax); /* med res line */
28: else
29: Line_ConvertLowRes_640x16Bit_Spec(edi, ebp, (Uint32 *)esi, eax); /* low res line (double on X) */
30:
31: /* Offset to next line (double on Y) */
32: pPCScreenDest = (((Uint8 *)pPCScreenDest) + PCScreenBytesPerLine * 2);
33: }
34:
35: bScreenContentsChanged = true;
36: }
37:
38:
39: static void Line_ConvertMediumRes_640x16Bit_Spec(Uint32 *edi, Uint32 *ebp, Uint16 *esi, Uint32 eax)
40: {
41: Uint32 ebx, ecx, edx;
42: int x, Screen4BytesPerLine;
43: Uint32 pixelspace[5]; /* Workspace to store pixels to so can print in right order for Spec512 */
44:
45: /* on x86, unaligned access macro touches also
46: * next byte, zero it for code checkers
47: */
48: pixelspace[4] = 0;
49:
50: Spec512_StartScanLine(); /* Build up palettes for every 4 pixels, store in 'ScanLinePalettes' */
51: edx = 0; /* Clear index for loop */
52:
53: x = STScreenWidthBytes >> 2; /* Amount to draw across in 16-pixels (4 bytes) */
54: Screen4BytesPerLine = PCScreenBytesPerLine/2;
55:
56: do /* x-loop */
57: {
58: /* Do 16 pixels at one time */
59: ebx = *edi;
60:
61:
62: #if SDL_BYTEORDER == SDL_BIG_ENDIAN
63: /* Plot in 'right-order' on big endian systems */
64: MED_BUILD_PIXELS_0 ; /* Generate 'ecx' as pixels [12,13,14,15] */
65: pixelspace[3] = ecx;
66: MED_BUILD_PIXELS_1 ; /* Generate 'ecx' as pixels [4,5,6,7] */
67: pixelspace[1] = ecx;
68: MED_BUILD_PIXELS_2 ; /* Generate 'ecx' as pixels [8,9,10,11] */
69: pixelspace[2] = ecx;
70: MED_BUILD_PIXELS_3 ; /* Generate 'ecx' as pixels [0,1,2,3] */
71: pixelspace[0] = ecx;
72: #else
73: /* Plot in 'wrong-order', as ebx is 68000 endian */
74: MED_BUILD_PIXELS_0 ; /* Generate 'ecx' as pixels [4,5,6,7] */
75: pixelspace[1] = ecx;
76: MED_BUILD_PIXELS_1 ; /* Generate 'ecx' as pixels [12,13,14,15] */
77: pixelspace[3] = ecx;
78: MED_BUILD_PIXELS_2 ; /* Generate 'ecx' as pixels [0,1,2,3] */
79: pixelspace[0] = ecx;
80: MED_BUILD_PIXELS_3 ; /* Generate 'ecx' as pixels [8,9,10,11] */
81: pixelspace[2] = ecx;
82: #endif
83: /* And plot, the Spec512 is offset by 1 pixel and works on 'chunks' of 4 pixels */
84: /* So, we plot 1_4_4_4_3 to give 16 pixels, changing palette between */
85: /* (last one is used for first of next 16-pixels) */
86: /* NOTE : In med res, we display 16 pixels in 8 cycles, so palette should be */
87: /* updated every 8 pixels, not every 4 pixels (as in low res) */
88: ecx = pixelspace[0];
89: if (!bScrDoubleY) { PLOT_SPEC512_LEFT_MED_640_16BIT(0); }
90: else { PLOT_SPEC512_LEFT_MED_640_16BIT_DOUBLE_Y(0); }
91: // Spec512_UpdatePaletteSpan();
92:
93: ecx = GET_SPEC512_OFFSET_PIXELS(pixelspace, 1);
94: if (!bScrDoubleY) { PLOT_SPEC512_MID_MED_640_16BIT(1); }
95: else { PLOT_SPEC512_MID_MED_640_16BIT_DOUBLE_Y(1); }
96: Spec512_UpdatePaletteSpan();
97:
98: ecx = GET_SPEC512_OFFSET_PIXELS(pixelspace, 5);
99: if (!bScrDoubleY) { PLOT_SPEC512_MID_MED_640_16BIT(5); }
100: else { PLOT_SPEC512_MID_MED_640_16BIT_DOUBLE_Y(5); }
101: // Spec512_UpdatePaletteSpan();
102:
103: ecx = GET_SPEC512_OFFSET_PIXELS(pixelspace, 9);
104: if (!bScrDoubleY) { PLOT_SPEC512_MID_MED_640_16BIT(9); }
105: else { PLOT_SPEC512_MID_MED_640_16BIT_DOUBLE_Y(9); }
106: Spec512_UpdatePaletteSpan();
107:
108: ecx = GET_SPEC512_OFFSET_FINAL_PIXELS(pixelspace);
109: if (!bScrDoubleY) { PLOT_SPEC512_END_MED_640_16BIT(13); }
110: else { PLOT_SPEC512_END_MED_640_16BIT_DOUBLE_Y(13); }
111:
112: esi += 16; /* Next PC pixels */
113: edi += 1; /* Next ST pixels */
114: ebp += 1; /* Next ST copy pixels */
115: }
116: while (--x); /* Loop on X */
117:
118: Spec512_EndScanLine();
119: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.