0
|
1 #include "viewerPS3.h"
|
|
2 #include "fb.h"
|
|
3 #include "types.h"
|
|
4 #include "ps3fb/cp_vt.h"
|
|
5 #include "ps3fb/cp_fb.h"
|
|
6 #include <stdio.h>
|
|
7
|
|
8 #define default_sdl_flag SDL_INIT_TIMER | SDL_INIT_JOYSTICK
|
|
9
|
|
10 ViewerPS3::ViewerPS3() {}
|
|
11 ViewerPS3::~ViewerPS3() {}
|
|
12
|
|
13 #if defined(__linux__)
|
|
14
|
|
15 #define DEVICE_NAME "/dev/fb0"
|
|
16 #define DIV_BYTE 8
|
|
17
|
|
18 ScreenInfo
|
|
19 ViewerPS3::get_fbdev_addr()
|
|
20 {
|
|
21 ScreenInfo info;
|
|
22
|
|
23 cp_vt_open_graphics(&vt);
|
|
24 cp_fb_open(&fb);
|
|
25
|
|
26 info.xres = fb.w;
|
|
27 info.yres = fb.h;
|
|
28 info.vbpp = 32;
|
|
29 info.fbptr[0] = (uint32_t *)fb.draw_addr[ 0 ];
|
|
30 info.fbptr[1] = (uint32_t *)fb.draw_addr[ 1 ];
|
|
31
|
|
32 return info;
|
|
33 }
|
|
34
|
|
35 #else /* !defined(__linux__) */
|
|
36 ScreenInfo
|
|
37 ViewerPS3::get_fbdev_addr(void) {
|
|
38 ScreenInfo tmp = {0,0,0,0};
|
|
39 return tmp;
|
|
40 }
|
|
41 #endif /* defined(__linux__) */
|
|
42
|
|
43
|
|
44 Uint32 *
|
|
45 ViewerPS3::video_init(TaskManager *manager, int bpp, int width, int height)
|
|
46 {
|
|
47 // Uint32 sdl_flag = default_sdl_flag | SDL_INIT_VIDEO;
|
|
48 Uint32 sdl_flag = default_sdl_flag ;
|
|
49
|
|
50 if (SDL_Init(sdl_flag) < 0) {
|
|
51 fprintf(stderr,"Couldn't initialize SDL: %s\n",SDL_GetError());
|
|
52 exit(1);
|
|
53 }
|
|
54
|
|
55 screen_info = get_fbdev_addr();
|
|
56
|
|
57 uint32_t *pixels = screen_info.fbptr[frame_ndx];
|
|
58
|
|
59 if (pixels == 0) {
|
|
60 fprintf(stderr, "Cannot get frame buffer!\n");
|
|
61 pixels = (new Uint32[width*height*32/8]);
|
|
62 }
|
|
63 this->width = screen_info.xres;
|
|
64 this->height = screen_info.yres;
|
|
65 this->bpp = screen_info.vbpp;
|
|
66
|
|
67 return pixels;
|
|
68 }
|
|
69
|
|
70 void
|
|
71 ViewerPS3::clean_pixels()
|
|
72 {
|
|
73 }
|
|
74
|
|
75 void
|
|
76 ViewerPS3::clear_screen()
|
|
77 {
|
|
78 }
|
|
79
|
|
80 uint32_t *
|
|
81 ViewerPS3::flip_screen(uint32_t *old)
|
|
82 {
|
|
83 // At the vsync, the previous frame is finished sending to the CRT
|
|
84 // cp_fb_wait_vsync( &fb );
|
|
85
|
|
86 // Send the frame just drawn to the CRT by the next vblank
|
|
87 #ifdef __linux__
|
|
88 cp_fb_flip( &fb, frame_ndx );
|
|
89 #endif
|
|
90
|
|
91 frame_ndx = frame_ndx ^ 0x01;
|
|
92 return (uint32_t*)fb.draw_addr[ frame_ndx ];
|
|
93 }
|
|
94
|
|
95
|
|
96 void
|
|
97 ViewerPS3::free_device()
|
|
98 {
|
|
99 #ifdef __linux__
|
|
100 cp_vt_close(&vt);
|
|
101 cp_fb_close(&fb);
|
|
102 #endif
|
|
103 }
|
|
104
|
|
105 /* end */
|