aboutsummaryrefslogtreecommitdiff
path: root/arch/casiowin/monochromelib/include/monochrome.h
blob: 92cb3599d112c291b488aa4bfe863fd759a5c27f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/* ****************************************************************************
 * monochrome.h -- MonochromeLib's main header.
 * Copyright (C) 2011 Pierre "PierrotLL" Le Gall <legallpierre89@gmail.com>
 * Copyright (C) 2016-2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
 *
 * This file is part of the 'casiowin/monochromelib' module,
 * in libcarrot, an experimental modular libc project.
 *
 * This file is free software: you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation, either version 3 of the License, or (at your option)
 * any later version.
 *
 * This file is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Lesser Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this file.  If not, see <http://www.gnu.org/licenses/>.
 * ************************************************************************* */
#include <cdefs.h>
#include <stdlib.h>
__BEGIN_DECLS

/* ************************************************************************* */
/*  Constants                                                                */
/* ************************************************************************* */
/* Screen dimensions */
#define ML_SCREEN_WIDTH  128
#define ML_SCREEN_HEIGHT 64

/* Contrast */
#define ML_CONTRAST_MIN    130
#define ML_CONTRAST_NORMAL 168
#define ML_CONTRAST_MAX    190

/* Colors */
typedef enum __ML_Color {
	ML_TRANSPARENT = -1,
	ML_WHITE       =  0,
	ML_BLACK       =  1,
	ML_XOR         =  2,
	ML_CHECKER     =  3,
} ML_Color;
/* ************************************************************************* */
/*  Main functions                                                           */
/* ************************************************************************* */
/* Get the VRAM address */
extern char *ML_vram_address _OF((void)) __THROW;
#define ML_vram_adress() ML_vram_address()

/* Interact with the VRAM */
extern void ML_clear_vram   _OF((void)) __THROW;
extern void ML_clear_screen _OF((void)) __THROW;
extern void ML_display_vram _OF((void)) __THROW;

/* Set the contrast */
extern void                ML_set_contrast _OF((unsigned char __contrast))
	__THROW;
extern __wur unsigned char ML_get_contrast _OF((void)) __THROW;

/* Interact with a pixel in the VRAM */
extern void ML_pixel _OF((int __x, int __y, ML_Color __color)) __THROW;
extern void ML_point _OF((int __x, int __y, int __width, ML_Color __color))
	__THROW;
extern __wur ML_Color ML_pixel_test _OF((int __x, int __y)) __THROW;

/* Draw a line in the VRAM */
extern void ML_line            _OF((int __x1, int __y1, int __x2, int __y2,
	ML_Color __color)) __THROW;
extern void ML_horizontal_line _OF((int __y, int __x1, int __x2,
	ML_Color __color)) __THROW;
extern void ML_vertical_line   _OF((int __x, int __y1, int __y2,
	ML_Color __color)) __THROW;

/* Draw a rectangle */
extern void ML_rectangle _OF((int __x1, int __y1, int __x2, int __y2,
	int __border_width, ML_Color __border_color, ML_Color __fill_color))
	__THROW;

/* Draw a polygon */
extern void ML_polygon        _OF((const int *__x, const int *__y,
	int __nb_vertices, ML_Color __color)) __THROW;
extern void ML_filled_polygon _OF((const int *__x, const int *__y,
	int __nb_vertices, ML_Color __color)) __THROW;

/* Draw a circle */
extern void ML_circle        _OF((int __x, int __y, int __radius,
	ML_Color __color)) __THROW;
extern void ML_filled_circle _OF((int __x, int __y, int __radius,
	ML_Color __color)) __THROW;

/* Draw an ellipse */
extern void ML_ellipse         _OF((int __x, int __y, int __radius1,
	int __radius2, ML_Color __color)) __THROW;
extern void ML_ellipse_in_rect _OF((int __x1, int __y1, int __x2, int __y2,
	ML_Color __color)) __THROW;

extern void ML_filled_ellipse         _OF((int __x, int __y, int __radius1,
	int __radius2, ML_Color __color)) __THROW;
extern void ML_filled_ellipse_in_rect _OF((int __x, int __y, int __radius1,
	int __radius2, ML_Color __color)) __THROW;

/* Scroll the screen */
extern void ML_horizontal_scroll _OF((int __scroll)) __THROW;
extern void ML_vertical_scroll   _OF((int __scroll)) __THROW;

/* Draw a BMP */
extern __nonnull(1, __bmp)
void ML_bmp_or  _OF((const unsigned char __bmp[__notnull], int __x,
	int __y, int __width, int __height)) __THROW;
extern __nonnull(1, __bmp)
void ML_bmp_and _OF((const unsigned char __bmp[__notnull], int __x,
	int __y, int __width, int __height)) __THROW;
extern __nonnull(1, __bmp)
void ML_bmp_xor _OF((const unsigned char __bmp[__notnull], int __x,
	int __y, int __width, int __height)) __THROW;

extern __nonnull(1, __bmp)
void ML_bmp_or_cl  _OF((const unsigned char __bmp[__notnull], int __x,
	int __y, int __width, int __height)) __THROW;
extern __nonnull(1, __bmp)
void ML_bmp_and_cl _OF((const unsigned char __bmp[__notnull], int __x,
	int __y, int __width, int __height)) __THROW;
extern __nonnull(1, __bmp)
void ML_bmp_xor_cl _OF((const unsigned char __bmp[__notnull], int __x,
	int __y, int __width, int __height)) __THROW;

/* Draw a 8x8 BMP */
extern __nonnull(1, __bmp)
void ML_bmp_8_or  _OF((const unsigned char __bmp[__notnull], int __x,
	int __y)) __THROW;
extern __nonnull(1, __bmp)
void ML_bmp_8_and _OF((const unsigned char __bmp[__notnull], int __x,
	int __y)) __THROW;
extern __nonnull(1, __bmp)
void ML_bmp_8_xor _OF((const unsigned char __bmp[__notnull], int __x,
	int __y)) __THROW;

extern __nonnull(1, __bmp)
void ML_bmp_8_or_cl  _OF((const unsigned char __bmp[__notnull], int __x,
	int __y)) __THROW;
extern __nonnull(1, __bmp)
void ML_bmp_8_and_cl _OF((const unsigned char __bmp[__notnull], int __x,
	int __y)) __THROW;
extern __nonnull(1, __bmp)
void ML_bmp_8_xor_cl _OF((const unsigned char __bmp[__notnull], int __x,
	int __y)) __THROW;

/* Draw a 16x16 BMP */
extern __nonnull(1, __bmp)
void ML_bmp_16_or  _OF((const unsigned short __bmp[__notnull], int __x,
	int __y)) __THROW;
extern __nonnull(1, __bmp)
void ML_bmp_16_and _OF((const unsigned short __bmp[__notnull], int __x,
	int __y)) __THROW;
extern __nonnull(1, __bmp)
void ML_bmp_16_xor _OF((const unsigned short __bmp[__notnull], int __x,
	int __y)) __THROW;

extern __nonnull(1, __bmp)
void ML_bmp_16_or_cl  _OF((const unsigned short __bmp[__notnull], int __x,
	int __y)) __THROW;
extern __nonnull(1, __bmp)
void ML_bmp_16_and_cl _OF((const unsigned short __bmp[__notnull], int __x,
	int __y)) __THROW;
extern __nonnull(1, __bmp)
void ML_bmp_16_xor_cl _OF((const unsigned short __bmp[__notnull], int __x,
	int __y)) __THROW;

__END_DECLS