|
|
1.1 root 1: /*
2: * UAE - The U*nix Amiga Emulator
3: *
4: * Picasso96 Support Module
5: *
6: * Copyright 1997 Brian King <[email protected], [email protected]>
7: *
8: * Theory of operation:
9: * On the Amiga side, a Picasso card consists mainly of a memory area that
10: * contains the frame buffer. On the UAE side, we allocate a block of memory
11: * that will hold the frame buffer. This block is in normal memory, it is
12: * never directly on the graphics card. All graphics operations, which are
13: * mainly reads and writes into this block and a few basic operations like
14: * filling a rectangle, operate on this block of memory.
15: * Since the memory is not on the graphics card, some work must be done to
16: * synchronize the display with the data in the Picasso frame buffer. There
17: * are various ways to do this. One possibility is to allocate a second
18: * buffer of the same size, and perform all write operations twice. Since
19: * we never read from the second buffer, it can actually be placed in video
20: * memory. The X11 driver could be made to use the Picasso frame buffer as
21: * the data buffer of an XImage, which could then be XPutImage()d from time
22: * to time. Another possibility is to translate all Picasso accesses into
23: * Xlib (or GDI, or whatever your graphics system is) calls. This possibility
24: * is a bit tricky, since there is a risk of generating very many single pixel
25: * accesses which may be rather slow.
26: *
27: * TODO:
28: * - add panning capability
1.1.1.3 root 29: * - we want to add a manual switch to override SetSwitch for hardware banging
30: * programs started from a Picasso workbench.
1.1 root 31: */
32:
33: #include "sysconfig.h"
34: #include "sysdeps.h"
35:
36: #include "config.h"
37: #include "options.h"
1.1.1.11 root 38: #include "threaddep/thread.h"
1.1 root 39: #include "uae.h"
40: #include "memory.h"
41: #include "custom.h"
42: #include "newcpu.h"
43: #include "xwin.h"
44: #include "picasso96.h"
45:
46: #ifdef PICASSO96
47:
1.1.1.13 root 48: /* #define P96TRACING_ENABLED */
1.1.1.4 root 49: #ifdef P96TRACING_ENABLED
50: #define P96TRACE(x) do { write_log x; } while(0)
51: #else
52: #define P96TRACE(x)
53: #endif
54:
1.1 root 55: static uae_u32 gfxmem_lget (uaecptr) REGPARAM;
56: static uae_u32 gfxmem_wget (uaecptr) REGPARAM;
57: static uae_u32 gfxmem_bget (uaecptr) REGPARAM;
58: static void gfxmem_lput (uaecptr, uae_u32) REGPARAM;
59: static void gfxmem_wput (uaecptr, uae_u32) REGPARAM;
60: static void gfxmem_bput (uaecptr, uae_u32) REGPARAM;
61: static int gfxmem_check (uaecptr addr, uae_u32 size) REGPARAM;
62: static uae_u8 *gfxmem_xlate (uaecptr addr) REGPARAM;
63:
64: static void write_gfx_long (uaecptr addr, uae_u32 value);
65: static void write_gfx_word (uaecptr addr, uae_u16 value);
66: static void write_gfx_byte (uaecptr addr, uae_u8 value);
67:
1.1.1.4 root 68: static uae_u8 all_ones_bitmap, all_zeros_bitmap;
1.1 root 69:
70: struct picasso96_state_struct picasso96_state;
71: struct picasso_vidbuf_description picasso_vidinfo;
72:
73: /* These are the maximum resolutions... They are filled in by GetSupportedResolutions() */
74: /* have to fill this in, otherwise problems occur
75: * @@@ ??? what problems?
76: */
77: struct ScreenResolution planar = { 320, 240 };
78: struct ScreenResolution chunky = { 640, 480 };
79: struct ScreenResolution hicolour = { 640, 480 };
80: struct ScreenResolution truecolour = { 640, 480 };
1.1.1.4 root 81: struct ScreenResolution alphacolour = { 640, 480 };
1.1 root 82:
83: uae_u16 picasso96_pixel_format = RGBFF_CHUNKY;
84:
85: struct PicassoResolution DisplayModes[MAX_PICASSO_MODES];
86:
87: static int mode_count = 0;
88:
1.1.1.12 root 89: static int set_gc_called = 0;
90: static int set_panning_called = 0;
91: /* Address of the screen in the Amiga frame buffer at the time of the last
92: SetPanning call. */
93: static uaecptr oldscr;
94:
1.1 root 95: static uae_u32 p2ctab[256][2];
96:
97: /*
98: * Debugging dumps
99: */
100:
101: static void DumpModeInfoStructure (uaecptr amigamodeinfoptr)
102: {
1.1.1.2 root 103: write_log ("ModeInfo Structure Dump:\n");
104: write_log (" Node.ln_Succ = 0x%x\n", get_long (amigamodeinfoptr));
105: write_log (" Node.ln_Pred = 0x%x\n", get_long (amigamodeinfoptr + 4));
106: write_log (" Node.ln_Type = 0x%x\n", get_byte (amigamodeinfoptr + 8));
107: write_log (" Node.ln_Pri = %d\n", get_byte (amigamodeinfoptr + 9));
108: /*write_log (" Node.ln_Name = %s\n", uaememptr->Node.ln_Name); */
109: write_log (" OpenCount = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_OpenCount));
110: write_log (" Active = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Active));
111: write_log (" Width = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_Width));
112: write_log (" Height = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_Height));
113: write_log (" Depth = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Depth));
114: write_log (" Flags = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_Flags));
115: write_log (" HorTotal = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorTotal));
116: write_log (" HorBlankSize = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorBlankSize));
117: write_log (" HorSyncStart = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorSyncStart));
118: write_log (" HorSyncSize = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_HorSyncSize));
119: write_log (" HorSyncSkew = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_HorSyncSkew));
120: write_log (" HorEnableSkew = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_HorEnableSkew));
121: write_log (" VerTotal = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerTotal));
122: write_log (" VerBlankSize = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerBlankSize));
123: write_log (" VerSyncStart = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerSyncStart));
124: write_log (" VerSyncSize = %d\n", get_word (amigamodeinfoptr + PSSO_ModeInfo_VerSyncSize));
125: write_log (" Clock = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_first_union));
126: write_log (" ClockDivide = %d\n", get_byte (amigamodeinfoptr + PSSO_ModeInfo_second_union));
127: write_log (" PixelClock = %d\n", get_long (amigamodeinfoptr + PSSO_ModeInfo_PixelClock));
1.1 root 128: }
129:
130: static void DumpLibResolutionStructure (uaecptr amigalibresptr)
131: {
132: int i;
133: uaecptr amigamodeinfoptr;
1.1.1.8 root 134: struct LibResolution *uaememptr = (struct LibResolution *) get_mem_bank (amigalibresptr).xlateaddr (amigalibresptr);
135:
1.1 root 136: return;
137:
1.1.1.2 root 138: write_log ("LibResolution Structure Dump:\n");
1.1 root 139:
140: if (get_long (amigalibresptr + PSSO_LibResolution_DisplayID) == 0xFFFFFFFF) {
1.1.1.2 root 141: write_log (" Finished With LibResolutions...\n");
1.1 root 142: } else {
1.1.1.2 root 143: write_log (" Name = %s\n", uaememptr->P96ID);
144: write_log (" DisplayID = 0x%x\n", get_long (amigalibresptr + PSSO_LibResolution_DisplayID));
145: write_log (" Width = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Width));
146: write_log (" Height = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Height));
147: write_log (" Flags = %d\n", get_word (amigalibresptr + PSSO_LibResolution_Flags));
1.1 root 148: for (i = 0; i < MAXMODES; i++) {
1.1.1.8 root 149: amigamodeinfoptr = get_long (amigalibresptr + PSSO_LibResolution_Modes + i * 4);
1.1.1.2 root 150: write_log (" ModeInfo[%d] = 0x%x\n", i, amigamodeinfoptr);
1.1 root 151: if (amigamodeinfoptr)
1.1.1.2 root 152: DumpModeInfoStructure (amigamodeinfoptr);
1.1 root 153: }
1.1.1.2 root 154: write_log (" BoardInfo = 0x%x\n", get_long (amigalibresptr + PSSO_LibResolution_BoardInfo));
1.1 root 155: }
156: }
157:
1.1.1.4 root 158: static char binary_byte[9];
1.1 root 159:
160: static char *BuildBinaryString (uae_u8 value)
161: {
162: int i;
163: for (i = 0; i < 8; i++) {
164: binary_byte[i] = (value & (1 << (7 - i))) ? '#' : '.';
165: }
1.1.1.4 root 166: binary_byte[8] = '\0';
1.1 root 167: return binary_byte;
168: }
169:
170: static void DumpPattern (struct Pattern *patt)
171: {
172: uae_u8 *mem;
173: int row, col;
174: for (row = 0; row < (1 << patt->Size); row++) {
175: mem = patt->Memory + row * 2;
176: for (col = 0; col < 2; col++) {
1.1.1.2 root 177: write_log ("%s", BuildBinaryString (*mem++));
1.1 root 178: }
1.1.1.2 root 179: write_log ("\n");
1.1 root 180: }
181: }
182:
183: static void DumpTemplate (struct Template *tmp, uae_u16 w, uae_u16 h)
184: {
185: uae_u8 *mem = tmp->Memory;
186: int row, col, width;
187: width = (w + 7) >> 3;
1.1.1.2 root 188: write_log ("xoffset = %d, bpr = %d\n", tmp->XOffset, tmp->BytesPerRow);
1.1 root 189: for (row = 0; row < h; row++) {
190: mem = tmp->Memory + row * tmp->BytesPerRow;
191: for (col = 0; col < width; col++) {
1.1.1.2 root 192: write_log ("%s", BuildBinaryString (*mem++));
1.1 root 193: }
1.1.1.2 root 194: write_log ("\n");
1.1 root 195: }
196: }
197:
1.1.1.11 root 198: int picasso_nr_resolutions (void)
199: {
200: return mode_count;
201: }
202:
1.1 root 203: static void ShowSupportedResolutions (void)
204: {
205: int i;
1.1.1.8 root 206:
1.1 root 207: return;
208:
209: for (i = 0; i < mode_count; i++)
1.1.1.2 root 210: write_log ("%s\n", DisplayModes[i].name);
211: }
212:
213: static uae_u8 GetBytesPerPixel (uae_u32 RGBfmt)
214: {
215: switch (RGBfmt) {
1.1.1.8 root 216: case RGBFB_CLUT:
1.1.1.2 root 217: return 1;
218:
1.1.1.8 root 219: case RGBFB_A8R8G8B8:
220: case RGBFB_A8B8G8R8:
221: case RGBFB_R8G8B8A8:
222: case RGBFB_B8G8R8A8:
1.1.1.2 root 223: return 4;
224:
1.1.1.8 root 225: case RGBFB_B8G8R8:
226: case RGBFB_R8G8B8:
1.1.1.2 root 227: return 3;
228:
1.1.1.8 root 229: case RGBFB_R5G5B5:
230: case RGBFB_R5G6B5:
231: case RGBFB_R5G6B5PC:
232: case RGBFB_R5G5B5PC:
233: case RGBFB_B5G6R5PC:
234: case RGBFB_B5G5R5PC:
1.1.1.2 root 235: return 2;
1.1.1.8 root 236: default:
1.1.1.2 root 237: write_log ("ERROR - GetBytesPerPixel() was unsuccessful with 0x%x?!\n", RGBfmt);
238: return 0;
239: }
1.1 root 240: }
241:
242: /*
243: * Amiga <-> native structure conversion functions
244: */
245:
246: static int CopyRenderInfoStructureA2U (uaecptr amigamemptr, struct RenderInfo *ri)
247: {
248: uaecptr memp = get_long (amigamemptr + PSSO_RenderInfo_Memory);
249:
1.1.1.4 root 250: if (valid_address (memp, PSSO_RenderInfo_sizeof)) {
1.1 root 251: ri->Memory = get_real_address (memp);
252: ri->BytesPerRow = get_word (amigamemptr + PSSO_RenderInfo_BytesPerRow);
253: ri->RGBFormat = get_long (amigamemptr + PSSO_RenderInfo_RGBFormat);
254: return 1;
255: }
1.1.1.2 root 256: write_log ("ERROR - Invalid RenderInfo memory area...\n");
1.1 root 257: return 0;
258: }
259:
260: static int CopyPatternStructureA2U (uaecptr amigamemptr, struct Pattern *pattern)
261: {
262: uaecptr memp = get_long (amigamemptr + PSSO_Pattern_Memory);
1.1.1.4 root 263: if (valid_address (memp, PSSO_Pattern_sizeof)) {
1.1 root 264: pattern->Memory = get_real_address (memp);
265: pattern->XOffset = get_word (amigamemptr + PSSO_Pattern_XOffset);
266: pattern->YOffset = get_word (amigamemptr + PSSO_Pattern_YOffset);
267: pattern->FgPen = get_long (amigamemptr + PSSO_Pattern_FgPen);
268: pattern->BgPen = get_long (amigamemptr + PSSO_Pattern_BgPen);
269: pattern->Size = get_byte (amigamemptr + PSSO_Pattern_Size);
270: pattern->DrawMode = get_byte (amigamemptr + PSSO_Pattern_DrawMode);
271: return 1;
272: }
1.1.1.2 root 273: write_log ("ERROR - Invalid Pattern memory area...\n");
1.1 root 274: return 0;
275: }
276:
277: static void CopyColorIndexMappingA2U (uaecptr amigamemptr, struct ColorIndexMapping *cim)
278: {
279: int i;
280: cim->ColorMask = get_long (amigamemptr);
281: for (i = 0; i < 256; i++, amigamemptr += 4)
282: cim->Colors[i] = get_long (amigamemptr + 4);
283: }
284:
285: static int CopyBitMapStructureA2U (uaecptr amigamemptr, struct BitMap *bm)
286: {
287: int i;
288:
289: bm->BytesPerRow = get_word (amigamemptr + PSSO_BitMap_BytesPerRow);
290: bm->Rows = get_word (amigamemptr + PSSO_BitMap_Rows);
291: bm->Flags = get_byte (amigamemptr + PSSO_BitMap_Flags);
292: bm->Depth = get_byte (amigamemptr + PSSO_BitMap_Depth);
293:
294: for (i = 0; i < bm->Depth; i++) {
1.1.1.8 root 295: uaecptr plane = get_long (amigamemptr + PSSO_BitMap_Planes + i * 4);
1.1 root 296: switch (plane) {
1.1.1.8 root 297: case 0:
1.1 root 298: bm->Planes[i] = &all_zeros_bitmap;
299: break;
1.1.1.8 root 300: case 0xFFFFFFFF:
1.1 root 301: bm->Planes[i] = &all_ones_bitmap;
302: break;
1.1.1.8 root 303: default:
1.1 root 304: if (valid_address (plane, bm->BytesPerRow * bm->Rows))
305: bm->Planes[i] = get_real_address (plane);
306: else
307: return 0;
308: break;
309: }
310: }
311: return 1;
312: }
313:
314: static int CopyTemplateStructureA2U (uaecptr amigamemptr, struct Template *tmpl)
315: {
316: uaecptr memp = get_long (amigamemptr + PSSO_Template_Memory);
317:
1.1.1.8 root 318: if (valid_address (memp, 1 /* FIXME */ )) {
1.1 root 319: tmpl->Memory = get_real_address (memp);
320: tmpl->BytesPerRow = get_word (amigamemptr + PSSO_Template_BytesPerRow);
321: tmpl->XOffset = get_byte (amigamemptr + PSSO_Template_XOffset);
322: tmpl->DrawMode = get_byte (amigamemptr + PSSO_Template_DrawMode);
323: tmpl->FgPen = get_long (amigamemptr + PSSO_Template_FgPen);
324: tmpl->BgPen = get_long (amigamemptr + PSSO_Template_BgPen);
325: return 1;
326: }
1.1.1.2 root 327: write_log ("ERROR - Invalid Template memory area...\n");
1.1 root 328: return 0;
329: }
330:
331: static void CopyLibResolutionStructureU2A (struct LibResolution *libres, uaecptr amigamemptr)
332: {
333: char *uaememptr = 0;
334: int i;
335:
1.1.1.8 root 336: uaememptr = gfxmem_xlate (amigamemptr); /* I know that amigamemptr is inside my gfxmem chunk, so I can just do the xlate() */
337: memset (uaememptr, 0, PSSO_LibResolution_sizeof); /* zero out our LibResolution structure */
1.1.1.3 root 338: strcpy (uaememptr + PSSO_LibResolution_P96ID, libres->P96ID);
1.1.1.2 root 339: put_long (amigamemptr + PSSO_LibResolution_DisplayID, libres->DisplayID);
340: put_word (amigamemptr + PSSO_LibResolution_Width, libres->Width);
341: put_word (amigamemptr + PSSO_LibResolution_Height, libres->Height);
342: put_word (amigamemptr + PSSO_LibResolution_Flags, libres->Flags);
1.1 root 343: for (i = 0; i < MAXMODES; i++)
1.1.1.8 root 344: put_long (amigamemptr + PSSO_LibResolution_Modes + i * 4, libres->Modes[i]);
1.1 root 345: #if 0
1.1.1.2 root 346: put_long (amigamemptr, libres->Node.ln_Succ);
347: put_long (amigamemptr + 4, libres->Node.ln_Pred);
348: put_byte (amigamemptr + 8, libres->Node.ln_Type);
349: put_byte (amigamemptr + 9, libres->Node.ln_Pri);
1.1 root 350: #endif
1.1.1.2 root 351: put_long (amigamemptr + 10, amigamemptr + PSSO_LibResolution_P96ID);
352: put_long (amigamemptr + PSSO_LibResolution_BoardInfo, libres->BoardInfo);
1.1 root 353: }
354:
355: /* list is Amiga address of list, in correct endian format for UAE
356: * node is Amiga address of node, in correct endian format for UAE */
357: static void AmigaListAddTail (uaecptr list, uaecptr node)
358: {
359: uaecptr amigamemptr = 0;
360:
361: if (get_long (list + 8) == list) {
362: /* Empty list - set it up */
1.1.1.8 root 363: put_long (list, node); /* point the lh_Head to our new node */
364: put_long (list + 4, 0); /* set the lh_Tail to NULL */
365: put_long (list + 8, node); /* point the lh_TailPred to our new node */
1.1 root 366:
367: /* Adjust the new node - don't rely on it being zeroed out */
1.1.1.8 root 368: put_long (node, 0); /* ln_Succ */
369: put_long (node + 4, 0); /* ln_Pred */
1.1 root 370: } else {
1.1.1.8 root 371: amigamemptr = get_long (list + 8); /* get the lh_TailPred contents */
1.1 root 372:
1.1.1.8 root 373: put_long (list + 8, node); /* point the lh_TailPred to our new node */
1.1 root 374:
375: /* Adjust the previous lh_TailPred node */
1.1.1.8 root 376: put_long (amigamemptr, node); /* point the ln_Succ to our new node */
1.1 root 377:
378: /* Adjust the new node - don't rely on it being zeroed out */
1.1.1.8 root 379: put_long (node, 0); /* ln_Succ */
380: put_long (node + 4, amigamemptr); /* ln_Pred */
1.1 root 381: }
382: }
383:
384: /*
385: * Functions to perform an action on the real screen
386: */
387:
388: /*
389: * Fill a rectangle on the screen. src points to the start of a line of the
390: * filled rectangle in the frame buffer; it can be used as a memcpy source if
391: * there is no OS specific function to fill the rectangle.
392: */
393:
1.1.1.12 root 394: static void do_fillrect (uae_u8 * src, int x, int y, int width, int height,
395: uae_u32 pen, int Bpp, RGBFTYPE rgbtype)
1.1 root 396: {
397: uae_u8 *dst;
1.1.1.12 root 398:
399: /* Clipping. */
400: x -= picasso96_state.XOffset;
401: y -= picasso96_state.YOffset;
402: if (x < 0) {
403: width += x;
404: x = 0;
405: }
406: if (y < 0) {
407: height += y;
408: y = 0;
409: }
410: if (x + width > picasso96_state.Width)
411: width = picasso96_state.Width - x;
412: if (y + height > picasso96_state.Height)
413: height = picasso96_state.Height - y;
414:
1.1.1.13 root 415: if (width <= 0 || height <= 0)
416: return;
417:
1.1 root 418: /* Try OS specific fillrect function here; and return if successful. */
419:
420: DX_Invalidate (y, y + height - 1);
1.1.1.8 root 421: if (!picasso_vidinfo.extra_mem)
1.1 root 422: return;
423:
424: width *= picasso96_state.BytesPerPixel;
1.1.1.2 root 425: dst = gfx_lock_picasso ();
1.1 root 426: if (!dst)
1.1.1.2 root 427: goto out;
1.1 root 428:
1.1.1.8 root 429: dst += y * picasso_vidinfo.rowbytes + x * picasso_vidinfo.pixbytes;
1.1.1.2 root 430: if (picasso_vidinfo.rgbformat == picasso96_state.RGBFormat) {
1.1.1.12 root 431: if (Bpp == 1) {
432: while (height-- > 0) {
433: memset (dst, pen, width);
434: dst += picasso_vidinfo.rowbytes;
435: }
436: } else {
437: while (height-- > 0) {
438: memcpy (dst, src, width);
439: dst += picasso_vidinfo.rowbytes;
440: }
1.1.1.2 root 441: }
442: } else {
443: int psiz = GetBytesPerPixel (picasso_vidinfo.rgbformat);
444: if (picasso96_state.RGBFormat != RGBFB_CHUNKY)
445: abort ();
446:
447: while (height-- > 0) {
448: int i;
449: switch (psiz) {
1.1.1.8 root 450: case 2:
1.1.1.2 root 451: for (i = 0; i < width; i++)
1.1.1.8 root 452: *((uae_u16 *) dst + i) = picasso_vidinfo.clut[src[i]];
1.1.1.2 root 453: break;
1.1.1.8 root 454: case 4:
1.1.1.2 root 455: for (i = 0; i < width; i++)
1.1.1.8 root 456: *((uae_u32 *) dst + i) = picasso_vidinfo.clut[src[i]];
1.1.1.2 root 457: break;
1.1.1.8 root 458: default:
459: abort ();
1.1.1.2 root 460: }
461: dst += picasso_vidinfo.rowbytes;
462: }
1.1 root 463: }
1.1.1.8 root 464: out:
1.1.1.2 root 465: gfx_unlock_picasso ();
1.1 root 466: }
467:
468: /*
469: * This routine modifies the real screen buffer after a blit has been
470: * performed in the save area. If can_do_blit is nonzero, the blit can
471: * be performed within the real screen buffer; otherwise, this routine
472: * must do it by hand using the data in the save area, pointed to by
473: * srcp.
474: */
475:
1.1.1.12 root 476: static void do_blit (struct RenderInfo *ri, int Bpp, int srcx, int srcy,
477: int dstx, int dsty, int width, int height,
478: BLIT_OPCODE opcode, int can_do_blit)
479: {
480: int xoff = picasso96_state.XOffset;
481: int yoff = picasso96_state.YOffset;
482: uae_u8 *srcp, *dstp;
483:
484: /* Clipping. */
485: dstx -= xoff;
486: dsty -= yoff;
487: if (srcy < yoff || srcx < xoff
488: || srcx - xoff + width > picasso96_state.Width
489: || srcy - yoff + height > picasso96_state.Height)
490: {
491: can_do_blit = 0;
492: }
493: if (dstx < 0) {
494: srcx -= dstx;
495: width += dstx;
496: dstx = 0;
497: }
498: if (dsty < 0) {
499: srcy -= dsty;
500: height += dsty;
501: dsty = 0;
502: }
503: if (dstx + width > picasso96_state.Width)
504: width = picasso96_state.Width - dstx;
505: if (dsty + height > picasso96_state.Height)
506: height = picasso96_state.Height - dsty;
1.1.1.13 root 507: if (width <= 0 || height <= 0)
508: return;
1.1.1.12 root 509:
1.1 root 510: /* If this RenderInfo points at something else than the currently visible
511: * screen, we must ignore the blit. */
512: if (can_do_blit) {
513: /*
514: * Call OS blitting function that can do it in video memory.
515: * Should return if it was successful
516: */
517: }
518:
1.1.1.12 root 519: /* If no OS blit available, we do a copy from the P96 framebuffer in Amiga
520: memory to the host's frame buffer. */
1.1 root 521: DX_Invalidate (dsty, dsty + height - 1);
1.1.1.8 root 522: if (!picasso_vidinfo.extra_mem)
1.1 root 523: return;
524:
1.1.1.2 root 525: dstp = gfx_lock_picasso ();
1.1 root 526: if (dstp == 0)
1.1.1.2 root 527: goto out;
528: dstp += dsty * picasso_vidinfo.rowbytes + dstx * picasso_vidinfo.pixbytes;
1.1.1.13 root 529: P96TRACE(("do_blit with srcp 0x%x, dstp 0x%x, dst_rowbytes %d, srcx %d, srcy %d, dstx %d, dsty %d, w %d, h %d, dst_pixbytes %d\n",
530: srcp, dstp, picasso_vidinfo.rowbytes, srcx, srcy, dstx, dsty, width, height, picasso_vidinfo.pixbytes));
531: P96TRACE(("gfxmem is at 0x%x\n",gfxmemory));
1.1.1.12 root 532:
533: srcp = ri->Memory + srcx * Bpp + srcy * ri->BytesPerRow;
1.1.1.2 root 534: if (picasso_vidinfo.rgbformat == picasso96_state.RGBFormat) {
1.1.1.12 root 535: width *= Bpp;
1.1.1.2 root 536: while (height-- > 0) {
537: memcpy (dstp, srcp, width);
1.1.1.12 root 538: srcp += ri->BytesPerRow;
1.1.1.2 root 539: dstp += picasso_vidinfo.rowbytes;
540: }
541: } else {
542: int psiz = GetBytesPerPixel (picasso_vidinfo.rgbformat);
543: if (picasso96_state.RGBFormat != RGBFB_CHUNKY)
544: abort ();
545:
546: while (height-- > 0) {
547: int i;
548: switch (psiz) {
1.1.1.8 root 549: case 2:
1.1.1.2 root 550: for (i = 0; i < width; i++)
1.1.1.8 root 551: *((uae_u16 *) dstp + i) = picasso_vidinfo.clut[srcp[i]];
1.1.1.2 root 552: break;
1.1.1.8 root 553: case 4:
1.1.1.2 root 554: for (i = 0; i < width; i++)
1.1.1.8 root 555: *((uae_u32 *) dstp + i) = picasso_vidinfo.clut[srcp[i]];
1.1.1.2 root 556: break;
1.1.1.8 root 557: default:
558: abort ();
1.1.1.2 root 559: }
1.1.1.12 root 560: srcp += ri->BytesPerRow;
1.1.1.2 root 561: dstp += picasso_vidinfo.rowbytes;
562: }
1.1 root 563: }
1.1.1.8 root 564: out:
1.1.1.2 root 565: gfx_unlock_picasso ();
1.1 root 566: }
567:
568: /*
1.1.1.12 root 569: * Invert a rectangle on the screen.
1.1 root 570: */
571:
1.1.1.12 root 572: static void do_invertrect (struct RenderInfo *ri, int Bpp, int x, int y, int width, int height)
1.1 root 573: {
1.1.1.12 root 574: #if 0
575: /* Clipping. */
576: x -= picasso96_state.XOffset;
577: y -= picasso96_state.YOffset;
578: if (x < 0) {
579: width += x;
580: x = 0;
581: }
582: if (y < 0) {
583: height += y;
584: y = 0;
585: }
586: if (x + width > picasso96_state.Width)
587: width = picasso96_state.Width - x;
588: if (y + height > picasso96_state.Height)
589: height = picasso96_state.Height - y;
1.1.1.13 root 590:
591: if (width <= 0 || height <= 0)
592: return;
593:
1.1.1.12 root 594: #endif
1.1.1.2 root 595: /* TODO: Try OS specific invertrect function here; and return if successful. */
1.1 root 596:
1.1.1.12 root 597: do_blit (ri, Bpp, x, y, x, y, width, height, BLIT_SRC, 0);
1.1 root 598: }
599:
600: static uaecptr wgfx_linestart;
601: static uaecptr wgfx_lineend;
602: static uaecptr wgfx_min, wgfx_max;
1.1.1.12 root 603: static long wgfx_y;
1.1 root 604:
605: static void wgfx_do_flushline (void)
606: {
1.1.1.12 root 607: int src_y = wgfx_y;
608: long x0, x1, width;
1.1 root 609: uae_u8 *src, *dstp;
1.1.1.12 root 610: int Bpp = GetBytesPerPixel (picasso_vidinfo.rgbformat);
611: int fb_bpp = picasso96_state.BytesPerPixel;
612:
613: wgfx_y -= picasso96_state.YOffset;
614: if (wgfx_y < 0 || wgfx_y >= picasso96_state.Height)
1.1.1.14! root 615: goto out1;
1.1 root 616:
617: DX_Invalidate (wgfx_y, wgfx_y);
1.1.1.8 root 618: if (!picasso_vidinfo.extra_mem)
1.1.1.14! root 619: goto out1;
1.1 root 620:
1.1.1.12 root 621: x0 = wgfx_min - wgfx_linestart;
622: width = wgfx_max - wgfx_min;
623: x0 -= picasso96_state.XOffset * fb_bpp;
624: if (x0 < 0) {
625: width += x0;
626: wgfx_min += x0;
627: x0 = 0;
628: }
629: if (x0 + width > picasso96_state.Width * fb_bpp)
630: width = picasso96_state.Width * fb_bpp - x0;
631:
1.1.1.2 root 632: dstp = gfx_lock_picasso ();
1.1 root 633: if (dstp == 0)
634: goto out;
1.1.1.12 root 635:
1.1.1.13 root 636: P96TRACE(("flushing %d\n", wgfx_y));
1.1.1.2 root 637: src = gfxmemory + wgfx_min;
1.1 root 638:
1.1.1.2 root 639: if (picasso_vidinfo.rgbformat == picasso96_state.RGBFormat) {
1.1.1.12 root 640: dstp += wgfx_y * picasso_vidinfo.rowbytes + x0;
641: memcpy (dstp, src, width);
1.1.1.2 root 642: } else {
643: int i;
644:
645: if (picasso96_state.RGBFormat != RGBFB_CHUNKY)
646: abort ();
647:
1.1.1.12 root 648: dstp += wgfx_y * picasso_vidinfo.rowbytes + x0 * Bpp;
649: switch (Bpp) {
1.1.1.8 root 650: case 2:
1.1.1.2 root 651: for (i = 0; i < width; i++)
1.1.1.8 root 652: *((uae_u16 *) dstp + i) = picasso_vidinfo.clut[src[i]];
1.1.1.2 root 653: break;
1.1.1.8 root 654: case 4:
1.1.1.2 root 655: for (i = 0; i < width; i++)
1.1.1.8 root 656: *((uae_u32 *) dstp + i) = picasso_vidinfo.clut[src[i]];
1.1.1.2 root 657: break;
1.1.1.8 root 658: default:
659: abort ();
1.1.1.2 root 660: }
661: }
1.1 root 662:
1.1.1.8 root 663: out:
1.1.1.2 root 664: gfx_unlock_picasso ();
1.1.1.14! root 665: out1:
1.1 root 666: wgfx_linestart = 0xFFFFFFFF;
667: }
668:
1.1.1.7 root 669: STATIC_INLINE void wgfx_flushline (void)
1.1 root 670: {
1.1.1.8 root 671: if (wgfx_linestart == 0xFFFFFFFF || !picasso_on)
1.1 root 672: return;
673: wgfx_do_flushline ();
674: }
675:
676: static int renderinfo_is_current_screen (struct RenderInfo *ri)
677: {
1.1.1.8 root 678: if (!picasso_on)
1.1 root 679: return 0;
1.1.1.3 root 680: if (ri->Memory != gfxmemory + (picasso96_state.Address - gfxmem_start))
1.1 root 681: return 0;
1.1.1.3 root 682:
1.1 root 683: return 1;
684: }
685:
686: /* Clear our screen, since we've got a new Picasso screen-mode, and refresh with the proper contents
1.1.1.2 root 687: * This is called on several occasions:
688: * 1. Amiga-->Picasso transition, via SetSwitch()
689: * 2. Picasso-->Picasso transition, via SetPanning().
690: * 3. whenever the graphics code notifies us that the screen contents have been lost.
691: */
692: void picasso_refresh (void)
1.1 root 693: {
694: struct RenderInfo ri;
695:
1.1.1.8 root 696: if (!picasso_on)
1.1 root 697: return;
698:
699: /* Make sure that the first time we show a Picasso video mode, we don't blit any crap.
700: * We can do this by checking if we have an Address yet. */
701: if (picasso96_state.Address) {
1.1.1.12 root 702: unsigned int width, height;
1.1 root 703: /* blit the stuff from our static frame-buffer to the gfx-card */
1.1.1.12 root 704: ri.Memory = gfxmemory + (picasso96_state.Address - gfxmem_start);
1.1 root 705: ri.BytesPerRow = picasso96_state.BytesPerRow;
706: ri.RGBFormat = picasso96_state.RGBFormat;
1.1.1.12 root 707:
708: if (set_panning_called) {
709: width = picasso96_state.VirtualWidth;
710: height = picasso96_state.VirtualHeight;
711: } else {
712: width = picasso96_state.Width;
713: height = picasso96_state.Height;
714: }
715:
716: do_blit (&ri, picasso96_state.BytesPerPixel, 0, 0, 0, 0, width, height, BLIT_SRC, 0);
1.1 root 717: } else
1.1.1.2 root 718: write_log ("ERROR - picasso_refresh() can't refresh!\n");
1.1 root 719: }
720:
721: /*
722: * BOOL FindCard(struct BoardInfo *bi); and
723: *
724: * FindCard is called in the first stage of the board initialisation and
725: * configuration and is used to look if there is a free and unconfigured
726: * board of the type the driver is capable of managing. If it finds one,
727: * it immediately reserves it for use by Picasso96, usually by clearing
728: * the CDB_CONFIGME bit in the flags field of the ConfigDev struct of
729: * this expansion card. But this is only a common example, a driver can
730: * do whatever it wants to mark this card as used by the driver. This
731: * mechanism is intended to ensure that a board is only configured and
732: * used by one driver. FindBoard also usually fills some fields of the
733: * BoardInfo struct supplied by the caller, the rtg.library, for example
734: * the MemoryBase, MemorySize and RegisterBase fields.
735: */
736: uae_u32 picasso_FindCard (void)
737: {
1.1.1.2 root 738: uaecptr AmigaBoardInfo = m68k_areg (regs, 0);
1.1 root 739: /* NOTES: See BoardInfo struct definition in Picasso96 dev info */
740:
1.1.1.2 root 741: if (allocated_gfxmem && !picasso96_state.CardFound) {
1.1 root 742: /* Fill in MemoryBase, MemorySize */
1.1.1.2 root 743: put_long (AmigaBoardInfo + PSSO_BoardInfo_MemoryBase, gfxmem_start);
1.1 root 744: /* size of memory, minus a 32K chunk: 16K for pattern bitmaps, 16K for resolution list */
1.1.1.2 root 745: put_long (AmigaBoardInfo + PSSO_BoardInfo_MemorySize, allocated_gfxmem - 32768);
1.1 root 746:
1.1.1.8 root 747: picasso96_state.CardFound = 1; /* mark our "card" as being found */
1.1 root 748: return -1;
749: } else
750: return 0;
751: }
752:
753: static void FillBoardInfo (uaecptr amigamemptr, struct LibResolution *res, struct PicassoResolution *dm)
754: {
755: char *uaememptr;
756: switch (dm->depth) {
1.1.1.8 root 757: case 1:
1.1 root 758: res->Modes[CHUNKY] = amigamemptr;
759: break;
1.1.1.8 root 760: case 2:
1.1 root 761: res->Modes[HICOLOR] = amigamemptr;
762: break;
1.1.1.8 root 763: case 3:
1.1 root 764: res->Modes[TRUECOLOR] = amigamemptr;
765: break;
1.1.1.8 root 766: default:
1.1 root 767: res->Modes[TRUEALPHA] = amigamemptr;
768: break;
769: }
1.1.1.8 root 770: uaememptr = gfxmem_xlate (amigamemptr); /* I know that amigamemptr is inside my gfxmem chunk, so I can just do the xlate() */
771: memset (uaememptr, 0, PSSO_ModeInfo_sizeof); /* zero out our ModeInfo struct */
1.1 root 772:
1.1.1.2 root 773: put_word (amigamemptr + PSSO_ModeInfo_Width, dm->res.width);
774: put_word (amigamemptr + PSSO_ModeInfo_Height, dm->res.height);
775: put_byte (amigamemptr + PSSO_ModeInfo_Depth, dm->depth * 8);
776: put_byte (amigamemptr + PSSO_ModeInfo_Flags, 0);
777: put_word (amigamemptr + PSSO_ModeInfo_HorTotal, dm->res.width);
778: put_word (amigamemptr + PSSO_ModeInfo_HorBlankSize, 0);
779: put_word (amigamemptr + PSSO_ModeInfo_HorSyncStart, 0);
780: put_word (amigamemptr + PSSO_ModeInfo_HorSyncSize, 0);
781: put_byte (amigamemptr + PSSO_ModeInfo_HorSyncSkew, 0);
782: put_byte (amigamemptr + PSSO_ModeInfo_HorEnableSkew, 0);
783:
784: put_word (amigamemptr + PSSO_ModeInfo_VerTotal, dm->res.height);
785: put_word (amigamemptr + PSSO_ModeInfo_VerBlankSize, 0);
786: put_word (amigamemptr + PSSO_ModeInfo_VerSyncStart, 0);
787: put_word (amigamemptr + PSSO_ModeInfo_VerSyncSize, 0);
1.1 root 788:
1.1.1.2 root 789: put_byte (amigamemptr + PSSO_ModeInfo_first_union, 98);
790: put_byte (amigamemptr + PSSO_ModeInfo_second_union, 14);
1.1 root 791:
1.1.1.2 root 792: put_long (amigamemptr + PSSO_ModeInfo_PixelClock, dm->res.width * dm->res.height * dm->refresh);
1.1 root 793: }
794:
1.1.1.4 root 795: static uae_u32 AssignModeID (int i, int count)
796: {
797: if (DisplayModes[i].res.width == 320 && DisplayModes[i].res.height == 200)
798: return 0x50001000;
799: else if (DisplayModes[i].res.width == 320 && DisplayModes[i].res.height == 240)
800: return 0x50011000;
801: else if (DisplayModes[i].res.width == 640 && DisplayModes[i].res.height == 400)
802: return 0x50021000;
803: else if (DisplayModes[i].res.width == 640 && DisplayModes[i].res.height == 480)
804: return 0x50031000;
805: else if (DisplayModes[i].res.width == 800 && DisplayModes[i].res.height == 600)
806: return 0x50041000;
807: else if (DisplayModes[i].res.width == 1024 && DisplayModes[i].res.height == 768)
808: return 0x50051000;
809: else if (DisplayModes[i].res.width == 1152 && DisplayModes[i].res.height == 864)
810: return 0x50061000;
811: else if (DisplayModes[i].res.width == 1280 && DisplayModes[i].res.height == 1024)
812: return 0x50071000;
813: else if (DisplayModes[i].res.width == 1600 && DisplayModes[i].res.height == 1280)
814: return 0x50081000;
815:
816: return 0x50091000 + count * 0x10000;
817: }
818:
1.1 root 819: /****************************************
820: * InitCard()
821: *
822: * a2: BoardInfo structure ptr - Amiga-based address in Intel endian-format
823: *
824: * Job - fill in the following structure members:
825: * gbi_RGBFormats: the pixel formats that the host-OS of UAE supports
826: * If UAE is running in a window, it should ONLY report the pixel format of the host-OS desktop
827: * If UAE is running full-screen, it should report ALL pixel formats that the host-OS can handle in full-screen
828: * NOTE: If full-screen, and the user toggles to windowed-mode, all hell will break loose visually. Must inform
829: * user that they're doing something stupid (unless their desktop and full-screen colour modes match).
830: * gbi_SoftSpriteFlags: should be the same as above for now, until actual cursor support is added
831: * gbi_BitsPerCannon: could be 6 or 8 or ???, depending on the host-OS gfx-card
832: * gbi_MaxHorResolution: fill this in for all modes (even if you don't support them)
833: * gbi_MaxVerResolution: fill this in for all modes (even if you don't support them)
834: */
835: uae_u32 picasso_InitCard (void)
836: {
837: struct LibResolution res;
838: int i;
839: int ModeInfoStructureCount = 1, LibResolutionStructureCount = 0;
840: uaecptr amigamemptr = 0;
1.1.1.2 root 841: uaecptr AmigaBoardInfo = m68k_areg (regs, 2);
1.1.1.8 root 842: put_word (AmigaBoardInfo + PSSO_BoardInfo_BitsPerCannon, DX_BitsPerCannon ());
1.1.1.2 root 843: put_word (AmigaBoardInfo + PSSO_BoardInfo_RGBFormats, picasso96_pixel_format);
844: put_word (AmigaBoardInfo + PSSO_BoardInfo_SoftSpriteFlags, picasso96_pixel_format);
1.1.1.12 root 845: put_long (AmigaBoardInfo + PSSO_BoardInfo_BoardType, BT_uaegfx);
1.1.1.2 root 846: put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 0, planar.width);
847: put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 2, chunky.width);
848: put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 4, hicolour.width);
849: put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 6, truecolour.width);
850: put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxHorResolution + 8, alphacolour.width);
851: put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 0, planar.height);
852: put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 2, chunky.height);
853: put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 4, hicolour.height);
854: put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 6, truecolour.height);
855: put_word (AmigaBoardInfo + PSSO_BoardInfo_MaxVerResolution + 8, alphacolour.height);
1.1 root 856:
857: for (i = 0; i < mode_count;) {
858: int j = i;
859: /* Add a LibResolution structure to the ResolutionsList MinList in our BoardInfo */
1.1.1.4 root 860: res.DisplayID = AssignModeID (i, LibResolutionStructureCount);
1.1 root 861: res.BoardInfo = AmigaBoardInfo;
862: res.Width = DisplayModes[i].res.width;
863: res.Height = DisplayModes[i].res.height;
864: res.Flags = P96F_PUBLIC;
865: res.P96ID[0] = 'P';
866: res.P96ID[1] = '9';
867: res.P96ID[2] = '6';
868: res.P96ID[3] = '-';
869: res.P96ID[4] = '0';
870: res.P96ID[5] = ':';
871: strcpy (res.Name, "uaegfx:");
1.1.1.3 root 872: strncat (res.Name, DisplayModes[i].name, strchr (DisplayModes[i].name, ',') - DisplayModes[i].name);
1.1 root 873: res.Modes[PLANAR] = 0;
874: res.Modes[CHUNKY] = 0;
875: res.Modes[HICOLOR] = 0;
876: res.Modes[TRUECOLOR] = 0;
877: res.Modes[TRUEALPHA] = 0;
878:
879: do {
880: /* Handle this display mode's depth */
1.1.1.12 root 881: /* Only add the modes when there is enough P96 RTG memory to hold the bitmap */
882: long required = DisplayModes[i].res.width * DisplayModes[i].res.height * DisplayModes[i].depth;
883: if (allocated_gfxmem - 32768 > required) {
884: amigamemptr = gfxmem_start + allocated_gfxmem - (PSSO_ModeInfo_sizeof * ModeInfoStructureCount++);
885: FillBoardInfo (amigamemptr, &res, &DisplayModes[i]);
886: }
1.1 root 887: i++;
888: } while (i < mode_count
889: && DisplayModes[i].res.width == DisplayModes[j].res.width
890: && DisplayModes[i].res.height == DisplayModes[j].res.height);
891:
1.1.1.2 root 892: amigamemptr = gfxmem_start + allocated_gfxmem - 16384 + (PSSO_LibResolution_sizeof * LibResolutionStructureCount++);
1.1 root 893: CopyLibResolutionStructureU2A (&res, amigamemptr);
1.1.1.8 root 894: DumpLibResolutionStructure (amigamemptr);
1.1 root 895: AmigaListAddTail (AmigaBoardInfo + PSSO_BoardInfo_ResolutionsList, amigamemptr);
896: }
897:
898: return 0;
899: }
900:
901: extern int x_size, y_size;
902:
903: /*
904: * SetSwitch:
905: * a0: struct BoardInfo
906: * d0.w: BOOL state
907: * this function should set a board switch to let the Amiga signal pass
908: * through when supplied with a 0 in d0 and to show the board signal if
909: * a 1 is passed in d0. You should remember the current state of the
910: * switch to avoid unneeded switching. If your board has no switch, then
911: * simply supply a function that does nothing except a RTS.
912: *
913: * NOTE: Return the opposite of the switch-state. BDK
914: */
915: uae_u32 picasso_SetSwitch (void)
916: {
1.1.1.2 root 917: uae_u16 flag = m68k_dreg (regs, 0) & 0xFFFF;
1.1 root 918:
919: /* Do not switch immediately. Tell the custom chip emulation about the
920: * desired state, and wait for custom.c to call picasso_enablescreen
921: * whenever it is ready to change the screen state. */
922: picasso_requested_on = !!flag;
1.1.1.11 root 923: #if 0
1.1.1.8 root 924: write_log ("SetSwitch() - trying to show %s screen\n", flag ? "picasso96" : "amiga");
1.1.1.11 root 925: #endif
1.1 root 926: /* Put old switch-state in D0 */
927: return !flag;
928: }
929:
930: void picasso_enablescreen (int on)
931: {
932: wgfx_linestart = 0xFFFFFFFF;
933: picasso_refresh ();
1.1.1.11 root 934: #if 0
1.1.1.8 root 935: write_log ("SetSwitch() - showing %s screen\n", on ? "picasso96" : "amiga");
1.1.1.11 root 936: #endif
937: }
938:
939: static int first_color_changed = 256;
940: static int last_color_changed = -1;
941:
942: void picasso_handle_vsync (void)
943: {
944: if (first_color_changed < last_color_changed) {
1.1.1.12 root 945: DX_SetPalette (first_color_changed, last_color_changed - first_color_changed);
1.1.1.11 root 946: /* If we're emulating a CLUT mode, we need to redraw the entire screen. */
947: if (picasso_vidinfo.rgbformat != picasso96_state.RGBFormat)
948: picasso_refresh ();
949: }
950:
951: first_color_changed = 256;
952: last_color_changed = -1;
1.1 root 953: }
954:
1.1.1.12 root 955: void picasso_clip_mouse (int *px, int *py)
956: {
957: int xoff = picasso96_state.XOffset;
958: int yoff = picasso96_state.YOffset;
959: if (*px < -xoff)
960: *px = -xoff;
961: if (*px + xoff > picasso_vidinfo.width)
962: *px = picasso_vidinfo.width - xoff;
963: if (*py < -yoff)
964: *py = -yoff;
965: if (*py + yoff > picasso_vidinfo.height)
966: *py = picasso_vidinfo.height - yoff;
967: }
968:
1.1 root 969: /*
970: * SetColorArray:
971: * a0: struct BoardInfo
972: * d0.w: startindex
973: * d1.w: count
974: * when this function is called, your driver has to fetch "count" color
975: * values starting at "startindex" from the CLUT field of the BoardInfo
976: * structure and write them to the hardware. The color values are always
977: * between 0 and 255 for each component regardless of the number of bits
978: * per cannon your board has. So you might have to shift the colors
979: * before writing them to the hardware.
980: */
981: uae_u32 picasso_SetColorArray (void)
982: {
983: /* Fill in some static UAE related structure about this new CLUT setting
984: * We need this for CLUT-based displays, and for mapping CLUT to hi/true colour */
1.1.1.2 root 985: uae_u16 start = m68k_dreg (regs, 0);
986: uae_u16 count = m68k_dreg (regs, 1);
1.1 root 987: int i;
1.1.1.2 root 988: uaecptr boardinfo = m68k_areg (regs, 0);
1.1 root 989: uaecptr clut = boardinfo + PSSO_BoardInfo_CLUT + start * 3;
1.1.1.2 root 990: int changed = 0;
1.1 root 991:
992: for (i = start; i < start + count; i++) {
1.1.1.2 root 993: int r = get_byte (clut);
994: int g = get_byte (clut + 1);
995: int b = get_byte (clut + 2);
996:
1.1.1.8 root 997: changed |= (picasso96_state.CLUT[i].Red != r || picasso96_state.CLUT[i].Green != g || picasso96_state.CLUT[i].Blue != b);
998:
999: picasso96_state.CLUT[i].Red = r;
1.1.1.2 root 1000: picasso96_state.CLUT[i].Green = g;
1001: picasso96_state.CLUT[i].Blue = b;
1.1 root 1002: clut += 3;
1003: }
1.1.1.2 root 1004: if (changed) {
1.1.1.11 root 1005: if (start < first_color_changed)
1006: first_color_changed = start;
1007: if (start + count > last_color_changed)
1008: last_color_changed = start + count;
1.1 root 1009: }
1.1.1.2 root 1010: /*write_log ("SetColorArray(%d,%d)\n", start, count); */
1.1.1.4 root 1011: return 1;
1.1 root 1012: }
1013:
1014: /*
1015: * SetDAC:
1016: * a0: struct BoardInfo
1017: * d7: RGBFTYPE RGBFormat
1018: * This function is called whenever the RGB format of the display changes,
1019: * e.g. from chunky to TrueColor. Usually, all you have to do is to set
1020: * the RAMDAC of your board accordingly.
1021: */
1022: uae_u32 picasso_SetDAC (void)
1023: {
1024: /* Fill in some static UAE related structure about this new DAC setting
1025: * Lets us keep track of what pixel format the Amiga is thinking about in our frame-buffer */
1026:
1.1.1.2 root 1027: write_log ("SetDAC()\n");
1.1.1.4 root 1028: return 1;
1.1 root 1029: }
1030:
1.1.1.6 root 1031: static void init_picasso_screen (void)
1032: {
1.1.1.12 root 1033: int width = picasso96_state.Width;
1034: int height = picasso96_state.Height;
1035: int vwidth = picasso96_state.VirtualWidth;
1036: int vheight = picasso96_state.VirtualHeight;
1037: int xoff = 0;
1038: int yoff = 0;
1039:
1.1.1.8 root 1040: if (!set_gc_called)
1.1.1.6 root 1041: return;
1042:
1.1.1.12 root 1043: if (set_panning_called) {
1044: picasso96_state.Extent = picasso96_state.Address + (picasso96_state.BytesPerRow * vheight);
1045: xoff = picasso96_state.XOffset;
1046: yoff = picasso96_state.YOffset;
1047: }
1.1.1.6 root 1048:
1.1.1.12 root 1049: gfx_set_picasso_modeinfo (width, height, picasso96_state.GC_Depth, picasso96_state.RGBFormat);
1.1.1.6 root 1050: DX_SetPalette (0, 256);
1051:
1052: wgfx_linestart = 0xFFFFFFFF;
1053: picasso_refresh ();
1054: }
1055:
1.1 root 1056: /*
1057: * SetGC:
1058: * a0: struct BoardInfo
1059: * a1: struct ModeInfo
1060: * d0: BOOL Border
1061: * This function is called whenever another ModeInfo has to be set. This
1062: * function simply sets up the CRTC and TS registers to generate the
1063: * timing used for that screen mode. You should not set the DAC, clocks
1064: * or linear start adress. They will be set when appropriate by their
1065: * own functions.
1066: */
1067: uae_u32 picasso_SetGC (void)
1068: {
1069: /* Fill in some static UAE related structure about this new ModeInfo setting */
1.1.1.2 root 1070: uaecptr modeinfo = m68k_areg (regs, 1);
1.1 root 1071:
1072: picasso96_state.Width = get_word (modeinfo + PSSO_ModeInfo_Width);
1.1.1.8 root 1073: picasso96_state.VirtualWidth = picasso96_state.Width; /* in case SetPanning doesn't get called */
1.1 root 1074:
1075: picasso96_state.Height = get_word (modeinfo + PSSO_ModeInfo_Height);
1076: picasso96_state.VirtualHeight = picasso96_state.Height;
1077:
1078: picasso96_state.GC_Depth = get_byte (modeinfo + PSSO_ModeInfo_Depth);
1079: picasso96_state.GC_Flags = get_byte (modeinfo + PSSO_ModeInfo_Flags);
1080:
1.1.1.13 root 1081: P96TRACE (("SetGC(%d,%d,%d)\n", picasso96_state.Width, picasso96_state.Height, picasso96_state.GC_Depth));
1.1 root 1082:
1.1.1.8 root 1083: set_gc_called = 1; /* @@@ when do we need to reset this? */
1.1.1.6 root 1084: init_picasso_screen ();
1.1.1.4 root 1085: return 1;
1.1 root 1086: }
1087:
1088: /*
1089: * SetPanning:
1090: * a0: struct BoardInfo
1091: * a1: UBYTE *Memory
1092: * d0: uae_u16 Width
1093: * d1: WORD XOffset
1094: * d2: WORD YOffset
1095: * d7: RGBFTYPE RGBFormat
1096: * This function sets the view origin of a display which might also be
1097: * overscanned. In register a1 you get the start address of the screen
1098: * bitmap on the Amiga side. You will have to subtract the starting
1099: * address of the board memory from that value to get the memory start
1100: * offset within the board. Then you get the offset in pixels of the
1101: * left upper edge of the visible part of an overscanned display. From
1102: * these values you will have to calculate the LinearStartingAddress
1103: * fields of the CRTC registers.
1104:
1105: * NOTE: SetPanning() can be used to know when a Picasso96 screen is
1106: * being opened. Better to do the appropriate clearing of the
1107: * background here than in SetSwitch() derived functions,
1108: * because SetSwitch() is not called for subsequent Picasso screens.
1109: */
1110: uae_u32 picasso_SetPanning (void)
1111: {
1.1.1.2 root 1112: uae_u16 Width = m68k_dreg (regs, 0);
1113: uaecptr start_of_screen = m68k_areg (regs, 1);
1.1.1.12 root 1114: uaecptr bi = m68k_areg (regs, 0);
1115: uaecptr bmeptr = get_long (bi + PSSO_BoardInfo_BitMapExtra); /* Get our BoardInfo ptr's BitMapExtra ptr */
1116: int oldxoff = picasso96_state.XOffset;
1117: int oldyoff = picasso96_state.YOffset;
1118: #if 0
1119: /* @@@ This is in WinUAE, but it breaks things. */
1120: if (oldscr == 0) {
1121: oldscr = start_of_screen;
1122: }
1123: if ((oldscr != start_of_screen)) {
1124: set_gc_called = 0;
1125: oldscr = start_of_screen;
1126: }
1127: #endif
1.1 root 1128:
1.1.1.8 root 1129: picasso96_state.Address = start_of_screen; /* Amiga-side address */
1130: picasso96_state.XOffset = (uae_s16) m68k_dreg (regs, 1);
1131: picasso96_state.YOffset = (uae_s16) m68k_dreg (regs, 2);
1.1.1.12 root 1132: picasso96_state.VirtualWidth = get_word (bmeptr + PSSO_BitMapExtra_Width);
1133: picasso96_state.VirtualHeight = get_word (bmeptr + PSSO_BitMapExtra_Height);
1.1.1.2 root 1134: picasso96_state.RGBFormat = m68k_dreg (regs, 7);
1135: picasso96_state.BytesPerPixel = GetBytesPerPixel (picasso96_state.RGBFormat);
1.1 root 1136: picasso96_state.BytesPerRow = Width * picasso96_state.BytesPerPixel;
1137:
1.1.1.6 root 1138: set_panning_called = 1;
1.1.1.13 root 1139: P96TRACE (("SetPanning(%d, %d, %d) Start 0x%x, BPR %d\n",
1140: Width, picasso96_state.XOffset, picasso96_state.YOffset, start_of_screen, picasso96_state.BytesPerRow));
1.1 root 1141:
1.1.1.6 root 1142: init_picasso_screen ();
1.1 root 1143:
1.1.1.12 root 1144: lastmx += oldxoff - picasso96_state.XOffset;
1145: lastmy += oldyoff - picasso96_state.YOffset;
1146:
1.1.1.4 root 1147: return 1;
1.1 root 1148: }
1149:
1.1.1.8 root 1150: static void do_xor8 (uae_u8 * ptr, long len, uae_u32 val)
1.1 root 1151: {
1152: int i;
1153: #if 0 && defined ALIGN_POINTER_TO32
1.1.1.8 root 1154: int align_adjust = ALIGN_POINTER_TO32 (ptr);
1.1 root 1155: int len2;
1156:
1157: len -= align_adjust;
1158: while (align_adjust) {
1159: *ptr ^= val;
1160: ptr++;
1161: align_adjust--;
1162: }
1163: len2 = len >> 2;
1164: len -= len2 << 2;
1165: for (i = 0; i < len2; i++, ptr += 4) {
1.1.1.8 root 1166: *(uae_u32 *) ptr ^= val;
1.1 root 1167: }
1168: while (len) {
1169: *ptr ^= val;
1170: ptr++;
1171: len--;
1172: }
1173: return;
1174: #endif
1175: for (i = 0; i < len; i++, ptr++) {
1176: do_put_mem_byte (ptr, do_get_mem_byte (ptr) ^ val);
1177: }
1178: }
1179:
1180: /*
1181: * InvertRect:
1182: *
1183: * Inputs:
1184: * a0:struct BoardInfo *bi
1185: * a1:struct RenderInfo *ri
1186: * d0.w:X
1187: * d1.w:Y
1188: * d2.w:Width
1189: * d3.w:Height
1190: * d4.l:Mask
1191: * d7.l:RGBFormat
1192: *
1193: * This function is used to invert a rectangular area on the board. It is called by BltBitMap,
1194: * BltPattern and BltTemplate.
1195: */
1196: uae_u32 picasso_InvertRect (void)
1197: {
1.1.1.2 root 1198: uaecptr renderinfo = m68k_areg (regs, 1);
1.1.1.8 root 1199: unsigned long X = (uae_u16) m68k_dreg (regs, 0);
1200: unsigned long Y = (uae_u16) m68k_dreg (regs, 1);
1201: unsigned long Width = (uae_u16) m68k_dreg (regs, 2);
1202: unsigned long Height = (uae_u16) m68k_dreg (regs, 3);
1.1.1.2 root 1203: uae_u32 mask = m68k_dreg (regs, 4);
1204: int Bpp = GetBytesPerPixel (m68k_dreg (regs, 7));
1.1 root 1205: uae_u32 xorval;
1.1.1.5 root 1206: unsigned int lines;
1.1 root 1207: struct RenderInfo ri;
1.1.1.12 root 1208: uae_u8 *uae_mem;
1.1.1.5 root 1209: unsigned long width_in_bytes;
1.1 root 1210:
1211: wgfx_flushline ();
1212:
1.1.1.8 root 1213: if (!CopyRenderInfoStructureA2U (renderinfo, &ri))
1.1 root 1214: return 0;
1215:
1.1.1.13 root 1216: P96TRACE (("InvertRect: X %d Y %d Width %d Height %d\n", X, Y, Width, Height));
1.1.1.8 root 1217: /*write_log ("InvertRect %d %lx\n", Bpp, (long)mask); */
1.1 root 1218:
1219: /* ??? Brian? mask used to be 32 bit, but it appears that only 8 bit
1220: * values are passed to this function. This code here seems to work
1221: * much better... */
1.1.1.12 root 1222: if (mask != 0xFF && Bpp > 1) {
1.1.1.2 root 1223: write_log ("InvertRect: not obeying mask 0x%x properly with Bpp %d.\n", mask, Bpp);
1.1 root 1224: mask = 0xFF;
1225: }
1226: if ((mask & ~0xFF) != 0) {
1.1.1.2 root 1227: write_log ("InvertRect: mask has high bits set!\n");
1.1 root 1228: }
1229: xorval = 0x01010101 * (mask & 0xFF);
1230: width_in_bytes = Bpp * Width;
1.1.1.12 root 1231: uae_mem = ri.Memory + Y * ri.BytesPerRow + X * Bpp;
1.1 root 1232:
1.1.1.2 root 1233: for (lines = 0; lines < Height; lines++, uae_mem += ri.BytesPerRow)
1.1 root 1234: do_xor8 (uae_mem, width_in_bytes, xorval);
1.1.1.2 root 1235:
1.1 root 1236: if (renderinfo_is_current_screen (&ri)) {
1237: if (mask == 0xFF)
1.1.1.12 root 1238: do_invertrect (&ri, Bpp, X, Y, Width, Height);
1.1 root 1239: else
1.1.1.12 root 1240: do_blit (&ri, Bpp, X, Y, X, Y, Width, Height, BLIT_SRC, 0);
1.1 root 1241: }
1242:
1.1.1.8 root 1243: return 1; /* 1 if supported, 0 otherwise */
1.1 root 1244: }
1245:
1.1.1.12 root 1246: /* Fill a rectangle in the Amiga-memory frame buffer. */
1247:
1248: STATIC_INLINE void do_fillrect_frame_buffer (struct RenderInfo *ri, int X, int Y,
1249: int Width, int Height, uae_u32 Pen, int Bpp,
1250: RGBFTYPE RGBFormat)
1251: {
1252: uae_u8 *start, *oldstart, *dst;
1253: long lines, cols;
1254:
1255: /* Do our virtual frame-buffer memory. First, we do a single line fill by hand */
1256: oldstart = start = ri->Memory + Y * ri->BytesPerRow + X * Bpp;
1257: switch (Bpp) {
1258: case 1:
1259: memset (start, Pen, Width);
1260: break;
1261: case 2:
1262: for (cols = 0; cols < Width; cols++) {
1263: do_put_mem_word ((uae_u16 *) start, Pen);
1264: start += 2;
1265: }
1266: break;
1267: case 3:
1268: for (cols = 0; cols < Width; cols++) {
1269: do_put_mem_byte (start, Pen & 0x000000FF);
1270: start++;
1271: *(uae_u16 *) (start) = (Pen & 0x00FFFF00) >> 8;
1272: start += 2;
1273: }
1274: break;
1275: case 4:
1276: for (cols = 0; cols < Width; cols++) {
1277: /**start = Pen; */
1278: do_put_mem_long ((uae_u32 *) start, Pen);
1279: start += 4;
1280: }
1281: break;
1282: }
1283:
1284: dst = oldstart + ri->BytesPerRow;
1285: /* next, we do the remaining line fills via memcpy() for > 1 BPP, otherwise some more memset() calls */
1286: if (Bpp > 1) {
1287: for (lines = 0; lines < (Height - 1); lines++, dst += ri->BytesPerRow)
1288: memcpy (dst, oldstart, Width * Bpp);
1289: } else {
1290: for (lines = 0; lines < (Height - 1); lines++, dst += ri->BytesPerRow)
1291: memset (dst, Pen, Width);
1292: }
1293: }
1294:
1295:
1.1 root 1296: /***********************************************************
1297: FillRect:
1298: ***********************************************************
1299: * a0: struct BoardInfo *
1300: * a1: struct RenderInfo *
1301: * d0: WORD X
1302: * d1: WORD Y
1303: * d2: WORD Width
1304: * d3: WORD Height
1305: * d4: uae_u32 Pen
1306: * d5: UBYTE Mask
1307: * d7: uae_u32 RGBFormat
1308: ***********************************************************/
1309: uae_u32 picasso_FillRect (void)
1310: {
1.1.1.2 root 1311: uaecptr renderinfo = m68k_areg (regs, 1);
1.1.1.8 root 1312: unsigned long X = (uae_u16) m68k_dreg (regs, 0);
1313: unsigned long Y = (uae_u16) m68k_dreg (regs, 1);
1314: unsigned long Width = (uae_u16) m68k_dreg (regs, 2);
1315: unsigned long Height = (uae_u16) m68k_dreg (regs, 3);
1.1.1.2 root 1316: uae_u32 Pen = m68k_dreg (regs, 4);
1.1.1.8 root 1317: uae_u8 Mask = (uae_u8) m68k_dreg (regs, 5);
1.1.1.2 root 1318: uae_u32 RGBFormat = m68k_dreg (regs, 7);
1.1 root 1319:
1320: int Bpp;
1321: struct RenderInfo ri;
1322:
1323: wgfx_flushline ();
1324:
1.1.1.8 root 1325: if (!CopyRenderInfoStructureA2U (renderinfo, &ri) || Y == 0xFFFF)
1.1 root 1326: return 0;
1327:
1.1.1.13 root 1328: P96TRACE(("FillRect(%d, %d, %d, %d) Pen 0x%x BPP %d BPR %d Mask 0x%x\n",
1329: X, Y, Width, Height, Pen, Bpp, ri.BytesPerRow, Mask));
1330:
1.1 root 1331: if (ri.RGBFormat != RGBFormat)
1.1.1.2 root 1332: write_log ("Weird Stuff!\n");
1.1 root 1333:
1.1.1.2 root 1334: Bpp = GetBytesPerPixel (RGBFormat);
1.1 root 1335:
1.1.1.12 root 1336: /* write_log ("FillRect(%d, %d, %d, %d) Pen 0x%x BPP %d BPR %d Mask 0x%x\n",
1.1.1.8 root 1337: X, Y, Width, Height, Pen, Bpp, ri.BytesPerRow, Mask); */
1.1 root 1338:
1339: if (Mask == 0xFF) {
1.1.1.12 root 1340: do_fillrect_frame_buffer (&ri, X, Y, Width, Height, Pen, Bpp, RGBFormat);
1.1 root 1341:
1.1.1.2 root 1342: if (renderinfo_is_current_screen (&ri))
1.1.1.12 root 1343: do_fillrect (ri.Memory + Y * ri.BytesPerRow + X * Bpp, X, Y,
1344: Width, Height, Pen, Bpp, RGBFormat);
1.1.1.2 root 1345:
1.1 root 1346: return 1;
1347: }
1348:
1349: /* We get here only if Mask != 0xFF */
1350: if (Bpp != 1) {
1351: write_log ("Picasso: mask != 0xFF in truecolor mode!\n");
1352: return 0;
1353: }
1354: Pen &= Mask;
1355: Mask = ~Mask;
1356:
1.1.1.5 root 1357: {
1.1.1.12 root 1358: uae_u8 *start = ri.Memory + Y * ri.BytesPerRow + X * Bpp;
1.1.1.5 root 1359: uae_u8 *end = start + Height * ri.BytesPerRow;
1360: for (; start != end; start += ri.BytesPerRow) {
1361: uae_u8 *p = start;
1362: unsigned long cols;
1363: for (cols = 0; cols < Width; cols++) {
1364: uae_u32 tmpval = do_get_mem_byte (p + cols) & Mask;
1365: do_put_mem_byte (p + cols, Pen | tmpval);
1366: }
1.1 root 1367: }
1368: }
1.1.1.12 root 1369:
1.1 root 1370: if (renderinfo_is_current_screen (&ri))
1.1.1.12 root 1371: do_blit (&ri, Bpp, X, Y, X, Y, Width, Height, BLIT_SRC, 0);
1.1 root 1372:
1373: return 1;
1374: }
1375:
1376: /*
1377: * BlitRect() is a generic (any chunky pixel format) rectangle copier
1378: * NOTE: If dstri is NULL, then we're only dealing with one RenderInfo area, and called from picasso_BlitRect()
1379: */
1380: static void BlitRect (struct RenderInfo *ri, struct RenderInfo *dstri,
1.1.1.5 root 1381: unsigned long srcx, unsigned long srcy, unsigned long dstx, unsigned long dsty,
1.1.1.12 root 1382: unsigned long width, unsigned long height, uae_u8 mask, BLIT_OPCODE opcode)
1.1 root 1383: {
1384: uae_u8 *src, *dst, *tmp, *tmp2, *tmp3;
1.1.1.5 root 1385: unsigned long lines;
1.1.1.8 root 1386: uae_u8 Bpp = GetBytesPerPixel (ri->RGBFormat);
1.1 root 1387: uae_u8 *blitsrc;
1388: unsigned long total_width = width * Bpp;
1389: unsigned long linewidth = (total_width + 15) & ~15;
1390: int cant_blit = 1;
1391:
1392: /*
1393: * If we have no destination RenderInfo, then we're dealing with a single-buffer action, called
1394: * from picasso_BlitRect(). The code up to the DX_xxxxx() functions deals with the frame-buffer,
1395: * while the DX_ functions actually deal with the visible screen.
1396: *
1397: * If we have a destination RenderInfo, then we've been called from picasso_BlitRectNoMaskComplete()
1398: * and we need to put the results on the screen from the frame-buffer.
1399: */
1400: if (dstri == NULL) {
1401: dstri = ri;
1402: cant_blit = 0;
1403: }
1404:
1405: /* Do our virtual frame-buffer memory first */
1.1.1.8 root 1406: src = ri->Memory + srcx * Bpp + srcy * ri->BytesPerRow;
1407: dst = dstri->Memory + dstx * Bpp + dsty * dstri->BytesPerRow;
1.1 root 1408: blitsrc = dst;
1409: if (mask != 0xFF && Bpp > 1)
1.1.1.2 root 1410: write_log ("ERROR - not obeying BlitRect() mask 0x%x properly with Bpp %d.\n", mask, Bpp);
1.1 root 1411:
1412: if (mask == 0xFF || Bpp > 1) {
1413: /* handle normal case efficiently */
1414: if (ri->Memory == dstri->Memory && dsty == srcy) {
1.1.1.5 root 1415: unsigned long i;
1.1 root 1416: for (i = 0; i < height; i++, src += ri->BytesPerRow, dst += dstri->BytesPerRow)
1417: memmove (dst, src, total_width);
1418: } else if (dsty < srcy) {
1.1.1.5 root 1419: unsigned long i;
1.1 root 1420: for (i = 0; i < height; i++, src += ri->BytesPerRow, dst += dstri->BytesPerRow)
1421: memcpy (dst, src, total_width);
1422: } else {
1.1.1.5 root 1423: unsigned long i;
1.1.1.8 root 1424: src += (height - 1) * ri->BytesPerRow;
1425: dst += (height - 1) * dstri->BytesPerRow;
1.1 root 1426: for (i = 0; i < height; i++, src -= ri->BytesPerRow, dst -= dstri->BytesPerRow)
1427: memcpy (dst, src, total_width);
1428: }
1.1.1.12 root 1429: if (cant_blit)
1430: srcx = dstx, srcy = dsty;
1.1 root 1431: if (renderinfo_is_current_screen (dstri))
1.1.1.12 root 1432: do_blit (dstri, Bpp, srcx, srcy, dstx, dsty, width, height, opcode, !cant_blit);
1.1 root 1433: return;
1434: }
1435:
1.1.1.8 root 1436: tmp3 = tmp2 = tmp = xmalloc (linewidth * height); /* allocate enough memory for the src-rect */
1.1 root 1437: if (!tmp)
1438: return;
1439:
1440: /* copy the src-rect into our temporary buffer space */
1441: for (lines = 0; lines < height; lines++, src += ri->BytesPerRow, tmp2 += linewidth) {
1442: memcpy (tmp2, src, total_width);
1443: }
1444:
1445: /* copy the temporary buffer to the destination */
1446: for (lines = 0; lines < height; lines++, dst += dstri->BytesPerRow, tmp += linewidth) {
1.1.1.5 root 1447: unsigned long cols;
1.1 root 1448: for (cols = 0; cols < width; cols++) {
1449: dst[cols] &= ~mask;
1450: dst[cols] |= tmp[cols] & mask;
1451: }
1452: }
1453: if (renderinfo_is_current_screen (dstri))
1.1.1.12 root 1454: do_blit (dstri, Bpp, dstx, dsty, dstx, dsty, width, height, opcode, 0);
1455:
1.1 root 1456: /* free the temp-buf */
1457: free (tmp3);
1458:
1459: }
1460:
1461: /***********************************************************
1462: BlitRect:
1463: ***********************************************************
1464: * a0: struct BoardInfo
1465: * a1: struct RenderInfo
1466: * d0: WORD SrcX
1467: * d1: WORD SrcY
1468: * d2: WORD DstX
1469: * d3: WORD DstY
1470: * d4: WORD Width
1471: * d5: WORD Height
1472: * d6: UBYTE Mask
1473: * d7: uae_u32 RGBFormat
1474: ***********************************************************/
1475: uae_u32 picasso_BlitRect (void)
1476: {
1.1.1.2 root 1477: uaecptr renderinfo = m68k_areg (regs, 1);
1.1.1.8 root 1478: unsigned long srcx = (uae_u16) m68k_dreg (regs, 0);
1479: unsigned long srcy = (uae_u16) m68k_dreg (regs, 1);
1480: unsigned long dstx = (uae_u16) m68k_dreg (regs, 2);
1481: unsigned long dsty = (uae_u16) m68k_dreg (regs, 3);
1482: unsigned long width = (uae_u16) m68k_dreg (regs, 4);
1483: unsigned long height = (uae_u16) m68k_dreg (regs, 5);
1484: uae_u8 Mask = (uae_u8) m68k_dreg (regs, 6);
1.1 root 1485:
1486: struct RenderInfo ri;
1487:
1488: wgfx_flushline ();
1489:
1.1.1.8 root 1490: if (!CopyRenderInfoStructureA2U (renderinfo, &ri))
1.1 root 1491: return 0;
1492:
1.1.1.13 root 1493: P96TRACE(("BlitRect(%d, %d, %d, %d, %d, %d, 0x%x)\n", srcx, srcy, dstx, dsty, width, height, Mask));
1.1.1.12 root 1494: BlitRect (&ri, NULL, srcx, srcy, dstx, dsty, width, height, Mask, BLIT_SRC);
1.1.1.2 root 1495: /*write_log ("BlitRect(%d, %d, %d, %d, %d, %d, 0x%x)\n", srcx, srcy, dstx, dsty, width, height, Mask); */
1.1 root 1496:
1497: return 1;
1498: }
1499:
1500: /***********************************************************
1501: BlitRectNoMaskComplete:
1502: ***********************************************************
1503: * a0: struct BoardInfo
1504: * a1: struct RenderInfo (src)
1505: * a2: struct RenderInfo (dst)
1506: * d0: WORD SrcX
1507: * d1: WORD SrcY
1508: * d2: WORD DstX
1509: * d3: WORD DstY
1510: * d4: WORD Width
1511: * d5: WORD Height
1512: * d6: UBYTE OpCode
1513: * d7: uae_u32 RGBFormat
1514: * NOTE: MUST return 0 in D0 if we're not handling this operation
1515: * because the RGBFormat or opcode aren't supported.
1516: * OTHERWISE return 1
1517: ***********************************************************/
1518: uae_u32 picasso_BlitRectNoMaskComplete (void)
1519: {
1.1.1.2 root 1520: uaecptr srcri = m68k_areg (regs, 1);
1521: uaecptr dstri = m68k_areg (regs, 2);
1.1.1.8 root 1522: unsigned long srcx = (uae_u16) m68k_dreg (regs, 0);
1523: unsigned long srcy = (uae_u16) m68k_dreg (regs, 1);
1524: unsigned long dstx = (uae_u16) m68k_dreg (regs, 2);
1525: unsigned long dsty = (uae_u16) m68k_dreg (regs, 3);
1526: unsigned long width = (uae_u16) m68k_dreg (regs, 4);
1527: unsigned long height = (uae_u16) m68k_dreg (regs, 5);
1.1.1.2 root 1528: uae_u8 OpCode = m68k_dreg (regs, 6);
1529: uae_u32 RGBFmt = m68k_dreg (regs, 7);
1.1 root 1530: struct RenderInfo src_ri, dst_ri;
1531:
1532: wgfx_flushline ();
1533:
1.1.1.8 root 1534: if (!CopyRenderInfoStructureA2U (srcri, &src_ri)
1535: || !CopyRenderInfoStructureA2U (dstri, &dst_ri))
1.1 root 1536: return 0;
1537:
1.1.1.13 root 1538: P96TRACE(("BlitRectNoMaskComplete() op 0x%2x, xy(%4d,%4d) --> xy(%4d,%4d), wh(%4d,%4d)\n",
1539: OpCode, srcx, srcy, dstx, dsty, width, height));
1.1 root 1540:
1541: switch (OpCode) {
1.1.1.8 root 1542: case 0x0C:
1.1.1.12 root 1543: BlitRect (&src_ri, &dst_ri, srcx, srcy, dstx, dsty, width, height, 0xFF, OpCode);
1.1 root 1544: return 1;
1545:
1.1.1.8 root 1546: default:
1.1 root 1547: /* FOR NOW! */
1548: return 0;
1549: }
1550: }
1551:
1552: /* This utility function is used both by BlitTemplate() and BlitPattern() */
1.1.1.8 root 1553: STATIC_INLINE void PixelWrite1 (uae_u8 * mem, int bits, uae_u32 fgpen, uae_u32 mask)
1.1 root 1554: {
1555: if (mask != 0xFF)
1556: fgpen = (fgpen & mask) | (do_get_mem_byte (mem + bits) & ~mask);
1557: do_put_mem_byte (mem + bits, fgpen);
1558: }
1559:
1.1.1.8 root 1560: STATIC_INLINE void PixelWrite2 (uae_u8 * mem, int bits, uae_u32 fgpen)
1.1 root 1561: {
1.1.1.8 root 1562: do_put_mem_word (((uae_u16 *) mem) + bits, fgpen);
1.1 root 1563: }
1564:
1.1.1.8 root 1565: STATIC_INLINE void PixelWrite3 (uae_u8 * mem, int bits, uae_u32 fgpen)
1.1 root 1566: {
1.1.1.8 root 1567: do_put_mem_byte (mem + bits * 3, fgpen & 0x000000FF);
1568: *(uae_u16 *) (mem + bits * 3 + 1) = (fgpen & 0x00FFFF00) >> 8;
1.1 root 1569: }
1570:
1.1.1.8 root 1571: STATIC_INLINE void PixelWrite4 (uae_u8 * mem, int bits, uae_u32 fgpen)
1.1 root 1572: {
1.1.1.8 root 1573: do_put_mem_long (((uae_u32 *) mem) + bits, fgpen);
1.1 root 1574: }
1575:
1.1.1.8 root 1576: STATIC_INLINE void PixelWrite (uae_u8 * mem, int bits, uae_u32 fgpen, uae_u8 Bpp, uae_u32 mask)
1.1 root 1577: {
1578: switch (Bpp) {
1579: case 1:
1580: if (mask != 0xFF)
1581: fgpen = (fgpen & mask) | (do_get_mem_byte (mem + bits) & ~mask);
1582: do_put_mem_byte (mem + bits, fgpen);
1583: break;
1584: case 2:
1.1.1.8 root 1585: do_put_mem_word (((uae_u16 *) mem) + bits, fgpen);
1.1 root 1586: break;
1587: case 3:
1.1.1.8 root 1588: do_put_mem_byte (mem + bits * 3, fgpen & 0x000000FF);
1589: *(uae_u16 *) (mem + bits * 3 + 1) = (fgpen & 0x00FFFF00) >> 8;
1.1 root 1590: break;
1591: case 4:
1.1.1.8 root 1592: do_put_mem_long (((uae_u32 *) mem) + bits, fgpen);
1.1 root 1593: break;
1594: }
1595: }
1596:
1597: /*
1598: * BlitPattern:
1599: *
1600: * Synopsis:BlitPattern(bi, ri, pattern, X, Y, Width, Height, Mask, RGBFormat);
1601: * Inputs:
1602: * a0:struct BoardInfo *bi
1603: * a1:struct RenderInfo *ri
1604: * a2:struct Pattern *pattern
1605: * d0.w:X
1606: * d1.w:Y
1607: * d2.w:Width
1608: * d3.w:Height
1609: * d4.w:Mask
1610: * d7.l:RGBFormat
1611: *
1612: * This function is used to paint a pattern on the board memory using the blitter. It is called by
1613: * BltPattern, if a AreaPtrn is used with positive AreaPtSz. The pattern consists of a b/w image
1614: * using a single plane of image data which will be expanded repeatedly to the destination RGBFormat
1615: * using ForeGround and BackGround pens as well as draw modes. The width of the pattern data is
1616: * always 16 pixels (one word) and the height is calculated as 2^Size. The data must be shifted up
1617: * and to the left by XOffset and YOffset pixels at the beginning.
1618: */
1619: uae_u32 picasso_BlitPattern (void)
1620: {
1.1.1.2 root 1621: uaecptr rinf = m68k_areg (regs, 1);
1622: uaecptr pinf = m68k_areg (regs, 2);
1.1.1.8 root 1623: unsigned long X = (uae_u16) m68k_dreg (regs, 0);
1624: unsigned long Y = (uae_u16) m68k_dreg (regs, 1);
1625: unsigned long W = (uae_u16) m68k_dreg (regs, 2);
1626: unsigned long H = (uae_u16) m68k_dreg (regs, 3);
1627: uae_u8 Mask = (uae_u8) m68k_dreg (regs, 4);
1.1.1.2 root 1628: uae_u32 RGBFmt = m68k_dreg (regs, 7);
1.1 root 1629:
1.1.1.3 root 1630: uae_u8 Bpp = GetBytesPerPixel (RGBFmt);
1.1 root 1631: int inversion = 0;
1632: struct RenderInfo ri;
1633: struct Pattern pattern;
1.1.1.5 root 1634: unsigned long rows;
1.1.1.2 root 1635: uae_u32 fgpen;
1.1.1.12 root 1636: uae_u8 *uae_mem;
1.1 root 1637: int xshift;
1.1.1.2 root 1638: unsigned long ysize_mask;
1.1 root 1639:
1640: wgfx_flushline ();
1641:
1.1.1.12 root 1642: if (! CopyRenderInfoStructureA2U (rinf, &ri)
1.1.1.8 root 1643: || !CopyPatternStructureA2U (pinf, &pattern))
1.1 root 1644: return 0;
1645:
1.1.1.8 root 1646: Bpp = GetBytesPerPixel (ri.RGBFormat);
1647: uae_mem = ri.Memory + Y * ri.BytesPerRow + X * Bpp; /* offset with address */
1.1 root 1648:
1649: if (pattern.DrawMode & INVERS)
1650: inversion = 1;
1651:
1652: pattern.DrawMode &= 0x03;
1653: if (Mask != 0xFF) {
1654: if (Bpp > 1)
1.1.1.2 root 1655: write_log ("ERROR - not obeying BlitPattern() mask 0x%x properly with Bpp %d.\n", Mask, Bpp);
1.1 root 1656: else if (pattern.DrawMode == COMP) {
1.1.1.2 root 1657: write_log ("ERROR - Unsupported Mask value 0x%x with COMP Draw in BlitPattern(), using fallback method.\n", Mask);
1.1 root 1658: return 0;
1659: }
1660: }
1661:
1.1.1.13 root 1662: P96TRACE (("BlitPattern() xy(%d,%d), wh(%d,%d) draw 0x%x, off(%d,%d), ph %d\n",
1663: X, Y, W, H, pattern.DrawMode, pattern.XOffset, pattern.YOffset, 1 << pattern.Size));
1.1 root 1664: #ifdef _DEBUG
1.1.1.8 root 1665: DumpPattern (&pattern);
1.1 root 1666: #endif
1667: ysize_mask = (1 << pattern.Size) - 1;
1668: xshift = pattern.XOffset & 15;
1669:
1670: for (rows = 0; rows < H; rows++, uae_mem += ri.BytesPerRow) {
1.1.1.5 root 1671: unsigned long prow = (rows + pattern.YOffset) & ysize_mask;
1.1.1.8 root 1672: unsigned int d = do_get_mem_word (((uae_u16 *) pattern.Memory) + prow);
1.1 root 1673: uae_u8 *uae_mem2 = uae_mem;
1.1.1.5 root 1674: unsigned long cols;
1.1 root 1675:
1676: if (xshift != 0)
1677: d = (d << xshift) | (d >> (16 - xshift));
1678:
1679: for (cols = 0; cols < W; cols += 16, uae_mem2 += Bpp << 4) {
1680: long bits;
1681: long max = W - cols;
1682: unsigned int data = d;
1683:
1684: if (max > 16)
1685: max = 16;
1.1.1.8 root 1686:
1.1 root 1687: for (bits = 0; bits < max; bits++) {
1688: int bit_set = data & 0x8000;
1689: data <<= 1;
1690: switch (pattern.DrawMode) {
1.1.1.8 root 1691: case JAM1:
1.1 root 1692: if (inversion)
1693: bit_set = !bit_set;
1694: if (bit_set)
1.1.1.2 root 1695: PixelWrite (uae_mem2, bits, pattern.FgPen, Bpp, Mask);
1.1 root 1696: break;
1.1.1.8 root 1697: case JAM2:
1.1 root 1698: if (inversion)
1699: bit_set = !bit_set;
1700: if (bit_set)
1.1.1.2 root 1701: PixelWrite (uae_mem2, bits, pattern.FgPen, Bpp, Mask);
1.1 root 1702: else
1.1.1.2 root 1703: PixelWrite (uae_mem2, bits, pattern.BgPen, Bpp, Mask);
1.1 root 1704: break;
1.1.1.8 root 1705: case COMP:
1.1 root 1706: if (bit_set) {
1707: fgpen = pattern.FgPen;
1708:
1709: switch (Bpp) {
1.1.1.8 root 1710: case 1:
1.1 root 1711: {
1712: uae_u8 *addr = uae_mem2 + bits;
1713: do_put_mem_byte (addr, do_get_mem_byte (addr) ^ fgpen);
1714: }
1715: break;
1.1.1.8 root 1716: case 2:
1.1 root 1717: {
1.1.1.8 root 1718: uae_u16 *addr = ((uae_u16 *) uae_mem2) + bits;
1.1 root 1719: do_put_mem_word (addr, do_get_mem_word (addr) ^ fgpen);
1720: }
1721: break;
1.1.1.8 root 1722: case 3:
1.1 root 1723: {
1.1.1.8 root 1724: uae_u32 *addr = (uae_u32 *) (uae_mem2 + bits * 3);
1.1 root 1725: do_put_mem_long (addr, do_get_mem_long (addr) ^ (fgpen & 0x00FFFFFF));
1726: }
1727: break;
1.1.1.8 root 1728: case 4:
1.1 root 1729: {
1.1.1.8 root 1730: uae_u32 *addr = ((uae_u32 *) uae_mem2) + bits;
1.1 root 1731: do_put_mem_long (addr, do_get_mem_long (addr) ^ fgpen);
1732: }
1733: break;
1734: }
1735: }
1736: break;
1737: }
1738: }
1739: }
1740: }
1741:
1742: if (renderinfo_is_current_screen (&ri))
1.1.1.12 root 1743: do_blit (&ri, Bpp, X, Y, X, Y, W, H, BLIT_SRC, 0);
1.1 root 1744:
1745: return 1;
1746: }
1747:
1748: /*************************************************
1749: BlitTemplate:
1750: **************************************************
1751: * Synopsis: BlitTemplate(bi, ri, template, X, Y, Width, Height, Mask, RGBFormat);
1752: * a0: struct BoardInfo *bi
1753: * a1: struct RenderInfo *ri
1754: * a2: struct Template *template
1755: * d0.w: X
1756: * d1.w: Y
1757: * d2.w: Width
1758: * d3.w: Height
1759: * d4.w: Mask
1760: * d7.l: RGBFormat
1761: *
1762: * This function is used to paint a template on the board memory using the blitter.
1763: * It is called by BltPattern and BltTemplate. The template consists of a b/w image
1764: * using a single plane of image data which will be expanded to the destination RGBFormat
1765: * using ForeGround and BackGround pens as well as draw modes.
1766: ***********************************************************************************/
1767: uae_u32 picasso_BlitTemplate (void)
1768: {
1769: uae_u8 inversion = 0;
1.1.1.2 root 1770: uaecptr rinf = m68k_areg (regs, 1);
1771: uaecptr tmpl = m68k_areg (regs, 2);
1.1.1.8 root 1772: unsigned long X = (uae_u16) m68k_dreg (regs, 0);
1773: unsigned long Y = (uae_u16) m68k_dreg (regs, 1);
1774: unsigned long W = (uae_u16) m68k_dreg (regs, 2);
1775: unsigned long H = (uae_u16) m68k_dreg (regs, 3);
1776: uae_u16 Mask = (uae_u16) m68k_dreg (regs, 4);
1.1 root 1777: struct Template tmp;
1778: struct RenderInfo ri;
1.1.1.5 root 1779: unsigned long rows;
1.1 root 1780: int bitoffset;
1.1.1.2 root 1781: uae_u32 fgpen;
1.1.1.12 root 1782: uae_u8 *uae_mem, Bpp;
1.1 root 1783: uae_u8 *tmpl_base;
1784:
1785: wgfx_flushline ();
1786:
1.1.1.8 root 1787: if (!CopyRenderInfoStructureA2U (rinf, &ri)
1788: || !CopyTemplateStructureA2U (tmpl, &tmp))
1.1 root 1789: return 0;
1790:
1.1.1.8 root 1791: Bpp = GetBytesPerPixel (ri.RGBFormat);
1792: uae_mem = ri.Memory + Y * ri.BytesPerRow + X * Bpp; /* offset into address */
1.1 root 1793:
1794: if (tmp.DrawMode & INVERS)
1795: inversion = 1;
1796:
1797: tmp.DrawMode &= 0x03;
1798: if (Mask != 0xFF) {
1799: if (Bpp > 1)
1.1.1.2 root 1800: write_log ("ERROR - not obeying BlitTemplate() mask 0x%x properly with Bpp %d.\n", Mask, Bpp);
1.1 root 1801: else if (tmp.DrawMode == COMP) {
1.1.1.2 root 1802: write_log ("ERROR - Unsupported Mask value 0x%x with COMP Draw in BlitTemplate(), using fallback method.\n", Mask);
1.1 root 1803: return 0;
1804: }
1805: }
1806:
1.1.1.13 root 1807: P96TRACE (("BlitTemplate() xy(%d,%d), wh(%d,%d) draw 0x%x fg 0x%x bg 0x%x \n",
1808: X, Y, W, H, tmp.DrawMode, tmp.FgPen, tmp.BgPen));
1.1 root 1809:
1810: bitoffset = tmp.XOffset % 8;
1811:
1812: #ifdef _DEBUG
1.1.1.8 root 1813: DumpTemplate (&tmp, W, H);
1.1 root 1814: #endif
1815:
1.1.1.8 root 1816: tmpl_base = tmp.Memory + tmp.XOffset / 8;
1.1 root 1817:
1818: for (rows = 0; rows < H; rows++, uae_mem += ri.BytesPerRow, tmpl_base += tmp.BytesPerRow) {
1.1.1.5 root 1819: unsigned long cols;
1.1 root 1820: uae_u8 *tmpl_mem = tmpl_base;
1821: uae_u8 *uae_mem2 = uae_mem;
1822: unsigned int data = *tmpl_mem;
1823:
1824: for (cols = 0; cols < W; cols += 8, uae_mem2 += Bpp << 3) {
1825: unsigned int byte;
1826: long bits;
1827: long max = W - cols;
1828:
1829: if (max > 8)
1830: max = 8;
1831:
1832: data <<= 8;
1833: data |= *++tmpl_mem;
1834:
1835: byte = data >> (8 - bitoffset);
1836:
1837: for (bits = 0; bits < max; bits++) {
1838: int bit_set = (byte & 0x80);
1839: byte <<= 1;
1840: switch (tmp.DrawMode) {
1.1.1.8 root 1841: case JAM1:
1.1 root 1842: if (inversion)
1843: bit_set = !bit_set;
1844: if (bit_set) {
1845: fgpen = tmp.FgPen;
1.1.1.8 root 1846: PixelWrite (uae_mem2, bits, fgpen, Bpp, Mask);
1.1 root 1847: }
1848: break;
1.1.1.8 root 1849: case JAM2:
1.1 root 1850: if (inversion)
1851: bit_set = !bit_set;
1852: fgpen = tmp.BgPen;
1853: if (bit_set)
1854: fgpen = tmp.FgPen;
1855:
1.1.1.8 root 1856: PixelWrite (uae_mem2, bits, fgpen, Bpp, Mask);
1.1 root 1857: break;
1.1.1.8 root 1858: case COMP:
1.1 root 1859: if (bit_set) {
1860: fgpen = tmp.FgPen;
1861:
1862: switch (Bpp) {
1.1.1.8 root 1863: case 1:
1.1 root 1864: {
1865: uae_u8 *addr = uae_mem2 + bits;
1866: do_put_mem_byte (addr, do_get_mem_byte (addr) ^ fgpen);
1867: }
1868: break;
1.1.1.8 root 1869: case 2:
1.1 root 1870: {
1.1.1.8 root 1871: uae_u16 *addr = ((uae_u16 *) uae_mem2) + bits;
1.1 root 1872: do_put_mem_word (addr, do_get_mem_word (addr) ^ fgpen);
1873: }
1874: break;
1.1.1.8 root 1875: case 3:
1.1 root 1876: {
1.1.1.8 root 1877: uae_u32 *addr = (uae_u32 *) (uae_mem2 + bits * 3);
1.1 root 1878: do_put_mem_long (addr, do_get_mem_long (addr) ^ (fgpen & 0x00FFFFFF));
1879: }
1880: break;
1.1.1.8 root 1881: case 4:
1.1 root 1882: {
1.1.1.8 root 1883: uae_u32 *addr = ((uae_u32 *) uae_mem2) + bits;
1.1 root 1884: do_put_mem_long (addr, do_get_mem_long (addr) ^ fgpen);
1885: }
1886: break;
1887: }
1888: }
1889: break;
1890: }
1891: }
1892: }
1893: }
1894:
1895: if (renderinfo_is_current_screen (&ri))
1.1.1.12 root 1896: do_blit (&ri, Bpp, X, Y, X, Y, W, H, BLIT_SRC, 0);
1.1 root 1897:
1898: return 1;
1899: }
1900:
1901: /*
1902: * CalculateBytesPerRow:
1903: * a0: struct BoardInfo
1904: * d0: uae_u16 Width
1905: * d7: RGBFTYPE RGBFormat
1906: * This function calculates the amount of bytes needed for a line of
1907: * "Width" pixels in the given RGBFormat.
1908: */
1909: uae_u32 picasso_CalculateBytesPerRow (void)
1910: {
1.1.1.2 root 1911: uae_u16 width = m68k_dreg (regs, 0);
1912: uae_u32 type = m68k_dreg (regs, 7);
1.1 root 1913:
1.1.1.8 root 1914: width = GetBytesPerPixel (type) * width;
1.1.1.13 root 1915: P96TRACE (("CalculateBytesPerRow() = %d\n", width));
1.1 root 1916:
1917: return width;
1918: }
1919:
1920: /*
1921: * SetDisplay:
1922: * a0: struct BoardInfo
1923: * d0: BOOL state
1924: * This function enables and disables the video display.
1925: *
1926: * NOTE: return the opposite of the state
1927: */
1928: uae_u32 picasso_SetDisplay (void)
1929: {
1.1.1.2 root 1930: uae_u32 state = m68k_dreg (regs, 0);
1.1.1.13 root 1931: P96TRACE (("SetDisplay(%d)\n", state));
1.1 root 1932: return !state;
1933: }
1934:
1935: /*
1936: * WaitVerticalSync:
1937: * a0: struct BoardInfo
1938: * This function waits for the next horizontal retrace.
1939: */
1940: uae_u32 picasso_WaitVerticalSync (void)
1941: {
1.1.1.8 root 1942: /*write_log ("WaitVerticalSync()\n"); */
1.1 root 1943: return 1;
1944: }
1945:
1946: /* NOTE: Watch for those planeptrs of 0x00000000 and 0xFFFFFFFF for all zero / all one bitmaps !!!! */
1.1.1.8 root 1947: static void PlanarToChunky (struct RenderInfo *ri, struct BitMap *bm,
1948: unsigned long srcx, unsigned long srcy,
1949: unsigned long dstx, unsigned long dsty, unsigned long width, unsigned long height, uae_u8 mask)
1.1 root 1950: {
1.1.1.2 root 1951: int j;
1.1 root 1952:
1.1.1.8 root 1953: uae_u8 *PLANAR[8], *image = ri->Memory + dstx * GetBytesPerPixel (ri->RGBFormat) + dsty * ri->BytesPerRow;
1.1 root 1954: int Depth = bm->Depth;
1.1.1.5 root 1955: unsigned long rows, bitoffset = srcx & 7;
1.1 root 1956: long eol_offset;
1957:
1958: /* if (mask != 0xFF)
1.1.1.8 root 1959: write_log ("P2C - pixel-width = %d, bit-offset = %d\n", width, bitoffset); */
1.1.1.5 root 1960:
1.1 root 1961: /* Set up our bm->Planes[] pointers to the right horizontal offset */
1962: for (j = 0; j < Depth; j++) {
1963: uae_u8 *p = bm->Planes[j];
1964: if (p != &all_zeros_bitmap && p != &all_ones_bitmap)
1.1.1.8 root 1965: p += srcx / 8 + srcy * bm->BytesPerRow;
1.1 root 1966: PLANAR[j] = p;
1967: if ((mask & (1 << j)) == 0)
1968: PLANAR[j] = &all_zeros_bitmap;
1969: }
1.1.1.8 root 1970: eol_offset = (long) bm->BytesPerRow - (long) ((width + 7) >> 3);
1.1 root 1971: for (rows = 0; rows < height; rows++, image += ri->BytesPerRow) {
1.1.1.5 root 1972: unsigned long cols;
1.1 root 1973:
1974: for (cols = 0; cols < width; cols += 8) {
1975: int k;
1976: uae_u32 a = 0, b = 0;
1977: unsigned int msk = 0xFF;
1978: long tmp = cols + 8 - width;
1979: if (tmp > 0) {
1980: msk <<= tmp;
1.1.1.8 root 1981: b = do_get_mem_long ((uae_u32 *) (image + cols + 4));
1.1 root 1982: if (tmp < 4)
1983: b &= 0xFFFFFFFF >> (32 - tmp * 8);
1984: else if (tmp > 4) {
1.1.1.8 root 1985: a = do_get_mem_long ((uae_u32 *) (image + cols));
1.1 root 1986: a &= 0xFFFFFFFF >> (64 - tmp * 8);
1987: }
1988: }
1989: for (k = 0; k < Depth; k++) {
1990: unsigned int data;
1991: if (PLANAR[k] == &all_zeros_bitmap)
1992: data = 0;
1993: else if (PLANAR[k] == &all_ones_bitmap)
1994: data = 0xFF;
1995: else {
1.1.1.8 root 1996: data = (uae_u8) (do_get_mem_word ((uae_u16 *) PLANAR[k]) >> (8 - bitoffset));
1.1 root 1997: PLANAR[k]++;
1998: }
1999: data &= msk;
2000: a |= p2ctab[data][0] << k;
2001: b |= p2ctab[data][1] << k;
2002: }
1.1.1.8 root 2003: do_put_mem_long ((uae_u32 *) (image + cols), a);
2004: do_put_mem_long ((uae_u32 *) (image + cols + 4), b);
1.1 root 2005: }
2006: for (j = 0; j < Depth; j++) {
2007: if (PLANAR[j] != &all_zeros_bitmap && PLANAR[j] != &all_ones_bitmap) {
2008: PLANAR[j] += eol_offset;
2009: }
2010: }
2011: }
2012: }
2013:
2014: /*
2015: * BlitPlanar2Chunky:
2016: * a0: struct BoardInfo *bi
2017: * a1: struct BitMap *bm - source containing planar information and assorted details
2018: * a2: struct RenderInfo *ri - dest area and its details
2019: * d0.w: SrcX
2020: * d1.w: SrcY
2021: * d2.w: DstX
2022: * d3.w: DstY
2023: * d4.w: SizeX
2024: * d5.w: SizeY
2025: * d6.b: MinTerm - uh oh!
2026: * d7.b: Mask - uh oh!
2027: *
2028: * This function is currently used to blit from planar bitmaps within system memory to chunky bitmaps
2029: * on the board. Watch out for plane pointers that are 0x00000000 (represents a plane with all bits "0")
2030: * or 0xffffffff (represents a plane with all bits "1").
2031: */
2032: uae_u32 picasso_BlitPlanar2Chunky (void)
2033: {
1.1.1.2 root 2034: uaecptr bm = m68k_areg (regs, 1);
2035: uaecptr ri = m68k_areg (regs, 2);
1.1.1.8 root 2036: unsigned long srcx = (uae_u16) m68k_dreg (regs, 0);
2037: unsigned long srcy = (uae_u16) m68k_dreg (regs, 1);
2038: unsigned long dstx = (uae_u16) m68k_dreg (regs, 2);
2039: unsigned long dsty = (uae_u16) m68k_dreg (regs, 3);
2040: unsigned long width = (uae_u16) m68k_dreg (regs, 4);
2041: unsigned long height = (uae_u16) m68k_dreg (regs, 5);
1.1.1.2 root 2042: uae_u8 minterm = m68k_dreg (regs, 6) & 0xFF;
2043: uae_u8 mask = m68k_dreg (regs, 7) & 0xFF;
1.1 root 2044: struct RenderInfo local_ri;
2045: struct BitMap local_bm;
2046:
2047: wgfx_flushline ();
2048:
2049: if (minterm != 0x0C) {
1.1.1.8 root 2050: write_log ("ERROR - BlitPlanar2Chunky() has minterm 0x%x, which I don't handle. Using fall-back routine.\n", minterm);
1.1 root 2051: return 0;
2052: }
1.1.1.8 root 2053: if (!CopyRenderInfoStructureA2U (ri, &local_ri)
2054: || !CopyBitMapStructureA2U (bm, &local_bm))
1.1 root 2055: return 0;
2056:
1.1.1.13 root 2057: P96TRACE (("BlitPlanar2Chunky(%d, %d, %d, %d, %d, %d) Minterm 0x%x, Mask 0x%x, Depth %d\n",
2058: srcx, srcy, dstx, dsty, width, height, minterm, mask, local_bm.Depth));
2059: P96TRACE (("P2C - BitMap has %d BPR, %d rows\n", local_bm.BytesPerRow, local_bm.Rows));
1.1.1.2 root 2060: PlanarToChunky (&local_ri, &local_bm, srcx, srcy, dstx, dsty, width, height, mask);
1.1 root 2061: if (renderinfo_is_current_screen (&local_ri))
1.1.1.12 root 2062: do_blit (&local_ri, GetBytesPerPixel (local_ri.RGBFormat), dstx, dsty, dstx, dsty, width, height, BLIT_SRC, 0);
1.1 root 2063:
1.1.1.4 root 2064: return 1;
1.1 root 2065: }
2066:
1.1.1.8 root 2067: static void PlanarToDirect (struct RenderInfo *ri, struct BitMap *bm,
2068: unsigned long srcx, unsigned long srcy,
2069: unsigned long dstx, unsigned long dsty,
2070: unsigned long width, unsigned long height, uae_u8 mask, struct ColorIndexMapping *cim)
1.1 root 2071: {
2072: int j;
1.1.1.8 root 2073: int bpp = GetBytesPerPixel (ri->RGBFormat);
1.1 root 2074: uae_u8 *PLANAR[8];
2075: uae_u8 *image = ri->Memory + dstx * bpp + dsty * ri->BytesPerRow;
2076: int Depth = bm->Depth;
1.1.1.5 root 2077: unsigned long rows;
1.1 root 2078: long eol_offset;
2079:
2080: /* Set up our bm->Planes[] pointers to the right horizontal offset */
2081: for (j = 0; j < Depth; j++) {
2082: uae_u8 *p = bm->Planes[j];
2083: if (p != &all_zeros_bitmap && p != &all_ones_bitmap)
1.1.1.8 root 2084: p += srcx / 8 + srcy * bm->BytesPerRow;
1.1 root 2085: PLANAR[j] = p;
2086: if ((mask & (1 << j)) == 0)
2087: PLANAR[j] = &all_zeros_bitmap;
2088: }
2089:
1.1.1.8 root 2090: eol_offset = (long) bm->BytesPerRow - (long) ((width + (srcx & 7)) >> 3);
1.1 root 2091: for (rows = 0; rows < height; rows++, image += ri->BytesPerRow) {
1.1.1.5 root 2092: unsigned long cols;
1.1 root 2093: uae_u8 *image2 = image;
2094: unsigned int bitoffs = 7 - (srcx & 7);
2095: int i;
2096:
1.1.1.8 root 2097: for (cols = 0; cols < width; cols++) {
1.1 root 2098: int v = 0, k;
2099: for (k = 0; k < Depth; k++) {
2100: if (PLANAR[k] == &all_ones_bitmap)
2101: v |= 1 << k;
2102: else if (PLANAR[k] != &all_zeros_bitmap) {
2103: v |= ((*PLANAR[k] >> bitoffs) & 1) << k;
2104: }
2105: }
2106:
2107: switch (bpp) {
1.1.1.8 root 2108: case 2:
2109: do_put_mem_word ((uae_u16 *) image2, cim->Colors[v]);
1.1 root 2110: image2 += 2;
2111: break;
1.1.1.8 root 2112: case 3:
1.1 root 2113: do_put_mem_byte (image2++, cim->Colors[v] & 0x000000FF);
1.1.1.8 root 2114: do_put_mem_word ((uae_u16 *) image2, (cim->Colors[v] & 0x00FFFF00) >> 8);
1.1 root 2115: image2 += 2;
2116: break;
1.1.1.8 root 2117: case 4:
2118: do_put_mem_long ((uae_u32 *) image2, cim->Colors[v]);
1.1 root 2119: image2 += 4;
2120: break;
2121: }
2122: bitoffs--;
2123: bitoffs &= 7;
2124: if (bitoffs == 7) {
2125: int k;
2126: for (k = 0; k < Depth; k++) {
2127: if (PLANAR[k] != &all_zeros_bitmap && PLANAR[k] != &all_ones_bitmap) {
2128: PLANAR[k]++;
2129: }
2130: }
2131: }
2132: }
2133:
2134: for (i = 0; i < Depth; i++) {
2135: if (PLANAR[i] != &all_zeros_bitmap && PLANAR[i] != &all_ones_bitmap) {
2136: PLANAR[i] += eol_offset;
2137: }
2138: }
2139: }
2140: }
2141:
2142: /*
2143: * BlitPlanar2Direct:
2144: *
2145: * Synopsis:
2146: * BlitPlanar2Direct(bi, bm, ri, cim, SrcX, SrcY, DstX, DstY, SizeX, SizeY, MinTerm, Mask);
2147: * Inputs:
2148: * a0:struct BoardInfo *bi
2149: * a1:struct BitMap *bm
2150: * a2:struct RenderInfo *ri
2151: * a3:struct ColorIndexMapping *cmi
2152: * d0.w:SrcX
2153: * d1.w:SrcY
2154: * d2.w:DstX
2155: * d3.w:DstY
2156: * d4.w:SizeX
2157: * d5.w:SizeY
2158: * d6.b:MinTerm
2159: * d7.b:Mask
2160: *
2161: * This function is currently used to blit from planar bitmaps within system memory to direct color
2162: * bitmaps (15, 16, 24 or 32 bit) on the board. Watch out for plane pointers that are 0x00000000 (represents
2163: * a plane with all bits "0") or 0xffffffff (represents a plane with all bits "1"). The ColorIndexMapping is
2164: * used to map the color index of each pixel formed by the bits in the bitmap's planes to a direct color value
2165: * which is written to the destination RenderInfo. The color mask and all colors within the mapping are words,
2166: * triple bytes or longwords respectively similar to the color values used in FillRect(), BlitPattern() or
2167: * BlitTemplate().
2168: */
2169: uae_u32 picasso_BlitPlanar2Direct (void)
2170: {
1.1.1.2 root 2171: uaecptr bm = m68k_areg (regs, 1);
2172: uaecptr ri = m68k_areg (regs, 2);
2173: uaecptr cim = m68k_areg (regs, 3);
1.1.1.8 root 2174: unsigned long srcx = (uae_u16) m68k_dreg (regs, 0);
2175: unsigned long srcy = (uae_u16) m68k_dreg (regs, 1);
2176: unsigned long dstx = (uae_u16) m68k_dreg (regs, 2);
2177: unsigned long dsty = (uae_u16) m68k_dreg (regs, 3);
2178: unsigned long width = (uae_u16) m68k_dreg (regs, 4);
2179: unsigned long height = (uae_u16) m68k_dreg (regs, 5);
1.1.1.2 root 2180: uae_u8 minterm = m68k_dreg (regs, 6);
2181: uae_u8 Mask = m68k_dreg (regs, 7);
1.1 root 2182: struct RenderInfo local_ri;
2183: struct BitMap local_bm;
2184: struct ColorIndexMapping local_cim;
2185:
2186: wgfx_flushline ();
2187:
2188: if (minterm != 0x0C) {
1.1.1.8 root 2189: write_log ("ERROR - BlitPlanar2Direct() has op-code 0x%x, which I don't handle. Using fall-back routine.\n", minterm);
1.1 root 2190: return 0;
2191: }
2192: if (Mask != 0xFF) {
1.1.1.2 root 2193: write_log ("ERROR - Unsupported Mask value 0x%x in BlitPlanar2Direct(), using fallback method.\n", Mask);
1.1 root 2194: return 0;
2195: }
1.1.1.8 root 2196: if (!CopyRenderInfoStructureA2U (ri, &local_ri)
2197: || !CopyBitMapStructureA2U (bm, &local_bm))
1.1 root 2198: return 0;
2199:
2200: CopyColorIndexMappingA2U (cim, &local_cim);
1.1.1.13 root 2201: P96TRACE (("BlitPlanar2Direct(%d, %d, %d, %d, %d, %d) Minterm 0x%x, Mask 0x%x, Depth %d\n",
2202: srcx, srcy, dstx, dsty, width, height, minterm, Mask, local_bm.Depth));
1.1.1.2 root 2203: PlanarToDirect (&local_ri, &local_bm, srcx, srcy, dstx, dsty, width, height, Mask, &local_cim);
1.1 root 2204: if (renderinfo_is_current_screen (&local_ri))
1.1.1.12 root 2205: do_blit (&local_ri, GetBytesPerPixel (local_ri.RGBFormat), dstx, dsty, dstx, dsty, width, height, BLIT_SRC, 0);
1.1 root 2206: return 1;
2207: }
2208:
2209: /* @@@ - Work to be done here!
2210: *
2211: * The address is the offset into our Picasso96 frame-buffer (pointed to by gfxmem_start)
2212: * where the value was put.
2213: *
2214: * Porting work: on some machines you may not need these functions, ie. if the memory for the
2215: * Picasso96 frame-buffer is directly viewable or directly blittable. On Win32 with DirectX,
2216: * this is not the case. So I provide some write-through functions (as per Mathias' orders!)
2217: */
2218: static void write_gfx_long (uaecptr addr, uae_u32 value)
2219: {
2220: uaecptr oldaddr = addr;
2221: int x, xbytes, y;
2222: uae_u8 *dst;
2223:
2224: if (!picasso_on)
2225: return;
2226:
2227: /*
2228: * Several writes to successive memory locations are a common access pattern.
2229: * Try to optimize it.
2230: */
2231: if (addr >= wgfx_linestart && addr + 4 <= wgfx_lineend) {
2232: if (addr < wgfx_min)
2233: wgfx_min = addr;
2234: if (addr + 4 > wgfx_max)
2235: wgfx_max = addr + 4;
2236: return;
2237: } else
2238: wgfx_flushline ();
2239:
2240: addr += gfxmem_start;
2241: /* Check to see if this needs to be written through to the display, or was it an "offscreen" area? */
2242: if (addr < picasso96_state.Address || addr + 4 > picasso96_state.Extent)
2243: return;
2244:
2245: addr -= picasso96_state.Address;
2246: y = addr / picasso96_state.BytesPerRow;
2247:
1.1.1.12 root 2248: if (y >= picasso96_state.VirtualHeight)
1.1 root 2249: return;
2250: wgfx_linestart = picasso96_state.Address - gfxmem_start + y * picasso96_state.BytesPerRow;
2251: wgfx_lineend = wgfx_linestart + picasso96_state.BytesPerRow;
2252: wgfx_y = y;
2253: wgfx_min = oldaddr;
2254: wgfx_max = oldaddr + 4;
2255: }
2256:
2257: static void write_gfx_word (uaecptr addr, uae_u16 value)
2258: {
2259: uaecptr oldaddr = addr;
2260: int x, xbytes, y;
2261: uae_u8 *dst;
2262:
2263: if (!picasso_on)
2264: return;
2265:
2266: /*
2267: * Several writes to successive memory locations are a common access pattern.
2268: * Try to optimize it.
2269: */
2270: if (addr >= wgfx_linestart && addr + 2 <= wgfx_lineend) {
2271: if (addr < wgfx_min)
2272: wgfx_min = addr;
2273: if (addr + 2 > wgfx_max)
2274: wgfx_max = addr + 2;
2275: return;
2276: } else
2277: wgfx_flushline ();
2278:
2279: addr += gfxmem_start;
2280: /* Check to see if this needs to be written through to the display, or was it an "offscreen" area? */
2281: if (addr < picasso96_state.Address || addr + 2 > picasso96_state.Extent)
2282: return;
2283:
2284: addr -= picasso96_state.Address;
2285: y = addr / picasso96_state.BytesPerRow;
2286:
1.1.1.12 root 2287: if (y >= picasso96_state.VirtualHeight)
1.1 root 2288: return;
2289: wgfx_linestart = picasso96_state.Address - gfxmem_start + y * picasso96_state.BytesPerRow;
2290: wgfx_lineend = wgfx_linestart + picasso96_state.BytesPerRow;
2291: wgfx_y = y;
2292: wgfx_min = oldaddr;
2293: wgfx_max = oldaddr + 2;
2294: }
2295:
2296: static void write_gfx_byte (uaecptr addr, uae_u8 value)
2297: {
2298: uaecptr oldaddr = addr;
2299: int x, xbytes, y;
2300: uae_u8 *dst;
2301:
2302: if (!picasso_on)
2303: return;
2304:
2305: /*
2306: * Several writes to successive memory locations are a common access pattern.
2307: * Try to optimize it.
2308: */
2309: if (addr >= wgfx_linestart && addr + 4 <= wgfx_lineend) {
2310: if (addr < wgfx_min)
2311: wgfx_min = addr;
2312: if (addr + 1 > wgfx_max)
2313: wgfx_max = addr + 1;
2314: return;
2315: } else
2316: wgfx_flushline ();
2317:
2318: addr += gfxmem_start;
2319: /* Check to see if this needs to be written through to the display, or was it an "offscreen" area? */
2320: if (addr < picasso96_state.Address || addr + 1 > picasso96_state.Extent)
2321: return;
2322:
2323: addr -= picasso96_state.Address;
2324: y = addr / picasso96_state.BytesPerRow;
2325:
1.1.1.12 root 2326: if (y >= picasso96_state.VirtualHeight)
1.1 root 2327: return;
2328: wgfx_linestart = picasso96_state.Address - gfxmem_start + y * picasso96_state.BytesPerRow;
2329: wgfx_lineend = wgfx_linestart + picasso96_state.BytesPerRow;
2330: wgfx_y = y;
2331: wgfx_min = oldaddr;
2332: wgfx_max = oldaddr + 1;
2333: }
2334:
2335: static uae_u32 REGPARAM2 gfxmem_lget (uaecptr addr)
2336: {
2337: uae_u32 *m;
2338: addr -= gfxmem_start & gfxmem_mask;
2339: addr &= gfxmem_mask;
1.1.1.8 root 2340: m = (uae_u32 *) (gfxmemory + addr);
2341: return do_get_mem_long (m);
1.1 root 2342: }
2343:
2344: static uae_u32 REGPARAM2 gfxmem_wget (uaecptr addr)
2345: {
2346: uae_u16 *m;
2347: addr -= gfxmem_start & gfxmem_mask;
2348: addr &= gfxmem_mask;
1.1.1.8 root 2349: m = (uae_u16 *) (gfxmemory + addr);
2350: return do_get_mem_word (m);
1.1 root 2351: }
2352:
2353: static uae_u32 REGPARAM2 gfxmem_bget (uaecptr addr)
2354: {
2355: addr -= gfxmem_start & gfxmem_mask;
2356: addr &= gfxmem_mask;
2357: return gfxmemory[addr];
2358: }
2359:
2360: static void REGPARAM2 gfxmem_lput (uaecptr addr, uae_u32 l)
2361: {
2362: uae_u32 *m;
2363: addr -= gfxmem_start & gfxmem_mask;
2364: addr &= gfxmem_mask;
1.1.1.8 root 2365: m = (uae_u32 *) (gfxmemory + addr);
2366: do_put_mem_long (m, l);
1.1 root 2367:
2368: /* write the long-word to our displayable memory */
1.1.1.8 root 2369: write_gfx_long (addr, l);
1.1 root 2370: }
2371:
2372: static void REGPARAM2 gfxmem_wput (uaecptr addr, uae_u32 w)
2373: {
2374: uae_u16 *m;
2375: addr -= gfxmem_start & gfxmem_mask;
2376: addr &= gfxmem_mask;
1.1.1.8 root 2377: m = (uae_u16 *) (gfxmemory + addr);
2378: do_put_mem_word (m, (uae_u16) w);
1.1 root 2379:
2380: /* write the word to our displayable memory */
1.1.1.8 root 2381: write_gfx_word (addr, (uae_u16) w);
1.1 root 2382: }
2383:
2384: static void REGPARAM2 gfxmem_bput (uaecptr addr, uae_u32 b)
2385: {
2386: addr -= gfxmem_start & gfxmem_mask;
2387: addr &= gfxmem_mask;
2388: gfxmemory[addr] = b;
2389:
2390: /* write the byte to our displayable memory */
1.1.1.8 root 2391: write_gfx_byte (addr, (uae_u8) b);
1.1 root 2392: }
2393:
2394: static int REGPARAM2 gfxmem_check (uaecptr addr, uae_u32 size)
2395: {
2396: addr -= gfxmem_start & gfxmem_mask;
2397: addr &= gfxmem_mask;
1.1.1.2 root 2398: return (addr + size) < allocated_gfxmem;
1.1 root 2399: }
2400:
2401: static uae_u8 REGPARAM2 *gfxmem_xlate (uaecptr addr)
2402: {
2403: addr -= gfxmem_start & gfxmem_mask;
2404: addr &= gfxmem_mask;
2405: return gfxmemory + addr;
2406: }
2407:
2408: addrbank gfxmem_bank = {
2409: gfxmem_lget, gfxmem_wget, gfxmem_bget,
2410: gfxmem_lput, gfxmem_wput, gfxmem_bput,
1.1.1.10 root 2411: gfxmem_xlate, gfxmem_check, NULL
1.1 root 2412: };
2413:
1.1.1.11 root 2414: int picasso_display_mode_index (uae_u32 x, uae_u32 y, uae_u32 d)
2415: {
2416: int i;
2417: for (i = 0; i < mode_count; i++) {
2418: if (DisplayModes[i].res.width == x
2419: && DisplayModes[i].res.height == y
2420: && DisplayModes[i].depth == d)
2421: break;
2422: }
2423: if (i == mode_count)
2424: i = -1;
2425: return i;
2426: }
2427:
1.1 root 2428: static int resolution_compare (const void *a, const void *b)
2429: {
1.1.1.8 root 2430: struct PicassoResolution *ma = (struct PicassoResolution *) a;
2431: struct PicassoResolution *mb = (struct PicassoResolution *) b;
1.1 root 2432: if (ma->res.width > mb->res.width)
2433: return -1;
2434: if (ma->res.width < mb->res.width)
2435: return 1;
2436: if (ma->res.height > mb->res.height)
2437: return -1;
2438: if (ma->res.height < mb->res.height)
2439: return 1;
2440: return ma->depth - mb->depth;
2441: }
1.1.1.8 root 2442:
1.1 root 2443: /* Call this function first, near the beginning of code flow
2444: * NOTE: Don't stuff it in InitGraphics() which seems reasonable...
2445: * Instead, put it in customreset() for safe-keeping. */
2446: void InitPicasso96 (void)
2447: {
2448: static int first_time = 1;
2449:
1.1.1.8 root 2450: memset (&picasso96_state, 0, sizeof (struct picasso96_state_struct));
1.1.1.2 root 2451:
1.1 root 2452: if (first_time) {
2453: int i;
2454:
2455: for (i = 0; i < 256; i++) {
2456: p2ctab[i][0] = (((i & 128) ? 0x01000000 : 0)
2457: | ((i & 64) ? 0x010000 : 0)
2458: | ((i & 32) ? 0x0100 : 0)
2459: | ((i & 16) ? 0x01 : 0));
2460: p2ctab[i][1] = (((i & 8) ? 0x01000000 : 0)
2461: | ((i & 4) ? 0x010000 : 0)
2462: | ((i & 2) ? 0x0100 : 0)
2463: | ((i & 1) ? 0x01 : 0));
2464: }
2465: mode_count = DX_FillResolutions (&picasso96_pixel_format);
1.1.1.8 root 2466: qsort (DisplayModes, mode_count, sizeof (struct PicassoResolution), resolution_compare);
1.1 root 2467:
2468: for (i = 0; i < mode_count; i++) {
1.1.1.8 root 2469: sprintf (DisplayModes[i].name, "%dx%d, %d-bit, %d Hz",
2470: DisplayModes[i].res.width, DisplayModes[i].res.height, DisplayModes[i].depth * 8, DisplayModes[i].refresh);
1.1 root 2471: switch (DisplayModes[i].depth) {
1.1.1.8 root 2472: case 1:
1.1 root 2473: if (DisplayModes[i].res.width > chunky.width)
2474: chunky.width = DisplayModes[i].res.width;
2475: if (DisplayModes[i].res.height > chunky.height)
2476: chunky.height = DisplayModes[i].res.height;
2477: break;
1.1.1.8 root 2478: case 2:
1.1 root 2479: if (DisplayModes[i].res.width > hicolour.width)
2480: hicolour.width = DisplayModes[i].res.width;
2481: if (DisplayModes[i].res.height > hicolour.height)
2482: hicolour.height = DisplayModes[i].res.height;
2483: break;
1.1.1.8 root 2484: case 3:
1.1 root 2485: if (DisplayModes[i].res.width > truecolour.width)
2486: truecolour.width = DisplayModes[i].res.width;
2487: if (DisplayModes[i].res.height > truecolour.height)
2488: truecolour.height = DisplayModes[i].res.height;
2489: break;
1.1.1.8 root 2490: case 4:
1.1 root 2491: if (DisplayModes[i].res.width > alphacolour.width)
2492: alphacolour.width = DisplayModes[i].res.width;
2493: if (DisplayModes[i].res.height > alphacolour.height)
2494: alphacolour.height = DisplayModes[i].res.height;
2495: break;
2496: }
2497: }
1.1.1.2 root 2498: ShowSupportedResolutions ();
1.1 root 2499:
2500: first_time = 0;
2501: }
2502: }
2503:
2504: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.