~ubuntu-branches/ubuntu/trusty/rlvm/trusty

« back to all changes in this revision

Viewing changes to src/Modules/Module_Bgr.cpp

  • Committer: Package Import Robot
  • Author(s): Ying-Chun Liu (PaulLiu)
  • Date: 2013-11-02 02:57:13 UTC
  • mfrom: (10.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20131102025713-yzg31grxr8i7xerh
Tags: 0.13-1
* New upstream release
  - rlvm will now warn on startup when it detects Japanese save data, but
    English patched game files, and offer to reset the save data.
  - Much better support for Little Busters. Most graphical glitches during
    the Little Busters Refrain have been fixed.
  - TCC tone curve effects have been reverse-engineered and implemented
    (thanks to lurkmoar)
  - Sepia scenes (and other graphical filters) should look much better.
  - Simple shake commands implemented (fancy per-layer shaking still
    unimplemented).
  - Make animations smooth: data should be uploaded to the graphics card
    before an animation loop starts, not while the animation loop is
    running.
  - Fixes finding system fonts on Linux
  - Thanks to Elliot Glaysher <glaysher@umich.edu>
* Remove upstreamed patches:
  - debian/patches/002_675426ad62bccf1de10b0ae31dd46331ec47aacb.patch
  - debian/patches/003_5dafabf5448635c4d4526d6e35ea7ec664a27261.patch
  - debian/patches/004_boost-drop-mt.patch
  - debian/patches/005_missing-include.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
 
34
34
#include "Effects/Effect.hpp"
35
35
#include "Effects/EffectFactory.hpp"
 
36
#include "MachineBase/GeneralOperations.hpp"
36
37
#include "MachineBase/RLMachine.hpp"
37
38
#include "MachineBase/RLOperation.hpp"
38
39
#include "MachineBase/RLOperation/Argc_T.hpp"
41
42
#include "Modules/Module_Grp.hpp"
42
43
#include "Systems/Base/Colour.hpp"
43
44
#include "Systems/Base/GraphicsSystem.hpp"
 
45
#include "Systems/Base/HIKRenderer.hpp"
44
46
#include "Systems/Base/HIKScript.hpp"
45
47
#include "Systems/Base/Surface.hpp"
46
48
#include "Systems/Base/System.hpp"
64
66
  void operator()(RLMachine& machine, int sel) {
65
67
    GraphicsSystem& graphics = machine.system().graphics();
66
68
    graphics.setDefaultBgrName("");
67
 
    graphics.setHikScript(NULL);
 
69
    graphics.setHikRenderer(NULL);
68
70
    graphics.setGraphicsBackground(BACKGROUND_HIK);
69
71
 
70
72
    boost::shared_ptr<Surface> before = graphics.renderToSurface();
92
94
    graphics.clearStack();
93
95
 
94
96
    fs::path path = system.findFile(filename, HIK_FILETYPES);
95
 
    if (path.empty()) {
96
 
      ostringstream oss;
97
 
      oss << "Could not find background file: " << filename;
98
 
      throw rlvm::Exception(oss.str());
99
 
    } else if (iends_with(path.string(), "hik")) {
 
97
    if (iends_with(path.string(), "hik")) {
100
98
      if (!machine.replaying_graphics_stack())
101
99
        graphics.clearAndPromoteObjects();
102
100
 
103
 
      graphics.setHikScript(new HIKScript(system, path));
 
101
      graphics.setHikRenderer(new HIKRenderer(
 
102
          system,
 
103
          graphics.GetHIKScript(system, filename, path)));
104
104
    } else {
105
105
      boost::shared_ptr<Surface> before = graphics.renderToSurface();
106
 
      boost::shared_ptr<Surface> source(
107
 
          graphics.loadSurfaceFromFile(machine, filename));
108
 
      boost::shared_ptr<Surface> haikei = graphics.getHaikei();
109
 
      source->blitToSurface(*haikei,
110
 
                            source->rect(),
111
 
                            source->rect(),
112
 
                            255, true);
 
106
 
 
107
      if (!path.empty()) {
 
108
        boost::shared_ptr<const Surface> source(
 
109
            graphics.getSurfaceNamedAndMarkViewed(machine, filename));
 
110
        boost::shared_ptr<Surface> haikei = graphics.getHaikei();
 
111
        source->blitToSurface(*haikei,
 
112
                              source->rect(),
 
113
                              source->rect(),
 
114
                              255, true);
 
115
      }
113
116
 
114
117
      // Promote the objects if we're in normal mode. If we're restoring the
115
118
      // graphics stack, we already have our layers promoted.
150
153
 
151
154
typedef Argc_T<
152
155
  Special_T<
 
156
    DefaultSpecialMapper,
153
157
    // 0:copy(strC 'filename')
154
158
    StrConstant_T,
155
159
    // 1:DUMMY. Unknown.
179
183
      filename = graphics.defaultBgrName();
180
184
 
181
185
    // Load "filename" as the background.
182
 
    shared_ptr<Surface> surface(
183
 
        graphics.loadSurfaceFromFile(machine, filename));
 
186
    shared_ptr<const Surface> surface(
 
187
        graphics.getSurfaceNamedAndMarkViewed(machine, filename));
184
188
    surface->blitToSurface(*graphics.getHaikei(),
185
189
                           surface->rect(), surface->rect(),
186
190
                           255, true);
191
195
      switch (it->type) {
192
196
        case 0: {
193
197
          // 0:copy(strC 'filename')
194
 
          surface = graphics.loadSurfaceFromFile(machine, it->first);
 
198
          surface = graphics.getSurfaceNamedAndMarkViewed(machine, it->first);
195
199
          surface->blitToSurface(*graphics.getHaikei(),
196
200
                                 surface->rect(), surface->rect(),
197
201
                                 255, true);
203
207
          Point dest;
204
208
          getSELPointAndRect(machine, it->third.get<1>(), srcRect, dest);
205
209
 
206
 
          surface = graphics.loadSurfaceFromFile(machine, it->third.get<0>());
 
210
          surface = graphics.getSurfaceNamedAndMarkViewed(machine, it->third.get<0>());
207
211
          Rect destRect = Rect(dest, srcRect.size());
208
212
          surface->blitToSurface(*graphics.getHaikei(), srcRect, destRect,
209
213
                                 255, true);
230
234
  }
231
235
};
232
236
 
 
237
struct bgrNext : public RLOp_Void_Void {
 
238
  void operator()(RLMachine& machine) {
 
239
    HIKRenderer* renderer = machine.system().graphics().getHikRenderer();
 
240
    if (renderer) {
 
241
      renderer->NextAnimationFrame();
 
242
    }
 
243
  }
 
244
};
 
245
 
233
246
struct bgrSetXOffset : public RLOp_Void_1< IntConstant_T > {
234
247
  void operator()(RLMachine& machine, int offset) {
235
 
    HIKScript* script = machine.system().graphics().getHikScript();
236
 
    if (script) {
237
 
      script->set_x_offset(offset);
 
248
    HIKRenderer* renderer = machine.system().graphics().getHikRenderer();
 
249
    if (renderer) {
 
250
      renderer->set_x_offset(offset);
238
251
    }
239
252
  }
240
253
};
241
254
 
242
255
struct bgrSetYOffset : public RLOp_Void_1< IntConstant_T > {
243
256
  void operator()(RLMachine& machine, int offset) {
244
 
    HIKScript* script = machine.system().graphics().getHikScript();
245
 
    if (script) {
246
 
      script->set_y_offset(offset);
 
257
    HIKRenderer* renderer = machine.system().graphics().getHikRenderer();
 
258
    if (renderer) {
 
259
      renderer->set_y_offset(offset);
 
260
    }
 
261
  }
 
262
};
 
263
 
 
264
struct bgrPreloadScript : public RLOp_Void_2<IntConstant_T, StrConstant_T> {
 
265
  void operator()(RLMachine& machine, int slot, string name) {
 
266
    System& system = machine.system();
 
267
    fs::path path = system.findFile(name, HIK_FILETYPES);
 
268
    if (iends_with(path.string(), "hik")) {
 
269
      system.graphics().PreloadHIKScript(system, slot, name, path);
247
270
    }
248
271
  }
249
272
};
262
285
  addUnsupportedOpcode(100, 0, "bgrMulti");
263
286
  addOpcode(100, 1, "bgrMulti", new bgrMulti_1);
264
287
 
 
288
  addOpcode(1000, 0, "bgrNext", new bgrNext);
 
289
 
265
290
  addOpcode(1104, 0, "bgrSetXOffset", new bgrSetXOffset);
266
291
  addOpcode(1105, 0, "bgrSetYOffset", new bgrSetYOffset);
 
292
 
 
293
  addOpcode(2000, 0, "bgrPreloadScript", new bgrPreloadScript);
 
294
  addOpcode(2001, 0, "bgrClearPreloadedScript",
 
295
            callFunction(&GraphicsSystem::ClearPreloadedHIKScript));
 
296
  addOpcode(2002, 0, "bgrClearAllPreloadedScripts",
 
297
            callFunction(&GraphicsSystem::ClearAllPreloadedHIKScripts));
267
298
}