annotate tools/ppl.c @ 1556:8f06c23e197d last_SDL1

Cosmetics.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 13 May 2018 05:59:42 +0300
parents 813244726b32
children 5e5f75b45f8d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
216
247b03797fc9 Rename player, add a copyright note.
Matti Hamalainen <ccr@tnsp.org>
parents: 203
diff changeset
1 /*
247b03797fc9 Rename player, add a copyright note.
Matti Hamalainen <ccr@tnsp.org>
parents: 203
diff changeset
2 * Cyrbe Pasci Player - A simple SDL-based UI for XM module playing
247b03797fc9 Rename player, add a copyright note.
Matti Hamalainen <ccr@tnsp.org>
parents: 203
diff changeset
3 * Programmed and designed by Matti 'ccr' Hamalainen
1096
96e0798f602b Bump copyright year.
Matti Hamalainen <ccr@tnsp.org>
parents: 958
diff changeset
4 * (C) Copyright 2012-2015 Tecnic Software productions (TNSP)
216
247b03797fc9 Rename player, add a copyright note.
Matti Hamalainen <ccr@tnsp.org>
parents: 203
diff changeset
5 *
247b03797fc9 Rename player, add a copyright note.
Matti Hamalainen <ccr@tnsp.org>
parents: 203
diff changeset
6 * Please read file 'COPYING' for information on license and distribution.
247b03797fc9 Rename player, add a copyright note.
Matti Hamalainen <ccr@tnsp.org>
parents: 203
diff changeset
7 */
643
ad738873083e Add SDL.h #include to ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
8 #include "dmlib.h"
1327
59e9ad13b50e Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 1323
diff changeset
9 #include "libgutil.h"
643
ad738873083e Add SDL.h #include to ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
10
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 #include "jss.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12 #include "jssmod.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 #include "jssmix.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14 #include "jssplr.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 #include "dmargs.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 #include "dmimage.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 #include "dmtext.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19
584
923d920a8a85 Build setupfont.h and setupimage.h from source data files. Use setupfont in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 559
diff changeset
20 #include "setupfont.h"
164
a49d431ff40e Add a hardcoded font to PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
21
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 struct
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25 BOOL exitFlag;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26 SDL_Surface *screen;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 SDL_Event event;
1556
8f06c23e197d Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1555
diff changeset
28
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 int optScrWidth, optScrHeight, optVFlags, optScrDepth;
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
30
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
31 int actChannel;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
32 BOOL pauseFlag;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
33
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
34 JSSModule *mod;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
35 JSSMixer *dev;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
36 JSSPlayer *plr;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
37 SDL_AudioSpec afmt;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38 } engine;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 struct
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 {
1555
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
42 Uint32
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
43 boxBg, inboxBg,
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
44 box1, box2,
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
45 viewDiv,
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
46 activeRow, activeChannel,
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
47 scope, muted, black, red;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48 } col;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 DMBitmapFont *font = NULL;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52
273
3b5493fac928 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
53 char *optFilename = NULL;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 int optOutFormat = JSS_AUDIO_S16,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55 optOutChannels = 2,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56 optOutFreq = 48000,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 optMuteOChannels = -1,
179
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
58 optStartOrder = 0;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 BOOL optUsePlayTime = FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60 size_t optPlayTime;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
62
860
daebbf28953d The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 809
diff changeset
63 static const DMOptArg optList[] =
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
65 { 0, '?', "help", "Show this help", OPT_NONE },
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
66 { 1, 'v', "verbose", "Be more verbose", OPT_NONE },
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67 { 2, 0, "fs", "Fullscreen", OPT_NONE },
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 { 3, 'w', "window", "Initial window size/resolution -w 640x480", OPT_ARGREQ },
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
69
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 { 4, '1', "16bit", "16-bit output", OPT_NONE },
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 { 5, '8', "8bit", "8-bit output", OPT_NONE },
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 { 6, 'm', "mono", "Mono output", OPT_NONE },
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 { 7, 's', "stereo", "Stereo output", OPT_NONE },
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 { 8, 'f', "freq", "Output frequency", OPT_ARGREQ },
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
76 { 9, 'M', "mute", "Mute other channels than #", OPT_ARGREQ },
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 { 10, 'o', "order", "Start from order #", OPT_ARGREQ },
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 { 11, 't', "time", "Play for # seconds", OPT_ARGREQ },
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
79 };
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 const int optListN = sizeof(optList) / sizeof(optList[0]);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 void argShowHelp()
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 dmPrintBanner(stdout, dmProgName, "[options] <module>");
860
daebbf28953d The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 809
diff changeset
87 dmArgsPrintHelp(stdout, optList, optListN, 0);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 BOOL argHandleOpt(const int optN, char *optArg, char *currArg)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
92 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93 switch (optN) {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 case 0:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 argShowHelp();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 exit(0);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 case 1:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100 dmVerbosity++;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 break;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
102
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 case 2:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 engine.optVFlags |= SDL_FULLSCREEN;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 case 3:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 int w, h;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 if (sscanf(optArg, "%dx%d", &w, &h) == 2)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 if (w < 320 || h < 200 || w > 3200 || h > 3200)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
114 dmErrorMsg("Invalid width or height: %d x %d\n", w, h);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 engine.optScrWidth = w;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 engine.optScrHeight = h;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
120 else
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
122 dmErrorMsg("Invalid size argument '%s'.\n", optArg);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 case 4:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 optOutFormat = JSS_AUDIO_S16;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 case 5:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 optOutFormat = JSS_AUDIO_U8;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 case 6:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 optOutChannels = JSS_AUDIO_MONO;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 case 7:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 optOutChannels = JSS_AUDIO_STEREO;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 case 8:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 optOutFreq = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 case 9:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 optMuteOChannels = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 case 10:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 optStartOrder = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 case 11:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 optPlayTime = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 optUsePlayTime = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 default:
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
162 dmErrorMsg("Unknown option '%s'.\n", currArg);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
165
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 return TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170 BOOL argHandleFile(char *currArg)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 if (!optFilename)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173 optFilename = currArg;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
176 dmErrorMsg("Too many filename arguments '%s'\n", currArg);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
178 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
179
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
180 return TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
181 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
182
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
183
1327
59e9ad13b50e Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 1323
diff changeset
184 static inline Uint32 dmCol(const float r, const float g, const float b)
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
185 {
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
186 return dmMapRGB(engine.screen, 255.0f * r, 255.0f * g, 255.0f * b);
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
187 }
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
188
130
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
189
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
190 BOOL dmInitializeVideo()
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 {
179
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
192 SDL_FreeSurface(engine.screen);
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
193
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 engine.screen = SDL_SetVideoMode(
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 engine.optScrWidth, engine.optScrHeight, engine.optScrDepth,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196 engine.optVFlags | SDL_RESIZABLE | SDL_SWSURFACE | SDL_HWPALETTE);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 if (engine.screen == NULL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
200 dmErrorMsg("Can't SDL_SetVideoMode(): %s\n", SDL_GetError());
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
202 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203
1555
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
204 col.black = dmCol(0 , 0 , 0);
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
205 col.inboxBg = dmCol(0.6, 0.5, 0.2);
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
206 col.boxBg = dmCol(0.7, 0.6, 0.3);
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
207 col.box1 = dmCol(1.0, 0.9, 0.6);
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
208 col.box2 = dmCol(0.3, 0.3, 0.15);
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
209 col.viewDiv = dmCol(0 , 0 , 0);
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
210 col.activeRow = dmCol(0.5, 0.4, 0.1);
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
211 col.activeChannel = dmCol(0.6, 0.8, 0.2);
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
212 col.muted = dmCol(0.3, 0.1, 0.1);
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
213 col.scope = dmCol(0 , 0.8, 0);
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
214 col.red = dmCol(1 , 0 , 0);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
215
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
216 return TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
217 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219
1327
59e9ad13b50e Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 1323
diff changeset
220 //
59e9ad13b50e Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 1323
diff changeset
221 // XXX TODO: To display actual continuous sample data for channel,
59e9ad13b50e Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 1323
diff changeset
222 // we would need to have separate "FIFO" buffers for each, updating
59e9ad13b50e Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 1323
diff changeset
223 // them with new data from incoming channel data.
59e9ad13b50e Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 1323
diff changeset
224 //
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
225 void dmDisplayChn(SDL_Surface *screen, int x0, int y0, int x1, int y1, int nchannel, JSSChannel *chn)
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
226 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
227 int yh = y1 - y0 - 2;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
228 if (yh < 10 || chn == NULL)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
229 return;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
230
809
eba3b87f3f84 Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents: 797
diff changeset
231 int xc, ym = y0 + (y1 - y0) / 2, vol = FP_GETH32(chn->chVolume);
1556
8f06c23e197d Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1555
diff changeset
232 DMFixedPoint offs = chn->chPos;
809
eba3b87f3f84 Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents: 797
diff changeset
233 int len = FP_GETH32(chn->chSize);
1556
8f06c23e197d Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1555
diff changeset
234 Uint32 pitch = screen->pitch / sizeof(Uint32);
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
235 Uint32 *pix = screen->pixels;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
236 Sint16 *data = chn->chData;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
237
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
238 dmFillBox3D(screen, x0, y0, x1, y1,
1555
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
239 (chn->chMute ? col.muted : col.black),
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
240 nchannel == engine.actChannel ? col.red : col.box2,
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
241 nchannel == engine.actChannel ? col.red : col.box1);
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
242
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
243 if (chn->chData == NULL || !chn->chPlaying)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
244 return;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
245
274
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
246 if (chn->chDirection)
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
247 {
274
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
248 for (xc = x0 + 1; xc < x1 - 1; xc++)
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
249 {
809
eba3b87f3f84 Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents: 797
diff changeset
250 if (FP_GETH32(offs) >= len)
274
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
251 break;
809
eba3b87f3f84 Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents: 797
diff changeset
252 Sint16 val = ym + (data[FP_GETH32(offs)] * yh * vol) / (65535 * 255);
1555
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
253 pix[xc + val * pitch] = col.scope;
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
254 FP_ADD(offs, chn->chDeltaO);
274
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
255 }
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
256 }
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
257 else
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
258 {
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
259 for (xc = x0 + 1; xc < x1 - 1; xc++)
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
260 {
809
eba3b87f3f84 Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents: 797
diff changeset
261 if (FP_GETH32(offs) < 0)
274
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
262 break;
809
eba3b87f3f84 Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents: 797
diff changeset
263 Sint16 val = ym + (data[FP_GETH32(offs)] * yh * vol) / (65535 * 255);
1555
813244726b32 Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents: 1409
diff changeset
264 pix[xc + val * pitch] = col.scope;
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
265 FP_SUB(offs, chn->chDeltaO);
274
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
266 }
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
267 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
268 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
269
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
270
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
271 void dmDisplayChannels(SDL_Surface *screen, int x0, int y0, int x1, int y1, JSSMixer *dev)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
272 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
273 int nchannel, qx, qy,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
274 qwidth = x1 - x0,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
275 qheight = y1 - y0,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
276 nwidth = jsetNChannels,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
277 nheight = 1;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
278
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
279 if (qheight < 40)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
280 return;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
281
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
282 while (qwidth / nwidth <= 60 && qheight / nheight >= 40)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
283 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
284 nheight++;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
285 nwidth /= nheight;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
286 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
287
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
288 // fprintf(stderr, "%d x %d\n", nwidth, nheight);
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
289
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
290 if (qheight / nheight <= 40)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
291 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
292 nwidth = qwidth / 60;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
293 nheight = qheight / 40;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
294 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
295
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
296 qwidth /= nwidth;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
297 qheight /= nheight;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
298
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
299 for (nchannel = qy = 0; qy < nheight && nchannel < jsetNChannels; qy++)
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
300 {
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
301 for (qx = 0; qx < nwidth && nchannel < jsetNChannels; qx++)
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
302 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
303 int xc = x0 + qx * qwidth,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
304 yc = y0 + qy * qheight;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
305
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
306 dmDisplayChn(screen, xc + 1, yc + 1,
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
307 xc + qwidth - 1, yc + qheight - 1,
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
308 nchannel, &dev->channels[nchannel]);
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
309
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
310 nchannel++;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
311 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
312 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
313 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
314
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
315
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316 static const char patNoteTable[12][3] =
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
318 "C-", "C#", "D-",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319 "D#", "E-", "F-",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
320 "F#", "G-", "G#",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321 "A-", "A#", "B-"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322 };
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
324
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325 #define jmpNMODEffectTable (36)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326 static const char jmpMODEffectTable[jmpNMODEffectTable] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
328 static const char jmpHexTab[16] = "0123456789ABCDEF";
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
329
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
330 static inline char dmHexVal(int v)
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
331 {
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
332 return jmpHexTab[v & 15];
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
333 }
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
334
1327
59e9ad13b50e Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 1323
diff changeset
335
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336 void dmPrintNote(SDL_Surface *screen, int xc, int yc, JSSNote *n)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338 char text[32];
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 char *ptr = text;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
340
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341 switch (n->note)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 case jsetNotSet:
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
344 strcpy(ptr, "..._");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
346 case jsetNoteOff:
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
347 strcpy(ptr, "===_");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 default:
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
350 sprintf(ptr, "%s%i_",
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351 patNoteTable[n->note % 12],
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352 n->note / 12);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 ptr += 4;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358 if (n->instrument != jsetNotSet)
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
359 {
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
360 int v = n->instrument + 1;
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
361 *ptr++ = dmHexVal(v >> 4);
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
362 *ptr++ = dmHexVal(v);
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
363 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364 else
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
365 {
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
366 *ptr++ = '.';
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
367 *ptr++ = '.';
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
368 }
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
369 *ptr++ = '_';
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
371 if (n->volume == jsetNotSet)
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
372 {
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
373 *ptr++ = '.';
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
374 *ptr++ = '.';
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
375 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 if (n->volume >= 0x00 && n->volume <= 0x40)
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
378 {
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
379 *ptr++ = dmHexVal(n->volume >> 4);
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
380 *ptr++ = dmHexVal(n->volume);
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
381 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384 char c;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
385 switch (n->volume & 0xf0)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
386 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387 case 0x50: c = '-'; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
388 case 0x60: c = '+'; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389 case 0x70: c = '/'; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390 case 0x80: c = '\\'; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391 case 0x90: c = 'S'; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392 case 0xa0: c = 'V'; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 case 0xb0: c = 'P'; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
394 case 0xc0: c = '<'; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 case 0xd0: c = '>'; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
396 case 0xe0: c = 'M'; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397 default: c = '?'; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398 }
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
399 *ptr++ = c;
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
400 *ptr++ = dmHexVal(n->volume);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401 }
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
402 *ptr++ = '_';
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
403
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
404 if (n->effect >= 0 && n->effect < jmpNMODEffectTable)
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
405 *ptr++ = jmpMODEffectTable[n->effect];
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
406 else
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
407 *ptr++ = (n->effect == jsetNotSet ? '.' : '?');
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
408
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
409 if (n->param != jsetNotSet)
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
410 {
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
411 *ptr++ = dmHexVal(n->param >> 4);
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
412 *ptr++ = dmHexVal(n->param);
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
413 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
414 else
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
415 {
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
416 *ptr++ = '.';
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
417 *ptr++ = '.';
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
418 }
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
419
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
420 *ptr = 0;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
421
130
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
422 dmDrawBMTextConstQ(screen, font, DMD_TRANSPARENT, xc, yc, text);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
423 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
424
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
425
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
426 void dmDisplayPattern(SDL_Surface *screen, int x0, int y0, int x1, int y1, JSSPattern *pat, int row)
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
427 {
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
428 int cwidth = (font->width * 10 + 3 * 4 + 5),
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
429 lwidth = 6 + font->width * 3,
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
430 qy0 = y0 + font->height + 2,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
431 qy1 = y1 - font->height - 2,
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
432 qwidth = ((x1 - x0 - lwidth) / cwidth),
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
433 qheight = ((qy1 - qy0 - 4) / (font->height + 1)),
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
434 nrow, nchannel, yc, choffs,
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
435 midrow = qheight / 2;
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
436
1258
13c274d22a29 Add some extra error checking.
Matti Hamalainen <ccr@tnsp.org>
parents: 1238
diff changeset
437 if (pat == NULL)
13c274d22a29 Add some extra error checking.
Matti Hamalainen <ccr@tnsp.org>
parents: 1238
diff changeset
438 return;
13c274d22a29 Add some extra error checking.
Matti Hamalainen <ccr@tnsp.org>
parents: 1238
diff changeset
439
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
440 if (engine.actChannel < qwidth / 2)
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
441 choffs = 0;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
442 else
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
443 if (engine.actChannel >= pat->nchannels - qwidth/2)
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
444 choffs = pat->nchannels - qwidth;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
445 else
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
446 choffs = engine.actChannel - qwidth/2;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
447
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
448 dmDrawBox3D(screen, x0 + lwidth, qy0, x1, qy1, col.box2, col.box1);
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
449
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
450 for (nchannel = 0; nchannel < qwidth; nchannel++)
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
451 {
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
452 int bx0 = x0 + lwidth + 1 + nchannel * cwidth,
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
453 bx1 = bx0 + cwidth;
1098
441a1ca43b02 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1096
diff changeset
454
441a1ca43b02 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1096
diff changeset
455 dmFillRect(screen, bx0+1, qy0+1, bx1-1, qy1-1,
441a1ca43b02 Cleanup.
Matti Hamalainen <ccr@tnsp.org>
parents: 1096
diff changeset
456 (engine.actChannel == nchannel + choffs) ? col.activeChannel : col.inboxBg);
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
457 }
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
458
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
459 yc = qy0 + 2 + (font->height + 1) * midrow;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
460 dmFillRect(screen, x0 + lwidth + 1, yc - 1, x1 - 1, yc + font->height, col.activeRow);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
461
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
462 for (nchannel = 0; nchannel < qwidth; nchannel++)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
463 {
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
464 int bx0 = x0 + lwidth + 1 + nchannel * cwidth,
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
465 bx1 = bx0 + cwidth;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
466
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
467 dmDrawVLine(screen, qy0 + 1, qy1 - 1, bx1, col.viewDiv);
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
468
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
469 if (jvmGetMute(engine.dev, nchannel + choffs))
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
470 {
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
471 dmDrawBMTextConstQ(screen, font, DMD_TRANSPARENT,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
472 bx0 + (cwidth - font->width * 5) / 2, qy1 + 3, "MUTED");
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
473 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
474
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
475 dmDrawBMTextQ(screen, font, DMD_TRANSPARENT,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
476 bx0 + (cwidth - font->width * 3) / 2, y0 + 1, "%3d",
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
477 nchannel + choffs);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
478 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
479
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
480 for (nrow = 0; nrow < qheight; nrow++)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
481 {
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
482 int crow = nrow - midrow + row;
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
483 yc = qy0 + 2 + (font->height + 1) * nrow;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
484
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
485 if (crow >= 0 && crow < pat->nrows)
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
486 {
130
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
487 dmDrawBMTextQ(screen, font, DMD_TRANSPARENT, x0, yc, "%03d", crow);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
488
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
489 for (nchannel = 0; nchannel < qwidth; nchannel++)
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
490 {
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
491 if (choffs + nchannel >= pat->nchannels)
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
492 break;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
493
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
494 dmPrintNote(screen, x0 + lwidth + 4 + nchannel * cwidth, yc,
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
495 pat->data + (pat->nchannels * crow) + choffs + nchannel);
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
496 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
497 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
498 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
499 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
500
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
501
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
502 void audioCallback(void *userdata, Uint8 *stream, int len)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
503 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
504 JSSMixer *d = (JSSMixer *) userdata;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
505
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
506 if (d != NULL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
507 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
508 jvmRenderAudio(d, stream, len / jvmGetSampleSize(d));
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
509 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
510 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
511
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
512
203
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
513 void dmMuteChannels(BOOL mute)
198
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
514 {
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
515 int i;
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
516 for (i = 0; i < engine.mod->nchannels; i++)
203
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
517 jvmMute(engine.dev, i, mute);
198
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
518 }
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
519
1327
59e9ad13b50e Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents: 1323
diff changeset
520
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
521 int main(int argc, char *argv[])
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
522 {
290
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
523 BOOL initSDL = FALSE, audioInit = FALSE;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
524 DMResource *file = NULL;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
525 int result = -1;
203
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
526 BOOL muteState = FALSE;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
527
1167
848a88ce7a57 Use dmMemset().
Matti Hamalainen <ccr@tnsp.org>
parents: 1098
diff changeset
528 dmMemset(&engine, 0, sizeof(engine));
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
529
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
530 engine.optScrWidth = 640;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
531 engine.optScrHeight = 480;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
532 engine.optScrDepth = 32;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
533
216
247b03797fc9 Rename player, add a copyright note.
Matti Hamalainen <ccr@tnsp.org>
parents: 203
diff changeset
534 dmInitProg("CBP", "Cyrbe Basci Player", "0.1", NULL, NULL);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
535
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
536 // Parse arguments
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
537 if (!dmArgsProcess(argc, argv, optList, optListN,
860
daebbf28953d The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents: 809
diff changeset
538 argHandleOpt, argHandleFile, OPTH_BAILOUT))
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
539 exit(1);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
540
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
541 // Open the files
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
542 if (optFilename == NULL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
543 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
544 dmErrorMsg("No filename specified.\n");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
545 return 1;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
546 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
547
730
3d813c81f33c More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents: 652
diff changeset
548 if ((result = dmf_create_stdio(optFilename, "rb", &file)) != DMERR_OK)
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
549 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
550 dmErrorMsg("Error opening file '%s', %d: (%s)\n",
730
3d813c81f33c More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents: 652
diff changeset
551 optFilename, result, dmErrorStr(result));
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
552 return 1;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
553 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
554
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
555 // Initialize miniJSS
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
556 jssInit();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
557
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
558 // Read module file
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
559 dmMsg(1, "Reading file: %s\n", optFilename);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
560 #ifdef JSS_SUP_XM
797
f066e9dccf29 Oops, fix some inverted booleans.
Matti Hamalainen <ccr@tnsp.org>
parents: 796
diff changeset
561 result = jssLoadXM(file, &engine.mod, TRUE);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
562 #endif
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
563 #ifdef JSS_SUP_JSSMOD
1199
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 1167
diff changeset
564 dmfreset(file);
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 1167
diff changeset
565 if (result != DMERR_OK)
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
566 {
777
ed60a7ee3ebb Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents: 745
diff changeset
567 dmMsg(1, "* Trying JSSMOD ...\n");
797
f066e9dccf29 Oops, fix some inverted booleans.
Matti Hamalainen <ccr@tnsp.org>
parents: 796
diff changeset
568 result = jssLoadJSSMOD(file, &engine.mod, TRUE);
1199
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 1167
diff changeset
569 dmfreset(file);
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 1167
diff changeset
570 if (result == DMERR_OK)
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 1167
diff changeset
571 result = jssLoadJSSMOD(file, &engine.mod, FALSE);
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 1167
diff changeset
572 }
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 1167
diff changeset
573 else
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 1167
diff changeset
574 {
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 1167
diff changeset
575 dmMsg(2, "* Trying XM...\n");
a79edf59d5d8 Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 1167
diff changeset
576 result = jssLoadXM(file, &engine.mod, FALSE);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
577 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
578 #endif
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
579 dmf_close(file);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
580
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
581 if (result != DMERR_OK)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
582 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
583 dmErrorMsg("Error loading module file, %d: %s\n",
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
584 result, dmErrorStr(result));
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
585 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
586 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
587
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
588 // Try to convert it
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
589 if ((result = jssConvertModuleForPlaying(engine.mod)) != DMERR_OK)
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
590 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
591 dmErrorMsg("Could not convert module for playing, %d: %s\n",
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
592 result, dmErrorStr(result));
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
593 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
594 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
595
164
a49d431ff40e Add a hardcoded font to PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
596 // Get font
730
3d813c81f33c More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents: 652
diff changeset
597 result = dmf_create_memio(NULL, "pplfont.fnt", engineSetupFont, sizeof(engineSetupFont), &file);
3d813c81f33c More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents: 652
diff changeset
598 if (result != DMERR_OK)
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
599 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
600 dmErrorMsg("Error opening font file 'pplfont.fnt', #%d: %s\n",
730
3d813c81f33c More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents: 652
diff changeset
601 result, dmErrorStr(result));
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
602 goto error_exit;
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
603 }
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
604 result = dmLoadBitmapFont(file, &font);
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
605 dmf_close(file);
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
606 if (result != DMERR_OK)
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
607 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
608 dmErrorMsg("Could not load font from file, %d: %s\n",
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
609 result, dmErrorStr(result));
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
610 goto error_exit;
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
611 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
612
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
613 // Initialize SDL components
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
614 if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER) != 0)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
615 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
616 dmErrorMsg("Could not initialize SDL: %s\n", SDL_GetError());
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
617 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
618 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
619 initSDL = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
620
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
621
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
622 // Initialize mixing device
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
623 dmMsg(2, "Initializing miniJSS mixer with: %d, %d, %d\n",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
624 optOutFormat, optOutChannels, optOutFreq);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
625
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
626 engine.dev = jvmInit(optOutFormat, optOutChannels, optOutFreq, JMIX_AUTO);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
627 if (engine.dev == NULL)
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
628 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
629 dmErrorMsg("jvmInit() returned NULL\n");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
630 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
631 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
632
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
633 switch (optOutFormat)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
634 {
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
635 case JSS_AUDIO_S16: engine.afmt.format = AUDIO_S16SYS; break;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
636 case JSS_AUDIO_U16: engine.afmt.format = AUDIO_U16SYS; break;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
637 case JSS_AUDIO_S8: engine.afmt.format = AUDIO_S8; break;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
638 case JSS_AUDIO_U8: engine.afmt.format = AUDIO_U8; break;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
639 default:
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
640 dmErrorMsg("Unsupported audio format %d (could not set matching SDL format)\n",
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
641 optOutFormat);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
642 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
643 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
644
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
645 engine.afmt.freq = optOutFreq;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
646 engine.afmt.channels = optOutChannels;
297
a991e4f0acfe Make audio buffer smaller, for now.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
647 engine.afmt.samples = optOutFreq / 16;
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
648 engine.afmt.callback = audioCallback;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
649 engine.afmt.userdata = (void *) engine.dev;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
650
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
651 // Open the audio device
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
652 if (SDL_OpenAudio(&engine.afmt, NULL) < 0)
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
653 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
654 dmErrorMsg("Couldn't open SDL audio: %s\n",
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
655 SDL_GetError());
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
656 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
657 }
290
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
658 audioInit = TRUE;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
659
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
660 // Initialize player
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
661 if ((engine.plr = jmpInit(engine.dev)) == NULL)
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
662 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
663 dmErrorMsg("jmpInit() returned NULL\n");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
664 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
665 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
666
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
667 jvmSetCallback(engine.dev, jmpExec, engine.plr);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
668 jmpSetModule(engine.plr, engine.mod);
179
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
669 jmpPlayOrder(engine.plr, optStartOrder);
1409
a515d42c04e7 Increase default mixer volume to 255.
Matti Hamalainen <ccr@tnsp.org>
parents: 1408
diff changeset
670 jvmSetGlobalVol(engine.dev, 255);
190
87b46e61f2c4 Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
671
87b46e61f2c4 Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
672 if (optMuteOChannels >= 0 && optMuteOChannels < engine.mod->nchannels)
87b46e61f2c4 Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
673 {
203
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
674 dmMuteChannels(TRUE);
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
675 jvmMute(engine.dev, optMuteOChannels, FALSE);
190
87b46e61f2c4 Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
676 engine.actChannel = optMuteOChannels;
203
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
677 muteState = TRUE;
190
87b46e61f2c4 Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
678 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
679
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
680 // Initialize video
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
681 if (!dmInitializeVideo())
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
682 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
683
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
684 SDL_WM_SetCaption(dmProgDesc, dmProgName);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
685
275
26d714c72c0f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 274
diff changeset
686 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
26d714c72c0f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 274
diff changeset
687
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
688 // okay, main loop here ... "play" module and print out info
275
26d714c72c0f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 274
diff changeset
689 SDL_LockAudio();
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
690 SDL_PauseAudio(0);
275
26d714c72c0f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 274
diff changeset
691 SDL_UnlockAudio();
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
692
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
693 int currTick, prevTick = 0, prevRow = -1;
276
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
694 while (!engine.exitFlag)
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
695 {
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
696 currTick = SDL_GetTicks();
296
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
697 BOOL force = (currTick - prevTick > 500), updated = FALSE;
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
698
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
699 while (SDL_PollEvent(&engine.event))
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
700 switch (engine.event.type)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
701 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
702 case SDL_KEYDOWN:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
703 switch (engine.event.key.keysym.sym)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
704 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
705 case SDLK_ESCAPE:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
706 engine.exitFlag = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
707 break;
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
708
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
709 case SDLK_SPACE:
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
710 engine.pauseFlag = !engine.pauseFlag;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
711 SDL_PauseAudio(engine.pauseFlag);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
712 break;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
713
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
714 case SDLK_LEFT:
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
715 if (engine.actChannel > 0)
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
716 {
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
717 engine.actChannel--;
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
718 force = TRUE;
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
719 }
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
720 break;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
721
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
722 case SDLK_RIGHT:
1338
2603f6ca632e Do not go past number of module channels with the active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 1327
diff changeset
723 if (engine.actChannel < engine.mod->nchannels - 1)
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
724 {
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
725 engine.actChannel++;
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
726 force = TRUE;
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
727 }
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
728 break;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
729
198
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
730 case SDLK_m:
203
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
731 if (engine.event.key.keysym.mod & KMOD_SHIFT)
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
732 {
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
733 muteState = !muteState;
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
734 dmMuteChannels(muteState);
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
735 }
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
736 else
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
737 if (engine.event.key.keysym.mod & KMOD_CTRL)
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
738 {
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
739 dmMuteChannels(FALSE);
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
740 }
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
741 else
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
742 {
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
743 jvmMute(engine.dev, engine.actChannel, !jvmGetMute(engine.dev, engine.actChannel));
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
744 }
198
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
745 force = TRUE;
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
746 break;
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
747
167
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
748 case SDLK_PAGEUP:
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
749 JSS_LOCK(engine.dev);
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
750 JSS_LOCK(engine.plr);
182
9024d249e47a Add a new function jmpChangeOrder() to change orderlist position "on fly",
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
751 jmpChangeOrder(engine.plr, dmClamp(engine.plr->order - 1, 0, engine.mod->norders));
167
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
752 JSS_UNLOCK(engine.plr);
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
753 JSS_UNLOCK(engine.dev);
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
754 force = TRUE;
167
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
755 break;
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
756
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
757 case SDLK_PAGEDOWN:
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
758 JSS_LOCK(engine.dev);
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
759 JSS_LOCK(engine.plr);
182
9024d249e47a Add a new function jmpChangeOrder() to change orderlist position "on fly",
Matti Hamalainen <ccr@tnsp.org>
parents: 179
diff changeset
760 jmpChangeOrder(engine.plr, dmClamp(engine.plr->order + 1, 0, engine.mod->norders));
167
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
761 JSS_UNLOCK(engine.plr);
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
762 JSS_UNLOCK(engine.dev);
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
763 force = TRUE;
167
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
764 break;
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
765
179
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
766 case SDLK_f:
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
767 engine.optVFlags ^= SDL_FULLSCREEN;
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
768 if (!dmInitializeVideo())
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
769 goto error_exit;
198
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
770 force = TRUE;
179
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
771 break;
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
772
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
773 default:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
774 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
775 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
776
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
777 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
778
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
779 case SDL_VIDEORESIZE:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
780 engine.optScrWidth = engine.event.resize.w;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
781 engine.optScrHeight = engine.event.resize.h;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
782
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
783 if (!dmInitializeVideo())
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
784 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
785
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
786 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
787
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
788 case SDL_VIDEOEXPOSE:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
789 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
790
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
791 case SDL_QUIT:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
792 engine.exitFlag = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
793 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
794 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
795
137
f721f9f7838a Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 130
diff changeset
796
f721f9f7838a Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 130
diff changeset
797 #if 1
276
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
798 JSS_LOCK(engine.plr);
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
799 JSSPattern *currPattern = engine.plr->pattern;
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
800 int currRow = engine.plr->row;
293
bc2e8ce003d7 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 290
diff changeset
801 if (!engine.plr->isPlaying)
bc2e8ce003d7 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 290
diff changeset
802 engine.exitFlag = TRUE;
276
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
803 JSS_UNLOCK(engine.plr);
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
804
276
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
805 if (currRow != prevRow || force)
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
806 {
296
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
807 prevRow = currRow;
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
808 force = TRUE;
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
809 }
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
810
296
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
811 // Draw frame
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
812 if (SDL_MUSTLOCK(engine.screen) != 0 && SDL_LockSurface(engine.screen) != 0)
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
813 {
958
985225a93aeb Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents: 860
diff changeset
814 dmErrorMsg("Can't lock surface.\n");
296
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
815 goto error_exit;
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
816 }
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
817
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
818 if (force)
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
819 {
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
820 dmClearSurface(engine.screen, col.boxBg);
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
821
1351
ae26c5926f10 Cleanup, update copyright.
Matti Hamalainen <ccr@tnsp.org>
parents: 1338
diff changeset
822 dmDrawBMTextQ(engine.screen, font, DMD_TRANSPARENT, 5, 5,
ae26c5926f10 Cleanup, update copyright.
Matti Hamalainen <ccr@tnsp.org>
parents: 1338
diff changeset
823 "%s v%s by ccr/TNSP - (c) Copyright 2012-2017 TNSP",
ae26c5926f10 Cleanup, update copyright.
Matti Hamalainen <ccr@tnsp.org>
parents: 1338
diff changeset
824 dmProgDesc, dmProgVersion);
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
825
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
826 dmDrawBMTextQ(engine.screen, font, DMD_TRANSPARENT, 5, 5 + 12 + 11,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
827 "Song: '%s'",
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
828 engine.mod->moduleName);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
829
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
830 dmDisplayPattern(engine.screen, 5, 40,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
831 engine.screen->w - 6, engine.screen->h * 0.8,
276
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
832 currPattern, currRow);
1238
e8c99da451cd Cosmetics.
Matti Hamalainen <ccr@tnsp.org>
parents: 1199
diff changeset
833
276
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
834 JSS_LOCK(engine.plr);
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
835 dmDrawBMTextQ(engine.screen, font, DMD_TRANSPARENT, 5, 5 + 12,
179
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
836 "Tempo: %3d | Speed: %3d | Row: %3d/%-3d | Order: %3d/%-3d | Pattern: %3d/%-3d",
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
837 engine.plr->tempo, engine.plr->speed,
1258
13c274d22a29 Add some extra error checking.
Matti Hamalainen <ccr@tnsp.org>
parents: 1238
diff changeset
838 engine.plr->row, (engine.plr->pattern != NULL) ? engine.plr->pattern->nrows : 0,
1408
2e1b2b87dada Add +1 to the displayed module order number.
Matti Hamalainen <ccr@tnsp.org>
parents: 1351
diff changeset
839 engine.plr->order + 1, engine.mod->norders,
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
840 engine.plr->npattern, engine.mod->npatterns);
276
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
841 JSS_UNLOCK(engine.plr);
296
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
842 updated = TRUE;
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
843 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
844
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
845 if (force || currTick - prevTick >= (engine.pauseFlag ? 100 : 20))
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
846 {
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
847 JSS_LOCK(engine.dev);
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
848 dmDisplayChannels(engine.screen, 5, engine.screen->h * 0.8 + 5,
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
849 engine.screen->w - 5, engine.screen->h - 5, engine.dev);
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
850 JSS_UNLOCK(engine.dev);
296
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
851 updated = TRUE;
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
852 }
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
853
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
854 if (force)
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
855 prevTick = currTick;
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
856
137
f721f9f7838a Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 130
diff changeset
857 #endif
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
858 // Flip screen
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
859 if (SDL_MUSTLOCK(engine.screen) != 0)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
860 SDL_UnlockSurface(engine.screen);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
861
296
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
862 if (updated)
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
863 SDL_Flip(engine.screen);
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
864
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
865 SDL_Delay(engine.pauseFlag ? 100 : 30);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
866 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
867
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
868 error_exit:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
869 if (engine.screen)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
870 SDL_FreeSurface(engine.screen);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
871
290
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
872 dmMsg(0, "Audio shutdown.\n");
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
873 if (audioInit)
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
874 {
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
875 SDL_LockAudio();
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
876 SDL_PauseAudio(1);
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
877 SDL_UnlockAudio();
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
878 SDL_CloseAudio();
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
879 }
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
880
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
881 jmpClose(engine.plr);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
882 jvmClose(engine.dev);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
883 jssFreeModule(engine.mod);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
884
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
885 dmFreeBitmapFont(font);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
886
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
887 if (initSDL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
888 SDL_Quit();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
889
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
890 jssClose();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
891
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
892 return 0;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
893 }