Skip to content

Commit

Permalink
MorphOS: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
BeWorld2018 committed Oct 17, 2023
1 parent f35c9f2 commit ba08b21
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 64 deletions.
1 change: 0 additions & 1 deletion src/audio/ahi/SDL_ahi_audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ AHIAUD_OpenDevice(_THIS, const char *devname)
hidden->buffers[0] = (Uint8 *) SDL_malloc(this->spec.size);
hidden->buffers[1] = (Uint8 *) SDL_malloc(this->spec.size);
if (hidden->buffers[0] == NULL || hidden->buffers[1] == NULL) {
D("[%s]No memory for audio buffer\n", __FUNCTION__);
SDL_SetError("No memory for audio buffer");
return -1;
}
Expand Down
3 changes: 1 addition & 2 deletions src/video/morphos/SDL_mosevents.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,6 @@ static void MOS_GadgetEvent(_THIS, const struct IntuiMessage *m)
case ETI_Jump:
D("[%s] ETI_JUMP\n", __FUNCTION__);
//SDL_WindowData *data = (SDL_WindowData *)m->IDCMPWindow->UserData;
//SDL_SetWindowFullscreen(data->window, data->winflags);
break;
}
}
Expand Down Expand Up @@ -236,7 +235,7 @@ MOS_AboutSystem(struct Window *window)
es.es_StructSize = sizeof(struct EasyStruct);
es.es_Flags = 0;
es.es_Title = "About System";
es.es_TextFormat = "System: %s - Vendor: %s\n\nHas Altivec: %s\n";
es.es_TextFormat = "System: %s - Vendor: %s\nHas Altivec: %s";
es.es_GadgetFormat = "Ok";

char System[256];
Expand Down
15 changes: 6 additions & 9 deletions src/video/morphos/SDL_mosmodes.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static const struct
{ PIXFMT_RGBA32, SDL_PIXELFORMAT_RGBA8888 },
};

SDL_bool
/*SDL_bool
MOS_MonitorHas3D(APTR monitor, Uint32 fmt) {
SDL_bool has3D = SDL_FALSE;
Expand All @@ -159,7 +159,7 @@ MOS_MonitorHas3D(APTR monitor, Uint32 fmt) {
}
return has3D;
}
}*/

int
MOS_InitModes(_THIS)
Expand All @@ -172,7 +172,7 @@ MOS_InitModes(_THIS)
Object **monitors;
STRPTR monitorname = NULL;
struct Screen *s;
APTR mon;
APTR mon = NULL;

SDL_zero(display);

Expand All @@ -183,7 +183,6 @@ MOS_InitModes(_THIS)
mode.driverdata = NULL;

s = LockPubScreen(NULL);
mon = NULL;

if (s) {
SDL_DisplayModeData *modedata;
Expand All @@ -199,9 +198,7 @@ MOS_InitModes(_THIS)

if (modedata) {
modedata->monitor = mon;
//3D support

modedata->has3D = MOS_MonitorHas3D(mon, getv(s, SA_PixelFormat));
//modedata->has3D = MOS_MonitorHas3D(mon, getv(s, SA_PixelFormat));
mode.format = pixfmt;
mode.w = width;
mode.h = height;
Expand Down Expand Up @@ -249,7 +246,7 @@ MOS_InitModes(_THIS)
}

modedata->monitor = m;
modedata->has3D = MOS_MonitorHas3D(mon, getv(m, SA_PixelFormat));
//modedata->has3D = MOS_MonitorHas3D(mon, getv(m, SA_PixelFormat));

display.desktop_mode = mode;
display.current_mode = mode;
Expand Down Expand Up @@ -303,7 +300,7 @@ MOS_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display)
mode.refresh_rate = (int)hori;
mode.format = MOS_GetSDLPixelFormat(pixelfmt,SDL_PIXELFORMAT_BGRA8888);

