cdrom: change pause timing again
[pcsx_rearmed.git] / plugins / dfxvideo / draw_pl.c
1 /*
2  * (C) notaz, 2010-2011
3  *
4  * This work is licensed under the terms of the GNU GPLv2 or later.
5  * See the COPYING file in the top-level directory.
6  */
7
8 #define _IN_DRAW
9
10 #include "gpu.h"
11
12 #include "../../frontend/plugin_lib.h"
13 #include "pcnt.h"
14
15 // misc globals
16 long           lLowerpart;
17 BOOL           bCheckMask = FALSE;
18 unsigned short sSetMask;
19 unsigned long  lSetMask;
20
21 static void blit(void)
22 {
23  int px = PSXDisplay.DisplayPosition.x & ~1; // XXX: align needed by bgr*_to_...
24  int py = PSXDisplay.DisplayPosition.y;
25  int w = PreviousPSXDisplay.Range.x1;
26  int h = PreviousPSXDisplay.DisplayMode.y;
27  unsigned short *srcs = psxVuw + py * 1024 + px;
28
29  if (w <= 0)
30    return;
31
32  // account for centering
33  h -= PreviousPSXDisplay.Range.y0;
34
35  rcbs->pl_vout_flip(srcs, 1024, PSXDisplay.RGB24, w, h);
36 }
37
38 void DoBufferSwap(void)
39 {
40  static int fbw, fbh, fb24bpp;
41
42  if (PreviousPSXDisplay.DisplayMode.x == 0 || PreviousPSXDisplay.DisplayMode.y == 0)
43   return;
44
45  /* careful if rearranging this code, we try to set mode and flip
46   * to get the hardware apply both changes at the same time */
47  if (PreviousPSXDisplay.DisplayMode.x != fbw || PreviousPSXDisplay.DisplayMode.y != fbh
48      || PSXDisplay.RGB24 != fb24bpp) {
49   fbw = PreviousPSXDisplay.DisplayMode.x;
50   fbh = PreviousPSXDisplay.DisplayMode.y;
51   fb24bpp = PSXDisplay.RGB24;
52   rcbs->pl_vout_set_mode(fbw, fbh, fbw, fbh, fb24bpp ? 24 : 16);
53  }
54
55  pcnt_start(PCNT_BLIT);
56  blit();
57  pcnt_end(PCNT_BLIT);
58 }
59
60 void DoClearScreenBuffer(void)
61 {
62 }
63
64 unsigned long ulInitDisplay(void)
65 {
66  if (rcbs->pl_vout_open() != 0)
67   return 0;
68
69  return 1; /* ok */
70 }
71
72 void CloseDisplay(void)
73 {
74  rcbs->pl_vout_close();
75 }