Annotation of hatari/src/convert/spec320x16.c, revision 1.1.1.7

1.1.1.7 ! root        1: /*
        !             2:   Hatari - spec320x16.c
1.1       root        3: 
1.1.1.7 ! root        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.
1.1.1.2   root        6: 
1.1.1.7 ! root        7:   Screen Conversion, Spec512 to 320x16Bit
        !             8: */
1.1       root        9: 
1.1.1.7 ! root       10: static void ConvertSpec512_320x16Bit(void)
        !            11: {
        !            12:        Uint32 *edi, *ebp;
        !            13:        Uint16 *esi;
        !            14:        Uint32 eax, ebx, ecx, edx;
        !            15:        Uint32 pixelspace[4]; /* Workspace to store pixels to so can print in right order for Spec512 */
        !            16:        int y, x;
        !            17: 
        !            18:        Spec512_StartFrame();            /* Start frame, track palettes */
        !            19: 
        !            20:        edx = 0;                         /* Clear index for loop */
        !            21: 
        !            22:        for (y = STScreenStartHorizLine; y < STScreenEndHorizLine; y++)
        !            23:        {
        !            24: 
        !            25:                Spec512_StartScanLine();        /* Build up palettes for every 4 pixels, store in 'ScanLinePalettes' */
        !            26:                edx = 0;                        /* Clear index for loop */
        !            27: 
        !            28:                /* Get screen addresses, 'edi'-ST screen, 'ebp'-Previous ST screen, 'esi'-PC screen */
        !            29:                eax = STScreenLineOffset[y] + STScreenLeftSkipBytes;  /* Offset for this line + Amount to skip on left hand side */
        !            30:                edi = (Uint32 *)((Uint8 *)pSTScreen + eax);       /* ST format screen 4-plane 16 colors */
        !            31:                ebp = (Uint32 *)((Uint8 *)pSTScreenCopy + eax);   /* Previous ST format screen */
        !            32:                esi = (Uint16 *)pPCScreenDest;                    /* PC format screen */
        !            33: 
        !            34:                x = STScreenWidthBytes >> 3;    /* Amount to draw across in 16-pixels (8 bytes) */
        !            35: 
        !            36:                do  /* x-loop */
        !            37:                {
        !            38:                        ebx = *edi;                 /* Do 16 pixels at one time */
        !            39:                        ecx = *(edi+1);
1.1       root       40: 
1.1.1.4   root       41: #if SDL_BYTEORDER == SDL_LIL_ENDIAN
                     42: 
1.1.1.7 ! root       43:                        /* Convert planes to byte indices - as works in wrong order store to workspace so can read back in order! */
        !            44:                        LOW_BUILD_PIXELS_0 ;        /* Generate 'ecx' as pixels [4,5,6,7] */
        !            45:                        pixelspace[1] = ecx;
        !            46:                        LOW_BUILD_PIXELS_1 ;        /* Generate 'ecx' as pixels [12,13,14,15] */
        !            47:                        pixelspace[3] = ecx;
        !            48:                        LOW_BUILD_PIXELS_2 ;        /* Generate 'ecx' as pixels [0,1,2,3] */
        !            49:                        pixelspace[0] = ecx;
        !            50:                        LOW_BUILD_PIXELS_3 ;        /* Generate 'ecx' as pixels [8,9,10,11] */
        !            51:                        pixelspace[2] = ecx;
        !            52: 
        !            53:                        /* And plot, the Spec512 is offset by 1 pixel and works on 'chunks' of 4 pixels */
        !            54:                        /* So, we plot 1_4_4_3 to give 16 pixels, changing palette between */
        !            55:                        /* (last one is used for first of next 16-pixels) */
        !            56:                        ecx = pixelspace[0];
        !            57:                        PLOT_SPEC512_LEFT_LOW_320_16BIT(0) ;
        !            58:                        Spec512_UpdatePaletteSpan();
        !            59: 
        !            60:                        ecx = *(Uint32 *)(((Uint8 *)pixelspace) + 1);
        !            61:                        PLOT_SPEC512_MID_320_16BIT(1) ;
        !            62:                        Spec512_UpdatePaletteSpan();
        !            63: 
        !            64:                        ecx = *(Uint32 *)(((Uint8 *)pixelspace) + 5);
        !            65:                        PLOT_SPEC512_MID_320_16BIT(5) ;
        !            66:                        Spec512_UpdatePaletteSpan();
        !            67: 
        !            68:                        ecx = *(Uint32 *)(((Uint8 *)pixelspace) + 9);
        !            69:                        PLOT_SPEC512_MID_320_16BIT(9) ;
        !            70:                        Spec512_UpdatePaletteSpan();
1.1.1.3   root       71: 
1.1.1.7 ! root       72:                        ecx = *(Uint32 *)(((Uint8 *)pixelspace) + 13);
        !            73:                        PLOT_SPEC512_END_LOW_320_16BIT(13) ;
1.1.1.3   root       74: 
1.1.1.4   root       75: #else
                     76: 
1.1.1.7 ! root       77:                        LOW_BUILD_PIXELS_0 ;
        !            78:                        pixelspace[3] = ecx;
        !            79:                        LOW_BUILD_PIXELS_1 ;
        !            80:                        pixelspace[1] = ecx;
        !            81:                        LOW_BUILD_PIXELS_2 ;
        !            82:                        pixelspace[2] = ecx;
        !            83:                        LOW_BUILD_PIXELS_3 ;
        !            84:                        pixelspace[0] = ecx;
        !            85: 
        !            86:                        ecx = pixelspace[0];
        !            87:                        PLOT_SPEC512_LEFT_LOW_320_16BIT(0);
        !            88:                        Spec512_UpdatePaletteSpan();
        !            89: 
        !            90:                        ecx = (pixelspace[0] >> 8) | (((Uint8)pixelspace[1])<<24);
        !            91:                        PLOT_SPEC512_MID_320_16BIT(1);
        !            92:                        Spec512_UpdatePaletteSpan();
        !            93: 
        !            94:                        ecx = (pixelspace[1] >> 8) | (((Uint8)pixelspace[2])<<24);
        !            95:                        PLOT_SPEC512_MID_320_16BIT(5);
        !            96:                        Spec512_UpdatePaletteSpan();
        !            97: 
        !            98:                        ecx = (pixelspace[2] >> 8) | (((Uint8)pixelspace[3])<<24);
        !            99:                        PLOT_SPEC512_MID_320_16BIT(9);
        !           100:                        Spec512_UpdatePaletteSpan();
        !           101: 
        !           102:                        ecx = (pixelspace[3] >> 8);
        !           103:                        PLOT_SPEC512_END_LOW_320_16BIT(13);
1.1.1.4   root      104: 
                    105: #endif
                    106: 
1.1.1.7 ! root      107:                        esi += 16;                  /* Next PC pixels */
        !           108:                        edi += 2;                   /* Next ST pixels */
        !           109:                        ebp += 2;                   /* Next ST copy pixels */
        !           110:                }
        !           111:                while (--x);                    /* Loop on X */
        !           112: 
        !           113:                Spec512_EndScanLine();
        !           114: 
        !           115:                /* Offset to next line */
        !           116:                pPCScreenDest = (((Uint8 *)pPCScreenDest) + PCScreenBytesPerLine);
        !           117:        }
1.1.1.2   root      118: 
1.1.1.7 ! root      119:        bScreenContentsChanged = TRUE;
1.1       root      120: }

unix.superglobalmegacorp.com

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