1
0
Fork 0
forked from len0rd/rockbox
foxbox/apps/plugins/xworld/sys.h
Franklin Wei 33cb13dee5 Xworld - Another World interpreter for Rockbox
Co-conspirators: Franklin Wei, Benjamin Brown

--------------------------------------------------------------------
This work is based on:
- Fabien Sanglard's "Fabother World" based on
- Piotr Padkowski's newRaw interpreter which was based on
- Gregory Montoir's reverse engineering of
- Eric Chahi's assembly code

--------------------------------------------------------------------
Progress:

* The plugin runs pretty nicely (with sound!) on most color targets
* Keymaps for color LCD targets are complete
* The manual entry is finished
* Grayscale/monochrome support is NOT PLANNED
  - the game looks horrible in grayscale! :p

--------------------------------------------------------------------
Notes:

* The original game strings were built-in to the executable, and
  were copyrighted and could not be used.
* This port ships with an alternate set of strings by default, but
  can load the "official" strings from a file at runtime.

--------------------------------------------------------------------
To be done (in descending order of importance):

* vertical stride compatibility                          <30% done>
* optimization                                           <10% done>

Change-Id: I3155b0d97c2ac470cb8a2040f40d4139ddcebfa5
Reviewed-on: http://gerrit.rockbox.org/1077
Reviewed-by: Michael Giacomelli <giac2000@hotmail.com>
2014-12-23 23:48:12 +01:00

146 lines
3.9 KiB
C

/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2014 Franklin Wei, Benjamin Brown
* Copyright (C) 2004 Gregory Montoir
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
***************************************************************************/
#ifndef __XWORLD_SYS_H__
#define __XWORLD_SYS_H__
#include "intern.h"
#define SYS_NEGATIVE_COLOR
#define NUM_COLORS 16
#define MAX_MUTEXES 16
#define SETTINGS_FILE "settings.xfg"
#define CODE_X 80
#define CODE_Y 36
enum {
DIR_LEFT = 1 << 0,
DIR_RIGHT = 1 << 1,
DIR_UP = 1 << 2,
DIR_DOWN = 1 << 3
};
struct PlayerInput {
uint8_t dirMask;
bool button;
bool code;
bool pause;
bool quit;
char lastChar;
bool save, load;
bool fastMode;
int8_t stateSlot;
};
struct keymapping_t {
int up;
int down;
int left;
int right;
#if (CONFIG_KEYPAD == SANSA_FUZEPLUS_PAD)
int upleft;
int upright;
int downleft;
int downright;
#endif
};
typedef void (*AudioCallback)(void *param, uint8_t *stream, int len);
typedef uint32_t (*TimerCallback)(uint32_t delay, void *param);
struct System {
struct mutex mutex_memory[MAX_MUTEXES];
uint16_t mutex_bitfield;
struct PlayerInput input;
fb_data palette[NUM_COLORS];
struct Engine* e;
struct keymapping_t keymap;
void *membuf;
size_t bytes_left;
bool loaded;
struct {
bool negative_enabled;
/*
scaling quality:
0: off
1: fast
2: good (color only)
*/
int scaling_quality;
/*
rotation:
0: off
1: cw
2: ccw
*/
int rotation_option;
bool showfps;
bool sound_enabled;
int sound_bufsize;
bool zoom;
} settings;
};
void sys_init(struct System*, const char *title);
void sys_menu(struct System*);
void sys_destroy(struct System*);
void sys_setPalette(struct System*, uint8_t s, uint8_t n, const uint8_t *buf);
void sys_copyRect(struct System*, uint16_t x, uint16_t y, uint16_t w, uint16_t h, const uint8_t *buf, uint32_t pitch);
void sys_processEvents(struct System*);
void sys_sleep(struct System*, uint32_t duration);
uint32_t sys_getTimeStamp(struct System*);
void sys_startAudio(struct System*, AudioCallback callback, void *param);
void sys_stopAudio(struct System*);
uint32_t sys_getOutputSampleRate(struct System*);
void *sys_addTimer(struct System*, uint32_t delay, TimerCallback callback, void *param);
void sys_removeTimer(struct System*, void *timerId);
void *sys_createMutex(struct System*);
void sys_destroyMutex(struct System*, void *mutex);
void sys_lockMutex(struct System*, void *mutex);
void sys_unlockMutex(struct System*, void *mutex);
/* a quick 'n dirty function to get some bytes in the audio buffer after zeroing them */
/* pretty much does the same thing as calloc, though much uglier and there's no free() */
void *sys_get_buffer(struct System*, size_t);
uint8_t* getOffScreenFramebuffer(struct System*);
struct MutexStack_t {
struct System *sys;
void *_mutex;
};
void MutexStack(struct MutexStack_t*, struct System*, void*);
void MutexStack_destroy(struct MutexStack_t*);
#endif