D("[%s] Mode %s - pixelfmt %ld 3DSUPPORT=%d\n", __FUNCTION__, name, pixelfmt, MOS_MonitorHas3D(md->monitor, pixelfmt));
//D("[%s] Mode %s - pixelfmt %ld 3DSUPPORT=%d\n", __FUNCTION__, name, pixelfmt, MOS_MonitorHas3D(md->monitor, pixelfmt));
mode.driverdata = sdl_display->desktop_mode.driverdata ? SDL_malloc(4) : NULL;
SDL_AddDisplayMode(sdl_display, &mode);
}
Expand Down
67 changes: 15 additions & 52 deletions src/video/morphos/SDL_moswindow.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,6 @@ MOS_CloseWindowSafely(SDL_Window *sdlwin, struct Window *win)
}

SDL_WindowData *data = (SDL_WindowData *) sdlwin->driverdata;
/*if (data->appmsg) {
if (RemoveAppWindow(data->appmsg)) {
data->appmsg = NULL;
}
}*/

if (data->menu) {
ClearMenuStrip(win);
FreeMenus(data->menu);
Expand Down Expand Up @@ -270,15 +264,10 @@ MOS_SetWindowTitle(_THIS, SDL_Window * window)

if (data->win) {
APTR old = data->window_title;
APTR title = NULL;

title = MOS_ConvertText(window->title, MIBENUM_UTF_8, MIBENUM_SYSTEM);

APTR title = MOS_ConvertText(window->title, MIBENUM_UTF_8, MIBENUM_SYSTEM);
D("[%s] %s to %s (0x%08lx)\n", __FUNCTION__, window->title, title, data->win);
SetWindowTitles(data->win, title, title);

data->window_title = title;

SDL_free(old);
}
}
Expand All @@ -298,13 +287,9 @@ MOS_SetWindowPosition(_THIS, SDL_Window * window)

if (data->win) {
SDL_VideoData *vd = data->videodata;
struct Screen *scr = vd->WScreen;
size_t bh = 0, top = window->y;

if (vd->CustomScreen == NULL)
bh = scr->BarHeight + 1;
size_t top = window->y;

top = MAX(bh, top);
top = MAX((vd->CustomScreen == NULL ? vd->WScreen->BarHeight + 1 : 0), top);

ChangeWindowBox(data->win, window->x, top, data->win->Width, data->win->Height);
}
Expand All @@ -318,18 +303,14 @@ MOS_SetWindowMinimumSize(_THIS, SDL_Window * window)

if (data->win) {
SDL_VideoData *vd = data->videodata;
struct Screen *scr = vd->WScreen;
size_t bh = 0, min_h = window->min_h, min_w = window->min_w;
size_t min_h = window->min_h, min_w = window->min_w;

if ((window->flags & SDL_WINDOW_BORDERLESS) == 0) {
min_w += data->win->BorderLeft + data->win->BorderRight;
min_h += data->win->BorderTop + data->win->BorderBottom;
}

if (vd->CustomScreen == NULL)
bh = scr->BarHeight + 1;

min_h = MIN(scr->Height - bh, min_h);
min_h = MIN(vd->WScreen->Height - (vd->CustomScreen == NULL ? vd->WScreen->BarHeight + 1 : 0), min_h);

WindowLimits(data->win, min_w, min_h, data->win->MaxWidth, MAX(data->win->MaxHeight, min_h));
}
Expand All @@ -343,18 +324,14 @@ MOS_SetWindowMaximumSize(_THIS, SDL_Window * window)

if (data->win) {
SDL_VideoData *vd = data->videodata;
struct Screen *scr = vd->WScreen;
size_t bh = 0, max_h = window->max_h, max_w = window->max_w;
size_t max_h = window->max_h, max_w = window->max_w;

if ((window->flags & SDL_WINDOW_BORDERLESS) == 0) {
max_w += data->win->BorderLeft + data->win->BorderRight;
max_h += data->win->BorderTop + data->win->BorderBottom;
}

if (vd->CustomScreen == NULL)
bh = scr->BarHeight + 1;

max_h = MIN(scr->Height - bh, max_h);
max_h = MIN(vd->WScreen->Height - (vd->CustomScreen == NULL ? vd->WScreen->BarHeight + 1 : 0), max_h);

WindowLimits(data->win, data->win->MinWidth, MIN(data->win->MinHeight, max_h), max_w, max_h);
}
Expand All @@ -368,18 +345,14 @@ MOS_SetWindowSize(_THIS, SDL_Window * window)

