--- hatari/src/convert/macros.h 2019/04/01 07:13:19 1.1.1.2 +++ hatari/src/convert/macros.h 2019/04/01 07:14:21 1.1.1.4 @@ -175,6 +175,124 @@ static const Uint32 Remap_1_Plane[16] = } +/* Plot Low Resolution (320xH) 32-Bit pixels */ +#define PLOT_LOW_320_32BIT(offset) \ +{ \ + esi[offset] = (Uint32)STRGBPalette[ecx & 0x00ff]; \ + esi[offset+1] = (Uint32)STRGBPalette[(ecx >> 8) & 0x00ff]; \ + esi[offset+2] = (Uint32)STRGBPalette[(ecx >> 16) & 0x00ff]; \ + esi[offset+3] = (Uint32)STRGBPalette[(ecx >> 24) & 0x00ff]; \ +} + +/* Plot Low Resolution (640xH) 32-Bit pixels */ +#define PLOT_LOW_640_32BIT(offset) \ +{ \ + esi[offset+0] = esi[offset+1] = STRGBPalette[ecx & 0x000000ff]; \ + esi[offset+2] = esi[offset+3] = STRGBPalette[(ecx >> 8) & 0x000000ff]; \ + esi[offset+4] = esi[offset+5] = STRGBPalette[(ecx >> 16) & 0x000000ff]; \ + esi[offset+6] = esi[offset+7] = STRGBPalette[(ecx >> 24) & 0x000000ff]; \ +} + +/* Plot Low Resolution (640xH) 16-Bit pixels (Double on Y) */ +#define PLOT_LOW_640_32BIT_DOUBLE_Y(offset) \ +{ \ + ebx = STRGBPalette[ecx & 0x000000ff]; \ + esi[offset+0] = esi[offset+1] = esi[offset+Screen4BytesPerLine+0] \ + = esi[offset+Screen4BytesPerLine+1] = ebx; \ + ebx = STRGBPalette[(ecx >> 8) & 0x000000ff]; \ + esi[offset+2] = esi[offset+3] = esi[offset+Screen4BytesPerLine+2] \ + = esi[offset+Screen4BytesPerLine+3] = ebx; \ + ebx = STRGBPalette[(ecx >> 16) & 0x000000ff]; \ + esi[offset+4] = esi[offset+5] = esi[offset+Screen4BytesPerLine+4] \ + = esi[offset+Screen4BytesPerLine+5] = ebx; \ + ebx = STRGBPalette[(ecx >> 24) & 0x000000ff]; \ + esi[offset+6] = esi[offset+7] = esi[offset+Screen4BytesPerLine+6] \ + = esi[offset+Screen4BytesPerLine+7] = ebx; \ +} + +/* Plot Medium Resolution(640xH) 32-Bit pixels */ +#define PLOT_MED_640_32BIT(offset) \ +{ \ + esi[offset+0] = STRGBPalette[ecx & 0x000000ff]; \ + esi[offset+1] = STRGBPalette[(ecx >> 8) & 0x000000ff]; \ + esi[offset+2] = STRGBPalette[(ecx >> 16) & 0x000000ff]; \ + esi[offset+3] = STRGBPalette[(ecx >> 24) & 0x000000ff]; \ +} + +/* Plot Medium Resolution(640xH) 32-Bit pixels (Double on Y) */ +#define PLOT_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]; \ +} + + +/* Plot Spectrum512 Resolution (320xH) 32-Bit pixels */ +#define PLOT_SPEC512_LEFT_LOW_320_32BIT(offset) \ +{ \ + esi[offset] = STRGBPalette[ecx & 0x000000ff]; \ +} + +/* Plot Spectrum512 Resolution (320xH) 32-Bit pixels */ +#define PLOT_SPEC512_MID_320_32BIT PLOT_MED_640_32BIT + +/* Plot Spectrum512 Resolution(320xH) 32-Bit pixels */ +#define PLOT_SPEC512_END_LOW_320_32BIT(offset) \ +{ \ + esi[offset] = STRGBPalette[ecx & 0x000000ff]; \ + esi[offset+1] = STRGBPalette[(ecx >> 8) & 0x000000ff]; \ + esi[offset+2] = STRGBPalette[(ecx >> 16) & 0x000000ff]; \ +} + + +/* Plot Spectrum512 Resolution (640xH) 32-Bit pixels */ +#define PLOT_SPEC512_LEFT_LOW_640_32BIT(offset) \ +{ \ + esi[offset] = esi[offset+1] = STRGBPalette[ecx & 0x000000ff]; \ +} + +/* Plot Spectrum512 Resolution (640xH) 32-Bit pixels */ +#define PLOT_SPEC512_MID_640_32BIT PLOT_LOW_640_32BIT + +/* Plot Spectrum512 Resolution (640xH) 32-Bit pixels */ +#define PLOT_SPEC512_END_LOW_640_32BIT(offset) \ +{ \ + esi[offset+0] = esi[offset+1] = STRGBPalette[ecx & 0x000000ff]; \ + esi[offset+2] = esi[offset+3] = STRGBPalette[(ecx >> 8) & 0x000000ff]; \ + esi[offset+4] = esi[offset+5] = STRGBPalette[(ecx >> 16) & 0x000000ff]; \ +} + +/* Plot Spectrum512 Resolution (640xH) 32-Bit pixels (Double on Y) */ +#define PLOT_SPEC512_LEFT_LOW_640_32BIT_DOUBLE_Y(offset) \ +{ \ + esi[offset+Screen4BytesPerLine] = esi[offset+Screen4BytesPerLine+1] = \ + esi[offset] = esi[offset+1] = STRGBPalette[ecx & 0x000000ff]; \ +} + +/* Plot Spectrum512 Resolution (640xH) 16-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) */ +#define PLOT_SPEC512_END_LOW_640_32BIT_DOUBLE_Y(offset) \ +{ \ + ebx = STRGBPalette[ecx & 0x000000ff]; \ + esi[offset+Screen4BytesPerLine] = esi[offset+Screen4BytesPerLine+1] \ + = esi[offset] = esi[offset+1] = ebx; \ + ebx = STRGBPalette[(ecx >> 8) & 0x000000ff]; \ + esi[offset+2+Screen4BytesPerLine] = esi[offset+3+Screen4BytesPerLine] \ + = esi[offset+2] = esi[offset+3] = ebx; \ + ebx = STRGBPalette[(ecx >> 16) & 0x000000ff]; \ + esi[offset+4+Screen4BytesPerLine] = esi[offset+5+Screen4BytesPerLine] \ + = esi[offset+4] = esi[offset+5] = ebx; \ +} + + /* Plot Low Resolution (320xH) 16-Bit pixels */ #define PLOT_LOW_320_16BIT(offset) \ { \ @@ -205,10 +323,10 @@ static const Uint32 Remap_1_Plane[16] = { \ ebpp = ecx + BASECOLOUR_LONG; \ ecx = ((ebpp & 0x0000ff00) << 8) | (ebpp & 0x000000ff); \ - esi[offset+PCScreenBytesPerLine/4] = \ + esi[offset+Screen4BytesPerLine] = \ esi[offset] = SDL_SwapLE32((ecx << 8) | ecx); \ ecx = ((ebpp & 0x00ff0000) >> 8) | (ebpp & 0xff000000); \ - esi[offset+1+PCScreenBytesPerLine/4] = \ + esi[offset+1+Screen4BytesPerLine] = \ esi[offset+1] = SDL_SwapLE32((ecx >> 8) | ecx); \ } @@ -225,13 +343,13 @@ static const Uint32 Remap_1_Plane[16] = #define PLOT_LOW_640_16BIT_DOUBLE_Y(offset) \ { \ ebx = STRGBPalette[ecx & 0x000000ff]; \ - esi[offset] = esi[offset+PCScreenBytesPerLine/4] = ebx; \ + esi[offset] = esi[offset+Screen4BytesPerLine] = ebx; \ ebx = STRGBPalette[(ecx >> 8) & 0x000000ff]; \ - esi[offset+1] = esi[offset+1+PCScreenBytesPerLine/4] = ebx; \ + esi[offset+1] = esi[offset+1+Screen4BytesPerLine] = ebx; \ ebx = STRGBPalette[(ecx >> 16) & 0x000000ff]; \ - esi[offset+2] = esi[offset+2+PCScreenBytesPerLine/4] = ebx; \ + esi[offset+2] = esi[offset+2+Screen4BytesPerLine] = ebx; \ ebx = STRGBPalette[(ecx >> 24) & 0x000000ff]; \ - esi[offset+3] = esi[offset+3+PCScreenBytesPerLine/4] = ebx; \ + esi[offset+3] = esi[offset+3+Screen4BytesPerLine] = ebx; \ } @@ -244,7 +362,7 @@ static const Uint32 Remap_1_Plane[16] = /* Plot Medium Resolution (640xH) 8-Bit pixels (Double on Y) */ #define PLOT_MED_640_8BIT_DOUBLE_Y(offset) \ { \ - esi[offset] = esi[offset+PCScreenBytesPerLine/4] =\ + esi[offset] = esi[offset+Screen4BytesPerLine] =\ SDL_SwapLE32(ecx + BASECOLOUR_LONG); \ } @@ -260,13 +378,13 @@ static const Uint32 Remap_1_Plane[16] = /* Plot Medium Resolution(640xH) 16-Bit pixels (Double on Y) */ #define PLOT_MED_640_16BIT_DOUBLE_Y(offset) \ { \ - esi[offset+PCScreenBytesPerLine/2] =\ + esi[offset+Screen2BytesPerLine] =\ esi[offset] = (Uint16)STRGBPalette[ecx & 0x000000ff]; \ - esi[offset+1+PCScreenBytesPerLine/2] =\ + esi[offset+1+Screen2BytesPerLine] =\ esi[offset+1] = (Uint16)STRGBPalette[(ecx >> 8) & 0x000000ff]; \ - esi[offset+2+PCScreenBytesPerLine/2] =\ + esi[offset+2+Screen2BytesPerLine] =\ esi[offset+2] = (Uint16)STRGBPalette[(ecx >> 16) & 0x000000ff]; \ - esi[offset+3+PCScreenBytesPerLine/2] =\ + esi[offset+3+Screen2BytesPerLine] =\ esi[offset+3] = (Uint16)STRGBPalette[(ecx >> 24) & 0x000000ff]; \ } @@ -316,7 +434,7 @@ static const Uint32 Remap_1_Plane[16] = /* Plot Spectrum512 Resolution (640xH) 16-Bit pixels (Double on Y) */ #define PLOT_SPEC512_LEFT_LOW_640_16BIT_DOUBLE_Y(offset) \ { \ - esi[offset+PCScreenBytesPerLine/4] = \ + esi[offset+Screen4BytesPerLine] = \ esi[offset] = STRGBPalette[ecx & 0x000000ff]; \ } @@ -327,11 +445,30 @@ static const Uint32 Remap_1_Plane[16] = #define PLOT_SPEC512_END_LOW_640_16BIT_DOUBLE_Y(offset) \ { \ ebx = STRGBPalette[ecx & 0x000000ff]; \ - esi[offset] = esi[offset+PCScreenBytesPerLine/4] = ebx; \ + esi[offset] = esi[offset+Screen4BytesPerLine] = ebx; \ ebx = STRGBPalette[(ecx >> 8) & 0x000000ff]; \ - esi[offset+1] = esi[offset+1+PCScreenBytesPerLine/4] = ebx; \ + esi[offset+1] = esi[offset+1+Screen4BytesPerLine] = ebx; \ ebx = STRGBPalette[(ecx >> 16) & 0x000000ff]; \ - esi[offset+2] = esi[offset+2+PCScreenBytesPerLine/4] = ebx; \ + esi[offset+2] = esi[offset+2+Screen4BytesPerLine] = ebx; \ } +/* Get Spec512 pixels which are offset by 1 pixel */ +#if defined(__i386__) // Unaligned direct access is only supported on i86 platforms + +# define GET_SPEC512_OFFSET_PIXELS(pixels, x) \ + (*(Uint32 *)(((Uint8 *)pixels) + x)) +# define GET_SPEC512_OFFSET_FINAL_PIXELS(pixels) \ + (*(Uint32 *)(((Uint8 *)pixels) + 13)) + +#else + +# define GET_SPEC512_OFFSET_PIXELS(pixels, x) \ + (((*(Uint32 *)(((Uint8 *)pixels) + x-1)) >> 8) \ + | ((*(Uint32 *)(((Uint8 *)pixels) + x+3)) << 24)) +# define GET_SPEC512_OFFSET_FINAL_PIXELS(pixels) \ + ((*(Uint32 *)(((Uint8 *)pixels) + 12)) >> 8) + +#endif /* __i386__ */ + + #endif /* HATARI_CONVERTMACROS_H */