1 // -*- Mode: C++; tab-width:2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 // vi:tw=80:et:ts=2:sts=2
3 //
4 // -----------------------------------------------------------------------
5 //
6 // This file is part of RLVM, a RealLive virtual machine clone.
7 //
8 // -----------------------------------------------------------------------
9 //
10 // Copyright (C) 2009 Elliot Glaysher
11 //
12 // This program is free software; you can redistribute it and/or modify
13 // it under the terms of the GNU General Public License as published by
14 // the Free Software Foundation; either version 3 of the License, or
15 // (at your option) any later version.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20 // GNU General Public License for more details.
21 //
22 // You should have received a copy of the GNU General Public License
23 // along with this program; if not, write to the Free Software
24 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
25 // -----------------------------------------------------------------------
26 
27 #include "machine/game_hacks.h"
28 
29 #include <functional>
30 #include <string>
31 
32 #include "libreallive/gameexe.h"
33 #include "machine/rlmachine.h"
34 #include "systems/base/graphics_system.h"
35 #include "systems/base/system.h"
36 
37 using std::bind;
38 using std::ref;
39 
40 namespace {
41 
PBRIDE_ResetAutoMode(RLMachine & machine)42 void PBRIDE_ResetAutoMode(RLMachine& machine) {
43   // During the first ending credits, if you click to skip them, the draw mode
44   // doesn't automatically get reset to DrawAuto. RealLive.exe takes care of
45   // this (draw mode on the stack, perhaps?), but until we know what causes
46   // this, hack.
47   machine.system().graphics().SetScreenUpdateMode(
48       GraphicsSystem::SCREENUPDATEMODE_AUTOMATIC);
49 }
50 
LB_SkipBaseball(RLMachine & machine)51 void LB_SkipBaseball(RLMachine& machine) {
52   // Baseball is a weird minigame that requires talking to a DLL. :( We will
53   // *never* emulate it properly without reverse engineering what the DLL does.
54   machine.ReturnFromFarcall();
55 }
56 
57 }  // namespace
58 
AddGameHacks(RLMachine & machine)59 void AddGameHacks(RLMachine& machine) {
60   std::string diskmark = machine.system().gameexe()("DISKMARK");
61 
62   if (diskmark == "P_BRIDE_SE.ENV") {
63     machine.AddLineAction(310, 446, bind(PBRIDE_ResetAutoMode, ref(machine)));
64   } else if (diskmark == "LB.ENV" || diskmark == "LB_EX.ENV") {
65     machine.AddLineAction(7030, 15, bind(LB_SkipBaseball, ref(machine)));
66   }
67 }
68