atari:xbios: Move all ST specific stuff to specific backend file.
1.1 --- a/src/video/xbios/SDL_xbios.c Wed Jul 30 11:36:59 2014 +0200
1.2 +++ b/src/video/xbios/SDL_xbios.c Wed Jul 30 12:39:05 2014 +0200
1.3 @@ -92,10 +92,6 @@
1.4
1.5 /* Default list of video modes */
1.6
1.7 -static const xbiosmode_t stmodes[1]={
1.8 - {ST_LOW>>8,320,200,4, XBIOSMODE_C2P}
1.9 -};
1.10 -
1.11 static const xbiosmode_t ttmodes[2]={
1.12 {TT_LOW,320,480,8, XBIOSMODE_C2P},
1.13 {TT_LOW,320,240,8, XBIOSMODE_C2P|XBIOSMODE_DOUBLELINE}
1.14 @@ -250,8 +246,13 @@
1.15 if (Getcookie(C__VDO, &cookie_cvdo) != C_FOUND) {
1.16 cookie_cvdo = VDO_ST << 16;
1.17 }
1.18 + SDL_XBIOS_VideoInit_ST(device, cookie_cvdo);
1.19
1.20 switch (cookie_cvdo>>16) {
1.21 + case VDO_ST:
1.22 + case VDO_STE:
1.23 + /* Already done as default */
1.24 + break;
1.25 case VDO_MILAN:
1.26 SDL_XBIOS_VideoInit_Milan(device);
1.27 break;
1.28 @@ -322,11 +323,6 @@
1.29 }
1.30 }
1.31
1.32 -static void XBIOS_ListSTModes(_THIS, int actually_add)
1.33 -{
1.34 - SDL_XBIOS_AddMode(this, actually_add, &stmodes[0]);
1.35 -}
1.36 -
1.37 static void XBIOS_ListTTModes(_THIS, int actually_add)
1.38 {
1.39 int i;
1.40 @@ -406,29 +402,8 @@
1.41 switch (XBIOS_cvdo >>16) {
1.42 case VDO_ST:
1.43 case VDO_STE:
1.44 - {
1.45 - short *oldpalette;
1.46 -
1.47 - XBIOS_oldvmode=Getrez();
1.48 - switch(XBIOS_oldvmode << 8) {
1.49 - case ST_LOW:
1.50 - XBIOS_oldnumcol=16;
1.51 - break;
1.52 - case ST_MED:
1.53 - XBIOS_oldnumcol=4;
1.54 - break;
1.55 - case ST_HIGH:
1.56 - XBIOS_oldnumcol=2;
1.57 - break;
1.58 - }
1.59 -
1.60 - oldpalette= (short *) XBIOS_oldpalette;
1.61 - for (i=0;i<XBIOS_oldnumcol;i++) {
1.62 - *oldpalette++=Setcolor(i,-1);
1.63 - }
1.64 -
1.65 - XBIOS_ListSTModes(this, 0);
1.66 - }
1.67 + (*XBIOS_saveMode)(this, vformat);
1.68 + (*XBIOS_listModes)(this, 0);
1.69 break;
1.70 case VDO_TT:
1.71 XBIOS_oldvmode=EgetShift();
1.72 @@ -541,7 +516,7 @@
1.73 switch (XBIOS_cvdo >>16) {
1.74 case VDO_ST:
1.75 case VDO_STE:
1.76 - XBIOS_ListSTModes(this, 1);
1.77 + (*XBIOS_listModes)(this, 1);
1.78 break;
1.79 case VDO_TT:
1.80 XBIOS_ListTTModes(this, 1);
1.81 @@ -610,18 +585,7 @@
1.82
1.83 static void XBIOS_FreeBuffers(_THIS)
1.84 {
1.85 - int i;
1.86 -
1.87 - if ((XBIOS_cvdo>>16) == VDO_MILAN) {
1.88 - (*XBIOS_freeVbuffers)(this);
1.89 - } else {
1.90 - for (i=0;i<2;i++) {
1.91 - if (XBIOS_screensmem[i]!=NULL) {
1.92 - Mfree(XBIOS_screensmem[i]);
1.93 - }
1.94 - XBIOS_screensmem[i]=NULL;
1.95 - }
1.96 - }
1.97 + (*XBIOS_freeVbuffers)(this);
1.98
1.99 if (XBIOS_shadowscreen!=NULL) {
1.100 Mfree(XBIOS_shadowscreen);
1.101 @@ -633,7 +597,7 @@
1.102 int width, int height, int bpp, Uint32 flags)
1.103 {
1.104 int mode, new_depth;
1.105 - int i, num_buffers;
1.106 + int num_buffers;
1.107 xbiosmode_t *new_video_mode;
1.108 Uint32 new_screen_size;
1.109 Uint32 modeflags;
1.110 @@ -704,24 +668,9 @@
1.111 }
1.112
1.113 /* Allocate buffers */
1.114 - if ((XBIOS_cvdo>>16) == VDO_MILAN) {
1.115 - if (!(*XBIOS_allocVbuffers)(this, num_buffers, new_screen_size)) {
1.116 - XBIOS_FreeBuffers(this);
1.117 - return (NULL);
1.118 - }
1.119 - } else {
1.120 - for (i=0; i<num_buffers; i++) {
1.121 - XBIOS_screensmem[i] = Atari_SysMalloc(new_screen_size, MX_STRAM);
1.122 -
1.123 - if (XBIOS_screensmem[i]==NULL) {
1.124 - XBIOS_FreeBuffers(this);
1.125 - SDL_SetError("Can not allocate %d KB for buffer %d", new_screen_size>>10, i);
1.126 - return (NULL);
1.127 - }
1.128 - SDL_memset(XBIOS_screensmem[i], 0, new_screen_size);
1.129 -
1.130 - XBIOS_screens[i]=(void *) (( (long) XBIOS_screensmem[i]+256) & 0xFFFFFF00UL);
1.131 - }
1.132 + if (!(*XBIOS_allocVbuffers)(this, num_buffers, new_screen_size)) {
1.133 + XBIOS_FreeBuffers(this);
1.134 + return (NULL);
1.135 }
1.136
1.137 /* Allocate the new pixel format for the screen */
1.138 @@ -768,26 +717,8 @@
1.139
1.140 switch(XBIOS_cvdo >> 16) {
1.141 case VDO_ST:
1.142 - Setscreen(-1,-1,new_video_mode->number);
1.143 -
1.144 - /* Reset palette */
1.145 - for (i=0;i<16;i++) {
1.146 - TT_palette[i]= ((i>>1)<<8) | (((i*8)/17)<<4) | (i>>1);
1.147 - }
1.148 - Setpalette(TT_palette);
1.149 - break;
1.150 case VDO_STE:
1.151 - Setscreen(-1,-1,new_video_mode->number);
1.152 -
1.153 - /* Reset palette */
1.154 - for (i=0;i<16;i++)
1.155 - {
1.156 - int c;
1.157 -
1.158 - c=((i&1)<<3)|((i>>1)&7);
1.159 - TT_palette[i]=(c<<8)|(c<<4)|c;
1.160 - }
1.161 - Setpalette(TT_palette);
1.162 + (*XBIOS_setMode)(this, new_video_mode);
1.163 break;
1.164 case VDO_TT:
1.165 EsetShift(new_video_mode->number);
1.166 @@ -881,11 +812,7 @@
1.167 }
1.168
1.169 #ifndef DEBUG_VIDEO_XBIOS
1.170 - if ((XBIOS_cvdo>>16) == VDO_MILAN) {
1.171 - (*XBIOS_swapVbuffers)(this);
1.172 - } else {
1.173 - Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
1.174 - }
1.175 + (*XBIOS_swapVbuffers)(this);
1.176
1.177 Vsync();
1.178 #endif
1.179 @@ -925,11 +852,7 @@
1.180 }
1.181
1.182 #ifndef DEBUG_VIDEO_XBIOS
1.183 - if ((XBIOS_cvdo>>16) == VDO_MILAN) {
1.184 - (*XBIOS_swapVbuffers)(this);
1.185 - } else {
1.186 - Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
1.187 - }
1.188 + (*XBIOS_swapVbuffers)(this);
1.189
1.190 Vsync();
1.191 #endif
1.192 @@ -951,18 +874,6 @@
1.193 int r,v,b;
1.194
1.195 switch( XBIOS_cvdo >> 16) {
1.196 - case VDO_ST:
1.197 - case VDO_STE:
1.198 - for (i=0;i<ncolors;i++)
1.199 - {
1.200 - r = colors[i].r;
1.201 - v = colors[i].g;
1.202 - b = colors[i].b;
1.203 -
1.204 - TT_palette[firstcolor+i]=((r*30)+(v*59)+(b*11))/100;
1.205 - }
1.206 - SDL_Atari_C2pConvert4_pal(TT_palette); /* convert the lighting */
1.207 - break;
1.208 case VDO_TT:
1.209 for(i = 0; i < ncolors; i++)
1.210 {
1.211 @@ -1005,10 +916,7 @@
1.212 switch(XBIOS_cvdo >> 16) {
1.213 case VDO_ST:
1.214 case VDO_STE:
1.215 - Setscreen(-1,XBIOS_oldvbase,XBIOS_oldvmode);
1.216 - if (XBIOS_oldnumcol) {
1.217 - Setpalette(XBIOS_oldpalette);
1.218 - }
1.219 + (*XBIOS_restoreMode)(this);
1.220 break;
1.221 case VDO_TT:
1.222 Setscreen(-1,XBIOS_oldvbase,-1);
2.1 --- a/src/video/xbios/SDL_xbios.h Wed Jul 30 11:36:59 2014 +0200
2.2 +++ b/src/video/xbios/SDL_xbios.h Wed Jul 30 12:39:05 2014 +0200
2.3 @@ -132,6 +132,9 @@
2.4
2.5 void SDL_XBIOS_AddMode(_THIS, int actually_add, const xbiosmode_t *modeinfo);
2.6
2.7 +/* SDL_xbios_st.c */
2.8 +void SDL_XBIOS_VideoInit_ST(_THIS, unsigned long cookie_cvdo);
2.9 +
2.10 /* SDL_xbios_milan.c */
2.11 void SDL_XBIOS_VideoInit_Milan(_THIS);
2.12
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/src/video/xbios/SDL_xbios_st.c Wed Jul 30 12:39:05 2014 +0200
3.3 @@ -0,0 +1,194 @@
3.4 +/*
3.5 + SDL - Simple DirectMedia Layer
3.6 + Copyright (C) 1997-2012 Sam Lantinga
3.7 +
3.8 + This library is free software; you can redistribute it and/or
3.9 + modify it under the terms of the GNU Library General Public
3.10 + License as published by the Free Software Foundation; either
3.11 + version 2 of the License, or (at your option) any later version.
3.12 +
3.13 + This library is distributed in the hope that it will be useful,
3.14 + but WITHOUT ANY WARRANTY; without even the implied warranty of
3.15 + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3.16 + Library General Public License for more details.
3.17 +
3.18 + You should have received a copy of the GNU Library General Public
3.19 + License along with this library; if not, write to the Free
3.20 + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
3.21 +
3.22 + Sam Lantinga
3.23 + slouken@libsdl.org
3.24 +*/
3.25 +#include "SDL_config.h"
3.26 +
3.27 +/*
3.28 + ST/STE Xbios video functions
3.29 +
3.30 + Patrice Mandin
3.31 +*/
3.32 +
3.33 +#include <mint/cookie.h>
3.34 +#include <mint/osbind.h>
3.35 +
3.36 +#include "../SDL_sysvideo.h"
3.37 +
3.38 +#include "../ataricommon/SDL_atarimxalloc_c.h"
3.39 +#include "../ataricommon/SDL_ataric2p_s.h"
3.40 +#include "SDL_xbios.h"
3.41 +
3.42 +static const xbiosmode_t stmodes[]={
3.43 + {ST_LOW>>8,320,200,4, XBIOSMODE_C2P}
3.44 +};
3.45 +
3.46 +static void listModes(_THIS, int actually_add);
3.47 +static void saveMode(_THIS, SDL_PixelFormat *vformat);
3.48 +static void setMode_ST(_THIS, xbiosmode_t *new_video_mode);
3.49 +static void setMode_STE(_THIS, xbiosmode_t *new_video_mode);
3.50 +static void restoreMode(_THIS);
3.51 +static void swapVbuffers(_THIS);
3.52 +static int allocVbuffers(_THIS, int num_buffers, int bufsize);
3.53 +static void freeVbuffers(_THIS);
3.54 +static int setColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
3.55 +
3.56 +void SDL_XBIOS_VideoInit_ST(_THIS, unsigned long cookie_cvdo)
3.57 +{
3.58 + XBIOS_listModes = listModes;
3.59 + XBIOS_saveMode = saveMode;
3.60 + XBIOS_setMode = setMode_ST;
3.61 + XBIOS_restoreMode = restoreMode;
3.62 + XBIOS_swapVbuffers = swapVbuffers;
3.63 + XBIOS_allocVbuffers = allocVbuffers;
3.64 + XBIOS_freeVbuffers = freeVbuffers;
3.65 +
3.66 + this->SetColors = setColors;
3.67 +
3.68 + if ((cookie_cvdo>>16) == VDO_STE) {
3.69 + XBIOS_setMode = setMode_STE;
3.70 + }
3.71 +}
3.72 +
3.73 +static void listModes(_THIS, int actually_add)
3.74 +{
3.75 + SDL_XBIOS_AddMode(this, actually_add, &stmodes[0]);
3.76 +}
3.77 +
3.78 +static void saveMode(_THIS, SDL_PixelFormat *vformat)
3.79 +{
3.80 + short *oldpalette;
3.81 + int i;
3.82 +
3.83 + XBIOS_oldvbase=Physbase();
3.84 + XBIOS_oldvmode=Getrez();
3.85 +
3.86 + switch(XBIOS_oldvmode << 8) {
3.87 + case ST_LOW:
3.88 + XBIOS_oldnumcol=16;
3.89 + break;
3.90 + case ST_MED:
3.91 + XBIOS_oldnumcol=4;
3.92 + break;
3.93 + case ST_HIGH:
3.94 + XBIOS_oldnumcol=2;
3.95 + break;
3.96 + }
3.97 +
3.98 + oldpalette= (short *) XBIOS_oldpalette;
3.99 + for (i=0;i<XBIOS_oldnumcol;i++) {
3.100 + *oldpalette++=Setcolor(i,-1);
3.101 + }
3.102 +}
3.103 +
3.104 +static void setMode_ST(_THIS, xbiosmode_t *new_video_mode)
3.105 +{
3.106 + int i;
3.107 +
3.108 + Setscreen(-1,XBIOS_screens[0],-1);
3.109 +
3.110 + Setscreen(-1,-1,new_video_mode->number);
3.111 +
3.112 + /* Reset palette, 8 shades of gray with a bit of green interleaved */
3.113 + for (i=0;i<16;i++) {
3.114 + TT_palette[i]= ((i>>1)<<8) | (((i*8)/17)<<4) | (i>>1);
3.115 + }
3.116 + Setpalette(TT_palette);
3.117 +}
3.118 +
3.119 +static void setMode_STE(_THIS, xbiosmode_t *new_video_mode)
3.120 +{
3.121 + int i;
3.122 +
3.123 + Setscreen(-1,XBIOS_screens[0],-1);
3.124 +
3.125 + Setscreen(-1,-1,new_video_mode->number);
3.126 +
3.127 + /* Reset palette, 16 shades of gray */
3.128 + for (i=0;i<16;i++) {
3.129 + int c;
3.130 +
3.131 + c=((i&1)<<3)|((i>>1)&7);
3.132 + TT_palette[i]=(c<<8)|(c<<4)|c;
3.133 + }
3.134 + Setpalette(TT_palette);
3.135 +}
3.136 +
3.137 +static void restoreMode(_THIS)
3.138 +{
3.139 + Setscreen(-1,XBIOS_oldvbase,XBIOS_oldvmode);
3.140 +
3.141 + if (XBIOS_oldnumcol) {
3.142 + Setpalette(XBIOS_oldpalette);
3.143 + }
3.144 +}
3.145 +
3.146 +static void swapVbuffers(_THIS)
3.147 +{
3.148 + Setscreen(-1,XBIOS_screens[XBIOS_fbnum],-1);
3.149 +}
3.150 +
3.151 +static int allocVbuffers(_THIS, int num_buffers, int bufsize)
3.152 +{
3.153 + int i;
3.154 +
3.155 + for (i=0; i<num_buffers; i++) {
3.156 + XBIOS_screensmem[i] = Atari_SysMalloc(bufsize, MX_STRAM);
3.157 +
3.158 + if (XBIOS_screensmem[i]==NULL) {
3.159 + SDL_SetError("Can not allocate %d KB for buffer %d", bufsize>>10, i);
3.160 + return (0);
3.161 + }
3.162 + SDL_memset(XBIOS_screensmem[i], 0, bufsize);
3.163 +
3.164 + XBIOS_screens[i]=(void *) (( (long) XBIOS_screensmem[i]+256) & 0xFFFFFF00UL);
3.165 + }
3.166 +
3.167 + return (1);
3.168 +}
3.169 +
3.170 +static void freeVbuffers(_THIS)
3.171 +{
3.172 + int i;
3.173 +
3.174 + for (i=0;i<2;i++) {
3.175 + if (XBIOS_screensmem[i]) {
3.176 + Mfree(XBIOS_screensmem[i]);
3.177 + }
3.178 + XBIOS_screensmem[i]=NULL;
3.179 + }
3.180 +}
3.181 +
3.182 +static int setColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
3.183 +{
3.184 + int i, r,g,b;
3.185 +
3.186 + for (i=0;i<ncolors;i++) {
3.187 + r = colors[i].r;
3.188 + g = colors[i].g;
3.189 + b = colors[i].b;
3.190 +
3.191 + TT_palette[firstcolor+i]=((r*30)+(g*59)+(b*11))/100;
3.192 + }
3.193 +
3.194 + SDL_Atari_C2pConvert4_pal(TT_palette); /* convert the lighting */
3.195 +
3.196 + return(1);
3.197 +}