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

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

unix.superglobalmegacorp.com

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