|
|
1.1 root 1: /*
2: Hatari - low640x16_spec.c
3:
1.1.1.2 root 4: This file is distributed under the GNU General Public License, version 2
5: or at your option any later version. Read the file gpl.txt for details.
1.1 root 6:
7: Screen conversion, Low Res Spec512 to 640x16Bit
8: */
9:
10: static void ConvertLowRes_640x16Bit_Spec(void)
11: {
12: Uint32 *edi, *ebp;
13: Uint32 *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 = (Uint32 *)pPCScreenDest; /* PC format screen */
25:
26: Line_ConvertLowRes_640x16Bit_Spec(edi, ebp, esi, eax);
27:
28: /* Offset to next line (double on Y) */
29: pPCScreenDest = (((Uint8 *)pPCScreenDest) + PCScreenBytesPerLine * 2);
30: }
31:
32: bScreenContentsChanged = true;
33: }
34:
35:
36: static void Line_ConvertLowRes_640x16Bit_Spec(Uint32 *edi, Uint32 *ebp, Uint32 *esi, Uint32 eax)
37: {
38: Uint32 ebx, ecx, edx;
39: int x, Screen4BytesPerLine;
40: Uint32 pixelspace[5]; /* Workspace to store pixels to so can print in right order for Spec512 */
41:
42: /* on x86, unaligned access macro touches also
43: * next byte, zero it for code checkers
44: */
45: pixelspace[4] = 0;
46:
47: Spec512_StartScanLine(); /* Build up palettes for every 4 pixels, store in 'ScanLinePalettes' */
48:
49: x = STScreenWidthBytes >> 3; /* Amount to draw across in 16-pixels (8 bytes) */
50: Screen4BytesPerLine = PCScreenBytesPerLine/4;
51:
52: do /* x-loop */
53: {
54: ebx = *edi; /* Do 16 pixels at one time */
55: ecx = *(edi+1);
56:
57: #if SDL_BYTEORDER == SDL_BIG_ENDIAN
58: /* Convert planes to byte indices - as works in wrong order store to workspace so can read back in order! */
59: LOW_BUILD_PIXELS_0 ; /* Generate 'ecx' as pixels [12,13,14,15] */
60: pixelspace[3] = ecx;
61: LOW_BUILD_PIXELS_1 ; /* Generate 'ecx' as pixels [4,5,6,7] */
62: pixelspace[1] = ecx;
63: LOW_BUILD_PIXELS_2 ; /* Generate 'ecx' as pixels [8,9,10,11] */
64: pixelspace[2] = ecx;
65: LOW_BUILD_PIXELS_3 ; /* Generate 'ecx' as pixels [0,1,2,3] */
66: pixelspace[0] = ecx;
67: #else
68: LOW_BUILD_PIXELS_0 ; /* Generate 'ecx' as pixels [4,5,6,7] */
69: pixelspace[1] = ecx;
70: LOW_BUILD_PIXELS_1 ; /* Generate 'ecx' as pixels [12,13,14,15] */
71: pixelspace[3] = ecx;
72: LOW_BUILD_PIXELS_2 ; /* Generate 'ecx' as pixels [0,1,2,3] */
73: pixelspace[0] = ecx;
74: LOW_BUILD_PIXELS_3 ; /* Generate 'ecx' as pixels [8,9,10,11] */
75: pixelspace[2] = ecx;
76: #endif
77: /* And plot, the Spec512 is offset by 1 pixel and works on 'chunks' of 4 pixels */
78: /* So, we plot 1_4_4_4_3 to give 16 pixels, changing palette between */
79: /* (last one is used for first of next 16-pixels) */
80: if (!bScrDoubleY) /* Double on Y? */
81: {
82: ecx = pixelspace[0];
83: PLOT_SPEC512_LEFT_LOW_640_16BIT(0);
84: Spec512_UpdatePaletteSpan();
85:
86: ecx = GET_SPEC512_OFFSET_PIXELS(pixelspace, 1);
87: PLOT_SPEC512_MID_640_16BIT(1);
88: Spec512_UpdatePaletteSpan();
89:
90: ecx = GET_SPEC512_OFFSET_PIXELS(pixelspace, 5);
91: PLOT_SPEC512_MID_640_16BIT(5);
92: Spec512_UpdatePaletteSpan();
93:
94: ecx = GET_SPEC512_OFFSET_PIXELS(pixelspace, 9);
95: PLOT_SPEC512_MID_640_16BIT(9);
96: Spec512_UpdatePaletteSpan();
97:
98: ecx = GET_SPEC512_OFFSET_FINAL_PIXELS(pixelspace);
99: PLOT_SPEC512_END_LOW_640_16BIT(13);
100: }
101: else
102: {
103: ecx = pixelspace[0];
104: PLOT_SPEC512_LEFT_LOW_640_16BIT_DOUBLE_Y(0);
105: Spec512_UpdatePaletteSpan();
106:
107: ecx = GET_SPEC512_OFFSET_PIXELS(pixelspace, 1);
108: PLOT_SPEC512_MID_640_16BIT_DOUBLE_Y(1);
109: Spec512_UpdatePaletteSpan();
110:
111: ecx = GET_SPEC512_OFFSET_PIXELS(pixelspace, 5);
112: PLOT_SPEC512_MID_640_16BIT_DOUBLE_Y(5);
113: Spec512_UpdatePaletteSpan();
114:
115: ecx = GET_SPEC512_OFFSET_PIXELS(pixelspace, 9);
116: PLOT_SPEC512_MID_640_16BIT_DOUBLE_Y(9);
117: Spec512_UpdatePaletteSpan();
118:
119: ecx = GET_SPEC512_OFFSET_FINAL_PIXELS(pixelspace);
120: PLOT_SPEC512_END_LOW_640_16BIT_DOUBLE_Y(13);
121: }
122:
123: esi += 16; /* Next PC pixels */
124: edi += 2; /* Next ST pixels */
125: ebp += 2; /* Next ST copy pixels */
126: }
127: while (--x); /* Loop on X */
128:
129: Spec512_EndScanLine();
130: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.