Annotation of hatari/src/convert/spec640x32.c, revision 1.1.1.1

1.1       root        1: /*
                      2:   Hatari - spec640x32.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, Spec512 to 640xH 32-Bit
                      8: */
                      9: 
                     10: 
                     11: static void ConvertSpec512_640x32Bit(void)
                     12: {
                     13:        Uint32 *edi, *ebp;
                     14:        Uint32 *esi;
                     15:        Uint32 eax, ebx, ecx, edx;
                     16:        Uint32 pixelspace[4]; /* Workspace to store pixels to so can print in right order for Spec512 */
                     17:        int y, x, Screen4BytesPerLine;
                     18: 
                     19:        Spec512_StartFrame();                     /* Start frame, track palettes */
                     20:        Screen4BytesPerLine = PCScreenBytesPerLine / 4;
                     21:        edx = 0;                                  /* Clear index for loop */
                     22: 
                     23:        for (y = STScreenStartHorizLine; y < STScreenEndHorizLine; y++)
                     24:        {
                     25: 
                     26:                Spec512_StartScanLine();        /* Build up palettes for every 4 pixels, store in 'ScanLinePalettes' */
                     27:                edx = 0;                        /* Clear index for loop */
                     28: 
                     29:                /* Get screen addresses, 'edi'-ST screen, 'ebp'-Previous ST screen, 'esi'-PC screen */
                     30:                eax = STScreenLineOffset[y] + STScreenLeftSkipBytes;  /* Offset for this line + Amount to skip on left hand side */
                     31:                edi = (Uint32 *)((Uint8 *)pSTScreen + eax);        /* ST format screen 4-plane 16 colors */
                     32:                ebp = (Uint32 *)((Uint8 *)pSTScreenCopy + eax);    /* Previous ST format screen */
                     33:                esi = (Uint32 *)pPCScreenDest;                     /* PC format screen */
                     34: 
                     35:                x = STScreenWidthBytes >> 3;    /* Amount to draw across in 16-pixels (8 bytes) */
                     36: 
                     37:                do  /* x-loop */
                     38:                {
                     39:                        ebx = *edi;                 /* Do 16 pixels at one time */
                     40:                        ecx = *(edi+1);
                     41: 
                     42: #if SDL_BYTEORDER == SDL_LIL_ENDIAN
                     43: 
                     44:                        /* Convert planes to byte indices - as works in wrong order store to workspace so can read back in order! */
                     45:                        LOW_BUILD_PIXELS_0 ;        /* Generate 'ecx' as pixels [4,5,6,7] */
                     46:                        pixelspace[1] = ecx;
                     47:                        LOW_BUILD_PIXELS_1 ;        /* Generate 'ecx' as pixels [12,13,14,15] */
                     48:                        pixelspace[3] = ecx;
                     49:                        LOW_BUILD_PIXELS_2 ;        /* Generate 'ecx' as pixels [0,1,2,3] */
                     50:                        pixelspace[0] = ecx;
                     51:                        LOW_BUILD_PIXELS_3 ;        /* Generate 'ecx' as pixels [8,9,10,11] */
                     52:                        pixelspace[2] = ecx;
                     53: 
                     54:                        /* And plot, the Spec512 is offset by 1 pixel and works on 'chunks' of 4 pixels */
                     55:                        /* So, we plot 1_4_4_3 to give 16 pixels, changing palette between */
                     56:                        /* (last one is used for first of next 16-pixels) */
                     57:                        if (!bScrDoubleY)           /* Double on Y? */
                     58:                        {
                     59:                                ecx = pixelspace[0];
                     60:                                PLOT_SPEC512_LEFT_LOW_640_32BIT(0);
                     61:                                Spec512_UpdatePaletteSpan();
                     62: 
                     63:                                ecx = *(Uint32 *)(((Uint8 *)pixelspace) + 1);
                     64:                                PLOT_SPEC512_MID_640_32BIT(2);
                     65:                                Spec512_UpdatePaletteSpan();
                     66: 
                     67:                                ecx = *(Uint32 *)(((Uint8 *)pixelspace) + 5);
                     68:                                PLOT_SPEC512_MID_640_32BIT(10);
                     69:                                Spec512_UpdatePaletteSpan();
                     70: 
                     71:                                ecx = *(Uint32 *)(((Uint8 *)pixelspace) + 9);
                     72:                                PLOT_SPEC512_MID_640_32BIT(18);
                     73:                                Spec512_UpdatePaletteSpan();
                     74: 
                     75:                                ecx = *(Uint32 *)(((Uint8 *)pixelspace) + 13);
                     76:                                PLOT_SPEC512_END_LOW_640_32BIT(26);
                     77:                        }
                     78:                        else
                     79:                        {
                     80:                                ecx = pixelspace[0];
                     81:                                PLOT_SPEC512_LEFT_LOW_640_32BIT_DOUBLE_Y(0);
                     82:                                Spec512_UpdatePaletteSpan();
                     83: 
                     84:                                ecx = *(Uint32 *)(((Uint8 *)pixelspace) + 1);
                     85:                                PLOT_SPEC512_MID_640_32BIT_DOUBLE_Y(2);
                     86:                                Spec512_UpdatePaletteSpan();
                     87: 
                     88:                                ecx = *(Uint32 *)(((Uint8 *)pixelspace) + 5);
                     89:                                PLOT_SPEC512_MID_640_32BIT_DOUBLE_Y(10) ;
                     90:                                Spec512_UpdatePaletteSpan();
                     91: 
                     92:                                ecx = *(Uint32 *)(((Uint8 *)pixelspace) + 9);
                     93:                                PLOT_SPEC512_MID_640_32BIT_DOUBLE_Y(18);
                     94:                                Spec512_UpdatePaletteSpan();
                     95: 
                     96:                                ecx = *(Uint32 *)(((Uint8 *)pixelspace) + 13);
                     97:                                PLOT_SPEC512_END_LOW_640_32BIT_DOUBLE_Y(26);
                     98:                        }
                     99: 
                    100: #else
                    101: 
                    102:                        LOW_BUILD_PIXELS_0 ;
                    103:                        pixelspace[3] = ecx;
                    104:                        LOW_BUILD_PIXELS_1 ;
                    105:                        pixelspace[1] = ecx;
                    106:                        LOW_BUILD_PIXELS_2 ;
                    107:                        pixelspace[2] = ecx;
                    108:                        LOW_BUILD_PIXELS_3 ;
                    109:                        pixelspace[0] = ecx;
                    110: 
                    111:                        if (!bScrDoubleY)           /* Double on Y? */
                    112:                        {
                    113:                                ecx = pixelspace[0];
                    114:                                PLOT_SPEC512_LEFT_LOW_640_32BIT(0);
                    115:                                Spec512_UpdatePaletteSpan();
                    116: 
                    117:                                ecx = (pixelspace[0] >> 8) | (((Uint8)pixelspace[1])<<24);
                    118:                                PLOT_SPEC512_MID_640_32BIT(2);
                    119:                                Spec512_UpdatePaletteSpan();
                    120: 
                    121:                                ecx = (pixelspace[1] >> 8) | (((Uint8)pixelspace[2])<<24);
                    122:                                PLOT_SPEC512_MID_640_32BIT(10);
                    123:                                Spec512_UpdatePaletteSpan();
                    124: 
                    125:                                ecx = (pixelspace[2] >> 8) | (((Uint8)pixelspace[3])<<24);
                    126:                                PLOT_SPEC512_MID_640_32BIT(18);
                    127:                                Spec512_UpdatePaletteSpan();
                    128: 
                    129:                                ecx = (pixelspace[3] >> 8);
                    130:                                PLOT_SPEC512_END_LOW_640_32BIT(26);
                    131:                        }
                    132:                        else
                    133:                        {
                    134:                                ecx = pixelspace[0];
                    135:                                PLOT_SPEC512_LEFT_LOW_640_32BIT_DOUBLE_Y(0);
                    136:                                Spec512_UpdatePaletteSpan();
                    137: 
                    138:                                ecx = (pixelspace[0] >> 8) | (((Uint8)pixelspace[1])<<24);
                    139:                                PLOT_SPEC512_MID_640_32BIT_DOUBLE_Y(2);
                    140:                                Spec512_UpdatePaletteSpan();
                    141: 
                    142:                                ecx = (pixelspace[1] >> 8) | (((Uint8)pixelspace[2])<<24);
                    143:                                PLOT_SPEC512_MID_640_32BIT_DOUBLE_Y(10);
                    144:                                Spec512_UpdatePaletteSpan();
                    145: 
                    146:                                ecx = (pixelspace[2] >> 8) | (((Uint8)pixelspace[3])<<24);
                    147:                                PLOT_SPEC512_MID_640_32BIT_DOUBLE_Y(18);
                    148:                                Spec512_UpdatePaletteSpan();
                    149: 
                    150:                                ecx = (pixelspace[3] >> 8);
                    151:                                PLOT_SPEC512_END_LOW_640_32BIT_DOUBLE_Y(26);
                    152:                        }
                    153: 
                    154: #endif
                    155: 
                    156:                        esi += 32;                  /* Next PC pixels */
                    157:                        edi += 2;                   /* Next ST pixels */
                    158:                        ebp += 2;                   /* Next ST copy pixels */
                    159:                }
                    160:                while (--x);                    /* Loop on X */
                    161: 
                    162:                Spec512_EndScanLine();
                    163: 
                    164:                /* Offset to next line: */
                    165:                pPCScreenDest = (((Uint8 *)pPCScreenDest)+2*PCScreenBytesPerLine);
                    166:        }
                    167: 
                    168:        bScreenContentsChanged = TRUE;
                    169: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.