summaryrefslogtreecommitdiff
path: root/apps/plugins/xworld/video.h
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2014-10-13 21:00:47 -0400
committerMichael Giacomelli <giac2000@hotmail.com>2014-12-23 23:48:12 +0100
commit33cb13dee5a527ac445ea1b13d42723e4eb3e3b0 (patch)
tree3ce36ea21b53377b900049143e77e74b77ca1b0d /apps/plugins/xworld/video.h
parentb681e932a9da797249ddc0e4ccab7ed7cf50fd41 (diff)
downloadrockbox-33cb13dee5a527ac445ea1b13d42723e4eb3e3b0.tar.gz
rockbox-33cb13dee5a527ac445ea1b13d42723e4eb3e3b0.zip
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>
Diffstat (limited to 'apps/plugins/xworld/video.h')
-rw-r--r--apps/plugins/xworld/video.h127
1 files changed, 127 insertions, 0 deletions
diff --git a/apps/plugins/xworld/video.h b/apps/plugins/xworld/video.h
new file mode 100644
index 0000000000..d4ff64f5b5
--- /dev/null
+++ b/apps/plugins/xworld/video.h
@@ -0,0 +1,127 @@
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 __VIDEO_H__
24#define __VIDEO_H__
25
26#include "intern.h"
27
28struct StrEntry {
29 uint16_t id;
30 char *str;
31};
32#define MAX_POINTS 50
33struct Polygon {
34
35 uint16_t bbw, bbh;
36 uint8_t numPoints;
37 struct Point points[MAX_POINTS];
38
39};
40void polygon_readVertices(struct Polygon*, const uint8_t *p, uint16_t zoom);
41
42struct Resource;
43struct Serializer;
44struct System;
45
46// This is used to detect the end of _stringsTableEng and _stringsTableDemo
47#define END_OF_STRING_DICTIONARY 0xFFFF
48
49// Special value when no palette change is necessary
50#define NO_PALETTE_CHANGE_REQUESTED 0xFF
51
52/* 320x200 pixels, with 2 pixels/byte */
53#define VID_PAGE_SIZE ( 320 * 200 / 2 )
54
55struct Video {
56
57 /* FW: static const uint8_t _font[];*/
58 /* FW: moved to video_data.c */
59 struct Resource *res;
60 struct System *sys;
61
62
63
64 uint8_t paletteIdRequested, currentPaletteId;
65 uint8_t *_pagePtrs[4];
66 uint8_t *page_data;
67 // I am almost sure that:
68 // _curPagePtr1 is the backbuffer
69 // _curPagePtr2 is the frontbuffer
70 // _curPagePtr3 is the background builder.
71 uint8_t *_curPagePtr1, *_curPagePtr2, *_curPagePtr3;
72
73 struct Polygon polygon;
74 int16_t _hliney;
75
76 //Precomputer division lookup table
77 uint16_t _interpTable[0x400];
78
79 struct Ptr _pData;
80 uint8_t *_dataBuf;
81
82
83};
84
85typedef void (*drawLine)(struct Video*, int16_t x1, int16_t x2, uint8_t col);
86
87//Video(Resource *res, System *stub);
88void video_create(struct Video*, struct Resource*, struct System*);
89void video_init(struct Video* v);
90
91void video_setDataBuffer(struct Video* v, uint8_t *dataBuf, uint16_t offset);
92void video_readAndDrawPolygon(struct Video* v, uint8_t color, uint16_t zoom, const struct Point *pt);
93void video_fillPolygon(struct Video* v, uint16_t color, uint16_t zoom, const struct Point *pt);
94void video_readAndDrawPolygonHierarchy(struct Video* v, uint16_t zoom, const struct Point *pt);
95int32_t video_calcStep(struct Video* v, const struct Point *p1, const struct Point *p2, uint16_t *dy);
96
97void video_drawString(struct Video* v, uint8_t color, uint16_t x, uint16_t y, uint16_t strId);
98void video_drawChar(struct Video* v, uint8_t c, uint16_t x, uint16_t y, uint8_t color, uint8_t *buf);
99void video_drawPoint(struct Video* v, uint8_t color, int16_t x, int16_t y);
100void video_drawLineBlend(struct Video* v, int16_t x1, int16_t x2, uint8_t color);
101void video_drawLineN(struct Video* v, int16_t x1, int16_t x2, uint8_t color);
102void video_drawLineP(struct Video* v, int16_t x1, int16_t x2, uint8_t color);
103uint8_t *video_getPagePtr(struct Video* v, uint8_t page);
104void video_changePagePtr1(struct Video* v, uint8_t page);
105void video_fillPage(struct Video* v, uint8_t page, uint8_t color);
106void video_copyPage(struct Video* v, uint8_t src, uint8_t dst, int16_t vscroll);
107void video_copyPagePtr(struct Video* v, const uint8_t *src);
108uint8_t *video_allocPage(struct Video* v);
109void video_changePal(struct Video* v, uint8_t pal);
110void video_updateDisplay(struct Video* v, uint8_t page);
111
112void video_saveOrLoad(struct Video* v, struct Serializer *ser);
113
114#define TRACE_PALETTE 0
115#define TRACE_FRAMEBUFFER 0
116#if TRACE_FRAMEBUFFER
117void video_dumpFrameBuffer(struct Video* v, uint8_t *src, uint8_t *dst, int x, int y);
118void video_dumpFrameBuffers(struct Video* v, char* comment);
119
120#endif
121
122#define TRACE_BG_BUFFER 0
123#if TRACE_BG_BUFFER
124void video_dumpBackGroundBuffer(struct Video* v);
125#endif
126
127#endif