ScummVM API documentation
Display.h
1 /* Copyright (C) 2003, 2004, 2005, 2006, 2008, 2009 Dean Beeler, Jerome Fisher
2  * Copyright (C) 2011-2022 Dean Beeler, Jerome Fisher, Sergey V. Mikayev
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License as published by
6  * the Free Software Foundation, either version 2.1 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this program. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef MT32EMU_DISPLAY_H
19 #define MT32EMU_DISPLAY_H
20 
21 #include "globals.h"
22 #include "Types.h"
23 
24 namespace MT32Emu {
25 
26 class Synth;
27 
29 class Display {
30 public:
31  static const unsigned int LCD_TEXT_SIZE = 20;
32 
33  enum Mode {
34  Mode_MAIN, // a.k.a. Master Volume
35  Mode_STARTUP_MESSAGE,
36  Mode_PROGRAM_CHANGE,
37  Mode_CUSTOM_MESSAGE,
38  Mode_ERROR_MESSAGE
39  };
40 
41  Display(Synth &synth);
42  void checkDisplayStateUpdated(bool &midiMessageLEDState, bool &midiMessageLEDUpdated, bool &lcdUpdated);
44  bool getDisplayState(char *targetBuffer, bool narrowLCD);
45  void setMainDisplayMode();
46 
47  void midiMessagePlayed();
48  void rhythmNotePlayed();
49  void voicePartStateChanged(Bit8u partIndex, bool activated);
50  void masterVolumeChanged();
51  void programChanged(Bit8u partIndex);
52  void checksumErrorOccurred();
53  bool customDisplayMessageReceived(const Bit8u *message, Bit32u startIndex, Bit32u length);
54  void displayControlMessageReceived(const Bit8u *messageBytes, Bit32u length);
55 
56 private:
57  typedef Bit8u DisplayBuffer[LCD_TEXT_SIZE];
58 
59  static const unsigned int TIMBRE_NAME_SIZE = 10;
60 
61  Synth &synth;
62 
63  bool lastLEDState;
64  bool lcdDirty;
65  bool lcdUpdateSignalled;
66  bool lastRhythmPartState;
67  bool voicePartStates[8];
68 
69  Bit8u lastProgramChangePartIndex;
70  const char *lastProgramChangeSoundGroupName;
71  Bit8u lastProgramChangeTimbreName[TIMBRE_NAME_SIZE];
72 
73  Mode mode;
74  Bit32u displayResetTimestamp;
75  bool displayResetScheduled;
76  Bit32u midiMessageLEDResetTimestamp;
77  bool midiMessagePlayedSinceLastReset;
78  Bit32u rhythmStateResetTimestamp;
79  bool rhythmNotePlayedSinceLastReset;
80 
81  DisplayBuffer displayBuffer;
82  DisplayBuffer customMessageBuffer;
83 
84  void scheduleDisplayReset();
85  bool shouldResetTimer(Bit32u scheduledResetTimestamp);
86  void maybeResetTimer(bool &timerState, Bit32u scheduledResetTimestamp);
87 };
88 
89 } // namespace MT32Emu
90 
91 #endif // #ifndef MT32EMU_DISPLAY_H
Definition: Analog.h:26
bool getDisplayState(char *targetBuffer, bool narrowLCD)
Definition: Synth.h:131
Definition: Display.h:29