1 #pragma once
2 
3 #include "../stdint.hpp"
4 #include "../globals.hpp"
5 
6 #include <SDL.h>
7 
8 // Abstract Rendering Class
9 class RenderBase
10 {
11 public:
12     RenderBase();
13 
14     virtual bool init(int src_width, int src_height,
15                       int scale,
16                       int video_mode,
17                       int scanlines)          = 0;
18     virtual void disable()                    = 0;
19     virtual bool start_frame()                = 0;
20     virtual bool finalize_frame()             = 0;
21     virtual void draw_frame(uint16_t* pixels) = 0;
22     void convert_palette(uint32_t adr, uint32_t r1, uint32_t g1, uint32_t b1);
23     void set_shadow_intensity(float f);
supports_window()24     virtual bool supports_window() { return true; }
supports_vsync()25     virtual bool supports_vsync() { return false; }
26 
27 protected:
28 	SDL_Surface *surface;
29 
30     // Palette Lookup
31     uint32_t rgb[S16_PALETTE_ENTRIES * 2];    // Extended to hold shadow colours
32 
33     uint32_t *screen_pixels;
34 
35     // Original Screen Width & Height
36     uint16_t orig_width, orig_height;
37 
38     // --------------------------------------------------------------------------------------------
39     // Screen setup properties. Example below:
40     // ________________________
41     // |  |                |  | <- screen size      (e.g. 1280 x 720)
42     // |  |                |  |
43     // |  |                |<-|--- destination size (e.g. 1027 x 720) to maintain aspect ratio
44     // |  |                |  |
45     // |  |                |  |    source size      (e.g. 320  x 224) System 16 proportions
46     // |__|________________|__|
47     //
48     // --------------------------------------------------------------------------------------------
49 
50     // Source texture / pixel array that we are going to manipulate
51     int src_width, src_height;
52 
53     // Destination window width and height
54     int dst_width, dst_height;
55 
56     // Screen width and height
57     int scn_width, scn_height;
58 
59     // Full-Screen, Stretch, Window
60     int video_mode;
61 
62     // Scanline density. 0 = Off, 1 = Full
63     int scanlines;
64 
65     // Screen Scale
66     int scale;
67 
68     // Offsets (for full-screen mode, where x/y resolution isn't a multiple of the original height)
69     uint32_t screen_xoff, screen_yoff;
70 
71     // SDL Pixel Format Codes. These differ between platforms.
72     uint8_t  Rshift, Gshift, Bshift;
73     uint32_t Rmask, Gmask, Bmask;
74 
75     // Shadow intensity multiplier
76     int shadow_multi;
77 
78     bool sdl_screen_size();
79 };