Przeglądaj źródła

Removed unused files

Iñigo Valentin 4 lat temu
rodzic
commit
0346bc1cd1
100 zmienionych plików z 1 dodań i 28447 usunięć
  1. 1 16
      utilities/CMakeLists.txt
  2. 0 49
      utilities/ffix_model_exporter/CMakeLists.txt
  3. 0 240
      utilities/ffix_model_exporter/src/AnimationExtractor.cpp
  4. 0 15
      utilities/ffix_model_exporter/src/AnimationExtractor.h
  5. 0 146
      utilities/ffix_model_exporter/src/Main.cpp
  6. 0 355
      utilities/ffix_model_exporter/src/MeshExtractor.cpp
  7. 0 15
      utilities/ffix_model_exporter/src/MeshExtractor.h
  8. 0 164
      utilities/ffix_model_exporter/src/ModelFile.cpp
  9. 0 36
      utilities/ffix_model_exporter/src/ModelFile.h
  10. 0 43
      utilities/ffix_script_dumper/CMakeLists.txt
  11. 0 24
      utilities/ffix_script_dumper/src/Main.cpp
  12. 0 2133
      utilities/ffix_script_dumper/src/ScriptFile.cpp
  13. 0 39
      utilities/ffix_script_dumper/src/ScriptFile.h
  14. 0 505
      utilities/ffix_script_dumper/src/TextFile.cpp
  15. 0 22
      utilities/ffix_script_dumper/src/TextFile.h
  16. 0 53
      utilities/ffix_sound_dumper/CMakeLists.txt
  17. 0 187
      utilities/ffix_sound_dumper/src/Main.cpp
  18. 0 20
      utilities/ffix_sound_dumper/src/Main.h
  19. 0 34
      utilities/ffix_sound_dumper/src/SoundParser.cpp
  20. 0 34
      utilities/ffix_sound_dumper/src/SoundParser.h
  21. 0 29
      utilities/ffix_sound_dumper/src/engine/SoundBackend.h
  22. 0 3830
      utilities/ffix_sound_dumper/src/engine/SoundManager.cpp
  23. 0 504
      utilities/ffix_sound_dumper/src/engine/SoundManager.h
  24. 0 139
      utilities/ffix_sound_dumper/src/engine/backends/SoundBackendSDL.cpp
  25. 0 37
      utilities/ffix_sound_dumper/src/engine/backends/SoundBackendSDL.h
  26. 0 57
      utilities/ffvii_battle_model_exporter/CMakeLists.txt
  27. 0 310
      utilities/ffvii_battle_model_exporter/src/AnimationExtractor.cpp
  28. 0 37
      utilities/ffvii_battle_model_exporter/src/AnimationExtractor.h
  29. 0 224
      utilities/ffvii_battle_model_exporter/src/AnimationScriptDumper.cpp
  30. 0 15
      utilities/ffvii_battle_model_exporter/src/AnimationScriptDumper.h
  31. 0 284
      utilities/ffvii_battle_model_exporter/src/EnemyFile.cpp
  32. 0 52
      utilities/ffvii_battle_model_exporter/src/EnemyFile.h
  33. 0 188
      utilities/ffvii_battle_model_exporter/src/Main.cpp
  34. 0 441
      utilities/ffvii_battle_model_exporter/src/MeshExtractor.cpp
  35. 0 15
      utilities/ffvii_battle_model_exporter/src/MeshExtractor.h
  36. 0 95
      utilities/ffvii_battle_model_exporter/src/RamEffectFile.cpp
  37. 0 31
      utilities/ffvii_battle_model_exporter/src/RamEffectFile.h
  38. 0 247
      utilities/ffvii_battle_model_exporter/src/StageFile.cpp
  39. 0 34
      utilities/ffvii_battle_model_exporter/src/StageFile.h
  40. 0 49
      utilities/ffvii_battle_scene_dumper/CMakeLists.txt
  41. 0 1375
      utilities/ffvii_battle_scene_dumper/src/EnemyFile.cpp
  42. 0 23
      utilities/ffvii_battle_scene_dumper/src/EnemyFile.h
  43. 0 66
      utilities/ffvii_battle_scene_dumper/src/FFVIIString.cpp
  44. 0 21
      utilities/ffvii_battle_scene_dumper/src/FFVIIString.h
  45. 0 28
      utilities/ffvii_battle_scene_dumper/src/Main.cpp
  46. 0 876
      utilities/ffvii_battle_scene_dumper/src/PlayerFile.cpp
  47. 0 23
      utilities/ffvii_battle_scene_dumper/src/PlayerFile.h
  48. 0 46
      utilities/ffvii_field_dat_dumper/CMakeLists.txt
  49. 0 3645
      utilities/ffvii_field_dat_dumper/src/DatFile.cpp
  50. 0 387
      utilities/ffvii_field_dat_dumper/src/DatFile.h
  51. 0 219
      utilities/ffvii_field_dat_dumper/src/Main.cpp
  52. 0 457
      utilities/ffvii_field_dat_dumper/src/MimFile.cpp
  53. 0 66
      utilities/ffvii_field_dat_dumper/src/MimFile.h
  54. 0 60
      utilities/ffvii_field_model_exporter/CMakeLists.txt
  55. 0 215
      utilities/ffvii_field_model_exporter/src/AnimationFile.cpp
  56. 0 63
      utilities/ffvii_field_model_exporter/src/AnimationFile.h
  57. 0 95
      utilities/ffvii_field_model_exporter/src/BcxFile.cpp
  58. 0 26
      utilities/ffvii_field_model_exporter/src/BcxFile.h
  59. 0 329
      utilities/ffvii_field_model_exporter/src/BsxFile.cpp
  60. 0 63
      utilities/ffvii_field_model_exporter/src/BsxFile.h
  61. 0 62
      utilities/ffvii_field_model_exporter/src/DatFile.cpp
  62. 0 33
      utilities/ffvii_field_model_exporter/src/DatFile.h
  63. 0 120
      utilities/ffvii_field_model_exporter/src/Main.cpp
  64. 0 551
      utilities/ffvii_field_model_exporter/src/MeshFile.cpp
  65. 0 45
      utilities/ffvii_field_model_exporter/src/MeshFile.h
  66. 0 111
      utilities/ffvii_field_model_exporter/src/Model.cpp
  67. 0 62
      utilities/ffvii_field_model_exporter/src/Model.h
  68. 0 73
      utilities/ffvii_field_model_exporter/src/SkeletonFile.cpp
  69. 0 25
      utilities/ffvii_field_model_exporter/src/SkeletonFile.h
  70. 0 277
      utilities/ffvii_field_model_exporter/src/TdbFile.cpp
  71. 0 26
      utilities/ffvii_field_model_exporter/src/TdbFile.h
  72. 0 51
      utilities/ffvii_field_model_exporter_pc/CMakeLists.txt
  73. 0 18
      utilities/ffvii_field_model_exporter_pc/bin/plugins.cfg
  74. 0 18
      utilities/ffvii_field_model_exporter_pc/bin/plugins_d.cfg
  75. 0 12
      utilities/ffvii_field_model_exporter_pc/bin/resources.cfg
  76. 0 12
      utilities/ffvii_field_model_exporter_pc/bin/resources_d.cfg
  77. 0 41
      utilities/ffvii_field_model_exporter_pc/include/FF7FieldModelExporterPC.h
  78. 0 39
      utilities/ffvii_field_model_exporter_pc/src/FF7FieldModelExporterPC.cpp
  79. 0 163
      utilities/ffvii_field_model_exporter_pc/src/main.cpp
  80. 0 42
      utilities/ffvii_font_exporter/CMakeLists.txt
  81. 0 373
      utilities/ffvii_font_exporter/src/FontFile.cpp
  82. 0 22
      utilities/ffvii_font_exporter/src/FontFile.h
  83. 0 142
      utilities/ffvii_font_exporter/src/Main.cpp
  84. 0 17
      utilities/ffvii_font_exporter/src/Main.h
  85. 0 51
      utilities/ffvii_sound_dumper/CMakeLists.txt
  86. 0 1892
      utilities/ffvii_sound_dumper/src/AkaoParser.cpp
  87. 0 302
      utilities/ffvii_sound_dumper/src/AkaoParser.h
  88. 0 201
      utilities/ffvii_sound_dumper/src/Main.cpp
  89. 0 20
      utilities/ffvii_sound_dumper/src/Main.h
  90. 0 29
      utilities/ffvii_sound_dumper/src/engine/SoundBackend.h
  91. 0 3817
      utilities/ffvii_sound_dumper/src/engine/SoundManager.cpp
  92. 0 512
      utilities/ffvii_sound_dumper/src/engine/SoundManager.h
  93. 0 137
      utilities/ffvii_sound_dumper/src/engine/backends/SoundBackendSDL.cpp
  94. 0 37
      utilities/ffvii_sound_dumper/src/engine/backends/SoundBackendSDL.h
  95. 0 81
      utilities/ffvii_sound_dumper_psf/CMakeLists.txt
  96. 0 4
      utilities/ffvii_sound_dumper_psf/src/libupse/config.h
  97. 0 37
      utilities/ffvii_sound_dumper_psf/src/libupse/upse-debug.h
  98. 0 61
      utilities/ffvii_sound_dumper_psf/src/libupse/upse-internal.h
  99. 0 36
      utilities/ffvii_sound_dumper_psf/src/libupse/upse-ps1-bios-base.h
  100. 0 64
      utilities/ffvii_sound_dumper_psf/src/libupse/upse-ps1-bios-private.h

+ 1 - 16
utilities/CMakeLists.txt

@@ -46,22 +46,7 @@ target_link_libraries(Utility
 )
 SET_PROPERTY(TARGET Utility PROPERTY FOLDER "utilities")
 
-add_subdirectory(ffix_model_exporter)
-add_subdirectory(ffix_script_dumper)
-add_subdirectory(ffix_sound_dumper)
-add_subdirectory(ffvii_battle_model_exporter)
-add_subdirectory(ffvii_battle_scene_dumper)
-add_subdirectory(ffvii_field_dat_dumper)
-add_subdirectory(ffvii_field_model_exporter)
-add_subdirectory(ffvii_field_model_exporter_pc)
-add_subdirectory(ffvii_font_exporter)
-add_subdirectory(ffvii_sound_dumper)
-add_subdirectory(ffvii_sound_dumper_psf)
 add_subdirectory(flevel)
 add_subdirectory(lzs)
 add_subdirectory(v-gears-launcher)
-add_subdirectory(xeno_cd_extract)
-add_subdirectory(xeno_model_exporter)
-add_subdirectory(xeno_script_dumper)
-add_subdirectory(xeno_sound_dumper)
-add_subdirectory(xeno_walkmesh_exporter)
+

+ 0 - 49
utilities/ffix_model_exporter/CMakeLists.txt

@@ -1,49 +0,0 @@
-include_directories(
-    ${CMAKE_CURRENT_SOURCE_DIR}/src
-)
-
-# define header and source files
-set(HEADER_FILES
-./src/MeshExtractor.h
-./src/ModelFile.h
-./src/MeshExtractor.cpp
-./src/AnimationExtractor.h
-)
-set(SOURCE_FILES
-./src/ModelFile.cpp
-./src/AnimationExtractor.cpp
-./src/MeshExtractor.cpp
-./src/Main.cpp
-)
-
-add_definitions(
-    -DQGEARS_ADD_MANAGERS
-)
-
-add_executable(ff9_model_exporter
-  ${HEADER_FILES}
-  ${SOURCE_FILES}
-)
-SET_PROPERTY(TARGET ff9_model_exporter PROPERTY FOLDER "utilities")
-
-if (APPLE)
-target_link_libraries(ff9_model_exporter "-framework CoreFoundation -framework Cocoa -framework IOKit")
-endif()
-
-if(WIN32)
-  set_target_properties(ff9_model_exporter PROPERTIES WIN32_EXECUTABLE ON)
-  if (MSVC)
-    set_target_properties(ff9_model_exporter PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
-  endif()
-endif()
-
-set(LIBRARIES
-    Utility
-    QGearsMain
-    v-gears-data
-)
-target_link_libraries(ff9_model_exporter    ${LIBRARIES})
-
-install(TARGETS ff9_model_exporter
-    DESTINATION tools/ff9
-)

+ 0 - 240
utilities/ffix_model_exporter/src/AnimationExtractor.cpp

@@ -1,240 +0,0 @@
-#include "AnimationExtractor.h"
-
-#include "../../common/Logger.h"
-
-
-
-void
-AnimationExtractor( const Ogre::SkeletonPtr& skeleton, const ModelInfo& info, Skeleton& skeleton_data )
-{
-    if( info.animations.size() != info.animations_name.size() )
-    {
-        LOGGER->Log( "AnimationExtractor ERROR: number of animations dont match number of animation names.\n" );
-        return;
-    }
-
-    float fps = 25.0f;
-
-    for( size_t i = 0; i < info.animations.size(); ++i )
-    {
-        if( info.animations[ i ] == "" || info.animations_name[ i ] == "" )
-        {
-            continue;
-        }
-        File* file = new File( "./data/field/" + info.animations[ i ] );
-
-        LOGGER->Log( "AnimationExtractor: " + Ogre::StringConverter::toString( i ) + " " + info.animations[ i ] + " as animation with name " + info.animations_name[ i ] + "\n" );
-
-        int number_of_frames = file->GetU16LE( 0x2 );
-        Ogre::Animation* anim = skeleton->createAnimation( info.animations_name[ i ], ( number_of_frames - 1 ) / fps );
-
-        float time = 0;
-        float tx, ty, tz;
-        u32 raw_rx, raw_ry, raw_rz;
-        float rx, ry, rz;
-        Ogre::Bone* bone1;
-        Ogre::Bone* bone2;
-        Ogre::NodeAnimationTrack* track1;
-        Ogre::NodeAnimationTrack* track2;
-        Ogre::TransformKeyFrame* frame1;
-        Ogre::TransformKeyFrame* frame2;
-        Ogre::Quaternion rot;
-        Ogre::Matrix3 mat;
-
-        for ( int frame = 0; frame < number_of_frames; ++frame )
-        {
-            // this is just to orientate model to right direction
-            if( frame == 0 )
-            {
-                bone1 = skeleton->getBone( 0 );
-                track1 = anim->createNodeTrack( 0, bone1 );
-                track1->removeAllKeyFrames();
-                frame1 = track1->createNodeKeyFrame( time );
-                mat.FromEulerAnglesYXZ( Ogre::Radian( Ogre::Degree( 0 ) ), Ogre::Radian( Ogre::Degree( -90 ) ), Ogre::Radian( Ogre::Degree( 0 ) ) );
-                rot.FromRotationMatrix( mat );
-                frame1->setRotation( rot );
-                bone2 = skeleton->getBone( 1 );
-                track2 = anim->createNodeTrack( 1, bone2 );
-                track2->removeAllKeyFrames();
-            }
-            else
-            {
-                bone1 = skeleton->getBone( 0 );
-                track1 = anim->getNodeTrack( 0 );
-                frame1 = track1->createNodeKeyFrame( time );
-                mat.FromEulerAnglesYXZ( Ogre::Radian( Ogre::Degree( 0 ) ), Ogre::Radian(Ogre::Degree( -90 ) ), Ogre::Radian( Ogre::Degree( 0 ) ) );
-                rot.FromRotationMatrix( mat );
-                frame1->setRotation( rot );
-                bone2 = skeleton->getBone( 1 );
-                track2 = anim->getNodeTrack( 1 );
-            }
-            frame2 = track2->createNodeKeyFrame( time );
-
-
-
-            u32 high_angle_offset = file->GetU32LE( 0xc );
-            u32 low_angle_offset = file->GetU32LE( 0x10 );
-
-            for( size_t bone = 0; bone < skeleton_data.size(); ++bone )
-            {
-                tx = 0; ty = 0; tz = 0;
-                rx = 0; ry = 0; rz = 0;
-                raw_rx = 0; raw_ry = 0; raw_rz = 0;
-
-                if( bone == 0 )
-                {
-                    // create root translation
-                    u16 flags = file->GetU16LE( 0xa );
-                    if( flags & 1 )
-                    {
-                        tx = ( s16 )file->GetU16LE( 0x4 );
-                    }
-                    else
-                    {
-                        u16 offset = file->GetU16LE( 0x4 );
-                        tx = ( s16 )file->GetU16LE( offset + frame * 2 );
-                    }
-                    if( flags & 2 )
-                    {
-                        ty = ( s16 )file->GetU16LE( 0x6 );
-                    }
-                    else
-                    {
-                        u16 offset = file->GetU16LE( 0x6 );
-                        ty = ( s16 )file->GetU16LE( offset + frame * 2 );
-                    }
-                    if( flags & 4 )
-                    {
-                        tz = ( s16 )file->GetU16LE( 0x8 );
-                    }
-                    else
-                    {
-                        u16 offset = file->GetU16LE( 0x8 );
-                        tz = ( s16 )file->GetU16LE( offset + frame * 2 );
-                    }
-                }
-
-
-
-                u16 flags = file->GetU16LE( high_angle_offset + 0x6 );
-
-                u16 data = file->GetU16LE( high_angle_offset + 0x0 );
-                //LOGGER->Log( "AnimationExtractor: data_x = 0x" + ToHexString( data, 4, '0' ) + ".\n" );
-                if( ( flags & 1 ) == 0 )
-                {
-                    data = file->GetU8( data + frame );
-                    //LOGGER->Log( "AnimationExtractor: flagged data_x = 0x" + ToHexString( data, 4, '0' ) + ".\n" );
-                }
-                raw_rx = ( data & 0xff ) << 4;
-
-                data = file->GetU16LE( high_angle_offset + 0x2 );
-                //LOGGER->Log( "AnimationExtractor: data_y = 0x" + ToHexString( data, 4, '0' ) + ".\n" );
-                if( ( flags & 2 ) == 0 )
-                {
-                    data = file->GetU8( data + frame );
-                    //LOGGER->Log( "AnimationExtractor: flagged data_y = 0x" + ToHexString( data, 4, '0' ) + ".\n" );
-                }
-                raw_ry = ( data & 0xff ) << 4;
-
-                data = file->GetU16LE( high_angle_offset + 0x4 );
-                //LOGGER->Log( "AnimationExtractor: data_z = 0x" + ToHexString( data, 4, '0' ) + ".\n" );
-                if( ( flags & 4 ) == 0 )
-                {
-                    data = file->GetU8( data + frame );
-                    //LOGGER->Log( "AnimationExtractor: flagged data_z = 0x" + ToHexString( data, 4, '0' ) + ".\n" );
-                }
-                raw_rz = ( data & 0xff ) << 4;
-
-                //LOGGER->Log( "AnimationExtractor: GET ROTATION frame = " + Ogre::StringConverter::toString( frame ) + ", bone = " + Ogre::StringConverter::toString( bone ) + ", flags = 0x" + ToHexString( flags, 4, '0' ) + ", high_rx = 0x" + ToHexString( raw_rx, 4, '0' ) + ", high_ry = 0x" + ToHexString( raw_ry, 4, '0' ) + ", high_rz = 0x" + ToHexString( raw_rz, 4, '0' ) + ".\n" );
-
-                // if there is low range angles
-                if( low_angle_offset != 0 )
-                {
-                    flags = file->GetU16LE( low_angle_offset + 0x6 );
-
-                    u16 data = file->GetU16LE( low_angle_offset + 0x0 );
-                    if( ( flags & 1 ) == 0 )
-                    {
-                        data = file->GetU8( data + frame / 2 );
-                        if( frame & 1 )
-                        {
-                            data >>= 4;
-                        }
-                    }
-                    raw_rx |= data & 0xf;
-
-                    data = file->GetU16LE( low_angle_offset + 0x2 );
-                    if( ( flags & 2 ) == 0 )
-                    {
-                        data = file->GetU8( data + frame / 2 );
-                        if( frame & 1 )
-                        {
-                            data >>= 4;
-                        }
-                    }
-                    raw_ry |= data & 0xf;
-
-                    data = file->GetU16LE( low_angle_offset + 0x4 );
-                    if( ( flags & 4 ) == 0 )
-                    {
-                        data = file->GetU8( data + frame / 2 );
-                        if( frame & 1 )
-                        {
-                            data >>= 4;
-                        }
-                    }
-                    raw_rz |= data & 0xf;
-
-                    //LOGGER->Log( "AnimationExtractor: GET ROTATION frame = " + Ogre::StringConverter::toString( frame ) + ", bone = " + Ogre::StringConverter::toString( bone ) + ", low_flags = 0x" + ToHexString( flags, 4, '0' ) + ", total_rx = 0x" + ToHexString( raw_rx, 4, '0' ) + ", total_ry = 0x" + ToHexString( raw_ry, 4, '0' ) + ", total_rz = 0x" + ToHexString( raw_rz, 4, '0' ) + ".\n" );
-
-                    low_angle_offset += 8;
-                }
-
-                high_angle_offset += 8;
-
-
-
-                rx = ( raw_rx / 4096.0f ) * 360.0f;
-                ry = ( raw_ry / 4096.0f ) * 360.0f;
-                rz = ( raw_rz / 4096.0f ) * 360.0f;
-
-
-
-                // assign data to bone
-                bone1 = skeleton->getBone( bone * 2 + 2 );
-                bone2 = skeleton->getBone( bone * 2 + 3 );
-                if( frame == 0 )
-                {
-                    track1 = anim->createNodeTrack( bone * 2 + 2, bone1 );
-                    track1->removeAllKeyFrames();
-                    track2 = anim->createNodeTrack( bone * 2 + 3, bone2 );
-                    track2->removeAllKeyFrames();
-
-                }
-                else
-                {
-                    track1 = anim->getNodeTrack( bone * 2 + 2 );
-                    track2 = anim->getNodeTrack( bone * 2 + 3 );
-                }
-                frame1 = track1->createNodeKeyFrame( time );
-                frame2 = track2->createNodeKeyFrame( time );
-                Ogre::Vector3 translate = Ogre::Vector3( tx, ty, tz + skeleton_data[ bone ].length ) / 512.0f;
-                //LOGGER->Log( "AnimationExtractor: frame = " + Ogre::StringConverter::toString( frame ) + ", bone = " + Ogre::StringConverter::toString( bone ) + ", translation = " + Ogre::StringConverter::toString( translate ) + ".\n" );
-                frame1->setTranslate( translate );
-                //mat.FromEulerAnglesXYZ( Ogre::Radian( Ogre::Degree( rx ) ), Ogre::Radian( Ogre::Degree( ry ) ), Ogre::Radian( Ogre::Degree( rz ) ) );
-                //mat.FromEulerAnglesXZY( Ogre::Radian( Ogre::Degree( rx ) ), Ogre::Radian( Ogre::Degree( rz ) ), Ogre::Radian( Ogre::Degree( ry ) ) );
-                //mat.FromEulerAnglesYZX( Ogre::Radian( Ogre::Degree( ry ) ), Ogre::Radian( Ogre::Degree( rz ) ), Ogre::Radian( Ogre::Degree( rx ) ) );
-                //mat.FromEulerAnglesYXZ( Ogre::Radian( Ogre::Degree( ry ) ), Ogre::Radian( Ogre::Degree( rx ) ), Ogre::Radian( Ogre::Degree( rz ) ) );
-                mat.FromEulerAnglesZYX( Ogre::Radian( Ogre::Degree( rz ) ), Ogre::Radian( Ogre::Degree( ry ) ), Ogre::Radian( Ogre::Degree( rx ) ) );
-                //mat.FromEulerAnglesZXY( Ogre::Radian( Ogre::Degree( rz ) ), Ogre::Radian( Ogre::Degree( rx ) ), Ogre::Radian( Ogre::Degree( ry ) ) );
-                //LOGGER->Log( "AnimationExtractor: frame = " + Ogre::StringConverter::toString( frame ) + ", bone = " + Ogre::StringConverter::toString( bone ) + ", rotation = " + Ogre::StringConverter::toString( rx ) + " " + Ogre::StringConverter::toString( ry ) + " " + Ogre::StringConverter::toString( rz ) + ".\n" );
-                rot.FromRotationMatrix( mat );
-                frame2->setRotation( rot );
-            }
-
-            time += 1.0f / fps;
-        }
-
-        delete file;
-    }
-}

+ 0 - 15
utilities/ffix_model_exporter/src/AnimationExtractor.h

@@ -1,15 +0,0 @@
-#ifndef ANIMATION_EXTRACTOR_H
-#define ANIMATION_EXTRACTOR_H
-
-#include <Ogre.h>
-
-#include "ModelFile.h"
-#include "common/File.h"
-
-
-
-void AnimationExtractor( const Ogre::SkeletonPtr& skeleton, const ModelInfo& info, Skeleton& skeleton_data );
-
-
-
-#endif // ANIMATION_EXTRACTOR_H

+ 0 - 146
utilities/ffix_model_exporter/src/Main.cpp

@@ -1,146 +0,0 @@
-#include <Ogre.h>
-#include "../../common/OgreBase.h"
-#include "../../common/Logger.h"
-#include "ModelFile.h"
-
-
-
-std::vector< ModelInfo > models;
-
-
-
-void
-fill_names()
-{
-/*
-    Unit unit;
-    unit.name = "";
-    Field field;
-
-
-    Ogre::ConfigFile cf;
-    cf.load("export.cfg");
-    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
-
-    while( seci.hasMoreElements() )
-    {
-        field.name = seci.peekNextKey();
-        Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
-
-        if( field.name != "" )
-        {
-
-            Ogre::ConfigFile::SettingsMultiMap::iterator i;
-            for (i = settings->begin(); i != settings->end(); ++i)
-            {
-                if (i->second != "")
-                {
-                    Ogre::StringVector export_data = Ogre::StringUtil::split(i->second, ":", 1);
-
-                    unit.name = export_data[0];
-
-                    Ogre::StringVector animations = Ogre::StringUtil::split(export_data[1], ",", 0);
-                    //LOGGER->Log(LOGGER_INFO, "Export %s: %s", field.name.c_str(), unit.name.c_str());
-                    for (int i = 0; i < animations.size(); ++i)
-                    {
-                        unit.animations.push_back(animations[i]);
-                    }
-                }
-
-                field.units.push_back(unit);
-                unit.name = "";
-                unit.animations.clear();
-            }
-
-            //LOGGER->Log(LOGGER_INFO, "Add export field %s", field.name.c_str());
-            fields.push_back(field);
-            field.units.clear();
-        }
-    }
-*/
-
-    MeshData data;
-    data.name = "zidane";
-    data.tex_width = 512;
-    data.tex_height = 256;
-    ModelInfo model;
-    model.data = data;
-    model.animations.push_back( "5/1b/1/3/1.animation" ); model.animations_name.push_back( "Walk" );
-    model.animations.push_back( "5/1b/1/3/2.animation" ); model.animations_name.push_back( "Run" );
-    model.animations.push_back( "5/1b/1/3/3.animation" ); model.animations_name.push_back( "TurnLeft" );
-    model.animations.push_back( "5/1b/1/3/4.animation" ); model.animations_name.push_back( "TurnRight" );
-    model.animations.push_back( "5/1b/1/3/5.animation" ); model.animations_name.push_back( "Idle" );
-    model.animations.push_back( "15.animation" ); model.animations_name.push_back( "Carry" );
-    models.push_back( model );
-}
-
-
-
-int
-main( int argc, char* argv[] )
-{
-    InitializeOgreBase( "FFIX Exporter" );
-
-    fill_names();
-
-
-
-/*
-    for( int f = 0; f < fields.size(); ++f )
-    {
-        BsxFile model( "data/field/" + fields[f].name + ".bsx" );
-        DatFile dat( "data/field/" + fields[f].name + ".dat" );
-
-        for (int i = 0; i < fields[f].units.size(); ++i)
-        {
-            if (fields[f].units[i].name != "")
-            {
-                Ogre::Entity* entity = NULL;
-                for (int j = 0; j < entities.size(); ++j)
-                {
-                    if (fields[f].units[i].name == entities[j]->getName())
-                    {
-                        entity = entities[j];
-                    }
-                }
-
-                DatModelData data;
-                dat.GetModelData(i, data);
-
-                Ogre::Entity* exported_entity = model.GetModel(entity, i, fields[f].units[i], data);
-
-                if (exported_entity != NULL)
-                {
-                    entities.push_back(exported_entity);
-                }
-            }
-        }
-    }
-
-    entities[ 0 ]->setVisible(true);
-*/
-
-
-
-    // TEMP
-
-    ModelFile model( "./data/field/5/1b/1/2/1.model" ); // zidane
-    Ogre::Entity* exported_entity = model.GetModel( models[ 0 ] );
-    if( exported_entity != NULL )
-    {
-        entities.push_back( exported_entity );
-        entities[ 0 ]->setVisible( true );
-    }
-
-
-
-    Ogre::Root::getSingleton().startRendering();
-
-
-
-    DeinitializeOgreBase();
-
-
-
-    return 0;
-}

+ 0 - 355
utilities/ffix_model_exporter/src/MeshExtractor.cpp

@@ -1,355 +0,0 @@
-#include "MeshExtractor.h"
-
-#define POSITION_BINDING 0
-#define COLOUR_BINDING 1
-#define TEXTURE_BINDING 2
-
-#include "../../common/Logger.h"
-#include "../../common/OgreGenUtilites.h"
-
-
-
-void
-MeshExtractor( const MeshData& mesh_data, const Ogre::String& material_name, File* file, int offset_to_data, VectorTexForGen& textures, const Ogre::MeshPtr& mesh )
-{
-    File* file12 = new File( "./data/field/5/1b/1/12/1" );
-    u32 offset_to_clut_tex = 4 + file12->GetU32LE( 4 + 4 ) & 0x00ffffff;
-    LOGGER->Log( "offset_to_clut_tex = \"" + HexToString( offset_to_clut_tex, 8, '0' ) + "\".\n" );
-    u32 offset_to_tx_ty = offset_to_clut_tex + file12->GetU8( 4 + 7 ) * 4;
-    LOGGER->Log( "offset_to_tx_ty = \"" + HexToString( offset_to_tx_ty, 8, '0' ) + "\".\n" );
-
-
-
-    int number_of_monochrome_textured_quads = file->GetU16LE( offset_to_data + 0x02 );
-    int number_of_monochrome_textured_triangles = file->GetU16LE( offset_to_data + 0x04 );
-    int number_of_shaded_textured_quads = file->GetU16LE( offset_to_data + 0x06 );
-    int number_of_shaded_textured_triangles = file->GetU16LE( offset_to_data + 0x08 );
-    int number_of_gradated_quads = file->GetU16LE( offset_to_data + 0x0a );
-    int number_of_gradated_triangles = file->GetU16LE( offset_to_data + 0x0c );
-    int number_of_monochrome_quads = file->GetU16LE( offset_to_data + 0x0e );
-    int number_of_monochrome_triangles = file->GetU16LE( offset_to_data + 0x10 );
-
-    u32 pointer_to_vertex_groups = file->GetU32LE( offset_to_data + 0x14 );
-    u32 pointer_to_vertex_data = file->GetU32LE( offset_to_data + 0x18 );
-    u32 pointer_to_mesh_data = file->GetU32LE( offset_to_data + 0x1c );
-    u32 pointer_to_texture_data = file->GetU32LE( offset_to_data + 0x20 );
-
-
-
-    Ogre::SubMesh* sub_mesh = mesh->createSubMesh(/* name */);
-    sub_mesh->setMaterialName( material_name );
-    sub_mesh->useSharedVertices = false;
-    sub_mesh->operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
-
-    // Allocate and prepare vertex data
-    sub_mesh->vertexData = new Ogre::VertexData();
-    sub_mesh->vertexData->vertexStart = 0;
-    sub_mesh->vertexData->vertexCount = static_cast< size_t >(
-        number_of_monochrome_textured_quads * 6 +
-        number_of_monochrome_textured_triangles * 3/* +
-        number_of_shaded_textured_quads * 6 +
-        number_of_shaded_textured_triangles * 3 +
-        number_of_gradated_quads * 6 +
-        number_of_gradated_triangles * 3 +
-        number_of_monochrome_quads * 6 +
-        number_of_monochrome_triangles * 3*/ );
-
-    sub_mesh->indexData = new Ogre::IndexData();
-    sub_mesh->indexData->indexStart = 0;
-    sub_mesh->indexData->indexCount = sub_mesh->vertexData->vertexCount;
-    sub_mesh->indexData->indexBuffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(
-        Ogre::HardwareIndexBuffer::IT_16BIT,
-        sub_mesh->indexData->indexCount,
-        Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
-    u16* idata = static_cast< u16* >( sub_mesh->indexData->indexBuffer->lock( Ogre::HardwareBuffer::HBL_DISCARD ) );
-    u32 cur_index = 0;
-
-    Ogre::VertexDeclaration* decl = sub_mesh->vertexData->vertexDeclaration;
-    Ogre::VertexBufferBinding* bind = sub_mesh->vertexData->vertexBufferBinding;
-    // 1st buffer
-    decl->addElement( POSITION_BINDING, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
-    Ogre::HardwareVertexBufferSharedPtr vbuf0 = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
-        decl->getVertexSize( POSITION_BINDING ),
-        sub_mesh->vertexData->vertexCount,
-        Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
-    bind->setBinding( POSITION_BINDING, vbuf0 );
-
-    // 2nd buffer
-    decl->addElement( COLOUR_BINDING, 0, Ogre::VET_COLOUR, Ogre::VES_DIFFUSE );
-    Ogre::HardwareVertexBufferSharedPtr vbuf1 = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
-        decl->getVertexSize( COLOUR_BINDING ),
-        sub_mesh->vertexData->vertexCount,
-        Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
-    // Set vertex buffer binding so buffer 1 is bound to our colour buffer
-    bind->setBinding( COLOUR_BINDING, vbuf1 );
-
-    // 3rd buffer
-    decl->addElement( TEXTURE_BINDING, 0, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0 );
-    Ogre::HardwareVertexBufferSharedPtr vbuf2 = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
-        decl->getVertexSize( TEXTURE_BINDING ),
-        sub_mesh->vertexData->vertexCount,
-        Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
-    bind->setBinding( TEXTURE_BINDING, vbuf2 );
-
-    float* pPos   = static_cast< float* >( vbuf0->lock( Ogre::HardwareBuffer::HBL_DISCARD ) );
-    float* tPos   = static_cast< float* >( vbuf2->lock( Ogre::HardwareBuffer::HBL_DISCARD ) );
-
-    Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
-    
-    std::vector<Ogre::RGBA> coloursVec(sub_mesh->vertexData->vertexCount);
-
-    Ogre::RGBA* colours = coloursVec.data();
-
-
-
-    for( int i = 0; i < number_of_monochrome_textured_quads; ++i )
-    {
-        int index_a = file->GetU16LE( pointer_to_mesh_data + 0x0 );
-        int index_b = file->GetU16LE( pointer_to_mesh_data + 0x2 );
-        int index_c = file->GetU16LE( pointer_to_mesh_data + 0x4 );
-        int index_d = file->GetU16LE( pointer_to_mesh_data + 0x6 );
-
-        Ogre::Vector3 a( ( s16 )file->GetU16LE( pointer_to_vertex_data + index_a * 0x8 + 0x0 ),
-                         ( s16 )file->GetU16LE( pointer_to_vertex_data + index_a * 0x8 + 0x2 ),
-                         ( s16 )file->GetU16LE( pointer_to_vertex_data + index_a * 0x8 + 0x4 ) );
-        Ogre::Vector3 b( ( s16 )file->GetU16LE( pointer_to_vertex_data + index_b * 0x8 + 0x0 ),
-                         ( s16 )file->GetU16LE( pointer_to_vertex_data + index_b * 0x8 + 0x2 ),
-                         ( s16 )file->GetU16LE( pointer_to_vertex_data + index_b * 0x8 + 0x4 ) );
-        Ogre::Vector3 c( ( s16 )file->GetU16LE( pointer_to_vertex_data + index_c * 0x8 + 0x0 ),
-                         ( s16 )file->GetU16LE( pointer_to_vertex_data + index_c * 0x8 + 0x2 ),
-                         ( s16 )file->GetU16LE( pointer_to_vertex_data + index_c * 0x8 + 0x4 ) );
-        Ogre::Vector3 d( ( s16 )file->GetU16LE( pointer_to_vertex_data + index_d * 0x8 + 0x0 ),
-                         ( s16 )file->GetU16LE( pointer_to_vertex_data + index_d * 0x8 + 0x2 ),
-                         ( s16 )file->GetU16LE( pointer_to_vertex_data + index_d * 0x8 + 0x4 ) );
-        a /= 512;
-        b /= 512;
-        c /= 512;
-        d /= 512;
-
-
-
-
-        int image_id = file->GetU8( pointer_to_mesh_data + 0x13 );
-        u16 blend = file12->GetU16LE( offset_to_clut_tex + image_id * 4 + 0 );
-        u16 clut = file12->GetU16LE( offset_to_clut_tex + image_id * 4 + 2 );
-        LOGGER->Log( "image_id = \"" + HexToString( image_id, 2, '0' ) + "\", clut = \"" + HexToString( clut, 4, '0' ) + "\", blend = \"" + HexToString( blend, 4, '0' ) + "\".\n" );
-/*
-        int clut_x = (clut & 0x003f) << 3;
-        int clut_y = (clut & 0xffc0) >> 6;
-        int bpp    = (tpage >> 0x7) & 0x3;
-        int vram_x = (tpage & 0xf) * 64;
-        int vram_y = ((tpage & 0x10) >> 4) * 256;
-*/
-        TexForGen texture;
-        texture.palette_x = 128/*clut_x*/;
-        texture.palette_y = 224/*clut_y*/;
-        if( image_id == 1 )
-        {
-            texture.texture_x = 768/*vram_x*/;
-        }
-        else
-        {
-            texture.texture_x = 832/*vram_x*/;
-        }
-        texture.texture_y = 256/*vram_y*/;
-        texture.bpp = BPP_8/*bpp*/;
-        AddTexture( texture, mesh_data, textures, LOGGER );
-
-        Ogre::Vector2 at( 0, 0 );
-        Ogre::Vector2 bt( 0, 0 );
-        Ogre::Vector2 ct( 0, 0 );
-        Ogre::Vector2 dt( 0, 0 );
-
-        u16 vertex1_uv = file->GetU16LE( pointer_to_mesh_data + 0x8 );
-        at.x = ( file->GetU8( pointer_to_texture_data + vertex1_uv * 2 + 0x0 ) + texture.start_x ) / ( float )mesh_data.tex_width;
-        at.y = ( file->GetU8( pointer_to_texture_data + vertex1_uv * 2 + 0x1 ) + texture.start_y ) / ( float )mesh_data.tex_height;
-
-        u16 vertex2_uv = file->GetU16LE( pointer_to_mesh_data + 0xa );
-        bt.x = ( file->GetU8( pointer_to_texture_data + vertex2_uv * 2 + 0x0 ) + texture.start_x ) / ( float )mesh_data.tex_width;
-        bt.y = ( file->GetU8( pointer_to_texture_data + vertex2_uv * 2 + 0x1 ) + texture.start_y ) / ( float )mesh_data.tex_height;
-
-        u16 vertex3_uv = file->GetU16LE( pointer_to_mesh_data + 0xc );
-        ct.x = ( file->GetU8( pointer_to_texture_data + vertex3_uv * 2 + 0x0 ) + texture.start_x ) / ( float )mesh_data.tex_width;
-        ct.y = ( file->GetU8( pointer_to_texture_data + vertex3_uv * 2 + 0x1 ) + texture.start_y ) / ( float )mesh_data.tex_height;
-
-        u16 vertex4_uv = file->GetU16LE( pointer_to_mesh_data + 0xe );
-        dt.x = ( file->GetU8( pointer_to_texture_data + vertex4_uv * 2 + 0x0 ) + texture.start_x ) / ( float )mesh_data.tex_width;
-        dt.y = ( file->GetU8( pointer_to_texture_data + vertex4_uv * 2 + 0x1 ) + texture.start_y ) / ( float )mesh_data.tex_height;
-
-        *pPos++ = a.x; *pPos++ = a.y; *pPos++ = a.z;
-        *pPos++ = c.x; *pPos++ = c.y; *pPos++ = c.z;
-        *pPos++ = b.x; *pPos++ = b.y; *pPos++ = b.z;
-        *pPos++ = b.x; *pPos++ = b.y; *pPos++ = b.z;
-        *pPos++ = c.x; *pPos++ = c.y; *pPos++ = c.z;
-        *pPos++ = d.x; *pPos++ = d.y; *pPos++ = d.z;
-
-        *tPos++ = at.x; *tPos++ = at.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-        *tPos++ = dt.x; *tPos++ = dt.y;
-
-        Ogre::ColourValue colour = Ogre::ColourValue( file->GetU8( pointer_to_mesh_data + 0x10 ) / 256.0f,
-                                                      file->GetU8( pointer_to_mesh_data + 0x11 ) / 256.0f,
-                                                      file->GetU8( pointer_to_mesh_data + 0x12 ) / 256.0f,
-                                                      1.0f );
-
-        rs->convertColourValue( colour, colours + cur_index + 0 );
-        rs->convertColourValue( colour, colours + cur_index + 1 );
-        rs->convertColourValue( colour, colours + cur_index + 2 );
-        rs->convertColourValue( colour, colours + cur_index + 3 );
-        rs->convertColourValue( colour, colours + cur_index + 4 );
-        rs->convertColourValue( colour, colours + cur_index + 5 );
-
-        idata[ cur_index + 0 ] = cur_index + 0;
-        idata[ cur_index + 1 ] = cur_index + 1;
-        idata[ cur_index + 2 ] = cur_index + 2;
-        idata[ cur_index + 3 ] = cur_index + 3;
-        idata[ cur_index + 4 ] = cur_index + 4;
-        idata[ cur_index + 5 ] = cur_index + 5;
-
-        Ogre::VertexBoneAssignment vba;
-        vba.weight = 1.0f;
-
-        vba.vertexIndex = cur_index + 0;
-        vba.boneIndex = file->GetU8( pointer_to_vertex_data + index_a * 0x8 + 0x6 ) * 2 + 3;
-        sub_mesh->addBoneAssignment( vba );
-        vba.vertexIndex = cur_index + 1;
-        vba.boneIndex = file->GetU8( pointer_to_vertex_data + index_c * 0x8 + 0x6 ) * 2 + 3;
-        sub_mesh->addBoneAssignment( vba );
-        vba.vertexIndex = cur_index + 2;
-        vba.boneIndex = file->GetU8( pointer_to_vertex_data + index_b * 0x8 + 0x6 ) * 2 + 3;
-        sub_mesh->addBoneAssignment( vba );
-        vba.vertexIndex = cur_index + 3;
-        vba.boneIndex = file->GetU8( pointer_to_vertex_data + index_b * 0x8 + 0x6 ) * 2 + 3;
-        sub_mesh->addBoneAssignment( vba );
-        vba.vertexIndex = cur_index + 4;
-        vba.boneIndex = file->GetU8( pointer_to_vertex_data + index_c * 0x8 + 0x6 ) * 2 + 3;
-        sub_mesh->addBoneAssignment( vba );
-        vba.vertexIndex = cur_index + 5;
-        vba.boneIndex = file->GetU8( pointer_to_vertex_data + index_d * 0x8 + 0x6 ) * 2 + 3;
-        sub_mesh->addBoneAssignment( vba );
-
-
-
-        cur_index += 6;
-        pointer_to_mesh_data += 0x18;
-    }
-
-
-
-    for( int i = 0; i < number_of_monochrome_textured_triangles; ++i )
-    {
-        int index_a = file->GetU16LE( pointer_to_mesh_data + 0x0 );
-        int index_b = file->GetU16LE( pointer_to_mesh_data + 0x2 );
-        int index_c = file->GetU16LE( pointer_to_mesh_data + 0x4 );
-
-        Ogre::Vector3 a( ( s16 )file->GetU16LE( pointer_to_vertex_data + index_a * 0x8 + 0x0 ),
-                         ( s16 )file->GetU16LE( pointer_to_vertex_data + index_a * 0x8 + 0x2 ),
-                         ( s16 )file->GetU16LE( pointer_to_vertex_data + index_a * 0x8 + 0x4 ) );
-        Ogre::Vector3 b( ( s16 )file->GetU16LE( pointer_to_vertex_data + index_b * 0x8 + 0x0 ),
-                         ( s16 )file->GetU16LE( pointer_to_vertex_data + index_b * 0x8 + 0x2 ),
-                         ( s16 )file->GetU16LE( pointer_to_vertex_data + index_b * 0x8 + 0x4 ) );
-        Ogre::Vector3 c( ( s16 )file->GetU16LE( pointer_to_vertex_data + index_c * 0x8 + 0x0 ),
-                         ( s16 )file->GetU16LE( pointer_to_vertex_data + index_c * 0x8 + 0x2 ),
-                         ( s16 )file->GetU16LE( pointer_to_vertex_data + index_c * 0x8 + 0x4 ) );
-        a /= 512;
-        b /= 512;
-        c /= 512;
-
-        int image_id = file->GetU8( pointer_to_mesh_data + 0x6 );
-        u16 blend = file12->GetU16LE( offset_to_clut_tex + image_id * 4 + 0 );
-        u16 clut = file12->GetU16LE( offset_to_clut_tex + image_id * 4 + 2 );
-        LOGGER->Log( "image_id = \"" + HexToString( image_id, 2, '0' ) + "\", clut = \"" + HexToString( clut, 4, '0' ) + "\", blend = \"" + HexToString( blend, 4, '0' ) + "\".\n" );
-/*
-        int clut_x = (clut & 0x003f) << 3;
-        int clut_y = (clut & 0xffc0) >> 6;
-        int bpp    = (tpage >> 0x7) & 0x3;
-        int vram_x = (tpage & 0xf) * 64;
-        int vram_y = ((tpage & 0x10) >> 4) * 256;
-*/
-
-        TexForGen texture;
-        texture.palette_x = 128/*clut_x*/;
-        texture.palette_y = 224/*clut_y*/;
-        if( image_id == 1 )
-        {
-            texture.texture_x = 768/*vram_x*/;
-        }
-        else
-        {
-            texture.texture_x = 832/*vram_x*/;
-        }
-        texture.texture_y = 256/*vram_y*/;
-        texture.bpp = BPP_8/*bpp*/;
-        AddTexture( texture, mesh_data, textures, LOGGER );
-
-        Ogre::Vector2 at( 0, 0 );
-        Ogre::Vector2 bt( 0, 0 );
-        Ogre::Vector2 ct( 0, 0 );
-
-        u16 vertex1_uv = file->GetU16LE( pointer_to_mesh_data + 0xc );
-        at.x = ( file->GetU8( pointer_to_texture_data + vertex1_uv * 2 + 0x0 ) + texture.start_x ) / ( float )mesh_data.tex_width;
-        at.y = ( file->GetU8( pointer_to_texture_data + vertex1_uv * 2 + 0x1 ) + texture.start_y ) / ( float )mesh_data.tex_height;
-
-        u16 vertex2_uv = file->GetU16LE( pointer_to_mesh_data + 0xe );
-        bt.x = ( file->GetU8( pointer_to_texture_data + vertex2_uv * 2 + 0x0 ) + texture.start_x ) / ( float )mesh_data.tex_width;
-        bt.y = ( file->GetU8( pointer_to_texture_data + vertex2_uv * 2 + 0x1 ) + texture.start_y ) / ( float )mesh_data.tex_height;
-
-        u16 vertex3_uv = file->GetU16LE( pointer_to_mesh_data + 0x10 );
-        ct.x = ( file->GetU8( pointer_to_texture_data + vertex3_uv * 2 + 0x0 ) + texture.start_x ) / ( float )mesh_data.tex_width;
-        ct.y = ( file->GetU8( pointer_to_texture_data + vertex3_uv * 2 + 0x1 ) + texture.start_y ) / ( float )mesh_data.tex_height;
-
-        *pPos++ = a.x; *pPos++ = a.y; *pPos++ = a.z;
-        *pPos++ = c.x; *pPos++ = c.y; *pPos++ = c.z;
-        *pPos++ = b.x; *pPos++ = b.y; *pPos++ = b.z;
-
-        *tPos++ = at.x; *tPos++ = at.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-
-        Ogre::ColourValue colour = Ogre::ColourValue( file->GetU8( pointer_to_mesh_data + 0x08 ) / 256.0f,
-                                                      file->GetU8( pointer_to_mesh_data + 0x09 ) / 256.0f,
-                                                      file->GetU8( pointer_to_mesh_data + 0x0a ) / 256.0f,
-                                                      1.0f );
-
-        rs->convertColourValue( colour, colours + cur_index + 0 );
-        rs->convertColourValue( colour, colours + cur_index + 1 );
-        rs->convertColourValue( colour, colours + cur_index + 2 );
-
-        idata[ cur_index + 0 ] = cur_index + 0;
-        idata[ cur_index + 1 ] = cur_index + 1;
-        idata[ cur_index + 2 ] = cur_index + 2;
-
-        Ogre::VertexBoneAssignment vba;
-        vba.weight = 1.0f;
-
-        vba.vertexIndex = cur_index + 0;
-        vba.boneIndex = file->GetU8( pointer_to_vertex_data + index_a * 0x8 + 0x6 ) * 2 + 3;
-        sub_mesh->addBoneAssignment( vba );
-        vba.vertexIndex = cur_index + 1;
-        vba.boneIndex = file->GetU8( pointer_to_vertex_data + index_c * 0x8 + 0x6 ) * 2 + 3;
-        sub_mesh->addBoneAssignment( vba );
-        vba.vertexIndex = cur_index + 2;
-        vba.boneIndex = file->GetU8( pointer_to_vertex_data + index_b * 0x8 + 0x6 ) * 2 + 3;
-        sub_mesh->addBoneAssignment( vba );
-
-        cur_index += 3;
-        pointer_to_mesh_data += 0x14;
-    }
-
-
-
-    vbuf0->unlock();
-    vbuf1->writeData( 0, vbuf1->getSizeInBytes(), colours, true );
-    vbuf2->unlock();
-
-    sub_mesh->indexData->indexBuffer->unlock();
-    // Optimize index data
-    sub_mesh->indexData->optimiseVertexCacheTriList();
-
-
-
-    delete file12;
-}

+ 0 - 15
utilities/ffix_model_exporter/src/MeshExtractor.h

@@ -1,15 +0,0 @@
-#ifndef MESH_EXTRACTOR_H
-#define MESH_EXTRACTOR_H
-
-#include <Ogre.h>
-
-#include "common/File.h"
-#include "../../common/OgreGenUtilites.h"
-
-
-
-void MeshExtractor( const MeshData& mesh_data, const Ogre::String& material_name, File* file, int offset_to_data, VectorTexForGen& textures, const Ogre::MeshPtr& mesh );
-
-
-
-#endif // MESH_EXTRACTOR_H

+ 0 - 164
utilities/ffix_model_exporter/src/ModelFile.cpp

@@ -1,164 +0,0 @@
-#include "ModelFile.h"
-
-#include <Ogre.h>
-
-#include "AnimationExtractor.h"
-#include "MeshExtractor.h"
-#include "../../common/Logger.h"
-#include "../../common/TimToVram.h"
-
-
-
-ModelFile::ModelFile( const Ogre::String& file ):
-    File( file )
-{
-}
-
-
-
-ModelFile::ModelFile( File* pFile ):
-    File( pFile )
-{
-}
-
-
-
-ModelFile::ModelFile( File* pFile, u32 offset, u32 length ):
-    File( pFile, offset, length )
-{
-}
-
-
-
-ModelFile::ModelFile( u8* pBuffer, u32 offset, u32 length ):
-    File( pBuffer, offset, length )
-{
-}
-
-
-
-ModelFile::~ModelFile()
-{
-}
-
-
-
-Ogre::Entity*
-ModelFile::GetModel( const ModelInfo& info )
-{
-    VectorTexForGen textures;
-    Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().create( info.data.name + "export", "General" );
-    Ogre::SkeletonPtr skeleton = Ogre::SkeletonManager::getSingleton().create( info.data.name + "export", "General" );
-
-    int number_of_bones = GetU8( 0x02 );
-    int number_of_parts = GetU8( 0x03 );
-    int offset_to_bones = GetU32LE( 0x0c );
-    int offset_to_parts = GetU32LE( 0x10 );
-
-
-
-    Ogre::Bone* root1 = skeleton->createBone( "0", 0 );
-    Ogre::Bone* root2 = skeleton->createBone( "1", 1 );
-    root1->addChild( root2 );
-
-    for( int i = 0; i < number_of_bones; ++i )
-    {
-        Bone bone;
-        bone.parent_id = ( i != 0 ) ? ( s8 )GetU8( offset_to_bones + i * 0x04 + 0x03 ) : -1;
-        bone.length    = ( s16 )GetU16LE( offset_to_bones + i * 0x04 + 0x00 );
-        m_Skeleton.push_back(bone);
-
-        Ogre::Bone* bone1 = skeleton->createBone( Ogre::StringConverter::toString( i * 2 + 2 ), i * 2 + 2 );
-        Ogre::Bone* bone2 = skeleton->createBone( Ogre::StringConverter::toString( i * 2 + 3 ), i * 2 + 3 );
-
-        LOGGER->Log( "Add skeleton bone: bone_id = " + Ogre::StringConverter::toString( i ) + ", length = " + Ogre::StringConverter::toString( bone.length ) + ", parent = " + Ogre::StringConverter::toString( bone.parent_id ) + ".\n" );
-
-        if( bone.parent_id == -1 )
-        {
-            skeleton->getBone( 1 )->addChild( bone1 );
-        }
-        else
-        {
-            skeleton->getBone( bone.parent_id * 2 + 3 )->addChild( bone1 );
-        }
-        bone1->addChild( bone2 );
-    }
-
-
-
-    AnimationExtractor( skeleton, info, m_Skeleton );
-
-
-
-    // draw skeleton
-    {
-        //DrawSkeleton( m_Skeleton, mesh );
-    }
-
-
-
-    for( int i = 0; i < number_of_parts; ++i )
-    {
-        MeshExtractor( info.data, "ffix/field_model/" + info.data.name, this, offset_to_parts + i * 0x28, textures, mesh );
-    }
-
-
-
-    // <OGRE> ///////////////////////////////
-    skeleton->optimiseAllAnimations();
-    Ogre::SkeletonSerializer skeleton_serializer;
-    skeleton_serializer.exportSkeleton( skeleton.getPointer(), "exported/models/field/units/" + info.data.name + ".skeleton" );
-
-    // Update bounds
-    Ogre::AxisAlignedBox aabb( -999, -999, -999, 999, 999, 999 );
-    mesh->_setBounds( aabb, false );
-    mesh->_setBoundingSphereRadius( 999 );
-
-    mesh->setSkeletonName( "models/field/units/" + info.data.name + ".skeleton" );
-
-    Ogre::MeshSerializer ser;
-    ser.exportMesh( mesh.getPointer(), "exported/models/field/units/" + info.data.name + ".mesh" );
-
-
-
-    // create and export textures for model
-    //if (textures.size() > 0)
-    {
-        Vram* vram = Vram::MakeInstance().release();
-
-        File* tex = new File( "./data/field/5/1b/2/4/1.tim" );
-        LoadTimFileToVram( tex, 0, vram );
-        delete tex;
-        tex = new File( "./data/field/5/1b/2/4/2.tim" );
-        LoadTimFileToVram( tex, 0, vram );
-        delete tex;
-
-        vram->Save( "1.jpg" );
-
-        CreateTexture( vram, info.data, "exported/models/field/units/" + info.data.name + ".png", textures );
-
-        delete vram;
-    }
-
-
-
-    CreateMaterial( "ffix/field_model/" + info.data.name, "exported/models/field/units/" + info.data.name + ".material", ( textures.size() > 0 ) ? "models/field/units/" + info.data.name + ".png" : "", "", "" );
-
-
-
-    Ogre::SceneManager* scene_manager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
-    Ogre::Entity* thisEntity = scene_manager->createEntity( info.data.name, "models/field/units/" + info.data.name + ".mesh" );
-    //thisEntity->setDisplaySkeleton(true);
-    //thisEntity->setDebugDisplayEnabled(true);
-    thisEntity->setVisible( false );
-    thisEntity->getAnimationState( info.animations_name[ 0 ] )->setEnabled(true);
-    thisEntity->getAnimationState( info.animations_name[ 0 ] )->setLoop(true);
-    Ogre::SceneNode* thisSceneNode = scene_manager->getRootSceneNode()->createChildSceneNode();
-    thisSceneNode->setPosition( 0, 0, 0 );
-    thisSceneNode->roll( Ogre::Radian( Ogre::Degree( 180.0f ) ) );
-    thisSceneNode->yaw( Ogre::Radian( Ogre::Degree( 120.0f ) ) );
-    thisSceneNode->pitch( Ogre::Radian( Ogre::Degree(90.0f ) ) );
-    thisSceneNode->attachObject( thisEntity );
-
-    return thisEntity;
-}

+ 0 - 36
utilities/ffix_model_exporter/src/ModelFile.h

@@ -1,36 +0,0 @@
-#ifndef MODEL_FILE_H
-#define MODEL_FILE_H
-
-#include "common/File.h"
-#include "../../common/OgreGenUtilites.h"
-#include "../../common/DrawSkeleton.h"
-
-
-
-struct ModelInfo
-{
-    MeshData                  data;
-    Ogre::String              file_name;
-    std::vector<Ogre::String> animations;
-    std::vector<Ogre::String> animations_name;
-};
-
-
-
-class ModelFile : public File
-{
-public:
-    ModelFile( const Ogre::String& file );
-    ModelFile( File* pFile );
-    ModelFile( File* pFile, u32 offset, u32 length );
-    ModelFile( u8* pBuffer, u32 offset, u32 length );
-    virtual ~ModelFile();
-
-    Ogre::Entity* GetModel( const ModelInfo& info );
-
-    Skeleton m_Skeleton;
-};
-
-
-
-#endif // MODEL_FILE_H

+ 0 - 43
utilities/ffix_script_dumper/CMakeLists.txt

@@ -1,43 +0,0 @@
-include_directories(
-    ${CMAKE_CURRENT_SOURCE_DIR}/src
-)
-
-# define header and source files
-set(HEADER_FILES
-./src/TextFile.h
-./src/ScriptFile.h
-)
-
-set(SOURCE_FILES
-./src/TextFile.cpp
-./src/Main.cpp
-./src/ScriptFile.cpp
-)
-
-add_definitions(
-    -DQGEARS_ADD_MANAGERS
-)
-
-add_executable(ff9_script_dumper
-  ${HEADER_FILES}
-  ${SOURCE_FILES}
-)
-SET_PROPERTY(TARGET ff9_script_dumper PROPERTY FOLDER "utilities")
-
-if(WIN32)
-  set_target_properties(ff9_script_dumper PROPERTIES WIN32_EXECUTABLE ON)
-  if (MSVC)
-    set_target_properties(ff9_script_dumper PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
-  endif()
-endif()
-
-set(LIBRARIES
-    Utility
-    QGearsMain
-    v-gears-data
-)
-target_link_libraries(ff9_script_dumper    ${LIBRARIES})
-
-install(TARGETS ff9_script_dumper
-    DESTINATION tools/ff9
-)

+ 0 - 24
utilities/ffix_script_dumper/src/Main.cpp

@@ -1,24 +0,0 @@
-#include "../../common/Logger.h"
-
-#include "ScriptFile.h"
-#include "TextFile.h"
-
-
-
-int
-main(int argc, char *argv[])
-{
-    LOGGER = new Logger("game.log");
-
-    TextFile* text_file = new TextFile("data/1.text");
-    text_file->DumpTexts();
-    delete text_file;
-
-    ScriptFile* script_file = new ScriptFile("data/1.script");
-    script_file->DumpScripts();
-    delete script_file;
-
-    delete LOGGER;
-
-    return 0;
-}

+ 0 - 2133
utilities/ffix_script_dumper/src/ScriptFile.cpp

@@ -1,2133 +0,0 @@
-#include "ScriptFile.h"
-#include "../../common/Logger.h"
-
-Logger* export_script;
-
-std::vector< StackItem > stack;
-
-Ogre::String raw_script;
-u32 script_offset;
-u32 script_pointer;
-u32 script_stored_pointer;
-u32 script_pointer_end;
-u8 control;
-
-
-ScriptFile::ScriptFile(const Ogre::String &file):
-    File(file)
-{
-}
-
-
-
-ScriptFile::ScriptFile(File *file, const u32 offset, const u32 length):
-    File(file, offset, length)
-{
-}
-
-
-
-ScriptFile::ScriptFile(u8* buffer, const u32 offset, const u32 length):
-    File(buffer, offset, length)
-{
-}
-
-
-
-ScriptFile::ScriptFile(File *file):
-    File(file)
-{
-}
-
-
-
-ScriptFile::~ScriptFile()
-{
-}
-
-
-
-void
-ScriptFile::DumpScripts()
-{
-    export_script = new Logger("scripts.txt");
-
-    u32 number_of_entity = GetU8( 0x03 );
-    for (u32 entity = 0; entity < number_of_entity; ++entity)
-    {
-        if ( GetU16LE( 0x80 + entity * 0x8 + 0x2) == 0 )
-        {
-            continue;
-        }
-
-        export_script->Log( "ENTITY: entity_id = 0x" + HexToString( entity, 2, '0' ) + "\n" );
-
-        script_offset = 0x80 + GetU16LE( 0x80 + entity * 0x8 );
-
-        u32 number_of_scripts = GetU8(script_offset + 1);
-
-        for (u32 i = 0; i < number_of_scripts; ++i)
-        {
-            raw_script = "";
-            u16 script_type = GetU16LE( script_offset + 2 + i * 0x4 );
-            script_pointer = script_offset + 2 + GetU16LE( script_offset + 2 + i * 0x4 + 2 );
-            script_pointer_end = script_pointer;
-
-            export_script->Log( "SCRIPT: script_id = 0x" + HexToString( script_type, 2, '0' ) + "\n" );
-            //export_script->Log( "script = w[8007aecc];\n" );
-            //export_script->Log( "mask = 8007ae10;\n" );
-
-            for( ; script_pointer <= script_pointer_end; )
-            {
-                u8 opcode = GetU8( script_pointer );
-                raw_script += " " + HexToString( opcode, 2, '0' );
-
-                //export_script->Log( "0x" + HexToString( script_pointer, 4, '0' ) + " 0x" + HexToString( script_pointer_end, 4, '0' ) + "\n" );
-
-                if( opcode != 0x02 && opcode != 0x03 && opcode != 0x06 && opcode != 0x0b )
-                {
-                    script_stored_pointer = script_pointer;
-                }
-
-                if( opcode != 0x05 )
-                {
-                    export_script->Log( "0x" + HexToString( script_stored_pointer, 4, '0' ) );
-                }
-
-                // Jump
-                if( opcode == 0x01 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 2 ), 2, '0' );
-                    s16 jump = GetU16LE( script_pointer + 1 ) + script_pointer + 3;
-                    AdvanceScript( 0, jump );
-                    script_pointer += 3;
-
-                    export_script->Log( "    JumpTo( 0x" + HexToString( jump, 4, '0' ) + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                // Jump If False
-                else if( opcode == 0x02 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 2 ), 2, '0' );
-                    s16 jump = GetU16LE( script_pointer + 1 ) + script_pointer + 3;
-                    AdvanceScript( 3, jump );
-
-                    export_script->Log("    JumpIf( " + GetStringFromStack() + " == false )To( 0x" + HexToString( jump, 4, '0' ) + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                // Jump If True
-                else if( opcode == 0x03 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 2 ), 2, '0' );
-                    s16 jump = GetU16LE( script_pointer + 1 ) + script_pointer + 3;
-                    AdvanceScript( 3, jump );
-
-                    export_script->Log("    JumpIf( " + GetStringFromStack() + " == true )To( 0x" + HexToString( jump, 4, '0' ) + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                // Return
-                else if( opcode == 0x04 )
-                {
-                    export_script->Log("    Return(); //" + raw_script + "\n" );
-                    raw_script = "";
-                    script_pointer += 1;
-                }
-                // StackSubRoutine
-                else if( opcode == 0x05 )
-                {
-                    script_stored_pointer = script_pointer;
-                    AdvanceScript( 1 );
-
-                    StackOpcodeParse();
-
-                    u8 advance_op = GetU8( script_pointer );
-                    if ( advance_op != 0x02 && advance_op != 0x03 && advance_op != 0x06 && advance_op != 0x0b )
-                    {
-                        export_script->Log( "0x" + HexToString( script_stored_pointer, 4, '0' ) );
-                        export_script->Log( "    " + GetStringFromStack() + "; //" + raw_script + "\n" );
-                        raw_script = "";
-                    }
-                }
-                else if (opcode == 0x06)
-                {
-                    AdvanceScript( 1 );
-                    u8 case_option   = GetU8( script_pointer );
-                    raw_script += " " + HexToString( case_option, 2, '0' );
-                    u16 default_jump = GetU16LE( script_pointer + 1 ) + script_pointer + 3;
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 2 ), 2, '0' );
-                    AdvanceScript( 0, default_jump );
-
-
-                    export_script->Log("    JumpSwitch( " + GetStringFromStack() + " )" );
-                    for ( int i = 0; i < case_option; ++i )
-                    {
-                        raw_script += " " + HexToString( GetU8( script_pointer + 3 + i * 4 + 0 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 3 + i * 4 + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 3 + i * 4 + 2 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 3 + i * 4 + 3 ), 2, '0' );
-
-                        u16 value  = GetU16LE( script_pointer + 3 + i * 4 + 0);
-                        u16 jump  = GetU16LE( script_pointer + 3 + i * 4 + 2) + script_pointer + 3;
-                        AdvanceScript( 0, jump );
-                        export_script->Log("( case " + HexToString( value, 4, '0' ) + ": jump_to:0x" + HexToString( jump, 4, '0' ) + ")" );
-                    }
-
-                    export_script->Log("( default: jump_to:0x" + HexToString( default_jump, 4, '0' ) + "); //" + raw_script + "\n" );
-                    raw_script = "";
-                    AdvanceScript( 3 + case_option * 4 );
-                }
-                else if( opcode == 0x07 )
-                {
-                    Ogre::String data1 = HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    Ogre::String data2 = HexToString( GetU8( script_pointer + 2 ), 2, '0' );
-                    raw_script += " " + data1 + " " + data2;
-                    AdvanceScript( 3 );
-
-                    export_script->Log( "    InitScriptEntity( entity_id = 0x" + data1 + ", shared_id = 0x" + data2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x08 )
-                {
-                    Ogre::String data1 = HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    Ogre::String data2 = HexToString( GetU8( script_pointer + 2 ), 2, '0' );
-                    raw_script += " " + data1 + " " + data2;
-                    AdvanceScript( 3 );
-
-                    export_script->Log( "    InitType3Entity( entity_id = 0x" + data1 + ", shared_id = 0x" + data2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x09 )
-                {
-                    Ogre::String data1 = HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    Ogre::String data2 = HexToString( GetU8( script_pointer + 2 ), 2, '0' );
-                    raw_script += " " + data1 + " " + data2;
-                    AdvanceScript( 3 );
-
-                    export_script->Log( "    InitModelEntity( entity_id = 0x" + data1 + ", shared_id = 0x" + data2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x0b )
-                {
-                    AdvanceScript( 1 );
-                    u8 case_option   = GetU8( script_pointer );
-                    s16 range_start  = GetU16LE( script_pointer + 1 );
-                    u16 default_jump = GetU16LE( script_pointer + 3 ) + script_pointer;
-                    AdvanceScript( 0, default_jump );
-
-                    raw_script += " " + HexToString( case_option, 2, '0' );
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 2 ), 2, '0' );
-                    raw_script += " " + HexToString( GetU8( script_pointer + 3 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 4 ), 2, '0' );
-
-                    export_script->Log("    JumpSwitch( " + GetStringFromStack() + " )" );
-                    for ( int i = 0; i < case_option; ++i )
-                    {
-                        raw_script += " " + HexToString( GetU8( script_pointer + 5 + i * 2 + 0 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 5 + i * 2 + 1 ), 2, '0' );
-
-                        u16 jump  = GetU16LE( script_pointer + 5 + i * 2) + script_pointer;
-                        AdvanceScript( 0, jump );
-                        export_script->Log("( case 0x" + HexToString( i + range_start, 4, '0' ) + ": jump_to:0x" + HexToString( jump, 4, '0' ) + ")" );
-                    }
-
-                    export_script->Log("( default: jump_to:0x" + HexToString( default_jump, 4, '0' ) + "); //" + raw_script + "\n" );
-                    raw_script = "";
-
-                    AdvanceScript( 5 + case_option * 2 );
-                }/*
-                // switch in row
-                else if (opcode == 0x0d)
-                {
-                    u16 case_option = GetU16LE(script_offset + script_pointer);
-                    s16 range_start = GetU16LE(script_offset + script_pointer + 2);
-                    u16 default_jump = GetU16LE(script_offset + script_pointer + 4);
-                    export_script->Log("\t0x0b_JumpSwitchInRow(range_start:0x%04x)(default:0x%04x)", range_start, script_offset + default_jump + script_pointer + 1);
-                    for (int i = 0; i < case_option; ++i)
-                    {
-                        u16 jump  = GetU16LE(script_offset + script_pointer + 6 + i * 2);
-                        export_script->Log("(jump:0x%04x)", script_offset + jump + script_pointer + 1);
-                    }
-                    script_pointer += 6 + case_option * 2;
-                    export_script->Log("; // pop 1 value from stack\n");
-                }*/
-                else if( opcode == 0x10 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String priority = Get8Variable();
-                    Ogre::String entity_id = Get8Variable();
-                    raw_script += " " + HexToString( GetU8( script_pointer ), 2, '0' );
-                    Ogre::String script_id = HexToString( GetU8( script_pointer ), 2, '0' );
-                    AdvanceScript( 1 );
-                    export_script->Log( "    RunScriptAsync( priority = " + priority + ", entity_id = " + entity_id + ", script_id = 0x" + script_id + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x14 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String priority = Get8Variable();
-                    Ogre::String entity_id = Get8Variable();
-                    raw_script += " " + HexToString( GetU8( script_pointer ), 2, '0' );
-                    Ogre::String script_id = HexToString( GetU8( script_pointer ), 2, '0' );
-                    AdvanceScript( 1 );
-                    export_script->Log( "    RunScriptStartSync( priority = " + priority + ", entity_id = " + entity_id + ", script_id = 0x" + script_id + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x1c )
-                {
-                    Ogre::String data = HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    Ogre::String entity_id = HexToString( GetU8( script_pointer + 2 ), 2, '0' );
-                    raw_script += " " + data + " " + entity_id;
-                    AdvanceScript( 3 );
-
-                    export_script->Log( "    MoveScriptToEnd( entity_id = 0x" + entity_id + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x1d )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String x = Get16Variable();
-                    Ogre::String z = Get16Variable();
-                    export_script->Log( "    SetEntityPositionByXZ( x = " + x + ", z = " + z + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x1f )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String window_id = Get8Variable();
-                    Ogre::String style = Get8Variable();
-                    Ogre::String text_id = Get16Variable();
-                    export_script->Log( "    WindowSync( window_id = " + window_id + ", style = " + style + ", text_id = " + text_id + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x20 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String window_id = Get8Variable();
-                    Ogre::String style = Get8Variable();
-                    Ogre::String text_id = Get16Variable();
-                    export_script->Log( "    WindowAsync( window_id = " + window_id + ", style = " + style + ", text_id = " + text_id + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x21 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    export_script->Log( "    0x21( " + Get8Variable() + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x22 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    export_script->Log( "    Wait( " + Get8Variable() + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x23 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String x = Get16Variable();
-                    Ogre::String y = Get16Variable();
-                    export_script->Log( "    MoveToPosition( x = " + x + ", y = " + y + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x25 )
-                {
-                    AdvanceScript( 1 );
-                    export_script->Log( "    ResetEntityData30_50_63_78(); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x26 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get8Variable();
-                    export_script->Log( "    SetEntityData5c( " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x27 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    export_script->Log( "    Set800c9df1( " + Get8Variable() + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x29)
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    if( control & 0x01 )
-                    {
-                        export_script->Log( "ERROR uexpected situation in opcode 0x29" );
-                        break;
-                    }
-
-                    raw_script += " " + HexToString( GetU8( script_pointer + 0 ), 2, '0' );
-                    u8 number = GetU8( script_pointer + 0 );
-                    AdvanceScript( 1 );
-
-                    export_script->Log( "    SetDataForType3Entity( number = " + HexToString( number, 2, '0' ) );
-                    for ( int i = 0; i < number; ++i )
-                    {
-                        Ogre::String value1 = Get16Variable();
-                        Ogre::String value2 = Get16Variable();
-                        export_script->Log(", " + value1 + ", " + value2 );
-                    }
-
-                    export_script->Log(" ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x2a )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get16Variable();
-                    export_script->Log( "    0x2a( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x2b )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get16Variable();
-                    export_script->Log( "    0x2b( " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x2c )
-                {
-                    AdvanceScript( 1 );
-
-                    export_script->Log( "    [ script + 0x16ed ] = h( GetCurrentEntityId() ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x2d )
-                {
-                    AdvanceScript( 1 );
-
-                    export_script->Log( "    0x2d(); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x2e )
-                {
-                    AdvanceScript( 1 );
-
-                    export_script->Log( "    0x2e(); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x2f )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get16Variable();
-                    Ogre::String value2 = Get8Variable();
-                    export_script->Log( "    Set32and34inEntityStruct( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x33 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get16Variable();
-                    export_script->Log( "    SetEntityData54( animation_id = " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x34 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get16Variable();
-                    export_script->Log( "    SetEntityData56( animation_id = " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x35 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get16Variable();
-                    export_script->Log( "    SetEntityData58( animation_id = " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x36 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String rot = Get8Variable();
-                    export_script->Log( "    SetEntityRotation( rotation = " + rot + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x3a )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String entity_id = Get8Variable();
-                    Ogre::String value = Get8Variable();
-                    export_script->Log( "    0x3a( entity_id = " + entity_id + ", " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x3d )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    export_script->Log( "    SetEntityData60and61( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x40 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String animation_id = Get16Variable();
-                    export_script->Log( "    PlayEntityAnimation( animation_id = " + animation_id + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x41 )
-                {
-                    AdvanceScript( 1 );
-                    export_script->Log( "    WaitUntilAnimationComplete(); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x43 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String entity_id = Get8Variable();
-                    export_script->Log( "    InitAdditionalScriptEntityForCurrentEntity( entity_id = " + entity_id + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x47 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String flags = Get8Variable();
-                    export_script->Log( "    SetEntityCollisionFlags( flags = " + flags + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x48 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get16Variable();
-                    Ogre::String value2 = Get8Variable();
-                    export_script->Log( "    0x48( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x4b )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get8Variable();
-                    Ogre::String solid = Get8Variable();
-                    Ogre::String talk = Get8Variable();
-                    export_script->Log( "    SetEntityCollision( " + value + ", solid_radius = " + solid + ", talk_radius = " + talk + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x50 )
-                {
-                    AdvanceScript( 1 );
-                    export_script->Log( "    WaitUntilRotationComplete(); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x51 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String entity_id = Get8Variable();
-                    Ogre::String steps = Get8Variable();
-                    export_script->Log( "    SetEntityRotateToEntity( entity_id = " + entity_id + ", steps = " + steps + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x52 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get16Variable();
-                    export_script->Log( "    SetEntityData74( " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x54 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get8Variable();
-                    export_script->Log( "    0x54( " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x55 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get8Variable();
-                    export_script->Log( "    SetEntityData5f( " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x56 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String rotation = Get8Variable();
-                    Ogre::String steps = Get8Variable();
-                    export_script->Log( "    SetEntityRotateToRotation( rotation = " + rotation + ", steps = " + steps + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x59 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    Ogre::String value3 = Get8Variable();
-                    Ogre::String value4 = Get8Variable();
-                    export_script->Log( "    CallFuncc1368( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x5b )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    export_script->Log( "    CallFuncc142c( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x61 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get16Variable();
-                    export_script->Log( "    CallFuncc17f0( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x62 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String character_id = Get8Variable(); // must be less than 9 or else we must not read next value
-                    Ogre::String value1 = Get8Variable();
-                    export_script->Log( "    CharacterSet34Flag00000200( character_id = " + character_id + ", " + value1 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x65 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    Ogre::String value3 = Get8Variable();
-                    export_script->Log( "    CallFuncc18d4( " + value1 + ", " + value2 + ", " + value3 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x66 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get16Variable();
-                    export_script->Log( "    Set8007bba8( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x67 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    export_script->Log( "    Set16e8and16ea( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x68 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get8Variable();
-                    export_script->Log( "    Set8007bbf4( " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x6a )
-                {
-                    AdvanceScript( 1 );
-
-                    export_script->Log( "    Set16f8to1(); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x6f )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get16Variable();
-                    Ogre::String value2 = Get16Variable();
-                    Ogre::String value3 = Get8Variable();
-                    Ogre::String value4 = Get8Variable();
-                    export_script->Log( "    CallFuncc0df4( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x75 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    export_script->Log( "    0x75( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x7a )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get16Variable();
-                    export_script->Log( "    SetEntityData4c( animation_id = " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x7b )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get16Variable();
-                    export_script->Log( "    SetEntityData4e( animation_id = " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x7e )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    export_script->Log( "    CallFuncc0bcc( " + value1 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x7f )
-                {
-                    AdvanceScript( 1 );
-
-                    export_script->Log( "    0x7f(); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x80 )
-                {
-                    AdvanceScript( 1 );
-
-                    export_script->Log( "    0x80(); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x86 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    Ogre::String value3 = Get8Variable();
-                    Ogre::String value4 = Get8Variable();
-                    export_script->Log( "    SetEntityData7c_7d_7e_7f( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x88 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get16Variable();
-                    Ogre::String value3 = Get16Variable();
-                    Ogre::String value4 = Get16Variable();
-                    export_script->Log( "    CallFuncaba98( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x8b )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    export_script->Log( "    SetEntityData6a_6b( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x8e )
-                {
-                    AdvanceScript( 1 );
-
-                    export_script->Log( "    0x8e(); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x8f )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String entity_id = Get8Variable();
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    Ogre::String value3 = Get8Variable();
-                    export_script->Log( "    0x8f( entity_id = " + entity_id + ", " + value1 + ", " + value2 + ", " + value3 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x90 )
-                {
-                    AdvanceScript( 1 );
-
-                    export_script->Log( "    [ script + 0x1700 ] = h( -1 ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x92 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get16Variable();
-                    Ogre::String value3 = Get8Variable();
-                    Ogre::String value4 = Get8Variable();
-                    Ogre::String value5 = Get8Variable();
-                    Ogre::String value6 = Get8Variable();
-                    Ogre::String value7 = Get8Variable();
-                    export_script->Log( "    CallFuncc02d0( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + ", " + value5 + ", " + value6 + ", " + value7 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x93 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String flags = Get8Variable();
-                    export_script->Log( "    SetEntityFlagsTo0f( flags = " + flags + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x94 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get16Variable();
-                    Ogre::String value2 = Get8Variable();
-                    Ogre::String value3 = Get8Variable();
-                    export_script->Log( "    SetEntityData76_90_91( " + value1 + ", " + value2 + ", " + value3 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x9a )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get16Variable();
-                    Ogre::String value2 = Get8Variable();
-                    export_script->Log( "    CallFuncc778c( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x9c )
-                {
-                    AdvanceScript( 1 );
-
-                    export_script->Log( "    Play76Animation(); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x9d )
-                {
-                    AdvanceScript( 1 );
-
-                    export_script->Log( "    PlaySomeAnimation(); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0x9f )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String entity_id = Get8Variable();
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    Ogre::String value3 = Get8Variable();
-                    export_script->Log( "    0x9f( entity_id = " + entity_id + ", " + value1 + ", " + value2 + ", " + value3 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xa1 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String x = Get16Variable();
-                    Ogre::String y = Get16Variable();
-                    Ogre::String z = Get16Variable();
-                    export_script->Log( "    SetEntityPositionByXYZ( x = " + x + ", y = " + y + ", z = " + z + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xa8 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get8Variable();
-                    export_script->Log( "    0xa8( " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xa9 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get8Variable();
-                    export_script->Log( "    Set8007ae2cAnd8007ae30WithScreenXYForEntity( " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xaa )
-                {
-                    AdvanceScript( 1 );
-
-                    export_script->Log( "    [80073998] = w(w[80073998] & fffbffff); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xab )
-                {
-                    AdvanceScript( 1 );
-
-                    export_script->Log( "    [80073998] = w(w[80073998] | 00040000); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xb3 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    Ogre::String value3 = Get16Variable();
-                    Ogre::String value4 = Get16Variable();
-                    Ogre::String value5 = Get16Variable();
-                    export_script->Log( "    CallFuncafac0( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + ", " + value5 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xb4 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get16Variable();
-                    export_script->Log( "    0xb4( " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xc5 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get16Variable();
-                    Ogre::String value2 = Get16Variable();
-                    export_script->Log( "    CallDynamic8006794c_1c_83c( " + value1 + ", " + value2 + ", 0x00, 0x00, 0x00 ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xc6 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get16Variable();
-                    Ogre::String value2 = Get16Variable();
-                    Ogre::String value3 = Get24Variable();
-                    export_script->Log( "    CallDynamic8006794c_1c_83c( " + value1 + ", " + value2 + ", " + value3 + ", 0x00, 0x00 ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xc7 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get16Variable();
-                    Ogre::String value2 = Get16Variable();
-                    Ogre::String value3 = Get24Variable();
-                    Ogre::String value4 = Get8Variable();
-                    export_script->Log( "    CallDynamic8006794c_1c_83c( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + ", 0x00 ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xc8 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get16Variable();
-                    Ogre::String value2 = Get16Variable();
-                    Ogre::String value3 = Get24Variable();
-                    Ogre::String value4 = Get8Variable();
-                    Ogre::String value5 = Get8Variable();
-                    export_script->Log( "    CallDynamic8006794c_1c_83c( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + ", " + value5 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xca )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    export_script->Log( "    CallFuncc196c( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xcb )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    export_script->Log( "    CallFuncc47e4( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xce )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get24Variable();
-                    export_script->Log( "    0xce( " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xd7 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value = Get8Variable();
-                    export_script->Log( "    Set8007bc14to0x2cIfValueEqual8007bc10( " + value + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xd9 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String character_id = Get8Variable();
-                    Ogre::String status_mask = Get8Variable();
-                    export_script->Log( "    CharacterRemoveStatuses( character_id = " + character_id + ", status_mask = " + status_mask + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xda )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    Ogre::String value3 = Get8Variable();
-                    Ogre::String value4 = Get16Variable();
-                    Ogre::String value5 = Get16Variable();
-                    export_script->Log( "    CallFuncafac0( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + ", " + value5 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xdc )
-                {
-                    AdvanceScript( 1 );
-
-                    export_script->Log( "    PerformJump(); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xdd )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String character_id = Get8Variable();
-                    export_script->Log( "    PartyRemove( character_id = " + character_id + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xde )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String character_id = Get8Variable();
-                    Ogre::String string_id = Get16Variable();
-                    export_script->Log( "    CharacterSetName( character_id = " + character_id + ", string_id = " + string_id + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xe2 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String x = Get16Variable();
-                    Ogre::String y = Get16Variable();
-                    Ogre::String z = Get16Variable();
-                    Ogre::String steps = Get8Variable();
-                    export_script->Log( "    Jump( x = " + x + ", y = " + y + ", z = " + z + ", steps = " + steps + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xe3 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    export_script->Log( "    Set8007bbd8( " + Get8Variable() + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xec )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    Ogre::String value3 = Get8Variable();
-                    Ogre::String value4 = Get8Variable();
-                    Ogre::String value5 = Get8Variable();
-                    Ogre::String value6 = Get8Variable();
-                    export_script->Log( "    0xec( " + value1 + ", " + value2 + ", " + value3 + ", " + value4 + ", " + value5 + ", " + value6 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xef )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    export_script->Log( "    Set8007bbe0_8007bbe8( " + Get8Variable() + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xf1 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String character_id = Get8Variable();
-                    Ogre::String hp = Get16Variable();
-                    export_script->Log( "    CharacterSetHP( character_id = " + character_id + ", hp = " + hp + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xf2 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String character_id = Get8Variable();
-                    Ogre::String mp = Get16Variable();
-                    export_script->Log( "    CharacterSetMP( character_id = " + character_id + ", mp = " + mp + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xf7 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    export_script->Log( "    CallFunc54fe0( " + value1 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xf8 )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    Ogre::String value3 = Get8Variable();
-                    export_script->Log( "    CallFunc54e88( " + value1 + ", " + value2 + ", " + value3 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xfd )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get16Variable();
-                    export_script->Log( "    CallDynamic8006794c_1c_8bc( " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else if( opcode == 0xfe )
-                {
-                    raw_script += " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-                    control = GetU8( script_pointer + 1 );
-                    AdvanceScript( 2 );
-
-                    Ogre::String character_id = Get8Variable();
-                    Ogre::String type = Get8Variable();
-                    Ogre::String preset_id = Get8Variable();
-                    Ogre::String value1 = Get8Variable();
-                    Ogre::String value2 = Get8Variable();
-                    export_script->Log( "    CharacterInit( character_id = " + character_id + ", type = " + type + ", preset_id = " + preset_id + ", " + value1 + ", " + value2 + " ); //" + raw_script + "\n" );
-                    raw_script = "";
-                }
-                else
-                {
-                    export_script->Log( "    MISSING OPCODE 0x" + HexToString( opcode, 2, '0' ) + "\n" );
-                    break;
-                }
-            }
-
-            export_script->Log( "\n" );
-        }
-        export_script->Log( "\n\n\n" );
-    }
-
-    delete export_script;
-}
-
-
-
-void
-ScriptFile::StackOpcodeParse()
-{
-    Ogre::String result;
-    stack.clear();
-
-    for ( ;; )
-    {
-        u8 stack_opcode = GetU8( script_pointer );
-        //export_script->Log( "StackOpcodeParse: 0x" + HexToString( script_pointer, 4, '0' ) + " opcode: 0x" + HexToString( stack_opcode, 2, '0' ) + "\n" );
-        raw_script += " " + HexToString( stack_opcode, 2, '0' );
-        AdvanceScript( 1 );
-
-        if( stack_opcode == 0x04 )
-        {
-            Ogre::String value = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value + "++ )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x05 )
-        {
-            Ogre::String value = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value + "-- )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x0e)
-        {
-            Ogre::String value1 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value1 + " == false )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x11 )
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value1 + " * " + value2 + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x12 )
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value1 + " / " + value2 + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x13 )
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value1 + " % " + value2 + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x14 )
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value1 + " + " + value2 + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x15)
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value1 + " - " + value2 + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x16)
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " << " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x17)
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " >> " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x18)
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " < " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x19)
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " > " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x1a)
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " <= " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x1b)
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " >= " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x20)
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " == " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x21)
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " != " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x22)
-        {
-            Ogre::String value = GetStringFromStack();
-            Ogre::String parameter = GetStringFromStack();
-            Ogre::String mask = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "MultipleEqual( mask = " + mask + ", parameter = " + parameter + ", value = " + value + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x24)
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " & " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x25)
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " XOR " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x27)
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " && " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x28)
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " || " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x29 )
-        {
-            raw_script += " " + HexToString( GetU8( script_pointer + 0 ), 2, '0' );
-
-            u16 data = GetU8( script_pointer + 0 );
-            AdvanceScript( 1 );
-            StackItem item;
-            item.value_int = 0x18000000 | data;
-            item.value_string = "";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x2a )
-        {
-            Ogre::String value = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "CountActiveBits( " + value + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x2b)
-        {
-            Ogre::String parameter = GetStringFromStack();
-            Ogre::String mask = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "GetUnitParameter( mask = " + mask + ", parameter = " + parameter + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x2c )
-        {
-            Ogre::String value = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = StoreVariableByStack( value );
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x2d)
-        {
-            Ogre::String value = GetStringFromStack();
-            Ogre::String parameter = GetStringFromStack();
-            Ogre::String mask = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "StoreUnitsParamsByMask( mask = " + mask + ", parameter = " + parameter + ", value = " + value + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x32 )
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " += " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x33 )
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " -= " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x35 )
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " >>= " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x3d )
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " &= " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x3e )
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " ^= " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x3f )
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "( " + value2 + " |= " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x4d )
-        {
-            Ogre::String value = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "PickRandomActiveBit( " + value + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x4f )
-        {
-            Ogre::String value = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "IsButtonPressed( " + value + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x52 )
-        {
-            Ogre::String value = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "GetCurrentHpForCharacter( " + value + " )";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x54)
-        {
-            Ogre::String value = GetStringFromStack();
-            Ogre::String parameter = GetStringFromStack();
-            Ogre::String mask = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "MultipleAnd( mask = " + mask + ", parameter = " + parameter + ", value = " + value + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x5d )
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "GetCurrentEntityRotationTo( " + value2 + ", " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x62 )
-        {
-            Ogre::String value = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "GetSinByRotation( " + value + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x64 )
-        {
-            Ogre::String value = GetStringFromStack( 0 );
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "0x64stack( " + value + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x66 )
-        {
-            Ogre::String value1 = GetStringFromStack();
-            Ogre::String value2 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "GetRotationBy( " + value2 + ", " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x6b )
-        {
-            Ogre::String value1 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "CallFunc4b85c( " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x6d )
-        {
-            Ogre::String value1 = GetStringFromStack();
-
-            StackItem item;
-            item.value_int = 0;
-            item.value_string = "CallFunc378c4( " + value1 + " )";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x78 )
-        {
-            raw_script += " " + HexToString( GetU8( script_pointer + 0 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-
-            u16 data = ( GetU8( script_pointer + 0 ) << 8 ) | GetU8( script_pointer + 1 );
-            AdvanceScript( 2 );
-            StackItem item;
-            item.value_int = 0x10000000 | data;
-            item.value_string = "";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x79 )
-        {
-            raw_script += " " + HexToString( GetU8( script_pointer + 0 ), 2, '0' );
-
-            u16 data = GetU8( script_pointer + 0 );
-            AdvanceScript( 1 );
-            StackItem item;
-            item.value_int = 0x14000000 | data;
-            item.value_string = "";
-            stack.push_back( item );
-        }
-        else if (stack_opcode == 0x7a)
-        {
-            raw_script += " " + HexToString( GetU8( script_pointer ), 2, '0' );
-
-            u8 type = GetU8( script_pointer );
-            AdvanceScript( 1 );
-            StackItem item;
-            item.value_int = 0;
-            switch (type)
-            {
-                case 0x00: item.value_string = "GetRandomByte()"; break;
-                case 0x02: item.value_string = "bu[script + 16ec]"; break;
-                case 0x03: item.value_string = "funcb0124( 0xc00, 0xffffffff, 0, 0, 0 )"; break;
-                case 0x06: item.value_string = "w[w[w[8006794c] + 1c] + 560]"; break;
-                case 0x09: item.value_string = "Func4ecc4()"; break;
-                case 0x0c: item.value_string = "w[8007ae2c]"; break;
-                case 0x0d: item.value_string = "w[8007ae30]"; break;
-                case 0x13: item.value_string = "Count80083248()"; break;
-                default: item.value_string = "Unimplemented type 0x" + HexToString( type , 2, '0' ) + " for stack opcode 0x7a.";
-            }
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x7d )
-        {
-            raw_script += " " + HexToString( GetU8( script_pointer ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-
-            u16 data = GetU16LE( script_pointer );
-            AdvanceScript( 2 );
-            StackItem item;
-            item.value_int = 0x1c000000 | data;
-            item.value_string = "";
-            stack.push_back( item );
-        }
-        else if( stack_opcode == 0x7e )
-        {
-            raw_script += " " + HexToString( GetU8( script_pointer ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 2 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 3 ), 2, '0' );
-
-            u32 data = GetU32LE( script_pointer ) & 0x03ffffff;
-            AdvanceScript( 4 );
-            StackItem item;
-            item.value_int = 0x1c000000 | data;
-            item.value_string = "";
-            stack.push_back( item );
-        }
-        // FinishSubRoutine
-        else if( stack_opcode == 0x7f )
-        {
-            return;
-        }
-        // AddCommand
-        else if( stack_opcode >= 0x80 )
-        {
-            StackItem item;
-            item.value_int = StackOpcode80Parse( stack_opcode );
-            item.value_string = "";
-            stack.push_back( item );
-        }
-        else
-        {
-            //export_script->Log( "0x" + HexToString( script_position, 4, '0' ) );
-            export_script->Log( " MISSING STACK OPCODE 0x" + HexToString( stack_opcode, 2, '0' ) + "; //" + raw_script + "\n" );
-            raw_script = "";
-            return;
-        }
-    }
-}
-
-
-
-u32
-ScriptFile::StackOpcode80Parse( u32 stack_opcode )
-{
-    u32 command = stack_opcode & 0x03;
-    command <<= 0x1a;
-    u32 A1 = stack_opcode & 0x1c;
-    A1 <<= 0x1b;
-    command |= A1;
-    u8 data = GetU8( script_pointer );
-    raw_script += " " + HexToString( data, 2, '0' );
-    AdvanceScript( 1 );
-    command |= data;
-    if (stack_opcode & 0x20)
-    {
-        data = GetU8( script_pointer );
-        raw_script += " " + HexToString( data, 2, '0' );
-        AdvanceScript( 1 );
-        data <<= 0x8;
-        command |= data;
-    }
-    //export_script->Log( "StackOpcode80Parse command: " + HexToString( command, 2, '0') + "\n" );
-    return command;
-}
-
-
-
-Ogre::String
-ScriptFile::LoadVariable( const StackItem& item )
-{
-    if( item.value_string != "" )
-    {
-        return "ERROR: LoadVariable must hanble top calue of stack as int. But value is \"" + stack.back().value_string + "\".";
-    }
-    u32 command = item.value_int;
-    //export_script->Log( "Load with command: " + HexToString( command, 2, '0') + "\n" );
-    if( ( command >> 0x18 ) == 0x10 )
-    {
-        switch (command & 0xff)
-        {
-            case 0x0: return "GetXPositionFromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
-            case 0x1: return "GetYPositionFromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
-            case 0x2: return "GetZPositionFromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
-            case 0x3: return "GetYRotationFromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
-            case 0x4: return "GetFlagsFromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
-            case 0x5: return "GetMainEntityIdFromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
-            case 0x6: return "GetCurrentScriptPriorityFromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
-            case 0x7: return "Get[3a]FromEntity( 0x" + HexToString( ( command >> 0x8 ) & 0xff, 2, '0' ) + " )";
-            default: return "Unimplemented 0x" + HexToString( ( command >> 0x18 ), 2, '0' ) + " with type 0x" + HexToString( ( command & 0xff ), 2, '0' ) + " load.";
-        }
-    }
-    else if( ( command >> 0x18 ) == 0x14 )
-    {
-        Ogre::String ret = "Get";
-        if( ( command & 0x7 ) == 2 )
-        {
-            ret += "Party";
-        }
-        else if( ( command & 0x7 ) == 3 )
-        {
-            ret += "Enemy";
-        }
-        else if( ( command & 0x7 ) == 4 )
-        {
-            ret += "Units";
-        }
-        else
-        {
-            ret += "Unknown" + HexToString( ( command & 0x7 ), 2, '0' );
-        }
-        ret += "Mask()";
-        return ret;
-    }
-    else if( ( command >> 0x18 ) == 0x18 )
-    {
-        switch ( ( command << 6 ) >> 6 )
-        {
-            case 0x0: return "GetXPositionFromEntity()";
-            case 0x1: return "GetYPositionFromEntity()";
-            case 0x2: return "GetZPositionFromEntity()";
-            case 0x3: return "GetYRotationFromEntity()";
-            case 0x4: return "GetFlagsFromEntity()";
-            case 0x5: return "GetMainEntityIdFromEntity()";
-            case 0x6: return "GetCurrentScriptPriorityFromEntity()";
-            case 0x7: return "Get[3a]FromEntity()";
-            default: return "Unimplemented 0x" + HexToString( ( command >> 0x18 ), 2, '0' ) + " with type 0x" + HexToString( ( ( command << 6 ) >> 6 ), 2, '0' ) + " load.";
-        }
-    }
-    else if( ( command >> 0x18 ) == 0x1c )
-    {
-        return "0x" + HexToString( ( command << 0x6 ) >> 0x6, 8, '0' );
-    }
-    else if( ( command >> 0x18 ) == 0x20 )
-    {
-        return "(bu[ 0x8007aef0 + 0x" + HexToString( ( command & 0xffff ) >> 0x3, 4, '0' ) + " ] >> 0x" + HexToString( command & 0x7, 2, '0' ) + ") & 1";
-    }
-    else if( ( command >> 0x18 ) == 0x24 )
-    {
-        return "(bu[ script + 0x" + HexToString( ( command & 0xffff ) >> 0x3, 4, '0' ) + " ] >> 0x" + HexToString( command & 0x7, 2, '0' ) + ") & 1";
-    }
-    else if( ( command >> 0x18 ) == 0x48 )
-    {
-        return "b3[ w[ 0x8007bcf8 ] + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
-    }
-    else if( ( command >> 0x18 ) == 0x80 )
-    {
-        return "b[ 0x8007aef0 + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
-    }
-    else if( ( command >> 0x18 ) == 0x88 )
-    {
-        return "b[ w[ 0x8007bcf8 ] + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
-    }
-    else if( ( command >> 0x18 ) == 0xa0 )
-    {
-        return "bu[ 0x8007aef0 + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
-    }
-    else if( ( command >> 0x18 ) == 0xa4 )
-    {
-        return "bu[ script + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
-    }
-    else if( ( command >> 0x18 ) == 0xa8 )
-    {
-        return "bu[ w[ 0x8007bcf8 ] + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
-    }
-    else if( ( command >> 0x18 ) == 0xc0 )
-    {
-        return "h[ 0x8007aef0 + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
-    }
-    else if( ( command >> 0x18 ) == 0xc4 )
-    {
-        return "h[ script + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
-    }
-    else if( ( command >> 0x18 ) == 0xe0 )
-    {
-        return "hu[ 0x8007aef0 + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
-    }
-    else if( ( command >> 0x18 ) == 0xe4 )
-    {
-        return "hu[ script + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
-    }
-    else if( ( command >> 0x18 ) == 0xe8 )
-    {
-        return "hu[ w[ 0x8007bcf8 ] + 0x" + HexToString( ( command & 0xffff ), 4, '0' ) + " ]";
-    }
-
-    return "Unimplemented 0x" + HexToString( ( command >> 0x18 ), 2, '0' ) + " load.";
-}
-
-
-
-Ogre::String
-ScriptFile::GetStringFromStack( int position )
-{
-    StackItem item;
-
-    if( position >= 0 )
-    {
-        item = stack[ stack.size() - 1 - position ];
-    }
-    else
-    {
-        item = stack.back();
-        stack.pop_back();
-    }
-
-    Ogre::String stack_result = "";
-    if ( item.value_string != "" )
-    {
-        Ogre::String string = item.value_string;
-        return string;
-    }
-    else
-    {
-        return LoadVariable( item );
-    }
-}
-
-
-
-Ogre::String
-ScriptFile::StoreVariableByStack( const Ogre::String& value )
-{
-    if ( stack.back().value_string != "" )
-    {
-        return "ERROR: StoreVariableByStack must hanble top calue of stack as int. But value is \"" + stack.back().value_string + "\".";
-    }
-
-    u32 command = stack.back().value_int;
-    //export_script->Log( "Save with command: " + HexToString( command, 2, '0') + " value: " + value + "\n" );
-    stack.pop_back();
-
-    if ( ( command >> 0x18 ) == 0x14 )
-    {
-        return "[ masks + 0x" + HexToString( ( command & 0x7 ) * 2, 2, '0' ) + " ] = h( " + value + " )";
-    }
-    else if ( ( command >> 0x18 ) == 0x20 )
-    {
-        if ( value == "0x00000000" )
-        {
-            return "[ 0x8007aef0 + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] = b( b[ 0x8007aef0 + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] & 0x" + HexToString( 0xff ^ (1 << (command & 0x7)), 2, '0' ) + " )";
-        }
-        else
-        {
-            return "[ 0x8007aef0 + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] = b( b[ 0x8007aef0 + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] | 0x" + HexToString( 1 << (command & 0x7), 2, '0' ) + " )";
-        }
-    }
-    else if ( ( command >> 0x18 ) == 0x24 )
-    {
-        if ( value == "0x00000000" )
-        {
-            return "[ script + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] = b( b[ script + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] & 0x" + HexToString( 0xff ^ (1 << (command & 0x7)), 2, '0' ) + " )";
-        }
-        else
-        {
-            return "[ script + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] = b( b[ script + 0x" + HexToString( (command & 0xffff) >> 0x3, 4, '0' ) + " ] | 0x" + HexToString( 1 << (command & 0x7), 2, '0' ) + " )";
-        }
-    }
-    else if ( ( command >> 0x18 ) == 0x48 )
-    {
-        return "[ w[ 0x8007bcf8 ] + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = b3( " + value + " )";
-    }
-    else if ( ( command >> 0x18 ) == 0x88 )
-    {
-        return "[ w[ 0x8007bcf8 ] + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = b( " + value + " )";
-    }
-    else if ( ( command >> 0x18 ) == 0xa0 )
-    {
-        return "[ 0x8007aef0 + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = b( " + value + " )";
-    }
-    else if ( ( command >> 0x18 ) == 0xa4 )
-    {
-        return "[ script + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = b( " + value + " )";
-    }
-    else if ( ( command >> 0x18 ) == 0xa8 )
-    {
-        return "[ w[ 0x8007bcf8 ] + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = b( " + value + " )";
-    }
-    else if ( ( command >> 0x18 ) == 0xc0 )
-    {
-        return "[ 0x8007aef0 + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = h( " + value + " )";
-    }
-    else if ( ( command >> 0x18 ) == 0xc4 )
-    {
-        return "[ script + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = h( " + value + " )";
-    }
-    else if ( ( command >> 0x18 ) == 0xe0 )
-    {
-        return "[ 0x8007aef0 + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = h( " + value + " )";
-    }
-    else if ( ( command >> 0x18 ) == 0xe4 )
-    {
-        return "[ script + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = h( " + value + " )";
-    }
-    else if ( ( command >> 0x18 ) == 0xe8 )
-    {
-        return "[ w[ 0x8007bcf8 ] + 0x" + HexToString( (command & 0xffff), 4, '0' ) + " ] = h( " + value + " )";
-    }
-
-    return "Unimplemented 0x" + HexToString( ( command >> 0x18 ), 2, '0' ) + " store.";
-}
-
-
-
-Ogre::String
-ScriptFile::Get8Variable()
-{
-    if( control & 1 )
-    {
-        control >>= 1;
-        StackOpcodeParse();
-        return GetStringFromStack();
-    }
-    else
-    {
-        control >>= 1;
-        u8 data = GetU8( script_pointer );
-        raw_script += " " + HexToString( data, 2, '0' );
-        AdvanceScript( 1 );
-        return "0x" + HexToString( data, 2, '0' );
-    }
-}
-
-
-
-Ogre::String
-ScriptFile::Get16Variable()
-{
-    if (control & 1)
-    {
-        control >>= 1;
-        StackOpcodeParse();
-        return GetStringFromStack();
-    }
-    else
-    {
-        control >>= 1;
-        u16 data = GetU16LE( script_pointer );
-        raw_script += " " + HexToString( GetU8( script_pointer + 0 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' );
-        AdvanceScript( 2 );
-        return "0x" + HexToString( data, 4, '0' );
-    }
-}
-
-
-
-Ogre::String
-ScriptFile::Get24Variable()
-{
-    if (control & 1)
-    {
-        control >>= 1;
-        StackOpcodeParse();
-        return GetStringFromStack();
-    }
-    else
-    {
-        control >>= 1;
-        u32 data = GetU16LE( script_pointer ) | ( GetU8( script_pointer + 2 ) << 0x10 );
-        raw_script += " " + HexToString( GetU8( script_pointer + 0 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 1 ), 2, '0' ) + " " + HexToString( GetU8( script_pointer + 2 ), 2, '0' );
-        AdvanceScript( 3 );
-        return "0x" + HexToString( data, 6, '0' );
-    }
-}
-
-
-
-void
-ScriptFile::AdvanceScript( u32 value, u32 jump )
-{
-    script_pointer += value;
-    script_pointer_end = (script_pointer > script_pointer_end) ? script_pointer : script_pointer_end;
-    script_pointer_end = ( jump > script_pointer_end ) ? jump : script_pointer_end;
-}

+ 0 - 39
utilities/ffix_script_dumper/src/ScriptFile.h

@@ -1,39 +0,0 @@
-#ifndef ScriptFILE_H
-#define ScriptFILE_H
-
-#include "common/File.h"
-
-
-
-struct StackItem
-{
-    u32 value_int;
-    Ogre::String value_string;
-};
-
-
-
-class ScriptFile : public File
-{
-public:
-    ScriptFile(const Ogre::String& file);
-    ScriptFile(File* pFile);
-    ScriptFile(File* pFile, u32 offset, u32 length);
-    ScriptFile(u8* pBuffer, u32 offset, u32 length);
-    virtual ~ScriptFile();
-
-    void DumpScripts();
-    void StackOpcodeParse();
-    u32  StackOpcode80Parse( u32 stack_opcode );
-    Ogre::String LoadVariable( const StackItem& item );
-    Ogre::String GetStringFromStack( int position = -1 );
-    Ogre::String StoreVariableByStack( const Ogre::String& value );
-    Ogre::String Get8Variable();
-    Ogre::String Get16Variable();
-    Ogre::String Get24Variable();
-    void AdvanceScript( u32 value, u32 jump = 0 );
-};
-
-
-
-#endif // ScriptFILE_H

+ 0 - 505
utilities/ffix_script_dumper/src/TextFile.cpp

@@ -1,505 +0,0 @@
-#include "TextFile.h"
-#include "../../common/Logger.h"
-
-
-
-//////////////////////////////////////////////
-unsigned short english_chars[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-unsigned short japanese_chars[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-unsigned short japanese_chars_fa[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-unsigned short japanese_chars_fb[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-unsigned short japanese_chars_fc[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-unsigned short japanese_chars_fd[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-unsigned short japanese_chars_fe[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-TextFile::TextFile(const Ogre::String &file):
-    File(file)
-{
-}
-
-
-
-TextFile::TextFile(File *file, const u32 offset, const u32 length):
-    File(file, offset, length)
-{
-}
-
-
-
-TextFile::TextFile(u8* buffer, const u32 offset, const u32 length):
-    File(buffer, offset, length)
-{
-}
-
-
-
-TextFile::TextFile(File *file):
-    File(file)
-{
-}
-
-
-
-TextFile::~TextFile()
-{
-}
-
-
-
-void
-TextFile::DumpTexts()
-{
-    Logger* export_text = new Logger( "texts.txt" );
-
-    std::vector< unsigned char > dialog;
-    dialog.push_back( 0xFF );
-    dialog.push_back( 0xFE );
-    export_text->Log( dialog );
-    dialog.clear();
-
-    u32 number_of_texts = GetU32LE( 0x0 );
-
-
-
-    for( u32 i = 0; i < number_of_texts; ++i )
-    {
-        u32 pointer_to_text = 0x04 + GetU16LE( 0x04 +  i * 0x04 );
-
-        //export_text->LogW( "<dialog id=\"" + ToIntString( i ) + "\">" );
-        export_text->LogW( "<dialog id=\"0x" + HexToString( i, 2, '0' ) + "\">" );
-        export_text->LogW( "0x" + HexToString( pointer_to_text, 4, '0' ) + "" );
-/*
-        for (unsigned char temp = 0x00; ; ++offset)
-        {
-            temp = GetU8(offset);
-            if (temp == 0xFF)
-            {
-                break;
-            }
-
-            if (temp == 0xE0 && english == true)
-            {
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-            }
-            else if (temp == 0xE1 && english == true)
-            {
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-            }
-            else if (temp == 0xE2 && english == true)
-            {
-                dialog.push_back(english_chars[0x0C] >> 8); dialog.push_back(english_chars[0x0C] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-            }
-            else if (temp == 0xE8)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<new_window />");
-            }
-            else if (temp == 0xEA)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"0\" />");
-            }
-            else if (temp == 0xEB)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"1\" />");
-            }
-            else if (temp == 0xEC)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"2\" />");
-            }
-            else if (temp == 0xED)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"3\" />");
-            }
-            else if (temp == 0xEE)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"4\" />");
-            }
-            else if (temp == 0xEF)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"5\" />");
-            }
-            else if (temp == 0xF0)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"6\" />");
-            }
-            else if (temp == 0xF1)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"7\" />");
-            }
-            else if (temp == 0xF2)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"8\" />");
-            }
-            else if (temp == 0xF3)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character party_id=\"0\" />");
-            }
-            else if (temp == 0xF4)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character party_id=\"1\" />");
-            }
-            else if (temp == 0xF5)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character party_id=\"2\" />");
-            }
-            else if (temp == 0xF6)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<image id=\"circle\" />");
-            }
-            else if (temp == 0xF7)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<image id=\"triangle\" />");
-            }
-            else if (temp == 0xF8)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<image id=\"square\" />");
-            }
-            else if (temp == 0xF9)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<image id=\"cross\" />");
-            }
-            else if ((temp == 0xFA || temp == 0xFB ||temp == 0xFC ||temp == 0xFD) && english == false)
-            {
-                ++offset;
-                unsigned char temp2 = GetU8(offset);
-
-                if (temp == 0xFA)
-                {
-                    if (japanese_chars_fa[temp2] != 0x0000)
-                    {
-                        dialog.push_back(japanese_chars_fa[temp2] >> 8); dialog.push_back(japanese_chars_fa[temp2] & 0xFF);
-                    }
-                    else
-                    {
-                        export_text->Log(dialog);
-                        dialog.clear();
-                        export_text->LogW("[MISSING 0xFA " + HexToString(temp2, 2, '0') + "]");
-                    }
-                }
-                else if (temp == 0xFB)
-                {
-                    if (japanese_chars_fb[temp2] != 0x0000)
-                    {
-                        dialog.push_back(japanese_chars_fb[temp2] >> 8); dialog.push_back(japanese_chars_fb[temp2] & 0xFF);
-                    }
-                    else
-                    {
-                        export_text->Log(dialog);
-                        dialog.clear();
-                        export_text->LogW("[MISSING 0xFB " + HexToString(temp2, 2, '0') + "]");
-                    }
-                }
-                else if (temp == 0xFC)
-                {
-                    if (japanese_chars_fc[temp2] != 0x0000)
-                    {
-                        dialog.push_back(japanese_chars_fc[temp2] >> 8); dialog.push_back(japanese_chars_fc[temp2] & 0xFF);
-                    }
-                    else
-                    {
-                        export_text->Log(dialog);
-                        dialog.clear();
-                        export_text->LogW("[MISSING 0xFC " + HexToString(temp2, 2, '0') + "]");
-                    }
-                }
-                else if (temp == 0xFD)
-                {
-                    if (japanese_chars_fd[temp2] != 0x0000)
-                    {
-                        dialog.push_back(japanese_chars_fd[temp2] >> 8); dialog.push_back(japanese_chars_fd[temp2] & 0xFF);
-                    }
-                    else
-                    {
-                        export_text->Log(dialog);
-                        dialog.clear();
-                        export_text->LogW("[MISSING 0xFD " + HexToString(temp2, 2, '0') + "]");
-                    }
-                }
-            }
-            else if (temp == 0xFE)
-            {
-                ++offset;
-
-                unsigned char temp2 = GetU8(offset);
-
-                if (temp2 == 0xD4)
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<colour id=\"red\" />");
-                }
-                else if (temp2 == 0xD5)
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<colour id=\"purple\" />");
-                }
-                else if (temp2 == 0xD6)
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<colour id=\"green\" />");
-                }
-                else if (temp2 == 0xD7)
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<colour id=\"cyan\" />");
-                }
-                else if (temp2 == 0xD8)
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<colour id=\"yellow\" />");
-                }
-                else if (temp2 == 0xD9)
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<colour id=\"white\" />");
-                }
-                else if (temp2 == 0xDC)
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<pause_ok />");
-                }
-                else if (temp2 == 0xDD)
-                {
-                    u16 wait = GetU16LE(offset + 1);
-                    ++offset;
-                    ++offset;
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<pause wait=\"" + ToIntString(wait) + "\" />");
-                }
-                else
-                {
-                    if (japanese_chars_fe[temp2] != 0x0000 && english == false)
-                    {
-                        dialog.push_back(japanese_chars_fe[temp2] >> 8); dialog.push_back(japanese_chars_fe[temp2] & 0xFF);
-                    }
-                    else
-                    {
-                        export_text->Log(dialog);
-                        dialog.clear();
-                        export_text->LogW("[MISSING 0xFE " + HexToString(temp2, 2, '0') + "]");
-                    }
-                }
-            }
-            else
-            {
-                if (japanese_chars[temp] != 0x0000 && english == false)
-                {
-                    dialog.push_back(japanese_chars[temp] >> 8); dialog.push_back(japanese_chars[temp] & 0xFF);
-                }
-                else if (english_chars[temp] != 0x0000 && english == true)
-                {
-                    dialog.push_back(english_chars[temp] >> 8); dialog.push_back(english_chars[temp] & 0xFF);
-                }
-                else
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("[MISSING CHAR " + HexToString(temp, 2, '0') + "]");
-                }
-            }
-        }
-*/
-        export_text->Log( dialog );
-        dialog.clear();
-        export_text->LogW( "</dialog>\n\n" );
-    }
-
-    delete export_text;
-}

+ 0 - 22
utilities/ffix_script_dumper/src/TextFile.h

@@ -1,22 +0,0 @@
-#ifndef TextFILE_H
-#define TextFILE_H
-
-#include "common/File.h"
-
-
-
-class TextFile : public File
-{
-public:
-    TextFile(const Ogre::String& file);
-    TextFile(File* pFile);
-    TextFile(File* pFile, u32 offset, u32 length);
-    TextFile(u8* pBuffer, u32 offset, u32 length);
-    virtual ~TextFile();
-
-    void DumpTexts();
-};
-
-
-
-#endif // TextFILE_H

+ 0 - 53
utilities/ffix_sound_dumper/CMakeLists.txt

@@ -1,53 +0,0 @@
-include_directories(
-    ${CMAKE_CURRENT_SOURCE_DIR}/src
-    ${CMAKE_CURRENT_SOURCE_DIR}/src/engine
-    ${CMAKE_CURRENT_SOURCE_DIR}/src/engine/backends
-)
-
-# define header and source files
-set(HEADER_FILES
-./src/engine/SoundManager.h
-./src/engine/SoundBackend.h
-./src/engine/backends/SoundBackendSDL.h
-./src/SoundParser.h
-./src/Main.h
-)
-
-set(SOURCE_FILES
-./src/engine/backends/SoundBackendSDL.cpp
-./src/engine/SoundManager.cpp
-./src/SoundParser.cpp
-./src/Main.cpp
-)
-
-add_definitions(
-    -DQGEARS_ADD_MANAGERS
-)
-
-add_executable(ff9_sound_dumper
-  ${HEADER_FILES}
-  ${SOURCE_FILES}
-)
-SET_PROPERTY(TARGET ff9_sound_dumper PROPERTY FOLDER "utilities")
-
-if (APPLE)
-target_link_libraries(ff9_sound_dumper "-framework CoreFoundation -framework Cocoa -framework IOKit")
-endif()
-
-if(WIN32)
-  set_target_properties(ff9_sound_dumper PROPERTIES WIN32_EXECUTABLE ON)
-  if (MSVC)
-    set_target_properties(ff9_sound_dumper PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
-  endif()
-endif()
-
-set(LIBRARIES
-    Utility
-    QGearsMain
-    v-gears-data
-)
-target_link_libraries(ff9_sound_dumper    ${LIBRARIES})
-
-install(TARGETS ff9_sound_dumper
-    DESTINATION tools/ff9
-)

+ 0 - 187
utilities/ffix_sound_dumper/src/Main.cpp

@@ -1,187 +0,0 @@
-#include "Main.h"
-
-#include <Ogre.h>
-#include <OgreWindowEventUtilities.h>
-#include <OIS/OIS.h>
-
-#include "common/FileSystem.h"
-#include "../../common/Logger.h"
-
-
-#include "SoundParser.h"
-#include "engine/SoundManager.h"
-
-
-
-int state;
-
-
-
-class DisplayFrameListener : public Ogre::FrameListener, public Ogre::WindowEventListener, public OIS::KeyListener
-{
-public:
-    DisplayFrameListener(Ogre::RenderWindow* win):
-        m_Window(win),
-        m_InputManager(0),
-        m_Keyboard(0),
-        m_Timer(0)
-    {
-        using namespace OIS;
-
-        Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
-        ParamList pl;
-        size_t windowHnd = 0;
-        std::ostringstream windowHndStr;
-
-        win->getCustomAttribute("WINDOW", &windowHnd);
-        windowHndStr << windowHnd;
-        pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
-
-        m_InputManager = InputManager::createInputSystem(pl);
-
-        m_Keyboard = static_cast<Keyboard*>(m_InputManager->createInputObject(OIS::OISKeyboard, true));
-        m_Keyboard->setEventCallback(this);
-
-        //Register as a Window listener
-        Ogre::WindowEventUtilities::addWindowEventListener(m_Window, this);
-    }
-
-    virtual
-    ~DisplayFrameListener(void)
-    {
-        m_InputManager->destroyInputObject(m_Keyboard);
-
-        OIS::InputManager::destroyInputSystem(m_InputManager);
-
-        //Remove ourself as a Window listener
-        Ogre::WindowEventUtilities::removeWindowEventListener(m_Window, this);
-        windowClosed(m_Window);
-    }
-
-    virtual void
-    windowClosed(Ogre::RenderWindow* rw)
-    {
-        state = EXIT;
-    }
-
-    bool
-    frameStarted(const Ogre::FrameEvent& evt)
-    {
-        if (state == EXIT)
-        {
-            return false;
-        }
-
-        if (m_Keyboard)
-        {
-            m_Keyboard->capture();
-        }
-
-        //if (m_Timer >= 0.003)
-        //{
-            //m_Timer = 0;
-            SOUND_PARSER->Update();
-        //}
-        //m_Timer += evt.timeSinceLastFrame;
-
-        SOUNDMAN->Update();
-
-        return true;
-    }
-
-    bool
-    keyPressed(const OIS::KeyEvent& e)
-    {
-        switch (e.key)
-        {
-            case OIS::KC_ESCAPE:
-            {
-                state = EXIT;
-            }
-            break;
-        }
-
-        return true;
-    }
-
-    bool
-    keyReleased(const OIS::KeyEvent& e)
-    {
-        return true;
-    }
-
-protected:
-    Ogre::RenderWindow* m_Window;
-
-    OIS::InputManager*  m_InputManager;
-    OIS::Keyboard*      m_Keyboard;
-
-    float               m_Timer;
-};
-
-
-
-int
-main( int argc, char *argv[] )
-{
-    Ogre::Root*         root;
-    Ogre::RenderWindow* window;
-
-    root = new Ogre::Root( "", "" );
-#ifndef _DEBUG
-    root->loadPlugin( "RenderSystem_GL.dll" );
-#else
-    root->loadPlugin( "RenderSystem_GL_d.dll" );
-#endif
-    root->setRenderSystem( root->getAvailableRenderers()[ 0 ] );
-    root->initialise( false );
-    Ogre::NameValuePairList misc;
-    misc[ "title" ] = "Xenogears SoundDumper";
-    window = root->createRenderWindow( "QGearsWindow", 800, 600, false, &misc );
-
-
-
-
-    LOGGER = new Logger( "game.log" );
-
-    state = GAME;
-
-
-
-    DisplayFrameListener* frame_listener = new DisplayFrameListener( window );
-    root->addFrameListener( frame_listener );
-
-    Ogre::SceneManager* scene_manager = root->createSceneManager( Ogre::ST_GENERIC, "Scene" );
-    scene_manager->setAmbientLight( Ogre::ColourValue( 1.0, 1.0, 1.0 ) );
-
-    Ogre::Camera* camera = scene_manager->createCamera( "Camera" );
-    camera->setNearClipDistance( 5 );
-
-    Ogre::Viewport* viewport = window->addViewport( camera );
-    viewport->setBackgroundColour( Ogre::ColourValue( 0, 0, 0 ) );
-    camera->setAspectRatio( Ogre::Real( viewport->getActualWidth()) / Ogre::Real( viewport->getActualHeight() ) );
-
-
-
-    SOUNDMAN = new SoundManager();
-    SOUND_PARSER = new SoundParser();
-
-
-
-    Ogre::Root::getSingleton().startRendering();
-
-
-
-    delete SOUND_PARSER;
-    delete SOUNDMAN;
-
-
-
-    delete root;
-    delete frame_listener;
-
-    delete LOGGER;
-
-    return 0;
-}
-

+ 0 - 20
utilities/ffix_sound_dumper/src/Main.h

@@ -1,20 +0,0 @@
-#ifndef MAIN_H
-#define MAIN_H
-
-
-
-enum
-{
-    EXIT,
-    GAME
-};
-
-
-
-extern int state;
-
-
-
-
-#endif // MAIN_H
-

+ 0 - 34
utilities/ffix_sound_dumper/src/SoundParser.cpp

@@ -1,34 +0,0 @@
-#include "SoundParser.h"
-
-#include "engine/SoundManager.h"
-#include "../../common/Logger.h"
-
-
-
-SoundParser *SOUND_PARSER = NULL;
-
-
-
-SoundParser::SoundParser()
-{
-}
-
-
-
-SoundParser::~SoundParser()
-{
-}
-
-
-
-void
-SoundParser::Update()
-{
-}
-
-
-
-void
-SoundParser::UpdateSpu()
-{
-}

+ 0 - 34
utilities/ffix_sound_dumper/src/SoundParser.h

@@ -1,34 +0,0 @@
-#ifndef SOUND_PARSER_H
-#define SOUND_PARSER_H
-
-#include <Ogre.h>
-
-#include "common/File.h"
-#include "common/TypeDefine.h"
-
-
-
-class SoundParser
-{
-public:
-    SoundParser();
-    virtual ~SoundParser();
-
-    void Update();
-
-    // debug routines
-    void DumpSequenceData( const Ogre::String& file );
-
-
-
-private:
-    void UpdateSpu();
-};
-
-
-
-extern SoundParser *SOUND_PARSER;
-
-
-
-#endif // SOUND_PARSER_H

+ 0 - 29
utilities/ffix_sound_dumper/src/engine/SoundBackend.h

@@ -1,29 +0,0 @@
-#ifndef SOUND_BACKEND_HH__
-#define SOUND_BACKEND_HH__
-
-
-
-#include "common/TypeDefine.h"
-#include <iostream>
-
-
-
-class SoundBackend
-{
-	protected:
-		static const u32 m_BUFFER_SIZE = 70560;
-		static const u16 m_FREQUENCY = 44100;
-		static const u8 m_CHANNELS_COUNT = 2;
-
-	public:
-		SoundBackend(){}
-		virtual ~SoundBackend(){}
-
-		virtual u32 GetBytesBuffered() = 0;
-		virtual void FeedStreamData(u8 *arg_data, u32 arg_length) = 0;
-};
-
-
-
-#endif
-

+ 0 - 3830
utilities/ffix_sound_dumper/src/engine/SoundManager.cpp

@@ -1,3830 +0,0 @@
-#include <iostream>
-#include <fstream>
-#include <iomanip>
-#include "SoundManager.h"
-#include "SoundBackend.h"
-#include "backends/SoundBackendSDL.h"
-#ifdef _MSC_VER
-#include <windows.h>
-#else
-#include <sys/time.h>
-#endif
-
-SoundManager *SOUNDMAN = NULL;
-SoundBackend *SBE = NULL;
-
-#ifndef HIWORD
-#define HIWORD(l) ((WORD) (((DWORD) (l) >> 16) & 0xFFFF))
-#endif
-
-#ifndef LOWORD
-#define LOWORD(a) ((WORD)(a))
-#endif
-
-typedef unsigned short int WORD;
-#ifndef _MSC_VER
-typedef unsigned int DWORD;
-#endif
-
-unsigned long RateTable[160];
-
-// REVERB info and timing vars...
-int *sRVBPlay = NULL;
-int *sRVBEnd = NULL;
-int *sRVBStart = NULL;
-// some delay factor for reverb
-int iReverbOff = -1;
-int iReverbRepeat = 0;
-int iReverbNum = 1;
-
-xa_decode_t   * xapGlobal=0;
-
-u32 * XAFeed  = NULL;
-u32 * XAPlay  = NULL;
-u32 * XAStart = NULL;
-u32 * XAEnd   = NULL;
-
-u32   XARepeat  = 0;
-u32   XALastVal = 0;
-
-int             iLeftXAVol  = 32767;
-int             iRightXAVol = 32767;
-
-static int gauss_ptr = 0;
-static int gauss_window[8] = {0, 0, 0, 0, 0, 0, 0, 0};
-
-#define gvall0 gauss_window[gauss_ptr]
-#define gvall(x) gauss_window[(gauss_ptr+x)&3]
-#define gvalr0 gauss_window[4+gauss_ptr]
-#define gvalr(x) gauss_window[4+((gauss_ptr+x)&3)]
-
-void SetupTimer();
-void RemoveTimer();
-
-
-
-const unsigned char version = 1;
-const unsigned char revision = 0;
-const unsigned char build = 0;
-
-// psx buffer / addresses
-unsigned short  regArea[10000];
-unsigned short  spuMem[256 * 1024];
-unsigned char * spuMemC;
-unsigned char * pSpuIrq = 0;
-unsigned char * pSpuBuffer;
-
-// user settings
-int             iUseXA = 1;
-int             iVolume = 3;
-int             iXAPitch = 1;
-int             iUseTimer = 2;
-int             iSPUIRQWait = 1;
-int             iDebugMode = 0;
-int             iRecordMode = 0;
-int             iUseReverb = 2;
-int             iUseInterpolation = 2;
-//int             iDisStereo = 0;
-
-// MAIN infos struct for each channel
-
-// channel + 1 infos (1 is security for fmod handling)
-SPUCHAN         s_chan[MAXCHAN + 1];
-REVERBInfo      rvb;
-
-// global noise generator
-unsigned long   dwNoiseVal = 1;
-int             iWatchDog = 0;
-
-// some vars to store psx reg infos
-unsigned short  spuCtrl = 0;
-unsigned short  spuStat = 0;
-unsigned short  spuIrq = 0;
-// address into spu mem
-unsigned long   spuAddr = 0xffffffff;
-
-// thread handlers
-int             bEndThread = 0;
-int             bThreadEnded = 0;
-int             bSpuInit = 0;
-int             bSPUIsOpen = 0;
-
-// flags for faster testing, if new channel starts
-unsigned long dwNewChannel = 0;
-
-// func of main emu, called on spu irq
-void (*irqCallback)(void) = 0;
-void (*cddavCallback)(unsigned short, unsigned short) = 0;
-
-// certain globals (were local before, but
-// with the new timeproc I need em global)
-
-static const int f[5][2] =
-{
-	{  0,   0},
-	{ 60,   0},
-	{115, -52},
-	{ 98, -55},
-	{122, -60}
-};
-
-int SSumR[NSSIZE];
-int SSumL[NSSIZE];
-int iCycle = 0;
-short * pS;
-
-// last channel processed on spu irq in timer mode
-static int lastch = -1;
-// last ns pos
-static int lastns = 0;
-// secure start counter
-static int iSecureStart = 0;
-
-
-
-SoundManager::SoundManager()
-{
-	u8 *buffer;
-
-
-	/* SPU initialization */
-	SPUinit();
-	SPUopen();
-
-
-
-	/* base initialization of main registers */
-	u16 temp;
-
-	SPUwriteRegister(0x1f801d80, 0x0000);
-	SPUwriteRegister(0x1f801d82, 0x0000);
-
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0x0000);
-	SPUwriteRegister(0x1f801d80, 0x0000);
-	SPUwriteRegister(0x1f801d82, 0x0000);
-
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801dae);
-
-	SPUwriteRegister(0x1f801dac, 0x0004);
-
-	// H_SPUvolL
-	SPUwriteRegister(0x1f801d84, 0x0000);
-
-	// H_SPUvolR
-	SPUwriteRegister(0x1f801d86, 0x0000);
-
-	// H_SPUoff1
-	SPUwriteRegister(0x1f801d8c, 0xffff);
-
-	// H_SPUoff2
-	SPUwriteRegister(0x1f801d8e, 0xffff);
-
-	// H_RVBon1
-	SPUwriteRegister(0x1f801d98, 0x0000);
-
-	// H_RVBon2
-	SPUwriteRegister(0x1f801d9a, 0x0000);
-
-	// H_Fmod1
-	SPUwriteRegister(0x1f801d90, 0x0000);
-
-	// H_Fmod2
-	SPUwriteRegister(0x1f801d92, 0x0000);
-
-	// H_Noise1
-	SPUwriteRegister(0x1f801d94, 0x0000);
-
-	// H_Noise2
-	SPUwriteRegister(0x1f801d96, 0x0000);
-
-	// H_CDLeft
-	SPUwriteRegister(0x1f801db0, 0x0000);
-
-	// H_CDRight
-	SPUwriteRegister(0x1f801db2, 0x0000);
-
-	SPUwriteRegister(0x1f801db4, 0x0000);
-	SPUwriteRegister(0x1f801db6, 0x0000);
-
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801dae);
-
-	// H_SPUaddr
-	SPUwriteRegister(0x1f801da6, 0x0200);
-
-	// H_SPUdata, hmmm... why 8 times??
-	for(int i = 0; i < 8; ++i)
-		SPUwriteRegister(0x1f801da8, 0x0707);
-
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801daa);
-
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0x0010);
-
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801dae);
-
-	// returns 0x0010
-	temp = SPUreadRegister(0x1f801daa);
-
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0x0000);
-
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801dae);
-
-
-
-	/* clear channels */
-	for(int i = 0; i < 24; ++i)
-	{
-		// left volume
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x00, 0x0000);
-		// right volume
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x02, 0x0000);
-		// pitch
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x04, 0x3fff);
-		// start address
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x06, 0x0200);
-		// level with pre-calcs
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x08, 0x0000);
-		// adsr times with precalcs
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x0a, 0x0000);
-	}
-
-
-
-	/* on/off SPU channels, why?? ;) */
-	// H_SPUon1
-	SPUwriteRegister(0x1f801d88, 0xffff);
-
-	// H_SPUon2
-	SPUwriteRegister(0x1f801d8a, 0x00ff);
-
-	// H_SPUoff1
-	SPUwriteRegister(0x1f801d8c, 0xffff);
-
-	// H_SPUoff2
-	SPUwriteRegister(0x1f801d8e, 0x00ff);
-
-
-
-	/* reverb initialization */
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc000);
-	// H_SPUReverbAddr
-	SPUwriteRegister(0x1f801da2, 0xfffe);
-
-
-
-	/* another dma transfer [unknown yet] */
-	// temporary writing another dma dump gotten with real emu
-	{
-		std::ifstream iF;
-		iF.open("data/dmadump2.bin", std::ios_base::binary);
-		u32 datasize = 64;
-		buffer = new u8[datasize];
-		iF.read((char *)buffer, datasize);
-		iF.close();
-		if(!this->PsxWriteDMA(0xedfc, buffer, datasize))
-		{
-			std::cout << "[SoundManager] error: failed to DMA write unknown data" << std::endl;
-			exit(EXIT_FAILURE);
-		}
-		delete [] buffer;
-	}
-
-
-
-	/* CDaudio controls? */
-	SPUwriteRegister(0x1f801d80, 0x3fff);
-	SPUwriteRegister(0x1f801d82, 0x3fff);
-	// H_CDLeft
-	SPUwriteRegister(0x1f801db0, 0x7fff);
-	// H_CDRight
-	SPUwriteRegister(0x1f801db2, 0x7fff);
-	SPUwriteRegister(0x1f801db4, 0x0000);
-	SPUwriteRegister(0x1f801db6, 0x0000);
-
-
-
-	/* here turning something important on, or clear something, me thinks... */
-	// returns 0xc0000
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc000);
-	// returns 0xc000
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc001);
-	// returns 0xc001
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc001);
-	// returns 0xc001
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc001);
-
-
-
-	/* clear channels volume again, for safe?? (cleared before) */
-	for(int i = 0; i < 24; ++i)
-	{
-		// left volume
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x00, 0x0000);
-		// right volume
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x02, 0x0000);
-	}
-
-
-
-	/* another init ;) */
-	// returns 0xc001
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc001);
-	// returns 0xc001
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUoff1
-	SPUwriteRegister(0x1f801d8c, 0x0000);
-	// H_SPUoff2
-	SPUwriteRegister(0x1f801d8e, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// H_RVBon1
-	SPUwriteRegister(0x1f801d98, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// H_RVBon2
-	SPUwriteRegister(0x1f801d9a, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// H_RVBon1
-	SPUwriteRegister(0x1f801d98, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// H_RVBon2
-	SPUwriteRegister(0x1f801d9a, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// H_FMod1
-	SPUwriteRegister(0x1f801d90, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// H_FMod2
-	SPUwriteRegister(0x1f801d92, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// H_FMod1
-	SPUwriteRegister(0x1f801d90, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// H_FMod2
-	SPUwriteRegister(0x1f801d92, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// H_Noise1
-	SPUwriteRegister(0x1f801d94, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// H_Noise2
-	SPUwriteRegister(0x1f801d96, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// H_Noise1
-	SPUwriteRegister(0x1f801d94, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// H_Noise2
-	SPUwriteRegister(0x1f801d96, 0x0000);
-	// returns 0xc001
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc001);
-	// returns 0xc001
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUrvolL
-	SPUwriteRegister(0x1f801d84, 0x0000);
-	// H_SPUrvolR
-	SPUwriteRegister(0x1f801d86, 0x0000);
-
-
-
-	/* set reverb parameters?? */
-	// H_Reverb
-	SPUwriteRegister(0x1f801dc0, 0x00e3);
-	SPUwriteRegister(0x1f801dc2, 0x00a9);
-	SPUwriteRegister(0x1f801dc4, 0x6f60);
-	SPUwriteRegister(0x1f801dc6, 0x4fa8);
-	SPUwriteRegister(0x1f801dc8, 0xbce0);
-	SPUwriteRegister(0x1f801dca, 0x4510);
-	SPUwriteRegister(0x1f801dcc, 0xbef0);
-	SPUwriteRegister(0x1f801dce, 0xa680);
-	SPUwriteRegister(0x1f801dd0, 0x5680);
-	SPUwriteRegister(0x1f801dd2, 0x52c0);
-	SPUwriteRegister(0x1f801dd4, 0x0dfb);
-	SPUwriteRegister(0x1f801dd6, 0x0b58);
-	SPUwriteRegister(0x1f801dd8, 0x0d09);
-	SPUwriteRegister(0x1f801dda, 0x0a3c);
-	SPUwriteRegister(0x1f801ddc, 0x0bd9);
-	SPUwriteRegister(0x1f801dde, 0x0973);
-	SPUwriteRegister(0x1f801de0, 0x0b59);
-	SPUwriteRegister(0x1f801de2, 0x08da);
-	SPUwriteRegister(0x1f801de4, 0x08d9);
-	SPUwriteRegister(0x1f801de6, 0x05e9);
-	SPUwriteRegister(0x1f801de8, 0x07ec);
-	SPUwriteRegister(0x1f801dea, 0x04b0);
-	SPUwriteRegister(0x1f801dec, 0x06ef);
-	SPUwriteRegister(0x1f801dee, 0x03d2);
-	SPUwriteRegister(0x1f801df0, 0x05ea);
-	SPUwriteRegister(0x1f801df2, 0x031d);
-	SPUwriteRegister(0x1f801df4, 0x031c);
-	SPUwriteRegister(0x1f801df6, 0x0238);
-	SPUwriteRegister(0x1f801df8, 0x0154);
-	SPUwriteRegister(0x1f801dfa, 0x00aa);
-	SPUwriteRegister(0x1f801dfc, 0x8000);
-	SPUwriteRegister(0x1f801dfe, 0x8000);
-
-
-
-	/* and finishing dma transfer of zeroes :), phew */
-	{
-		u32 datasize = 1024;
-		u8 *buffer = new u8[datasize];
-		memset((void *)buffer, 0x00, datasize);
-		for(int i = 0; i < 28; ++i)
-		{
-			if(!this->PsxWriteDMA(0xf204 + 128 * i, buffer, datasize))
-			{
-				std::cout << "[SoundManager] error: failed to DMA write 0x00 data" << std::endl;
-				exit(EXIT_FAILURE);
-			}
-		}
-		delete [] buffer;
-	}
-
-
-
-	/* last init */
-	// H_SPUReverbAddr
-	SPUwriteRegister(0x1f801da2, 0xf204);
-	// returns 0xc001
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc081);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// H_Noise1
-	SPUwriteRegister(0x1f801d94, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// H_Noise2
-	SPUwriteRegister(0x1f801d96, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// H_Noise1
-	SPUwriteRegister(0x1f801d94, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// H_Noise2
-	SPUwriteRegister(0x1f801d96, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// H_RVBon1
-	SPUwriteRegister(0x1f801d98, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// H_RVBon2
-	SPUwriteRegister(0x1f801d9a, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// H_RVBon1
-	SPUwriteRegister(0x1f801d98, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// H_RVBon2
-	SPUwriteRegister(0x1f801d9a, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// H_FMod1
-	SPUwriteRegister(0x1f801d90, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// H_FMod2
-	SPUwriteRegister(0x1f801d92, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// H_FMod1
-	SPUwriteRegister(0x1f801d90, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// H_FMod2
-	SPUwriteRegister(0x1f801d92, 0x0000);
-	// H_SPUoff1
-	SPUwriteRegister(0x1f801d8c, 0xffff);
-	// H_SPUoff2
-	SPUwriteRegister(0x1f801d8e, 0x00ff);
-}
-
-
-bool SoundManager::PsxWriteDMA(u16 arg_address, u8 *arg_data, u32 arg_length)
-{
-	u16 temp;
-
-	// write and verify destination address
-	SPUwriteRegister(0x1f801da6, arg_address);
-	if(SPUreadRegister(0x1f801da6) != arg_address)
-		return false;
-
-	// set and verify dma operation
-	temp = SPUreadRegister(0x1f801daa);
-	temp |= 32;
-	SPUwriteRegister(0x1f801daa, temp);
-	if(SPUreadRegister(0x1f801daa) != temp)
-		return false;
-
-	SPUwriteDMAMem((unsigned short *)arg_data, arg_length / 2);
-
-	// clear and verify dma operation
-	temp = SPUreadRegister(0x1f801daa);
-	temp &= ~32;
-	SPUwriteRegister(0x1f801daa, temp);
-	if(SPUreadRegister(0x1f801daa) != temp)
-		return false;
-
-	return true;
-}
-
-
-SoundManager::~SoundManager()
-{
-    // close SPU
-    SPUclose();
-}
-
-
-
-void SoundManager::Update()
-{
-    SPUasync(0xc000);
-}
-
-
-
-void
-SoundManager::PsxChannelPlay( u8 arg_channel )
-{
-    if( arg_channel < 16 )
-    {
-        // H_SPUon1
-        SPUwriteRegister( 0x1f801d88, 1 << arg_channel );
-    }
-    else if( arg_channel >= 16 && arg_channel < 24 )
-    {
-        // H_SPUon2
-        SPUwriteRegister( 0x1f801d8a, 1 << ( arg_channel - 16 ) );
-    }
-}
-
-
-
-void
-SoundManager::PsxChannelStop( u8 arg_channel )
-{
-    if( arg_channel < 16 )
-    {
-        // H_SPUoff1
-        SPUwriteRegister( 0x1f801d8c, 1 << arg_channel );
-    }
-    else if( arg_channel >= 16 && arg_channel < 24 )
-    {
-        // H_SPUoff2
-        SPUwriteRegister( 0x1f801d8e, 1 << ( arg_channel - 16 ) );
-    }
-}
-
-
-
-void
-SoundManager::PsxReverbOn( u8 arg_channel )
-{
-    if( arg_channel < 16 )
-    {
-        // H_RVBon1
-        SPUwriteRegister( 0x1f801d98, 1 << arg_channel );
-    }
-    else if( arg_channel >= 16 && arg_channel < 24 )
-    {
-        // H_RVBon2
-        SPUwriteRegister( 0x1f801d9a, 1 << ( arg_channel - 16 ) );
-    }
-}
-
-
-
-void
-SoundManager::PsxSetReverbDepth( u16 arg_left, u16 arg_right )
-{
-    SPUwriteRegister( 0x1f801d84, arg_left );
-    SPUwriteRegister( 0x1f801d86, arg_right );
-}
-
-
-
-void
-SoundManager::SetVoiceStartAddress( u8 arg_voice, u32 arg_address )
-{
-    if( arg_voice < 0x18 )
-    {
-        // if address isn't divisible by 8, it's
-        // increased to the next value divisible by 8
-        if( arg_address % 8 )
-        {
-            arg_address += 8;
-            arg_address &= ~7;
-        }
-
-        SPUwriteRegister( m_PSX_SPU_BASE + arg_voice * 0x10 + 0x06, ( u16 )( arg_address / 8 ) );
-    }
-}
-
-
-
-void SoundManager::SetVoiceLoopAddress(u8 arg_voice, u32 arg_address)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	// if address isn't divisible by 8, it's
-	// increased to the next value divisible by 8
-	if(arg_address % 8)
-	{
-		arg_address += 8;
-		arg_address &= ~7;
-	}
-
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x0e, (u16)(arg_address / 8));
-}
-
-
-// +++
-void SoundManager::SetVoiceVolume(u8 arg_voice,
-		s16 arg_volume_left, s16 arg_volume_right)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x00,
-			arg_volume_left & 0x7fff);
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x02,
-			arg_volume_right & 0x7fff);
-}
-
-
-// +++
-void SoundManager::SetVoicePitch(u8 arg_voice, u16 arg_pitch)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	if(arg_pitch >= 0x4000)
-	{
-		std::cout << "*** error: wrong pitch!" << std::endl;
-		return;
-	}
-
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x04, arg_pitch);
-}
-
-
-// +++
-void SoundManager::SetVoiceAttackRate(u8 arg_voice,
-		u16 arg_rate, SpuRateMode arg_mode)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	if(arg_rate >= 0x80)
-	{
-		std::cout << "*** error: wrong attack rate!" << std::endl;
-		return;
-	}
-
-	u16 value = (arg_mode == SPU_VOICE_EXPIncN) ? (1 << 7) : 0;
-	value |= arg_rate;
-	value <<= 8;
-
-	u16 temp = SPUreadRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x08) & 0xFF;
-	temp |= value;
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x08, temp);
-}
-
-
-// +++
-void SoundManager::SetVoiceSustainRate(u8 arg_voice,
-		u16 arg_rate, SpuRateMode arg_mode)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	if(arg_rate >= 0x80)
-	{
-		std::cout << "*** error: wrong sustain rate!" << std::endl;
-		return;
-	}
-
-	u16 value;
-	switch(arg_mode)
-	{
-		case SPU_VOICE_EXPIncN:
-			value = 0x200;
-			break;
-
-		case SPU_VOICE_LINEARDecN:
-			value = 0x100;
-			break;
-
-		case SPU_VOICE_EXPDec:
-			value = 0x300;
-			break;
-
-		default:
-		std::cout << "*** error: wrong sustain rate mode!" << std::endl;
-		case SPU_VOICE_LINEARIncN:
-			value = 0x000;
-			break;
-	}
-
-	u16 temp = SPUreadRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x0a) & 0x3F;
-	temp |= (arg_rate | value) << 6;
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x0a, temp);
-}
-
-
-// +++
-void SoundManager::SetVoiceReleaseRate(u8 arg_voice,
-		u16 arg_rate, SpuRateMode arg_mode)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	if(arg_rate >= 0x20)
-	{
-		std::cout << "*** error: wrong release rate!" << std::endl;
-		return;
-	}
-
-	u16 value = (arg_mode == SPU_VOICE_EXPDec) ? (1 << 5) : 0;
-	value |= arg_rate;
-
-	u16 temp = SPUreadRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x0a)
-		& 0xFFC0;
-	temp |= value;
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x0a, temp);
-}
-
-
-// +++
-void SoundManager::SetVoiceDecayRate(u8 arg_voice, u16 arg_rate)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	if(arg_rate >= 0x10)
-	{
-		std::cout << "*** error: wrong decay rate!" << std::endl;
-		return;
-	}
-
-	u16 temp = SPUreadRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x08)
-		& 0xFF0F;
-	temp |= arg_rate << 4;
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x08, temp);
-}
-
-
-// +++
-void SoundManager::SetVoiceSustainLevel(u8 arg_voice, u16 arg_level)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	if(arg_level >= 0x10)
-	{
-		std::cout << "*** error: wrong sustain level!" << std::endl;
-		return;
-	}
-
-	u16 temp = SPUreadRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x08)
-		& 0xFFF0;
-	temp |= arg_level;
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x08, temp);
-}
-
-
-void InitADSR()
-{
-	unsigned long r = 3;
-	unsigned long rs = 1;
-	unsigned long rd = 0;
-	int i;
-
-	// build the rate table according to Neill's rules
-	memset(RateTable, 0, sizeof(unsigned long) * 160);
-
-	// we start at pos 32 with the real values... everything before is 0
-	for(i = 32; i < 160; i++)
-	{
-		if(r < 0x3FFFFFFF)
-		{
-			r += rs;
-			rd++;
-			if(rd == 5)
-			{
-				rd = 1;
-				rs *= 2;
-			}
-		}
-		if(r > 0x3FFFFFFF)
-			r = 0x3FFFFFFF;
-
-		RateTable[i] = r;
-	}
-}
-
-
-void StartADSR(int ch)
-{
-	s_chan[ch].ADSRX.lVolume = 1;
-	s_chan[ch].ADSRX.State = 0;
-	s_chan[ch].ADSRX.EnvelopeVol = 0;
-}
-
-
-int MixADSR(int ch)
-{
-	// channel stopped
-	if(s_chan[ch].bStop)
-	{
-		// release
-		if(s_chan[ch].ADSRX.ReleaseModeExp)
-		{
-			switch((s_chan[ch].ADSRX.EnvelopeVol >> 28) & 0x07)
-			{
-				case 0:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 0 + 32];
-					break;
-
-				case 1:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 4 + 32];
-					break;
-
-				case 2:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 6 + 32];
-					break;
-
-				case 3:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 8 + 32];
-					break;
-
-				case 4:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 9 + 32];
-					break;
-
-				case 5:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 10 + 32];
-					break;
-
-				case 6:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 11 + 32];
-					break;
-
-				case 7:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 12 + 32];
-					break;
-			}
-		}
-		else
-			s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-				(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x0C + 32];
-
-		if(s_chan[ch].ADSRX.EnvelopeVol < 0)
-		{
-			s_chan[ch].ADSRX.EnvelopeVol = 0;
-			s_chan[ch].bOn = 0;
-		}
-
-		s_chan[ch].ADSRX.lVolume = s_chan[ch].ADSRX.EnvelopeVol >> 21;
-
-		return s_chan[ch].ADSRX.lVolume;
-	}
-
-	// channel not stopped
-	else
-	{
-		// attack
-		if(s_chan[ch].ADSRX.State == 0)
-		{
-			if(s_chan[ch].ADSRX.AttackModeExp)
-			{
-				if(s_chan[ch].ADSRX.EnvelopeVol < 0x60000000)
-					s_chan[ch].ADSRX.EnvelopeVol += RateTable[
-						(s_chan[ch].ADSRX.AttackRate^0x7F) - 0x10 + 32];
-				else
-					s_chan[ch].ADSRX.EnvelopeVol += RateTable[
-						(s_chan[ch].ADSRX.AttackRate^0x7F) - 0x18 + 32];
-			}
-			else
-				s_chan[ch].ADSRX.EnvelopeVol += RateTable[
-					(s_chan[ch].ADSRX.AttackRate^0x7F) - 0x10 + 32];
-
-			if(s_chan[ch].ADSRX.EnvelopeVol < 0)
-			{
-				s_chan[ch].ADSRX.EnvelopeVol = 0x7FFFFFFF;
-				s_chan[ch].ADSRX.State = 1;
-			}
-
-			s_chan[ch].ADSRX.lVolume = s_chan[ch].ADSRX.EnvelopeVol >> 21;
-			return s_chan[ch].ADSRX.lVolume;
-		}
-
-		// decay
-		if(s_chan[ch].ADSRX.State == 1)
-		{
-			switch((s_chan[ch].ADSRX.EnvelopeVol >> 28) & 0x07)
-			{
-				case 0:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 0 + 32];
-					break;
-
-				case 1:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 4 + 32];
-					break;
-
-				case 2:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 6 + 32];
-					break;
-
-				case 3:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 8 + 32];
-					break;
-
-				case 4:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 9 + 32];
-					break;
-
-				case 5:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 10 + 32];
-					break;
-
-				case 6:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 11 + 32];
-					break;
-
-				case 7:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 12 + 32];
-					break;
-			}
-
-			if(s_chan[ch].ADSRX.EnvelopeVol < 0)
-				s_chan[ch].ADSRX.EnvelopeVol = 0;
-
-			if(((s_chan[ch].ADSRX.EnvelopeVol >> 27) & 0xF) <=
-					s_chan[ch].ADSRX.SustainLevel)
-				s_chan[ch].ADSRX.State = 2;
-
-			s_chan[ch].ADSRX.lVolume = s_chan[ch].ADSRX.EnvelopeVol >> 21;
-			return s_chan[ch].ADSRX.lVolume;
-		}
-
-		// sustain
-		if(s_chan[ch].ADSRX.State == 2)
-		{
-			if(s_chan[ch].ADSRX.SustainIncrease)
-			{
-				if(s_chan[ch].ADSRX.SustainModeExp)
-				{
-					if(s_chan[ch].ADSRX.EnvelopeVol < 0x60000000)
-						s_chan[ch].ADSRX.EnvelopeVol += RateTable[
-							(s_chan[ch].ADSRX.SustainRate^0x7F) - 0x10 + 32];
-					else
-						s_chan[ch].ADSRX.EnvelopeVol += RateTable[
-							(s_chan[ch].ADSRX.SustainRate^0x7F) - 0x18 + 32];
-				}
-				else
-					s_chan[ch].ADSRX.EnvelopeVol += RateTable[
-						(s_chan[ch].ADSRX.SustainRate^0x7F) - 0x10 + 32];
-
-				if(s_chan[ch].ADSRX.EnvelopeVol < 0)
-					s_chan[ch].ADSRX.EnvelopeVol = 0x7FFFFFFF;
-			}
-			else
-			{
-				if(s_chan[ch].ADSRX.SustainModeExp)
-				{
-					switch((s_chan[ch].ADSRX.EnvelopeVol >> 28) & 0x7)
-					{
-						case 0:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 0 + 32];
-							break;
-
-						case 1:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 4 + 32];
-							break;
-
-						case 2:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 6 + 32];
-							break;
-
-						case 3:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 8 + 32];
-							break;
-
-						case 4:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 9 + 32];
-							break;
-
-						case 5:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 10 + 32];
-							break;
-
-						case 6:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 11 + 32];
-							break;
-
-						case 7:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 12 + 32];
-							break;
-					}
-				}
-				else
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-						((s_chan[ch].ADSRX.SustainRate^0x7F)) - 0x0F + 32];
-
-				if(s_chan[ch].ADSRX.EnvelopeVol < 0)
-					s_chan[ch].ADSRX.EnvelopeVol = 0;
-			}
-
-			s_chan[ch].ADSRX.lVolume = s_chan[ch].ADSRX.EnvelopeVol >> 21;
-			return s_chan[ch].ADSRX.lVolume;
-		}
-	}
-
-	return 0;
-}
-
-unsigned short SPUreadDMA()
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "SPUreadDMA()" << std::endl;
-#endif
-
-	unsigned short s = spuMem[spuAddr >> 1];
-	spuAddr += 2;
-	if(spuAddr > 0x7ffff)
-		spuAddr = 0;
-
-	iWatchDog = 0;
-
-	return s;
-}
-
-
-void SPUreadDMAMem(unsigned short *pusPSXMem, int iSize)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "SPUreadDMAMem()" << std::endl;
-#endif
-
-	int i;
-
-	for(i = 0; i < iSize; i++)
-	{
-		// spu addr got by writeregister
-		*pusPSXMem++ = spuMem[spuAddr >> 1];
-		// inc spu addr
-		spuAddr += 2;
-		// wrap
-		if(spuAddr > 0x7ffff)
-			spuAddr = 0;
-	}
-
-	iWatchDog = 0;
-}
-
-
-// to investigate: do sound data updates by writedma affect spu
-// irqs? Will an irq be triggered, if new data is written to
-// the memory irq address?
-
-void SPUwriteDMA(unsigned short val)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "SPUwriteDMA()" << std::endl;
-#endif
-
-	// spu addr got by writeregister
-	spuMem[spuAddr >> 1] = val;
-
-	// inc spu addr
-	spuAddr += 2;
-	// wrap
-	if(spuAddr > 0x7ffff)
-		spuAddr = 0;
-
-	iWatchDog = 0;
-}
-
-
-
-void SPUwriteDMAMem(unsigned short *pusPSXMem, int iSize)
-{
-    int i;
-
-    for ( i = 0; i < iSize; i++ )
-    {
-        // spu addr got by writeregister
-        spuMem[spuAddr >> 1] = *pusPSXMem++;
-        // inc spu addr
-        spuAddr += 2;
-        // wrap
-        if(spuAddr > 0x7ffff)
-        {
-            spuAddr = 0;
-        }
-    }
-
-    iWatchDog = 0;
-}
-
-
-const int gauss[] =
-{
-	0x172, 0x519, 0x176, 0x000, 0x16E, 0x519, 0x17A, 0x000,
-	0x16A, 0x518, 0x17D, 0x000, 0x166, 0x518, 0x181, 0x000,
-	0x162, 0x518, 0x185, 0x000, 0x15F, 0x518, 0x189, 0x000,
-	0x15B, 0x518, 0x18D, 0x000, 0x157, 0x517, 0x191, 0x000,
-	0x153, 0x517, 0x195, 0x000, 0x150, 0x517, 0x19A, 0x000,
-	0x14C, 0x516, 0x19E, 0x000, 0x148, 0x516, 0x1A2, 0x000,
-	0x145, 0x515, 0x1A6, 0x000, 0x141, 0x514, 0x1AA, 0x000,
-	0x13E, 0x514, 0x1AE, 0x000, 0x13A, 0x513, 0x1B2, 0x000,
-	0x137, 0x512, 0x1B7, 0x001, 0x133, 0x511, 0x1BB, 0x001,
-	0x130, 0x511, 0x1BF, 0x001, 0x12C, 0x510, 0x1C3, 0x001,
-	0x129, 0x50F, 0x1C8, 0x001, 0x125, 0x50E, 0x1CC, 0x001,
-	0x122, 0x50D, 0x1D0, 0x001, 0x11E, 0x50C, 0x1D5, 0x001,
-	0x11B, 0x50B, 0x1D9, 0x001, 0x118, 0x50A, 0x1DD, 0x001,
-	0x114, 0x508, 0x1E2, 0x001, 0x111, 0x507, 0x1E6, 0x002,
-	0x10E, 0x506, 0x1EB, 0x002, 0x10B, 0x504, 0x1EF, 0x002,
-	0x107, 0x503, 0x1F3, 0x002, 0x104, 0x502, 0x1F8, 0x002,
-	0x101, 0x500, 0x1FC, 0x002, 0x0FE, 0x4FF, 0x201, 0x002,
-	0x0FB, 0x4FD, 0x205, 0x003, 0x0F8, 0x4FB, 0x20A, 0x003,
-	0x0F5, 0x4FA, 0x20F, 0x003, 0x0F2, 0x4F8, 0x213, 0x003,
-	0x0EF, 0x4F6, 0x218, 0x003, 0x0EC, 0x4F5, 0x21C, 0x004,
-	0x0E9, 0x4F3, 0x221, 0x004, 0x0E6, 0x4F1, 0x226, 0x004,
-	0x0E3, 0x4EF, 0x22A, 0x004, 0x0E0, 0x4ED, 0x22F, 0x004,
-	0x0DD, 0x4EB, 0x233, 0x005, 0x0DA, 0x4E9, 0x238, 0x005,
-	0x0D7, 0x4E7, 0x23D, 0x005, 0x0D4, 0x4E5, 0x241, 0x005,
-	0x0D2, 0x4E3, 0x246, 0x006, 0x0CF, 0x4E0, 0x24B, 0x006,
-	0x0CC, 0x4DE, 0x250, 0x006, 0x0C9, 0x4DC, 0x254, 0x006,
-	0x0C7, 0x4D9, 0x259, 0x007, 0x0C4, 0x4D7, 0x25E, 0x007,
-	0x0C1, 0x4D5, 0x263, 0x007, 0x0BF, 0x4D2, 0x267, 0x008,
-	0x0BC, 0x4D0, 0x26C, 0x008, 0x0BA, 0x4CD, 0x271, 0x008,
-	0x0B7, 0x4CB, 0x276, 0x009, 0x0B4, 0x4C8, 0x27B, 0x009,
-	0x0B2, 0x4C5, 0x280, 0x009, 0x0AF, 0x4C3, 0x284, 0x00A,
-	0x0AD, 0x4C0, 0x289, 0x00A, 0x0AB, 0x4BD, 0x28E, 0x00A,
-	0x0A8, 0x4BA, 0x293, 0x00B, 0x0A6, 0x4B7, 0x298, 0x00B,
-	0x0A3, 0x4B5, 0x29D, 0x00B, 0x0A1, 0x4B2, 0x2A2, 0x00C,
-	0x09F, 0x4AF, 0x2A6, 0x00C, 0x09C, 0x4AC, 0x2AB, 0x00D,
-	0x09A, 0x4A9, 0x2B0, 0x00D, 0x098, 0x4A6, 0x2B5, 0x00E,
-	0x096, 0x4A2, 0x2BA, 0x00E, 0x093, 0x49F, 0x2BF, 0x00F,
-	0x091, 0x49C, 0x2C4, 0x00F, 0x08F, 0x499, 0x2C9, 0x00F,
-	0x08D, 0x496, 0x2CE, 0x010, 0x08B, 0x492, 0x2D3, 0x010,
-	0x089, 0x48F, 0x2D8, 0x011, 0x086, 0x48C, 0x2DC, 0x011,
-	0x084, 0x488, 0x2E1, 0x012, 0x082, 0x485, 0x2E6, 0x013,
-	0x080, 0x481, 0x2EB, 0x013, 0x07E, 0x47E, 0x2F0, 0x014,
-	0x07C, 0x47A, 0x2F5, 0x014, 0x07A, 0x477, 0x2FA, 0x015,
-	0x078, 0x473, 0x2FF, 0x015, 0x076, 0x470, 0x304, 0x016,
-	0x075, 0x46C, 0x309, 0x017, 0x073, 0x468, 0x30E, 0x017,
-	0x071, 0x465, 0x313, 0x018, 0x06F, 0x461, 0x318, 0x018,
-	0x06D, 0x45D, 0x31D, 0x019, 0x06B, 0x459, 0x322, 0x01A,
-	0x06A, 0x455, 0x326, 0x01B, 0x068, 0x452, 0x32B, 0x01B,
-	0x066, 0x44E, 0x330, 0x01C, 0x064, 0x44A, 0x335, 0x01D,
-	0x063, 0x446, 0x33A, 0x01D, 0x061, 0x442, 0x33F, 0x01E,
-	0x05F, 0x43E, 0x344, 0x01F, 0x05E, 0x43A, 0x349, 0x020,
-	0x05C, 0x436, 0x34E, 0x020, 0x05A, 0x432, 0x353, 0x021,
-	0x059, 0x42E, 0x357, 0x022, 0x057, 0x42A, 0x35C, 0x023,
-	0x056, 0x425, 0x361, 0x024, 0x054, 0x421, 0x366, 0x024,
-	0x053, 0x41D, 0x36B, 0x025, 0x051, 0x419, 0x370, 0x026,
-	0x050, 0x415, 0x374, 0x027, 0x04E, 0x410, 0x379, 0x028,
-	0x04D, 0x40C, 0x37E, 0x029, 0x04C, 0x408, 0x383, 0x02A,
-	0x04A, 0x403, 0x388, 0x02B, 0x049, 0x3FF, 0x38C, 0x02C,
-	0x047, 0x3FB, 0x391, 0x02D, 0x046, 0x3F6, 0x396, 0x02E,
-	0x045, 0x3F2, 0x39B, 0x02F, 0x043, 0x3ED, 0x39F, 0x030,
-	0x042, 0x3E9, 0x3A4, 0x031, 0x041, 0x3E5, 0x3A9, 0x032,
-	0x040, 0x3E0, 0x3AD, 0x033, 0x03E, 0x3DC, 0x3B2, 0x034,
-	0x03D, 0x3D7, 0x3B7, 0x035, 0x03C, 0x3D2, 0x3BB, 0x036,
-	0x03B, 0x3CE, 0x3C0, 0x037, 0x03A, 0x3C9, 0x3C5, 0x038,
-	0x038, 0x3C5, 0x3C9, 0x03A, 0x037, 0x3C0, 0x3CE, 0x03B,
-	0x036, 0x3BB, 0x3D2, 0x03C, 0x035, 0x3B7, 0x3D7, 0x03D,
-	0x034, 0x3B2, 0x3DC, 0x03E, 0x033, 0x3AD, 0x3E0, 0x040,
-	0x032, 0x3A9, 0x3E5, 0x041, 0x031, 0x3A4, 0x3E9, 0x042,
-	0x030, 0x39F, 0x3ED, 0x043, 0x02F, 0x39B, 0x3F2, 0x045,
-	0x02E, 0x396, 0x3F6, 0x046, 0x02D, 0x391, 0x3FB, 0x047,
-	0x02C, 0x38C, 0x3FF, 0x049, 0x02B, 0x388, 0x403, 0x04A,
-	0x02A, 0x383, 0x408, 0x04C, 0x029, 0x37E, 0x40C, 0x04D,
-	0x028, 0x379, 0x410, 0x04E, 0x027, 0x374, 0x415, 0x050,
-	0x026, 0x370, 0x419, 0x051, 0x025, 0x36B, 0x41D, 0x053,
-	0x024, 0x366, 0x421, 0x054, 0x024, 0x361, 0x425, 0x056,
-	0x023, 0x35C, 0x42A, 0x057, 0x022, 0x357, 0x42E, 0x059,
-	0x021, 0x353, 0x432, 0x05A, 0x020, 0x34E, 0x436, 0x05C,
-	0x020, 0x349, 0x43A, 0x05E, 0x01F, 0x344, 0x43E, 0x05F,
-	0x01E, 0x33F, 0x442, 0x061, 0x01D, 0x33A, 0x446, 0x063,
-	0x01D, 0x335, 0x44A, 0x064, 0x01C, 0x330, 0x44E, 0x066,
-	0x01B, 0x32B, 0x452, 0x068, 0x01B, 0x326, 0x455, 0x06A,
-	0x01A, 0x322, 0x459, 0x06B, 0x019, 0x31D, 0x45D, 0x06D,
-	0x018, 0x318, 0x461, 0x06F, 0x018, 0x313, 0x465, 0x071,
-	0x017, 0x30E, 0x468, 0x073, 0x017, 0x309, 0x46C, 0x075,
-	0x016, 0x304, 0x470, 0x076, 0x015, 0x2FF, 0x473, 0x078,
-	0x015, 0x2FA, 0x477, 0x07A, 0x014, 0x2F5, 0x47A, 0x07C,
-	0x014, 0x2F0, 0x47E, 0x07E, 0x013, 0x2EB, 0x481, 0x080,
-	0x013, 0x2E6, 0x485, 0x082, 0x012, 0x2E1, 0x488, 0x084,
-	0x011, 0x2DC, 0x48C, 0x086, 0x011, 0x2D8, 0x48F, 0x089,
-	0x010, 0x2D3, 0x492, 0x08B, 0x010, 0x2CE, 0x496, 0x08D,
-	0x00F, 0x2C9, 0x499, 0x08F, 0x00F, 0x2C4, 0x49C, 0x091,
-	0x00F, 0x2BF, 0x49F, 0x093, 0x00E, 0x2BA, 0x4A2, 0x096,
-	0x00E, 0x2B5, 0x4A6, 0x098, 0x00D, 0x2B0, 0x4A9, 0x09A,
-	0x00D, 0x2AB, 0x4AC, 0x09C, 0x00C, 0x2A6, 0x4AF, 0x09F,
-	0x00C, 0x2A2, 0x4B2, 0x0A1, 0x00B, 0x29D, 0x4B5, 0x0A3,
-	0x00B, 0x298, 0x4B7, 0x0A6, 0x00B, 0x293, 0x4BA, 0x0A8,
-	0x00A, 0x28E, 0x4BD, 0x0AB, 0x00A, 0x289, 0x4C0, 0x0AD,
-	0x00A, 0x284, 0x4C3, 0x0AF, 0x009, 0x280, 0x4C5, 0x0B2,
-	0x009, 0x27B, 0x4C8, 0x0B4, 0x009, 0x276, 0x4CB, 0x0B7,
-	0x008, 0x271, 0x4CD, 0x0BA, 0x008, 0x26C, 0x4D0, 0x0BC,
-	0x008, 0x267, 0x4D2, 0x0BF, 0x007, 0x263, 0x4D5, 0x0C1,
-	0x007, 0x25E, 0x4D7, 0x0C4, 0x007, 0x259, 0x4D9, 0x0C7,
-	0x006, 0x254, 0x4DC, 0x0C9, 0x006, 0x250, 0x4DE, 0x0CC,
-	0x006, 0x24B, 0x4E0, 0x0CF, 0x006, 0x246, 0x4E3, 0x0D2,
-	0x005, 0x241, 0x4E5, 0x0D4, 0x005, 0x23D, 0x4E7, 0x0D7,
-	0x005, 0x238, 0x4E9, 0x0DA, 0x005, 0x233, 0x4EB, 0x0DD,
-	0x004, 0x22F, 0x4ED, 0x0E0, 0x004, 0x22A, 0x4EF, 0x0E3,
-	0x004, 0x226, 0x4F1, 0x0E6, 0x004, 0x221, 0x4F3, 0x0E9,
-	0x004, 0x21C, 0x4F5, 0x0EC, 0x003, 0x218, 0x4F6, 0x0EF,
-	0x003, 0x213, 0x4F8, 0x0F2, 0x003, 0x20F, 0x4FA, 0x0F5,
-	0x003, 0x20A, 0x4FB, 0x0F8, 0x003, 0x205, 0x4FD, 0x0FB,
-	0x002, 0x201, 0x4FF, 0x0FE, 0x002, 0x1FC, 0x500, 0x101,
-	0x002, 0x1F8, 0x502, 0x104, 0x002, 0x1F3, 0x503, 0x107,
-	0x002, 0x1EF, 0x504, 0x10B, 0x002, 0x1EB, 0x506, 0x10E,
-	0x002, 0x1E6, 0x507, 0x111, 0x001, 0x1E2, 0x508, 0x114,
-	0x001, 0x1DD, 0x50A, 0x118, 0x001, 0x1D9, 0x50B, 0x11B,
-	0x001, 0x1D5, 0x50C, 0x11E, 0x001, 0x1D0, 0x50D, 0x122,
-	0x001, 0x1CC, 0x50E, 0x125, 0x001, 0x1C8, 0x50F, 0x129,
-	0x001, 0x1C3, 0x510, 0x12C, 0x001, 0x1BF, 0x511, 0x130,
-	0x001, 0x1BB, 0x511, 0x133, 0x001, 0x1B7, 0x512, 0x137,
-	0x000, 0x1B2, 0x513, 0x13A, 0x000, 0x1AE, 0x514, 0x13E,
-	0x000, 0x1AA, 0x514, 0x141, 0x000, 0x1A6, 0x515, 0x145,
-	0x000, 0x1A2, 0x516, 0x148, 0x000, 0x19E, 0x516, 0x14C,
-	0x000, 0x19A, 0x517, 0x150, 0x000, 0x195, 0x517, 0x153,
-	0x000, 0x191, 0x517, 0x157, 0x000, 0x18D, 0x518, 0x15B,
-	0x000, 0x189, 0x518, 0x15F, 0x000, 0x185, 0x518, 0x162,
-	0x000, 0x181, 0x518, 0x166, 0x000, 0x17D, 0x518, 0x16A,
-	0x000, 0x17A, 0x519, 0x16E, 0x000, 0x176, 0x519, 0x172
-};
-
-void SPUwriteRegister(unsigned long reg, unsigned short val)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << setfill('0');
-	std::cout << "*** SPUwriteRegister() " << "[address 0x"
-	   << hex << setw(8) << reg << "] ";
-#endif
-
-	const unsigned long r = reg & 0xfff;
-	regArea[(r - 0xc00) >> 1] = val;
-
-	// some channel info?
-	if(r >= 0x0c00 && r < 0x0d80)
-	{
-		// calc channel
-		int ch = (r >> 4) - 0xc0;
-
-		switch(r & 0x0f)
-		{
-			// l volume
-			case 0:
-#ifdef DEBUG_OUTPUT
-				std::cout << "Left Volume - ";
-#endif
-
-				SetVolumeL((unsigned char)ch, val);
-				break;
-
-			// r volume
-			case 2:
-#ifdef DEBUG_OUTPUT
-				std::cout << "Right Volume - ";
-#endif
-
-				SetVolumeR((unsigned char)ch, val);
-				break;
-
-			// pitch
-			case 4:
-#ifdef DEBUG_OUTPUT
-				std::cout << "Pitch - ";
-#endif
-
-				SetPitch(ch, val);
-				break;
-
-			// start
-			case 6:
-#ifdef DEBUG_OUTPUT
-				std::cout << "Start Address - ";
-#endif
-				s_chan[ch].pStart = spuMemC + ((unsigned long)val << 3);
-				break;
-
-			// level with pre-calcs
-			case 8:
-#ifdef DEBUG_OUTPUT
-				std::cout << "Level with Pre-Calcs - ";
-#endif
-
-				{
-					const unsigned long lval = val;
-
-					s_chan[ch].ADSRX.AttackModeExp=(lval&0x8000)?1:0;
-					s_chan[ch].ADSRX.AttackRate=(lval>>8) & 0x007f;
-					s_chan[ch].ADSRX.DecayRate=(lval>>4) & 0x000f;
-					s_chan[ch].ADSRX.SustainLevel=lval & 0x000f;
-				}
-				break;
-
-			// adsr times with pre-calcs
-			case 10:
-#ifdef DEBUG_OUTPUT
-				std::cout << "ADSR Times with Pre-Calcs - ";
-#endif
-
-				{
-					const unsigned long lval = val;
-
-					s_chan[ch].ADSRX.SustainModeExp = (lval & 0x8000) ? 1 : 0;
-					s_chan[ch].ADSRX.SustainIncrease = (lval & 0x4000) ? 0 : 1;
-					s_chan[ch].ADSRX.SustainRate = (lval >> 6) & 0x007f;
-					s_chan[ch].ADSRX.ReleaseModeExp = (lval & 0x0020) ? 1 : 0;
-					s_chan[ch].ADSRX.ReleaseRate = lval & 0x001f;
-				}
-				break;
-
-			// adsr volume... mmm have to investigate this
-			case 12:
-#ifdef DEBUG_OUTPUT
-				std::cout << "ADSR Volume - ";
-#endif
-				break;
-
-			// loop
-			case 14:
-#ifdef DEBUG_OUTPUT
-				std::cout << "Loop Address - ";
-#endif
-				s_chan[ch].pLoop = spuMemC + ((unsigned long)val << 3);
-				s_chan[ch].bIgnoreLoop = 1;
-				break;
-		}
-
-		iWatchDog = 0;
-
-#ifdef DEBUG_OUTPUT
-		std::cout << "0x" << hex << setw(4) << val << std::endl;
-#endif
-
-		return;
-	}
-
-	switch(r)
-	{
-		case H_SPUaddr:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUaddr - ";
-#endif
-			spuAddr = (unsigned long)val << 3;
-			break;
-
-		case H_SPUdata:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUdata - ";
-#endif
-			spuMem[spuAddr >> 1] = val;
-			spuAddr += 2;
-			if(spuAddr > 0x7ffff)
-				spuAddr = 0;
-			break;
-
-		case H_SPUctrl:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUctrl - ";
-#endif
-			spuCtrl = val;
-			break;
-
-		case H_SPUstat:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUstat - ";
-#endif
-			spuStat = val & 0xf800;
-			break;
-
-		case H_SPUReverbAddr:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUReverbAddr - ";
-#endif
-			if(val == 0xFFFF || val <= 0x200)
-				rvb.StartAddr = rvb.CurrAddr = 0;
-			else
-			{
-				const long iv = (unsigned long)val << 2;
-				if(rvb.StartAddr != iv)
-				{
-					rvb.StartAddr = (unsigned long)val << 2;
-					rvb.CurrAddr = rvb.StartAddr;
-				}
-			}
-			break;
-
-		case H_SPUirqAddr:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUirqAddr - ";
-#endif
-			spuIrq = val;
-			pSpuIrq = spuMemC + ((unsigned long) val << 3);
-			break;
-
-		case H_SPUrvolL:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUrvolL - ";
-#endif
-			rvb.VolLeft = val;
-			break;
-
-		case H_SPUrvolR:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUrvolR - ";
-#endif
-			rvb.VolRight = val;
-			break;
-
-		case H_SPUon1:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUon1 - ";
-#endif
-			SoundOn(0, 16, val);
-			break;
-
-		case H_SPUon2:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUon2 - ";
-#endif
-			SoundOn(16, 24, val);
-			break;
-
-		case H_SPUoff1:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUoff1 - ";
-#endif
-			SoundOff(0, 16, val);
-			break;
-
-		case H_SPUoff2:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUoff2 - ";
-#endif
-			SoundOff(16, 24, val);
-			break;
-
-		case H_CDLeft:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_CDLeft - ";
-#endif
-			iLeftXAVol = val & 0x7fff;
-			if(cddavCallback)
-				cddavCallback(0, val);
-			break;
-
-		case H_CDRight:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_CDRight - ";
-#endif
-			iRightXAVol = val & 0x7fff;
-			if(cddavCallback)
-				cddavCallback(1, val);
-			break;
-
-		case H_FMod1:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_FMod1 - ";
-#endif
-			FModOn(0, 16, val);
-			break;
-
-		case H_FMod2:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_FMod2 - ";
-#endif
-			FModOn(16, 24, val);
-			break;
-
-		case H_Noise1:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_Noise1 - ";
-#endif
-			NoiseOn(0, 16, val);
-			break;
-
-		case H_Noise2:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_Noise2 - ";
-#endif
-			NoiseOn(16, 24, val);
-			break;
-
-		case H_RVBon1:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_RVBon1 - ";
-#endif
-			ReverbOn(0, 16, val);
-			break;
-
-		case H_RVBon2:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_RVBon2 - ";
-#endif
-			ReverbOn(16, 24, val);
-			break;
-
-		case H_Reverb + 0:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_Reverb - ";
-#endif
-			rvb.FB_SRC_A = val;
-
-			// OK, here's the fake REVERB stuff...
-			// depending on effect we do more or less delay and repeats... bah
-			// still... better than nothing :)
-
-			SetREVERB(val);
-			break;
-
-
-		case H_Reverb+2   : rvb.FB_SRC_B=(short)val;       break;
-		case H_Reverb+4   : rvb.IIR_ALPHA=(short)val;      break;
-		case H_Reverb+6   : rvb.ACC_COEF_A=(short)val;     break;
-		case H_Reverb+8   : rvb.ACC_COEF_B=(short)val;     break;
-		case H_Reverb+10  : rvb.ACC_COEF_C=(short)val;     break;
-		case H_Reverb+12  : rvb.ACC_COEF_D=(short)val;     break;
-		case H_Reverb+14  : rvb.IIR_COEF=(short)val;       break;
-		case H_Reverb+16  : rvb.FB_ALPHA=(short)val;       break;
-		case H_Reverb+18  : rvb.FB_X=(short)val;           break;
-		case H_Reverb+20  : rvb.IIR_DEST_A0=(short)val;    break;
-		case H_Reverb+22  : rvb.IIR_DEST_A1=(short)val;    break;
-		case H_Reverb+24  : rvb.ACC_SRC_A0=(short)val;     break;
-		case H_Reverb+26  : rvb.ACC_SRC_A1=(short)val;     break;
-		case H_Reverb+28  : rvb.ACC_SRC_B0=(short)val;     break;
-		case H_Reverb+30  : rvb.ACC_SRC_B1=(short)val;     break;
-		case H_Reverb+32  : rvb.IIR_SRC_A0=(short)val;     break;
-		case H_Reverb+34  : rvb.IIR_SRC_A1=(short)val;     break;
-		case H_Reverb+36  : rvb.IIR_DEST_B0=(short)val;    break;
-		case H_Reverb+38  : rvb.IIR_DEST_B1=(short)val;    break;
-		case H_Reverb+40  : rvb.ACC_SRC_C0=(short)val;     break;
-		case H_Reverb+42  : rvb.ACC_SRC_C1=(short)val;     break;
-		case H_Reverb+44  : rvb.ACC_SRC_D0=(short)val;     break;
-		case H_Reverb+46  : rvb.ACC_SRC_D1=(short)val;     break;
-		case H_Reverb+48  : rvb.IIR_SRC_B1=(short)val;     break;
-		case H_Reverb+50  : rvb.IIR_SRC_B0=(short)val;     break;
-		case H_Reverb+52  : rvb.MIX_DEST_A0=(short)val;    break;
-		case H_Reverb+54  : rvb.MIX_DEST_A1=(short)val;    break;
-		case H_Reverb+56  : rvb.MIX_DEST_B0=(short)val;    break;
-		case H_Reverb+58  : rvb.MIX_DEST_B1=(short)val;    break;
-		case H_Reverb+60  : rvb.IN_COEF_L=(short)val;      break;
-		case H_Reverb+62  : rvb.IN_COEF_R=(short)val;      break;
-	}
-
-	iWatchDog = 0;
-
-#ifdef DEBUG_OUTPUT
-	std::cout << "0x" << hex << setw(4) << val << std::endl;
-#endif
-}
-
-
-
-unsigned short SPUreadRegister(unsigned long reg)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << setfill('0');
-	std::cout << "*** SPUreadRegister(0x" << hex << setw(8) << reg << "), returned ";
-#endif
-
-	const unsigned long r = reg & 0xfff;
-
-	iWatchDog = 0;
-
-	if(r >= 0x0c00 && r < 0x0d80)
-	{
-		switch(r & 0x0f)
-		{
-			// get adsr vol
-			case 12:
-				{
-					const int ch = (r >> 4) - 0xc0;
-
-					// we are started, but not processed? return 1
-					if(s_chan[ch].bNew)
-					{
-#ifdef DEBUG_OUTPUT
-						std::cout << "0x" << hex << setw(4) << 1 << std::endl;
-#endif
-						return 1;
-					}
-
-					// same here... we haven't decoded one sample
-					// yet, so no envelope yet. return 1 as well
-					if(s_chan[ch].ADSRX.lVolume &&
-						!s_chan[ch].ADSRX.EnvelopeVol)
-					{
-#ifdef DEBUG_OUTPUT
-						std::cout << "0x" << hex << setw(4) << 1 << std::endl;
-#endif
-						return 1;
-					}
-
-#ifdef DEBUG_OUTPUT
-					std::cout << "0x" << hex << setw(4)
-						<< (unsigned short)(s_chan[ch].ADSRX.EnvelopeVol >> 16)
-						<< std::endl;
-#endif
-					return (unsigned short)(s_chan[ch].ADSRX.EnvelopeVol >> 16);
-				}
-
-			// get loop address
-			case 14:
-				{
-					const int ch = (r >> 4) - 0xc0;
-					if(s_chan[ch].pLoop == NULL)
-					{
-#ifdef DEBUG_OUTPUT
-						std::cout << "0x" << hex << setw(4) << 0 << std::endl;
-#endif
-						return 0;
-					}
-
-#ifdef DEBUG_OUTPUT
-					std::cout << "0x" << hex << setw(4)
-						<< (unsigned short)((s_chan[ch].pLoop - spuMemC) >> 3)
-						<< std::endl;
-#endif
-					return (unsigned short)((s_chan[ch].pLoop - spuMemC) >> 3);
-				}
-		}
-	}
-
-	switch(r)
-	{
-		case H_SPUctrl:
-#ifdef DEBUG_OUTPUT
-			std::cout << "0x" << hex << setw(4) << spuCtrl << std::endl;
-#endif
-			return spuCtrl;
-
-		case H_SPUstat:
-#ifdef DEBUG_OUTPUT
-			std::cout << "0x" << hex << setw(4) << spuStat << std::endl;
-#endif
-			return spuStat;
-
-		case H_SPUaddr:
-#ifdef DEBUG_OUTPUT
-			std::cout << "0x" << hex
-				<< setw(4) << (unsigned short)(spuAddr >> 3) << std::endl;
-#endif
-			return (unsigned short)(spuAddr >> 3);
-
-		case H_SPUdata:
-			{
-				unsigned short s = spuMem[spuAddr >> 1];
-				spuAddr += 2;
-				if(spuAddr > 0x7ffff)
-					spuAddr = 0;
-
-#ifdef DEBUG_OUTPUT
-				std::cout << "0x" << hex << setw(4) << s << std::endl;
-#endif
-				return s;
-			}
-
-		case H_SPUirqAddr:
-#ifdef DEBUG_OUTPUT
-			std::cout << "0x" << hex << setw(4) << spuIrq << std::endl;
-#endif
-			return spuIrq;
-	}
-
-#ifdef DEBUG_OUTPUT
-	std::cout << "0x" << hex << setw(4) << regArea[(r - 0xc00) >> 1] << std::endl;
-#endif
-	return regArea[(r - 0xc00) >> 1];
-}
-
-
-void SoundOn(int start, int end, unsigned short val)
-{
-	int ch;
-
-	// loop channels
-	for(ch = start; ch < end; ch++, val >>= 1)
-	{
-		if((val & 1) && s_chan[ch].pStart)
-		// mmm... start has to be set before key on !?!
-
-		{
-			s_chan[ch].bIgnoreLoop = 0;
-			s_chan[ch].bNew = 1;
-
-			// bitfield for faster testing
-			dwNewChannel |= (1 << ch);
-		}
-	}
-}
-
-
-void SoundOff(int start, int end, unsigned short val)
-{
-	int ch;
-
-	// loop channels
-	for(ch = start; ch < end; ch++, val >>= 1)
-	{
-		if(val & 1) // && s_chan[i].bOn)  mmm...
-			s_chan[ch].bStop = 1;
-	}
-}
-
-
-void FModOn(int start, int end, unsigned short val)
-{
-	int ch;
-
-	// loop channels
-	for(ch = start; ch < end; ch++, val >>= 1)
-	{
-		// fmod on/off
-		if(val & 1)
-		{
-			if(ch > 0)
-			{
-				// sound channel
-				s_chan[ch].bFMod = 1;
-
-				// freq channel
-				s_chan[ch - 1].bFMod = 2;
-			}
-		}
-		else
-			s_chan[ch].bFMod = 0;
-	}
-}
-
-
-void NoiseOn(int start, int end, unsigned short val)
-{
-	int ch;
-
-	// loop channels
-	for(ch = start; ch < end; ch++, val >>= 1)
-	{
-		// noise on/off
-		if(val & 1)
-		{
-			s_chan[ch].bNoise = 1;
-		}
-		else
-		{
-			s_chan[ch].bNoise = 0;
-		}
-	}
-}
-
-
-// please note: sweep and phase invert are wrong... but I've never seen
-// them used
-void SetVolumeL(unsigned char ch, short vol)
-{
-	s_chan[ch].iLeftVolRaw = vol;
-
-	// sweep
-	if(vol & 0x8000)
-	{
-		short sInc = 1;
-		if(vol & 0x2000)
-			sInc = -1;
-
-		// -> mmm... phase inverted? have to investigate this
-		if(vol & 0x1000)
-			vol ^= 0xffff;
-
-		// -> sweep: 0..127 -> 0..64
-		vol = ((vol & 0x7f) + 1) / 2;
-
-		// -> HACK: we don't sweep right now, so we
-		// just raise/lower the volume by the half!
-		vol += vol / (2 * sInc);
-		vol *= 128;
-	}
-
-	// no sweep
-	else
-	{
-		// -> mmm... phase inverted? have to investigate this
-		if(vol & 0x4000)
-			vol = 0x3fff - (vol & 0x3fff);
-	}
-
-	vol &= 0x3fff;
-
-	// store volume
-	s_chan[ch].iLeftVolume = vol;
-}
-
-void SetVolumeR(unsigned char ch, short vol)
-{
-	s_chan[ch].iRightVolRaw = vol;
-
-	// comments... see above :)
-	if(vol & 0x8000)
-	{
-		short sInc = 1;
-		if(vol & 0x2000)
-			sInc = -1;
-		if(vol & 0x1000)
-			vol ^= 0xffff;
-		vol = ((vol & 0x7f) + 1) / 2;
-		vol += vol / (2 * sInc);
-		vol *= 128;
-	}
-	else
-	{
-		if(vol & 0x4000)
-			vol = 0x3fff - (vol & 0x3fff);
-	}
-
-	vol &= 0x3fff;
-	s_chan[ch].iRightVolume = vol;
-}
-
-
-void SetPitch(int ch, unsigned short val)
-{
-	int NP;
-	if(val > 0x3fff)
-		NP = 0x3fff;
-	else
-		NP = val;
-
-	s_chan[ch].iRawPitch = NP;
-
-	NP = (44100L * NP) / 4096L;
-	if(NP < 1)
-		NP = 1;
-
-	s_chan[ch].iActFreq = NP;
-}
-
-
-void ReverbOn(int start, int end, unsigned short val)
-{
-	int ch;
-
-	// loop channels
-	for(ch = start; ch < end; ch++, val >>= 1)
-	{
-		// reverb on/off
-		if(val & 1)
-			s_chan[ch].bReverb = 1;
-		else
-			s_chan[ch].bReverb = 0;
-	}
-}
-void SetREVERB(unsigned short val)
-{
-	switch(val)
-	{
-		// off
-		case 0x0000:
-			iReverbOff = -1;
-			break;
-
-		// ok room
-		case 0x007D:
-			iReverbOff = 32;
-			iReverbNum = 2;
-			iReverbRepeat = 128;
-			break;
-
-		// studio small
-		case 0x0033:
-			iReverbOff = 32;
-			iReverbNum = 2;
-			iReverbRepeat = 64;
-			break;
-
-		// ok studio medium
-		case 0x00B1:
-			iReverbOff = 48;
-			iReverbNum = 2;
-			iReverbRepeat = 96;
-			break;
-
-		// ok studio large ok
-		case 0x00E3:
-			iReverbOff = 64;
-			iReverbNum = 2;
-			iReverbRepeat = 128;
-			break;
-
-		// ok hall
-		case 0x01A5:
-			iReverbOff = 128;
-			iReverbNum = 4;
-			iReverbRepeat = 32;
-			break;
-
-		// space echo
-		case 0x033D:
-			iReverbOff = 256;
-			iReverbNum = 4;
-			iReverbRepeat = 64;
-			break;
-
-		// echo/delay
-		case 0x0001:
-			iReverbOff = 184;
-			iReverbNum = 3;
-			iReverbRepeat = 128;
-			break;
-
-		// half echo
-		case 0x0017:
-			iReverbOff = 128;
-			iReverbNum = 2;
-			iReverbRepeat = 128;
-			break;
-
-		default:
-			iReverbOff = 32;
-			iReverbNum = 1;
-			iReverbRepeat = 0;
-			break;
-	}
-}
-
-
-void StartREVERB(int ch)
-{
-	// reverb possible?
-	if(s_chan[ch].bReverb && (spuCtrl & 0x80))
-	{
-		if(iUseReverb == 2)
-			s_chan[ch].bRVBActive = 1;
-		else
-			// fake reverb used?
-			if(iUseReverb == 1 && iReverbOff > 0)
-			{
-				// activate it
-				s_chan[ch].bRVBActive = 1;
-				s_chan[ch].iRVBOffset = iReverbOff * 45;
-				s_chan[ch].iRVBRepeat = iReverbRepeat * 45;
-				s_chan[ch].iRVBNum = iReverbNum;
-			}
-	}
-	else
-		// no reverb
-		s_chan[ch].bRVBActive = 0;
-}
-
-
-void InitREVERB()
-{
-	if(iUseReverb == 2)
-		memset(sRVBStart, 0, NSSIZE * 2 * 4);
-}
-
-
-void StoreREVERB(int ch, int ns)
-{
-	if(iUseReverb == 0)
-		return;
-
-	// Neil's reverb
-	if(iUseReverb == 2)
-	{
-		const int iRxl =
-			(s_chan[ch].sval * s_chan[ch].iLeftVolume) / 0x4000;
-		const int iRxr =
-			(s_chan[ch].sval * s_chan[ch].iRightVolume) / 0x4000;
-
-		ns <<= 1;
-
-		// -> we mix all active reverb channels into an extra buffer
-		*(sRVBStart + ns) += iRxl;
-		*(sRVBStart + ns + 1) += iRxr;
-	}
-
-	// Pete's easy fake reverb
-	else
-	{
-		int *pN;
-		int iRn, iRr = 0;
-
-		// we use the half channel volume (/0x8000) for the
-		// first reverb effects, quarter for next and so on
-		int iRxl =
-			(s_chan[ch].sval * s_chan[ch].iLeftVolume) / 0x8000;
-		int iRxr =
-			(s_chan[ch].sval * s_chan[ch].iRightVolume) / 0x8000;
-
-		for(iRn = 1; iRn <= s_chan[ch].iRVBNum;
-				iRn++, iRr += s_chan[ch].iRVBRepeat,iRxl /= 2, iRxr /= 2)
-		{
-			pN = sRVBPlay + ((s_chan[ch].iRVBOffset + iRr + ns) << 1);
-			if(pN >= sRVBEnd)
-				pN = sRVBStart + (pN - sRVBEnd);
-
-			(*pN) += iRxl;
-			pN++;
-			(*pN) += iRxr;
-		}
-	}
-}
-
-
-// get_buffer content helper: takes care about wraps
-int g_buffer(int iOff)
-{
-	short *p = (short *)spuMem;
-	iOff = (iOff * 4) + rvb.CurrAddr;
-	while(iOff > 0x3FFFF)
-		iOff = rvb.StartAddr + (iOff - 0x40000);
-	while(iOff < rvb.StartAddr)
-		iOff = 0x3ffff - (rvb.StartAddr - iOff);
-
-	return (int)*(p + iOff);
-}
-
-
-// set_buffer content helper: takes care about wraps and clipping
-void s_buffer(int iOff, int iVal)
-{
-	short *p = (short *)spuMem;
-	iOff = (iOff * 4) + rvb.CurrAddr;
-	while(iOff > 0x3FFFF)
-		iOff = rvb.StartAddr + (iOff - 0x40000);
-	while(iOff < rvb.StartAddr)
-		iOff = 0x3ffff - (rvb.StartAddr - iOff);
-	if(iVal < -32768L)
-		iVal = -32768L;
-	if(iVal > 32767L)
-		iVal = 32767L;
-
-	*(p + iOff) = (short)iVal;
-}
-
-
-// set_buffer (+1 sample) content helper: takes care about wraps and clipping
-void s_buffer1(int iOff, int iVal)
-{
-	short *p = (short *)spuMem;
-	iOff = (iOff * 4) + rvb.CurrAddr + 1;
-	while(iOff > 0x3FFFF)
-		iOff = rvb.StartAddr + (iOff - 0x40000);
-	while(iOff < rvb.StartAddr)
-		iOff = 0x3ffff - (rvb.StartAddr - iOff);
-	if(iVal < -32768L)
-		iVal = -32768L;
-	if(iVal > 32767L)
-		iVal = 32767L;
-
-	*(p + iOff) = (short)iVal;
-}
-
-
-int MixREVERBLeft(int ns)
-{
-	if(iUseReverb == 0)
-		return 0;
-
-	if(iUseReverb == 2)
-	{
-		// this func will be called with 44.1 khz
-		static int iCnt = 0;
-
-		// reverb is off
-		if(!rvb.StartAddr)
-		{
-			rvb.iLastRVBLeft = rvb.iLastRVBRight =
-				rvb.iRVBLeft = rvb.iRVBRight = 0;
-
-			return 0;
-		}
-
-		iCnt++;
-
-		// we work on every second left value: downsample to 22 khz
-		if(iCnt & 1)
-		{
-			// -> reverb on? oki
-			if(spuCtrl & 0x80)
-			{
-				int ACC0, ACC1, FB_A0, FB_A1, FB_B0, FB_B1;
-
-				const int INPUT_SAMPLE_L = *(sRVBStart + (ns << 1));
-				const int INPUT_SAMPLE_R = *(sRVBStart + (ns << 1) + 1);
-
-				const int IIR_INPUT_A0 =
-					(g_buffer(rvb.IIR_SRC_A0) * rvb.IIR_COEF) / 32768L +
-					(INPUT_SAMPLE_L * rvb.IN_COEF_L) / 32768L;
-				const int IIR_INPUT_A1 =
-					(g_buffer(rvb.IIR_SRC_A1) * rvb.IIR_COEF) / 32768L +
-					(INPUT_SAMPLE_R * rvb.IN_COEF_R) / 32768L;
-				const int IIR_INPUT_B0 =
-					(g_buffer(rvb.IIR_SRC_B0) * rvb.IIR_COEF) / 32768L +
-					(INPUT_SAMPLE_L * rvb.IN_COEF_L) / 32768L;
-				const int IIR_INPUT_B1 =
-					(g_buffer(rvb.IIR_SRC_B1) * rvb.IIR_COEF) / 32768L +
-					(INPUT_SAMPLE_R * rvb.IN_COEF_R) / 32768L;
-
-				const int IIR_A0 = (IIR_INPUT_A0 * rvb.IIR_ALPHA) / 32768L +
-					(g_buffer(rvb.IIR_DEST_A0) *
-					 (32768L - rvb.IIR_ALPHA)) / 32768L;
-				const int IIR_A1 = (IIR_INPUT_A1 * rvb.IIR_ALPHA) / 32768L +
-					(g_buffer(rvb.IIR_DEST_A1) *
-					 (32768L - rvb.IIR_ALPHA)) / 32768L;
-				const int IIR_B0 = (IIR_INPUT_B0 * rvb.IIR_ALPHA) / 32768L +
-					(g_buffer(rvb.IIR_DEST_B0) *
-					 (32768L - rvb.IIR_ALPHA)) / 32768L;
-				const int IIR_B1 = (IIR_INPUT_B1 * rvb.IIR_ALPHA) / 32768L +
-					(g_buffer(rvb.IIR_DEST_B1) *
-					 (32768L - rvb.IIR_ALPHA)) / 32768L;
-
-				s_buffer1(rvb.IIR_DEST_A0, IIR_A0);
-				s_buffer1(rvb.IIR_DEST_A1, IIR_A1);
-				s_buffer1(rvb.IIR_DEST_B0, IIR_B0);
-				s_buffer1(rvb.IIR_DEST_B1, IIR_B1);
-
-				ACC0 = (g_buffer(rvb.ACC_SRC_A0) * rvb.ACC_COEF_A) / 32768L +
-					(g_buffer(rvb.ACC_SRC_B0) * rvb.ACC_COEF_B) / 32768L +
-					(g_buffer(rvb.ACC_SRC_C0) * rvb.ACC_COEF_C) / 32768L +
-					(g_buffer(rvb.ACC_SRC_D0) * rvb.ACC_COEF_D) / 32768L;
-				ACC1 = (g_buffer(rvb.ACC_SRC_A1) * rvb.ACC_COEF_A) / 32768L +
-					(g_buffer(rvb.ACC_SRC_B1) * rvb.ACC_COEF_B) / 32768L +
-					(g_buffer(rvb.ACC_SRC_C1) * rvb.ACC_COEF_C) / 32768L +
-					(g_buffer(rvb.ACC_SRC_D1) * rvb.ACC_COEF_D) / 32768L;
-
-				FB_A0 = g_buffer(rvb.MIX_DEST_A0 - rvb.FB_SRC_A);
-				FB_A1 = g_buffer(rvb.MIX_DEST_A1 - rvb.FB_SRC_A);
-				FB_B0 = g_buffer(rvb.MIX_DEST_B0 - rvb.FB_SRC_B);
-				FB_B1 = g_buffer(rvb.MIX_DEST_B1 - rvb.FB_SRC_B);
-
-				s_buffer(rvb.MIX_DEST_A0,
-					ACC0 - (FB_A0 * rvb.FB_ALPHA) / 32768L);
-				s_buffer(rvb.MIX_DEST_A1,
-					ACC1 - (FB_A1 * rvb.FB_ALPHA) / 32768L);
-
-				s_buffer(rvb.MIX_DEST_B0, (rvb.FB_ALPHA * ACC0) / 32768L -
-					(FB_A0 * (int)(rvb.FB_ALPHA ^ 0xFFFF8000)) / 32768L -
-					(FB_B0 * rvb.FB_X) / 32768L);
-				s_buffer(rvb.MIX_DEST_B1, (rvb.FB_ALPHA * ACC1) / 32768L -
-					(FB_A1 * (int)(rvb.FB_ALPHA ^ 0xFFFF8000)) / 32768L -
-					(FB_B1 * rvb.FB_X) / 32768L);
-
-				rvb.iLastRVBLeft  = rvb.iRVBLeft;
-				rvb.iLastRVBRight = rvb.iRVBRight;
-
-				rvb.iRVBLeft =
-					(g_buffer(rvb.MIX_DEST_A0) + g_buffer(rvb.MIX_DEST_B0)) / 3;
-				rvb.iRVBRight =
-					(g_buffer(rvb.MIX_DEST_A1) + g_buffer(rvb.MIX_DEST_B1)) / 3;
-
-				rvb.iRVBLeft = (rvb.iRVBLeft * rvb.VolLeft) / 0x4000;
-				rvb.iRVBRight = (rvb.iRVBRight * rvb.VolRight) / 0x4000;
-
-				rvb.CurrAddr++;
-				if(rvb.CurrAddr > 0x3ffff)
-					rvb.CurrAddr = rvb.StartAddr;
-
-				return rvb.iLastRVBLeft + (rvb.iRVBLeft-rvb.iLastRVBLeft) / 2;
-			}
-			// reverb off
-			else
-				rvb.iLastRVBLeft = rvb.iLastRVBRight =
-					rvb.iRVBLeft = rvb.iRVBRight = 0;
-
-			rvb.CurrAddr++;
-			if(rvb.CurrAddr > 0x3ffff)
-				rvb.CurrAddr = rvb.StartAddr;
-		}
-
-		return rvb.iLastRVBLeft;
-	}
-	// easy fake reverb
-	else
-	{
-		// -> simply take the reverb mix buf value
-		const int iRV = *sRVBPlay;
-		// -> init it after
-		*sRVBPlay++ = 0;
-		// -> and take care about wrap arounds
-		if(sRVBPlay >= sRVBEnd)
-			sRVBPlay = sRVBStart;
-
-		// -> return reverb buf mix val
-		return iRV;
-	}
-}
-
-
-int MixREVERBRight()
-{
-	if(iUseReverb == 0)
-		return 0;
-
-	// Neill's reverb
-	if(iUseReverb == 2)
-	{
-		int i = rvb.iLastRVBRight + (rvb.iRVBRight - rvb.iLastRVBRight) / 2;
-		rvb.iLastRVBRight = rvb.iRVBRight;
-
-		// -> just return the last right reverb val
-		// (little bit scaled by the previous right val)
-		return i;
-	}
-	// easy fake reverb
-	else
-	{
-		// -> simply take the reverb mix buf value
-		const int iRV = *sRVBPlay;
-		// -> init it after
-		*sRVBPlay++ = 0;
-		// -> and take care about wrap arounds
-		if(sRVBPlay >= sRVBEnd)
-			sRVBPlay = sRVBStart;
-
-		// -> return reverb mix buf val
-		return iRV;
-	}
-}
-
-
-void MixXA()
-{
-	int ns;
-
-	for(ns = 0; ns < NSSIZE && XAPlay != XAFeed; ns++)
-	{
-		XALastVal = *XAPlay++;
-		if(XAPlay == XAEnd)
-			XAPlay = XAStart;
-		SSumL[ns] += (((short)(XALastVal & 0xffff)) * iLeftXAVol) / 32767;
-		SSumR[ns] += (((short)((XALastVal >> 16) & 0xffff)) *
-			iRightXAVol) / 32767;
-	}
-
-	if(XAPlay == XAFeed && XARepeat)
-	{
-		XARepeat--;
-		for(;ns < NSSIZE; ns++)
-		{
-			SSumL[ns] += (((short)(XALastVal & 0xffff)) * iLeftXAVol) / 32767;
-			SSumR[ns] += (((short)((XALastVal >> 16) & 0xffff)) *
-				iRightXAVol) / 32767;
-		}
-	}
-}
-
-
-void FeedXA(xa_decode_t *xap)
-{
-#ifdef VGears_SOUND
-	int sinc, spos, i, iSize, iPlace, vl, vr;
-
-	if(!bSPUIsOpen)
-		return;
-
-	// store info for save states
-	xapGlobal = xap;
-	// set up repeat
-	XARepeat  = 100;
-
-	// get size
-	iSize = ((44100 * xap->nsamples) / xap->freq);
-
-	// if none
-	if(!iSize)
-		return;
-
-	// how much space in my buf?
-	if(XAFeed < XAPlay)
-		iPlace = XAPlay - XAFeed;
-	else
-		iPlace = (XAEnd - XAFeed) + (XAPlay - XAStart);
-
-	// no place at all
-	if(iPlace == 0)
-		return;
-
-	// pitch change option
-	if(iXAPitch)
-	{
-		static unsigned long dwLT = 0;
-		static unsigned long dwFPS = 0;
-		static int   iFPSCnt = 0;
-		static int   iLastSize = 0;
-		static unsigned long dwL1 = 0;
-		unsigned long dw, dw1, dw2;
-
-//G		dw = timeGetTime_spu();
-		dw = GGetTime();
-
-		iPlace = iSize;
-
-		dwFPS += dw - dwLT;
-		iFPSCnt++;
-
-		dwLT = dw;
-
-		if(iFPSCnt >= 10)
-		{
-			if(!dwFPS)
-				dwFPS = 1;
-			dw1 = 1000000 / dwFPS;
-			if(dw1 >= (dwL1 - 100) && dw1 <= (dwL1 + 100))
-				dw1 = dwL1;
-			else
-				dwL1 = dw1;
-			dw2 = (xap->freq * 100 / xap->nsamples);
-			if((!dw1) || ((dw2 + 100) >= dw1))
-				iLastSize = 0;
-			else
-			{
-				iLastSize = iSize * dw2 / dw1;
-				if(iLastSize > iPlace)
-					iLastSize = iPlace;
-				iSize = iLastSize;
-			}
-			iFPSCnt = 0;
-			dwFPS = 0;
-		}
-		else
-		{
-			if(iLastSize)
-				iSize = iLastSize;
-		}
-	}
-
-	spos = 0x10000L;
-	// calc freq by num / size
-	sinc = (xap->nsamples << 16) / iSize;
-
-	if(xap->stereo)
-	{
-		u32 * pS = (u32 *)xap->pcm;
-		u32 l = 0;
-
-		if(iXAPitch)
-		{
-			int32_t l1, l2;
-			short s;
-			for(i = 0; i < iSize; i++)
-			{
-				if(iUseInterpolation == 2)
-				{
-					while(spos >= 0x10000L)
-					{
-						l = *pS++;
-						gauss_window[gauss_ptr] = (short)LOWORD(l);
-						gauss_window[4 + gauss_ptr] = (short)HIWORD(l);
-						gauss_ptr = (gauss_ptr + 1) & 3;
-						spos -= 0x10000L;
-					}
-					vl = (spos >> 6) & ~3;
-					vr = (gauss[vl]*gvall0) & ~2047;
-					vr += (gauss[vl + 1] * gvall(1)) & ~2047;
-					vr += (gauss[vl + 2] * gvall(2)) & ~2047;
-					vr += (gauss[vl + 3] * gvall(3)) & ~2047;
-					l= (vr >> 11) & 0xffff;
-					vr = (gauss[vl] * gvalr0) & ~2047;
-					vr += (gauss[vl + 1] * gvalr(1)) & ~2047;
-					vr += (gauss[vl + 2] * gvalr(2)) & ~2047;
-					vr += (gauss[vl + 3] * gvalr(3)) & ~2047;
-					l |= vr << 5;
-				}
-				else
-				{
-					while(spos >= 0x10000L)
-					{
-						l = *pS++;
-						spos -= 0x10000L;
-					}
-				}
-
-				s = (short)LOWORD(l);
-				l1 = s;
-				l1 = (l1 * iPlace) / iSize;
-				if(l1 < -32767)
-					l1 = -32767;
-				if(l1 > 32767)
-					l1 = 32767;
-				s = (short)HIWORD(l);
-				l2 = s;
-				l2 = (l2 * iPlace) / iSize;
-				if(l2 < -32767)
-					l2 = -32767;
-				if(l2 > 32767)
-					l2 = 32767;
-				l = (l1 & 0xffff)|(l2 << 16);
-
-				*XAFeed++ = l;
-
-				if(XAFeed == XAEnd)
-					XAFeed = XAStart;
-				if(XAFeed == XAPlay)
-				{
-					if(XAPlay != XAStart)
-						XAFeed = XAPlay - 1;
-					break;
-				}
-
-				spos += sinc;
-			}
-		}
-		else
-		{
-			for(i = 0; i < iSize; i++)
-			{
-				if(iUseInterpolation == 2)
-				{
-					while(spos >= 0x10000L)
-					{
-						l = *pS++;
-						gauss_window[gauss_ptr] = (short)LOWORD(l);
-						gauss_window[4 + gauss_ptr] = (short)HIWORD(l);
-						gauss_ptr = (gauss_ptr + 1) & 3;
-						spos -= 0x10000L;
-					}
-					vl = (spos >> 6) & ~3;
-					vr = (gauss[vl] * gvall0) & ~2047;
-					vr += (gauss[vl + 1] * gvall(1)) & ~2047;
-					vr += (gauss[vl + 2] * gvall(2)) & ~2047;
-					vr += (gauss[vl + 3] * gvall(3)) & ~2047;
-					l = (vr >> 11) & 0xffff;
-					vr = (gauss[vl] * gvalr0) & ~2047;
-					vr += (gauss[vl + 1] * gvalr(1)) & ~2047;
-					vr += (gauss[vl + 2] * gvalr(2)) & ~2047;
-					vr += (gauss[vl + 3] * gvalr(3)) & ~2047;
-					l |= vr << 5;
-				}
-				else
-				{
-					while(spos>=0x10000L)
-					{
-						l = *pS++;
-						spos -= 0x10000L;
-					}
-				}
-
-				*XAFeed++ = l;
-
-				if(XAFeed == XAEnd)
-					XAFeed = XAStart;
-				if(XAFeed == XAPlay)
-				{
-					if(XAPlay != XAStart)
-						XAFeed = XAPlay - 1;
-					break;
-				}
-
-				spos += sinc;
-			}
-		}
-	}
-	else
-	{
-		unsigned short * pS = (unsigned short *)xap->pcm;
-		u32 l;
-		short s = 0;
-
-		if(iXAPitch)
-		{
-			int32_t l1;
-			for(i = 0; i < iSize; i++)
-			{
-				if(iUseInterpolation == 2)
-				{
-					while(spos >= 0x10000L)
-					{
-						gauss_window[gauss_ptr] = (short)*pS++;
-						gauss_ptr = (gauss_ptr + 1) & 3;
-						spos -= 0x10000L;
-					}
-					vl = (spos >> 6) & ~3;
-					vr = (gauss[vl] * gvall0) & ~2047;
-					vr += (gauss[vl + 1] * gvall(1)) & ~2047;
-					vr += (gauss[vl + 2] * gvall(2)) & ~2047;
-					vr += (gauss[vl + 3] * gvall(3)) & ~2047;
-					l1 = s = vr >> 11;
-					l1 &= 0xffff;
-				}
-				else
-				{
-					while(spos >= 0x10000L)
-					{
-						s = *pS++;
-						spos -= 0x10000L;
-					}
-					l1 = s;
-				}
-
-				l1 = (l1 * iPlace) / iSize;
-				if(l1 < -32767)
-					l1 = -32767;
-				if(l1 > 32767)
-					l1 = 32767;
-				l = (l1 & 0xffff) | (l1 << 16);
-				*XAFeed++ = l;
-
-				if(XAFeed == XAEnd)
-					XAFeed = XAStart;
-				if(XAFeed == XAPlay)
-				{
-					if(XAPlay != XAStart)
-						XAFeed = XAPlay - 1;
-					break;
-				}
-
-				spos += sinc;
-			}
-		}
-		else
-		{
-			for(i = 0; i < iSize; i++)
-			{
-				if(iUseInterpolation == 2)
-				{
-					while(spos >= 0x10000L)
-					{
-						gauss_window[gauss_ptr] = (short)*pS++;
-						gauss_ptr = (gauss_ptr + 1) & 3;
-						spos -= 0x10000L;
-					}
-					vl = (spos >> 6) & ~3;
-					vr = (gauss[vl] * gvall0) & ~2047;
-					vr += (gauss[vl + 1] * gvall(1)) & ~2047;
-					vr += (gauss[vl + 2] * gvall(2)) & ~2047;
-					vr += (gauss[vl + 3] * gvall(3)) & ~2047;
-					l= s = vr >> 11;
-					l &= 0xffff;
-				}
-				else
-				{
-					while(spos >= 0x10000L)
-					{
-						s = *pS++;
-						spos -= 0x10000L;
-					}
-					l = s;
-				}
-
-				*XAFeed++ = (l | (l << 16));
-
-				if(XAFeed == XAEnd)
-					XAFeed = XAStart;
-				if(XAFeed == XAPlay)
-				{
-					if(XAPlay != XAStart)
-						XAFeed = XAPlay - 1;
-					break;
-				}
-
-				spos += sinc;
-			}
-		}
-	}
-#endif
-}
-
-void InterpolateUp(int ch)
-{
-	if(s_chan[ch].SB[32]==1)                              // flag == 1? calc step and set flag... and don't change the value in this pass
-	{
-		const int id1=s_chan[ch].SB[30]-s_chan[ch].SB[29];  // curr delta to next val
-		const int id2=s_chan[ch].SB[31]-s_chan[ch].SB[30];  // and next delta to next-next val :)
-
-		s_chan[ch].SB[32]=0;
-
-		if(id1>0)                                           // curr delta positive
-		{
-			if(id2<id1)
-			{s_chan[ch].SB[28]=id1;s_chan[ch].SB[32]=2;}
-			else
-				if(id2<(id1<<1))
-					s_chan[ch].SB[28]=(id1*s_chan[ch].sinc)/0x10000L;
-				else
-					s_chan[ch].SB[28]=(id1*s_chan[ch].sinc)/0x20000L;
-		}
-		else                                                // curr delta negative
-		{
-			if(id2>id1)
-			{s_chan[ch].SB[28]=id1;s_chan[ch].SB[32]=2;}
-			else
-				if(id2>(id1<<1))
-					s_chan[ch].SB[28]=(id1*s_chan[ch].sinc)/0x10000L;
-				else
-					s_chan[ch].SB[28]=(id1*s_chan[ch].sinc)/0x20000L;
-		}
-	}
-	else
-		if(s_chan[ch].SB[32]==2)                              // flag 1: calc step and set flag... and don't change the value in this pass
-		{
-			s_chan[ch].SB[32]=0;
-
-			s_chan[ch].SB[28]=(s_chan[ch].SB[28]*s_chan[ch].sinc)/0x20000L;
-			if(s_chan[ch].sinc<=0x8000)
-				s_chan[ch].SB[29]=s_chan[ch].SB[30]-(s_chan[ch].SB[28]*((0x10000/s_chan[ch].sinc)-1));
-			else s_chan[ch].SB[29]+=s_chan[ch].SB[28];
-		}
-		else                                                  // no flags? add bigger val (if possible), calc smaller step, set flag1
-			s_chan[ch].SB[29]+=s_chan[ch].SB[28];
-}
-
-//
-// even easier interpolation on downsampling, also no special filter, again just "Pete's common sense" tm
-//
-
-void InterpolateDown(int ch)
-{
-	if(s_chan[ch].sinc>=0x20000L)                                 // we would skip at least one val?
-	{
-		s_chan[ch].SB[29]+=(s_chan[ch].SB[30]-s_chan[ch].SB[29])/2; // add easy weight
-		if(s_chan[ch].sinc>=0x30000L)                               // we would skip even more vals?
-			s_chan[ch].SB[29]+=(s_chan[ch].SB[31]-s_chan[ch].SB[30])/2;// add additional next weight
-	}
-}
-
-////////////////////////////////////////////////////////////////////////
-// helpers for gauss interpolation
-
-#define gval0 (((short*)(&s_chan[ch].SB[29]))[gpos])
-#define gval(x) (((short*)(&s_chan[ch].SB[29]))[(gpos+x)&3])
-
-//#include "gauss_i.h"
-
-////////////////////////////////////////////////////////////////////////
-
-//#include "xa.c"
-
-////////////////////////////////////////////////////////////////////////
-// START SOUND... called by main thread to setup a new sound on a channel
-////////////////////////////////////////////////////////////////////////
-
-void StartSound(int ch)
-{
-	StartADSR(ch);
-	StartREVERB(ch);
-
-	s_chan[ch].pCurr=s_chan[ch].pStart;                   // set sample start
-
-	s_chan[ch].s_1=0;                                     // init mixing vars
-	s_chan[ch].s_2=0;
-	s_chan[ch].iSBPos=28;
-
-	s_chan[ch].bNew=0;                                    // init channel flags
-	s_chan[ch].bStop=0;
-	s_chan[ch].bOn=1;
-
-	s_chan[ch].SB[29]=0;                                  // init our interpolation helpers
-	s_chan[ch].SB[30]=0;
-
-	if(iUseInterpolation>=2)                              // gauss interpolation?
-	{s_chan[ch].spos=0x30000L;s_chan[ch].SB[28]=0;}  // -> start with more decoding
-	else {s_chan[ch].spos=0x10000L;s_chan[ch].SB[31]=0;}  // -> no/simple interpolation starts with one 44100 decoding
-
-	dwNewChannel&=~(1<<ch);                               // clear new channel bit
-}
-
-////////////////////////////////////////////////////////////////////////
-// MAIN SPU FUNCTION
-// here is the main job handler... thread, timer or direct func call
-// basically the whole sound processing is done in this fat func!
-////////////////////////////////////////////////////////////////////////
-
-// 5 ms waiting phase, if buffer is full and no new sound has to get started
-// .. can be made smaller (smallest val: 1 ms), but bigger waits give
-// better performance
-
-#define PAUSE_W 5
-#define PAUSE_L 5000
-
-////////////////////////////////////////////////////////////////////////
-
-static void *MAINThread(void *arg)
-{
-//	std::cout << "!!!!!!!!!!!!!!!!!!!TEST!!!!!!!!!!!!!!!!!!" << std::endl;
-	int s_1, s_2;
-	int fa;
-	int ns;
-	int voldiv = iVolume;
-	unsigned char *start;
-	unsigned int nSample;
-	int ch, predict_nr, shift_factor, flags, d, s;
-	int gpos, bIRQReturn = 0;
-
-	// until we are shutting down
-	while(!bEndThread)
-	{
-		// ok, at the beginning we are looking if there is
-		// enuff free place in the dsound/oss buffer to
-		// fill in new data, or if there is a new channel to start.
-		// if not, we wait (thread) or return (timer/spuasync)
-		// until enuff free place is available/a new channel gets
-		// started
-
-		// new channel should start immedately?
-		// (at least one bit 0 ... MAXCHANNEL is set?)
-		if(dwNewChannel)
-		{
-			// set iSecure
-			// (if it is set 5 times - that means on 5 tries a new samples
-			// has been started - in a row, we will reset it, to give the
-			// sound update a chance)
-			iSecureStart++;
-			if(iSecureStart > 5)
-				iSecureStart = 0;
-		}
-		// 0: no new channel
-		else
-			iSecureStart = 0;
-
-		// no new start? no thread end? and still enough data in sound buffer?
-		while(!iSecureStart && !bEndThread &&
-			(SBE->GetBytesBuffered() > TESTSIZE))
-		{
-			// reset secure
-			iSecureStart = 0;
-
-			// linux no-thread mode? bye
-			if(iUseTimer)
-				return 0;
-
-			// else sleep for x ms (linux)
-
-#ifndef _MSC_VER
-			usleep(PAUSE_L);
-#else
-			Sleep(PAUSE_L);
-#endif
-
-//			SDL_Delay(PAUSE_L);
-			if(dwNewChannel)
-			// if a new channel kicks in (or, of course,
-			// sound buffer runs low), we will leave the loop
-				iSecureStart = 1;
-		}
-
-		// continue from irq handling in timer mode?
-		// will be -1 if no continue is pending
-		if(lastch >= 0)
-		{
-			// -> setup all kind of vars to continue
-			ch = lastch;
-			ns = lastns;
-			lastch = -1;
-
-			// -> directly jump to the continue point
-			goto GOON;
-		}
-
-
-
-		{
-			// loop em all... we will collect 1 ms
-			// of sound of each playing channel
-			for(ch = 0; ch < MAXCHAN; ch++)
-			{
-				// start new channel
-				if(s_chan[ch].bNew)
-					StartSound(ch);
-
-				// channel not playing? - next
-				if(!s_chan[ch].bOn)
-					continue;
-
-				// new psx frequency?
-				if(s_chan[ch].iActFreq != s_chan[ch].iUsedFreq)
-				{
-					// take int and calc steps
-					s_chan[ch].iUsedFreq = s_chan[ch].iActFreq;
-					s_chan[ch].sinc = s_chan[ch].iRawPitch << 4;
-					if(!s_chan[ch].sinc)
-						s_chan[ch].sinc = 1;
-
-					// freq change in simple interpolation mode [set flag]
-					if(iUseInterpolation == 1)
-						s_chan[ch].SB[32] = 1;
-				}
-
-				// loop until 1 ms of data is reached
-				ns = 0;
-				while(ns < NSSIZE)
-				{
-					while(s_chan[ch].spos >= 0x10000L)
-					{
-						// 28 reached
-						if(s_chan[ch].iSBPos == 28)
-						{
-							// set up the current pos
-							start = s_chan[ch].pCurr;
-
-							// special "stop" sign
-							if (start == (unsigned char *)-1)
-							{
-								// turn everything off
-								s_chan[ch].bOn = 0;
-								s_chan[ch].ADSRX.lVolume = 0;
-								s_chan[ch].ADSRX.EnvelopeVol = 0;
-
-								// and done for this channel
-								goto ENDX;
-							}
-
-							s_chan[ch].iSBPos = 0;
-
-							// spu irq handler here? mmm... do it later
-
-							s_1 = s_chan[ch].s_1;
-							s_2 = s_chan[ch].s_2;
-
-							predict_nr = (int)*start;
-							start++;
-							shift_factor = predict_nr & 0xf;
-							predict_nr >>= 4;
-							flags=(int)*start;
-							start++;
-
-							for (nSample = 0; nSample < 28; start++)
-							{
-								d = (int)*start;
-								s = ((d & 0xf) << 12);
-								if(s & 0x8000)
-									s |= 0xffff0000;
-
-								fa = (s >> shift_factor);
-								fa = fa + ((s_1 * f[predict_nr][0]) >> 6) +
-									((s_2 * f[predict_nr][1]) >> 6);
-								s_2 = s_1;
-								s_1 = fa;
-								s = ((d & 0xf0) << 8);
-
-								s_chan[ch].SB[nSample++] = fa;
-
-								if(s & 0x8000)
-									s |= 0xffff0000;
-								fa = (s >> shift_factor);
-								fa = fa + ((s_1 * f[predict_nr][0]) >> 6) +
-									((s_2 * f[predict_nr][1]) >> 6);
-								s_2 = s_1;
-								s_1 = fa;
-
-								s_chan[ch].SB[nSample++] = fa;
-							}
-
-							// irq check? mmm...
-
-							// some callbacks and irq active?
-							if(irqCallback && (spuCtrl & 0x40))
-							{
-								// irq address reached? &
-								// special: irq on looping addr,
-								// when stop/loop flag is set
-								if((pSpuIrq > start - 16 && pSpuIrq <= start)
-									||
-									((flags & 1) &&
-									(pSpuIrq >  s_chan[ch].pLoop - 16 &&
-									pSpuIrq <= s_chan[ch].pLoop)))
-								{
-									// debug flag
-									s_chan[ch].iIrqDone = 1;
-									// call main emu
-									irqCallback();
-
-									// option: wait after irq for main emu
-									if(iSPUIRQWait)
-									{
-										unsigned long dwWatchTime;
-
-										if(iUseTimer == 2)
-											bIRQReturn = 1;
-										else
-										{
-//											dwWatchTime = timeGetTime_spu() +
-//												2500;
-											dwWatchTime = GGetTime() +
-												2500;
-											iWatchDog = 1;
-											while(iWatchDog && !bEndThread &&
-												GGetTime() < dwWatchTime)
-#ifndef _MSC_VER
-			usleep(10);
-#else
-			Sleep(10);
-#endif
-
-//												SDL_Delay(1000L);
-										}
-									}
-								}
-							}
-
-							// flag handler
-
-							// loop address
-							if((flags & 4) && (!s_chan[ch].bIgnoreLoop))
-								s_chan[ch].pLoop = start - 16;
-
-							// stop loop
-							if(flags & 1)
-							{
-								// PETE: if we don't check exactly for 3,
-								// loop hang ups will happen (DQ4, for example)
-								if(flags != 3 || s_chan[ch].pLoop == NULL)
-								{
-									// and checking if pLoop is
-									// set avoids crashes, yeah
-									start = (unsigned char *)-1;
-								}
-								else
-								{
-									start = s_chan[ch].pLoop;
-								}
-							}
-
-							// store values for next cycle
-							s_chan[ch].pCurr = start;
-							s_chan[ch].s_1 = s_1;
-							s_chan[ch].s_2 = s_2;
-
-							// special return for
-							// "spu irq - wait for cpu action"
-							if(bIRQReturn)
-							{
-								bIRQReturn = 0;
-								lastch = ch;
-								lastns = ns;
-								return 0;
-							}
-GOON:
-							;
-						}
-
-						// get sample data
-						fa = s_chan[ch].SB[s_chan[ch].iSBPos++];
-
-						// muted?
-						if((spuCtrl & 0x4000) == 0)
-							fa = 0;
-						// else adjust
-						else
-						{
-							if(fa > 32767L)
-								fa = 32767L;
-							if(fa < -32767L)
-								fa = -32767L;
-						}
-
-						// gauss/cubic interpolation
-						if(iUseInterpolation >= 2)
-						{
-							gpos = s_chan[ch].SB[28];
-							gval0 = fa;
-							gpos = (gpos + 1) & 3;
-							s_chan[ch].SB[28] = gpos;
-						}
-						// simple interpolation
-						else if(iUseInterpolation == 1)
-						{
-							s_chan[ch].SB[28] = 0;
-							// helpers for simple linear interpolation:
-							// delay real val for two slots, and calc
-							// the two deltas, for a
-							// 'look at the future behaviour'
-							s_chan[ch].SB[29] = s_chan[ch].SB[30];
-
-							s_chan[ch].SB[30] = s_chan[ch].SB[31];
-							s_chan[ch].SB[31] = fa;
-							// flag: calc new interpolation
-							s_chan[ch].SB[32] = 1;
-						}
-						// no interpolation
-						else
-							s_chan[ch].SB[29] = fa;
-
-						s_chan[ch].spos -= 0x10000L;
-					}
-
-					// noise handler... just produces some noise data
-					// surely wrong...
-					// and no noise frequency (spuCtrl & 0x3f00) will be used...
-					// and sometimes the noise will be
-					// used as fmod modulation... pfff
-
-					if(s_chan[ch].bNoise)
-					{
-						if((dwNoiseVal <<= 1) & 0x80000000L)
-						{
-							dwNoiseVal ^= 0x0040001L;
-							fa = ((dwNoiseVal >> 2) & 0x7fff);
-							fa = -fa;
-						}
-						else
-							fa = (dwNoiseVal >> 2) & 0x7fff;
-
-						// mmm... depending on the noise freq we allow
-						// bigger/smaller changes to the previous val
-						fa = s_chan[ch].iOldNoise +
-							((fa - s_chan[ch].iOldNoise) /
-							 ((0x001f - ((spuCtrl & 0x3f00) >> 9)) + 1));
-						if(fa > 32767L)
-							fa = 32767L;
-						if(fa < -32767L)
-							fa = -32767L;
-						s_chan[ch].iOldNoise = fa;
-
-						// no gauss/cubic interpolation?
-						if(iUseInterpolation < 2)
-							// store noise val in "current sample slot"
-							s_chan[ch].SB[29] = fa;
-					}
-					// NO NOISE (NORMAL SAMPLE DATA) HERE
-					else
-					{
-						// cubic interpolation
-						if(iUseInterpolation == 3)
-						{
-							long xd;
-							xd = ((s_chan[ch].spos) >> 1) + 1;
-							gpos = s_chan[ch].SB[28];
-
-							fa = gval(3) - 3 * gval(2) + 3 * gval(1) - gval0;
-							fa *= (xd - (2 << 15)) / 6;
-							fa >>= 15;
-							fa += gval(2) - gval(1) - gval(1) + gval0;
-							fa *= (xd - (1 << 15)) >> 1;
-							fa >>= 15;
-							fa += gval(1) - gval0;
-							fa *= xd;
-							fa >>= 15;
-							fa = fa + gval0;
-						}
-						// gauss interpolation
-						else if(iUseInterpolation == 2)
-						{
-							int vl, vr;
-							vl = (s_chan[ch].spos >> 6) & ~3;
-							gpos = s_chan[ch].SB[28];
-							vr = (gauss[vl] * gval0) & ~2047;
-							vr += (gauss[vl + 1] * gval(1)) & ~2047;
-							vr += (gauss[vl + 2] * gval(2)) & ~2047;
-							vr += (gauss[vl + 3] * gval(3)) & ~2047;
-							fa = vr >> 11;
-						}
-						// simple interpolation
-						else if(iUseInterpolation == 1)
-						{
-							// upsampling?
-							if(s_chan[ch].sinc < 0x10000L)
-								InterpolateUp(ch);
-							else
-								InterpolateDown(ch);
-							fa = s_chan[ch].SB[29];
-						}
-						else
-							// no interpolation
-							fa = s_chan[ch].SB[29];
-					}
-
-					// add adsr
-					s_chan[ch].sval = (MixADSR(ch) * fa) / 1023;
-
-					// fmod freq channel
-					if(s_chan[ch].bFMod == 2)
-					{
-						int NP = s_chan[ch+1].iRawPitch;
-
-						NP = ((32768L + s_chan[ch].sval) * NP) / 32768L;
-
-						if(NP > 0x3fff)
-							NP = 0x3fff;
-						if(NP < 0x1)
-							NP = 0x1;
-
-						// mmmm... if I do this, all is screwed
-						// s_chan[ch+1].iRawPitch=NP;
-
-						// calc frequency
-						NP = (44100L * NP) / (4096L);
-
-						s_chan[ch + 1].iActFreq = NP;
-						s_chan[ch + 1].iUsedFreq = NP;
-						s_chan[ch + 1].sinc = (((NP / 10) << 16) / 4410);
-						if(!s_chan[ch + 1].sinc)
-							s_chan[ch + 1].sinc = 1;
-						// freq change in simple interpolation mode
-						if(iUseInterpolation == 1)
-							s_chan[ch + 1].SB[32] = 1;
-
-						// mmmm... set up freq decoding positions?
-						// s_chan[ch+1].iSBPos=28;
-						// s_chan[ch+1].spos=0x10000L;
-					}
-					else
-					{
-						// ok, left/right sound volume
-						// (psx volume goes from 0 ... 0x3fff)
-
-						// debug mute
-						if(s_chan[ch].iMute)
-							s_chan[ch].sval = 0;
-						else
-						{
-							SSumL[ns] += (s_chan[ch].sval *
-								s_chan[ch].iLeftVolume) / 0x4000L;
-							SSumR[ns] += (s_chan[ch].sval *
-								s_chan[ch].iRightVolume) / 0x4000L;
-						}
-
-						// now let us store sound data for reverb
-						if(s_chan[ch].bRVBActive)
-							StoreREVERB(ch, ns);
-					}
-
-					// ok, go on until 1 ms data
-					// of this channel is collected
-
-					ns++;
-					s_chan[ch].spos += s_chan[ch].sinc;
-				} // while(ns < NSSIZE)
-ENDX:
-				;
-			} // for(ch = 0; ch < MAXCHAN; ch++)
-		}
-
-		// here we have another 1 ms of sound data
-
-		// mix XA infos (if any)
-		if(XAPlay != XAFeed || XARepeat)
-			MixXA();
-
-		// mix all channels (including reverb) into one buffer
-/*
-		// no stereo?
-		if(iDisStereo)
-		{
-			int dl, dr;
-			for(ns = 0; ns < NSSIZE; ns++)
-			{
-				SSumL[ns] += MixREVERBLeft(ns);
-
-				dl = SSumL[ns] / voldiv;
-				SSumL[ns] = 0;
-				if(dl < -32767)
-					dl = -32767;
-				if(dl > 32767)
-					dl = 32767;
-
-				SSumR[ns] += MixREVERBRight();
-
-				dr = SSumR[ns] / voldiv;
-				SSumR[ns] = 0;
-				if(dr < -32767)
-					dr = -32767;
-				if(dr > 32767)
-					dr = 32767;
-				*pS++ = (dl + dr) / 2;
-			}
-		}
-		// stereo
-		else
-*/
-			for(ns = 0; ns < NSSIZE; ns++)
-			{
-				SSumL[ns] += MixREVERBLeft(ns);
-
-				d = SSumL[ns] / voldiv;
-				SSumL[ns] = 0;
-				if(d < -32767)
-					d = -32767;
-				if(d > 32767)
-					d = 32767;
-				*pS++ = d;
-
-				SSumR[ns] += MixREVERBRight();
-
-				d = SSumR[ns] / voldiv;
-				SSumR[ns] = 0;
-				if(d < -32767)
-					d = -32767;
-				if(d > 32767)
-					d = 32767;
-				*pS++ = d;
-			}
-
-		InitREVERB();
-
-		// feed the sound
-		// wanna have around 1/60 sec (16.666 ms) updates
-
-		//temp fix: lowered for low latency alsa configs
-		if(iCycle++ > 8)
-		{
-			SBE->FeedStreamData((u8 *)pSpuBuffer,
-					((unsigned char *)pS) -
-					((unsigned char *)pSpuBuffer));
-			pS = (short *)pSpuBuffer;
-			iCycle = 0;
-		}
-	}
-
-	// end of big main loop...
-	bThreadEnded = 1;
-
-	return 0;
-}
-
-
-
-void SPUasync(unsigned long cycle)
-{
-	// clear the watchdog
-	iWatchDog = 0;
-
-	// special mode, only used in Linux by this spu
-	// (or if you enable the experimental Windows mode)
-	if(iUseTimer == 2)
-	{
-		// no init, no call
-		if(!bSpuInit)
-			return;
-
-		// linux high-compat mode
-		MAINThread(0);
-	}
-}
-
-
-
-void SPUupdate(void)
-{
-    SPUasync(0);
-}
-
-
-
-void SPUplayADPCMchannel(xa_decode_t *xap)
-{
-	if(!iUseXA)
-		return;
-	if(!xap)
-		return;
-	if(!xap->freq)
-		return;
-
-	FeedXA(xap);
-}
-
-
-
-long SPUinit(void)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUinit()" << std::endl;
-#endif
-
-	spuMemC = (unsigned char *)spuMem;
-	memset((void *)s_chan, 0, MAXCHAN * sizeof(SPUCHAN));
-	memset((void *)&rvb, 0, sizeof(REVERBInfo));
-	InitADSR();
-	return 0;
-}
-
-
-void SetupTimer(void)
-{
-	// init some mixing buffers
-	memset(SSumR, 0, NSSIZE * sizeof(int));
-	memset(SSumL, 0, NSSIZE * sizeof(int));
-	// setup soundbuffer pointer
-	pS = (short *)pSpuBuffer;
-
-	// init thread vars
-	bEndThread = 0;
-	bThreadEnded = 0;
-	// flag: we are inited
-	bSpuInit = 1;
-}
-
-
-void RemoveTimer(void)
-{
-	// raise flag to end thread
-	bEndThread = 1;
-
-	if(!iUseTimer)
-	{
-		int i = 0;
-		// wait until thread has ended
-		while(!bThreadEnded && i < 2000)
-		{
-#ifndef _MSC_VER
-			usleep(10);
-#else
-			Sleep(10);
-#endif
-//			SDL_Delay(1000L);
-			i++;
-		}
-	}
-
-	// no more spu is running
-	bThreadEnded = 0;
-	bSpuInit = 0;
-}
-
-
-void SetupStreams(void)
-{
-	int i;
-
-	// alloc mixing buffer
-	pSpuBuffer = (unsigned char *)malloc(32768);
-
-	if(iUseReverb == 1)
-		i = 88200 * 2;
-	else
-		i = NSSIZE * 2;
-
-	// alloc reverb buffer
-	sRVBStart = (int *)malloc(i * 4);
-	memset(sRVBStart, 0, i * 4);
-	sRVBEnd = sRVBStart + i;
-	sRVBPlay = sRVBStart;
-
-	// alloc xa buffer
-	XAStart = (u32 *)malloc(44100 * 4);
-	XAPlay = XAStart;
-	XAFeed = XAStart;
-	XAEnd = XAStart + 44100;
-
-	for(i = 0; i < MAXCHAN; i++)
-	{
-		// we don't use mutex sync... not needed, would only
-		// slow us down:
-
-		// init sustain
-		s_chan[i].ADSRX.SustainLevel = 1024;
-		s_chan[i].iMute = 0;
-		s_chan[i].iIrqDone = 0;
-		s_chan[i].pLoop = spuMemC;
-		s_chan[i].pStart = spuMemC;
-		s_chan[i].pCurr = spuMemC;
-	}
-}
-
-
-void RemoveStreams(void)
-{
-	// free mixing buffer
-	free(pSpuBuffer);
-	pSpuBuffer = NULL;
-	// free reverb buffer
-	free(sRVBStart);
-	sRVBStart = 0;
-	// free xa buffer
-	free(XAStart);
-	XAStart = 0;
-}
-
-
-
-long SPUopen(void)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUopen()" << std::endl;
-#endif
-
-	// security for some stupid main emus
-	if(bSPUIsOpen)
-		return 0;
-
-	iUseXA = 1;
-	iVolume = 3;
-	iReverbOff = -1;
-	spuIrq = 0;
-	spuAddr = 0xffffffff;
-	bEndThread = 0;
-	bThreadEnded = 0;
-	spuMemC = (unsigned char *)spuMem;
-	memset((void *)s_chan, 0, (MAXCHAN + 1) * sizeof(SPUCHAN));
-	pSpuIrq = 0;
-	iSPUIRQWait = 1;
-
-	SBE = new SoundBackendSDL();
-
-	// prepare streaming
-	SetupStreams();
-
-	// timer for feeding data
-	SetupTimer();
-
-	bSPUIsOpen = 1;
-
-	return PSE_SPU_ERR_SUCCESS;
-}
-
-
-
-void SPUsetConfigFile(char * pCfg)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUsetConfigFile()" << std::endl;
-#endif
-
-//	pConfigFile = pCfg;
-}
-
-
-
-long SPUclose(void)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUclose()" << std::endl;
-#endif
-
-	// security
-	if(!bSPUIsOpen)
-		return 0;
-
-	bSPUIsOpen = 0;
-	RemoveTimer();
-
-	if(SBE != NULL)
-		delete SBE;
-
-	RemoveStreams();
-
-	return 0;
-}
-
-
-
-long SPUshutdown(void)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUshutdown()" << std::endl;
-#endif
-
-	return 0;
-}
-
-
-
-long SPUtest(void)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUtest()" << std::endl;
-#endif
-
-	return 0;
-}
-
-
-
-long SPUconfigure(void)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUconfigure()" << std::endl;
-#endif
-
-//G	StartCfgTool("CFG");
-	return 0;
-}
-
-
-
-void SPUabout(void)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUabout()" << std::endl;
-#endif
-
-//G	StartCfgTool("ABOUT");
-}
-
-
-
-void SPUregisterCallback(void (*callback)(void))
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUregisterCallback()" << std::endl;
-#endif
-
-	irqCallback = callback;
-}
-
-
-
-void SPUregisterCDDAVolume(void (*CDDAVcallback)(unsigned short,unsigned short))
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUregisterCDDAVolume()" << std::endl;
-#endif
-
-	cddavCallback = CDDAVcallback;
-}
-
-
-
-unsigned short SPUgetOne(unsigned long val)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUgetOne()" << std::endl;
-#endif
-
-	if(spuAddr != 0xffffffff)
-	{
-		return SPUreadDMA();
-	}
-	if(val >= 512 * 1024)
-		val = 512 * 1024 - 1;
-	return spuMem[val >> 1];
-}
-
-
-
-void SPUputOne(unsigned long val, unsigned short data)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUputOne()" << std::endl;
-#endif
-
-	if(spuAddr != 0xffffffff)
-	{
-		SPUwriteDMA(data);
-		return;
-	}
-	if(val >= 512 * 1024)
-		val = 512 * 1024 - 1;
-	spuMem[val >> 1] = data;
-}
-
-
-
-void SPUplaySample(unsigned char ch)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUplaySample()" << std::endl;
-#endif
-}
-
-
-
-void SPUsetAddr(unsigned char ch, unsigned short waddr)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUsetAddr()" << std::endl;
-#endif
-
-	s_chan[ch].pStart = spuMemC + ((unsigned long)waddr << 3);
-}
-
-
-
-void SPUsetPitch(unsigned char ch, unsigned short pitch)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUsetPitch()" << std::endl;
-#endif
-
-	SetPitch(ch, pitch);
-}
-
-
-
-void SPUsetVolumeL(unsigned char ch, short vol)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUsetVolumeL()" << std::endl;
-#endif
-
-	SetVolumeR(ch, vol);
-}
-
-
-
-void SPUsetVolumeR(unsigned char ch, short vol)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUsetVolumeR()" << std::endl;
-#endif
-
-	SetVolumeL(ch, vol);
-}
-
-
-
-void SPUstartChannels1(unsigned short channels)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUstartChannels1()" << std::endl;
-#endif
-
-	SoundOn(0, 16, channels);
-}
-
-
-
-void SPUstartChannels2(unsigned short channels)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUstartChannels2()" << std::endl;
-#endif
-
-	SoundOn(16, 24, channels);
-}
-
-
-
-void SPUstopChannels1(unsigned short channels)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUstopChannels1()" << std::endl;
-#endif
-
-	SoundOff(0, 16, channels);
-}
-
-
-
-void SPUstopChannels2(unsigned short channels)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUstopChannels2()" << std::endl;
-#endif
-
-	SoundOff(16, 24, channels);
-}
-
-
-
-void SPUplaySector(unsigned long mode, unsigned char *p)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUplaySector()\n" << std::endl;
-#endif
-
-	// no XA
-	if(!iUseXA)
-		return;
-}
-
-
-u32 GGetTime()
-{
-#ifndef _MSC_VER
-	// well, maybe there are better ways
-	// to do that, but at least it works
-	struct timeval tv;
-	gettimeofday(&tv, 0);
-
-	return tv.tv_sec * 1000 + tv.tv_usec / 1000;
-#else
-    return ::GetTickCount(); // TODO FIX ME, probably wrong
-#endif
-}
-

+ 0 - 504
utilities/ffix_sound_dumper/src/engine/SoundManager.h

@@ -1,504 +0,0 @@
-/*
- * Main source code was taken from Pete's PSX sound plugin.
- * I plan full source reorganising - want to set more sound
- * engine behaviour
- */
-
-
-
-#ifndef SOUND_MANAGER_H
-#define SOUND_MANAGER_H
-
-
-
-#include "common/TypeDefine.h"
-
-
-
-class SoundManager
-{
-public:
-    SoundManager();
-    virtual ~SoundManager();
-
-    void Update();
-
-    void PsxChannelPlay(u8 arg_channel);
-    void PsxChannelStop(u8 arg_channel);
-    void PsxReverbOn(u8 arg_channel);
-    void PsxSetReverbDepth( u16 arg_left, u16 arg_right );
-
-    enum SpuRateMode
-    {
-        SPU_VOICE_LINEARIncN = 1,
-        SPU_VOICE_LINEARDecN = 3,
-        SPU_VOICE_EXPIncN    = 5,
-        SPU_VOICE_EXPDec     = 7
-    };
-
-    static const u32 m_PSX_SPU_BASE = 0x1F801C00;
-
-    void SetVoiceStartAddress(u8 arg_voice, u32 arg_address);
-    void SetVoiceLoopAddress(u8 arg_voice, u32 arg_address);
-    void SetVoiceVolume(u8 arg_voice, s16 arg_volume_left, s16 arg_volume_right);
-    void SetVoicePitch(u8 arg_voice, u16 arg_pitch);
-    void SetVoiceAttackRate(u8 arg_voice, u16 arg_rate, SpuRateMode arg_mode);
-    void SetVoiceSustainRate(u8 arg_voice, u16 arg_rate, SpuRateMode arg_mode);
-    void SetVoiceReleaseRate(u8 arg_voice, u16 arg_rate, SpuRateMode arg_mode);
-    void SetVoiceDecayRate(u8 arg_voice, u16 arg_rate);
-    void SetVoiceSustainLevel(u8 arg_voice, u16 arg_level);
-
-    static const u32 m_REGISTER_BASE = 0x1f801c00;
-
-    bool PsxWriteDMA(u16 arg_address, u8 *arg_data, u32 arg_length);
-};
-
-
-
-extern SoundManager *SOUNDMAN;
-
-void InitADSR();
-void StartADSR(int ch);
-int MixADSR(int ch);
-
-
-
-// PETE ///////////////
-unsigned short SPUreadDMA();
-void SPUreadDMAMem( unsigned short *pusPSXMem, int iSize );
-void SPUwriteDMA( unsigned short val );
-void SPUwriteDMAMem( unsigned short *pusPSXMem, int iSize );
-// PETE ///////////////
-
-
-
-
-extern const int gauss[];
-
-#define H_SPUReverbAddr  0x0da2
-#define H_SPUirqAddr     0x0da4
-#define H_SPUaddr        0x0da6
-#define H_SPUdata        0x0da8
-#define H_SPUctrl        0x0daa
-#define H_SPUstat        0x0dae
-#define H_SPUmvolL       0x0d80
-#define H_SPUmvolR       0x0d82
-#define H_SPUrvolL       0x0d84
-#define H_SPUrvolR       0x0d86
-#define H_SPUon1         0x0d88
-#define H_SPUon2         0x0d8a
-#define H_SPUoff1        0x0d8c
-#define H_SPUoff2        0x0d8e
-#define H_FMod1          0x0d90
-#define H_FMod2          0x0d92
-#define H_Noise1         0x0d94
-#define H_Noise2         0x0d96
-#define H_RVBon1         0x0d98
-#define H_RVBon2         0x0d9a
-#define H_SPUMute1       0x0d9c
-#define H_SPUMute2       0x0d9e
-#define H_CDLeft         0x0db0
-#define H_CDRight        0x0db2
-#define H_ExtLeft        0x0db4
-#define H_ExtRight       0x0db6
-#define H_Reverb         0x0dc0
-#define H_SPUPitch0      0x0c04
-#define H_SPUPitch1      0x0c14
-#define H_SPUPitch2      0x0c24
-#define H_SPUPitch3      0x0c34
-#define H_SPUPitch4      0x0c44
-#define H_SPUPitch5      0x0c54
-#define H_SPUPitch6      0x0c64
-#define H_SPUPitch7      0x0c74
-#define H_SPUPitch8      0x0c84
-#define H_SPUPitch9      0x0c94
-#define H_SPUPitch10     0x0ca4
-#define H_SPUPitch11     0x0cb4
-#define H_SPUPitch12     0x0cc4
-#define H_SPUPitch13     0x0cd4
-#define H_SPUPitch14     0x0ce4
-#define H_SPUPitch15     0x0cf4
-#define H_SPUPitch16     0x0d04
-#define H_SPUPitch17     0x0d14
-#define H_SPUPitch18     0x0d24
-#define H_SPUPitch19     0x0d34
-#define H_SPUPitch20     0x0d44
-#define H_SPUPitch21     0x0d54
-#define H_SPUPitch22     0x0d64
-#define H_SPUPitch23     0x0d74
-
-#define H_SPUStartAdr0   0x0c06
-#define H_SPUStartAdr1   0x0c16
-#define H_SPUStartAdr2   0x0c26
-#define H_SPUStartAdr3   0x0c36
-#define H_SPUStartAdr4   0x0c46
-#define H_SPUStartAdr5   0x0c56
-#define H_SPUStartAdr6   0x0c66
-#define H_SPUStartAdr7   0x0c76
-#define H_SPUStartAdr8   0x0c86
-#define H_SPUStartAdr9   0x0c96
-#define H_SPUStartAdr10  0x0ca6
-#define H_SPUStartAdr11  0x0cb6
-#define H_SPUStartAdr12  0x0cc6
-#define H_SPUStartAdr13  0x0cd6
-#define H_SPUStartAdr14  0x0ce6
-#define H_SPUStartAdr15  0x0cf6
-#define H_SPUStartAdr16  0x0d06
-#define H_SPUStartAdr17  0x0d16
-#define H_SPUStartAdr18  0x0d26
-#define H_SPUStartAdr19  0x0d36
-#define H_SPUStartAdr20  0x0d46
-#define H_SPUStartAdr21  0x0d56
-#define H_SPUStartAdr22  0x0d66
-#define H_SPUStartAdr23  0x0d76
-
-#define H_SPULoopAdr0   0x0c0e
-#define H_SPULoopAdr1   0x0c1e
-#define H_SPULoopAdr2   0x0c2e
-#define H_SPULoopAdr3   0x0c3e
-#define H_SPULoopAdr4   0x0c4e
-#define H_SPULoopAdr5   0x0c5e
-#define H_SPULoopAdr6   0x0c6e
-#define H_SPULoopAdr7   0x0c7e
-#define H_SPULoopAdr8   0x0c8e
-#define H_SPULoopAdr9   0x0c9e
-#define H_SPULoopAdr10  0x0cae
-#define H_SPULoopAdr11  0x0cbe
-#define H_SPULoopAdr12  0x0cce
-#define H_SPULoopAdr13  0x0cde
-#define H_SPULoopAdr14  0x0cee
-#define H_SPULoopAdr15  0x0cfe
-#define H_SPULoopAdr16  0x0d0e
-#define H_SPULoopAdr17  0x0d1e
-#define H_SPULoopAdr18  0x0d2e
-#define H_SPULoopAdr19  0x0d3e
-#define H_SPULoopAdr20  0x0d4e
-#define H_SPULoopAdr21  0x0d5e
-#define H_SPULoopAdr22  0x0d6e
-#define H_SPULoopAdr23  0x0d7e
-
-#define H_SPU_ADSRLevel0   0x0c08
-#define H_SPU_ADSRLevel1   0x0c18
-#define H_SPU_ADSRLevel2   0x0c28
-#define H_SPU_ADSRLevel3   0x0c38
-#define H_SPU_ADSRLevel4   0x0c48
-#define H_SPU_ADSRLevel5   0x0c58
-#define H_SPU_ADSRLevel6   0x0c68
-#define H_SPU_ADSRLevel7   0x0c78
-#define H_SPU_ADSRLevel8   0x0c88
-#define H_SPU_ADSRLevel9   0x0c98
-#define H_SPU_ADSRLevel10  0x0ca8
-#define H_SPU_ADSRLevel11  0x0cb8
-#define H_SPU_ADSRLevel12  0x0cc8
-#define H_SPU_ADSRLevel13  0x0cd8
-#define H_SPU_ADSRLevel14  0x0ce8
-#define H_SPU_ADSRLevel15  0x0cf8
-#define H_SPU_ADSRLevel16  0x0d08
-#define H_SPU_ADSRLevel17  0x0d18
-#define H_SPU_ADSRLevel18  0x0d28
-#define H_SPU_ADSRLevel19  0x0d38
-#define H_SPU_ADSRLevel20  0x0d48
-#define H_SPU_ADSRLevel21  0x0d58
-#define H_SPU_ADSRLevel22  0x0d68
-#define H_SPU_ADSRLevel23  0x0d78
-
-// we have a timebase of 1.020408f ms, not 1 ms... so adjust adsr defines
-#define ATTACK_MS      494L
-#define DECAYHALF_MS   286L
-#define DECAY_MS       572L
-#define SUSTAIN_MS     441L
-#define RELEASE_MS     437L
-//#define LOWORD(l)    ((unsigned short)(l))
-//#define HIWORD(l)    ((unsigned short)(((unsigned long)(l) >> 16) & 0xFFFF))
-
-extern int bSPUIsOpen;
-
-
-typedef struct
-{
-	long y0, y1;
-} ADPCM_Decode_t;
-
-typedef struct
-{
-	int freq;
-	int nbits;
-	int stereo;
-	int nsamples;
-	ADPCM_Decode_t left, right;
-	short pcm[16384];
-} xa_decode_t;
-
-
-
-extern xa_decode_t *xapGlobal;
-
-extern u32 *XAFeed;
-extern u32 *XAPlay;
-extern u32 *XAStart;
-extern u32 *XAEnd;
-
-extern u32 XARepeat;
-extern u32 XALastVal;
-
-extern int iLeftXAVol;
-extern int iRightXAVol;
-
-#define PSE_LT_SPU                  4
-#define PSE_SPU_ERR_SUCCESS         0
-#define PSE_SPU_ERR                 -60
-#define PSE_SPU_ERR_NOTCONFIGURED   PSE_SPU_ERR - 1
-#define PSE_SPU_ERR_INIT            PSE_SPU_ERR - 2
-#ifndef max
-#define max(a,b)            (((a) > (b)) ? (a) : (b))
-#define min(a,b)            (((a) < (b)) ? (a) : (b))
-#endif
-
-// 137 ms test buffer... if less than that is buffered, a new upload will happen
-#define TESTSIZE    24192
-// num of channels
-#define MAXCHAN     24
-// ~ 1 ms of data
-#define NSSIZE 45
-
-
-
-// ADSR infos per channel
-typedef struct
-{
-	int            AttackModeExp;
-	long           AttackTime;
-	long           DecayTime;
-	long           SustainLevel;
-	int            SustainModeExp;
-	long           SustainModeDec;
-	long           SustainTime;
-	int            ReleaseModeExp;
-	unsigned long  ReleaseVal;
-	long           ReleaseTime;
-	long           ReleaseStartTime;
-	long           ReleaseVol;
-	long           lTime;
-	long           lVolume;
-} ADSRInfo;
-
-typedef struct
-{
-	int            State;
-	int            AttackModeExp;
-	int            AttackRate;
-	int            DecayRate;
-	int            SustainLevel;
-	int            SustainModeExp;
-	int            SustainIncrease;
-	int            SustainRate;
-	int            ReleaseModeExp;
-	int            ReleaseRate;
-	int            EnvelopeVol;
-	long           lVolume;
-	long           lDummy1;
-	long           lDummy2;
-} ADSRInfoEx;
-
-// used for debug channel muting
-#define FLAG_MUTE  1
-// used for simple interpolation
-#define FLAG_IPOL0 2
-#define FLAG_IPOL1 4
-
-
-// MAIN CHANNEL STRUCT
-typedef struct
-{
-	int bNew;              // start flag
-	int iSBPos;            // mixing stuff
-	int spos;
-	int sinc;
-	int SB[32 + 32];       // Pete added another 32 dwords in 1.6 ...
-	                       // prevents overflow issues with gaussian/cubic
-						   // interpolation (thanx xodnizel!), and can be
-						   // used for even better interpolations, eh? :)
-	int sval;
-
-	unsigned char *pStart; // start ptr into sound mem
-	unsigned char *pCurr;  // current pos in sound mem
-	unsigned char *pLoop;  // loop ptr in sound mem
-
-	int bOn;               // is channel active (sample playing?)
-	int bStop;             // is ch stop (can still be playing, if ADSR Release)
-	int bReverb;           // reverb, must have ctrl register bit, to get active
-	int iActFreq;          // current psx pitch
-	int iUsedFreq;         // current pc pitch
-	int iLeftVolume;       // left volume
-	int iLeftVolRaw;       // left psx volume value
-	int bIgnoreLoop;       // ignore loop, if an external loop address is used
-	int iMute;             // mute mode
-	int iRightVolume;      // right volume
-	int iRightVolRaw;      // right psx volume value
-	int iRawPitch;         // raw pitch (0...3fff)
-	int iIrqDone;          // debug irq done flag
-	int s_1;               // last decoding infos
-	int s_2;
-	int bRVBActive;        // reverb active flag
-	int iRVBOffset;        // reverb offset
-	int iRVBRepeat;        // reverb repeat
-	int bNoise;            // noise active flag
-	int bFMod;             // freq mod (0=off, 1=sound channel, 2=freq channel)
-	int iRVBNum;           // another reverb helper
-	int iOldNoise;         // old noise val for this channel
-	ADSRInfo ADSR;         // active ADSR settings
-	ADSRInfoEx ADSRX;      // next ADSR settings
-					       // (will be moved to active on sample start)
-} SPUCHAN;
-
-
-// REVERB
-typedef struct
-{
-	int StartAddr;      // reverb area start addr in samples
-	int CurrAddr;       // reverb area curr addr in samples
-
-	int VolLeft;
-	int VolRight;
-	int iLastRVBLeft;
-	int iLastRVBRight;
-	int iRVBLeft;
-	int iRVBRight;
-
-
-	int FB_SRC_A;       // (offset)
-	int FB_SRC_B;       // (offset)
-	int IIR_ALPHA;      // (coef.)
-	int ACC_COEF_A;     // (coef.)
-	int ACC_COEF_B;     // (coef.)
-	int ACC_COEF_C;     // (coef.)
-	int ACC_COEF_D;     // (coef.)
-	int IIR_COEF;       // (coef.)
-	int FB_ALPHA;       // (coef.)
-	int FB_X;           // (coef.)
-	int IIR_DEST_A0;    // (offset)
-	int IIR_DEST_A1;    // (offset)
-	int ACC_SRC_A0;     // (offset)
-	int ACC_SRC_A1;     // (offset)
-	int ACC_SRC_B0;     // (offset)
-	int ACC_SRC_B1;     // (offset)
-	int IIR_SRC_A0;     // (offset)
-	int IIR_SRC_A1;     // (offset)
-	int IIR_DEST_B0;    // (offset)
-	int IIR_DEST_B1;    // (offset)
-	int ACC_SRC_C0;     // (offset)
-	int ACC_SRC_C1;     // (offset)
-	int ACC_SRC_D0;     // (offset)
-	int ACC_SRC_D1;     // (offset)
-	int IIR_SRC_B1;     // (offset)
-	int IIR_SRC_B0;     // (offset)
-	int MIX_DEST_A0;    // (offset)
-	int MIX_DEST_A1;    // (offset)
-	int MIX_DEST_B0;    // (offset)
-	int MIX_DEST_B1;    // (offset)
-	int IN_COEF_L;      // (coef.)
-	int IN_COEF_R;      // (coef.)
-} REVERBInfo;
-
-
-extern char * pConfigFile;
-
-extern int *          sRVBPlay;
-extern int *          sRVBEnd;
-extern int *          sRVBStart;
-extern int            iReverbOff;
-extern int            iReverbRepeat;
-extern int            iReverbNum;
-
-// psx buffers / addresses
-extern unsigned short  regArea[];
-extern unsigned short  spuMem[];
-extern unsigned char * spuMemC;
-extern unsigned char * pSpuIrq;
-extern unsigned char * pSpuBuffer;
-
-// user settings
-extern int        iUseXA;
-extern int        iVolume;
-extern int        iXAPitch;
-extern int        iUseTimer;
-extern int        iSPUIRQWait;
-extern int        iDebugMode;
-extern int        iRecordMode;
-extern int        iUseReverb;
-extern int        iUseInterpolation;
-extern int        iDisStereo;
-// MISC
-
-extern int iWatchDog;
-
-//extern SPUCHAN s_chan[];
-extern REVERBInfo rvb;
-
-extern unsigned long dwNoiseVal;
-extern unsigned short spuCtrl;
-extern unsigned short spuStat;
-extern unsigned short spuIrq;
-extern unsigned long  spuAddr;
-extern int      bEndThread;
-extern int      bThreadEnded;
-extern int      bSpuInit;
-extern unsigned long dwNewChannel;
-
-extern int      SSumR[];
-extern int      SSumL[];
-extern int      iCycle;
-extern short *  pS;
-
-extern void (*cddavCallback)(unsigned short,unsigned short);
-extern SPUCHAN s_chan[];
-
-
-
-void SPUwriteRegister(unsigned long reg, unsigned short val);
-unsigned short SPUreadRegister(unsigned long reg);
-void SoundOn(int start, int end, unsigned short val);
-void SoundOff(int start, int end, unsigned short val);
-void FModOn(int start, int end, unsigned short val);
-void NoiseOn(int start, int end, unsigned short val);
-void SetVolumeL(unsigned char ch, short vol);
-void SetVolumeR(unsigned char ch, short vol);
-void SetPitch(int ch, unsigned short val);
-void ReverbOn(int start, int end, unsigned short val);
-
-void SetREVERB(unsigned short val);
-void StartREVERB(int ch);
-void InitREVERB();
-void StoreREVERB(int ch, int ns);
-int g_buffer(int iOff);
-void s_buffer(int iOff, int iVal);
-void s_buffer1(int iOff, int iVal);
-int MixREVERBLeft(int ns);
-int MixREVERBRight();
-
-void MixXA();
-void FeedXA(xa_decode_t *xap);
-
-long SPUinit(void);
-long SPUopen(void);
-long SPUclose(void);
-void SPUasync(unsigned long cycle);
-void SPUplayADPCMchannel(xa_decode_t *xap);
-unsigned short SPUgetOne(unsigned long val);
-void SPUputOne(unsigned long val,unsigned short data);
-void SPUplaySample(unsigned char ch);
-void SPUsetAddr(unsigned char ch, unsigned short waddr);
-void SPUsetPitch(unsigned char ch, unsigned short pitch);
-void SPUsetVolumeL(unsigned char ch, short vol);
-void SPUsetVolumeR(unsigned char ch, short vol);
-void SPUstartChannels1(unsigned short channels);
-void SPUstartChannels2(unsigned short channels);
-void SPUstopChannels1(unsigned short channels);
-void SPUstopChannels2(unsigned short channels);
-void SPUplaySector(unsigned long mode, unsigned char * p);
-u32 GGetTime();
-
-
-
-#endif
-

+ 0 - 139
utilities/ffix_sound_dumper/src/engine/backends/SoundBackendSDL.cpp

@@ -1,139 +0,0 @@
-//#include <SDL/SDL.h>
-#include "common/TypeDefine.h"
-
-#include "SoundBackendSDL.h"
-
-
-
-using namespace std;
-
-
-// NOTE: This has been commented out as we don't have SDL so can't link to it, should add
-// another backend if we still need this
-
-//void sound_manager_fill_audio(void *arg_user_data, Uint8 *arg_stream, int arg_length);
-
-
-SoundBackendSDL::SoundBackendSDL()
-{
-    /*
-	// init SDL::Audio subsystem
-	Uint32 initialized_subsystems = SDL_WasInit(SDL_INIT_EVERYTHING);
-	int initialization_successfull;
-	if(initialized_subsystems)
-		if(initialized_subsystems & SDL_INIT_AUDIO)
-			SDL_CloseAudio();
-		else
-			initialization_successfull = SDL_InitSubSystem(SDL_INIT_AUDIO);
-	else
-		initialization_successfull = SDL_Init(SDL_INIT_AUDIO);
-
-	if(initialization_successfull == -1)
-	{
-		cout << "[SoundManager] error: " << SDL_GetError();
-		exit(EXIT_FAILURE);
-	}
-	else
-		cout << "[SoundManager] info: initialization successfull."
-			<< endl;
-
-	// set desired configuration
-	SDL_AudioSpec desired_configuration;
-	desired_configuration.freq = m_FREQUENCY;            // frequency
-	desired_configuration.format = AUDIO_S16SYS;         // sample format
-	desired_configuration.channels = m_CHANNELS_COUNT;   // channels count
-	desired_configuration.samples = 512;                 // internal buffer size
-	desired_configuration.callback =
-		sound_manager_fill_audio;                        // callback function
-	desired_configuration.userdata = (void *)&m_Context; // user data
-	SDL_AudioSpec obtained_configuration;
-	SDL_OpenAudio(&desired_configuration, &obtained_configuration);
-	if(desired_configuration.freq != obtained_configuration.freq ||
-		desired_configuration.format != obtained_configuration.format ||
-		desired_configuration.channels != obtained_configuration.channels)
-	{
-		cout << "[SoundManager] error: obtained unsuitable configuration."
-			<< endl;
-		SDL_CloseAudio();
-		SDL_QuitSubSystem(SDL_INIT_AUDIO);
-	}
-
-	// initialize context for callback
-	m_Context.buffer_size = m_BUFFER_SIZE;
-	m_Context.buffer = new uint8_t[m_Context.buffer_size];
-	if(m_Context.buffer == NULL)
-	{
-		cout << "[SoundManager] error: out of memory." << endl;
-		exit(EXIT_FAILURE);
-	}
-
-	m_Context.play_length = 0;
-
-    SDL_PauseAudio(0);*/
-}
-
-
-SoundBackendSDL::~SoundBackendSDL()
-{
-    /*
-	SDL_PauseAudio(1);
-
-	SDL_CloseAudio();
-	SDL_QuitSubSystem(SDL_INIT_AUDIO);
-	if(!SDL_WasInit(SDL_INIT_EVERYTHING))
-	{
-		cout << "[SoundManager] info: exit successfull" << endl;
-		SDL_Quit();
-	}
-
-	if(m_Context.buffer != NULL)
-        delete [] m_Context.buffer;*/
-}
-
-
-u32 SoundBackendSDL::GetBytesBuffered()
-{
-	if(m_Context.play_length <
-			m_Context.buffer_size / 2)
-		return 0;
-	else
-		return m_Context.buffer_size;
-}
-
-
-void SoundBackendSDL::FeedStreamData(u8 *arg_data, u32 arg_length)
-{
-    /*
-	SDL_LockAudio();
-
-	memcpy((void *)(m_Context.buffer + m_Context.play_length),
-			(const void *)arg_data, arg_length);
-	m_Context.play_length += arg_length;
-
-    SDL_UnlockAudio();*/
-}
-
-
-void sound_manager_fill_audio(void *arg_user_data, unsigned char *arg_stream, int arg_length)
-{
-    /*
-	SoundBackendSDL::FillAudioContext *context =
-			(SoundBackendSDL::FillAudioContext *)arg_user_data;
-
-	if(!context->play_length)
-		return;
-
-	int play_length = arg_length < (int)context->play_length ?
-			arg_length : context->play_length;
-
-	// mix data to sdl buffer for playing
-	SDL_MixAudio(arg_stream, (Uint8 *)context->buffer,
-			play_length, SDL_MIX_MAXVOLUME);
-	context->play_length -= play_length;
-
-	// shift pcm data to buffer beginning
-	memcpy((void *)context->buffer,
-			(const void *)(context->buffer + play_length),
-            context->play_length);*/
-}
-

+ 0 - 37
utilities/ffix_sound_dumper/src/engine/backends/SoundBackendSDL.h

@@ -1,37 +0,0 @@
-#ifndef SOUND_BACKEND_SDL_HH__
-#define SOUND_BACKEND_SDL_HH__
-
-
-
-//#include <SDL/SDL.h>
-#include "common/TypeDefine.h"
-
-#include "../SoundBackend.h"
-#include <stdint.h>
-
-
-class SoundBackendSDL : public SoundBackend
-{
-	private:
-		struct FillAudioContext
-		{
-			uint8_t *buffer;
-			uint32_t buffer_size;
-			uint32_t play_length;
-		};
-
-		FillAudioContext m_Context;
-        //friend void sound_manager_fill_audio(void *arg_user_data, Uint8 *arg_stream, int arg_length);
-
-	public:
-		SoundBackendSDL();
-		virtual ~SoundBackendSDL();
-
-		virtual u32 GetBytesBuffered();
-		virtual void FeedStreamData(u8 *arg_data, u32 arg_length);
-};
-
-
-
-#endif
-

+ 0 - 57
utilities/ffvii_battle_model_exporter/CMakeLists.txt

@@ -1,57 +0,0 @@
-include_directories(
-    ${CMAKE_CURRENT_SOURCE_DIR}/src
-)
-
-# define header and source files
-set(HEADER_FILES
-./src/MeshExtractor.h
-./src/StageFile.h
-./src/RamEffectFile.h
-./src/EnemyFile.h
-./src/MeshExtractor.cpp
-./src/AnimationScriptDumper.h
-./src/AnimationExtractor.h
-)
-
-set(SOURCE_FILES
-./src/EnemyFile.cpp
-./src/RamEffectFile.cpp
-./src/AnimationExtractor.cpp
-./src/MeshExtractor.cpp
-./src/AnimationScriptDumper.cpp
-./src/StageFile.cpp
-./src/Main.cpp
-)
-
-add_definitions(
-    -DQGEARS_ADD_MANAGERS
-)
-
-add_executable(ff7_battle_model_exporter
-  ${HEADER_FILES}
-  ${SOURCE_FILES}
-)
-SET_PROPERTY(TARGET ff7_battle_model_exporter PROPERTY FOLDER "utilities")
-
-if (APPLE)
-target_link_libraries(ff7_battle_model_exporter "-framework CoreFoundation -framework Cocoa -framework IOKit")
-endif()
-
-
-if(WIN32)
-  set_target_properties(ff7_battle_model_exporter PROPERTIES WIN32_EXECUTABLE ON)
-  if (MSVC)
-    set_target_properties(ff7_battle_model_exporter PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
-  endif()
-endif()
-
-set(LIBRARIES
-    Utility
-    QGearsMain
-    v-gears-data
-)
-target_link_libraries(ff7_battle_model_exporter    ${LIBRARIES})
-
-install(TARGETS ff7_battle_model_exporter
-    DESTINATION tools/ff7
-)

+ 0 - 310
utilities/ffvii_battle_model_exporter/src/AnimationExtractor.cpp

@@ -1,310 +0,0 @@
-/*
- * Copyright (C) 2022 The V-Gears Team
- *
- * This file is part of V-Gears
- *
- * V-Gears is free software: you can redistribute it and/or modify it under
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, version 3.0 (GPLv3) of the License.
- *
- * V-Gears 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 General Public License for more details.
- */
-
-#include "AnimationExtractor.h"
-#include "../../common/Logger.h"
-
-/**
- * Reads a bit stream from a file.
- *
- * Used by {@see AnimationExtractor}.
- *
- * @param file[in] The file to read.
- * @param offset[in] Offset at which to start reading the file.
- * @param readed_bits[out] The number of bits read from the file.
- * @param bit_to_read[in] Number of bits to read.
- * @param real_size[in] @todo Understand and document.
- * @return @todo Understand and document.
- */
-float ReadBitStream(
-  File* file, const int offset, int &readed_bits,
-  const int bit_to_read, const int real_size
-){
-    int ret = 0;
-    for (int i = 0; i < bit_to_read; ++ i){
-        ret <<= 1;
-        // Read new bit.
-        int byte = file->GetU8(offset + (readed_bits / 8));
-        //LOGGER->Log(
-        //  LOGGER_INFO,
-        //  "ReadBitStream data = %02x readed_bits = %02x", byte, readed_bits
-        //);
-        if ((byte >> (7 - (readed_bits & 7))) & 1) ret |= 1;
-        readed_bits += 1;
-    }
-    // Force the sign bit to extend across the 32-bit boundary.
-    ret <<= (0x20 - bit_to_read);
-    ret >>= (0x20 - bit_to_read);
-    // Fxtend compressed value.
-    ret <<= (real_size - bit_to_read);
-    return (float)ret;
-}
-
-float ReadDynamicFrameOffsetBits(
-  File* file, const int offset, int &readed_bits
-){
-    int readed_bytes = readed_bits / 8;
-    int bit_in_byte = readed_bits & 7;
-    int data = (file->GetU8(offset + readed_bytes + 0) << 8) | file->GetU8(offset + readed_bytes + 1);
-    //LOGGER->Log(LOGGER_INFO, "ReadDynamicFrameOffsetBits data = %04x (bit_in_byte %02x)", data, bit_in_byte);
-    if ((data & (1 << (15 - bit_in_byte))) != 0)
-    {
-        // 16 bit value
-        data <<= 8;
-        //LOGGER->Log(LOGGER_INFO, "ReadDynamicFrameOffsetBits 16bit = %04x", data);
-        data |= file->GetU8(offset + readed_bytes + 2);
-        //LOGGER->Log(LOGGER_INFO, "ReadDynamicFrameOffsetBits 16bit = %04x", data);
-        data <<= (bit_in_byte + 9);
-        //LOGGER->Log(LOGGER_INFO, "ReadDynamicFrameOffsetBits 16bit = %04x", data);
-        data >>= 0x10;
-        //LOGGER->Log(LOGGER_INFO, "ReadDynamicFrameOffsetBits 16bit = %04x", data);
-        readed_bits += 17;
-    }
-    else
-    {
-        // 7 bit value
-        data <<= (bit_in_byte + 0x11);
-        data >>= 0x19;
-        //LOGGER->Log(LOGGER_INFO, "ReadDynamicFrameOffsetBits 7bit = %d", data);
-        readed_bits += 8;
-    }
-
-    //LOGGER->Log(LOGGER_INFO, "ReadDynamicFrameOffsetBits = %d", data);
-    return (float)data;
-}
-
-
-
-float
-ReadEncryptedRotationBits(File* file, const int offset, int &readed_bits, const int compression)
-{
-    int ret = 0;
-
-    int control_bit = static_cast<int>(ReadBitStream(file, offset, readed_bits, 1, 1));
-    //LOGGER->Log(LOGGER_INFO, "ReadEncryptedRotationBits control_bit = %x", control_bit);
-    if (control_bit != 0)
-    {
-        control_bit = static_cast<int>(ReadBitStream(file, offset, readed_bits, 3, 3));
-        control_bit &= 7;
-        //LOGGER->Log(LOGGER_INFO, "ReadEncryptedRotationBits control_bit = %x", control_bit);
-        if (control_bit == 0)
-        {
-            ret = -1;
-        }
-        else if (control_bit == 7)
-        {
-            ret = static_cast<int>(ReadBitStream(file, offset, readed_bits, 12 - compression, 12));
-        }
-        else
-        {
-            int data = static_cast<int>(ReadBitStream(file, offset, readed_bits, control_bit, control_bit));
-            //LOGGER->Log(LOGGER_INFO, "ReadEncryptedRotationBits data = %x", data);
-            if (data >= 0)
-            {
-                data += (1 << (control_bit - 1));
-            }
-            else
-            {
-                data -= (1 << (control_bit - 1));
-            }
-
-            ret = data << (compression + 16);
-            ret >>= 16;
-        }
-    }
-
-    //LOGGER->Log(LOGGER_INFO, "ReadEncryptedRotationBits = %x", ret);
-    return (float)ret;
-}
-
-
-
-void AnimationExtractor(
-  File* file, const Ogre::SkeletonPtr& skeleton, const EnemyInfo& info,
-  Skeleton& skeleton_data, bool with_weapon
-){
-    float weapon_tx, weapon_ty, weapon_tz, weapon_rx, weapon_ry, weapon_rz = 0;
-
-    for (size_t i = 0; i < info.animations.size(); ++i)
-    {
-        if (info.animations[i] == "")
-        {
-            continue;
-        }
-        LOGGER->Log("AnimationExtractor:" + Ogre::StringConverter::toString(i) + " " + info.animations[i] + "\n");
-        int offset_to_animation = file->GetU32LE(0x0c + i * 0x04);
-        int offset_to_animation_weapon = 0;
-        if (with_weapon)
-        {
-            offset_to_animation_weapon = file->GetU32LE(0x4c + i * 0x04);
-        }
-        int number_of_frames = file->GetU16LE(offset_to_animation + 0x0);
-        int compression = file->GetU8(offset_to_animation + 0x4);
-        int compression_weapon = 0;
-        if (with_weapon)
-        {
-            compression_weapon = file->GetU8(offset_to_animation_weapon + 0x4);
-        }
-
-        Ogre::Animation* anim = skeleton->createAnimation(info.animations[i], (number_of_frames - 1) / 10.0f);
-
-        float time = 0;
-        int readed_bits = 0;
-        int readed_bits_weapon = 0;
-
-        float tx, ty, tz;
-        Ogre::Bone* bone1;
-        Ogre::Bone* bone2;
-        Ogre::NodeAnimationTrack* track1;
-        Ogre::NodeAnimationTrack* track2;
-        Ogre::TransformKeyFrame* frame1;
-        Ogre::TransformKeyFrame* frame2;
-        Ogre::Quaternion rot;
-        Ogre::Matrix3 mat;
-
-        for (int frame = 0; frame < number_of_frames; ++frame)
-        {
-            if (readed_bits == 0)
-            {
-                tx = ReadBitStream(file, offset_to_animation + 5, readed_bits, 16, 16);
-                ty = ReadBitStream(file, offset_to_animation + 5, readed_bits, 16, 16);
-                tz = ReadBitStream(file, offset_to_animation + 5, readed_bits, 16, 16);
-                // skip first rotation
-                ReadBitStream(file, offset_to_animation + 5, readed_bits, 12 - compression, 12);
-                ReadBitStream(file, offset_to_animation + 5, readed_bits, 12 - compression, 12);
-                ReadBitStream(file, offset_to_animation + 5, readed_bits, 12 - compression, 12);
-
-                bone1 = skeleton->getBone(0);
-                track1 = anim->createNodeTrack(0, bone1);
-                track1->removeAllKeyFrames();
-                frame1 = track1->createNodeKeyFrame(time);
-                mat.FromEulerAnglesYXZ(Ogre::Radian(Ogre::Degree(0)), Ogre::Radian(Ogre::Degree(-90)), Ogre::Radian(Ogre::Degree(0)));
-                rot.FromRotationMatrix(mat);
-                frame1->setRotation(rot);
-                bone2 = skeleton->getBone(1);
-                track2 = anim->createNodeTrack(1, bone2);
-                track2->removeAllKeyFrames();
-                frame2 = track2->createNodeKeyFrame(time);
-                frame2->setTranslate(Ogre::Vector3(tx, ty, tz) / 512);
-
-                for (size_t bone = 0; bone < skeleton_data.size(); ++bone)
-                {
-                    skeleton_data[bone].rx = (ReadBitStream(file, offset_to_animation + 5, readed_bits, 12 - compression, 12) / 4096.0f) * 360;
-                    skeleton_data[bone].ry = (ReadBitStream(file, offset_to_animation + 5, readed_bits, 12 - compression, 12) / 4096.0f) * 360;
-                    skeleton_data[bone].rz = (ReadBitStream(file, offset_to_animation + 5, readed_bits, 12 - compression, 12) / 4096.0f) * 360;
-
-                    bone1 = skeleton->getBone(bone * 2 + 2);
-                    bone2 = skeleton->getBone(bone * 2 + 3);
-                    track1 = anim->createNodeTrack(bone * 2 + 2, bone1);
-                    track1->removeAllKeyFrames();
-                    track2 = anim->createNodeTrack(bone * 2 + 3, bone2);
-                    track2->removeAllKeyFrames();
-                    frame1 = track1->createNodeKeyFrame(time);
-                    frame2 = track2->createNodeKeyFrame(time);
-                    frame2->setTranslate(Ogre::Vector3(0.0f, 0.0f, static_cast<float>(skeleton_data[bone].length) / 512));
-                    mat.FromEulerAnglesYXZ(Ogre::Radian(Ogre::Degree(skeleton_data[bone].ry)), Ogre::Radian(Ogre::Degree(skeleton_data[bone].rx)), Ogre::Radian(Ogre::Degree(skeleton_data[bone].rz)));
-                    rot.FromRotationMatrix(mat);
-                    frame1->setRotation(rot);
-                }
-
-                if (with_weapon)
-                {
-                    weapon_tx = ReadBitStream(file, offset_to_animation_weapon + 5, readed_bits_weapon, 16, 16);
-                    weapon_ty = ReadBitStream(file, offset_to_animation_weapon + 5, readed_bits_weapon, 16, 16);
-                    weapon_tz = ReadBitStream(file, offset_to_animation_weapon + 5, readed_bits_weapon, 16, 16);
-                    weapon_rx = (ReadBitStream(file, offset_to_animation_weapon + 5, readed_bits_weapon, 12 - compression_weapon, 12) / 4096.0f) * 360;
-                    weapon_ry = (ReadBitStream(file, offset_to_animation_weapon + 5, readed_bits_weapon, 12 - compression_weapon, 12) / 4096.0f) * 360;
-                    weapon_rz = (ReadBitStream(file, offset_to_animation_weapon + 5, readed_bits_weapon, 12 - compression_weapon, 12) / 4096.0f) * 360;
-
-                    bone1 = skeleton->getBone(skeleton_data.size() * 2 + 3);
-                    track1 = anim->createNodeTrack(skeleton_data.size() * 2 + 3, bone1);
-                    track1->removeAllKeyFrames();
-                    frame1 = track1->createNodeKeyFrame(time);
-                    mat.FromEulerAnglesYXZ(Ogre::Radian(Ogre::Degree(weapon_ry)), Ogre::Radian(Ogre::Degree(weapon_rx)), Ogre::Radian(Ogre::Degree(weapon_rz)));
-                    rot.FromRotationMatrix(mat);
-                    frame1->setRotation(rot);
-
-                    bone2 = skeleton->getBone(skeleton_data.size() * 2 + 2);
-                    track2 = anim->createNodeTrack(skeleton_data.size() * 2 + 2, bone2);
-                    track2->removeAllKeyFrames();
-                    frame2 = track2->createNodeKeyFrame(time);
-                    frame2->setTranslate(Ogre::Vector3(weapon_tx, weapon_ty, weapon_tz) / 512);
-                }
-            }
-            else
-            {
-                tx += ReadDynamicFrameOffsetBits(file, offset_to_animation + 5, readed_bits);
-                ty += ReadDynamicFrameOffsetBits(file, offset_to_animation + 5, readed_bits);
-                tz += ReadDynamicFrameOffsetBits(file, offset_to_animation + 5, readed_bits);
-                // skip first rotation
-                ReadEncryptedRotationBits(file, offset_to_animation + 5, readed_bits, compression);
-                ReadEncryptedRotationBits(file, offset_to_animation + 5, readed_bits, compression);
-                ReadEncryptedRotationBits(file, offset_to_animation + 5, readed_bits, compression);
-
-                bone1 = skeleton->getBone(0);
-                track1 = anim->getNodeTrack(0);
-                frame1 = track1->createNodeKeyFrame(time);
-                mat.FromEulerAnglesYXZ(Ogre::Radian(Ogre::Degree(0)), Ogre::Radian(Ogre::Degree(-90)), Ogre::Radian(Ogre::Degree(0)));
-                rot.FromRotationMatrix(mat);
-                frame1->setRotation(rot);
-                bone2 = skeleton->getBone(1);
-                track2 = anim->getNodeTrack(1);
-                frame2 = track2->createNodeKeyFrame(time);
-                frame2->setTranslate(Ogre::Vector3(tx, ty, tz) / 512);
-
-                for (size_t bone = 0; bone < skeleton_data.size(); ++bone)
-                {
-                    skeleton_data[bone].rx += (ReadEncryptedRotationBits(file, offset_to_animation + 5, readed_bits, compression) / 4096.0f) * 360;
-                    skeleton_data[bone].ry += (ReadEncryptedRotationBits(file, offset_to_animation + 5, readed_bits, compression) / 4096.0f) * 360;
-                    skeleton_data[bone].rz += (ReadEncryptedRotationBits(file, offset_to_animation + 5, readed_bits, compression) / 4096.0f) * 360;
-                    bone1 = skeleton->getBone(bone * 2 + 2);
-                    bone2 = skeleton->getBone(bone * 2 + 3);
-                    track1 = anim->getNodeTrack(bone * 2 + 2);
-                    track2 = anim->getNodeTrack(bone * 2 + 3);
-                    frame1 = track1->createNodeKeyFrame(time);
-                    frame2 = track2->createNodeKeyFrame(time);
-                    frame2->setTranslate(Ogre::Vector3(0.0f, 0.0f, static_cast<float>(skeleton_data[bone].length) / 512));
-                    mat.FromEulerAnglesYXZ(Ogre::Radian(Ogre::Degree(skeleton_data[bone].ry)), Ogre::Radian(Ogre::Degree(skeleton_data[bone].rx)), Ogre::Radian(Ogre::Degree(skeleton_data[bone].rz)));
-                    rot.FromRotationMatrix(mat);
-                    frame1->setRotation(rot);
-                }
-
-                if (with_weapon)
-                {
-                    weapon_tx += ReadDynamicFrameOffsetBits(file, offset_to_animation_weapon + 5, readed_bits_weapon);
-                    weapon_ty += ReadDynamicFrameOffsetBits(file, offset_to_animation_weapon + 5, readed_bits_weapon);
-                    weapon_tz += ReadDynamicFrameOffsetBits(file, offset_to_animation_weapon + 5, readed_bits_weapon);
-                    weapon_rx += (ReadEncryptedRotationBits(file, offset_to_animation_weapon + 5, readed_bits_weapon, compression_weapon) / 4096.0f) * 360;
-                    weapon_ry += (ReadEncryptedRotationBits(file, offset_to_animation_weapon + 5, readed_bits_weapon, compression_weapon) / 4096.0f) * 360;
-                    weapon_rz += (ReadEncryptedRotationBits(file, offset_to_animation_weapon + 5, readed_bits_weapon, compression_weapon) / 4096.0f) * 360;
-
-                    bone1 = skeleton->getBone(skeleton_data.size() * 2 + 3);
-                    track1 = anim->getNodeTrack(skeleton_data.size() * 2 + 3);
-                    frame1 = track1->createNodeKeyFrame(time);
-                    mat.FromEulerAnglesYXZ(Ogre::Radian(Ogre::Degree(weapon_ry)), Ogre::Radian(Ogre::Degree(weapon_rx)), Ogre::Radian(Ogre::Degree(weapon_rz)));
-                    rot.FromRotationMatrix(mat);
-                    frame1->setRotation(rot);
-
-                    bone2 = skeleton->getBone(skeleton_data.size() * 2 + 2);
-                    track2 = anim->getNodeTrack(skeleton_data.size() * 2 + 2);
-                    frame2 = track2->createNodeKeyFrame(time);
-                    frame2->setTranslate(Ogre::Vector3(weapon_tx, weapon_ty, weapon_tz) / 512);
-                }
-            }
-
-            time += 1.0f / 10.0f;
-        }
-    }
-}

+ 0 - 37
utilities/ffvii_battle_model_exporter/src/AnimationExtractor.h

@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2022 The V-Gears Team
- *
- * This file is part of V-Gears
- *
- * V-Gears is free software: you can redistribute it and/or modify it under
- * terms of the GNU General Public License as published by the Free Software
- * Foundation, version 3.0 (GPLv3) of the License.
- *
- * V-Gears 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 General Public License for more details.
- */
-
-#pragma once
-
-#include <Ogre.h>
-#include "EnemyFile.h"
-#include "common/File.h"
-
-/**
- * Extracts an animation from a file.
- *
- * @param file[in] The file from which to read the animation data.
- * @param skeleton[in|out] Skeleton to add the animation to.
- * @param info[in] @todo Understand and document.
- * @param skeleton_data[in|out] Information about the skeleton the animation
- * animates.
- * @param with_weapon[in] Includes the weapon in the animation.
- * @todo Add more documentation. It's a battle animation? Acharacter animation?
- * An enemy animation?
- */
-void AnimationExtractor(
-  File* file, const Ogre::SkeletonPtr& skeleton, const EnemyInfo& info,
-  Skeleton& skeleton_data, bool with_weapon
-);

+ 0 - 224
utilities/ffvii_battle_model_exporter/src/AnimationScriptDumper.cpp

@@ -1,224 +0,0 @@
-#include "AnimationScriptDumper.h"
-
-
-
-void
-AdvanceScript(u32 value, u32& current, u32& end)
-{
-    current += value;
-    u32 temp_end = current;
-    end = (temp_end > end) ? temp_end : end;
-}
-
-
-
-void
-AnimationScriptDumper(File* file, int offset_to_anim_file, Logger* dump)
-{
-    int number_of_scripts = 0x20;
-
-    for (u8 i = 0; i < number_of_scripts; ++i)
-    {
-        u32 script = offset_to_anim_file + file->GetU16LE(offset_to_anim_file + 0x68 + i * 0x04);
-        u32 end = script;
-
-        u8 opcode = file->GetU8(script);
-        if (opcode == 0x00) // skip if script starts with 0x00
-        {
-            continue;
-        }
-
-        dump->Log("\nfunction action_script_" + IntToString(i) + "()\n");
-
-        for (; script <= end;)
-        {
-            //dump->Log(HexToString(script, 4, '0') + " (end " + HexToString(end, 4, '0') + "): ");
-            u8 opcode = file->GetU8(script);
-
-            dump->Log("    ");
-
-            if (opcode < 0x8E)
-            {
-                dump->Log("play_animation(" + IntToString(opcode) + ");\n");
-                AdvanceScript(1, script, end);
-            }
-            else if (opcode == 0xA9)
-            {
-                dump->Log("animation_reset(); -- A9 this increment pointer by 2 and execute animation on second pointer. This called if we back from other action using EE.\n");
-                end = (script + 2 > end) ? script + 2 : end;
-                script += 1;
-            }
-            else if (opcode == 0xAA)
-            {
-                dump->Log("unpause_camera(); -- AA\n");
-                AdvanceScript(1, script, end);
-            }
-            else if (opcode == 0xAD)
-            {
-                dump->Log("set_effect(\"machinegun_fire\", " +
-                    HexToString(file->GetU8(script + 1), 2, '0') +
-                    ", " +
-                    HexToString(file->GetU16LE(script + 2), 4, '0') +
-                    ", " +
-                    HexToString(file->GetU8(script + 4), 2, '0') +
-                    ", " +
-                    HexToString(file->GetU8(script + 5), 2, '0') +
-                    "); -- AD\n"
-                );
-                AdvanceScript(6, script, end);
-            }
-            else if (opcode == 0xB6)
-            {
-                dump->Log("pause_camera_finish_animation(" + IntToString(file->GetU8(script + 1)) + "); -- B6\n");
-                AdvanceScript(2, script, end);
-            }
-            else if (opcode == 0xB9)
-            {
-                dump->Log("set_camera(" +
-                    HexToString(file->GetU8(script + 1), 2, '0') +
-                    "); -- B9\n"
-                );
-                AdvanceScript(2, script, end);
-            }
-            else if (opcode == 0xBE)
-            {
-                dump->Log("execute_hurt(" +
-                    HexToString(file->GetU8(script + 1), 2, '0') +
-                    "); -- BE\n"
-                );
-                AdvanceScript(2, script, end);
-            }
-            else if (opcode == 0xC1)
-            {
-                dump->Log("jump(); -- C1\n");
-                script += 1;
-            }
-            else if (opcode == 0xC2)
-            {
-                dump->Log("execute_damage(" +
-                    HexToString(file->GetU8(script + 1), 2, '0') +
-                    "); -- C2\n"
-                );
-                AdvanceScript(2, script, end);
-            }
-            else if (opcode == 0xC5)
-            {
-                dump->Log("set_unit_fade_wait(); -- C9\n");
-                AdvanceScript(1, script, end);
-            }
-            else if (opcode == 0xC6)
-            {
-                dump->Log("set_unit_fade_time(" +
-                    HexToString(file->GetU8(script + 1), 2, '0') +
-                    "); -- C6\n"
-                );
-                AdvanceScript(2, script, end);
-            }
-            else if (opcode == 0xC9)
-            {
-                dump->Log("jump_label(); -- C9\n");
-                AdvanceScript(1, script, end);
-            }
-            else if (opcode == 0xCA)
-            {
-                dump->Log("jump_if_not_loaded(); -- CA\n");
-                AdvanceScript(1, script, end);
-            }
-            else if (opcode == 0xD1)
-            {
-                dump->Log("move_to_target(\"linear_movement\", " +
-                    HexToString(file->GetU16LE(script + 1), 4, '0') +
-                    ", " +
-                    HexToString(file->GetU16LE(script + 3), 4, '0') +
-                    ", " +
-                    HexToString(file->GetU8(script + 5), 2, '0') +
-                    "); -- D1\n"
-                );
-                AdvanceScript(6, script, end);
-            }
-            else if (opcode == 0xD8)
-            {
-                dump->Log("play_sound_for_attacker(" +
-                    HexToString(file->GetU8(script + 1), 2, '0') +
-                    ", " +
-                    HexToString(file->GetU16LE(script + 2), 4, '0') +
-                    "); -- D8\n"
-                );
-                AdvanceScript(4, script, end);
-            }
-            else if (opcode == 0xE5)
-            {
-                dump->Log("return_direction(); -- E5\n");
-                AdvanceScript(1, script, end);
-            }
-            else if (opcode == 0xE8)
-            {
-                dump->Log("load_additional_effect(); -- E8\n");
-                AdvanceScript(1, script, end);
-            }
-            else if (opcode == 0xEA)
-            {
-                dump->Log("show_action_name(); -- EA\n");
-                AdvanceScript(1, script, end);
-            }
-            else if (opcode == 0xEC)
-            {
-                dump->Log("execute_additional_effect(); -- EC\n");
-                AdvanceScript(1, script, end);
-            }
-            else if (opcode == 0xEE)
-            {
-                dump->Log("return_to_idle(); -- EE\n");
-                script += 1;
-            }
-            else if (opcode == 0xF0)
-            {
-                dump->Log("set_effect(\"foot_dust\"); -- F0\n");
-                AdvanceScript(1, script, end);
-            }
-            else if (opcode == 0xF3)
-            {
-                dump->Log("wait(); -- F3\n");
-                AdvanceScript(1, script, end);
-            }
-            else if (opcode == 0xF4)
-            {
-                dump->Log("set_wait(" +
-                    HexToString(file->GetU8(script + 1), 2, '0') +
-                    "); -- F4\n"
-                );
-                AdvanceScript(2, script, end);
-            }
-            else if (opcode == 0xF6)
-            {
-                dump->Log("play_die_if_dead(); -- F6\n");
-                AdvanceScript(1, script, end);
-            }
-            else if (opcode == 0xF7)
-            {
-                dump->Log("execute_attack(" +
-                    HexToString(file->GetU8(script + 1), 2, '0') +
-                    "); -- F7\n"
-                );
-                AdvanceScript(2, script, end);
-            }
-            else if (opcode == 0xFA)
-            {
-                dump->Log("return_position(); -- FA\n");
-                AdvanceScript(1, script, end);
-            }
-            else if (opcode == 0xFC)
-            {
-                dump->Log("set_direction(); -- FC\n");
-                AdvanceScript(1, script, end);
-            }
-            else
-            {
-                dump->Log("[ACTION_OPCODE " + HexToString(opcode, 2, '0') + "]\n");
-                script += 1;
-            }
-        }
-
-        dump->Log("end;\n");
-    }
-}

+ 0 - 15
utilities/ffvii_battle_model_exporter/src/AnimationScriptDumper.h

@@ -1,15 +0,0 @@
-#ifndef ANIMATION_SCRIPT_DUMPER_H
-#define ANIMATION_SCRIPT_DUMPER_H
-
-#include <Ogre.h>
-
-#include "common/File.h"
-#include "common/Logger.h"
-
-
-
-void AnimationScriptDumper(File* file, int offset_to_anim_file, Logger* dump);
-
-
-
-#endif // ANIMATION_SCRIPT_DUMPER_H

+ 0 - 284
utilities/ffvii_battle_model_exporter/src/EnemyFile.cpp

@@ -1,284 +0,0 @@
-#include "EnemyFile.h"
-
-#include <Ogre.h>
-
-#include "AnimationExtractor.h"
-#include "AnimationScriptDumper.h"
-#include "../../common/Logger.h"
-#include "../../common/OgreGenUtilites.h"
-#include "../../common/TimToVram.h"
-
-
-
-EnemyFile::EnemyFile( const Ogre::String& file ):
-    LzsFile( file ),
-    m_WithWeapon( false )
-{
-}
-
-
-
-EnemyFile::EnemyFile( File* pFile ):
-    LzsFile( pFile ),
-    m_WithWeapon( false )
-{
-}
-
-
-
-EnemyFile::EnemyFile( File* pFile, u32 offset, u32 length ):
-    LzsFile( pFile, offset, length ),
-    m_WithWeapon( false )
-{
-}
-
-
-
-EnemyFile::EnemyFile( u8* pBuffer, u32 offset, u32 length ):
-    LzsFile( pBuffer, offset, length ),
-    m_WithWeapon( false )
-{
-}
-
-
-
-EnemyFile::~EnemyFile()
-{
-}
-
-
-
-Ogre::Entity*
-EnemyFile::GetModel( const EnemyInfo& info )
-{
-    DumpSettings( "exported/models/ffvii/battle/units/" + info.data.name + ".lua" );
-
-    VectorTexForGen textures;
-    Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().create(info.data.name + "export", "General");
-    Ogre::SkeletonPtr skeleton = Ogre::SkeletonManager::getSingleton().create(info.data.name + "export", "General");
-
-
-
-    int offset_to_models_description = GetU32LE(0x04);
-    int number_of_bones = GetU32LE(offset_to_models_description);
-
-    Ogre::Bone* root1 = skeleton->createBone("0", 0);
-    Ogre::Bone* root2 = skeleton->createBone("1", 1);
-    root1->addChild(root2);
-
-    for (int i = 0; i < number_of_bones; ++i)
-    {
-        Bone bone;
-        bone.parent_id = (s16)GetU16LE(offset_to_models_description + 0x0c + i * 0x08 + 0x00);
-        bone.length    = (s16)GetU16LE(offset_to_models_description + 0x0c + i * 0x08 + 0x02);
-        bone.offset    = GetU32LE(offset_to_models_description + 0x0c + i * 0x08 + 0x04);
-        m_Skeleton.push_back(bone);
-
-        Ogre::Bone* bone1 = skeleton->createBone(Ogre::StringConverter::toString(i * 2 + 2), i * 2 + 2);
-        Ogre::Bone* bone2 = skeleton->createBone(Ogre::StringConverter::toString(i * 2 + 3), i * 2 + 3);
-
-        LOGGER->Log("Skeleton bone-" + Ogre::StringConverter::toString(i + 2) + " length-" + Ogre::StringConverter::toString(bone.length) + " parent-" + Ogre::StringConverter::toString(bone.parent_id) +  + "\n");
-        LOGGER->Log("bone1 " + Ogre::StringConverter::toString(i * 2 + 2) + ", bone2 " + Ogre::StringConverter::toString(i * 2 + 3) + "\n");
-
-        skeleton->getBone(bone.parent_id * 2 + 1)->addChild(bone1);
-        bone1->addChild(bone2);
-    }
-
-    if( m_WithWeapon == true )
-    {
-        Ogre::Bone* weapon1 = skeleton->createBone("weapon_1", number_of_bones * 2 + 2);
-        root1->addChild(weapon1);
-        Ogre::Bone* weapon2 = skeleton->createBone("weapon_2", number_of_bones * 2 + 3);
-        weapon1->addChild(weapon2);
-    }
-
-
-
-    for (size_t bone = 0; bone < m_Skeleton.size(); ++bone)
-    {
-        int offset = m_Skeleton[bone].offset;
-        if (offset != 0)
-        {
-            int offset_to_vertex = offset_to_models_description + offset;
-            MeshExtractor(info.data, "ffvii/battle_model/" + info.data.name, this, offset_to_vertex, textures, mesh, Ogre::StringConverter::toString(bone), bone * 2 + 2);
-        }
-    }
-
-    if (m_WithWeapon == true)
-    {
-        int number_of_files = GetU32LE(0x00);
-        int offset_to_models_description = GetU32LE(number_of_files * 0x04 - 0x04);
-        int offset_to_vertex = offset_to_models_description + 0x0c;
-        MeshExtractor(info.data, "ffvii/battle_model/" + info.data.name, this, offset_to_vertex, textures, mesh, "weapon", number_of_bones * 2 + 3);
-    }
-
-
-
-    AnimationExtractor(this, skeleton, info, m_Skeleton, m_WithWeapon);
-
-
-
-    // <OGRE> ///////////////////////////////
-    skeleton->optimiseAllAnimations();
-    Ogre::SkeletonSerializer skeleton_serializer;
-    skeleton_serializer.exportSkeleton(skeleton.getPointer(), "exported/models/ffvii/battle/units/" + info.data.name + ".skeleton");
-
-    // Update bounds
-    Ogre::AxisAlignedBox aabb(-999, -999, -999, 999, 999, 999);
-    mesh->_setBounds(aabb, false);
-    mesh->_setBoundingSphereRadius(999);
-
-    mesh->setSkeletonName( "models/ffvii/battle/units/" + info.data.name + ".skeleton" );
-
-    Ogre::MeshSerializer ser;
-    ser.exportMesh(mesh.getPointer(), "exported/models/ffvii/battle/units/" + info.data.name + ".mesh");
-
-
-
-    // create and export textures for model
-    if (textures.size() > 0)
-    {
-        int number_of_files = GetU32LE(0x00);
-        int offset_to_texture = GetU32LE(number_of_files * 0x04);
-        Vram* vram = Vram::MakeInstance().release();
-
-        LoadTimFileToVram(this, offset_to_texture, vram);
-
-        CreateTexture( vram, info.data, "exported/models/ffvii/battle/units/" + info.data.name + ".png", textures );
-        delete vram;
-    }
-
-
-
-    //CreateMaterial("ffvii/battle_model/" + info.data.name, "exported/models/ffvii/battle/units/" + info.data.name + ".material", (textures.size() > 0) ? "models/ffvii/battle/units/" + info.data.name + ".png" : "", "Test/Fixed", "Test/Red");
-    CreateMaterial("ffvii/battle_model/" + info.data.name, "exported/models/ffvii/battle/units/" + info.data.name + ".material", (textures.size() > 0) ? "models/ffvii/battle/units/" + info.data.name + ".png" : "", "", "");
-
-
-
-    Ogre::SceneManager* scene_manager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
-    Ogre::Entity* thisEntity = scene_manager->createEntity( info.data.name, "models/ffvii/battle/units/" + info.data.name + ".mesh" );
-    //thisEntity->setDisplaySkeleton(true);
-    //thisEntity->setDebugDisplayEnabled(true);
-    thisEntity->setVisible(false);
-    thisEntity->getAnimationState("Idle")->setEnabled(true);
-    thisEntity->getAnimationState("Idle")->setLoop(true);
-    Ogre::SceneNode* thisSceneNode = scene_manager->getRootSceneNode()->createChildSceneNode();
-    thisSceneNode->setPosition(0, 0, 0);
-    thisSceneNode->roll(Ogre::Radian(Ogre::Degree(180.0f)));
-    thisSceneNode->yaw(Ogre::Radian(Ogre::Degree(120.0f)));
-    thisSceneNode->pitch(Ogre::Radian(Ogre::Degree(90.0f)));
-    thisSceneNode->attachObject(thisEntity);
-
-    return thisEntity;
-}
-
-
-
-void
-EnemyFile::DumpSettings(const Ogre::String& file)
-{
-    Logger* settings = new Logger( file );
-
-    int model_settings_offset = GetU32LE(0x08);
-
-    m_WithWeapon = (GetU8( model_settings_offset + 2 ) & 0x80) > 0;
-    LOGGER->Log( "Model With Weapon '" + Ogre::StringConverter::toString(m_WithWeapon) + "'\n" );
-
-    settings->Log("// animation scripts\n");
-    settings->Log("+00 [][]     " + HexToString(GetU16LE(model_settings_offset + 0), 4, '0') + " - if this is not 0 we add 0x40 bit to 8015190b\n");
-    settings->Log("+02 []       " + HexToString(GetU8(model_settings_offset + 2), 2, '0') + " - 0x3f - dead type. 0x80 - play secondary animation\n");
-    settings->Log("+03 []       " + HexToString(GetU8(model_settings_offset + 3), 2, '0') + "\n");
-    settings->Log("+04 [][]     " + HexToString(GetU16LE(model_settings_offset + 4), 4, '0') + " - collision radius. Set to 801518e4+6\n");
-    settings->Log("+06 [][]     " + HexToString(GetU16LE(model_settings_offset + 6), 4, '0') + " - to 801518ec\n");
-    settings->Log("+08 [][]     " + HexToString(GetU16LE(model_settings_offset + 8), 4, '0') + " - to 801518ee\n");
-    settings->Log("+0a [][]     " + HexToString(GetU16LE(model_settings_offset + 0xa), 4, '0') + " - to 801518f0\n");
-    settings->Log("+0c [][]     " + HexToString(GetU16LE(model_settings_offset + 0xc), 4, '0') + "\n");
-    settings->Log("+0e [][]     " + HexToString(GetU16LE(model_settings_offset + 0xe), 4, '0') + "\n");
-    settings->Log("+10 [][]     " + HexToString(GetU16LE(model_settings_offset + 0x10), 4, '0') + " - filler?\n");
-
-    settings->Log("+12 array of joints (bone indexes)\n    ");
-    for (int i = 0; i < 0x10; ++i)
-    {
-        if (i != 0)
-        {
-            settings->Log(" ");
-        }
-        settings->Log(HexToString(GetU8(model_settings_offset + 0x12 + i), 2, '0'));
-    }
-    settings->Log("\n");
-
-    settings->Log("+22 [][]     " + HexToString(GetU16LE(model_settings_offset + 0x22), 4, '0') + " - filler?\n");
-
-    settings->Log("+24 array of 8 offsets to something\n    ");
-    for (int i = 0; i < 8; ++i)
-    {
-        if (i != 0)
-        {
-            settings->Log(" ");
-        }
-        settings->Log(HexToString(GetU32LE(model_settings_offset + 0x24 + i * 4), 8, '0'));
-    }
-    settings->Log("\n");
-
-    settings->Log("+44 array of 4 something\n    ");
-    for (int i = 0; i < 4; ++i)
-    {
-        if (i != 0)
-        {
-            settings->Log(" ");
-        }
-        settings->Log(HexToString(GetU16LE(model_settings_offset + 0x44 + i * 2), 4, '0'));
-    }
-    settings->Log("\n");
-
-    settings->Log("+4c array of 6 something\n    ");
-    for (int i = 0; i < 6; ++i)
-    {
-        if (i != 0)
-        {
-            settings->Log(" ");
-        }
-        settings->Log(HexToString(GetU16LE(model_settings_offset + 0x4c + i * 2), 4, '0'));
-    }
-    settings->Log("\n");
-
-    settings->Log("+58 array of 6 something\n    ");
-    for (int i = 0; i < 6; ++i)
-    {
-        if (i != 0)
-        {
-            settings->Log(" ");
-        }
-        settings->Log(HexToString(GetU16LE(model_settings_offset + 0x58 + i * 2), 4, '0'));
-    }
-    settings->Log("\n");
-
-    settings->Log("+64 [][]     " + HexToString(GetU16LE(model_settings_offset + 0x64), 4, '0') + "\n");
-    settings->Log("+66 [][]     " + HexToString(GetU16LE(model_settings_offset + 0x66), 4, '0') + " - filler?\n");
-
-    settings->Log("+68 array of 32 offsets to animation scripts\n    ");
-    for (int i = 0; i < 0x20; ++i)
-    {
-        if (i != 0)
-        {
-            if (i % 8 == 0)
-            {
-                settings->Log("\n    ");
-            }
-            else
-            {
-                settings->Log(" ");
-            }
-        }
-        settings->Log(HexToString(GetU32LE(model_settings_offset + 0x68 + i * 4), 8, '0'));
-    }
-    settings->Log("\n");
-
-
-
-    AnimationScriptDumper(this, model_settings_offset, settings);
-
-
-
-    delete settings;
-}

+ 0 - 52
utilities/ffvii_battle_model_exporter/src/EnemyFile.h

@@ -1,52 +0,0 @@
-#ifndef ENEMY_FILE_H
-#define ENEMY_FILE_H
-
-#include "MeshExtractor.h"
-#include "common/LzsFile.h"
-#include "../../common/Vram.h"
-#include "../../common/OgreGenUtilites.h"
-
-
-
-struct EnemyInfo
-{
-    MeshData                  data;
-    Ogre::String              file_name;
-    std::vector<Ogre::String> animations;
-};
-
-
-
-struct Bone
-{
-    int length;
-    int parent_id;
-    int offset;
-
-    float tx, ty, tz;
-    float rx, ry, rz;
-};
-typedef std::vector<Bone> Skeleton;
-
-
-
-class EnemyFile : public LzsFile
-{
-public:
-    EnemyFile(const Ogre::String& file);
-    EnemyFile(File* pFile);
-    EnemyFile(File* pFile, u32 offset, u32 length);
-    EnemyFile(u8* pBuffer, u32 offset, u32 length);
-    virtual ~EnemyFile();
-
-    Ogre::Entity* GetModel(const EnemyInfo& info);
-    void          DumpSettings(const Ogre::String& file);
-
-private:
-    Skeleton m_Skeleton;
-    bool     m_WithWeapon;
-};
-
-
-
-#endif // BSX_FILE_h

+ 0 - 188
utilities/ffvii_battle_model_exporter/src/Main.cpp

@@ -1,188 +0,0 @@
-#include <Ogre.h>
-#include "../../common/OgreBase.h"
-#include "../../common/Logger.h"
-
-#include "EnemyFile.h"
-#include "RamEffectFile.h"
-#include "StageFile.h"
-
-
-std::vector<EnemyInfo> models_all;
-std::vector<EffectInfo> effects_all;
-std::vector<StageInfo> stages_all;
-
-
-
-void
-fill_names()
-{
-    EnemyInfo info;
-
-    Ogre::ConfigFile cf;
-    cf.load("export_models.cfg");
-    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
-
-    while (seci.hasMoreElements())
-    {
-        Ogre::String names = seci.peekNextKey();
-        Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
-        if (names != "")
-        {
-            Ogre::StringVector name = Ogre::StringUtil::split(names, ":", 3);
-            if (name.size() < 3)
-            {
-                LOGGER->Log("In '" + names + "' not enough names. Must be 3.\n");
-                continue;
-            }
-            info.file_name = name[0];
-            info.data.name = name[1];
-
-            Ogre::StringVector tex_size = Ogre::StringUtil::split(name[2], "x", 2);
-            info.data.tex_width = Ogre::StringConverter::parseInt(tex_size[0]);
-            info.data.tex_height = Ogre::StringConverter::parseInt(tex_size[1]);
-
-            if (info.file_name != "")
-            {
-                Ogre::ConfigFile::SettingsMultiMap::iterator i;
-                for (i = settings->begin(); i != settings->end(); ++i)
-                {
-                    info.animations.push_back(i->second);
-                    LOGGER->Log("Animation add:" + info.file_name + " " + i->second + "\n");
-                }
-
-                models_all.push_back(info);
-                info.animations.clear();
-            }
-        }
-    }
-
-
-
-    EffectInfo effect;
-    cf.load("export_effects.cfg");
-    seci = cf.getSectionIterator();
-
-    while (seci.hasMoreElements())
-    {
-        Ogre::String names = seci.peekNextKey();
-        Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
-        if (names == "")
-        {
-            Ogre::ConfigFile::SettingsMultiMap::iterator i;
-            for (i = settings->begin(); i != settings->end(); ++i)
-            {
-                effect.data.name = i->second;
-                effect.data.tex_width = 256;
-                effect.data.tex_height = 256;
-                effect.offset = Ogre::StringConverter::parseInt(i->first);
-
-                LOGGER->Log("Effect: " + i->second + ": " + i->first);
-
-                effects_all.push_back(effect);
-            }
-        }
-    }
-
-
-
-    StageInfo stage;
-    cf.load("export_stages.cfg");
-    seci = cf.getSectionIterator();
-
-    while (seci.hasMoreElements())
-    {
-        Ogre::String names = seci.peekNextKey();
-        Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
-        if (names == "")
-        {
-            Ogre::ConfigFile::SettingsMultiMap::iterator i;
-            for (i = settings->begin(); i != settings->end(); ++i)
-            {
-                stage.file_name = i->first;
-
-                Ogre::StringVector name = Ogre::StringUtil::split(i->second, ":", 2);
-                if (name.size() < 2)
-                {
-                    LOGGER->Log("In '" + names + "' not enough names. Must be 2.\n");
-                    continue;
-                }
-
-                stage.data.name = name[0];
-
-                Ogre::StringVector tex_size = Ogre::StringUtil::split(name[1], "x", 2);
-                stage.data.tex_width = Ogre::StringConverter::parseInt(tex_size[0]);
-                stage.data.tex_height = Ogre::StringConverter::parseInt(tex_size[1]);
-
-                LOGGER->Log("Stage: " + i->first + ": " + i->second + "\n");
-
-                stages_all.push_back(stage);
-            }
-        }
-    }
-
-
-    LOGGER->Log("Initialize export list finished.\n\n\n\n");
-}
-
-int
-main(int argc, char *argv[])
-{
-    InitializeOgreBase( "FFVII Battle Model Exporter" );
-
-
-
-    fill_names();
-
-
-
-
-    for (size_t i = 0; i < models_all.size(); ++i)
-    {
-        EnemyFile model("data/" + models_all[i].file_name + ".LZS");
-
-        //model.WriteFile(models_all[i].file_name + "_u.LZS");
-        Ogre::Entity* exported_entity = model.GetModel(models_all[i]);
-
-        if (exported_entity != NULL)
-        {
-            entities.push_back(exported_entity);
-        }
-    }
-
-    for (size_t i = 0; i < effects_all.size(); ++i)
-    {
-        RamEffectFile effect("data/ram.bin");
-        Ogre::Entity* exported_entity = effect.GetModel(effects_all[i]);
-        if (exported_entity != NULL)
-        {
-            entities.push_back(exported_entity);
-        }
-    }
-
-    for (size_t i = 0; i < stages_all.size(); ++i)
-    {
-        StageFile model("data/" + stages_all[i].file_name + ".LZS");
-
-        //model.WriteFile(models_all[i].file_name + "_u.LZS");
-        Ogre::Entity* exported_entity = model.GetModel(stages_all[i]);
-
-        if (exported_entity != NULL)
-        {
-            entities.push_back(exported_entity);
-        }
-    }
-
-    entities[ 0 ]->setVisible(true);
-
-
-
-    Ogre::Root::getSingleton().startRendering();
-
-
-
-    DeinitializeOgreBase();
-
-
-
-    return 0;
-}

+ 0 - 441
utilities/ffvii_battle_model_exporter/src/MeshExtractor.cpp

@@ -1,441 +0,0 @@
-#include "MeshExtractor.h"
-
-#define POSITION_BINDING 0
-#define COLOUR_BINDING 1
-#define TEXTURE_BINDING 2
-
-#include "../../common/Logger.h"
-#include "../../common/OgreGenUtilites.h"
-
-
-
-void
-MeshExtractor( const MeshData& mesh_data, const Ogre::String& material_name, File* file, int offset_to_data, VectorTexForGen& textures, const Ogre::MeshPtr& mesh, const Ogre::String& name, int bone_id )
-{
-    int offset_to_vertex     = offset_to_data;
-    int offset_to_triangle_t = offset_to_vertex + 0x04 + file->GetU32LE( offset_to_vertex );
-    int number_of_triangle_t = file->GetU16LE( offset_to_triangle_t );
-    u16 tpage  = file->GetU16LE( offset_to_triangle_t + 0x02 );
-    int offset_to_quad_t     = offset_to_triangle_t + 0x04 + number_of_triangle_t * 0x10;
-    int number_of_quad_t     = file->GetU16LE( offset_to_quad_t );
-    int offset_to_triangle   = offset_to_quad_t + 0x4 + number_of_quad_t * 0x14;
-    int number_of_triangle   = file->GetU16LE( offset_to_triangle );
-    int offset_to_quad       = offset_to_triangle + 0x4 + number_of_triangle * 0x14;
-    int number_of_quad       = file->GetU16LE( offset_to_quad );
-
-    Ogre::SubMesh* sub_mesh = mesh->createSubMesh( name );
-    sub_mesh->setMaterialName( material_name );
-    sub_mesh->useSharedVertices = false;
-    sub_mesh->operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
-
-    // Allocate and prepare vertex data
-    sub_mesh->vertexData = new Ogre::VertexData();
-    sub_mesh->vertexData->vertexStart = 0;
-    sub_mesh->vertexData->vertexCount = static_cast< size_t >( number_of_triangle_t * 3 + number_of_quad_t * 6 + number_of_triangle * 3 + number_of_quad * 6 );
-
-    sub_mesh->indexData = new Ogre::IndexData();
-    sub_mesh->indexData->indexStart = 0;
-    sub_mesh->indexData->indexCount = sub_mesh->vertexData->vertexCount;
-    sub_mesh->indexData->indexBuffer = Ogre::HardwareBufferManager::getSingleton().createIndexBuffer(
-        Ogre::HardwareIndexBuffer::IT_16BIT,
-        sub_mesh->indexData->indexCount,
-        Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
-    u16* idata = static_cast< u16* >( sub_mesh->indexData->indexBuffer->lock( Ogre::HardwareBuffer::HBL_DISCARD ) );
-    u32 cur_index = 0;
-
-    Ogre::VertexDeclaration* decl = sub_mesh->vertexData->vertexDeclaration;
-    Ogre::VertexBufferBinding* bind = sub_mesh->vertexData->vertexBufferBinding;
-    // 1st buffer
-    decl->addElement( POSITION_BINDING, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION );
-    Ogre::HardwareVertexBufferSharedPtr vbuf0 = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
-        decl->getVertexSize( POSITION_BINDING ),
-        sub_mesh->vertexData->vertexCount,
-        Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
-    bind->setBinding( POSITION_BINDING, vbuf0 );
-
-    // 2nd buffer
-    decl->addElement( COLOUR_BINDING, 0, Ogre::VET_COLOUR, Ogre::VES_DIFFUSE );
-    Ogre::HardwareVertexBufferSharedPtr vbuf1 = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
-        decl->getVertexSize( COLOUR_BINDING ),
-        sub_mesh->vertexData->vertexCount,
-        Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
-    // Set vertex buffer binding so buffer 1 is bound to our colour buffer
-    bind->setBinding( COLOUR_BINDING, vbuf1 );
-
-    // 3rd buffer
-    decl->addElement( TEXTURE_BINDING, 0, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0 );
-    Ogre::HardwareVertexBufferSharedPtr vbuf2 = Ogre::HardwareBufferManager::getSingleton().createVertexBuffer(
-        decl->getVertexSize( TEXTURE_BINDING ),
-        sub_mesh->vertexData->vertexCount,
-        Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY );
-    bind->setBinding( TEXTURE_BINDING, vbuf2 );
-
-    float* pPos   = static_cast< float* >( vbuf0->lock( Ogre::HardwareBuffer::HBL_DISCARD ) );
-    float* tPos   = static_cast< float* >( vbuf2->lock( Ogre::HardwareBuffer::HBL_DISCARD ) );
-
-    Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
-
-    std::vector<Ogre::RGBA> coloursVec(sub_mesh->vertexData->vertexCount);
-    Ogre::RGBA* colours = coloursVec.data();
-
-
-    // add textured triangle
-    for (int j = 0; j < number_of_triangle_t; ++j)
-    {
-        int offset_a = file->GetU16LE(offset_to_triangle_t + 0x4 + j * 0x10 + 0x0);
-        int offset_b = file->GetU16LE(offset_to_triangle_t + 0x4 + j * 0x10 + 0x2);
-        int offset_c = file->GetU16LE(offset_to_triangle_t + 0x4 + j * 0x10 + 0x4);
-
-        Ogre::Vector3 a((s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_a + 00),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_a + 02),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_a + 04));
-        Ogre::Vector3 b((s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_b + 00),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_b + 02),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_b + 04));
-        Ogre::Vector3 c((s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_c + 00),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_c + 02),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_c + 04));
-        a /= 512;
-        b /= 512;
-        c /= 512;
-
-        u16 clut = file->GetU16LE(offset_to_triangle_t + 0x4 + j * 0x10 + 0xa);
-        int clut_x = (clut & 0x003f) << 3;
-        int clut_y = (clut & 0xffc0) >> 6;
-        int bpp    = (tpage >> 0x7) & 0x3;
-        int vram_x = (tpage & 0xf) * 64;
-        int vram_y = ((tpage & 0x10) >> 4) * 256;
-        TexForGen texture;
-        texture.palette_x = clut_x;
-        texture.palette_y = clut_y;
-        texture.texture_x = vram_x;
-        texture.texture_y = vram_y;
-        texture.bpp = ( BPP )bpp;
-        AddTexture( texture, mesh_data, textures, LOGGER );
-
-        Ogre::Vector2 at(0, 0);
-        Ogre::Vector2 bt(0, 0);
-        Ogre::Vector2 ct(0, 0);
-
-        int x = file->GetU8(offset_to_triangle_t + 0x4 + j * 0x10 + 0x8) + texture.start_x;
-        at.x = x / (float)mesh_data.tex_width;
-        int y = file->GetU8(offset_to_triangle_t + 0x4 + j * 0x10 + 0x9) + texture.start_y;
-        at.y = y / (float)mesh_data.tex_height;
-        x = file->GetU8(offset_to_triangle_t + 0x4 + j * 0x10 + 0xc) + texture.start_x;
-        bt.x = x / (float)mesh_data.tex_width;
-        y = file->GetU8(offset_to_triangle_t + 0x4 + j * 0x10 + 0xd) + texture.start_y;
-        bt.y = y / (float)mesh_data.tex_height;
-        x = file->GetU8(offset_to_triangle_t + 0x4 + j * 0x10 + 0xe) + texture.start_x;
-        ct.x = x / (float)mesh_data.tex_width;
-        y = file->GetU8(offset_to_triangle_t + 0x4 + j * 0x10 + 0xf) + texture.start_y;
-        ct.y = y / (float)mesh_data.tex_height;
-
-        *pPos++ = a.x; *pPos++ = a.y; *pPos++ = a.z;
-        *pPos++ = c.x; *pPos++ = c.y; *pPos++ = c.z;
-        *pPos++ = b.x; *pPos++ = b.y; *pPos++ = b.z;
-
-        *tPos++ = at.x; *tPos++ = at.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-
-        Ogre::ColourValue colour = Ogre::ColourValue(file->GetU8(offset_to_triangle_t + 0x4 + j * 0x10 + 0x6) / 256.0f,
-                                                     file->GetU8(offset_to_triangle_t + 0x4 + j * 0x10 + 0x6) / 256.0f,
-                                                     file->GetU8(offset_to_triangle_t + 0x4 + j * 0x10 + 0x6) / 256.0f,
-                                                     1.0f);
-
-        rs->convertColourValue(colour, colours + cur_index + 0);
-        rs->convertColourValue(colour, colours + cur_index + 1);
-        rs->convertColourValue(colour, colours + cur_index + 2);
-
-        idata[cur_index + 0] = cur_index + 0;
-        idata[cur_index + 1] = cur_index + 1;
-        idata[cur_index + 2] = cur_index + 2;
-
-        cur_index += 3;
-    }
-
-
-
-    // add textured quad
-    for (int j = 0; j < number_of_quad_t; ++j)
-    {
-        int offset_a = file->GetU16LE(offset_to_quad_t + 0x4 + j * 0x14 + 0x0);
-        int offset_b = file->GetU16LE(offset_to_quad_t + 0x4 + j * 0x14 + 0x2);
-        int offset_c = file->GetU16LE(offset_to_quad_t + 0x4 + j * 0x14 + 0x4);
-        int offset_d = file->GetU16LE(offset_to_quad_t + 0x4 + j * 0x14 + 0x6);
-
-        Ogre::Vector3 a((s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_a + 00),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_a + 02),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_a + 04));
-        Ogre::Vector3 b((s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_b + 00),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_b + 02),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_b + 04));
-        Ogre::Vector3 c((s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_c + 00),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_c + 02),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_c + 04));
-        Ogre::Vector3 d((s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_d + 00),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_d + 02),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_d + 04));
-        a /= 512;
-        b /= 512;
-        c /= 512;
-        d /= 512;
-
-        u16 clut = file->GetU16LE(offset_to_quad_t + 0x4 + j * 0x14 + 0xa);
-        int clut_x = (clut & 0x003f) << 3;
-        int clut_y = (clut & 0xffc0) >> 6;
-        int bpp    = (tpage >> 0x7) & 0x3;
-        int vram_x = (tpage & 0xf) * 64;
-        int vram_y = ((tpage & 0x10) >> 4) * 256;
-        TexForGen texture;
-        texture.palette_x = clut_x;
-        texture.palette_y = clut_y;
-        texture.texture_x = vram_x;
-        texture.texture_y = vram_y;
-        texture.bpp = ( BPP )bpp;
-        AddTexture( texture, mesh_data, textures, LOGGER );
-
-        Ogre::Vector2 at(0, 0);
-        Ogre::Vector2 bt(0, 0);
-        Ogre::Vector2 ct(0, 0);
-        Ogre::Vector2 dt(0, 0);
-
-        int x = file->GetU8(offset_to_quad_t + 0x4 + j * 0x14 + 0x8) + texture.start_x;
-        at.x = x / (float)mesh_data.tex_width;
-        int y = file->GetU8(offset_to_quad_t + 0x4 + j * 0x14 + 0x9) + texture.start_y;
-        at.y = y / (float)mesh_data.tex_height;
-
-        x = file->GetU8(offset_to_quad_t + 0x4 + j * 0x14 + 0xc) + texture.start_x;
-        bt.x = x / (float)mesh_data.tex_width;
-        y = file->GetU8(offset_to_quad_t + 0x4 + j * 0x14 + 0xd) + texture.start_y;
-        bt.y = y / (float)mesh_data.tex_height;
-
-        x = file->GetU8(offset_to_quad_t + 0x4 + j * 0x14 + 0xe) + texture.start_x;
-        ct.x = x / (float)mesh_data.tex_width;
-        y = file->GetU8(offset_to_quad_t + 0x4 + j * 0x14 + 0xf) + texture.start_y;
-        ct.y = y / (float)mesh_data.tex_height;
-
-        x = file->GetU8(offset_to_quad_t + 0x4 + j * 0x14 + 0x10) + texture.start_x;
-        dt.x = x / (float)mesh_data.tex_width;
-        y = file->GetU8(offset_to_quad_t + 0x4 + j * 0x14 + 0x11) + texture.start_y;
-        dt.y = y / (float)mesh_data.tex_height;
-
-        *pPos++ = a.x; *pPos++ = a.y; *pPos++ = a.z;
-        *pPos++ = c.x; *pPos++ = c.y; *pPos++ = c.z;
-        *pPos++ = b.x; *pPos++ = b.y; *pPos++ = b.z;
-        *pPos++ = b.x; *pPos++ = b.y; *pPos++ = b.z;
-        *pPos++ = c.x; *pPos++ = c.y; *pPos++ = c.z;
-        *pPos++ = d.x; *pPos++ = d.y; *pPos++ = d.z;
-
-        *tPos++ = at.x; *tPos++ = at.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-        *tPos++ = dt.x; *tPos++ = dt.y;
-
-        Ogre::ColourValue colour = Ogre::ColourValue(file->GetU8(offset_to_quad_t + 0x4 + j * 0x14 + 0x12) / 256.0f,
-                                                     file->GetU8(offset_to_quad_t + 0x4 + j * 0x14 + 0x12) / 256.0f,
-                                                     file->GetU8(offset_to_quad_t + 0x4 + j * 0x14 + 0x12) / 256.0f,
-                                                     1.0f);
-
-        rs->convertColourValue(colour, colours + cur_index + 0);
-        rs->convertColourValue(colour, colours + cur_index + 1);
-        rs->convertColourValue(colour, colours + cur_index + 2);
-        rs->convertColourValue(colour, colours + cur_index + 3);
-        rs->convertColourValue(colour, colours + cur_index + 4);
-        rs->convertColourValue(colour, colours + cur_index + 5);
-
-        idata[cur_index + 0] = cur_index + 0;
-        idata[cur_index + 1] = cur_index + 1;
-        idata[cur_index + 2] = cur_index + 2;
-        idata[cur_index + 3] = cur_index + 3;
-        idata[cur_index + 4] = cur_index + 4;
-        idata[cur_index + 5] = cur_index + 5;
-
-        cur_index += 6;
-    }
-
-
-
-    // add color triangle
-    for (int j = 0; j < number_of_triangle; ++j)
-    {
-        int offset_a = file->GetU16LE(offset_to_triangle + 0x4 + j * 0x14 + 0x0);
-        int offset_b = file->GetU16LE(offset_to_triangle + 0x4 + j * 0x14 + 0x2);
-        int offset_c = file->GetU16LE(offset_to_triangle + 0x4 + j * 0x14 + 0x4);
-
-        Ogre::Vector3 a((s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_a + 00),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_a + 02),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_a + 04));
-        Ogre::Vector3 b((s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_b + 00),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_b + 02),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_b + 04));
-        Ogre::Vector3 c((s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_c + 00),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_c + 02),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_c + 04));
-        a /= 512;
-        b /= 512;
-        c /= 512;
-
-        TexForGen texture;
-        texture.palette_x = 0;
-        texture.palette_y = 0;
-        texture.texture_x = 0;
-        texture.texture_y = 0;
-        texture.bpp = BPP_BLACK;
-        AddTexture( texture, mesh_data, textures, LOGGER );
-
-        Ogre::Vector2 at(0, 0);
-        Ogre::Vector2 bt(0, 0);
-        Ogre::Vector2 ct(0, 0);
-
-        at.x = bt.x = ct.x = texture.start_x / (float)mesh_data.tex_width;
-        at.y = bt.y = ct.y = texture.start_y / (float)mesh_data.tex_height;
-
-        *pPos++ = a.x; *pPos++ = a.y; *pPos++ = a.z;
-        *pPos++ = c.x; *pPos++ = c.y; *pPos++ = c.z;
-        *pPos++ = b.x; *pPos++ = b.y; *pPos++ = b.z;
-
-        *tPos++ = at.x; *tPos++ = at.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-
-        Ogre::ColourValue acolour_ = Ogre::ColourValue(file->GetU8(offset_to_triangle + 0x4 + j * 0x14 + 0x08) / 256.0f,
-                                                       file->GetU8(offset_to_triangle + 0x4 + j * 0x14 + 0x09) / 256.0f,
-                                                       file->GetU8(offset_to_triangle + 0x4 + j * 0x14 + 0x0a) / 256.0f,
-                                                       file->GetU8(offset_to_triangle + 0x4 + j * 0x14 + 0x0b) / 256.0f);
-        Ogre::ColourValue bcolour_ = Ogre::ColourValue(file->GetU8(offset_to_triangle + 0x4 + j * 0x14 + 0x0c) / 256.0f,
-                                                       file->GetU8(offset_to_triangle + 0x4 + j * 0x14 + 0x0d) / 256.0f,
-                                                       file->GetU8(offset_to_triangle + 0x4 + j * 0x14 + 0x0e) / 256.0f,
-                                                       file->GetU8(offset_to_triangle + 0x4 + j * 0x14 + 0x0f) / 256.0f);
-        Ogre::ColourValue ccolour_ = Ogre::ColourValue(file->GetU8(offset_to_triangle + 0x4 + j * 0x14 + 0x10) / 256.0f,
-                                                       file->GetU8(offset_to_triangle + 0x4 + j * 0x14 + 0x11) / 256.0f,
-                                                       file->GetU8(offset_to_triangle + 0x4 + j * 0x14 + 0x12) / 256.0f,
-                                                       file->GetU8(offset_to_triangle + 0x4 + j * 0x14 + 0x13) / 256.0f);
-
-        rs->convertColourValue(acolour_, colours + cur_index + 0);
-        rs->convertColourValue(ccolour_, colours + cur_index + 1);
-        rs->convertColourValue(bcolour_, colours + cur_index + 2);
-
-        idata[cur_index + 0] = cur_index + 0;
-        idata[cur_index + 1] = cur_index + 1;
-        idata[cur_index + 2] = cur_index + 2;
-
-        cur_index += 3;
-    }
-
-
-
-    // add color quad
-    for (int j = 0; j < number_of_quad; ++j)
-    {
-        int offset_a = file->GetU16LE(offset_to_quad + 0x4 + j * 0x18 + 0x0);
-        int offset_b = file->GetU16LE(offset_to_quad + 0x4 + j * 0x18 + 0x2);
-        int offset_c = file->GetU16LE(offset_to_quad + 0x4 + j * 0x18 + 0x4);
-        int offset_d = file->GetU16LE(offset_to_quad + 0x4 + j * 0x18 + 0x6);
-
-        Ogre::Vector3 a((s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_a + 00),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_a + 02),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_a + 04));
-        Ogre::Vector3 b((s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_b + 00),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_b + 02),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_b + 04));
-        Ogre::Vector3 c((s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_c + 00),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_c + 02),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_c + 04));
-        Ogre::Vector3 d((s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_d + 00),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_d + 02),
-                        (s16)file->GetU16LE(offset_to_vertex + 0x04 + offset_d + 04));
-        a /= 512;
-        b /= 512;
-        c /= 512;
-        d /= 512;
-
-        TexForGen texture;
-        texture.palette_x = 0;
-        texture.palette_y = 0;
-        texture.texture_x = 0;
-        texture.texture_y = 0;
-        texture.bpp = BPP_BLACK;
-        AddTexture( texture, mesh_data, textures, LOGGER );
-
-        Ogre::Vector2 at(0, 0);
-        Ogre::Vector2 bt(0, 0);
-        Ogre::Vector2 ct(0, 0);
-        Ogre::Vector2 dt(0, 0);
-
-        at.x = bt.x = ct.x = dt.x = texture.start_x / (float)mesh_data.tex_width;
-        at.y = bt.y = ct.y = dt.y = texture.start_y / (float)mesh_data.tex_height;
-
-        *pPos++ = a.x; *pPos++ = a.y; *pPos++ = a.z;
-        *pPos++ = c.x; *pPos++ = c.y; *pPos++ = c.z;
-        *pPos++ = b.x; *pPos++ = b.y; *pPos++ = b.z;
-        *pPos++ = b.x; *pPos++ = b.y; *pPos++ = b.z;
-        *pPos++ = c.x; *pPos++ = c.y; *pPos++ = c.z;
-        *pPos++ = d.x; *pPos++ = d.y; *pPos++ = d.z;
-
-        *tPos++ = at.x; *tPos++ = at.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-        *tPos++ = dt.x; *tPos++ = dt.y;
-
-        Ogre::ColourValue acolour_ = Ogre::ColourValue(file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x08) / 256.0f,
-                                                       file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x09) / 256.0f,
-                                                       file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x0a) / 256.0f,
-                                                       file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x0b) / 256.0f);
-        Ogre::ColourValue bcolour_ = Ogre::ColourValue(file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x0c) / 256.0f,
-                                                       file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x0d) / 256.0f,
-                                                       file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x0e) / 256.0f,
-                                                       file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x0f) / 256.0f);
-        Ogre::ColourValue ccolour_ = Ogre::ColourValue(file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x10) / 256.0f,
-                                                       file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x11) / 256.0f,
-                                                       file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x12) / 256.0f,
-                                                       file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x13) / 256.0f);
-        Ogre::ColourValue dcolour_ = Ogre::ColourValue(file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x14) / 256.0f,
-                                                       file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x15) / 256.0f,
-                                                       file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x16) / 256.0f,
-                                                       file->GetU8(offset_to_quad + 0x4 + j * 0x18 + 0x17) / 256.0f);
-
-        rs->convertColourValue(acolour_, colours + cur_index + 0);
-        rs->convertColourValue(ccolour_, colours + cur_index + 1);
-        rs->convertColourValue(bcolour_, colours + cur_index + 2);
-        rs->convertColourValue(bcolour_, colours + cur_index + 3);
-        rs->convertColourValue(ccolour_, colours + cur_index + 4);
-        rs->convertColourValue(dcolour_, colours + cur_index + 5);
-
-        idata[cur_index + 0] = cur_index + 0;
-        idata[cur_index + 1] = cur_index + 1;
-        idata[cur_index + 2] = cur_index + 2;
-        idata[cur_index + 3] = cur_index + 3;
-        idata[cur_index + 4] = cur_index + 4;
-        idata[cur_index + 5] = cur_index + 5;
-
-        cur_index += 6;
-    }
-
-    vbuf0->unlock();
-    vbuf1->writeData(0, vbuf1->getSizeInBytes(), colours, true);
-    vbuf2->unlock();
-
-    sub_mesh->indexData->indexBuffer->unlock();
-    // Optimize index data
-    sub_mesh->indexData->optimiseVertexCacheTriList();
-
-    if (bone_id != -1)
-    {
-        LOGGER->Log("Assign bones to vertexes\n");
-
-        int vertex_number = sub_mesh->vertexData->vertexCount;
-        for( int i = 0; i < vertex_number; ++i )
-        {
-            Ogre::VertexBoneAssignment vba;
-            vba.vertexIndex = i;
-            vba.boneIndex = bone_id;
-            vba.weight = 1.0f;
-            sub_mesh->addBoneAssignment( vba );
-        }
-    }
-}

+ 0 - 15
utilities/ffvii_battle_model_exporter/src/MeshExtractor.h

@@ -1,15 +0,0 @@
-#ifndef MESH_EXTRACTOR_H
-#define MESH_EXTRACTOR_H
-
-#include <Ogre.h>
-
-#include "common/File.h"
-#include "common/OgreGenUtilites.h"
-
-
-
-void MeshExtractor(const MeshData& mesh_data, const Ogre::String& material_name, File* file, int offset_to_data, VectorTexForGen& textures, const Ogre::MeshPtr& mesh, const Ogre::String& name, int bone_id = -1);
-
-
-
-#endif // MESH_EXTRACTOR_H

+ 0 - 95
utilities/ffvii_battle_model_exporter/src/RamEffectFile.cpp

@@ -1,95 +0,0 @@
-#include <Ogre.h>
-
-#include "RamEffectFile.h"
-#include "../../common/Logger.h"
-#include "../../common/OgreGenUtilites.h"
-
-
-
-RamEffectFile::RamEffectFile(const Ogre::String& file):
-    File(file)
-{
-}
-
-
-
-RamEffectFile::RamEffectFile(File* pFile):
-    File(pFile)
-{
-}
-
-
-
-RamEffectFile::RamEffectFile(File* pFile, u32 offset, u32 length):
-    File(pFile, offset, length)
-{
-}
-
-
-
-RamEffectFile::RamEffectFile(u8* pBuffer, u32 offset, u32 length):
-    File(pBuffer, offset, length)
-{
-}
-
-
-
-RamEffectFile::~RamEffectFile()
-{
-}
-
-
-
-Ogre::Entity*
-RamEffectFile::GetModel(const EffectInfo info)
-{
-    VectorTexForGen textures;
-    Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().create(info.data.name + "export", "General");
-
-
-
-    int offset_to_models_description = GetU32LE(info.offset) - 0x80000000; // there is additional info in offset + 4 and so on (described in function funcd29d4)
-
-
-
-    int offset_to_vertex     = offset_to_models_description;
-    MeshExtractor(info.data, "ffvii/battle_effect/" + info.data.name, this, offset_to_vertex, textures, mesh, info.data.name);
-
-
-
-    // Update bounds
-    Ogre::AxisAlignedBox aabb(-999, -999, -999, 999, 999, 999);
-    mesh->_setBounds(aabb, false);
-    mesh->_setBoundingSphereRadius(999);
-
-    Ogre::MeshSerializer ser;
-    ser.exportMesh(mesh.getPointer(), "exported/models/ffvii/battle/effects/" + info.data.name + ".mesh");
-
-
-
-    // create and export textures for model
-    if (textures.size() > 0)
-    {
-        Vram* vram = Vram::MakeInstance().release();
-        CreateTexture(vram, info.data, "exported/models/ffvii/battle/effects/" + info.data.name + ".png", textures);
-        delete vram;
-    }
-
-
-
-    CreateMaterial("ffvii/battle_effect/" + info.data.name, "exported/models/ffvii/battle/effects/" + info.data.name + ".material", (textures.size() > 0) ? "models/ffvii/battle/effects/" + info.data.name + ".png" : "", "", "");
-
-
-
-    Ogre::SceneManager* scene_manager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
-    Ogre::Entity* thisEntity = scene_manager->createEntity( info.data.name, "models/ffvii/battle/effects/" + info.data.name + ".mesh" );
-    thisEntity->setVisible(true);
-    Ogre::SceneNode* thisSceneNode = scene_manager->getRootSceneNode()->createChildSceneNode();
-    thisSceneNode->setPosition(0, 0, 0);
-    thisSceneNode->roll(Ogre::Radian(Ogre::Degree(180.0f)));
-    thisSceneNode->yaw(Ogre::Radian(Ogre::Degree(120.0f)));
-    thisSceneNode->pitch(Ogre::Radian(Ogre::Degree(90.0f)));
-    thisSceneNode->attachObject(thisEntity);
-
-    return thisEntity;
-}

+ 0 - 31
utilities/ffvii_battle_model_exporter/src/RamEffectFile.h

@@ -1,31 +0,0 @@
-#ifndef RAM_EFFECT_FILE_h
-#define RAM_EFFECT_FILE_h
-
-#include "MeshExtractor.h"
-#include "common/File.h"
-
-
-
-struct EffectInfo
-{
-    MeshData data;
-    int      offset;
-};
-
-
-
-class RamEffectFile : public File
-{
-public:
-    RamEffectFile(const Ogre::String& file);
-    RamEffectFile(File* pFile);
-    RamEffectFile(File* pFile, u32 offset, u32 length);
-    RamEffectFile(u8* pBuffer, u32 offset, u32 length);
-    virtual ~RamEffectFile();
-
-    Ogre::Entity* GetModel(const EffectInfo info);
-};
-
-
-
-#endif // RAM_EFFECT_FILE_h

+ 0 - 247
utilities/ffvii_battle_model_exporter/src/StageFile.cpp

@@ -1,247 +0,0 @@
-#include "StageFile.h"
-
-#include <Ogre.h>
-
-#include "../../common/Logger.h"
-#include "../../common/TimToVram.h"
-#include "../../common/OgreGenUtilites.h"
-
-
-
-StageFile::StageFile( const Ogre::String& file ):
-    LzsFile( file )
-{
-}
-
-
-
-StageFile::StageFile(File* pFile):
-    LzsFile(pFile)
-{
-}
-
-
-
-StageFile::StageFile(File* pFile, u32 offset, u32 length):
-    LzsFile(pFile, offset, length)
-{
-}
-
-
-
-StageFile::StageFile(u8* pBuffer, u32 offset, u32 length):
-    LzsFile(pBuffer, offset, length)
-{
-}
-
-
-
-StageFile::~StageFile()
-{
-}
-
-
-
-Ogre::Entity*
-StageFile::GetModel( const StageInfo& info )
-{
-    //DumpSettings("exported/" + info.data.name + ".lua");
-
-    VectorTexForGen textures;
-    Ogre::MeshPtr mesh = Ogre::MeshManager::getSingleton().create(info.data.name + "export", "General");
-    Ogre::SkeletonPtr skeleton = Ogre::SkeletonManager::getSingleton().create(info.data.name + "export", "General");
-
-    u32 number_of_files = GetU32LE(0);
-    LOGGER->Log("Number of file " + IntToString(number_of_files) + "\n");
-
-
-
-    Ogre::Bone* root1 = skeleton->createBone( "0", 0 );
-    Ogre::Bone* root2 = skeleton->createBone( "1", 1 );
-    root1->addChild( root2 );
-
-    Ogre::Animation* anim = skeleton->createAnimation( "Idle", 1 );
-    Ogre::NodeAnimationTrack* track1 = anim->createNodeTrack( 0, root1 );
-    track1->removeAllKeyFrames();
-    Ogre::TransformKeyFrame* frame1 = track1->createNodeKeyFrame( 0 );
-    Ogre::Matrix3 matrix;
-    matrix.FromEulerAnglesYXZ( Ogre::Radian( Ogre::Degree( 0 ) ), Ogre::Radian( Ogre::Degree( -90 ) ), Ogre::Radian( Ogre::Degree( 0 ) ) );
-    Ogre::Quaternion rot;
-    rot.FromRotationMatrix( matrix );
-    frame1->setRotation( rot );
-
-
-
-    for (u32 i = 1; i < number_of_files - 1; ++i)
-    {
-        int offset_to_vertex = GetU32LE(0x04 + i * 0x04);
-        MeshExtractor(info.data, "ffvii/battle_stage/" + info.data.name, this, offset_to_vertex, textures, mesh, Ogre::StringConverter::toString(i), 1);
-    }
-
-
-
-    // <OGRE> ///////////////////////////////
-    skeleton->optimiseAllAnimations();
-    Ogre::SkeletonSerializer skeleton_serializer;
-    skeleton_serializer.exportSkeleton(skeleton.getPointer(), "exported/models/ffvii/battle/stages/" + info.data.name + ".skeleton");
-
-    // Update bounds
-    Ogre::AxisAlignedBox aabb(-999, -999, -999, 999, 999, 999);
-    mesh->_setBounds(aabb, false);
-    mesh->_setBoundingSphereRadius(999);
-
-    mesh->setSkeletonName( "models/ffvii/battle/stages/" + info.data.name + ".skeleton" );
-
-    Ogre::MeshSerializer ser;
-    ser.exportMesh(mesh.getPointer(), "exported/models/ffvii/battle/stages/" + info.data.name + ".mesh");
-
-
-
-    // create and export textures for model
-    if( textures.size() > 0 )
-    {
-        int number_of_files = GetU32LE( 0x00 );
-        int offset_to_texture = GetU32LE( number_of_files * 0x04 );
-        Vram* vram = Vram::MakeInstance().release();
-
-        LoadTimFileToVram( this, offset_to_texture, vram );
-        //vram->Save( "qqq" );
-        CreateTexture( vram, info.data, "exported/models/ffvii/battle/stages/" + info.data.name + ".png", textures );
-        delete vram;
-    }
-
-
-
-    CreateMaterial("ffvii/battle_stage/" + info.data.name, "exported/models/ffvii/battle/stages/" + info.data.name + ".material", "models/ffvii/battle/stages/" + info.data.name + ".png", "", "");
-
-
-
-    Ogre::SceneManager* scene_manager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
-    Ogre::Entity* thisEntity = scene_manager->createEntity( info.data.name, "models/ffvii/battle/stages/" + info.data.name + ".mesh" );
-    //thisEntity->setDisplaySkeleton(true);
-    //thisEntity->setDebugDisplayEnabled(true);
-    thisEntity->setVisible(false);
-    thisEntity->getAnimationState( "Idle" )->setEnabled( true );
-    thisEntity->getAnimationState( "Idle" )->setLoop( true );
-    Ogre::SceneNode* thisSceneNode = scene_manager->getRootSceneNode()->createChildSceneNode();
-    thisSceneNode->setPosition( 0, 0, 0 );
-    thisSceneNode->roll( Ogre::Radian( Ogre::Degree( 180.0f ) ) );
-    thisSceneNode->yaw( Ogre::Radian( Ogre::Degree( 120.0f ) ) );
-    thisSceneNode->pitch( Ogre::Radian( Ogre::Degree( 90.0f ) ) );
-    thisSceneNode->attachObject( thisEntity );
-
-    return thisEntity;
-}
-
-
-
-/*
-void
-StageFile::DumpSettings(const Ogre::String& file)
-{
-    Logger* settings = new Logger(file);
-
-    int model_settings_offset = GetU32LE(0x08);
-
-    m_WithWeapon = GetU8(model_settings_offset + 2) & 0x80;
-    LOGGER->Log("Model With Weapon '" + Ogre::StringConverter::toString(m_WithWeapon) + "'\n");
-
-    settings->Log("// animation scripts\n");
-    settings->Log("+00 [][]     " + ToHexString(GetU16LE(model_settings_offset + 0), 4, '0') + " - if this is not 0 we add 0x40 bit to 8015190b\n");
-    settings->Log("+02 []       " + ToHexString(GetU8(model_settings_offset + 2), 2, '0') + " - 0x3f - dead type. 0x80 - play secondary animation\n");
-    settings->Log("+03 []       " + ToHexString(GetU8(model_settings_offset + 3), 2, '0') + "\n");
-    settings->Log("+04 [][]     " + ToHexString(GetU16LE(model_settings_offset + 4), 4, '0') + " - collision radius. Set to 801518e4+6\n");
-    settings->Log("+06 [][]     " + ToHexString(GetU16LE(model_settings_offset + 6), 4, '0') + " - to 801518ec\n");
-    settings->Log("+08 [][]     " + ToHexString(GetU16LE(model_settings_offset + 8), 4, '0') + " - to 801518ee\n");
-    settings->Log("+0a [][]     " + ToHexString(GetU16LE(model_settings_offset + 0xa), 4, '0') + " - to 801518f0\n");
-    settings->Log("+0c [][]     " + ToHexString(GetU16LE(model_settings_offset + 0xc), 4, '0') + "\n");
-    settings->Log("+0e [][]     " + ToHexString(GetU16LE(model_settings_offset + 0xe), 4, '0') + "\n");
-    settings->Log("+10 [][]     " + ToHexString(GetU16LE(model_settings_offset + 0x10), 4, '0') + " - filler?\n");
-
-    settings->Log("+12 array of joints (bone indexes)\n    ");
-    for (int i = 0; i < 0x10; ++i)
-    {
-        if (i != 0)
-        {
-            settings->Log(" ");
-        }
-        settings->Log(ToHexString(GetU8(model_settings_offset + 0x12 + i), 2, '0'));
-    }
-    settings->Log("\n");
-
-    settings->Log("+22 [][]     " + ToHexString(GetU16LE(model_settings_offset + 0x22), 4, '0') + " - filler?\n");
-
-    settings->Log("+24 array of 8 offsets to something\n    ");
-    for (int i = 0; i < 8; ++i)
-    {
-        if (i != 0)
-        {
-            settings->Log(" ");
-        }
-        settings->Log(ToHexString(GetU32LE(model_settings_offset + 0x24 + i * 4), 8, '0'));
-    }
-    settings->Log("\n");
-
-    settings->Log("+44 array of 4 something\n    ");
-    for (int i = 0; i < 4; ++i)
-    {
-        if (i != 0)
-        {
-            settings->Log(" ");
-        }
-        settings->Log(ToHexString(GetU16LE(model_settings_offset + 0x44 + i * 2), 4, '0'));
-    }
-    settings->Log("\n");
-
-    settings->Log("+4c array of 6 something\n    ");
-    for (int i = 0; i < 6; ++i)
-    {
-        if (i != 0)
-        {
-            settings->Log(" ");
-        }
-        settings->Log(ToHexString(GetU16LE(model_settings_offset + 0x4c + i * 2), 4, '0'));
-    }
-    settings->Log("\n");
-
-    settings->Log("+58 array of 6 something\n    ");
-    for (int i = 0; i < 6; ++i)
-    {
-        if (i != 0)
-        {
-            settings->Log(" ");
-        }
-        settings->Log(ToHexString(GetU16LE(model_settings_offset + 0x58 + i * 2), 4, '0'));
-    }
-    settings->Log("\n");
-
-    settings->Log("+64 [][]     " + ToHexString(GetU16LE(model_settings_offset + 0x64), 4, '0') + "\n");
-    settings->Log("+66 [][]     " + ToHexString(GetU16LE(model_settings_offset + 0x66), 4, '0') + " - filler?\n");
-
-    settings->Log("+68 array of 32 offsets to animation scripts\n    ");
-    for (int i = 0; i < 0x20; ++i)
-    {
-        if (i != 0)
-        {
-            if (i % 8 == 0)
-            {
-                settings->Log("\n    ");
-            }
-            else
-            {
-                settings->Log(" ");
-            }
-        }
-        settings->Log(ToHexString(GetU32LE(model_settings_offset + 0x68 + i * 4), 8, '0'));
-    }
-    settings->Log("\n");
-
-
-
-    AnimationScriptDumper(this, model_settings_offset, settings);
-
-
-
-    delete settings;
-}
-*/

+ 0 - 34
utilities/ffvii_battle_model_exporter/src/StageFile.h

@@ -1,34 +0,0 @@
-#ifndef STAGE_FILE_H
-#define STAGE_FILE_H
-
-#include "MeshExtractor.h"
-#include "common/LzsFile.h"
-#include "../../common/Vram.h"
-#include "../../common/OgreGenUtilites.h"
-
-
-
-struct StageInfo
-{
-    MeshData                  data;
-    Ogre::String              file_name;
-};
-
-
-
-class StageFile : public LzsFile
-{
-public:
-    StageFile(const Ogre::String& file);
-    StageFile(File* pFile);
-    StageFile(File* pFile, u32 offset, u32 length);
-    StageFile(u8* pBuffer, u32 offset, u32 length);
-    virtual ~StageFile();
-
-    Ogre::Entity* GetModel(const StageInfo& info);
-    //void          DumpSettings(const Ogre::String& file);
-};
-
-
-
-#endif // STAGE_FILE_H

+ 0 - 49
utilities/ffvii_battle_scene_dumper/CMakeLists.txt

@@ -1,49 +0,0 @@
-include_directories(
-    ${CMAKE_CURRENT_SOURCE_DIR}/src
-)
-
-# define header and source files
-set(HEADER_FILES
-./src/FFVIIString.h
-./src/EnemyFile.h
-./src/PlayerFile.h
-)
-
-set(SOURCE_FILES
-./src/PlayerFile.cpp
-./src/EnemyFile.cpp
-./src/FFVIIString.cpp
-./src/Main.cpp
-)
-
-add_definitions(
-    -DQGEARS_ADD_MANAGERS
-)
-
-add_executable(ff7_battle_scene_dumper
-  ${HEADER_FILES}
-  ${SOURCE_FILES}
-)
-SET_PROPERTY(TARGET ff7_battle_scene_dumper PROPERTY FOLDER "utilities")
-
-if (APPLE)
-target_link_libraries(ff7_battle_scene_dumper "-framework CoreFoundation -framework Cocoa -framework IOKit")
-endif()
-
-if(WIN32)
-  set_target_properties(ff7_battle_scene_dumper PROPERTIES WIN32_EXECUTABLE ON)
-  if (MSVC)
-    set_target_properties(ff7_battle_scene_dumper PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
-  endif()
-endif()
-
-set(LIBRARIES
-    Utility
-    QGearsMain
-    v-gears-data
-)
-target_link_libraries(ff7_battle_scene_dumper    ${LIBRARIES})
-
-install(TARGETS ff7_battle_scene_dumper
-    DESTINATION tools/ff7
-)

+ 0 - 1375
utilities/ffvii_battle_scene_dumper/src/EnemyFile.cpp

@@ -1,1375 +0,0 @@
-#include "EnemyFile.h"
-
-#include "FFVIIString.h"
-#include "../../common/Logger.h"
-
-
-
-Ogre::String
-ElementIdToString( const int element_id )
-{
-    switch( element_id )
-    {
-        case 0x00: return "Fire";
-        case 0x02: return "Lighting";
-        case 0x03: return "Earth";
-        case 0x05: return "Gravity";
-        case 0x07: return "Wind";
-        case 0x0b: return "Hit";
-        case 0x0c: return "Punch";
-        case 0x0d: return "Shoot";
-    }
-
-    return "UnknownElement0x" + HexToString( element_id, 4, '0' );
-}
-
-Ogre::String
-ElementEffectIdToString( const int effect_id )
-{
-    switch( effect_id )
-    {
-        case 0x02: return "DoubleDamage";
-        case 0x05: return "Nullify";
-    }
-
-    return "UnknownElementEffect0x" + HexToString( effect_id, 4, '0' );
-}
-
-Ogre::String
-StatusIdToString( const int status_id )
-{
-    switch( status_id )
-    {
-        case 0x00: return "Death";
-        case 0x02: return "Sleep";
-        case 0x03: return "Poison";
-        case 0x04: return "Sadness";
-        case 0x05: return "Fury";
-        case 0x06: return "Confusion";
-        case 0x07: return "Silence";
-        case 0x0a: return "Stop";
-        case 0x0b: return "Frog";
-        case 0x0c: return "Small";
-        case 0x15: return "DeathSentence";
-        case 0x19: return "Paralysis";
-        case 0x1a: return "Darkness";
-    }
-
-    return "UnknownStatusId0x" + HexToString( status_id, 4, '0' );
-}
-
-Ogre::String
-ItemIdToString( const int item_id )
-{
-    switch( item_id )
-    {
-        case 0x00: return "Potion";
-        case 0x03: return "Ether";
-        case 0x14: return "Grenade";
-    }
-
-    return "UnknownItemId0x" + HexToString( item_id, 4, '0' );
-}
-
-Ogre::String
-AttackIdToString( const int attack_id )
-{
-    switch( attack_id )
-    {
-        case 0x001b: return "Fire";
-        case 0x0110: return "MachineGun";
-        case 0x0111: return "Tonfa";
-        case 0x0112: return "Bite";
-        case 0x0113: return "Tentacle";
-        case 0x0114: return "Drilldrive";
-        case 0x0115: return "Handclaw";
-        case 0x0116: return "BeamGun";
-        case 0x0117: return "LaserCannon";
-        case 0x0118: return "WMachineGun";
-        case 0x0119: return "SmokeShot";
-        case 0x011a: return "Rifle";
-        case 0x011b: return "ScorpionTail";
-        case 0x011c: return "SearchScope";
-        case 0x011d: return "Rifle";
-        case 0x011e: return "TailLaser";
-        case 0x011f: return "Empty0x11f";
-        case 0x0120: return "Empty0x120";
-    }
-
-    return "UnknownAttackId0x" + HexToString( attack_id, 4, '0' );
-}
-
-
-
-
-Ogre::String
-StageIdToFileName( const int stage_id )
-{
-    switch( stage_id )
-    {
-        case 0x09: return "sector_1_train_station";
-        case 0x0c: return "reactor_1_entrance";
-    }
-
-    return "UnknownStageId0x" + HexToString( stage_id, 4, '0' );
-}
-
-
-EnemyFile::EnemyFile( const Ogre::String &file ):
-    File( file )
-{
-    DumpData();
-}
-
-
-
-EnemyFile::EnemyFile( File *file, const u32 &offset, const u32 &length ):
-    File( file, offset, length )
-{
-    DumpData();
-}
-
-
-
-EnemyFile::EnemyFile( u8* buffer, const u32 &offset, const u32 &length ):
-    File( buffer, offset, length )
-{
-    DumpData();
-}
-
-
-
-EnemyFile::EnemyFile( File *file ):
-    File( file )
-{
-    DumpData();
-}
-
-
-
-EnemyFile::~EnemyFile()
-{
-}
-
-
-
-void
-EnemyFile::DumpData()
-{
-    Logger* export_text = new Logger( "enemy.lua" );
-    bool added = false;
-
-    int enemy_data_offset = 0x0298;
-    int enemy_ai_offset   = 0x0e80;
-
-    for( int k = 0 ; k < 3; ++k )
-    {
-        if( GetU16LE( k * 0x02 ) == 0xffff )
-        {
-            continue;
-        }
-
-        FFVIIString name;
-        name.resize( 32 );
-        std::copy( buffer_ + enemy_data_offset + k * 184, buffer_ + enemy_data_offset + k * 184 + 0x20, name.begin() );
-        Ogre::String r_name = FFVIIStringToString( name );
-
-        export_text->Log( "-- " + Ogre::String( r_name.c_str() ) + "(" + IntToString( GetU16LE( k * 0x02 ) ) + ")\n" );
-        export_text->Log( Ogre::String( r_name.c_str() ) + "= {\n" );
-
-        export_text->Log( "    max_hp = " + IntToString( GetU32LE( enemy_data_offset + k * 184 + 0xa4 ) ) + ",\n" );
-        export_text->Log( "    max_mp = " + IntToString( GetU16LE( enemy_data_offset + k * 184 + 0x9c ) ) + ",\n" );
-        export_text->Log( "\n" );
-        export_text->Log( "    level = " + IntToString( GetU8( enemy_data_offset + k * 184 + 0x20 ) ) + ",\n" );
-        export_text->Log( "    physical_power = " + IntToString( GetU8( enemy_data_offset + k * 184 + 0x24 ) ) + ",\n" );
-        export_text->Log( "    physical_defense = " + IntToString( GetU8( enemy_data_offset + k * 184 + 0x25 ) ) + ",\n" );
-        export_text->Log( "    physical_dodge = " + IntToString( GetU8( enemy_data_offset + k * 184 + 0x23 ) ) + ",\n" );
-        export_text->Log( "    magic_power = " + IntToString( GetU8( enemy_data_offset + k * 184 + 0x26 ) ) + ",\n" );
-        export_text->Log( "    magic_defense = " + IntToString( GetU8( enemy_data_offset + k * 184 + 0x27 ) ) + ",\n" );
-        export_text->Log( "    speed = " + IntToString( GetU8( enemy_data_offset + k * 184 + 0x21 ) ) + ",\n" );
-        export_text->Log( "    luck = " + IntToString( GetU8( enemy_data_offset + k * 184 + 0x22 ) ) + ",\n" );
-        export_text->Log( "\n" );
-        export_text->Log( "    back_damage_multiplier = " + FloatToString( GetU8( enemy_data_offset + k * 184 + 0xa2 ) / 8.0f ) + ",\n" );
-        export_text->Log( "\n" );
-        export_text->Log( "    morph_item = " + ItemIdToString( GetU16LE( enemy_data_offset + k * 184 + 0xa0 ) ) + ",\n" );
-        export_text->Log( "\n" );
-        export_text->Log( "    reward_exp = " + IntToString( GetU32LE( enemy_data_offset + k * 184 + 0xa8 ) ) + ",\n" );
-        export_text->Log( "    reward_ap = " + IntToString( GetU16LE( enemy_data_offset + k * 184 + 0x9e ) ) + ",\n" );
-        export_text->Log( "    reward_gil = " + IntToString( GetU32LE( enemy_data_offset + k * 184 + 0xac ) ) + ",\n" );
-        export_text->Log( "\n" );
-
-        export_text->Log( "    reward_items_drop = {" );
-        added = false;
-        for( int l = 0; l < 4; ++l )
-        {
-            u8 rate = GetU8( enemy_data_offset + k * 184 + 0x88 + l );
-            u16 item_id = GetU16LE( enemy_data_offset + k * 184 + 0x8c + l * 0x02 );
-            if( item_id != 65535 && rate < 0x80 )
-            {
-                added = true;
-                export_text->Log( "\n        " + ItemIdToString( item_id ) + " = " + IntToString( rate ) + "," );
-            }
-            if( added == true && l == 3 )
-            {
-                export_text->Log( "\n    " );
-            }
-        }
-        export_text->Log( "},\n");
-
-        export_text->Log( "\n" );
-
-        export_text->Log( "    elements = {" );
-        bool added = false;
-        for( int l = 0; l < 8; ++l )
-        {
-            int element_id = GetU8( enemy_data_offset + k * 184 + 0x28 + l );
-            if( element_id != 255 )
-            {
-                added = true;
-                int effect = GetU8( enemy_data_offset + k * 184 + 0x30 + l );
-                export_text->Log( "\n        " + ElementIdToString( element_id ) + " = \"" + ElementEffectIdToString( effect ) + "\"," );
-            }
-            if( added == true && l == 7 )
-            {
-                export_text->Log( "\n    " );
-            }
-        }
-        export_text->Log( "},\n");
-
-        export_text->Log( "\n" );
-
-        u32 status_immunes = GetU32LE( enemy_data_offset + k * 184 + 0xb0 );
-        export_text->Log( "    status_immunes = {" );
-        added = false;
-        for( int l = 0; l < 32; ++l )
-        {
-            if( ( ( status_immunes >> l ) & 1 ) == 0 )
-            {
-                added = true;
-                export_text->Log( "\n        " + StatusIdToString( l ) + "," );
-            }
-            if( added == true && l == 31 )
-            {
-                export_text->Log( "\n    " );
-            }
-        }
-        export_text->Log( "},\n");
-
-        export_text->Log( "\n" );
-
-        export_text->Log( "    attacks = {" );
-        added = false;
-        for( int l = 0; l < 16; ++l )
-        {
-            int script_id = GetU8( enemy_data_offset + k * 184 + 0x38 + l );
-            int attack_id = GetU16LE( enemy_data_offset + k * 184 + 0x48 + l * 0x02 );
-            int camera_movement = GetU16LE( enemy_data_offset + k * 184 + 0x68 + l * 0x02 );
-            if( attack_id != 65535 )
-            {
-                added = true;
-                if( l != 0 )
-                {
-                    export_text->Log( "," );
-                }
-                export_text->Log( "\n        " + AttackIdToString( attack_id ) + " = {" );
-                bool ext_added = false;
-                if( script_id != 255 )
-                {
-                    ext_added = true;
-                    export_text->Log( "\n            script_id = " + IntToString( script_id ) + "," );
-                }
-                if( camera_movement != 65535 )
-                {
-                    ext_added = true;
-                    export_text->Log( "\n            camera_movement = " + IntToString( camera_movement ) + "," );
-                }
-                if( ext_added == true )
-                {
-                    export_text->Log( "\n        " );
-                }
-                export_text->Log( "}" );
-            }
-            if( added == true && l == 15 )
-            {
-                export_text->Log( "\n    " );
-            }
-        }
-        export_text->Log( "},\n");
-
-        export_text->Log( "\n" );
-
-        export_text->Log( "    items_steal = {" );
-        added = false;
-        for( int l = 0; l < 4; ++l )
-        {
-            u8 rate = GetU8( enemy_data_offset + k * 184 + 0x88 + l );
-            u16 item_id = GetU16LE( enemy_data_offset + k * 184 + 0x8c + l * 0x02 );
-            if( item_id != 65535 && rate >= 0x80 )
-            {
-                added = true;
-                export_text->Log( "\n        " + ItemIdToString( item_id ) + " = " + IntToString( rate - 0x80 ) + "," );
-            }
-            if( added == true && l == 3 )
-            {
-                export_text->Log( "\n    " );
-            }
-        }
-        export_text->Log( "},\n");
-
-        export_text->Log( "\n" );
-
-        int berserk = GetU16LE( enemy_data_offset + k * 184 + 0x94 );
-        if( berserk != 65535 )
-        {
-            export_text->Log( "    berserk_attack = " + AttackIdToString( berserk ) + ",\n\n" );
-        }
-
-        export_text->Log( "    manipulate_attacks = {");
-        added = false;
-        for( int l = 0; l < 3; ++l )
-        {
-            int attack_id = GetU16LE( enemy_data_offset + k * 184 + 0x94 + l * 0x02 );
-            if( attack_id != 65535 )
-            {
-                added = true;
-                export_text->Log( "\n        " + AttackIdToString( attack_id ) + "," );
-            }
-            if( added == true && l == 2 )
-            {
-                export_text->Log( "\n    " );
-            }
-        }
-        export_text->Log( "},\n");
-
-        //export_text->Log( "\n    unknown_0x9a = \"0x" + HexToString( GetU16LE( enemy_data_offset + k * 184 + 0x9a ), 4, '0' ) + ",\n" );
-
-/*
-
-
-
-        LOGGER->Log("AI:\n");
-        int ai_offset = enemy_ai_offset + GetU16LE(enemy_ai_offset + k * 2);
-
-        for (int l = 0; l < 0x10; ++l)
-        {
-            u16 local_script_offset = GetU16LE(ai_offset + l * 2);
-            if (local_script_offset == 0xFFFF)
-            {
-                continue;
-            }
-
-            LOGGER->Log("script %x:\n", l);
-
-            int script_offset = ai_offset + local_script_offset;
-            int pointer = 0;
-            bool run = true;
-
-            for (; run == true;)
-            {
-                u8 opcode = GetU8(script_offset + pointer);
-                u8 opcode_h = opcode >> 4;
-                u8 opcode_l = opcode & 0xF;
-
-                LOGGER->Log("0x%04x ", pointer);
-
-
-
-                if (GetU8(script_offset + pointer + 0)  == 0x00 &&
-                    GetU8(script_offset + pointer + 3)  == 0x52 &&
-                    GetU8(script_offset + pointer + 4)  == 0x70)
-                {
-                    int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int jump     = GetU16LE(script_offset + pointer + 5);
-
-                    LOGGER->Log("JumpIfTrue(bit[0x%04x + 0x%02x])(0x%04x);\n", address1, bits1, jump);
-                    pointer += 7;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x01 &&
-                    GetU8(script_offset + pointer + 3)  == 0x52 &&
-                    GetU8(script_offset + pointer + 4)  == 0x70)
-                {
-                    int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int jump     = GetU16LE(script_offset + pointer + 5);
-
-                    LOGGER->Log("JumpIfTrue(b[0x%04x + 0x%02x])(0x%04x);\n", address1, bits1, jump);
-                    pointer += 7;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x00 &&
-                    GetU8(script_offset + pointer + 3)  == 0x70)
-                {
-                    int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int jump     = GetU16LE(script_offset + pointer + 4);
-
-                    LOGGER->Log("JumpIfFalse(bit[0x%04x + 0x%02x])(0x%04x);\n", address1, bits1, jump);
-                    pointer += 6;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x01 &&
-                    GetU8(script_offset + pointer + 3)  == 0x60 &&
-                    GetU8(script_offset + pointer + 5)  == 0x35 &&
-                    GetU8(script_offset + pointer + 6)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x40 &&
-                    GetU8(script_offset + pointer + 9)  == 0x70)
-                {
-                    int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 1) & 7;
-
-                    int value1   = GetU8(script_offset + pointer + 4);
-                    int value2   = GetU8(script_offset + pointer + 7);
-
-                    int jump     = GetU16LE(script_offset + pointer + 10);
-
-                    LOGGER->Log("JumpIf((b[0x%04x + 0x%02x] & 0x%02x) != 0x%02x)(0x%04x);\n", address1, bits1, value1, value2, jump);
-                    pointer += 12;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x02 &&
-                    GetU8(script_offset + pointer + 1)  == 0x60 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x00 &&
-                    GetU8(script_offset + pointer + 4)  == 0x26 &&
-                    GetU8(script_offset + pointer + 5)  == 0x40 &&
-                    GetU8(script_offset + pointer + 6)  == 0x80 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x00 &&
-                    GetU8(script_offset + pointer + 9)  == 0x40 &&
-                    GetU8(script_offset + pointer + 10) == 0x70)
-                {
-                    int address = GetU16LE(script_offset + pointer + 11);
-                    LOGGER->Log("JumpIfSelfNotInFrontRow(0x%04x);\n", address);
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x02 &&
-                    GetU8(script_offset + pointer + 1)  == 0x80 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x00 &&
-                    GetU8(script_offset + pointer + 4)  == 0x26 &&
-                    GetU8(script_offset + pointer + 5)  == 0x40 &&
-                    GetU8(script_offset + pointer + 6)  == 0x80 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x00 &&
-                    GetU8(script_offset + pointer + 9)  == 0x40 &&
-                    GetU8(script_offset + pointer + 10) == 0x70)
-                {
-                    int address = GetU16LE(script_offset + pointer + 11);
-                    LOGGER->Log("JumpIfNotAllFriendsInFrontRow(0x%04x);\n", address);
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x02 &&
-                    GetU8(script_offset + pointer + 1)  == 0x80 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x00 &&
-                    GetU8(script_offset + pointer + 4)  == 0x26 &&
-                    GetU8(script_offset + pointer + 5)  == 0x40 &&
-                    GetU8(script_offset + pointer + 6)  == 0x80 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x01 &&
-                    GetU8(script_offset + pointer + 9)  == 0x40 &&
-                    GetU8(script_offset + pointer + 10) == 0x70)
-                {
-                    int address = GetU16LE(script_offset + pointer + 11);
-                    LOGGER->Log("JumpIfNotAllFriendsInBackRow(0x%04x);\n", address);
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x02 &&
-                    GetU8(script_offset + pointer + 1)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x00 &&
-                    GetU8(script_offset + pointer + 4)  == 0x26 &&
-                    GetU8(script_offset + pointer + 5)  == 0x40 &&
-                    GetU8(script_offset + pointer + 6)  == 0x80 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x00 &&
-                    GetU8(script_offset + pointer + 9)  == 0x40 &&
-                    GetU8(script_offset + pointer + 10) == 0x70)
-                {
-                    int address = GetU16LE(script_offset + pointer + 11);
-                    LOGGER->Log("JumpIfNotAllOpponentsInFrontRow(0x%04x);\n", address);
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x02 &&
-                    GetU8(script_offset + pointer + 1)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x00 &&
-                    GetU8(script_offset + pointer + 4)  == 0x26 &&
-                    GetU8(script_offset + pointer + 5)  == 0x40 &&
-                    GetU8(script_offset + pointer + 6)  == 0x80 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x01 &&
-                    GetU8(script_offset + pointer + 9)  == 0x40 &&
-                    GetU8(script_offset + pointer + 10) == 0x70)
-                {
-                    int address = GetU16LE(script_offset + pointer + 11);
-                    LOGGER->Log("JumpIfNotAllOpponentsInBackRow(0x%04x);\n", address);
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x02 &&
-                    GetU8(script_offset + pointer + 1)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x00 &&
-                    GetU8(script_offset + pointer + 4)  == 0x1a &&
-                    GetU8(script_offset + pointer + 5)  == 0x40 &&
-                    GetU8(script_offset + pointer + 6)  == 0x80 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x00 &&
-                    GetU8(script_offset + pointer + 9)  == 0x40 &&
-                    GetU8(script_offset + pointer + 10) == 0x70)
-                {
-                    int address = GetU16LE(script_offset + pointer + 11);
-                    LOGGER->Log("JumpIfAllOpponentsInDarknessStatus(0x%04x);\n", address);
-                    pointer += 13;
-                    continue;
-                }
-
-                if ((GetU8(script_offset + pointer + 0)  == 0x10 || GetU8(script_offset + pointer + 0)  == 0x11 || GetU8(script_offset + pointer + 0)  == 0x12) &&
-                    GetU8(script_offset + pointer + 3)  == 0x60 &&
-                    GetU8(script_offset + pointer + 5)  == 0x90)
-                {
-                    int address = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int value   = GetU8(script_offset + pointer + 4);
-                    LOGGER->Log("[0x%04x + 0x%02x] = b(0x%02x);\n", address, bits, value);
-                    pointer += 6;
-                    continue;
-                }
-
-                if ((GetU8(script_offset + pointer + 0)  == 0x10 || GetU8(script_offset + pointer + 0)  == 0x11 || GetU8(script_offset + pointer + 0)  == 0x12) &&
-                    GetU8(script_offset + pointer + 3)  == 0x61 &&
-                    GetU8(script_offset + pointer + 6)  == 0x90)
-                {
-                    int address = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int value   = GetU16LE(script_offset + pointer + 4);
-                    LOGGER->Log("[0x%04x + 0x%02x] = h(0x%04x);\n", address, bits, value);
-                    pointer += 7;
-                    continue;
-                }
-
-                if ((GetU8(script_offset + pointer + 0)  == 0x10 || GetU8(script_offset + pointer + 0)  == 0x11 || GetU8(script_offset + pointer + 0)  == 0x12) &&
-                    GetU8(script_offset + pointer + 3)  == 0x62 &&
-                    GetU8(script_offset + pointer + 7)  == 0x90)
-                {
-                    int address = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int value   = (GetU16LE(script_offset + pointer + 4) << 1) | GetU8(script_offset + pointer + 6);
-                    LOGGER->Log("[0x%04x + 0x%02x] = w(0x%08x);\n", address, bits, value);
-                    pointer += 8;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x11 &&
-                    GetU8(script_offset + pointer + 3)  == 0x01 &&
-                    GetU8(script_offset + pointer + 6)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x35 &&
-                    GetU8(script_offset + pointer + 9)  == 0x90)
-                {
-                    int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 1) & 7;
-
-                    int address2 = GetU16LE(script_offset + pointer + 4) >> 3;
-                    int bits2    = GetU16LE(script_offset + pointer + 4) & 7;
-
-                    int value    = GetU8(script_offset + pointer + 7);
-
-                    LOGGER->Log("[0x%04x + 0x%02x] = b(b[0x%04x + 0x%02x] & 0x%02x);\n", address1, bits1, address2, bits2, value);
-                    pointer += 10;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 6)  == 0x90)
-                {
-                    int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int address2 = GetU16LE(script_offset + pointer + 4) >> 3;
-                    int bits2    = GetU16LE(script_offset + pointer + 4) & 7;
-
-                    LOGGER->Log("[0x%04x + 0x%02x] = h(h[0x%04x + 0x%02x]);\n", address1, bits1, address2, bits2);
-                    pointer += 7;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 3)  == 0x61 &&
-                    GetU8(script_offset + pointer + 6)  == 0x90)
-                {
-                    int address = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int value   = GetU8(script_offset + pointer + 4) | (GetU8(script_offset + pointer + 5) << 8);
-                    LOGGER->Log("[0x%04x + 0x%02x] = h(0x%04x);\n", address, bits, value);
-                    pointer += 7;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 1)  == 0x70 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 4)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 5)  == 0x20 &&
-                    GetU8(script_offset + pointer + 6)  == 0x00 &&
-                    GetU8(script_offset + pointer + 7)  == 0x26 &&
-                    GetU8(script_offset + pointer + 8)  == 0x40 &&
-                    GetU8(script_offset + pointer + 9)  == 0x80 &&
-                    GetU8(script_offset + pointer + 10) == 0x60 &&
-                    GetU8(script_offset + pointer + 11) == 0x01 &&
-                    GetU8(script_offset + pointer + 12) == 0x40 &&
-                    GetU8(script_offset + pointer + 13) == 0x82 &&
-                    GetU8(script_offset + pointer + 14) == 0x90)
-                {
-                    LOGGER->Log("SetRandomOpponentInBackRowToAttack();\n");
-                    pointer += 15;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 1)  == 0x70 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 4)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 5)  == 0x20 &&
-                    GetU8(script_offset + pointer + 6)  == 0x00 &&
-                    GetU8(script_offset + pointer + 7)  == 0x26 &&
-                    GetU8(script_offset + pointer + 8)  == 0x40 &&
-                    GetU8(script_offset + pointer + 9)  == 0x80 &&
-                    GetU8(script_offset + pointer + 10) == 0x60 &&
-                    GetU8(script_offset + pointer + 11) == 0x00 &&
-                    GetU8(script_offset + pointer + 12) == 0x40 &&
-                    GetU8(script_offset + pointer + 13) == 0x82 &&
-                    GetU8(script_offset + pointer + 14) == 0x90)
-                {
-                    LOGGER->Log("SetRandomOpponentInFrontRowToAttack();\n");
-                    pointer += 15;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 1)  == 0x70 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 4)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 5)  == 0x20 &&
-                    GetU8(script_offset + pointer + 6)  == 0x03 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x41 &&
-                    GetU8(script_offset + pointer + 9)  == 0x80 &&
-                    GetU8(script_offset + pointer + 10) == 0x85 &&
-                    GetU8(script_offset + pointer + 11) == 0x82 &&
-                    GetU8(script_offset + pointer + 12) == 0x90)
-                {
-                    LOGGER->Log("SetRandomOpponentWithLowestCurrentHP();\n");
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 1)  == 0x70 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 4)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 5)  == 0x20 &&
-                    GetU8(script_offset + pointer + 6)  == 0x03 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x41 &&
-                    GetU8(script_offset + pointer + 9)  == 0x80 &&
-                    GetU8(script_offset + pointer + 10) == 0x84 &&
-                    GetU8(script_offset + pointer + 11) == 0x82 &&
-                    GetU8(script_offset + pointer + 12) == 0x90)
-                {
-                    LOGGER->Log("SetRandomOpponentWithHighestCurrentHP();\n");
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 1)  == 0x70 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 4)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 5)  == 0x20 &&
-                    GetU8(script_offset + pointer + 6)  == 0x02 &&
-                    GetU8(script_offset + pointer + 7)  == 0x10 &&
-                    GetU8(script_offset + pointer + 8)  == 0x41 &&
-                    GetU8(script_offset + pointer + 9)  == 0x80 &&
-                    GetU8(script_offset + pointer + 10) == 0x85 &&
-                    GetU8(script_offset + pointer + 11) == 0x82 &&
-                    GetU8(script_offset + pointer + 12) == 0x90)
-                {
-                    LOGGER->Log("SetRandomOpponentWithLowestMagicDefence();\n");
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 1)  == 0x70 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 4)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 5)  == 0x20 &&
-                    GetU8(script_offset + pointer + 6)  == 0x02 &&
-                    GetU8(script_offset + pointer + 7)  == 0x00 &&
-                    GetU8(script_offset + pointer + 8)  == 0x41 &&
-                    GetU8(script_offset + pointer + 9)  == 0x80 &&
-                    GetU8(script_offset + pointer + 10) == 0x85 &&
-                    GetU8(script_offset + pointer + 11) == 0x82 &&
-                    GetU8(script_offset + pointer + 12) == 0x90)
-                {
-                    LOGGER->Log("SetRandomOpponentWithLowestDefence();\n");
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 1)  == 0x70 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 4)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 5)  == 0x20 &&
-                    GetU8(script_offset + pointer + 6) == 0x82 &&
-                    GetU8(script_offset + pointer + 7) == 0x90)
-                {
-                    LOGGER->Log("SetRandomOpponentToAttack();\n");
-                    pointer += 8;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x60 &&
-                    GetU8(script_offset + pointer + 2)  == 0x02 &&
-                    GetU8(script_offset + pointer + 5) == 0x92)
-                {
-                    int action   = GetU8(script_offset + pointer + 1);
-                    int address1 = GetU16LE(script_offset + pointer + 3) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 3) & 7;
-
-                    LOGGER->Log("RunCommand(0x%02x, h[0x%04x + 0x%02x]);\n", action, address1, bits1);
-                    pointer += 6;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x81 &&
-                    GetU8(script_offset + pointer + 1)  == 0x01 &&
-                    GetU8(script_offset + pointer + 4)  == 0x34 &&
-                    GetU8(script_offset + pointer + 5)  == 0x52 &&
-                    GetU8(script_offset + pointer + 6) == 0x70)
-                {
-                    int address1 = GetU16LE(script_offset + pointer + 2) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 2) & 7;
-                    int jump     = GetU16LE(script_offset + pointer + 7);
-
-                    LOGGER->Log("JumpIfRandomNot(1/b[0x%04x + 0x%02x])(0x%04x);\n", address1, bits1, jump);
-                    pointer += 9;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x81 &&
-                    GetU8(script_offset + pointer + 1)  == 0x60 &&
-                    GetU8(script_offset + pointer + 3)  == 0x34 &&
-                    GetU8(script_offset + pointer + 4)  == 0x52 &&
-                    GetU8(script_offset + pointer + 5) == 0x70)
-                {
-                    int value    = GetU8(script_offset + pointer + 2);
-                    int jump     = GetU16LE(script_offset + pointer + 6);
-
-                    LOGGER->Log("JumpIfRandomNot(1/0x%02x)(0x%04x);\n", value, jump);
-                    pointer += 8;
-                    continue;
-                }
-
-
-
-                switch (opcode)
-                {
-                    case 0x00:
-                    case 0x01:
-                    case 0x02:
-                    case 0x03:
-                    {
-                        LOGGER->Log("0x%02x LoadValue(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
-                        pointer += 3;
-                    }
-                    break;
-
-                    case 0x10:
-                    case 0x11:
-                    case 0x12:
-                    case 0x13:
-                    {
-                        LOGGER->Log("0x%02x PushAddress(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
-                        pointer += 3;
-                    }
-                    break;
-
-                    case 0x30:
-                    {
-                        LOGGER->Log("0x%02x MathAdd()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x31:
-                    {
-                        LOGGER->Log("0x%02x MathSub()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x32:
-                    {
-                        LOGGER->Log("0x%02x MathMul()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x33:
-                    {
-                        LOGGER->Log("0x%02x MathDiv()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-
-                    case 0x34:
-                    {
-                        LOGGER->Log("0x%02x MathMod()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x35:
-                    {
-                        LOGGER->Log("0x%02x MathAnd()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x36:
-                    {
-                        LOGGER->Log("0x%02x MathOr()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x37:
-                    {
-                        LOGGER->Log("0x%02x MathNor()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x40:
-                    {
-                        LOGGER->Log("0x%02x CompareEqual()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x41:
-                    {
-                        LOGGER->Log("0x%02x CompareNotEqual()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x42:
-                    {
-                        LOGGER->Log("0x%02x CompareGreaterEqual()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x43:
-                    {
-                        LOGGER->Log("0x%02x CompareLessEqual()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x44:
-                    {
-                        LOGGER->Log("0x%02x CompareGreater()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x45:
-                    {
-                        LOGGER->Log("0x%02x CompareLess()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x50:
-                    {
-                        LOGGER->Log("0x%02x LogAnd()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x51:
-                    {
-                        LOGGER->Log("0x%02x LogOr()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x52:
-                    {
-                        LOGGER->Log("0x%02x LogNot()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x60:
-                    {
-                        u32 value = GetU8(script_offset + pointer + 1);
-                        LOGGER->Log("0x%02x PushImmediate(0x%02x)\n", opcode, value);
-                        pointer += 2;
-                    }
-                    break;
-
-                    case 0x61:
-                    {
-                        u32 value = GetU8(script_offset + pointer + 1) | (GetU8(script_offset + pointer + 2) << 8);
-                        LOGGER->Log("0x%02x PushImmediate(0x%04x)\n", opcode, value);
-                        pointer += 3;
-                    }
-                    break;
-
-                    case 0x70:
-                    {
-                        LOGGER->Log("0x%02x JumpIfFalse(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
-                        pointer += 3;
-                    }
-                    break;
-
-                    case 0x71:
-                    {
-                        LOGGER->Log("0x%02x JumpIfNotEqual(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
-                        pointer += 3;
-                    }
-                    break;
-
-                    case 0x72:
-                    {
-                        LOGGER->Log("0x%02x JumpTo(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
-                        pointer += 3;
-                    }
-                    break;
-
-                    case 0x73:
-                    {
-                        LOGGER->Log("0x%02x FinishScript()\n", opcode);
-                        run = false;
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x75:
-                    {
-                        LOGGER->Log("0x%02x LinkScriptToOtherPlayer()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x80:
-                    {
-                        LOGGER->Log("0x%02x FilterValueByMask()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x81:
-                    {
-                        LOGGER->Log("0x%02x MathRandom()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x82:
-                    {
-                        LOGGER->Log("0x%02x PickRandomBit()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x83:
-                    {
-                        LOGGER->Log("0x%02x CountActiveBits()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x84:
-                    {
-                        LOGGER->Log("0x%02x GetHighestMask()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x85:
-                    {
-                        LOGGER->Log("0x%02x GetLowestMask()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x86:
-                    {
-                        LOGGER->Log("0x%02x GetMPCost()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x87:
-                    {
-                        LOGGER->Log("0x%02x SetBit()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x90:
-                    {
-                        LOGGER->Log("0x%02x StoreValue()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x91:
-                    {
-                        LOGGER->Log("0x%02x Pop()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x92:
-                    {
-                        LOGGER->Log("0x%02x RunCommand()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x93:
-                    {
-                        LOGGER->Log("0x%02x DisplayText(", opcode);
-                        pointer += 1;
-
-                        FFVIIString text;
-
-                        unsigned char letter = GetU8(script_offset + pointer);
-                        while (true)
-                        {
-                            if (letter == 0xea || letter == 0xeb || letter == 0xec || letter == 0xed || letter == 0xee || letter == 0xef || letter == 0xf0 || letter == 0xf1)
-                            {
-                                LOGGER->Log("[variable%02x", letter);
-                                LOGGER->Log("%02x", GetU8(script_offset + pointer + 1));
-                                LOGGER->Log("%02x]", GetU8(script_offset + pointer + 2));
-                                pointer += 3;
-                            }
-                            else
-                            {
-                                LOGGER->Log("%02x", letter);
-                                text.push_back(letter);
-                                pointer += 1;
-
-                                if (letter == 0xff)
-                                {
-                                    break;
-                                }
-                            }
-
-                            letter = GetU8(script_offset + pointer);
-                        }
-
-                        RString r_text = FFVIIStringToRString(text);
-                        LOGGER->Log(")(%s)\n", r_text.c_str());
-
-                    }
-                    break;
-
-                    case 0x94:
-                    {
-                        LOGGER->Log("0x%02x CopyUnitsData()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x95:
-                    {
-                        LOGGER->Log("0x%02x ExchangeByteWithMemory(800f83a4 + 2 <-> memorybank1/2)\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x96:
-                    {
-                        LOGGER->Log("0x%02x GetUnitsElementalDefense()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0xA0:
-                    {
-                        LOGGER->Log("0x%02x DebugTextOutput(", opcode);
-                        pointer += 1;
-
-                        unsigned char pop = GetU8(script_offset + pointer);
-                        pointer += 1;
-
-                        char letter[2];
-                        letter[1] = 0;
-
-                        letter[0] = GetU8(script_offset + pointer);
-                        while (letter[0] != 0)
-                        {
-                            LOGGER->Log("%s", letter);
-                            pointer += 1;
-
-                            letter[0] = GetU8(script_offset + pointer);
-                        }
-
-                        pointer += 1;
-                        LOGGER->Log(")(pop %d var from stack)\n", pop);
-
-                    }
-                    break;
-
-                    default:
-                    {
-                        LOGGER->Log("0x%02x Unknown\n", opcode);
-                        run = false;
-                    }
-                }
-            }
-
-            LOGGER->Log("\n", l);
-        }
-*/
-        export_text->Log( "},\n\n\n" );
-    }
-
-
-
-//    <entity_model name="Background" file_name="models/battle/stages/reactor_1.mesh" position="0 0 0" direction="0" />
-
-//    <entity_model name="Mp1" file_name="models/battle/units/mp.mesh" position="-5 2.5 0" direction="0" />
-//    <entity_model name="Mp2" file_name="models/battle/units/mp.mesh" position="-5 2.5 0" direction="0" />
-
-    int set_up_1_offset  = 0x0008;
-    int set_up_2_offset  = 0x0058;
-    int formation_offset = 0x0118;
-
-    for( int k = 0 ; k < 4; ++k )
-    {
-        delete export_text;
-        export_text = new Logger( "battle_" + IntToString( k ) + ".xml" );
-        export_text->Log( "<map>\n" );
-        export_text->Log( "    <entity_model name=\"Background\" file_name=\"models/ffvii/battle/stages/" + StageIdToFileName( GetU16LE( set_up_1_offset + k * 20 + 0x00 ) ) + ".mesh\" position=\"0 0 0\" direction=\"0\" />\n\n" );
-/*
-
-        LOGGER->Log("unknown: ");
-        for (int l = 0; l < 18; ++l)
-        {
-            LOGGER->Log(" %02x", GetU8(set_up_1_offset + 0x02 + k * 20 + l));
-        }
-        LOGGER->Log("\n");
-        LOGGER->Log("unknown: ");
-        for (int l = 0; l < 48; ++l)
-        {
-            LOGGER->Log(" %02x", GetU8(set_up_2_offset + k * 48 + l));
-        }
-        LOGGER->Log("\n");
-        LOGGER->Log("formation:\n");
-*/
-        for( int l = 0; l < 6; ++l )
-        {
-            Ogre::Vector3 position = Ogre::Vector3(
-                ( s16 )GetU16LE( formation_offset + k * 96 + l * 16 + 0x02 ),
-                ( s16 )GetU16LE( formation_offset + k * 96 + l * 16 + 0x06 ),
-                ( s16 )GetU16LE( formation_offset + k * 96 + l * 16 + 0x04 )
-            );
-            position /= 512.0f;
-            export_text->Log( "    <entity_model name=\"" + IntToString( ( s16 )GetU16LE( formation_offset + k * 96 + l * 16 + 0x00 ) ) + "\" file_name=\"models/ffvii/battle/stages/" + StageIdToFileName( GetU16LE( set_up_1_offset + k * 20 + 0x00 ) ) + ".mesh\" position=\"" + Ogre::StringConverter::toString( position ) + "\" direction=\"0\" />\n" );
-
-/*
-            xmlTextWriterWriteFormatAttribute(writer, BAD_CAST "row", "%d", GetU16LE(formation_offset + 0x08 + k * 96 + l * 16));
-            xmlTextWriterEndElement(writer);
-
-            int enemy_id = (Sint16)GetU16LE(formation_offset + 0x00 + k * 96 + l * 16);
-            if (enemy_id != -1)
-            {
-                LOGGER->Log("Enemy Id %04d\t", (Sint16)GetU16LE(formation_offset + 0x00 + k * 96 + l * 16));
-                LOGGER->Log("Position:");
-                LOGGER->Log(" x(%04d)", (Sint16)GetU16LE(formation_offset + 0x02 + k * 96 + l * 16));
-                LOGGER->Log(" y(%04d)", (Sint16)GetU16LE(formation_offset + 0x04 + k * 96 + l * 16));
-                LOGGER->Log(" z(%04d)\t", (Sint16)GetU16LE(formation_offset + 0x06 + k * 96 + l * 16));
-                LOGGER->Log("Row %d\t", (Sint16)GetU16LE(formation_offset + 0x08 + k * 96 + l * 16));
-                LOGGER->Log("unknown: ");
-                for (int l = 0; l < 6; ++l)
-                {
-                    LOGGER->Log(" %02x", GetU8(formation_offset + 0x0A + k * 96 + l * 16));
-                }
-                LOGGER->Log("\n");
-            }
-*/
-        }
-    }
-
-
-
-    // attack names and id
-    delete export_text;
-    export_text = new Logger( "enemy_attacks.lua" );
-    int attack_data         = 0x04c0;
-    int attack_id_offset    = 0x0840;
-    int attack_names_offset = 0x0880;
-
-    for( int k = 0; k < 32; ++k )
-    {
-        int attack_id = GetU16LE( attack_id_offset + k * 0x02 );
-        if( attack_id != 65535 )
-        {
-            FFVIIString name;
-            name.resize(32);
-            std::copy( buffer_ + attack_names_offset + k * 0x20, buffer_ + attack_names_offset + 0x20 + k * 0x20, name.begin() );
-
-            export_text->Log( "-- " + Ogre::String( FFVIIStringToString( name ).c_str() ) + " (" + IntToString( GetU16LE( attack_id_offset + k * 0x02 ) ) + ")\n" );
-
-
-            export_text->Log( Ogre::String( AttackIdToString( attack_id ) ) + " = {\n" );
-
-            export_text->Log( "    mp_cost = " + IntToString( GetU16LE( attack_data + k * 0x1c + 0x04 ) ) + ",\n" );
-            export_text->Log( "    power = " + FloatToString( GetU8( attack_data + k * 0x1c + 0x0f ) / 16.0f ) + ",\n" );
-            export_text->Log( "    hit = " + IntToString( GetU8( attack_data + k * 0x1c + 0 ) ) + ",\n" );
-            export_text->Log( "\n");
-            export_text->Log( "    formula = \"0x" + HexToString( GetU8( attack_data + k * 0x1c + 0x0e ), 2, '0' ) + "\",\n" );
-            export_text->Log( "    target = \"0x" + HexToString( GetU8( attack_data + k * 0x1c + 0x0c ), 2, '0' ) + "\",\n" );
-            export_text->Log( "    additional_effect = \"0x" + HexToString( GetU8( attack_data + k * 0x1c + 0x12 ), 2, '0' ) + "\",\n" );
-            export_text->Log( "    additional_effect_modifier = \"0x" + HexToString( GetU8( attack_data + k * 0x1c + 0x13 ), 2, '0' ) + "\",\n" );
-            export_text->Log( "    special = \"0x" + HexToString( GetU16LE( attack_data + k * 0x1c + 0x1a ), 4, '0' ) + "\",\n" );
-            export_text->Log( "\n");
-            int restore_type = GetU8( attack_data + k * 0x1c + 0x10 );
-            if( restore_type == 0 )
-            {
-                export_text->Log( "    restore_type = \"restore_hp\"\n\n" );
-            }
-            else if( restore_type == 1 )
-            {
-                export_text->Log( "    restore_type = \"restore_mp\"\n\n" );
-            }
-            else if( restore_type == 2 )
-            {
-                export_text->Log( "    restore_type = \"restore_status\"\n\n" );
-            }
-
-            u16 elements = GetU16LE( attack_data + k * 0x1c + 0x18 );
-            export_text->Log( "    elements = {" );
-            added = false;
-            if( elements != 65535 )
-            {
-                for( int l = 0; l < 16; ++l )
-                {
-                    if( ( ( elements >> l ) & 1 ) != 0 )
-                    {
-                        added = true;
-                        export_text->Log( "\n        " + ElementIdToString( l ) + "," );
-                    }
-                    if( added == true && l == 15 )
-                    {
-                        export_text->Log( "\n    " );
-                    }
-                }
-            }
-            export_text->Log( "},\n\n");
-
-            u8 status_chance = GetU8( attack_data + k * 0x1c + 0x11 );
-            u8 status_type = status_chance >> 6;
-            status_chance = ( status_chance & 0x3f ) << 2;
-            u32 status = GetU32LE( attack_data + k * 0x1c + 0x14 );
-            if( status != 0xffffffff )
-            {
-                if( status_type == 0 )
-                {
-                    export_text->Log( "    status_add = {" );
-                }
-                else if( status_type == 1 )
-                {
-                    export_text->Log( "    status_remove = {" );
-                }
-                else if( status_type == 2 )
-                {
-                    export_text->Log( "    status_switch = {" );
-                }
-
-                for( int l = 0; l < 32; ++l )
-                {
-                    if( ( ( status >> l ) & 1 ) != 0 )
-                    {
-                        export_text->Log( "\n        " + StatusIdToString( l ) + "," );
-                    }
-                    if( l == 31 )
-                    {
-                        export_text->Log( "\n    " );
-                    }
-                }
-
-                export_text->Log( "},\n\n");
-            }
-
-            export_text->Log( "    target_hurt_script_id = " + IntToString( GetU8( attack_data + k * 0x1c + 0x02 ) ) + ",\n" );
-
-            int sound_id = GetU16LE( attack_data + k * 0x1c + 6 );
-            if( sound_id != 65535 )
-            {
-                export_text->Log( "    sound_id_normal = " + IntToString( sound_id ) + ",\n" );
-                export_text->Log( "    sound_id_cricical = " + IntToString( sound_id ) + ",\n" );
-                export_text->Log( "    sound_id_miss = " + IntToString( sound_id ) + ",\n" );
-            }
-
-            int attack_effect_id = GetU8( attack_data + k * 0x1c + 0x0d );
-            if( attack_effect_id != 255 )
-            {
-                export_text->Log( "    attack_effect_id = " + IntToString( attack_effect_id ) + ",\n" );
-            }
-
-            int impact_effect_id = GetU8( attack_data + k * 0x1c + 0x01 );
-            if( impact_effect_id != 255 )
-            {
-                export_text->Log( "    impact_effect_id = " + IntToString( impact_effect_id ) + ",\n" );
-            }
-
-            int camera_id = GetU16LE( attack_data + k * 0x1c + 0x08 );
-            if( camera_id != 65535 )
-            {
-                export_text->Log( "    camera_id_single = " + IntToString( camera_id ) + ",\n" );
-            }
-
-            camera_id = GetU16LE( attack_data + k * 0x1c + 0x0a );
-            if( camera_id != 65535 )
-            {
-                export_text->Log( "    camera_id_multiple = " + IntToString( camera_id ) + ",\n" );
-            }
-
-            export_text->Log( "},\n\n\n" );
-        }
-    }
-}

+ 0 - 23
utilities/ffvii_battle_scene_dumper/src/EnemyFile.h

@@ -1,23 +0,0 @@
-#ifndef ENEMY_FILE_H
-#define ENEMY_FILE_H
-
-#include "common/File.h"
-
-
-
-class EnemyFile : public File
-{
-public:
-    EnemyFile( const Ogre::String &file );
-    EnemyFile( File* file );
-    EnemyFile( File* file, const u32 &offset, const u32 &length );
-    EnemyFile( u8* buffer, const u32 &offset, const u32 &length );
-    virtual ~EnemyFile();
-
-private:
-    void DumpData();
-};
-
-
-
-#endif // ENEMY_FILE_H

+ 0 - 66
utilities/ffvii_battle_scene_dumper/src/FFVIIString.cpp

@@ -1,66 +0,0 @@
-#include "FFVIIString.h"
-
-
-unsigned char NA = 0xD0;
-
-unsigned char ascii[256] = {      // ASCII to FF7 conversion ( NA  = none)
-    0xFF, NA , NA , NA , NA , NA , NA , NA , NA ,0xE1,0xE7, NA , NA ,0xE8, NA , NA ,
-     NA , NA , NA , NA , NA , NA , NA , NA , NA , NA , NA , NA , NA , NA , NA , NA ,
-    0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
-    0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
-
-    0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F,
-    0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F,
-    0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F,
-    0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E, NA ,
-
-     NA , NA ,0xC2,0xA4,0xC3,0xA9, NA ,0xD6, NA ,0xC4, NA ,0xBC,0xAE, NA , NA , NA ,
-     NA ,0xB4,0xB5,0xB2,0xB3,0xC0,0xB0,0xB1,0x8C,0x8A, NA ,0xBD,0xAF, NA , NA ,0xB9,
-    0xAA,0xA1,0x82,0x83,0xBB,0x94, NA , NA , NA ,0x89,0x9B,0xA7,0xA2, NA ,0x88, NA ,
-    0x81,0x91, NA , NA ,0x8B,0x95,0x86,0xC1, NA , NA ,0x9C,0xA8, NA , NA , NA ,0xA0,
-
-    0xAB,0x61,0xC5,0xAC,0x60, NA ,0x8E,0x62,0xC9,0x63,0xC6,0xC8,0xCD,0xCA,0xCB,0xCC,
-     NA ,0x64,0xD1,0xCE,0xCF,0xAD,0x65, NA ,0x8F, NA ,0x84,0x85,0x66, NA , NA ,0x87,
-    0x68,0x67,0x69,0x6B,0x6A,0x6C,0x9E,0x6D,0x6F,0x6E,0x70,0x71,0x73,0x72,0x74,0x75,
-     NA ,0x76,0x78,0x77,0x79,0x7B,0x7A,0xB6,0x9F,0x7D,0x7C,0x7E,0x7F, NA , NA ,0xB8,
-};
-
-
-
-FFVIIString
-StringToFFVIIString( const Ogre::String& string )
-{
-    FFVIIString ret;
-
-    for( size_t i = 0; i < string.size(); ++i )
-    {
-        ret.push_back( ascii[ string[ i ] ] );
-    }
-
-    return ret;
-}
-
-
-
-Ogre::String
-FFVIIStringToString( const FFVIIString& string )
-{
-    Ogre::String ret;
-
-    for( size_t i = 0; i < string.size(); ++i )
-    {
-        Ogre::String l = "";
-
-        for( int j = 0; j < 256; ++j )
-        {
-            if( ascii[ j ] == string[ i ] )
-            {
-                l = j;
-            }
-        }
-
-        ret += l;
-    }
-
-    return ret;
-}

+ 0 - 21
utilities/ffvii_battle_scene_dumper/src/FFVIIString.h

@@ -1,21 +0,0 @@
-#ifndef FFVIISTRING_H
-#define FFVIISTRING_H
-
-
-
-#include <Ogre.h>
-#include <vector>
-
-
-
-typedef std::vector< unsigned char > FFVIIString;
-
-
-
-// converter
-FFVIIString  StringToFFVIIString( const Ogre::String& string );
-Ogre::String FFVIIStringToString( const FFVIIString& string );
-
-
-
-#endif

+ 0 - 28
utilities/ffvii_battle_scene_dumper/src/Main.cpp

@@ -1,28 +0,0 @@
-#include <Ogre.h>
-#include "../../common/OgreBase.h"
-#include "../../common/Logger.h"
-
-#include "EnemyFile.h"
-#include "PlayerFile.h"
-
-
-
-int
-main( int argc, char *argv[] )
-{
-    InitializeOgreBase( "FFVII Battle Scene Exporter" );
-
-
-
-    EnemyFile* enemy = new EnemyFile( "./data/scene82" );
-    delete enemy;
-
-    //PlayerFile* player = new PlayerFile( "player_ai" );
-    //delete player;
-
-
-
-    DeinitializeOgreBase();
-
-    return 0;
-}

+ 0 - 876
utilities/ffvii_battle_scene_dumper/src/PlayerFile.cpp

@@ -1,876 +0,0 @@
-#include "PlayerFile.h"
-
-#include "FFVIIString.h"
-#include "../../common/Logger.h"
-
-
-
-PlayerFile::PlayerFile( const Ogre::String &file ):
-    File( file )
-{
-    DumpData();
-}
-
-
-
-PlayerFile::PlayerFile( File *file, const u32 &offset, const u32 &length ):
-    File( file, offset, length )
-{
-    DumpData();
-}
-
-
-
-PlayerFile::PlayerFile( u8* buffer, const u32 &offset, const u32 &length ):
-    File( buffer, offset, length )
-{
-    DumpData();
-}
-
-
-
-PlayerFile::PlayerFile( File *file ):
-    File( file )
-{
-    DumpData();
-}
-
-
-
-PlayerFile::~PlayerFile()
-{
-}
-
-
-
-void
-PlayerFile::DumpData()
-{
-/*
-    for (int i = 0; i < 12; ++i)
-    {
-        int ai_offset = GetU16LE(i * 2);
-        if (ai_offset == 0xffff)
-        {
-            continue;
-        }
-        LOGGER->Log("PLAYER %x:\n", i);
-
-        for (int l = 0; l < 0x10; ++l)
-        {
-            u16 local_script_offset = GetU16LE(ai_offset + l * 2);
-            if (local_script_offset == 0xFFFF)
-            {
-                continue;
-            }
-
-            LOGGER->Log("script %x:\n", l);
-
-            int script_offset = ai_offset + local_script_offset;
-            int pointer = 0;
-            bool run = true;
-
-            for (; run == true;)
-            {
-                u8 opcode = GetU8(script_offset + pointer);
-                u8 opcode_h = opcode >> 4;
-                u8 opcode_l = opcode & 0xF;
-
-                LOGGER->Log("0x%04x ", pointer);
-
-
-
-                if (GetU8(script_offset + pointer + 0)  == 0x00 &&
-                    GetU8(script_offset + pointer + 3)  == 0x52 &&
-                    GetU8(script_offset + pointer + 4)  == 0x70)
-                {
-                    int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int jump     = GetU16LE(script_offset + pointer + 5);
-
-                    LOGGER->Log("JumpIfTrue(bit[0x%04x + 0x%02x])(0x%04x);\n", address1, bits1, jump);
-                    pointer += 7;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x01 &&
-                    GetU8(script_offset + pointer + 3)  == 0x52 &&
-                    GetU8(script_offset + pointer + 4)  == 0x70)
-                {
-                    int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int jump     = GetU16LE(script_offset + pointer + 5);
-
-                    LOGGER->Log("JumpIfTrue(b[0x%04x + 0x%02x])(0x%04x);\n", address1, bits1, jump);
-                    pointer += 7;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x00 &&
-                    GetU8(script_offset + pointer + 3)  == 0x70)
-                {
-                    int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int jump     = GetU16LE(script_offset + pointer + 4);
-
-                    LOGGER->Log("JumpIfFalse(bit[0x%04x + 0x%02x])(0x%04x);\n", address1, bits1, jump);
-                    pointer += 6;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x01 &&
-                    GetU8(script_offset + pointer + 3)  == 0x60 &&
-                    GetU8(script_offset + pointer + 5)  == 0x35 &&
-                    GetU8(script_offset + pointer + 6)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x40 &&
-                    GetU8(script_offset + pointer + 9)  == 0x70)
-                {
-                    int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 1) & 7;
-
-                    int value1   = GetU8(script_offset + pointer + 4);
-                    int value2   = GetU8(script_offset + pointer + 7);
-
-                    int jump     = GetU16LE(script_offset + pointer + 10);
-
-                    LOGGER->Log("JumpIf((b[0x%04x + 0x%02x] & 0x%02x) != 0x%02x)(0x%04x);\n", address1, bits1, value1, value2, jump);
-                    pointer += 12;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x02 &&
-                    GetU8(script_offset + pointer + 1)  == 0x60 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x00 &&
-                    GetU8(script_offset + pointer + 4)  == 0x26 &&
-                    GetU8(script_offset + pointer + 5)  == 0x40 &&
-                    GetU8(script_offset + pointer + 6)  == 0x80 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x00 &&
-                    GetU8(script_offset + pointer + 9)  == 0x40 &&
-                    GetU8(script_offset + pointer + 10) == 0x70)
-                {
-                    int address = GetU16LE(script_offset + pointer + 11);
-                    LOGGER->Log("JumpIfSelfNotInFrontRow(0x%04x);\n", address);
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x02 &&
-                    GetU8(script_offset + pointer + 1)  == 0x80 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x00 &&
-                    GetU8(script_offset + pointer + 4)  == 0x26 &&
-                    GetU8(script_offset + pointer + 5)  == 0x40 &&
-                    GetU8(script_offset + pointer + 6)  == 0x80 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x00 &&
-                    GetU8(script_offset + pointer + 9)  == 0x40 &&
-                    GetU8(script_offset + pointer + 10) == 0x70)
-                {
-                    int address = GetU16LE(script_offset + pointer + 11);
-                    LOGGER->Log("JumpIfNotAllFriendsInFrontRow(0x%04x);\n", address);
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x02 &&
-                    GetU8(script_offset + pointer + 1)  == 0x80 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x00 &&
-                    GetU8(script_offset + pointer + 4)  == 0x26 &&
-                    GetU8(script_offset + pointer + 5)  == 0x40 &&
-                    GetU8(script_offset + pointer + 6)  == 0x80 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x01 &&
-                    GetU8(script_offset + pointer + 9)  == 0x40 &&
-                    GetU8(script_offset + pointer + 10) == 0x70)
-                {
-                    int address = GetU16LE(script_offset + pointer + 11);
-                    LOGGER->Log("JumpIfNotAllFriendsInBackRow(0x%04x);\n", address);
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x02 &&
-                    GetU8(script_offset + pointer + 1)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x00 &&
-                    GetU8(script_offset + pointer + 4)  == 0x26 &&
-                    GetU8(script_offset + pointer + 5)  == 0x40 &&
-                    GetU8(script_offset + pointer + 6)  == 0x80 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x00 &&
-                    GetU8(script_offset + pointer + 9)  == 0x40 &&
-                    GetU8(script_offset + pointer + 10) == 0x70)
-                {
-                    int address = GetU16LE(script_offset + pointer + 11);
-                    LOGGER->Log("JumpIfNotAllOpponentsInFrontRow(0x%04x);\n", address);
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x02 &&
-                    GetU8(script_offset + pointer + 1)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x00 &&
-                    GetU8(script_offset + pointer + 4)  == 0x26 &&
-                    GetU8(script_offset + pointer + 5)  == 0x40 &&
-                    GetU8(script_offset + pointer + 6)  == 0x80 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x01 &&
-                    GetU8(script_offset + pointer + 9)  == 0x40 &&
-                    GetU8(script_offset + pointer + 10) == 0x70)
-                {
-                    int address = GetU16LE(script_offset + pointer + 11);
-                    LOGGER->Log("JumpIfNotAllOpponentsInBackRow(0x%04x);\n", address);
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x02 &&
-                    GetU8(script_offset + pointer + 1)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x00 &&
-                    GetU8(script_offset + pointer + 4)  == 0x1a &&
-                    GetU8(script_offset + pointer + 5)  == 0x40 &&
-                    GetU8(script_offset + pointer + 6)  == 0x80 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x00 &&
-                    GetU8(script_offset + pointer + 9)  == 0x40 &&
-                    GetU8(script_offset + pointer + 10) == 0x70)
-                {
-                    int address = GetU16LE(script_offset + pointer + 11);
-                    LOGGER->Log("JumpIfAllOpponentsInDarknessStatus(0x%04x);\n", address);
-                    pointer += 13;
-                    continue;
-                }
-
-                if ((GetU8(script_offset + pointer + 0)  == 0x10 || GetU8(script_offset + pointer + 0)  == 0x11 || GetU8(script_offset + pointer + 0)  == 0x12) &&
-                    GetU8(script_offset + pointer + 3)  == 0x60 &&
-                    GetU8(script_offset + pointer + 5)  == 0x90)
-                {
-                    int address = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int value   = GetU8(script_offset + pointer + 4);
-                    LOGGER->Log("[0x%04x + 0x%02x] = b(0x%02x);\n", address, bits, value);
-                    pointer += 6;
-                    continue;
-                }
-
-                if ((GetU8(script_offset + pointer + 0)  == 0x10 || GetU8(script_offset + pointer + 0)  == 0x11 || GetU8(script_offset + pointer + 0)  == 0x12) &&
-                    GetU8(script_offset + pointer + 3)  == 0x61 &&
-                    GetU8(script_offset + pointer + 6)  == 0x90)
-                {
-                    int address = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int value   = GetU16LE(script_offset + pointer + 4);
-                    LOGGER->Log("[0x%04x + 0x%02x] = h(0x%04x);\n", address, bits, value);
-                    pointer += 7;
-                    continue;
-                }
-
-                if ((GetU8(script_offset + pointer + 0)  == 0x10 || GetU8(script_offset + pointer + 0)  == 0x11 || GetU8(script_offset + pointer + 0)  == 0x12) &&
-                    GetU8(script_offset + pointer + 3)  == 0x62 &&
-                    GetU8(script_offset + pointer + 7)  == 0x90)
-                {
-                    int address = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int value   = (GetU16LE(script_offset + pointer + 4) << 1) | GetU8(script_offset + pointer + 6);
-                    LOGGER->Log("[0x%04x + 0x%02x] = w(0x%08x);\n", address, bits, value);
-                    pointer += 8;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x11 &&
-                    GetU8(script_offset + pointer + 3)  == 0x01 &&
-                    GetU8(script_offset + pointer + 6)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x35 &&
-                    GetU8(script_offset + pointer + 9)  == 0x90)
-                {
-                    int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 1) & 7;
-
-                    int address2 = GetU16LE(script_offset + pointer + 4) >> 3;
-                    int bits2    = GetU16LE(script_offset + pointer + 4) & 7;
-
-                    int value    = GetU8(script_offset + pointer + 7);
-
-                    LOGGER->Log("[0x%04x + 0x%02x] = b(b[0x%04x + 0x%02x] & 0x%02x);\n", address1, bits1, address2, bits2, value);
-                    pointer += 10;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 6)  == 0x90)
-                {
-                    int address1 = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int address2 = GetU16LE(script_offset + pointer + 4) >> 3;
-                    int bits2    = GetU16LE(script_offset + pointer + 4) & 7;
-
-                    LOGGER->Log("[0x%04x + 0x%02x] = h(h[0x%04x + 0x%02x]);\n", address1, bits1, address2, bits2);
-                    pointer += 7;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 3)  == 0x61 &&
-                    GetU8(script_offset + pointer + 6)  == 0x90)
-                {
-                    int address = GetU16LE(script_offset + pointer + 1) >> 3;
-                    int bits    = GetU16LE(script_offset + pointer + 1) & 7;
-                    int value   = GetU8(script_offset + pointer + 4) | (GetU8(script_offset + pointer + 5) << 8);
-                    LOGGER->Log("[0x%04x + 0x%02x] = h(0x%04x);\n", address, bits, value);
-                    pointer += 7;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 1)  == 0x70 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 4)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 5)  == 0x20 &&
-                    GetU8(script_offset + pointer + 6)  == 0x00 &&
-                    GetU8(script_offset + pointer + 7)  == 0x26 &&
-                    GetU8(script_offset + pointer + 8)  == 0x40 &&
-                    GetU8(script_offset + pointer + 9)  == 0x80 &&
-                    GetU8(script_offset + pointer + 10) == 0x60 &&
-                    GetU8(script_offset + pointer + 11) == 0x01 &&
-                    GetU8(script_offset + pointer + 12) == 0x40 &&
-                    GetU8(script_offset + pointer + 13) == 0x82 &&
-                    GetU8(script_offset + pointer + 14) == 0x90)
-                {
-                    LOGGER->Log("SetRandomOpponentInBackRowToAttack();\n");
-                    pointer += 15;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 1)  == 0x70 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 4)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 5)  == 0x20 &&
-                    GetU8(script_offset + pointer + 6)  == 0x00 &&
-                    GetU8(script_offset + pointer + 7)  == 0x26 &&
-                    GetU8(script_offset + pointer + 8)  == 0x40 &&
-                    GetU8(script_offset + pointer + 9)  == 0x80 &&
-                    GetU8(script_offset + pointer + 10) == 0x60 &&
-                    GetU8(script_offset + pointer + 11) == 0x00 &&
-                    GetU8(script_offset + pointer + 12) == 0x40 &&
-                    GetU8(script_offset + pointer + 13) == 0x82 &&
-                    GetU8(script_offset + pointer + 14) == 0x90)
-                {
-                    LOGGER->Log("SetRandomOpponentInFrontRowToAttack();\n");
-                    pointer += 15;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 1)  == 0x70 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 4)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 5)  == 0x20 &&
-                    GetU8(script_offset + pointer + 6)  == 0x03 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x41 &&
-                    GetU8(script_offset + pointer + 9)  == 0x80 &&
-                    GetU8(script_offset + pointer + 10) == 0x85 &&
-                    GetU8(script_offset + pointer + 11) == 0x82 &&
-                    GetU8(script_offset + pointer + 12) == 0x90)
-                {
-                    LOGGER->Log("SetRandomOpponentWithLowestCurrentHP();\n");
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 1)  == 0x70 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 4)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 5)  == 0x20 &&
-                    GetU8(script_offset + pointer + 6)  == 0x03 &&
-                    GetU8(script_offset + pointer + 7)  == 0x60 &&
-                    GetU8(script_offset + pointer + 8)  == 0x41 &&
-                    GetU8(script_offset + pointer + 9)  == 0x80 &&
-                    GetU8(script_offset + pointer + 10) == 0x84 &&
-                    GetU8(script_offset + pointer + 11) == 0x82 &&
-                    GetU8(script_offset + pointer + 12) == 0x90)
-                {
-                    LOGGER->Log("SetRandomOpponentWithHighestCurrentHP();\n");
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 1)  == 0x70 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 4)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 5)  == 0x20 &&
-                    GetU8(script_offset + pointer + 6)  == 0x02 &&
-                    GetU8(script_offset + pointer + 7)  == 0x10 &&
-                    GetU8(script_offset + pointer + 8)  == 0x41 &&
-                    GetU8(script_offset + pointer + 9)  == 0x80 &&
-                    GetU8(script_offset + pointer + 10) == 0x85 &&
-                    GetU8(script_offset + pointer + 11) == 0x82 &&
-                    GetU8(script_offset + pointer + 12) == 0x90)
-                {
-                    LOGGER->Log("SetRandomOpponentWithLowestMagicDefence();\n");
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 1)  == 0x70 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 4)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 5)  == 0x20 &&
-                    GetU8(script_offset + pointer + 6)  == 0x02 &&
-                    GetU8(script_offset + pointer + 7)  == 0x00 &&
-                    GetU8(script_offset + pointer + 8)  == 0x41 &&
-                    GetU8(script_offset + pointer + 9)  == 0x80 &&
-                    GetU8(script_offset + pointer + 10) == 0x85 &&
-                    GetU8(script_offset + pointer + 11) == 0x82 &&
-                    GetU8(script_offset + pointer + 12) == 0x90)
-                {
-                    LOGGER->Log("SetRandomOpponentWithLowestDefence();\n");
-                    pointer += 13;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x12 &&
-                    GetU8(script_offset + pointer + 1)  == 0x70 &&
-                    GetU8(script_offset + pointer + 2)  == 0x20 &&
-                    GetU8(script_offset + pointer + 3)  == 0x02 &&
-                    GetU8(script_offset + pointer + 4)  == 0xA0 &&
-                    GetU8(script_offset + pointer + 5)  == 0x20 &&
-                    GetU8(script_offset + pointer + 6) == 0x82 &&
-                    GetU8(script_offset + pointer + 7) == 0x90)
-                {
-                    LOGGER->Log("SetRandomOpponentToAttack();\n");
-                    pointer += 8;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x60 &&
-                    GetU8(script_offset + pointer + 2)  == 0x02 &&
-                    GetU8(script_offset + pointer + 5) == 0x92)
-                {
-                    int action   = GetU8(script_offset + pointer + 1);
-                    int address1 = GetU16LE(script_offset + pointer + 3) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 3) & 7;
-
-                    LOGGER->Log("RunCommand(0x%02x, h[0x%04x + 0x%02x]);\n", action, address1, bits1);
-                    pointer += 6;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x81 &&
-                    GetU8(script_offset + pointer + 1)  == 0x01 &&
-                    GetU8(script_offset + pointer + 4)  == 0x34 &&
-                    GetU8(script_offset + pointer + 5)  == 0x52 &&
-                    GetU8(script_offset + pointer + 6) == 0x70)
-                {
-                    int address1 = GetU16LE(script_offset + pointer + 2) >> 3;
-                    int bits1    = GetU16LE(script_offset + pointer + 2) & 7;
-                    int jump     = GetU16LE(script_offset + pointer + 7);
-
-                    LOGGER->Log("JumpIfRandomNot(1/b[0x%04x + 0x%02x])(0x%04x);\n", address1, bits1, jump);
-                    pointer += 9;
-                    continue;
-                }
-
-                if (GetU8(script_offset + pointer + 0)  == 0x81 &&
-                    GetU8(script_offset + pointer + 1)  == 0x60 &&
-                    GetU8(script_offset + pointer + 3)  == 0x34 &&
-                    GetU8(script_offset + pointer + 4)  == 0x52 &&
-                    GetU8(script_offset + pointer + 5) == 0x70)
-                {
-                    int value    = GetU8(script_offset + pointer + 2);
-                    int jump     = GetU16LE(script_offset + pointer + 6);
-
-                    LOGGER->Log("JumpIfRandomNot(1/0x%02x)(0x%04x);\n", value, jump);
-                    pointer += 8;
-                    continue;
-                }
-
-
-
-                switch (opcode)
-                {
-                    case 0x00:
-                    case 0x01:
-                    case 0x02:
-                    case 0x03:
-                    {
-                        LOGGER->Log("0x%02x LoadValue(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
-                        pointer += 3;
-                    }
-                    break;
-
-                    case 0x10:
-                    case 0x11:
-                    case 0x12:
-                    case 0x13:
-                    {
-                        LOGGER->Log("0x%02x PushAddress(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
-                        pointer += 3;
-                    }
-                    break;
-
-                    case 0x30:
-                    {
-                        LOGGER->Log("0x%02x MathAdd()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x31:
-                    {
-                        LOGGER->Log("0x%02x MathSub()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x32:
-                    {
-                        LOGGER->Log("0x%02x MathMul()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x33:
-                    {
-                        LOGGER->Log("0x%02x MathDiv()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-
-                    case 0x34:
-                    {
-                        LOGGER->Log("0x%02x MathMod()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x35:
-                    {
-                        LOGGER->Log("0x%02x MathAnd()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x36:
-                    {
-                        LOGGER->Log("0x%02x MathOr()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x37:
-                    {
-                        LOGGER->Log("0x%02x MathNor()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x40:
-                    {
-                        LOGGER->Log("0x%02x CompareEqual()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x41:
-                    {
-                        LOGGER->Log("0x%02x CompareNotEqual()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x42:
-                    {
-                        LOGGER->Log("0x%02x CompareGreaterEqual()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x43:
-                    {
-                        LOGGER->Log("0x%02x CompareLessEqual()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x44:
-                    {
-                        LOGGER->Log("0x%02x CompareGreater()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x45:
-                    {
-                        LOGGER->Log("0x%02x CompareLess()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x50:
-                    {
-                        LOGGER->Log("0x%02x LogAnd()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x51:
-                    {
-                        LOGGER->Log("0x%02x LogOr()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x52:
-                    {
-                        LOGGER->Log("0x%02x LogNot()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x60:
-                    {
-                        u32 value = GetU8(script_offset + pointer + 1);
-                        LOGGER->Log("0x%02x PushImmediate(0x%02x)\n", opcode, value);
-                        pointer += 2;
-                    }
-                    break;
-
-                    case 0x61:
-                    {
-                        u32 value = GetU8(script_offset + pointer + 1) | (GetU8(script_offset + pointer + 2) << 8);
-                        LOGGER->Log("0x%02x PushImmediate(0x%04x)\n", opcode, value);
-                        pointer += 3;
-                    }
-                    break;
-
-                    case 0x70:
-                    {
-                        LOGGER->Log("0x%02x JumpIfFalse(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
-                        pointer += 3;
-                    }
-                    break;
-
-                    case 0x71:
-                    {
-                        LOGGER->Log("0x%02x JumpIfNotEqual(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
-                        pointer += 3;
-                    }
-                    break;
-
-                    case 0x72:
-                    {
-                        LOGGER->Log("0x%02x JumpTo(0x%04x)\n", opcode, GetU16LE(script_offset + pointer + 1));
-                        pointer += 3;
-                    }
-                    break;
-
-                    case 0x73:
-                    {
-                        LOGGER->Log("0x%02x FinishScript()\n", opcode);
-                        run = false;
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x75:
-                    {
-                        LOGGER->Log("0x%02x LinkScriptToOtherPlayer()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x80:
-                    {
-                        LOGGER->Log("0x%02x FilterValueByMask()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x81:
-                    {
-                        LOGGER->Log("0x%02x MathRandom()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x82:
-                    {
-                        LOGGER->Log("0x%02x PickRandomBit()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x83:
-                    {
-                        LOGGER->Log("0x%02x CountActiveBits()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x84:
-                    {
-                        LOGGER->Log("0x%02x GetHighestMask()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x85:
-                    {
-                        LOGGER->Log("0x%02x GetLowestMask()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x86:
-                    {
-                        LOGGER->Log("0x%02x GetMPCost()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x87:
-                    {
-                        LOGGER->Log("0x%02x SetBit()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x90:
-                    {
-                        LOGGER->Log("0x%02x StoreValue()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x91:
-                    {
-                        LOGGER->Log("0x%02x Pop()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x92:
-                    {
-                        LOGGER->Log("0x%02x RunCommand()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x93:
-                    {
-                        LOGGER->Log("0x%02x DisplayText(", opcode);
-                        pointer += 1;
-
-                        FFVIIString text;
-
-                        unsigned char letter = GetU8(script_offset + pointer);
-                        while (true)
-                        {
-                            if (letter == 0xea || letter == 0xeb || letter == 0xec || letter == 0xed || letter == 0xee || letter == 0xef || letter == 0xf0 || letter == 0xf1)
-                            {
-                                LOGGER->Log("[variable%02x", letter);
-                                LOGGER->Log("%02x", GetU8(script_offset + pointer + 1));
-                                LOGGER->Log("%02x]", GetU8(script_offset + pointer + 2));
-                                pointer += 3;
-                            }
-                            else
-                            {
-                                LOGGER->Log("%02x", letter);
-                                text.push_back(letter);
-                                pointer += 1;
-
-                                if (letter == 0xff)
-                                {
-                                    break;
-                                }
-                            }
-
-                            letter = GetU8(script_offset + pointer);
-                        }
-
-                        RString r_text = FFVIIStringToRString(text);
-                        LOGGER->Log(")(%s)\n", r_text.c_str());
-
-                    }
-                    break;
-
-                    case 0x94:
-                    {
-                        LOGGER->Log("0x%02x CopyUnitsData()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x95:
-                    {
-                        LOGGER->Log("0x%02x ExchangeByteWithMemory(800f83a4 + 2 <-> memorybank1/2)\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0x96:
-                    {
-                        LOGGER->Log("0x%02x GetUnitsElementalDefense()\n", opcode);
-                        pointer += 1;
-                    }
-                    break;
-
-                    case 0xA0:
-                    {
-                        LOGGER->Log("0x%02x DebugTextOutput(", opcode);
-                        pointer += 1;
-
-                        unsigned char pop = GetU8(script_offset + pointer);
-                        pointer += 1;
-
-                        char letter[2];
-                        letter[1] = 0;
-
-                        letter[0] = GetU8(script_offset + pointer);
-                        while (letter[0] != 0)
-                        {
-                            LOGGER->Log("%s", letter);
-                            pointer += 1;
-
-                            letter[0] = GetU8(script_offset + pointer);
-                        }
-
-                        pointer += 1;
-                        LOGGER->Log(")(pop %d var from stack)\n", pop);
-
-                    }
-                    break;
-
-                    default:
-                    {
-                        LOGGER->Log("0x%02x Unknown\n", opcode);
-                        run = false;
-                    }
-                }
-            }
-
-            LOGGER->Log("\n", l);
-        }
-
-        LOGGER->Log("\n\n\n");
-    }
-*/
-}

+ 0 - 23
utilities/ffvii_battle_scene_dumper/src/PlayerFile.h

@@ -1,23 +0,0 @@
-#ifndef PLFILE_H
-#define PLFILE_H
-
-#include "common/File.h"
-
-
-
-class PlayerFile : public File
-{
-public:
-    PlayerFile( const Ogre::String &file );
-    PlayerFile( File* file );
-    PlayerFile( File* file, const u32 &offset, const u32 &length );
-    PlayerFile( u8* buffer, const u32 &offset, const u32 &length );
-    virtual ~PlayerFile();
-
-private:
-    void DumpData();
-};
-
-
-
-#endif // PLFILE_H

+ 0 - 46
utilities/ffvii_field_dat_dumper/CMakeLists.txt

@@ -1,46 +0,0 @@
-include_directories(
-    ${CMAKE_CURRENT_SOURCE_DIR}/include
-)
-
-# define header and source files
-set(HEADER_FILES
-    src/MimFile.h
-    src/DatFile.h
-)
-set(SOURCE_FILES
-    src/MimFile.cpp
-    src/DatFile.cpp
-    src/Main.cpp
-)
-
-add_definitions(
-    -DQGEARS_ADD_MANAGERS
-)
-
-add_executable(ff7_field_dat_dumper
-  ${HEADER_FILES}
-  ${SOURCE_FILES}
-)
-SET_PROPERTY(TARGET ff7_field_dat_dumper PROPERTY FOLDER "utilities")
-
-if (APPLE)
-target_link_libraries(ff7_field_dat_dumper "-framework CoreFoundation -framework Cocoa -framework IOKit")
-endif()
-
-if(WIN32)
-  set_target_properties(ff7_field_dat_dumper PROPERTIES WIN32_EXECUTABLE ON)
-  if (MSVC)
-    set_target_properties(ff7_field_dat_dumper PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
-  endif()
-endif()
-
-set(LIBRARIES
-    Utility
-    QGearsMain
-    v-gears-data
-)
-target_link_libraries(ff7_field_dat_dumper    ${LIBRARIES})
-
-install(TARGETS ff7_field_dat_dumper
-    DESTINATION tools/ff7
-)

+ 0 - 3645
utilities/ffvii_field_dat_dumper/src/DatFile.cpp

@@ -1,3645 +0,0 @@
-#include "DatFile.h"
-
-#include <OgreStringConverter.h>
-#include <OgreVector3.h>
-
-
-
-class surface_find
-{
-public:
-    surface_find( const SurfaceTexData& a ):
-        m_Surface(a)
-    {
-    }
-
-    bool
-    operator()( const SurfaceTexData& a ) const
-    {
-        return ( a.page_x     == m_Surface.page_x ) &&
-               ( a.page_y     == m_Surface.page_y ) &&
-               ( a.clut_y     == m_Surface.clut_y ) &&
-               ( a.clut_x     == m_Surface.clut_x ) &&
-               ( a.bpp        == m_Surface.bpp ) &&
-               ( a.clut_start == m_Surface.clut_start ) &&
-               ( a.clut_width == m_Surface.clut_width ) &&
-               ( a.mod_type   == m_Surface.mod_type ) &&
-               ( a.mod_r      == m_Surface.mod_r ) &&
-               ( a.mod_g      == m_Surface.mod_g ) &&
-               ( a.mod_b      == m_Surface.mod_b );
-    }
-
-private:
-    SurfaceTexData m_Surface;
-};
-
-
-
-class added_tile_find
-{
-public:
-    added_tile_find( const AddedTile& a ):
-        m_Tile( a )
-    {
-    }
-
-    bool
-    operator()( const AddedTile& a ) const
-    {
-        return ( a.background == m_Tile.background ) &&
-               ( a.src_x      == m_Tile.src_x ) &&
-               ( a.src_y      == m_Tile.src_y ) &&
-               ( a.clut_x     == m_Tile.clut_x ) &&
-               ( a.clut_y     == m_Tile.clut_y ) &&
-               ( a.bpp        == m_Tile.bpp ) &&
-               ( a.page_x     == m_Tile.page_x ) &&
-               ( a.page_y     == m_Tile.page_y ) &&
-               ( a.clut_start == m_Tile.clut_start ) &&
-               ( a.clut_width == m_Tile.clut_width ) &&
-               ( a.mod_type   == m_Tile.mod_type ) &&
-               ( a.mod_r      == m_Tile.mod_r ) &&
-               ( a.mod_g      == m_Tile.mod_g ) &&
-               ( a.mod_b      == m_Tile.mod_b );
-    }
-
-private:
-    AddedTile m_Tile;
-};
-
-
-
-class anim_time_sort
-{
-public:
-    bool
-    operator()( const KeyFrame& x, const KeyFrame& y ) const
-    {
-        return x.time < y.time;
-    }
-};
-
-
-
-class anim_name_sort
-{
-public:
-    bool
-    operator()( const Animation& x, const Animation& y ) const
-    {
-        return x.name < y.name;
-    }
-};
-
-
-
-std::vector< Ogre::String > DatFile::m_SoundOpcodes;
-
-
-
-//////////////////////////////////////////////
-static const unsigned short english_chars[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x2000, 0x2100, 0x2200, 0x2300, 0x2400, 0x2500, 0x2600, 0x2700, 0x2800, 0x2900, 0x2A00, 0x2B00, 0x2C00, 0x2D00, 0x2E00, 0x2F00, // 0x00 - 0x0F
-    0x3000, 0x3100, 0x3200, 0x3300, 0x3400, 0x3500, 0x3600, 0x3700, 0x3800, 0x3900, 0x3A00, 0x3B00, 0x3C00, 0x3D00, 0x3E00, 0x3F00, // 0x10 - 0x1F
-    0x4000, 0x4100, 0x4200, 0x4300, 0x4400, 0x4500, 0x4600, 0x4700, 0x4800, 0x4900, 0x4A00, 0x4B00, 0x4C00, 0x4D00, 0x4E00, 0x4F00, // 0x20 - 0x2F
-    0x5000, 0x5100, 0x5200, 0x5300, 0x5400, 0x5500, 0x5600, 0x5700, 0x5800, 0x5900, 0x5A00, 0x5B00, 0x5C00, 0x5D00, 0x5E00, 0x5F00, // 0x30 - 0x3F
-    0x6000, 0x6100, 0x6200, 0x6300, 0x6400, 0x6500, 0x6600, 0x6700, 0x6800, 0x6900, 0x6A00, 0x6B00, 0x6C00, 0x6D00, 0x6E00, 0x6F00, // 0x40 - 0x4F
-    0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700, 0x7800, 0x7900, 0x7A00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2620, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x1C20, 0x1D20, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0D00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-static const unsigned short japanese_chars[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0xD030, 0x7030, 0xD330, 0x7330, 0xD630, 0x7630, 0xD930, 0x0000, 0xDC30, 0x7C30, 0xAC30, 0x4C30, 0xAE30, 0x4E30, 0xB030, 0x5030, // 0x00 - 0x0F
-    0xB230, 0x5230, 0xB430, 0x5430, 0xB630, 0x5630, 0xB830, 0x5830, 0xBA30, 0x5A30, 0xBC30, 0x5C30, 0xBE30, 0x5E30, 0xC030, 0x6030, // 0x10 - 0x1F
-    0x0000, 0x0000, 0xC530, 0x0000, 0xC730, 0x6730, 0xC930, 0x6930, 0x0000, 0xD130, 0x7130, 0xD430, 0x0000, 0xD730, 0x7730, 0xDA30, // 0x20 - 0x2F
-    0x0000, 0xDD30, 0x0000, 0x3000, 0x3100, 0x3200, 0x3300, 0x3400, 0x3500, 0x3600, 0x3700, 0x3800, 0x3900, 0x0130, 0x0230, 0x2000, // 0x30 - 0x3F
-    0xCF30, 0x6F30, 0xD230, 0x7230, 0xD530, 0x7530, 0xD830, 0x7830, 0xDB30, 0x7B30, 0xAB30, 0x4B30, 0xAD30, 0x4D30, 0xAF30, 0x4F30, // 0x40 - 0x4F
-    0xB130, 0x5130, 0xB330, 0x5330, 0xB530, 0x5530, 0xB730, 0x5730, 0xB930, 0x5930, 0xBB30, 0x5B30, 0xBD30, 0x5D30, 0xBF30, 0x5F30, // 0x50 - 0x5F
-    0xC130, 0x6130, 0xC430, 0x6430, 0xC630, 0x6630, 0xC830, 0x6830, 0xA630, 0x4630, 0xA230, 0x4230, 0xA430, 0x4430, 0xA830, 0x4830, // 0x60 - 0x6F
-    0xAA30, 0x4A30, 0xCA30, 0x6A30, 0xCB30, 0x6B30, 0x0000, 0x6C30, 0xCD30, 0x6D30, 0xCE30, 0x6E30, 0xDE30, 0x7E30, 0xDF30, 0x7F30, // 0x70 - 0x7F
-    0xE030, 0x8030, 0xE130, 0x8130, 0xE230, 0x8230, 0xE930, 0x8930, 0xEA30, 0x8A30, 0xEB30, 0x8B30, 0xEC30, 0x8C30, 0xED30, 0x8D30, // 0x80 - 0x8F
-    0xE430, 0x8430, 0xE630, 0x0000, 0x0000, 0x8830, 0xEF30, 0x8F30, 0xF330, 0x9330, 0x0000, 0x9230, 0xC330, 0x6330, 0xE330, 0x8330, // 0x90 - 0x9F
-    0xE530, 0x8530, 0xE730, 0x8730, 0xA130, 0x4130, 0xA330, 0x0000, 0xA530, 0x0000, 0xA730, 0x4730, 0x0000, 0x4930, 0x01FF, 0x1FFF, // 0xA0 - 0xAF
-    0x0E30, 0x0F30, 0x0000, 0x0000, 0x4100, 0x4200, 0x4300, 0x4400, 0x4500, 0x4600, 0x4700, 0x4800, 0x4900, 0x4A00, 0x4B00, 0x4C00, // 0xB0 - 0xBF
-    0x4D00, 0x4E00, 0x4F00, 0x5000, 0x5100, 0x5200, 0x5300, 0x5400, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFB30, 0x0000, // 0xC0 - 0xCF
-    0xFC30, 0x7E00, 0x2620, 0x0000, 0x0000, 0x0000, 0x0000, 0x1030, 0x1130, 0x0000, 0x0000, 0x0000, 0x0000, 0x0C30, 0x0D30, 0x08FF, // 0xD0 - 0xDF
-    0x09FF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0D00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-static const unsigned short japanese_chars_fa[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2759, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0672, 0x7F4F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3478, 0x4466, 0x8364, 0x0000, 0x0000, 0x0000, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x666B, 0x5E79, 0x0000, 0x0000, 0xA898, 0x0000, 0x176C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x885B, 0x0000, 0x7D54, 0x0000, 0xD552, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6297, 0x0000, 0x0000, 0x0000, 0x0854, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x0E66, 0x0000, 0x0000, 0x9C62, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x004E, 0x0000, 0x0580, // 0x50 - 0x5F
-    0x0000, 0x0000, 0x857F, 0x0000, 0x0000, 0x0000, 0x9950, 0x6856, 0x0000, 0x549B, 0xD56C, 0x0000, 0x0000, 0x0000, 0x0000, 0xFA51, // 0x60 - 0x6F
-    0x0163, 0xF876, 0x4B62, 0x0000, 0xBA78, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xB965, 0x4C88, 0x0000, // 0x70 - 0x7F
-    0x9A5B, 0x0000, 0x0000, 0x4D52, 0x1F77, 0x0000, 0x9A89, 0x1752, 0x8C5F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xDE56, 0x0000, // 0x80 - 0x8F
-    0x9A7D, 0x7565, 0x0000, 0x0000, 0x0000, 0x0000, 0x3E5C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0882, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3E5F, 0x0000, 0x0000, 0x0000, 0x4266, 0x0000, 0x0000, 0x2662, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x0000, 0x0000, 0xB751, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xEA8C, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0xCD53, 0x0000, 0xEE76, 0x0000, 0x0000, 0x9B52, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7551, 0x0000, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-static const unsigned short japanese_chars_fb[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0xB182, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0B4E, 0x0000, 0x6551, 0x4851, 0x0D4E, 0x505B, 0x9B4F, 0x4B5C, // 0x00 - 0x0F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8E96, 0x0000, 0x0000, 0xE890, 0x0000, 0x3458, 0x0000, 0xF24E, 0x9395, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x5096, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x554F, 0x0000, 0x9965, 0x0000, 0x0A4E, 0x0000, 0x8B4E, 0x0000, 0x0000, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6559, 0x0000, 0x0000, 0x0000, 0x1D52, 0x5167, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0xCA8E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xBA87, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x7751, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xB672, 0x4B61, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8B95, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0C54, 0x1F90, 0x4590, 0x0000, 0x0000, 0x0000, 0x0000, 0x7354, 0x0000, 0x0000, 0x0000, 0x0D50, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0xBA4E, 0xCA4E, 0x0000, 0x0000, 0x535F, 0x0000, 0x0000, 0xDB98, 0xE54E, 0x1659, 0x0000, 0x0000, 0x0000, 0xAB8E, 0x0000, // 0x90 - 0x9F
-    0xCB65, 0x0000, 0x0000, 0x0000, 0x5F6A, 0xB068, 0x0000, 0x8970, 0xB065, 0x214E, 0x2C67, 0x1B54, 0x0000, 0x8551, 0x5C4F, 0x668B, // 0xA0 - 0xAF
-    0x7972, 0x0000, 0x0000, 0x0000, 0x747A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xB38D, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7795, 0x0000, 0x0000, 0x5458, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8B89, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4351, 0x0000, 0x0000, 0x0000, 0x427D, 0x0000, 0x0000, 0x0D54, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x1062, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-static const unsigned short japanese_chars_fc[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0x188A, 0x0000, 0x7890, 0x6A75, 0x5788, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F
-    0x9358, 0xC35F, 0x0000, 0x0000, 0x0000, 0x0000, 0x5390, 0x0000, 0x0000, 0x0000, 0x0000, 0xFB5D, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x884E, 0x0000, 0x3D84, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x20 - 0x2F
-    0xE565, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xE353, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x296E, 0x0000, 0x0000, 0x0000, 0x0000, 0x708D, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x7153, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x008A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x3159, 0x5765, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0xBC62, 0x0000, 0x0000, 0x0000, 0x5965, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0000, 0x0000, 0x0000, 0xC253, 0xE577, 0x5E80, 0x0000, 0xD54E, 0x2552, 0xC696, 0xE14F, 0x2875, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xE965, 0x0000, 0x0000, 0x0000, 0x0000, 0x718A, 0x305E, 0x0000, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0xF258, 0x6E6D, 0x0000, 0xA052, 0x0000, 0x047D, 0x0000, 0x3C79, 0x5F67, 0x0000, 0x3775, 0x0000, 0x0000, 0x0000, 0xCB7A, // 0xA0 - 0xAF
-    0x0000, 0xFA4F, 0x0000, 0x0000, 0x0000, 0xC179, 0x0000, 0x0000, 0x1250, 0x114F, 0x0000, 0x0000, 0x0000, 0xA952, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xAC8A, 0x0000, 0x0000, 0xF167, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-static const unsigned short japanese_chars_fd[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x1D4F, 0x0000, 0xA263, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F
-    0xE682, 0x0000, 0xF056, 0x0000, 0x0000, 0x0000, 0x0000, 0xA25B, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0000, 0x2B59, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xB88C, 0x1F67, 0x0000, 0x0000, 0x0000, 0x0000, 0xDD4F, 0x2F5E, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x1154, 0x0000, 0x0000, 0x7289, 0x0000, 0x216B, 0x0000, 0x207D, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xB78C, 0x0000, 0x0000, 0x0000, 0x7C5E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x8179, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x975E, 0x0000, 0x0000, 0x0000, 0xCA7D, 0x1478, 0x0000, 0x0000, 0x8766, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0xC599, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFD88, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x3293, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x5453, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x3181, 0x0000, 0x8D8E, 0x0000, 0x0000, 0x0000, 0x0000, 0x3052, 0x0000, 0x0000, 0x0000, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x9F52, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x5291, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-static const unsigned short japanese_chars_fe[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0x0000, 0x667D, 0x0000, 0x0000, 0x0000, 0xAD65, 0x0000, 0x0000, 0xB96C, 0x0000, 0xD550, 0x585B, 0x0000, 0x0000, // 0x00 - 0x0F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8B4F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x9758, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x0000, 0xB48C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4256, 0xF158, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xB54F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1D8B, 0x0000, 0x0000, 0x0000, 0xA14F, 0x206B, 0xC45B, 0xD95F, // 0x70 - 0x7F
-    0x0000, 0x944E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xA65E, 0x0000, 0x0000, 0x0000, 0x0000, 0x988A, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x298F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x668A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7272, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC079, 0x0000, 0xFD8E, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3B52, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-static const std::map<int, Ogre::String> MapIdToFieldName
-{
-    { 0x74, "ffvii_md1stin" },
-    { 0x75, "ffvii_md1_1" },
-    { 0x76, "ffvii_md1_2" }
-};
-
-Ogre::String
-MapIdToString( const int map_id )
-{
-    auto it = MapIdToFieldName.find(map_id);
-    if (it != std::end(MapIdToFieldName))
-    {
-        return it->second;
-    }
-    return "Unknown_0x" + HexToString( map_id, 4, '0' );
-}
-
-
-
-float
-MapIdToScale( const int map_id )
-{
-    switch( map_id )
-    {
-        case 0x75: return 2.0f;
-    }
-
-    return 1.0f;
-}
-
-DatFile::DatFile(const Ogre::String &file):
-    LzsFile(file)
-{
-}
-
-DatFile::DatFile(File *file, const u32 offset, const u32 length):
-    LzsFile(file, offset, length)
-{
-}
-
-DatFile::DatFile(u8* buffer, const u32 offset, const u32 length):
-    LzsFile(buffer, offset, length)
-{
-}
-
-DatFile::DatFile(File *file):
-    LzsFile(file)
-{
-}
-
-DatFile::~DatFile()
-{
-    delete full_image;
-
-    for( u8 i = 0; i < m_Surfaces.size(); ++i )
-    {
-        delete m_Surfaces[ i ].surface;
-    }
-    m_Surfaces.clear();
-}
-
-
-void
-DatFile::DumpText( const Ogre::String& export_path, const Field& field, bool english )
-{
-    std::sort( m_Dialogs.begin(), m_Dialogs.end() );
-    m_Dialogs.erase( std::unique( m_Dialogs.begin(), m_Dialogs.end()), m_Dialogs.end() );
-
-    Logger* export_text = new Logger( export_path + "maps/ffvii_field/" + field.name + "_text.txt" );
-
-    // get sector 1 offset (scripts and dialog)
-    u32 offset_to_sector  = 0x1C;
-    u16 offset_to_dialogs = GetU16LE( offset_to_sector + 0x04 );
-
-    std::vector< unsigned char > dialog;
-    dialog.push_back(0xFF);
-    dialog.push_back(0xFE);
-
-    for (unsigned int i = 0; i < m_Dialogs.size(); ++i)
-    {
-        // get offset of string data
-        u32 offset = offset_to_sector + offset_to_dialogs + GetU16LE(offset_to_sector + offset_to_dialogs + 0x02 + m_Dialogs[i] * 0x02);
-
-        export_text->Log(dialog);
-        dialog.clear();
-        export_text->LogW( "<dialog id=\"" + std::to_string(m_Dialogs[i]) + "\">" );
-
-        for (unsigned char temp = 0x00; ; ++offset)
-        {
-            temp = GetU8(offset);
-            if (temp == 0xFF)
-            {
-                break;
-            }
-
-            if (temp == 0xE0 && english == true)
-            {
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-            }
-            else if (temp == 0xE1 && english == true)
-            {
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-            }
-            else if (temp == 0xE2 && english == true)
-            {
-                dialog.push_back(english_chars[0x0C] >> 8); dialog.push_back(english_chars[0x0C] & 0xFF);
-                dialog.push_back(english_chars[0x00] >> 8); dialog.push_back(english_chars[0x00] & 0xFF);
-            }
-            else if (temp == 0xE8)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<next_page />");
-            }
-            else if (temp == 0xEA)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<include name=\"char_cloud\" />");
-            }
-            else if (temp == 0xEB)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<include name=\"char_barret\" />");
-            }
-            else if (temp == 0xEC)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"2\" />");
-            }
-            else if (temp == 0xED)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"3\" />");
-            }
-            else if (temp == 0xEE)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"4\" />");
-            }
-            else if (temp == 0xEF)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"5\" />");
-            }
-            else if (temp == 0xF0)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"6\" />");
-            }
-            else if (temp == 0xF1)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"7\" />");
-            }
-            else if (temp == 0xF2)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character id=\"8\" />");
-            }
-            else if (temp == 0xF3)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character party_id=\"0\" />");
-            }
-            else if (temp == 0xF4)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character party_id=\"1\" />");
-            }
-            else if (temp == 0xF5)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<character party_id=\"2\" />");
-            }
-            else if (temp == 0xF6)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<image sprite=\"ButtonCircle\" />");
-            }
-            else if (temp == 0xF7)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<image sprite=\"ButtonTriangle\" />");
-            }
-            else if (temp == 0xF8)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<image sprite=\"ButtonSquare\" />");
-            }
-            else if (temp == 0xF9)
-            {
-                export_text->Log(dialog);
-                dialog.clear();
-                export_text->LogW("<image sprite=\"ButtonCross\" />");
-            }
-            else if ((temp == 0xFA || temp == 0xFB ||temp == 0xFC ||temp == 0xFD) && english == false)
-            {
-                ++offset;
-                unsigned char temp2 = GetU8(offset);
-
-                if (temp == 0xFA)
-                {
-                    if (japanese_chars_fa[temp2] != 0x0000)
-                    {
-                        dialog.push_back(japanese_chars_fa[temp2] >> 8); dialog.push_back(japanese_chars_fa[temp2] & 0xFF);
-                    }
-                    else
-                    {
-                        export_text->Log(dialog);
-                        dialog.clear();
-                        export_text->LogW("[MISSING 0xFA " + HexToString(temp2, 2, '0') + "]");
-                    }
-                }
-                else if (temp == 0xFB)
-                {
-                    if (japanese_chars_fb[temp2] != 0x0000)
-                    {
-                        dialog.push_back(japanese_chars_fb[temp2] >> 8); dialog.push_back(japanese_chars_fb[temp2] & 0xFF);
-                    }
-                    else
-                    {
-                        export_text->Log(dialog);
-                        dialog.clear();
-                        export_text->LogW("[MISSING 0xFB " + HexToString(temp2, 2, '0') + "]");
-                    }
-                }
-                else if (temp == 0xFC)
-                {
-                    if (japanese_chars_fc[temp2] != 0x0000)
-                    {
-                        dialog.push_back(japanese_chars_fc[temp2] >> 8); dialog.push_back(japanese_chars_fc[temp2] & 0xFF);
-                    }
-                    else
-                    {
-                        export_text->Log(dialog);
-                        dialog.clear();
-                        export_text->LogW("[MISSING 0xFC " + HexToString(temp2, 2, '0') + "]");
-                    }
-                }
-                else if( temp == 0xFD )
-                {
-                    if( japanese_chars_fd[ temp2 ] != 0x0000 )
-                    {
-                        dialog.push_back( japanese_chars_fd[ temp2 ] >> 8 ); dialog.push_back( japanese_chars_fd[ temp2 ] & 0xFF );
-                    }
-                    else
-                    {
-                        export_text->Log( dialog );
-                        dialog.clear();
-                        export_text->LogW( "[MISSING 0xFD " + HexToString( temp2, 2, '0' ) + "]" );
-                    }
-                }
-            }
-            else if (temp == 0xFE)
-            {
-                ++offset;
-
-                unsigned char temp2 = GetU8(offset);
-
-                if (temp2 == 0xD4)
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<colour id=\"red\" />");
-                }
-                else if (temp2 == 0xD5)
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<colour id=\"purple\" />");
-                }
-                else if (temp2 == 0xD6)
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<colour id=\"green\" />");
-                }
-                else if (temp2 == 0xD7)
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<colour id=\"cyan\" />");
-                }
-                else if (temp2 == 0xD8)
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<colour id=\"yellow\" />");
-                }
-                else if (temp2 == 0xD9)
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("</colour>");
-                }
-                else if (temp2 == 0xDC)
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<pause_ok />");
-                }
-                else if (temp2 == 0xDD)
-                {
-                    u16 wait = GetU16LE(offset + 1);
-                    ++offset;
-                    ++offset;
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("<pause time=\"" + IntToString(wait) + "\" />");
-                }
-                else
-                {
-                    if (japanese_chars_fe[temp2] != 0x0000 && english == false)
-                    {
-                        dialog.push_back(japanese_chars_fe[temp2] >> 8); dialog.push_back(japanese_chars_fe[temp2] & 0xFF);
-                    }
-                    else
-                    {
-                        export_text->Log(dialog);
-                        dialog.clear();
-                        export_text->LogW("[MISSING 0xFE " + HexToString(temp2, 2, '0') + "]");
-                    }
-                }
-            }
-            else
-            {
-                if (japanese_chars[temp] != 0x0000 && english == false)
-                {
-                    dialog.push_back(japanese_chars[temp] >> 8); dialog.push_back(japanese_chars[temp] & 0xFF);
-                }
-                else if (english_chars[temp] != 0x0000 && english == true)
-                {
-                    dialog.push_back(english_chars[temp] >> 8); dialog.push_back(english_chars[temp] & 0xFF);
-                }
-                else
-                {
-                    export_text->Log(dialog);
-                    dialog.clear();
-                    export_text->LogW("[MISSING CHAR " + HexToString(temp, 2, '0') + "]");
-                }
-            }
-        }
-
-        export_text->Log(dialog);
-        dialog.clear();
-        export_text->LogW("</dialog>\n\n");
-    }
-
-    delete export_text;
-}
-
-
-
-void
-DatFile::DumpScript(const Ogre::String& export_path, const Field& field)
-{
-    Logger* export_script = new Logger(export_path + "maps/ffvii_field/" + field.name + "_script.txt");
-
-    // get sector 1 offset (scripts and dialog)
-    u32 start_address = GetU32LE(0);
-    u32 offset_to_sector = 0x1c;
-
-    u8  number_of_entity = GetU8(offset_to_sector + 0x02);
-    u16 string_offset = GetU16LE(offset_to_sector + 0x04);
-    u16 number_of_extra_offsets = GetU16LE(offset_to_sector + 0x06);
-
-    float downscaler = 128.0f * field.scale;
-
-    std::vector< Ogre::String > entity_list;
-
-    for (u8 i = 0; i < number_of_entity; ++i)
-    {
-        // get entity name
-        Ogre::String name = Ogre::String(reinterpret_cast<char*>(buffer_)+offset_to_sector + 0x20 + i * 0x08);
-        if (name == "")
-        {
-            name = "unnamed_" + IntToString(i);
-        }
-        entity_list.push_back(name);
-    }
-
-    for (u8 i = 0; i < number_of_entity; ++i)
-    {
-        export_script->Log(entity_list[i] + "\n");
-        u32 prev_script = 0;
-        bool one_ret_check = false;
-
-        for (u8 j = 0; j < 32; ++j)
-        {
-            u32 script = offset_to_sector + GetU16LE(offset_to_sector + 0x20 + number_of_entity * 0x08 + number_of_extra_offsets * 0x04 + i * 0x40 + j * 0x02);
-            u32 end = script;
-
-            u8 opcode = GetU8(script);
-
-            if (opcode == 0x00 && j != 0) // skip if script contain only RET opcode and this is not init script
-            {
-                continue;
-            }
-            if (prev_script == script)
-            {
-                continue;
-            }
-            prev_script = script;
-
-            export_script->Log("script_" + IntToString(j) + ":\n");
-
-            for (; script <= end;)
-            {
-                export_script->Log(OffsetString(script) + " (end " + OffsetString(end) + "): ");
-
-                u8 opcode = GetU8(script);
-
-                switch (opcode)
-                {
-                case RET:
-                {
-                    export_script->Log("return\n");
-
-                    if (j == 0 && one_ret_check == false) // in init we need to meet ret at least once
-                    {
-                        AdvanceScript(1, script, end);
-                        one_ret_check = true;
-                    }
-                    else
-                    {
-                        script += 1;
-                    }
-                } break;
-
-                case REQ:
-                {
-                    u8 entity_id = GetU8(script + 1);
-                    u8 priority = GetU8(script + 2) >> 5;
-                    u8 script_id = GetU8(script + 2) & 0x1F;
-                    export_script->Log("script:request( \"" + entity_list[entity_id] + "\", \"script_" + IntToString(script_id) + "\", " + IntToString(priority) + " )\n");
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case REQSW:
-                {
-                    u8 entity_id = GetU8(script + 1);
-                    u8 priority = GetU8(script + 2) >> 5;
-                    u8 script_id = GetU8(script + 2) & 0x1F;
-                    export_script->Log("script:request_start_sync( \"" + entity_list[entity_id] + "\", \"script_" + IntToString(script_id) + "\", " + IntToString(priority) + " )\n");
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case REQEW:
-                {
-                    u8 entity_id = GetU8(script + 1);
-                    u8 priority = GetU8(script + 2) >> 5;
-                    u8 script_id = GetU8(script + 2) & 0x1F;
-                    export_script->Log("script:request_end_sync( \"" + entity_list[entity_id] + "\", \"script_" + IntToString(script_id) + "\", " + IntToString(priority) + " )\n");
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case RETTO:
-                {
-                    u8 priority = GetU8(script + 1) >> 5;
-                    u8 script_id = GetU8(script + 1) & 0x1F;
-
-                    export_script->Log(
-                        "return_to( \"script_" +
-                        IntToString(script_id) +
-                        "\", " +
-                        IntToString(priority) +
-                        " );\n"
-                        );
-
-                    script += 2;
-                } break;
-
-                case JOIN:
-                {
-                    export_script->Log(
-                        "[UNREVERSED] JOIN(" +
-                        ArgumentString(script + 1, 1) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case SPLIT:
-                {
-                    export_script->Log(
-                        "[UNREVERSED] SPLIT(" +
-                        ArgumentString(script + 1, 14) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(15, script, end);
-                } break;
-
-                case SPTYE:
-                {
-                    export_script->Log(
-                        "game:party_set( " +
-                        ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 3)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 4)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 2) >> 4, GetU8(script + 5)) +
-                        " );\n"
-                        );
-                    AdvanceScript(6, script, end);
-                } break;
-
-                case GTPYE:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 3), "game:party_get_id_of_member( 0 )") +
-                        SetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 4), "game:party_get_id_of_member( 1 )") +
-                        SetVariable(GetU8(script + 2) >> 4, GetU8(script + 5), "game:party_get_id_of_member( 2 )")
-                        );
-                    AdvanceScript(6, script, end);
-                } break;
-
-                case SPECIAL:
-                {
-                    u8 special_opcode = GetU8(script + 1);
-
-                    if (special_opcode == 0xF5) // ARROW
-                    {
-                        export_script->Log(
-                            "game:pointer_enable( " +
-                            BoolToString(!(GetU8(script + 2))) +
-                            " )\n"
-                            );
-                        AdvanceScript(3, script, end);
-                    }
-                    else if (special_opcode == 0xF9) // FLMAT
-                    {
-                        export_script->Log("game:fill_materia()\n");
-                        AdvanceScript(2, script, end);
-                    }
-                    else if (special_opcode == 0xFB) // BTLLK
-                    {
-                        export_script->Log(
-                            "game:battle_enable( " +
-                            BoolToString(!(GetU8(script + 2))) +
-                            " )\n"
-                            );
-                        AdvanceScript(3, script, end);
-                    }
-                    else if (special_opcode == 0xFC) // MVLCK
-                    {
-                        export_script->Log(
-                            "game:movie_enable( " +
-                            BoolToString(!(GetU8(script + 2))) +
-                            " )\n"
-                            );
-                        AdvanceScript(3, script, end);
-                    }
-                    else if (special_opcode == 0xFD) // SPCNM
-                    {
-                        export_script->Log(
-                            "[UNREVERSED] SPECIAL SPCNM(" +
-                            ArgumentString(script + 2, 2) +
-                            ");\n"
-                            );
-                        AdvanceScript(4, script, end);
-                    }
-                    else if (special_opcode == 0xFE) // RSGLB
-                    {
-                        export_script->Log("game:global_reset()\n");
-                        AdvanceScript(2, script, end);
-                    }
-                    else
-                    {
-                        export_script->Log("[SPECIAL OPCODE " + HexToString(special_opcode, 2, '0') + "]\n");
-                        script += 2;
-                    }
-                } break;
-
-                case JMPF:
-                {
-                    u32 temp_end = script + GetU8(script + 1) + 1;
-                    export_script->Log("jumpto( " + OffsetString(temp_end) + " );\n");
-                    end = (temp_end > end) ? temp_end : end;
-                    script += 2;
-                } break;
-
-                case JMPFL:
-                {
-                    u32 temp_end = script + GetU16LE(script + 1) + 1;
-
-                    export_script->Log(
-                        "jumpto( " +
-                        OffsetString(temp_end) +
-                        " );\n"
-                        );
-
-                    end = (temp_end > end) ? temp_end : end;
-                    script += 3;
-                } break;
-
-                case JMPB:
-                {
-                    export_script->Log(
-                        "jumpto( " +
-                        OffsetString(script - GetU8(script + 1)) +
-                        " );\n"
-                        );
-
-                    script += 2;
-                } break;
-
-                case JMPBL:
-                {
-                    export_script->Log(
-                        "jumpto( " +
-                        OffsetString(script - GetU16LE(script + 1)) +
-                        " );\n"
-                        );
-
-                    script += 3;
-                } break;
-
-                case IFUB:
-                {
-                    u32 temp_end = script + GetU8(script + 5) + 5;
-
-                    export_script->Log(
-                        "if ( " +
-                        ParseRelation(GetU8(script + 4), ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)), ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3))) +
-                        " ) then continue else jumpto(" + OffsetString(temp_end) + ");\n"
-                        );
-
-                    end = (temp_end > end) ? temp_end : end;
-                    script += 6;
-                } break;
-
-                case IFUBL:
-                {
-                    u32 temp_end = script + GetU16LE(script + 5) + 5;
-
-                    export_script->Log(
-                        "if ( " +
-                        ParseRelation(GetU8(script + 4), ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)), ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3))) +
-                        " ) then continue else jumpto(" + OffsetString(temp_end) + ");\n"
-                        );
-
-                    end = (temp_end > end) ? temp_end : end;
-                    script += 7;
-                } break;
-
-                case IFSW:
-                {
-                    u32 temp_end = script + GetU8(script + 7) + 7;
-
-                    export_script->Log(
-                        "if ( " +
-                        ParseRelation(GetU8(script + 6), ParseGetVariable(GetU8(script + 1) >> 4, (s16)GetU16LE(script + 2)), ParseGetVariable(GetU8(script + 1) & 0x0F, (s16)GetU16LE(script + 4))) +
-                        " ) then continue else jumpto(" + OffsetString(temp_end) + ");\n"
-                        );
-
-                    // If we find a jump back to this address, then this if statement is actually a while()
-
-                    end = (temp_end > end) ? temp_end : end;
-                    script += 8;
-                } break;
-
-                case IFSWL:
-                {
-                    u32 temp_end = script + GetU16LE(script + 7) + 7;
-
-                    export_script->Log(
-                        "if ( " +
-                        ParseRelation(GetU8(script + 6), ParseGetVariable(GetU8(script + 1) >> 4, (s16)GetU16LE(script + 2)), ParseGetVariable(GetU8(script + 1) & 0x0F, (s16)GetU16LE(script + 4))) +
-                        " ) then continue else jumpto(" + OffsetString(temp_end) + ");\n"
-                        );
-
-                    end = (temp_end > end) ? temp_end : end;
-                    script += 9;
-                } break;
-
-                case IFUW:
-                {
-                    u32 temp_end = script + GetU8(script + 7) + 7;
-
-                    export_script->Log(
-                        "if ( " +
-                        ParseRelation(GetU8(script + 6), ParseGetVariable(GetU8(script + 1) >> 4, GetU16LE(script + 2)), ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 4))) +
-                        " ) then continue else jumpto(" + OffsetString(temp_end) + ");\n"
-                        );
-
-                    end = (temp_end > end) ? temp_end : end;
-                    script += 8;
-                } break;
-
-                case TUTOR:
-                {
-                    export_script->Log(
-                        "[UNREVERSED] TUTOR(" +
-                        ArgumentString(script + 1, 1) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case WAIT:
-                {
-                    export_script->Log("script:wait( " + FloatToString(GetU16LE(script + 1) / 30.0f) + " )\n");
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case NFADE:
-                {
-                    u8 type = GetU8(script + 3);
-
-                    if (type == 0)
-                    {
-                        export_script->Log("fade:clear();\n");
-                    }
-                    else
-                    {
-                        export_script->Log(
-                            "[NEEDS TO CHECK NFADE time needs to be divided] fade:fade(" +
-                            ParseGetVariable(GetU8(script + 1) >> 4, GetU16LE(script + 4)) +
-                            ", " +
-                            ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 5)) +
-                            ", " +
-                            ParseGetVariable(GetU8(script + 2) >> 4, GetU16LE(script + 6)) +
-                            ", " +
-                            ((type == 12) ? "Fade.SUBTRACT" : "Fade.ADD") +
-                            ", " +
-                            ParseGetVariable(GetU8(script + 2) & 0x0F, GetU16LE(script + 7)) +
-                            ");\n"
-                            );
-                    }
-
-                    AdvanceScript(9, script, end);
-                } break;
-
-                case BLINK:
-                {
-                    export_script->Log(
-                        entity_list[i] +
-                        ":enable_eye_blink(" +
-                        BoolToString(!(GetU8(script + 1))) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case KAWAI:
-                {
-                    u8 kawai_length = GetU8(script + 1);
-
-                    export_script->Log(
-                        "[UNREVERSED] KAWAI(" +
-                        ArgumentString(script + 1, kawai_length - 1) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(kawai_length, script, end);
-                } break;
-
-                case WCLS:
-                {
-                    export_script->Log(
-                        "[UNREVERSED] WCLS(" +
-                        ArgumentString(script + 1, 1) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case WSIZW:
-                {
-                    u8 type = GetU8(script + 2);
-
-                    export_script->Log(
-                        "-- resize window (id = " +
-                        IntToString(GetU8(script + 1)) +
-                        ", x = " +
-                        IntToString(GetU16LE(script + 2)) +
-                        ", y = " +
-                        IntToString(GetU16LE(script + 4)) +
-                        ", width = " +
-                        IntToString(GetU16LE(script + 6)) +
-                        ", height = " +
-                        IntToString(GetU16LE(script + 8)) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(10, script, end);
-                } break;
-
-                case IFKEY:
-                {
-                    u32 temp_end = script + GetU8(script + 3) + 3;
-
-                    export_script->Log(
-                        "if (pressed buttons \"" +
-                        HexToString(GetU16LE(script + 1), 4, '0') +
-                        "\") then continue else jumpto(" + OffsetString(temp_end) + ");\n"
-                        );
-
-                    end = (temp_end > end) ? temp_end : end;
-                    script += 4;
-                } break;
-
-                case IFKEYON:
-                {
-                    u32 temp_end = script + GetU8(script + 3) + 3;
-
-                    export_script->Log(
-                        "if (first pressed buttons \"" +
-                        HexToString(GetU16LE(script + 1), 4, '0') +
-                        "\") then continue else jumpto(" + OffsetString(temp_end) + ");\n"
-                        );
-
-                    end = (temp_end > end) ? temp_end : end;
-                    script += 4;
-                } break;
-
-                case UC:
-                {
-                    export_script->Log(
-                        "field:pc_lock(" +
-                        BoolToString(GetU8(script + 1) > 0) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case WSPCL:
-                {
-                    export_script->Log(
-                        "[UNREVERSED] WSPCL(" +
-                        ArgumentString(script + 1, 4) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case STTIM:
-                {
-                    export_script->Log(
-                        "game:set_timer(hours(" +
-                        ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 3)) +
-                        "), minutes(" +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 4)) +
-                        "), seconds(" +
-                        ParseGetVariable(GetU8(script + 2) & 0x0F, GetU8(script + 5)) +
-                        "));\n"
-                        );
-                    AdvanceScript(6, script, end);
-                } break;
-
-                case GOLDU:
-                {
-                    export_script->Log(
-                        "game:add_money(upper(" +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 4)) +
-                        "), lower(" +
-                        ParseGetVariable(GetU8(script + 1) >> 4, GetU16LE(script + 2)) +
-                        "));\n"
-                        );
-                    AdvanceScript(6, script, end);
-                } break;
-
-                case GOLDD:
-                {
-                    export_script->Log(
-                        "game:remove_money(upper(" +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 4)) +
-                        "), lower(" +
-                        ParseGetVariable(GetU8(script + 1) >> 4, GetU16LE(script + 2)) +
-                        "));\n"
-                        );
-                    AdvanceScript(6, script, end);
-                } break;
-
-                case CHGLD:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), "game:get_money_lower()") +
-                        SetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3), "game:get_money_top()")
-                        );
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case MHMMX:
-                {
-                    export_script->Log(
-                        "game:restore_hp_mp_status_to_all();\n"
-                        );
-                    AdvanceScript(1, script, end);
-                } break;
-
-                case HMPMAX3:
-                {
-                    export_script->Log(
-                        "game:party_restore_hp_mp();\n"
-                        );
-                    AdvanceScript(1, script, end);
-                } break;
-
-                case MESSAGE:
-                {
-                    m_Dialogs.push_back(GetU8(script + 2));
-                    export_script->Log(
-                        "message:show_text_wait(" +
-                        IntToString(GetU8(script + 1)) +
-                        ", " +
-                        IntToString(GetU8(script + 2)) +
-                        ", x, y);\n"
-                        );
-
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case MPNAM:
-                {
-                    m_Dialogs.push_back(GetU8(script + 1));
-                    export_script->Log(
-                        "field:map_name(" +
-                        IntToString(GetU8(script + 1)) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case ASK:
-                {
-                    m_Dialogs.push_back(GetU8(script + 3));
-                    export_script->Log(
-                        "message:show_text_wait(" +
-                        IntToString(GetU8(script + 2)) +
-                        ", " +
-                        IntToString(GetU8(script + 3)) +
-                        ", x, y); -- ASK cursor at \"" +
-                        ParseGetVariable(GetU8(script + 1), GetU8(script + 6)) +
-                        "\", start " +
-                        IntToString(GetU8(script + 4)) +
-                        ", end " +
-                        IntToString(GetU8(script + 5)) +
-                        "\n"
-                        );
-
-                    AdvanceScript(7, script, end);
-                } break;
-
-                case MENU:
-                {
-                    export_script->Log(
-                        "[UNREVERSED] MENU(" +
-                        ArgumentString(script + 1, 3) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case MENU2:
-                {
-                    export_script->Log(
-                        "field:menu_lock(" +
-                        BoolToString(GetU8(script + 1) > 0) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case BTLTB:
-                {
-                    export_script->Log(
-                        "field:set_battle_table(" +
-                        IntToString(GetU8(script + 1)) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case WINDOW:
-                {
-                    export_script->Log(
-                        "-- set window parameters (id = " +
-                        IntToString(GetU8(script + 1)) +
-                        ", x = " +
-                        IntToString(GetU16LE(script + 2)) +
-                        ", y = " +
-                        IntToString(GetU16LE(script + 4)) +
-                        ", width = " +
-                        IntToString(GetU16LE(script + 6)) +
-                        ", height = " +
-                        IntToString(GetU16LE(script + 8)) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(10, script, end);
-                } break;
-
-                case WMODE:
-                {
-                    u8 type = GetU8(script + 2);
-
-                    export_script->Log(
-                        "-- set window mode (id = " +
-                        IntToString(GetU8(script + 1)) +
-                        ", MessageStyle." +
-                        ((type == 0) ? "SOLID" : ((type == 1) ? "NONE" : "TRANSPARENT")) +
-                        ", disable input from player: " +
-                        BoolToString(GetU8(script + 3) > 0) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case WREST:
-                {
-                    export_script->Log(
-                        "-- reset window to default (id = " +
-                        IntToString(GetU8(script + 1)) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case WCLSE:
-                {
-                    export_script->Log(
-                        "[UNREVERSED] WCLSE(" +
-                        ArgumentString(script + 1, 1) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case STITM:
-                {
-                    export_script->Log(
-                        "game:item_add(" +
-                        ParseGetVariable(GetU8(script + 1) >> 4, GetU16LE(script + 2)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 4)) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case CKITM:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1), GetU8(script + 4), "game:get_number_of_item(" + IntToString(GetU16LE(script + 2)) + ")")
-                        );
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case SMTRA:
-                {
-                    export_script->Log(
-                        "game:materia_add(" +
-                        ParseGetVariable(GetU8(script + 1) >> 4, GetU16LE(script + 3)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 4)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 2) >> 4, GetU16LE(script + 5)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 2) & 0x0F, GetU8(script + 6)) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(7, script, end);
-                } break;
-
-                case SHAKE:
-                {
-                    export_script->Log(
-                        "[UNREVERSED] SHAKE(" +
-                        ArgumentString(script + 1, 7) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(8, script, end);
-                } break;
-
-                case MAPJUMP:
-                {
-                    export_script->Log(
-                        "field:jump_to_map(" +
-                        IntToString(GetU16LE(script + 1)) +
-                        ", " +
-                        IntToString(GetU16LE(script + 3)) +
-                        ", " +
-                        IntToString(GetU16LE(script + 5)) +
-                        ", " +
-                        IntToString(GetU16LE(script + 7)) +
-                        ", " +
-                        FloatToString((GetU8(script + 9) / 256.0f) * 360.0f) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(10, script, end);
-                } break;
-
-                case SCRLC:
-                {
-                    int type = GetU8(script + 4);
-
-                    export_script->Log(
-                        "field:screen_set_scroll_to_pc(" +
-                        ((type == 4) ? "Field.NONE" : ((type == 5) ? "Field.LINEAR" : ((type == 6) ? "Field.SMOOTH" : "Unknown_type_" + IntToString(type)))) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 2), 0, 30.0f) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case SCRLA:
-                {
-                    int type = GetU8(script + 5);
-
-                    export_script->Log(
-                        "field:screen_set_scroll_to_entity(" +
-                        entity_list[GetU8(script + 4)] +
-                        ", " +
-                        ((type == 1) ? "Field.NONE" : ((type == 2) ? "Field.LINEAR" : ((type == 3) ? "Field.SMOOTH" : "Unknown_type_" + IntToString(type)))) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1), GetU16LE(script + 2), 0, 30.0f) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(6, script, end);
-                } break;
-
-                case SCR2D:
-                {
-                    export_script->Log("background2d:scroll_to_position( " + ParseGetVariable(GetU8(script + 1) >> 4, (s16)GetU16LE(script + 2)) + ", " + ParseGetVariable(GetU8(script + 1) & 0x0F, (s16)GetU16LE(script + 4)) + ", Background2D.NONE, 0 )\n");
-                    AdvanceScript(6, script, end);
-                } break;
-
-                case SCRCC:
-                {
-                    export_script->Log("background2d:autoscroll_to_entity( --[[ player entity object here ]] )\n");
-                    AdvanceScript(1, script, end);
-                } break;
-
-                case SCR2DC:
-                {
-                    export_script->Log("background2d:scroll_to_position( " + ParseGetVariable(GetU8(script + 1) >> 4, (s16)GetU16LE(script + 3)) + ", " + ParseGetVariable(GetU8(script + 1) & 0x0F, (s16)GetU16LE(script + 5)) + ", Background2D.SMOOTH, " + ParseGetVariable(GetU8(script + 2) & 0x0F, (s16)GetU16LE(script + 7), 0, 30.0f) + " )\n");
-                    AdvanceScript(9, script, end);
-                }  break;
-
-                case SCRLW:
-                {
-                    export_script->Log("background2d:scroll_sync()\n");
-                    AdvanceScript(1, script, end);
-                } break;
-
-                case SCR2DL:
-                {
-                    export_script->Log("background2d:scroll_to_position( " + ParseGetVariable(GetU8(script + 1) >> 4, (s16)GetU16LE(script + 3)) + ", " + ParseGetVariable(GetU8(script + 1) & 0x0F, (s16)GetU16LE(script + 5)) + ", Background2D.LINEAR, " + ParseGetVariable(GetU8(script + 2) & 0x0F, (s16)GetU16LE(script + 7), 0, 30.0f) + " )\n");
-                    AdvanceScript(9, script, end);
-                } break;
-
-                case VWOFT:
-                {
-                    export_script->Log(
-                        "[UNREVERSED] VWOFT(" +
-                        ArgumentString(script + 1, 6) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(7, script, end);
-                } break;
-
-                case FADE:
-                {
-                    u8 type = GetU8(script + 7);
-
-                    if (type == 4)
-                    {
-                        export_script->Log("fade:black();\n");
-                    }
-                    else
-                    {
-                        u8 speed = GetU8(script + 6);
-                        u8 start = GetU8(script + 8);
-
-                        export_script->Log(
-                            "[NEEDS TO CHECK FADE] fade:fade( " +
-                            ParseGetVariable(GetU8(script + 1) >> 4, GetU16LE(script + 3)) +
-                            ", " +
-                            ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 4)) +
-                            ", " +
-                            ParseGetVariable(GetU8(script + 2) & 0x0F, GetU16LE(script + 5)) +
-                            ", " +
-                            ((type == 1 || type == 2 || type == 7 || type == 8) ? "Fade.SUBTRACT" : "Fade.ADD") +
-                            ", " +
-                            IntToString(speed) +
-                            ", " +
-                            IntToString(start) +
-                            " );\n"
-                            );
-                    }
-
-                    AdvanceScript(9, script, end);
-                } break;
-
-                case FADEW:
-                {
-                    export_script->Log("fade:wait();\n");
-                    AdvanceScript(1, script, end);
-                } break;
-
-                case IDLCK:
-                {
-                    export_script->Log(
-                        "field:lock_walkmesh( " +
-                        IntToString(GetU16LE(script + 1)) +
-                        ", " +
-                        BoolToString(GetU8(script + 3) > 0) +
-                        " );\n"
-                        );
-
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case LSTMP:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1), GetU8(script + 2), "field:get_last_map()")
-                        );
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case BATTLE:
-                {
-                    export_script->Log(
-                        "field:battle_run( " +
-                        ParseGetVariable(GetU8(script + 1), GetU16LE(script + 2)) +
-                        " );\n"
-                        );
-
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case BTLON:
-                {
-                    export_script->Log(
-                        "field:random_encounter_on( " +
-                        BoolToString(!(GetU8(script + 1))) +
-                        " );\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                }  break;
-
-                case BTLMD:
-                {
-                    export_script->Log(
-                        "[UNREVERSED] BTLMD(" +
-                        ArgumentString(script + 1, 2) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case PLUS_:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), "( ( " + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " + " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3)) + " > 255 ) ? 255 : " + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " + " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3)) + " )")
-                        );
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case PLUS2_:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), "( ( " + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " + " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 3)) + " > 65535 ) ? 65535 : " + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " + " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 3)) + " )")
-                        );
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case MINUS_:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), "( ( " + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " - " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3)) + " < 0 ) ? 0 : " + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " - " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3)) + " )")
-                        );
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case MINUS2_:
-                {
-                    export_script->Log(SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), "( ( " + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " - " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 3)) + " < 0 ) ? 0 : " + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " - " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 3)) + " )"));
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case INC_:
-                {
-                    export_script->Log(SetVariable(GetU8(script + 1), GetU8(script + 2), "( ( " + ParseGetVariable(GetU8(script + 1), GetU8(script + 2)) + " + 1 > 255 ) ? 255 : " + ParseGetVariable(GetU8(script + 1), GetU8(script + 2)) + " + 1 )"));
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case TALKON:
-                {
-                    export_script->Log(
-                        entity_list[i] +
-                        ":set_talkable( " +
-                        BoolToString(!(GetU8(script + 1))) +
-                        " );\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case SETBYTE:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3)))
-                        );
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case SETWORD:
-                {
-                    export_script->Log(SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 3))));
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case BITON:
-                {
-                    export_script->Log(SetBitChange(GetU8(script + 1) >> 4, GetU8(script + 2), GetU8(script + 1) & 0x0F, GetU8(script + 3), true));
-
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case BITOFF:
-                {
-                    export_script->Log(SetBitChange(GetU8(script + 1) >> 4, GetU8(script + 2), GetU8(script + 1) & 0x0F, GetU8(script + 3), false));
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case PLUS:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " + " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3)))
-                        );
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case MINUS:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " - " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3)))
-                        );
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case MUL:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), "((" + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " * " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3)) + " > 255) ? 255 : " + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " * " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3)) + ")")
-                        );
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case MOD:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " % " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3)))
-                        );
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case AND:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " & " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3)))
-                        );
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case AND2:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " & " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 3)))
-                        );
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case OR:
-                {
-                    export_script->Log(SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " | " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3))));
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case OR2:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + " | " + ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 3)))
-                        );
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case INC:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1), GetU8(script + 2), ParseGetVariable(GetU8(script + 1), GetU8(script + 2)) + " + 1")
-                        );
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case DEC:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1), GetU8(script + 2), ParseGetVariable(GetU8(script + 1), GetU8(script + 2)) + " - 1")
-                        );
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case RANDOM:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1), GetU8(script + 2), "math.rand()")
-                        );
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case PC:
-                {
-                    export_script->Log("set_entity_to_character( \"" + entity_list[i] + "\", " + IntToString(GetU8(script + 1)) + " );\n");
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case opCodeCHAR:
-                {
-                    export_script->Log("-- assosiate entity with model (CHAR) argument doesn't matter\n");
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case DFANM:
-                {
-                    export_script->Log(entity_list[i] + ":set_default_animation( \"" + IntToString(GetU8(script + 1)) + "\" ) -- speed=" + FloatToString(1.0f / GetU8(script + 2)) + "\n");
-                    export_script->Log("                 " + entity_list[i] + ":play_animation( \"" + IntToString(GetU8(script + 1)) + "\" )\n");
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case ANIME1:
-                {
-                    export_script->Log(entity_list[i] + ":play_animation( \"" + IntToString(GetU8(script + 1)) + "\" ) -- speed=" + FloatToString(1.0f / GetU8(script + 2)) + "\n");
-                    export_script->Log("                 " + entity_list[i] + ":animation_sync()\n");
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case VISI:
-                {
-                    export_script->Log(entity_list[i] + ":set_visible( " + BoolToString(GetU8(script + 1) > 0) + " )\n");
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case XYZI:
-                {
-                    export_script->Log(entity_list[i] + ":set_position( " +
-                        
-                        ParseGetVariable(GetU8(script + 1) >> 4,   (s16)GetU16LE(script + 3), 0, downscaler) + ", " + 
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, (s16)GetU16LE(script + 5), 0, downscaler) + ", " + 
-                        ParseGetVariable(GetU8(script + 2) >> 4,   (s16)GetU16LE(script + 7), 0, downscaler) + 
-                        " ) -- triangle_id=" + ParseGetVariable(GetU8(script + 2) & 0x0F, (s16)GetU16LE(script + 9)) + "\n");
-                    AdvanceScript(11, script, end);
-                } break;
-
-                case XYI:
-                {
-                    export_script->Log(
-                        entity_list[i] +
-                        ":set_2d_position_triangle( " +
-                        ParseGetVariable(GetU8(script + 1) >> 4, (s16)GetU16LE(script + 3), false, downscaler) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, (s16)GetU16LE(script + 5), false, downscaler) +
-                        ", triangle_id=" +
-                        ParseGetVariable(GetU8(script + 2) >> 4, (s16)GetU16LE(script + 7)) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(9, script, end);
-                } break;
-
-                case MOVE:
-                {
-                    export_script->Log(entity_list[i] + ":move_to_position( " + ParseGetVariable(GetU8(script + 1) >> 4, (s16)GetU16LE(script + 2), false, downscaler) + ", " + ParseGetVariable(GetU8(script + 1) & 0x0F, (s16)GetU16LE(script + 4), false, downscaler) + " )\n");
-                    export_script->Log("                 " + entity_list[i] + ":move_sync()\n");
-                    AdvanceScript(6, script, end);
-                } break;
-
-                case CMOVE:
-                {
-                    export_script->Log(
-                        entity_list[i] +
-                        ":set_rotation_lock( true );\n" +
-                        entity_list[i] +
-                        ":move_to_position( " +
-                        ParseGetVariable(GetU8(script + 1) >> 4, (s16)GetU16LE(script + 2), 0, downscaler) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, (s16)GetU16LE(script + 4), 0, downscaler) +
-                        ", false );\n" +
-                        entity_list[i] +
-                        ":set_rotation_lock( false );\n"
-                        );
-
-                    AdvanceScript(6, script, end);
-                } break;
-
-                case MOVA:
-                {
-                    export_script->Log(
-                        entity_list[i] +
-                        ":move_to_model( " +
-                        entity_list[GetU8(script + 1)] +
-                        ", true );\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case TURA:
-                {
-                    u8 type = GetU8(script + 2);
-
-                    export_script->Log(
-                        entity_list[i] +
-                        ":turn_to_entity( " +
-                        entity_list[GetU8(script + 1)] +
-                        ", " +
-                        ((type == 0) ? "Entity.CLOCKWISE" : ((type == 1) ? "Entity.ANTICLOCKWISE" : "Entity.CLOSEST")) +
-                        ", " +
-                        FloatToString(GetU8(script + 3) / 30.0f) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case ANIMW:
-                {
-                    export_script->Log(
-                        entity_list[i] +
-                        ":set_animation_wait();\n"
-                        );
-
-                    AdvanceScript(1, script, end);
-                } break;
-
-                case FMOVE:
-                {
-                    export_script->Log(
-                        entity_list[i] +
-                        ":move_to_position( \"" +
-                        ParseGetVariable(GetU8(script + 1) >> 4, (s16)GetU16LE(script + 2)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, (s16)GetU16LE(script + 4)) +
-                        ", false );\n"
-                        );
-
-                    AdvanceScript(6, script, end);
-                } break;
-
-                case ANIME2:
-                {
-                    export_script->Log(
-                        entity_list[i] +
-                        ":play_animation( \"" +
-                        IntToString(GetU8(script + 1)) +
-                        "\", 0, -1, " +
-                        FloatToString(1.0f / GetU8(script + 2)) +
-                        ", false );\n"
-                        );
-
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case ANIM_1:
-                {
-                    export_script->Log(entity_list[i] + ":play_animation_stop( \"" + IntToString(GetU8(script + 1)) + "\" ) -- speed=" + FloatToString(1.0f / GetU8(script + 2)) + "\n");
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case CANM_1:
-                {
-                    export_script->Log(
-                        entity_list[i] +
-                        ":play_animation( \"" +
-                        IntToString(GetU8(script + 1)) +
-                        "\", " +
-                        FloatToString(GetU8(script + 2) / 30.0f) +
-                        ", " +
-                        FloatToString(GetU8(script + 3) / 30.0f) +
-                        ", " +
-                        FloatToString(1.0f / GetU8(script + 4)) +
-                        ", true );\n"
-                        );
-
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case MSPED:
-                {
-                    export_script->Log(entity_list[i] + ":set_move_speed( " + ParseGetVariable(GetU8(script + 1), GetU16LE(script + 2), 0, 256.0f * downscaler / (30.0f)) + " )\n");
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case DIR:
-                {
-                    export_script->Log(entity_list[i] + ":set_direction( " + ParseGetVariable(GetU8(script + 1), GetU8(script + 2), 0, 256.0f / 360.0f) + " )\n");
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case TURNGEN:
-                {
-                    u8 type = GetU8(script + 3);
-                    u8 calc = GetU8(script + 5);
-                    export_script->Log(entity_list[i] + ":turn_to_direction( " + ParseGetVariable(GetU8(script + 1), GetU8(script + 2), 0, 256.0f / 360.0f) + ", " + ((type == 0) ? "Entity.CLOCKWISE" : ((type == 1) ? "Entity.ANTICLOCKWISE" : "Entity.CLOSEST")) + ", " + ((calc == 1) ? "Entity.LINEAR" : "Entity.SMOOTH") + ", " + FloatToString(GetU8(script + 4) / 30.0f) + " )\n");
-                    export_script->Log(entity_list[i] + ":turn_sync()\n");
-                    AdvanceScript(6, script, end);
-                } break;
-
-                case TURN:
-                {
-                    u8 calc = GetU8(script + 5);
-
-                    export_script->Log(
-                        entity_list[i] +
-                        ":turn_to_direction( " +
-                        ParseGetVariable(GetU8(script + 1), GetU16LE(script + 2), 0, 256.0f / 360.0f) +
-                        ", Entity.CLOCKWISE, " +
-                        ((calc == 1) ? "Field.LINEAR" : "Field.SMOOTH") +
-                        ", " +
-                        FloatToString(GetU8(script + 4) / 30.0f) +
-                        " );\n"
-                        );
-                    export_script->Log(entity_list[i] + ":turn_sync()\n");
-
-                    AdvanceScript(6, script, end);
-                } break;
-
-                case DIRA:
-                {
-                    export_script->Log(entity_list[i] + ":set_direction( \"" + entity_list[GetU8(script + 1)] + "\" )\n");
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case GETDIR:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1), GetU8(script + 3), entity_list[GetU8(script + 2)] + ":get_direction()")
-                        );
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case GETAXY:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 3), entity_list[GetU8(script + 2)] + ":get_x()") +
-                        SetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 4), entity_list[GetU8(script + 2)] + ":get_y()")
-                        );
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case GETAI:
-                {
-                    export_script->Log(SetVariable(GetU8(script + 1), GetU8(script + 3), entity_list[GetU8(script + 2)] + ":get_move_triangle_id()"));
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case ANIM_2: // ANIM!2
-                {
-                    export_script->Log(entity_list[i] + ":play_animation_stop( \"" + IntToString(GetU8(script + 1)) + "\" ) -- speed=" + FloatToString(1.0f / GetU8(script + 2)) + "\n");
-                    export_script->Log("                 " + entity_list[i] + ":animation_sync()\n");
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case CANIM2:
-                {
-                    export_script->Log(entity_list[i] + ":play_animation( \"" + IntToString(GetU8(script + 1)) + "\", " + FloatToString(GetU8(script + 2) / 30.0f) + ", " + FloatToString(GetU8(script + 3) / 30.0f) + " ) -- speed=" + FloatToString(1.0f / GetU8(script + 4)) + "\n");
-                    export_script->Log("                 " + entity_list[i] + ":animation_sync()\n");
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case CANM_2:
-                {
-                    export_script->Log(entity_list[i] + ":play_animation_stop( \"" + IntToString(GetU8(script + 1)) + "\", " + FloatToString(GetU8(script + 2) / 30.0f) + ", " + FloatToString(GetU8(script + 3) / 30.0f) + " ) -- speed=" + FloatToString(1.0f / GetU8(script + 4)) + "\n");
-                    export_script->Log("                 " + entity_list[i] + ":animation_sync()\n");
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case ASPED:
-                {
-                    export_script->Log("-- set speed of entity animation to \"" + ParseGetVariable(GetU8(script + 1), GetU16LE(script + 2), 0, 0x10) + "\"\n");
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case CC:
-                {
-                    export_script->Log(
-                        "field:set_player_entity( " +
-                        entity_list[GetU8(script + 1)] +
-                        " );\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case JUMP:
-                {
-                    export_script->Log(
-                        entity_list[i] +
-                        ":jump_to_position( " +
-                        ParseGetVariable(GetU8(script + 1) >> 4, (s16)GetU16LE(script + 3)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, (s16)GetU16LE(script + 5)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 2) >> 4, GetU16LE(script + 7)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 2) & 0x0F, GetU16LE(script + 9), 0, 30.0f) +
-                        " );\n"
-                        );
-
-                    AdvanceScript(11, script, end);
-                } break;
-
-                case AXYZI:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1) >> 4, GetU8(script + 4), entity_list[GetU8(script + 3)] + ":get_x()") +
-                        SetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 5), entity_list[GetU8(script + 3)] + ":get_y()") +
-                        SetVariable(GetU8(script + 2) >> 4, GetU8(script + 6), entity_list[GetU8(script + 3)] + ":get_z()") +
-                        SetVariable(GetU8(script + 2) & 0x0F, GetU8(script + 7), entity_list[GetU8(script + 3)] + ":get_move_triangle_id()")
-                        );
-                    AdvanceScript(8, script, end);
-                } break;
-
-                case LADER:
-                {
-                    u8 type = GetU8(script + 11);
-
-                    export_script->Log(
-                        entity_list[i] +
-                        ":climb_to_position( " +
-                        ParseGetVariable(GetU8(script + 1) >> 4, (s16)GetU16LE(script + 3)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, (s16)GetU16LE(script + 5)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 2) >> 4, (s16)GetU16LE(script + 7)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 2) & 0x0F, GetU16LE(script + 9)) +
-                        ", " +
-                        ((type == 0) ? "Entity.UP_TO_DOWN" : ((type == 1) ? "Entity.DOWN_TO_UP" : ((type == 2) ? "Entity.LEFT_TO_RIGHT" : ((type == 1) ? "Entity.RIGHT_TO_LEFT" : "")))) +
-                        " ); -- direction needs to be seted to \"" +
-                        FloatToString((GetU8(script + 13) / 256.0f) * 360.0f) +
-                        "\" and animation during climbing is \"" +
-                        IntToString(GetU8(script + 12)) +
-                        "\" with speed \"" +
-                        FloatToString(1.0f / GetU8(script + 14)) +
-                        "\"\n"
-                        );
-
-                    AdvanceScript(15, script, end);
-                } break;
-
-                case OFST:
-                {
-                    u8 type = GetU8(script + 3);
-                    export_script->Log(entity_list[i] + ":offset_to_position( " + ParseGetVariable(GetU8(script + 1) >> 4, (s16)GetU16LE(script + 4), 0, downscaler) + ", " + ParseGetVariable(GetU8(script + 1) & 0x0F, (s16)GetU16LE(script + 6), false, downscaler) + ", " + ParseGetVariable(GetU8(script + 2) >> 4, (s16)GetU16LE(script + 8), false, downscaler) + ", " + ((type == 2) ? "Entity.SMOOTH" : "Entity.LINEAR") + ", " + ParseGetVariable(GetU8(script + 2) & 0x0F, GetU16LE(script + 10), 0, 30.0f) + " )\n");
-                    AdvanceScript(12, script, end);
-                } break;
-
-                case OFSTW:
-                {
-                    export_script->Log(entity_list[i] + ":offset_sync()\n");
-                    AdvanceScript(1, script, end);
-                } break;
-
-                case TALKR:
-                {
-                    export_script->Log(
-                        entity_list[i] +
-                        ":set_talk_range( " +
-                        ParseGetVariable(GetU8(script + 1), GetU8(script + 2)) +
-                        " );\n"
-                        );
-
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case CLIDR:
-                {
-                    export_script->Log(
-                        entity_list[i] +
-                        ":set_solid_range( " +
-                        ParseGetVariable(GetU8(script + 1), GetU8(script + 2)) +
-                        " );\n"
-                        );
-
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case SOLID:
-                {
-                    export_script->Log(entity_list[i] + ":set_solid( " + BoolToString(!(GetU8(script + 1))) + " )\n");
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case PRTYP:
-                {
-                    export_script->Log(
-                        "game:party_add( " +
-                        IntToString(GetU8(script + 1)) +
-                        " );\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case PRTYM:
-                {
-                    export_script->Log(
-                        "game:party_remove( " +
-                        IntToString(GetU8(script + 1)) +
-                        " );\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case PRTYE:
-                {
-                    export_script->Log(
-                        "game:party_set( " +
-                        IntToString(GetU8(script + 1)) +
-                        ", " +
-                        IntToString(GetU8(script + 2)) +
-                        ", " +
-                        IntToString(GetU8(script + 3)) +
-                        " );\n"
-                        );
-
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case MMBUD:
-                {
-                    export_script->Log(
-                        "game:character_enable( " +
-                        IntToString(GetU8(script + 2)) +
-                        ", " +
-                        BoolToString(GetU8(script + 1) > 0) +
-                        " );\n"
-                        );
-
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case MMBLK:
-                {
-                    export_script->Log(
-                        "[UNREVERSED] MMBLK(" +
-                        ArgumentString(script + 1, 1) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case LINE:
-                {
-                    export_script->Log(
-                        "-- define line point1( " +
-                        IntToString(GetU16LE(script + 1)) +
-                        ", " +
-                        IntToString(GetU16LE(script + 3)) +
-                        ", " +
-                        IntToString(GetU16LE(script + 5)) +
-                        "), point2(" +
-                        IntToString(GetU16LE(script + 7)) +
-                        ", " +
-                        IntToString(GetU16LE(script + 9)) +
-                        ", " +
-                        IntToString(GetU16LE(script + 11)) +
-                        " )\n"
-                        );
-
-                    AdvanceScript(13, script, end);
-                } break;
-
-                case LINON:
-                {
-                    export_script->Log(
-                        "-- turn line " +
-                        Ogre::String((GetU8(script + 1) == 1) ? "on" : "off") +
-                        "\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case MPJPO:
-                {
-                    export_script->Log(
-                        "field:gateway_enable( " +
-                        Ogre::String((GetU8(script + 1) == 1) ? "false" : "true") +
-                        " );\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case SLINE:
-                {
-                    u8 type = GetU8(script + 2);
-
-                    export_script->Log(
-                        "-- redefine line point1( " +
-                        ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 4)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 6)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 2) >> 4, GetU8(script + 8)) +
-                        "), point2(" +
-                        ParseGetVariable(GetU8(script + 2) & 0x0F, GetU8(script + 10)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 3) >> 4, GetU8(script + 12)) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 3) & 0x0F, GetU8(script + 14)) +
-                        " )\n"
-                        );
-
-                    AdvanceScript(16, script, end);
-                } break;
-
-                case PMJMP:
-                {
-                    export_script->Log(
-                        "[UNREVERSED] PMJMP(" +
-                        ArgumentString(script + 1, 2) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case AKAO2:
-                {
-                    u8 sub_opcode = GetU8(script + 4);
-
-                    Ogre::String sound = "music:execute_akao( " +
-                        HexToString(sub_opcode, 2, '0') +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) >> 4, GetU16LE(script + 5), 4) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 7), 4) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 2) >> 4, GetU16LE(script + 9), 4) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 2) & 0x0F, GetU16LE(script + 11), 4) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 3) >> 4, GetU16LE(script + 13), 4) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 3) & 0x0F, GetU16LE(script + 15), 4) +
-                        " );\n";
-
-                    m_SoundOpcodes.push_back(sound);
-                    export_script->Log(sound);
-
-                    AdvanceScript(15, script, end);
-                } break;
-
-                case ANIMB:
-                {
-                    export_script->Log(
-                        entity_list[i] +
-                        ":animation_stop();\n"
-                        );
-
-                    AdvanceScript(1, script, end);
-                } break;
-
-                case TURNW:
-                {
-                    export_script->Log(
-                        entity_list[i] +
-                        ":set_turn_wait();\n"
-                        );
-
-                    AdvanceScript(1, script, end);
-                } break;
-
-                case BGON:
-                {
-                    export_script->Log(
-                        "field:background_on( \"" +
-                        ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) +
-                        "\", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3)) +
-                        " ); -- turns on layer of background animation with given id\n"
-                        );
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case BGOFF:
-                {
-                    export_script->Log(
-                        "field:background_off( \"" +
-                        ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) +
-                        "\", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 3)) +
-                        " ); -- turns off layer of background animation with given id\n"
-                        );
-                    AdvanceScript(4, script, end);
-                } break;
-
-                case BGCLR:
-                {
-                    export_script->Log(
-                        "field:background_clear( \"" +
-                        ParseGetVariable(GetU8(script + 1), GetU8(script + 2)) +
-                        "\" ); -- turns off all layer of background animation with given id\n"
-                        );
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case STPAL:
-                {
-                    export_script->Log("-- store palette \"" + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2)) + "\" to slot \"0x" + ParseGetVariable(GetU8(script + 1) & 0x0f, GetU8(script + 3), 2) + "\" starting from clut_x=\"0x00\" and with width=\"0x" + HexToString(GetU8(script + 4) + 1, 2, '0') + "\"\n");
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case LDPAL:
-                {
-                    export_script->Log("-- load palette \"" + ParseGetVariable(GetU8(script + 1) & 0x0f, GetU8(script + 3)) + "\" from slot \"0x" + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), 2) + "\" starting from clut_x=\"0x00\" and with width=\"0x" + HexToString(GetU8(script + 4) + 1, 2, '0') + "\"\n");
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case CPPAL:
-                {
-                    export_script->Log("-- copy palette stored in slot \"0x" + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 2), 2) + "\" with width=\"0x" + HexToString(GetU8(script + 4) + 1, 2, '0') + " to slot \"0x" + ParseGetVariable(GetU8(script + 1) & 0x0f, GetU8(script + 3), 2) + "\"\n");
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case ADPAL:
-                {
-                    export_script->Log("-- add to palette stored in slot \"0x" + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 4), 2) + "\" with width=\"0x" + HexToString(GetU8(script + 9) + 1, 2, '0') + "\" with values R=\"" + ParseGetVariable(GetU8(script + 3) >> 4, GetU8(script + 8)) + "\", G=\"" + ParseGetVariable(GetU8(script + 2) & 0x0f, GetU8(script + 7)) + "\", B=\"" + ParseGetVariable(GetU8(script + 2) >> 4, GetU8(script + 6)) + "\" and store it to slot \"0x" + ParseGetVariable(GetU8(script + 1) & 0x0f, GetU8(script + 5), 2) + "\"\n");
-                    AdvanceScript(10, script, end);
-                } break;
-
-                case MPPAL2:
-                {
-                    export_script->Log("-- multiply palette stored in slot \"0x" + ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 4), 2) + "\" with width=\"0x" + HexToString(GetU8(script + 9) + 1, 2, '0') + " with values R=\"" + ParseGetVariable(GetU8(script + 3) >> 4, GetU8(script + 8)) + "\", G=\"" + ParseGetVariable(GetU8(script + 2) & 0x0f, GetU8(script + 7)) + "\", B=\"" + ParseGetVariable(GetU8(script + 2) >> 4, GetU8(script + 6)) + "\" (note: 64 - 1.0f, 32 - 0.5f) and store it to slot \"0x" + ParseGetVariable(GetU8(script + 1) & 0x0f, GetU8(script + 5), 2) + "\"\n");
-                    AdvanceScript(10, script, end);
-                } break;
-
-                case STPLS:
-                {
-                    export_script->Log("-- store palette \"" + IntToString(GetU8(script + 1)) + "\" to slot \"0x" + HexToString(GetU8(script + 2), 2, '0') + "\" starting from clut_x=\"0x" + HexToString(GetU8(script + 3), 2, '0') + "\" and with width=\"0x" + HexToString(GetU8(script + 4) + 1, 2, '0') + "\"\n");
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case LDPLS:
-                {
-                    export_script->Log("-- load palette \"" + IntToString(GetU8(script + 2)) + "\" from slot \"0x" + HexToString(GetU8(script + 1), 2, '0') + "\" starting from clut_x=\"0x" + HexToString(GetU8(script + 3), 2, '0') + "\" and with width=\"0x" + HexToString(GetU8(script + 4) + 1, 2, '0') + "\"\n");
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case RTPAL2:
-                {
-                    export_script->Log("[UNREVERSED] RTPAL2( " + ArgumentString(script + 1, 7) + " );\n");
-                    AdvanceScript(8, script, end);
-                } break;
-
-                case ADPAL2:
-                {
-                    export_script->Log("[UNREVERSED] ADPAL2( " + ArgumentString(script + 1, 10) + ");\n");
-                    AdvanceScript(11, script, end);
-                } break;
-
-                case MUSIC:
-                {
-                    Ogre::String sound = "music:execute_akao( " +
-                        HexToString(0x10, 2, '0') +
-                        ", pointer_to_field_AKAO_" +
-                        IntToString(GetU8(script + 1)) +
-                        " ); -- play field music\n";
-
-                    m_SoundOpcodes.push_back(sound);
-                    export_script->Log(sound);
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case SOUND:
-                {
-                    Ogre::String sound = "music:execute_akao( " +
-                        HexToString(0x20, 2, '0') +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, GetU8(script + 4), true) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) >> 4, GetU16LE(script + 2), true) +
-                        " ); -- play sound\n";
-
-                    m_SoundOpcodes.push_back(sound);
-                    export_script->Log(sound);
-
-                    AdvanceScript(5, script, end);
-                } break;
-
-                case AKAO:
-                {
-                    u8 sub_opcode = GetU8(script + 4);
-
-                    Ogre::String sound = "music:execute_akao( " +
-                        HexToString(sub_opcode, 2, '0') +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) >> 4, GetU8(script + 5), true) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 1) & 0x0F, GetU16LE(script + 7), true) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 2) >> 4, GetU16LE(script + 9), true) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 2) & 0x0F, GetU16LE(script + 11), true) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 3) >> 4, GetU16LE(script + 13), true) +
-                        ", " +
-                        ParseGetVariable(GetU8(script + 3) & 0x0F, GetU16LE(script + 15), true) +
-                        " );\n";
-                    m_SoundOpcodes.push_back(sound);
-
-                    export_script->Log(sound);
-
-                    AdvanceScript(14, script, end);
-                } break;
-
-                case MULCK:
-                {
-                    export_script->Log(
-                        "music:lock( " +
-                        BoolToString(GetU8(script + 1) > 0) +
-                        " );\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case BMUSC:
-                {
-                    export_script->Log(
-                        "[UNREVERSED] BMUSC(" +
-                        IntToString(GetU8(script + 1)) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case PMVIE:
-                {
-                    export_script->Log(
-                        "field:movie_set( " +
-                        IntToString(GetU8(script + 1)) +
-                        " );\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case MOVIE:
-                {
-                    export_script->Log("field:play_movie();\n");
-                    AdvanceScript(1, script, end);
-                } break;
-
-                case MVIEF:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1), GetU8(script + 2), "field:get_movie_frame()")
-                        );
-                    AdvanceScript(3, script, end);
-                } break;
-
-                case MVCAM:
-                {
-                    export_script->Log(
-                        "field:movie_camera_enable( " +
-                        BoolToString(!GetU8(script + 1)) +
-                        " );\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case FMUSC:
-                {
-                    export_script->Log(
-                        "[UNREVERSED] FMUSC(" +
-                        ArgumentString(script + 1, 1) +
-                        ");\n"
-                        );
-
-                    AdvanceScript(2, script, end);
-                } break;
-
-                case CHMST:
-                {
-                    export_script->Log(
-                        SetVariable(GetU8(script + 1), GetU8(script + 2), "field:is_music_playing()")
-                        );
-                    AdvanceScript(3, script, end);
-                } break;
-
-                default:
-                {
-                    export_script->Log("[OPCODE " + HexToString(opcode, 2, '0') + "]\n");
-                    script += 1;
-                } break;
-                } // end switch
-            }
-
-            export_script->Log("\n");
-        }
-    }
-    delete export_script;
-}
-
-
-
-void
-DatFile::DumpSoundOpcodesData( const Ogre::String& export_file )
-{
-    std::sort( m_SoundOpcodes.begin(), m_SoundOpcodes.end() );
-    m_SoundOpcodes.erase(std::unique(m_SoundOpcodes.begin(), m_SoundOpcodes.end()), m_SoundOpcodes.end());
-
-    Logger* export_sound = new Logger(export_file);
-
-    for (unsigned int i = 0; i < m_SoundOpcodes.size(); ++i)
-    {
-        export_sound->Log(m_SoundOpcodes[i]);
-    }
-
-    delete export_sound;
-}
-
-
-
-void
-DatFile::AdvanceScript(u32 value, u32& current, u32& end)
-{
-    current += value;
-    u32 temp_end = current;
-    end = (temp_end > end) ? temp_end : end;
-}
-
-// A map of slots to values to value names, for example slot 1 value 3 = "love_point_aeris"
-std::map<int, std::map<int, Ogre::String>> VariableNamesMap 
-{
-    // Slot 1
-    { 1, { { 3, "love_point_aeris" },
-    { 4, "love_point_tifa" },
-    { 5, "love_point_yuffie" },
-    { 6, "love_point_barret" },
-    { 21, "timer_minutes" },
-    { 22, "timer_seconds" },
-    { 23, "timer_frames" },
-    { 36, "graveyard_item" },
-    { 48, "item_mask2" },
-    { 80, "battle_love_aeris" },
-    { 81, "battle_love_tifa" },
-    { 82, "battle_love_yuffie" },
-    { 83, "battle_love_barret" },
-    { 164, "graveyard_train" },
-    { 225, "act1_1_flags1" },
-    { 226, "act1_1_flags2" } }
-    },
-    // Slot 2
-    { 2, { { 0, "progress_game" },
-    { 28, "menu_appear" },
-    { 30, "menu_selectable" }
-    } },
-    // Slot 3
-    { 3, { { 66, "act1_1_flags3" },
-    { 111, "flower_flag" },
-    { 112, "act1_3_flags5" },
-    { 126, "act1_3_unknown" },
-    { 127, "tunnel_room" },
-    { 128, "act1_3_flags1" },
-    { 129, "act1_3_flags2" },
-    { 130, "act1_3_flags3" },
-    { 131, "act1_3_flags4" },
-    { 208, "act1_2_flags1" },
-    { 209, "act1_2_flags2" },
-    { 210, "act1_2_flags3" },
-    { 211, "act1_2_flags4" },
-    { 212, "act1_2_flags5" },
-    { 213, "act1_2_flags6" },
-    { 214, "act1_2_flags7" },
-    { 215, "act1_2_flags8" },
-    { 216, "act1_2_flags9" },
-    { 217, "act1_7_flags1" },
-    { 223, "act1_1_flags4" },
-    } },
-    // Slot 13
-    { 13, { { 30, "pointer" },
-    { 31, "materia_full" },
-    { 91, "save_flag" }
-    } },
-    // Slot 15
-    { 15, { { 32, "sector1_item" },
-    { 33, "sector5_item" },
-    { 80, "subway_item" }
-    } }
-};
-
-Ogre::String
-DatFile::ParseVariableName(int slot, int value)
-{
-    auto slotMap = VariableNamesMap.find(slot);
-    if (slotMap != std::end(VariableNamesMap))
-    {
-        auto valueStr = slotMap->second.find(value);
-        if (valueStr != std::end(slotMap->second))
-        {
-            return valueStr->second;
-        }
-    }
-    LOGGER->Log("\n[WARNING] ParseVariableName " + IntToString(value) + " for slot " + IntToString(slot) + " not implemented.\n");
-    return "";
-}
-
-Ogre::String
-DatFile::ParseGetVariable( int get_slot, int get_value, unsigned int hex, float fixed )
-{
-    if( get_slot == 0 )
-    {
-        if( hex > 0 )
-        {
-            return HexToString( get_value, hex, '0' );
-        }
-        else
-        {
-            return FloatToString( get_value / fixed );
-        }
-    }
-    else if( get_slot == 1 || get_slot == 2 || get_slot == 3 || get_slot == 13 || get_slot == 15 )
-    {
-        return "game:variable_get( \"" + ParseVariableName( get_slot, get_value ) + "\" )";
-    }
-    else if( get_slot == 5 )
-    {
-        return "temp5_" + HexToString( get_value, 2, '0' );
-    }
-    else if( get_slot == 6 )
-    {
-        return "temp6_" + HexToString( get_value, 2, '0' );
-    }
-
-    LOGGER->Log( "\n[WARNING] ParseGetVariable " + IntToString( get_value ) + " for slot " + IntToString( get_slot ) + " not implemented.\n" );
-
-    return "";
-}
-
-
-
-Ogre::String
-DatFile::SetVariable( int set_slot, int set_value, Ogre::String get_string )
-{
-    if (set_slot == 1 || set_slot == 2 || set_slot == 3 || set_slot == 13 || set_slot == 15)
-    {
-        return "game:variable_set(\"" + ParseVariableName(set_slot, set_value) + "\", " + get_string + ");\n";
-    }
-    else if (set_slot == 5)
-    {
-        return "temp5_" + HexToString( set_value, 2, '0' ) + " = " + get_string + ";\n";
-    }
-    else if (set_slot == 6)
-    {
-        return "temp6_" + HexToString( set_value, 2, '0' ) + " = " + get_string + ";\n";
-    }
-
-    LOGGER->Log("\n[WARNING] SetVariable " + IntToString(set_value) + " for slot " + IntToString(set_slot) + " not implemented.\n");
-
-    return "";
-}
-
-
-
-Ogre::String
-DatFile::SetBitChange(int set_slot, int set_value, int get_slot, int get_value, bool on)
-{
-    if (set_slot == 1 || set_slot == 3  || set_slot == 5 || set_slot == 13 || set_slot == 15)
-    {
-        if (on == true)
-        {
-            return SetVariable(set_slot, set_value, "(" + ParseGetVariable(set_slot, set_value) + " | (1 << " + ParseGetVariable(get_slot, get_value) + "))");
-        }
-        else
-        {
-            return SetVariable(set_slot, set_value, "(" + ParseGetVariable(set_slot, set_value) + " & XOR(1 << " + ParseGetVariable(get_slot, get_value) + "))");
-        }
-    }
-
-    LOGGER->Log("\n[WARNING] SetBitChange " + IntToString(set_value) + " for slot " + IntToString(set_slot) + " not implemented.\n");
-
-    return "";
-}
-
-
-
-Ogre::String
-DatFile::ParseRelation(int relation, Ogre::String string1, Ogre::String string2)
-{
-    switch (relation)
-    {
-        case 0:  return string1 + " == " + string2;
-        case 1:  return string1 + " != " + string2;
-        case 2:  return string1 + " > " + string2;
-        case 3:  return string1 + " < " + string2;
-        case 4:  return string1 + " >= " + string2;
-        case 5:  return string1 + " <= " + string2;
-        case 6:  return string1 + " & " + string2;
-        case 7:  return string1 + " ^ " + string2;
-        case 8:  return string1 + " | " + string2;
-        case 9:  return string1 + " & (1 << " + string2 + ")";
-        case 10: return "!(" + string1 + " & (1 << " + string2 + "))";
-    }
-
-    return "";
-}
-
-
-
-Ogre::String
-DatFile::ArgumentString(int script, int number)
-{
-    Ogre::String ret = "";
-
-    for (int i = 0; i < number; ++i)
-    {
-        ret += HexToString(GetU8(script + i), 2, '0');
-        if (i + 1 < number)
-        {
-            ret += ", ";
-        }
-    }
-
-    return ret;
-}
-
-
-
-Ogre::String
-DatFile::OffsetString(int val)
-{
-    return HexToString(val, 4, '0');
-}
-
-
-
-void
-DatFile::GetCamera( Ogre::Vector3& position, Ogre::Quaternion& orientation, Ogre::Degree& fov, const Field& field )
-{
-    float downscaler = 128.0f * field.scale;
-
-    // sector 4
-    u32 offset_to_camera = 0x1c + GetU32LE( 0x0c ) - GetU32LE( 0x00 );
-    LOGGER->Log( "offset_to_camera = " + HexToString( offset_to_camera, 8, '0' ) + "\n" );
-
-    // get camera matrix (3 vectors)
-    Ogre::Matrix3 matrix;
-    matrix[ 0 ][ 0 ] = ( s16 )GetU16LE( offset_to_camera + 0x00 ) / 4096.0f;
-    matrix[ 1 ][ 0 ] = ( s16 )GetU16LE( offset_to_camera + 0x02 ) / 4096.0f;
-    matrix[ 2 ][ 0 ] = ( s16 )GetU16LE( offset_to_camera + 0x04 ) / 4096.0f;
-    matrix[ 0 ][ 1 ] = ( s16 )GetU16LE( offset_to_camera + 0x06 ) / 4096.0f;
-    matrix[ 1 ][ 1 ] = ( s16 )GetU16LE( offset_to_camera + 0x08 ) / 4096.0f;
-    matrix[ 2 ][ 1 ] = ( s16 )GetU16LE( offset_to_camera + 0x0a ) / 4096.0f;
-    matrix[ 0 ][ 2 ] = ( s16 )GetU16LE( offset_to_camera + 0x0c ) / 4096.0f;
-    matrix[ 1 ][ 2 ] = ( s16 )GetU16LE( offset_to_camera + 0x0e ) / 4096.0f;
-    matrix[ 2 ][ 2 ] = ( s16 )GetU16LE( offset_to_camera + 0x12 ) / 4096.0f;
-    // get camera position in camera space
-    position.x  = -( s32 )GetU32LE( offset_to_camera + 0x14 ) / downscaler;
-    position.y  = -( s32 )GetU32LE( offset_to_camera + 0x18 ) / downscaler;
-    position.z  = -( s32 )GetU32LE( offset_to_camera + 0x1c ) / downscaler;
-
-    orientation.FromRotationMatrix( matrix );
-    position = orientation * position;
-    //matrix[ 0 ][ 0 ] = matrix[ 0 ][ 0 ];
-    //matrix[ 1 ][ 0 ] = matrix[ 1 ][ 0 ];
-    //matrix[ 2 ][ 0 ] = matrix[ 2 ][ 0 ];
-    matrix[ 0 ][ 1 ] = -matrix[ 0 ][ 1 ];
-    matrix[ 1 ][ 1 ] = -matrix[ 1 ][ 1 ];
-    matrix[ 2 ][ 1 ] = -matrix[ 2 ][ 1 ];
-    matrix[ 0 ][ 2 ] = -matrix[ 0 ][ 2 ];
-    matrix[ 1 ][ 2 ] = -matrix[ 1 ][ 2 ];
-    matrix[ 2 ][ 2 ] = -matrix[ 2 ][ 2 ];
-    orientation.FromRotationMatrix( matrix );
-
-    float focal_length = GetU16LE( offset_to_camera + 0x24 );
-    fov = Ogre::Degree( Ogre::Radian( 2 * atanf( 240.0f / ( 2.0f * focal_length ) ) ) );
-
-    LOGGER->Log( "Field camera matrix : " + Ogre::StringConverter::toString( matrix ) + "\n" );
-    LOGGER->Log( "Camera position     : " + Ogre::StringConverter::toString( position ) + "\n" );
-    LOGGER->Log( "Camera focal_length : " + FloatToString( focal_length ) + "\n");
-    LOGGER->Log( "Unknown (depth que?): DQB = " + HexToString( GetU32LE( offset_to_camera + 0x20 ), 8, '0' ) + ", DQA = " + HexToString( GetU16LE( offset_to_camera + 0x26 ), 4, '0' ) + "\n" );
-}
-
-
-
-void
-DatFile::GetScreenRange( int& min_x, int& min_y, int& max_x, int& max_y )
-{
-    // sector 5
-    u32 offset_to_triggers = 0x1c + GetU32LE( 0x10 ) - GetU32LE( 0x00 );
-
-    min_x = ( s16 )GetU16LE( offset_to_triggers + 0x0c ) * 3;
-    min_y = ( s16 )GetU16LE( offset_to_triggers + 0x0e ) * 3;
-    max_x = ( s16 )GetU16LE( offset_to_triggers + 0x10 ) * 3;
-    max_y = ( s16 )GetU16LE( offset_to_triggers + 0x12 ) * 3;
-
-    //LOGGER->Log(LOGGER_INFO, "Screen range: x: max = %d", max_x);
-    //LOGGER->Log(LOGGER_INFO, "                 min = %d", min_x);
-    //LOGGER->Log(LOGGER_INFO, "              y: max = %d", max_y);
-    //LOGGER->Log(LOGGER_INFO, "                 min = %d", min_y);
-    //LOGGER->Log(LOGGER_INFO, "Leftover info %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x %08x %08x %08x %08x %08x %08x", GetU8(offset_to_triggers + 0x14), GetU8(offset_to_triggers + 0x15), GetU8(offset_to_triggers + 0x16), GetU8(offset_to_triggers + 0x17), GetU8(offset_to_triggers + 0x18), GetU8(offset_to_triggers + 0x19), GetU8(offset_to_triggers + 0x1A), GetU8(offset_to_triggers + 0x1B), GetU8(offset_to_triggers + 0x1C), GetU8(offset_to_triggers + 0x1D), GetU8(offset_to_triggers + 0x1E), GetU8(offset_to_triggers + 0x1F), GetU32LE(offset_to_triggers + 0x20), GetU32LE(offset_to_triggers + 0x24), GetU32LE(offset_to_triggers + 0x28), GetU32LE(offset_to_triggers + 0x2C), GetU32LE(offset_to_triggers + 0x30), GetU32LE(offset_to_triggers + 0x34));
-}
-
-
-
-void
-DatFile::DumpBackground( const Ogre::String& export_path, const Field& field, MimFile& mim )
-{
-    Logger* export_text = new Logger( export_path + "maps/ffvii_field/" + field.name + "_bg.xml" );
-
-    int width = field.tex_width;
-    int height = field.tex_height;
-
-    // set camera for depth calculation
-    Ogre::Vector3 position = Ogre::Vector3::ZERO;
-    Ogre::Quaternion orientation = Ogre::Quaternion::IDENTITY;
-    Ogre::Degree fov = Ogre::Degree( 90 );
-    GetCamera( position, orientation, fov, field );
-
-    int min_x, min_y, max_x, max_y;
-    GetScreenRange( min_x, min_y, max_x, max_y );
-
-    export_text->Log( "<background2d" );
-    export_text->Log( " image=\"maps/ffvii/field/" + field.name + ".png\"" );
-    export_text->Log( " position=\"" + Ogre::StringConverter::toString( position ) + "\"" );
-    export_text->Log( " orientation=\"" + Ogre::StringConverter::toString( orientation ) + "\"" );
-    export_text->Log( " fov=\"" + Ogre::StringConverter::toString( fov ) + "\"" );
-    export_text->Log( " range=\"" + IntToString( min_x ) + " " + IntToString( min_y ) + " " + IntToString( max_x ) + " " + IntToString( max_y ) + "\"" );
-    export_text->Log( " clip=\"" + IntToString( 320 * 3 ) + " " + IntToString( 240 * 3 ) + "\"" );
-    export_text->Log( ">\n" );
-
-    assert(width != 0);
-    assert(height != 0);
-    full_image = CreateSurface( width, height );
-    x_32 = 0; y_32 = 0; x_16 = 0; y_16 = 0; n_16 = 0;
-
-    // sector 3
-    u32 offset_to_background = 0x1c + GetU32LE( 0x08 ) - GetU32LE( 0x00 );
-    u32 offset_to_1 = offset_to_background + 0x10;
-    u32 offset_to_2 = offset_to_background + GetU32LE( offset_to_background + 0x00 );
-    u32 offset_to_3 = offset_to_background + GetU32LE( offset_to_background + 0x04 );
-    u32 offset_to_4 = offset_to_background + GetU32LE( offset_to_background + 0x08 );
-    u32 offset_to_5 = offset_to_background + GetU32LE( offset_to_background + 0x0c );
-    u32 s1 = offset_to_1;
-    u32 s2 = offset_to_2;
-    u32 s3 = offset_to_3;
-    u32 s4 = offset_to_4;
-    u32 s5 = offset_to_5;
-
-
-
-    // get global texture setting
-    u16 g_page_x   =   GetU16LE( s3 ) & 0x000f;
-    u16 g_page_y   = ( GetU16LE( s3 ) & 0x0010 ) >> 0x04;
-    u8  g_blending = ( GetU16LE( s3 ) & 0x0060 ) >> 0x05;
-    u8  g_bpp      = ( GetU16LE( s3 ) & 0x0180 ) >> 0x07;
-    s3 += 0x02;
-
-
-
-    std::vector< Tile > tiles;
-
-    for( ; s1 < offset_to_2; s1 += 0x06 )
-    {
-        if( GetU16LE(s1) == 0x7ffe )
-        {
-            g_page_x   =   GetU16LE( s3 ) & 0x000f;
-            g_page_y   = ( GetU16LE( s3 ) & 0x0010 ) >> 0x04;
-            g_blending = ( GetU16LE( s3 ) & 0x0060 ) >> 0x05;
-            g_bpp      = ( GetU16LE( s3 ) & 0x0180 ) >> 0x07;
-            s3 += 0x02;
-            s1 += 0x06;
-        }
-        if( GetU16LE( s1 ) == 0x7fff )
-        {
-            s1 += 0x02;
-            break;
-        }
-
-        u16 sprite_num = GetU16LE( s1 + 0x04 );
-
-        for( u16 i = 0; i < sprite_num; ++i )
-        {
-            Tile tile;
-            tile.background      = 0;
-            tile.dest_x          = GetU16LE( s2 + 0x00 );
-            tile.dest_y          = GetU16LE( s2 + 0x02 );
-            tile.src_x           = GetU8( s2 + 0x04 );
-            tile.src_y           = GetU8( s2 + 0x05 );
-            tile.clut_y          = ( GetU16LE( s2 + 0x06 ) & 0xffc0 ) >> 6;
-            tile.clut_x          = ( GetU16LE( s2 + 0x06 ) & 0x003f ) << 4;
-            tile.bpp             = g_bpp;
-            tile.page_x          = u8(g_page_x);
-            tile.page_y          = u8(g_page_y);
-            tile.depth           = 999;
-            tile.blending        = 0;
-            tile.animation_id    = 0;
-            tile.animation_frame = 0;
-            tiles.push_back( tile );
-            s2 += 0x08;
-        }
-    }
-
-
-
-    for( ; s1 < offset_to_2; s1 += 0x06 )
-    {
-        if( GetU16LE( s1 ) == 0x7fff )
-        {
-            s1 += 0x02;
-            break;
-        }
-
-        u16 sprite_num = GetU16LE( s1 + 0x04 );
-
-        for( u32 i = 0; i < sprite_num; ++i )
-        {
-            Tile tile;
-            tile.background      = 1;
-            tile.dest_x          = GetU16LE( s4 + 0x00 );
-            tile.dest_y          = GetU16LE( s4 + 0x02 );
-            tile.src_x           = u8(GetU16LE( s4 + 0x04 ));
-            tile.src_y           = u8(GetU16LE( s4 + 0x05 ));
-            tile.clut_y          = ( GetU16LE( s4 + 0x06 ) & 0xffc0 ) >> 6;
-            tile.clut_x          = ( GetU16LE( s4 + 0x06 ) & 0x003f ) << 4;
-            tile.bpp             = ( GetU16LE( s4 + 0x08 ) & 0x0180 ) >> 0x07;
-            tile.page_x          = GetU16LE( s4 + 0x08 ) & 0x000f;
-            tile.page_y          = ( GetU16LE( s4 + 0x08 ) & 0x0010 ) >> 0x04;
-            tile.depth           = GetU16LE( s4 + 0x0a ) / ( 32.0f * field.scale );
-            tile.blending        = ( GetU16LE( s4 + 0x08 ) & 0x60 ) >> 0x05;
-            tile.animation_id    = GetU8( s4 + 0x0c ) & 0x0f;
-            tile.animation_frame = GetU8( s4 + 0x0d );
-            tiles.push_back( tile );
-            s4 += 0x0e;
-        }
-    }
-
-
-/*
-    for( ; s1 < offset_to_2; s1 += 0x06 )
-    {
-        if( GetU16LE( s1 ) == 0x7ffe )
-        {
-            g_page_x   =   GetU16LE( s3 ) & 0x000f;
-            g_page_y   = ( GetU16LE( s3 ) & 0x0010 ) >> 0x04;
-            g_blending = ( GetU16LE( s3 ) & 0x0060 ) >> 0x05;
-            g_bpp      = ( GetU16LE( s3 ) & 0x0180 ) >> 0x07;
-            s3 += 0x02;
-            //LOGGER->Log( "Set global tex page x = " + HexToString( g_page_x, 4, '0' ) +", tex page y = " + HexToString( g_page_y, 4, '0' ) + ", blending = " + HexToString( g_blending, 2, '0' ) + ", bpp = " + HexToString( g_bpp, 2, '0' ) + "\n" );
-            s1 += 0x06;
-        }
-        if( GetU16LE( s1 ) == 0x7fff )
-        {
-            s1 += 0x02;
-            break;
-        }
-
-        u16 sprite_num = GetU16LE( s1 + 0x04 );
-
-        for( u32 i = 0; i < sprite_num; ++i )
-        {
-            Tile tile;
-            tile.background = 2;
-            tile.dest_x     = GetU16LE( s5 + 0x00 );
-            tile.dest_y     = GetU16LE( s5 + 0x02 );
-            tile.src_x      = GetU8( s5 + 0x04 );
-            tile.src_y      = GetU8( s5 + 0x05 );
-            tile.clut_y     = ( GetU16LE( s5 + 0x06 ) & 0xffc0 ) >> 6;
-            tile.clut_x     = ( GetU16LE( s5 + 0x06 ) & 0x003f ) << 4;
-            tile.bpp        = g_bpp;
-            tile.page_x     = g_page_x;
-            tile.page_y     = g_page_y;
-            tile.depth      = 0;
-            tile.blending   = g_blending;
-            tile.animation  = GetU8( s5 + 0x08 ) & 0x0f;
-            tile.animation_index = GetU8( s5 + 0x09 );
-            tiles.push_back( tile );
-
-            s5 += 0x0a;
-        }
-    }
-
-
-
-    // add layer 4 sprite
-    for( ; s1 < offset_to_2; s1 += 0x06 )
-    {
-        if( GetU16LE( s1 ) == 0x7ffe )
-        {
-            g_page_x   =   GetU16LE( s3 ) & 0x000f;
-            g_page_y   = ( GetU16LE( s3 ) & 0x0010 ) >> 0x04;
-            g_blending = ( GetU16LE( s3 ) & 0x0060 ) >> 0x05;
-            g_bpp      = ( GetU16LE( s3 ) & 0x0180 ) >> 0x07;
-            s3 += 0x02;
-            //LOGGER->Log( "Set global tex page x = " + ToHexString( g_page_x, 4, '0' ) +", tex page y = " + ToHexString( g_page_y, 4, '0' ) + ", blending = " + ToHexString( g_blending, 2, '0' ) + ", bpp = " + ToHexString( g_bpp, 2, '0' ) + "\n" );
-            s1 += 0x06;
-        }
-        if( GetU16LE( s1 ) == 0x7fff )
-        {
-            break;
-        }
-
-        u16 sprite_num = GetU16LE( s1 + 0x04 );
-
-        for( u32 i = 0; i < sprite_num; ++i )
-        {
-            Tile tile;
-            tile.background = 3;
-            tile.dest_x     = GetU16LE( s5 + 0x00 );
-            tile.dest_y     = GetU16LE( s5 + 0x02 );
-            tile.src_x      = GetU8( s5 + 0x04 );
-            tile.src_y      = GetU8( s5 + 0x05 );
-            tile.clut_y     = ( GetU16LE( s5 + 0x06 ) & 0xffc0 ) >> 6;
-            tile.clut_x     = ( GetU16LE( s5 + 0x06 ) & 0x003f ) << 4;
-            tile.bpp        = g_bpp;
-            tile.page_x     = g_page_x;
-            tile.page_y     = g_page_y;
-            tile.depth      = 0;
-            tile.blending   = g_blending;
-            tile.animation  = GetU8( s5 + 0x08 ) & 0x0f;
-            tile.animation_index = GetU8( s5 + 0x09 );
-            tiles.push_back( tile );
-
-            s5 += 0x0a;
-        }
-    }
-*/
-
-
-
-    // unify animations
-    std::vector< Tile > temp_tiles;
-
-
-
-    for( unsigned int i = 0; i < field.animations.size(); ++i )
-    {
-        LOGGER->Log( "Start add animation \"" + field.animations[ i ].name + "\".\n" );
-
-        for( unsigned int j = 0; j < field.animations[ i ].keyframes.size(); ++j )
-        {
-            if( field.animations[ i ].keyframes[ j ].blank != true )
-            {
-                LOGGER->Log( "Start add not blank keyframe at time \"" + FloatToString( field.animations[ i ].keyframes[ j ].time ) + "\".\n" );
-
-                for( unsigned int k = 0; k < tiles.size(); ++k )
-                {
-                    if( TileCompare( tiles[ k ], field.animations[ i ].keyframes[ j ], mim ) == true )
-                    {
-                        tiles[ k ].animated = true;
-
-                        Tile tile;
-
-                        unsigned int l = 0;
-                        for( ; l < temp_tiles.size(); ++l )
-                        {
-                            if(   tiles[ k ].dest_x == temp_tiles[ l ].dest_x &&
-                                  tiles[ k ].dest_y == temp_tiles[ l ].dest_y &&
-                                  tiles[ k ].blending == temp_tiles[ l ].blending &&
-                                ( tiles[ k ].animation_id == temp_tiles[ l ].animation_id ||
-                                  tiles[ k ].depth == temp_tiles[ l ].depth ) )
-                            {
-                                LOGGER->Log( "Temp_tile found use existed one.\n" );
-                                tile = temp_tiles[ l ];
-                                break;
-                            }
-                        }
-
-                        if( l == temp_tiles.size() )
-                        {
-                            LOGGER->Log( "Temp_tile not found add new one.\n" );
-                            tile = tiles[ k ];
-                        }
-
-                        LOGGER->Log( "Search for existed animation in temp_tiles.\n" );
-                        unsigned int m = 0;
-                        for( ; m < tile.animations.size(); ++m )
-                        {
-                            if( tile.animations[ m ].name == field.animations[ i ].name )
-                            {
-                                LOGGER->Log( "Animation found.\n" );
-                                break;
-                            }
-                        }
-
-                        if( m == tile.animations.size() )
-                        {
-                            LOGGER->Log( "Animation not found add new one.\n" );
-                            Animation animation;
-                            animation.name = field.animations[ i ].name;
-                            animation.time = field.animations[ i ].time;
-                            tile.animations.push_back( animation );
-                        }
-
-                        KeyFrame frame;
-                        frame.time       = field.animations[ i ].keyframes[ j ].time;
-                        frame.src_x      = tiles[ k ].src_x;
-                        frame.src_y      = tiles[ k ].src_y;
-                        frame.clut_x     = tiles[ k ].clut_x;
-                        frame.clut_y     = tiles[ k ].clut_y;
-                        frame.bpp        = tiles[ k ].bpp;
-                        frame.page_x     = tiles[ k ].page_x;
-                        frame.page_y     = tiles[ k ].page_y;
-                        frame.clut_start = field.animations[ i ].keyframes[ j ].clut_start;
-                        frame.clut_width = field.animations[ i ].keyframes[ j ].clut_width;
-                        frame.mod_type   = field.animations[ i ].keyframes[ j ].mod_type;
-                        frame.mod_r      = field.animations[ i ].keyframes[ j ].mod_r;
-                        frame.mod_g      = field.animations[ i ].keyframes[ j ].mod_g;
-                        frame.mod_b      = field.animations[ i ].keyframes[ j ].mod_b;
-
-
-                        tile.animations[ m ].keyframes.push_back( frame );
-                        LOGGER->Log( "Keyframe at time \"" + FloatToString( field.animations[ i ].keyframes[ j ].time ) + "\" added.\n" );
-
-                        if( l == temp_tiles.size() )
-                        {
-                            temp_tiles.push_back( tile );
-                        }
-                        else
-                        {
-                            temp_tiles[ l ] = tile;
-                        }
-                    }
-                }
-            }
-            else
-            {
-                LOGGER->Log( "Start add blank keyframe at time \"" + FloatToString( field.animations[ i ].keyframes[ j ].time ) + "\".\n" );
-
-                for( unsigned int k = 0; k < tiles.size(); ++k )
-                {
-                    if( tiles[ k ].animation_id == field.animations[ i ].keyframes[ j ].animation_id && tiles[ k ].animation_frame == 1 )
-                    {
-                        Tile tile;
-
-                        unsigned int l = 0;
-                        for( ; l < temp_tiles.size(); ++l )
-                        {
-                            if(   tiles[ k ].dest_x == temp_tiles[ l ].dest_x &&
-                                  tiles[ k ].dest_y == temp_tiles[ l ].dest_y &&
-                                  tiles[ k ].blending == temp_tiles[ l ].blending &&
-                                ( tiles[ k ].animation_id == temp_tiles[ l ].animation_id ||
-                                  tiles[ k ].depth == temp_tiles[ l ].depth ) )
-                            {
-                                LOGGER->Log( "Temp_tile found use existed one.\n" );
-                                tile = temp_tiles[ l ];
-                                break;
-                            }
-                        }
-
-                        if( l == temp_tiles.size() )
-                        {
-                            LOGGER->Log( "Temp_tile not found add new one.\n" );
-                            tile = tiles[ k ];
-                        }
-
-                        LOGGER->Log( "Search for existed animation in temp_tiles.\n" );
-                        unsigned int m = 0;
-                        for( ; m < tile.animations.size(); ++m )
-                        {
-                            if( tile.animations[ m ].name == field.animations[ i ].name )
-                            {
-                                LOGGER->Log( "Animation found.\n" );
-                                break;
-                            }
-                        }
-
-                        if( m == tile.animations.size() )
-                        {
-                            LOGGER->Log( "Animation not found add new one.\n" );
-                            Animation animation;
-                            animation.name = field.animations[ i ].name;
-                            animation.time = field.animations[ i ].time;
-                            tile.animations.push_back( animation );
-                        }
-
-                        KeyFrame frame;
-                        frame.time       = field.animations[ i ].keyframes[ j ].time;
-                        frame.src_x      = 0;
-                        frame.src_y      = 0;
-                        frame.clut_x     = 0;
-                        frame.clut_y     = 0;
-                        frame.bpp        = 0;
-                        frame.page_x     = 0;
-                        frame.page_y     = 0;
-                        frame.mod_type   = "";
-                        tile.animations[ m ].keyframes.push_back( frame );
-                        LOGGER->Log( "Keyframe at time \"" + FloatToString( field.animations[ i ].keyframes[ j ].time ) + "\" added.\n" );
-
-                        if( l == temp_tiles.size() )
-                        {
-                            temp_tiles.push_back( tile );
-                        }
-                        else
-                        {
-                            temp_tiles[ l ] = tile;
-                        }
-                    }
-                }
-            }
-        }
-    }
-
-
-
-    for( unsigned int i = 0; i < tiles.size(); ++i )
-    {
-        if( tiles[ i ].animated != true )
-        {
-             temp_tiles.push_back( tiles[ i ] );
-        }
-    }
-
-
-
-    LOGGER->Log( "Start sorting all tiles.\n" );
-    for( unsigned int i = 0; i < temp_tiles.size(); ++i )
-    {
-        for (unsigned int l = 0; l < temp_tiles[i].animations.size(); ++l)
-        {
-            std::sort( temp_tiles[ i ].animations[ l ].keyframes.begin(), temp_tiles[ i ].animations[ l ].keyframes.end(), anim_time_sort() );
-        }
-        std::sort( temp_tiles[ i ].animations.begin(), temp_tiles[ i ].animations.end(), anim_name_sort() );
-    }
-    LOGGER->Log( "Finish sorting all tiles.\n" );
-
-
-
-    tiles = temp_tiles;
-
-
-
-    LOGGER->Log( "Start add tiles to file.\n" );
-    for( unsigned int i = 0; i < tiles.size(); ++i )
-    {
-        AddTile( tiles[ i ], mim, export_text );
-    }
-    LOGGER->Log( "Finish add tiles to file.\n" );
-
-
-
-    Ogre::TexturePtr ptex;
-    Ogre::HardwarePixelBufferSharedPtr buffer;
-    ptex = Ogre::TextureManager::getSingleton().createManual( "DynaTex", "General", Ogre::TEX_TYPE_2D, width, height, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC );
-    buffer = ptex->getBuffer( 0, 0 );
-    buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD );
-    const Ogre::PixelBox& pb = buffer->getCurrentLock();
-
-    for( s32 y = 0; y < height; ++y )
-    {
-        u32* data = static_cast< u32* >( (u32*) pb.data ) + y * pb.rowPitch;
-
-        for( s32 x = 0; x < width; ++x )
-        {
-            u32 clut = full_image->pixels[ y * width * 4 + x * 4 + 3 ]
-                   | ( full_image->pixels[ y * width * 4 + x * 4 + 2 ] << 8 )
-                   | ( full_image->pixels[ y * width * 4 + x * 4 + 1 ] << 16 )
-                   | ( full_image->pixels[ y * width * 4 + x * 4 + 0 ] << 24 );
-            data[ x ] = clut;
-        }
-    }
-
-    Ogre::Image image;
-    image.loadDynamicImage( ( Ogre::uchar* )pb.data, width, height, Ogre::PF_R8G8B8A8 );
-    image.save( export_path + "maps/ffvii_field/" + field.name + ".png" );
-    buffer->unlock();
-    Ogre::TextureManager::getSingleton().remove( "DynaTex" );
-
-    export_text->Log( "</background2d>" );
-    delete export_text;
-}
-
-
-
-bool
-DatFile::TileCompare( const Tile& tile, const FieldKeyFrame& keyframe, MimFile& mim )
-{
-    bool ret = true;
-
-    // compare animations
-    if( keyframe.animation_id != tile.animation_id )
-    {
-        ret = false;
-    }
-    else if( keyframe.animation_id != 0 )
-    {
-        if( ( 1 << keyframe.animation_frame ) != tile.animation_frame )
-        {
-            ret = false;
-        }
-    }
-
-    // compare palette
-    if( keyframe.clut_y != -1 )
-    {
-        if( keyframe.clut_y != tile.clut_y )
-        {
-            ret = false;
-        }
-/*
-        else
-        {
-            // set size depending on background
-            u8 size = ( tile.background > 1 ) ? 32 : 16;
-            if( mim.ClutCheck( tile.page_x, tile.page_y, tile.clut_x, tile.bpp, tile.src_x, tile.src_y, size, size, keyframe.clut_x, keyframe.clut_width ) == false )
-            {
-                ret = false;
-            }
-        }
-*/
-    }
-
-    return ret;
-}
-
-
-
-void
-DatFile::AddTile( const Tile& tile, MimFile& mim, Logger* export_text )
-{
-    AddedTile added_main_tile = AddTileTex( tile.background, tile.src_x, tile.src_y, tile.clut_x, tile.clut_y, tile.bpp, tile.page_x, tile.page_y, mim, 0, 0, "", 1, 1, 1 );
-
-    Ogre::String blending_str = "";
-    if( tile.blending == 0 )
-    {
-        blending_str = "alpha";
-    }
-    else if( tile.blending == 1 || tile.blending == 3 ) // 3 is source + 0.25 * destination
-    {
-        blending_str = "add";
-    }
-    else if( tile.blending == 2 )
-    {
-        blending_str = "subtract";
-    }
-    else
-    {
-        LOGGER->Log( "Tile blending with type \"" + Ogre::StringConverter::toString( tile.blending ) + "\" not supported." );
-    }
-
-    export_text->Log(
-                        "    <tile destination=\"" +
-                        Ogre::StringConverter::toString( tile.dest_x * 3 ) +
-                        " " +
-                        Ogre::StringConverter::toString( tile.dest_y * 3 ) +
-                        "\" width=\"" +
-                        Ogre::StringConverter::toString( added_main_tile.width * 3 ) +
-                        "\" height=\"" +
-                        Ogre::StringConverter::toString( added_main_tile.height * 3 ) +
-                        "\" uv=\"" +
-                        Ogre::StringConverter::toString( added_main_tile.x / ( float ) full_image->width ) +
-                        " " +
-                        Ogre::StringConverter::toString( added_main_tile.y / ( float ) full_image->height ) +
-                        " " +
-                        Ogre::StringConverter::toString( ( added_main_tile.x + added_main_tile.width ) / ( float ) full_image->width ) +
-                        " " +
-                        Ogre::StringConverter::toString( ( added_main_tile.y + added_main_tile.height ) / ( float ) full_image->height ) +
-                        "\" depth=\"" +
-                        Ogre::StringConverter::toString( ( tile.depth > 0.002f ) ? tile.depth : 0.002f ) +
-                        "\" blending=\"" + blending_str + "\""
-    );
-
-    if( tile.animations.size() == 0 )
-    {
-        export_text->Log( " />\n" );
-    }
-    else
-    {
-        export_text->Log( ">\n" );
-
-        for( unsigned int l = 0; l < tile.animations.size(); ++l )
-        {
-            export_text->Log( "        <animation name=\"" + tile.animations[ l ].name + "\" length=\"" + Ogre::StringConverter::toString( tile.animations[ l ].time ) + "\" >" );
-
-            for( unsigned int i = 0; i < tile.animations[ l ].keyframes.size(); ++i )
-            {
-                export_text->Log( "<keyframe" );
-                export_text->Log( " time=\"" + Ogre::StringConverter::toString( tile.animations[ l ].keyframes[ i ].time ) + "\"" );
-
-                //LOGGER->Log( "Animation tile pixels src_x=\"" + IntToString( tile.animation_key.keyframes[ i ].src_x ) + "\" src_y=\"" + IntToString( tile.animation_key.keyframes[ i ].src_y ) + "\"\n" );
-                AddedTile added_tile = AddTileTex( tile.background, tile.animations[ l ].keyframes[ i ].src_x, tile.animations[ l ].keyframes[ i ].src_y, tile.animations[ l ].keyframes[ i ].clut_x, tile.animations[ l ].keyframes[ i ].clut_y, tile.animations[ l ].keyframes[ i ].bpp, tile.animations[ l ].keyframes[ i ].page_x, tile.animations[ l ].keyframes[ i ].page_y, mim, tile.animations[ l ].keyframes[ i ].clut_start, tile.animations[ l ].keyframes[ i ].clut_width, tile.animations[ l ].keyframes[ i ].mod_type, tile.animations[ l ].keyframes[ i ].mod_r, tile.animations[ l ].keyframes[ i ].mod_g, tile.animations[ l ].keyframes[ i ].mod_b );
-                //LOGGER->Log( "Animation tile pixels x=\"" + IntToString( x ) + "\" y=\"" + IntToString( y ) + "\"\n" );
-                export_text->Log( " uv=\""
-                                 +Ogre::StringConverter::toString( added_tile.x / ( float ) full_image->width )
-                                 +" "
-                                 +Ogre::StringConverter::toString( added_tile.y / ( float ) full_image->height )
-                                 +" "
-                                 +Ogre::StringConverter::toString( ( added_tile.x + added_tile.width ) / ( float ) full_image->width )
-                                 +" "
-                                 +Ogre::StringConverter::toString( ( added_tile.y + added_tile.height ) / ( float ) full_image->height )
-                                 +"\""
-                );
-                export_text->Log( "/>" );
-            }
-
-            export_text->Log( "</animation>\n" );
-        }
-
-        export_text->Log( "    </tile>\n" );
-    }
-}
-
-
-
-AddedTile
-DatFile::AddTileTex( const u8 background, const u8 src_x, const u8 src_y, const u16 clut_x, const u16 clut_y, const u8 bpp, const u8 page_x, const u8 page_y, MimFile& mim, const int clut_start, const int clut_width, const Ogre::String& mod_type, const float mod_r, const float mod_g, const float mod_b )
-{
-    AddedTile tile;
-    tile.background = background;
-    tile.src_x      = src_x;
-    tile.src_y      = src_y;
-    tile.clut_x     = clut_x;
-    tile.clut_y     = clut_y;
-    tile.bpp        = bpp;
-    tile.page_x     = page_x;
-    tile.page_y     = page_x;
-    tile.clut_start = clut_start;
-    tile.clut_width = clut_width;
-    tile.mod_type   = mod_type;
-    tile.mod_r      = mod_r;
-    tile.mod_g      = mod_g;
-    tile.mod_b      = mod_b;
-    std::vector< AddedTile >::iterator tile_it = std::find_if( m_AddedTiles.begin(), m_AddedTiles.end(), added_tile_find( tile ) );
-
-    if( tile_it != m_AddedTiles.end() )
-    {
-        return *tile_it;
-    }
-
-
-
-    SurfaceTexData surface;
-    surface.page_x     = page_x;
-    surface.page_y     = page_y;
-    surface.clut_x     = clut_x;
-    surface.clut_y     = clut_y;
-    surface.bpp        = bpp;
-    surface.clut_start = clut_start;
-    surface.clut_width = clut_width;
-    surface.mod_type   = mod_type;
-    surface.mod_r      = mod_r;
-    surface.mod_g      = mod_g;
-    surface.mod_b      = mod_b;
-
-    std::vector< SurfaceTexData >::iterator it = std::find_if( m_Surfaces.begin(), m_Surfaces.end(), surface_find( surface ) );
-
-    if( it == m_Surfaces.end() )
-    {
-        surface.surface = mim.GetSurface( page_x, page_y, clut_x, clut_y, bpp, clut_start, clut_width, mod_type, mod_r, mod_g, mod_b );
-        m_Surfaces.push_back( surface );
-    }
-    else
-    {
-        surface = *it;
-    }
-
-    // set size depending on background
-    u8 size = ( background > 1 ) ? 32 : 16;
-
-    Surface* sub_image = CreateSubSurface( src_x, src_y, size, size, surface.surface );
-
-    if( sub_image->width == 32 )
-    {
-        tile.x = float(x_32);
-        tile.y = float(y_32);
-
-        x_32 += 32;
-        if( x_32 == full_image->width )
-        {
-            y_32 += 32;
-            x_32 = 0;
-        }
-    }
-    else if( sub_image->width == 16 )
-    {
-        // if we start new 16x16*4 block
-        if( n_16 == 0 )
-        {
-            x_16 = x_32;
-            y_16 = y_32;
-
-            x_32 += 32;
-            if( x_32 == full_image->width )
-            {
-                y_32 += 32;
-                x_32 = 0;
-            }
-        }
-
-        tile.x = float(x_16);
-        tile.y = float(y_16);
-
-        ++n_16;
-        if( n_16 == 1 || n_16 == 3 )
-        {
-            x_16 += 16;
-        }
-        else if( n_16 == 2 )
-        {
-            x_16 -= 16;
-            y_16 += 16;
-        }
-        else if( n_16 == 4 )
-        {
-            n_16 = 0;
-        }
-    }
-
-    CopyToSurface( full_image, int(tile.x), int(tile.y), sub_image );
-
-
-
-    tile.width  = size;
-    tile.height = size;
-    m_AddedTiles.push_back( tile );
-    return tile;
-}
-
-
-
-void
-DatFile::DumpWalkmesh( const Ogre::String& export_path, const Field& field )
-{
-    Logger* export_script = new Logger( export_path + "/maps/ffvii_field/" + field.name + "_wm.xml" );
-    export_script->Log( "<walkmesh>\n" );
-
-    // get sector 2 offset (walkmesh)
-    u32 offset_to_walkmesh = 0x1C + GetU32LE( 0x04 ) - GetU32LE( 0x00 );
-    u32 number_of_poly = GetU32LE( offset_to_walkmesh );
-
-    int start_walkmesh = offset_to_walkmesh + 0x04;
-    int start_access   = offset_to_walkmesh + 0x04 + number_of_poly * 0x18;
-
-    float downscaler = 128.0f * field.scale;
-
-    Ogre::Vector3 A, B, C;
-
-    for( u32 i = 0; i < number_of_poly; ++i )
-    {
-        A.x = ( s16 )GetU16LE( start_walkmesh + 0x00 ) / downscaler;
-        A.y = ( s16 )GetU16LE( start_walkmesh + 0x02 ) / downscaler;
-        A.z = ( s16 )GetU16LE( start_walkmesh + 0x04 ) / downscaler;
-
-        B.x = ( s16 )GetU16LE( start_walkmesh + 0x08 ) / downscaler;
-        B.y = ( s16 )GetU16LE( start_walkmesh + 0x0A ) / downscaler;
-        B.z = ( s16 )GetU16LE( start_walkmesh + 0x0C ) / downscaler;
-
-        C.x = ( s16 )GetU16LE( start_walkmesh + 0x10 ) / downscaler;
-        C.y = ( s16 )GetU16LE( start_walkmesh + 0x12 ) / downscaler;
-        C.z = ( s16 )GetU16LE( start_walkmesh + 0x14 ) / downscaler;
-
-        export_script->Log(
-            "    <triangle a=\"" +
-            Ogre::StringConverter::toString( A ) +
-            "\" b=\"" +
-            Ogre::StringConverter::toString( B ) +
-            "\" c=\"" +
-            Ogre::StringConverter::toString( C ) +
-            "\" a_b=\"" +
-            IntToString( ( s16 )GetU16LE( start_access + 0x00 ) ) +
-            "\" b_c=\"" +
-            IntToString( ( s16 )GetU16LE( start_access + 0x02 ) ) +
-            "\" c_a=\"" +
-            IntToString( ( s16 )GetU16LE( start_access + 0x04 ) ) +
-            "\"/>\n"
-        );
-
-        // go to the next triangle
-        start_walkmesh += 0x18;
-        start_access   += 0x06;
-    }
-
-    export_script->Log( "</walkmesh>" );
-    delete export_script;
-}
-
-
-
-void
-DatFile::DumpTriggersMovements( const Ogre::String& export_path, const Field& field )
-{
-    Logger* export_script = new Logger( export_path + "/maps/ffvii_field/" + field.name + "_triggers.xml" );
-
-    // get sector 5 triggers
-    u32 offset_to_triggers = 0x1c + GetU32LE( 0x10 ) - GetU32LE( 0x00 );
-
-    u32 start_triggers = offset_to_triggers + 0x38;
-
-    float downscaler_this = 128.0f * field.scale;
-
-    for( u32 i = 0; i < 12; ++i )
-    {
-        s16 map_id = GetU16LE( start_triggers + 0x12 );
-
-        // if not inactive gateway
-        if( map_id != 32767 )
-        {
-            float downscaler_next = 128.0f * MapIdToScale( map_id );
-
-            Ogre::Vector3 point1(   ( s16 )GetU16LE( start_triggers + 0x00 ) / downscaler_this,
-                                    ( s16 )GetU16LE( start_triggers + 0x02 ) / downscaler_this,
-                                    ( s16 )GetU16LE( start_triggers + 0x04 ) / downscaler_this );
-            Ogre::Vector3 point2(   ( s16 )GetU16LE( start_triggers + 0x06 ) / downscaler_this,
-                                    ( s16 )GetU16LE( start_triggers + 0x08 ) / downscaler_this,
-                                    ( s16 )GetU16LE( start_triggers + 0x0a ) / downscaler_this );
-            Ogre::Vector3 position( ( s16 )GetU16LE( start_triggers + 0x0c ) / downscaler_next,
-                                    ( s16 )GetU16LE( start_triggers + 0x0e ) / downscaler_next,
-                                    ( s16 )GetU16LE( start_triggers + 0x10 ) / downscaler_next );
-            float direction = 360.0f * GetU8( start_triggers + 0x14 ) / 255.0f;
-
-            export_script->Log( "    <entity_trigger name=\"Gateway" + IntToString( i ) + "\" point1=\"" + Ogre::StringConverter::toString( point1 ) + "\" point2=\"" + Ogre::StringConverter::toString( point2 ) + "\" enabled=\"true\" />\n" );
-            export_script->Log( "    <entity_point name=\"Spawn_"+ field.name + "\" position=\"" + Ogre::StringConverter::toString( position ) + "\" rotation=\"" + FloatToString( direction ) + "\" />\n" );
-            export_script->Log( "    <!-- map \"" + MapIdToString( map_id ) + "\" -->\n" );
-        }
-
-        start_triggers += 0x18;
-    }
-
-
-
-    // movement rotation
-    const u8 movement = GetU8(offset_to_triggers + 0x09);
-    const float movementDegree = 180.0f * (static_cast<float>(movement) - 128.0f) / 128.0f;
-    export_script->Log( "<movement_rotation degree=\"" + Ogre::StringConverter::toString( movementDegree ) + "\" />\n" );
-
-
-
-    delete export_script;
-}

+ 0 - 387
utilities/ffvii_field_dat_dumper/src/DatFile.h

@@ -1,387 +0,0 @@
-#ifndef DATFILE_H
-#define DATFILE_H
-
-#include "../../common/Logger.h"
-#include "common/LzsFile.h"
-#include "../../common/Surface.h"
-#include "MimFile.h"
-
-enum eOpcodes
-{
-    RET = 0x0,
-    REQ = 0x01,
-    REQSW = 0x02,
-    REQEW = 0x03,
-    RETTO = 0x07,
-    JOIN = 0x08,
-    SPLIT = 0x09,
-    SPTYE = 0x0A,
-    GTPYE = 0x0B,
-    SPECIAL = 0x0F,
-    JMPF = 0x10,
-    JMPFL = 0x11,
-    JMPB = 0x12,
-    JMPBL = 0x13,
-    IFUB = 0x14,
-    IFUBL = 0x15,
-    IFSW = 0x16,
-    IFSWL = 0x17,
-    IFUW = 0x18,
-    TUTOR = 0x21,
-    WAIT = 0x24,
-    NFADE = 0x25,
-    BLINK = 0x26,
-    KAWAI = 0x28,
-    WCLS = 0x2E,
-    WSIZW = 0x2F,
-    IFKEY = 0x30,
-    IFKEYON = 0x31,
-    UC = 0x33,
-    WSPCL = 0x36,
-    STTIM = 0x38,
-    GOLDU = 0x39,
-    GOLDD = 0x3A,
-    CHGLD = 0x3B,
-    MHMMX = 0x3E,
-    HMPMAX3 = 0x3F,
-    MESSAGE = 0x40,
-    MPNAM = 0x43,
-    ASK = 0x48,
-    MENU = 0x49,
-    MENU2 = 0x4A,
-    BTLTB = 0x4B,
-    WINDOW = 0x50,
-    WMODE = 0x52,
-    WREST = 0x53,
-    WCLSE = 0x54,
-    STITM = 0x58,
-    CKITM = 0x5A,
-    SMTRA = 0x5B,
-    SHAKE = 0x5E,
-    MAPJUMP = 0x60,
-    SCRLC = 0x62,
-    SCRLA = 0x63,
-    SCR2D = 0x64,
-    SCRCC = 0x65,
-    SCR2DC = 0x66,
-    SCRLW = 0x67,
-    SCR2DL = 0x68,
-    VWOFT = 0x6A,
-    FADE = 0x6B,
-    FADEW = 0x6C,
-    IDLCK = 0x6D,
-    LSTMP = 0x6E,
-    BATTLE = 0x70,
-    BTLON = 0x71,
-    BTLMD = 0x72,
-    PLUS_ = 0x76, // PLUS!
-    PLUS2_ = 0x77, // PLUS2!
-    MINUS_ = 0x78, // MINUS!
-    MINUS2_= 0x79, // MINUS2!
-    INC_= 0x7A, //  INC!
-    TALKON = 0x7E,
-    SETBYTE = 0x80,
-    SETWORD = 0x81,
-    BITON = 0x82,
-    BITOFF = 0x83,
-    PLUS = 0x85,
-    MINUS = 0x87,
-    MUL = 0x89,
-    MOD = 0x8D,
-    AND = 0x8F,
-    AND2 = 0x90,
-    OR = 0x91,
-    OR2 = 0x92,
-    INC = 0x95,
-    DEC = 0x97,
-    RANDOM = 0x99,
-    PC = 0xA0,
-    opCodeCHAR = 0xA1,
-    DFANM = 0xA2,
-    ANIME1 = 0xA3,
-    VISI = 0xA4,
-    XYZI = 0xA5,
-    XYI = 0xA6,
-    MOVE = 0xA8,
-    CMOVE = 0xA9,
-    MOVA = 0xAA,
-    TURA = 0xAB,
-    ANIMW = 0xAC,
-    FMOVE = 0xAD,
-    ANIME2 = 0xAE,
-    ANIM_1 = 0xAF, // ANIM!1
-    CANM_1 = 0xB1, // CANM!1 
-    MSPED = 0xB2,
-    DIR = 0xB3,
-    TURNGEN = 0xB4,
-    TURN = 0xB5,
-    DIRA = 0xB6,
-    GETDIR = 0xB7,
-    GETAXY = 0xB8,
-    GETAI = 0xB9,
-    ANIM_2 = 0xBA, // ANIM!2
-    CANIM2 = 0xBB,
-    CANM_2 = 0xBC, // CANM!2
-    ASPED = 0xBD,
-    CC = 0xBF,
-    JUMP = 0xC0,
-    AXYZI = 0xC1,
-    LADER = 0xC2,
-    OFST = 0xC3,
-    OFSTW = 0xC4,
-    TALKR = 0xC5,
-    CLIDR = 0xC6,
-    SOLID = 0xC7,
-    PRTYP = 0xC8,
-    PRTYM = 0xC9,
-    PRTYE = 0xCA,
-    MMBUD = 0xCD,
-    MMBLK = 0xCE,
-    LINE = 0xD0,
-    LINON = 0xD1,
-    MPJPO = 0xD2,
-    SLINE = 0xD3,
-    PMJMP = 0xD8,
-    AKAO2 = 0xDA,
-    ANIMB = 0xDD,
-    TURNW = 0xDE,
-    BGON = 0xE0,
-    BGOFF = 0xE1,
-    BGCLR = 0xE4,
-    STPAL = 0xE5,
-    LDPAL = 0xE6,
-    CPPAL = 0xE7,
-    ADPAL = 0xE9,
-    MPPAL2 = 0xEA,
-    STPLS = 0xEB,
-    LDPLS = 0xEC,
-    RTPAL2 = 0xEE,
-    ADPAL2 = 0xEF,
-    MUSIC = 0xF0,
-    SOUND = 0xF1,
-    AKAO = 0xF2,
-    MULCK = 0xF5,
-    BMUSC = 0xF6,
-    PMVIE = 0xF8,
-    MOVIE = 0xF9,
-    MVIEF = 0xFA,
-    MVCAM = 0xFB,
-    FMUSC = 0xFC,
-    CHMST = 0xFE
-};
-
-struct FieldKeyFrame
-{
-    FieldKeyFrame():
-        time( 0 ),
-        blank( false ),
-        animation_id( 0 ),
-        animation_frame( 0 ),
-        clut_y( -1 ),
-        clut_start( 0 ),
-        clut_width( 0 ),
-        mod_type( "add" ),
-        mod_r( 0 ),
-        mod_g( 0 ),
-        mod_b( 0 )
-    {
-    }
-
-    float time;
-    bool blank;
-
-    int animation_id;
-    int animation_frame;
-
-    int clut_y;
-    int clut_start;
-    int clut_width;
-    Ogre::String mod_type;
-    float mod_r;
-    float mod_g;
-    float mod_b;
-};
-
-struct FiledAnimation
-{
-    Ogre::String name;
-    float time;
-    std::vector< FieldKeyFrame > keyframes;
-};
-
-struct Field
-{
-    Ogre::String name;
-    float scale;
-    int tex_width;
-    int tex_height;
-    std::vector< FiledAnimation > animations;
-};
-
-
-
-struct DatModelData
-{
-    int face_id;
-    int number_of_bones;
-    int number_of_parts;
-    int number_of_animation;
-    int global_model_id;
-};
-
-
-
-struct SurfaceTexData
-{
-    Surface* surface;
-    u16 page_x;
-    u16 page_y;
-    u16 clut_x;
-    u16 clut_y;
-    u8 bpp;
-
-    int clut_start;
-    int clut_width;
-    Ogre::String mod_type;
-    float mod_r;
-    float mod_g;
-    float mod_b;
-};
-
-
-
-struct KeyFrame
-{
-    float time;
-    u8 src_x;
-    u8 src_y;
-    u16 clut_x;
-    u16 clut_y;
-    u8 bpp;
-    u8 page_x;
-    u8 page_y;
-
-    int clut_start;
-    int clut_width;
-    Ogre::String mod_type;
-    float mod_r;
-    float mod_g;
-    float mod_b;
-};
-
-struct Animation
-{
-    float time;
-    Ogre::String name;
-    std::vector< KeyFrame > keyframes;
-};
-
-
-
-struct Tile
-{
-    Tile():
-        animated( false )
-    {
-    }
-
-    bool animated;
-    u8 background;
-    s16 dest_x;
-    s16 dest_y;
-    u8 src_x;
-    u8 src_y;
-    u16 clut_x;
-    u16 clut_y;
-    u8 bpp;
-    u8 page_x;
-    u8 page_y;
-    float depth;
-    u8 blending;
-    u8 animation_id;
-    u8 animation_frame;
-    std::vector< Animation > animations;
-};
-
-
-
-struct AddedTile
-{
-    u8 background;
-    u8 src_x;
-    u8 src_y;
-    u16 clut_x;
-    u16 clut_y;
-    u8 bpp;
-    u8 page_x;
-    u8 page_y;
-
-    int clut_start;
-    int clut_width;
-    Ogre::String mod_type;
-    float mod_r;
-    float mod_g;
-    float mod_b;
-
-    float x;
-    float y;
-    float width;
-    float height;
-};
-
-
-
-class DatFile : public LzsFile
-{
-public:
-    DatFile( const Ogre::String& file );
-    DatFile( File* file );
-    DatFile( File* file, const u32 offset, const u32 length );
-    DatFile( u8* buffer, const u32 offset, const u32 length );
-    virtual ~DatFile();
-
-    void DumpText( const Ogre::String& export_path, const Field& field, bool english );
-    void DumpScript( const Ogre::String& export_path, const Field& field );
-    void DumpWalkmesh( const Ogre::String& export_path, const Field& field );
-    void GetCamera( Ogre::Vector3& position, Ogre::Quaternion& orientation, Ogre::Degree& fov, const Field& field );
-    void GetScreenRange( int& min_x, int& min_y, int& max_x, int& max_y );
-    void DumpBackground( const Ogre::String& export_path, const Field& field, MimFile& mim );
-    void DumpTriggersMovements( const Ogre::String& export_path, const Field& field );
-    static void DumpSoundOpcodesData( const Ogre::String& export_file );
-
-    void AdvanceScript( u32 value, u32& current, u32& end );
-
-    Ogre::String ParseVariableName( int slot, int value );
-    Ogre::String ParseGetVariable( int get_slot, int get_value, unsigned int hex = 0, float fixed = 1.0f );
-    Ogre::String SetVariable( int set_slot, int set_value, Ogre::String get_string );
-    Ogre::String SetBitChange( int set_slot, int set_value, int get_slot, int get_value, bool on );
-    Ogre::String ParseRelation( int relation, Ogre::String string1, Ogre::String string2 );
-
-    Ogre::String PaddingString();
-
-    Ogre::String ArgumentString( int script, int number );
-    Ogre::String OffsetString( int val );
-
-    bool TileCompare( const Tile& tile, const FieldKeyFrame& keyframe, MimFile& mim );
-    void AddTile( const Tile& tile, MimFile& mim, Logger* export_text );
-    AddedTile AddTileTex( const u8 background, const u8 src_x, const u8 src_y, const u16 clut_x, const u16 clut_y, const u8 bpp, const u8 page_x, const u8 page_y, MimFile& mim, const int clut_start, const int clut_width, const Ogre::String& mod_type, const float mod_r, const float mod_g, const float mod_b );
-
-private:
-    std::vector< int > m_Dialogs;
-
-    static std::vector< Ogre::String > m_SoundOpcodes;
-
-    std::vector< SurfaceTexData > m_Surfaces;
-    Surface* full_image;
-    int x_32;
-    int y_32;
-    int x_16;
-    int y_16;
-    int n_16;
-
-    std::vector< AddedTile > m_AddedTiles;
-};
-
-
-
-#endif // DATFILE_H

+ 0 - 219
utilities/ffvii_field_dat_dumper/src/Main.cpp

@@ -1,219 +0,0 @@
-#include <iostream>
-#include <Ogre.h>
-#include "common/OgreBase.h"
-#include "common/Logger.h"
-
-#include "DatFile.h"
-#include "MimFile.h"
-
-
-
-std::vector< Field > fields;
-
-int state;
-
-
-
-void
-fill_names()
-{
-    Ogre::ConfigFile cf;
-    cf.load( "export.cfg" );
-    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
-
-    while( seci.hasMoreElements() )
-    {
-        Field field;
-
-        Ogre::String names = seci.peekNextKey();
-        Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext();
-
-        if( names == "" )
-        {
-            continue;
-        }
-
-        Ogre::StringVector name = Ogre::StringUtil::split( names, ":", 2 );
-        if( name.size() < 3 )
-        {
-            LOGGER->Log( "In \"" + names + "\" not enough data. Must be 3.\n" );
-            continue;
-        }
-        field.name = name[ 0 ];
-        field.scale = Ogre::StringConverter::parseReal( name[ 2 ] );
-
-        Ogre::StringVector tex_size = Ogre::StringUtil::split( name[ 1 ], "x", 1 );
-        field.tex_width = Ogre::StringConverter::parseInt( tex_size[ 0 ] );
-        field.tex_height = Ogre::StringConverter::parseInt( tex_size[ 1 ] );
-
-        LOGGER->Log( "Export map \"" + field.name + "\" with tex_width=" + IntToString( field.tex_width ) + ", tex_height=" + IntToString( field.tex_height ) + ".\n" );
-
-        Ogre::ConfigFile::SettingsMultiMap::iterator i;
-        for( i = settings->begin(); i != settings->end(); ++i )
-        {
-            FiledAnimation animation;
-            animation.name = i->first;
-
-            Ogre::StringVector anim = Ogre::StringUtil::split( i->second, "|" );
-            if( anim.size() < 1 )
-            {
-                LOGGER->Log( "In \"" + i->second + "\" not enough data separated by \"|\". Must be at least 1.\n" );
-                continue;
-            }
-
-            float total_time = 0;
-
-            LOGGER->Log( "Animation \"" + animation.name + "\" added.\n" );
-
-            // go through all frames
-            for( unsigned int j = 0; j < anim.size(); ++j )
-            {
-                Ogre::StringVector frame_data = Ogre::StringUtil::split( anim[ j ], ";", 2 );
-                if( frame_data.size() < 2 )
-                {
-                    total_time += Ogre::StringConverter::parseReal( anim[ j ] );
-                    LOGGER->Log( "In \"" + anim[ j ] + "\" not enough data separated by \";\". Must be more than 1. Insert pause this way.\n" );
-                    continue;
-                }
-
-                FieldKeyFrame frame;
-                total_time += Ogre::StringConverter::parseReal( frame_data[ 0 ] );
-                frame.time = total_time;
-
-                for( unsigned int k = 1; k < frame_data.size(); ++k )
-                {
-                    Ogre::StringVector frame_data_settings = Ogre::StringUtil::split( frame_data[ k ], "=", 1 );
-                    if( frame_data_settings.size() != 2 )
-                    {
-                        LOGGER->Log( "In \"" + frame_data[ k ] + "\" not enough data separated by \"=\". Must be 2.\n" );
-                        continue;
-                    }
-
-                    if( frame_data_settings[ 0 ] == "animation" )
-                    {
-                        Ogre::StringVector animation_settings = Ogre::StringUtil::split( frame_data_settings[ 1 ], " ", 1 );
-                        if( animation_settings.size() != 2 )
-                        {
-                            LOGGER->Log( "In \"" + frame_data_settings[ 1 ] + "\" not enough data separated by \" \". Must be 2.\n" );
-                            continue;
-                        }
-
-                        frame.animation_id = Ogre::StringConverter::parseInt( animation_settings[ 0 ] );
-                        if( animation_settings[ 1 ] == "blank" )
-                        {
-                            frame.blank = true;
-                        }
-                        else
-                        {
-                            frame.animation_frame = Ogre::StringConverter::parseInt( animation_settings[ 1 ] );
-                        }
-                    }
-                    else if( frame_data_settings[ 0 ] == "clut" )
-                    {
-                        Ogre::StringVector clut_total_settings = Ogre::StringUtil::split( frame_data_settings[ 1 ], ",", 1 );
-                        if( clut_total_settings.size() != 2 )
-                        {
-                            LOGGER->Log( "In \"" + frame_data_settings[ 1 ] + "\" not enough data separated by \",\". Must be 2.\n" );
-                            continue;
-                        }
-
-                        Ogre::StringVector clut_palette_settings = Ogre::StringUtil::split( clut_total_settings[ 0 ], " ", 2 );
-                        if( clut_palette_settings.size() != 3 )
-                        {
-                            LOGGER->Log( "In \"" + clut_total_settings[ 0 ] + "\" not enough data separated by \" \". Must be 3.\n" );
-                            continue;
-                        }
-
-                        frame.clut_y      = Ogre::StringConverter::parseInt( clut_palette_settings[ 0 ] ) + 0x1e0;
-                        frame.clut_start  = Ogre::StringConverter::parseInt( clut_palette_settings[ 1 ] );
-                        frame.clut_width = Ogre::StringConverter::parseInt( clut_palette_settings[ 2 ] );
-
-                        Ogre::StringVector clut_mod_settings = Ogre::StringUtil::split( clut_total_settings[ 1 ], ":", 1 );
-                        if( clut_mod_settings.size() != 2 )
-                        {
-                            LOGGER->Log( "In \"" + clut_total_settings[ 1 ] + "\" not enough data separated by \":\". Must be 2.\n" );
-                            continue;
-                        }
-
-                        frame.mod_type = clut_mod_settings[ 0 ];
-                        Ogre::Vector3 rgb = Ogre::StringConverter::parseVector3( clut_mod_settings[ 1 ] );
-                        frame.mod_r = rgb.x;
-                        frame.mod_g = rgb.y;
-                        frame.mod_b = rgb.z;
-                    }
-                    else
-                    {
-                        LOGGER->Log( "Unknown animation type \"" + frame_data_settings[ 0 ] + "\".\n");
-                        continue;
-                    }
-                }
-
-                animation.keyframes.push_back( frame );
-                LOGGER->Log( "Keyframe added at time \"" + FloatToString( frame.time ) + "\". Settings blank=\"" + BoolToString( frame.blank ) + "\", animation_id=\"" + IntToString( frame.animation_id ) + "\", animation_frame=\"" + IntToString( frame.animation_frame ) + "\" clut_y=\"" + IntToString( frame.clut_y ) + "\", clut_start=\"" + IntToString( frame.clut_start ) + "\", clut_width=\"" + IntToString( frame.clut_width ) + "\", mod_type=\"" + frame.mod_type + "\", mod_r=\"" + FloatToString( frame.mod_r ) + "\", mod_g=\"" + FloatToString( frame.mod_g ) + "\", mod_b=\"" + FloatToString( frame.mod_b ) + "\".\n" );
-            }
-
-            animation.time = total_time;
-            field.animations.push_back( animation );
-        }
-
-        fields.push_back( field );
-    }
-}
-
-
-
-int
-main( int argc, char *argv[] )
-{
-    std::cout << "[]START" << std::endl;
-    InitializeOgreBase( "FFVII Field Model Exporter" );
-    std::cout << "[]OGRE INITIALIZED" << std::endl;
-    fill_names();
-    std::cout << "[]NAMES FILLED" << std::endl;
-
-
-    // can use this for debugging if not using export.cfg
-    Field f = {};
-    f.tex_width = 1024;
-    f.tex_height = 512;
-    // Note: Must create path CWD\export_en\maps\ffvii_field
-    f.name = "4sbwy_1"; // DO NOT put a full path here, else it will attempt to save with full output path and fail
-    fields.push_back(f);
-
-
-
-
-    /*for (int f = 0; f < fields.size(); ++f)
-    {
-        DatFile dat("data/jp/" + fields[f].name + ".dat");
-        dat.DumpScript("export_jp/" + fields[f].name + "_script.txt");
-        dat.DumpText("export_jp/" + fields[f].name + "_text.txt", false);
-        dat.DumpWalkmesh("export_jp/" + fields[f].name + "_wm.xml");
-    }
-    for (int f = 0; f < fields.size(); ++f)
-    {
-        DatFile dat("data/jp_in/" + fields[f].name + ".dat");
-        dat.DumpScript("export_jp_in/" + fields[f].name + "_script.txt");
-        dat.DumpText("export_jp_in/" + fields[f].name + "_text.txt", false);
-        dat.DumpWalkmesh("export_jp_in/" + fields[f].name + "_wm.xml");
-    }*/
-
-    for (unsigned int f = 0; f < fields.size(); ++f)
-    {
-        DatFile dat( fields[ f ].name + ".dat" );
-        MimFile mim( fields[ f ].name + ".mim" );
-        dat.DumpScript(  "export_en/", fields[ f ] );
-        dat.DumpText( "export_en/", fields[ f ], true );
-        //dat.DumpTriggersMovements( "export_en/", fields[ f ] );
-        //dat.DumpWalkmesh( "export_en/", fields[ f ] );
-        //dat.DumpBackground( "export_en/", fields[ f ], mim );
-    }
-
-    //DatFile::DumpSoundOpcodesData("sound.txt");
-
-
-
-    DeinitializeOgreBase();
-
-    return 0;
-}

+ 0 - 457
utilities/ffvii_field_dat_dumper/src/MimFile.cpp

@@ -1,457 +0,0 @@
-#include "MimFile.h"
-
-#include "../../common/Logger.h"
-
-
-
-MimFile::MimFile( const Ogre::String& file )
-    : LzsFile(file), m_Vram(Vram::MakeInstance())
-{
-    InnerGetImage();
-}
-
-
-
-MimFile::MimFile( File* pFile )
-    : LzsFile(pFile), m_Vram(Vram::MakeInstance())
-{
-    InnerGetImage();
-}
-
-
-
-MimFile::MimFile( File* pFile, const u32 offset, const u32 length )
-    : LzsFile(pFile, offset, length), m_Vram(Vram::MakeInstance())
-{
-    InnerGetImage();
-}
-
-
-
-MimFile::MimFile( u8* pBuffer, const u32 offset, const u32 length )
-    : LzsFile(pBuffer, offset, length), m_Vram(Vram::MakeInstance())
-{
-    InnerGetImage();
-}
-
-
-
-MimFile::~MimFile()
-{
-}
-
-
-
-Surface*
-MimFile::GetSurface( const u16 page_x, const u16 page_y, const u16 clut_x, const u16 clut_y, const u8 bpp, const int clut_start, const int clut_width, const Ogre::String& mod_type, const float mod_r, const float mod_g, const float mod_b )
-{
-    // lastest texture page x are on the border with vram so we need get smaller tex
-    u16 size_x = ( page_x >= 15 && bpp == 1 ) ? 128 : 256;
-    Surface* ret = CreateSurface( size_x, 256 );
-
-    if( clut_y > mClutHeight + mClutVramPositionY )
-    {
-        LOGGER->Log( "MimFile::GetSurface: Warning: \"clut_number\" is greater than number of clut in file." );
-        return ret;
-    }
-
-    // temp clut color
-    ClutColor color;
-
-    if( bpp == 0 )
-    {
-        for( int y = 0; y < 256; ++y )
-        {
-            for( int x = 0; x < 128; ++x )
-            {
-                u16 real_x = mImageVramPositionX + page_x * 128 + x;
-                u16 real_y = mImageVramPositionY + page_y * 256 + y;
-
-                int data = (m_Vram->GetU8(real_x, real_y) & 0x0f) + clut_x;
-                u16 col = m_Vram->GetU16(data * 2, clut_y);
-
-                color.r = ( ( col       ) & 31 ) * 255 / 31;
-                color.g = ( ( col >>  5 ) & 31 ) * 255 / 31;
-                color.b = ( ( col >> 10 ) & 31 ) * 255 / 31;
-                if( data >= clut_start && data < clut_start + clut_width )
-                {
-                    GetModifiedClut( color, mod_type, mod_r, mod_g, mod_b );
-                }
-                u8 stp = (col & 0x80) >> 15;
-
-                if( col == 0x0000 )
-                {
-                    color.a = 0;
-                }
-                else if( stp == 1 && color.r == 0 && color.g == 0 && color.b == 0 )
-                {
-                    color.a = 255;
-                }
-                else if( stp == 1 && ( color.r != 0 || color.g != 0 || color.b != 0 ) )
-                {
-                    color.a = 127;
-                }
-                else if( stp == 0 && ( color.r != 0 || color.g != 0 || color.b != 0 ) )
-                {
-                    color.a = 255;
-                }
-
-                memcpy( ret->pixels.data() + x * 8 + ret->width * 4 * y + 0x00, &color, sizeof( ClutColor ) );
-
-
-
-                data = ((m_Vram->GetU8(real_x, real_y) & 0xf0) >> 4) + clut_x;
-                col = m_Vram->GetU16(data * 2, clut_y);
-
-                color.r = ( ( col       ) & 31 ) * 255 / 31;
-                color.g = ( ( col >>  5 ) & 31 ) * 255 / 31;
-                color.b = ( ( col >> 10 ) & 31 ) * 255 / 31;
-                if( data >= clut_start && data < clut_start + clut_width )
-                {
-                    GetModifiedClut( color, mod_type, mod_r, mod_g, mod_b );
-                }
-                stp = ( col & 0x80 ) >> 15;
-
-                if( col == 0x0000 )
-                {
-                    color.a = 0;
-                }
-                else if( stp == 1 && color.r == 0 && color.g == 0 && color.b == 0 )
-                {
-                    color.a = 255;
-                }
-                else if( stp == 1 && ( color.r != 0 || color.g != 0 || color.b != 0 ) )
-                {
-                    color.a = 127;
-                }
-                else if( stp == 0 && ( color.r != 0 || color.g != 0 || color.b != 0 ) )
-                {
-                    color.a = 255;
-                }
-
-                memcpy( ret->pixels.data() + x * 8 + ret->width * 4 * y + 0x04, &color, sizeof( ClutColor ) );
-            }
-        }
-    }
-
-
-
-    else if( bpp == 1 )
-    {
-        for( int y = 0; y < 256; ++y )
-        {
-            for( int x = 0; x < size_x; ++x )
-            {
-                u16 real_x = mImageVramPositionX + page_x * 128 + x;
-                u16 real_y = mImageVramPositionY + page_y * 256 + y;
-
-                u8 data = m_Vram->GetU8(real_x, real_y);
-                u16 col = m_Vram->GetU16(data * 2 + clut_x * 2, clut_y);
-
-                color.r = ( ( col       ) & 31 ) * 255 / 31;
-                color.g = ( ( col >>  5 ) & 31 ) * 255 / 31;
-                color.b = ( ( col >> 10 ) & 31 ) * 255 / 31;
-                if( data >= clut_start && data < clut_start + clut_width )
-                {
-                    GetModifiedClut( color, mod_type, mod_r, mod_g, mod_b );
-                }
-
-                u8 stp = ( col & 0x8000 ) >> 15;
-
-                if( col == 0x0000 )
-                {
-                    color.a = 0;
-                }
-                else if( stp == 1 && color.r == 0 && color.g == 0 && color.b == 0 )
-                {
-                    color.a = 255;
-                }
-                else if( stp == 1 && ( color.r != 0 || color.g != 0 || color.b != 0 ) )
-                {
-                    color.a = 127;
-                }
-                else if( stp == 0 && ( color.r != 0 || color.g != 0 || color.b != 0 ) )
-                {
-                    color.a = 255;
-                }
-
-                memcpy( ret->pixels.data() + x * 4 + ret->width * 4 * y, &color, sizeof( ClutColor ) );
-            }
-        }
-    }
-
-
-
-    else if ( bpp == 2 )
-    {
-        for( int y = 0; y < 256; ++y )
-        {
-            for( int x = 0; x < 256; ++x )
-            {
-                u16 real_x = mImageVramPositionX + page_x * 128 + x * 2;
-                u16 real_y = mImageVramPositionY + page_y * 256 + y;
-
-                u16 col = m_Vram->GetU16(real_x, real_y);
-
-                color.r = ( ( col       ) & 31 ) * 255 / 31;
-                color.g = ( ( col >>  5 ) & 31 ) * 255 / 31;
-                color.b = ( ( col >> 10 ) & 31 ) * 255 / 31;
-
-                if( col == 0x0000 )
-                {
-                    color.a = 0;
-                }
-                else
-                {
-                    color.a = 255;
-                }
-
-                memcpy( ret->pixels.data() + x * 4 + ret->width * 4 * y, &color, sizeof( ClutColor ) );
-            }
-        }
-    }
-
-    return ret;
-}
-
-
-
-void
-MimFile::InnerGetImage()
-{
-    // get number of clut
-    MimHeader* mim_header = ( MimHeader* )buffer_;
-
-    mClutVramPositionX = mim_header->x;
-    mClutVramPositionY = mim_header->y;
-    mClutWidth         = mim_header->width;
-    mClutHeight        = mim_header->height;
-
-    for( int y = 0; y < mClutHeight; ++y )
-    {
-        for( int x = 0; x < mClutWidth; ++x )
-        {
-            u16 color = GetU16LE( sizeof( MimHeader ) + y * mClutWidth * 2 + x * 2 );
-            m_Vram->PutU16(x * 2 + mClutVramPositionX, y + mClutVramPositionY, color);
-        }
-    }
-
-
-
-    // set image buffer
-    MimHeader2* mim_header2 = ( MimHeader2* )( ( u8* )buffer_ + mim_header->header2_offset );
-    mImageVramPositionX = mim_header2->x * 2;
-    mImageVramPositionY = mim_header2->y;
-    mImageWidth         = mim_header2->width * 2;
-    mImageHeight        = mim_header2->height;
-
-    for( int y = 0; y < mImageHeight; ++y )
-    {
-        for( int x = 0; x < mImageWidth; ++x )
-        {
-            u8 data = GetU8( mim_header->header2_offset + sizeof( MimHeader2 ) + y * mImageWidth + x );
-            m_Vram->PutU8( x + mImageVramPositionX, y + mImageVramPositionY, data );
-        }
-    }
-
-
-
-    // add to image buffer
-    u32 data_3_offset = mim_header->header2_offset + mim_header2->data_size;
-
-    if( buffer_size_ > data_3_offset )
-    {
-        MimHeader2* mim_header3 = ( MimHeader2* )( ( u8* )buffer_ + data_3_offset );
-
-        if (mim_header3->data_size > 0)
-        {
-            u16 image_vram_position_x = mim_header3->x * 2;
-            u16 image_vram_position_y = mim_header3->y;
-            u16 image_width           = mim_header3->width * 2;
-            u16 image_height          = mim_header3->height;
-
-            for( int y = 0; y < image_height; ++y )
-            {
-                for( int x = 0; x < image_width; ++x )
-                {
-                    u8 data = GetU8( data_3_offset + sizeof( MimHeader2 ) + y * image_width + x );
-                    m_Vram->PutU8(x + image_vram_position_x, y + image_vram_position_y, data);
-                }
-            }
-
-            // update image size
-            u16 first_end_x     = mImageVramPositionX + mImageWidth;
-            u16 second_end_x    = image_vram_position_x + image_width;
-            u16 min_start_x     = ( mImageVramPositionX < image_vram_position_x ) ? mImageVramPositionX : image_vram_position_x;
-            u16 max_end_x       = ( first_end_x > second_end_x ) ? first_end_x : second_end_x;
-
-            mImageVramPositionX = min_start_x;
-            mImageWidth         = max_end_x - min_start_x;
-
-            u16 first_end_y     = mImageVramPositionY + mImageHeight;
-            u16 second_end_y    = image_vram_position_y + image_height;
-            u16 min_start_y     = (mImageVramPositionY < image_vram_position_y) ? mImageVramPositionY : image_vram_position_y;
-            u16 max_end_y       = (first_end_y > second_end_y) ? first_end_y : second_end_y;
-
-            mImageVramPositionY = min_start_y;
-            mImageHeight        = max_end_y - min_start_y;
-        }
-    }
-
-    mImageVramPositionX = 0;
-    mImageVramPositionY = 0;
-    mImageWidth  = 2048;
-    mImageHeight = 512;
-
-    //m_Vram.Save( "export" );
-}
-
-
-
-void
-MimFile::GetModifiedClut( MimFile::ClutColor& clut, const Ogre::String& mod_type, const float mod_r, const float mod_g, const float mod_b )
-{
-    if( mod_type == "mult" )
-    {
-        if( clut.r * mod_r >= 256 )
-        {
-            clut.r = 255;
-        }
-        else if( clut.r * mod_r < 0 )
-        {
-            clut.r = 0;
-        }
-        else
-        {
-            clut.r *= u8(mod_r);
-        }
-
-        if( clut.g * mod_g >= 256 )
-        {
-            clut.g = 255;
-        }
-        else if(clut.g * mod_g < 0 )
-        {
-            clut.g = 0;
-        }
-        else
-        {
-            clut.g *= u8(mod_g);
-        }
-
-        if( clut.b * mod_b >= 256 )
-        {
-            clut.b = 255;
-        }
-        else if( clut.b * mod_b < 0 )
-        {
-            clut.b = 0;
-        }
-        else
-        {
-            clut.b *= u8(mod_b);
-        }
-    }
-    else if( mod_type == "add" )
-    {
-        if( clut.r + mod_r * 8 >= 256 )
-        {
-            clut.r = 255;
-        }
-        else if( clut.r + mod_r * 8 < 0 )
-        {
-            clut.r = 0;
-        }
-        else
-        {
-            clut.r += u8(mod_r * 8);
-        }
-
-        if( clut.g + mod_g * 8 >= 256 )
-        {
-            clut.g = 255;
-        }
-        else if( clut.g + mod_g * 8 < 0 )
-        {
-            clut.g = 0;
-        }
-        else
-        {
-            clut.g += u8(mod_g * 8);
-        }
-
-        if( clut.b + mod_b * 8 >= 256 )
-        {
-            clut.b = 255;
-        }
-        else if( clut.b + mod_b * 8 < 0 )
-        {
-            clut.b = 0;
-        }
-        else
-        {
-            clut.b += u8(mod_b * 8);
-        }
-    }
-}
-
-
-
-/*
-bool
-MimFile::ClutCheck(const u16 page_x, const u16 page_y, const u16 clut_x, const u8 bpp, const u8 src_x, const u8 src_y, const u8 width, const u8 height, const u16 check_clut_x, const u16 check_clut_width )
-{
-    if( bpp == 0 )
-    {
-        for( int y = src_y; y < src_y + height; ++y )
-        {
-            for( int x = src_x / 2; x < ( src_x + width ) / 2; ++x )
-            {
-                u16 real_x = mImageVramPositionX + page_x * 128 + x;
-                u16 real_y = mImageVramPositionY + page_y * 256 + y;
-
-                u8 data = ( m_Vram.GetU8( real_x, real_y ) & 0x0f ) * 2 + clut_x * 3;
-
-                if( data > check_clut_x + check_clut_width || data < check_clut_x )
-                {
-                    return false;
-                }
-
-                data = ( ( m_Vram.GetU8( real_x, real_y ) & 0xf0 ) >> 4 ) * 2 + clut_x * 2;
-
-                if( data > check_clut_x + check_clut_width || data < check_clut_x )
-                {
-                    return false;
-                }
-            }
-        }
-    }
-    else if( bpp == 1 )
-    {
-LOGGER->Log( "TileCompare: src_x=" + IntToString( src_x ) + " width=" + IntToString( width ) + "\n" );
-LOGGER->Log( "TileCompare: src_y=" + IntToString( src_y ) + " height=" + IntToString( height ) + "\n" );
-LOGGER->Log( "TileCompare: clut_x=" + IntToString( src_x ) + " check_clut_width=" + IntToString( check_clut_width ) + "\n" );
-
-        for( int y = src_y; y < src_y + height; ++y )
-        {
-            for( int x = src_x; x < src_x + width; ++x )
-            {
-                u16 real_x = mImageVramPositionX + page_x * 128 + x;
-                u16 real_y = mImageVramPositionY + page_y * 256 + y;
-
-                u8 data = m_Vram.GetU8( real_x, real_y );
-                u16 col = m_Vram.GetU16( data * 2 + clut_x * 2, 493 );
-LOGGER->Log( "TileCompare: x=" + IntToString( x ) + " y=" + IntToString( y ) + "\n" );
-LOGGER->Log( "TileCompare: data=0x" + HexToString( data, 2, '0' ) + " col=0x" + HexToString( col, 4, '0' ) + "\n" );
-
-                if( data >= check_clut_x + check_clut_width || data < check_clut_x )
-                {
-                    //return false;
-                }
-            }
-        }
-    }
-
-    return true;
-}
-*/

+ 0 - 66
utilities/ffvii_field_dat_dumper/src/MimFile.h

@@ -1,66 +0,0 @@
-#ifndef MIM_FILE_H
-#define MIM_FILE_H
-
-#include "common/LzsFile.h"
-#include "../../common/Vram.h"
-
-
-
-class MimFile : public LzsFile
-{
-public:
-    struct ClutColor
-    {
-        u8 r;
-        u8 g;
-        u8 b;
-        u8 a;
-    };
-
-    MimFile( const Ogre::String& file );
-    MimFile( File* pFile );
-    MimFile( File* pFile, const u32 offset, const u32 length );
-    MimFile( u8* pBuffer, const u32 offset, const u32 length );
-    virtual ~MimFile();
-    Surface* GetSurface( const u16 page_x, const u16 page_y, const u16 clut_x, const u16 clut_y, const u8 bpp, const int clut_start, const int clut_width, const Ogre::String& mod_type, const float mod_r, const float mod_g, const float mod_b );
-    void GetModifiedClut( ClutColor& clut, const Ogre::String& mod_type, const float mod_r, const float mod_g, const float mod_b );
-    //bool ClutCheck(const u16 page_x, const u16 page_y, const u16 clut_x, const u8 bpp, const u8 src_x, const u8 src_y, const u8 width, const u8 height, const u16 check_clut_x, const u16 check_clut_width );
-
-private:
-    void InnerGetImage();
-
-private:
-    struct MimHeader
-    {
-        u32 header2_offset;   /**< @brief offset for second header */
-        u16 x;                /**< @brief x position of CLUT in VRAM */
-        u16 y;                /**< @brief y position of CLUT in VRAM */
-        u16 width;            /**< @brief number of colors in CLUT */
-        u16 height;           /**< @brief number of CLUT */
-    };
-
-    struct MimHeader2
-    {
-        u32 data_size;        /**< @brief size of image data */
-        u16 x;                /**< @brief x position of image in VRAM */
-        u16 y;                /**< @brief y position of image in VRAM */
-        u16 width;            /**< @brief width of image */
-        u16 height;           /**< @brief height of image */
-    };
-
-    u16  mClutVramPositionX;
-    u16  mClutVramPositionY;
-    u16  mClutWidth;
-    u16  mClutHeight;
-
-    u16  mImageVramPositionX;
-    u16  mImageVramPositionY;
-    u16  mImageWidth;
-    u16  mImageHeight;
-
-    std::unique_ptr<Vram> m_Vram;
-};
-
-
-
-#endif

+ 0 - 60
utilities/ffvii_field_model_exporter/CMakeLists.txt

@@ -1,60 +0,0 @@
-include_directories(
-    ${CMAKE_CURRENT_SOURCE_DIR}/src
-)
-
-# define header and source files
-set(HEADER_FILES
-./src/Model.h
-./src/MeshFile.h
-./src/DatFile.h
-./src/MeshFile.cpp
-./src/AnimationFile.h
-./src/BsxFile.h
-./src/SkeletonFile.h
-./src/BcxFile.h
-./src/TdbFile.h
-)
-
-set(SOURCE_FILES
-./src/AnimationFile.cpp
-./src/DatFile.cpp
-./src/MeshFile.cpp
-./src/Model.cpp
-./src/TdbFile.cpp
-./src/BcxFile.cpp
-./src/BsxFile.cpp
-./src/Main.cpp
-./src/SkeletonFile.cpp
-)
-
-add_definitions(
-    -DQGEARS_ADD_MANAGERS
-)
-
-add_executable(ff7_field_model_exporter
-  ${HEADER_FILES}
-  ${SOURCE_FILES}
-)
-SET_PROPERTY(TARGET ff7_field_model_exporter PROPERTY FOLDER "utilities")
-
-if (APPLE)
-target_link_libraries(ff7_field_model_exporter "-framework CoreFoundation -framework Cocoa -framework IOKit")
-endif()
-
-if(WIN32)
-  set_target_properties(ff7_field_model_exporter PROPERTIES WIN32_EXECUTABLE ON)
-  if (MSVC)
-    set_target_properties(ff7_field_model_exporter PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
-  endif()
-endif()
-
-set(LIBRARIES
-    Utility
-    QGearsMain
-    v-gears-data
-)
-target_link_libraries(ff7_field_model_exporter    ${LIBRARIES})
-
-install(TARGETS ff7_field_model_exporter
-    DESTINATION tools/ff7
-)

+ 0 - 215
utilities/ffvii_field_model_exporter/src/AnimationFile.cpp

@@ -1,215 +0,0 @@
-#include "../../common/Logger.h"
-#include "AnimationFile.h"
-
-
-
-AnimationFile::AnimationFile(const Ogre::String& file):
-    File(file)
-{
-}
-
-
-
-AnimationFile::AnimationFile(File* pFile):
-    File(pFile)
-{
-}
-
-
-
-AnimationFile::AnimationFile(File* pFile, const u32 offset, const u32 length):
-    File(pFile, offset, length)
-{
-}
-
-
-
-AnimationFile::AnimationFile(u8* pBuffer, const u32 offset, const u32 length):
-    File(pBuffer, offset, length)
-{
-}
-
-
-
-AnimationFile::~AnimationFile()
-{
-}
-
-
-
-void
-AnimationFile::GetData( std::vector< s16 >& skeleton_length, const Unit& unit, const int offset_to_animations, const int number_of_animation, const int start_animation, Ogre::SkeletonPtr skeleton)
-{
-    for (int i = 0; i < number_of_animation; ++i)
-    {
-        /*LOGGER->Log(LOGGER_INFO, "Animation Header %02x%02x %02x %02x %02x %02x %02x%02x %02x%02x %02x%02x %02x%02x%02x%02x",
-                    GetU8(offset_to_animations + i * 0x10 + 0x00), GetU8(offset_to_animations + i * 0x10 + 0x01), GetU8(offset_to_animations + i * 0x10 + 0x02), GetU8(offset_to_animations + i * 0x10 + 0x03),
-                    GetU8(offset_to_animations + i * 0x10 + 0x04), GetU8(offset_to_animations + i * 0x10 + 0x05), GetU8(offset_to_animations + i * 0x10 + 0x06), GetU8(offset_to_animations + i * 0x10 + 0x07),
-                    GetU8(offset_to_animations + i * 0x10 + 0x08), GetU8(offset_to_animations + i * 0x10 + 0x09), GetU8(offset_to_animations + i * 0x10 + 0x0A), GetU8(offset_to_animations + i * 0x10 + 0x0B),
-                    GetU8(offset_to_animations + i * 0x10 + 0x0C), GetU8(offset_to_animations + i * 0x10 + 0x0D), GetU8(offset_to_animations + i * 0x10 + 0x0E), GetU8(offset_to_animations + i * 0x10 + 0x0F));
-        */
-        AnimationHeader header;
-        header.number_of_frames                  = GetU16LE(offset_to_animations + i * 0x10 + 0x00);
-        header.number_of_bones                   = GetU8(offset_to_animations + i * 0x10 + 0x02);
-        header.number_of_frames_translation      = GetU8(offset_to_animations + i * 0x10 + 0x03);
-        header.number_of_static_translation      = GetU8(offset_to_animations + i * 0x10 + 0x04);
-        header.number_of_frames_rotation         = GetU8(offset_to_animations + i * 0x10 + 0x05);
-        header.offset_to_frames_translation_data = GetU16LE(offset_to_animations + i * 0x10 + 0x06);
-        header.offset_to_static_translation_data = GetU16LE(offset_to_animations + i * 0x10 + 0x08);
-        header.offset_to_frames_rotation_data    = GetU16LE(offset_to_animations + i * 0x10 + 0x0A);
-        header.offset_to_animation_data          = GetU32LE(offset_to_animations + i * 0x10 + 0x0C) - 0x80000000;
-        m_AnimationHeaders.push_back(header);
-    }
-
-    for (size_t i = 0; (i < static_cast<size_t>(number_of_animation)) && (start_animation + i < unit.animations.size()); ++i)
-    {
-        if (unit.animations[start_animation + i] == "" || unit.animations[start_animation + i] == " ")
-        {
-            continue;
-        }
-
-        /*
-        File file(mpBuffer, m_AnimationHeaders[i].offset_to_animation_data, 0x04 + m_AnimationHeaders[i].number_of_bones * 0x08 + m_AnimationHeaders[i].number_of_frames_translation * m_AnimationHeaders[i].number_of_frames * 0x02 + m_AnimationHeaders[i].number_of_static_translation * 0x02 + m_AnimationHeaders[i].number_of_frames_rotation * m_AnimationHeaders[i].number_of_frames);
-        file.WriteFile(RString((Ogre::String("dump/") + Ogre::String("animation_") + Ogre::StringConverter::toString(i) + Ogre::String("_data")).c_str()));
-        */
-
-        Ogre::Animation* anim = skeleton->createAnimation(unit.animations[start_animation + i], (float)(m_AnimationHeaders[i].number_of_frames - 1) / 30.0f);
-
-        for (u32 j = 0; j < m_AnimationHeaders[i].number_of_frames; ++j)
-        {
-            Frame frame;
-
-            // root bone
-            Ogre::Bone* root = skeleton->getBone(0);
-
-            Ogre::NodeAnimationTrack* track;
-            if (j == 0)
-            {
-                track = anim->createNodeTrack(0, root);
-                track->removeAllKeyFrames();
-            }
-            else
-            {
-                track = anim->getNodeTrack(0);
-            }
-
-            Ogre::TransformKeyFrame* frame_root = track->createNodeKeyFrame((float)j / 30.0f);
-
-            Ogre::Quaternion rot;
-            Ogre::Matrix3 mat;
-            mat.FromEulerAnglesZXY(Ogre::Radian(Ogre::Degree(180)), Ogre::Radian(Ogre::Degree(0)), Ogre::Radian(Ogre::Degree(0)));
-            rot.FromRotationMatrix(mat);
-            frame_root->setRotation(rot);
-
-            for (u32 k = 0; k < m_AnimationHeaders[i].number_of_bones; ++k)
-            {
-                BonePosition position;
-
-                u8 flag = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x00);
-
-                u8 rx = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x01);
-                u8 ry = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x02);
-                u8 rz = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x03);
-                u8 tx = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x04);
-                u8 ty = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x05);
-                u8 tz = GetU8(m_AnimationHeaders[i].offset_to_animation_data + 0x04 + k * 0x08 + 0x06);
-
-                // rotation
-                if (flag & 0x01)
-                {
-                    position.rotation_x = 360.0f * GetU8(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_frames_rotation_data + rx * m_AnimationHeaders[i].number_of_frames + j) / 255.0f;
-                }
-                else
-                {
-                    position.rotation_x = 360.0f * rx / 255.0f;
-                }
-
-                if (flag & 0x02)
-                {
-                    position.rotation_y = 360.0f * GetU8(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_frames_rotation_data + ry * m_AnimationHeaders[i].number_of_frames + j) / 255.0f;
-                }
-                else
-                {
-                    position.rotation_y = 360.0f * ry / 255.0f;
-                }
-
-                if (flag & 0x04)
-                {
-                    position.rotation_z = 360.0f * GetU8(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_frames_rotation_data + rz * m_AnimationHeaders[i].number_of_frames + j) / 255.0f;
-                }
-                else
-                {
-                    position.rotation_z = 360.0f * rz / 255.0f;
-                }
-
-                // translation
-                position.translation_x = 0;
-                position.translation_y = 0;
-                position.translation_z = 0;
-
-                if (flag & 0x10)
-                {
-                    position.translation_x = static_cast<float>( -(s16)GetU16LE(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_frames_translation_data + tx * m_AnimationHeaders[i].number_of_frames * 2 + j * 2));
-                }
-                else if (tx != 0xFF)
-                {
-                    position.translation_x = static_cast<float>(-(s16)GetU16LE(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_static_translation_data + tx * 2));
-                }
-
-                if (flag & 0x20)
-                {
-                    position.translation_y = static_cast<float>(-(s16)GetU16LE(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_frames_translation_data + ty * m_AnimationHeaders[i].number_of_frames * 2 + j * 2));
-                }
-                else if (ty != 0xFF)
-                {
-                    position.translation_y = static_cast<float>(-(s16)GetU16LE(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_static_translation_data + ty * 2));
-                }
-
-                if (flag & 0x40)
-                {
-                    position.translation_z = static_cast<float>(-(s16)GetU16LE(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_frames_translation_data + tz * m_AnimationHeaders[i].number_of_frames * 2 + j * 2));
-                }
-                else if (tz != 0xFF)
-                {
-                    position.translation_z = static_cast<float>(-(s16)GetU16LE(m_AnimationHeaders[i].offset_to_animation_data + m_AnimationHeaders[i].offset_to_static_translation_data + tz * 2));
-                }
-
-                //LOGGER->Log(LOGGER_INFO, "%d %d", m_AnimationHeaders[i].number_of_frames, j);
-                //LOGGER->Log(LOGGER_INFO, "animation (%f %f %f) (%f %f %f)", position.rotation_x, position.rotation_y, position.rotation_z, position.translation_x, position.translation_y, position.translation_z);
-
-                frame.bone.push_back(position);
-
-                Ogre::Bone* bone1 = skeleton->getBone(k * 2 + 1);
-                Ogre::Bone* bone2 = skeleton->getBone(k * 2 + 2);
-
-                Ogre::NodeAnimationTrack* track1;
-                Ogre::NodeAnimationTrack* track2;
-                if (j == 0)
-                {
-                    track1 = anim->createNodeTrack(k * 2 + 1, bone1);
-                    track1->removeAllKeyFrames();
-                    track2 = anim->createNodeTrack(k * 2 + 2, bone2);
-                    track2->removeAllKeyFrames();
-                }
-                else
-                {
-                    track1 = anim->getNodeTrack(k * 2 + 1);
-                    track2 = anim->getNodeTrack(k * 2 + 2);
-                }
-
-                Ogre::TransformKeyFrame* frame1 = track1->createNodeKeyFrame((float)j / 30.0f);
-                Ogre::TransformKeyFrame* frame2 = track2->createNodeKeyFrame((float)j / 30.0f);
-
-                float length = skeleton_length[ k ];
-
-                frame1->setTranslate(Ogre::Vector3(position.translation_x, position.translation_z - length, position.translation_y) / 1024);
-
-                Ogre::Quaternion rot;
-                Ogre::Matrix3 mat;
-                mat.FromEulerAnglesZXY(Ogre::Radian(Ogre::Degree(-position.rotation_y)), Ogre::Radian(Ogre::Degree(-position.rotation_x)), Ogre::Radian(Ogre::Degree(-position.rotation_z)));
-                rot.FromRotationMatrix(mat);
-                frame2->setRotation(rot);
-            }
-        }
-    }
-}

+ 0 - 63
utilities/ffvii_field_model_exporter/src/AnimationFile.h

@@ -1,63 +0,0 @@
-#ifndef ANIMATION_FILE_H
-#define ANIMATION_FILE_H
-
-#include <Ogre.h>
-
-#include "common/File.h"
-#include "BsxFile.h"
-
-
-
-struct BonePosition
-{
-    float rotation_x;
-    float rotation_y;
-    float rotation_z;
-
-    float translation_x;
-    float translation_y;
-    float translation_z;
-};
-
-
-
-struct Frame
-{
-    std::vector<BonePosition> bone;
-};
-
-
-
-class AnimationFile : public File
-{
-public:
-    explicit     AnimationFile(const Ogre::String& file);
-    explicit     AnimationFile(File* pFile);
-                 AnimationFile(File* pFile, const u32 offset, const u32 length);
-                 AnimationFile(u8* pBuffer, const u32 offset, const u32 length);
-    virtual     ~AnimationFile();
-
-    void         GetData( std::vector< s16 >& skeleton_length, const Unit& unit, const int offset_to_animations, const int number_of_animation, const int start_animation, Ogre::SkeletonPtr skeleton );
-
-private:
-    struct AnimationHeader
-    {
-        u16 number_of_frames;                  // 00-01
-        u16 number_of_bones;                   // 02
-        u16 number_of_frames_translation;      // 03
-        u16 number_of_static_translation;      // 04
-        u16 number_of_frames_rotation;         // 05
-        u16 offset_to_frames_translation_data; // 06-07
-        u16 offset_to_static_translation_data; // 08-09
-        u16 offset_to_frames_rotation_data;    // 0A-0B
-        u32 offset_to_animation_data;          // 0C-0F
-    };
-
-    typedef std::vector<AnimationHeader> AnimationHeaders;
-
-    AnimationHeaders m_AnimationHeaders;
-};
-
-
-
-#endif // ANIMATION_FILE_H

+ 0 - 95
utilities/ffvii_field_model_exporter/src/BcxFile.cpp

@@ -1,95 +0,0 @@
-#include <Ogre.h>
-#include <math.h>
-#include <vector>
-
-#include "../../common/Logger.h"
-
-#include "AnimationFile.h"
-#include "BcxFile.h"
-#include "MeshFile.h"
-#include "SkeletonFile.h"
-
-
-
-BcxFile::BcxFile(const Ogre::String& file):
-    LzsFile(file)
-{
-}
-
-
-
-BcxFile::BcxFile(File *file, const u32 offset, const u32 length):
-    LzsFile(file, offset, length)
-{
-}
-
-
-
-BcxFile::BcxFile(u8* buffer, const u32 offset, const u32 length):
-    LzsFile(buffer, offset, length)
-{
-}
-
-
-
-BcxFile::BcxFile(File *file):
-    LzsFile(file)
-{
-}
-
-
-
-BcxFile::~BcxFile()
-{
-}
-
-
-
-void
-BcxFile::GetModel( std::vector< s16 >& skeleton_length, const Unit& unit, Ogre::MeshPtr mesh, Ogre::SkeletonPtr skeleton, VectorTexForGenBsx& textures )
-{
-    u32 offset_to_model_info = GetU32LE(0x04);
-
-    u8 number_of_bones      = GetU8(offset_to_model_info + 0x02);
-    u8 number_of_parts      = GetU8(offset_to_model_info + 0x03);
-    u8 number_of_animations = GetU8(offset_to_model_info + 0x04);
-
-    //////////////////////////
-    // mesh
-    //////////////////////////
-    u16 offset_to_parts = GetU16LE(offset_to_model_info + 0x1c) + number_of_bones * 4;
-    MeshFile file_m(this);
-    file_m.GetData(unit.name, offset_to_parts, number_of_parts, mesh, textures);
-    //////////////////////////
-
-    //////////////////////////
-    // skeleton
-    //////////////////////////
-    u16 offset_to_bones = GetU16LE(offset_to_model_info + 0x1C);
-    SkeletonFile file_s(this);
-    file_s.GetData( skeleton_length, offset_to_bones, number_of_bones, skeleton );
-    //////////////////////////
-
-    ///////////////////////////////////////////////////
-    // animations
-    ///////////////////////////////////////////////////
-    u32 offset_to_animations = GetU32LE(offset_to_model_info + 0x1C) - 0x80000000 + number_of_bones * 4 + number_of_parts * 0x20;
-
-    AnimationFile afile(this);
-    afile.GetData( skeleton_length, unit, offset_to_animations, number_of_animations, 0, skeleton );
-}
-
-
-
-void
-BcxFile::GetSkeleton( std::vector< s16 >& skeleton_length )
-{
-    u32 offset_to_model_info = GetU32LE(0x04);
-
-    u8 number_of_bones  = GetU8(offset_to_model_info + 0x02);
-    u16 offset_to_bones = GetU16LE(offset_to_model_info + 0x1C);
-    SkeletonFile file_s(this);
-    Ogre::SkeletonPtr skeleton;
-    skeleton.reset();
-    file_s.GetData( skeleton_length, offset_to_bones, number_of_bones, skeleton);
-}

+ 0 - 26
utilities/ffvii_field_model_exporter/src/BcxFile.h

@@ -1,26 +0,0 @@
-#ifndef BCX_FILE_H
-#define BCX_FILE_H
-
-
-
-#include "BsxFile.h"
-#include "common/LzsFile.h"
-
-
-
-class BcxFile : public LzsFile
-{
-public:
-    explicit BcxFile(const Ogre::String& file);
-    explicit BcxFile(File* file);
-             BcxFile(File* file, const u32 offset, const u32 length);
-             BcxFile(u8* buffer, const u32 offset, const u32 length);
-    virtual ~BcxFile(void);
-
-    void GetModel( std::vector< s16 >& skeleton_length, const Unit& unit, Ogre::MeshPtr mesh, Ogre::SkeletonPtr skeleton, VectorTexForGenBsx& textures );
-    void GetSkeleton( std::vector< s16 >& skeleton_length );
-};
-
-
-
-#endif // BCX_FILE_h

+ 0 - 329
utilities/ffvii_field_model_exporter/src/BsxFile.cpp

@@ -1,329 +0,0 @@
-#include <Ogre.h>
-
-#include "../../common/Logger.h"
-
-#include "BsxFile.h"
-#include "BcxFile.h"
-#include "TdbFile.h"
-#include "AnimationFile.h"
-#include "MeshFile.h"
-#include "SkeletonFile.h"
-
-
-
-BsxFile::BsxFile(const Ogre::String& file):
-LzsFile(file), m_Vram(Vram::MakeInstance())
-{
-    ReadBSXTextureToVram();
-}
-
-
-
-BsxFile::BsxFile(File* pFile):
-LzsFile(pFile), m_Vram(Vram::MakeInstance())
-{
-    ReadBSXTextureToVram();
-}
-
-
-
-BsxFile::BsxFile(File* pFile, const u32 offset, const u32 length):
-LzsFile(pFile, offset, length), m_Vram(Vram::MakeInstance())
-{
-    ReadBSXTextureToVram();
-}
-
-
-
-BsxFile::BsxFile(u8* pBuffer, const u32 offset, const u32 length):
-LzsFile(pBuffer, offset, length), m_Vram(Vram::MakeInstance())
-{
-    ReadBSXTextureToVram();
-}
-
-
-
-BsxFile::~BsxFile()
-{
-}
-
-
-
-Ogre::Entity*
-BsxFile::GetModel( Ogre::Entity* entity, const s8 character_id, const Unit& unit, const DatModelData dat )
-{
-    int start_animation = ( dat.global_model_id > 0 ) ? 3 : 0;
-    u32 offset_to_models_description = GetU32LE( 0x04 );
-    s32 number_of_models_description = GetU32LE( offset_to_models_description + 0x04 );
-
-    if( character_id >= number_of_models_description )
-    {
-        return NULL;
-    }
-
-    u32 offset_to_field_model_description = offset_to_models_description + 0x10 + character_id * 0x30;
-    //LOGGER->Log(LOGGER_INFO, "\n\noffset_to_field_model_description: %08x", offset_to_field_model_description);
-
-    u8 number_of_bones      = GetU8(offset_to_field_model_description + 0x17);
-    u8 number_of_parts      = GetU8(offset_to_field_model_description + 0x23);
-    u8 number_of_animations = GetU8(offset_to_field_model_description + 0x2f);
-    //LOGGER->Log(LOGGER_INFO, "number of bones %02x", number_of_bones);
-    //LOGGER->Log(LOGGER_INFO, "number of parts %02x", number_of_parts);
-    //LOGGER->Log(LOGGER_INFO, "number of animations %02x", number_of_animations);
-
-    VectorTexForGenBsx textures;
-    std::vector< s16 > skeleton_length;
-
-    Ogre::MeshPtr mesh;
-    Ogre::SkeletonPtr skeleton;
-
-    if (entity == NULL)
-    {
-        mesh     = Ogre::MeshManager::getSingleton().create( "export" + unit.name, "General" );
-        skeleton = Ogre::SkeletonManager::getSingleton().create( "export" + unit.name, "General" );
-
-        switch (dat.global_model_id)
-        {
-            case 1:
-            {
-                BcxFile file( "data/field/cloud.bcx" );
-                file.GetModel(skeleton_length, unit, mesh, skeleton, textures);
-            }
-            break;
-
-            case 3:
-            {
-                BcxFile file( "data/field/ballet.bcx" );
-                file.GetModel(skeleton_length, unit, mesh, skeleton, textures);
-            }
-            break;
-
-            case 4:
-            {
-                BcxFile file( "data/field/tifa.bcx" );
-                file.GetModel(skeleton_length, unit, mesh, skeleton, textures);
-            }
-            break;
-
-            case 7:
-            {
-                BcxFile file( "data/field/yufi.bcx" );
-                file.GetModel(skeleton_length, unit, mesh, skeleton, textures);
-            }
-            break;
-
-            default:
-            {
-                // mesh
-                u32 offset_to_parts = offset_to_field_model_description + GetU32LE(offset_to_field_model_description + 0x4) + number_of_bones * 4;
-                MeshFile file_m(this);
-                file_m.GetData(unit.name, offset_to_parts, number_of_parts, mesh, textures);
-
-                // skeleton
-                u32 offset_to_bones = offset_to_field_model_description + GetU16LE(offset_to_field_model_description + 0x4);
-                SkeletonFile file_s(this);
-                file_s.GetData(skeleton_length, offset_to_bones, number_of_bones, skeleton);
-            }
-        }
-    }
-    else
-    {
-        skeleton = Ogre::SkeletonManager::getSingleton().getByName(entity->getSkeleton()->getName());
-
-        switch( dat.global_model_id )
-        {
-            case 1:
-            {
-                BcxFile file( "data/field/cloud.bcx" );
-                file.GetSkeleton( skeleton_length );
-            }
-            break;
-
-            case 3:
-            {
-                BcxFile file( "data/field/ballet.bcx" );
-                file.GetSkeleton( skeleton_length );
-            }
-            break;
-
-            case 4:
-            {
-                BcxFile file( "data/field/tifa.bcx" );
-                file.GetSkeleton( skeleton_length );
-            }
-            break;
-
-            case 7:
-            {
-                BcxFile file( "data/field/yufi.bcx" );
-                file.GetSkeleton( skeleton_length );
-            }
-            break;
-
-            default:
-            {
-                // skeleton
-                u32 offset_to_bones = offset_to_field_model_description + GetU16LE( offset_to_field_model_description + 0x4 );
-                SkeletonFile file_s( this );
-                Ogre::SkeletonPtr null_skeleton;
-                null_skeleton.reset();
-                file_s.GetData( skeleton_length, offset_to_bones, number_of_bones, null_skeleton );
-            }
-        }
-    }
-
-
-
-    // animations
-    u32 offset_to_animations = offset_to_field_model_description + GetU16LE(offset_to_field_model_description + 0x4) + number_of_bones * 4 + number_of_parts * 0x20;
-    AnimationFile file( this );
-    file.GetData( skeleton_length, unit, offset_to_animations, number_of_animations, start_animation, skeleton );
-
-
-
-    Ogre::SkeletonSerializer skeleton_serializer;
-    skeleton_serializer.exportSkeleton( skeleton.getPointer(), "exported/models/ffvii/field/units/" + unit.name + ".skeleton" );
-
-    if( entity == NULL )
-    {
-        // Update bounds
-        Ogre::AxisAlignedBox aabb( -999, -999, -999, 999, 999, 999 );
-        mesh->_setBounds( aabb, false );
-        mesh->_setBoundingSphereRadius( 999 );
-
-        mesh->setSkeletonName( "models/ffvii/field/units/" + unit.name + ".skeleton" );
-
-        Ogre::MeshSerializer ser;
-        ser.exportMesh( mesh.getPointer(), "exported/models/ffvii/field/units/" + unit.name + ".mesh" );
-
-
-
-        // create and export textures for model
-        CreateTexture( unit.name, dat.face_id, textures );
-
-
-
-        Ogre::MaterialPtr material = Ogre::MaterialManager::getSingleton().create( "ffvii/model/field/" + unit.name, "General" );
-        Ogre::Technique* tech = material->getTechnique( 0 );
-        Ogre::Pass* pass1 = tech->getPass( 0 );
-        pass1->setVertexColourTracking( Ogre::TVC_AMBIENT );
-        pass1->setCullingMode( Ogre::CULL_NONE );
-        Ogre::Pass* pass2 = tech->createPass();
-        pass2->setCullingMode( Ogre::CULL_NONE );
-        pass2->setAlphaRejectFunction( Ogre::CMPF_GREATER );
-        pass2->setAlphaRejectValue( 0 );
-        Ogre::TextureUnitState* tex = pass2->createTextureUnitState();
-        /*
-        if( dat.face_id != 0x21 )
-        {
-            tex->setTextureScroll( 0.0625 * 2, 0 );
-        }
-        */
-        tex->setTextureName( "models/ffvii/field/units/" + unit.name + ".png" );
-        tex->setNumMipmaps( 0 );
-        tex->setTextureFiltering( Ogre::TFO_NONE );
-        Ogre::MaterialSerializer mat;
-        mat.exportMaterial( material, "exported/models/ffvii/field/units/" + unit.name + ".material" );
-
-
-
-        Ogre::SceneManager* scene_manager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
-        Ogre::Entity* thisEntity = scene_manager->createEntity( unit.name, "models/ffvii/field/units/" + unit.name + ".mesh" );
-        //thisEntity->setDisplaySkeleton(true);
-        //thisEntity->setDebugDisplayEnabled(true);
-        thisEntity->setVisible( false );
-        thisEntity->getAnimationState( "Idle" )->setEnabled( true );
-        thisEntity->getAnimationState( "Idle" )->setLoop( true );
-        Ogre::SceneNode* thisSceneNode = scene_manager->getRootSceneNode()->createChildSceneNode();
-        thisSceneNode->setPosition( 0, 0, 0 );
-        thisSceneNode->roll( Ogre::Radian( Ogre::Degree( 180.0f ) ) );
-        thisSceneNode->yaw( Ogre::Radian( Ogre::Degree( 120.0f ) ) );
-        thisSceneNode->pitch( Ogre::Radian( Ogre::Degree( 90.0f ) ) );
-        thisSceneNode->attachObject( thisEntity );
-
-        return thisEntity;
-    }
-    else
-    {
-        entity->refreshAvailableAnimationState();
-        return NULL;
-    }
-}
-
-
-
-void
-BsxFile::CreateTexture( const Ogre::String& name, const int face_id, const VectorTexForGenBsx& textures )
-{
-    int tex_width = 512;
-    int tex_height = 256;
-
-    Ogre::TexturePtr ptex;
-    Ogre::HardwarePixelBufferSharedPtr buffer;
-    ptex = Ogre::TextureManager::getSingleton().createManual( "DynaTex", "General", Ogre::TEX_TYPE_2D, tex_width, tex_height, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC );
-    buffer = ptex->getBuffer( 0, 0 );
-    buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD );
-    const Ogre::PixelBox& pb = buffer->getCurrentLock();
-
-
-
-
-    for( unsigned int i = 0; i < textures.size(); ++i )
-    {
-        // type 0x0 - eye, type 0x1 - mouth, type 0x2 - normal texture.
-        if( textures[ i ].type == 0 || textures[ i ].type == 1 )
-        {
-            TdbFile face_texture( "data/field/field.tdb" );
-            face_texture.CreateTexture( pb, face_id, textures[ i ].start_x, textures[ i ].start_y );
-        }
-        else if( textures[ i ].type == 2 )
-        {
-            CreateTextureFromVram( pb, m_Vram.get(), textures[ i ].start_x, textures[ i ].start_y, textures[ i ].palette_x, textures[ i ].palette_y, textures[ i ].texture_x, textures[ i ].texture_y, textures[ i ].bpp, true );
-        }
-    }
-
-
-
-    Ogre::Image image;
-    image.loadDynamicImage((Ogre::uchar*)pb.data, tex_width, tex_height, Ogre::PF_R8G8B8A8);
-    image.save( "exported/models/ffvii/field/units/" + name + ".png" );
-    buffer->unlock();
-
-    return;
-}
-
-
-
-void
-BsxFile::ReadBSXTextureToVram()
-{
-    u32 offset_to_models_description = GetU32LE( 0x04 );
-    u32 offset_to_texture = offset_to_models_description + GetU32LE( offset_to_models_description + 0x08 );
-
-    u32 unknown = GetU32LE( offset_to_texture + 0x04 ) & 0xffffff00;
-    //LOGGER->Log(LOGGER_INFO, "WARNING WARNING %04x", unknown);
-
-    u8 number_of_texture = GetU8( offset_to_texture + 0x04 );
-    //LOGGER->Log(LOGGER_INFO, "number_of_texture %04x", number_of_texture);
-    if( number_of_texture == 0 )
-    {
-        return;
-    }
-
-    for( int i = 0; i < number_of_texture; ++i )
-    {
-        u16 width     = GetU16LE( offset_to_texture + 0x08 + i * 0x0c + 0x00 ) * 2;
-        u16 height    = GetU16LE( offset_to_texture + 0x08 + i * 0x0c + 0x02 );
-        u16 vram_x    = GetU16LE( offset_to_texture + 0x08 + i * 0x0c + 0x04 ) * 2;
-        u16 vram_y    = GetU16LE( offset_to_texture + 0x08 + i * 0x0c + 0x06 );
-        u32 start     = offset_to_texture + GetU32LE( offset_to_texture + 0x08 + i * 0x0c + 0x08 );
-        //LOGGER->Log(LOGGER_INFO, "Store BSX texture to vram %04x %04x", vram_x, vram_y);
-        for( int y = 0; y < height; ++y )
-        {
-            for( int x = 0; x < width; ++x )
-            {
-                m_Vram->PutU8( vram_x + x, vram_y + y, GetU8( start + y * width + x ) );
-            }
-        }
-    }
-}

+ 0 - 63
utilities/ffvii_field_model_exporter/src/BsxFile.h

@@ -1,63 +0,0 @@
-#ifndef BSX_FILE_H
-#define BSX_FILE_H
-
-#include <Ogre.h>
-
-#include "DatFile.h"
-#include "common/LzsFile.h"
-#include "../../common/Vram.h"
-#include "../../common/OgreGenUtilites.h"
-
-
-
-struct Unit
-{
-    Ogre::String name;
-    std::vector<Ogre::String> animations;
-};
-
-struct Field
-{
-    Ogre::String name;
-    std::vector< Unit > units;
-};
-
-struct TexForGenBsx: TexForGen
-{
-    int type;
-
-    bool operator==( const TexForGenBsx& i ) const
-    {
-        return i.texture_x == texture_x &&
-               i.texture_y == texture_y &&
-               i.palette_y == palette_y &&
-               i.palette_x == palette_x &&
-               i.bpp       == bpp &&
-             ( i.type == type || ( i.type < 2 && type < 2 ) );
-    }
-};
-
-typedef std::vector< TexForGenBsx > VectorTexForGenBsx;
-
-
-
-class BsxFile : public LzsFile
-{
-public:
-    explicit     BsxFile(const Ogre::String& file);
-    explicit     BsxFile(File* pFile);
-                 BsxFile(File* pFile, const u32 offset, const u32 length);
-                 BsxFile(u8* pBuffer, const u32 offset, const u32 length);
-    virtual     ~BsxFile();
-
-    Ogre::Entity* GetModel(Ogre::Entity* entity, const s8 character_id, const Unit& unit, const DatModelData dat);
-    void         CreateTexture(const Ogre::String& name, const int face_id, const VectorTexForGenBsx& textures);
-    void         ReadBSXTextureToVram();
-
-private:
-    std::unique_ptr<Vram> m_Vram;
-};
-
-
-
-#endif // BSX_FILE_h

+ 0 - 62
utilities/ffvii_field_model_exporter/src/DatFile.cpp

@@ -1,62 +0,0 @@
-#include "DatFile.h"
-#include "../../common/Logger.h"
-
-
-
-DatFile::DatFile(const Ogre::String& file):
-    LzsFile(file)
-{
-}
-
-
-
-DatFile::DatFile(File *file, const u32 offset, const u32 length):
-    LzsFile(file, offset, length)
-{
-}
-
-
-
-DatFile::DatFile(u8* buffer, const u32 offset, const u32 length):
-    LzsFile(buffer, offset, length)
-{
-}
-
-
-
-DatFile::DatFile(File *file):
-    LzsFile(file)
-{
-}
-
-
-
-DatFile::~DatFile()
-{
-}
-
-
-
-void
-DatFile::GetModelData( const int model_id, DatModelData& data )
-{
-    LOGGER->Log( "\nDUMP sector 7 for model id " + HexToString( model_id, 2, '0' ) + "\n" );
-
-    // get sector 7
-    u32 offset = 0x1C + GetU32LE( 0x18 ) - GetU32LE( 0x00 ) + 4 + model_id * 8;
-
-    data.face_id = GetU8( offset + 0x00 );
-    LOGGER->Log( "face_id: 0x"  + HexToString( data.face_id, 2, '0' ) + "\n" );
-
-    data.number_of_bones = GetU8( offset + 0x01 );
-    LOGGER->Log( "number_of_bones: 0x" + HexToString( data.number_of_bones, 2, '0' ) + "\n" );
-
-    data.number_of_parts = GetU8( offset + 0x02 );
-    LOGGER->Log( "number_of_parts: 0x" + HexToString( data.number_of_parts, 2, '0' ) + "\n" );
-
-    data.number_of_animation = GetU8( offset + 0x03 );
-    LOGGER->Log( "number_of_animation: 0x" + HexToString( data.number_of_animation, 2, '0' ) + "\n" );
-
-    data.global_model_id = GetU8( offset + 0x07 );
-    LOGGER->Log( "global_model_id: 0x" + HexToString( data.global_model_id, 2, '0' ) + "\n" );
-}

+ 0 - 33
utilities/ffvii_field_model_exporter/src/DatFile.h

@@ -1,33 +0,0 @@
-#ifndef DATFILE_H
-#define DATFILE_H
-
-#include "common/LzsFile.h"
-
-
-
-struct DatModelData
-{
-    int face_id;
-    int number_of_bones;
-    int number_of_parts;
-    int number_of_animation;
-    int global_model_id;
-};
-
-
-
-class DatFile : public LzsFile
-{
-public:
-    explicit DatFile(const Ogre::String& file);
-    explicit DatFile(File* file);
-    DatFile(File* file, const u32 offset, const u32 length);
-    DatFile(u8* buffer, const u32 offset, const u32 length);
-    virtual ~DatFile();
-
-    void GetModelData( const int model_id, DatModelData& data );
-};
-
-
-
-#endif // DATFILE_H

+ 0 - 120
utilities/ffvii_field_model_exporter/src/Main.cpp

@@ -1,120 +0,0 @@
-#include <Ogre.h>
-#include "common/OgreBase.h"
-#include "common/Logger.h"
-
-#include "BsxFile.h"
-#include "DatFile.h"
-
-
-
-std::vector< Field > fields;
-
-
-
-void
-fill_names()
-{
-    Unit unit;
-    unit.name = "";
-    Field field;
-
-
-    Ogre::ConfigFile cf;
-    cf.load( "export.cfg" );
-    Ogre::ConfigFile::SectionIterator seci = cf.getSectionIterator();
-
-    while( seci.hasMoreElements() )
-    {
-        field.name = seci.peekNextKey();
-        Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext();
-
-        if( field.name != "" )
-        {
-
-            Ogre::ConfigFile::SettingsMultiMap::iterator i;
-            for( i = settings->begin(); i != settings->end(); ++i )
-            {
-                if( i->second != "" )
-                {
-                    Ogre::StringVector export_data = Ogre::StringUtil::split( i->second, ":", 1 );
-
-                    unit.name = export_data[ 0 ];
-
-                    Ogre::StringVector animations = Ogre::StringUtil::split( export_data[ 1 ], ",", 0 );
-                    //LOGGER->Log(LOGGER_INFO, "Export %s: %s", field.name.c_str(), unit.name.c_str());
-                    for( size_t i = 0; i < animations.size(); ++i )
-                    {
-                        unit.animations.push_back( animations[ i ] );
-                    }
-                }
-
-                field.units.push_back(unit);
-                unit.name = "";
-                unit.animations.clear();
-            }
-
-            //LOGGER->Log(LOGGER_INFO, "Add export field %s", field.name.c_str());
-            fields.push_back(field);
-            field.units.clear();
-        }
-    }
-}
-
-
-
-int
-main( int argc, char *argv[] )
-{
-    InitializeOgreBase( "FFVII Field Model Exporter" );
-
-
-
-    fill_names();
-
-
-
-    for( size_t f = 0; f < fields.size(); ++f )
-    {
-        BsxFile model( "data/field/" + fields[ f ].name + ".bsx" );
-        DatFile dat( "data/field/" + fields[ f ].name + ".dat" );
-
-        for( size_t i = 0; i < fields[ f ].units.size(); ++i )
-        {
-            if( fields[ f ].units[ i ].name != "" )
-            {
-                Ogre::Entity* entity = NULL;
-                for( size_t j = 0; j < entities.size(); ++j )
-                {
-                    if( fields[ f ].units[ i ].name == entities[ j ]->getName() )
-                    {
-                        entity = entities[ j ];
-                    }
-                }
-
-                DatModelData data;
-                dat.GetModelData( i, data );
-
-                Ogre::Entity* exported_entity = model.GetModel( entity, i, fields[ f ].units[ i ], data );
-
-                if( exported_entity != NULL )
-                {
-                    entities.push_back( exported_entity );
-                }
-            }
-        }
-    }
-
-    entities[ 0 ]->setVisible(true);
-
-
-
-    Ogre::Root::getSingleton().startRendering();
-
-
-
-    DeinitializeOgreBase();
-
-
-
-    return 0;
-}

+ 0 - 551
utilities/ffvii_field_model_exporter/src/MeshFile.cpp

@@ -1,551 +0,0 @@
-#include "MeshFile.h"
-
-#include "common/Logger.h"
-#include "common/OgreBase.h"
-
-float tex_width  = 512.0f;
-float tex_height = 256.0f;
-
-
-//---------------------------------------------------------------------
-MeshFile::MeshFile(const Ogre::String& file):
-    File(file)
-{
-}
-
-//---------------------------------------------------------------------
-MeshFile::MeshFile(File* pFile):
-    File(pFile)
-{
-}
-
-//---------------------------------------------------------------------
-MeshFile::MeshFile(File* pFile, const u32 offset, const u32 length):
-    File(pFile, offset, length)
-{
-}
-
-//---------------------------------------------------------------------
-MeshFile::MeshFile(u8* pBuffer, const u32 offset, const u32 length):
-    File(pBuffer, offset, length)
-{
-}
-
-//---------------------------------------------------------------------
-MeshFile::~MeshFile(void)
-{
-}
-
-//---------------------------------------------------------------------
-Ogre::ColourValue
-MeshFile::readColor( const u32 offset )
-{
-    u8 r( GetU8( offset + 0 ) )
-      ,g( GetU8( offset + 1 ) )
-      ,b( GetU8( offset + 2 ) )
-      ,a( GetU8( offset + 3 ) );
-
-    return Ogre::ColourValue( r / 255.0f, g / 255.0f, b / 255.0f, a / 255.0f );
-}
-
-//---------------------------------------------------------------------
-void
-MeshFile::readQuad( const u32 offset_to_poly, std::vector<Ogre::Vector3>& vertexes, float* &pPos, u16* &index, u32 &cur_vertex, Ogre::RGBA* &curcolour_, bool multi_color )
-{
-    u8 i1( GetU8( offset_to_poly + 0x00 ) )
-      ,i2( GetU8( offset_to_poly + 0x01 ) )
-      ,i3( GetU8( offset_to_poly + 0x02 ) )
-      ,i4( GetU8( offset_to_poly + 0x03 ) );
-
-    // set vertexes
-    Ogre::Vector3 a( vertexes[ i1 ] );
-    Ogre::Vector3 b( vertexes[ i2 ] );
-    Ogre::Vector3 c( vertexes[ i3 ] );
-    Ogre::Vector3 d( vertexes[ i4 ] );
-    *pPos++ = a.x; *pPos++ = a.y; *pPos++ = a.z;
-    *pPos++ = b.x; *pPos++ = b.y; *pPos++ = b.z;
-    *pPos++ = c.x; *pPos++ = c.y; *pPos++ = c.z;
-    *pPos++ = d.x; *pPos++ = d.y; *pPos++ = d.z;
-
-    Ogre::ColourValue col_a = readColor( offset_to_poly + 0x04);
-    Ogre::ColourValue col_b = col_a;
-    Ogre::ColourValue col_c = col_a;
-    Ogre::ColourValue col_d = col_a;
-    if( multi_color ){
-        col_b = readColor( offset_to_poly + 0x08 );
-        col_c = readColor( offset_to_poly + 0x0c );
-        col_d = readColor( offset_to_poly + 0x10 );
-    };
-
-    Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
-    rs->convertColourValue( col_a, curcolour_++ );
-    rs->convertColourValue( col_b, curcolour_++ );
-    rs->convertColourValue( col_c, curcolour_++ );
-    rs->convertColourValue( col_d, curcolour_++ );
-
-    *(index++) = cur_vertex + 0;
-    *(index++) = cur_vertex + 2;
-    *(index++) = cur_vertex + 3;
-    *(index++) = cur_vertex + 3;
-    *(index++) = cur_vertex + 1;
-    *(index++) = cur_vertex + 0;
-
-    cur_vertex += 4;
-}
-
-//---------------------------------------------------------------------
-void
-MeshFile::readTriangle( const u32 offset_to_poly, std::vector<Ogre::Vector3>& vertexes, float* &pPos, u16* &index, u32 &cur_vertex, Ogre::RGBA* &curcolour_, bool multi_color )
-{
-    u8 i1( GetU8( offset_to_poly + 0x00 ) )
-      ,i2( GetU8( offset_to_poly + 0x01 ) )
-      ,i3( GetU8( offset_to_poly + 0x02 ) );
-    // set vertexes
-    Ogre::Vector3 a = vertexes[ i1 ];
-    Ogre::Vector3 b = vertexes[ i2 ];
-    Ogre::Vector3 c = vertexes[ i3 ];
-    *pPos++ = a.x; *pPos++ = a.y; *pPos++ = a.z;
-    *pPos++ = b.x; *pPos++ = b.y; *pPos++ = b.z;
-    *pPos++ = c.x; *pPos++ = c.y; *pPos++ = c.z;
-
-    Ogre::ColourValue col_a = readColor( offset_to_poly + 0x04 );
-    Ogre::ColourValue col_b = col_a;
-    Ogre::ColourValue col_c = col_a;
-    if( multi_color ){
-        col_b = readColor( offset_to_poly + 0x08);
-        col_c = readColor( offset_to_poly + 0x0c);
-    };
-
-    Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
-    rs->convertColourValue( col_a, curcolour_++ );
-    rs->convertColourValue( col_b, curcolour_++ );
-    rs->convertColourValue( col_c, curcolour_++ );
-    *(index++) = cur_vertex + 2;
-    *(index++) = cur_vertex + 1;
-    *(index++) = cur_vertex + 0;
-
-    cur_vertex += 3;
-}
-
-//---------------------------------------------------------------------
-void
-MeshFile::readPart( const Ogre::String& name, const u32 i, const u32 offset_to_part, Ogre::MeshPtr mesh, VectorTexForGenBsx& textures )
-{
-    Ogre::String material_name( "ffvii/model/field/" + name );
-    // add vertexes to array
-    u8  number_of_vertex   = GetU8(offset_to_part + 0x02);
-    u16 offset_to_vertexes = GetU16LE(offset_to_part + 0x18);
-    //LOGGER->Log(LOGGER_INFO, "number_of_vertex:    %02x", number_of_vertex);
-    std::vector<Ogre::Vector3> vertexes;
-    for (u32 j = 0; j < number_of_vertex; ++j)
-    {
-        u16 offset_to_vertex = offset_to_vertexes + j * 0x08;
-
-        Ogre::Vector3 point;
-        point.x = static_cast<float>(-( s16 )GetU16LE( offset_to_vertex + 4 + 0x00 ));
-        point.z = static_cast<float>(-(s16)GetU16LE(offset_to_vertex + 4 + 0x02));
-        point.y = static_cast<float>(-(s16)GetU16LE(offset_to_vertex + 4 + 0x04));
-        point /= 1024.0f;
-        vertexes.push_back( point );
-    }
-
-    u8 number_of_quad_t      = GetU8(offset_to_part + 0x04);
-    u8 number_of_triangle_t  = GetU8(offset_to_part + 0x05);
-    u8 number_of_quad_t2     = GetU8(offset_to_part + 0x06);
-    u8 number_of_triangle_t2 = GetU8(offset_to_part + 0x07);
-    u8 number_of_triangle_m  = GetU8(offset_to_part + 0x08);
-    u8 number_of_quad_m      = GetU8(offset_to_part + 0x09);
-    u8 number_of_triangle    = GetU8(offset_to_part + 0x0A);
-    u8 number_of_quads       = GetU8(offset_to_part + 0x0B);
-
-    size_t quad_count( number_of_quad_t
-                     + number_of_quad_t2
-                     + number_of_quad_m
-                     + number_of_quads );
-
-    size_t triangle_count( number_of_triangle_t
-                         + number_of_triangle_t2
-                         + number_of_triangle_m
-                         + number_of_triangle );
-
-    Ogre::SubMesh* sub_mesh = mesh->createSubMesh(Ogre::StringConverter::toString(i));
-    sub_mesh->setMaterialName( material_name );
-    sub_mesh->useSharedVertices = false;
-    sub_mesh->operationType = Ogre::RenderOperation::OT_TRIANGLE_LIST;
-
-    Ogre::HardwareBufferManager& buffer_manager( Ogre::HardwareBufferManager::getSingleton() );
-    // Allocate and prepare vertex data
-    sub_mesh->vertexData = new Ogre::VertexData();
-    sub_mesh->vertexData->vertexStart = 0;
-    sub_mesh->vertexData->vertexCount = triangle_count * 3 + quad_count * 4;
-    sub_mesh->indexData = new Ogre::IndexData();
-    sub_mesh->indexData->indexStart = 0;
-    sub_mesh->indexData->indexCount = triangle_count * 3 + quad_count * 6;
-    sub_mesh->indexData->indexBuffer = buffer_manager.createIndexBuffer(
-        Ogre::HardwareIndexBuffer::IT_16BIT,
-        sub_mesh->indexData->indexCount,
-        Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
-    u16* cur_index = static_cast< u16* >(sub_mesh->indexData->indexBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD));
-    u32 cur_vertex = 0;
-
-    Ogre::VertexDeclaration* decl = sub_mesh->vertexData->vertexDeclaration;
-    Ogre::VertexBufferBinding* bind = sub_mesh->vertexData->vertexBufferBinding;
-    // position buffer
-    decl->addElement(POSITION_BINDING, 0, Ogre::VET_FLOAT3, Ogre::VES_POSITION);
-    Ogre::HardwareVertexBufferSharedPtr vbuf0 = buffer_manager.createVertexBuffer(
-            decl->getVertexSize(POSITION_BINDING),
-            sub_mesh->vertexData->vertexCount,
-            Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
-    bind->setBinding(POSITION_BINDING, vbuf0);
-
-    // vertex color buffer
-    decl->addElement(COLOUR_BINDING, 0, Ogre::VET_COLOUR, Ogre::VES_DIFFUSE);
-    Ogre::HardwareVertexBufferSharedPtr vbuf1 = buffer_manager.createVertexBuffer(
-            decl->getVertexSize(COLOUR_BINDING),
-            sub_mesh->vertexData->vertexCount,
-            Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
-    // Set vertex buffer binding so buffer 1 is bound to our colour buffer
-    bind->setBinding(COLOUR_BINDING, vbuf1);
-
-    // texture coordinate buffer
-    decl->addElement(TEXTURE_BINDING, 0, Ogre::VET_FLOAT2, Ogre::VES_TEXTURE_COORDINATES, 0);
-    Ogre::HardwareVertexBufferSharedPtr vbuf2 = buffer_manager.createVertexBuffer(
-            decl->getVertexSize(TEXTURE_BINDING),
-            sub_mesh->vertexData->vertexCount,
-            Ogre::HardwareBuffer::HBU_STATIC_WRITE_ONLY);
-    bind->setBinding(TEXTURE_BINDING, vbuf2);
-
-    float* pPos   = static_cast<float*>(vbuf0->lock(Ogre::HardwareBuffer::HBL_DISCARD));
-    float* tPos   = static_cast<float*>(vbuf2->lock(Ogre::HardwareBuffer::HBL_DISCARD));
-
-    Ogre::RenderSystem* rs = Ogre::Root::getSingleton().getRenderSystem();
-    
-    std::vector<Ogre::RGBA> coloursVec(sub_mesh->vertexData->vertexCount);
-    Ogre::RGBA* colours = coloursVec.data();
-
-    Ogre::RGBA* curcolour_( colours );
-
-
-
-
-    u32 offset_to_poly           = offset_to_vertexes + GetU16LE( offset_to_part + 0x0E );
-    u32 offset_to_texture_coords = offset_to_vertexes + GetU16LE( offset_to_part + 0x10 );
-    offset_to_4                  = offset_to_vertexes + GetU16LE( offset_to_part + 0x12 );
-    offset_to_5                  = offset_to_vertexes + GetU16LE( offset_to_part + 0x14 );
-
-    // add textured quad
-    for( u32 j = 0; j < number_of_quad_t; ++j )
-    {
-        readQuad( offset_to_poly, vertexes, pPos, cur_index, cur_vertex, curcolour_, true );
-        TexForGenBsx texture;
-        AddTexture( texture, textures );
-
-        Ogre::Vector2 at;
-        Ogre::Vector2 bt;
-        Ogre::Vector2 ct;
-        Ogre::Vector2 dt;
-
-        u8 texture_coords_id = GetU8( offset_to_poly + 0x14 );
-        int x = GetU8( offset_to_texture_coords + texture_coords_id * 0x02 + 0x00 ) + texture.start_x;
-        at.x = x / tex_width;
-        int y = GetU8( offset_to_texture_coords + texture_coords_id * 0x02 + 0x01 ) + texture.start_y;
-        at.y = y / tex_height;
-
-        texture_coords_id = GetU8( offset_to_poly + 0x15 );
-        x = GetU8( offset_to_texture_coords + texture_coords_id * 0x02 + 0x00 ) + texture.start_x;
-        bt.x = x / tex_width;
-        y = GetU8( offset_to_texture_coords + texture_coords_id * 0x02 + 0x01 ) + texture.start_y;
-        bt.y = y / tex_height;
-
-        texture_coords_id = GetU8(offset_to_poly + 0x16);
-        x = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x00) + texture.start_x;
-        ct.x = x / tex_width;
-        y = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x01) + texture.start_y;
-        ct.y = y / tex_height;
-
-        texture_coords_id = GetU8(offset_to_poly + 0x17);
-        x = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x00) + texture.start_x;
-        dt.x = x / tex_width;
-        y = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x01) + texture.start_y;
-        dt.y = y / tex_height;
-
-
-        *tPos++ = at.x; *tPos++ = at.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-        *tPos++ = dt.x; *tPos++ = dt.y;
-
-        offset_to_poly += 0x18;
-    }
-
-    // add textured triangle
-    for (u32 j = 0; j < number_of_triangle_t; ++j)
-    {
-        readTriangle( offset_to_poly, vertexes, pPos, cur_index, cur_vertex, curcolour_, true );
-
-        TexForGenBsx texture;
-        AddTexture( texture, textures );
-
-        Ogre::Vector2 at;
-        Ogre::Vector2 bt;
-        Ogre::Vector2 ct;
-
-        u8 texture_coords_id = GetU8(offset_to_poly + 0x10);
-        int x = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x00) + texture.start_x;
-        at.x = x / tex_width;
-        int y = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x01) + texture.start_y;
-        at.y = y / tex_height;
-
-        texture_coords_id = GetU8(offset_to_poly + 0x11);
-        x = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x00) + texture.start_x;
-        bt.x = x / tex_width;
-        y = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x01) + texture.start_y;
-        bt.y = y / tex_height;
-
-        texture_coords_id = GetU8(offset_to_poly + 0x12);
-        x = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x00) + texture.start_x;
-        ct.x = x / tex_width;
-        y = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x01) + texture.start_y;
-        ct.y = y / tex_height;
-
-        *tPos++ = at.x; *tPos++ = at.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-
-        offset_to_poly += 0x14;
-    }
-
-    // add textured monochrome quad
-    for (u32 j = 0; j < number_of_quad_t2; ++j)
-    {
-        readQuad( offset_to_poly, vertexes, pPos, cur_index, cur_vertex, curcolour_, false );
-
-        TexForGenBsx texture;
-        AddTexture( texture, textures );
-
-        Ogre::Vector2 at;
-        Ogre::Vector2 bt;
-        Ogre::Vector2 ct;
-        Ogre::Vector2 dt;
-
-        u8 texture_coords_id = GetU8(offset_to_poly + 0x8);
-        int x = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x00) + texture.start_x;
-        at.x = x / tex_width;
-        int y = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x01) + texture.start_y;
-        at.y = y / tex_height;
-
-        texture_coords_id = GetU8(offset_to_poly + 0x9);
-        x = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x00) + texture.start_x;
-        bt.x = x / tex_width;
-        y = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x01) + texture.start_y;
-        bt.y = y / tex_height;
-
-        texture_coords_id = GetU8(offset_to_poly + 0xa);
-        x = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x00) + texture.start_x;
-        dt.x = x / tex_width;
-        y = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x01) + texture.start_y;
-        dt.y = y / tex_height;
-
-        texture_coords_id = GetU8(offset_to_poly + 0xb);
-        x = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x00) + texture.start_x;
-        ct.x = x / tex_width;
-        y = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x01) + texture.start_y;
-        ct.y = y / tex_height;
-
-        *tPos++ = at.x; *tPos++ = at.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-        *tPos++ = dt.x; *tPos++ = dt.y;
-
-        offset_to_poly += 0x0C;
-    }
-
-    // add textured monochrome triangle
-    for (u32 j = 0; j < number_of_triangle_t2; ++j)
-    {
-        readTriangle( offset_to_poly, vertexes, pPos, cur_index, cur_vertex, curcolour_, false );
-
-        TexForGenBsx texture;
-        AddTexture( texture, textures );
-
-        Ogre::Vector2 at;
-        Ogre::Vector2 bt;
-        Ogre::Vector2 ct;
-
-        u8 texture_coords_id = GetU8(offset_to_poly + 0x8);
-        int x = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x00) + texture.start_x;
-        at.x = x / tex_width;
-        int y = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x01) + texture.start_y;
-        at.y = y / tex_height;
-
-        texture_coords_id = GetU8(offset_to_poly + 0x9);
-        x = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x00) + texture.start_x;
-        bt.x = x / tex_width;
-        y = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x01) + texture.start_y;
-        bt.y = y / tex_height;
-
-        texture_coords_id = GetU8(offset_to_poly + 0xa);
-        x = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x00) + texture.start_x;
-        ct.x = x / tex_width;
-        y = GetU8(offset_to_texture_coords + texture_coords_id * 0x02 + 0x01) + texture.start_y;
-        ct.y = y / tex_height;
-
-        *tPos++ = at.x; *tPos++ = at.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-
-        offset_to_poly += 0x0C;
-    }
-
-    // add monochrome triangle
-    for (u32 j = 0; j < number_of_triangle_m; ++j)
-    {
-        readTriangle( offset_to_poly, vertexes, pPos, cur_index, cur_vertex, curcolour_, false );
-
-        Ogre::Vector2 at(0.99f, 0.99f);
-        Ogre::Vector2 bt(0.99f, 0.99f);
-        Ogre::Vector2 ct(0.99f, 0.99f);
-        *tPos++ = at.x; *tPos++ = at.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-
-        offset_to_poly += 0x08;
-    }
-
-    // add monochrome quad
-    for (u32 j = 0; j < number_of_quad_m; ++j)
-    {
-        readQuad( offset_to_poly, vertexes, pPos, cur_index, cur_vertex, curcolour_, false );
-
-        Ogre::Vector2 at(0.99f, 0.99f);
-        Ogre::Vector2 bt(0.99f, 0.99f);
-        Ogre::Vector2 ct(0.99f, 0.99f);
-        Ogre::Vector2 dt(0.99f, 0.99f);
-        *tPos++ = at.x; *tPos++ = at.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-        *tPos++ = dt.x; *tPos++ = dt.y;
-
-        offset_to_poly += 0x08;
-    }
-
-    // add color triangle
-    for (u32 j = 0; j < number_of_triangle; ++j)
-    {
-        readTriangle( offset_to_poly, vertexes, pPos, cur_index, cur_vertex, curcolour_, true );
-
-        Ogre::Vector2 at(0.99f, 0.99f);
-        Ogre::Vector2 bt(0.99f, 0.99f);
-        Ogre::Vector2 ct(0.99f, 0.99f);
-        *tPos++ = at.x; *tPos++ = at.y;
-        *tPos++ = bt.x; *tPos++ = bt.y;
-        *tPos++ = ct.x; *tPos++ = ct.y;
-
-        offset_to_poly += 0x10;
-    }
-
-    // add color quad
-    for (u32 j = 0; j < number_of_quads; ++j)
-    {
-        readQuad( offset_to_poly, vertexes, pPos, cur_index, cur_vertex, curcolour_, true );
-
-        Ogre::Vector2 a(0.99f, 0.99f);
-        Ogre::Vector2 b(0.99f, 0.99f);
-        Ogre::Vector2 c(0.99f, 0.99f);
-        Ogre::Vector2 d(0.99f, 0.99f);
-        *tPos++ = a.x; *tPos++ = a.y;
-        *tPos++ = b.x; *tPos++ = b.y;
-        *tPos++ = c.x; *tPos++ = c.y;
-        *tPos++ = d.x; *tPos++ = d.y;
-
-        offset_to_poly += 0x14;
-    }
-
-    vbuf0->unlock();
-    vbuf1->writeData(0, vbuf1->getSizeInBytes(), colours, true);
-    vbuf2->unlock();
-
-    sub_mesh->indexData->indexBuffer->unlock();
-    // Optimize index data
-    sub_mesh->indexData->optimiseVertexCacheTriList();
-
-    int vertex_number = sub_mesh->vertexData->vertexCount;
-    u8 bone_index( GetU8(offset_to_part + 0x01) );
-    //LOGGER->Log(LOGGER_INFO, "vertex_number %08x", vertex_number);
-    for (int i = 0; i < vertex_number; ++i)
-    {
-        Ogre::VertexBoneAssignment vba;
-        vba.vertexIndex = i;
-        vba.boneIndex = bone_index * 2 + 2;
-        vba.weight = 1.0f;
-        sub_mesh->addBoneAssignment(vba);
-    }
-}
-
-//---------------------------------------------------------------------
-void
-MeshFile::GetData(const Ogre::String& name, const int offset_to_parts, const int number_of_parts, Ogre::MeshPtr mesh, VectorTexForGenBsx& textures)
-{
-    int part_end( number_of_parts );
-    int part_begin = 0;
-
-    for (int i = part_begin; i < number_of_parts && i < part_end; ++i)
-    {
-        u32 offset_to_part   = offset_to_parts + i * 0x20;
-        readPart( name, i, offset_to_part, mesh, textures );
-    }
-}
-
-//---------------------------------------------------------------------
-void
-MeshFile::AddTexture( TexForGenBsx& texture, VectorTexForGenBsx& textures )
-{
-    u8 control = GetU8(offset_to_5);
-    //LOGGER->Log(LOGGER_INFO, "quad control: %02x", control);
-    ++offset_to_5;
-
-    u8 blend = ( control >> 4 ) & 0x3;
-    u8 flag_id = control & 0xf;
-    u32 flag = GetU32LE( offset_to_4 + flag_id * 4 );
-    int type = flag & 0x3f;
-    int bpp = (flag >> 0x6) & 0x3;
-    int vram_x = ((flag >> 0x8) & 0xf) * 64;
-    int vram_y = ((flag >> 0xc) & 0x1) * 256;
-    int clut_x = ((flag >> 0x10) & 0x3f) * 16;
-    int clut_y = (flag >> 0x16) & 0x1ff;
-
-    texture.texture_x = vram_x;
-    texture.texture_y = vram_y;
-    texture.palette_x = clut_x;
-    texture.palette_y = clut_y;
-    texture.bpp = ( BPP )bpp;
-    texture.type = type;
-
-    for( size_t i = 0; i < textures.size(); i++ )
-    {
-        if( texture == textures[ i ] )
-        {
-            texture.start_x = textures[ i ].start_x;
-            texture.start_y = textures[ i ].start_y;
-            return;
-        }
-    }
-
-    LOGGER->Log( "New Texture: X:0x" + HexToString( texture.texture_x, 4, '0' ) + ", Y:0x" + HexToString( texture.texture_y, 4, '0' ) + ", CLUTX:0x" + HexToString( texture.palette_x, 4, '0' ) + ", CLUTY:0x" + HexToString( texture.palette_y, 4, '0' ) + ", bpp:0x" + HexToString( texture.bpp, 2, '0' ) + ", type:0x" + HexToString( texture.type, 2, '0' ) + "\n" );
-
-    texture.start_x = 0;
-    texture.start_y = 0;
-    for (size_t i = 0; i < textures.size(); i++)
-    {
-        if (texture.start_x <= textures[i].start_x)
-        {
-            texture.start_x = textures[i].start_x + 256;
-        }
-    }
-
-    textures.push_back( texture );
-
-    //LOGGER->Log(LOGGER_INFO, "Startx:0x%04x, Starty:0x%04x", texture.start_x, texture.start_y);
-}
-
-//---------------------------------------------------------------------

+ 0 - 45
utilities/ffvii_field_model_exporter/src/MeshFile.h

@@ -1,45 +0,0 @@
-#ifndef MESH_FILE_H
-#define MESH_FILE_H
-
-#include <Ogre.h>
-
-#include "BsxFile.h"
-#include "common/File.h"
-
-
-
-class MeshFile : public File
-{
-public:
-    explicit     MeshFile(const Ogre::String& file);
-    explicit     MeshFile(File* pFile);
-                 MeshFile(File* pFile, const u32 offset, const u32 length);
-                 MeshFile(u8* pBuffer, const u32 offset, const u32 length);
-    virtual     ~MeshFile();
-
-    Ogre::ColourValue  readColor( const u32 offset );
-
-    void         GetData(const Ogre::String& name, const int offset_to_parts, const int number_of_parts, Ogre::MeshPtr mesh, VectorTexForGenBsx& textures );
-
-    void         AddTexture( TexForGenBsx& texture, VectorTexForGenBsx& textures );
-
-    enum BufferBinding
-    {
-        POSITION_BINDING = 0x0
-      , COLOUR_BINDING   = 0x1
-      , TEXTURE_BINDING  = 0x2
-      , NORMAL_BINDING   = 0x3
-    };
-
-private:
-    int offset_to_4;
-    int offset_to_5;
-
-    void         readQuad( const u32 offset_to_poly, std::vector<Ogre::Vector3>& vertexes, float* &pPos, u16* &index, u32 &cur_vertex, Ogre::RGBA* &curcolour_, bool multi_color );
-    void         readTriangle( const u32 offset_to_poly, std::vector<Ogre::Vector3>& vertexes, float* &pPos, u16* &index, u32 &cur_vertex, Ogre::RGBA* &curcolour_, bool multi_color );
-    void         readPart( const Ogre::String& name, const u32 i, const u32 offset_to_part, Ogre::MeshPtr mesh, VectorTexForGenBsx& textures );
-};
-
-
-
-#endif // NESH_FILE_h

+ 0 - 111
utilities/ffvii_field_model_exporter/src/Model.cpp

@@ -1,111 +0,0 @@
-// $Id: Model.cpp 94 2006-11-12 19:44:43Z crazy_otaku $
-
-#include <OgreTagPoint.h>
-
-
-#include "Model.h"
-
-using namespace QGears;
-
-uint32 g_ModelNumber = 0;
-
-
-
-Model::Model(void):
-    m_CurrentFrame(0),
-    m_PlayedAnimation(0),
-    m_AnimationWait(0),
-    m_Scale(1.0f)
-{
-    ++g_ModelNumber;
-}
-
-
-
-Model::~Model(void)
-{
-}
-
-
-
-void
-Model::Update(const uint32 delta_time)
-{
-    /*
-    if (m_AnimationWait >= 4)
-    {
-        if (m_Animation.size() > m_PlayedAnimation)
-        {
-            if (m_CurrentFrame < m_Animation[m_PlayedAnimation].frame.size() - 1)
-            {
-                ++m_CurrentFrame;
-            }
-            else
-            {
-                m_CurrentFrame = 0;
-            }
-        }
-
-        m_AnimationWait = 0;
-    }
-
-    ++m_AnimationWait;*/
-}
-
-
-
-
-
-
-void
-Model::DrawHierarchy(const sint8 level) const
-{
-}
-
-
-
-void
-Model::AddBone(const sint16 length, const sint8 parent_id)
-{
-    Bone bone;
-    bone.length    = length;
-    bone.parent_id = parent_id;
-    m_Skeleton.push_back(bone);
-}
-
-
-/*
-void
-Model::AddPart(const TotalGeometry& geometry, const int parent_bone)
-{
-    Part part;
-    part.geometry    = geometry;
-    part.parent_bone = parent_bone;
-    m_Parts.push_back(part);
-}
-*/
-
-
-void
-Model::AddAnimation(const Animation& animation)
-{
-    //m_Animation.push_back(animation);
-}
-
-
-
-void
-Model::SetAnimation(uint32 animation_id)
-{
-    m_PlayedAnimation = animation_id;
-    m_CurrentFrame = 0;
-}
-
-
-
-int
-Model::GetNumberOfBones(void) const
-{
-    return m_Skeleton.size();
-}
-

+ 0 - 62
utilities/ffvii_field_model_exporter/src/Model.h

@@ -1,62 +0,0 @@
-#ifndef MODEL_H
-#define MODEL_H
-
-#include <Ogre.h>
-#include "common/TypeDefine.h"
-
-
-struct BonePosition
-{
-    float rotation_x;
-    float rotation_y;
-    float rotation_z;
-
-    float translation_x;
-    float translation_y;
-    float translation_z;
-};
-
-
-
-struct Frame
-{
-    std::vector<BonePosition> bone;
-};
-
-
-
-struct Animation
-{
-    std::vector<Frame> frame;
-};
-
-
-
-struct Model
-{
-    Model(void);
-    ~Model(void);
-    void Update(const QGears::uint32 delta_time);
-    void DrawHierarchy(const QGears::sint8 level) const;
-    void AddBone(const QGears::sint16 length, const QGears::sint8 parent_id);
-    //void AddPart(const TotalGeometry& geometry, const int parent_bone);
-    void AddAnimation(const Animation& animation);
-    void SetAnimation(QGears::uint32 animation_id);
-    int GetNumberOfBones(void) const;
-
-    QGears::uint32 m_CurrentFrame;
-    QGears::uint32 m_PlayedAnimation;
-    QGears::uint32 m_AnimationWait;
-    float m_Scale;
-
-    struct Bone
-    {
-        QGears::sint16 length;
-        QGears::sint8  parent_id;
-    };
-    std::vector<Bone>             m_Skeleton;
-};
-
-
-
-#endif // MODEL_H

+ 0 - 73
utilities/ffvii_field_model_exporter/src/SkeletonFile.cpp

@@ -1,73 +0,0 @@
-#include "SkeletonFile.h"
-#include "common/Logger.h"
-
-
-
-SkeletonFile::SkeletonFile(const Ogre::String& file):
-    File( file )
-{
-}
-
-
-
-SkeletonFile::SkeletonFile(File* pFile):
-    File(pFile)
-{
-}
-
-
-
-SkeletonFile::SkeletonFile(File* pFile, const u32 offset, const u32 length):
-    File(pFile, offset, length)
-{
-}
-
-
-
-SkeletonFile::SkeletonFile(u8* pBuffer, const u32 offset, const u32 length):
-    File(pBuffer, offset, length)
-{
-}
-
-
-
-SkeletonFile::~SkeletonFile()
-{
-}
-
-
-
-void
-SkeletonFile::GetData( std::vector< s16 >& skeleton_length, const int offset_to_bones, const int number_of_bones, Ogre::SkeletonPtr skeleton )
-{
-    if (skeleton != nullptr)
-    {
-        Ogre::Bone* root = skeleton->createBone( "0", 0 );
-    }
-
-    for( int i = 0; i < number_of_bones; ++i )
-    {
-        s16 length    = GetU16LE(offset_to_bones + i * 0x04 + 0x00);
-        s8  parent_id = GetU8(offset_to_bones + i * 0x04 + 0x02);
-
-        skeleton_length.push_back( length );
-
-        if (skeleton != nullptr)
-        {
-            //LOGGER->Log(LOGGER_INFO, "Skeleton bone-%d length-%d parent-%d part-%d", i, length, parent_id, GetU8(offset_to_bones + i * 0x04 + 0x03));
-
-            Ogre::Bone* bone1 = skeleton->createBone(Ogre::StringConverter::toString(i * 2 + 1), i * 2 + 1);
-            Ogre::Bone* bone2 = skeleton->createBone(Ogre::StringConverter::toString(i * 2 + 2), i * 2 + 2);
-
-            if (parent_id == -1)
-            {
-                skeleton->getBone(0)->addChild(bone1);
-            }
-            else
-            {
-                skeleton->getBone(parent_id * 2 + 2)->addChild(bone1);
-            }
-            bone1->addChild(bone2);
-        }
-    }
-}

+ 0 - 25
utilities/ffvii_field_model_exporter/src/SkeletonFile.h

@@ -1,25 +0,0 @@
-#ifndef SKELETON_FILE_H
-#define SKELETON_FILE_H
-
-#include <Ogre.h>
-
-#include "SkeletonFile.h"
-#include "common/File.h"
-
-
-
-class SkeletonFile : public File
-{
-public:
-    explicit     SkeletonFile(const Ogre::String& file);
-    explicit     SkeletonFile(File* pFile);
-                 SkeletonFile(File* pFile, const u32 offset, const u32 length);
-                 SkeletonFile(u8* pBuffer, const u32 offset, const u32 length);
-    virtual     ~SkeletonFile(void);
-
-    void         GetData ( std::vector< s16 >& skeleton_length, const int offset_to_bones, const int number_of_bones, Ogre::SkeletonPtr skeleton );
-};
-
-
-
-#endif // SKELETON_FILE_H

+ 0 - 277
utilities/ffvii_field_model_exporter/src/TdbFile.cpp

@@ -1,277 +0,0 @@
-#include "../../common/Logger.h"
-
-#include "TdbFile.h"
-
-
-
-TdbFile::TdbFile(const Ogre::String& file):
-    LzsFile(file)
-{
-}
-
-
-
-TdbFile::TdbFile(File* pFile):
-    LzsFile(pFile)
-{
-}
-
-
-
-TdbFile::TdbFile(File* pFile, const u32 offset, const u32 length):
-    LzsFile(pFile, offset, length)
-{
-}
-
-
-
-TdbFile::TdbFile(u8* pBuffer, const u32 offset, const u32 length):
-    LzsFile(pBuffer, offset, length)
-{
-}
-
-
-
-TdbFile::~TdbFile()
-{
-}
-
-
-
-void
-TdbFile::CreateTexture( const Ogre::PixelBox& pb, const int face_id, const int start_x, const int start_y )
-{
-    typedef std::vector< u8 > Face;
-    std::vector< Face > face_row;
-    Face face;
-    // face 0
-    face.push_back( 0x7e ); face.push_back( 0x00 ); face.push_back( 0x01 ); face.push_back( 0x02 ); face.push_back( 0x03 ); face.push_back( 0x04 ); face.push_back( 0x07 );
-    face.push_back( 0x7e ); face.push_back( 0x05 ); face.push_back( 0x06 );
-    face_row.push_back( face );
-    face.clear();
-    // face 1
-    face.push_back( 0x7e ); face.push_back( 0x08 ); face.push_back( 0x09 ); face.push_back( 0x0a ); face.push_back( 0x0b ); face.push_back( 0x0c ); face.push_back( 0x0f );
-    face.push_back( 0x7e ); face.push_back( 0x0d ); face.push_back( 0x0e );
-    face_row.push_back( face );
-    face.clear();
-    // face 2
-    face.push_back( 0x7e ); face.push_back( 0x10 ); face.push_back( 0x11 ); face.push_back( 0x12 ); face.push_back( 0x13 ); face.push_back( 0x14 ); face.push_back( 0x17 );
-    face.push_back( 0x7e ); face.push_back( 0x15 ); face.push_back( 0x16 );
-    face_row.push_back( face );
-    face.clear();
-    // face 3
-    face.push_back(0x7e); face.push_back(0x18); face.push_back(0x19); face.push_back(0x1a); face.push_back(0x1b); face.push_back(0x1c); face.push_back(0x1f);
-    face.push_back(0x7e); face.push_back(0x1d); face.push_back(0x1e);
-    face_row.push_back( face );
-    face.clear();
-    // face 4
-    face_row.push_back( face );
-    face.clear();
-    // face 5
-    face_row.push_back( face );
-    face.clear();
-    // face 6
-    face.push_back(0x7e); face.push_back(0x30); face.push_back(0x31); face.push_back(0x32); face.push_back(0x33); face.push_back(0x34); face.push_back(0x17);
-    face.push_back(0x7e); face.push_back(0x35); face.push_back(0x36);
-    face_row.push_back( face );
-    face.clear();
-    // face 7
-    face_row.push_back( face );
-    face.clear();
-    // face 8
-    face_row.push_back( face );
-    face.clear();
-    // face 9
-    face_row.push_back( face );
-    face.clear();
-    // face a
-    face_row.push_back( face );
-    face.clear();
-    // face b
-    face_row.push_back( face );
-    face.clear();
-    // face c
-    face.push_back(0x7e); face.push_back(0x54); face.push_back(0x7e); face.push_back(0x7e); face.push_back(0x7e); face.push_back(0x7e); face.push_back(0x7e);
-    face.push_back(0x7e); face.push_back(0x55); face.push_back(0x7e);
-    face_row.push_back( face );
-    face.clear();
-    // face d
-    face.push_back(0x7e); face.push_back(0x56); face.push_back(0x7e); face.push_back(0x7e); face.push_back(0x7e); face.push_back(0x7e); face.push_back(0x7e);
-    face.push_back(0x7e); face.push_back(0x57); face.push_back(0x7e);
-    face_row.push_back( face );
-    face.clear();
-    // face e
-    face_row.push_back( face );
-    face.clear();
-    // face f
-    face_row.push_back( face );
-    face.clear();
-    // face 10
-    face_row.push_back( face );
-    face.clear();
-    // face 11
-    face.push_back(0x7e); face.push_back(0x5e); face.push_back(0x7e); face.push_back(0x7e); face.push_back(0x7e); face.push_back(0x7e); face.push_back(0x7e);
-    face.push_back(0x7e); face.push_back(0x5f); face.push_back(0x7e);
-    face_row.push_back( face );
-    face.clear();
-    // face 12
-    face.push_back( 0x7e ); face.push_back( 0x60 ); face.push_back( 0x7e ); face.push_back( 0x7e ); face.push_back( 0x7e ); face.push_back( 0x7e ); face.push_back( 0x7e );
-    face.push_back( 0x7e ); face.push_back( 0x61 ); face.push_back( 0x7e );
-    face_row.push_back( face );
-    face.clear();
-    // face 13
-    face_row.push_back( face );
-    face.clear();
-    // face 14
-    face_row.push_back( face );
-    face.clear();
-    // face 15
-    face_row.push_back( face );
-    face.clear();
-    // face 16
-    face_row.push_back( face );
-    face.clear();
-    // face 17
-    face_row.push_back( face );
-    face.clear();
-    // face 18
-    face_row.push_back( face );
-    face.clear();
-    // face 19
-    face_row.push_back( face );
-    face.clear();
-    // face 1a
-    face_row.push_back( face );
-    face.clear();
-    // face 1b
-    face_row.push_back( face );
-    face.clear();
-    // face 1c
-    face_row.push_back( face );
-    face.clear();
-    // face 1d
-    face.push_back(0x7e); face.push_back(0x76); face.push_back(0x7e); face.push_back(0x7e); face.push_back(0x7e); face.push_back(0x7e); face.push_back(0x7e);
-    face.push_back(0x7e); face.push_back(0x77); face.push_back(0x7e);
-    face_row.push_back( face );
-    face.clear();
-
-/*
-// eye and mouth by face id
-7E202122232427 7E2627 4
-7E28292A2B2C2F 7E2D2E 5
-7E38393A3B3C3F 7E3D3E 7
-7E404142434447 7E4546 8
-7E48494A4B4C4F 7E4D4E 9
-7E507E7E7E7E7E 7E517E a
-7E527E7E7E7E7E 7E537E b
-7E587E7E7E7E7E 7E597E e
-7E5A7E7E7E7E7E 7E5B7E f
-7E5C7E7E7E7E7E 7E5D7E 10
-7E627E7E7E7E7E 7E637E 13
-7E647E7E7E7E7E 7E657E 14
-7E667E7E7E7E7E 7E677E 15
-7E687E7E7E7E7E 7E697E 16
-7E6A7E7E7E7E7E 7E6B7E 17
-7E6C7E7E7E7E7E 7E6D7E 18
-7E6E7E7E7E7E7E 7E6F7E 19
-7E707E7E7E7E7E 7E717E 1a
-7E727E7E7E7E7E 7E737E 1b
-7E747E7E7E7E7E 7E757E 1c
-7E787E7E7E7E7E 7E797E 1e
-7E7A7E7E7E7E7E 7E7B7E 1f
-7E7C7E7E7E7E7E 7E7D7E 20
-*/
-
-
-    if( face_id >= static_cast<int>(face_row.size()) || face_row[ face_id ].size() == 0 )
-    {
-        LOGGER->Log( "[ERROR] There is no data for face id: 0x" + HexToString( face_id, 2, '0' ) );
-        return;
-    }
-
-    int offset_to_clut = GetU32LE( 0xc ) + face_id * 32;
-
-    int start_x_new = start_x;
-    int start_y_new = start_y;
-
-    // eyes should be created twice
-    bool second_eye = false;
-
-    for( size_t i = 1; i < face_row[ face_id ].size(); ++i )
-    {
-        int offset_to_image = GetU32LE( 0x8 ) + face_row[ face_id ][ i ] * 512;
-
-        if( i == 7 ) // mouth starts here. mouth always starts from 0xa0
-        {
-            start_x_new = start_x;
-            start_y_new += 160;
-        }
-
-        for( u32 y = 0; y < 32; ++y )
-        {
-            u32* data = static_cast< u32* >( (u32*) pb.data ) + ( y + start_y_new ) * pb.rowPitch;
-
-            for( u32 x = 0; x < 16; ++x )
-            {
-                u8 pixel = GetU8( offset_to_image + y * 16 + x );
-                u16 clut1 = GetU16LE( offset_to_clut + ( pixel & 0xf ) * 2 );
-                u16 clut2 = GetU16LE( offset_to_clut + ( pixel >> 4 ) * 2 );
-
-                u32 ogre_pixel1 = ( ( ( clut1 & 0x1f ) * 255 / 31 ) << 0x18 ) | ( ( ( ( clut1 >>  5 ) & 0x1f ) * 255 / 31 ) << 0x10 ) | ( ( ( ( clut1 >> 10 ) & 0x1f ) * 255 / 31 ) << 0x8 ) | 0;
-
-                u8 stp = ( clut1 & 0x8000 ) >> 15;
-                if( stp == 0 && ( ogre_pixel1 & 0xffffff00 ) == 0 )
-                {
-                    ogre_pixel1 |= 0;
-                }
-                else if( stp == 0 && ( ogre_pixel1 & 0xffffff00) != 0 )
-                {
-                    ogre_pixel1 |= 255;
-                }
-                else if( stp == 1 && ( ogre_pixel1 & 0xffffff00 ) == 0 )
-                {
-                    ogre_pixel1 |= 255;
-                }
-                else if( stp == 1 && ( ogre_pixel1 & 0xffffff00 ) != 0 )
-                {
-                    ogre_pixel1 |= 255 / 4;
-                }
-
-                u32 ogre_pixel2 = ( ( ( clut2 & 0x1f ) * 255 / 31 ) << 0x18 ) | ( ( ( ( clut2 >>  5 ) & 0x1f ) * 255 / 31 ) << 0x10 ) | ( ( ( ( clut2 >> 10 ) & 0x1f ) * 255 / 31 ) << 0x8 ) | 0;
-
-                stp = ( clut2 & 0x8000 ) >> 15;
-                if( stp == 0 && ( ogre_pixel2 & 0xffffff00 ) == 0 )
-                {
-                    ogre_pixel2 |= 0;
-                }
-                else if( stp == 0 && ( ogre_pixel2 & 0xffffff00 ) != 0 )
-                {
-                    ogre_pixel2 |= 255;
-                }
-                else if( stp == 1 && ( ogre_pixel2 & 0xffffff00 ) == 0 )
-                {
-                    ogre_pixel2 |= 255;
-                }
-                else if( stp == 1 && ( ogre_pixel2 & 0xffffff00 ) != 0 )
-                {
-                    ogre_pixel2 |= 255 / 4;
-                }
-
-                data[ start_x_new + x * 2 + 0 ] = ogre_pixel1;
-                data[ start_x_new + x * 2 + 1 ] = ogre_pixel2;
-            }
-        }
-
-        if( second_eye == false && i < 7 )
-        {
-            --i;
-            second_eye = true;
-        }
-        else
-        {
-            second_eye = false;
-        }
-
-        start_x_new += 32;
-    }
-}

+ 0 - 26
utilities/ffvii_field_model_exporter/src/TdbFile.h

@@ -1,26 +0,0 @@
-#ifndef TDB_FILE_H
-#define TDB_FILE_H
-
-#include <Ogre.h>
-
-#include "../../common/Surface.h"
-#include "common/LzsFile.h"
-#include "../../common/Vram.h"
-
-
-
-class TdbFile : public LzsFile
-{
-public:
-    explicit     TdbFile( const Ogre::String& file );
-    explicit     TdbFile( File* pFile );
-                 TdbFile( File* pFile, const u32 offset, const u32 length );
-                 TdbFile( u8* pBuffer, const u32 offset, const u32 length );
-    virtual     ~TdbFile();
-
-    void         CreateTexture( const Ogre::PixelBox& pb, const int face_id, const int start_x, const int start_y );
-};
-
-
-
-#endif // TDB_FILE_h

+ 0 - 51
utilities/ffvii_field_model_exporter_pc/CMakeLists.txt

@@ -1,51 +0,0 @@
-include_directories(
-    ${CMAKE_CURRENT_SOURCE_DIR}/include
-)
-
-# define header and source files
-set(HEADER_FILES
-    include/FF7FieldModelExporterPC.h
-)
-set(SOURCE_FILES
-    src/FF7FieldModelExporterPC.cpp
-    src/main.cpp
-)
-
-#add_definitions(
-#    -DQGEARS_ADD_MANAGERS
-#)
-
-add_executable(ff7_field_model_exporter_pc
-  ${SOURCE_FILES}
-  ${HEADER_FILES}
-)
-SET_PROPERTY(TARGET ff7_field_model_exporter_pc PROPERTY FOLDER "utilities")
-
-if (APPLE)
-target_link_libraries(ff7_field_model_exporter_pc "-framework CoreFoundation -framework Cocoa -framework IOKit")
-endif()
-
-if(WIN32)
-  set_target_properties(ff7_field_model_exporter_pc PROPERTIES WIN32_EXECUTABLE ON)
-  if (MSVC)
-    set_target_properties(ff7_field_model_exporter_pc PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
-  endif()
-endif()
-
-set(LIBRARIES
-    v-gears-data
-
-    QGearsMain
-
-
-    ${OGRE_LIBRARIES}
-    ${OIS_LIBRARIES}
-    ${ZLIB_LIBRARIES}
-Utility
-
-)
-target_link_libraries(ff7_field_model_exporter_pc    ${LIBRARIES})
-
-install(TARGETS ff7_field_model_exporter_pc
-    DESTINATION tools/ff7
-)

+ 0 - 18
utilities/ffvii_field_model_exporter_pc/bin/plugins.cfg

@@ -1,18 +0,0 @@
-# Defines plugins to load
-
-# Define plugin folder
-PluginFolder=.
-
-# Define plugins
- Plugin=RenderSystem_Direct3D9
-# Plugin=RenderSystem_Direct3D11
- Plugin=RenderSystem_GL
-# Plugin=RenderSystem_GLES
-# Plugin=RenderSystem_GLES2
-# Plugin=Plugin_ParticleFX
-# Plugin=Plugin_BSPSceneManager
-# Plugin=Plugin_CgProgramManager
-# Plugin=Plugin_PCZSceneManager
-# Plugin=Plugin_OctreeZone
-# Plugin=Plugin_OctreeSceneManager
-Plugin=Plugin_Data

+ 0 - 18
utilities/ffvii_field_model_exporter_pc/bin/plugins_d.cfg

@@ -1,18 +0,0 @@
-# Defines plugins to load
-
-# Define plugin folder
-PluginFolder=.
-
-# Define plugins
-# Plugin=RenderSystem_Direct3D9_d
-# Plugin=RenderSystem_Direct3D11
- Plugin=RenderSystem_GL_d
-# Plugin=RenderSystem_GLES
-# Plugin=RenderSystem_GLES2
-# Plugin=Plugin_ParticleFX
-# Plugin=Plugin_BSPSceneManager
-# Plugin=Plugin_CgProgramManager
-# Plugin=Plugin_PCZSceneManager
-# Plugin=Plugin_OctreeZone
-# Plugin=Plugin_OctreeSceneManager
-#Plugin=Plugin_Data_d

+ 0 - 12
utilities/ffvii_field_model_exporter_pc/bin/resources.cfg

@@ -1,12 +0,0 @@
-# alternative ressources directly from the game files
-[Bootstrap]
-Zip=../../OgreCore.zip
-
-[Game]
-FileSystem=../../../output/data
-
-[FFVII]
-#FileSystem=D:/game/Final Fantasy VII/data_orig
-#FileSystem=D:/game/Final Fantasy VII/data
-LGP=D:/game/Final Fantasy VII/data/field/char.lgp
-LGP=D:/game/Final Fantasy VII/data/field/gflevel.lgp

+ 0 - 12
utilities/ffvii_field_model_exporter_pc/bin/resources_d.cfg

@@ -1,12 +0,0 @@
-# alternative ressources directly from the game files
-[Bootstrap]
-Zip=../../OgreCore.zip
-
-[Game]
-FileSystem=../../../output/data
-
-[FFVII]
-#FileSystem=D:/game/Final Fantasy VII/data_orig
-#FileSystem=D:/game/Final Fantasy VII/data
-#LGP=D:/game/Final Fantasy VII/data/field/char.lgp
-#LGP=D:/game/Final Fantasy VII/data/field/gflevel.lgp

+ 0 - 41
utilities/ffvii_field_model_exporter_pc/include/FF7FieldModelExporterPC.h

@@ -1,41 +0,0 @@
-/*
------------------------------------------------------------------------------
-Copyright (c) 26.10.2013 Tobias Peters <tobias.peters@kreativeffekt.at>
-
-This file is part of Q-Gears
-
-Q-Gears 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, version 2.0 (GPLv2) of the License.
-
-Q-Gears 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 General Public License for more details.
------------------------------------------------------------------------------
-*/
-#ifndef __FF7FieldModelExporterPC_H__
-#define __FF7FieldModelExporterPC_H__
-
-#include "QGearsUtility.h"
-
-namespace QGears
-{
-    namespace FF7
-    {
-        class FieldModelExporterPC : public Utility
-        {
-        public:
-            FieldModelExporterPC( int argc, char *argv[] );
-            virtual ~FieldModelExporterPC();
-
-        protected:
-            virtual String getWindowTitle( void ) const;
-
-        private:
-            FieldModelExporterPC();
-        };
-    }
-}
-
-#endif // __FF7FieldModelExporterPC_H__

+ 0 - 39
utilities/ffvii_field_model_exporter_pc/src/FF7FieldModelExporterPC.cpp

@@ -1,39 +0,0 @@
-/*
------------------------------------------------------------------------------
-Copyright (c) 26.10.2013 Tobias Peters <tobias.peters@kreativeffekt.at>
-
-This file is part of Q-Gears
-
-Q-Gears 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, version 2.0 (GPLv2) of the License.
-
-Q-Gears 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 General Public License for more details.
------------------------------------------------------------------------------
-*/
-#include "FF7FieldModelExporterPC.h"
-
-namespace QGears
-{
-    namespace FF7
-    {
-        FieldModelExporterPC::FieldModelExporterPC( int argc, char *argv[] ) :
-            Utility( argc, argv )
-        {
-        }
-
-        FieldModelExporterPC::~FieldModelExporterPC()
-        {
-        }
-
-        String
-        FieldModelExporterPC::getWindowTitle() const
-        {
-            return "FFVII Field Model Exporter PC";
-        }
-
-    }
-}

+ 0 - 163
utilities/ffvii_field_model_exporter_pc/src/main.cpp

@@ -1,163 +0,0 @@
-/*
------------------------------------------------------------------------------
-The MIT License (MIT)
-
-Copyright (c) 2013-08-10 Tobias Peters <tobias.peters@kreativeffekt.at>
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
------------------------------------------------------------------------------
-*/
-#include <fstream>
-
-#include <Ogre.h>
-#include <OgreMesh.h>
-
-#include "FF7FieldModelExporterPC.h"
-#include "common/TypeDefine.h"
-#include "common/QGearsStringUtil.h"
-
-#include "data/QGearsAFileManager.h"
-#include "data/QGearsHRCFileManager.h"
-#include "data/QGearsLZSFLevelFileManager.h"
-#include "common/FF7NameLookup.h"
-
-void attachMesh( Ogre::MeshPtr &mesh )
-{
-    Ogre::SceneManager* scene_manager = Ogre::Root::getSingleton().getSceneManager( "Scene" );
-    Ogre::Entity* entity = scene_manager->createEntity( mesh );
-    entity->setDisplaySkeleton( true );
-    entity->setDebugDisplayEnabled( true );
-   // entity->getAnimationState( "Idle" )->setEnabled( true );
-  //  entity->getAnimationState( "Idle" )->setLoop( true );
-    Ogre::SceneNode* root_node = scene_manager->getRootSceneNode();
-    root_node->showBoundingBox( true );
-   // root_node->attachObject( entity );
-    entity->setVisible( true );
-
-    entities.push_back( entity );
-}
-
-void exportMesh( const Ogre::MeshPtr &mesh )
-{
-    Ogre::MeshSerializer        mesh_ser;
-    mesh_ser.exportMesh( mesh.getPointer(), mesh->getName() );
-
-    Ogre::SkeletonPtr           skeleton( mesh->getSkeleton() );
-    Ogre::SkeletonSerializer    sk_ser;
-    sk_ser.exportSkeleton( skeleton.getPointer(), skeleton->getName() );
-
-    Ogre::Mesh::SubMeshIterator it( mesh->getSubMeshIterator() );
-    Ogre::MaterialSerializer    mat_ser;
-    size_t i(0);
-    while( it.hasMoreElements() )
-    {
-        Ogre::SubMesh *sub_mesh( it.getNext() );
-        Ogre::MaterialPtr mat( Ogre::MaterialManager::getSingleton().getByName( sub_mesh->getMaterialName() ) );
-        if (mat != nullptr)
-        {
-            mat_ser.queueForExport( mat );
-        }
-        ++i;
-    }
-    QGears::String base_name;
-    QGears::StringUtil::splitFull( mesh->getName(), base_name );
-    mat_ser.exportQueued( base_name + QGears::EXT_MATERIAL );
-}
-
-
-
-int main( int argc, char *argv[] )
-{
-    try
-    {
-        QGears::FF7::FieldModelExporterPC app(argc, argv);
-        if (!app.initOgre()) return 0;
-
-        Ogre::SceneManager*         scene_manager(Ogre::Root::getSingleton().createSceneManager(Ogre::ST_GENERIC, "Scene"));
-        QGears::AFilePtr            a;
-        QGears::HRCFilePtr          hrc = QGears::HRCFileManager::getSingleton().load("adda.hrc", "FFVII").staticCast<QGears::HRCFile>();
-        QGears::AFileManager       &afl_mgr(QGears::AFileManager::getSingleton());
-
-        auto meshName = QGears::FF7::NameLookup::model("adda.hrc") + ".mesh";
-
-        Ogre::MeshPtr mesh(Ogre::MeshManager::getSingleton().load(meshName, "FFVII"));
-        Ogre::SkeletonPtr skeleton(mesh->getSkeleton());
-
-
-        a = afl_mgr.load("aeae.a", "FFVII").staticCast<QGears::AFile>();
-        a->AddTo(skeleton, "Idle");
-        a = afl_mgr.load("aeaf.a", "FFVII").staticCast<QGears::AFile>();
-        a->AddTo(skeleton, "Walk");
-        a = afl_mgr.load("aeba.a", "FFVII").staticCast<QGears::AFile>();
-        a->AddTo(skeleton, "Run");
-
-
-        attachMesh(mesh);
-        exportMesh(mesh);
-
-
-        entities[0]->setVisible(true);
-
-        QGears::LZSFLevelFileManager   &fmgr(QGears::LZSFLevelFileManager::getSingleton());
-        // QGears::FLevelFilePtr           f = fmgr.load( "ancnt1", "FFVII" ).staticCast<QGears::FLevelFile>();
-
-        /*
-        mesh = Ogre::MeshManager::getSingleton().load(meshName, "FFVII");
-        skeleton = mesh->getSkeleton();
-        a = afl_mgr.load("bvjf.a", "FFVII").staticCast<QGears::AFile>();
-        a->addTo(skeleton, "JumpFromTrain");
-        */
-
-        //attachMesh( mesh );
-
-
-        // Create background rectangle covering the whole screen
-        //Ogre::Rectangle2D* rect = new Ogre::Rectangle2D(true);
-        //rect->setCorners(-1.0, 1.0, 1.0, -1.0);
-        // rect->setMaterial( "map" );
-
-        // Render the background before everything else
-        //rect->setRenderQueueGroup( Ogre::RENDER_QUEUE_BACKGROUND );
-
-        // Use infinite AAB to always stay visible
-        //Ogre::AxisAlignedBox aabInf;
-        //aabInf.setInfinite();
-        //rect->setBoundingBox( aabInf );
-
-        // Attach background to the scene
-        Ogre::SceneNode* node = scene_manager->getRootSceneNode()->createChildSceneNode("Background");
-
-        node->attachObject(entities[0]);
-
-        //   node->attachObject( entities[0] );
-
-        Ogre::Root::getSingleton().startRendering();
-        skeleton.reset();
-        mesh.reset();
-        //    f.reset();
-        hrc.reset();
-        //delete rect;
-        return 0;
-    }
-    catch (const Ogre::Exception& ex)
-    {
-        std::cout << "Ogre::Exception: " << ex.what() << std::endl;
-        return 1;
-    }
-}

+ 0 - 42
utilities/ffvii_font_exporter/CMakeLists.txt

@@ -1,42 +0,0 @@
-include_directories(
-    ${CMAKE_CURRENT_SOURCE_DIR}/include
-)
-
-# define header and source files
-set(HEADER_FILES
-./src/FontFile.h
-./src/Main.h
-)
-set(SOURCE_FILES
-./src/FontFile.cpp
-./src/Main.cpp
-)
-
-add_definitions(
-    -DQGEARS_ADD_MANAGERS
-)
-
-add_executable(ff7_font_exporter
-  ${HEADER_FILES}
-  ${SOURCE_FILES}
-)
-SET_PROPERTY(TARGET ff7_font_exporter PROPERTY FOLDER "utilities")
-
-if(WIN32)
-  set_target_properties(ff7_font_exporter PROPERTIES WIN32_EXECUTABLE ON)
-  if (MSVC)
-    set_target_properties(ff7_font_exporter PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
-  endif()
-endif()
-
-set(LIBRARIES
-    Utility
-    QGearsMain
-    v-gears-data
-    ${ZLIB_LIBRARIES}
-)
-target_link_libraries(ff7_font_exporter    ${LIBRARIES})
-
-install(TARGETS ff7_font_exporter
-    DESTINATION tools/ff7
-)

+ 0 - 373
utilities/ffvii_font_exporter/src/FontFile.cpp

@@ -1,373 +0,0 @@
-#include "FontFile.h"
-#include "../../common/Logger.h"
-
-#include <OgreStringConverter.h>
-#include <OgreVector3.h>
-
-
-
-//////////////////////////////////////////////
-unsigned short english_chars[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x2000, 0x2100, 0x2200, 0x2300, 0x2400, 0x2500, 0x2600, 0x2700, 0x2800, 0x2900, 0x2A00, 0x2B00, 0x2C00, 0x2D00, 0x2E00, 0x2F00, // 0x00 - 0x0F
-    0x3000, 0x3100, 0x3200, 0x3300, 0x3400, 0x3500, 0x3600, 0x3700, 0x3800, 0x3900, 0x3A00, 0x3B00, 0x3C00, 0x3D00, 0x3E00, 0x3F00, // 0x10 - 0x1F
-    0x4000, 0x4100, 0x4200, 0x4300, 0x4400, 0x4500, 0x4600, 0x4700, 0x4800, 0x4900, 0x4A00, 0x4B00, 0x4C00, 0x4D00, 0x4E00, 0x4F00, // 0x20 - 0x2F
-    0x5000, 0x5100, 0x5200, 0x5300, 0x5400, 0x5500, 0x5600, 0x5700, 0x5800, 0x5900, 0x5A00, 0x5B00, 0x5C00, 0x5D00, 0x5E00, 0x5F00, // 0x30 - 0x3F
-    0x6000, 0x6100, 0x6200, 0x6300, 0x6400, 0x6500, 0x6600, 0x6700, 0x6800, 0x6900, 0x6A00, 0x6B00, 0x6C00, 0x6D00, 0x6E00, 0x6F00, // 0x40 - 0x4F
-    0x7000, 0x7100, 0x7200, 0x7300, 0x7400, 0x7500, 0x7600, 0x7700, 0x7800, 0x7900, 0x7A00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2620, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x1C20, 0x1D20, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0D00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-unsigned short japanese_chars[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0xD030, 0x7030, 0xD330, 0x7330, 0xD630, 0x7630, 0xD930, 0x0000, 0xDC30, 0x7C30, 0xAC30, 0x4C30, 0xAE30, 0x4E30, 0xB030, 0x5030, // 0x00 - 0x0F
-    0xB230, 0x5230, 0xB430, 0x5430, 0xB630, 0x5630, 0xB830, 0x5830, 0xBA30, 0x5A30, 0xBC30, 0x5C30, 0xBE30, 0x5E30, 0xC030, 0x6030, // 0x10 - 0x1F
-    0x0000, 0x0000, 0xC530, 0x0000, 0xC730, 0x6730, 0xC930, 0x6930, 0x0000, 0xD130, 0x7130, 0xD430, 0x0000, 0xD730, 0x7730, 0xDA30, // 0x20 - 0x2F
-    0x0000, 0xDD30, 0x0000, 0x3000, 0x3100, 0x3200, 0x3300, 0x3400, 0x3500, 0x3600, 0x3700, 0x3800, 0x3900, 0x0130, 0x0230, 0x2000, // 0x30 - 0x3F
-    0xCF30, 0x6F30, 0xD230, 0x7230, 0xD530, 0x7530, 0xD830, 0x7830, 0xDB30, 0x7B30, 0xAB30, 0x4B30, 0xAD30, 0x4D30, 0xAF30, 0x4F30, // 0x40 - 0x4F
-    0xB130, 0x5130, 0xB330, 0x5330, 0xB530, 0x5530, 0xB730, 0x5730, 0xB930, 0x5930, 0xBB30, 0x5B30, 0xBD30, 0x5D30, 0xBF30, 0x5F30, // 0x50 - 0x5F
-    0xC130, 0x6130, 0xC430, 0x6430, 0xC630, 0x6630, 0xC830, 0x6830, 0xA630, 0x4630, 0xA230, 0x4230, 0xA430, 0x4430, 0xA830, 0x4830, // 0x60 - 0x6F
-    0xAA30, 0x4A30, 0xCA30, 0x6A30, 0xCB30, 0x6B30, 0x0000, 0x6C30, 0xCD30, 0x6D30, 0xCE30, 0x6E30, 0xDE30, 0x7E30, 0xDF30, 0x7F30, // 0x70 - 0x7F
-    0xE030, 0x8030, 0xE130, 0x8130, 0xE230, 0x8230, 0xE930, 0x8930, 0xEA30, 0x8A30, 0xEB30, 0x8B30, 0xEC30, 0x8C30, 0xED30, 0x8D30, // 0x80 - 0x8F
-    0xE430, 0x8430, 0xE630, 0x0000, 0x0000, 0x8830, 0xEF30, 0x8F30, 0xF330, 0x9330, 0x0000, 0x9230, 0xC330, 0x6330, 0xE330, 0x8330, // 0x90 - 0x9F
-    0xE530, 0x8530, 0xE730, 0x8730, 0xA130, 0x4130, 0xA330, 0x0000, 0xA530, 0x0000, 0xA730, 0x4730, 0x0000, 0x4930, 0x01FF, 0x1FFF, // 0xA0 - 0xAF
-    0x0E30, 0x0F30, 0x0000, 0x0000, 0x4100, 0x4200, 0x4300, 0x4400, 0x4500, 0x4600, 0x4700, 0x4800, 0x4900, 0x4A00, 0x4B00, 0x4C00, // 0xB0 - 0xBF
-    0x4D00, 0x4E00, 0x4F00, 0x5000, 0x5100, 0x5200, 0x5300, 0x5400, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFB30, 0x0000, // 0xC0 - 0xCF
-    0xFC30, 0x7E00, 0x2620, 0x0000, 0x0000, 0x0000, 0x0000, 0x1030, 0x1130, 0x0000, 0x0000, 0x0000, 0x0000, 0x0C30, 0x0D30, 0x08FF, // 0xD0 - 0xDF
-    0x09FF, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0D00, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-unsigned short japanese_chars_fa[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x2759, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0672, 0x7F4F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3478, 0x4466, 0x8364, 0x0000, 0x0000, 0x0000, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x666B, 0x5E79, 0x0000, 0x0000, 0xA898, 0x0000, 0x176C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x885B, 0x0000, 0x7D54, 0x0000, 0xD552, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6297, 0x0000, 0x0000, 0x0000, 0x0854, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x0E66, 0x0000, 0x0000, 0x9C62, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x004E, 0x0000, 0x0580, // 0x50 - 0x5F
-    0x0000, 0x0000, 0x857F, 0x0000, 0x0000, 0x0000, 0x9950, 0x6856, 0x0000, 0x549B, 0xD56C, 0x0000, 0x0000, 0x0000, 0x0000, 0xFA51, // 0x60 - 0x6F
-    0x0163, 0xF876, 0x4B62, 0x0000, 0xBA78, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xB965, 0x4C88, 0x0000, // 0x70 - 0x7F
-    0x9A5B, 0x0000, 0x0000, 0x4D52, 0x1F77, 0x0000, 0x9A89, 0x1752, 0x8C5F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xDE56, 0x0000, // 0x80 - 0x8F
-    0x9A7D, 0x7565, 0x0000, 0x0000, 0x0000, 0x0000, 0x3E5C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0882, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3E5F, 0x0000, 0x0000, 0x0000, 0x4266, 0x0000, 0x0000, 0x2662, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x0000, 0x0000, 0xB751, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xEA8C, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0xCD53, 0x0000, 0xEE76, 0x0000, 0x0000, 0x9B52, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7551, 0x0000, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-unsigned short japanese_chars_fb[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0xB182, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0B4E, 0x0000, 0x6551, 0x4851, 0x0D4E, 0x505B, 0x9B4F, 0x4B5C, // 0x00 - 0x0F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8E96, 0x0000, 0x0000, 0xE890, 0x0000, 0x3458, 0x0000, 0xF24E, 0x9395, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x5096, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x554F, 0x0000, 0x9965, 0x0000, 0x0A4E, 0x0000, 0x8B4E, 0x0000, 0x0000, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x6559, 0x0000, 0x0000, 0x0000, 0x1D52, 0x5167, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0xCA8E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xBA87, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x7751, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xB672, 0x4B61, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8B95, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0C54, 0x1F90, 0x4590, 0x0000, 0x0000, 0x0000, 0x0000, 0x7354, 0x0000, 0x0000, 0x0000, 0x0D50, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0xBA4E, 0xCA4E, 0x0000, 0x0000, 0x535F, 0x0000, 0x0000, 0xDB98, 0xE54E, 0x1659, 0x0000, 0x0000, 0x0000, 0xAB8E, 0x0000, // 0x90 - 0x9F
-    0xCB65, 0x0000, 0x0000, 0x0000, 0x5F6A, 0xB068, 0x0000, 0x8970, 0xB065, 0x214E, 0x2C67, 0x1B54, 0x0000, 0x8551, 0x5C4F, 0x668B, // 0xA0 - 0xAF
-    0x7972, 0x0000, 0x0000, 0x0000, 0x747A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xB38D, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7795, 0x0000, 0x0000, 0x5458, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8B89, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4351, 0x0000, 0x0000, 0x0000, 0x427D, 0x0000, 0x0000, 0x0D54, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x1062, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-unsigned short japanese_chars_fc[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0x188A, 0x0000, 0x7890, 0x6A75, 0x5788, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F
-    0x9358, 0xC35F, 0x0000, 0x0000, 0x0000, 0x0000, 0x5390, 0x0000, 0x0000, 0x0000, 0x0000, 0xFB5D, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x884E, 0x0000, 0x3D84, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x20 - 0x2F
-    0xE565, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xE353, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x296E, 0x0000, 0x0000, 0x0000, 0x0000, 0x708D, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x7153, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x008A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x3159, 0x5765, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0xBC62, 0x0000, 0x0000, 0x0000, 0x5965, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0000, 0x0000, 0x0000, 0xC253, 0xE577, 0x5E80, 0x0000, 0xD54E, 0x2552, 0xC696, 0xE14F, 0x2875, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xE965, 0x0000, 0x0000, 0x0000, 0x0000, 0x718A, 0x305E, 0x0000, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0xF258, 0x6E6D, 0x0000, 0xA052, 0x0000, 0x047D, 0x0000, 0x3C79, 0x5F67, 0x0000, 0x3775, 0x0000, 0x0000, 0x0000, 0xCB7A, // 0xA0 - 0xAF
-    0x0000, 0xFA4F, 0x0000, 0x0000, 0x0000, 0xC179, 0x0000, 0x0000, 0x1250, 0x114F, 0x0000, 0x0000, 0x0000, 0xA952, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xAC8A, 0x0000, 0x0000, 0xF167, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-unsigned short japanese_chars_fd[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x1D4F, 0x0000, 0xA263, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x00 - 0x0F
-    0xE682, 0x0000, 0xF056, 0x0000, 0x0000, 0x0000, 0x0000, 0xA25B, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0000, 0x2B59, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xB88C, 0x1F67, 0x0000, 0x0000, 0x0000, 0x0000, 0xDD4F, 0x2F5E, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x1154, 0x0000, 0x0000, 0x7289, 0x0000, 0x216B, 0x0000, 0x207D, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xB78C, 0x0000, 0x0000, 0x0000, 0x7C5E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x8179, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x975E, 0x0000, 0x0000, 0x0000, 0xCA7D, 0x1478, 0x0000, 0x0000, 0x8766, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0xC599, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x70 - 0x7F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xFD88, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x3293, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x5453, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x3181, 0x0000, 0x8D8E, 0x0000, 0x0000, 0x0000, 0x0000, 0x3052, 0x0000, 0x0000, 0x0000, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x9F52, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x5291, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-unsigned short japanese_chars_fe[256] = {
-    // 0    1       2       3       4       5       6       7       8       9       A       B       C       D       E       F
-    0x0000, 0x0000, 0x0000, 0x667D, 0x0000, 0x0000, 0x0000, 0xAD65, 0x0000, 0x0000, 0xB96C, 0x0000, 0xD550, 0x585B, 0x0000, 0x0000, // 0x00 - 0x0F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x10 - 0x1F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x8B4F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x20 - 0x2F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x9758, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x30 - 0x3F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x40 - 0x4F
-    0x0000, 0x0000, 0x0000, 0xB48C, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x4256, 0xF158, 0x0000, 0x0000, 0x0000, 0x0000, // 0x50 - 0x5F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xB54F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x60 - 0x6F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1D8B, 0x0000, 0x0000, 0x0000, 0xA14F, 0x206B, 0xC45B, 0xD95F, // 0x70 - 0x7F
-    0x0000, 0x944E, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xA65E, 0x0000, 0x0000, 0x0000, 0x0000, 0x988A, // 0x80 - 0x8F
-    0x0000, 0x0000, 0x298F, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x668A, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x90 - 0x9F
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x7272, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xA0 - 0xAF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xC079, 0x0000, 0xFD8E, 0x0000, 0x0000, 0x0000, // 0xB0 - 0xBF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x3B52, // 0xC0 - 0xCF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xD0 - 0xDF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xE0 - 0xEF
-    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0xF0 - 0xFF
-};
-
-
-
-FontFile::FontFile(const Ogre::String &file):
-    File(file)
-{
-}
-
-
-
-FontFile::FontFile(File *file, const u32 offset, const u32 length):
-    File(file, offset, length)
-{
-}
-
-
-
-FontFile::FontFile(u8* buffer, const u32 offset, const u32 length):
-    File(buffer, offset, length)
-{
-}
-
-
-
-FontFile::FontFile(File *file):
-    File(file)
-{
-}
-
-
-
-FontFile::~FontFile()
-{
-}
-
-
-
-
-
-void
-FontFile::Export( const Ogre::String &export_file, bool english )
-{
-    Logger* export_text = new Logger( export_file );
-
-    std::vector< unsigned char > text;
-    text.push_back( 0xff );
-    text.push_back( 0xfe );
-    export_text->Log( text );
-    text.clear();
-
-    int pos = 0;
-
-    if( english == true )
-    {
-        export_text->LogW( "<font name=\"FFVIIFont\" language=\"English\" image=\"fonts/ffvii_en.png\" image_size=\"256 256\" height=\"16\">\n" );
-
-        for (int i = 0; i < 256; ++i)
-        {
-            if( english_chars[ i ] != 0x0000 && english_chars[ i ] != 0x0D00 )
-            {
-                export_text->LogW( "    <char name=\"" );
-                if( english_chars[ i ] == 0x2200 )
-                {
-                    export_text->LogW( "&quot;" );
-                }
-                else
-                {
-                    text.push_back( english_chars[ i ] >> 8 );
-                    text.push_back( english_chars[ i ] & 0xff );
-                    export_text->Log( text );
-                    text.clear();
-                }
-                export_text->LogW( "\" x=\"" + Ogre::StringConverter::toString( ( i % 0x15 ) * 0xc ) + "\"" );
-                export_text->LogW( " y=\"" + Ogre::StringConverter::toString( ( i / 0x15 ) * 0xc ) + "\"" );
-                export_text->LogW( " width=\"12\" height=\"12\"" );
-                export_text->LogW( " pre=\"" + Ogre::StringConverter::toString( GetU8( pos ) >> 5 ) + "\"" );
-                export_text->LogW( " post=\"" + Ogre::StringConverter::toString( ( GetU8( pos ) & 0x1f ) - 12 ) + "\" />\n" );
-            }
-
-            ++pos;
-        }
-    }
-    else
-    {
-        export_text->LogW( "<font name=\"FFVIIFont\" language=\"Japanese\" image=\"fonts/ffvii_jp.png\" image_size=\"512 256\" height=\"16\">\n" );
-
-        for (int i = 0; i < 256; ++i)
-        {
-            if( japanese_chars[ i ] != 0x0000 && japanese_chars[ i ] != 0x0D00 )
-            {
-                export_text->LogW( "    <char name=\"" );
-                text.push_back( japanese_chars[ i ] >> 8 );
-                text.push_back( japanese_chars[ i ] & 0xff );
-                export_text->Log( text );
-                text.clear();
-                export_text->LogW( "\" x=\"" + Ogre::StringConverter::toString( ( i % 0x15 ) * 0xc ) + "\"" );
-                export_text->LogW( " y=\"" + Ogre::StringConverter::toString( ( i / 0x15 ) * 0xc ) + "\"" );
-                export_text->LogW( " width=\"12\" height=\"12\"" );
-                export_text->LogW( " pre=\"" + Ogre::StringConverter::toString( GetU8( pos ) >> 5 ) + "\"" );
-                export_text->LogW( " post=\"" + Ogre::StringConverter::toString( ( GetU8( pos ) & 0x1f ) - 12 ) + "\" />\n" );
-            }
-
-            ++pos;
-        }
-
-        pos = 0xe7;
-
-        for (int i = 0; i < 256; ++i)
-        {
-            if( japanese_chars_fa[ i ] != 0x0000 && japanese_chars_fa[ i ] != 0x0D00 )
-            {
-                export_text->LogW( "    <char name=\"" );
-                text.push_back( japanese_chars_fa[ i ] >> 8 );
-                text.push_back( japanese_chars_fa[ i ] & 0xff );
-                export_text->Log( text );
-                text.clear();
-                export_text->LogW( "\" x=\"" + Ogre::StringConverter::toString( ( i % 0x15 ) * 0xc ) + "\"" );
-                export_text->LogW( " y=\"" + Ogre::StringConverter::toString( 0x84 + ( i / 0x15 ) * 0xc ) + "\"" );
-                export_text->LogW( " width=\"12\" height=\"12\"" );
-                export_text->LogW( " pre=\"" + Ogre::StringConverter::toString( GetU8( pos ) >> 5 ) + "\"" );
-                export_text->LogW( " post=\"" + Ogre::StringConverter::toString( ( GetU8( pos ) & 0x1f ) - 12 ) + "\" />\n" );
-            }
-
-            ++pos;
-        }
-
-        pos = 0x1b9;
-
-        for (int i = 0; i < 256; ++i)
-        {
-            if( japanese_chars_fb[ i ] != 0x0000 && japanese_chars_fb[ i ] != 0x0D00 )
-            {
-                export_text->LogW( "    <char name=\"" );
-                text.push_back( japanese_chars_fb[ i ] >> 8 );
-                text.push_back( japanese_chars_fb[ i ] & 0xff );
-                export_text->Log( text );
-                text.clear();
-                export_text->LogW( "\" x=\"" + Ogre::StringConverter::toString( 256 + ( i % 0x15 ) * 0xc ) + "\"" );
-                export_text->LogW( " y=\"" + Ogre::StringConverter::toString( ( i / 0x15 ) * 0xc ) + "\"" );
-                export_text->LogW( " width=\"12\" height=\"12\"" );
-                export_text->LogW( " pre=\"" + Ogre::StringConverter::toString( GetU8( pos ) >> 5 ) + "\"" );
-                export_text->LogW( " post=\"" + Ogre::StringConverter::toString( ( GetU8( pos ) & 0x1f ) - 12 ) + "\" />\n" );
-            }
-
-            ++pos;
-        }
-
-        pos = 0x2a0;
-
-        for (int i = 0; i < 256; ++i)
-        {
-            if( japanese_chars_fc[ i ] != 0x0000 && japanese_chars_fc[ i ] != 0x0D00 )
-            {
-                export_text->LogW( "    <char name=\"" );
-                text.push_back( japanese_chars_fc[ i ] >> 8 );
-                text.push_back( japanese_chars_fc[ i ] & 0xff );
-                export_text->Log( text );
-                text.clear();
-                export_text->LogW( "\" x=\"" + Ogre::StringConverter::toString( 256 + ( i % 0x15 ) * 0xc ) + "\"" );
-                export_text->LogW( " y=\"" + Ogre::StringConverter::toString( 0x84 + ( i / 0x15 ) * 0xc ) + "\"" );
-                export_text->LogW( " width=\"12\" height=\"12\"" );
-                export_text->LogW( " pre=\"" + Ogre::StringConverter::toString( GetU8( pos ) >> 5 ) + "\"" );
-                export_text->LogW( " post=\"" + Ogre::StringConverter::toString( ( GetU8( pos ) & 0x1f ) - 12 ) + "\" />\n" );
-            }
-
-            ++pos;
-        }
-
-        pos = 0x372;
-
-        for (int i = 0; i < 256; ++i)
-        {
-            if( japanese_chars_fd[ i ] != 0x0000 && japanese_chars_fd[ i ] != 0x0D00 )
-            {
-                export_text->LogW( "    <char name=\"" );
-                text.push_back( japanese_chars_fd[ i ] >> 8 );
-                text.push_back( japanese_chars_fd[ i ] & 0xff );
-                export_text->Log( text );
-                text.clear();
-                export_text->LogW( "\" x=\"" + Ogre::StringConverter::toString( ( i % 0x15 ) * 0xc ) + "\"" );
-                export_text->LogW( " y=\"" + Ogre::StringConverter::toString( 0x84 + ( i / 0x15 ) * 0xc ) + "\"" );
-                export_text->LogW( " width=\"12\" height=\"12\"" );
-                export_text->LogW( " pre=\"" + Ogre::StringConverter::toString( GetU8( pos ) >> 5 ) + "\"" );
-                export_text->LogW( " post=\"" + Ogre::StringConverter::toString( ( GetU8( pos ) & 0x1f ) - 12 ) + "\" />\n" );
-            }
-
-            ++pos;
-        }
-
-        pos = 0x444;
-
-        for (int i = 0; i < 256; ++i)
-        {
-            if( japanese_chars_fe[ i ] != 0x0000 && japanese_chars_fe[ i ] != 0x0D00 )
-            {
-                export_text->LogW( "    <char name=\"" );
-                text.push_back( japanese_chars_fe[ i ] >> 8 );
-                text.push_back( japanese_chars_fe[ i ] & 0xff );
-                export_text->Log( text );
-                text.clear();
-                export_text->LogW( "\" x=\"" + Ogre::StringConverter::toString( 256 + ( i % 0x15 ) * 0xc ) + "\"" );
-                export_text->LogW( " y=\"" + Ogre::StringConverter::toString( 0x84 + ( i / 0x15 ) * 0xc ) + "\"" );
-                export_text->LogW( " width=\"12\" height=\"12\"" );
-                export_text->LogW( " pre=\"" + Ogre::StringConverter::toString( GetU8( pos ) >> 5 ) + "\"" );
-                export_text->LogW( " post=\"" + Ogre::StringConverter::toString( ( GetU8( pos ) & 0x1f ) - 12 ) + "\" />\n" );
-            }
-
-            ++pos;
-        }
-    }
-
-    export_text->LogW("</font>\n");
-
-    delete export_text;
-}

+ 0 - 22
utilities/ffvii_font_exporter/src/FontFile.h

@@ -1,22 +0,0 @@
-#ifndef FONT_FILE_H
-#define FONT_FILE_H
-
-#include "common/File.h"
-
-
-
-class FontFile : public File
-{
-public:
-    FontFile( const Ogre::String& file );
-    FontFile( File* file );
-    FontFile( File* file, const u32 offset, const u32 length );
-    FontFile( u8* buffer, const u32 offset, const u32 length );
-    virtual ~FontFile();
-
-    void Export( const Ogre::String& export_file, bool english );
-};
-
-
-
-#endif // FONT_FILE_H

+ 0 - 142
utilities/ffvii_font_exporter/src/Main.cpp

@@ -1,142 +0,0 @@
-#include "Main.h"
-
-#include <Ogre.h>
-
-#include <stdio.h>
-#include <iostream>
-
-#include "../../common/BinGZipFile.h"
-#include "common/FileSystem.h"
-#include "../../common/Logger.h"
-#include "../../common/TimToVram.h"
-#include "../../common/OgreGenUtilites.h"
-
-#include "FontFile.h"
-
-
-
-int state;
-
-
-
-int
-main( int argc, char *argv[] )
-{
-    Ogre::Root*         root;
-    Ogre::RenderWindow* window;
-
-    root = new Ogre::Root( "", "" );
-#ifndef _DEBUG
-    root->loadPlugin( "RenderSystem_GL.dll" );
-#else
-    root->loadPlugin( "RenderSystem_GL_d.dll" );
-#endif
-    root->setRenderSystem( root->getAvailableRenderers()[ 0 ] );
-    root->initialise( false );
-    Ogre::NameValuePairList misc;
-    misc[ "title" ] = "FFVII Exporter";
-    window = root->createRenderWindow( "QGearsWindow", 800, 600, false, &misc );
-
-
-    LOGGER = new Logger( "game.log" );
-
-    state = GAME;
-
-
-
-    {
-        BinGZipFile* file = new BinGZipFile( "data/en/WINDOW.BIN" );
-        File* font_graf    = file->ExtractGZip( 1 );
-        File* font_padding = file->ExtractGZip( 2 );
-        FontFile font( font_padding );
-        font.Export( "export_en/ui/fonts/ffvii_en.xml", true );
-        //font_graf->WriteFile( "font.tim" );
-
-        Vram* vram = Vram::MakeInstance().release();
-        LoadTimFileToVram( font_graf, 0, vram );
-        //vram->Save( "text" );
-
-        Ogre::TexturePtr ptex;
-        Ogre::HardwarePixelBufferSharedPtr buffer;
-        ptex = Ogre::TextureManager::getSingleton().createManual( "DynaTex", "General", Ogre::TEX_TYPE_2D, 256, 256, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC );
-        buffer = ptex->getBuffer( 0, 0 );
-        buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD );
-        const Ogre::PixelBox& pb = buffer->getCurrentLock();
-        CreateTextureFromVram( pb, vram, 0, 0, 0x80, 0x1f7, 0x380, 0x100, BPP_4 , false );
-        Ogre::Image image;
-        image.loadDynamicImage( ( Ogre::uchar* )pb.data, 256, 256, Ogre::PF_R8G8B8A8 );
-        image.save( "export_en/ui/fonts/ffvii_en.png" );
-        buffer->unlock();
-
-        delete vram;
-        delete file;
-    }
-
-    {
-        BinGZipFile* file = new BinGZipFile( "data/jp/WINDOW.BIN" );
-        File* font_graf    = file->ExtractGZip( 1 );
-        File* font_graf2   = file->ExtractGZip( 2 );
-        File* font_padding = file->ExtractGZip( 3 );
-        font_padding->WriteFile( "font_padding.dat" );
-        FontFile font( font_padding );
-        font.Export( "export_jp/ui/fonts/ffvii_jp.xml", false );
-        font_graf->WriteFile( "font.tim" );
-        font_graf2->WriteFile( "font2.tim" );
-
-        Vram* vram = Vram::MakeInstance().release();
-        LoadTimFileToVram( font_graf, 0, vram );
-        LoadTimFileToVram( font_graf2, 0, vram );
-        //vram->Save( "text" );
-
-        Ogre::TexturePtr ptex;
-        Ogre::HardwarePixelBufferSharedPtr buffer;
-        ptex = Ogre::TextureManager::getSingleton().createManual( "DynaTex", "General", Ogre::TEX_TYPE_2D, 512, 256, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC );
-        buffer = ptex->getBuffer( 0, 0 );
-        buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD );
-        const Ogre::PixelBox& pb = buffer->getCurrentLock();
-        CreateTextureFromVram( pb, vram, 0, 0, 0x80, 0x1f7, 0x380, 0x100, BPP_4 , false );
-        CreateTextureFromVram( pb, vram, 256, 0, 0x90, 0x1f7, 0x380, 0x100, BPP_4 , false );
-        Ogre::Image image;
-        image.loadDynamicImage( ( Ogre::uchar* )pb.data, 512, 256, Ogre::PF_R8G8B8A8 );
-        image.save( "export_jp/ui/fonts/ffvii_jp.png" );
-        buffer->unlock();
-
-        delete vram;
-        delete file;
-    }
-
-    {
-        File sword( "sword.tim" );
-
-        Vram* vram = Vram::MakeInstance().release();
-        LoadTimFileToVram( &sword, 0, vram );
-        //vram->Save( "sword" );
-
-        Ogre::TexturePtr ptex;
-        Ogre::HardwarePixelBufferSharedPtr buffer;
-        ptex = Ogre::TextureManager::getSingleton().createManual( "DynaTex", "General", Ogre::TEX_TYPE_2D, 256, 256, 0, Ogre::PF_R8G8B8A8, Ogre::TU_STATIC );
-        buffer = ptex->getBuffer( 0, 0 );
-        buffer->lock( Ogre::HardwareBuffer::HBL_DISCARD );
-        const Ogre::PixelBox& pb = buffer->getCurrentLock();
-        CreateTextureFromVram( pb, vram, 0, 0, 0x0, 0x1e0, 0x0, 0x0, BPP_8 , false );
-
-        Ogre::Image image;
-        image.loadDynamicImage( ( Ogre::uchar* )pb.data, 256, 256, Ogre::PF_R8G8B8A8 );
-        image.save( "sword.png" );
-        buffer->unlock();
-
-        delete vram;
-    }
-
-    LOGGER->Log("===================== Stop the game!!!");
-
-
-
-    delete LOGGER;
-
-
-
-    delete root;
-
-    return 0;
-}

+ 0 - 17
utilities/ffvii_font_exporter/src/Main.h

@@ -1,17 +0,0 @@
-#ifndef MAIN_H
-#define MAIN_H
-
-
-
-enum
-{
-    EXIT,
-    GAME
-};
-
-extern int state;
-
-
-
-
-#endif // MAIN_H

+ 0 - 51
utilities/ffvii_sound_dumper/CMakeLists.txt

@@ -1,51 +0,0 @@
-include_directories(
-    ${CMAKE_CURRENT_SOURCE_DIR}/include
-)
-
-# define header and source files
-set(HEADER_FILES
-./src/AkaoParser.h
-./src/engine/SoundManager.h
-./src/engine/SoundBackend.h
-./src/engine/backends/SoundBackendSDL.h
-./src/Main.h
-)
-
-set(SOURCE_FILES
-./src/AkaoParser.cpp
-./src/engine/backends/SoundBackendSDL.cpp
-./src/engine/SoundManager.cpp
-./src/Main.cpp
-)
-
-add_definitions(
-    -DQGEARS_ADD_MANAGERS
-)
-
-add_executable(ff7_sound_dumper
-  ${HEADER_FILES}
-  ${SOURCE_FILES}
-)
-SET_PROPERTY(TARGET ff7_sound_dumper PROPERTY FOLDER "utilities")
-
-if (APPLE)
-target_link_libraries(ff7_sound_dumper "-framework CoreFoundation -framework Cocoa -framework IOKit")
-endif()
-
-if(WIN32)
-  set_target_properties(ff7_sound_dumper PROPERTIES WIN32_EXECUTABLE ON)
-  if (MSVC)
-    set_target_properties(ff7_sound_dumper PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
-  endif()
-endif()
-
-set(LIBRARIES
-    Utility
-    QGearsMain
-    v-gears-data
-)
-target_link_libraries(ff7_sound_dumper    ${LIBRARIES})
-
-install(TARGETS ff7_sound_dumper
-    DESTINATION tools/ff7
-)

+ 0 - 1892
utilities/ffvii_sound_dumper/src/AkaoParser.cpp

@@ -1,1892 +0,0 @@
-#include "AkaoParser.h"
-#include <iostream>
-#include <iomanip>
-
-#include "engine/SoundManager.h"
-#include "common/File.h"
-#include "common/Logger.h"
-#include "common/TypeDefine.h"
-
-
-
-const u16 akao_pause_table[ 11 ] =
-{
-    0xc0c0, 0x6060, 0x3030, 0x1818, 0x0c0c, 0x0606, 0x0303, 0x2020, 0x1010, 0x0808, 0x0404
-};
-
-
-
-s16 akao_left_volume_table[ 256 ] =
-{
-    32640, 32384, 32128, 31872, 31616, 31360, 31104, 30848, 30592, 30336, 30080, 29824, 29568, 29312, 29056, 28800,
-    28544, 28288, 28032, 27776, 27520, 27264, 27008, 26752, 26496, 26240, 25984, 25728, 25472, 25216, 24960, 24704,
-    24448, 24192, 23936, 23680, 23424, 23168, 22912, 22656, 22400, 22144, 21888, 21632, 21376, 21120, 20864, 20608,
-    20352, 20096, 19840, 19584, 19328, 19072, 18816, 18560, 18304, 18048, 17792, 17536, 17280, 17024, 16768, 16512,
-    16256, 16000, 15744, 15488, 15232, 14976, 14720, 14464, 14208, 13952, 13696, 13440, 13184, 12928, 12672, 12416,
-    12160, 11904, 11648, 11392, 11136, 10880, 10624, 10368, 10112,  9856,  9600,  9344,  9088,  8832,  8576,  8320,
-     8064,  7808,  7552,  7296,  7040,  6784,  6528,  6272,  6016,  5760,  5504,  5248,  4992,  4736,  4480,  4224,
-     3968,  3712,  3456,  3200,  2944,  2688,  2432,  2176,  1920,  1664,  1408,  1152,   896,   640,   384,   128,
-        0,    -1,    -4,    -9,   -16,   -25,   -36,   -49,   -64,   -81,  -100,  -121,  -144,  -169,  -196,  -225,
-     -256,  -289,  -324,  -361,  -400,  -441,  -484,  -529,  -576,  -625,  -676,  -729,  -784,  -841,  -900,  -961,
-    -1024, -1089, -1156, -1225, -1296, -1369, -1444, -1521, -1600, -1681, -1764, -1849, -1936, -2025, -2116, -2209,
-    -2304, -2401, -2500, -2601, -2704, -2809, -2916, -3025, -3136, -3249, -3364, -3481, -3600, -3721, -3844, -3969,
-     4096,  4225,  4356,  4489,  4624,  4761,  4900,  5041,  5184,  5329,  5476,  5625,  5776,  5929,  6084,  6241,
-     6400,  6561,  6724,  6889,  7056,  7225,  7396,  7569,  7744,  7921,  8100,  8281,  8464,  8649,  8836,  9025,
-     9216,  9409,  9604,  9801, 10000, 10201, 10404, 10609, 10816, 11025, 11236, 11449, 11664, 11881, 12100, 12321,
-    12544, 12769, 12996, 13225, 13456, 13689, 13924, 14161, 14400, 14641, 14884, 15129, 15376, 15625, 15876, 16129
-};
-
-s16 akao_right_volume_table[ 256 ] =
-{
-      128,   384,   640,   896,  1152,  1408,  1664,  1920,  2176,  2432,  2688,  2944,  3200,  3456,  3712,  3968,
-     4224,  4480,  4736,  4992,  5248,  5504,  5760,  6016,  6272,  6528,  6784,  7040,  7296,  7552,  7808,  8064,
-     8320,  8576,  8832,  9088,  9344,  9600,  9856, 10112, 10368, 10624, 10880, 11136, 11392, 11648, 11904, 12160,
-    12416, 12672, 12928, 13184, 13440, 13696, 13952, 14208, 14464, 14720, 14976, 15232, 15488, 15744, 16000, 16256,
-    16512, 16768, 17024, 17280, 17536, 17792, 18048, 18304, 18560, 18816, 19072, 19328, 19584, 19840, 20096, 20352,
-    20608, 20864, 21120, 21376, 21632, 21888, 22144, 22400, 22656, 22912, 23168, 23424, 23680, 23936, 24192, 24448,
-    24704, 24960, 25216, 25472, 25728, 25984, 26240, 26496, 26752, 27008, 27264, 27520, 27776, 28032, 28288, 28544,
-    28800, 29056, 29312, 29568, 29824, 30080, 30336, 30592, 30848, 31104, 31360, 31616, 31872, 32128, 32384, 32640,
-    16129, 15876, 15625, 15376, 15129, 14884, 14641, 14400, 14161, 13924, 13689, 13456, 13225, 12996, 12769, 12544,
-    12321, 12100, 11881, 11664, 11449, 11236, 11025, 10816, 10609, 10404, 10201, 10000,  9801,  9604,  9409,  9216,
-     9025,  8836,  8649,  8464,  8281,  8100,  7921,  7744,  7569,  7396,  7225,  7056,  6889,  6724,  6561,  6400,
-     6241,  6084,  5929,  5776,  5625,  5476,  5329,  5184,  5084,  4900,  4761,  4624,  4489,  4356,  4225,  4096,
-    -3969, -3844, -3721, -3600, -3481, -3364, -3249, -3136, -3025, -2916, -2809, -2704, -2601, -2500, -2401, -2304,
-    -2209, -2116, -2025, -1936, -1849, -1764, -1981, -1600, -1521, -1444, -1369, -1296, -1225, -1156, -1089, -1024,
-     -961,  -900,  -841,  -784,  -729,  -676,  -625,  -576,  -529,  -484,  -441,  -400,  -361,  -324,  -289,  -256,
-     -225,  -196,  -169,  -144,  -121,  -100,   -81,   -64,   -49,   -36,   -25,   -16,    -9,    -4,    -1,     0
-};
-
-s16 akao_wave_table[ 708 ] =
-{
-      8191,  -8191,  16383, -16383,  24575, -24575,  32767, -32767,     0,      0,     -2,      0,  32767, -32767,      0,      0,
-        -2,      0,   8191,      0,  16383,      0,  24575,      0, 32767,      0,      0,     -2,  32767,      0,  32767,      0,
-         0,     -2,  -8191,      0, -16383,      0, -24575,      0,-32767,      0,      0,     -2, -32767,      0, -32767,      0,
-         0,     -2,      0,   1280,   2530,   4813,   5790,   6625,  7297,   7789,   8090,   8191,   8092,   7793,   7302,   6632,
-      5799,   4823,   3728,   2542,   1293,      0,  -1268,  -2518, -3706,  -4803,  -5782,  -6618,  -7292,  -7786,  -8089,  -8192,
-     -8095,  -7798,  -7309,  -6641,  -5809,  -4835,  -3741,  -2556, -1307,      0,   2561,   5060,   9626,  11580,  13250,  14594,
-     15578,  16180,  16383,  16184,  15586,  14605,  13265,  11599,  9647,   7457,   5085,   2587,      0,  -2536,  -5036,  -7412,
-     -9605, -11563, -13235, -14583, -15571, -16177, -16384, -16189,-15595, -14618, -13281, -11618,  -9669,  -7482,  -5111,  -2614,
-         0,   3842,   7590,  14439,  17370,  19875,  21891,  23367, 24270,  24575,  24276,  23379,  21908,  19898,  17398,  14470,
-     11186,   7627,   3881,      0,  -3804,  -7554, -11118, -14408,-17344, -19853, -21874, -23357, -24265, -24576, -24284, -23393,
-    -21927, -19922, -17427, -14503, -11223,  -7666,  -3921,      0,  5123,  10120,  19252,  23161,  26500,  29188,  31157,  32360,
-     32767,  32369,  31173,  29211,  26531,  23198,  19294,  14915, 10170,   5175,      0,  -5072, -10072, -14823, -19210, -23125,
-    -26470, -29165, -31142, -32353, -32768, -32378, -31190, -29236,-26562, -23235, -19337, -14963, -10221,  -5227,      0,      0,
-       -39,      0,      0,   5123,  10120,  19252,  23161,  26500, 29188,  31157,  32360,  32767,  32369,  31173,  29211,  26531,
-     23198,  19294,  14915,  10170,   5175,      0,  -5072, -10072,-14823, -19210, -23125, -26470, -29165, -31142, -32353, -32768,
-    -32378, -31190, -29236, -26562, -23235, -19337, -14963, -10221, -5227,      0,      0,    -39,      0,   2530,   4813,   6625,
-      7789,   8191,   7793,   6632,   4823,   2542,     13,  -2518, -4803,  -6618,  -7786,  -8192,  -7798,  -6641,  -4835,  -2556,
-         0,   5060,   9626,  13250,  15578,  16383,  15586,  13265,  9647,   5085,     26,  -5036,  -9605, -13235, -15571, -16384,
-    -15595, -13281,  -9669,  -5111,      0,   7590,  14439,  19875, 23367,  24575,  23379,  19898,  14470,   7627,     39,  -7554,
-    -14408, -19853, -23357, -24576, -23393, -19922, -14503,  -7666,     0,  10120,  19252,  26500,  31157,  32767,  31173,  26531,
-     19294,  10170,     52, -10072, -19210, -26470, -31142, -32768,-31190, -26562, -19337, -10221,      0,      0,    -20,      0,
-         0,  10120,  19252,  26500,  31157,  32767,  31173,  26531, 19294,  10170,     52, -10072, -19210, -26470, -31142, -32768,
-    -31190, -26562, -19337, -10221,      0,      0,    -20,      0,     0,   2047,   4095,   6143,   8191,   6143,   4095,   2047,
-         0,  -2047,  -4095,  -6143,  -8191,  -6143,  -4095,  -2047,     0,   4095,   8191,  12287,  16383,  12287,   8191,   4095,
-         0,  -4095,  -8191, -12287, -16383, -12287,  -8191,  -4095,     0,   6143,  12287,  18431,  24575,  18431,  12287,   6143,
-         0,  -6143, -12287, -18431, -24575, -18431, -12287,  -6143,     0,   8191,  16383,  24575,  32767,  24575,  16383,   8191,
-         0,  -8191, -16383, -24575, -32767, -24575, -16383,  -8191,     0,      0,    -16,      0,      0,   8191,  16383,  24575,
-     32767,  24575,  16383,   8191,      0,  -8191, -16383, -24575,-32767, -24575, -16383,  -8191,      0,      0,    -16,      0,
-         0,  12797,  32005,  -2563,  -4882,  31036,  30160,   2044, -3055, -15627,  26127,  13070,  16362, -16671, -29678,   6177,
-    -20485,  18944, -11289,  -2827,  -7881,  -6189,  21005,   4355,-20769,  19192,   1862,  28916, -28991, -26855,  13586,  -2560,
-      6912, -19223,  15134, -20971, -25400,  26105, -15581,  29176, 11505, -23036, -27908, -14066, -20471,   4325,   2052, -32767,
-      4858,   4376,  -6391,  18424, -27175,  -8932,   6921,   3060, 31740,   8447, -27644,  32252, -29963, -18665,  29945,  11004,
-     -8954, -10253,  -2819,   1544,  -3560,  27103, -17401,  19191,-30229, -17625,   4361,  32751,  13845,  -4915,  30241, -26603,
-     22223, -11258,  13090,  -8218, -20726, -17931, -12792,  23813,-16402,  -4070,   8424, -24810, -29454, -15641, -11730, -14847,
-    -17968, -32500,  17187,  10461, -26889,  23612, -24610, -20760,-18917,  16115,   5128,  -9495,  11275, -20173, -22303,   1498,
-      2324,  20002,    -24, -30735,   8688, -29403,  32252,   7408, 24081,  15848, -14582, -28905,    -16,  27149,    -29,   4851,
-      1055,  30732, -15121,  23298,  15618,    754,   5401,  -9515,-17143, -28135,  -2813,  25309,  14342,   3878, -22277,  -7938,
-     -2333,   3586,    528,  17414, -27436, -12022, -22458,   4337,  6860, -16899,   6704, -24341,  24554, -16624, -17425,  -8421,
-    -15860,  10976,  16114, -20953,  20481,  -1571,  13841, -21222,  2015,  27909,   6669, -18725,  27947,  13831,  -1076,  16904,
-      3873,  14070, -14330,   1539,   -553,  30743,   1541, -20725,-27140,   4332, -22770, -21005,  26127, -16910,  -8456,  -7135,
-    -19993,   -787,  23324, -24311, -13070,  -2573, -25861, -19433,-27928,  32520,  19450, -30211,  15388,   -785,  -3365,  18973,
-     26397, -10497,  26074,  -3588,  28170,   2572,   4600,  18946, 23548,  -5370, -23059,  12518, -32751, -11724,   2296,  17372,
-     -2551, -22798, -26099,  28678,  -2582, -25348, -32482, -21018, -6642, -27145, -19708, -25345,  -4118,  -2791,  -1536,  15094,
-    -14379,  10018, -17608,  17361,  30701,  18696, -12798, -21745, 15851,  -9462,  25601,  16377,  30450, -27895, -11761,  29925,
-         0,      0,   -256,      0
-};
-
-u16 akao_wave_table_key_nodes[ 16 ] =
-{
-    0, 12, 18, 28, 34, 44, 50, 210, 360, 428, 252, 336, 448, 428, 360, 428
-};
-
-u8 opcode_size[ 96 ] =
-{
-    00, 02, 02, 02, 03, 02, 01, 01, 02, 03, 02, 03, 02, 02, 02, 02, // a0-af
-    03, 02, 02, 01, 04, 02, 01, 02, 04, 02, 01, 02, 03, 02, 01, 02, // b0-bf
-    02, 02, 01, 01, 01, 01, 01, 01, 01, 00, 00, 00, 01, 00, 02, 02, // c0-cf
-    01, 00, 02, 02, 01, 01, 01, 01, 02, 02, 02, 00, 02, 03, 03, 03, // d0-df
-    00, 00, 00, 00, 00, 00, 00, 00, 03, 04, 03, 04, 03, 01, 00, 00, // e0-ef
-    00, 00, 02, 01, 03, 01, 02, 03, 02, 01, 00, 00, 00, 03, 03, 00, // f0-ff
-};
-
-
-
-AkaoParser *AKAOPARSER = NULL;
-
-
-
-AkaoParser::AkaoParser():
-    music_( NULL )
-{
-    memset( ( u8* )m_MusicChannelData, 0x00, sizeof( ChannelData ) * 24 );
-}
-
-
-
-AkaoParser::~AkaoParser()
-{
-}
-
-
-
-void
-AkaoParser::Update()
-{
-    UpdateDynamicSpuParameters();
-
-
-
-    if ( m_MusicChannelConfig.active_channel_mask != 0 )
-    {
-        //V1 = w[80062fea];
-        u32 tempo = m_MusicChannelConfig.tempo >> 0x10;
-/*
-        if (V1 != 0)
-        {
-            if (V1 < 80)
-            {
-                tempo += (tempo * V1) >> 0x7;
-            }
-            else
-            {
-                tempo = (tempo * V1) >> 0x8;
-            }
-        }
-*/
-        m_MusicChannelConfig.tempo_counter += tempo;
-
-
-
-        if ( ( m_MusicChannelConfig.tempo_counter & 0xffff0000 ) /*|| ( w[80062ff8] & 00000004 )*/ )
-        {
-            m_MusicChannelConfig.tempo_counter &= 0x0000ffff;
-            //[80062f04] = w(0);
-
-            u32 channel_mask = m_MusicChannelConfig.active_channel_mask;
-            int channel_id = 0;
-            for ( u32 bit = 1; channel_mask != 0; bit <<= 1, channel_id += 1 )
-            {
-                if ( channel_mask & bit )
-                {
-                    channel_mask ^= bit;
-
-                    m_MusicChannelData[ channel_id ].pause -= 0x0101;
-
-                    if ( ( m_MusicChannelData[ channel_id ].pause & 0x00ff ) == 0 )
-                    {
-                        UpdateSequence( m_MusicChannelData, channel_id, m_MusicChannelConfig );
-                    }
-                    else if ( ( m_MusicChannelData[ channel_id ].pause & 0xff00 ) == 0 )
-                    {
-                        m_MusicChannelData[ channel_id ].pause |= 0x100;
-                        m_MusicChannelConfig.unknown_0c &= ~bit;
-                        m_MusicChannelConfig.unknown_10 |= bit;
-                    }
-
-                    UpdateCounters( m_MusicChannelData, channel_id, m_MusicChannelConfig );
-                }
-            }
-
-            if ( m_MusicChannelConfig.tempo_increment_counter != 0 )
-            {
-                m_MusicChannelConfig.tempo_increment_counter -= 1;
-
-                m_MusicChannelConfig.tempo += m_MusicChannelConfig.tempo_increment;
-            }
-
-            if( m_MusicChannelConfig.reverb_depth_increment_counter != 0 )
-            {
-                m_MusicChannelConfig.reverb_depth_increment_counter -= 1;
-                m_MusicChannelConfig.reverb_depth += m_MusicChannelConfig.tempo_increment_counter;
-                m_MusicChannelConfig.spu_update_flags |= SPU_REVERB;
-            }
-
-            if( m_MusicChannelConfig.lower_timer_top != 0 )
-            {
-                m_MusicChannelConfig.lower_timer += 1;
-
-                if( m_MusicChannelConfig.lower_timer == m_MusicChannelConfig.lower_timer_top )
-                {
-                    m_MusicChannelConfig.lower_timer = 0;
-                    m_MusicChannelConfig.upper_timer += 1;
-
-                    if( m_MusicChannelConfig.upper_timer == m_MusicChannelConfig.upper_timer_top )
-                    {
-                        m_MusicChannelConfig.upper_timer = 0;
-                        m_MusicChannelConfig.top_timer += 1;
-                    }
-                }
-            }
-        }
-    }
-}
-
-
-
-void
-AkaoParser::LoadInstruments( const Ogre::String& all_file, const Ogre::String& dat_file )
-{
-    // load instruments adpsm
-    {
-        File* file = new File( all_file );
-
-        u32 address = file->GetU32LE( 0x0 ) / 8;
-        u32 datasize = file->GetU32LE( 0x4 );
-
-        u8* buffer = new u8[ datasize ];
-        file->GetFileBuffer( buffer, 0x10, datasize );
-
-        if ( !SOUNDMAN->PsxWriteDMA( address, buffer, datasize ) )
-        {
-            LOGGER->Log( "[AkaoParser::LoadVoiceData] error: failed to DMA write sample data.\n" );
-        }
-
-        delete[] buffer;
-        delete file;
-    }
-
-
-
-    {
-        File* file = new File( dat_file );
-
-        int file_size = file->GetFileSize();
-
-        // load index records
-        InstrumentData data;
-        for ( int i = 0; i < file_size; i += 0x40 )
-        {
-            data.start_offset = file->GetU32LE( i + 0x00 );
-            data.loop_offset = file->GetU32LE( i + 0x04 );
-            data.attack_rate = file->GetU8( i + 0x08 );
-            data.decay_rate = file->GetU8( i + 0x09 );
-            data.sustain_level = file->GetU8( i + 0x0a );
-            data.sustain_rate = file->GetU8( i + 0x0b );
-            data.release_rate = file->GetU8( i + 0x0c );
-            data.attack_mode = file->GetU8( i + 0x0d );
-            data.sustain_mode = file->GetU8( i + 0x0e );
-            data.release_mode = file->GetU8( i + 0x0f );
-            data.pitch[ 0 ] = file->GetU32LE( i + 0x10 );
-            data.pitch[ 1 ] = file->GetU32LE( i + 0x14 );
-            data.pitch[ 2 ] = file->GetU32LE( i + 0x18 );
-            data.pitch[ 3 ] = file->GetU32LE( i + 0x1c );
-            data.pitch[ 4 ] = file->GetU32LE( i + 0x20 );
-            data.pitch[ 5 ] = file->GetU32LE( i + 0x24 );
-            data.pitch[ 6 ] = file->GetU32LE( i + 0x28 );
-            data.pitch[ 7 ] = file->GetU32LE( i + 0x2c );
-            data.pitch[ 8 ] = file->GetU32LE( i + 0x30 );
-            data.pitch[ 9 ] = file->GetU32LE( i + 0x34 );
-            data.pitch[ 10 ] = file->GetU32LE( i + 0x38 );
-            data.pitch[ 11 ] = file->GetU32LE( i + 0x3c );
-
-            m_InstrumentData.push_back( data );
-        }
-
-        delete file;
-    }
-}
-
-
-
-void
-AkaoParser::UnloadInstruments()
-{
-    m_InstrumentData.clear();
-}
-
-
-
-void
-AkaoParser::PlayMusic( const Ogre::String& file )
-{
-    if ( music_ != NULL )
-    {
-        delete music_;
-    }
-    music_ = new File( file );
-
-
-
-    if ( music_->GetU8( 0 ) == 0x41 && music_->GetU8( 1 ) == 0x4b && music_->GetU8( 2 ) == 0x41 && music_->GetU8( 3 ) == 0x4f) // AKAO
-    {
-        int music_id = music_->GetU16LE( 4 );
-        int length = music_->GetU16LE( 6 );
-        int reverb_mode = music_->GetU16LE( 8 );
-
-        //A0 = reverb_mode;
-        //func29af0;
-
-        //[V0 + 0] = w(w[8009a000]);
-        //[V0 + 4] = w(akao_offset + 16);
-        //[V0 + 8] = w(frame_length);
-        //[V0 + c] = w(frame_id);
-        //[V0 + 10] = w(w[8009a008]);
-
-
-/*
-        if (m_MusicChannelConfig.active_channel_mask != 0)
-        {
-            A2 = 80096608;
-
-            V0 = w[8009a128];
-            V1 = w[8009a12c];
-
-            [8009a12c] = w(0);
-            [8009a128] = w(0);
-            [8009a110] = w(0);
-
-            m_MusicChannelConfig.for_play_channel_mask = 0;
-
-            A0 = m_MusicChannelConfig.active_channel_mask | V0 | V1;
-            m_MusicChannelConfig.active_channel_mask = A0;
-            [8009a114] = w(A0 | w[8009a114]);
-
-            A1 = 1;
-            loop29f18:	; 80029F18
-                if (A0 XOR A1)
-                {
-                    A0 = A0 XOR A1;
-                    [A2 + 56] = h(204);
-                    [A2 + 0] = w(80049c40);
-                }
-
-                A1 = A1 << 1;
-                A2 = A2 + 108;
-            80029F34	bne    a0, zero, loop29f18 [$80029f18]
-        }
-*/
-
-
-
-        //[8009a114] = w(w[8009a114] | 00ffffff);
-
-
-
-        u16 offset_to_akao = 0;
-        m_MusicChannelConfig.active_channel_mask = music_->GetU32LE( 0x10 ) & 0x00ffffff;
-        u32 channel_mask = m_MusicChannelConfig.active_channel_mask;
-        int channel_id = 0;
-        for ( u32 bit = 1; channel_mask != 0; bit <<= 1, channel_id += 1 )
-        {
-            if ( channel_mask & bit )
-            {
-                channel_mask ^= bit;
-
-                m_MusicChannelData[ channel_id ].akao_sequence_pointer = 20 + offset_to_akao + 2 + music_->GetU16LE( 20 + offset_to_akao );
-                offset_to_akao += 2;
-                //LOGGER->Log( "Init channel " + ToIntString( channel_id ) + " with offset to AKAO " + ToHexString( m_MusicChannelData[ channel_id ].akao_sequence_pointer, 4, '0' ) + "\n" );
-
-                InitChannelInstrument( m_MusicChannelData, channel_id, 0x14 );
-
-                //[S3 + 14] = w(80083580);
-                m_MusicChannelData[ channel_id ].volume_multiplier = 0x7f;
-                m_MusicChannelData[ channel_id ].pitch_addition = 0;
-                m_MusicChannelData[ channel_id ].mirror_update_flags = 0;
-                m_MusicChannelData[ channel_id ].volume_level = 0x3fff0000;
-                m_MusicChannelData[ channel_id ].pause = 0x103;
-                m_MusicChannelData[ channel_id ].volume_level_change_ticks = 0;
-                //[S3 + 5e] = h(0);
-                m_MusicChannelData[ channel_id ].volume_index = 0x4000;
-                m_MusicChannelData[ channel_id ].unknown_62 = 0;
-                m_MusicChannelData[ channel_id ].unknown_64 = 0;
-                m_MusicChannelData[ channel_id ].unknown_6c = 0;
-                m_MusicChannelData[ channel_id ].unknown_6e = 0;
-                m_MusicChannelData[ channel_id ].wave1_modifier = 0;
-                //[S3 + 80] = h(0);
-                //[S3 + 90] = h(0);
-                //[S3 + 92] = h(0);
-                //[S3 + 9e] = h(0);
-                //[S3 + a0] = h(0);
-                //[S3 + a4] = h(0);
-                //[S3 + a6] = h(0);
-                m_MusicChannelData[ channel_id ].loop_index = 0;
-                m_MusicChannelData[ channel_id ].saved_pause = 0;
-                m_MusicChannelData[ channel_id ].pause_multiplier = 0;
-                //[S3 + c6] = h(4000);
-                m_MusicChannelData[ channel_id ].pitch_selector = 0;
-                m_MusicChannelData[ channel_id ].pitch_modifier = 0;
-                m_MusicChannelData[ channel_id ].unknown_d2 = 0;
-                //[S3 + da] = h(0);
-            }
-        }
-
-        m_MusicChannelConfig.for_play_channel_mask = 0;
-/*
-        [8009a110] = w(0);
-*/
-
-        m_MusicChannelConfig.tempo = 0xffff0000;
-        m_MusicChannelConfig.tempo_counter = 1; // this way we update sequence on next update
-/*
-        [8009a128] = w(0);
-        [8009a12c] = w(0);
-        [8009a130] = w(0);
-        [8009a134] = w(0);
-        [8009a138] = w(0);
-*/
-        m_MusicChannelConfig.spu_update_flags = 0;
-        m_MusicChannelConfig.reverb_depth = 0;
-        //[8009a148] = w(0);
-
-        m_MusicChannelConfig.tempo_increment_counter = 0;
-
-        //[8009a150] = h(0);
-        //[8009a152] = h(0);
-        m_MusicChannelConfig.reverb_depth_increment_counter = 0;
-        //[8009a158] = h(0);
-        m_MusicChannelConfig.upper_timer_top = 0;
-        m_MusicChannelConfig.upper_timer = 0;
-        m_MusicChannelConfig.lower_timer_top = 0;
-        m_MusicChannelConfig.lower_timer = 0;
-        m_MusicChannelConfig.top_timer = 0;
-/*
-        [8009a15e] = h(0);
-        [8009a160] = h(0);
-        [8009a162] = h(0);
-
-        if (w[80062ff8] & 1)
-        {
-            [8009a108] = w(0);
-            [8009a118] = w(w[8009a108]);
-        }
-
-        func2ff4c
-
-        func30038
-
-        func30148
-*/
-    }
-}
-
-
-
-void
-AkaoParser::UpdateDynamicSpuParameters()
-{
-    u32 for_play_channel_mask = 0;
-
-
-
-    if( m_MusicChannelConfig.spu_update_flags & SPU_REVERB )
-    {
-        s16 reverb_depth = m_MusicChannelConfig.reverb_depth >> 0x10;
-        /* looks like update of total reverb volume if this is ever used
-        V1 = hu[80062fb8];
-        if (V1 < 80)
-        {
-            reverb_depth = reverb_depth + ((reverb_depth * V1) >> 7);
-        }
-        else
-        {
-            reverb_depth = (reverb_depth * V1) >> 8;
-        }
-        */
-        u8 pan = 0x40 /*hu[80062f70]*/;
-        s16 left = reverb_depth;
-        s16 right = reverb_depth;
-        if( pan < 0x40 )
-        {
-            right = reverb_depth - ( ( reverb_depth * ( pan ^ 0x3f ) ) >> 6 );
-        }
-        else
-        {
-            left = reverb_depth - ( ( reverb_depth * ( pan & 0x3f ) ) >> 6 );
-        }
-
-        SOUNDMAN->PsxSetReverbDepth( left, right );
-
-        m_MusicChannelConfig.spu_update_flags ^= SPU_REVERB;
-    }
-
-
-
-    if ( m_MusicChannelConfig.active_channel_mask != 0 )
-    {
-        for_play_channel_mask |= m_MusicChannelConfig.for_play_channel_mask;
-        u32 channel_mask = m_MusicChannelConfig.active_channel_mask;
-        int channel_id = 0;
-        for ( u32 bit = 1; channel_mask != 0; bit <<= 1, channel_id += 1 )
-        {
-            if ( channel_mask & bit )
-            {
-                channel_mask ^= bit;
-
-                UpdatePitchAndVolume( m_MusicChannelData, channel_id );
-
-                if ( m_MusicChannelData[ channel_id ].spu_update_flags )
-                {
-                    UpdateSpu( m_MusicChannelData, channel_id );
-                }
-            }
-        }
-
-        m_MusicChannelConfig.for_play_channel_mask = 0;
-    }
-
-
-
-    if ( for_play_channel_mask != 0 )
-    {
-        UpdatePlayChannel( true, for_play_channel_mask );
-    }
-}
-
-
-
-void
-AkaoParser::UpdatePitchAndVolume( ChannelData* channel_data, int channel_id )
-{
-    int temp = ( ( channel_data[ channel_id ].volume_level >> 16) * channel_data[ channel_id ].volume_multiplier ) >> 7;
-
-    if ( channel_data[ channel_id ].spu_update_flags & ( SPU_LEFT_VOLUME | SPU_RIGHT_VOLUME ) )
-    {
-        //temp = ( ( temp + h[T0 + d8] ) * ( hu[80062f5e] & 0x7f ) ) >> 7;
-        temp = ( temp * 0x7f ) >> 7;
-
-/*
-        if (hu[8009c5a8] != 0)
-        {
-            temp = (temp * h[8009c5a2 + channel_id * c]) >> 7;
-        }
-*/
-
-
-        int volume_index = ( /*h[T0 + da] + */channel_data[ channel_id ].volume_index >> 8) & 0xff;
-
-/*
-        V1 = w[8009a104];
-        if (V1 == 1) // stereo
-*/
-        {
-            channel_data[ channel_id ].left_volume = ( temp * akao_left_volume_table[ volume_index ] ) >> 0xf;
-            channel_data[ channel_id ].right_volume = ( temp * akao_right_volume_table[ volume_index ] ) >> 0xf;
-        }
-/*
-        else if (V1 == 4)
-        {
-            channel_data[ channel_id ].left_volume = (temp * akao_left_volume_table[ volume_index ] ) >> 0xf;
-            channel_data[ channel_id ].right_volume = (temp * akao_right_volume_table[ volume_index ] ) >> 0xf;
-
-            if (A1 & 00aaaaaa == 0)
-            {
-                channel_data[ channel_id ].left_volume = 0 NOR channel_data[ channel_id ].left_volume;
-            }
-            else
-            {
-                channel_data[ channel_id ].right_volume = 0 NOR channel_data[ channel_id ].right_volume;
-            }
-        }
-        else
-        {
-            channel_data[ channel_id ].left_volume = ( temp * h[80049cc4]) >> 0xf;
-            channel_data[ channel_id ].right_volume = ( temp * h[80049cc4]) >> 0xf;
-        }
-*/
-    }
-
-
-
-    u16 new_pitch = 0;
-/*
-    if (w[T0 + 38] & 00000010)
-    {
-        V1 = h[T0 + d6] + h[T0 + 36] + w[T0 - 10]; // uses pitch from previous channel
-    }
-    else*/
-    if ( channel_data[ channel_id ].spu_update_flags & SPU_PITCH )
-    {
-        new_pitch = channel_data[ channel_id ].pitch_base + ( channel_data[ channel_id ].pitch_addition >> 0x10 ) + channel_data[ channel_id ].pitch_addition2;
-    }
-
-
-
-    if (/*(w[T0 + 38] & 00000010) ||*/ ( channel_data[ channel_id ].spu_update_flags & SPU_PITCH ) )
-    {
-        channel_data[ channel_id ].spu_update_flags |= SPU_PITCH;
-        channel_data[ channel_id ].pitch = new_pitch & 0x3fff;
-    }
-}
-
-
-
-void
-AkaoParser::UpdateSpu( ChannelData* channel_data, int channel_id )
-{
-    //S1 = A0;
-    //S0 = A1;
-
-    if ( channel_data[ channel_id ].spu_update_flags & SPU_PITCH )
-    {
-/*
-        A0 = S1;
-        A1 = hu[S0 + 1c]; // f8
-        func395c8;
-*/
-        //LOGGER->Log( "UpdateSpu::SPU_PITCH channel " + Ogre::StringConverter::toString( channel_id ) + " value:" + Ogre::StringConverter::toString( channel_data[ channel_id ].pitch ) + ".\n" );
-        SOUNDMAN->SetVoicePitch( channel_id, channel_data[ channel_id ].pitch );
-        channel_data[ channel_id ].spu_update_flags &= ~SPU_PITCH;
-    }
-
-    if ( channel_data[ channel_id ].spu_update_flags & ( SPU_LEFT_VOLUME | SPU_RIGHT_VOLUME ) )
-    {
-/*
-        A0 = S1;
-        A1 = h[S0 + 28]; // 104
-        A2 = h[S0 + 2a]; // 106
-        func393c8;
-*/
-        //LOGGER->Log( "UpdateSpu::SPU_LEFT_VOLUME|SPU_RIGHT_VOLUME channel " + Ogre::StringConverter::toString( channel_id ) + " value:" + Ogre::StringConverter::toString( channel_data[ channel_id ].left_volume ) + " " + Ogre::StringConverter::toString( channel_data[ channel_id ].right_volume ) + ".\n" );
-        SOUNDMAN->SetVoiceVolume( channel_id, channel_data[ channel_id ].left_volume, channel_data[ channel_id ].right_volume );
-        channel_data[ channel_id ].spu_update_flags &= ~( SPU_LEFT_VOLUME | SPU_RIGHT_VOLUME );
-    }
-
-    if ( channel_data[ channel_id ].spu_update_flags & SPU_START_OFFSET )
-    {
-/*
-        A0 = S1;
-        A1 = w[S0 + 8];
-        func39644; // we set start address here
-*/
-        //LOGGER->Log( "UpdateSpu::SPU_START_OFFSET channel " + Ogre::StringConverter::toString( channel_id ) + " value:" + Ogre::StringConverter::toString( channel_data[ channel_id ].start_offset ) + ".\n" );
-        SOUNDMAN->SetVoiceStartAddress( channel_id, channel_data[ channel_id ].start_offset );
-        channel_data[ channel_id ].spu_update_flags &= ~SPU_START_OFFSET;
-    }
-
-    if ( channel_data[ channel_id ].spu_update_flags & SPU_LOOP_OFFSET )
-    {
-/*
-        A0 = S1;
-        A1 = w[S0 + c];
-        func396c0;
-*/
-        //LOGGER->Log( "UpdateSpu::SPU_LOOP_OFFSET channel " + Ogre::StringConverter::toString( channel_id ) + " value:" + Ogre::StringConverter::toString( channel_data[ channel_id ].loop_offset ) + ".\n" );
-        SOUNDMAN->SetVoiceLoopAddress( channel_id, channel_data[ channel_id ].loop_offset );
-        channel_data[ channel_id ].spu_update_flags &= ~SPU_LOOP_OFFSET;
-    }
-
-    if ( channel_data[ channel_id ].spu_update_flags & ( SPU_SUSTAIN_RATE | SPU_SUSTAIN_MODE ) )
-    {
-/*
-        A0 = S1;
-        A1 = h[S0 + 24]; // 100
-        A2 = h[S0 + 14]; // f0
-        func398ec;
-*/
-        //LOGGER->Log( "UpdateSpu::SPU_SUSTAIN_RATE|SPU_SUSTAIN_MODE channel " + Ogre::StringConverter::toString( channel_id ) + " value:" + Ogre::StringConverter::toString( channel_data[ channel_id ].sustain_rate ) + " " + Ogre::StringConverter::toString( channel_data[ channel_id ].sustain_mode ) + ".\n" );
-        SOUNDMAN->SetVoiceSustainRate( channel_id, channel_data[ channel_id ].sustain_rate, (SoundManager::SpuRateMode)channel_data[ channel_id ].sustain_mode );
-        channel_data[ channel_id ].spu_update_flags &= ~( SPU_SUSTAIN_RATE | SPU_SUSTAIN_MODE );
-    }
-
-    if ( channel_data[ channel_id ].spu_update_flags & ( SPU_ATTACK_RATE | SPU_ATTACK_MODE ) )
-    {
-/*
-        A0 = S1;
-        A1 = h[S0 + 1e]; // fa
-        A2 = h[S0 + 10]; // ec
-        func39850;
-*/
-        //LOGGER->Log( "UpdateSpu::SPU_ATTACK_RATE|SPU_ATTACK_MODE channel " + Ogre::StringConverter::toString( channel_id ) + " value:" + Ogre::StringConverter::toString( channel_data[ channel_id ].attack_rate ) + " " + Ogre::StringConverter::toString( channel_data[ channel_id ].attack_mode ) + ".\n" );
-        SOUNDMAN->SetVoiceAttackRate( channel_id, channel_data[ channel_id ].attack_rate, ( SoundManager::SpuRateMode )channel_data[ channel_id ].attack_mode );
-        channel_data[ channel_id ].spu_update_flags &= ~( SPU_ATTACK_RATE | SPU_ATTACK_MODE );
-    }
-
-    if ( channel_data[ channel_id ].spu_update_flags & ( SPU_RELEASE_RATE | SPU_RELEASE_MODE ) )
-    {
-/*
-        A0 = S1;
-        A1 = h[S0 + 26]; // 102 // release rate
-        A2 = h[S0 + 18]; // f4 // release mode
-        func399d0;
-*/
-        //LOGGER->Log( "UpdateSpu::SPU_RELEASE_RATE|SPU_RELEASE_MODE channel " + Ogre::StringConverter::toString( channel_id ) + " value:" + Ogre::StringConverter::toString( channel_data[ channel_id ].release_rate ) + " " + Ogre::StringConverter::toString( channel_data[ channel_id ].release_mode ) + ".\n" );
-        SOUNDMAN->SetVoiceReleaseRate( channel_id, channel_data[ channel_id ].release_rate, (SoundManager::SpuRateMode)channel_data[ channel_id ].release_mode );
-        channel_data[ channel_id ].spu_update_flags &= ~( SPU_RELEASE_RATE | SPU_RELEASE_MODE );
-    }
-
-    if ( channel_data[ channel_id ].spu_update_flags & ( SPU_DECAY_RATE | SPU_SUSTAIN_LEVEL ) )
-    {
-/*
-        A0 = S1;
-        A1 = h[S0 + 20]; // fc // decay rate.
-        func3973c;
-
-        A0 = S1;
-        A1 = h[S0 + 22]; // fe // sustain level.
-        func397c8;
-*/
-        //LOGGER->Log( "UpdateSpu::SPU_DECAY_RATE|SPU_SUSTAIN_LEVEL channel " + Ogre::StringConverter::toString( channel_id ) + " value:" + Ogre::StringConverter::toString( channel_data[ channel_id ].decay_rate ) + " " + Ogre::StringConverter::toString( channel_data[ channel_id ].sustain_level ) + ".\n" );
-        SOUNDMAN->SetVoiceDecayRate( channel_id, channel_data[ channel_id ].decay_rate );
-        SOUNDMAN->SetVoiceSustainLevel( channel_id, channel_data[ channel_id ].sustain_level );
-        channel_data[ channel_id ].spu_update_flags &= ~( SPU_DECAY_RATE | SPU_SUSTAIN_LEVEL );
-    }
-}
-
-
-
-void
-AkaoParser::UpdatePlayChannel( bool on, u32 channel_mask )
-{
-    int channel_id = 0;
-    for ( u32 bit = 1; channel_mask != 0; bit <<= 1, channel_id += 1 )
-    {
-        if ( channel_mask & bit )
-        {
-            channel_mask ^= bit;
-
-            if ( on == true )
-            {
-                SOUNDMAN->PsxChannelPlay( channel_id );
-                std::cout << "Play channel " << channel_id << std::endl;
-            }
-            else
-            {
-                SOUNDMAN->PsxChannelStop( channel_id );
-                std::cout << "Stop channel " << channel_id << std::endl;
-            }
-        }
-    }
-}
-
-
-
-void
-AkaoParser::UpdateSequence( ChannelData* channel_data, int channel_id, ChannelConfig& channel_config )
-{
-    //LOGGER->Log( "UpdateSequence for channel " + ToIntString( channel_id ) + "\n" );
-
-    u8 opcode;
-
-    for( ;; )
-    {
-        opcode = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer );
-
-        if( opcode < 0xa0 )
-        {
-            channel_data[ channel_id ].akao_sequence_pointer += 1;
-            break;
-        }
-        else if( opcode == 0xa1 ) // load instrument
-        {
-            LOGGER->Log( "    0xA1 [NOT COMPLETE] " );
-            int instrument_id = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 1 );
-            //LOGGER->Log( "Load instrument " + ToIntString( instrument_id ) + "with 0xA1.\n" );
-
-/*
-            A0 = hu[A3 + 24];
-
-            if (w[80062f04] != 0)
-            {
-                A0 = A0 - 18;
-            }
-
-            if (w[A3 + 38] & 00000100)
-            {
-                [A1 + 24] = w(w[A1 + 24] & (0 NOR (1 << A0)))
-                [A3 + 38] = w(w[A3 + 38] & fffffeff)
-            }
-
-            if (hu[A3 + 54] != 0 || (A2 & w[A1 + c] & w[80099fcc]) == 0)
-            {
-                [A3 + e0] = w(w[A3 + e0] | 00000010);
-                [A3 + 30] = w((w[A3 + 30] * w[80075f28 + instrument_id * 40 + 10]) / w[80075f28 + hu[A3 + 58] * 40 + 10]);
-            }
-*/
-            // if loaded adsr release rate, load rest
-            // note from G
-            /*
-            if (w[A3 + 38] & 00000200)
-            {
-                InstrumentData data = m_InstrumentData[ instrument_id ];
-
-                channel_data[ channel_id ].instrument_id = instrument_id;
-                channel_data[ channel_id ].start_offset = data.start_offset;
-                channel_data[ channel_id ].loop_offset = data.loop_offset;
-                channel_data[ channel_id ].attack_rate = data.attack_rate;
-                channel_data[ channel_id ].decay_rate = data.decay_rate;
-                channel_data[ channel_id ].attack_mode = data.attack_mode;
-                channel_data[ channel_id ].sustain_mode = data.sustain_mode;
-                channel_data[ channel_id ].sustain_level = data.sustain_level;
-                channel_data[ channel_id ].sustain_rate = data.sustain_rate;
-                channel_data[ channel_id ].spu_update_flags |=
-                    SPU_START_OFFSET | SPU_ATTACK_RATE | SPU_SUSTAIN_RATE |
-                    SPU_ATTACK_MODE | SPU_DECAY_RATE | SPU_SUSTAIN_MODE |
-                    SPU_SUSTAIN_LEVEL | SPU_LOOP_OFFSET; // update everything we just set
-            }
-            else // init all data
-            */
-            {
-                InitChannelInstrument( channel_data, channel_id, instrument_id );
-            }
-
-            channel_data[ channel_id ].akao_sequence_pointer += 2;
-        }
-        else if( opcode == 0xa2 ) // pause
-        {
-            LOGGER->Log( "    0xA2 " );
-            u8 value = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 1 );
-            channel_data[ channel_id ].pause_multiplier = 0;
-            channel_data[ channel_id ].saved_pause = value;
-            channel_data[ channel_id ].pause = ( value << 8 ) | value;
-            //LOGGER->Log( "Set pause to 0x" + ToHexString( value, 2, '0' ) + ".\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 2;
-        }
-        else if( opcode == 0xa3 ) // set volume multiplier
-        {
-            LOGGER->Log( "    0xA3 " );
-            channel_data[ channel_id ].volume_multiplier = ( s8 )( music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 1 ) );
-            channel_data[ channel_id ].spu_update_flags |= SPU_LEFT_VOLUME | SPU_RIGHT_VOLUME;
-            //LOGGER->Log( "Set volume multiplier to 0x" + ToHexString( channel_data[ channel_id ].volume_multiplier, 2, '0' ) + ".\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 2;
-        }
-        else if( opcode == 0xa5 ) // set pitch correction
-        {
-            LOGGER->Log( "    0xA5 " );
-            channel_data[ channel_id ].pitch_correction = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 1 );
-            //LOGGER->Log( "Set pitch correction to 0x" + ToHexString( channel_data[ channel_id ].pitch_correction, 4, '0' ) + ".\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 2;
-        }
-        else if( opcode == 0xa6 ) // increment pitch correction
-        {
-            LOGGER->Log( "    0xA6 Increment pitch correction.\n" );
-            channel_data[ channel_id ].pitch_correction = ( channel_data[ channel_id ].pitch_correction + 1 ) & 0xf;
-            channel_data[ channel_id ].akao_sequence_pointer += 1;
-        }
-        else if( opcode == 0xa7 ) // decrement pitch correction
-        {
-            LOGGER->Log( "    0xA7 Decrement pitch correction.\n" );
-            channel_data[ channel_id ].pitch_correction = ( channel_data[ channel_id ].pitch_correction - 1 ) & 0xf;
-            channel_data[ channel_id ].akao_sequence_pointer += 1;
-        }
-        else if( opcode == 0xa8 ) // set volume
-        {
-            LOGGER->Log( "    0xA8 " );
-            channel_data[ channel_id ].volume_multiplier = ( s8 )( music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 1 ) );
-            channel_data[ channel_id ].spu_update_flags |= SPU_LEFT_VOLUME | SPU_RIGHT_VOLUME;
-            channel_data[ channel_id ].volume_level_change_ticks = 0;
-            channel_data[ channel_id ].volume_level = ( s8 )( music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 1 ) ) << 0x17;
-            //LOGGER->Log( "Set volume to 0x" + ToHexString(channel_data[ channel_id ].volume_level, 8, '0' ) + " and reset volume_level_change_ticks.\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 2;
-        }
-        else if( opcode == 0xa9 ) // set volume increase/descrease
-        {
-            LOGGER->Log( "    0xA9 " );
-            u16 value1 = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 1 );
-            s8 value2 = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 2 );
-            value1 = ( value1 == 0 ) ? 0x100 : value1;
-            channel_data[ channel_id ].volume_level_change_ticks = value1;
-            channel_data[ channel_id ].volume_level &= 0xffff0000;
-            channel_data[ channel_id ].volume_level_add = ( ( value2 << 0x17 ) - channel_data[ channel_id ].volume_level ) / channel_data[ channel_id ].volume_level_change_ticks;
-            //LOGGER->Log( "Set volume tick to 0x" + ToHexString( channel_data[ channel_id ].volume_level_change_ticks, 4, '0' ) + " and " );
-            //LOGGER->Log( "volume_level_add 0x" + ToHexString( channel_data[ channel_id ].volume_level_add, 8, '0' ) + ".\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 3;
-        }
-        else if( opcode == 0xaa ) // set volume pan
-        {
-            LOGGER->Log( "    0xAA " );
-            channel_data[ channel_id ].spu_update_flags |= SPU_LEFT_VOLUME | SPU_RIGHT_VOLUME;
-            channel_data[ channel_id ].volume_index = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 1 ) << 0x8;
-            channel_data[ channel_id ].unknown_62 = 0;
-            //LOGGER->Log( "Set volume pan to 0x" + ToHexString( channel_data[ channel_id ].volume_index, 4, '0' ) + ".\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 2;
-        }
-        else if( opcode == 0xad ) // ???
-        {
-            LOGGER->Log( "    0xAD [UNIMPLEMENTED]\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 2;
-        }
-        else if( opcode == 0xb1 ) // ???
-        {
-            LOGGER->Log( "    0xB1 [UNIMPLEMENTED]\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 2;
-        }
-        else if( opcode == 0xb4 ) // set wave 1
-        {
-            LOGGER->Log( "    0xB4 " );
-            channel_data[ channel_id ].mirror_update_flags &= 0x00000001;
-
-            u16 value1 = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 1 );
-            u16 value2 = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 2 );
-            u16 value3 = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 3 );
-
-            if( channel_data[ channel_id ].unknown_54 != 0 )
-            {
-                channel_data[ channel_id ].wave1_delay = 0;
-
-                if( value1 != 0 )
-                {
-                    channel_data[ channel_id ].wave1_modifier = value1 << 0x8;
-                }
-            }
-            else
-            {
-                channel_data[ channel_id ].wave1_delay = value1;
-            }
-
-            if( value2 == 0 )
-            {
-                value2 = 0x100;
-            }
-
-            channel_data[ channel_id ].wave1_refresh_interval = value2;
-            channel_data[ channel_id ].wave1_table_node_index = value3;
-            u16 pitch_base = channel_data[ channel_id ].pitch_base;
-            if( ( channel_data[ channel_id ].wave1_modifier & 0x8000 ) == 0 )
-            {
-
-                pitch_base = ( pitch_base * 0xf ) >> 8;
-            }
-
-            channel_data[ channel_id ].wave1_multiplier = ( ( ( channel_data[ channel_id ].wave1_modifier & 0x7f00 ) >> 8 ) * pitch_base ) >> 7;
-            channel_data[ channel_id ].wave1_delay_current = channel_data[ channel_id ].wave1_delay;
-            channel_data[ channel_id ].wave1_refresh_interval_counter = channel_data[ channel_id ].wave1_table_node_index;
-            channel_data[ channel_id ].wave1_table_index = akao_wave_table_key_nodes[ channel_data[ channel_id ].wave1_table_node_index ];
-            //LOGGER->Log( "Set wave1 refresh interval to 0x" + ToHexString( channel_data[ channel_id ].wave1_refresh_interval, 4, '0' ) + " " );
-            //LOGGER->Log( ", wave1 node index to 0x" + ToHexString( channel_data[ channel_id ].wave1_table_node_index, 4, '0' ) + " " );
-            //LOGGER->Log( "and wave1 delay (or wave1 modifier) to 0x" + ToHexString( value1, 2, '0' ) + ".\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 4;
-        }
-        else if( opcode == 0xb5 ) // set wave modifier
-        {
-            LOGGER->Log( "    0xB5 " );
-            channel_data[ channel_id ].wave1_modifier = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 1 ) << 0x8;
-            u16 pitch_base = channel_data[ channel_id ].pitch_base;
-            if( ( channel_data[ channel_id ].wave1_modifier & 0x8000 ) == 0 )
-            {
-                pitch_base = ( pitch_base * 0xf ) >> 8;
-            }
-            channel_data[ channel_id ].wave1_multiplier = ( ( ( channel_data[ channel_id ].wave1_modifier & 0x7f00) >> 8 ) * pitch_base ) >> 7;
-            //LOGGER->Log( "Set wave modifier to 0x" + ToHexString( channel_data[ channel_id ].wave1_modifier, 4, '0' ) + ".\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 2;
-        }
-        else if( opcode == 0xc2 ) // turn reverb on
-        {
-            LOGGER->Log( "    0xC2 [UNIMPLEMENTED]\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 1;
-        }
-        else if( opcode == 0xc8 ) // set loop point
-        {
-            LOGGER->Log( "    0xC8 " );
-            channel_data[ channel_id ].loop_index = ( channel_data[ channel_id ].loop_index + 1 ) & 3;
-            u16 index = channel_data[ channel_id ].loop_index;
-            channel_data[ channel_id ].loop_pointer[ index ] = channel_data[ channel_id ].akao_sequence_pointer + 1;
-            channel_data[ channel_id ].loop_count[ index ] = 0;
-            //LOGGER->Log( "Set loop index 0x" + ToHexString( index, 4, '0' ) + ".\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 1;
-        }
-        else if( opcode == 0xc9 ) // conditional jump
-        {
-            LOGGER->Log( "    0xC9 " );
-
-            u16 value = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 1 );
-            value = ( value == 0 ) ? 0x100 : value;
-
-            u16 index = channel_data[ channel_id ].loop_index;
-
-            channel_data[ channel_id ].loop_count[ index ] += 1;
-            if( channel_data[ channel_id ].loop_count[ index ] != value )
-            {
-                channel_data[ channel_id ].akao_sequence_pointer = channel_data[ channel_id ].loop_pointer[ index ];
-                //LOGGER->Log( "Repeat conditional jump with index 0x" + ToHexString( index, 4, '0' ) + " and value 0x" + ToHexString( value, 4, '0' ) + ". Current loop count 0x" +  ToHexString( channel_data[ channel_id ].loop_count[ index ], 4, '0' ) + "\n" );
-            }
-            else
-            {
-                channel_data[ channel_id ].loop_index = ( index - 1 ) & 3;
-                //LOGGER->Log( "Go through conditional jump with index 0x" + ToHexString( index, 4, '0' ) + " and value 0x" + ToHexString( value, 4, '0' ) + ".\n" );
-            }
-            channel_data[ channel_id ].akao_sequence_pointer += 1;
-        }
-        else if( opcode == 0xcc )
-        {
-            LOGGER->Log( "    0xCC Set unknown_6e to 1.\n" );
-            channel_data[ channel_id ].unknown_6e = 1;
-            channel_data[ channel_id ].akao_sequence_pointer += 1;
-        }
-        else if( opcode == 0xcd ) // does nothing
-        {
-            LOGGER->Log( "    0xCD Do nothing.\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 1;
-        }
-        else if( opcode == 0xd9 )
-        {
-            LOGGER->Log( "    0xD9 [UNIMPLEMENTED]\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 2;
-        }
-        else if( opcode == 0xe0 ) // ???
-        {
-            LOGGER->Log( "    0xE0 [UNIMPLEMENTED]\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 1;
-        }
-        else if( opcode == 0xe2 ) // ???
-        {
-            LOGGER->Log( "    0xE2 [UNIMPLEMENTED]\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 1;
-        }
-        else if( opcode == 0xe8 ) // set tempo
-        {
-            LOGGER->Log( "    0xE8 " );
-            channel_config.tempo = music_->GetU16LE( channel_data[ channel_id ].akao_sequence_pointer + 1 ) << 0x10;
-            channel_config.tempo_increment_counter = 0;
-            //LOGGER->Log( "Set tempo to 0x" + ToHexString( channel_config.tempo, 8, '0' ) + " and reset tempo increment counter to 0.\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 3;
-        }
-        else if( opcode == 0xea ) // set reverb depth
-        {
-            LOGGER->Log( "    0xEA " );
-            channel_config.spu_update_flags |= SPU_REVERB;
-            channel_config.reverb_depth = music_->GetU16LE( channel_data[ channel_id ].akao_sequence_pointer + 1 ) << 0x10;
-            channel_config.reverb_depth_increment_counter = 0;
-            //LOGGER->Log( "Set reverb depth to 0x" + ToHexString( channel_config.reverb_depth, 8, '0' ) + " and reset reverb depth increment counter to 0.\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 3;
-        }
-        else if( opcode == 0xec )
-        {
-            LOGGER->Log( "    0xEC [UNIMPLEMENTED]\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 3;
-        }
-        else if( opcode == 0xee ) // ???
-        {
-            LOGGER->Log( "    0xEE [UNIMPLEMENTED]\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 3;
-        }
-        else if( opcode == 0xf0 )
-        {
-            LOGGER->Log( "    0xF0 [UNIMPLEMENTED]\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 4;
-        }
-        else if( opcode == 0xf1 )
-        {
-            LOGGER->Log( "    0xF1 [UNIMPLEMENTED]\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 4;
-        }
-        else if( opcode == 0xf2 ) // load instrument
-        {
-            LOGGER->Log( "    0xF2 " );
-            int instrument_id = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 1 );
-            //LOGGER->Log( "Load instrument " + ToIntString( instrument_id ) + " with 0xF2.\n" );
-
-            InstrumentData data = m_InstrumentData[ instrument_id ];
-
-            if( ( channel_data[ channel_id ].unknown_54 != 0 ) /*|| ( (A2 & w[A1 + c] & w[80099fcc]) == 0 )*/ )
-            {
-                channel_data[ channel_id ].spu_update_flags |= SPU_PITCH;
-                channel_data[ channel_id ].pitch_base = (  channel_data[ channel_id ].pitch_base * data.pitch[ 0 ] ) / m_InstrumentData[ channel_data[ channel_id ].instrument_id ].pitch[ 0 ];
-            }
-
-            channel_data[ channel_id ].instrument_id = instrument_id;
-            channel_data[ channel_id ].start_offset = 0x00076fe0;
-            channel_data[ channel_id ].loop_offset = data.loop_offset;
-            channel_data[ channel_id ].attack_rate = data.attack_rate;
-            channel_data[ channel_id ].decay_rate = data.decay_rate;
-            channel_data[ channel_id ].sustain_level = data.sustain_level;
-            channel_data[ channel_id ].sustain_rate = data.sustain_rate;
-            channel_data[ channel_id ].attack_mode = data.attack_mode;
-            channel_data[ channel_id ].sustain_mode = data.sustain_mode;
-
-            channel_data[ channel_id ].spu_update_flags |= SPU_START_OFFSET | SPU_ATTACK_RATE | SPU_SUSTAIN_RATE | SPU_ATTACK_MODE | SPU_DECAY_RATE | SPU_SUSTAIN_MODE | SPU_SUSTAIN_LEVEL | SPU_LOOP_OFFSET;
-
-            if( ( channel_data[ channel_id ].mirror_update_flags & 0x00000200 ) == 0 )
-            {
-                channel_data[ channel_id ].release_rate = data.release_rate;
-                channel_data[ channel_id ].release_mode = data.release_mode;
-
-                channel_data[ channel_id ].spu_update_flags |= SPU_RELEASE_RATE | SPU_RELEASE_MODE;
-            }
-
-            channel_data[ channel_id ].akao_sequence_pointer += 2;
-        }
-        else if( opcode == 0xfd ) // reset timers lower and upper
-        {
-            LOGGER->Log( "    0xFD Reset upper timer to 0 with bound " );
-            channel_config.upper_timer_top = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 2 );
-            //LOGGER->Log( ToHexString( channel_config.upper_timer_top, 4, '0' ) + " and lower timer to 0 with bound " );
-            channel_config.upper_timer = 0;
-            channel_config.lower_timer_top = music_->GetU8( channel_data[ channel_id ].akao_sequence_pointer + 1 );
-            //LOGGER->Log( ToHexString( channel_config.lower_timer_top, 4, '0' ) + ".\n" );
-            channel_config.lower_timer = 0;
-            channel_data[ channel_id ].akao_sequence_pointer += 3;
-        }
-        else if( opcode == 0xfe ) // reset timer top
-        {
-            LOGGER->Log( "    0xFE Reset top timer to " );
-            channel_config.top_timer = music_->GetU16LE( channel_data[ channel_id ].akao_sequence_pointer + 1 );
-            //LOGGER->Log( ToHexString( channel_config.top_timer, 4, '0' ) + ".\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 3;
-        }
-        else if( opcode == 0xff )
-        {
-            LOGGER->Log( "    0xFF [UNIMPLEMENTED]\n" );
-            channel_data[ channel_id ].akao_sequence_pointer += 4;
-        }
-        else
-        {
-            //LOGGER->Log( ToHexString( opcode, 2, '0' ) + " [UNKNOWN]\n" );
-            break;
-        }
-    }
-
-
-
-    if( opcode != 0xa0 )
-    {
-        //LOGGER->Log( "    0x" + ToHexString( opcode, 2, '0' ) + " PLAY.\n" );
-
-        u8 ret_op = NextSequenceHandle( channel_data, channel_id, channel_config );
-
-
-
-        if( channel_data[ channel_id ].pause_multiplier != 0)
-        {
-            channel_data[ channel_id ].pause = channel_data[ channel_id ].pause_multiplier * 0x101;
-        }
-
-        if( ( channel_data[ channel_id ].pause & 0xff ) == 0 )
-        {
-            channel_data[ channel_id ].pause = akao_pause_table[ opcode % 11 ];
-        }
-
-        if( ( ( ret_op - 0x84 ) >= 0xb ) && ( ( channel_data[ channel_id ].unknown_6e & 5 ) == 0 ) )
-        {
-            channel_data[ channel_id ].pause -= 0x0200;
-        }
-
-        channel_data[ channel_id ].saved_pause = channel_data[ channel_id ].pause & 0x00ff;
-
-
-
-        if( opcode >= 0x8f )
-        {
-            channel_data[ channel_id ].unknown_6c = 0;
-            channel_data[ channel_id ].unknown_6e &= 0xfffd;
-            channel_data[ channel_id ].pitch_addition2 = 0;
-            channel_data[ channel_id ].unknown_d8 = 0;
-        }
-        else if( opcode < 0x84 )
-        {
-            u32 pitch_base = 0;
-
-            if( channel_data[ channel_id ].mirror_update_flags & 0x00000008 )
-            {
-/*
-                S2 = opcode / b;
-
-                if (hu[channel_data + 54] == 0)
-                {
-                    [channels_config + 8] = w(w[channels_config + 8] | mask);
-                }
-                else
-                {
-                    [80099fd0] = w(w[80099fd0] | mask);
-                }
-
-                V1 = (S2 & ff) / c;
-                A0 = (S2 & ff) % c
-                A2 = w[channel_data + 14];
-                A0 = A0 & ff;
-
-                V0 = A0 * 5;
-                A2 = A2 + V0;
-                if (bu[A2] != hu[channel_data + 58])
-                {
-                    [channel_data + 58] = h(bu[A2]);
-                    V0 = bu[A2] * 40;
-                    [channel_data + e4] = w(w[80075f28 + V0]);
-                    [channel_data + e8] = w(w[80075f2c + V0]);
-                    [channel_data + fa] = h(bu[80075f30 + V0]);
-                    [channel_data + fc] = h(bu[80075f31 + V0]);
-                    [channel_data + fe] = h(bu[80075f32 + V0]);
-                    [channel_data + 100] = h(bu[80075f33 + V0]);
-                    [channel_data + ec] = w(bu[80075f35 + V0]);
-                    [channel_data + f0] = w(bu[80075f36 + V0]);
-
-                    if ((w[channel_data + 38] & 200) == 0)
-                    {
-                        V0 = bu[A2] * 40;
-                        [channel_data + 102] = h(bu[80075f34 + V0]);
-                        [channel_data + f4] = w(bu[80075f37 + V0]);
-                        [channel_data + e0] = w(w[channel_data + e0] | 1ff80);
-                    }
-                    else
-                    {
-                        [channel_data + e0] = w(w[channel_data + e0] | 1bb80);
-                    }
-                }
-
-                V1 = bu[A2 + 1];
-
-                A1 = (S2 & ff) / c;
-                V1 = (S2 & ff) % c;
-
-                A1 = A1 & ff;
-                A0 = w[80075f38 + bu[A2 + 0] * 40 + V1 * 4];
-
-                if (A1 >= 7)
-                {
-                    V0 = A1 - 6;
-                    A0 = V0 << A0;
-                }
-                else if (A1 < 6)
-                {
-                    V0 = 6 - A1;
-                    A0 = A0 >> V0;
-                }
-
-                [channel_data + 44] = w((bu[A2 + 2] + (bu[A2 + 3] << 8)) << 10);
-                [channel_data + 60] = h(bu[A2 + 4] << 8);
-*/
-            }
-            else
-            {
-                u8 pitch_index = opcode / 11 + channel_data[ channel_id ].pitch_correction * 12;
-
-                if( ( channel_data[ channel_id ].unknown_6c != 0 ) && ( channel_data[ channel_id ].unknown_6a != 0 ) )
-                {
-                    channel_data[ channel_id ].unknown_68 = channel_data[ channel_id ].unknown_6c;
-                    channel_data[ channel_id ].unknown_d2 = pitch_index + channel_data[ channel_id ].pitch_selector - channel_data[ channel_id ].unknown_6a - channel_data[ channel_id ].unknown_d4;
-                    channel_data[ channel_id ].saved_pitch = channel_data[ channel_id ].unknown_6a - channel_data[ channel_id ].pitch_selector - channel_data[ channel_id ].unknown_d4;
-                    pitch_index = channel_data[ channel_id ].unknown_6a + channel_data[ channel_id ].unknown_d4;
-                }
-                else
-                {
-                    channel_data[ channel_id ].saved_pitch = pitch_index;
-                    pitch_index += channel_data[ channel_id ].pitch_selector;
-                }
-
-
-
-                if( ( channel_data[ channel_id ].unknown_6e & 0x0002 ) == 0 )
-                {
-                    if( channel_data[ channel_id ].unknown_54 == 0 )
-                    {
-                        channel_config.for_play_channel_mask |= ( 1 << channel_id );
-
-                        if( channel_data[ channel_id ].mirror_update_flags & 0x00000100 )
-                        {
-                            u16 mirror_channel_id = channel_data[ channel_id ].mirror_channel_id;
-                            if( mirror_channel_id >= 0x18 )
-                            {
-                                mirror_channel_id -= 0x18;
-                            }
-
-                            channel_config.for_play_channel_mask |= ( 1 << mirror_channel_id );
-                        }
-                    }
-/*
-                    else
-                    {
-                        [80099fd0] = w(w[80099fd0] | ( 1 << channel_id ));
-                    }
-*/
-                    channel_data[ channel_id ].unknown_64 = 0;
-                }
-
-
-
-                u8 mod = pitch_index / 12;
-
-                pitch_base = m_InstrumentData[ channel_data[ channel_id ].instrument_id ].pitch[ pitch_index % 12 ];
-                if( mod >= 7 )
-                {
-                    pitch_base <<= ( mod - 6 );
-                }
-                else if( mod < 6 )
-                {
-                    pitch_base >>= ( 6 - mod );
-                }
-            }
-
-
-
-            if( channel_data[ channel_id ].unknown_54 == 0 )
-            {
-                channel_config.unknown_0c |= ( 1 << channel_id );
-            }
-/*
-            else
-            {
-                [80099fd4] = w(w[80099fd4] | ( 1 << channel_id ));
-            }
-*/
-
-
-            channel_data[ channel_id ].spu_update_flags |= SPU_LEFT_VOLUME | SPU_RIGHT_VOLUME | SPU_PITCH;
-
-
-
-            s16 pitch_modifier = channel_data[ channel_id ].pitch_modifier;
-            if( pitch_modifier != 0 )
-            {
-                if( pitch_modifier > 0 )
-                {
-                    pitch_modifier = ( pitch_base * pitch_modifier ) >> 7;
-                }
-                else
-                {
-                    pitch_modifier = ( pitch_base * pitch_modifier ) >> 8;
-                }
-
-                pitch_base = ( pitch_base + pitch_modifier ) & 0xffff;
-            }
-            channel_data[ channel_id ].pitch_base = pitch_base;
-
-
-
-
-            if( channel_data[ channel_id ].mirror_update_flags & 0x00000001 )
-            {
-                u16 wave1_modifier = ( channel_data[ channel_id ].wave1_modifier & 0x7f00 ) >> 8;
-                if( channel_data[ channel_id ].wave1_modifier & 0x8000 )
-                {
-                    pitch_base = wave1_modifier * pitch_base;
-                }
-                else
-                {
-                    pitch_base = wave1_modifier * ( ( pitch_base * 0xf ) >> 8 );
-                }
-
-                channel_data[ channel_id ].wave1_multiplier = pitch_base >> 0x7;
-                channel_data[ channel_id ].wave1_delay_current = channel_data[ channel_id ].wave1_delay;
-                channel_data[ channel_id ].wave1_refresh_interval_counter = 1;
-                channel_data[ channel_id ].wave1_table_index = akao_wave_table_key_nodes[ channel_data[ channel_id ].wave1_table_node_index ];
-            }
-
-            if( channel_data[ channel_id ].mirror_update_flags & 0X00000002 )
-            {
-                channel_data[ channel_id ].wave2_delay_current = channel_data[ channel_id ].wave2_delay;
-                channel_data[ channel_id ].wave2_refresh_interval_counter = 1;
-                channel_data[ channel_id ].wave2_table_index = akao_wave_table_key_nodes[ channel_data[ channel_id ].wave2_table_node_index ];
-            }
-
-            if( channel_data[ channel_id ].mirror_update_flags & 0x00000004 )
-            {
-                channel_data[ channel_id ].wave3_refresh_interval_counter = 1;
-                channel_data[ channel_id ].wave3_table_index = akao_wave_table_key_nodes[ channel_data[ channel_id ].wave3_table_node_index ];
-            }
-
-            channel_data[ channel_id ].pitch_addition2 = 0;
-            channel_data[ channel_id ].unknown_d8 = 0;
-            channel_data[ channel_id ].pitch_addition = 0;
-        }
-
-
-
-        u16 unknown_d2 = channel_data[ channel_id ].unknown_d2;
-
-        channel_data[ channel_id ].unknown_6e = ( channel_data[ channel_id ].unknown_6e & 0xfffd ) | ( ( channel_data[ channel_id ].unknown_6e & 0x0001 ) << 1 );
-
-        if( unknown_d2 != 0 )
-        {
-            channel_data[ channel_id ].saved_pitch += unknown_d2;
-
-            u8 selected_pitch = channel_data[ channel_id ].saved_pitch + channel_data[ channel_id ].pitch_selector;
-            u32 pitch_value = 0;
-
-            if( channel_data[ channel_id ].unknown_54 == 0 )
-            {
-                pitch_value = m_InstrumentData[ channel_data[ channel_id ].instrument_id ].pitch[ selected_pitch % 12 ];
-
-                s16 pitch_modifier = channel_data[ channel_id ].pitch_modifier;
-                if( pitch_modifier != 0 )
-                {
-                    if( pitch_modifier > 0 )
-                    {
-                        pitch_modifier = ( pitch_value * pitch_modifier ) >> 7;
-                    }
-                    else
-                    {
-                        pitch_modifier = ( pitch_value * pitch_modifier ) >> 8;
-                    }
-                    pitch_value += pitch_modifier;
-                }
-            }
-            else
-            {
-                pitch_value = m_InstrumentData[ channel_data[ channel_id ].instrument_id ].pitch[ selected_pitch %= 12 ];
-            }
-
-            pitch_value <<= 0x10;
-
-            selected_pitch /= 12;
-
-            if( selected_pitch >= 7 )
-            {
-                pitch_value <<= ( selected_pitch - 6 );
-            }
-            else if (selected_pitch < 6)
-            {
-                pitch_value >>= ( 6 - selected_pitch );
-            }
-
-            channel_data[ channel_id ].unknown_64 = channel_data[ channel_id ].unknown_68;
-            channel_data[ channel_id ].unknown_d2 = 0;
-            channel_data[ channel_id ].pitch_growth = (pitch_value + channel_data[ channel_id ].pitch_addition - ( channel_data[ channel_id ].pitch_base << 0x10 ) ) / channel_data[ channel_id ].unknown_64;
-        }
-
-        channel_data[ channel_id ].unknown_d4 = channel_data[ channel_id ].pitch_selector;
-        channel_data[ channel_id ].unknown_6a = channel_data[ channel_id ].saved_pitch;
-    }
-    else // 0xa0
-    {
-        LOGGER->Log( "    0xA0 FINISH.\n" );
-    }
-}
-
-
-
-const u8
-AkaoParser::NextSequenceHandle( ChannelData* channel_data, int channel_id, ChannelConfig& channel_config )
-{
-    u32 pointer = channel_data[ channel_id ].akao_sequence_pointer;
-    u16 loop_index = channel_data[ channel_id ].loop_index;
-
-    while( true )
-    {
-        u8 opcode = music_->GetU8( pointer );
-
-        if( opcode < 0x9a )
-        {
-            if( opcode >= 0x8f )
-            {
-                channel_data[ channel_id ].unknown_6c = 0;
-                channel_data[ channel_id ].unknown_6e &= 0xfffa;
-            }
-
-            return opcode;
-        }
-
-        if( opcode < 0xa0 )
-        {
-            return 0xa0;
-        }
-
-
-        u8 size = opcode_size[ opcode - 0xa0 ];
-        if( size == 0 )
-        {
-            switch( opcode )
-            {
-                case 0xc9:
-                {
-                    if( music_->GetU8( pointer + 1 ) == channel_data[ channel_id ].loop_count[ loop_index ] )
-                    {
-                        pointer += 2;
-                        loop_index = (loop_index - 1) & 3;
-                    }
-                    else
-                    {
-                        pointer = channel_data[ channel_id ].loop_pointer[ loop_index ];
-                    }
-                    continue;
-                }
-                break;
-
-                case 0xca:
-                {
-                    pointer = channel_data[ channel_id ].loop_pointer[ loop_index ];
-                    continue;
-                }
-                break;
-
-                case 0xcb:
-                case 0xcd:
-                case 0xd1:
-                case 0xdb:
-                {
-                    pointer += 1;
-                    channel_data[ channel_id ].unknown_6c = 0;
-                    channel_data[ channel_id ].unknown_6e &= 0xfffa;
-                    continue;
-                }
-                break;
-
-                case 0xee:
-                {
-                    pointer += 3 + ( s16 )( music_->GetU16LE( pointer + 1 ) );
-                    continue;
-                }
-                break;
-
-                case 0xef:
-                {
-                    if( channel_config.conditional_value >= music_->GetU8( pointer + 1 ) )
-                    {
-                        pointer += 4 + ( s16 )( music_->GetU16LE( pointer + 2 ) );
-                    }
-                    else
-                    {
-                        pointer += 4;
-                    }
-                    continue;
-                }
-                break;
-
-                case 0xf0:
-                case 0xf1:
-                {
-                    if( music_->GetU8( pointer + 1 ) == channel_data[ channel_id ].loop_count[ loop_index ] + 1 )
-                    {
-                        loop_index = (loop_index - 1) & 3;
-                        pointer += 4 + ( s16 )( music_->GetU16LE( pointer + 2 ) );
-                    }
-                    else
-                    {
-                        pointer += 4;
-                    }
-                    continue;
-                }
-                break;
-
-                default:
-                {
-                    channel_data[ channel_id ].unknown_6c = 0;
-                    channel_data[ channel_id ].unknown_6e &= 0xfffa;
-                    return 0xa0;
-                }
-            }
-        }
-
-        pointer += size;
-    }
-}
-
-
-
-void
-AkaoParser::UpdateCounters( ChannelData* channel_data, int channel_id, ChannelConfig& channel_config )
-{
-    // update volume level
-    if( channel_data[ channel_id ].volume_level_change_ticks != 0 )
-    {
-        channel_data[ channel_id ].volume_level_change_ticks -= 1;
-
-        s32 volume_level = channel_data[ channel_id ].volume_level + channel_data[ channel_id ].volume_level_add;
-
-        if( ( volume_level & 0xffe0 ) != ( channel_data[ channel_id ].volume_level & 0xffe0 ) )
-        {
-            channel_data[ channel_id ].spu_update_flags |= SPU_LEFT_VOLUME | SPU_RIGHT_VOLUME;
-        }
-        channel_data[ channel_id ].volume_level = volume_level;
-    }
-
-    if( channel_data[ channel_id ].unknown_c6_change_ticks != 0 )
-    {
-        channel_data[ channel_id ].unknown_c6_change_ticks -= 1;
-
-        u16 value = channel_data[ channel_id ].unknown_c6 + channel_data[ channel_id ].unknown_c8;
-
-        if( channel_data[ channel_id ].mirror_update_flags & 0x00000100 )
-        {
-            if( ( value & 0xff00 ) != ( channel_data[ channel_id ].unknown_c6 & 0xff00 ) )
-            {
-                channel_data[ channel_id ].spu_update_flags |= SPU_LEFT_VOLUME | SPU_RIGHT_VOLUME;
-            }
-        }
-
-        channel_data[ channel_id ].unknown_c6 = value;
-    }
-/*
-    if (hu[S0 + 62] != 0)
-    {
-        [S0 + 62] = h(hu[S0 + 62] - 1);
-
-        A1 = hu[S0 + 60] + h[S0 + ca];
-
-        if ((A1 & ff00) != (hu[S0 + 60] & ff00))
-        {
-            [S0 + e0] = w(w[S0 + e0] | 00000003);
-        }
-
-        [S0 + 60] = h(A1);
-    }
-
-    if (hu[S0 + 74] != 0) // wave1_delay_current
-    {
-        [S0 + 74] = h(hu[S0 + 74] - 1);
-    }
-
-    if (hu[S0 + 88] != 0) // wave2_delay_current
-    {
-        [S0 + 88] = h(hu[S0 + 88] - 1);
-    }
-
-    if (hu[S0 + a4] != 0)
-    {
-        [S0 + a4] = h(hu[S0 + a4] - 1);
-
-        if (hu[S0 + a4] == 0)
-        {
-            channel_config.unknown_2c ^= ( 1 << channel_id );
-            [8009a13c] = w(w[8009a13c] | 00000010);
-
-            func2ff4c;
-        }
-    }
-
-    if (hu[S0 + a6] != 0)
-    {
-        [S0 + a4] = h(hu[S0 + a4] - 1);
-
-        if (hu[S0 + a4] == 0)
-        {
-            channel_config.unknown_34 ^= ( 1 << channel_id );
-
-            8002E660	jal    func30148 [$80030148]
-        }
-    }
-
-    if (hu[S0 + 80] != 0)
-    {
-        [S0 + 80] = h(hu[S0 + 80] - 1);
-        [S0 + 7e] = h(hu[S0 + 7e] + hu[S0 + 82]);
-
-        A0 = (hu[S0 + 7e] & 7f00) >> 8;
-        if (hu[S0 + 7e] & 8000)
-        {
-            V0 = A0 * w[S0 + 30];
-        }
-        else
-        {
-            V0 = A0 * ((w[S0 + 30] * f) >> 8);
-        }
-        [S0 + 7c] = h(V0 >> 7);
-
-        if (hu[S0 + 74] == 0)
-        {
-            if (hu[S0 + 78] != 1)
-            {
-                A0 = w[S0 + 18];
-                if (h[A0 + 0] == 0)
-                {
-                    if (h[A0 + 2] == 0)
-                    {
-                        A0 = A0 + h[A0 + 4] * 2;
-                    }
-                }
-
-                A1 = (hu[S0 + 7c] * h[A0]) >> 10;
-                if (A1 != h[S0 + d6])
-                {
-                    [S0 + d6] = h(A1);
-                    [S0 + e0] = w(w[S0 + e0] | 00000010);
-
-                    if (A1 >= 0)
-                    {
-                        [S0 + d6] = h(A1 * 2);
-                    }
-                }
-            }
-        }
-    }
-
-    if (hu[S0 + 92] != 0)
-    {
-        [S0 + 92] = h(hu[S0 + 92] - 1);
-        [S0 + 90] = h(hu[S0 + 90] + hu[S0 + 94]);
-
-        if (hu[S0 + 88] == 0)
-        {
-            if (hu[S0 + 8c] != 1)
-            {
-                A0 = w[S0 + 1c];
-                if (h[A0 + 0] == 0)
-                {
-                    V0 = h[A0 + 2];
-                    if (V0 == 0)
-                    {
-                        A0 = A0 + h[A0 + 4] * 2;
-                    }
-                }
-
-                A1 = ((((((h[S0 + 46] * w[S0 + 2c]) >> 7) * (hu[S0 + 90] >> 8)) << 9) >> 10) * h[A0]) >> f;
-                if (A1 != h[S0 + d8])
-                {
-                    [S0 + e0] = w(w[S0 + e0] | 00000003);
-                    [S0 + d8] = h(A1);
-                }
-            }
-        }
-    }
-
-    if (hu[S0 + a0] != 0)
-    {
-        [S0 + a0] = h(hu[S0 + a0] - 1);
-        [S0 + 9e] = h(hu[S0 + 9e] + hu[S0 + a2]);
-
-        if (hu[S0 + 9a] != 1)
-        {
-            A0 = w[S0 + 20];
-            if (h[A0 + 0] == 0)
-            {
-                if (h[A0 + 2] == 0)
-                {
-                    A0 = A0 + h[A0 + 4] * 2;
-                }
-            }
-
-            A1 = ((hu[S0 + 9e] >> 8) * h[A0]) >> f;
-            if (A1 != h[S0 + da])
-            {
-                [S0 + e0] = w(w[S0 + e0] | 00000003);
-                [S0 + da] = h(A1);
-            }
-        }
-    }
-
-    if (hu[S0 + 64] != 0)
-    {
-        [S0 + 64] = h(hu[S0 + 64] - 1);
-
-        A1 = w[S0 + 34] + w[S0 + 4c];
-
-        if ((A1 & ffff0000) != (w[S0 + 34] & ffff0000))
-        {
-            [S0 + e0] = w(w[S0 + e0] | 00000010);
-        }
-
-        [S0 + 34] = w(A1);
-    }
-*/
-}
-
-
-
-void
-AkaoParser::InitChannelInstrument( ChannelData* channel_data, int channel_id, int instrument_id )
-{
-    //LOGGER->Log( "Load voice " + Ogre::StringConverter::toString( instrument_id ) + " to channel " + Ogre::StringConverter::toString( channel_id ) + ".\n" );
-    InstrumentData data = m_InstrumentData[ instrument_id ];
-
-    channel_data[ channel_id ].instrument_id = instrument_id;
-    channel_data[ channel_id ].start_offset = data.start_offset;
-    channel_data[ channel_id ].loop_offset = data.loop_offset;
-    //LOGGER->Log( "SPU_ADDRESS_START " + Ogre::StringConverter::toString( data.start_offset ) + "\n" );
-    //LOGGER->Log( "SPU_ADDRESS_LOOP " + Ogre::StringConverter::toString( data.loop_offset ) + "\n" );
-    channel_data[ channel_id ].attack_mode = data.attack_mode;
-    channel_data[ channel_id ].sustain_mode = data.sustain_mode;
-    channel_data[ channel_id ].release_mode = data.release_mode;
-    channel_data[ channel_id ].attack_rate = data.attack_rate;
-    channel_data[ channel_id ].decay_rate = data.decay_rate;
-    channel_data[ channel_id ].sustain_level = data.sustain_level;
-    channel_data[ channel_id ].sustain_rate = data.sustain_rate;
-    channel_data[ channel_id ].release_rate = data.release_rate;
-    channel_data[ channel_id ].spu_update_flags |=
-        SPU_START_OFFSET | SPU_ATTACK_RATE | SPU_SUSTAIN_RATE | SPU_RELEASE_RATE |
-        SPU_ATTACK_MODE | SPU_DECAY_RATE | SPU_SUSTAIN_MODE | SPU_RELEASE_MODE |
-        SPU_SUSTAIN_LEVEL | SPU_LOOP_OFFSET; // update everything we just set
-}
-
-
-
-void
-AkaoParser::DumpSequenceData( const Ogre::String& file )
-{
-    std::ofstream oF;
-    oF.open( file.c_str(), std::ios_base::binary | std::ios_base::out );
-    if ( !oF.is_open() )
-    {
-        return;
-    }
-
-    oF << std::setfill( '0' );
-    oF << std::hex;
-    oF << "*** Frame ID: 0x" << std::setw( 4 ) << music_->GetU16LE( 4 ) << std::endl;
-    oF << std::dec;
-    oF << "*** Frame Length: " << music_->GetU16LE( 6 ) << " bytes" << std::endl;
-    oF << std::hex;
-    oF << "*** Reverb Mode: 0x" << std::setw( 4 ) << music_->GetU16LE( 8 ) << std::endl;
-    oF << std::endl;
-
-    oF << std::hex;
-    oF << "*** Channels mask: " <<std:: setw( 8 ) << music_->GetU32LE( 16 ) << std::endl << std::endl;
-
-    for ( int i = 0; i < 24; ++i )
-    {
-        if ( ( ( music_->GetU32LE( 16 ) ) & ( 1 << i ) ) == 0 )
-        {
-            continue;
-        }
-
-        oF << std::dec;
-        oF << "*** Channel " << std::setw( 2 ) << ( int )i << " sequence: " << std::endl;
-
-        oF << std::hex;
-        u16 j = 0;
-        bool work = true;
-        while ( work )
-        {
-            u8 opcode = music_->GetU8( m_MusicChannelData[ i ].akao_sequence_pointer + j );
-            switch ( opcode )
-            {
-                case 0xa0:
-                    oF << std::setw( 2 ) << ( int )music_->GetU8( m_MusicChannelData[ i ].akao_sequence_pointer + j + 0 );
-                    oF << std::endl;
-                    work = false;
-                    break;
-                // no parameters
-                case 0xa6: case 0xa7: case 0xb3: case 0xb6: case 0xba: case 0xbe: case 0xc2: case 0xc3:
-                case 0xc4: case 0xc5: case 0xc6: case 0xc7: case 0xc8: case 0xca: case 0xcb: case 0xcc:
-                case 0xcd: case 0xd0: case 0xd1: case 0xd4: case 0xd5: case 0xd6: case 0xd7: case 0xdb:
-                case 0xe0: case 0xe1: case 0xe2: case 0xe3: case 0xe4: case 0xe5: case 0xe6: case 0xe7:
-                case 0xed: case 0xf3: case 0xf5: case 0xf9: case 0xfa: case 0xfb: case 0xfc: case 0xff:
-                    oF << std::setw( 2 ) << ( int )music_->GetU8( m_MusicChannelData[ i ].akao_sequence_pointer + j + 0 );
-                    oF << std::endl;
-                    ++j;
-                    break;
-                // one parameter
-                case 0xa1: case 0xa2: case 0xa3: case 0xa5: case 0xa8: case 0xaa: case 0xac: case 0xad:
-                case 0xae: case 0xaf: case 0xb1: case 0xb2: case 0xb5: case 0xb7: case 0xb9: case 0xbb:
-                case 0xbd: case 0xbf: case 0xc0: case 0xc1: case 0xc9: case 0xce: case 0xcf: case 0xd2:
-                case 0xd3: case 0xd8: case 0xd9: case 0xda: case 0xdc: case 0xf2: case 0xf6: case 0xf8:
-                    oF << std::setw( 2 ) << ( int )music_->GetU8( m_MusicChannelData[ i ].akao_sequence_pointer + j + 0 ) << ' ';
-                    oF << std::setw( 2 ) << ( int )music_->GetU8( m_MusicChannelData[ i ].akao_sequence_pointer + j + 1 );
-                    oF << std::endl;
-                    j += 2;
-                    break;
-                // two parameters
-                case 0xa4: case 0xa9: case 0xab: case 0xb0: case 0xbc: case 0xdd: case 0xde: case 0xdf:
-                case 0xe8: case 0xea: case 0xec: case 0xee: case 0xf4: case 0xf7: case 0xfd: case 0xfe:
-                    oF << std::setw( 2 ) << ( int )music_->GetU8( m_MusicChannelData[ i ].akao_sequence_pointer + j + 0 ) << ' ';
-                    oF << std::setw( 2 ) << ( int )music_->GetU8( m_MusicChannelData[ i ].akao_sequence_pointer + j + 1 ) << ' ';
-                    oF << std::setw( 2 ) << ( int )music_->GetU8( m_MusicChannelData[ i ].akao_sequence_pointer + j + 2 );
-                    oF << std::endl;
-                    j += 3;
-                    break;
-                // three parameters
-                case 0xb4: case 0xb8: case 0xe9: case 0xeb: case 0xef: case 0xf0: case 0xf1:
-                    oF << std::setw( 2 ) << ( int )music_->GetU8( m_MusicChannelData[ i ].akao_sequence_pointer + j + 0 ) << ' ';
-                    oF << std::setw( 2 ) << ( int )music_->GetU8( m_MusicChannelData[ i ].akao_sequence_pointer + j + 1 ) << ' ';
-                    oF << std::setw( 2 ) << ( int )music_->GetU8( m_MusicChannelData[ i ].akao_sequence_pointer + j + 2 ) << ' ';
-                    oF << std::setw( 2 ) << ( int )music_->GetU8( m_MusicChannelData[ i ].akao_sequence_pointer + j + 3 );
-                    oF << std::endl;
-                    j += 4;
-                    break;
-                default:
-                    oF << std::setw( 2 ) << ( int )music_->GetU8( m_MusicChannelData[ i ].akao_sequence_pointer + j + 0 );
-                    if ( music_->GetU8( m_MusicChannelData[ i ].akao_sequence_pointer + j + 1 ) < 0xa0)
-                    {
-                        oF << ' ';
-                    }
-                    else
-                    {
-                        oF << std::endl;
-                    }
-                    ++j;
-            }
-        }
-
-        oF << std::endl;
-    }
-
-    oF.close();
-}

+ 0 - 302
utilities/ffvii_sound_dumper/src/AkaoParser.h

@@ -1,302 +0,0 @@
-#ifndef AKAO_PARSER_H
-#define AKAO_PARSER_H
-
-#include <Ogre.h>
-
-#include <vector>
-#include "common/File.h"
-#include "common/TypeDefine.h"
-
-
-
-class AkaoParser
-{
-public:
-    AkaoParser();
-    virtual ~AkaoParser();
-
-    void Update();
-
-    // instrument
-    void LoadInstruments( const Ogre::String& all_file, const Ogre::String& dat_file );
-    void UnloadInstruments();
-
-    // akao command 0x10
-    void PlayMusic( const Ogre::String& file );
-
-    // debug routines
-    void DumpSequenceData( const Ogre::String& file );
-
-
-
-private:
-    enum SpuParameter
-    {
-        SPU_LEFT_VOLUME   = 1 <<  0, // 0x00000001
-        SPU_RIGHT_VOLUME  = 1 <<  1, // 0x00000002
-        SPU_PITCH         = 1 <<  4, // 0x00000010
-        SPU_START_OFFSET  = 1 <<  7, // 0x00000080
-        SPU_ATTACK_RATE   = 1 <<  8, // 0x00000100
-        SPU_SUSTAIN_RATE  = 1 <<  9, // 0x00000200
-        SPU_RELEASE_RATE  = 1 << 10, // 0x00000400
-        SPU_ATTACK_MODE   = 1 << 11, // 0x00000800
-        SPU_DECAY_RATE    = 1 << 12, // 0x00001000
-        SPU_SUSTAIN_MODE  = 1 << 13, // 0x00002000
-        SPU_RELEASE_MODE  = 1 << 14, // 0x00004000
-        SPU_SUSTAIN_LEVEL = 1 << 15, // 0x00008000
-        SPU_LOOP_OFFSET   = 1 << 16, // 0x00010000
-    };
-
-    enum SpuConfigUpdate
-    {
-        SPU_REVERB        = 1 <<  7, // 0x00000080
-    };
-
-
-
-    // instrument
-    struct InstrumentData
-    {
-        u32 start_offset; // 0x00
-        u32 loop_offset;  // 0x04
-        u8 attack_rate;   // 0x08
-        u8 decay_rate;    // 0x09
-        u8 sustain_level; // 0x0a
-        u8 sustain_rate;  // 0x0b
-        u8 release_rate;  // 0x0c
-        u8 attack_mode;   // 0x0d
-        u8 sustain_mode;  // 0x0e
-        u8 release_mode;  // 0x0f
-        u32 pitch[ 12 ];
-    };
-    std::vector< InstrumentData > m_InstrumentData;
-
-
-
-    struct ChannelData
-    {
-        // 0x00 [][][][]
-        u32 akao_sequence_pointer;
-        // 0x04-0x10 [][][][]
-        u32 loop_pointer[ 4 ];
-
-        // 0x18 [][][][] in real here was addreses into wave table, but we store indexes here
-        u32 wave1_table_index;
-        // 0x1c [][][][]
-        u32 wave2_table_index;
-        // 0x20 [][][][]
-        u32 wave3_table_index;
-        // 0x24 [][]
-        u16 mirror_channel_id;
-        // 0x2c [][][][]
-        s32 volume_multiplier;
-
-        // 0x30 [][][][]
-        u32 pitch_base;
-        // 0x34 [][][][]
-        s32 pitch_addition;
-        // 0x38 [][][][]
-        u32 mirror_update_flags;
-
-        // 0x44 [][][][]
-        s32 volume_level;
-        // 0x48 [][][][]
-        s32 volume_level_add;
-        // 0x4c [][][][]
-        s32 pitch_growth;
-
-        // 0x54 [][]
-        u16 unknown_54;
-        // 0x56 [][]
-        u16 pause;
-        // 0x58 [][]
-        int instrument_id;
-
-        // 0x5c [][]
-        u16 volume_level_change_ticks;
-        // 0x5e [][]
-        u16 unknown_c6_change_ticks;
-        // 0x60 [][]
-        u16 volume_index;
-        // 0x62 [][]
-        u16 unknown_62;
-        // 0x64 [][]
-        u16 unknown_64;
-        // 0x66 [][]
-        u16 pitch_correction;
-        // 0x68 [][]
-        u16 unknown_68;
-        // 0x6a [][]
-        u16 unknown_6a;
-        // 0x6c [][]
-        u16 unknown_6c;
-        // 0x6e [][]
-        u16 unknown_6e;
-
-        // 0x72 [][]
-        u16 wave1_delay;
-        // 0x74 [][]
-        u16 wave1_delay_current;
-        // 0x76 [][]
-        u16 wave1_refresh_interval;
-        // 0x78 [][]
-        u16 wave1_refresh_interval_counter;
-        // 0x7a [][]
-        u16 wave1_table_node_index;
-        // 0x7c [][]
-        u16 wave1_multiplier;
-        // 0x7e [][]
-        u16 wave1_modifier;
-
-        // 0x86 [][]
-        u16 wave2_delay;
-        // 0x88 [][]
-        u16 wave2_delay_current;
-
-        // 0x8c [][]
-        u16 wave2_refresh_interval_counter;
-        // 0x8e [][]
-        u16 wave2_table_node_index;
-
-        // 0x9a [][]
-        u16 wave3_refresh_interval_counter;
-        // 0x9c [][]
-        u16 wave3_table_node_index;
-
-        // 0xb8 [][]
-        u16 loop_index;
-        // 0xba-0xc0 [][]
-        u16 loop_count[ 4 ];
-
-        // 0xc2 [][]
-        u16 saved_pause;
-        // 0xc4 [][]
-        u16 pause_multiplier;
-        // 0xc6 [][]
-        u16 unknown_c6;
-        // 0xc8 [][]
-        u16 unknown_c8;
-
-        // 0xcc [][]
-        u16 pitch_selector;
-        // 0xce [][]
-        s16 pitch_modifier;
-        // 0xd0 [][]
-        u16 saved_pitch;
-        // 0xd2 [][]
-        u16 unknown_d2;
-        // 0xd4 [][]
-        u16 unknown_d4;
-        // 0xd6 [][]
-        s16 pitch_addition2;
-        // 0xd8 [][]
-        u16 unknown_d8;
-
-        // 0xe0 [][][][]
-        u32 spu_update_flags;
-        // 0xe4 [][][][]
-        u32 start_offset;
-        // 0xe8 [][][][]
-        u32 loop_offset;
-        // 0xec [][][][]
-        u32 attack_mode;
-        // 0xf0 [][][][]
-        u32 sustain_mode;
-        // 0xf4 [][][][]
-        u32 release_mode;
-        // 0xf8 [][]
-        u16 pitch;
-        // 0xfa [][]
-        u16 attack_rate;
-        // 0xfc [][]
-        u16 decay_rate;
-        // 0xfe [][]
-        u16 sustain_level;
-        // 0x100 [][]
-        u16 sustain_rate;
-        // 0x102 [][]
-        u16 release_rate;
-        // 0x104 [][]
-        u16 left_volume;
-        // 0x106 [][]
-        u16 right_volume;
-    };
-    ChannelData m_MusicChannelData[ 24 ];
-
-
-
-    struct ChannelConfig
-    {
-        // 0x04 [][][][]
-        u32 active_channel_mask;
-        // 0x08 [][][][]
-        u32 for_play_channel_mask;
-        // 0x0c [][][][]
-        u32 unknown_0c;
-        // 0x10 [][][][]
-        u32 unknown_10;
-        // 0x18 [][][][]
-        u32 tempo;
-        // 0x1c [][][][]
-        u32 tempo_increment;
-        // 0x20 [][][][]
-        u32 tempo_counter;
-
-        // 0x2c [][][][]
-        u32 unknown_2c;
-
-        // 0x34 [][][][]
-        u32 unknown_34;
-
-        // 0x38 [][][][]
-        u32 spu_update_flags;
-
-        // 0x40 [][][][]
-        u32 reverb_depth;
-
-        // 0x48 [][]
-        u16 tempo_increment_counter;
-        // 0x4e [][]
-        u16 conditional_value;
-        // 0x50 [][]
-        u16 reverb_depth_increment_counter;
-
-        // 0x56 [][]
-        u16 upper_timer_top;
-        // 0x58 [][]
-        u16 upper_timer;
-        // 0x5a [][]
-        u16 lower_timer_top;
-        // 0x5c [][]
-        u16 lower_timer;
-        // 0x5e [][]
-        u16 top_timer;
-    };
-    ChannelConfig m_MusicChannelConfig;
-
-
-
-    File* music_;
-
-
-
-private:
-    void UpdateDynamicSpuParameters();
-    void UpdatePitchAndVolume( ChannelData* channel_data, int channel_id );
-    void UpdateSpu( ChannelData* channel_data, int channel_id );
-    void UpdatePlayChannel( bool on, u32 channel_mask );
-    void UpdateSequence( ChannelData* channel_data, int channel_id, ChannelConfig& channel_config );
-
-    const u8 NextSequenceHandle( ChannelData* channel_data, int channel_id, ChannelConfig& channel_config );
-    void UpdateCounters( ChannelData* channel_data, int channel_id, ChannelConfig& channel_config );
-
-    void InitChannelInstrument( ChannelData* channel_data, int channel_id, int instrument_id );
-};
-
-
-
-extern AkaoParser *AKAOPARSER;
-
-
-
-#endif // AKAO_PARSER_H

+ 0 - 201
utilities/ffvii_sound_dumper/src/Main.cpp

@@ -1,201 +0,0 @@
-#include "Main.h"
-
-#include <Ogre.h>
-#include <OIS/OIS.h>
-#include <OgreWindowEventUtilities.h>
-
-#include "common/FileSystem.h"
-#include "common/Logger.h"
-
-
-#include "AkaoParser.h"
-#include "engine/SoundManager.h"
-
-
-
-int state;
-
-
-
-class DisplayFrameListener : public Ogre::FrameListener, public Ogre::WindowEventListener, public OIS::KeyListener
-{
-public:
-    DisplayFrameListener(Ogre::RenderWindow* win):
-        m_Window(win),
-        m_InputManager(0),
-        m_Keyboard(0),
-        m_Timer(0)
-    {
-        using namespace OIS;
-
-        Ogre::LogManager::getSingletonPtr()->logMessage("*** Initializing OIS ***");
-        ParamList pl;
-        size_t windowHnd = 0;
-        std::ostringstream windowHndStr;
-
-        win->getCustomAttribute("WINDOW", &windowHnd);
-        windowHndStr << windowHnd;
-        pl.insert(std::make_pair(std::string("WINDOW"), windowHndStr.str()));
-
-        m_InputManager = InputManager::createInputSystem(pl);
-
-        m_Keyboard = static_cast<Keyboard*>(m_InputManager->createInputObject(OIS::OISKeyboard, true));
-        m_Keyboard->setEventCallback(this);
-
-        //Register as a Window listener
-        Ogre::WindowEventUtilities::addWindowEventListener(m_Window, this);
-    }
-
-    virtual
-    ~DisplayFrameListener(void)
-    {
-        m_InputManager->destroyInputObject(m_Keyboard);
-
-        OIS::InputManager::destroyInputSystem(m_InputManager);
-
-        //Remove ourself as a Window listener
-        Ogre::WindowEventUtilities::removeWindowEventListener(m_Window, this);
-        windowClosed(m_Window);
-    }
-
-    virtual void
-    windowClosed(Ogre::RenderWindow* rw)
-    {
-        state = EXIT;
-    }
-
-    bool
-    frameStarted(const Ogre::FrameEvent& evt)
-    {
-        if (state == EXIT)
-        {
-            return false;
-        }
-
-        if (m_Keyboard)
-        {
-            m_Keyboard->capture();
-        }
-
-        if (m_Timer >= 0.003)
-        {
-            m_Timer = 0;
-            AKAOPARSER->Update();
-        }
-        m_Timer += evt.timeSinceLastFrame;
-
-        SOUNDMAN->Update();
-
-        return true;
-    }
-
-    bool
-    keyPressed(const OIS::KeyEvent& e)
-    {
-        switch (e.key)
-        {
-            case OIS::KC_ESCAPE:
-            {
-                state = EXIT;
-            }
-            break;
-        }
-
-        return true;
-    }
-
-    bool
-    keyReleased(const OIS::KeyEvent& e)
-    {
-        return true;
-    }
-
-protected:
-    Ogre::RenderWindow* m_Window;
-
-    OIS::InputManager*  m_InputManager;
-    OIS::Keyboard*      m_Keyboard;
-
-    float               m_Timer;
-};
-
-
-
-int
-main( int argc, char *argv[] )
-{
-    Ogre::Root*         root;
-    Ogre::RenderWindow* window;
-
-    root = new Ogre::Root( "", "" );
-#ifndef _DEBUG
-    root->loadPlugin( "RenderSystem_GL.dll" );
-#else
-    root->loadPlugin( "RenderSystem_GL_d.dll" );
-#endif
-    root->setRenderSystem( root->getAvailableRenderers()[ 0 ] );
-    root->initialise( false );
-    Ogre::NameValuePairList misc;
-    misc[ "title" ] = "FFVII Exporter";
-    window = root->createRenderWindow( "QGearsWindow", 800, 600, false, &misc );
-
-    LOGGER = new Logger( "game.log" );
-
-    state = GAME;
-
-
-
-    DisplayFrameListener* frame_listener = new DisplayFrameListener( window );
-    root->addFrameListener( frame_listener );
-
-    Ogre::SceneManager* scene_manager = root->createSceneManager( Ogre::ST_GENERIC, "Scene" );
-    scene_manager->setAmbientLight( Ogre::ColourValue( 1.0, 1.0, 1.0 ) );
-
-    Ogre::Camera* camera = scene_manager->createCamera( "Camera" );
-    camera->setNearClipDistance( 5 );
-
-    Ogre::Viewport* viewport = window->addViewport( camera );
-    viewport->setBackgroundColour( Ogre::ColourValue( 0, 0, 0 ) );
-    camera->setAspectRatio( Ogre::Real( viewport->getActualWidth()) / Ogre::Real( viewport->getActualHeight() ) );
-
-
-
-    SOUNDMAN = new SoundManager();
-    AKAOPARSER = new AkaoParser();
-
-
-
-    AKAOPARSER->LoadInstruments( "data/INSTR.ALL", "data/INSTR.DAT" );
-
-
-
-    if( argc == 2 )
-    {
-        AKAOPARSER->PlayMusic( Ogre::String( "data/music/") + argv[ 1 ] );
-        //AKAOPARSER->DumpSequenceData( Ogre::String( "dump_" ) + argv[ 1 ] + ".txt" );
-    }
-    else
-    {
-        AKAOPARSER->PlayMusic( "data/music/aeris_theme.snd" );
-        //AKAOPARSER->DumpSequenceData( "dump_aeris_theme.txt" );
-    }
-
-
-
-    Ogre::Root::getSingleton().startRendering();
-
-
-
-    delete AKAOPARSER;
-    delete SOUNDMAN;
-
-
-
-    delete root;
-    delete frame_listener;
-
-    delete LOGGER;
-
-    return 0;
-}
-

+ 0 - 20
utilities/ffvii_sound_dumper/src/Main.h

@@ -1,20 +0,0 @@
-#ifndef MAIN_H
-#define MAIN_H
-
-
-
-enum
-{
-    EXIT,
-    GAME
-};
-
-
-
-extern int state;
-
-
-
-
-#endif // MAIN_H
-

+ 0 - 29
utilities/ffvii_sound_dumper/src/engine/SoundBackend.h

@@ -1,29 +0,0 @@
-#ifndef SOUND_BACKEND_HH__
-#define SOUND_BACKEND_HH__
-
-
-
-#include "common/TypeDefine.h"
-#include <iostream>
-
-
-
-class SoundBackend
-{
-	protected:
-		static const u32 m_BUFFER_SIZE = 70560;
-		static const u16 m_FREQUENCY = 44100;
-		static const u8 m_CHANNELS_COUNT = 2;
-
-	public:
-		SoundBackend(){}
-		virtual ~SoundBackend(){}
-
-		virtual u32 GetBytesBuffered() = 0;
-		virtual void FeedStreamData(u8 *arg_data, u32 arg_length) = 0;
-};
-
-
-
-#endif
-

+ 0 - 3817
utilities/ffvii_sound_dumper/src/engine/SoundManager.cpp

@@ -1,3817 +0,0 @@
-#include <iostream>
-#include <fstream>
-#include <iomanip>
-#include "SoundManager.h"
-#include "SoundBackend.h"
-#include "backends/SoundBackendSDL.h"
-#ifdef _MSC_VER
-    #include <windows.h>
-#else
-    #include <sys/time.h>
-#endif
-
-SoundManager *SOUNDMAN = NULL;
-SoundBackend *SBE = NULL;
-
-
-
-unsigned long RateTable[160];
-
-// REVERB info and timing vars...
-int *sRVBPlay = NULL;
-int *sRVBEnd = NULL;
-int *sRVBStart = NULL;
-// some delay factor for reverb
-int iReverbOff = -1;
-int iReverbRepeat = 0;
-int iReverbNum = 1;
-
-xa_decode_t   * xapGlobal=0;
-
-u32 * XAFeed  = NULL;
-u32 * XAPlay  = NULL;
-u32 * XAStart = NULL;
-u32 * XAEnd   = NULL;
-
-u32   XARepeat  = 0;
-u32   XALastVal = 0;
-
-int             iLeftXAVol  = 32767;
-int             iRightXAVol = 32767;
-
-static int gauss_ptr = 0;
-static int gauss_window[8] = {0, 0, 0, 0, 0, 0, 0, 0};
-
-#define gvall0 gauss_window[gauss_ptr]
-#define gvall(x) gauss_window[(gauss_ptr+x)&3]
-#define gvalr0 gauss_window[4+gauss_ptr]
-#define gvalr(x) gauss_window[4+((gauss_ptr+x)&3)]
-
-void SetupTimer();
-void RemoveTimer();
-
-
-
-const unsigned char version = 1;
-const unsigned char revision = 0;
-const unsigned char build = 0;
-
-// psx buffer / addresses
-unsigned short  regArea[10000];
-unsigned short  spuMem[256 * 1024];
-unsigned char * spuMemC;
-unsigned char * pSpuIrq = 0;
-unsigned char * pSpuBuffer;
-
-// user settings
-int             iUseXA = 1;
-int             iVolume = 3;
-int             iXAPitch = 1;
-int             iUseTimer = 2;
-int             iSPUIRQWait = 1;
-int             iDebugMode = 0;
-int             iRecordMode = 0;
-int             iUseReverb = 2;
-int             iUseInterpolation = 2;
-//int             iDisStereo = 0;
-
-// MAIN infos struct for each channel
-
-// channel + 1 infos (1 is security for fmod handling)
-SPUCHAN         s_chan[MAXCHAN + 1];
-REVERBInfo      rvb;
-
-// global noise generator
-unsigned long   dwNoiseVal = 1;
-int             iWatchDog = 0;
-
-// some vars to store psx reg infos
-unsigned short  spuCtrl = 0;
-unsigned short  spuStat = 0;
-unsigned short  spuIrq = 0;
-// address into spu mem
-unsigned long   spuAddr = 0xffffffff;
-
-// thread handlers
-int             bEndThread = 0;
-int             bThreadEnded = 0;
-int             bSpuInit = 0;
-int             bSPUIsOpen = 0;
-
-// flags for faster testing, if new channel starts
-unsigned long dwNewChannel = 0;
-
-// func of main emu, called on spu irq
-void (*irqCallback)(void) = 0;
-void (*cddavCallback)(unsigned short, unsigned short) = 0;
-
-// certain globals (were local before, but
-// with the new timeproc I need em global)
-
-static const int f[5][2] =
-{
-	{  0,   0},
-	{ 60,   0},
-	{115, -52},
-	{ 98, -55},
-	{122, -60}
-};
-
-int SSumR[NSSIZE];
-int SSumL[NSSIZE];
-int iCycle = 0;
-short * pS;
-
-// last channel processed on spu irq in timer mode
-static int lastch = -1;
-// last ns pos
-static int lastns = 0;
-// secure start counter
-static int iSecureStart = 0;
-
-
-
-SoundManager::SoundManager()
-{
-	u8 *buffer;
-
-
-	/* SPU initialization */
-	SPUinit();
-	SPUopen();
-
-
-
-	/* base initialization of main registers */
-	u16 temp;
-
-	SPUwriteRegister(0x1f801d80, 0x0000);
-	SPUwriteRegister(0x1f801d82, 0x0000);
-
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0x0000);
-	SPUwriteRegister(0x1f801d80, 0x0000);
-	SPUwriteRegister(0x1f801d82, 0x0000);
-
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801dae);
-
-	SPUwriteRegister(0x1f801dac, 0x0004);
-
-	// H_SPUvolL
-	SPUwriteRegister(0x1f801d84, 0x0000);
-
-	// H_SPUvolR
-	SPUwriteRegister(0x1f801d86, 0x0000);
-
-	// H_SPUoff1
-	SPUwriteRegister(0x1f801d8c, 0xffff);
-
-	// H_SPUoff2
-	SPUwriteRegister(0x1f801d8e, 0xffff);
-
-	// H_RVBon1
-	SPUwriteRegister(0x1f801d98, 0x0000);
-
-	// H_RVBon2
-	SPUwriteRegister(0x1f801d9a, 0x0000);
-
-	// H_Fmod1
-	SPUwriteRegister(0x1f801d90, 0x0000);
-
-	// H_Fmod2
-	SPUwriteRegister(0x1f801d92, 0x0000);
-
-	// H_Noise1
-	SPUwriteRegister(0x1f801d94, 0x0000);
-
-	// H_Noise2
-	SPUwriteRegister(0x1f801d96, 0x0000);
-
-	// H_CDLeft
-	SPUwriteRegister(0x1f801db0, 0x0000);
-
-	// H_CDRight
-	SPUwriteRegister(0x1f801db2, 0x0000);
-
-	SPUwriteRegister(0x1f801db4, 0x0000);
-	SPUwriteRegister(0x1f801db6, 0x0000);
-
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801dae);
-
-	// H_SPUaddr
-	SPUwriteRegister(0x1f801da6, 0x0200);
-
-	// H_SPUdata, hmmm... why 8 times??
-	for(int i = 0; i < 8; ++i)
-		SPUwriteRegister(0x1f801da8, 0x0707);
-
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801daa);
-
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0x0010);
-
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801dae);
-
-	// returns 0x0010
-	temp = SPUreadRegister(0x1f801daa);
-
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0x0000);
-
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801dae);
-
-
-
-	/* clear channels */
-	for(int i = 0; i < 24; ++i)
-	{
-		// left volume
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x00, 0x0000);
-		// right volume
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x02, 0x0000);
-		// pitch
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x04, 0x3fff);
-		// start address
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x06, 0x0200);
-		// level with pre-calcs
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x08, 0x0000);
-		// adsr times with precalcs
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x0a, 0x0000);
-	}
-
-
-
-	/* on/off SPU channels, why?? ;) */
-	// H_SPUon1
-	SPUwriteRegister(0x1f801d88, 0xffff);
-
-	// H_SPUon2
-	SPUwriteRegister(0x1f801d8a, 0x00ff);
-
-	// H_SPUoff1
-	SPUwriteRegister(0x1f801d8c, 0xffff);
-
-	// H_SPUoff2
-	SPUwriteRegister(0x1f801d8e, 0x00ff);
-
-
-
-	/* reverb initialization */
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc000);
-	// H_SPUReverbAddr
-	SPUwriteRegister(0x1f801da2, 0xfffe);
-
-
-
-	/* another dma transfer [unknown yet] */
-	// temporary writing another dma dump gotten with real emu
-	{
-		std::ifstream iF;
-		iF.open("data/dmadump2.bin", std::ios_base::binary);
-		u32 datasize = 64;
-		buffer = new u8[datasize];
-		iF.read((char *)buffer, datasize);
-		iF.close();
-		if(!this->PsxWriteDMA(0xedfc, buffer, datasize))
-		{
-			std::cout << "[SoundManager] error: failed to DMA write unknown data" << std::endl;
-			exit(EXIT_FAILURE);
-		}
-		delete [] buffer;
-	}
-
-
-
-	/* CDaudio controls? */
-	SPUwriteRegister(0x1f801d80, 0x3fff);
-	SPUwriteRegister(0x1f801d82, 0x3fff);
-	// H_CDLeft
-	SPUwriteRegister(0x1f801db0, 0x7fff);
-	// H_CDRight
-	SPUwriteRegister(0x1f801db2, 0x7fff);
-	SPUwriteRegister(0x1f801db4, 0x0000);
-	SPUwriteRegister(0x1f801db6, 0x0000);
-
-
-
-	/* here turning something important on, or clear something, me thinks... */
-	// returns 0xc0000
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc000);
-	// returns 0xc000
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc001);
-	// returns 0xc001
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc001);
-	// returns 0xc001
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc001);
-
-
-
-	/* clear channels volume again, for safe?? (cleared before) */
-	for(int i = 0; i < 24; ++i)
-	{
-		// left volume
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x00, 0x0000);
-		// right volume
-		SPUwriteRegister(m_REGISTER_BASE + 16 * i + 0x02, 0x0000);
-	}
-
-
-
-	/* another init ;) */
-	// returns 0xc001
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc001);
-	// returns 0xc001
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUoff1
-	SPUwriteRegister(0x1f801d8c, 0x0000);
-	// H_SPUoff2
-	SPUwriteRegister(0x1f801d8e, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// H_RVBon1
-	SPUwriteRegister(0x1f801d98, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// H_RVBon2
-	SPUwriteRegister(0x1f801d9a, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// H_RVBon1
-	SPUwriteRegister(0x1f801d98, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// H_RVBon2
-	SPUwriteRegister(0x1f801d9a, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// H_FMod1
-	SPUwriteRegister(0x1f801d90, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// H_FMod2
-	SPUwriteRegister(0x1f801d92, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// H_FMod1
-	SPUwriteRegister(0x1f801d90, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// H_FMod2
-	SPUwriteRegister(0x1f801d92, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// H_Noise1
-	SPUwriteRegister(0x1f801d94, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// H_Noise2
-	SPUwriteRegister(0x1f801d96, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// H_Noise1
-	SPUwriteRegister(0x1f801d94, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// H_Noise2
-	SPUwriteRegister(0x1f801d96, 0x0000);
-	// returns 0xc001
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc001);
-	// returns 0xc001
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUrvolL
-	SPUwriteRegister(0x1f801d84, 0x0000);
-	// H_SPUrvolR
-	SPUwriteRegister(0x1f801d86, 0x0000);
-
-
-
-	/* set reverb parameters?? */
-	// H_Reverb
-	SPUwriteRegister(0x1f801dc0, 0x00e3);
-	SPUwriteRegister(0x1f801dc2, 0x00a9);
-	SPUwriteRegister(0x1f801dc4, 0x6f60);
-	SPUwriteRegister(0x1f801dc6, 0x4fa8);
-	SPUwriteRegister(0x1f801dc8, 0xbce0);
-	SPUwriteRegister(0x1f801dca, 0x4510);
-	SPUwriteRegister(0x1f801dcc, 0xbef0);
-	SPUwriteRegister(0x1f801dce, 0xa680);
-	SPUwriteRegister(0x1f801dd0, 0x5680);
-	SPUwriteRegister(0x1f801dd2, 0x52c0);
-	SPUwriteRegister(0x1f801dd4, 0x0dfb);
-	SPUwriteRegister(0x1f801dd6, 0x0b58);
-	SPUwriteRegister(0x1f801dd8, 0x0d09);
-	SPUwriteRegister(0x1f801dda, 0x0a3c);
-	SPUwriteRegister(0x1f801ddc, 0x0bd9);
-	SPUwriteRegister(0x1f801dde, 0x0973);
-	SPUwriteRegister(0x1f801de0, 0x0b59);
-	SPUwriteRegister(0x1f801de2, 0x08da);
-	SPUwriteRegister(0x1f801de4, 0x08d9);
-	SPUwriteRegister(0x1f801de6, 0x05e9);
-	SPUwriteRegister(0x1f801de8, 0x07ec);
-	SPUwriteRegister(0x1f801dea, 0x04b0);
-	SPUwriteRegister(0x1f801dec, 0x06ef);
-	SPUwriteRegister(0x1f801dee, 0x03d2);
-	SPUwriteRegister(0x1f801df0, 0x05ea);
-	SPUwriteRegister(0x1f801df2, 0x031d);
-	SPUwriteRegister(0x1f801df4, 0x031c);
-	SPUwriteRegister(0x1f801df6, 0x0238);
-	SPUwriteRegister(0x1f801df8, 0x0154);
-	SPUwriteRegister(0x1f801dfa, 0x00aa);
-	SPUwriteRegister(0x1f801dfc, 0x8000);
-	SPUwriteRegister(0x1f801dfe, 0x8000);
-
-
-
-	/* and finishing dma transfer of zeroes :), phew */
-	{
-		u32 datasize = 1024;
-		u8 *buffer = new u8[datasize];
-		memset((void *)buffer, 0x00, datasize);
-		for(int i = 0; i < 28; ++i)
-		{
-			if(!this->PsxWriteDMA(0xf204 + 128 * i, buffer, datasize))
-			{
-				std::cout << "[SoundManager] error: failed to DMA write 0x00 data" << std::endl;
-				exit(EXIT_FAILURE);
-			}
-		}
-		delete [] buffer;
-	}
-
-
-
-	/* last init */
-	// H_SPUReverbAddr
-	SPUwriteRegister(0x1f801da2, 0xf204);
-	// returns 0xc001
-	temp = SPUreadRegister(0x1f801daa);
-	// H_SPUctrl
-	SPUwriteRegister(0x1f801daa, 0xc081);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// H_Noise1
-	SPUwriteRegister(0x1f801d94, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// H_Noise2
-	SPUwriteRegister(0x1f801d96, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d94);
-	// H_Noise1
-	SPUwriteRegister(0x1f801d94, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d96);
-	// H_Noise2
-	SPUwriteRegister(0x1f801d96, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// H_RVBon1
-	SPUwriteRegister(0x1f801d98, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// H_RVBon2
-	SPUwriteRegister(0x1f801d9a, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d98);
-	// H_RVBon1
-	SPUwriteRegister(0x1f801d98, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d9a);
-	// H_RVBon2
-	SPUwriteRegister(0x1f801d9a, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// H_FMod1
-	SPUwriteRegister(0x1f801d90, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// H_FMod2
-	SPUwriteRegister(0x1f801d92, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d90);
-	// H_FMod1
-	SPUwriteRegister(0x1f801d90, 0x0000);
-	// returns 0x0000
-	temp = SPUreadRegister(0x1f801d92);
-	// H_FMod2
-	SPUwriteRegister(0x1f801d92, 0x0000);
-	// H_SPUoff1
-	SPUwriteRegister(0x1f801d8c, 0xffff);
-	// H_SPUoff2
-	SPUwriteRegister(0x1f801d8e, 0x00ff);
-}
-
-
-bool SoundManager::PsxWriteDMA(u16 arg_address, u8 *arg_data, u32 arg_length)
-{
-	u16 temp;
-
-	// write and verify destination address
-	SPUwriteRegister(0x1f801da6, arg_address);
-	if(SPUreadRegister(0x1f801da6) != arg_address)
-		return false;
-
-	// set and verify dma operation
-	temp = SPUreadRegister(0x1f801daa);
-	temp |= 32;
-	SPUwriteRegister(0x1f801daa, temp);
-	if(SPUreadRegister(0x1f801daa) != temp)
-		return false;
-
-	SPUwriteDMAMem((unsigned short *)arg_data, arg_length / 2);
-
-	// clear and verify dma operation
-	temp = SPUreadRegister(0x1f801daa);
-	temp &= ~32;
-	SPUwriteRegister(0x1f801daa, temp);
-	if(SPUreadRegister(0x1f801daa) != temp)
-		return false;
-
-	return true;
-}
-
-
-SoundManager::~SoundManager()
-{
-    // close SPU
-    SPUclose();
-}
-
-
-
-void SoundManager::Update()
-{
-    SPUasync(0xc000);
-}
-
-
-
-void
-SoundManager::PsxChannelPlay( u8 arg_channel )
-{
-    if( arg_channel < 16 )
-    {
-        // H_SPUon1
-        SPUwriteRegister( 0x1f801d88, 1 << arg_channel );
-    }
-    else if( arg_channel >= 16 && arg_channel < 24 )
-    {
-        // H_SPUon2
-        SPUwriteRegister( 0x1f801d8a, 1 << ( arg_channel - 16 ) );
-    }
-}
-
-
-
-void
-SoundManager::PsxChannelStop( u8 arg_channel )
-{
-    if( arg_channel < 16 )
-    {
-        // H_SPUoff1
-        SPUwriteRegister( 0x1f801d8c, 1 << arg_channel );
-    }
-    else if( arg_channel >= 16 && arg_channel < 24 )
-    {
-        // H_SPUoff2
-        SPUwriteRegister( 0x1f801d8e, 1 << ( arg_channel - 16 ) );
-    }
-}
-
-
-
-void
-SoundManager::PsxReverbOn( u8 arg_channel )
-{
-    if( arg_channel < 16 )
-    {
-        // H_RVBon1
-        SPUwriteRegister( 0x1f801d98, 1 << arg_channel );
-    }
-    else if( arg_channel >= 16 && arg_channel < 24 )
-    {
-        // H_RVBon2
-        SPUwriteRegister( 0x1f801d9a, 1 << ( arg_channel - 16 ) );
-    }
-}
-
-
-
-void
-SoundManager::PsxSetReverbDepth( u16 arg_left, u16 arg_right )
-{
-    SPUwriteRegister( 0x1f801d84, arg_left );
-    SPUwriteRegister( 0x1f801d86, arg_right );
-}
-
-
-
-void
-SoundManager::SetVoiceStartAddress( u8 arg_voice, u32 arg_address )
-{
-    if( arg_voice < 0x18 )
-    {
-        // if address isn't divisible by 8, it's
-        // increased to the next value divisible by 8
-        if( arg_address % 8 )
-        {
-            arg_address += 8;
-            arg_address &= ~7;
-        }
-
-        SPUwriteRegister( m_PSX_SPU_BASE + arg_voice * 0x10 + 0x06, ( u16 )( arg_address / 8 ) );
-    }
-}
-
-
-
-void SoundManager::SetVoiceLoopAddress(u8 arg_voice, u32 arg_address)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	// if address isn't divisible by 8, it's
-	// increased to the next value divisible by 8
-	if(arg_address % 8)
-	{
-		arg_address += 8;
-		arg_address &= ~7;
-	}
-
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x0e, (u16)(arg_address / 8));
-}
-
-
-// +++
-void SoundManager::SetVoiceVolume(u8 arg_voice,
-		s16 arg_volume_left, s16 arg_volume_right)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x00,
-			arg_volume_left & 0x7fff);
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x02,
-			arg_volume_right & 0x7fff);
-}
-
-
-// +++
-void SoundManager::SetVoicePitch(u8 arg_voice, u16 arg_pitch)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	if(arg_pitch >= 0x4000)
-	{
-		std::cout << "*** error: wrong pitch!" << std::endl;
-		return;
-	}
-
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x04, arg_pitch);
-}
-
-
-// +++
-void SoundManager::SetVoiceAttackRate(u8 arg_voice,
-		u16 arg_rate, SpuRateMode arg_mode)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	if(arg_rate >= 0x80)
-	{
-		std::cout << "*** error: wrong attack rate!" << std::endl;
-		return;
-	}
-
-	u16 value = (arg_mode == SPU_VOICE_EXPIncN) ? (1 << 7) : 0;
-	value |= arg_rate;
-	value <<= 8;
-
-	u16 temp = SPUreadRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x08) & 0xFF;
-	temp |= value;
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x08, temp);
-}
-
-
-// +++
-void SoundManager::SetVoiceSustainRate(u8 arg_voice,
-		u16 arg_rate, SpuRateMode arg_mode)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	if(arg_rate >= 0x80)
-	{
-		std::cout << "*** error: wrong sustain rate!" << std::endl;
-		return;
-	}
-
-	u16 value;
-	switch(arg_mode)
-	{
-		case SPU_VOICE_EXPIncN:
-			value = 0x200;
-			break;
-
-		case SPU_VOICE_LINEARDecN:
-			value = 0x100;
-			break;
-
-		case SPU_VOICE_EXPDec:
-			value = 0x300;
-			break;
-
-		default:
-		std::cout << "*** error: wrong sustain rate mode!" << std::endl;
-		case SPU_VOICE_LINEARIncN:
-			value = 0x000;
-			break;
-	}
-
-	u16 temp = SPUreadRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x0a) & 0x3F;
-	temp |= (arg_rate | value) << 6;
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x0a, temp);
-}
-
-
-// +++
-void SoundManager::SetVoiceReleaseRate(u8 arg_voice,
-		u16 arg_rate, SpuRateMode arg_mode)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	if(arg_rate >= 0x20)
-	{
-		std::cout << "*** error: wrong release rate!" << std::endl;
-		return;
-	}
-
-	u16 value = (arg_mode == SPU_VOICE_EXPDec) ? (1 << 5) : 0;
-	value |= arg_rate;
-
-	u16 temp = SPUreadRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x0a)
-		& 0xFFC0;
-	temp |= value;
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x0a, temp);
-}
-
-
-// +++
-void SoundManager::SetVoiceDecayRate(u8 arg_voice, u16 arg_rate)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	if(arg_rate >= 0x10)
-	{
-		std::cout << "*** error: wrong decay rate!" << std::endl;
-		return;
-	}
-
-	u16 temp = SPUreadRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x08)
-		& 0xFF0F;
-	temp |= arg_rate << 4;
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x08, temp);
-}
-
-
-// +++
-void SoundManager::SetVoiceSustainLevel(u8 arg_voice, u16 arg_level)
-{
-	if(arg_voice >= 0x18)
-	{
-		std::cout << "*** error: wrong channel!" << std::endl;
-		return;
-	}
-
-	if(arg_level >= 0x10)
-	{
-		std::cout << "*** error: wrong sustain level!" << std::endl;
-		return;
-	}
-
-	u16 temp = SPUreadRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x08)
-		& 0xFFF0;
-	temp |= arg_level;
-	SPUwriteRegister(m_PSX_SPU_BASE + arg_voice * 0x10 + 0x08, temp);
-}
-
-
-void InitADSR()
-{
-	unsigned long r = 3;
-	unsigned long rs = 1;
-	unsigned long rd = 0;
-	int i;
-
-	// build the rate table according to Neill's rules
-	memset(RateTable, 0, sizeof(unsigned long) * 160);
-
-	// we start at pos 32 with the real values... everything before is 0
-	for(i = 32; i < 160; i++)
-	{
-		if(r < 0x3FFFFFFF)
-		{
-			r += rs;
-			rd++;
-			if(rd == 5)
-			{
-				rd = 1;
-				rs *= 2;
-			}
-		}
-		if(r > 0x3FFFFFFF)
-			r = 0x3FFFFFFF;
-
-		RateTable[i] = r;
-	}
-}
-
-
-void StartADSR(int ch)
-{
-	s_chan[ch].ADSRX.lVolume = 1;
-	s_chan[ch].ADSRX.State = 0;
-	s_chan[ch].ADSRX.EnvelopeVol = 0;
-}
-
-
-int MixADSR(int ch)
-{
-	// channel stopped
-	if(s_chan[ch].bStop)
-	{
-		// release
-		if(s_chan[ch].ADSRX.ReleaseModeExp)
-		{
-			switch((s_chan[ch].ADSRX.EnvelopeVol >> 28) & 0x07)
-			{
-				case 0:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 0 + 32];
-					break;
-
-				case 1:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 4 + 32];
-					break;
-
-				case 2:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 6 + 32];
-					break;
-
-				case 3:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 8 + 32];
-					break;
-
-				case 4:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 9 + 32];
-					break;
-
-				case 5:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 10 + 32];
-					break;
-
-				case 6:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 11 + 32];
-					break;
-
-				case 7:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x18 + 12 + 32];
-					break;
-			}
-		}
-		else
-			s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-				(s_chan[ch].ADSRX.ReleaseRate^0x1F)) - 0x0C + 32];
-
-		if(s_chan[ch].ADSRX.EnvelopeVol < 0)
-		{
-			s_chan[ch].ADSRX.EnvelopeVol = 0;
-			s_chan[ch].bOn = 0;
-		}
-
-		s_chan[ch].ADSRX.lVolume = s_chan[ch].ADSRX.EnvelopeVol >> 21;
-
-		return s_chan[ch].ADSRX.lVolume;
-	}
-
-	// channel not stopped
-	else
-	{
-		// attack
-		if(s_chan[ch].ADSRX.State == 0)
-		{
-			if(s_chan[ch].ADSRX.AttackModeExp)
-			{
-				if(s_chan[ch].ADSRX.EnvelopeVol < 0x60000000)
-					s_chan[ch].ADSRX.EnvelopeVol += RateTable[
-						(s_chan[ch].ADSRX.AttackRate^0x7F) - 0x10 + 32];
-				else
-					s_chan[ch].ADSRX.EnvelopeVol += RateTable[
-						(s_chan[ch].ADSRX.AttackRate^0x7F) - 0x18 + 32];
-			}
-			else
-				s_chan[ch].ADSRX.EnvelopeVol += RateTable[
-					(s_chan[ch].ADSRX.AttackRate^0x7F) - 0x10 + 32];
-
-			if(s_chan[ch].ADSRX.EnvelopeVol < 0)
-			{
-				s_chan[ch].ADSRX.EnvelopeVol = 0x7FFFFFFF;
-				s_chan[ch].ADSRX.State = 1;
-			}
-
-			s_chan[ch].ADSRX.lVolume = s_chan[ch].ADSRX.EnvelopeVol >> 21;
-			return s_chan[ch].ADSRX.lVolume;
-		}
-
-		// decay
-		if(s_chan[ch].ADSRX.State == 1)
-		{
-			switch((s_chan[ch].ADSRX.EnvelopeVol >> 28) & 0x07)
-			{
-				case 0:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 0 + 32];
-					break;
-
-				case 1:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 4 + 32];
-					break;
-
-				case 2:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 6 + 32];
-					break;
-
-				case 3:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 8 + 32];
-					break;
-
-				case 4:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 9 + 32];
-					break;
-
-				case 5:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 10 + 32];
-					break;
-
-				case 6:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 11 + 32];
-					break;
-
-				case 7:
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[(4 *
-						(s_chan[ch].ADSRX.DecayRate^0x1F)) - 0x18 + 12 + 32];
-					break;
-			}
-
-			if(s_chan[ch].ADSRX.EnvelopeVol < 0)
-				s_chan[ch].ADSRX.EnvelopeVol = 0;
-
-			if(((s_chan[ch].ADSRX.EnvelopeVol >> 27) & 0xF) <=
-					s_chan[ch].ADSRX.SustainLevel)
-				s_chan[ch].ADSRX.State = 2;
-
-			s_chan[ch].ADSRX.lVolume = s_chan[ch].ADSRX.EnvelopeVol >> 21;
-			return s_chan[ch].ADSRX.lVolume;
-		}
-
-		// sustain
-		if(s_chan[ch].ADSRX.State == 2)
-		{
-			if(s_chan[ch].ADSRX.SustainIncrease)
-			{
-				if(s_chan[ch].ADSRX.SustainModeExp)
-				{
-					if(s_chan[ch].ADSRX.EnvelopeVol < 0x60000000)
-						s_chan[ch].ADSRX.EnvelopeVol += RateTable[
-							(s_chan[ch].ADSRX.SustainRate^0x7F) - 0x10 + 32];
-					else
-						s_chan[ch].ADSRX.EnvelopeVol += RateTable[
-							(s_chan[ch].ADSRX.SustainRate^0x7F) - 0x18 + 32];
-				}
-				else
-					s_chan[ch].ADSRX.EnvelopeVol += RateTable[
-						(s_chan[ch].ADSRX.SustainRate^0x7F) - 0x10 + 32];
-
-				if(s_chan[ch].ADSRX.EnvelopeVol < 0)
-					s_chan[ch].ADSRX.EnvelopeVol = 0x7FFFFFFF;
-			}
-			else
-			{
-				if(s_chan[ch].ADSRX.SustainModeExp)
-				{
-					switch((s_chan[ch].ADSRX.EnvelopeVol >> 28) & 0x7)
-					{
-						case 0:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 0 + 32];
-							break;
-
-						case 1:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 4 + 32];
-							break;
-
-						case 2:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 6 + 32];
-							break;
-
-						case 3:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 8 + 32];
-							break;
-
-						case 4:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 9 + 32];
-							break;
-
-						case 5:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 10 + 32];
-							break;
-
-						case 6:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 11 + 32];
-							break;
-
-						case 7:
-							s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-								((s_chan[ch].ADSRX.SustainRate^0x7F))
-								- 0x1B + 12 + 32];
-							break;
-					}
-				}
-				else
-					s_chan[ch].ADSRX.EnvelopeVol -= RateTable[
-						((s_chan[ch].ADSRX.SustainRate^0x7F)) - 0x0F + 32];
-
-				if(s_chan[ch].ADSRX.EnvelopeVol < 0)
-					s_chan[ch].ADSRX.EnvelopeVol = 0;
-			}
-
-			s_chan[ch].ADSRX.lVolume = s_chan[ch].ADSRX.EnvelopeVol >> 21;
-			return s_chan[ch].ADSRX.lVolume;
-		}
-	}
-
-	return 0;
-}
-
-unsigned short SPUreadDMA()
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "SPUreadDMA()" << std::endl;
-#endif
-
-	unsigned short s = spuMem[spuAddr >> 1];
-	spuAddr += 2;
-	if(spuAddr > 0x7ffff)
-		spuAddr = 0;
-
-	iWatchDog = 0;
-
-	return s;
-}
-
-
-void SPUreadDMAMem(unsigned short *pusPSXMem, int iSize)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "SPUreadDMAMem()" << std::endl;
-#endif
-
-	int i;
-
-	for(i = 0; i < iSize; i++)
-	{
-		// spu addr got by writeregister
-		*pusPSXMem++ = spuMem[spuAddr >> 1];
-		// inc spu addr
-		spuAddr += 2;
-		// wrap
-		if(spuAddr > 0x7ffff)
-			spuAddr = 0;
-	}
-
-	iWatchDog = 0;
-}
-
-
-// to investigate: do sound data updates by writedma affect spu
-// irqs? Will an irq be triggered, if new data is written to
-// the memory irq address?
-
-void SPUwriteDMA(unsigned short val)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "SPUwriteDMA()" << std::endl;
-#endif
-
-	// spu addr got by writeregister
-	spuMem[spuAddr >> 1] = val;
-
-	// inc spu addr
-	spuAddr += 2;
-	// wrap
-	if(spuAddr > 0x7ffff)
-		spuAddr = 0;
-
-	iWatchDog = 0;
-}
-
-
-
-void SPUwriteDMAMem(unsigned short *pusPSXMem, int iSize)
-{
-    int i;
-
-    for ( i = 0; i < iSize; i++ )
-    {
-        // spu addr got by writeregister
-        spuMem[spuAddr >> 1] = *pusPSXMem++;
-        // inc spu addr
-        spuAddr += 2;
-        // wrap
-        if(spuAddr > 0x7ffff)
-        {
-            spuAddr = 0;
-        }
-    }
-
-    iWatchDog = 0;
-}
-
-
-const int gauss[] =
-{
-	0x172, 0x519, 0x176, 0x000, 0x16E, 0x519, 0x17A, 0x000,
-	0x16A, 0x518, 0x17D, 0x000, 0x166, 0x518, 0x181, 0x000,
-	0x162, 0x518, 0x185, 0x000, 0x15F, 0x518, 0x189, 0x000,
-	0x15B, 0x518, 0x18D, 0x000, 0x157, 0x517, 0x191, 0x000,
-	0x153, 0x517, 0x195, 0x000, 0x150, 0x517, 0x19A, 0x000,
-	0x14C, 0x516, 0x19E, 0x000, 0x148, 0x516, 0x1A2, 0x000,
-	0x145, 0x515, 0x1A6, 0x000, 0x141, 0x514, 0x1AA, 0x000,
-	0x13E, 0x514, 0x1AE, 0x000, 0x13A, 0x513, 0x1B2, 0x000,
-	0x137, 0x512, 0x1B7, 0x001, 0x133, 0x511, 0x1BB, 0x001,
-	0x130, 0x511, 0x1BF, 0x001, 0x12C, 0x510, 0x1C3, 0x001,
-	0x129, 0x50F, 0x1C8, 0x001, 0x125, 0x50E, 0x1CC, 0x001,
-	0x122, 0x50D, 0x1D0, 0x001, 0x11E, 0x50C, 0x1D5, 0x001,
-	0x11B, 0x50B, 0x1D9, 0x001, 0x118, 0x50A, 0x1DD, 0x001,
-	0x114, 0x508, 0x1E2, 0x001, 0x111, 0x507, 0x1E6, 0x002,
-	0x10E, 0x506, 0x1EB, 0x002, 0x10B, 0x504, 0x1EF, 0x002,
-	0x107, 0x503, 0x1F3, 0x002, 0x104, 0x502, 0x1F8, 0x002,
-	0x101, 0x500, 0x1FC, 0x002, 0x0FE, 0x4FF, 0x201, 0x002,
-	0x0FB, 0x4FD, 0x205, 0x003, 0x0F8, 0x4FB, 0x20A, 0x003,
-	0x0F5, 0x4FA, 0x20F, 0x003, 0x0F2, 0x4F8, 0x213, 0x003,
-	0x0EF, 0x4F6, 0x218, 0x003, 0x0EC, 0x4F5, 0x21C, 0x004,
-	0x0E9, 0x4F3, 0x221, 0x004, 0x0E6, 0x4F1, 0x226, 0x004,
-	0x0E3, 0x4EF, 0x22A, 0x004, 0x0E0, 0x4ED, 0x22F, 0x004,
-	0x0DD, 0x4EB, 0x233, 0x005, 0x0DA, 0x4E9, 0x238, 0x005,
-	0x0D7, 0x4E7, 0x23D, 0x005, 0x0D4, 0x4E5, 0x241, 0x005,
-	0x0D2, 0x4E3, 0x246, 0x006, 0x0CF, 0x4E0, 0x24B, 0x006,
-	0x0CC, 0x4DE, 0x250, 0x006, 0x0C9, 0x4DC, 0x254, 0x006,
-	0x0C7, 0x4D9, 0x259, 0x007, 0x0C4, 0x4D7, 0x25E, 0x007,
-	0x0C1, 0x4D5, 0x263, 0x007, 0x0BF, 0x4D2, 0x267, 0x008,
-	0x0BC, 0x4D0, 0x26C, 0x008, 0x0BA, 0x4CD, 0x271, 0x008,
-	0x0B7, 0x4CB, 0x276, 0x009, 0x0B4, 0x4C8, 0x27B, 0x009,
-	0x0B2, 0x4C5, 0x280, 0x009, 0x0AF, 0x4C3, 0x284, 0x00A,
-	0x0AD, 0x4C0, 0x289, 0x00A, 0x0AB, 0x4BD, 0x28E, 0x00A,
-	0x0A8, 0x4BA, 0x293, 0x00B, 0x0A6, 0x4B7, 0x298, 0x00B,
-	0x0A3, 0x4B5, 0x29D, 0x00B, 0x0A1, 0x4B2, 0x2A2, 0x00C,
-	0x09F, 0x4AF, 0x2A6, 0x00C, 0x09C, 0x4AC, 0x2AB, 0x00D,
-	0x09A, 0x4A9, 0x2B0, 0x00D, 0x098, 0x4A6, 0x2B5, 0x00E,
-	0x096, 0x4A2, 0x2BA, 0x00E, 0x093, 0x49F, 0x2BF, 0x00F,
-	0x091, 0x49C, 0x2C4, 0x00F, 0x08F, 0x499, 0x2C9, 0x00F,
-	0x08D, 0x496, 0x2CE, 0x010, 0x08B, 0x492, 0x2D3, 0x010,
-	0x089, 0x48F, 0x2D8, 0x011, 0x086, 0x48C, 0x2DC, 0x011,
-	0x084, 0x488, 0x2E1, 0x012, 0x082, 0x485, 0x2E6, 0x013,
-	0x080, 0x481, 0x2EB, 0x013, 0x07E, 0x47E, 0x2F0, 0x014,
-	0x07C, 0x47A, 0x2F5, 0x014, 0x07A, 0x477, 0x2FA, 0x015,
-	0x078, 0x473, 0x2FF, 0x015, 0x076, 0x470, 0x304, 0x016,
-	0x075, 0x46C, 0x309, 0x017, 0x073, 0x468, 0x30E, 0x017,
-	0x071, 0x465, 0x313, 0x018, 0x06F, 0x461, 0x318, 0x018,
-	0x06D, 0x45D, 0x31D, 0x019, 0x06B, 0x459, 0x322, 0x01A,
-	0x06A, 0x455, 0x326, 0x01B, 0x068, 0x452, 0x32B, 0x01B,
-	0x066, 0x44E, 0x330, 0x01C, 0x064, 0x44A, 0x335, 0x01D,
-	0x063, 0x446, 0x33A, 0x01D, 0x061, 0x442, 0x33F, 0x01E,
-	0x05F, 0x43E, 0x344, 0x01F, 0x05E, 0x43A, 0x349, 0x020,
-	0x05C, 0x436, 0x34E, 0x020, 0x05A, 0x432, 0x353, 0x021,
-	0x059, 0x42E, 0x357, 0x022, 0x057, 0x42A, 0x35C, 0x023,
-	0x056, 0x425, 0x361, 0x024, 0x054, 0x421, 0x366, 0x024,
-	0x053, 0x41D, 0x36B, 0x025, 0x051, 0x419, 0x370, 0x026,
-	0x050, 0x415, 0x374, 0x027, 0x04E, 0x410, 0x379, 0x028,
-	0x04D, 0x40C, 0x37E, 0x029, 0x04C, 0x408, 0x383, 0x02A,
-	0x04A, 0x403, 0x388, 0x02B, 0x049, 0x3FF, 0x38C, 0x02C,
-	0x047, 0x3FB, 0x391, 0x02D, 0x046, 0x3F6, 0x396, 0x02E,
-	0x045, 0x3F2, 0x39B, 0x02F, 0x043, 0x3ED, 0x39F, 0x030,
-	0x042, 0x3E9, 0x3A4, 0x031, 0x041, 0x3E5, 0x3A9, 0x032,
-	0x040, 0x3E0, 0x3AD, 0x033, 0x03E, 0x3DC, 0x3B2, 0x034,
-	0x03D, 0x3D7, 0x3B7, 0x035, 0x03C, 0x3D2, 0x3BB, 0x036,
-	0x03B, 0x3CE, 0x3C0, 0x037, 0x03A, 0x3C9, 0x3C5, 0x038,
-	0x038, 0x3C5, 0x3C9, 0x03A, 0x037, 0x3C0, 0x3CE, 0x03B,
-	0x036, 0x3BB, 0x3D2, 0x03C, 0x035, 0x3B7, 0x3D7, 0x03D,
-	0x034, 0x3B2, 0x3DC, 0x03E, 0x033, 0x3AD, 0x3E0, 0x040,
-	0x032, 0x3A9, 0x3E5, 0x041, 0x031, 0x3A4, 0x3E9, 0x042,
-	0x030, 0x39F, 0x3ED, 0x043, 0x02F, 0x39B, 0x3F2, 0x045,
-	0x02E, 0x396, 0x3F6, 0x046, 0x02D, 0x391, 0x3FB, 0x047,
-	0x02C, 0x38C, 0x3FF, 0x049, 0x02B, 0x388, 0x403, 0x04A,
-	0x02A, 0x383, 0x408, 0x04C, 0x029, 0x37E, 0x40C, 0x04D,
-	0x028, 0x379, 0x410, 0x04E, 0x027, 0x374, 0x415, 0x050,
-	0x026, 0x370, 0x419, 0x051, 0x025, 0x36B, 0x41D, 0x053,
-	0x024, 0x366, 0x421, 0x054, 0x024, 0x361, 0x425, 0x056,
-	0x023, 0x35C, 0x42A, 0x057, 0x022, 0x357, 0x42E, 0x059,
-	0x021, 0x353, 0x432, 0x05A, 0x020, 0x34E, 0x436, 0x05C,
-	0x020, 0x349, 0x43A, 0x05E, 0x01F, 0x344, 0x43E, 0x05F,
-	0x01E, 0x33F, 0x442, 0x061, 0x01D, 0x33A, 0x446, 0x063,
-	0x01D, 0x335, 0x44A, 0x064, 0x01C, 0x330, 0x44E, 0x066,
-	0x01B, 0x32B, 0x452, 0x068, 0x01B, 0x326, 0x455, 0x06A,
-	0x01A, 0x322, 0x459, 0x06B, 0x019, 0x31D, 0x45D, 0x06D,
-	0x018, 0x318, 0x461, 0x06F, 0x018, 0x313, 0x465, 0x071,
-	0x017, 0x30E, 0x468, 0x073, 0x017, 0x309, 0x46C, 0x075,
-	0x016, 0x304, 0x470, 0x076, 0x015, 0x2FF, 0x473, 0x078,
-	0x015, 0x2FA, 0x477, 0x07A, 0x014, 0x2F5, 0x47A, 0x07C,
-	0x014, 0x2F0, 0x47E, 0x07E, 0x013, 0x2EB, 0x481, 0x080,
-	0x013, 0x2E6, 0x485, 0x082, 0x012, 0x2E1, 0x488, 0x084,
-	0x011, 0x2DC, 0x48C, 0x086, 0x011, 0x2D8, 0x48F, 0x089,
-	0x010, 0x2D3, 0x492, 0x08B, 0x010, 0x2CE, 0x496, 0x08D,
-	0x00F, 0x2C9, 0x499, 0x08F, 0x00F, 0x2C4, 0x49C, 0x091,
-	0x00F, 0x2BF, 0x49F, 0x093, 0x00E, 0x2BA, 0x4A2, 0x096,
-	0x00E, 0x2B5, 0x4A6, 0x098, 0x00D, 0x2B0, 0x4A9, 0x09A,
-	0x00D, 0x2AB, 0x4AC, 0x09C, 0x00C, 0x2A6, 0x4AF, 0x09F,
-	0x00C, 0x2A2, 0x4B2, 0x0A1, 0x00B, 0x29D, 0x4B5, 0x0A3,
-	0x00B, 0x298, 0x4B7, 0x0A6, 0x00B, 0x293, 0x4BA, 0x0A8,
-	0x00A, 0x28E, 0x4BD, 0x0AB, 0x00A, 0x289, 0x4C0, 0x0AD,
-	0x00A, 0x284, 0x4C3, 0x0AF, 0x009, 0x280, 0x4C5, 0x0B2,
-	0x009, 0x27B, 0x4C8, 0x0B4, 0x009, 0x276, 0x4CB, 0x0B7,
-	0x008, 0x271, 0x4CD, 0x0BA, 0x008, 0x26C, 0x4D0, 0x0BC,
-	0x008, 0x267, 0x4D2, 0x0BF, 0x007, 0x263, 0x4D5, 0x0C1,
-	0x007, 0x25E, 0x4D7, 0x0C4, 0x007, 0x259, 0x4D9, 0x0C7,
-	0x006, 0x254, 0x4DC, 0x0C9, 0x006, 0x250, 0x4DE, 0x0CC,
-	0x006, 0x24B, 0x4E0, 0x0CF, 0x006, 0x246, 0x4E3, 0x0D2,
-	0x005, 0x241, 0x4E5, 0x0D4, 0x005, 0x23D, 0x4E7, 0x0D7,
-	0x005, 0x238, 0x4E9, 0x0DA, 0x005, 0x233, 0x4EB, 0x0DD,
-	0x004, 0x22F, 0x4ED, 0x0E0, 0x004, 0x22A, 0x4EF, 0x0E3,
-	0x004, 0x226, 0x4F1, 0x0E6, 0x004, 0x221, 0x4F3, 0x0E9,
-	0x004, 0x21C, 0x4F5, 0x0EC, 0x003, 0x218, 0x4F6, 0x0EF,
-	0x003, 0x213, 0x4F8, 0x0F2, 0x003, 0x20F, 0x4FA, 0x0F5,
-	0x003, 0x20A, 0x4FB, 0x0F8, 0x003, 0x205, 0x4FD, 0x0FB,
-	0x002, 0x201, 0x4FF, 0x0FE, 0x002, 0x1FC, 0x500, 0x101,
-	0x002, 0x1F8, 0x502, 0x104, 0x002, 0x1F3, 0x503, 0x107,
-	0x002, 0x1EF, 0x504, 0x10B, 0x002, 0x1EB, 0x506, 0x10E,
-	0x002, 0x1E6, 0x507, 0x111, 0x001, 0x1E2, 0x508, 0x114,
-	0x001, 0x1DD, 0x50A, 0x118, 0x001, 0x1D9, 0x50B, 0x11B,
-	0x001, 0x1D5, 0x50C, 0x11E, 0x001, 0x1D0, 0x50D, 0x122,
-	0x001, 0x1CC, 0x50E, 0x125, 0x001, 0x1C8, 0x50F, 0x129,
-	0x001, 0x1C3, 0x510, 0x12C, 0x001, 0x1BF, 0x511, 0x130,
-	0x001, 0x1BB, 0x511, 0x133, 0x001, 0x1B7, 0x512, 0x137,
-	0x000, 0x1B2, 0x513, 0x13A, 0x000, 0x1AE, 0x514, 0x13E,
-	0x000, 0x1AA, 0x514, 0x141, 0x000, 0x1A6, 0x515, 0x145,
-	0x000, 0x1A2, 0x516, 0x148, 0x000, 0x19E, 0x516, 0x14C,
-	0x000, 0x19A, 0x517, 0x150, 0x000, 0x195, 0x517, 0x153,
-	0x000, 0x191, 0x517, 0x157, 0x000, 0x18D, 0x518, 0x15B,
-	0x000, 0x189, 0x518, 0x15F, 0x000, 0x185, 0x518, 0x162,
-	0x000, 0x181, 0x518, 0x166, 0x000, 0x17D, 0x518, 0x16A,
-	0x000, 0x17A, 0x519, 0x16E, 0x000, 0x176, 0x519, 0x172
-};
-
-void SPUwriteRegister(unsigned long reg, unsigned short val)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << setfill('0');
-	std::cout << "*** SPUwriteRegister() " << "[address 0x"
-	   << hex << setw(8) << reg << "] ";
-#endif
-
-	const unsigned long r = reg & 0xfff;
-	regArea[(r - 0xc00) >> 1] = val;
-
-	// some channel info?
-	if(r >= 0x0c00 && r < 0x0d80)
-	{
-		// calc channel
-		int ch = (r >> 4) - 0xc0;
-
-		switch(r & 0x0f)
-		{
-			// l volume
-			case 0:
-#ifdef DEBUG_OUTPUT
-				std::cout << "Left Volume - ";
-#endif
-
-				SetVolumeL((unsigned char)ch, val);
-				break;
-
-			// r volume
-			case 2:
-#ifdef DEBUG_OUTPUT
-				std::cout << "Right Volume - ";
-#endif
-
-				SetVolumeR((unsigned char)ch, val);
-				break;
-
-			// pitch
-			case 4:
-#ifdef DEBUG_OUTPUT
-				std::cout << "Pitch - ";
-#endif
-
-				SetPitch(ch, val);
-				break;
-
-			// start
-			case 6:
-#ifdef DEBUG_OUTPUT
-				std::cout << "Start Address - ";
-#endif
-				s_chan[ch].pStart = spuMemC + ((unsigned long)val << 3);
-				break;
-
-			// level with pre-calcs
-			case 8:
-#ifdef DEBUG_OUTPUT
-				std::cout << "Level with Pre-Calcs - ";
-#endif
-
-				{
-					const unsigned long lval = val;
-
-					s_chan[ch].ADSRX.AttackModeExp=(lval&0x8000)?1:0;
-					s_chan[ch].ADSRX.AttackRate=(lval>>8) & 0x007f;
-					s_chan[ch].ADSRX.DecayRate=(lval>>4) & 0x000f;
-					s_chan[ch].ADSRX.SustainLevel=lval & 0x000f;
-				}
-				break;
-
-			// adsr times with pre-calcs
-			case 10:
-#ifdef DEBUG_OUTPUT
-				std::cout << "ADSR Times with Pre-Calcs - ";
-#endif
-
-				{
-					const unsigned long lval = val;
-
-					s_chan[ch].ADSRX.SustainModeExp = (lval & 0x8000) ? 1 : 0;
-					s_chan[ch].ADSRX.SustainIncrease = (lval & 0x4000) ? 0 : 1;
-					s_chan[ch].ADSRX.SustainRate = (lval >> 6) & 0x007f;
-					s_chan[ch].ADSRX.ReleaseModeExp = (lval & 0x0020) ? 1 : 0;
-					s_chan[ch].ADSRX.ReleaseRate = lval & 0x001f;
-				}
-				break;
-
-			// adsr volume... mmm have to investigate this
-			case 12:
-#ifdef DEBUG_OUTPUT
-				std::cout << "ADSR Volume - ";
-#endif
-				break;
-
-			// loop
-			case 14:
-#ifdef DEBUG_OUTPUT
-				std::cout << "Loop Address - ";
-#endif
-				s_chan[ch].pLoop = spuMemC + ((unsigned long)val << 3);
-				s_chan[ch].bIgnoreLoop = 1;
-				break;
-		}
-
-		iWatchDog = 0;
-
-#ifdef DEBUG_OUTPUT
-		std::cout << "0x" << hex << setw(4) << val << std::endl;
-#endif
-
-		return;
-	}
-
-	switch(r)
-	{
-		case H_SPUaddr:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUaddr - ";
-#endif
-			spuAddr = (unsigned long)val << 3;
-			break;
-
-		case H_SPUdata:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUdata - ";
-#endif
-			spuMem[spuAddr >> 1] = val;
-			spuAddr += 2;
-			if(spuAddr > 0x7ffff)
-				spuAddr = 0;
-			break;
-
-		case H_SPUctrl:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUctrl - ";
-#endif
-			spuCtrl = val;
-			break;
-
-		case H_SPUstat:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUstat - ";
-#endif
-			spuStat = val & 0xf800;
-			break;
-
-		case H_SPUReverbAddr:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUReverbAddr - ";
-#endif
-			if(val == 0xFFFF || val <= 0x200)
-				rvb.StartAddr = rvb.CurrAddr = 0;
-			else
-			{
-				const long iv = (unsigned long)val << 2;
-				if(rvb.StartAddr != iv)
-				{
-					rvb.StartAddr = (unsigned long)val << 2;
-					rvb.CurrAddr = rvb.StartAddr;
-				}
-			}
-			break;
-
-		case H_SPUirqAddr:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUirqAddr - ";
-#endif
-			spuIrq = val;
-			pSpuIrq = spuMemC + ((unsigned long) val << 3);
-			break;
-
-		case H_SPUrvolL:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUrvolL - ";
-#endif
-			rvb.VolLeft = val;
-			break;
-
-		case H_SPUrvolR:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUrvolR - ";
-#endif
-			rvb.VolRight = val;
-			break;
-
-		case H_SPUon1:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUon1 - ";
-#endif
-			SoundOn(0, 16, val);
-			break;
-
-		case H_SPUon2:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUon2 - ";
-#endif
-			SoundOn(16, 24, val);
-			break;
-
-		case H_SPUoff1:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUoff1 - ";
-#endif
-			SoundOff(0, 16, val);
-			break;
-
-		case H_SPUoff2:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_SPUoff2 - ";
-#endif
-			SoundOff(16, 24, val);
-			break;
-
-		case H_CDLeft:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_CDLeft - ";
-#endif
-			iLeftXAVol = val & 0x7fff;
-			if(cddavCallback)
-				cddavCallback(0, val);
-			break;
-
-		case H_CDRight:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_CDRight - ";
-#endif
-			iRightXAVol = val & 0x7fff;
-			if(cddavCallback)
-				cddavCallback(1, val);
-			break;
-
-		case H_FMod1:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_FMod1 - ";
-#endif
-			FModOn(0, 16, val);
-			break;
-
-		case H_FMod2:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_FMod2 - ";
-#endif
-			FModOn(16, 24, val);
-			break;
-
-		case H_Noise1:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_Noise1 - ";
-#endif
-			NoiseOn(0, 16, val);
-			break;
-
-		case H_Noise2:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_Noise2 - ";
-#endif
-			NoiseOn(16, 24, val);
-			break;
-
-		case H_RVBon1:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_RVBon1 - ";
-#endif
-			ReverbOn(0, 16, val);
-			break;
-
-		case H_RVBon2:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_RVBon2 - ";
-#endif
-			ReverbOn(16, 24, val);
-			break;
-
-		case H_Reverb + 0:
-#ifdef DEBUG_OUTPUT
-			std::cout << "H_Reverb - ";
-#endif
-			rvb.FB_SRC_A = val;
-
-			// OK, here's the fake REVERB stuff...
-			// depending on effect we do more or less delay and repeats... bah
-			// still... better than nothing :)
-
-			SetREVERB(val);
-			break;
-
-
-		case H_Reverb+2   : rvb.FB_SRC_B=(short)val;       break;
-		case H_Reverb+4   : rvb.IIR_ALPHA=(short)val;      break;
-		case H_Reverb+6   : rvb.ACC_COEF_A=(short)val;     break;
-		case H_Reverb+8   : rvb.ACC_COEF_B=(short)val;     break;
-		case H_Reverb+10  : rvb.ACC_COEF_C=(short)val;     break;
-		case H_Reverb+12  : rvb.ACC_COEF_D=(short)val;     break;
-		case H_Reverb+14  : rvb.IIR_COEF=(short)val;       break;
-		case H_Reverb+16  : rvb.FB_ALPHA=(short)val;       break;
-		case H_Reverb+18  : rvb.FB_X=(short)val;           break;
-		case H_Reverb+20  : rvb.IIR_DEST_A0=(short)val;    break;
-		case H_Reverb+22  : rvb.IIR_DEST_A1=(short)val;    break;
-		case H_Reverb+24  : rvb.ACC_SRC_A0=(short)val;     break;
-		case H_Reverb+26  : rvb.ACC_SRC_A1=(short)val;     break;
-		case H_Reverb+28  : rvb.ACC_SRC_B0=(short)val;     break;
-		case H_Reverb+30  : rvb.ACC_SRC_B1=(short)val;     break;
-		case H_Reverb+32  : rvb.IIR_SRC_A0=(short)val;     break;
-		case H_Reverb+34  : rvb.IIR_SRC_A1=(short)val;     break;
-		case H_Reverb+36  : rvb.IIR_DEST_B0=(short)val;    break;
-		case H_Reverb+38  : rvb.IIR_DEST_B1=(short)val;    break;
-		case H_Reverb+40  : rvb.ACC_SRC_C0=(short)val;     break;
-		case H_Reverb+42  : rvb.ACC_SRC_C1=(short)val;     break;
-		case H_Reverb+44  : rvb.ACC_SRC_D0=(short)val;     break;
-		case H_Reverb+46  : rvb.ACC_SRC_D1=(short)val;     break;
-		case H_Reverb+48  : rvb.IIR_SRC_B1=(short)val;     break;
-		case H_Reverb+50  : rvb.IIR_SRC_B0=(short)val;     break;
-		case H_Reverb+52  : rvb.MIX_DEST_A0=(short)val;    break;
-		case H_Reverb+54  : rvb.MIX_DEST_A1=(short)val;    break;
-		case H_Reverb+56  : rvb.MIX_DEST_B0=(short)val;    break;
-		case H_Reverb+58  : rvb.MIX_DEST_B1=(short)val;    break;
-		case H_Reverb+60  : rvb.IN_COEF_L=(short)val;      break;
-		case H_Reverb+62  : rvb.IN_COEF_R=(short)val;      break;
-	}
-
-	iWatchDog = 0;
-
-#ifdef DEBUG_OUTPUT
-	std::cout << "0x" << hex << setw(4) << val << std::endl;
-#endif
-}
-
-
-
-unsigned short SPUreadRegister(unsigned long reg)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << setfill('0');
-	std::cout << "*** SPUreadRegister(0x" << hex << setw(8) << reg << "), returned ";
-#endif
-
-	const unsigned long r = reg & 0xfff;
-
-	iWatchDog = 0;
-
-	if(r >= 0x0c00 && r < 0x0d80)
-	{
-		switch(r & 0x0f)
-		{
-			// get adsr vol
-			case 12:
-				{
-					const int ch = (r >> 4) - 0xc0;
-
-					// we are started, but not processed? return 1
-					if(s_chan[ch].bNew)
-					{
-#ifdef DEBUG_OUTPUT
-						std::cout << "0x" << hex << setw(4) << 1 << std::endl;
-#endif
-						return 1;
-					}
-
-					// same here... we haven't decoded one sample
-					// yet, so no envelope yet. return 1 as well
-					if(s_chan[ch].ADSRX.lVolume &&
-						!s_chan[ch].ADSRX.EnvelopeVol)
-					{
-#ifdef DEBUG_OUTPUT
-						std::cout << "0x" << hex << setw(4) << 1 << std::endl;
-#endif
-						return 1;
-					}
-
-#ifdef DEBUG_OUTPUT
-					std::cout << "0x" << hex << setw(4)
-						<< (unsigned short)(s_chan[ch].ADSRX.EnvelopeVol >> 16)
-						<< std::endl;
-#endif
-					return (unsigned short)(s_chan[ch].ADSRX.EnvelopeVol >> 16);
-				}
-
-			// get loop address
-			case 14:
-				{
-					const int ch = (r >> 4) - 0xc0;
-					if(s_chan[ch].pLoop == NULL)
-					{
-#ifdef DEBUG_OUTPUT
-						std::cout << "0x" << hex << setw(4) << 0 << std::endl;
-#endif
-						return 0;
-					}
-
-#ifdef DEBUG_OUTPUT
-					std::cout << "0x" << hex << setw(4)
-						<< (unsigned short)((s_chan[ch].pLoop - spuMemC) >> 3)
-						<< std::endl;
-#endif
-					return (unsigned short)((s_chan[ch].pLoop - spuMemC) >> 3);
-				}
-		}
-	}
-
-	switch(r)
-	{
-		case H_SPUctrl:
-#ifdef DEBUG_OUTPUT
-			std::cout << "0x" << hex << setw(4) << spuCtrl << std::endl;
-#endif
-			return spuCtrl;
-
-		case H_SPUstat:
-#ifdef DEBUG_OUTPUT
-			std::cout << "0x" << hex << setw(4) << spuStat << std::endl;
-#endif
-			return spuStat;
-
-		case H_SPUaddr:
-#ifdef DEBUG_OUTPUT
-			std::cout << "0x" << hex
-				<< setw(4) << (unsigned short)(spuAddr >> 3) << std::endl;
-#endif
-			return (unsigned short)(spuAddr >> 3);
-
-		case H_SPUdata:
-			{
-				unsigned short s = spuMem[spuAddr >> 1];
-				spuAddr += 2;
-				if(spuAddr > 0x7ffff)
-					spuAddr = 0;
-
-#ifdef DEBUG_OUTPUT
-				std::cout << "0x" << hex << setw(4) << s << std::endl;
-#endif
-				return s;
-			}
-
-		case H_SPUirqAddr:
-#ifdef DEBUG_OUTPUT
-			std::cout << "0x" << hex << setw(4) << spuIrq << std::endl;
-#endif
-			return spuIrq;
-	}
-
-#ifdef DEBUG_OUTPUT
-	std::cout << "0x" << hex << setw(4) << regArea[(r - 0xc00) >> 1] << std::endl;
-#endif
-	return regArea[(r - 0xc00) >> 1];
-}
-
-
-void SoundOn(int start, int end, unsigned short val)
-{
-	int ch;
-
-	// loop channels
-	for(ch = start; ch < end; ch++, val >>= 1)
-	{
-		if((val & 1) && s_chan[ch].pStart)
-		// mmm... start has to be set before key on !?!
-
-		{
-			s_chan[ch].bIgnoreLoop = 0;
-			s_chan[ch].bNew = 1;
-
-			// bitfield for faster testing
-			dwNewChannel |= (1 << ch);
-		}
-	}
-}
-
-
-void SoundOff(int start, int end, unsigned short val)
-{
-	int ch;
-
-	// loop channels
-	for(ch = start; ch < end; ch++, val >>= 1)
-	{
-		if(val & 1) // && s_chan[i].bOn)  mmm...
-			s_chan[ch].bStop = 1;
-	}
-}
-
-
-void FModOn(int start, int end, unsigned short val)
-{
-	int ch;
-
-	// loop channels
-	for(ch = start; ch < end; ch++, val >>= 1)
-	{
-		// fmod on/off
-		if(val & 1)
-		{
-			if(ch > 0)
-			{
-				// sound channel
-				s_chan[ch].bFMod = 1;
-
-				// freq channel
-				s_chan[ch - 1].bFMod = 2;
-			}
-		}
-		else
-			s_chan[ch].bFMod = 0;
-	}
-}
-
-
-void NoiseOn(int start, int end, unsigned short val)
-{
-	int ch;
-
-	// loop channels
-	for(ch = start; ch < end; ch++, val >>= 1)
-	{
-		// noise on/off
-		if(val & 1)
-		{
-			s_chan[ch].bNoise = 1;
-		}
-		else
-		{
-			s_chan[ch].bNoise = 0;
-		}
-	}
-}
-
-
-// please note: sweep and phase invert are wrong... but I've never seen
-// them used
-void SetVolumeL(unsigned char ch, short vol)
-{
-	s_chan[ch].iLeftVolRaw = vol;
-
-	// sweep
-	if(vol & 0x8000)
-	{
-		short sInc = 1;
-		if(vol & 0x2000)
-			sInc = -1;
-
-		// -> mmm... phase inverted? have to investigate this
-		if(vol & 0x1000)
-			vol ^= 0xffff;
-
-		// -> sweep: 0..127 -> 0..64
-		vol = ((vol & 0x7f) + 1) / 2;
-
-		// -> HACK: we don't sweep right now, so we
-		// just raise/lower the volume by the half!
-		vol += vol / (2 * sInc);
-		vol *= 128;
-	}
-
-	// no sweep
-	else
-	{
-		// -> mmm... phase inverted? have to investigate this
-		if(vol & 0x4000)
-			vol = 0x3fff - (vol & 0x3fff);
-	}
-
-	vol &= 0x3fff;
-
-	// store volume
-	s_chan[ch].iLeftVolume = vol;
-}
-
-void SetVolumeR(unsigned char ch, short vol)
-{
-	s_chan[ch].iRightVolRaw = vol;
-
-	// comments... see above :)
-	if(vol & 0x8000)
-	{
-		short sInc = 1;
-		if(vol & 0x2000)
-			sInc = -1;
-		if(vol & 0x1000)
-			vol ^= 0xffff;
-		vol = ((vol & 0x7f) + 1) / 2;
-		vol += vol / (2 * sInc);
-		vol *= 128;
-	}
-	else
-	{
-		if(vol & 0x4000)
-			vol = 0x3fff - (vol & 0x3fff);
-	}
-
-	vol &= 0x3fff;
-	s_chan[ch].iRightVolume = vol;
-}
-
-
-void SetPitch(int ch, unsigned short val)
-{
-	int NP;
-	if(val > 0x3fff)
-		NP = 0x3fff;
-	else
-		NP = val;
-
-	s_chan[ch].iRawPitch = NP;
-
-	NP = (44100L * NP) / 4096L;
-	if(NP < 1)
-		NP = 1;
-
-	s_chan[ch].iActFreq = NP;
-}
-
-
-void ReverbOn(int start, int end, unsigned short val)
-{
-	int ch;
-
-	// loop channels
-	for(ch = start; ch < end; ch++, val >>= 1)
-	{
-		// reverb on/off
-		if(val & 1)
-			s_chan[ch].bReverb = 1;
-		else
-			s_chan[ch].bReverb = 0;
-	}
-}
-void SetREVERB(unsigned short val)
-{
-	switch(val)
-	{
-		// off
-		case 0x0000:
-			iReverbOff = -1;
-			break;
-
-		// ok room
-		case 0x007D:
-			iReverbOff = 32;
-			iReverbNum = 2;
-			iReverbRepeat = 128;
-			break;
-
-		// studio small
-		case 0x0033:
-			iReverbOff = 32;
-			iReverbNum = 2;
-			iReverbRepeat = 64;
-			break;
-
-		// ok studio medium
-		case 0x00B1:
-			iReverbOff = 48;
-			iReverbNum = 2;
-			iReverbRepeat = 96;
-			break;
-
-		// ok studio large ok
-		case 0x00E3:
-			iReverbOff = 64;
-			iReverbNum = 2;
-			iReverbRepeat = 128;
-			break;
-
-		// ok hall
-		case 0x01A5:
-			iReverbOff = 128;
-			iReverbNum = 4;
-			iReverbRepeat = 32;
-			break;
-
-		// space echo
-		case 0x033D:
-			iReverbOff = 256;
-			iReverbNum = 4;
-			iReverbRepeat = 64;
-			break;
-
-		// echo/delay
-		case 0x0001:
-			iReverbOff = 184;
-			iReverbNum = 3;
-			iReverbRepeat = 128;
-			break;
-
-		// half echo
-		case 0x0017:
-			iReverbOff = 128;
-			iReverbNum = 2;
-			iReverbRepeat = 128;
-			break;
-
-		default:
-			iReverbOff = 32;
-			iReverbNum = 1;
-			iReverbRepeat = 0;
-			break;
-	}
-}
-
-
-void StartREVERB(int ch)
-{
-	// reverb possible?
-	if(s_chan[ch].bReverb && (spuCtrl & 0x80))
-	{
-		if(iUseReverb == 2)
-			s_chan[ch].bRVBActive = 1;
-		else
-			// fake reverb used?
-			if(iUseReverb == 1 && iReverbOff > 0)
-			{
-				// activate it
-				s_chan[ch].bRVBActive = 1;
-				s_chan[ch].iRVBOffset = iReverbOff * 45;
-				s_chan[ch].iRVBRepeat = iReverbRepeat * 45;
-				s_chan[ch].iRVBNum = iReverbNum;
-			}
-	}
-	else
-		// no reverb
-		s_chan[ch].bRVBActive = 0;
-}
-
-
-void InitREVERB()
-{
-	if(iUseReverb == 2)
-		memset(sRVBStart, 0, NSSIZE * 2 * 4);
-}
-
-
-void StoreREVERB(int ch, int ns)
-{
-	if(iUseReverb == 0)
-		return;
-
-	// Neil's reverb
-	if(iUseReverb == 2)
-	{
-		const int iRxl =
-			(s_chan[ch].sval * s_chan[ch].iLeftVolume) / 0x4000;
-		const int iRxr =
-			(s_chan[ch].sval * s_chan[ch].iRightVolume) / 0x4000;
-
-		ns <<= 1;
-
-		// -> we mix all active reverb channels into an extra buffer
-		*(sRVBStart + ns) += iRxl;
-		*(sRVBStart + ns + 1) += iRxr;
-	}
-
-	// Pete's easy fake reverb
-	else
-	{
-		int *pN;
-		int iRn, iRr = 0;
-
-		// we use the half channel volume (/0x8000) for the
-		// first reverb effects, quarter for next and so on
-		int iRxl =
-			(s_chan[ch].sval * s_chan[ch].iLeftVolume) / 0x8000;
-		int iRxr =
-			(s_chan[ch].sval * s_chan[ch].iRightVolume) / 0x8000;
-
-		for(iRn = 1; iRn <= s_chan[ch].iRVBNum;
-				iRn++, iRr += s_chan[ch].iRVBRepeat,iRxl /= 2, iRxr /= 2)
-		{
-			pN = sRVBPlay + ((s_chan[ch].iRVBOffset + iRr + ns) << 1);
-			if(pN >= sRVBEnd)
-				pN = sRVBStart + (pN - sRVBEnd);
-
-			(*pN) += iRxl;
-			pN++;
-			(*pN) += iRxr;
-		}
-	}
-}
-
-
-// get_buffer content helper: takes care about wraps
-int g_buffer(int iOff)
-{
-	short *p = (short *)spuMem;
-	iOff = (iOff * 4) + rvb.CurrAddr;
-	while(iOff > 0x3FFFF)
-		iOff = rvb.StartAddr + (iOff - 0x40000);
-	while(iOff < rvb.StartAddr)
-		iOff = 0x3ffff - (rvb.StartAddr - iOff);
-
-	return (int)*(p + iOff);
-}
-
-
-// set_buffer content helper: takes care about wraps and clipping
-void s_buffer(int iOff, int iVal)
-{
-	short *p = (short *)spuMem;
-	iOff = (iOff * 4) + rvb.CurrAddr;
-	while(iOff > 0x3FFFF)
-		iOff = rvb.StartAddr + (iOff - 0x40000);
-	while(iOff < rvb.StartAddr)
-		iOff = 0x3ffff - (rvb.StartAddr - iOff);
-	if(iVal < -32768L)
-		iVal = -32768L;
-	if(iVal > 32767L)
-		iVal = 32767L;
-
-	*(p + iOff) = (short)iVal;
-}
-
-
-// set_buffer (+1 sample) content helper: takes care about wraps and clipping
-void s_buffer1(int iOff, int iVal)
-{
-	short *p = (short *)spuMem;
-	iOff = (iOff * 4) + rvb.CurrAddr + 1;
-	while(iOff > 0x3FFFF)
-		iOff = rvb.StartAddr + (iOff - 0x40000);
-	while(iOff < rvb.StartAddr)
-		iOff = 0x3ffff - (rvb.StartAddr - iOff);
-	if(iVal < -32768L)
-		iVal = -32768L;
-	if(iVal > 32767L)
-		iVal = 32767L;
-
-	*(p + iOff) = (short)iVal;
-}
-
-
-int MixREVERBLeft(int ns)
-{
-	if(iUseReverb == 0)
-		return 0;
-
-	if(iUseReverb == 2)
-	{
-		// this func will be called with 44.1 khz
-		static int iCnt = 0;
-
-		// reverb is off
-		if(!rvb.StartAddr)
-		{
-			rvb.iLastRVBLeft = rvb.iLastRVBRight =
-				rvb.iRVBLeft = rvb.iRVBRight = 0;
-
-			return 0;
-		}
-
-		iCnt++;
-
-		// we work on every second left value: downsample to 22 khz
-		if(iCnt & 1)
-		{
-			// -> reverb on? oki
-			if(spuCtrl & 0x80)
-			{
-				int ACC0, ACC1, FB_A0, FB_A1, FB_B0, FB_B1;
-
-				const int INPUT_SAMPLE_L = *(sRVBStart + (ns << 1));
-				const int INPUT_SAMPLE_R = *(sRVBStart + (ns << 1) + 1);
-
-				const int IIR_INPUT_A0 =
-					(g_buffer(rvb.IIR_SRC_A0) * rvb.IIR_COEF) / 32768L +
-					(INPUT_SAMPLE_L * rvb.IN_COEF_L) / 32768L;
-				const int IIR_INPUT_A1 =
-					(g_buffer(rvb.IIR_SRC_A1) * rvb.IIR_COEF) / 32768L +
-					(INPUT_SAMPLE_R * rvb.IN_COEF_R) / 32768L;
-				const int IIR_INPUT_B0 =
-					(g_buffer(rvb.IIR_SRC_B0) * rvb.IIR_COEF) / 32768L +
-					(INPUT_SAMPLE_L * rvb.IN_COEF_L) / 32768L;
-				const int IIR_INPUT_B1 =
-					(g_buffer(rvb.IIR_SRC_B1) * rvb.IIR_COEF) / 32768L +
-					(INPUT_SAMPLE_R * rvb.IN_COEF_R) / 32768L;
-
-				const int IIR_A0 = (IIR_INPUT_A0 * rvb.IIR_ALPHA) / 32768L +
-					(g_buffer(rvb.IIR_DEST_A0) *
-					 (32768L - rvb.IIR_ALPHA)) / 32768L;
-				const int IIR_A1 = (IIR_INPUT_A1 * rvb.IIR_ALPHA) / 32768L +
-					(g_buffer(rvb.IIR_DEST_A1) *
-					 (32768L - rvb.IIR_ALPHA)) / 32768L;
-				const int IIR_B0 = (IIR_INPUT_B0 * rvb.IIR_ALPHA) / 32768L +
-					(g_buffer(rvb.IIR_DEST_B0) *
-					 (32768L - rvb.IIR_ALPHA)) / 32768L;
-				const int IIR_B1 = (IIR_INPUT_B1 * rvb.IIR_ALPHA) / 32768L +
-					(g_buffer(rvb.IIR_DEST_B1) *
-					 (32768L - rvb.IIR_ALPHA)) / 32768L;
-
-				s_buffer1(rvb.IIR_DEST_A0, IIR_A0);
-				s_buffer1(rvb.IIR_DEST_A1, IIR_A1);
-				s_buffer1(rvb.IIR_DEST_B0, IIR_B0);
-				s_buffer1(rvb.IIR_DEST_B1, IIR_B1);
-
-				ACC0 = (g_buffer(rvb.ACC_SRC_A0) * rvb.ACC_COEF_A) / 32768L +
-					(g_buffer(rvb.ACC_SRC_B0) * rvb.ACC_COEF_B) / 32768L +
-					(g_buffer(rvb.ACC_SRC_C0) * rvb.ACC_COEF_C) / 32768L +
-					(g_buffer(rvb.ACC_SRC_D0) * rvb.ACC_COEF_D) / 32768L;
-				ACC1 = (g_buffer(rvb.ACC_SRC_A1) * rvb.ACC_COEF_A) / 32768L +
-					(g_buffer(rvb.ACC_SRC_B1) * rvb.ACC_COEF_B) / 32768L +
-					(g_buffer(rvb.ACC_SRC_C1) * rvb.ACC_COEF_C) / 32768L +
-					(g_buffer(rvb.ACC_SRC_D1) * rvb.ACC_COEF_D) / 32768L;
-
-				FB_A0 = g_buffer(rvb.MIX_DEST_A0 - rvb.FB_SRC_A);
-				FB_A1 = g_buffer(rvb.MIX_DEST_A1 - rvb.FB_SRC_A);
-				FB_B0 = g_buffer(rvb.MIX_DEST_B0 - rvb.FB_SRC_B);
-				FB_B1 = g_buffer(rvb.MIX_DEST_B1 - rvb.FB_SRC_B);
-
-				s_buffer(rvb.MIX_DEST_A0,
-					ACC0 - (FB_A0 * rvb.FB_ALPHA) / 32768L);
-				s_buffer(rvb.MIX_DEST_A1,
-					ACC1 - (FB_A1 * rvb.FB_ALPHA) / 32768L);
-
-				s_buffer(rvb.MIX_DEST_B0, (rvb.FB_ALPHA * ACC0) / 32768L -
-					(FB_A0 * (int)(rvb.FB_ALPHA ^ 0xFFFF8000)) / 32768L -
-					(FB_B0 * rvb.FB_X) / 32768L);
-				s_buffer(rvb.MIX_DEST_B1, (rvb.FB_ALPHA * ACC1) / 32768L -
-					(FB_A1 * (int)(rvb.FB_ALPHA ^ 0xFFFF8000)) / 32768L -
-					(FB_B1 * rvb.FB_X) / 32768L);
-
-				rvb.iLastRVBLeft  = rvb.iRVBLeft;
-				rvb.iLastRVBRight = rvb.iRVBRight;
-
-				rvb.iRVBLeft =
-					(g_buffer(rvb.MIX_DEST_A0) + g_buffer(rvb.MIX_DEST_B0)) / 3;
-				rvb.iRVBRight =
-					(g_buffer(rvb.MIX_DEST_A1) + g_buffer(rvb.MIX_DEST_B1)) / 3;
-
-				rvb.iRVBLeft = (rvb.iRVBLeft * rvb.VolLeft) / 0x4000;
-				rvb.iRVBRight = (rvb.iRVBRight * rvb.VolRight) / 0x4000;
-
-				rvb.CurrAddr++;
-				if(rvb.CurrAddr > 0x3ffff)
-					rvb.CurrAddr = rvb.StartAddr;
-
-				return rvb.iLastRVBLeft + (rvb.iRVBLeft-rvb.iLastRVBLeft) / 2;
-			}
-			// reverb off
-			else
-				rvb.iLastRVBLeft = rvb.iLastRVBRight =
-					rvb.iRVBLeft = rvb.iRVBRight = 0;
-
-			rvb.CurrAddr++;
-			if(rvb.CurrAddr > 0x3ffff)
-				rvb.CurrAddr = rvb.StartAddr;
-		}
-
-		return rvb.iLastRVBLeft;
-	}
-	// easy fake reverb
-	else
-	{
-		// -> simply take the reverb mix buf value
-		const int iRV = *sRVBPlay;
-		// -> init it after
-		*sRVBPlay++ = 0;
-		// -> and take care about wrap arounds
-		if(sRVBPlay >= sRVBEnd)
-			sRVBPlay = sRVBStart;
-
-		// -> return reverb buf mix val
-		return iRV;
-	}
-}
-
-
-int MixREVERBRight()
-{
-	if(iUseReverb == 0)
-		return 0;
-
-	// Neill's reverb
-	if(iUseReverb == 2)
-	{
-		int i = rvb.iLastRVBRight + (rvb.iRVBRight - rvb.iLastRVBRight) / 2;
-		rvb.iLastRVBRight = rvb.iRVBRight;
-
-		// -> just return the last right reverb val
-		// (little bit scaled by the previous right val)
-		return i;
-	}
-	// easy fake reverb
-	else
-	{
-		// -> simply take the reverb mix buf value
-		const int iRV = *sRVBPlay;
-		// -> init it after
-		*sRVBPlay++ = 0;
-		// -> and take care about wrap arounds
-		if(sRVBPlay >= sRVBEnd)
-			sRVBPlay = sRVBStart;
-
-		// -> return reverb mix buf val
-		return iRV;
-	}
-}
-
-
-void MixXA()
-{
-	int ns;
-
-	for(ns = 0; ns < NSSIZE && XAPlay != XAFeed; ns++)
-	{
-		XALastVal = *XAPlay++;
-		if(XAPlay == XAEnd)
-			XAPlay = XAStart;
-		SSumL[ns] += (((short)(XALastVal & 0xffff)) * iLeftXAVol) / 32767;
-		SSumR[ns] += (((short)((XALastVal >> 16) & 0xffff)) *
-			iRightXAVol) / 32767;
-	}
-
-	if(XAPlay == XAFeed && XARepeat)
-	{
-		XARepeat--;
-		for(;ns < NSSIZE; ns++)
-		{
-			SSumL[ns] += (((short)(XALastVal & 0xffff)) * iLeftXAVol) / 32767;
-			SSumR[ns] += (((short)((XALastVal >> 16) & 0xffff)) *
-				iRightXAVol) / 32767;
-		}
-	}
-}
-
-
-void FeedXA(xa_decode_t *xap)
-{
-	int sinc, spos, i, iSize, iPlace, vl, vr;
-
-	if(!bSPUIsOpen)
-		return;
-
-	// store info for save states
-	xapGlobal = xap;
-	// set up repeat
-	XARepeat  = 100;
-
-	// get size
-	iSize = ((44100 * xap->nsamples) / xap->freq);
-
-	// if none
-	if(!iSize)
-		return;
-
-	// how much space in my buf?
-	if(XAFeed < XAPlay)
-		iPlace = XAPlay - XAFeed;
-	else
-		iPlace = (XAEnd - XAFeed) + (XAPlay - XAStart);
-
-	// no place at all
-	if(iPlace == 0)
-		return;
-
-	// pitch change option
-	if(iXAPitch)
-	{
-		static unsigned long dwLT = 0;
-		static unsigned long dwFPS = 0;
-		static int   iFPSCnt = 0;
-		static int   iLastSize = 0;
-		static unsigned long dwL1 = 0;
-		unsigned long dw, dw1, dw2;
-
-//G		dw = timeGetTime_spu();
-		dw = GGetTime();
-
-		iPlace = iSize;
-
-		dwFPS += dw - dwLT;
-		iFPSCnt++;
-
-		dwLT = dw;
-
-		if(iFPSCnt >= 10)
-		{
-			if(!dwFPS)
-				dwFPS = 1;
-			dw1 = 1000000 / dwFPS;
-			if(dw1 >= (dwL1 - 100) && dw1 <= (dwL1 + 100))
-				dw1 = dwL1;
-			else
-				dwL1 = dw1;
-			dw2 = (xap->freq * 100 / xap->nsamples);
-			if((!dw1) || ((dw2 + 100) >= dw1))
-				iLastSize = 0;
-			else
-			{
-				iLastSize = iSize * dw2 / dw1;
-				if(iLastSize > iPlace)
-					iLastSize = iPlace;
-				iSize = iLastSize;
-			}
-			iFPSCnt = 0;
-			dwFPS = 0;
-		}
-		else
-		{
-			if(iLastSize)
-				iSize = iLastSize;
-		}
-	}
-
-	spos = 0x10000L;
-	// calc freq by num / size
-	sinc = (xap->nsamples << 16) / iSize;
-
-	if(xap->stereo)
-	{
-		u32 * pS = (u32 *)xap->pcm;
-		u32 l = 0;
-
-		if(iXAPitch)
-		{
-			int32_t l1, l2;
-			short s;
-			for(i = 0; i < iSize; i++)
-			{
-				if(iUseInterpolation == 2)
-				{
-					while(spos >= 0x10000L)
-					{
-						l = *pS++;
-						gauss_window[gauss_ptr] = (short)LOWORD(l);
-						gauss_window[4 + gauss_ptr] = (short)HIWORD(l);
-						gauss_ptr = (gauss_ptr + 1) & 3;
-						spos -= 0x10000L;
-					}
-					vl = (spos >> 6) & ~3;
-					vr = (gauss[vl]*gvall0) & ~2047;
-					vr += (gauss[vl + 1] * gvall(1)) & ~2047;
-					vr += (gauss[vl + 2] * gvall(2)) & ~2047;
-					vr += (gauss[vl + 3] * gvall(3)) & ~2047;
-					l= (vr >> 11) & 0xffff;
-					vr = (gauss[vl] * gvalr0) & ~2047;
-					vr += (gauss[vl + 1] * gvalr(1)) & ~2047;
-					vr += (gauss[vl + 2] * gvalr(2)) & ~2047;
-					vr += (gauss[vl + 3] * gvalr(3)) & ~2047;
-					l |= vr << 5;
-				}
-				else
-				{
-					while(spos >= 0x10000L)
-					{
-						l = *pS++;
-						spos -= 0x10000L;
-					}
-				}
-
-				s = (short)LOWORD(l);
-				l1 = s;
-				l1 = (l1 * iPlace) / iSize;
-				if(l1 < -32767)
-					l1 = -32767;
-				if(l1 > 32767)
-					l1 = 32767;
-				s = (short)HIWORD(l);
-				l2 = s;
-				l2 = (l2 * iPlace) / iSize;
-				if(l2 < -32767)
-					l2 = -32767;
-				if(l2 > 32767)
-					l2 = 32767;
-				l = (l1 & 0xffff)|(l2 << 16);
-
-				*XAFeed++ = l;
-
-				if(XAFeed == XAEnd)
-					XAFeed = XAStart;
-				if(XAFeed == XAPlay)
-				{
-					if(XAPlay != XAStart)
-						XAFeed = XAPlay - 1;
-					break;
-				}
-
-				spos += sinc;
-			}
-		}
-		else
-		{
-			for(i = 0; i < iSize; i++)
-			{
-				if(iUseInterpolation == 2)
-				{
-					while(spos >= 0x10000L)
-					{
-						l = *pS++;
-						gauss_window[gauss_ptr] = (short)LOWORD(l);
-						gauss_window[4 + gauss_ptr] = (short)HIWORD(l);
-						gauss_ptr = (gauss_ptr + 1) & 3;
-						spos -= 0x10000L;
-					}
-					vl = (spos >> 6) & ~3;
-					vr = (gauss[vl] * gvall0) & ~2047;
-					vr += (gauss[vl + 1] * gvall(1)) & ~2047;
-					vr += (gauss[vl + 2] * gvall(2)) & ~2047;
-					vr += (gauss[vl + 3] * gvall(3)) & ~2047;
-					l = (vr >> 11) & 0xffff;
-					vr = (gauss[vl] * gvalr0) & ~2047;
-					vr += (gauss[vl + 1] * gvalr(1)) & ~2047;
-					vr += (gauss[vl + 2] * gvalr(2)) & ~2047;
-					vr += (gauss[vl + 3] * gvalr(3)) & ~2047;
-					l |= vr << 5;
-				}
-				else
-				{
-					while(spos>=0x10000L)
-					{
-						l = *pS++;
-						spos -= 0x10000L;
-					}
-				}
-
-				*XAFeed++ = l;
-
-				if(XAFeed == XAEnd)
-					XAFeed = XAStart;
-				if(XAFeed == XAPlay)
-				{
-					if(XAPlay != XAStart)
-						XAFeed = XAPlay - 1;
-					break;
-				}
-
-				spos += sinc;
-			}
-		}
-	}
-	else
-	{
-		unsigned short * pS = (unsigned short *)xap->pcm;
-		u32 l;
-		short s = 0;
-
-		if(iXAPitch)
-		{
-			int32_t l1;
-			for(i = 0; i < iSize; i++)
-			{
-				if(iUseInterpolation == 2)
-				{
-					while(spos >= 0x10000L)
-					{
-						gauss_window[gauss_ptr] = (short)*pS++;
-						gauss_ptr = (gauss_ptr + 1) & 3;
-						spos -= 0x10000L;
-					}
-					vl = (spos >> 6) & ~3;
-					vr = (gauss[vl] * gvall0) & ~2047;
-					vr += (gauss[vl + 1] * gvall(1)) & ~2047;
-					vr += (gauss[vl + 2] * gvall(2)) & ~2047;
-					vr += (gauss[vl + 3] * gvall(3)) & ~2047;
-					l1 = s = vr >> 11;
-					l1 &= 0xffff;
-				}
-				else
-				{
-					while(spos >= 0x10000L)
-					{
-						s = *pS++;
-						spos -= 0x10000L;
-					}
-					l1 = s;
-				}
-
-				l1 = (l1 * iPlace) / iSize;
-				if(l1 < -32767)
-					l1 = -32767;
-				if(l1 > 32767)
-					l1 = 32767;
-				l = (l1 & 0xffff) | (l1 << 16);
-				*XAFeed++ = l;
-
-				if(XAFeed == XAEnd)
-					XAFeed = XAStart;
-				if(XAFeed == XAPlay)
-				{
-					if(XAPlay != XAStart)
-						XAFeed = XAPlay - 1;
-					break;
-				}
-
-				spos += sinc;
-			}
-		}
-		else
-		{
-			for(i = 0; i < iSize; i++)
-			{
-				if(iUseInterpolation == 2)
-				{
-					while(spos >= 0x10000L)
-					{
-						gauss_window[gauss_ptr] = (short)*pS++;
-						gauss_ptr = (gauss_ptr + 1) & 3;
-						spos -= 0x10000L;
-					}
-					vl = (spos >> 6) & ~3;
-					vr = (gauss[vl] * gvall0) & ~2047;
-					vr += (gauss[vl + 1] * gvall(1)) & ~2047;
-					vr += (gauss[vl + 2] * gvall(2)) & ~2047;
-					vr += (gauss[vl + 3] * gvall(3)) & ~2047;
-					l= s = vr >> 11;
-					l &= 0xffff;
-				}
-				else
-				{
-					while(spos >= 0x10000L)
-					{
-						s = *pS++;
-						spos -= 0x10000L;
-					}
-					l = s;
-				}
-
-				*XAFeed++ = (l | (l << 16));
-
-				if(XAFeed == XAEnd)
-					XAFeed = XAStart;
-				if(XAFeed == XAPlay)
-				{
-					if(XAPlay != XAStart)
-						XAFeed = XAPlay - 1;
-					break;
-				}
-
-				spos += sinc;
-			}
-		}
-	}
-}
-
-void InterpolateUp(int ch)
-{
-	if(s_chan[ch].SB[32]==1)                              // flag == 1? calc step and set flag... and don't change the value in this pass
-	{
-		const int id1=s_chan[ch].SB[30]-s_chan[ch].SB[29];  // curr delta to next val
-		const int id2=s_chan[ch].SB[31]-s_chan[ch].SB[30];  // and next delta to next-next val :)
-
-		s_chan[ch].SB[32]=0;
-
-		if(id1>0)                                           // curr delta positive
-		{
-			if(id2<id1)
-			{s_chan[ch].SB[28]=id1;s_chan[ch].SB[32]=2;}
-			else
-				if(id2<(id1<<1))
-					s_chan[ch].SB[28]=(id1*s_chan[ch].sinc)/0x10000L;
-				else
-					s_chan[ch].SB[28]=(id1*s_chan[ch].sinc)/0x20000L;
-		}
-		else                                                // curr delta negative
-		{
-			if(id2>id1)
-			{s_chan[ch].SB[28]=id1;s_chan[ch].SB[32]=2;}
-			else
-				if(id2>(id1<<1))
-					s_chan[ch].SB[28]=(id1*s_chan[ch].sinc)/0x10000L;
-				else
-					s_chan[ch].SB[28]=(id1*s_chan[ch].sinc)/0x20000L;
-		}
-	}
-	else
-		if(s_chan[ch].SB[32]==2)                              // flag 1: calc step and set flag... and don't change the value in this pass
-		{
-			s_chan[ch].SB[32]=0;
-
-			s_chan[ch].SB[28]=(s_chan[ch].SB[28]*s_chan[ch].sinc)/0x20000L;
-			if(s_chan[ch].sinc<=0x8000)
-				s_chan[ch].SB[29]=s_chan[ch].SB[30]-(s_chan[ch].SB[28]*((0x10000/s_chan[ch].sinc)-1));
-			else s_chan[ch].SB[29]+=s_chan[ch].SB[28];
-		}
-		else                                                  // no flags? add bigger val (if possible), calc smaller step, set flag1
-			s_chan[ch].SB[29]+=s_chan[ch].SB[28];
-}
-
-//
-// even easier interpolation on downsampling, also no special filter, again just "Pete's common sense" tm
-//
-
-void InterpolateDown(int ch)
-{
-	if(s_chan[ch].sinc>=0x20000L)                                 // we would skip at least one val?
-	{
-		s_chan[ch].SB[29]+=(s_chan[ch].SB[30]-s_chan[ch].SB[29])/2; // add easy weight
-		if(s_chan[ch].sinc>=0x30000L)                               // we would skip even more vals?
-			s_chan[ch].SB[29]+=(s_chan[ch].SB[31]-s_chan[ch].SB[30])/2;// add additional next weight
-	}
-}
-
-////////////////////////////////////////////////////////////////////////
-// helpers for gauss interpolation
-
-#define gval0 (((short*)(&s_chan[ch].SB[29]))[gpos])
-#define gval(x) (((short*)(&s_chan[ch].SB[29]))[(gpos+x)&3])
-
-//#include "gauss_i.h"
-
-////////////////////////////////////////////////////////////////////////
-
-//#include "xa.c"
-
-////////////////////////////////////////////////////////////////////////
-// START SOUND... called by main thread to setup a new sound on a channel
-////////////////////////////////////////////////////////////////////////
-
-void StartSound(int ch)
-{
-	StartADSR(ch);
-	StartREVERB(ch);
-
-	s_chan[ch].pCurr=s_chan[ch].pStart;                   // set sample start
-
-	s_chan[ch].s_1=0;                                     // init mixing vars
-	s_chan[ch].s_2=0;
-	s_chan[ch].iSBPos=28;
-
-	s_chan[ch].bNew=0;                                    // init channel flags
-	s_chan[ch].bStop=0;
-	s_chan[ch].bOn=1;
-
-	s_chan[ch].SB[29]=0;                                  // init our interpolation helpers
-	s_chan[ch].SB[30]=0;
-
-	if(iUseInterpolation>=2)                              // gauss interpolation?
-	{s_chan[ch].spos=0x30000L;s_chan[ch].SB[28]=0;}  // -> start with more decoding
-	else {s_chan[ch].spos=0x10000L;s_chan[ch].SB[31]=0;}  // -> no/simple interpolation starts with one 44100 decoding
-
-	dwNewChannel&=~(1<<ch);                               // clear new channel bit
-}
-
-////////////////////////////////////////////////////////////////////////
-// MAIN SPU FUNCTION
-// here is the main job handler... thread, timer or direct func call
-// basically the whole sound processing is done in this fat func!
-////////////////////////////////////////////////////////////////////////
-
-// 5 ms waiting phase, if buffer is full and no new sound has to get started
-// .. can be made smaller (smallest val: 1 ms), but bigger waits give
-// better performance
-
-#define PAUSE_W 5
-#define PAUSE_L 5000
-
-////////////////////////////////////////////////////////////////////////
-
-static void *MAINThread(void *arg)
-{
-//	std::cout << "!!!!!!!!!!!!!!!!!!!TEST!!!!!!!!!!!!!!!!!!" << std::endl;
-	int s_1, s_2;
-	int fa;
-	int ns;
-	int voldiv = iVolume;
-	unsigned char *start;
-	unsigned int nSample;
-	int ch, predict_nr, shift_factor, flags, d, s;
-	int gpos, bIRQReturn = 0;
-
-	// until we are shutting down
-	while(!bEndThread)
-	{
-		// ok, at the beginning we are looking if there is
-		// enuff free place in the dsound/oss buffer to
-		// fill in new data, or if there is a new channel to start.
-		// if not, we wait (thread) or return (timer/spuasync)
-		// until enuff free place is available/a new channel gets
-		// started
-
-		// new channel should start immedately?
-		// (at least one bit 0 ... MAXCHANNEL is set?)
-		if(dwNewChannel)
-		{
-			// set iSecure
-			// (if it is set 5 times - that means on 5 tries a new samples
-			// has been started - in a row, we will reset it, to give the
-			// sound update a chance)
-			iSecureStart++;
-			if(iSecureStart > 5)
-				iSecureStart = 0;
-		}
-		// 0: no new channel
-		else
-			iSecureStart = 0;
-
-		// no new start? no thread end? and still enough data in sound buffer?
-		while(!iSecureStart && !bEndThread &&
-			(SBE->GetBytesBuffered() > TESTSIZE))
-		{
-			// reset secure
-			iSecureStart = 0;
-
-			// linux no-thread mode? bye
-			if(iUseTimer)
-				return 0;
-
-			// else sleep for x ms (linux)
-
-#ifndef _MSC_VER
-			usleep(PAUSE_L);
-#else
-			Sleep(PAUSE_L);
-#endif
-
-//			SDL_Delay(PAUSE_L);
-			if(dwNewChannel)
-			// if a new channel kicks in (or, of course,
-			// sound buffer runs low), we will leave the loop
-				iSecureStart = 1;
-		}
-
-		// continue from irq handling in timer mode?
-		// will be -1 if no continue is pending
-		if(lastch >= 0)
-		{
-			// -> setup all kind of vars to continue
-			ch = lastch;
-			ns = lastns;
-			lastch = -1;
-
-			// -> directly jump to the continue point
-			goto GOON;
-		}
-
-
-
-		{
-			// loop em all... we will collect 1 ms
-			// of sound of each playing channel
-			for(ch = 0; ch < MAXCHAN; ch++)
-			{
-				// start new channel
-				if(s_chan[ch].bNew)
-					StartSound(ch);
-
-				// channel not playing? - next
-				if(!s_chan[ch].bOn)
-					continue;
-
-				// new psx frequency?
-				if(s_chan[ch].iActFreq != s_chan[ch].iUsedFreq)
-				{
-					// take int and calc steps
-					s_chan[ch].iUsedFreq = s_chan[ch].iActFreq;
-					s_chan[ch].sinc = s_chan[ch].iRawPitch << 4;
-					if(!s_chan[ch].sinc)
-						s_chan[ch].sinc = 1;
-
-					// freq change in simple interpolation mode [set flag]
-					if(iUseInterpolation == 1)
-						s_chan[ch].SB[32] = 1;
-				}
-
-				// loop until 1 ms of data is reached
-				ns = 0;
-				while(ns < NSSIZE)
-				{
-					while(s_chan[ch].spos >= 0x10000L)
-					{
-						// 28 reached
-						if(s_chan[ch].iSBPos == 28)
-						{
-							// set up the current pos
-							start = s_chan[ch].pCurr;
-
-							// special "stop" sign
-							if (start == (unsigned char *)-1)
-							{
-								// turn everything off
-								s_chan[ch].bOn = 0;
-								s_chan[ch].ADSRX.lVolume = 0;
-								s_chan[ch].ADSRX.EnvelopeVol = 0;
-
-								// and done for this channel
-								goto ENDX;
-							}
-
-							s_chan[ch].iSBPos = 0;
-
-							// spu irq handler here? mmm... do it later
-
-							s_1 = s_chan[ch].s_1;
-							s_2 = s_chan[ch].s_2;
-
-							predict_nr = (int)*start;
-							start++;
-							shift_factor = predict_nr & 0xf;
-							predict_nr >>= 4;
-							flags=(int)*start;
-							start++;
-
-							for (nSample = 0; nSample < 28; start++)
-							{
-								d = (int)*start;
-								s = ((d & 0xf) << 12);
-								if(s & 0x8000)
-									s |= 0xffff0000;
-
-								fa = (s >> shift_factor);
-								fa = fa + ((s_1 * f[predict_nr][0]) >> 6) +
-									((s_2 * f[predict_nr][1]) >> 6);
-								s_2 = s_1;
-								s_1 = fa;
-								s = ((d & 0xf0) << 8);
-
-								s_chan[ch].SB[nSample++] = fa;
-
-								if(s & 0x8000)
-									s |= 0xffff0000;
-								fa = (s >> shift_factor);
-								fa = fa + ((s_1 * f[predict_nr][0]) >> 6) +
-									((s_2 * f[predict_nr][1]) >> 6);
-								s_2 = s_1;
-								s_1 = fa;
-
-								s_chan[ch].SB[nSample++] = fa;
-							}
-
-							// irq check? mmm...
-
-							// some callbacks and irq active?
-							if(irqCallback && (spuCtrl & 0x40))
-							{
-								// irq address reached? &
-								// special: irq on looping addr,
-								// when stop/loop flag is set
-								if((pSpuIrq > start - 16 && pSpuIrq <= start)
-									||
-									((flags & 1) &&
-									(pSpuIrq >  s_chan[ch].pLoop - 16 &&
-									pSpuIrq <= s_chan[ch].pLoop)))
-								{
-									// debug flag
-									s_chan[ch].iIrqDone = 1;
-									// call main emu
-									irqCallback();
-
-									// option: wait after irq for main emu
-									if(iSPUIRQWait)
-									{
-										unsigned long dwWatchTime;
-
-										if(iUseTimer == 2)
-											bIRQReturn = 1;
-										else
-										{
-//											dwWatchTime = timeGetTime_spu() +
-//												2500;
-											dwWatchTime = GGetTime() +
-												2500;
-											iWatchDog = 1;
-											while(iWatchDog && !bEndThread &&
-												GGetTime() < dwWatchTime)
-#ifndef _MSC_VER
-			usleep(10);
-#else
-			Sleep(10);
-#endif
-
-//												SDL_Delay(1000L);
-										}
-									}
-								}
-							}
-
-							// flag handler
-
-							// loop address
-							if((flags & 4) && (!s_chan[ch].bIgnoreLoop))
-								s_chan[ch].pLoop = start - 16;
-
-							// stop loop
-							if(flags & 1)
-							{
-								// PETE: if we don't check exactly for 3,
-								// loop hang ups will happen (DQ4, for example)
-								if(flags != 3 || s_chan[ch].pLoop == NULL)
-								{
-									// and checking if pLoop is
-									// set avoids crashes, yeah
-									start = (unsigned char *)-1;
-								}
-								else
-								{
-									start = s_chan[ch].pLoop;
-								}
-							}
-
-							// store values for next cycle
-							s_chan[ch].pCurr = start;
-							s_chan[ch].s_1 = s_1;
-							s_chan[ch].s_2 = s_2;
-
-							// special return for
-							// "spu irq - wait for cpu action"
-							if(bIRQReturn)
-							{
-								bIRQReturn = 0;
-								lastch = ch;
-								lastns = ns;
-								return 0;
-							}
-GOON:
-							;
-						}
-
-						// get sample data
-						fa = s_chan[ch].SB[s_chan[ch].iSBPos++];
-
-						// muted?
-						if((spuCtrl & 0x4000) == 0)
-							fa = 0;
-						// else adjust
-						else
-						{
-							if(fa > 32767L)
-								fa = 32767L;
-							if(fa < -32767L)
-								fa = -32767L;
-						}
-
-						// gauss/cubic interpolation
-						if(iUseInterpolation >= 2)
-						{
-							gpos = s_chan[ch].SB[28];
-							gval0 = fa;
-							gpos = (gpos + 1) & 3;
-							s_chan[ch].SB[28] = gpos;
-						}
-						// simple interpolation
-						else if(iUseInterpolation == 1)
-						{
-							s_chan[ch].SB[28] = 0;
-							// helpers for simple linear interpolation:
-							// delay real val for two slots, and calc
-							// the two deltas, for a
-							// 'look at the future behaviour'
-							s_chan[ch].SB[29] = s_chan[ch].SB[30];
-
-							s_chan[ch].SB[30] = s_chan[ch].SB[31];
-							s_chan[ch].SB[31] = fa;
-							// flag: calc new interpolation
-							s_chan[ch].SB[32] = 1;
-						}
-						// no interpolation
-						else
-							s_chan[ch].SB[29] = fa;
-
-						s_chan[ch].spos -= 0x10000L;
-					}
-
-					// noise handler... just produces some noise data
-					// surely wrong...
-					// and no noise frequency (spuCtrl & 0x3f00) will be used...
-					// and sometimes the noise will be
-					// used as fmod modulation... pfff
-
-					if(s_chan[ch].bNoise)
-					{
-						if((dwNoiseVal <<= 1) & 0x80000000L)
-						{
-							dwNoiseVal ^= 0x0040001L;
-							fa = ((dwNoiseVal >> 2) & 0x7fff);
-							fa = -fa;
-						}
-						else
-							fa = (dwNoiseVal >> 2) & 0x7fff;
-
-						// mmm... depending on the noise freq we allow
-						// bigger/smaller changes to the previous val
-						fa = s_chan[ch].iOldNoise +
-							((fa - s_chan[ch].iOldNoise) /
-							 ((0x001f - ((spuCtrl & 0x3f00) >> 9)) + 1));
-						if(fa > 32767L)
-							fa = 32767L;
-						if(fa < -32767L)
-							fa = -32767L;
-						s_chan[ch].iOldNoise = fa;
-
-						// no gauss/cubic interpolation?
-						if(iUseInterpolation < 2)
-							// store noise val in "current sample slot"
-							s_chan[ch].SB[29] = fa;
-					}
-					// NO NOISE (NORMAL SAMPLE DATA) HERE
-					else
-					{
-						// cubic interpolation
-						if(iUseInterpolation == 3)
-						{
-							long xd;
-							xd = ((s_chan[ch].spos) >> 1) + 1;
-							gpos = s_chan[ch].SB[28];
-
-							fa = gval(3) - 3 * gval(2) + 3 * gval(1) - gval0;
-							fa *= (xd - (2 << 15)) / 6;
-							fa >>= 15;
-							fa += gval(2) - gval(1) - gval(1) + gval0;
-							fa *= (xd - (1 << 15)) >> 1;
-							fa >>= 15;
-							fa += gval(1) - gval0;
-							fa *= xd;
-							fa >>= 15;
-							fa = fa + gval0;
-						}
-						// gauss interpolation
-						else if(iUseInterpolation == 2)
-						{
-							int vl, vr;
-							vl = (s_chan[ch].spos >> 6) & ~3;
-							gpos = s_chan[ch].SB[28];
-							vr = (gauss[vl] * gval0) & ~2047;
-							vr += (gauss[vl + 1] * gval(1)) & ~2047;
-							vr += (gauss[vl + 2] * gval(2)) & ~2047;
-							vr += (gauss[vl + 3] * gval(3)) & ~2047;
-							fa = vr >> 11;
-						}
-						// simple interpolation
-						else if(iUseInterpolation == 1)
-						{
-							// upsampling?
-							if(s_chan[ch].sinc < 0x10000L)
-								InterpolateUp(ch);
-							else
-								InterpolateDown(ch);
-							fa = s_chan[ch].SB[29];
-						}
-						else
-							// no interpolation
-							fa = s_chan[ch].SB[29];
-					}
-
-					// add adsr
-					s_chan[ch].sval = (MixADSR(ch) * fa) / 1023;
-
-					// fmod freq channel
-					if(s_chan[ch].bFMod == 2)
-					{
-						int NP = s_chan[ch+1].iRawPitch;
-
-						NP = ((32768L + s_chan[ch].sval) * NP) / 32768L;
-
-						if(NP > 0x3fff)
-							NP = 0x3fff;
-						if(NP < 0x1)
-							NP = 0x1;
-
-						// mmmm... if I do this, all is screwed
-						// s_chan[ch+1].iRawPitch=NP;
-
-						// calc frequency
-						NP = (44100L * NP) / (4096L);
-
-						s_chan[ch + 1].iActFreq = NP;
-						s_chan[ch + 1].iUsedFreq = NP;
-						s_chan[ch + 1].sinc = (((NP / 10) << 16) / 4410);
-						if(!s_chan[ch + 1].sinc)
-							s_chan[ch + 1].sinc = 1;
-						// freq change in simple interpolation mode
-						if(iUseInterpolation == 1)
-							s_chan[ch + 1].SB[32] = 1;
-
-						// mmmm... set up freq decoding positions?
-						// s_chan[ch+1].iSBPos=28;
-						// s_chan[ch+1].spos=0x10000L;
-					}
-					else
-					{
-						// ok, left/right sound volume
-						// (psx volume goes from 0 ... 0x3fff)
-
-						// debug mute
-						if(s_chan[ch].iMute)
-							s_chan[ch].sval = 0;
-						else
-						{
-							SSumL[ns] += (s_chan[ch].sval *
-								s_chan[ch].iLeftVolume) / 0x4000L;
-							SSumR[ns] += (s_chan[ch].sval *
-								s_chan[ch].iRightVolume) / 0x4000L;
-						}
-
-						// now let us store sound data for reverb
-						if(s_chan[ch].bRVBActive)
-							StoreREVERB(ch, ns);
-					}
-
-					// ok, go on until 1 ms data
-					// of this channel is collected
-
-					ns++;
-					s_chan[ch].spos += s_chan[ch].sinc;
-				} // while(ns < NSSIZE)
-ENDX:
-				;
-			} // for(ch = 0; ch < MAXCHAN; ch++)
-		}
-
-		// here we have another 1 ms of sound data
-
-		// mix XA infos (if any)
-		if(XAPlay != XAFeed || XARepeat)
-			MixXA();
-
-		// mix all channels (including reverb) into one buffer
-/*
-		// no stereo?
-		if(iDisStereo)
-		{
-			int dl, dr;
-			for(ns = 0; ns < NSSIZE; ns++)
-			{
-				SSumL[ns] += MixREVERBLeft(ns);
-
-				dl = SSumL[ns] / voldiv;
-				SSumL[ns] = 0;
-				if(dl < -32767)
-					dl = -32767;
-				if(dl > 32767)
-					dl = 32767;
-
-				SSumR[ns] += MixREVERBRight();
-
-				dr = SSumR[ns] / voldiv;
-				SSumR[ns] = 0;
-				if(dr < -32767)
-					dr = -32767;
-				if(dr > 32767)
-					dr = 32767;
-				*pS++ = (dl + dr) / 2;
-			}
-		}
-		// stereo
-		else
-*/
-			for(ns = 0; ns < NSSIZE; ns++)
-			{
-				SSumL[ns] += MixREVERBLeft(ns);
-
-				d = SSumL[ns] / voldiv;
-				SSumL[ns] = 0;
-				if(d < -32767)
-					d = -32767;
-				if(d > 32767)
-					d = 32767;
-				*pS++ = d;
-
-				SSumR[ns] += MixREVERBRight();
-
-				d = SSumR[ns] / voldiv;
-				SSumR[ns] = 0;
-				if(d < -32767)
-					d = -32767;
-				if(d > 32767)
-					d = 32767;
-				*pS++ = d;
-			}
-
-		InitREVERB();
-
-		// feed the sound
-		// wanna have around 1/60 sec (16.666 ms) updates
-
-		//temp fix: lowered for low latency alsa configs
-		if(iCycle++ > 8)
-		{
-			SBE->FeedStreamData((u8 *)pSpuBuffer,
-					((unsigned char *)pS) -
-					((unsigned char *)pSpuBuffer));
-			pS = (short *)pSpuBuffer;
-			iCycle = 0;
-		}
-	}
-
-	// end of big main loop...
-	bThreadEnded = 1;
-
-	return 0;
-}
-
-
-
-void SPUasync(unsigned long cycle)
-{
-	// clear the watchdog
-	iWatchDog = 0;
-
-	// special mode, only used in Linux by this spu
-	// (or if you enable the experimental Windows mode)
-	if(iUseTimer == 2)
-	{
-		// no init, no call
-		if(!bSpuInit)
-			return;
-
-		// linux high-compat mode
-		MAINThread(0);
-	}
-}
-
-
-
-void SPUupdate(void)
-{
-    SPUasync(0);
-}
-
-
-
-void SPUplayADPCMchannel(xa_decode_t *xap)
-{
-	if(!iUseXA)
-		return;
-	if(!xap)
-		return;
-	if(!xap->freq)
-		return;
-
-	FeedXA(xap);
-}
-
-
-
-long SPUinit(void)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUinit()" << std::endl;
-#endif
-
-	spuMemC = (unsigned char *)spuMem;
-	memset((void *)s_chan, 0, MAXCHAN * sizeof(SPUCHAN));
-	memset((void *)&rvb, 0, sizeof(REVERBInfo));
-	InitADSR();
-	return 0;
-}
-
-
-void SetupTimer(void)
-{
-	// init some mixing buffers
-	memset(SSumR, 0, NSSIZE * sizeof(int));
-	memset(SSumL, 0, NSSIZE * sizeof(int));
-	// setup soundbuffer pointer
-	pS = (short *)pSpuBuffer;
-
-	// init thread vars
-	bEndThread = 0;
-	bThreadEnded = 0;
-	// flag: we are inited
-	bSpuInit = 1;
-}
-
-
-void RemoveTimer(void)
-{
-	// raise flag to end thread
-	bEndThread = 1;
-
-	if(!iUseTimer)
-	{
-		int i = 0;
-		// wait until thread has ended
-		while(!bThreadEnded && i < 2000)
-		{
-#ifndef _MSC_VER
-			usleep(10);
-#else
-			Sleep(10);
-#endif
-//			SDL_Delay(1000L);
-			i++;
-		}
-	}
-
-	// no more spu is running
-	bThreadEnded = 0;
-	bSpuInit = 0;
-}
-
-
-void SetupStreams(void)
-{
-	int i;
-
-	// alloc mixing buffer
-	pSpuBuffer = (unsigned char *)malloc(32768);
-
-	if(iUseReverb == 1)
-		i = 88200 * 2;
-	else
-		i = NSSIZE * 2;
-
-	// alloc reverb buffer
-	sRVBStart = (int *)malloc(i * 4);
-	memset(sRVBStart, 0, i * 4);
-	sRVBEnd = sRVBStart + i;
-	sRVBPlay = sRVBStart;
-
-	// alloc xa buffer
-	XAStart = (u32 *)malloc(44100 * 4);
-	XAPlay = XAStart;
-	XAFeed = XAStart;
-	XAEnd = XAStart + 44100;
-
-	for(i = 0; i < MAXCHAN; i++)
-	{
-		// we don't use mutex sync... not needed, would only
-		// slow us down:
-
-		// init sustain
-		s_chan[i].ADSRX.SustainLevel = 1024;
-		s_chan[i].iMute = 0;
-		s_chan[i].iIrqDone = 0;
-		s_chan[i].pLoop = spuMemC;
-		s_chan[i].pStart = spuMemC;
-		s_chan[i].pCurr = spuMemC;
-	}
-}
-
-
-void RemoveStreams(void)
-{
-	// free mixing buffer
-	free(pSpuBuffer);
-	pSpuBuffer = NULL;
-	// free reverb buffer
-	free(sRVBStart);
-	sRVBStart = 0;
-	// free xa buffer
-	free(XAStart);
-	XAStart = 0;
-}
-
-
-
-long SPUopen(void)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUopen()" << std::endl;
-#endif
-
-	// security for some stupid main emus
-	if(bSPUIsOpen)
-		return 0;
-
-	iUseXA = 1;
-	iVolume = 3;
-	iReverbOff = -1;
-	spuIrq = 0;
-	spuAddr = 0xffffffff;
-	bEndThread = 0;
-	bThreadEnded = 0;
-	spuMemC = (unsigned char *)spuMem;
-	memset((void *)s_chan, 0, (MAXCHAN + 1) * sizeof(SPUCHAN));
-	pSpuIrq = 0;
-	iSPUIRQWait = 1;
-
-	SBE = new SoundBackendSDL();
-
-	// prepare streaming
-	SetupStreams();
-
-	// timer for feeding data
-	SetupTimer();
-
-	bSPUIsOpen = 1;
-
-	return PSE_SPU_ERR_SUCCESS;
-}
-
-
-
-void SPUsetConfigFile(char * pCfg)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUsetConfigFile()" << std::endl;
-#endif
-
-//	pConfigFile = pCfg;
-}
-
-
-
-long SPUclose(void)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUclose()" << std::endl;
-#endif
-
-	// security
-	if(!bSPUIsOpen)
-		return 0;
-
-	bSPUIsOpen = 0;
-	RemoveTimer();
-
-	if(SBE != NULL)
-		delete SBE;
-
-	RemoveStreams();
-
-	return 0;
-}
-
-
-
-long SPUshutdown(void)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUshutdown()" << std::endl;
-#endif
-
-	return 0;
-}
-
-
-
-long SPUtest(void)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUtest()" << std::endl;
-#endif
-
-	return 0;
-}
-
-
-
-long SPUconfigure(void)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUconfigure()" << std::endl;
-#endif
-
-//G	StartCfgTool("CFG");
-	return 0;
-}
-
-
-
-void SPUabout(void)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUabout()" << std::endl;
-#endif
-
-//G	StartCfgTool("ABOUT");
-}
-
-
-
-void SPUregisterCallback(void (*callback)(void))
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUregisterCallback()" << std::endl;
-#endif
-
-	irqCallback = callback;
-}
-
-
-
-void SPUregisterCDDAVolume(void (*CDDAVcallback)(unsigned short,unsigned short))
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUregisterCDDAVolume()" << std::endl;
-#endif
-
-	cddavCallback = CDDAVcallback;
-}
-
-
-
-unsigned short SPUgetOne(unsigned long val)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUgetOne()" << std::endl;
-#endif
-
-	if(spuAddr != 0xffffffff)
-	{
-		return SPUreadDMA();
-	}
-	if(val >= 512 * 1024)
-		val = 512 * 1024 - 1;
-	return spuMem[val >> 1];
-}
-
-
-
-void SPUputOne(unsigned long val, unsigned short data)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUputOne()" << std::endl;
-#endif
-
-	if(spuAddr != 0xffffffff)
-	{
-		SPUwriteDMA(data);
-		return;
-	}
-	if(val >= 512 * 1024)
-		val = 512 * 1024 - 1;
-	spuMem[val >> 1] = data;
-}
-
-
-
-void SPUplaySample(unsigned char ch)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUplaySample()" << std::endl;
-#endif
-}
-
-
-
-void SPUsetAddr(unsigned char ch, unsigned short waddr)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUsetAddr()" << std::endl;
-#endif
-
-	s_chan[ch].pStart = spuMemC + ((unsigned long)waddr << 3);
-}
-
-
-
-void SPUsetPitch(unsigned char ch, unsigned short pitch)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUsetPitch()" << std::endl;
-#endif
-
-	SetPitch(ch, pitch);
-}
-
-
-
-void SPUsetVolumeL(unsigned char ch, short vol)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUsetVolumeL()" << std::endl;
-#endif
-
-	SetVolumeR(ch, vol);
-}
-
-
-
-void SPUsetVolumeR(unsigned char ch, short vol)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUsetVolumeR()" << std::endl;
-#endif
-
-	SetVolumeL(ch, vol);
-}
-
-
-
-void SPUstartChannels1(unsigned short channels)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUstartChannels1()" << std::endl;
-#endif
-
-	SoundOn(0, 16, channels);
-}
-
-
-
-void SPUstartChannels2(unsigned short channels)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUstartChannels2()" << std::endl;
-#endif
-
-	SoundOn(16, 24, channels);
-}
-
-
-
-void SPUstopChannels1(unsigned short channels)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUstopChannels1()" << std::endl;
-#endif
-
-	SoundOff(0, 16, channels);
-}
-
-
-
-void SPUstopChannels2(unsigned short channels)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUstopChannels2()" << std::endl;
-#endif
-
-	SoundOff(16, 24, channels);
-}
-
-
-
-void SPUplaySector(unsigned long mode, unsigned char *p)
-{
-#ifdef DEBUG_OUTPUT
-	std::cout << "*** SPUplaySector()\n" << std::endl;
-#endif
-
-	// no XA
-	if(!iUseXA)
-		return;
-}
-
-
-u32 GGetTime()
-{
-#ifdef _MSC_VER
-    return ::GetTickCount(); // TODO FIX ME
-#else
-	// well, maybe there are better ways
-	// to do that, but at least it works
-	struct timeval tv;
-	gettimeofday(&tv, 0);
-
-	return tv.tv_sec * 1000 + tv.tv_usec / 1000;
-#endif
-}
-

+ 0 - 512
utilities/ffvii_sound_dumper/src/engine/SoundManager.h

@@ -1,512 +0,0 @@
-/*
- * Main source code was taken from Pete's PSX sound plugin.
- * I plan full source reorganising - want to set more sound
- * engine behaviour
- */
-
-
-
-#ifndef SOUND_MANAGER_H
-#define SOUND_MANAGER_H
-
-
-
-#include "common/TypeDefine.h"
-
-
-
-class SoundManager
-{
-public:
-    SoundManager();
-    virtual ~SoundManager();
-
-    void Update();
-
-    void PsxChannelPlay(u8 arg_channel);
-    void PsxChannelStop(u8 arg_channel);
-    void PsxReverbOn(u8 arg_channel);
-    void PsxSetReverbDepth( u16 arg_left, u16 arg_right );
-
-    enum SpuRateMode
-    {
-        SPU_VOICE_LINEARIncN = 1,
-        SPU_VOICE_LINEARDecN = 3,
-        SPU_VOICE_EXPIncN    = 5,
-        SPU_VOICE_EXPDec     = 7
-    };
-
-    static const u32 m_PSX_SPU_BASE = 0x1F801C00;
-
-    void SetVoiceStartAddress(u8 arg_voice, u32 arg_address);
-    void SetVoiceLoopAddress(u8 arg_voice, u32 arg_address);
-    void SetVoiceVolume(u8 arg_voice, s16 arg_volume_left, s16 arg_volume_right);
-    void SetVoicePitch(u8 arg_voice, u16 arg_pitch);
-    void SetVoiceAttackRate(u8 arg_voice, u16 arg_rate, SpuRateMode arg_mode);
-    void SetVoiceSustainRate(u8 arg_voice, u16 arg_rate, SpuRateMode arg_mode);
-    void SetVoiceReleaseRate(u8 arg_voice, u16 arg_rate, SpuRateMode arg_mode);
-    void SetVoiceDecayRate(u8 arg_voice, u16 arg_rate);
-    void SetVoiceSustainLevel(u8 arg_voice, u16 arg_level);
-
-    static const u32 m_REGISTER_BASE = 0x1f801c00;
-
-    bool PsxWriteDMA(u16 arg_address, u8 *arg_data, u32 arg_length);
-};
-
-
-
-extern SoundManager *SOUNDMAN;
-
-void InitADSR();
-void StartADSR(int ch);
-int MixADSR(int ch);
-
-
-
-// PETE ///////////////
-unsigned short SPUreadDMA();
-void SPUreadDMAMem( unsigned short *pusPSXMem, int iSize );
-void SPUwriteDMA( unsigned short val );
-void SPUwriteDMAMem( unsigned short *pusPSXMem, int iSize );
-// PETE ///////////////
-
-
-
-
-extern const int gauss[];
-
-#define H_SPUReverbAddr  0x0da2
-#define H_SPUirqAddr     0x0da4
-#define H_SPUaddr        0x0da6
-#define H_SPUdata        0x0da8
-#define H_SPUctrl        0x0daa
-#define H_SPUstat        0x0dae
-#define H_SPUmvolL       0x0d80
-#define H_SPUmvolR       0x0d82
-#define H_SPUrvolL       0x0d84
-#define H_SPUrvolR       0x0d86
-#define H_SPUon1         0x0d88
-#define H_SPUon2         0x0d8a
-#define H_SPUoff1        0x0d8c
-#define H_SPUoff2        0x0d8e
-#define H_FMod1          0x0d90
-#define H_FMod2          0x0d92
-#define H_Noise1         0x0d94
-#define H_Noise2         0x0d96
-#define H_RVBon1         0x0d98
-#define H_RVBon2         0x0d9a
-#define H_SPUMute1       0x0d9c
-#define H_SPUMute2       0x0d9e
-#define H_CDLeft         0x0db0
-#define H_CDRight        0x0db2
-#define H_ExtLeft        0x0db4
-#define H_ExtRight       0x0db6
-#define H_Reverb         0x0dc0
-#define H_SPUPitch0      0x0c04
-#define H_SPUPitch1      0x0c14
-#define H_SPUPitch2      0x0c24
-#define H_SPUPitch3      0x0c34
-#define H_SPUPitch4      0x0c44
-#define H_SPUPitch5      0x0c54
-#define H_SPUPitch6      0x0c64
-#define H_SPUPitch7      0x0c74
-#define H_SPUPitch8      0x0c84
-#define H_SPUPitch9      0x0c94
-#define H_SPUPitch10     0x0ca4
-#define H_SPUPitch11     0x0cb4
-#define H_SPUPitch12     0x0cc4
-#define H_SPUPitch13     0x0cd4
-#define H_SPUPitch14     0x0ce4
-#define H_SPUPitch15     0x0cf4
-#define H_SPUPitch16     0x0d04
-#define H_SPUPitch17     0x0d14
-#define H_SPUPitch18     0x0d24
-#define H_SPUPitch19     0x0d34
-#define H_SPUPitch20     0x0d44
-#define H_SPUPitch21     0x0d54
-#define H_SPUPitch22     0x0d64
-#define H_SPUPitch23     0x0d74
-
-#define H_SPUStartAdr0   0x0c06
-#define H_SPUStartAdr1   0x0c16
-#define H_SPUStartAdr2   0x0c26
-#define H_SPUStartAdr3   0x0c36
-#define H_SPUStartAdr4   0x0c46
-#define H_SPUStartAdr5   0x0c56
-#define H_SPUStartAdr6   0x0c66
-#define H_SPUStartAdr7   0x0c76
-#define H_SPUStartAdr8   0x0c86
-#define H_SPUStartAdr9   0x0c96
-#define H_SPUStartAdr10  0x0ca6
-#define H_SPUStartAdr11  0x0cb6
-#define H_SPUStartAdr12  0x0cc6
-#define H_SPUStartAdr13  0x0cd6
-#define H_SPUStartAdr14  0x0ce6
-#define H_SPUStartAdr15  0x0cf6
-#define H_SPUStartAdr16  0x0d06
-#define H_SPUStartAdr17  0x0d16
-#define H_SPUStartAdr18  0x0d26
-#define H_SPUStartAdr19  0x0d36
-#define H_SPUStartAdr20  0x0d46
-#define H_SPUStartAdr21  0x0d56
-#define H_SPUStartAdr22  0x0d66
-#define H_SPUStartAdr23  0x0d76
-
-#define H_SPULoopAdr0   0x0c0e
-#define H_SPULoopAdr1   0x0c1e
-#define H_SPULoopAdr2   0x0c2e
-#define H_SPULoopAdr3   0x0c3e
-#define H_SPULoopAdr4   0x0c4e
-#define H_SPULoopAdr5   0x0c5e
-#define H_SPULoopAdr6   0x0c6e
-#define H_SPULoopAdr7   0x0c7e
-#define H_SPULoopAdr8   0x0c8e
-#define H_SPULoopAdr9   0x0c9e
-#define H_SPULoopAdr10  0x0cae
-#define H_SPULoopAdr11  0x0cbe
-#define H_SPULoopAdr12  0x0cce
-#define H_SPULoopAdr13  0x0cde
-#define H_SPULoopAdr14  0x0cee
-#define H_SPULoopAdr15  0x0cfe
-#define H_SPULoopAdr16  0x0d0e
-#define H_SPULoopAdr17  0x0d1e
-#define H_SPULoopAdr18  0x0d2e
-#define H_SPULoopAdr19  0x0d3e
-#define H_SPULoopAdr20  0x0d4e
-#define H_SPULoopAdr21  0x0d5e
-#define H_SPULoopAdr22  0x0d6e
-#define H_SPULoopAdr23  0x0d7e
-
-#define H_SPU_ADSRLevel0   0x0c08
-#define H_SPU_ADSRLevel1   0x0c18
-#define H_SPU_ADSRLevel2   0x0c28
-#define H_SPU_ADSRLevel3   0x0c38
-#define H_SPU_ADSRLevel4   0x0c48
-#define H_SPU_ADSRLevel5   0x0c58
-#define H_SPU_ADSRLevel6   0x0c68
-#define H_SPU_ADSRLevel7   0x0c78
-#define H_SPU_ADSRLevel8   0x0c88
-#define H_SPU_ADSRLevel9   0x0c98
-#define H_SPU_ADSRLevel10  0x0ca8
-#define H_SPU_ADSRLevel11  0x0cb8
-#define H_SPU_ADSRLevel12  0x0cc8
-#define H_SPU_ADSRLevel13  0x0cd8
-#define H_SPU_ADSRLevel14  0x0ce8
-#define H_SPU_ADSRLevel15  0x0cf8
-#define H_SPU_ADSRLevel16  0x0d08
-#define H_SPU_ADSRLevel17  0x0d18
-#define H_SPU_ADSRLevel18  0x0d28
-#define H_SPU_ADSRLevel19  0x0d38
-#define H_SPU_ADSRLevel20  0x0d48
-#define H_SPU_ADSRLevel21  0x0d58
-#define H_SPU_ADSRLevel22  0x0d68
-#define H_SPU_ADSRLevel23  0x0d78
-
-// we have a timebase of 1.020408f ms, not 1 ms... so adjust adsr defines
-#define ATTACK_MS      494L
-#define DECAYHALF_MS   286L
-#define DECAY_MS       572L
-#define SUSTAIN_MS     441L
-#define RELEASE_MS     437L
-
-#ifndef _MSC_VER
-#ifndef LOWORD
-#define LOWORD(l)    ((unsigned short)(l))
-#endif
-
-#ifndef HIWORD
-#define HIWORD(l)    ((unsigned short)(((unsigned long)(l) >> 16) & 0xFFFF))
-#endif
-#endif
-
-extern int bSPUIsOpen;
-
-
-typedef struct
-{
-	long y0, y1;
-} ADPCM_Decode_t;
-
-typedef struct
-{
-	int freq;
-	int nbits;
-	int stereo;
-	int nsamples;
-	ADPCM_Decode_t left, right;
-	short pcm[16384];
-} xa_decode_t;
-
-
-
-extern xa_decode_t *xapGlobal;
-
-extern u32 *XAFeed;
-extern u32 *XAPlay;
-extern u32 *XAStart;
-extern u32 *XAEnd;
-
-extern u32 XARepeat;
-extern u32 XALastVal;
-
-extern int iLeftXAVol;
-extern int iRightXAVol;
-
-#define PSE_LT_SPU                  4
-#define PSE_SPU_ERR_SUCCESS         0
-#define PSE_SPU_ERR                 -60
-#define PSE_SPU_ERR_NOTCONFIGURED   PSE_SPU_ERR - 1
-#define PSE_SPU_ERR_INIT            PSE_SPU_ERR - 2
-#ifndef max
-#define max(a,b)            (((a) > (b)) ? (a) : (b))
-#define min(a,b)            (((a) < (b)) ? (a) : (b))
-#endif
-
-// 137 ms test buffer... if less than that is buffered, a new upload will happen
-#define TESTSIZE    24192
-// num of channels
-#define MAXCHAN     24
-// ~ 1 ms of data
-#define NSSIZE 45
-
-
-
-// ADSR infos per channel
-typedef struct
-{
-	int            AttackModeExp;
-	long           AttackTime;
-	long           DecayTime;
-	long           SustainLevel;
-	int            SustainModeExp;
-	long           SustainModeDec;
-	long           SustainTime;
-	int            ReleaseModeExp;
-	unsigned long  ReleaseVal;
-	long           ReleaseTime;
-	long           ReleaseStartTime;
-	long           ReleaseVol;
-	long           lTime;
-	long           lVolume;
-} ADSRInfo;
-
-typedef struct
-{
-	int            State;
-	int            AttackModeExp;
-	int            AttackRate;
-	int            DecayRate;
-	int            SustainLevel;
-	int            SustainModeExp;
-	int            SustainIncrease;
-	int            SustainRate;
-	int            ReleaseModeExp;
-	int            ReleaseRate;
-	int            EnvelopeVol;
-	long           lVolume;
-	long           lDummy1;
-	long           lDummy2;
-} ADSRInfoEx;
-
-// used for debug channel muting
-#define FLAG_MUTE  1
-// used for simple interpolation
-#define FLAG_IPOL0 2
-#define FLAG_IPOL1 4
-
-
-// MAIN CHANNEL STRUCT
-typedef struct
-{
-	int bNew;              // start flag
-	int iSBPos;            // mixing stuff
-	int spos;
-	int sinc;
-	int SB[32 + 32];       // Pete added another 32 dwords in 1.6 ...
-	                       // prevents overflow issues with gaussian/cubic
-						   // interpolation (thanx xodnizel!), and can be
-						   // used for even better interpolations, eh? :)
-	int sval;
-
-	unsigned char *pStart; // start ptr into sound mem
-	unsigned char *pCurr;  // current pos in sound mem
-	unsigned char *pLoop;  // loop ptr in sound mem
-
-	int bOn;               // is channel active (sample playing?)
-	int bStop;             // is ch stop (can still be playing, if ADSR Release)
-	int bReverb;           // reverb, must have ctrl register bit, to get active
-	int iActFreq;          // current psx pitch
-	int iUsedFreq;         // current pc pitch
-	int iLeftVolume;       // left volume
-	int iLeftVolRaw;       // left psx volume value
-	int bIgnoreLoop;       // ignore loop, if an external loop address is used
-	int iMute;             // mute mode
-	int iRightVolume;      // right volume
-	int iRightVolRaw;      // right psx volume value
-	int iRawPitch;         // raw pitch (0...3fff)
-	int iIrqDone;          // debug irq done flag
-	int s_1;               // last decoding infos
-	int s_2;
-	int bRVBActive;        // reverb active flag
-	int iRVBOffset;        // reverb offset
-	int iRVBRepeat;        // reverb repeat
-	int bNoise;            // noise active flag
-	int bFMod;             // freq mod (0=off, 1=sound channel, 2=freq channel)
-	int iRVBNum;           // another reverb helper
-	int iOldNoise;         // old noise val for this channel
-	ADSRInfo ADSR;         // active ADSR settings
-	ADSRInfoEx ADSRX;      // next ADSR settings
-					       // (will be moved to active on sample start)
-} SPUCHAN;
-
-
-// REVERB
-typedef struct
-{
-	int StartAddr;      // reverb area start addr in samples
-	int CurrAddr;       // reverb area curr addr in samples
-
-	int VolLeft;
-	int VolRight;
-	int iLastRVBLeft;
-	int iLastRVBRight;
-	int iRVBLeft;
-	int iRVBRight;
-
-
-	int FB_SRC_A;       // (offset)
-	int FB_SRC_B;       // (offset)
-	int IIR_ALPHA;      // (coef.)
-	int ACC_COEF_A;     // (coef.)
-	int ACC_COEF_B;     // (coef.)
-	int ACC_COEF_C;     // (coef.)
-	int ACC_COEF_D;     // (coef.)
-	int IIR_COEF;       // (coef.)
-	int FB_ALPHA;       // (coef.)
-	int FB_X;           // (coef.)
-	int IIR_DEST_A0;    // (offset)
-	int IIR_DEST_A1;    // (offset)
-	int ACC_SRC_A0;     // (offset)
-	int ACC_SRC_A1;     // (offset)
-	int ACC_SRC_B0;     // (offset)
-	int ACC_SRC_B1;     // (offset)
-	int IIR_SRC_A0;     // (offset)
-	int IIR_SRC_A1;     // (offset)
-	int IIR_DEST_B0;    // (offset)
-	int IIR_DEST_B1;    // (offset)
-	int ACC_SRC_C0;     // (offset)
-	int ACC_SRC_C1;     // (offset)
-	int ACC_SRC_D0;     // (offset)
-	int ACC_SRC_D1;     // (offset)
-	int IIR_SRC_B1;     // (offset)
-	int IIR_SRC_B0;     // (offset)
-	int MIX_DEST_A0;    // (offset)
-	int MIX_DEST_A1;    // (offset)
-	int MIX_DEST_B0;    // (offset)
-	int MIX_DEST_B1;    // (offset)
-	int IN_COEF_L;      // (coef.)
-	int IN_COEF_R;      // (coef.)
-} REVERBInfo;
-
-
-extern char * pConfigFile;
-
-extern int *          sRVBPlay;
-extern int *          sRVBEnd;
-extern int *          sRVBStart;
-extern int            iReverbOff;
-extern int            iReverbRepeat;
-extern int            iReverbNum;
-
-// psx buffers / addresses
-extern unsigned short  regArea[];
-extern unsigned short  spuMem[];
-extern unsigned char * spuMemC;
-extern unsigned char * pSpuIrq;
-extern unsigned char * pSpuBuffer;
-
-// user settings
-extern int        iUseXA;
-extern int        iVolume;
-extern int        iXAPitch;
-extern int        iUseTimer;
-extern int        iSPUIRQWait;
-extern int        iDebugMode;
-extern int        iRecordMode;
-extern int        iUseReverb;
-extern int        iUseInterpolation;
-extern int        iDisStereo;
-// MISC
-
-extern int iWatchDog;
-
-//extern SPUCHAN s_chan[];
-extern REVERBInfo rvb;
-
-extern unsigned long dwNoiseVal;
-extern unsigned short spuCtrl;
-extern unsigned short spuStat;
-extern unsigned short spuIrq;
-extern unsigned long  spuAddr;
-extern int      bEndThread;
-extern int      bThreadEnded;
-extern int      bSpuInit;
-extern unsigned long dwNewChannel;
-
-extern int      SSumR[];
-extern int      SSumL[];
-extern int      iCycle;
-extern short *  pS;
-
-extern void (*cddavCallback)(unsigned short,unsigned short);
-extern SPUCHAN s_chan[];
-
-
-
-void SPUwriteRegister(unsigned long reg, unsigned short val);
-unsigned short SPUreadRegister(unsigned long reg);
-void SoundOn(int start, int end, unsigned short val);
-void SoundOff(int start, int end, unsigned short val);
-void FModOn(int start, int end, unsigned short val);
-void NoiseOn(int start, int end, unsigned short val);
-void SetVolumeL(unsigned char ch, short vol);
-void SetVolumeR(unsigned char ch, short vol);
-void SetPitch(int ch, unsigned short val);
-void ReverbOn(int start, int end, unsigned short val);
-
-void SetREVERB(unsigned short val);
-void StartREVERB(int ch);
-void InitREVERB();
-void StoreREVERB(int ch, int ns);
-int g_buffer(int iOff);
-void s_buffer(int iOff, int iVal);
-void s_buffer1(int iOff, int iVal);
-int MixREVERBLeft(int ns);
-int MixREVERBRight();
-
-void MixXA();
-void FeedXA(xa_decode_t *xap);
-
-long SPUinit(void);
-long SPUopen(void);
-long SPUclose(void);
-void SPUasync(unsigned long cycle);
-void SPUplayADPCMchannel(xa_decode_t *xap);
-unsigned short SPUgetOne(unsigned long val);
-void SPUputOne(unsigned long val,unsigned short data);
-void SPUplaySample(unsigned char ch);
-void SPUsetAddr(unsigned char ch, unsigned short waddr);
-void SPUsetPitch(unsigned char ch, unsigned short pitch);
-void SPUsetVolumeL(unsigned char ch, short vol);
-void SPUsetVolumeR(unsigned char ch, short vol);
-void SPUstartChannels1(unsigned short channels);
-void SPUstartChannels2(unsigned short channels);
-void SPUstopChannels1(unsigned short channels);
-void SPUstopChannels2(unsigned short channels);
-void SPUplaySector(unsigned long mode, unsigned char * p);
-u32 GGetTime();
-
-
-
-#endif
-

+ 0 - 137
utilities/ffvii_sound_dumper/src/engine/backends/SoundBackendSDL.cpp

@@ -1,137 +0,0 @@
-//#include <SDL/SDL.h>
-#include "common/TypeDefine.h"
-
-#include "SoundBackendSDL.h"
-
-
-
-using namespace std;
-
-
-
-void sound_manager_fill_audio(void *arg_user_data, unsigned char *arg_stream, int arg_length);
-
-
-SoundBackendSDL::SoundBackendSDL()
-{
-    /*
-	// init SDL::Audio subsystem
-	Uint32 initialized_subsystems = SDL_WasInit(SDL_INIT_EVERYTHING);
-	int initialization_successfull;
-	if(initialized_subsystems)
-		if(initialized_subsystems & SDL_INIT_AUDIO)
-			SDL_CloseAudio();
-		else
-			initialization_successfull = SDL_InitSubSystem(SDL_INIT_AUDIO);
-	else
-		initialization_successfull = SDL_Init(SDL_INIT_AUDIO);
-
-	if(initialization_successfull == -1)
-	{
-		cout << "[SoundManager] error: " << SDL_GetError();
-		exit(EXIT_FAILURE);
-	}
-	else
-		cout << "[SoundManager] info: initialization successfull."
-			<< endl;
-
-	// set desired configuration
-	SDL_AudioSpec desired_configuration;
-	desired_configuration.freq = m_FREQUENCY;            // frequency
-	desired_configuration.format = AUDIO_S16SYS;         // sample format
-	desired_configuration.channels = m_CHANNELS_COUNT;   // channels count
-	desired_configuration.samples = 512;                 // internal buffer size
-	desired_configuration.callback =
-		sound_manager_fill_audio;                        // callback function
-	desired_configuration.userdata = (void *)&m_Context; // user data
-	SDL_AudioSpec obtained_configuration;
-	SDL_OpenAudio(&desired_configuration, &obtained_configuration);
-	if(desired_configuration.freq != obtained_configuration.freq ||
-		desired_configuration.format != obtained_configuration.format ||
-		desired_configuration.channels != obtained_configuration.channels)
-	{
-		cout << "[SoundManager] error: obtained unsuitable configuration."
-			<< endl;
-		SDL_CloseAudio();
-		SDL_QuitSubSystem(SDL_INIT_AUDIO);
-	}
-
-	// initialize context for callback
-	m_Context.buffer_size = m_BUFFER_SIZE;
-	m_Context.buffer = new uint8_t[m_Context.buffer_size];
-	if(m_Context.buffer == NULL)
-	{
-		cout << "[SoundManager] error: out of memory." << endl;
-		exit(EXIT_FAILURE);
-	}
-
-	m_Context.play_length = 0;
-
-    SDL_PauseAudio(0);*/
-}
-
-
-SoundBackendSDL::~SoundBackendSDL()
-{
-    /*
-	SDL_PauseAudio(1);
-
-	SDL_CloseAudio();
-	SDL_QuitSubSystem(SDL_INIT_AUDIO);
-	if(!SDL_WasInit(SDL_INIT_EVERYTHING))
-	{
-		cout << "[SoundManager] info: exit successfull" << endl;
-		SDL_Quit();
-	}
-
-	if(m_Context.buffer != NULL)
-        delete [] m_Context.buffer;*/
-}
-
-
-u32 SoundBackendSDL::GetBytesBuffered()
-{
-	if(m_Context.play_length <
-			m_Context.buffer_size / 2)
-		return 0;
-	else
-		return m_Context.buffer_size;
-}
-
-
-void SoundBackendSDL::FeedStreamData(u8 *arg_data, u32 arg_length)
-{
-    /*
-	SDL_LockAudio();
-
-	memcpy((void *)(m_Context.buffer + m_Context.play_length),
-			(const void *)arg_data, arg_length);
-	m_Context.play_length += arg_length;
-
-    SDL_UnlockAudio();*/
-}
-
-
-void sound_manager_fill_audio(void *arg_user_data, unsigned char *arg_stream, int arg_length)
-{
-    /*
-	SoundBackendSDL::FillAudioContext *context =
-			(SoundBackendSDL::FillAudioContext *)arg_user_data;
-
-	if(!context->play_length)
-		return;
-
-	int play_length = arg_length < (int)context->play_length ?
-			arg_length : context->play_length;
-
-	// mix data to sdl buffer for playing
-	SDL_MixAudio(arg_stream, (Uint8 *)context->buffer,
-			play_length, SDL_MIX_MAXVOLUME);
-	context->play_length -= play_length;
-
-	// shift pcm data to buffer beginning
-	memcpy((void *)context->buffer,
-			(const void *)(context->buffer + play_length),
-            context->play_length);*/
-}
-

+ 0 - 37
utilities/ffvii_sound_dumper/src/engine/backends/SoundBackendSDL.h

@@ -1,37 +0,0 @@
-#ifndef SOUND_BACKEND_SDL_HH__
-#define SOUND_BACKEND_SDL_HH__
-
-
-
-//#include <SDL/SDL.h>
-#include "common/TypeDefine.h"
-
-#include "../SoundBackend.h"
-#include <stdint.h>
-
-
-class SoundBackendSDL : public SoundBackend
-{
-	private:
-		struct FillAudioContext
-		{
-			uint8_t *buffer;
-			uint32_t buffer_size;
-			uint32_t play_length;
-		};
-
-		FillAudioContext m_Context;
-        friend void sound_manager_fill_audio(void *arg_user_data, unsigned char *arg_stream, int arg_length);
-
-	public:
-		SoundBackendSDL();
-		virtual ~SoundBackendSDL();
-
-		virtual u32 GetBytesBuffered();
-		virtual void FeedStreamData(u8 *arg_data, u32 arg_length);
-};
-
-
-
-#endif
-

+ 0 - 81
utilities/ffvii_sound_dumper_psf/CMakeLists.txt

@@ -1,81 +0,0 @@
-include_directories(
-    ${CMAKE_CURRENT_SOURCE_DIR}/include
-    ${CMAKE_CURRENT_SOURCE_DIR}/libupse
-)
-
-# define header and source files
-set(HEADER_FILES
-./src/libupse/upse-ps1-spu-register-io.h
-./src/libupse/upse-ps1-memory-manager.h
-./src/libupse/upse-r3000-abstract.h
-./src/libupse/upse-ps1-counters.h
-./src/libupse/config.h
-./src/libupse/upse-types.h
-./src/libupse/upse-spu-internal.h
-./src/libupse/upse-ps1-spu-abstract.h
-./src/libupse/upse-ps1-executive.h
-./src/libupse/upse-internal.h
-./src/libupse/upse-ps1-hal.h
-./src/libupse/upse-ps1-spu-reverb.h
-./src/libupse/upse-ps1-bios-base.h
-./src/libupse/upse.h
-./src/libupse/upse-ps1-bios-private.h
-./src/libupse/upse-string.h
-./src/libupse/upse-ps1-spu-base.h
-./src/libupse/upse-ps1-spu-dma-handler.h
-./src/libupse/upse-ps1-dma-manager.h
-./src/libupse/upse-ps1-spu-adsr-filter.h
-./src/libupse/upse-debug.h
-./src/walkthrough.hh
-./src/typedefs.h
-)
-
-set(SOURCE_FILES
-./src/main.cc
-#./src/libupse/upse_ps1_spu_adsr_filter.c
-#./src/libupse/upse_ps1_spu_reverb.c
-#./src/libupse/upse_bios_manager.c
-#./src/libupse/upse_ps1_spu_dma_handler.c
-#./src/libupse/upse_ps1_spu_base.c
-#./src/libupse/upse_r3000_abstract.c
-#./src/libupse/upse_r3000_bytecode_evaluator.c
-#./src/libupse/upse_unpack_psf.c
-#./src/libupse/upse_ps1_counters.c
-#./src/libupse/upse_ps1_hal.c
-#./src/libupse/upse_ps1_memory_manager.c
-#./src/libupse/upse_string.c
-#./src/libupse/upse_ps1_dma_manager.c
-#./src/libupse/upse_util.c
-#./src/libupse/upse_ps1_bios_base.c
-#./src/libupse/upse_ps1_executive.c
-#./src/libupse/upse_ps1_spu_register_io.c
-./src/walkthrough.cc
-)
-
-add_definitions(
-    -DQGEARS_ADD_MANAGERS
-)
-
-add_executable(ff7_sound_dumper_psf
-  ${HEADER_FILES}
-  ${SOURCE_FILES}
-)
-SET_PROPERTY(TARGET ff7_sound_dumper_psf PROPERTY FOLDER "utilities")
-
-if(WIN32)
-  set_target_properties(ff7_sound_dumper_psf PROPERTIES WIN32_EXECUTABLE ON)
-  if (MSVC)
-    set_target_properties(ff7_sound_dumper_psf PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE")
-  endif()
-endif()
-
-set(LIBRARIES
-    Utility
-    QGearsMain
-    v-gears-data
-)
-target_link_libraries(ff7_sound_dumper_psf    ${LIBRARIES})
-
-install(TARGETS ff7_sound_dumper_psf
-    DESTINATION tools/ff7
-)

+ 0 - 4
utilities/ffvii_sound_dumper_psf/src/libupse/config.h

@@ -1,4 +0,0 @@
-/* Define to 1 if your processor stores words with the most significant byte
-   first (like Motorola and SPARC, unlike Intel and VAX). */
-/* #undef WORDS_BIGENDIAN */
-

+ 0 - 37
utilities/ffvii_sound_dumper_psf/src/libupse/upse-debug.h

@@ -1,37 +0,0 @@
-/*
- * UPSE: the unix playstation sound emulator.
- *
- * Filename: upse-debug.h
- * Purpose: libupse: UPSE debug infrastructure
- *
- * Copyright (c) 2007 William Pitcock <nenolod@sacredspiral.co.uk>
- *
- * UPSE is free software, released under the GNU General Public License,
- * version 2.
- *
- * A copy of the GNU General Public License, version 2, is included in
- * the UPSE source kit as COPYING.
- *
- * UPSE is offered without any warranty of any kind, explicit or implicit.
- */
-
-#ifndef _UPSE__LIBUPSE__UPSE_DEBUG_H__GUARD
-#define _UPSE__LIBUPSE__UPSE_DEBUG_H__GUARD
-
-#undef UPSE_DEBUG
-
-#define _ENTER _DEBUG("enter")
-#define _LEAVE _DEBUG("leave")
-#define _MESSAGE(tag, string, ...) do { fprintf(stderr, "libupse: %s: %s:%d (%s): " string "\n", \
-    tag, __FILE__, __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__); } while(0)
-
-#define _ERROR(...) _MESSAGE("ERROR", __VA_ARGS__)
-#define _WARN(...)  _MESSAGE("WARN", __VA_ARGS__)
-
-#ifdef UPSE_DEBUG
-#define _DEBUG(...) _MESSAGE("DEBUG",  __VA_ARGS__)
-#else
-#define _DEBUG(...) {}
-#endif
-
-#endif

+ 0 - 61
utilities/ffvii_sound_dumper_psf/src/libupse/upse-internal.h

@@ -1,61 +0,0 @@
-/*
- * UPSE: the unix playstation sound emulator.
- *
- * Filename: upse-internal.h
- * Purpose: libupse: UPSE Internal header
- *
- * Copyright (c) 2007 William Pitcock <nenolod@sacredspiral.co.uk>
- * Portions copyright (c) 1999-2002 Pcsx Team
- * Portions copyright (c) 2004 "Xodnizel"
- *
- * UPSE is free software, released under the GNU General Public License,
- * version 2.
- *
- * A copy of the GNU General Public License, version 2, is included in
- * the UPSE source kit as COPYING.
- *
- * UPSE is offered without any warranty of any kind, explicit or implicit.
- */
-
-#ifndef __PSXCOMMON_H__
-#define __PSXCOMMON_H__
-
-#if PSS_STYLE==2
-
-#define PSS "\\"
-#define PS '\\'
-
-#elif PSS_STYLE==1
-
-#define PSS "/"
-#define PS '/'
-
-#elif PSS_STYLE==3
-
-#define PSS "\\"
-#define PS '\\'
-#endif
-
-#include <zlib.h>
-
-#include <sys/types.h>
-#include "upse-types.h"
-
-void __Log(char *fmt, ...);
-
-#define BIAS	2
-#define PSXCLK	33868800	/* 33.8688 Mhz */
-
-#include "upse.h"
-#include "upse-debug.h"
-#include "upse-r3000-abstract.h"
-#include "upse-ps1-memory-manager.h"
-#include "upse-ps1-hal.h"
-#include "upse-ps1-bios-base.h"
-#include "upse-ps1-dma-manager.h"
-#include "upse-ps1-counters.h"
-#include "upse-ps1-executive.h"
-#include "upse-ps1-spu-abstract.h"
-#include "upse-ps1-spu-base.h"
-
-#endif /* __PSXCOMMON_H__ */

+ 0 - 36
utilities/ffvii_sound_dumper_psf/src/libupse/upse-ps1-bios-base.h

@@ -1,36 +0,0 @@
-/*
- * UPSE: the unix playstation sound emulator.
- *
- * Filename: upse-ps1-bios-base.h
- * Purpose: libupse: UPSE PS1 FakeBIOS public header
- *
- * Copyright (c) 2007 William Pitcock <nenolod@sacredspiral.co.uk>
- * Portions copyright (c) 1999-2002 Pcsx Team
- * Portions copyright (c) 2004 "Xodnizel"
- *
- * UPSE is free software, released under the GNU General Public License,
- * version 2.
- *
- * A copy of the GNU General Public License, version 2, is included in
- * the UPSE source kit as COPYING.
- *
- * UPSE is offered without any warranty of any kind, explicit or implicit.
- */
-
-#ifndef _UPSE__LIBUPSE__UPSE_PS1_BIOS_BASE_H__GUARD
-#define _UPSE__LIBUPSE__UPSE_PS1_BIOS_BASE_H__GUARD
-
-/* these are for tracing in the executive layer --nenolod */
-extern char *biosA0n[256];
-extern char *biosB0n[256];
-extern char *biosC0n[256];
-
-void upse_ps1_bios_init(void);
-void upse_ps1_bios_shutdown(void);
-void upse_ps1_bios_exception(void);
-
-extern void (*biosA0[256]) (void);
-extern void (*biosB0[256]) (void);
-extern void (*biosC0[256]) (void);
-
-#endif

+ 0 - 64
utilities/ffvii_sound_dumper_psf/src/libupse/upse-ps1-bios-private.h

@@ -1,64 +0,0 @@
-/*
- * UPSE: the unix playstation sound emulator.
- *
- * Filename: upse-ps1-bios-private.h
- * Purpose: libupse: UPSE PS1 FakeBIOS private defines/functions
- *
- * Copyright (c) 2007 William Pitcock <nenolod@sacredspiral.co.uk>
- * Portions copyright (c) 1999-2002 Pcsx Team
- * Portions copyright (c) 2004 "Xodnizel"
- *
- * UPSE is free software, released under the GNU General Public License,
- * version 2.
- *
- * A copy of the GNU General Public License, version 2, is included in
- * the UPSE source kit as COPYING.
- *
- * UPSE is offered without any warranty of any kind, explicit or implicit.
- */
-
-#ifndef _UPSE__LIBUPSE__UPSE_PS1_BIOS_PRIVATE_H__GUARD
-#define _UPSE__LIBUPSE__UPSE_PS1_BIOS_PRIVATE_H__GUARD
-
-//#define r0 (upse_r3000_cpu_regs.GPR.n.r0)
-#define at (upse_r3000_cpu_regs.GPR.n.at)
-#define v0 (upse_r3000_cpu_regs.GPR.n.v0)
-#define v1 (upse_r3000_cpu_regs.GPR.n.v1)
-#define a0 (upse_r3000_cpu_regs.GPR.n.a0)
-#define a1 (upse_r3000_cpu_regs.GPR.n.a1)
-#define a2 (upse_r3000_cpu_regs.GPR.n.a2)
-#define a3 (upse_r3000_cpu_regs.GPR.n.a3)
-#define t0 (upse_r3000_cpu_regs.GPR.n.t0)
-#define t1 (upse_r3000_cpu_regs.GPR.n.t1)
-#define t2 (upse_r3000_cpu_regs.GPR.n.t2)
-#define t3 (upse_r3000_cpu_regs.GPR.n.t3)
-#define t4 (upse_r3000_cpu_regs.GPR.n.t4)
-#define t5 (upse_r3000_cpu_regs.GPR.n.t5)
-#define t6 (upse_r3000_cpu_regs.GPR.n.t6)
-#define t7 (upse_r3000_cpu_regs.GPR.n.t7)
-#define s0 (upse_r3000_cpu_regs.GPR.n.s0)
-#define s1 (upse_r3000_cpu_regs.GPR.n.s1)
-#define s2 (upse_r3000_cpu_regs.GPR.n.s2)
-#define s3 (upse_r3000_cpu_regs.GPR.n.s3)
-#define s4 (upse_r3000_cpu_regs.GPR.n.s4)
-#define s5 (upse_r3000_cpu_regs.GPR.n.s5)
-#define s6 (upse_r3000_cpu_regs.GPR.n.s6)
-#define s7 (upse_r3000_cpu_regs.GPR.n.s7)
-#define t8 (upse_r3000_cpu_regs.GPR.n.t6)
-#define t9 (upse_r3000_cpu_regs.GPR.n.t7)
-#define k0 (upse_r3000_cpu_regs.GPR.n.k0)
-#define k1 (upse_r3000_cpu_regs.GPR.n.k1)
-#define gp (upse_r3000_cpu_regs.GPR.n.gp)
-#define sp (upse_r3000_cpu_regs.GPR.n.sp)
-#define fp (upse_r3000_cpu_regs.GPR.n.s8)
-#define ra (upse_r3000_cpu_regs.GPR.n.ra)
-#define pc0 (upse_r3000_cpu_regs.pc)
-
-#define Ra0 ((char*)PSXM(a0))
-#define Ra1 ((char*)PSXM(a1))
-#define Ra2 ((char*)PSXM(a2))
-#define Ra3 ((char*)PSXM(a3))
-#define Rv0 ((char*)PSXM(v0))
-#define Rsp ((char*)PSXM(sp))
-
-#endif

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików