| 1 | /* |
| 2 | SDL - Simple DirectMedia Layer |
| 3 | Copyright (C) 1997-2009 Sam Lantinga |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Library General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library 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 | Library General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Library General Public |
| 16 | License along with this library; if not, write to the Free |
| 17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | |
| 19 | Sam Lantinga |
| 20 | slouken@libsdl.org |
| 21 | */ |
| 22 | #include "SDL_config.h" |
| 23 | |
| 24 | /* |
| 25 | Milan Xbios video functions |
| 26 | |
| 27 | Patrice Mandin |
| 28 | */ |
| 29 | |
| 30 | #include <mint/cookie.h> |
| 31 | #include <mint/falcon.h> |
| 32 | |
| 33 | #include "SDL_xbios.h" |
| 34 | #include "SDL_xbios_milan.h" |
| 35 | |
| 36 | #ifndef Validmode |
| 37 | #define Validmode(mode) \ |
| 38 | (short)trap_14_ww((short)0x5f,(short)(mode)) |
| 39 | #endif |
| 40 | |
| 41 | #define NUM_PREDEFINED_MODES 7 |
| 42 | |
| 43 | typedef struct { |
| 44 | Uint16 width, height; |
| 45 | } predefined_mode_t; |
| 46 | |
| 47 | static const predefined_mode_t mode_list[NUM_PREDEFINED_MODES]={ |
| 48 | {640,400}, |
| 49 | {640,480}, |
| 50 | {800,608}, |
| 51 | {1024,768}, |
| 52 | {1152,864}, |
| 53 | {1280,1024}, |
| 54 | {1600,1200} |
| 55 | }; |
| 56 | |
| 57 | static const Uint8 mode_bpp[4]={ |
| 58 | 8, 15, 16, 32 |
| 59 | }; |
| 60 | |
| 61 | /*--- Variables ---*/ |
| 62 | |
| 63 | static int enum_actually_add; |
| 64 | static SDL_VideoDevice *enum_this; |
| 65 | |
| 66 | /*--- Functions ---*/ |
| 67 | |
| 68 | static unsigned long /*cdecl*/ enumfunc(SCREENINFO *inf, unsigned long flag) |
| 69 | { |
| 70 | xbiosmode_t modeinfo; |
| 71 | |
| 72 | modeinfo.number = inf->devID; |
| 73 | modeinfo.width = inf->scrWidth; |
| 74 | modeinfo.height = inf->scrHeight; |
| 75 | modeinfo.depth = inf->scrPlanes; |
| 76 | modeinfo.flags = 0; |
| 77 | |
| 78 | SDL_XBIOS_AddMode(enum_this, enum_actually_add, &modeinfo); |
| 79 | |
| 80 | return ENUMMODE_CONT; |
| 81 | } |
| 82 | |
| 83 | void SDL_XBIOS_ListMilanModes(_THIS, int actually_add) |
| 84 | { |
| 85 | int i; |
| 86 | |
| 87 | /* Read validated predefined modes */ |
| 88 | for (i=0; i<NUM_PREDEFINED_MODES; i++) { |
| 89 | int j; |
| 90 | Uint16 deviceid = 0x1000 + (i<<4); |
| 91 | |
| 92 | for (j=1; j<4; j++) { |
| 93 | if (Validmode(deviceid + j)) { |
| 94 | xbiosmode_t modeinfo; |
| 95 | |
| 96 | modeinfo.number = deviceid + j; |
| 97 | modeinfo.width = mode_list[i].width; |
| 98 | modeinfo.height = mode_list[i].height; |
| 99 | modeinfo.depth = mode_bpp[j-1]; |
| 100 | modeinfo.flags = 0; |
| 101 | |
| 102 | SDL_XBIOS_AddMode(this, actually_add, &modeinfo); |
| 103 | } |
| 104 | } |
| 105 | } |
| 106 | |
| 107 | /* Read custom created modes */ |
| 108 | enum_this = this; |
| 109 | enum_actually_add = actually_add; |
| 110 | VsetScreen(-1, &enumfunc, MI_MAGIC, CMD_ENUMMODES); |
| 111 | } |