--- hatari/src/convert/macros.h 2019/04/01 07:14:21 1.1.1.4 +++ hatari/src/convert/macros.h 2019/04/09 08:53:34 1.1.1.7 @@ -3,8 +3,8 @@ Lookup tables and macros for screen conversion routines. - This file is distributed under the GNU Public License, version 2 or at your - option any later version. Read the file gpl.txt for details. + This file is distributed under the GNU General Public License, version 2 + or at your option any later version. Read the file gpl.txt for details. */ #ifndef HATARI_CONVERTMACROS_H @@ -95,6 +95,15 @@ static const Uint32 Remap_1_Plane[16] = }; + +/*----------------------------------------------------------------------*/ +/* Macros to convert from Atari's planar mode to chunky mode + * (1 byte per pixel). Convert by blocks of 4 pixels. + * 16 low res pixels -> 4 planes of 16 bits + * 16 med res pixels -> 2 planes of 16 bits + * 16 hi res pixels -> 1 plane of 16 bits + */ + #define LOW_BUILD_PIXELS_0 \ { \ ebx &= 0x0f0f0f0f; \ @@ -175,6 +184,16 @@ static const Uint32 Remap_1_Plane[16] = } + +/*----------------------------------------------------------------------*/ +/* Macros to plot Atari's pixels in the emulator's buffer + * (the buffer can be 32, 16 or 8 bits per pixel) + */ + +/* + * 32 bit screen format + */ + /* Plot Low Resolution (320xH) 32-Bit pixels */ #define PLOT_LOW_320_32BIT(offset) \ { \ @@ -240,7 +259,7 @@ static const Uint32 Remap_1_Plane[16] = } /* Plot Spectrum512 Resolution (320xH) 32-Bit pixels */ -#define PLOT_SPEC512_MID_320_32BIT PLOT_MED_640_32BIT +#define PLOT_SPEC512_MID_320_32BIT PLOT_LOW_320_32BIT /* Plot Spectrum512 Resolution(320xH) 32-Bit pixels */ #define PLOT_SPEC512_END_LOW_320_32BIT(offset) \ @@ -275,10 +294,10 @@ static const Uint32 Remap_1_Plane[16] = esi[offset] = esi[offset+1] = STRGBPalette[ecx & 0x000000ff]; \ } -/* Plot Spectrum512 Resolution (640xH) 16-Bit pixels (Double on Y) */ +/* Plot Spectrum512 Resolution (640xH) 32-Bit pixels (Double on Y) */ #define PLOT_SPEC512_MID_640_32BIT_DOUBLE_Y PLOT_LOW_640_32BIT_DOUBLE_Y -/* Plot Spectrum512 Resolution (640xH) 16-Bit pixels (Double on Y) */ +/* Plot Spectrum512 Resolution (640xH) 32-Bit pixels (Double on Y) */ #define PLOT_SPEC512_END_LOW_640_32BIT_DOUBLE_Y(offset) \ { \ ebx = STRGBPalette[ecx & 0x000000ff]; \ @@ -293,6 +312,41 @@ static const Uint32 Remap_1_Plane[16] = } +/* Plot Spectrum512 Medium Resolution (640xH) 32-Bit pixels */ +#define PLOT_SPEC512_LEFT_MED_640_32BIT PLOT_SPEC512_LEFT_LOW_320_32BIT + +#define PLOT_SPEC512_MID_MED_640_32BIT PLOT_SPEC512_MID_320_32BIT + +#define PLOT_SPEC512_END_MED_640_32BIT PLOT_SPEC512_END_LOW_320_32BIT + + +/* Plot Spectrum512 Medium Resolution (640xH) 32-Bit pixels (Double on Y) */ +#define PLOT_SPEC512_LEFT_MED_640_32BIT_DOUBLE_Y(offset) \ +{ \ + esi[offset+Screen4BytesPerLine] = esi[offset] = STRGBPalette[ecx & 0x000000ff]; \ +} + +#define PLOT_SPEC512_MID_MED_640_32BIT_DOUBLE_Y(offset) \ +{ \ + esi[offset+0+Screen4BytesPerLine] = esi[offset+0] = STRGBPalette[ecx & 0x000000ff]; \ + esi[offset+1+Screen4BytesPerLine] = esi[offset+1] = STRGBPalette[(ecx >> 8) & 0x000000ff]; \ + esi[offset+2+Screen4BytesPerLine] = esi[offset+2] = STRGBPalette[(ecx >> 16) & 0x000000ff]; \ + esi[offset+3+Screen4BytesPerLine] = esi[offset+3] = STRGBPalette[(ecx >> 24) & 0x000000ff]; \ +} + +#define PLOT_SPEC512_END_MED_640_32BIT_DOUBLE_Y(offset) \ +{ \ + esi[offset+0+Screen4BytesPerLine] = esi[offset+0] = STRGBPalette[ecx & 0x000000ff]; \ + esi[offset+1+Screen4BytesPerLine] = esi[offset+1] = STRGBPalette[(ecx >> 8) & 0x000000ff]; \ + esi[offset+2+Screen4BytesPerLine] = esi[offset+2] = STRGBPalette[(ecx >> 16) & 0x000000ff]; \ +} + + + +/* + * 16 bit screen format + */ + /* Plot Low Resolution (320xH) 16-Bit pixels */ #define PLOT_LOW_320_16BIT(offset) \ { \ @@ -403,7 +457,7 @@ static const Uint32 Remap_1_Plane[16] = } /* Plot Spectrum512 Resolution(320xH) 16-Bit pixels */ -#define PLOT_SPEC512_MID_320_16BIT PLOT_MED_640_16BIT +#define PLOT_SPEC512_MID_320_16BIT PLOT_LOW_640_16BIT /* Plot Spectrum512 Resolution(320xH) 16-Bit pixels */ #define PLOT_SPEC512_END_LOW_320_16BIT(offset) \ @@ -452,9 +506,30 @@ static const Uint32 Remap_1_Plane[16] = esi[offset+2] = esi[offset+2+Screen4BytesPerLine] = ebx; \ } + +/* Plot Spectrum512 Medium Resolution (640xH) 16-Bit pixels */ +#define PLOT_SPEC512_LEFT_MED_640_16BIT PLOT_SPEC512_LEFT_LOW_320_16BIT + +#define PLOT_SPEC512_MID_MED_640_16BIT PLOT_SPEC512_MID_320_16BIT + +#define PLOT_SPEC512_END_MED_640_16BIT PLOT_SPEC512_END_LOW_320_16BIT + + +/* Plot Spectrum512 Medium Resolution (640xH) 16-Bit pixels (Double on Y) */ +#define PLOT_SPEC512_LEFT_MED_640_16BIT_DOUBLE_Y PLOT_SPEC512_LEFT_MED_640_32BIT_DOUBLE_Y + +#define PLOT_SPEC512_MID_MED_640_16BIT_DOUBLE_Y PLOT_SPEC512_MID_MED_640_32BIT_DOUBLE_Y + +#define PLOT_SPEC512_END_MED_640_16BIT_DOUBLE_Y PLOT_SPEC512_END_MED_640_32BIT_DOUBLE_Y + + + /* Get Spec512 pixels which are offset by 1 pixel */ #if defined(__i386__) // Unaligned direct access is only supported on i86 platforms +/* on AMD XP, first one is 1/3 faster than aligned access, and + * final pixels access ~15% faster than aligned operation below + */ # define GET_SPEC512_OFFSET_PIXELS(pixels, x) \ (*(Uint32 *)(((Uint8 *)pixels) + x)) # define GET_SPEC512_OFFSET_FINAL_PIXELS(pixels) \