1 #define PIGFX_RTG_BASE 0x70000000
2 #define PIGFX_REG_SIZE 0x00010000
3 #define PIGFX_RTG_SIZE 0x02000000
4 #define PIGFX_SCRATCH_SIZE 0x00800000
5 #define PIGFX_SCRATCH_AREA 0x72010000
6 #define PIGFX_UPPER 0x72810000
10 #include "rtg_driver_amiga/rtg_enums.h"
12 void rtg_write(uint32_t address, uint32_t value, uint8_t mode);
13 unsigned int rtg_read(uint32_t address, uint8_t mode);
14 void rtg_set_clut_entry(uint8_t index, uint32_t xrgb);
15 void rtg_init_display();
16 void rtg_shutdown_display();
18 void rtg_fillrect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t color, uint16_t pitch, uint16_t format, uint8_t mask);
19 void rtg_fillrect_solid(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t color, uint16_t pitch, uint16_t format);
20 void rtg_invertrect(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint16_t pitch, uint16_t format, uint8_t mask);
21 void rtg_blitrect(uint16_t x, uint16_t y, uint16_t dx, uint16_t dy, uint16_t w, uint16_t h, uint16_t pitch, uint16_t format, uint8_t mask);
22 void rtg_blitrect_solid(uint16_t x, uint16_t y, uint16_t dx, uint16_t dy, uint16_t w, uint16_t h, uint16_t pitch, uint16_t format);
23 void rtg_blitrect_nomask_complete(uint16_t sx, uint16_t sy, uint16_t dx, uint16_t dy, uint16_t w, uint16_t h, uint16_t srcpitch, uint16_t dstpitch, uint32_t src_addr, uint32_t dst_addr, uint16_t format, uint8_t minterm);
24 void rtg_blittemplate(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t src_addr, uint32_t fgcol, uint32_t bgcol, uint16_t pitch, uint16_t t_pitch, uint16_t format, uint16_t offset_x, uint8_t mask, uint8_t draw_mode);
25 void rtg_blitpattern(uint16_t x, uint16_t y, uint16_t w, uint16_t h, uint32_t src_addr, uint32_t fgcol, uint32_t bgcol, uint16_t pitch, uint16_t format, uint16_t offset_x, uint16_t offset_y, uint8_t mask, uint8_t draw_mode, uint8_t loop_rows);
26 void rtg_drawline_solid(int16_t x1_, int16_t y1_, int16_t x2_, int16_t y2_, uint16_t len, uint32_t fgcol, uint16_t pitch, uint16_t format);
27 void rtg_drawline (int16_t x1_, int16_t y1_, int16_t x2_, int16_t y2_, uint16_t len, uint16_t pattern, uint16_t pattern_offset, uint32_t fgcol, uint32_t bgcol, uint16_t pitch, uint16_t format, uint8_t mask, uint8_t draw_mode);
29 void rtg_p2c (int16_t sx, int16_t sy, int16_t dx, int16_t dy, int16_t w, int16_t h, uint8_t draw_mode, uint8_t planes, uint8_t mask, uint8_t layer_mask, uint16_t src_line_pitch, uint8_t *bmp_data_src);
31 #define PATTERN_LOOPX \
33 cur_byte = (invert) ? sptr[tmpl_x] ^ 0xFF : sptr[tmpl_x]; \
35 #define PATTERN_LOOPY \
37 if ((ys + offset_y + 1) % loop_rows == 0) \
39 tmpl_x = (offset_x / 8) % 2; \
43 #define TEMPLATE_LOOPX \
45 cur_byte = (invert) ? sptr[tmpl_x] ^ 0xFF : sptr[tmpl_x]; \
47 #define TEMPLATE_LOOPY \
50 tmpl_x = offset_x / 8; \
53 #define INVERT_RTG_PIXELS(dest, format) \
56 if (cur_byte & 0x80) (dest)[0] ^= mask; \
57 if (cur_byte & 0x40) (dest)[1] ^= mask; \
58 if (cur_byte & 0x20) (dest)[2] ^= mask; \
59 if (cur_byte & 0x10) (dest)[3] ^= mask; \
60 if (cur_byte & 0x08) (dest)[4] ^= mask; \
61 if (cur_byte & 0x04) (dest)[5] ^= mask; \
62 if (cur_byte & 0x02) (dest)[6] ^= mask; \
63 if (cur_byte & 0x01) (dest)[7] ^= mask; \
66 if (cur_byte & 0x80) ((uint16_t *)dest)[0] = ~((uint16_t *)dest)[0]; \
67 if (cur_byte & 0x40) ((uint16_t *)dest)[1] = ~((uint16_t *)dest)[1]; \
68 if (cur_byte & 0x20) ((uint16_t *)dest)[2] = ~((uint16_t *)dest)[2]; \
69 if (cur_byte & 0x10) ((uint16_t *)dest)[3] = ~((uint16_t *)dest)[3]; \
70 if (cur_byte & 0x08) ((uint16_t *)dest)[4] = ~((uint16_t *)dest)[4]; \
71 if (cur_byte & 0x04) ((uint16_t *)dest)[5] = ~((uint16_t *)dest)[5]; \
72 if (cur_byte & 0x02) ((uint16_t *)dest)[6] = ~((uint16_t *)dest)[6]; \
73 if (cur_byte & 0x01) ((uint16_t *)dest)[7] = ~((uint16_t *)dest)[7]; \
76 if (cur_byte & 0x80) ((uint32_t *)dest)[0] = ~((uint32_t *)dest)[0]; \
77 if (cur_byte & 0x40) ((uint32_t *)dest)[1] = ~((uint32_t *)dest)[1]; \
78 if (cur_byte & 0x20) ((uint32_t *)dest)[2] = ~((uint32_t *)dest)[2]; \
79 if (cur_byte & 0x10) ((uint32_t *)dest)[3] = ~((uint32_t *)dest)[3]; \
80 if (cur_byte & 0x08) ((uint32_t *)dest)[4] = ~((uint32_t *)dest)[4]; \
81 if (cur_byte & 0x04) ((uint32_t *)dest)[5] = ~((uint32_t *)dest)[5]; \
82 if (cur_byte & 0x02) ((uint32_t *)dest)[6] = ~((uint32_t *)dest)[6]; \
83 if (cur_byte & 0x01) ((uint32_t *)dest)[7] = ~((uint32_t *)dest)[7]; \
87 #define SET_RTG_PIXELS_MASK(dest, src, format) \
88 if (cur_byte & 0x80) (dest)[0] = src ^ ((dest)[0] & ~mask); \
89 if (cur_byte & 0x40) (dest)[1] = src ^ ((dest)[1] & ~mask); \
90 if (cur_byte & 0x20) (dest)[2] = src ^ ((dest)[2] & ~mask); \
91 if (cur_byte & 0x10) (dest)[3] = src ^ ((dest)[3] & ~mask); \
92 if (cur_byte & 0x08) (dest)[4] = src ^ ((dest)[4] & ~mask); \
93 if (cur_byte & 0x04) (dest)[5] = src ^ ((dest)[5] & ~mask); \
94 if (cur_byte & 0x02) (dest)[6] = src ^ ((dest)[6] & ~mask); \
95 if (cur_byte & 0x01) (dest)[7] = src ^ ((dest)[7] & ~mask); \
97 #define SET_RTG_PIXELS2_COND_MASK(dest, src, src2, format) \
98 (dest)[0] = (cur_byte & 0x80) ? src : src2 ^ ((dest)[0] & ~mask); \
99 (dest)[1] = (cur_byte & 0x40) ? src : src2 ^ ((dest)[1] & ~mask); \
100 (dest)[2] = (cur_byte & 0x20) ? src : src2 ^ ((dest)[2] & ~mask); \
101 (dest)[3] = (cur_byte & 0x10) ? src : src2 ^ ((dest)[3] & ~mask); \
102 (dest)[4] = (cur_byte & 0x08) ? src : src2 ^ ((dest)[4] & ~mask); \
103 (dest)[5] = (cur_byte & 0x04) ? src : src2 ^ ((dest)[5] & ~mask); \
104 (dest)[6] = (cur_byte & 0x02) ? src : src2 ^ ((dest)[6] & ~mask); \
105 (dest)[7] = (cur_byte & 0x01) ? src : src2 ^ ((dest)[7] & ~mask); \
108 #define SET_RTG_PIXELS(dest, src, format) \
111 if (cur_byte & 0x80) (dest)[0] = src; \
112 if (cur_byte & 0x40) (dest)[1] = src; \
113 if (cur_byte & 0x20) (dest)[2] = src; \
114 if (cur_byte & 0x10) (dest)[3] = src; \
115 if (cur_byte & 0x08) (dest)[4] = src; \
116 if (cur_byte & 0x04) (dest)[5] = src; \
117 if (cur_byte & 0x02) (dest)[6] = src; \
118 if (cur_byte & 0x01) (dest)[7] = src; \
120 case RTGFMT_RBG565: \
121 if (cur_byte & 0x80) ((uint16_t *)dest)[0] = src; \
122 if (cur_byte & 0x40) ((uint16_t *)dest)[1] = src; \
123 if (cur_byte & 0x20) ((uint16_t *)dest)[2] = src; \
124 if (cur_byte & 0x10) ((uint16_t *)dest)[3] = src; \
125 if (cur_byte & 0x08) ((uint16_t *)dest)[4] = src; \
126 if (cur_byte & 0x04) ((uint16_t *)dest)[5] = src; \
127 if (cur_byte & 0x02) ((uint16_t *)dest)[6] = src; \
128 if (cur_byte & 0x01) ((uint16_t *)dest)[7] = src; \
131 if (cur_byte & 0x80) ((uint32_t *)dest)[0] = src; \
132 if (cur_byte & 0x40) ((uint32_t *)dest)[1] = src; \
133 if (cur_byte & 0x20) ((uint32_t *)dest)[2] = src; \
134 if (cur_byte & 0x10) ((uint32_t *)dest)[3] = src; \
135 if (cur_byte & 0x08) ((uint32_t *)dest)[4] = src; \
136 if (cur_byte & 0x04) ((uint32_t *)dest)[5] = src; \
137 if (cur_byte & 0x02) ((uint32_t *)dest)[6] = src; \
138 if (cur_byte & 0x01) ((uint32_t *)dest)[7] = src; \
142 #define SET_RTG_PIXELS2_COND(dest, src, src2, format) \
145 (dest)[0] = (cur_byte & 0x80) ? src : src2; \
146 (dest)[1] = (cur_byte & 0x40) ? src : src2; \
147 (dest)[2] = (cur_byte & 0x20) ? src : src2; \
148 (dest)[3] = (cur_byte & 0x10) ? src : src2; \
149 (dest)[4] = (cur_byte & 0x08) ? src : src2; \
150 (dest)[5] = (cur_byte & 0x04) ? src : src2; \
151 (dest)[6] = (cur_byte & 0x02) ? src : src2; \
152 (dest)[7] = (cur_byte & 0x01) ? src : src2; \
154 case RTGFMT_RBG565: \
155 ((uint16_t *)dest)[0] = (cur_byte & 0x80) ? src : src2; \
156 ((uint16_t *)dest)[1] = (cur_byte & 0x40) ? src : src2; \
157 ((uint16_t *)dest)[2] = (cur_byte & 0x20) ? src : src2; \
158 ((uint16_t *)dest)[3] = (cur_byte & 0x10) ? src : src2; \
159 ((uint16_t *)dest)[4] = (cur_byte & 0x08) ? src : src2; \
160 ((uint16_t *)dest)[5] = (cur_byte & 0x04) ? src : src2; \
161 ((uint16_t *)dest)[6] = (cur_byte & 0x02) ? src : src2; \
162 ((uint16_t *)dest)[7] = (cur_byte & 0x01) ? src : src2; \
165 ((uint32_t *)dest)[0] = (cur_byte & 0x80) ? src : src2; \
166 ((uint32_t *)dest)[1] = (cur_byte & 0x40) ? src : src2; \
167 ((uint32_t *)dest)[2] = (cur_byte & 0x20) ? src : src2; \
168 ((uint32_t *)dest)[3] = (cur_byte & 0x10) ? src : src2; \
169 ((uint32_t *)dest)[4] = (cur_byte & 0x08) ? src : src2; \
170 ((uint32_t *)dest)[5] = (cur_byte & 0x04) ? src : src2; \
171 ((uint32_t *)dest)[6] = (cur_byte & 0x02) ? src : src2; \
172 ((uint32_t *)dest)[7] = (cur_byte & 0x01) ? src : src2; \
178 #define SET_RTG_PIXEL(dest, src, format) \
183 case RTGFMT_RBG565: \
184 *((uint16_t *)dest) = src; \
187 *((uint32_t *)dest) = src; \
191 #define SET_RTG_PIXEL_MASK(dest, src, format) \
194 *(dest) = src ^ (*(dest) & ~mask); \
196 case RTGFMT_RBG565: \
197 *((uint16_t *)dest) = src; \
200 *((uint32_t *)dest) = src; \
204 #define INVERT_RTG_PIXEL(dest, format) \
209 case RTGFMT_RBG565: \
210 *((uint16_t *)dest) = ~*((uint16_t *)dest); \
213 *((uint32_t *)dest) = ~*((uint32_t *)dest); \
217 #define HANDLE_MINTERM_PIXEL(s, d, f) \
221 SET_RTG_PIXEL_MASK(&d, s, f); break; \
222 case MINTERM_ONLYDST: \
223 d = d & ~(s); break; \
224 case MINTERM_NOTSRC: \
225 SET_RTG_PIXEL_MASK(&d, s, f); break; \
226 case MINTERM_ONLYSRC: \
228 SET_RTG_PIXEL_MASK(&d, s, f); break; \
229 case MINTERM_INVERT: \
234 s = ~(d & ~(s)) & mask; \
235 SET_RTG_PIXEL_MASK(&d, s, f); break; \
238 SET_RTG_PIXEL_MASK(&d, s, f); break; \
240 d ^= (s & mask); break; \
241 case MINTERM_DST: /* This one does nothing. */ \
243 case MINTERM_NOTONLYSRC: \
244 d |= (s & mask); break; \
246 SET_RTG_PIXEL_MASK(&d, s, f); break; \
247 case MINTERM_NOTONLYDST: \
248 s = ~(d & s) & mask; \
249 SET_RTG_PIXEL_MASK(&d, s, f); break; \
251 d |= (s & mask); break; \
255 #define DECODE_PLANAR_PIXEL(a) \
257 case 8: if (layer_mask & 0x80 && bmp_data[(plane_size * 7) + cur_byte] & cur_bit) a |= 0x80; \
259 case 7: if (layer_mask & 0x40 && bmp_data[(plane_size * 6) + cur_byte] & cur_bit) a |= 0x40; \
261 case 6: if (layer_mask & 0x20 && bmp_data[(plane_size * 5) + cur_byte] & cur_bit) a |= 0x20; \
263 case 5: if (layer_mask & 0x10 && bmp_data[(plane_size * 4) + cur_byte] & cur_bit) a |= 0x10; \
265 case 4: if (layer_mask & 0x08 && bmp_data[(plane_size * 3) + cur_byte] & cur_bit) a |= 0x08; \
267 case 3: if (layer_mask & 0x04 && bmp_data[(plane_size * 2) + cur_byte] & cur_bit) a |= 0x04; \
269 case 2: if (layer_mask & 0x02 && bmp_data[plane_size + cur_byte] & cur_bit) a |= 0x02; \
271 case 1: if (layer_mask & 0x01 && bmp_data[cur_byte] & cur_bit) a |= 0x01; \
275 #define DECODE_INVERTED_PLANAR_PIXEL(a) \
277 case 8: if (layer_mask & 0x80 && (bmp_data[(plane_size * 7) + cur_byte] ^ 0xFF) & cur_bit) a |= 0x80; \
279 case 7: if (layer_mask & 0x40 && (bmp_data[(plane_size * 6) + cur_byte] ^ 0xFF) & cur_bit) a |= 0x40; \
281 case 6: if (layer_mask & 0x20 && (bmp_data[(plane_size * 5) + cur_byte] ^ 0xFF) & cur_bit) a |= 0x20; \
283 case 5: if (layer_mask & 0x10 && (bmp_data[(plane_size * 4) + cur_byte] ^ 0xFF) & cur_bit) a |= 0x10; \
285 case 4: if (layer_mask & 0x08 && (bmp_data[(plane_size * 3) + cur_byte] ^ 0xFF) & cur_bit) a |= 0x08; \
287 case 3: if (layer_mask & 0x04 && (bmp_data[(plane_size * 2) + cur_byte] ^ 0xFF) & cur_bit) a |= 0x04; \
289 case 2: if (layer_mask & 0x02 && (bmp_data[plane_size + cur_byte] ^ 0xFF) & cur_bit) a |= 0x02; \
291 case 1: if (layer_mask & 0x01 && (bmp_data[cur_byte] ^ 0xFF) & cur_bit) a |= 0x01; \