if (data->win) {
SDL_VideoData *vd = data->videodata;
struct Screen *scr = vd->WScreen;
size_t bh = 0, h = window->h, w = window->w;
size_t h = window->h, w = window->w;

if ((window->flags & SDL_WINDOW_BORDERLESS) == 0) {
w += data->win->BorderLeft + data->win->BorderRight;
h += data->win->BorderTop + data->win->BorderBottom;
}

if (vd->CustomScreen == NULL)
bh = scr->BarHeight + 1;

h = MIN(scr->Height - bh, h);
h = MIN(vd->WScreen->Height - (vd->CustomScreen == NULL ? vd->WScreen->BarHeight + 1 : 0), h);

ChangeWindowBox(data->win, data->win->LeftEdge, data->win->TopEdge, w, h);
}
Expand Down Expand Up @@ -676,20 +649,14 @@ MOS_MaximizeWindow(_THIS, SDL_Window * window)
{
SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
SDL_VideoData *vd = (SDL_VideoData *) data->videodata;
struct Screen *scr = data->win->WScreen;
ULONG bh = 0;

D("[%s] wnd 0x%08lx - w=%d, h=%d\n", __FUNCTION__, data->win, data->win->MaxWidth, data->win->MaxHeight);

if (data->win && window->flags & SDL_WINDOW_RESIZABLE) {

data->sdlflags |= SDL_WINDOW_MAXIMIZED;
data->sdlflags &= ~SDL_WINDOW_MINIMIZED;

if (vd->CustomScreen == NULL)
bh = scr->BarHeight + 1;

ChangeWindowBox(data->win, 0, bh, data->win->MaxWidth, data->win->MaxHeight);
ChangeWindowBox(data->win, 0, (vd->CustomScreen == NULL ? data->win->WScreen->BarHeight + 1 : 0), data->win->MaxWidth, data->win->MaxHeight);
}
}

Expand Down Expand Up @@ -759,6 +726,7 @@ MOS_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display,
vd->FullScreen = fullscreen;

MOS_OpenWindows(_this);

if (data->__tglContext) MOS_GL_ResizeContext(_this, window);
}

Expand Down Expand Up @@ -814,9 +782,8 @@ MOS_DestroyWindow(_THIS, SDL_Window * window)
if (data) {
SDL_VideoData *videodata = (SDL_VideoData *) data->videodata;

if (data->__tglContext) {
if (data->__tglContext)
MOS_GL_DeleteContext(_this, data->__tglContext);
}

REMOVE(&data->node);

Expand Down Expand Up @@ -900,11 +867,8 @@ MOS_RecreateWindow(_THIS, SDL_Window * window)

MOS_ShowWindow_Internal(_this, window);

if (data->win) {
// Make sure the new window is active
if (data->win) { // Make sure the new window is active
MOS_ShowWindow(_this, window);
} else {
D("[%s] Failed to re-create window '%s'\n", __FUNCTION__, window->title);
}
}

Expand Down Expand Up @@ -995,7 +959,8 @@ MOS_FlashWindow(_THIS, SDL_Window * window, SDL_FlashOperation operation)
D("[%s]\n", __FUNCTION__);

SDL_WindowData *data = (SDL_WindowData *) window->driverdata;
if (!data->win) return 0;
if (!data->win)
return 0;

switch(operation)
{
Expand Down Expand Up @@ -1029,5 +994,3 @@ MOS_GetWindowBordersSize(_THIS, SDL_Window * window, int *top, int *left, int *b

return 0;
}

/* vi: set ts=4 sw=4 expandtab: */

0 comments on commit ba08b21

Please sign in to comment.