Annotation of hatari/src/convert/spec640x16.c, revision 1.1.1.2

1.1.1.2 ! root        1: /*
        !             2:   Hatari - spec640x18.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 640x16Bit
        !             8: */
1.1       root        9: 
                     10: 
                     11: void ConvertSpec512_640x16Bit(void)
                     12: {
1.1.1.2 ! root       13:   Uint32 *edi, *ebp;
        !            14:   Uint32 *esi;
        !            15:   register Uint32 eax, ebx, ecx, edx;
        !            16: 
        !            17:   Spec512_StartFrame();                 /* Start frame, track palettes */
        !            18: 
        !            19:   edx = 0;                              /* Clear index for loop */
        !            20:   ScrY = STScreenStartHorizLine;        /* Starting line in ST screen */
        !            21: 
        !            22:   do      /* y-loop */
        !            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[ScrY] + STScreenLeftSkipBytes;  /* Offset for this line + Amount to skip on left hand side */
        !            30:     edi = (Uint32 *)((Uint8 *)pSTScreen + eax);        /* ST format screen 4-plane 16 colours */
        !            31:     ebp = (Uint32 *)((Uint8 *)pSTScreenCopy + eax);    /* Previous ST format screen */
        !            32:     esi = (Uint32 *)pPCScreenDest;                     /* PC format screen */
        !            33: 
        !            34:     ScrX = 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);
        !            40: 
        !            41: #if SDL_BYTEORDER == SDL_LIL_ENDIAN
        !            42: 
        !            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:       PixelWorkspace[1] = ecx;
        !            46:       LOW_BUILD_PIXELS_1 ;              /* Generate 'ecx' as pixels [12,13,14,15] */
        !            47:       PixelWorkspace[3] = ecx;
        !            48:       LOW_BUILD_PIXELS_2 ;              /* Generate 'ecx' as pixels [0,1,2,3] */
        !            49:       PixelWorkspace[0] = ecx;
        !            50:       LOW_BUILD_PIXELS_3 ;              /* Generate 'ecx' as pixels [8,9,10,11] */
        !            51:       PixelWorkspace[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:       if(!bScrDoubleY)                  /* Double on Y? */
        !            57:       {
        !            58:         ecx = PixelWorkspace[0];
        !            59:         PLOT_SPEC512_LEFT_LOW_640_16BIT(0) ;
        !            60:         Spec512_UpdatePaletteSpan();
        !            61: 
        !            62:         ecx = *(Uint32 *)( ((Uint8 *)PixelWorkspace)+1 );
        !            63:         PLOT_SPEC512_MID_640_16BIT(1) ;
        !            64:         Spec512_UpdatePaletteSpan();
        !            65: 
        !            66:         ecx = *(Uint32 *)( ((Uint8 *)PixelWorkspace)+5 );
        !            67:         PLOT_SPEC512_MID_640_16BIT(5) ;
        !            68:         Spec512_UpdatePaletteSpan();
        !            69: 
        !            70:         ecx = *(Uint32 *)( ((Uint8 *)PixelWorkspace)+9 );
        !            71:         PLOT_SPEC512_MID_640_16BIT(9) ;
        !            72:         Spec512_UpdatePaletteSpan();
        !            73: 
        !            74:         ecx = *(Uint32 *)( ((Uint8 *)PixelWorkspace)+13 );
        !            75:         PLOT_SPEC512_END_LOW_640_16BIT(13) ;
        !            76:       }
        !            77:       else
        !            78:       {
        !            79:         ecx = PixelWorkspace[0];
        !            80:         PLOT_SPEC512_LEFT_LOW_640_16BIT_DOUBLE_Y(0) ;
        !            81:         Spec512_UpdatePaletteSpan();
        !            82: 
        !            83:         ecx = *(Uint32 *)( ((Uint8 *)PixelWorkspace)+1 );
        !            84:         PLOT_SPEC512_MID_640_16BIT_DOUBLE_Y(1) ;
        !            85:         Spec512_UpdatePaletteSpan();
        !            86: 
        !            87:         ecx = *(Uint32 *)( ((Uint8 *)PixelWorkspace)+5 );
        !            88:         PLOT_SPEC512_MID_640_16BIT_DOUBLE_Y(5) ;
        !            89:         Spec512_UpdatePaletteSpan();
        !            90: 
        !            91:         ecx = *(Uint32 *)( ((Uint8 *)PixelWorkspace)+9 );
        !            92:         PLOT_SPEC512_MID_640_16BIT_DOUBLE_Y(9) ;
        !            93:         Spec512_UpdatePaletteSpan();
        !            94: 
        !            95:         ecx = *(Uint32 *)( ((Uint8 *)PixelWorkspace)+13 );
        !            96:         PLOT_SPEC512_END_LOW_640_16BIT_DOUBLE_Y(13) ;
        !            97:       }
        !            98: 
        !            99: #else
        !           100:       /* Well, I didn't get the code above working on big-endian  machines, too,
        !           101:          But I hope the following lines are good enough to do the job... */
        !           102: 
        !           103:       LOW_BUILD_PIXELS_0 ;
        !           104:       PixelWorkspace[3] = ecx;
        !           105:       LOW_BUILD_PIXELS_1 ;
        !           106:       PixelWorkspace[1] = ecx;
        !           107:       LOW_BUILD_PIXELS_2 ;
        !           108:       PixelWorkspace[2] = ecx;
        !           109:       LOW_BUILD_PIXELS_3 ;
        !           110:       PixelWorkspace[0] = ecx;
        !           111: 
        !           112:       if(!bScrDoubleY)                  /* Double on Y? */
        !           113:       {
        !           114:         ecx = PixelWorkspace[0];
        !           115:         PLOT_SPEC512_MID_640_16BIT(0) ;
        !           116:         Spec512_UpdatePaletteSpan();
        !           117: 
        !           118:         ecx = PixelWorkspace[1];
        !           119:         PLOT_SPEC512_MID_640_16BIT(4) ;
        !           120:         Spec512_UpdatePaletteSpan();
        !           121: 
        !           122:         ecx = PixelWorkspace[2];
        !           123:         PLOT_SPEC512_MID_640_16BIT(8) ;
        !           124:         Spec512_UpdatePaletteSpan();
        !           125: 
        !           126:         ecx = PixelWorkspace[3];
        !           127:         PLOT_SPEC512_MID_640_16BIT(12) ;
        !           128:         Spec512_UpdatePaletteSpan();
        !           129:       }
        !           130:       else
        !           131:       {
        !           132:         ecx = PixelWorkspace[0];
        !           133:         PLOT_SPEC512_MID_640_16BIT_DOUBLE_Y(0) ;
        !           134:         Spec512_UpdatePaletteSpan();
        !           135: 
        !           136:         ecx = PixelWorkspace[1];
        !           137:         PLOT_SPEC512_MID_640_16BIT_DOUBLE_Y(4) ;
        !           138:         Spec512_UpdatePaletteSpan();
        !           139: 
        !           140:         ecx = PixelWorkspace[2];
        !           141:         PLOT_SPEC512_MID_640_16BIT_DOUBLE_Y(8) ;
        !           142:         Spec512_UpdatePaletteSpan();
        !           143: 
        !           144:         ecx = PixelWorkspace[3];
        !           145:         PLOT_SPEC512_MID_640_16BIT_DOUBLE_Y(12) ;
        !           146:         Spec512_UpdatePaletteSpan();
        !           147:       }
        !           148: 
        !           149: #endif
        !           150: 
        !           151:       esi += 16;                        /* Next PC pixels */
        !           152:       edi += 2;                         /* Next ST pixels */
        !           153:       ebp += 2;                         /* Next ST copy pixels */
        !           154:     }
        !           155:     while(--ScrX);                      /* Loop on X */
        !           156: 
        !           157:     Spec512_EndScanLine();
        !           158: 
        !           159:     /* Offset to next line: */
        !           160:     pPCScreenDest = (void *)(((unsigned char *)pPCScreenDest)+2*PCScreenBytesPerLine);
        !           161:     ScrY += 1;
1.1       root      162:   }
1.1.1.2 ! root      163:   while(ScrY < STScreenEndHorizLine);   /* Loop on Y */
1.1       root      164: 
1.1.1.2 ! root      165:   bScreenContentsChanged = TRUE;
1.1       root      166: }
                    167: 

unix.superglobalmegacorp.com

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