| 1 | /* gameplaySP - raspberry backend |
| 2 | * |
| 3 | * Copyright (C) 2013 DPR <pribyl.email@gmail.com> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
| 7 | * published by the Free Software Foundation; either version 2 of |
| 8 | * the License, or (at your option) any later version. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | * General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with this program; if not, write to the Free Software |
| 17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 18 | */ |
| 19 | |
| 20 | #include "../common.h" |
| 21 | #include <sys/types.h> |
| 22 | #include <sys/stat.h> |
| 23 | #include "gles_video.h" |
| 24 | #include "rpi.h" |
| 25 | #include "bcm_host.h" |
| 26 | |
| 27 | u32 gamepad_config_map[PLAT_BUTTON_COUNT] = |
| 28 | { |
| 29 | BUTTON_ID_UP, // Up |
| 30 | BUTTON_ID_LEFT, // Left |
| 31 | BUTTON_ID_DOWN, // Down |
| 32 | BUTTON_ID_RIGHT, // Right |
| 33 | BUTTON_ID_START, // Start |
| 34 | BUTTON_ID_SELECT, // Select |
| 35 | BUTTON_ID_L, // Ltrigger |
| 36 | BUTTON_ID_R, // Rtrigger |
| 37 | BUTTON_ID_FPS, // A |
| 38 | BUTTON_ID_A, // B |
| 39 | BUTTON_ID_B, // X |
| 40 | BUTTON_ID_MENU, // Y |
| 41 | BUTTON_ID_SAVESTATE, // 1 |
| 42 | BUTTON_ID_LOADSTATE, // 2 |
| 43 | BUTTON_ID_FASTFORWARD, // 3 |
| 44 | BUTTON_ID_NONE, // 4 |
| 45 | BUTTON_ID_MENU // Space |
| 46 | }; |
| 47 | |
| 48 | |
| 49 | #define MAX_VIDEO_MEM (480*270*2) |
| 50 | static int video_started=0; |
| 51 | static uint16_t * video_buff; |
| 52 | |
| 53 | |
| 54 | void gpsp_plat_init(void) |
| 55 | { |
| 56 | int ret, w, h, fd; |
| 57 | //const char *layer_fb_name; |
| 58 | SDL_Surface* myVideoSurface; |
| 59 | |
| 60 | bcm_host_init(); |
| 61 | |
| 62 | ret = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE); |
| 63 | if (ret != 0) { |
| 64 | fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError()); |
| 65 | exit(1); |
| 66 | } |
| 67 | |
| 68 | myVideoSurface = SDL_SetVideoMode( 0, 0, 16, SDL_SWSURFACE); |
| 69 | // Print out some information about the video surface |
| 70 | if (myVideoSurface == NULL) { |
| 71 | fprintf(stderr, "SDL_Init failed: %s\n", SDL_GetError()); |
| 72 | exit(1); |
| 73 | } |
| 74 | SDL_ShowCursor(0); |
| 75 | fb_set_mode(240, 160, 0, 0, 0, 0); |
| 76 | screen_scale = 3; |
| 77 | } |
| 78 | |
| 79 | void gpsp_plat_quit(void) |
| 80 | { |
| 81 | if (video_started) { |
| 82 | video_close(); |
| 83 | free(video_buff); |
| 84 | video_started=0; |
| 85 | } |
| 86 | SDL_Quit(); |
| 87 | } |
| 88 | |
| 89 | |
| 90 | void *fb_flip_screen(void) |
| 91 | { |
| 92 | video_draw(video_buff); |
| 93 | return video_buff; |
| 94 | } |
| 95 | |
| 96 | void fb_wait_vsync(void) |
| 97 | { |
| 98 | } |
| 99 | |
| 100 | void fb_set_mode(int w, int h, int buffers, int scale,int filter, int filter2) |
| 101 | { |
| 102 | if (video_started) { |
| 103 | video_close(); |
| 104 | free(video_buff); |
| 105 | } |
| 106 | video_buff=malloc(w*h*sizeof(uint16_t)); |
| 107 | memset(video_buff,0,w*h*sizeof(uint16_t)); |
| 108 | video_init(w,h,filter); |
| 109 | video_started=1; |
| 110 | } |
| 111 | // vim:shiftwidth=2:expandtab |