--- hatari/src/includes/screen.h 2019/04/01 07:13:05 1.1.1.10 +++ hatari/src/includes/screen.h 2019/04/09 08:49:29 1.1.1.13 @@ -11,54 +11,61 @@ #include /* for SDL_Surface */ -/* Assumes 32 pixels left+right */ -#define SCREENBYTES_LEFT 16 /* Bytes for left border in ST screen */ -#define SCREENBYTES_MIDDLE 160 /* Middle (320 pixels) */ -#define SCREENBYTES_RIGHT 16 /* right border */ +/* The 'screen' is a representation of the ST video memory */ +/* taking into account all the border tricks. Data are stored */ +/* in 'planar' format (1 word per plane) and are then converted */ +/* to an SDL buffer that will be displayed. */ +/* So, all video lines are converted to a unique line of */ +/* SCREENBYTES_LINE bytes in planar format. */ +/* SCREENBYTES_LINE should always be a multiple of 8. */ + +/* left/right borders must be multiple of 8 bytes */ +#define SCREENBYTES_LEFT (nBorderPixelsLeft/2) /* Bytes for left border */ +#define SCREENBYTES_MIDDLE 160 /* Middle (320 pixels) */ +#define SCREENBYTES_RIGHT (nBorderPixelsRight/2) /* Right border */ #define SCREENBYTES_LINE (SCREENBYTES_LEFT+SCREENBYTES_MIDDLE+SCREENBYTES_RIGHT) #define SCREENBYTES_MONOLINE 80 /* Byte per line in ST-high resolution */ /* Overscan values */ -#define OVERSCAN_LEFT (SCREENBYTES_LEFT*2) /* Number of pixels in each border */ -#define OVERSCAN_RIGHT (SCREENBYTES_RIGHT*2) -#define OVERSCAN_TOP 29 -#define OVERSCAN_BOTTOM 47 +#define OVERSCAN_TOP 29 +#define MAX_OVERSCAN_BOTTOM 47 /* number of bottom lines to display on screen */ /* Number of visible screen lines including top/bottom borders */ -#define NUM_VISIBLE_LINES (OVERSCAN_TOP+200+OVERSCAN_BOTTOM) +#define NUM_VISIBLE_LINES (OVERSCAN_TOP+200+MAX_OVERSCAN_BOTTOM) + +/* 1x16 colour palette per screen line, +1 line as may write after line 200 */ +#define HBL_PALETTE_LINES ((NUM_VISIBLE_LINES+1)*16) +/* Bit mask of palette colours changes, top bit set is resolution change */ +#define HBL_PALETTE_MASKS (NUM_VISIBLE_LINES+1) /* Frame buffer, used to store details in screen conversion */ typedef struct { - Uint16 HBLPalettes[(NUM_VISIBLE_LINES+1)*16]; /* 1x16 colour palette per screen line, +1 line as may write after line 200 */ - Uint32 HBLPaletteMasks[NUM_VISIBLE_LINES+1]; /* Bit mask of palette colours changes, top bit set is resolution change */ + Uint16 HBLPalettes[HBL_PALETTE_LINES]; + Uint32 HBLPaletteMasks[HBL_PALETTE_MASKS]; Uint8 *pSTScreen; /* Copy of screen built up during frame (copy each line on HBL to simulate monitor raster) */ Uint8 *pSTScreenCopy; /* Previous frames copy of above */ int OverscanModeCopy; /* Previous screen overscan mode */ - BOOL bFullUpdate; /* Set TRUE to cause full update on next draw */ + bool bFullUpdate; /* Set TRUE to cause full update on next draw */ } FRAMEBUFFER; /* Number of frame buffers (1 or 2) - should be 2 for supporting screen flipping */ #define NUM_FRAMEBUFFERS 2 -/* ST Resolution defines */ +/* ST/TT resolution defines */ enum { ST_LOW_RES, ST_MEDIUM_RES, ST_HIGH_RES, - ST_LOWMEDIUM_MIX_RES -}; - -/* Update Palette defines */ -enum -{ - UPDATE_PALETTE_NONE, - UPDATE_PALETTE_UPDATE, - UPDATE_PALETTE_FULLUPDATE + TT_MEDIUM_RES = 4, + TT_HIGH_RES = 6, + TT_LOW_RES }; +#define ST_MEDIUM_RES_BIT 0x1 +#define ST_RES_MASK 0x3 /* Palette mask values for 'HBLPaletteMask[]' */ #define PALETTEMASK_RESOLUTION 0x00040000 @@ -76,22 +83,10 @@ enum OVERSCANMODE_BOTTOM /* 0x02 (Top+Bottom) 0x03 */ }; -/* Available fullscreen modes */ -#define NUM_DISPLAYMODEOPTIONS 6 -enum -{ - DISPLAYMODE_LOWCOL_LOWRES, /* low color, low resolution (fastest) */ - DISPLAYMODE_LOWCOL_HIGHRES, /* low color, zoomed resolution */ - DISPLAYMODE_LOWCOL_DUMMY, /* unused */ - DISPLAYMODE_HICOL_LOWRES, /* high color, low resolution */ - DISPLAYMODE_HICOL_HIGHRES, /* high color, zoomed resolution (slowest) */ - DISPLAYMODE_HICOL_DUMMY /* unused */ -}; - - -extern BOOL bGrabMouse; -extern BOOL bInFullScreen; -extern int STRes,PrevSTRes; +extern bool bGrabMouse; +extern bool bInFullScreen; +extern int nScreenZoomX, nScreenZoomY; +extern int nBorderPixelsLeft, nBorderPixelsRight; extern int STScreenStartHorizLine; extern int STScreenLeftSkipBytes; extern FRAMEBUFFER *pFrameBuffer; @@ -106,7 +101,7 @@ extern void Screen_Reset(void); extern void Screen_SetFullUpdate(void); extern void Screen_EnterFullScreen(void); extern void Screen_ReturnFromFullScreen(void); -extern void Screen_DidResolutionChange(void); -extern void Screen_Draw(void); +extern void Screen_ModeChanged(void); +extern bool Screen_Draw(void); #endif /* ifndef HATARI_SCREEN_H */