annotate src/video/riscos/SDL_riscostask.c @ 4171:3012f1c37361 SDL-1.2

Fixed bug #619 Description From Tim Angus 2008-08-31 03:38:36 (-) [reply] When pressing "system keys" e.g. ALT+F4 etc., the default for the windib driver is to ignore them completely, whereas with the directx driver they're handled (badly as it turns out). As the windib driver is the default, I assume its behaviour is considered correct, so the following patch makes the directx driver the same in this regard.
author Sam Lantinga <slouken@libsdl.org>
date Mon, 13 Apr 2009 08:44:48 +0000
parents a1b03ba2fcd0
children
rev   line source
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
1 /*
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
4159
a1b03ba2fcd0 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 1402
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
4
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
6 modify it under the terms of the GNU Library General Public
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8 version 2 of the License, or (at your option) any later version.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
9
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
13 Library General Public License for more details.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
14
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
15 You should have received a copy of the GNU Library General Public
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
16 License along with this library; if not, write to the Free
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
18
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
19 Sam Lantinga
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1059
diff changeset
20 slouken@libsdl.org
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
21 */
1402
d910939febfa Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents: 1379
diff changeset
22 #include "SDL_config.h"
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
23
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
24 /*
1035
974ba6ae0fa3 Date: Wed, 26 Jan 2005 13:37:09 GMT
Sam Lantinga <slouken@libsdl.org>
parents: 955
diff changeset
25 This file added by Alan Buckley (alan_baa@hotmail.com) to support RISC OS
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
26 26 March 2003
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
27
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
28 File includes routines for:
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
29 Setting up as a WIMP Task
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
30 Reading information about the current desktop
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
31 Storing information before a switch to full screen
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
32 Restoring desktop after switching to full screen
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
33 */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
34
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
35 #include "kernel.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
36 #include "swis.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
37
1358
c71e05b4dc2e More header massaging... works great on Windows. ;-)
Sam Lantinga <slouken@libsdl.org>
parents: 1338
diff changeset
38 #include "SDL_stdinc.h"
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
39 #include "SDL_riscostask.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
40
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
41 #if !SDL_THREADS_DISABLED
955
d74fbf56f2f6 Date: Fri, 25 Jun 2004 13:29:15 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
42 #include <pthread.h>
d74fbf56f2f6 Date: Fri, 25 Jun 2004 13:29:15 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
43 pthread_t main_thread;
d74fbf56f2f6 Date: Fri, 25 Jun 2004 13:29:15 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
44 #endif
d74fbf56f2f6 Date: Fri, 25 Jun 2004 13:29:15 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
45
1035
974ba6ae0fa3 Date: Wed, 26 Jan 2005 13:37:09 GMT
Sam Lantinga <slouken@libsdl.org>
parents: 955
diff changeset
46 /* RISC OS variables */
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
47
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
48 static int task_handle = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
49 static int wimp_version = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
50
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
51 /* RISC OS variables to help compatability with certain programs */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
52 int riscos_backbuffer = 0; /* Create a back buffer in system memory for full screen mode */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
53 int riscos_closeaction = 1; /* Close icon action */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
54
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
55 static int stored_mode = -1; /* -1 when in desktop, mode number or pointer when full screen */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
56
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
57 extern int mouseInWindow; /* Mouse is in WIMP window */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
58
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
59 /* Local function */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
60
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
61 static int RISCOS_GetTaskName(char *task_name, size_t maxlen);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
62
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
63 /* Uncomment next line to copy mode changes/restores to stderr */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
64 /* #define DUMP_MODE */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
65 #ifdef DUMP_MODE
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
66 #include "stdio.h"
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
67 static void dump_mode()
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
68 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 fprintf(stderr, "mode %d\n", stored_mode);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
70 if (stored_mode < -1 || stored_mode >= 256)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
72 int blockSize = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
73 int *storeBlock = (int *)stored_mode;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
74
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 while(blockSize < 5 || storeBlock[blockSize] != -1)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
76 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
77 fprintf(stderr, " %d\n", storeBlock[blockSize++]);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
78 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
79 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
80 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
81 #endif
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
82
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
83 /******************************************************************
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
84
1035
974ba6ae0fa3 Date: Wed, 26 Jan 2005 13:37:09 GMT
Sam Lantinga <slouken@libsdl.org>
parents: 955
diff changeset
85 Initialise as RISC OS Wimp task
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
86
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
87 *******************************************************************/
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
88
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
89 int RISCOS_InitTask()
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
90 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
91 char task_name[32];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
92 _kernel_swi_regs regs;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
93 int messages[4];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
94
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
95 if (RISCOS_GetTaskName(task_name, SDL_arraysize(task_name)) == 0) return 0;
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
96
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
97 messages[0] = 9; /* Palette changed */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
98 messages[1] = 0x400c1; /* Mode changed */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
99 messages[2] = 8; /* Pre quit */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
100 messages[2] = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
101
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
102 regs.r[0] = (unsigned int)360; /* Minimum version 3.6 */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
103 regs.r[1] = (unsigned int)0x4b534154;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
104 regs.r[2] = (unsigned int)task_name;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
105 regs.r[3] = (unsigned int)messages;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
106
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
107 if (_kernel_swi(Wimp_Initialise, &regs, &regs) == 0)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
108 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
109 wimp_version = regs.r[0];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
110 task_handle = regs.r[1];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
111 return 1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
112 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
113
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
114 #if !SDL_THREADS_DISABLED
955
d74fbf56f2f6 Date: Fri, 25 Jun 2004 13:29:15 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
115 main_thread = pthread_self();
d74fbf56f2f6 Date: Fri, 25 Jun 2004 13:29:15 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
116 #endif
d74fbf56f2f6 Date: Fri, 25 Jun 2004 13:29:15 +0100
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
117
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
118 return 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
119 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
120
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
121 /*********************************************************************
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
122
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
123 Close down application on exit.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
124
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
125 **********************************************************************/
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
126
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
127 void RISCOS_ExitTask()
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
128 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
129 _kernel_swi_regs regs;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
130
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
131 if (stored_mode == -1)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
132 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
133 /* Ensure cursor is put back to standard pointer shape if
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
134 we have been running in a window */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
135 _kernel_osbyte(106,1,0);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
136 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
137
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
138 /* Ensure we end up back in the wimp */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
139 RISCOS_RestoreWimpMode();
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
140
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
141 /* Neatly exit the task */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
142 regs.r[0] = task_handle;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
143 regs.r[1] = (unsigned int)0x4b534154;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
144 _kernel_swi(Wimp_CloseDown, &regs, &regs);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
145 task_handle = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
146 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
147
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
148 /**************************************************************************
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
149
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
150 Get the name of the task for the desktop.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
151
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
152 Param: task_name - name of task 32 characters.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
153
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
154 Returns: 1 is successful, otherwise 0
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
155
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
156 Notes: Works by getting using OS_GetEnv to get the command line
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
157 used to run the program and then parsing a name from it
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
158 as follows.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
159
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
160 1. Use name after final period if not !RunImage
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
161 2. If name is !RunImage then process item before the period
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
162 in front of !RunImage.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
163 3. If directory name use that
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
164 4. if in form <XXX$Dir> use the XXX.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
165
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
166 Finally once this value has been retrieved use it unless
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
167 there is a variable set up in the form SDL$<name>$TaskName
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
168 in which case the value of this variable will be used.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
169
1035
974ba6ae0fa3 Date: Wed, 26 Jan 2005 13:37:09 GMT
Sam Lantinga <slouken@libsdl.org>
parents: 955
diff changeset
170 Now also gets other RISC OS configuration varibles
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
171 SDL$<name>$BackBuffer - set to 1 to use a system memory backbuffer in fullscreen mode
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
172 so updates wait until a call to SDL_UpdateRects. (default 0)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
173 This is required for programmes where they have assumed this is
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
174 always the case which is contrary to the documentation.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
175 SDL$<name>$CloseAction
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
176 0 Don't show close icon
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
177 1 Show close icon
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
178
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
179 ***************************************************************************/
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
180
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
181 int RISCOS_GetTaskName(char *task_name, size_t maxlen)
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
182 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
183 _kernel_swi_regs regs;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
184
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
185 task_name[0] = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
186
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
187 /* Figure out a sensible task name */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
188 if (_kernel_swi(OS_GetEnv, &regs, &regs) == 0)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
189 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
190 char *command_line = (char *)regs.r[0];
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
191 size_t len = SDL_strlen(command_line)+1;
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
192 char *buffer = SDL_stack_alloc(char, len);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
193 char *env_var;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
194 char *p;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
195
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
196 SDL_strlcpy(buffer, command_line, len);
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
197 p = SDL_strchr(buffer, ' ');
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
198 if (p) *p = 0;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
199 p = SDL_strrchr(buffer, '.');
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
200 if (p == 0) p = buffer;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
201 if (stricmp(p+1,"!RunImage") == 0)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
202 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
203 *p = 0;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
204 p = SDL_strrchr(buffer, '.');
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
205 if (p == 0) p = buffer;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
206 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
207 if (*p == '.') p++;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
208 if (*p == '!') p++; /* Skip "!" at beginning of application directories */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
209
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
210 if (*p == '<')
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
211 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
212 // Probably in the form <appname$Dir>
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
213 char *q = SDL_strchr(p, '$');
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
214 if (q == 0) q = SDL_strchr(p,'>'); /* Use variable name if not */
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
215 if (q) *q = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
216 p++; /* Move over the < */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
217 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
218
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
219 if (*p)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
220 {
1035
974ba6ae0fa3 Date: Wed, 26 Jan 2005 13:37:09 GMT
Sam Lantinga <slouken@libsdl.org>
parents: 955
diff changeset
221 /* Read variables that effect the RISC OS SDL engine for this task */
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
222 len = SDL_strlen(p) + 18; /* 18 is larger than the biggest variable name */
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
223 env_var = SDL_stack_alloc(char, len);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
224 if (env_var)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
225 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
226 char *env_val;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
227
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
228 /* See if a variable of form SDL$<dirname>$TaskName exists */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
229
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
230 SDL_strlcpy(env_var, "SDL$", len);
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
231 SDL_strlcat(env_var, p, len);
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
232 SDL_strlcat(env_var, "$TaskName", len);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
233
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
234 env_val = SDL_getenv(env_var);
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
235 if (env_val) SDL_strlcpy(task_name, env_val, maxlen);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
236
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
237 SDL_strlcpy(env_var, "SDL$", len);
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
238 SDL_strlcat(env_var, p, len);
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
239 SDL_strlcat(env_var, "$BackBuffer", len);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
240
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
241 env_val = SDL_getenv(env_var);
1035
974ba6ae0fa3 Date: Wed, 26 Jan 2005 13:37:09 GMT
Sam Lantinga <slouken@libsdl.org>
parents: 955
diff changeset
242 if (env_val) riscos_backbuffer = atoi(env_val);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
243
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
244 SDL_strlcpy(env_var, "SDL$", len);
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
245 SDL_strlcat(env_var, p, len);
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
246 SDL_strlcat(env_var, "$CloseAction", len);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
247
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
248 env_val = SDL_getenv(env_var);
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
249 if (env_val && SDL_strcmp(env_val,"0") == 0) riscos_closeaction = 0;
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
250
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
251 SDL_stack_free(env_var);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
252 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
253
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
254 if (!*task_name) SDL_strlcpy(task_name, p, maxlen);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
255 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
256
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
257 SDL_stack_free(buffer);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
258 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
259
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
260 if (task_name[0] == 0) SDL_strlcpy(task_name, "SDL Task", maxlen);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
261
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
262 return 1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
263 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
264
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
265 /*****************************************************************
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
266
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
267 Store the current desktop screen mode if we are in the desktop.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
268
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
269 ******************************************************************/
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
270
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
271 void RISCOS_StoreWimpMode()
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
272 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
273 _kernel_swi_regs regs;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
274
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
275 /* Don't store if in full screen mode */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
276 if (stored_mode != -1) return;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
277
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
278 regs.r[0] = 1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
279 _kernel_swi(OS_ScreenMode, &regs, &regs);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
280 if (regs.r[1] >= 0 && regs.r[1] < 256) stored_mode = regs.r[1];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
281 else
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
282 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
283 int blockSize = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
284 int *retBlock = (int *)regs.r[1];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
285 int *storeBlock;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
286 int j;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
287
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
288 while(blockSize < 5 || retBlock[blockSize] != -1) blockSize++;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
289 blockSize++;
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
290 storeBlock = (int *)SDL_malloc(blockSize * sizeof(int));
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
291 retBlock = (int *)regs.r[1];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
292 for ( j = 0; j < blockSize; j++)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
293 storeBlock[j] = retBlock[j];
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
294
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
295 stored_mode = (int)storeBlock;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
296 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
297 #if DUMP_MODE
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
298 fprintf(stderr, "Stored "); dump_mode();
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
299 #endif
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
300 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
301
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
302 /*****************************************************************
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
303
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
304 Restore desktop screen mode if we are in full screen mode.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
305
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
306 *****************************************************************/
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
307
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
308 void RISCOS_RestoreWimpMode()
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
309 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
310 _kernel_swi_regs regs;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
311
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
312 /* Only need to restore if we are in full screen mode */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
313 if (stored_mode == -1) return;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
314
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
315 #if DUMP_MODE
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
316 fprintf(stderr, "Restored"); dump_mode();
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
317 #endif
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
318
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
319 regs.r[0] = stored_mode;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
320 _kernel_swi(Wimp_SetMode, &regs, &regs);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
321 if (stored_mode < 0 || stored_mode > 256)
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
322 {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
323 SDL_free((int *)stored_mode);
630
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
324 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
325 stored_mode = -1;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
326
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
327 /* Flush keyboard buffer to dump the keystrokes we've already polled */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
328 regs.r[0] = 21;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
329 regs.r[1] = 0; /* Keyboard buffer number */
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
330 _kernel_swi(OS_Byte, &regs, &regs);
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
331
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
332 mouseInWindow = 0;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
333
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
334 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
335
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
336 /*********************************************************************
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
337
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
338 Get version of Wimp running when task was initialised.
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
339
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
340 *********************************************************************/
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
341
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
342 int RISCOS_GetWimpVersion()
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
343 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
344 return wimp_version;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
345 }
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
346
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
347 int RISCOS_GetTaskHandle()
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
348 {
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
349 return task_handle;
550bccdf04bd Added initial support for RISC OS (thanks Peter Naulls!)
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
350 }