[Scummvm-cvs-logs] SF.net SVN: scummvm: [20802] residual/trunk
marcus_c at users.sourceforge.net
marcus_c at users.sourceforge.net
Mon Feb 20 14:09:05 CET 2006
Revision: 20802
Author: marcus_c
Date: 2006-02-20 14:08:03 -0800 (Mon, 20 Feb 2006)
ViewCVS: http://svn.sourceforge.net/scummvm?rev=20802&view=rev
Log Message:
-----------
Dreamcast port (Work In Progress) imported.
Modified Paths:
--------------
residual/trunk/README
residual/trunk/bits.h
residual/trunk/registry.cpp
residual/trunk/stdafx.h
Added Paths:
-----------
residual/trunk/dc/
residual/trunk/dc/Makefile
residual/trunk/dc/driver_ronin.cpp
residual/trunk/dc/driver_ronin.h
residual/trunk/dc/driver_ronin_event.cpp
residual/trunk/dc/driver_ronin_gfx.cpp
residual/trunk/dc/driver_ronin_sound.cpp
residual/trunk/dc/main.cpp
residual/trunk/dc/matrix_ops.cpp
residual/trunk/dc/matrix_ops.h
residual/trunk/dc/texture_manager.cpp
residual/trunk/dc/texture_manager.h
Modified: residual/trunk/README
===================================================================
--- residual/trunk/README 2006-02-20 20:57:26 UTC (rev 20801)
+++ residual/trunk/README 2006-02-20 22:08:03 UTC (rev 20802)
@@ -126,6 +126,7 @@
Lionel 'bbrox' Ulmer OpenGL optimisations
Ori 'salty-horse' Avtalion Lipsync, LAF support
Andrea 'Yak Bizzarro' Corna Improved font support
+ Marcus Comstedt Dreamcast port
Special Thanks To:
------------------
Modified: residual/trunk/bits.h
===================================================================
--- residual/trunk/bits.h 2006-02-20 20:57:26 UTC (rev 20801)
+++ residual/trunk/bits.h 2006-02-20 22:08:03 UTC (rev 20802)
@@ -23,7 +23,9 @@
#include <stdlib.h>
#include <stdio.h>
+#ifndef __DC__
#include <SDL_byteorder.h>
+#endif
// Use config.h, generated by configure
#if defined(HAVE_CONFIG_H)
Property changes on: residual/trunk/dc
___________________________________________________________________
Name: svn:ignore
+ lua
imuse
mixer
residual
residual.map
*.d
Added: residual/trunk/dc/Makefile
===================================================================
--- residual/trunk/dc/Makefile (rev 0)
+++ residual/trunk/dc/Makefile 2006-02-20 22:08:03 UTC (rev 20802)
@@ -0,0 +1,27 @@
+# $URL$
+# $Id$
+
+ronindir = /usr/local/ronin
+
+srcdir = ..
+
+VPATH = $(srcdir)
+
+CXX = sh-elf-g++ -ml -m4-single-only
+CXXFLAGS= -O3 -Wno-multichar -funroll-loops -fschedule-insns2 -fomit-frame-pointer -fdelete-null-pointer-checks -fno-exceptions -I$(srcdir)/lua -I$(srcdir) -I$(ronindir)/include -D__DC__
+LDFLAGS = -Wl,-Ttext,0x8c010000,-Map,$@.map -nostartfiles $(ronindir)/lib/crt0.o
+LIBS = -L$(ronindir)/lib -lronin -lz -lm
+
+
+DRIVER_OBJS = \
+ driver_ronin.o \
+ driver_ronin_gfx.o \
+ driver_ronin_sound.o \
+ driver_ronin_event.o \
+ matrix_ops.o \
+ texture_manager.o
+
+
+include $(srcdir)/Makefile.common
+
+
Property changes on: residual/trunk/dc/Makefile
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: residual/trunk/dc/driver_ronin.cpp
===================================================================
--- residual/trunk/dc/driver_ronin.cpp (rev 0)
+++ residual/trunk/dc/driver_ronin.cpp 2006-02-20 22:08:03 UTC (rev 20802)
@@ -0,0 +1,65 @@
+// Residual - Virtual machine to run LucasArts' 3D adventure games
+// Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#include "debug.h"
+#include "driver_ronin.h"
+
+#include <ronin/ronin.h>
+#include <ronin/report.h>
+
+
+DriverRonin::DriverRonin()
+{
+ //FIXME
+ reportf("%s\n", __func__);
+
+ cdfs_init();
+
+ initEvent();
+ initGfx();
+ initSound();
+}
+
+DriverRonin::~DriverRonin()
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+
+void DriverRonin::quit()
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+MutexRef DriverRonin::createMutex() {
+ return (MutexRef)NULL;
+}
+
+void DriverRonin::lockMutex(MutexRef mutex) {
+ ;
+}
+
+void DriverRonin::unlockMutex(MutexRef mutex) {
+ ;
+}
+
+void DriverRonin::deleteMutex(MutexRef mutex) {
+ ;
+}
+
Property changes on: residual/trunk/dc/driver_ronin.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: residual/trunk/dc/driver_ronin.h
===================================================================
--- residual/trunk/dc/driver_ronin.h (rev 0)
+++ residual/trunk/dc/driver_ronin.h 2006-02-20 22:08:03 UTC (rev 20802)
@@ -0,0 +1,174 @@
+// Residual - Virtual machine to run LucasArts' 3D adventure games
+// Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#ifndef DRIVER_RONIN_H
+#define DRIVER_RONIN_H
+
+#include "bits.h"
+#include "vector3d.h"
+#include "color.h"
+#include "model.h"
+#include "colormap.h"
+#include "bitmap.h"
+#include "driver.h"
+#include "matrix_ops.h"
+#include "texture_manager.h"
+
+#include <ronin/soundcommon.h>
+
+#define SOUND_BUFFER_SHIFT 3
+
+class DriverRonin : public Driver, MatrixOps, TextureManager {
+public:
+ DriverRonin();
+ virtual ~DriverRonin();
+
+ void setupCamera(float fov, float nclip, float fclip, float roll);
+ void positionCamera(Vector3d pos, Vector3d interest);
+
+ void toggleFullscreenMode();
+ void clearScreen();
+ void flipBuffer();
+
+ bool isHardwareAccelerated();
+
+ void startActorDraw(Vector3d pos, float yaw, float pitch, float roll);
+ void finishActorDraw();
+
+ void set3DMode();
+
+ void translateViewpoint(Vector3d pos, float pitch, float yaw, float roll);
+ void translateViewpoint();
+
+ void drawHierachyNode(const Model::HierNode *node);
+ void drawModelFace(const Model::Face *face, float *vertices, float *vertNormals, float *textureVerts);
+
+ void disableLights();
+ void setupLight(Scene::Light *light, int lightId);
+
+ void createMaterial(Material *material, const char *data, const CMap *cmap);
+ void selectMaterial(const Material *material);
+ void destroyMaterial(Material *material);
+
+ void createBitmap(Bitmap *bitmap);
+ void drawBitmap(const Bitmap *bitmap);
+ void destroyBitmap(Bitmap *bitmap);
+
+ void drawDepthBitmap(int x, int y, int w, int h, char *data);
+ void drawBitmap();
+ void dimScreen();
+ void dimRegion(int x, int y, int w, int h, float level);
+
+ Bitmap *getScreenshot(int w, int h);
+ void storeDisplay();
+ void copyStoredToDisplay();
+
+ void drawEmergString(int x, int y, const char *text, const Color &fgColor);
+ void loadEmergFont();
+ TextObjectHandle *createTextBitmap(uint8 *bitmap, int width, int height, const Color &fgColor);
+ void drawTextBitmap(int x, int y, TextObjectHandle *handle);
+ void destroyTextBitmap(TextObjectHandle *handle);
+
+ void drawRectangle(PrimitiveObject *primitive);
+ void drawLine(PrimitiveObject *primitive);
+
+ void prepareSmushFrame(int width, int height, byte *bitmap);
+ void drawSmushFrame(int offsetX, int offsetY);
+
+ char *getVideoDeviceName();
+
+ const ControlDescriptor *listControls();
+ int getNumControls();
+ bool controlIsAxis(int num);
+ float getControlAxis(int num);
+ bool getControlState(int num);
+ bool pollEvent(Event &event);
+ uint32 getMillis();
+ void delayMillis(uint msecs);
+ void setTimerCallback(TimerProc callback, int interval);
+
+ MutexRef createMutex();
+ void lockMutex(MutexRef mutex);
+ void unlockMutex(MutexRef mutex);
+ void deleteMutex(MutexRef mutex);
+
+ bool setSoundCallback(SoundProc proc, void *param);
+ void clearSoundCallback();
+ int getOutputSampleRate() const;
+
+ void quit();
+
+private:
+ // Gfx
+ int _polyCount;
+ void *_smushTex;
+ float _u_scale, _v_scale;
+ // Event
+ int _devpoll;
+ uint32 _msecs;
+ unsigned int _t0;
+ uint32 _timer_duration, _timer_next_expiry;
+ bool _timer_active;
+ int (*_timer_callback) (int);
+ class JoyState {
+ public:
+ bool present;
+ unsigned short buttons;
+ unsigned char rtrigger;
+ unsigned char ltrigger;
+ unsigned char joyx;
+ unsigned char joyy;
+ unsigned char joyx2;
+ unsigned char joyy2;
+ } _joy1_state, _joy2_state;
+ class MouseState {
+ public:
+ bool present;
+ unsigned char buttons;
+ short axis1;
+ short axis2;
+ short axis3;
+ short axis4;
+ short axis5;
+ short axis6;
+ short axis7;
+ short axis8;
+ } _mouse_state;
+ class KeyboardState {
+ public:
+ bool present;
+ byte flags;
+ unsigned char shift;
+ unsigned char key[6];
+ } _kbd_state;
+ // Sound
+ SoundProc _sound_proc;
+ void *_sound_proc_param;
+ int temp_sound_buffer[RING_BUFFER_SAMPLES>>SOUND_BUFFER_SHIFT];
+
+ void initEvent();
+ void initGfx();
+ void initSound();
+ bool checkInput(struct mapledev *pad, Event &event);
+ bool checkJoystick(struct mapledev *pad, JoyState &state, int base, Event &event);
+ bool checkMouse(struct mapledev *pad, Event &event);
+ bool checkKeyboard(struct mapledev *pad, Event &event);
+ uint16 makeAscii(int keycode, int shift_state);
+ void checkSound();
+};
+
+#endif
Property changes on: residual/trunk/dc/driver_ronin.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: residual/trunk/dc/driver_ronin_event.cpp
===================================================================
--- residual/trunk/dc/driver_ronin_event.cpp (rev 0)
+++ residual/trunk/dc/driver_ronin_event.cpp 2006-02-20 22:08:03 UTC (rev 20802)
@@ -0,0 +1,594 @@
+// Residual - Virtual machine to run LucasArts' 3D adventure games
+// Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#include "debug.h"
+#include "driver_ronin.h"
+
+#include <ronin/ronin.h>
+#include <ronin/report.h>
+
+// Control allocation
+
+/* Controller: 16 buttons, 6 axises */
+/* Mouse: 8 buttons, 8 axises */
+
+/* 0x02 - 0x9f Keyboard */
+/* 0xa0 - 0xb7 Controller 1 */
+/* 0xb8 - 0xcf Controller 2 */
+/* 0xd0 - 0xdf Mouse */
+/* 0xe0 - 0xe7 Shift keys */
+
+
+#define JOY1 0xa0
+#define JOY2 0xb8
+#define MOUSE 0xd0
+
+
+static const Driver::ControlDescriptor controls[] = {
+ { "KEY_ESCAPE", 0x29 },
+ { "KEY_1", 0x1e },
+ { "KEY_2", 0x1f },
+ { "KEY_3", 0x20 },
+ { "KEY_4", 0x21 },
+ { "KEY_5", 0x22 },
+ { "KEY_6", 0x23 },
+ { "KEY_7", 0x24 },
+ { "KEY_8", 0x25 },
+ { "KEY_9", 0x26 },
+ { "KEY_0", 0x27 },
+ { "KEY_MINUS", 0x2d },
+ { "KEY_EQUALS", 0x2e },
+ { "KEY_BACK", 0x2a },
+ { "KEY_TAB", 0x2b },
+ { "KEY_Q", 0x14 },
+ { "KEY_W", 0x1a },
+ { "KEY_E", 0x08 },
+ { "KEY_R", 0x15 },
+ { "KEY_T", 0x17 },
+ { "KEY_Y", 0x1c },
+ { "KEY_U", 0x18 },
+ { "KEY_I", 0x0c },
+ { "KEY_O", 0x12 },
+ { "KEY_P", 0x13 },
+ { "KEY_LBRACKET", 0x2f },
+ { "KEY_RBRACKET", 0x30 },
+ { "KEY_RETURN", 0x28 },
+ { "KEY_LCONTROL", 0xe0 },
+ { "KEY_A", 0x04 },
+ { "KEY_S", 0x16 },
+ { "KEY_D", 0x07 },
+ { "KEY_F", 0x09 },
+ { "KEY_G", 0x0a },
+ { "KEY_H", 0x0b },
+ { "KEY_J", 0x0d },
+ { "KEY_K", 0x0e },
+ { "KEY_L", 0x0f },
+ { "KEY_SEMICOLON", 0x33 },
+ { "KEY_APOSTROPHE", 0x34 },
+ { "KEY_GRAVE", 0x32 },
+ { "KEY_LSHIFT", 0xe1 },
+ { "KEY_BACKSLASH", 0x87 },
+ { "KEY_Z", 0x1d },
+ { "KEY_X", 0x1b },
+ { "KEY_C", 0x06 },
+ { "KEY_V", 0x19 },
+ { "KEY_B", 0x05 },
+ { "KEY_N", 0x11 },
+ { "KEY_M", 0x10 },
+ { "KEY_COMMA", 0x36 },
+ { "KEY_PERIOD", 0x37 },
+ { "KEY_SLASH", 0x38 },
+ { "KEY_RSHIFT", 0xe5 },
+ { "KEY_MULTIPLY", 0x55 },
+ { "KEY_LMENU", 0xe2 },
+ { "KEY_SPACE", 0x2c },
+ { "KEY_CAPITAL", 0x39 },
+ { "KEY_F1", 0x3a },
+ { "KEY_F2", 0x3b },
+ { "KEY_F3", 0x3c },
+ { "KEY_F4", 0x3d },
+ { "KEY_F5", 0x3e },
+ { "KEY_F6", 0x3f },
+ { "KEY_F7", 0x40 },
+ { "KEY_F8", 0x41 },
+ { "KEY_F9", 0x42 },
+ { "KEY_F10", 0x43 },
+ { "KEY_NUMLOCK", 0x53 },
+ { "KEY_SCROLL", 0x47 },
+ { "KEY_NUMPAD7", 0x5f },
+ { "KEY_NUMPAD8", 0x60 },
+ { "KEY_NUMPAD9", 0x61 },
+ { "KEY_SUBTRACT", 0x56 },
+ { "KEY_NUMPAD4", 0x5c },
+ { "KEY_NUMPAD5", 0x5d },
+ { "KEY_NUMPAD6", 0x5e },
+ { "KEY_ADD", 0x57 },
+ { "KEY_NUMPAD1", 0x59 },
+ { "KEY_NUMPAD2", 0x5a },
+ { "KEY_NUMPAD3", 0x5b },
+ { "KEY_NUMPAD0", 0x62 },
+ { "KEY_DECIMAL", 0x63 },
+ { "KEY_F11", 0x44 },
+ { "KEY_F12", 0x45 },
+ { "KEY_STOP", 0x48 },
+ { "KEY_NUMPADENTER", 0x58 },
+ { "KEY_RCONTROL", 0xe4 },
+ { "KEY_DIVIDE", 0x54 },
+ { "KEY_SYSRQ", 0x46 },
+ { "KEY_RMENU", 0xe6 },
+ { "KEY_HOME", 0x4a },
+ { "KEY_UP", 0x52 },
+ { "KEY_PRIOR", 0x4b },
+ { "KEY_LEFT", 0x50 },
+ { "KEY_RIGHT", 0x4f },
+ { "KEY_END", 0x4d },
+ { "KEY_DOWN", 0x51 },
+ { "KEY_NEXT", 0x4e },
+ { "KEY_INSERT", 0x49 },
+ { "KEY_DELETE", 0x4c },
+ { "KEY_LWIN", 0xe3 },
+ { "KEY_RWIN", 0xe7 },
+ { "KEY_APPS", 0x65 },
+ { "KEY_JOY1_B1", JOY1+0x02 },
+ { "KEY_JOY1_B2", JOY1+0x01 },
+ { "KEY_JOY1_B3", JOY1+0x00 },
+ { "KEY_JOY1_B4", JOY1+0x0b },
+ { "KEY_JOY1_B5", JOY1+0x0a },
+ { "KEY_JOY1_B6", JOY1+0x09 },
+ { "KEY_JOY1_B7", JOY1+0x08 },
+ { "KEY_JOY1_B8", JOY1+0x03 },
+ { "KEY_JOY1_B9", JOY1+0x0e },
+ { "KEY_JOY1_B10", JOY1+0x0f },
+ { "KEY_JOY1_HLEFT", JOY1+0x06 },
+ { "KEY_JOY1_HUP", JOY1+0x04 },
+ { "KEY_JOY1_HRIGHT", JOY1+0x07 },
+ { "KEY_JOY1_HDOWN", JOY1+0x05 },
+ { "KEY_JOY2_B1", JOY2+0x02 },
+ { "KEY_JOY2_B2", JOY2+0x01 },
+ { "KEY_JOY2_B3", JOY2+0x00 },
+ { "KEY_JOY2_B4", JOY2+0x0b },
+ { "KEY_JOY2_B5", JOY2+0x0a },
+ { "KEY_JOY2_B6", JOY2+0x09 },
+ { "KEY_JOY2_B7", JOY2+0x08 },
+ { "KEY_JOY2_B8", JOY2+0x03 },
+ { "KEY_JOY2_B9", JOY2+0x0e },
+ { "KEY_JOY2_B10", JOY2+0x0f },
+ { "KEY_JOY2_HLEFT", JOY2+0x06 },
+ { "KEY_JOY2_HUP", JOY2+0x04 },
+ { "KEY_JOY2_HRIGHT", JOY2+0x07 },
+ { "KEY_JOY2_HDOWN", JOY2+0x05 },
+ { "KEY_MOUSE_B1", MOUSE+0x02 },
+ { "KEY_MOUSE_B2", MOUSE+0x01 },
+ { "KEY_MOUSE_B3", MOUSE+0x00 },
+ { "KEY_MOUSE_B4", MOUSE+0x03 },
+ { "AXIS_JOY1_X", JOY1+0x12 },
+ { "AXIS_JOY1_Y", JOY1+0x13 },
+ { "AXIS_JOY1_Z", JOY1+0x10 },
+ { "AXIS_JOY1_R", JOY1+0x11 },
+ { "AXIS_JOY1_U", JOY1+0x14 },
+ { "AXIS_JOY1_V", JOY1+0x15 },
+ { "AXIS_JOY2_X", JOY2+0x12 },
+ { "AXIS_JOY2_Y", JOY2+0x13 },
+ { "AXIS_JOY2_Z", JOY2+0x10 },
+ { "AXIS_JOY2_R", JOY2+0x11 },
+ { "AXIS_JOY2_U", JOY2+0x14 },
+ { "AXIS_JOY2_V", JOY2+0x15 },
+ { "AXIS_MOUSE_X", MOUSE+0x08 },
+ { "AXIS_MOUSE_Y", MOUSE+0x09 },
+ { "AXIS_MOUSE_Z", MOUSE+0x0a },
+ { NULL, 0 }
+};
+
+const Driver::ControlDescriptor *DriverRonin::listControls()
+{
+ return controls;
+}
+
+int DriverRonin::getNumControls()
+{
+ return 0xe8;
+}
+
+bool DriverRonin::controlIsAxis(int num)
+{
+ return (num >= JOY1+0x10 && num <= JOY1+0x15) ||
+ (num >= JOY2+0x10 && num <= JOY2+0x15) ||
+ (num >= MOUSE+0x08 && num <= MOUSE+0x0f);
+}
+
+float DriverRonin::getControlAxis(int num)
+{
+ JoyState *state;
+ if(num >= MOUSE+0x08 && num <= MOUSE+0x0f) {
+ short *axis = &_mouse_state.axis1 + (num - MOUSE+0x08);
+ return *axis * 1.0/0x200;
+ } else if(num >= JOY1+0x10 && num <= JOY1+0x15) {
+ num -= JOY1+0x10;
+ state = &_joy1_state;
+ } else if(num >= JOY2+0x10 && num <= JOY2+0x15) {
+ num -= JOY2+0x10;
+ state = &_joy2_state;
+ } else
+ return 0;
+
+ unsigned char *axis = &state->rtrigger + num;
+ if(num < 2)
+ // Triggers
+ return *axis * 1.0/256;
+ else
+ // Joystick X/Y
+ return *axis * 1.0/128 - 1.0;
+}
+
+bool DriverRonin::getControlState(int num)
+{
+ if(num >= 2 && num <= 0x9f) {
+ for(int i=0; i<6; i++)
+ if(_kbd_state.key[i] == num)
+ return true;
+ } else if(num >= 0xe0 && num <= 0xe7) {
+ return (_kbd_state.shift & (1 << (num-0xe0))) != 0;
+ } else if(num >= JOY1 && num <= JOY1+0x0f) {
+ return (_joy1_state.buttons & (1 << (num-JOY1))) != 0;
+ } else if(num >= JOY2 && num <= JOY2+0x0f) {
+ return (_joy2_state.buttons & (1 << (num-JOY2))) != 0;
+ } else if(num >= MOUSE && num <= MOUSE+0x07) {
+ return (_mouse_state.buttons & (1 << (num-MOUSE))) != 0;
+ }
+ return false;
+}
+
+uint16 DriverRonin::makeAscii(int keycode, int shift_state)
+{
+ if(keycode >= 0x04 && keycode <= 0x1d) {
+ uint16 ascii = keycode + ('a' - 0x04);
+ if(shift_state & KBD_SHIFT)
+ ascii -= ('a' - 'A');
+ if(shift_state & KBD_CTRL)
+ ascii &= 0x1f;
+ return ascii;
+ } else if(keycode >= 0x1e && keycode <= 0x26)
+ return keycode + ((shift_state & KBD_SHIFT)?
+ ('!'-0x1e) : ('1'-0x1e));
+ else if(keycode >= 0x59 && keycode <= 0x61)
+ return keycode + ('1'-0x59);
+ else if(keycode >= 0x2d && keycode <= 0x38 && keycode != 0x31)
+ return ((shift_state & KBD_SHIFT)?
+ "=¯`{ }+*½<>?" :
+ "-^@[ ];:§,./")[keycode - 0x2d];
+ else if(keycode >= 0x54 && keycode <= 0x57)
+ return "/*-+"[keycode-0x54];
+ else switch(keycode) {
+ case 0x27:
+ return ((shift_state & KBD_SHIFT)? '~' : '0');
+ case 0x62:
+ return '0';
+ case 0x28: case 0x58:
+ return 13;
+ case 0x29:
+ return 27;
+ case 0x2a:
+ return 8;
+ case 0x2b:
+ return 9;
+ case 0x2c:
+ return ' ';
+ case 0x4c:
+ return 127;
+ case 0x63:
+ return '.';
+ case 0x64: case 0x87:
+ return ((shift_state & KBD_SHIFT)? '_' : '\\');
+ case 0x89:
+ return ((shift_state & KBD_SHIFT)? '|' : '¥'); break;
+ }
+
+ return 0;
+}
+
+bool DriverRonin::checkJoystick(struct mapledev *pad, JoyState &state, int base, Event &event)
+{
+ if(!state.present) {
+ state.present = true;
+ state.buttons = 0;
+ }
+
+ state.rtrigger = pad->cond.controller.rtrigger;
+ state.ltrigger = pad->cond.controller.ltrigger;
+ state.joyx = pad->cond.controller.joyx;
+ state.joyy = pad->cond.controller.joyy;
+ state.joyx2 = pad->cond.controller.joyx2;
+ state.joyy2 = pad->cond.controller.joyy2;
+
+ unsigned short buttons = ~pad->cond.controller.buttons;
+ if(buttons != state.buttons) {
+ int up = state.buttons & ~buttons;
+ int down = buttons & ~state.buttons;
+ for(int i=0; i<8; i++)
+ if(up & (i<<i)) {
+ event.type = EVENT_KEYUP;
+ event.kbd.num = base + i;
+ event.kbd.ascii = 0;
+ event.kbd.flags = _kbd_state.flags;
+ state.buttons &= ~(1<<i);
+ return true;
+ } else if(down & (i<<8)) {
+ event.type = EVENT_KEYDOWN;
+ event.kbd.num = base + i;
+ event.kbd.ascii = 0;
+ event.kbd.flags = _kbd_state.flags;
+ state.buttons |= (1<<i);
+ return true;
+ }
+ state.buttons = buttons;
+ }
+ return false;
+}
+
+bool DriverRonin::checkMouse(struct mapledev *pad, Event &event)
+{
+ if(!_mouse_state.present) {
+ _mouse_state.present = true;
+ _mouse_state.buttons = 0;
+ }
+
+ _mouse_state.axis1 = pad->cond.mouse.axis1;
+ _mouse_state.axis2 = pad->cond.mouse.axis2;
+ _mouse_state.axis3 = pad->cond.mouse.axis3;
+ _mouse_state.axis4 = pad->cond.mouse.axis4;
+ _mouse_state.axis5 = pad->cond.mouse.axis5;
+ _mouse_state.axis6 = pad->cond.mouse.axis6;
+ _mouse_state.axis7 = pad->cond.mouse.axis7;
+ _mouse_state.axis8 = pad->cond.mouse.axis8;
+
+ unsigned char buttons = (~pad->cond.mouse.buttons) & 0xff;
+ if(buttons != _mouse_state.buttons) {
+ int up = _mouse_state.buttons & ~buttons;
+ int down = buttons & ~_mouse_state.buttons;
+ for(int i=0; i<8; i++)
+ if(up & (i<<i)) {
+ event.type = EVENT_KEYUP;
+ event.kbd.num = MOUSE + i;
+ event.kbd.ascii = 0;
+ event.kbd.flags = _kbd_state.flags;
+ _mouse_state.buttons &= ~(1<<i);
+ return true;
+ } else if(down & (i<<8)) {
+ event.type = EVENT_KEYDOWN;
+ event.kbd.num = MOUSE + i;
+ event.kbd.ascii = 0;
+ event.kbd.flags = _kbd_state.flags;
+ _mouse_state.buttons |= (1<<i);
+ return true;
+ }
+ _mouse_state.buttons = buttons;
+ }
+ return false;
+}
+
+bool DriverRonin::checkKeyboard(struct mapledev *pad, Event &event)
+{
+ int _flags = 0;
+
+ if(pad->cond.kbd.shift & 0x11)
+ _flags |= KBD_CTRL;
+ if(pad->cond.kbd.shift & 0x22)
+ _flags |= KBD_SHIFT;
+ if(pad->cond.kbd.shift & 0x44)
+ _flags |= KBD_ALT;
+
+ if(!_kbd_state.present) {
+ _kbd_state.present = true;
+ _kbd_state.shift = 0;
+ memset(_kbd_state.key, 0, sizeof(_kbd_state.key));
+ }
+
+ _kbd_state.flags = _flags;
+
+ if(pad->cond.kbd.shift != _kbd_state.shift) {
+ int up = _kbd_state.shift & ~pad->cond.kbd.shift;
+ int down = pad->cond.kbd.shift & ~_kbd_state.shift;
+ for(int i=0; i<8; i++)
+ if(up & (i<<i)) {
+ event.type = EVENT_KEYUP;
+ event.kbd.num = 0xe0 + i;
+ event.kbd.ascii = 0;
+ event.kbd.flags = _flags;
+ _kbd_state.shift &= ~(1<<i);
+ return true;
+ } else if(down & (i<<8)) {
+ event.type = EVENT_KEYDOWN;
+ event.kbd.num = 0xe0 + i;
+ event.kbd.ascii = 0;
+ event.kbd.flags = _flags;
+ _kbd_state.shift |= (1<<i);
+ return true;
+ }
+ _kbd_state.shift = pad->cond.kbd.shift;
+ }
+
+ if(!memcmp(pad->cond.kbd.key, _kbd_state.key, sizeof(_kbd_state.key)))
+ return false;
+
+ for(int i=5; i>=0; --i) {
+ unsigned char old_key = _kbd_state.key[i];
+ if(old_key >= 2 && old_key <= 0x9f) {
+ int found = false;
+ for(int j=0; j<6; j++)
+ if(pad->cond.kbd.key[j] == old_key) {
+ found = true;
+ break;
+ }
+ if(!found) {
+ event.type = EVENT_KEYUP;
+ event.kbd.num = old_key;
+ event.kbd.ascii = makeAscii(old_key, _flags);
+ event.kbd.flags = _flags;
+#ifdef KBD_DEBUG
+ printf("KEYUP %02x state=[", old_key);
+ for(int z=0; z<6; z++)
+ printf((z == i?"<%02x> ":"%02x "), _kbd_state.key[z]);
+ printf("] cond=[");
+ for(int z=0; z<6; z++)
+ printf("%02x ", pad->cond.kbd.key[z]);
+ printf("]\n");
+#endif
+ _kbd_state.key[i] = 0;
+ return true;
+ }
+ }
+ }
+ for(int i=0; i<6; i++) {
+ unsigned char new_key = pad->cond.kbd.key[i];
+ if(new_key >= 2 && new_key <= 0x9f) {
+ int found = false;
+ int free_pos = -1;
+ for(int j=0; j<6; j++)
+ if(_kbd_state.key[j] == new_key) {
+ found = true;
+ break;
+ } else if(free_pos < 0 &&
+ (_kbd_state.key[j] < 2 ||
+ _kbd_state.key[j] > 0xa0))
+ free_pos = j;
+ if(!found && free_pos >= 0) {
+ event.type = EVENT_KEYDOWN;
+ event.kbd.num = new_key;
+ event.kbd.ascii = makeAscii(new_key, _flags);
+ event.kbd.flags = _flags;
+#ifdef KBD_DEBUG
+ printf("KEYDOWN %02x state=[", new_key);
+ for(int z=0; z<6; z++)
+ printf((z == free_pos?"{%02x} ":"%02x "), _kbd_state.key[z]);
+ printf("] cond=[");
+ for(int z=0; z<6; z++)
+ printf((z==i? "<%02x> ":"%02x "), pad->cond.kbd.key[z]);
+ printf("]\n");
+#endif
+ _kbd_state.key[free_pos] = new_key;
+ return true;
+ }
+ }
+ }
+
+ memcpy(_kbd_state.key, pad->cond.kbd.key, sizeof(_kbd_state.key));
+ return false;
+}
+
+bool DriverRonin::checkInput(struct mapledev *pad, Event &event)
+{
+ int joyCnt=0, mouseCnt=0, kbdCnt=0;
+ for(int i=0; i<4; i++, pad++)
+ if((pad->func & MAPLE_FUNC_CONTROLLER) &&
+ joyCnt < 2) {
+ if(checkJoystick(pad, (joyCnt? _joy2_state
+ : _joy1_state),
+ (joyCnt? JOY2 : JOY1), event))
+ return true;
+ joyCnt++;
+ } else if((pad->func & MAPLE_FUNC_MOUSE) &&
+ mouseCnt < 1) {
+ if(checkMouse(pad, event))
+ return true;
+ mouseCnt++;
+ } else if((pad->func & MAPLE_FUNC_KEYBOARD) &&
+ kbdCnt < 1) {
+ if(checkKeyboard(pad, event))
+ return true;
+ kbdCnt++;
+ }
+ return false;
+}
+
+bool DriverRonin::pollEvent(Event &event)
+{
+ unsigned int t = Timer();
+
+ if(_timer_active && ((int)(t-_timer_next_expiry))>=0) {
+ _timer_duration = _timer_callback(_timer_duration);
+ _timer_next_expiry = t+USEC_TO_TIMER(1000*_timer_duration);
+ }
+
+ if(((int)(t-_devpoll))<0)
+ return false;
+
+ _devpoll += USEC_TO_TIMER(17000);
+ if(((int)(t-_devpoll))>=0)
+ _devpoll = t + USEC_TO_TIMER(17000);
+
+ getMillis();
+ int mask = getimask();
+ setimask(15);
+ checkSound();
+ bool r = checkInput(locked_get_pads(), event);
+ setimask(mask);
+ return r;
+}
+
+uint32 DriverRonin::getMillis()
+{
+ unsigned int t = Timer();
+ unsigned int dm, dt = t - _t0;
+
+ _t0 = t;
+ dm = (dt << 6)/3125U;
+ dt -= (dm * 3125U)>>6;
+ _t0 -= dt;
+
+ return _msecs += dm;
+}
+
+void DriverRonin::delayMillis(uint msecs)
+{
+ getMillis();
+ unsigned int t, start = Timer();
+ int time = (((unsigned int)msecs)*100000U)>>11;
+ while(((int)((t = Timer())-start))<time) {
+ if(_timer_active && ((int)(t-_timer_next_expiry))>=0) {
+ _timer_duration = _timer_callback(_timer_duration);
+ _timer_next_expiry = t+USEC_TO_TIMER(1000*_timer_duration);
+ }
+ checkSound();
+ }
+ getMillis();
+}
+
+void DriverRonin::setTimerCallback(TimerProc callback, int interval)
+{
+ if (callback != NULL) {
+ _timer_duration = interval;
+ _timer_next_expiry = Timer() + USEC_TO_TIMER(1000*interval);
+ _timer_callback = callback;
+ _timer_active = true;
+ } else {
+ _timer_active = false;
+ }
+}
+
+void DriverRonin::initEvent()
+{
+ _devpoll = 0;
+ _msecs = 0;
+ _t0 = 0;
+ _timer_active = false;
+ maple_init();
+ _joy1_state.present = false;
+ _joy2_state.present = false;
+ _mouse_state.present = false;
+ _kbd_state.present = false;
+ _kbd_state.flags = 0;
+}
Property changes on: residual/trunk/dc/driver_ronin_event.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: residual/trunk/dc/driver_ronin_gfx.cpp
===================================================================
--- residual/trunk/dc/driver_ronin_gfx.cpp (rev 0)
+++ residual/trunk/dc/driver_ronin_gfx.cpp 2006-02-20 22:08:03 UTC (rev 20802)
@@ -0,0 +1,612 @@
+// Residual - Virtual machine to run LucasArts' 3D adventure games
+// Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#include "debug.h"
+#include "colormap.h"
+#include "material.h"
+#include "driver_ronin.h"
+
+#include <ronin/ronin.h>
+#include <ronin/report.h>
+#include <ronin/sincos_rroot.h>
+
+void DriverRonin::toggleFullscreenMode()
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+bool DriverRonin::isHardwareAccelerated()
+{
+ reportf("%s\n", __func__);
+ return true;
+}
+
+void DriverRonin::setupCamera(float fov, float nclip, float fclip, float roll)
+{
+ //FIXME
+ //reportf("%s\n", __func__);
+
+ clearMatrixStack();
+
+ float cot_fov = 1 / std::tan(fov * (M_PI / 180 / 2));
+ float frustum[4][4] = {
+ { (-640/2) * cot_fov, 0, 0, 0 },
+ { 0, (480/2 / 0.75) * cot_fov, 0, 0 },
+ { 640/2, 480/2, (nclip + fclip) / (nclip - fclip), 1 },
+ { 0, 0, 2*(nclip*fclip) / (nclip - fclip), 0 }
+ };
+ loadMatrix(&frustum);
+ rotateZ( roll );
+}
+
+void DriverRonin::positionCamera(Vector3d pos, Vector3d interest)
+{
+ //FIXME
+ //reportf("%s\n", __func__);
+ float fx = interest.x() - pos.x(),
+ fy = interest.y() - pos.y(),
+ fz = interest.z() - pos.z();
+ float n;
+ RROOT(fx*fx + fy*fy + fz*fz, n);
+ fx *= n;
+ fy *= n;
+ fz *= n;
+ float sx = 0, sy = 0, sz = 0;
+ if (fx == 0.0 && fy == 0.0) {
+ sx = -fz;
+ sz = fx;
+ } else {
+ sx = fy;
+ sy = -fx;
+ }
+ float m[4][4] = {
+ { sx, sy*fz-sz*fy, -fx, 0 },
+ { sy, sz*fx-sx*fz, -fy, 0 },
+ { sz, sx*fy-sy*fx, -fz, 0 },
+ { 0, 0, 0, 1 }
+ };
+ applyMatrix(&m);
+ translate(-pos.x(), -pos.y(), -pos.z());
+}
+
+void DriverRonin::clearScreen()
+{
+ struct polygon_list mypoly;
+ struct packed_colour_vertex_list myvertex;
+
+ if(!_polyCount)
+ ta_begin_frame();
+
+ mypoly.cmd =
+ TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_OPAQUE|TA_CMD_POLYGON_SUBLIST|
+ TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR;
+ mypoly.mode1 = TA_POLYMODE1_Z_ALWAYS/*|TA_POLYMODE1_NO_Z_UPDATE*/;
+ mypoly.mode2 =
+ TA_POLYMODE2_BLEND_SRC|TA_POLYMODE2_FOG_DISABLED;
+ mypoly.texture = 0;
+
+ mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0;
+
+ ta_commit_list(&mypoly);
+
+ myvertex.cmd = TA_CMD_VERTEX;
+ myvertex.ocolour = 0;
+ myvertex.colour = 0xff00ff;
+ myvertex.z = 0.01;
+ myvertex.u = 0.0;
+ myvertex.v = 0.0;
+
+ myvertex.x = 0;
+ myvertex.y = 0;
+ ta_commit_list(&myvertex);
+
+ myvertex.x = 640;
+ ta_commit_list(&myvertex);
+
+ myvertex.x = 0;
+ myvertex.y = 480;
+ ta_commit_list(&myvertex);
+
+ myvertex.x = 640;
+ myvertex.cmd |= TA_CMD_VERTEX_EOS;
+ ta_commit_list(&myvertex);
+
+ _polyCount++;
+
+ //FIXME
+ // reportf("%s\n", __func__);
+}
+
+void commit_dummy_transpoly()
+{
+ struct polygon_list mypoly;
+
+ mypoly.cmd =
+ TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_TRANSPARENT|TA_CMD_POLYGON_SUBLIST|
+ TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR;
+ mypoly.mode1 = TA_POLYMODE1_Z_ALWAYS|TA_POLYMODE1_NO_Z_UPDATE;
+ mypoly.mode2 =
+ TA_POLYMODE2_BLEND_SRC_ALPHA|TA_POLYMODE2_BLEND_DST_INVALPHA|
+ TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_ENABLE_ALPHA;
+ mypoly.texture = 0;
+ mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0;
+ ta_commit_list(&mypoly);
+}
+
+void DriverRonin::flipBuffer()
+{
+ if(_polyCount) {
+ ta_commit_end();
+ commit_dummy_transpoly();
+ ta_commit_frame();
+ _polyCount = 0;
+ }
+}
+
+void DriverRonin::startActorDraw(Vector3d pos, float yaw, float pitch, float roll)
+{
+ //FIXME
+ //reportf("%s\n", __func__);
+ translateViewpoint(pos, pitch, yaw, roll);
+}
+
+void DriverRonin::finishActorDraw()
+{
+ //FIXME
+ //reportf("%s\n", __func__);
+ translateViewpoint();
+}
+
+void DriverRonin::set3DMode()
+{
+ //FIXME
+ //reportf("%s\n", __func__);
+}
+
+void DriverRonin::translateViewpoint(Vector3d pos, float pitch, float yaw, float roll)
+{
+ //FIXME
+ //reportf("%s\n", __func__);
+ pushMatrix();
+ translate(pos.x(), pos.y(), pos.z());
+ rotateZ( -yaw );
+ rotateX( -pitch );
+ rotateY( -roll );
+}
+
+void DriverRonin::translateViewpoint()
+{
+ //FIXME
+ //reportf("%s\n", __func__);
+ popMatrix();
+}
+
+void DriverRonin::drawHierachyNode(const Model::HierNode *node)
+{
+ //FIXME
+ //reportf("%s\n", __func__);
+ translateViewpoint(node->_animPos / node->_totalWeight, node->_animPitch / node->_totalWeight, node->_animYaw / node->_totalWeight, node->_animRoll / node->_totalWeight);
+ if (node->_hierVisible) {
+ if (node->_mesh != NULL && node->_meshVisible) {
+ pushMatrix();
+ translate(node->_pivot.x(), node->_pivot.y(), node->_pivot.z());
+ node->_mesh->draw();
+ popMatrix();
+ }
+
+ if (node->_child != NULL) {
+ node->_child->draw();
+ }
+ }
+ translateViewpoint();
+
+ if (node->_sibling != NULL)
+ node->_sibling->draw();
+}
+
+void DriverRonin::drawModelFace(const Model::Face *face, float *vertices, float *vertNormals, float *textureVerts)
+{
+ //FIXME
+ //reportf("%s\n", __func__);
+
+ struct packed_colour_vertex_list myvertex;
+
+ myvertex.cmd = TA_CMD_VERTEX;
+ myvertex.ocolour = 0;
+ myvertex.colour = 0x00ff00;
+ myvertex.u = 0.0;
+ myvertex.v = 0.0;
+
+ for (int i = 0; i < face->_numVertices; ) {
+ int j = i&1? i>>1 : face->_numVertices-1-(i>>1);
+ float *v = vertices + 3*face->_vertices[j];
+
+ if(face->_texVertices != NULL) {
+ float *t = textureVerts + 2*face->_texVertices[j];
+ myvertex.u = t[0] * _u_scale;
+ myvertex.v = t[1] * _v_scale;
+ //printf("%f %f\n", myvertex.u, myvertex.v);
+ }
+
+ if(++i == face->_numVertices)
+ myvertex.cmd |= TA_CMD_VERTEX_EOS;
+
+ ta_commit_vertex(&myvertex, v[0], v[1], v[2]);
+ }
+}
+
+void DriverRonin::disableLights()
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+void DriverRonin::setupLight(Scene::Light *light, int lightId)
+{
+ //FIXME
+ //reportf("%s\n", __func__);
+}
+
+void DriverRonin::createMaterial(Material *material, const char *data, const CMap *cmap)
+{
+ //FIXME
+ reportf("%s\n", __func__);
+ reportf("%d x %d x %d\n", material->_width, material->_height, material->_numImages);
+ if(data != NULL && material->_numImages > 0) {
+ Texture *tex = allocateTexture(material->_width, material->_height, material->_numImages);
+ material->_textures = tex;
+ for(int i=0; i<material->_numImages; i++) {
+ tex->setTexture(i, (const uint8 *)data, cmap);
+ data += material->_width * material->_height + 24;
+ }
+ } else {
+ material->_textures = 0;
+ }
+}
+
+void DriverRonin::selectMaterial(const Material *material)
+{
+ //FIXME
+ //reportf("%s\n", __func__);
+ struct polygon_list mypoly;
+
+ if(!_polyCount)
+ ta_begin_frame();
+
+ if(material->_textures) {
+ mypoly.cmd =
+ TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_OPAQUE|TA_CMD_POLYGON_SUBLIST|
+ TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR|
+ TA_CMD_POLYGON_TEXTURED|TA_CMD_POLYGON_GOURAUD_SHADING;
+ mypoly.mode1 = TA_POLYMODE1_Z_GREATEREQUAL; //TA_POLYMODE1_Z_ALWAYS|TA_POLYMODE1_NO_Z_UPDATE;
+ ((Texture *)material->_textures)->setup(material->_currImage, mypoly, _u_scale, _v_scale);
+ } else {
+
+ // reportf("%d x %d x %d\n", material->_width, material->_height, material->_numImages);
+
+ mypoly.cmd =
+ TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_OPAQUE|TA_CMD_POLYGON_SUBLIST|
+ TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR|
+ TA_CMD_POLYGON_GOURAUD_SHADING;
+ mypoly.mode1 = TA_POLYMODE1_Z_GREATEREQUAL; //TA_POLYMODE1_Z_ALWAYS|TA_POLYMODE1_NO_Z_UPDATE;
+ mypoly.mode2 =
+ TA_POLYMODE2_BLEND_SRC|TA_POLYMODE2_FOG_DISABLED;
+ mypoly.texture = 0;
+ }
+
+ mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0;
+
+ ta_commit_list(&mypoly);
+
+ _polyCount++;
+}
+
+void DriverRonin::destroyMaterial(Material *material)
+{
+ //FIXME
+ reportf("%s\n", __func__);
+ if(material->_textures)
+ freeTexture((Texture *)material->_textures);
+}
+
+#define QACR0 (*(volatile unsigned int *)(void *)0xff000038)
+#define QACR1 (*(volatile unsigned int *)(void *)0xff00003c)
+#define SQ_WAIT_STORE_QUEUES() do { unsigned int *d = (unsigned int *)0xe0000000; d[0] = d[8] = 0; } while(0)
+static void texture_memcpy64(void *dest, void *src, int cnt)
+{
+ unsigned int *s = (unsigned int *)src;
+ unsigned int *d = (unsigned int *)(void *)
+ (0xe0000000 | (((unsigned long)dest) & 0x03ffffc0));
+ unsigned int old_qacr0 = QACR0;
+ unsigned int old_qacr1 = QACR1;
+ SQ_WAIT_STORE_QUEUES();
+ QACR0 = ((0xa4000000>>26)<<2)&0x1c;
+ QACR1 = ((0xa4000000>>26)<<2)&0x1c;
+ while(cnt--) {
+ d[0] = *s++;
+ d[1] = *s++;
+ d[2] = *s++;
+ d[3] = *s++;
+ asm("pref @%0" : : "r" (s+16));
+ d[4] = *s++;
+ d[5] = *s++;
+ d[6] = *s++;
+ d[7] = *s++;
+ asm("pref @%0" : : "r" (d));
+ d += 8;
+ d[0] = *s++;
+ d[1] = *s++;
+ d[2] = *s++;
+ d[3] = *s++;
+ asm("pref @%0" : : "r" (s+16));
+ d[4] = *s++;
+ d[5] = *s++;
+ d[6] = *s++;
+ d[7] = *s++;
+ asm("pref @%0" : : "r" (d));
+ d += 8;
+ }
+ SQ_WAIT_STORE_QUEUES();
+ QACR0 = old_qacr0;
+ QACR1 = old_qacr1;
+}
+
+void DriverRonin::createBitmap(Bitmap *bitmap)
+{
+ static int x = 0;
+
+ //FIXME
+ reportf("%s %p\n", __func__, bitmap);
+
+ printf("format = %d, numImages = %d, w x h = %d x %d\n",
+ bitmap->_format, bitmap->_numImages,
+ bitmap->_width, bitmap->_height);
+ bitmap->_texIds = NULL;
+ if(bitmap->_format == 1 && ++x <= 3) {
+ bitmap->_texIds = ta_txalloc(bitmap->_width * bitmap->_height * 2);
+ texture_memcpy64(bitmap->_texIds, bitmap->_data[0],
+ (bitmap->_height*bitmap->_width)>>5);
+ }
+ if(true) {
+ for(int i=0; i<bitmap->_numImages; i++) {
+ delete[] bitmap->_data[i];
+ }
+ delete[] bitmap->_data;
+ bitmap->_data = NULL;
+ }
+}
+
+void DriverRonin::drawBitmap(const Bitmap *bitmap)
+{
+ struct polygon_list mypoly;
+ struct packed_colour_vertex_list myvertex;
+
+ if(bitmap->_format != 1 || !bitmap->_texIds)
+ return;
+
+ if(!_polyCount)
+ ta_begin_frame();
+
+ mypoly.cmd =
+ TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_OPAQUE|TA_CMD_POLYGON_SUBLIST|
+ TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR|TA_CMD_POLYGON_TEXTURED;
+ mypoly.mode1 = TA_POLYMODE1_Z_ALWAYS/*|TA_POLYMODE1_NO_Z_UPDATE*/;
+ mypoly.mode2 =
+ TA_POLYMODE2_BLEND_SRC|TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_TEXTURE_REPLACE|
+ TA_POLYMODE2_U_SIZE_1024|TA_POLYMODE2_V_SIZE_1024;
+ mypoly.texture = TA_TEXTUREMODE_RGB565|TA_TEXTUREMODE_NON_TWIDDLED|
+ TA_TEXTUREMODE_STRIDE|TA_TEXTUREMODE_ADDRESS(bitmap->_texIds);
+
+ mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0;
+
+ ta_commit_list(&mypoly);
+
+ myvertex.cmd = TA_CMD_VERTEX;
+ myvertex.ocolour = 0;
+ myvertex.colour = 0;
+ myvertex.z = 0.01;
+ myvertex.u = 0.0;
+ myvertex.v = 0.0;
+
+ myvertex.x = bitmap->_x;
+ myvertex.y = bitmap->_y;
+ ta_commit_list(&myvertex);
+
+ myvertex.x += bitmap->_width;
+ myvertex.u = bitmap->_width*(1/1024.0);
+ ta_commit_list(&myvertex);
+
+ myvertex.x = bitmap->_x;
+ myvertex.y += bitmap->_height;
+ myvertex.u = 0.0;
+ myvertex.v = bitmap->_height*(1/1024.0);
+ ta_commit_list(&myvertex);
+
+ myvertex.x += bitmap->_width;
+ myvertex.u = bitmap->_width*(1/1024.0);
+ myvertex.cmd |= TA_CMD_VERTEX_EOS;
+ ta_commit_list(&myvertex);
+
+ _polyCount++;
+
+ //FIXME
+ //reportf("%s %p\n", __func__, bitmap);
+}
+
+void DriverRonin::destroyBitmap(Bitmap *bitmap)
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+void DriverRonin::drawDepthBitmap(int x, int y, int w, int h, char *data)
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+Bitmap *DriverRonin::getScreenshot(int w, int h)
+{
+ //FIXME
+ reportf("%s\n", __func__);
+ return NULL;
+}
+
+void DriverRonin::storeDisplay()
+{
+ //FIXME
+ //reportf("%s\n", __func__);
+}
+
+void DriverRonin::copyStoredToDisplay()
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+void DriverRonin::dimScreen()
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+void DriverRonin::dimRegion(int x, int y, int w, int h, float level)
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+void DriverRonin::drawEmergString(int x, int y, const char *text, const Color &fgColor)
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+void DriverRonin::loadEmergFont()
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+Driver::TextObjectHandle *DriverRonin::createTextBitmap(uint8 *bitmap, int width, int height, const Color &fgColor)
+{
+ //FIXME
+ reportf("%s\n", __func__);
+ return new TextObjectHandle;
+}
+
+void DriverRonin::drawTextBitmap(int x, int y, TextObjectHandle *handle)
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+void DriverRonin::destroyTextBitmap(TextObjectHandle *handle)
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+void DriverRonin::drawRectangle(PrimitiveObject *primitive)
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+void DriverRonin::drawLine(PrimitiveObject *primitive)
+{
+ //FIXME
+ reportf("%s\n", __func__);
+}
+
+void DriverRonin::prepareSmushFrame(int width, int height, byte *bitmap)
+{
+ //FIXME
+ //reportf("%s(%d,%d,%p)\n", __func__, width, height, bitmap);
+ assert(width == 640 && height == 480);
+ texture_memcpy64(_smushTex, bitmap, (640*480)>>5);
+}
+
+void DriverRonin::drawSmushFrame(int offsetX, int offsetY)
+{
+ //FIXME
+ // reportf("%s(%d,%d)\n", __func__, offsetX, offsetY);
+
+ struct polygon_list mypoly;
+ struct packed_colour_vertex_list myvertex;
+
+ if(!_polyCount)
+ ta_begin_frame();
+
+ mypoly.cmd =
+ TA_CMD_POLYGON|TA_CMD_POLYGON_TYPE_OPAQUE|TA_CMD_POLYGON_SUBLIST|
+ TA_CMD_POLYGON_STRIPLENGTH_2|TA_CMD_POLYGON_PACKED_COLOUR|TA_CMD_POLYGON_TEXTURED;
+ mypoly.mode1 = TA_POLYMODE1_Z_ALWAYS|TA_POLYMODE1_NO_Z_UPDATE;
+ mypoly.mode2 =
+ TA_POLYMODE2_BLEND_SRC|TA_POLYMODE2_FOG_DISABLED|TA_POLYMODE2_TEXTURE_REPLACE|
+ TA_POLYMODE2_U_SIZE_1024|TA_POLYMODE2_V_SIZE_1024;
+ mypoly.texture = TA_TEXTUREMODE_RGB565|TA_TEXTUREMODE_NON_TWIDDLED|
+ TA_TEXTUREMODE_STRIDE|TA_TEXTUREMODE_ADDRESS(_smushTex);
+
+ mypoly.red = mypoly.green = mypoly.blue = mypoly.alpha = 0;
+
+ ta_commit_list(&mypoly);
+
+ myvertex.cmd = TA_CMD_VERTEX;
+ myvertex.ocolour = 0;
+ myvertex.colour = 0;
+ myvertex.z = 0.01;
+ myvertex.u = 0.0;
+ myvertex.v = 0.0;
+
+ myvertex.x = offsetX;
+ myvertex.y = offsetY;
+ ta_commit_list(&myvertex);
+
+ myvertex.x += 640;
+ myvertex.u = 640*(1/1024.0);
+ ta_commit_list(&myvertex);
+
+ myvertex.x = offsetX;
+ myvertex.y += 480;
+ myvertex.u = 0.0;
+ myvertex.v = 480*(1/1024.0);
+ ta_commit_list(&myvertex);
+
+ myvertex.x += 640;
+ myvertex.u = 640*(1/1024.0);
+ myvertex.cmd |= TA_CMD_VERTEX_EOS;
+ ta_commit_list(&myvertex);
+
+ _polyCount++;
+}
+
+char *DriverRonin::getVideoDeviceName()
+{
+ return "Dreamcast PowerVR Video Device";
+}
+
+void DriverRonin::initGfx()
+{
+ _polyCount = 0;
+ dc_setup_ta();
+ initTextures();
+ *(volatile unsigned int *)(0xa05f80e4) = 640/32; //stride
+
+ _smushTex = ta_txalloc(640 * 480 * 2);
+}
Property changes on: residual/trunk/dc/driver_ronin_gfx.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: residual/trunk/dc/driver_ronin_sound.cpp
===================================================================
--- residual/trunk/dc/driver_ronin_sound.cpp (rev 0)
+++ residual/trunk/dc/driver_ronin_sound.cpp 2006-02-20 22:08:03 UTC (rev 20802)
@@ -0,0 +1,98 @@
+// Residual - Virtual machine to run LucasArts' 3D adventure games
+// Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#include "debug.h"
+#include "driver_ronin.h"
+
+#include <ronin/ronin.h>
+#include <ronin/report.h>
+
+EXTERN_C void *memcpy4s(void *s1, const void *s2, unsigned int n);
+
+bool DriverRonin::setSoundCallback(SoundProc proc, void *param)
+{
+ assert(SAMPLE_MODE == 0);
+
+ _sound_proc_param = param;
+ _sound_proc = proc;
+
+ return true;
+}
+
+void DriverRonin::clearSoundCallback()
+{
+ _sound_proc = NULL;
+ _sound_proc_param = NULL;
+ stop_sound();
+}
+
+int DriverRonin::getOutputSampleRate() const
+{
+ //FIXME
+ /// XXX reportf("%s\n", __func__);
+ return read_sound_int(&SOUNDSTATUS->freq);
+}
+
+void DriverRonin::checkSound()
+{
+ int n;
+ int curr_ring_buffer_samples;
+
+ if(!_sound_proc)
+ return;
+
+ if(read_sound_int(&SOUNDSTATUS->mode) != MODE_PLAY)
+ start_sound();
+
+ curr_ring_buffer_samples = read_sound_int(&SOUNDSTATUS->ring_length);
+
+ n = read_sound_int(&SOUNDSTATUS->samplepos);
+
+ if((n-=fillpos)<0)
+ n += curr_ring_buffer_samples;
+
+ n = ADJUST_BUFFER_SIZE(n-10);
+
+ if(n<100)
+ return;
+
+ _sound_proc(_sound_proc_param, (byte*)temp_sound_buffer,
+ 2*SAMPLES_TO_BYTES(n));
+
+ if(fillpos+n > curr_ring_buffer_samples) {
+ int r = curr_ring_buffer_samples - fillpos;
+ memcpy4s(RING_BUF+fillpos, temp_sound_buffer, SAMPLES_TO_BYTES(r));
+ fillpos = 0;
+ n -= r;
+ memcpy4s(RING_BUF, temp_sound_buffer+r, SAMPLES_TO_BYTES(n));
+ } else {
+ memcpy4s(RING_BUF+fillpos, temp_sound_buffer, SAMPLES_TO_BYTES(n));
+ }
+ if((fillpos += n) >= curr_ring_buffer_samples)
+ fillpos = 0;
+}
+
+void DriverRonin::initSound()
+{
+ _sound_proc = NULL;
+
+ init_arm();
+ stop_sound();
+ do_sound_command(CMD_SET_FREQ_EXP(FREQ_22050_EXP));
+ do_sound_command(CMD_SET_STEREO(1));
+ do_sound_command(CMD_SET_BUFFER(SOUND_BUFFER_SHIFT));
+}
Property changes on: residual/trunk/dc/driver_ronin_sound.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: residual/trunk/dc/main.cpp
===================================================================
--- residual/trunk/dc/main.cpp (rev 0)
+++ residual/trunk/dc/main.cpp 2006-02-20 22:08:03 UTC (rev 20802)
@@ -0,0 +1,181 @@
+// Residual - Virtual machine to run LucasArts' 3D adventure games
+// Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#include "stdafx.h"
+#include "debug.h"
+#include "bitmap.h"
+#include "resource.h"
+#include "lua.h"
+#include "registry.h"
+#include "localize.h"
+#include "engine.h"
+#include "timer.h"
+#include "smush.h"
+#include "driver_ronin.h"
+
+#include "mixer/mixer.h"
+
+#include "imuse/imuse.h"
+
+#define Timer RoninTimer
+
+#include <ronin/ronin.h>
+#include <ronin/report.h>
+
+#undef Timer
+
+// Hacky global toggles for experimental/debug code
+bool ZBUFFER_GLOBAL, SHOWFPS_GLOBAL, TINYGL_GLOBAL;
+enDebugLevels debugLevel = DEBUG_NONE;
+
+static bool g_lua_initialized = false;
+Driver *g_driver = NULL;
+
+void quit();
+
+int main() {
+ int i;
+
+#ifndef NOSERIAL
+ serial_init(57600);
+ usleep(2000000);
+ printf("Serial OK\r\n");
+#endif
+
+ atexit(quit);
+
+ g_registry = new Registry();
+ g_registry->set("DataDir", "/GRIMDATA");
+ g_registry->set("good_times", "TRUE");
+
+ g_driver = new DriverRonin();
+ g_engine = new Engine();
+ g_resourceloader = new ResourceLoader();
+ g_localizer = new Localizer();
+ g_mixer = new SoundMixer();
+ g_mixer->setVolume(255);
+ g_timer = new Timer();
+ g_smush = new Smush();
+ g_imuse = new Imuse(20);
+
+ Bitmap *splash_bm = NULL;
+ splash_bm = g_resourceloader->loadBitmap("splash.bm");
+
+ g_driver->clearScreen();
+ splash_bm->draw();
+ g_driver->flipBuffer();
+
+ lua_iolibopen();
+ lua_strlibopen();
+ lua_mathlibopen();
+
+ register_lua();
+ g_lua_initialized = true;
+
+ bundle_dofile("_system.lua");
+
+ lua_pushnil(); // resumeSave
+ lua_pushnil(); // bootParam
+// lua_pushnumber(0); // bootParam
+ lua_call("BOOT");
+
+ g_engine->setMode(ENGINE_MODE_NORMAL);
+ g_engine->mainLoop();
+
+ quit();
+
+ return 0;
+}
+
+void quit() {
+ if (g_lua_initialized) {
+ lua_removelibslists();
+ lua_close();
+ g_lua_initialized = false;
+ }
+ if (g_registry) {
+ g_registry->save();
+ delete g_registry;
+ g_registry = NULL;
+ }
+ if (g_smush) {
+ delete g_smush;
+ g_smush = NULL;
+ }
+ if (g_imuse) {
+ delete g_imuse;
+ g_imuse = NULL;
+ }
+ if (g_localizer) {
+ delete g_localizer;
+ g_localizer = NULL;
+ }
+ if (g_resourceloader) {
+ delete g_resourceloader;
+ g_resourceloader = NULL;
+ }
+ if (g_engine) {
+ delete g_engine;
+ g_engine = NULL;
+ }
+ if (g_timer) {
+ delete g_timer;
+ g_timer = NULL;
+ }
+ if (g_mixer) {
+ delete g_mixer;
+ g_mixer = NULL;
+ }
+ if (g_driver) {
+ delete g_driver;
+ g_driver = NULL;
+ }
+
+ report("Exiting to IP slave...\n");
+ ((void (*)())0x8cf00000)();
+}
+
+int system(const char *command)
+{
+ return -1;
+}
+
+int remove(const char *pathname)
+{
+ return -1;
+}
+
+int unlink(const char *pathname)
+{
+ return -1;
+}
+
+int rename(const char *oldpath, const char *newpath)
+{
+ return -1;
+}
+
+char *tmpnam(char *s)
+{
+ return NULL;
+}
+
+clock_t clock(void)
+{
+ return 0;
+}
+
Property changes on: residual/trunk/dc/main.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: residual/trunk/dc/matrix_ops.cpp
===================================================================
--- residual/trunk/dc/matrix_ops.cpp (rev 0)
+++ residual/trunk/dc/matrix_ops.cpp 2006-02-20 22:08:03 UTC (rev 20802)
@@ -0,0 +1,97 @@
+// Residual - Virtual machine to run LucasArts' 3D adventure games
+// Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#include "matrix_ops.h"
+
+#include <ronin/ronin.h>
+#include <ronin/matrix.h>
+#include <ronin/sincos_rroot.h>
+#include <assert.h>
+
+#define DEG(X) ((int)(X*(65536.0/360.0)))
+
+void MatrixOps::pushMatrix()
+{
+ assert(_matrix_depth < MAX_MATRIX_STACK_DEPTH);
+ save_matrix(&_matrix_stack[_matrix_depth++]);
+}
+
+void MatrixOps::popMatrix()
+{
+ assert(_matrix_depth > 0);
+ load_matrix(&_matrix_stack[--_matrix_depth]);
+}
+
+void MatrixOps::translate(float x, float y, float z)
+{
+ static float matrix[4][4] = {
+ { 1.0, 0.0, 0.0, 0.0 },
+ { 0.0, 1.0, 0.0, 0.0 },
+ { 0.0, 0.0, 1.0, 0.0 },
+ { 0.0, 0.0, 0.0, 1.0 },
+ };
+ matrix[3][0] = x;
+ matrix[3][1] = y;
+ matrix[3][2] = z;
+ apply_matrix(&matrix);
+}
+
+void MatrixOps::rotateX(float deg)
+{
+ static float matrix[4][4] = {
+ { 1.0, 0.0, 0.0, 0.0 },
+ { 0.0, 1.0, 0.0, 0.0 },
+ { 0.0, 0.0, 1.0, 0.0 },
+ { 0.0, 0.0, 0.0, 1.0 },
+ };
+ float s, c;
+ SINCOS(DEG(deg), s, c);
+ matrix[1][1] = matrix[2][2] = c;
+ matrix[1][2] = -(matrix[2][1] = s);
+ apply_matrix(&matrix);
+}
+
+void MatrixOps::rotateY(float deg)
+{
+ static float matrix[4][4] = {
+ { 1.0, 0.0, 0.0, 0.0 },
+ { 0.0, 1.0, 0.0, 0.0 },
+ { 0.0, 0.0, 1.0, 0.0 },
+ { 0.0, 0.0, 0.0, 1.0 },
+ };
+ float s, c;
+ SINCOS(DEG(deg), s, c);
+ matrix[0][0] = matrix[2][2] = c;
+ matrix[2][0] = -(matrix[0][2] = s);
+ apply_matrix(&matrix);
+}
+
+void MatrixOps::rotateZ(float deg)
+{
+ static float matrix[4][4] = {
+ { 1.0, 0.0, 0.0, 0.0 },
+ { 0.0, 1.0, 0.0, 0.0 },
+ { 0.0, 0.0, 1.0, 0.0 },
+ { 0.0, 0.0, 0.0, 1.0 },
+ };
+ float s, c;
+ SINCOS(DEG(deg), s, c);
+ matrix[0][0] = matrix[1][1] = c;
+ matrix[0][1] = -(matrix[1][0] = s);
+ apply_matrix(&matrix);
+}
+
Property changes on: residual/trunk/dc/matrix_ops.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: residual/trunk/dc/matrix_ops.h
===================================================================
--- residual/trunk/dc/matrix_ops.h (rev 0)
+++ residual/trunk/dc/matrix_ops.h 2006-02-20 22:08:03 UTC (rev 20802)
@@ -0,0 +1,42 @@
+// Residual - Virtual machine to run LucasArts' 3D adventure games
+// Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#ifndef MATRIX_OPS_H
+#define MATRIX_OPS_H
+
+#include <ronin/matrix.h>
+
+#define MAX_MATRIX_STACK_DEPTH 16
+
+class MatrixOps {
+ private:
+ int _matrix_depth;
+ float _matrix_stack[MAX_MATRIX_STACK_DEPTH][4][4];
+
+ public:
+ void clearMatrixStack() { _matrix_depth = 0; }
+ void loadMatrix(float (*m)[4][4]) { load_matrix(m); }
+ void applyMatrix(float (*m)[4][4]) { apply_matrix(m); }
+ void pushMatrix();
+ void popMatrix();
+ void translate(float x, float y, float z);
+ void rotateX(float deg);
+ void rotateY(float deg);
+ void rotateZ(float deg);
+};
+
+#endif
Property changes on: residual/trunk/dc/matrix_ops.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: residual/trunk/dc/texture_manager.cpp
===================================================================
--- residual/trunk/dc/texture_manager.cpp (rev 0)
+++ residual/trunk/dc/texture_manager.cpp 2006-02-20 22:08:03 UTC (rev 20802)
@@ -0,0 +1,224 @@
+// Residual - Virtual machine to run LucasArts' 3D adventure games
+// Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#include "debug.h"
+#include "colormap.h"
+#include "material.h"
+#include "texture_manager.h"
+
+static int twiddletab[1024];
+
+static void init_twiddletab()
+{
+ int x;
+ for(x=0; x<1024; x++)
+ twiddletab[x] = (x&1)|((x&2)<<1)|((x&4)<<2)|((x&8)<<3)|((x&16)<<4)|
+ ((x&32)<<5)|((x&64)<<6)|((x&128)<<7)|((x&256)<<8)|((x&512)<<9);
+}
+
+TextureManager::Texture::Texture(uint16 *tex, unsigned int fsz, int width, int height, int cnt)
+ : _data(tex), _width(width), _height(height), _cnt(cnt), _framesize(fsz)
+{
+ _texture = TA_TEXTUREMODE_ARGB1555|TA_TEXTUREMODE_ADDRESS(_data);
+ _mode2 = TA_POLYMODE2_BLEND_SRC|TA_POLYMODE2_FOG_DISABLED|
+ TA_POLYMODE2_TEXTURE_REPLACE|TA_POLYMODE2_BILINEAR_FILTER;
+
+ switch(_width) {
+ case 4:
+ /* XXX */
+ case 8:
+ _mode2 |= TA_POLYMODE2_U_SIZE_8;
+ _uscale = 1.0/8;
+ break;
+ case 16:
+ _mode2 |= TA_POLYMODE2_U_SIZE_16;
+ _uscale = 1.0/16;
+ break;
+ case 32:
+ _mode2 |= TA_POLYMODE2_U_SIZE_32;
+ _uscale = 1.0/32;
+ break;
+ case 64:
+ _mode2 |= TA_POLYMODE2_U_SIZE_64;
+ _uscale = 1.0/64;
+ break;
+ case 128:
+ _mode2 |= TA_POLYMODE2_U_SIZE_128;
+ _uscale = 1.0/128;
+ break;
+ case 256:
+ _mode2 |= TA_POLYMODE2_U_SIZE_256;
+ _uscale = 1.0/256;
+ break;
+ default:
+ assert(0);
+ break;
+ }
+ switch(_height) {
+ case 4:
+ /* XXX */
+ case 8:
+ _mode2 |= TA_POLYMODE2_V_SIZE_8;
+ _vscale = 1.0/8;
+ break;
+ case 16:
+ _mode2 |= TA_POLYMODE2_V_SIZE_16;
+ _vscale = 1.0/16;
+ break;
+ case 32:
+ _mode2 |= TA_POLYMODE2_V_SIZE_32;
+ _vscale = 1.0/32;
+ break;
+ case 64:
+ _mode2 |= TA_POLYMODE2_V_SIZE_64;
+ _vscale = 1.0/64;
+ break;
+ case 128:
+ _mode2 |= TA_POLYMODE2_V_SIZE_128;
+ _vscale = 1.0/128;
+ break;
+ case 256:
+ _mode2 |= TA_POLYMODE2_V_SIZE_256;
+ _vscale = 1.0/256;
+ break;
+ default:
+ assert(0);
+ break;
+ }
+ assert((_width > 4 && _height > 4) || (_width == 4 && _height == 4));
+}
+
+void TextureManager::Texture::
+setTextureTwiddled(uint16 *tex, const uint8 *data,
+ const CMap *cmap, int sz, int extra)
+{
+ for(int y=0; y<sz; y++, data += extra)
+ for(int x=0; x<sz; x++) {
+ uint8 n = *data++;
+ uint16 t;
+ if(!n)
+ t = 0;
+ else {
+ uint8 *c = (uint8*)cmap->_colors+3*n;
+ t = 0x8000 |
+ ((c[0]<<7)&0x7c00)|
+ ((c[1]<<2)&0x03e0)|
+ ((c[2]>>3)&0x001f);
+ }
+ *(uint16*)(((twiddletab[x]<<2)|(twiddletab[y]<<1))
+ + (char *)tex) = t;
+ }
+}
+
+void TextureManager::Texture::setTexture(int n, const uint8 *data, const CMap *cmap)
+{
+ uint16 *tex = (uint16 *)(n * _framesize + (char *)_data);
+
+ if(_width == _height)
+ setTextureTwiddled(tex, data, cmap, _width);
+ else if(_width > _height) {
+ const uint8 *d2 = data;
+ uint16 *t2 = tex;
+ unsigned int fsz = _height * _height * 2;
+ for(int x = 0; x < _width; x += _height) {
+ setTextureTwiddled(t2, d2, cmap, _height, _width - _height);
+ d2 += _height;
+ t2 += _height * _height;
+ }
+ } else {
+ const uint8 *d2 = data;
+ uint16 *t2 = tex;
+ for(int x = 0; x < _height; x += _width) {
+ setTextureTwiddled(t2, d2, cmap, _width);
+ d2 += _width * _width;
+ t2 += _width * _width;
+ }
+ }
+}
+
+TextureManager::Texture *TextureManager::allocateTexture(int width, int height, int cnt)
+{
+ unsigned int framesize = width * height * 2;
+ uint16 *tex = (uint16 *) allocateTexMem(framesize * cnt);
+ return new Texture(tex, framesize, width, height, cnt);
+}
+
+void TextureManager::freeTexture(Texture *t)
+{
+ freeTexMem(t->getMemory(), t->getFrameSize()*t->getCnt());
+ delete t;
+}
+
+void *TextureManager::allocateTexMem(unsigned int size)
+{
+ assert(size > 0 && !(size&7));
+ // First fit
+ FreeListNode *n, **link;
+ for(link = &_freeListHead; (n = *link) != NULL; link = &n->next)
+ if(n->size >= size)
+ break;
+ assert(n != NULL);
+ if(n->size > size) {
+ FreeListNode *n2 = (FreeListNode *)(size + (char *)n);
+ n2->size = n->size - size;
+ n2->next = n->next;
+ *link = n2;
+ } else {
+ *link = n->next;
+ }
+ return (void *)n;
+}
+
+void TextureManager::freeTexMem(void *mem, unsigned int size)
+{
+ assert(size > 0 && !(size&7) && mem != NULL);
+
+ FreeListNode *n, **link;
+ for(link = &_freeListHead; (n = *link) != NULL; link = &n->next)
+ if(mem == (n->size + (char *)n))
+ break;
+ else if(mem < n) {
+ n = NULL;
+ break;
+ } else
+ assert(mem > (n->size + (char *)n));
+ if(n == NULL) {
+ n = (FreeListNode *)mem;
+ n->size = size;
+ n->next = *link;
+ *link = n;
+ } else {
+ n->size += size;
+ }
+
+ // Join this block with the next one if possible
+ if((char *)n->next == n->size + (char *)n) {
+ n->size += n->next->size;
+ n->next = n->next->next;
+ }
+
+ assert(n->next == NULL || (char *)n->next > n->size + (char *)n);
+}
+
+void TextureManager::initTextures()
+{
+ unsigned int aperture = 0x180000;
+ _freeListHead = (FreeListNode *)ta_txalloc(aperture);
+ _freeListHead->next = NULL;
+ _freeListHead->size = aperture;
+ init_twiddletab();
+}
Property changes on: residual/trunk/dc/texture_manager.cpp
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Added: residual/trunk/dc/texture_manager.h
===================================================================
--- residual/trunk/dc/texture_manager.h (rev 0)
+++ residual/trunk/dc/texture_manager.h 2006-02-20 22:08:03 UTC (rev 20802)
@@ -0,0 +1,67 @@
+// Residual - Virtual machine to run LucasArts' 3D adventure games
+// Copyright (C) 2003-2006 The ScummVM-Residual Team (www.scummvm.org)
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+#ifndef TEXTURE_MANAGER_H
+#define TEXTURE_MANAGER_H
+
+#include "bits.h"
+#include "colormap.h"
+
+#include <ronin/ta.h>
+
+class TextureManager {
+ public:
+ class Texture {
+ public:
+ Texture(uint16 *tex, unsigned int fsz, int width, int height, int cnt);
+ void setTexture(int n, const uint8 *data, const CMap *cmap);
+ void setup(int n, struct polygon_list &list, float &uscale, float &vscale) {
+ list.mode2 = _mode2;
+ list.texture = _texture + TA_TEXTUREMODE_ADDRESS(n*_framesize);
+ uscale = _uscale;
+ vscale = _vscale;
+ }
+ uint16 *getMemory() const { return _data; }
+ unsigned int getFrameSize() const { return _framesize; }
+ uint16 getCnt() const { return _cnt; }
+ private:
+ static void setTextureTwiddled(uint16 *tex, const uint8 *data,
+ const CMap *cmap, int sz, int extra=0);
+ unsigned int _mode2, _texture;
+ float _uscale, _vscale;
+ uint16 *_data;
+ uint16 _width, _height, _cnt;
+ unsigned int _framesize;
+ };
+
+ TextureManager() : _freeListHead(NULL) {}
+ Texture *allocateTexture(int width, int height, int cnt);
+ void freeTexture(Texture *t);
+ void initTextures();
+
+ private:
+ struct FreeListNode {
+ struct FreeListNode *next;
+ unsigned int size;
+ };
+ FreeListNode *_freeListHead;
+ void *allocateTexMem(unsigned int size);
+ void freeTexMem(void *mem, unsigned int size);
+};
+
+#endif
+
Property changes on: residual/trunk/dc/texture_manager.h
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Date Rev Author URL Id
Name: svn:eol-style
+ native
Modified: residual/trunk/registry.cpp
===================================================================
--- residual/trunk/registry.cpp 2006-02-20 20:57:26 UTC (rev 20801)
+++ residual/trunk/registry.cpp 2006-02-20 22:08:03 UTC (rev 20802)
@@ -24,6 +24,7 @@
Registry *g_registry = NULL;
Registry::Registry() : _dirty(false) {
+#ifndef __DC__
#ifdef WIN32
std::string filename = "residual.ini";
#else
@@ -46,6 +47,7 @@
}
std::fclose(f);
}
+#endif
}
const char *Registry::get(const char *key, const char *defval) const {
@@ -74,6 +76,7 @@
if (!_dirty)
return;
+#ifndef __DC__
#ifdef WIN32
std::string filename = "residual.ini";
#else
@@ -91,5 +94,6 @@
std::fprintf(f, "%s=%s\n", i->first.c_str(), i->second.c_str());
std::fclose(f);
+#endif
_dirty = false;
}
Modified: residual/trunk/stdafx.h
===================================================================
--- residual/trunk/stdafx.h 2006-02-20 20:57:26 UTC (rev 20801)
+++ residual/trunk/stdafx.h 2006-02-20 22:08:03 UTC (rev 20802)
@@ -97,8 +97,10 @@
#endif
#if !defined(macintosh)
#include <sys/types.h>
+#if !defined(__DC__)
#include <sys/uio.h>
#endif
+#endif
#if !defined (__BEOS__)
#include <unistd.h>
#endif
@@ -112,7 +114,11 @@
#include <stdarg.h>
#include <assert.h>
#include <ctype.h>
+#if defined(__DC__)
+#include <ronin/cdfs.h>
+#else
#include <dirent.h>
+#endif
#endif
More information about the Scummvm-git-logs
mailing list