annotate ppl.c @ 165:3e8e0dc30711

Minor visual improvements.
author Matti Hamalainen <ccr@tnsp.org>
date Sat, 06 Oct 2012 08:11:47 +0300
parents a49d431ff40e
children e281663f04ba
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
1 #include "jss.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
2 #include "jssmod.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
3 #include "jssmix.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
4 #include "jssplr.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
5
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
6 #include "dmlib.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
7 #include "dmargs.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
8 #include "dmimage.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
9 #include "dmtext.h"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
10
164
a49d431ff40e Add a hardcoded font to PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
11 #include "pplfont.h"
a49d431ff40e Add a hardcoded font to PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
12
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 #include <errno.h>
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
14
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
15 struct
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 BOOL exitFlag;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 SDL_Surface *screen;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 SDL_Event event;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20 int optScrWidth, optScrHeight, optVFlags, optScrDepth;
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
21
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
22 int actChannel;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
23 BOOL pauseFlag;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
24
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
25 JSSModule *mod;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
26 JSSMixer *dev;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
27 JSSPlayer *plr;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
28 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
29 } engine;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 struct
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
32 {
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
33 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
34 } col;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 DMBitmapFont *font = NULL;
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 char *optFilename = NULL,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 *optFontFilename = "c64font.png";
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 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
42 optOutChannels = 2,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
43 optOutFreq = 48000,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
44 optMuteOChannels = -1,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
45 optStartOrder = -1;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
46 BOOL optUsePlayTime = FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 size_t optPlayTime;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
48
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
49
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
50 DMOptArg optList[] =
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
51 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
52 { 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
53 { 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
54 { 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
55 { 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
56
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57 { 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
58 { 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
59 { 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
60 { 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
61 { 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
62
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
63 { 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
64 { 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
65 { 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
66 };
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
67
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
68 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
69
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 void argShowHelp()
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 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
74 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
75 }
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 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
79 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
80 switch (optN) {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 case 0:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
82 argShowHelp();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83 exit(0);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
85
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
86 case 1:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 dmVerbosity++;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
88 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
90 case 2:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 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
92 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
93
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
94 case 3:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 int w, h;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 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
98 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
99 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
100 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 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
102 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104 engine.optScrWidth = w;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 engine.optScrHeight = h;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
107 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
108 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
109 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
110 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
111 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
112 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
113 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
115 case 4:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116 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
117 break;
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 case 5:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120 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
121 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 case 6:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124 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
125 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 case 7:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128 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
129 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 case 8:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132 optOutFreq = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 case 9:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 optMuteOChannels = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 case 10:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
140 optStartOrder = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 case 11:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 optPlayTime = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145 optUsePlayTime = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
148 default:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 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
150 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
152
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
153 return TRUE;
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
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
156
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
157 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
158 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159 if (!optFilename)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160 optFilename = currArg;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
161 else
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 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
164 return FALSE;
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
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 return TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
169
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
170
130
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
171 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
172 {
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
173 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
174 DMUnscaledBlitFunc blit = NULL;
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
175
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
176 while (*ptr)
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
177 {
137
f721f9f7838a Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 130
diff changeset
178 int ch = *ptr++;
130
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
179 SDL_Surface *glyph;
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
180
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
181 if (ch == '_')
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 xc += 4;
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
184 continue;
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
185 }
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
186
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
187 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
188 {
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
189 if (blit == NULL)
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
190 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
191
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
192 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
193 xc += font->width;
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
194 }
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
195 else
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
196 xc += font->width;
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
197 }
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
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
200
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
201 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
202 {
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
203 char *tmp = dm_strdup_vprintf(fmt, ap);
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
204 if (tmp != NULL)
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 dmDrawBMTextConstQ(screen, font, mode, xc, yc, tmp);
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
207 dmFree(tmp);
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
208 }
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
209 }
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
210
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
211
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
212 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
213 {
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
214 va_list ap;
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 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
217 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
218 va_end(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
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
221
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
222 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
223 {
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
224 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
225 }
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
226
130
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
227
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 BOOL dmInitializeVideo()
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
229 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
230 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
231 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
232 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
233
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
234 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
235 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 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
237 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
239
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
240 col.inboxBg = dmCol(0.6, 0.5, 0.2);
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
241 col.boxBg = dmCol(0.7, 0.6, 0.3);
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
242 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
243 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
244 col.viewDiv = dmCol(0,0,0);
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
245 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
246 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
247
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
248 return TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
249 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
250
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
252 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
253 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
254 int yh = y1 - y0 - 2;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
255 if (yh < 10 || chn == NULL)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
256 return;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
257
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
258 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
259 int pitch = screen->pitch / sizeof(Uint32);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
260 DMFixedPoint offs = chn->chPos;
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
261 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
262 Uint32 *pix = screen->pixels;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
263 Sint16 *data = chn->chData;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
264
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
265
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
266 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
267 (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
268 nchannel == engine.actChannel ? colx : col.box2,
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
269 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
270
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
271 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
272 return;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
273
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
274 for (xc = x0 + 1; xc < x1 - 1; xc++)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
275 {
159
f1aa6e90ad22 Fix sample display.
Matti Hamalainen <ccr@tnsp.org>
parents: 151
diff changeset
276 Sint16 val = ym + (data[FP_GETH(offs)] * yh * vol) / (65535 * 255);
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
277 pix[xc + val * pitch] = coln;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
278 if (chn->chDirection)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
279 FP_ADD(offs, chn->chDeltaO);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
280 else
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
281 FP_SUB(offs, chn->chDeltaO);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
282 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
283 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
284
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
285
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
286 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
287 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
288 int nchannel, qx, qy,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
289 qwidth = x1 - x0,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
290 qheight = y1 - y0,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
291 nwidth = jsetNChannels,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
292 nheight = 1;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
293
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
294 if (qheight < 40)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
295 return;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
296
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
297 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
298 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
299 nheight++;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
300 nwidth /= nheight;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
301 }
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 // 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
304
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
305 if (qheight / nheight <= 40)
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
306 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
307 nwidth = qwidth / 60;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
308 nheight = qheight / 40;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
309 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
310
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
311 qwidth /= nwidth;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
312 qheight /= nheight;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
313
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
314 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
315 {
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
316 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
317 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
318 int xc = x0 + qx * qwidth,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
319 yc = y0 + qy * qheight;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
320
165
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
321 dmDisplayChn(screen, xc + 1, yc + 1,
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
322 xc + qwidth - 1, yc + qheight - 1,
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
323 nchannel, &dev->channels[nchannel]);
3e8e0dc30711 Minor visual improvements.
Matti Hamalainen <ccr@tnsp.org>
parents: 164
diff changeset
324
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
325 nchannel++;
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 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
328 }
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
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 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
332 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
333 "C-", "C#", "D-",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
334 "D#", "E-", "F-",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335 "F#", "G-", "G#",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336 "A-", "A#", "B-"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
337 };
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
338
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
340 #define jmpNMODEffectTable (36)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341 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
342
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 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
344 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
345 char text[32];
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
346 char *ptr = text;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 switch (n->note)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
349 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 case jsetNotSet:
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
351 sprintf(ptr, "..._");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353 case jsetNoteOff:
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
354 sprintf(ptr, "===_");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
356 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
357 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
358 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
359 n->note / 12);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
360 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
361 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
362
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
363 ptr += 4;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
364
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
365 if (n->instrument != jsetNotSet)
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
366 sprintf(ptr, "%.2x_", n->instrument + 1);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367 else
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
368 sprintf(ptr, ".._");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370 ptr += 3;
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 if (n->volume == jsetNotSet)
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
373 sprintf(ptr, ".._");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375 if (n->volume >= 0x00 && n->volume <= 0x40)
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
376 sprintf(ptr, "%.2x_", n->volume);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
379 char c;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
380 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
381 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
382 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
383 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
384 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
385 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
386 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
387 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
388 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
389 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
390 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
391 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
392 default: c = '?'; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 }
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
394 sprintf(ptr, "%c%x_", c, (n->volume & 0x0f));
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
396
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397 ptr += 3;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
398
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
399 if (n->effect >= 0 && n->effect < jmpNMODEffectTable)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400 *ptr = jmpMODEffectTable[n->effect];
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402 if (n->effect == jsetNotSet)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
403 *ptr = '.';
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
404 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
405 *ptr = '?';
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
406
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
407 ptr += 1;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
408
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
409 if (n->param != jsetNotSet)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
410 sprintf(ptr, "%.2x", n->param);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
411 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
412 sprintf(ptr, "..");
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
413
130
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
414 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
415 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
416
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
417
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
418 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
419 {
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
420 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
421 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
422 qy0 = y0 + font->height + 2,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
423 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
424 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
425 qheight = ((qy1 - qy0 - 4) / (font->height + 1)),
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
426 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
427 midrow = qheight / 2;
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
428
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
429 if (engine.actChannel < qwidth / 2)
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
430 choffs = 0;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
431 else
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
432 if (engine.actChannel >= pat->nchannels - qwidth/2)
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
433 choffs = pat->nchannels - qwidth;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
434 else
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
435 choffs = engine.actChannel - qwidth/2;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
436
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
437 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
438
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
439 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
440 {
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
441 int bx0 = x0 + lwidth + 1 + nchannel * cwidth,
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
442 bx1 = bx0 + cwidth;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
443
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
444 if (engine.actChannel == nchannel + choffs)
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
445 {
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
446 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
447 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
448 else
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
449 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
450 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
451 }
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
452 }
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
453
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
454 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
455 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
456
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
457 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
458 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
459 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
460 bx1 = bx0 + cwidth;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
461
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
462 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
463
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
464 if (jvmGetMute(engine.dev, nchannel + choffs))
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
465 {
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
466 dmDrawBMTextConstQ(screen, font, DMD_TRANSPARENT,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
467 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
468 }
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
469
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
470 dmDrawBMTextQ(screen, font, DMD_TRANSPARENT,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
471 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
472 nchannel + choffs);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
473 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
474
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
475 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
476 {
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
477 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
478 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
479
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
480 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
481 {
130
1d7dc7c8745c Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents: 99
diff changeset
482 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
483
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
484 for (nchannel = 0; nchannel < qwidth; nchannel++)
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
485 {
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
486 if (choffs + nchannel >= pat->nchannels)
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
487 break;
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
488
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
489 dmPrintNote(screen, x0 + lwidth + 4 + nchannel * cwidth, yc,
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
490 pat->data + (pat->nchannels * crow) + choffs + nchannel);
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
491 }
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
492 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
493 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
494 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
495
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
496
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
497 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
498 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
499 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
500
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
501 if (d != NULL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
502 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
503 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
504 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
505 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
506
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
507
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
508 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
509 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
510 BOOL initSDL = FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
511 DMResource *file = NULL;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
512 int result = -1;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
513
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
514 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
515
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
516 engine.optScrWidth = 640;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
517 engine.optScrHeight = 480;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
518 engine.optScrDepth = 32;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
519
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
520 dmInitProg("ppl", "Penis Player", "0.1", NULL, NULL);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
521
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
522 // Parse arguments
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
523 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
524 argHandleOpt, argHandleFile, TRUE))
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
525 exit(1);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
526
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
527 // Open the files
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
528 if (optFilename == NULL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
529 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
530 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
531 return 1;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
532 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
533
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
534 if ((file = dmf_create_stdio(optFilename, "rb")) == NULL)
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
535 {
80
5cefa59baa9d Better error messages.
Matti Hamalainen <ccr@tnsp.org>
parents: 78
diff changeset
536 dmError("Error opening file '%s', %d: (%s)\n",
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
537 optFilename, errno, strerror(errno));
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
538 return 1;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
539 }
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 // Initialize miniJSS
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
542 jssInit();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
543
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
544 // Read module file
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
545 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
546 #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
547 dmMsg(2, "* Trying XM...\n");
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
548 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
549 #endif
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
550 #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
551 if (result != 0)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
552 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
553 size_t bufgot, bufsize = dmfsize(file);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
554 Uint8 *buf = dmMalloc(bufsize);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
555 dmfseek(file, 0L, SEEK_SET);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
556 dmMsg(2, "* Trying JSSMOD (%d bytes, %p)...\n", bufsize, buf);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
557 if ((bufgot = dmfread(buf, 1, bufsize, file)) != bufsize)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
558 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
559 dmf_close(file);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
560 dmError("Error reading file (not enough data %d), #%d: %s\n",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
561 bufgot, dmferror(file), dmErrorStr(dmferror(file)));
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
562 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
563 }
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
564 result = jssLoadJSSMOD(buf, bufsize, &engine.mod);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
565 dmFree(buf);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
566 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
567 #endif
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
568 dmf_close(file);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
569
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
570 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
571 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
572 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
573 result, dmErrorStr(result));
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
574 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
575 }
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 // Try to convert it
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
578 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
579 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
580 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
581 result, dmErrorStr(result));
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
582 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
583 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
584
164
a49d431ff40e Add a hardcoded font to PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
585 // Get font
a49d431ff40e Add a hardcoded font to PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
586 // file = dmf_create_stdio("fnsmall.fnt", "rb");
a49d431ff40e Add a hardcoded font to PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
587 file = dmf_open_memio(optFontFilename, dmPlayerFont, sizeof(dmPlayerFont));
a49d431ff40e Add a hardcoded font to PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
588 if (file == NULL)
99
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
589 {
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
590 dmError("Error opening font file '%s', %d: %s\n",
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
591 optFontFilename, errno, strerror(errno));
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
592 goto error_exit;
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
593 }
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
594 result = dmLoadBitmapFont(file, &font);
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
595 dmf_close(file);
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
596 if (result != DMERR_OK)
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
597 {
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
598 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
599 result, dmErrorStr(result));
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
600 goto error_exit;
7a59611f9d4f Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 80
diff changeset
601 }
71
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 // Initialize SDL components
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
604 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
605 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
606 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
607 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
608 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
609 initSDL = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
610
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 // Initialize mixing device
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
613 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
614 optOutFormat, optOutChannels, optOutFreq);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
615
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
616 engine.dev = jvmInit(optOutFormat, optOutChannels, optOutFreq, JMIX_AUTO);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
617 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
618 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
619 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
620 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
621 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
622
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
623 switch (optOutFormat)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
624 {
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
625 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
626 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
627 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
628 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
629 default:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
630 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
631 optOutFormat);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
632 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
633 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
634
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
635 engine.afmt.freq = optOutFreq;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
636 engine.afmt.channels = optOutChannels;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
637 engine.afmt.samples = optOutFreq * optOutChannels * 4;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
638 engine.afmt.callback = audioCallback;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
639 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
640
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
641 // Open the audio device
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
642 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
643 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
644 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
645 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
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
649 // Initialize player
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
650 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
651 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
652 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
653 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
654 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
655
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
656 jvmSetCallback(engine.dev, jmpExec, engine.plr);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
657 jmpSetModule(engine.plr, engine.mod);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
658 jmpPlayOrder(engine.plr, 0);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
659 jvmSetGlobalVol(engine.dev, 100);
71
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 // Initialize video
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
662 if (!dmInitializeVideo())
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
663 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
664
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
665 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
666
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
667 // okay, main loop here ... "play" module and print out info
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
668 SDL_PauseAudio(0);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
669
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
670 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
671
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
672 while (!engine.exitFlag && engine.plr->isPlaying)
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
673 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
674 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
675 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
676 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
677 case SDL_KEYDOWN:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
678 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
679 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
680 case SDLK_ESCAPE:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
681 engine.exitFlag = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
682 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
683
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
684 case SDLK_SPACE:
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
685 engine.pauseFlag = !engine.pauseFlag;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
686 SDL_PauseAudio(engine.pauseFlag);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
687 break;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
688
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
689 case SDLK_LEFT:
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
690 if (engine.actChannel > 0)
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
691 engine.actChannel--;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
692 break;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
693
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
694 case SDLK_RIGHT:
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
695 if (engine.actChannel < engine.mod->nchannels)
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
696 engine.actChannel++;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
697 break;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
698
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
699 case SDLK_RETURN:
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
700 jvmMute(engine.dev, engine.actChannel, !jvmGetMute(engine.dev, engine.actChannel));
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
701 break;
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
702
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
703 default:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
704 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
705 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
706
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
707 break;
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 case SDL_VIDEORESIZE:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
710 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
711 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
712
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
713 if (!dmInitializeVideo())
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
714 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
715
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
716 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
717
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
718 case SDL_VIDEOEXPOSE:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
719 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
720
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
721 case SDL_QUIT:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
722 engine.exitFlag = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
723 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
724 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
725
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
726 // Draw frame
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
727 if (SDL_MUSTLOCK(engine.screen) != 0 && SDL_LockSurface(engine.screen) != 0)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
728 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
729 dmError("Can't lock surface.\n");
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
730 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
731 }
137
f721f9f7838a Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 130
diff changeset
732
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
733 currTick = SDL_GetTicks();
137
f721f9f7838a Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 130
diff changeset
734 #if 1
164
a49d431ff40e Add a hardcoded font to PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
735 if (engine.plr->row != prevRow || currTick - prevTick > 100)
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
736 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
737 dmClearSurface(engine.screen, col.boxBg);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
738
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
739 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
740
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
741 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
742 "Song: '%s'",
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
743 engine.mod->moduleName);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
744
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
745 dmDisplayPattern(engine.screen, 5, 40,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
746 engine.screen->w - 6, engine.screen->h * 0.8,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
747 engine.plr->pattern, engine.plr->row);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
748
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
749 prevTick = currTick;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
750 prevRow = engine.plr->row;
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
751 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
752 else
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
753 {
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
754 dmFillRect(engine.screen, 5, 5 + 12, engine.screen->w, 5 + 12 + 10, col.boxBg);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
755 }
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
756
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
757 dmDrawBMTextQ(engine.screen, font, DMD_TRANSPARENT, 5, 5 + 12,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
758 "Tempo: %3d | Speed: %3d | Row: %3d | Order: %3d/%3d | Pattern: %3d/%3d",
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
759 engine.plr->tempo, engine.plr->speed, engine.plr->row,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
760 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
761 engine.plr->npattern, engine.mod->npatterns);
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
762
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
763
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
764
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
765 JSS_LOCK(engine.dev);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
766 JSS_LOCK(engine.plr);
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
767 dmDisplayChannels(engine.screen, 5, engine.screen->h * 0.8 + 5,
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
768 engine.screen->w - 5, engine.screen->h - 5, engine.dev);
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
769
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
770 JSS_UNLOCK(engine.plr);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
771 JSS_UNLOCK(engine.dev);
151
8708b0354eb8 Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents: 148
diff changeset
772
137
f721f9f7838a Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents: 130
diff changeset
773 #endif
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
774
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
775 // Flip screen
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
776 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
777 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
778
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
779 SDL_Flip(engine.screen);
164
a49d431ff40e Add a hardcoded font to PPL.
Matti Hamalainen <ccr@tnsp.org>
parents: 159
diff changeset
780 SDL_Delay(engine.pauseFlag ? 100 : 10);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
781 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
782
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
783 error_exit:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
784 SDL_PauseAudio(1);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
785
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
786 if (engine.screen)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
787 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
788
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
789 SDL_LockAudio();
147
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
790 jmpClose(engine.plr);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
791 jvmClose(engine.dev);
ead759da30b4 Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents: 137
diff changeset
792 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
793 SDL_UnlockAudio();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
794
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
795 dmFreeBitmapFont(font);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
796
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
797 if (initSDL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
798 SDL_Quit();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
799
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
800 jssClose();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
801
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
802 return 0;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
803 }