UbixOS V2  2.0
objgfx30.h
Go to the documentation of this file.
1 /*-
2  * Copyright (c) 2002-2018 The UbixOS Project.
3  * All rights reserved.
4  *
5  * This was developed by Christopher W. Olsen for the UbixOS Project.
6  *
7  * Redistribution and use in source and binary forms, with or without modification, are permitted
8  * provided that the following conditions are met:
9  *
10  * 1) Redistributions of source code must retain the above copyright notice, this list of
11  * conditions, the following disclaimer and the list of authors.
12  * 2) Redistributions in binary form must reproduce the above copyright notice, this list of
13  * conditions, the following disclaimer and the list of authors in the documentation and/or
14  * other materials provided with the distribution.
15  * 3) Neither the name of the UbixOS Project nor the names of its contributors may be used to
16  * endorse or promote products derived from this software without specific prior written
17  * permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
20  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
24  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 /*
30  * objgfx30.h
31  *
32  * Created on: Jan 12, 2018
33  * Author: cwolsen
34  */
35 
36 #ifndef SYS_INCLUDE_OBJGFX_OBJGFX30_H_
37 #define SYS_INCLUDE_OBJGFX_OBJGFX30_H_
38 
39 #include <stdlib.h> // for NULL
40 
41 #define RadToDeg 180.0/3.14159265358979;
42 
43 typedef signed char Int8;
44 typedef signed short int Int16;
45 typedef signed long int Int32;
46 
47 typedef unsigned char uInt8;
48 typedef unsigned short int uInt16;
49 typedef unsigned long int uInt32;
50 
53 };
54 
55 typedef struct {
59 } TRGB;
60 
61 typedef struct {
66 } TRGBA;
67 
68 typedef struct {
76  void* BankSwitch;
78  uInt16 xRes, yRes;
88  // Direct colour fields (required for Direct/6 and YUV/7 memory models
98  // VESA 2.0 specific fields
102  uInt8 paddington[461];
103 } TMode_Rec;
104 
105 typedef struct {
106  char VBESignature[4];
109  char * OEMStringPtr;
113  // VESA 2.0 specific fields
118  uInt8 paddington[474];
119 } TVESA_Rec;
120 
121 typedef struct {
124 } TPoint;
125 
126 typedef struct {
136 } TPixelFmt;
137 
138 // Default pixel formats
139 
140 const TPixelFmt NULL_PIXFMT = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
141 const TPixelFmt DEF_PIXFMT_8BPP = { 8, 0, 0, 0, 0, 0, 0, 0, 0 };
142 const TPixelFmt DEF_PIXFMT_15BPP = { 15, 10, 5, 0, 15, 5, 5, 5, 1 };
143 const TPixelFmt DEF_PIXFMT_16BPP = { 16, 11, 5, 0, 0, 5, 6, 5, 0 };
144 const TPixelFmt DEF_PIXFMT_24BPP = { 24, 16, 8, 0, 8, 8, 8 };
145 const TPixelFmt DEF_PIXFMT_32BPP = { 32, 16, 8, 0, 24, 8, 8, 8, 8 };
146 const TPixelFmt DEF_MAC_PIXFMT_16BPP = { 16, 8, 4, 0, 12, 4, 4, 4, 4 };
147 
148 #include "defpal.inc"
149 
150 class TGfx0 {
151  protected:
155  uInt32 bSize; // buffer size (in bytes)
156  uInt32 lSize; // LineOfs size (in bytes)
159  uInt8 BPP; // bits per pixel
168  bool AntiAlias;
169  bool clipLine(Int32&, Int32&, Int32&, Int32&);
172  public:
173  void* Buffer;
176  TGfx0(void);
177  bool ogAlias(TGfx0&, uInt32, uInt32, uInt32, uInt32);
179  void ogBSpline(uInt32, TPoint*, uInt32, uInt32);
180  void ogCircle(Int32, Int32, uInt32, uInt32);
181  void ogClear(uInt32);
182  bool ogClone(TGfx0&);
183  void ogCopy(TGfx0&);
193  bool ogGetAntiAlias(void);
194  uInt8 ogGetBPP(void);
196  uInt32 ogGetMaxX(void);
197  uInt32 ogGetMaxY(void);
198  void ogGetPal(void);
199  void ogGetPixFmt(TPixelFmt&);
202  void ogHFlip(void);
203  void ogHLine(Int32, Int32, Int32, uInt32);
204  void ogLine(Int32, Int32, Int32, Int32, uInt32);
205  void ogLoadPal(const char *);
206  void ogPolygon(uInt32, TPoint*, uInt32);
207  void ogRect(Int32, Int32, Int32, Int32, uInt32);
209  void ogSavePal(const char *);
211  bool ogSetAntiAlias(bool);
212  void ogSetPixel(uInt32, uInt32, uInt32);
215  void ogSpline(uInt32, TPoint*, uInt32, uInt32);
217  void ogUnpackRGB(uInt32, uInt8&, uInt8&, uInt8&);
218  void ogVFlip(void);
219  void ogVLine(Int32, Int32, Int32, uInt32);
220  ~TGfx0(void);
221 };
222 // TGfx0
223 
224 class TScreen: public TGfx0 {
225  protected:
229  public:
230  TScreen(void);
231  void setupMode(uInt16);
232  ~TScreen(void);
233 };
234 // TScreen
235 
236 #endif /* END SYS_INCLUDE_OBJGFX_OBJGFX30_H_ */
TMode_Rec::BankSize
uInt8 BankSize
Definition: objgfx30.h:85
TGfx0::DataState
ogDataState DataState
Definition: objgfx30.h:158
TVESA_Rec::OEMStringPtr
char * OEMStringPtr
Definition: objgfx30.h:109
TMode_Rec::Reserved
uInt8 Reserved
Definition: objgfx30.h:87
TGfx0::ogVFlip
void ogVFlip(void)
TVESA_Rec::minVersion
uInt8 minVersion
Definition: objgfx30.h:107
TMode_Rec::Granularity
uInt16 Granularity
Definition: objgfx30.h:72
TVESA_Rec
Definition: objgfx30.h:105
TGfx0::ogBSpline
void ogBSpline(uInt32, TPoint *, uInt32, uInt32)
TScreen::InGraphics
bool InGraphics
Definition: objgfx30.h:228
TRGBA
Definition: objgfx30.h:61
TGfx0::ogFillConvexPolygon
void ogFillConvexPolygon(uInt32, TPoint *, uInt32)
TGfx0::ogFillPolygon
void ogFillPolygon(uInt32, TPoint *, uInt32)
TMode_Rec::BlueMaskSize
uInt8 BlueMaskSize
Definition: objgfx30.h:93
TPixelFmt::BlueMaskSize
uInt8 BlueMaskSize
Definition: objgfx30.h:134
TGfx0::GreenShifter
uInt8 GreenShifter
Definition: objgfx30.h:165
ogNONE
Definition: objgfx30.h:52
TGfx0::ogSavePal
void ogSavePal(const char *)
uInt32
unsigned long int uInt32
Definition: objgfx30.h:49
TScreen::setupMode
void setupMode(uInt16)
TGfx0::ogGetMaxX
uInt32 ogGetMaxX(void)
TScreen::ModeRec
TMode_Rec * ModeRec
Definition: objgfx30.h:227
TGfx0::ogGetPal
void ogGetPal(void)
TMode_Rec::NumberOfBanks
uInt8 NumberOfBanks
Definition: objgfx30.h:83
DEF_PIXFMT_32BPP
const TPixelFmt DEF_PIXFMT_32BPP
Definition: objgfx30.h:145
Int8
signed char Int8
Definition: objgfx30.h:43
uInt16
unsigned short int uInt16
Definition: objgfx30.h:48
TRGB::blue
uInt8 blue
Definition: objgfx30.h:58
TRGB::green
uInt8 green
Definition: objgfx30.h:57
TPoint::y
Int32 y
Definition: objgfx30.h:123
TRGBA::red
uInt8 red
Definition: objgfx30.h:62
TGfx0::ogSetPixel
void ogSetPixel(uInt32, uInt32, uInt32)
TScreen::TScreen
TScreen(void)
TGfx0::ogVLine
void ogVLine(Int32, Int32, Int32, uInt32)
TMode_Rec::WindowSize
uInt16 WindowSize
Definition: objgfx30.h:73
ogALIASING
Definition: objgfx30.h:52
TGfx0::RedFieldPosition
uInt8 RedFieldPosition
Definition: objgfx30.h:160
TScreen::~TScreen
~TScreen(void)
TGfx0::ogArc
void ogArc(Int32, Int32, uInt32, uInt32, uInt32, uInt32)
DEF_MAC_PIXFMT_16BPP
const TPixelFmt DEF_MAC_PIXFMT_16BPP
Definition: objgfx30.h:146
TRGBA::alpha
uInt8 alpha
Definition: objgfx30.h:65
TRGB
Definition: objgfx30.h:55
TGfx0::ogClone
bool ogClone(TGfx0 &)
TGfx0::ogTriangle
void ogTriangle(Int32, Int32, Int32, Int32, Int32, Int32, uInt32)
TGfx0::GreenFieldPosition
uInt8 GreenFieldPosition
Definition: objgfx30.h:161
TGfx0::ogFillTriangle
void ogFillTriangle(Int32, Int32, Int32, Int32, Int32, Int32, uInt32)
TPixelFmt::GreenMaskSize
uInt8 GreenMaskSize
Definition: objgfx30.h:133
TMode_Rec::ModeAttributes
uInt16 ModeAttributes
Definition: objgfx30.h:69
TGfx0::ogAlias
bool ogAlias(TGfx0 &, uInt32, uInt32, uInt32, uInt32)
TGfx0::ogCurve
void ogCurve(Int32, Int32, Int32, Int32, Int32, Int32, uInt32, uInt32)
TMode_Rec::NumOfImagePages
uInt8 NumOfImagePages
Definition: objgfx30.h:86
TGfx0::Owner
TGfx0 * Owner
Definition: objgfx30.h:152
TGfx0::ogClear
void ogClear(uInt32)
TMode_Rec::BlueFieldPosition
uInt8 BlueFieldPosition
Definition: objgfx30.h:94
TMode_Rec::NumBitPlanes
uInt8 NumBitPlanes
Definition: objgfx30.h:81
TGfx0::aaRawLine
void aaRawLine(uInt32, uInt32, uInt32, uInt32, uInt32)
TGfx0::MaxY
uInt32 MaxY
Definition: objgfx30.h:154
TGfx0::ogRGB
uInt32 ogRGB(uInt8, uInt8, uInt8)
TMode_Rec::RedFieldPosition
uInt8 RedFieldPosition
Definition: objgfx30.h:90
TGfx0::ogCreate
bool ogCreate(uInt32, uInt32, TPixelFmt)
TPixelFmt
Definition: objgfx30.h:126
TGfx0::RedShifter
uInt8 RedShifter
Definition: objgfx30.h:164
TGfx0::ogGetBPP
uInt8 ogGetBPP(void)
TGfx0::ogFillRect
void ogFillRect(Int32, Int32, Int32, Int32, uInt32)
TGfx0::TransparentColor
uInt32 TransparentColor
Definition: objgfx30.h:157
TGfx0::ogGetPixFmt
void ogGetPixFmt(TPixelFmt &)
TGfx0::ogGetDataState
ogDataState ogGetDataState(void)
TGfx0::ogGetMaxY
uInt32 ogGetMaxY(void)
TGfx0::ogCircle
void ogCircle(Int32, Int32, uInt32, uInt32)
TVESA_Rec::OEMVendorNamePtr
char * OEMVendorNamePtr
Definition: objgfx30.h:115
TGfx0::BPP
uInt8 BPP
Definition: objgfx30.h:159
TGfx0::ogPolygon
void ogPolygon(uInt32, TPoint *, uInt32)
TGfx0::ogSetTransparentColor
uInt32 ogSetTransparentColor(uInt32)
TRGB::red
uInt8 red
Definition: objgfx30.h:56
TGfx0::ogSpline
void ogSpline(uInt32, TPoint *, uInt32, uInt32)
TGfx0::BlueShifter
uInt8 BlueShifter
Definition: objgfx30.h:166
TGfx0::ogSetAntiAlias
bool ogSetAntiAlias(bool)
uInt8
unsigned char uInt8
Definition: objgfx30.h:47
DEF_PIXFMT_24BPP
const TPixelFmt DEF_PIXFMT_24BPP
Definition: objgfx30.h:144
Int32
signed long int Int32
Definition: objgfx30.h:45
TMode_Rec::BitsPerPixel
uInt8 BitsPerPixel
Definition: objgfx30.h:82
TRGBA::green
uInt8 green
Definition: objgfx30.h:63
TGfx0::TGfx0
TGfx0(void)
TMode_Rec::yRes
uInt16 yRes
Definition: objgfx30.h:78
TMode_Rec::MemoryModel
uInt8 MemoryModel
Definition: objgfx30.h:84
TGfx0::ogCopy
void ogCopy(TGfx0 &)
TPixelFmt::RedMaskSize
uInt8 RedMaskSize
Definition: objgfx30.h:132
TGfx0::yRes
uInt32 yRes
Definition: objgfx30.h:153
TGfx0::ogFillCircle
void ogFillCircle(Int32, Int32, uInt32, uInt32)
TGfx0::AntiAlias
bool AntiAlias
Definition: objgfx30.h:168
TGfx0
Definition: objgfx30.h:150
TPixelFmt::AlphaMaskSize
uInt8 AlphaMaskSize
Definition: objgfx30.h:135
TGfx0::xRes
uInt32 xRes
Definition: objgfx30.h:153
TGfx0::pal
TRGB * pal
Definition: objgfx30.h:175
TGfx0::MaxX
uInt32 MaxX
Definition: objgfx30.h:154
TMode_Rec::BytesPerLine
uInt16 BytesPerLine
Definition: objgfx30.h:77
TMode_Rec::WindowASeg
uInt16 WindowASeg
Definition: objgfx30.h:74
TGfx0::ogHLine
void ogHLine(Int32, Int32, Int32, uInt32)
TVESA_Rec::VideoModePtr
uInt16 * VideoModePtr
Definition: objgfx30.h:111
TScreen::VESARec
TVESA_Rec * VESARec
Definition: objgfx30.h:226
TPoint::x
Int32 x
Definition: objgfx30.h:122
TGfx0::LineOfs
uInt32 * LineOfs
Definition: objgfx30.h:174
TMode_Rec::OffScreenMemSize
uInt16 OffScreenMemSize
Definition: objgfx30.h:101
TRGBA::blue
uInt8 blue
Definition: objgfx30.h:64
TScreen
Definition: objgfx30.h:224
TGfx0::uInt8AlphaShifter
uInt8AlphaShifter
Definition: objgfx30.h:167
TGfx0::BlueFieldPosition
uInt8 BlueFieldPosition
Definition: objgfx30.h:162
TGfx0::ogScaleBuf
void ogScaleBuf(Int32, Int32, Int32, Int32, TGfx0 &, Int32, Int32, Int32, Int32)
TPixelFmt::BPP
uInt8 BPP
Definition: objgfx30.h:127
TGfx0::ogSetRGBPalette
void ogSetRGBPalette(uInt8, uInt8, uInt8, uInt8)
TMode_Rec::DirectColourMode
uInt8 DirectColourMode
Definition: objgfx30.h:97
TVESA_Rec::OEMProductRevPtr
char * OEMProductRevPtr
Definition: objgfx30.h:117
TGfx0::uInt8AlphaFieldPosition
uInt8AlphaFieldPosition
Definition: objgfx30.h:163
TMode_Rec::WindowBSeg
uInt16 WindowBSeg
Definition: objgfx30.h:75
DEF_PIXFMT_16BPP
const TPixelFmt DEF_PIXFMT_16BPP
Definition: objgfx30.h:143
TGfx0::ogCopyBuf
void ogCopyBuf(Int32, Int32, TGfx0 &, Int32, Int32, Int32, Int32)
TMode_Rec::CharWidth
uInt8 CharWidth
Definition: objgfx30.h:79
TGfx0::lSize
uInt32 lSize
Definition: objgfx30.h:156
DEF_PIXFMT_8BPP
const TPixelFmt DEF_PIXFMT_8BPP
Definition: objgfx30.h:141
TGfx0::bSize
uInt32 bSize
Definition: objgfx30.h:155
TPixelFmt::AlphaFieldPosition
uInt8 AlphaFieldPosition
Definition: objgfx30.h:131
TMode_Rec::RedMaskSize
uInt8 RedMaskSize
Definition: objgfx30.h:89
TMode_Rec
Definition: objgfx30.h:68
TGfx0::clipLine
bool clipLine(Int32 &, Int32 &, Int32 &, Int32 &)
TGfx0::ogLine
void ogLine(Int32, Int32, Int32, Int32, uInt32)
TVESA_Rec::OEMSoftwareRev
uInt16 OEMSoftwareRev
Definition: objgfx30.h:114
TPixelFmt::RedFieldPosition
uInt8 RedFieldPosition
Definition: objgfx30.h:128
ogDataState
ogDataState
Definition: objgfx30.h:51
TGfx0::ogCubicBezierCurve
void ogCubicBezierCurve(Int32, Int32, Int32, Int32, Int32, Int32, Int32, Int32, uInt32, uInt32)
TVESA_Rec::majVersion
uInt8 majVersion
Definition: objgfx30.h:108
TPoint
Definition: objgfx30.h:121
TMode_Rec::WindowAFlags
uInt8 WindowAFlags
Definition: objgfx30.h:70
TGfx0::ogLoadPal
void ogLoadPal(const char *)
ogOWNER
Definition: objgfx30.h:52
TMode_Rec::GreenFieldPosition
uInt8 GreenFieldPosition
Definition: objgfx30.h:92
TMode_Rec::WindowBFlags
uInt8 WindowBFlags
Definition: objgfx30.h:71
TGfx0::ogHFlip
void ogHFlip(void)
TVESA_Rec::OEMProductNamePtr
char * OEMProductNamePtr
Definition: objgfx30.h:116
TGfx0::ogRect
void ogRect(Int32, Int32, Int32, Int32, uInt32)
TGfx0::ogGetTransparentColor
uInt32 ogGetTransparentColor(void)
TMode_Rec::BankSwitch
void * BankSwitch
Definition: objgfx30.h:76
TMode_Rec::AlphaMaskSize
uInt8 AlphaMaskSize
Definition: objgfx30.h:95
NULL_PIXFMT
const TPixelFmt NULL_PIXFMT
Definition: objgfx30.h:140
TGfx0::ogGetPixel
uInt32 ogGetPixel(Int32, Int32)
TGfx0::rawLine
void rawLine(uInt32, uInt32, uInt32, uInt32, uInt32)
TMode_Rec::AlphaFieldPosition
uInt8 AlphaFieldPosition
Definition: objgfx30.h:96
DEF_PIXFMT_15BPP
const TPixelFmt DEF_PIXFMT_15BPP
Definition: objgfx30.h:142
TGfx0::ogUnpackRGB
void ogUnpackRGB(uInt32, uInt8 &, uInt8 &, uInt8 &)
TGfx0::Buffer
void * Buffer
Definition: objgfx30.h:173
TMode_Rec::OffScreenMemOffset
void * OffScreenMemOffset
Definition: objgfx30.h:100
TPixelFmt::GreenFieldPosition
uInt8 GreenFieldPosition
Definition: objgfx30.h:129
Int16
signed short int Int16
Definition: objgfx30.h:44
TMode_Rec::CharHeight
uInt8 CharHeight
Definition: objgfx30.h:80
TMode_Rec::GreenMaskSize
uInt8 GreenMaskSize
Definition: objgfx30.h:91
TGfx0::~TGfx0
~TGfx0(void)
TMode_Rec::PhysBasePtr
uInt32 PhysBasePtr
Definition: objgfx30.h:99
TVESA_Rec::Capabilities
uInt32 Capabilities
Definition: objgfx30.h:110
TVESA_Rec::TotalMemory
uInt16 TotalMemory
Definition: objgfx30.h:112
TGfx0::ogGetAntiAlias
bool ogGetAntiAlias(void)
TPixelFmt::BlueFieldPosition
uInt8 BlueFieldPosition
Definition: objgfx30.h:130