summaryrefslogtreecommitdiff
path: root/apps/plugins/xworld/sys.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/xworld/sys.h')
-rw-r--r--apps/plugins/xworld/sys.h146
1 files changed, 146 insertions, 0 deletions
diff --git a/apps/plugins/xworld/sys.h b/apps/plugins/xworld/sys.h
new file mode 100644
index 0000000000..f1920acf37
--- /dev/null
+++ b/apps/plugins/xworld/sys.h
@@ -0,0 +1,146 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2014 Franklin Wei, Benjamin Brown
11 * Copyright (C) 2004 Gregory Montoir
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 ***************************************************************************/
22
23#ifndef __XWORLD_SYS_H__
24#define __XWORLD_SYS_H__
25
26#include "intern.h"
27
28#define SYS_NEGATIVE_COLOR
29#define NUM_COLORS 16
30#define MAX_MUTEXES 16
31#define SETTINGS_FILE "settings.xfg"
32#define CODE_X 80
33#define CODE_Y 36
34
35enum {
36 DIR_LEFT = 1 << 0,
37 DIR_RIGHT = 1 << 1,
38 DIR_UP = 1 << 2,
39 DIR_DOWN = 1 << 3
40};
41
42struct PlayerInput {
43
44 uint8_t dirMask;
45 bool button;
46 bool code;
47 bool pause;
48 bool quit;
49 char lastChar;
50 bool save, load;
51 bool fastMode;
52 int8_t stateSlot;
53};
54
55
56struct keymapping_t {
57 int up;
58 int down;
59 int left;
60 int right;
61#if (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD)
62 int upleft;
63 int upright;
64 int downleft;
65 int downright;
66#endif
67};
68
69typedef void (*AudioCallback)(void *param, uint8_t *stream, int len);
70typedef uint32_t (*TimerCallback)(uint32_t delay, void *param);
71
72struct System {
73 struct mutex mutex_memory[MAX_MUTEXES];
74 uint16_t mutex_bitfield;
75 struct PlayerInput input;
76 fb_data palette[NUM_COLORS];
77 struct Engine* e;
78 struct keymapping_t keymap;
79
80 void *membuf;
81 size_t bytes_left;
82
83 bool loaded;
84
85 struct {
86 bool negative_enabled;
87 /*
88 scaling quality:
89 0: off
90 1: fast
91 2: good (color only)
92 */
93 int scaling_quality;
94 /*
95 rotation:
96 0: off
97 1: cw
98 2: ccw
99 */
100 int rotation_option;
101
102 bool showfps;
103 bool sound_enabled;
104 int sound_bufsize;
105 bool zoom;
106 } settings;
107};
108
109void sys_init(struct System*, const char *title);
110void sys_menu(struct System*);
111void sys_destroy(struct System*);
112
113void sys_setPalette(struct System*, uint8_t s, uint8_t n, const uint8_t *buf);
114void sys_copyRect(struct System*, uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint8_t *buf, uint32_t pitch);
115
116void sys_processEvents(struct System*);
117void sys_sleep(struct System*, uint32_t duration);
118uint32_t sys_getTimeStamp(struct System*);
119
120void sys_startAudio(struct System*, AudioCallback callback, void *param);
121void sys_stopAudio(struct System*);
122uint32_t sys_getOutputSampleRate(struct System*);
123
124void *sys_addTimer(struct System*, uint32_t delay, TimerCallback callback, void *param);
125void sys_removeTimer(struct System*, void *timerId);
126
127void *sys_createMutex(struct System*);
128void sys_destroyMutex(struct System*, void *mutex);
129void sys_lockMutex(struct System*, void *mutex);
130void sys_unlockMutex(struct System*, void *mutex);
131
132/* a quick 'n dirty function to get some bytes in the audio buffer after zeroing them */
133/* pretty much does the same thing as calloc, though much uglier and there's no free() */
134void *sys_get_buffer(struct System*, size_t);
135
136uint8_t* getOffScreenFramebuffer(struct System*);
137
138struct MutexStack_t {
139 struct System *sys;
140 void *_mutex;
141};
142
143void MutexStack(struct MutexStack_t*, struct System*, void*);
144void MutexStack_destroy(struct MutexStack_t*);
145
146#endif