annotate tools/ppl.c @ 777:ed60a7ee3ebb

Change JSSMOD loader to use DMResources.
author Matti Hamalainen <ccr@tnsp.org>
date Fri, 24 May 2013 01:19:11 +0300
parents ab645f4cb8fa
children 97ecc0a9c21f
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
559
61af51348ea4 Fix copyright.
Matti Hamalainen <ccr@tnsp.org>
parents: 493
diff changeset
4 * (C) Copyright 2012 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 <SDL.h>
ad738873083e Add SDL.h #include to ppl.
Matti Hamalainen <ccr@tnsp.org>
parents: 584
diff changeset
9 #include "dmlib.h"
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;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28 int optScrWidth, optScrHeight, optVFlags, optScrDepth;
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
29
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
30 int actChannel;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
31 BOOL pauseFlag;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
32
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
33 JSSModule *mod;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
34 JSSMixer *dev;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
35 JSSPlayer *plr;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
36 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
37 } engine;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
38
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
39 struct
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 {
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
41 Uint32 boxBg, inboxBg, box1, box2, viewDiv, activeRow, activeChannel;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 } col;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 DMBitmapFont *font = NULL;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46
273
3b5493fac928 Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 216
diff changeset
47 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
48 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
49 optOutChannels = 2,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 optOutFreq = 48000,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 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
52 optStartOrder = 0;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 BOOL optUsePlayTime = FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
54 size_t optPlayTime;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
55
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
56
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 DMOptArg optList[] =
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
59 { 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
60 { 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
61 { 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
62 { 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
63
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
64 { 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
65 { 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
66 { 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
67 { 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
68 { 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
69
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 { 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
71 { 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
72 { 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
73 };
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
75 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
76
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 void argShowHelp()
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 dmPrintBanner(stdout, dmProgName, "[options] <module>");
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 dmArgsPrintHelp(stdout, optList, optListN);
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
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85 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
86 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 switch (optN) {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 case 0:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 argShowHelp();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 exit(0);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 break;
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 case 1:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 dmVerbosity++;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 case 2:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
98 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
99 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
100
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 case 3:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 int w, h;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 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
105 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 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
107 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 dmError("Invalid width or height: %d x %d\n", w, h);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 engine.optScrWidth = w;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 engine.optScrHeight = h;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 dmError("Invalid size argument '%s'.\n", optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
119 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 case 4:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 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
124 break;
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 case 5:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 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
128 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 case 6:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 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
132 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 case 7:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 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
136 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 case 8:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 optOutFreq = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142 case 9:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 optMuteOChannels = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 case 10:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 optStartOrder = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 case 11:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 optPlayTime = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152 optUsePlayTime = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
154
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
155 default:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156 dmError("Unknown option '%s'.\n", currArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 return TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
162
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
163
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
164 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
165 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 if (!optFilename)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 optFilename = currArg;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 else
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 dmError("Too many filename arguments '%s'\n", currArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
171 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
173
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 return TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
175 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177
130
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
178 void dmDrawBMTextConstQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt)
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
179 {
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
180 const char *ptr = fmt;
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
181 DMUnscaledBlitFunc blit = NULL;
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
182
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
183 while (*ptr)
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
184 {
745
ab645f4cb8fa Uppercase the strings in PPL for now.
Matti Hamalainen <ccr@tnsp.org>
parents: 730
diff changeset
185 int ch = toupper(*ptr++);
130
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
186 SDL_Surface *glyph;
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
187
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
188 if (ch == '_')
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
189 {
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
190 xc += 4;
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
191 continue;
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
192 }
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
193
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
194 if (ch >= 0 && ch < font->nglyphs && (glyph = font->glyphs[ch]) != NULL)
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
195 {
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
196 if (blit == NULL)
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
197 blit = dmGetUnscaledBlitFunc(glyph->format, screen->format, mode);
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
198
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
199 blit(glyph, xc, yc, screen);
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
200 xc += font->width;
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
201 }
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
202 else
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
203 xc += font->width;
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
204 }
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
205 }
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
206
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
207
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
208 void dmDrawBMTextVAQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, va_list ap)
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
209 {
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
210 char tmp[512];
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
211 vsnprintf(tmp, sizeof(tmp), fmt, ap);
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
212 dmDrawBMTextConstQ(screen, font, mode, xc, yc, tmp);
130
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
213 }
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
214
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
215
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
216 void dmDrawBMTextQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, ...)
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
217 {
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
218 va_list ap;
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
219
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
220 va_start(ap, fmt);
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
221 dmDrawBMTextVAQ(screen, font, mode, xc, yc, fmt, ap);
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
222 va_end(ap);
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
223 }
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
224
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
225
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
226 Uint32 dmCol(float r, float g, float b)
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
227 {
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
228 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
229 }
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
230
130
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
231
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 BOOL dmInitializeVideo()
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 {
179
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
234 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
235
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 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
237 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
238 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
239
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 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
241 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
242 dmError("Can't SDL_SetVideoMode(): %s\n", SDL_GetError());
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
243 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
244 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
245
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
246 col.inboxBg = dmCol(0.6, 0.5, 0.2);
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
247 col.boxBg = dmCol(0.7, 0.6, 0.3);
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
248 col.box1 = dmCol(1.0, 0.9, 0.6);
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
249 col.box2 = dmCol(0.3, 0.3, 0.15);
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
250 col.viewDiv = dmCol(0,0,0);
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
251 col.activeRow = dmCol(0.5,0.4,0.1);
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
252 col.activeChannel = dmCol(0.6, 0.8, 0.2);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
253
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254 return TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
258 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
259 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
260 int yh = y1 - y0 - 2;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
261 if (yh < 10 || chn == NULL)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
262 return;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
263
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
264 int xc, ym = y0 + (y1 - y0) / 2, vol = FP_GETH(chn->chVolume);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
265 int pitch = screen->pitch / sizeof(Uint32);
287
1e89cd081956 Use fixed point everywhere in the mixing internals, to avoid going over
Matti Hamalainen <ccr@tnsp.org>
parents: 276
diff changeset
266 int len = FP_GETH(chn->chSize);
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
267 DMFixedPoint offs = chn->chPos;
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
268 Uint32 coln = dmCol(0.0, 0.8, 0.0), colx = dmCol(1.0, 0, 0);
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
269 Uint32 *pix = screen->pixels;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
270 Sint16 *data = chn->chData;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
271
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 dmFillBox3D(screen, x0, y0, x1, y1,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
274 (chn->chMute ? dmCol(0.3,0.1,0.1) : dmCol(0,0,0)),
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
275 nchannel == engine.actChannel ? colx : col.box2,
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
276 nchannel == engine.actChannel ? colx : col.box1);
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
277
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
278 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
279 return;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
280
274
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
281 if (chn->chDirection)
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
282 {
274
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
283 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
284 {
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
285 if (FP_GETH(offs) >= len)
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
286 break;
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
287 Sint16 val = ym + (data[FP_GETH(offs)] * yh * vol) / (65535 * 255);
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
288 pix[xc + val * pitch] = coln;
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
289 FP_ADD(offs, chn->chDeltaO);
274
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
290 }
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
291 }
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
292 else
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
293 {
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
294 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
295 {
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
296 if (FP_GETH(offs) < 0)
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
297 break;
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
298 Sint16 val = ym + (data[FP_GETH(offs)] * yh * vol) / (65535 * 255);
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
299 pix[xc + val * pitch] = coln;
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
300 FP_SUB(offs, chn->chDeltaO);
274
31e62b1f1b6e Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 273
diff changeset
301 }
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 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
304
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
305
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
306 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
307 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
308 int nchannel, qx, qy,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
309 qwidth = x1 - x0,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
310 qheight = y1 - y0,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
311 nwidth = jsetNChannels,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
312 nheight = 1;
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 if (qheight < 40)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
315 return;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
316
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
317 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
318 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
319 nheight++;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
320 nwidth /= nheight;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
321 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
322
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
323 // fprintf(stderr, "%d x %d\n", nwidth, nheight);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
324
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
325 if (qheight / nheight <= 40)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
326 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
327 nwidth = qwidth / 60;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
328 nheight = qheight / 40;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
329 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
330
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
331 qwidth /= nwidth;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
332 qheight /= nheight;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
333
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
334 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
335 {
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
336 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
337 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
338 int xc = x0 + qx * qwidth,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
339 yc = y0 + qy * qheight;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
340
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
341 dmDisplayChn(screen, xc + 1, yc + 1,
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
342 xc + qwidth - 1, yc + qheight - 1,
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
343 nchannel, &dev->channels[nchannel]);
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
344
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
345 nchannel++;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
346 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
347 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
348 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
349
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
350
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351 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
352 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353 "C-", "C#", "D-",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 "D#", "E-", "F-",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355 "F#", "G-", "G#",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 "A-", "A#", "B-"
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
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
359
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 #define jmpNMODEffectTable (36)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 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
362
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
363 static const char jmpHexTab[16] = "0123456789ABCDEF";
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
364
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
365 static inline char dmHexVal(int v)
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
366 {
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
367 return jmpHexTab[v & 15];
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
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370 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
371 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
372 char text[32];
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373 char *ptr = text;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375 switch (n->note)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
376 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 case jsetNotSet:
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
378 strcpy(ptr, "..._");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380 case jsetNoteOff:
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
381 strcpy(ptr, "===_");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
383 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
384 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
385 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
386 n->note / 12);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
387 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
388 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390 ptr += 4;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392 if (n->instrument != jsetNotSet)
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
393 {
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
394 int v = n->instrument + 1;
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
395 *ptr++ = dmHexVal(v >> 4);
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
396 *ptr++ = dmHexVal(v);
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
397 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398 else
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
399 {
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
400 *ptr++ = '.';
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
401 *ptr++ = '.';
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
402 }
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
403 *ptr++ = '_';
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
404
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
405 if (n->volume == jsetNotSet)
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
406 {
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
407 *ptr++ = '.';
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
408 *ptr++ = '.';
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
409 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
410 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
411 if (n->volume >= 0x00 && n->volume <= 0x40)
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
412 {
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
413 *ptr++ = dmHexVal(n->volume >> 4);
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
414 *ptr++ = dmHexVal(n->volume);
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
415 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
416 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
417 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
418 char c;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
419 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
420 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
421 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
422 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
423 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
424 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
425 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
426 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
427 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
428 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
429 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
430 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
431 default: c = '?'; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
432 }
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
433 *ptr++ = c;
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
434 *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
435 }
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
436 *ptr++ = '_';
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
437
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
438 if (n->effect >= 0 && n->effect < jmpNMODEffectTable)
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
439 *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
440 else
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
441 *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
442
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
443 if (n->param != jsetNotSet)
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
444 {
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
445 *ptr++ = dmHexVal(n->param >> 4);
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
446 *ptr++ = dmHexVal(n->param);
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
447 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
448 else
201
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
449 {
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
450 *ptr++ = '.';
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
451 *ptr++ = '.';
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
452 }
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
453
844f38cbff65 Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents: 199
diff changeset
454 *ptr = 0;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
455
130
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
456 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
457 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
458
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
459
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
460 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
461 {
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
462 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
463 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
464 qy0 = y0 + font->height + 2,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
465 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
466 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
467 qheight = ((qy1 - qy0 - 4) / (font->height + 1)),
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
468 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
469 midrow = qheight / 2;
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
470
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
471 if (engine.actChannel < qwidth / 2)
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
472 choffs = 0;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
473 else
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
474 if (engine.actChannel >= pat->nchannels - qwidth/2)
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
475 choffs = pat->nchannels - qwidth;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
476 else
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
477 choffs = engine.actChannel - qwidth/2;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
478
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
479 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
480
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
481 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
482 {
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
483 int bx0 = x0 + lwidth + 1 + nchannel * cwidth,
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
484 bx1 = bx0 + cwidth;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
485
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
486 if (engine.actChannel == nchannel + choffs)
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
487 {
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
488 dmFillRect(screen, bx0+1, qy0 + 1, bx1-1, qy1 - 1, col.activeChannel);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
489 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
490 else
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
491 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
492 dmFillRect(screen, bx0+1, qy0 + 1, bx1-1, qy1 - 1, col.inboxBg);
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
493 }
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
494 }
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
495
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
496 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
497 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
498
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
499 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
500 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
501 int bx0 = x0 + lwidth + 1 + nchannel * cwidth,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
502 bx1 = bx0 + cwidth;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
503
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
504 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
505
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
506 if (jvmGetMute(engine.dev, nchannel + choffs))
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
507 {
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
508 dmDrawBMTextConstQ(screen, font, DMD_TRANSPARENT,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
509 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
510 }
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
511
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
512 dmDrawBMTextQ(screen, font, DMD_TRANSPARENT,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
513 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
514 nchannel + choffs);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
515 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
516
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
517 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
518 {
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
519 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
520 yc = qy0 + 2 + (font->height + 1) * nrow;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
521
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
522 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
523 {
130
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
524 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
525
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
526 for (nchannel = 0; nchannel < qwidth; nchannel++)
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
527 {
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
528 if (choffs + nchannel >= pat->nchannels)
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
529 break;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
530
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
531 dmPrintNote(screen, x0 + lwidth + 4 + nchannel * cwidth, yc,
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
532 pat->data + (pat->nchannels * crow) + choffs + nchannel);
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
533 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
534 }
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 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
537
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
538
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
539 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
540 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
541 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
542
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
543 if (d != NULL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
544 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
545 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
546 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
547 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
548
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
549
203
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
550 void dmMuteChannels(BOOL mute)
198
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
551 {
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
552 int i;
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
553 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
554 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
555 }
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
556
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
557 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
558 {
290
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
559 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
560 DMResource *file = NULL;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
561 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
562 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
563
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
564 memset(&engine, 0, sizeof(engine));
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
565
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
566 engine.optScrWidth = 640;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
567 engine.optScrHeight = 480;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
568 engine.optScrDepth = 32;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
569
216
247b03797fc9 Rename player, add a copyright note.
Matti Hamalainen <ccr@tnsp.org>
parents: 203
diff changeset
570 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
571
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
572 // Parse arguments
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
573 if (!dmArgsProcess(argc, argv, optList, optListN,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
574 argHandleOpt, argHandleFile, TRUE))
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
575 exit(1);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
576
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
577 // Open the files
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
578 if (optFilename == NULL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
579 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
580 dmError("No filename specified.\n");
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
581 return 1;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
582 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
583
730
3d813c81f33c More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents: 652
diff changeset
584 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
585 {
80
5cefa59baa9d Better error messages.
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
586 dmError("Error opening file '%s', %d: (%s)\n",
730
3d813c81f33c More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents: 652
diff changeset
587 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
588 return 1;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
589 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
590
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
591 // Initialize miniJSS
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
592 jssInit();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
593
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
594 // Read module file
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
595 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
596 #ifdef JSS_SUP_XM
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
597 dmMsg(2, "* Trying XM...\n");
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
598 result = jssLoadXM(file, &engine.mod);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
599 #endif
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
600 #ifdef JSS_SUP_JSSMOD
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
601 if (result != 0)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
602 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
603 dmfseek(file, 0L, SEEK_SET);
777
ed60a7ee3ebb Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents: 745
diff changeset
604 dmMsg(1, "* Trying JSSMOD ...\n");
ed60a7ee3ebb Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents: 745
diff changeset
605 result = jssLoadJSSMOD(file, &engine.mod);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
606 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
607 #endif
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
608 dmf_close(file);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
609
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
610 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
611 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
612 dmError("Error loading module file, %d: %s\n",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
613 result, dmErrorStr(result));
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
614 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
615 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
616
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
617 // Try to convert it
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
618 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
619 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
620 dmError("Could not convert module for playing, %d: %s\n",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
621 result, dmErrorStr(result));
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
622 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
623 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
624
164
a49d431ff40e Add a hardcoded font to PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
625 // Get font
730
3d813c81f33c More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents: 652
diff changeset
626 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
627 if (result != DMERR_OK)
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
628 {
730
3d813c81f33c More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents: 652
diff changeset
629 dmError("Error opening font file 'pplfont.fnt', #%d: %s\n",
3d813c81f33c More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents: 652
diff changeset
630 result, dmErrorStr(result));
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
631 goto error_exit;
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
632 }
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
633 result = dmLoadBitmapFont(file, &font);
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
634 dmf_close(file);
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
635 if (result != DMERR_OK)
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
636 {
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
637 dmError("Could not load font from file, %d: %s\n",
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
638 result, dmErrorStr(result));
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
639 goto error_exit;
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
640 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
641
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
642 // Initialize SDL components
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
643 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
644 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
645 dmError("Could not initialize SDL: %s\n", SDL_GetError());
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
646 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
647 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
648 initSDL = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
649
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 // Initialize mixing device
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
652 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
653 optOutFormat, optOutChannels, optOutFreq);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
654
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
655 engine.dev = jvmInit(optOutFormat, optOutChannels, optOutFreq, JMIX_AUTO);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
656 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
657 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
658 dmError("jvmInit() returned NULL\n");
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
659 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
660 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
661
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
662 switch (optOutFormat)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
663 {
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
664 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
665 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
666 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
667 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
668 default:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
669 dmError("Unsupported audio format %d (could not set matching SDL format)\n",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
670 optOutFormat);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
671 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
672 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
673
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
674 engine.afmt.freq = optOutFreq;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
675 engine.afmt.channels = optOutChannels;
297
a991e4f0acfe Make audio buffer smaller, for now.
Matti Hamalainen <ccr@tnsp.org>
parents: 296
diff changeset
676 engine.afmt.samples = optOutFreq / 16;
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
677 engine.afmt.callback = audioCallback;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
678 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
679
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
680 // Open the audio device
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
681 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
682 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
683 dmError("Couldn't open SDL audio: %s\n",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
684 SDL_GetError());
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
685 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
686 }
290
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
687 audioInit = TRUE;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
688
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
689 // Initialize player
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
690 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
691 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
692 dmError("jmpInit() returned NULL\n");
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
693 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
694 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
695
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
696 jvmSetCallback(engine.dev, jmpExec, engine.plr);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
697 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
698 jmpPlayOrder(engine.plr, optStartOrder);
190
87b46e61f2c4 Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
699 jvmSetGlobalVol(engine.dev, 64);
87b46e61f2c4 Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
700
87b46e61f2c4 Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
701 if (optMuteOChannels >= 0 && optMuteOChannels < engine.mod->nchannels)
87b46e61f2c4 Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
702 {
203
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
703 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
704 jvmMute(engine.dev, optMuteOChannels, FALSE);
190
87b46e61f2c4 Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
705 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
706 muteState = TRUE;
190
87b46e61f2c4 Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents: 185
diff changeset
707 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
708
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
709 // Initialize video
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
710 if (!dmInitializeVideo())
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
711 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
712
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
713 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
714
275
26d714c72c0f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 274
diff changeset
715 SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
26d714c72c0f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 274
diff changeset
716
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
717 // okay, main loop here ... "play" module and print out info
275
26d714c72c0f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 274
diff changeset
718 SDL_LockAudio();
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
719 SDL_PauseAudio(0);
275
26d714c72c0f Cleanups.
Matti Hamalainen <ccr@tnsp.org>
parents: 274
diff changeset
720 SDL_UnlockAudio();
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
721
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
722 int currTick, prevTick = 0, prevRow = -1;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
723
276
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
724 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
725 {
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
726 currTick = SDL_GetTicks();
296
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
727 BOOL force = (currTick - prevTick > 500), updated = FALSE;
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
728
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
729 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
730 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
731 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
732 case SDL_KEYDOWN:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
733 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
734 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
735 case SDLK_ESCAPE:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
736 engine.exitFlag = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
737 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
738
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
739 case SDLK_SPACE:
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
740 engine.pauseFlag = !engine.pauseFlag;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
741 SDL_PauseAudio(engine.pauseFlag);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
742 break;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
743
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
744 case SDLK_LEFT:
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
745 if (engine.actChannel > 0)
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
746 {
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
747 engine.actChannel--;
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
748 force = TRUE;
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
749 }
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
750 break;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
751
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
752 case SDLK_RIGHT:
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
753 if (engine.actChannel < engine.mod->nchannels)
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
754 {
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
755 engine.actChannel++;
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
756 force = TRUE;
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
757 }
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
758 break;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
759
198
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
760 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
761 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
762 {
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
763 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
764 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
765 }
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
766 else
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
767 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
768 {
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
769 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
770 }
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
771 else
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
772 {
bed7457cd8da Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents: 201
diff changeset
773 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
774 }
198
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
775 force = TRUE;
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
776 break;
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
777
167
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
778 case SDLK_PAGEUP:
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
779 JSS_LOCK(engine.dev);
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
780 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
781 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
782 JSS_UNLOCK(engine.plr);
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
783 JSS_UNLOCK(engine.dev);
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
784 force = TRUE;
167
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
785 break;
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
786
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
787 case SDLK_PAGEDOWN:
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
788 JSS_LOCK(engine.dev);
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
789 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
790 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
791 JSS_UNLOCK(engine.plr);
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
792 JSS_UNLOCK(engine.dev);
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
793 force = TRUE;
167
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
794 break;
e281663f04ba Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents: 165
diff changeset
795
179
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
796 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
797 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
798 if (!dmInitializeVideo())
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
799 goto error_exit;
198
4568c479541c Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents: 190
diff changeset
800 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
801 break;
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
802
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
803 default:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
804 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
805 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
806
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
807 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
808
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
809 case SDL_VIDEORESIZE:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
810 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
811 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
812
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
813 if (!dmInitializeVideo())
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
814 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
815
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
816 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
817
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
818 case SDL_VIDEOEXPOSE:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
819 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
820
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
821 case SDL_QUIT:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
822 engine.exitFlag = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
823 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
824 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
825
137
f721f9f7838a Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 130
diff changeset
826
f721f9f7838a Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 130
diff changeset
827 #if 1
276
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
828 JSS_LOCK(engine.plr);
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
829 JSSPattern *currPattern = engine.plr->pattern;
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
830 int currRow = engine.plr->row;
293
bc2e8ce003d7 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 290
diff changeset
831 if (!engine.plr->isPlaying)
bc2e8ce003d7 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 290
diff changeset
832 engine.exitFlag = TRUE;
276
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
833 JSS_UNLOCK(engine.plr);
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
834
276
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
835 if (currRow != prevRow || force)
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
836 {
296
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
837 prevRow = currRow;
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
838 force = TRUE;
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
839 }
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
840
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
841 // Draw frame
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
842 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
843 {
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
844 dmError("Can't lock surface.\n");
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
845 goto error_exit;
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
846 }
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
847
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
848 if (force)
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
849 {
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
850 dmClearSurface(engine.screen, col.boxBg);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
851
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
852 dmDrawBMTextQ(engine.screen, font, DMD_TRANSPARENT, 5, 5, "%s v%s by ccr/TNSP - (c) Copyright 2012 TNSP", dmProgDesc, dmProgVersion);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
853
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
854 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
855 "Song: '%s'",
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
856 engine.mod->moduleName);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
857
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
858 dmDisplayPattern(engine.screen, 5, 40,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
859 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
860 currPattern, currRow);
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
861
276
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
862 JSS_LOCK(engine.plr);
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
863 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
864 "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
865 engine.plr->tempo, engine.plr->speed,
b29c9a2fbeb5 Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents: 176
diff changeset
866 engine.plr->row, engine.plr->pattern->nrows,
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
867 engine.plr->order, engine.mod->norders,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
868 engine.plr->npattern, engine.mod->npatterns);
276
40efff364904 Fix some possible data races.
Matti Hamalainen <ccr@tnsp.org>
parents: 275
diff changeset
869 JSS_UNLOCK(engine.plr);
296
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
870 updated = TRUE;
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
871 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
872
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
873 if (force || currTick - prevTick >= (engine.pauseFlag ? 100 : 20))
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
874 {
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
875 JSS_LOCK(engine.dev);
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
876 dmDisplayChannels(engine.screen, 5, engine.screen->h * 0.8 + 5,
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
877 engine.screen->w - 5, engine.screen->h - 5, engine.dev);
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
878 JSS_UNLOCK(engine.dev);
296
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
879 updated = TRUE;
176
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
880 }
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
881
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
882 if (force)
dfe7e392ea7e Optimize screen updates.
Matti Hamalainen <ccr@tnsp.org>
parents: 167
diff changeset
883 prevTick = currTick;
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
884
137
f721f9f7838a Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 130
diff changeset
885 #endif
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
886 // Flip screen
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
887 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
888 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
889
296
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
890 if (updated)
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
891 SDL_Flip(engine.screen);
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
892
6d62918739c6 Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents: 293
diff changeset
893 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
894 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
895
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
896 error_exit:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
897 if (engine.screen)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
898 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
899
290
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
900 dmMsg(0, "Audio shutdown.\n");
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
901 if (audioInit)
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
902 {
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
903 SDL_LockAudio();
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
904 SDL_PauseAudio(1);
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
905 SDL_UnlockAudio();
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
906 SDL_CloseAudio();
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
907 }
61cab36b6d32 Improve locking.
Matti Hamalainen <ccr@tnsp.org>
parents: 287
diff changeset
908
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
909 jmpClose(engine.plr);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
910 jvmClose(engine.dev);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
911 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
912
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
913 dmFreeBitmapFont(font);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
914
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
915 if (initSDL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
916 SDL_Quit();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
917
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
918 jssClose();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
919
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
920 return 0;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
921 }