annotate ppl.c @ 78:3b3908d28a4b

PPL now looks a bit saner, but does not do anything interesting yet.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 02 Oct 2012 05:53:18 +0300
parents b908fda1036e
children 5cefa59baa9d
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
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
11 #include <errno.h>
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
12
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
13 struct
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 BOOL exitFlag;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
16 SDL_Surface *screen;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
17 SDL_Event event;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
18 int optScrWidth, optScrHeight, optVFlags, optScrDepth;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
19 } engine;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
20
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
21 struct
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
22 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
23 Uint32 boxBg, inboxBg, box1, box2, viewDiv, activeRow;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
24 } col;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
25
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
26
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
27 DMBitmapFont *font = NULL;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
28
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
29 char *optFilename = NULL,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
30 *optFontFilename = "c64font.png";
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
31 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
32 optOutChannels = 2,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
33 optOutFreq = 48000,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
34 optMuteOChannels = -1,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
35 optStartOrder = -1;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
36 BOOL optUsePlayTime = FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
37 size_t optPlayTime;
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
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
40 DMOptArg optList[] =
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
41 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
42 { 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
43 { 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
44 { 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
45 { 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
46
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
47 { 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
48 { 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
49 { 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
50 { 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
51 { 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
52
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
53 { 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
54 { 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
55 { 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
56 };
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
57
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
58 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
59
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
60
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
61 void argShowHelp()
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 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
64 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
65 }
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 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
69 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
70 switch (optN) {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
71 case 0:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
72 argShowHelp();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
73 exit(0);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
74 break;
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 case 1:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
77 dmVerbosity++;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
78 break;
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 case 2:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
81 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
82 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
83
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
84 case 3:
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 int w, h;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
87 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
88 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
89 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
90 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
91 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
92 return FALSE;
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 engine.optScrWidth = w;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
95 engine.optScrHeight = h;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
96 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
97 else
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 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
100 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
101 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
102 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
103 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
104
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
105 case 4:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
106 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
107 break;
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 case 5:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
110 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
111 break;
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 case 6:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
114 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
115 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
116
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
117 case 7:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
118 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
119 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
120
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
121 case 8:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
122 optOutFreq = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
123 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
124
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
125 case 9:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
126 optMuteOChannels = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
127 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
128
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
129 case 10:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
130 optStartOrder = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
131 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
132
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
133 case 11:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
134 optPlayTime = atoi(optArg);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
135 optUsePlayTime = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
136 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
137
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
138 default:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
139 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
140 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
141 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
142
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
143 return TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
144 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
145
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
146
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
147 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
148 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
149 if (!optFilename)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
150 optFilename = currArg;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
151 else
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 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
154 return FALSE;
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 return TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
158 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
159
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
160
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
161 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
162 {
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
163 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
164 }
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
165
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
166 BOOL dmInitializeVideo()
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
167 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
168 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
169 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
170 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
171
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
172 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
173 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
174 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
175 return FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
176 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
177
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
178 col.inboxBg = dmCol(0.7, 0.55, 0.1);
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
179 col.boxBg = dmCol(0.8, 0.65, 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
180 col.box1 = dmCol(0.95, 0.95, 0.8);
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
181 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
182 col.viewDiv = dmCol(0,0,0);
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
183 col.activeRow = dmCol(150,80,0);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
184
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
185 return TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
186 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
187
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
188
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
189 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
190 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
191 "C-", "C#", "D-",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
192 "D#", "E-", "F-",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
193 "F#", "G-", "G#",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
194 "A-", "A#", "B-"
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
195 };
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
196
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
197
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
198 #define jmpNMODEffectTable (36)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
199 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
200
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
201 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
202 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
203 char text[32];
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
204 char *ptr = text;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
205
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
206 switch (n->note)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
207 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
208 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
209 sprintf(ptr, "..._");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
210 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
211 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
212 sprintf(ptr, "===_");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
213 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
214 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
215 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
216 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
217 n->note / 12);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
218 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
219 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
220
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
221 ptr += 4;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
222
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
223 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
224 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
225 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
226 sprintf(ptr, ".._");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
227
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
228 ptr += 3;
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 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
231 sprintf(ptr, ".._");
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
232 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
233 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
234 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
235 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
236 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
237 char c;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
238 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
239 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
240 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
241 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
242 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
243 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
244 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
245 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
246 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
247 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
248 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
249 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
250 default: c = '?'; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
251 }
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
252 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
253 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
254
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
255 ptr += 3;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
256
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
257 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
258 *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
259 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
260 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
261 *ptr = '.';
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
262 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
263 *ptr = '?';
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
264
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
265 ptr += 1;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
266
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
267 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
268 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
269 else
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
270 sprintf(ptr, "..");
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
271
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
272 dmDrawBMTextConst(screen, font, DMD_SATURATE, xc, yc, text);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
273 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
274
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
275
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
276 void dmDisplayPattern(SDL_Surface *screen, int x0, int y0, int x1, int y1, JSSPattern *pat, int row, int choffs)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
277 {
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
278 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
279 lwidth = 6 + font->width * 3,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
280 qwidth = ((x1 - x0 - lwidth) / cwidth),
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
281 qheight = ((y1 - y0 - 4) / (font->height + 1)),
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
282 nrow, nchannel,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
283 midrow = qheight / 2;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
284
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
285 dmDrawBox3D(screen, x0 + lwidth, y0, x1, y1,
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
286 col.inboxBg, col.box2, col.box1);
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
287
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
288 for (nchannel = 1; nchannel < qwidth; nchannel++)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
289 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
290 dmDrawVLine(screen, y0 + 1, y1 - 1, x0 + lwidth + 1 + nchannel * cwidth, col.viewDiv);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
291 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
292
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
293
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
294 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
295 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
296 int yc = y0 + 2 + (font->height + 1) * nrow;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
297
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
298 dmDrawBMText(screen, font, DMD_SATURATE, x0, yc, "%03d", nrow);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
299
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
300 if (nrow == row)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
301 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
302 dmFillRect(screen, x0 + lwidth + 1, yc - 1, x1 - 1, yc + font->height, col.activeRow);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
303 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
304
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
305 for (nchannel = 0; nchannel < qwidth; nchannel++)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
306 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
307 if (choffs + nchannel >= pat->nchannels)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
308 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
309
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
310 dmPrintNote(screen, x0 + lwidth + 4 + nchannel * cwidth, yc,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
311 pat->data + (pat->nchannels * nrow) + choffs + nchannel);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
312 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
313 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
314 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
315
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
316
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
317 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
318 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
319 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
320
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
321 if (d != NULL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
322 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
323 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
324 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
325 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
326
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
327
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
328 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
329 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
330 BOOL initSDL = FALSE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
331 DMResource *file = NULL;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
332 JSSModule *mod = NULL;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
333 JSSMixer *dev = NULL;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
334 JSSPlayer *plr = NULL;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
335 SDL_AudioSpec afmt;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
336 int result = -1;
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 memset(&afmt, 0, sizeof(afmt));
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
339 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
340
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
341 engine.optScrWidth = 640;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
342 engine.optScrHeight = 480;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
343 engine.optScrDepth = 32;
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 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
346
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
347 // Parse arguments
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
348 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
349 argHandleOpt, argHandleFile, TRUE))
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
350 exit(1);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
351
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
352 // Open the files
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
353 if (optFilename == NULL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
354 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
355 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
356 return 1;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
357 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
358
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
359 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
360 {
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
361 dmError("Error opening file '%s', %d (%s)\n",
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
362 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
363 return 1;
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
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
366 // Initialize miniJSS
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
367 jssInit();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
368
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
369 // Read module file
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
370 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
371 #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
372 dmMsg(2, "* Trying XM...\n");
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
373 result = jssLoadXM(file, &mod);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
374 #endif
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
375 #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
376 if (result != 0)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
377 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
378 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
379 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
380 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
381 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
382 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
383 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
384 dmf_close(file);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
385 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
386 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
387 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
388 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
389 result = jssLoadJSSMOD(buf, bufsize, &mod);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
390 dmFree(buf);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
391 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
392 #endif
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
393 dmf_close(file);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
394
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
395 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
396 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
397 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
398 result, dmErrorStr(result));
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
399 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
400 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
401
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
402 // Try to convert it
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
403 if ((result = jssConvertModuleForPlaying(mod)) != DMERR_OK)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
404 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
405 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
406 result, dmErrorStr(result));
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
407 goto error_exit;
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
78
3b3908d28a4b PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents: 71
diff changeset
410 if ((file = dmf_create_stdio(optFontFilename, "rb")) == NULL)
71
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
411 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
412 dmError("Error opening input file '%s'. (%s)\n",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
413 optFontFilename, strerror(errno));
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
414 goto error_exit;
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 SDL_Surface *fontbmap = dmLoadImage(file);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
417 dmf_close(file);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
418 if (fontbmap == NULL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
419 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
420 dmError("Could not load image file '%s'.\n", optFontFilename);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
421 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
422 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
423
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
424 if ((result = dmCreateBitmapFontFromImage(fontbmap, 8, 8, &font)) != DMERR_OK)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
425 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
426 dmError("Could not create a font from image, %d: %s\n",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
427 result, dmErrorStr(result));
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
428 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
429 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
430 SDL_FreeSurface(fontbmap);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
431
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
432
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
433 // Initialize SDL components
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
434 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
435 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
436 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
437 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
438 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
439 initSDL = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
440
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
441
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
442 // Initialize mixing device
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
443 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
444 optOutFormat, optOutChannels, optOutFreq);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
445
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
446 dev = jvmInit(optOutFormat, optOutChannels, optOutFreq, JMIX_AUTO);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
447 if (dev == NULL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
448 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
449 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
450 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
451 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
452
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
453 switch (optOutFormat)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
454 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
455 case JSS_AUDIO_S16: afmt.format = AUDIO_S16SYS; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
456 case JSS_AUDIO_U16: afmt.format = AUDIO_U16SYS; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
457 case JSS_AUDIO_S8: afmt.format = AUDIO_S8; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
458 case JSS_AUDIO_U8: afmt.format = AUDIO_U8; break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
459 default:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
460 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
461 optOutFormat);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
462 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
463 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
464
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
465 afmt.freq = optOutFreq;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
466 afmt.channels = optOutChannels;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
467 afmt.samples = optOutFreq * optOutChannels * 4;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
468 afmt.callback = audioCallback;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
469 afmt.userdata = (void *) dev;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
470
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
471 // Open the audio device
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
472 if (SDL_OpenAudio(&afmt, NULL) < 0)
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 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
475 SDL_GetError());
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
476 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
477 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
478
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
479 // Initialize player
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
480 if ((plr = jmpInit(dev)) == NULL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
481 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
482 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
483 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
484 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
485
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
486 jvmSetCallback(dev, jmpExec, plr);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
487 jmpSetModule(plr, mod);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
488 jmpPlayOrder(plr, 0);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
489 jvmSetGlobalVol(dev, 60);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
490
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
491 // Initialize video
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
492 if (!dmInitializeVideo())
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
493 goto error_exit;
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 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
496
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
497
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
498 // 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
499 SDL_PauseAudio(0);
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 while (!engine.exitFlag && plr->isPlaying)
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 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
504 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
505 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
506 case SDL_KEYDOWN:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
507 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
508 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
509 case SDLK_ESCAPE:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
510 engine.exitFlag = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
511 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
512
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
513 default:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
514 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
515 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
516
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
517 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
518
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
519 case SDL_VIDEORESIZE:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
520 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
521 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
522
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
523 if (!dmInitializeVideo())
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
524 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
525
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
526 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
527
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
528 case SDL_VIDEOEXPOSE:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
529 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
530
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
531 case SDL_QUIT:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
532 engine.exitFlag = TRUE;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
533 break;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
534 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
535
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
536 // Draw frame
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
537 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
538 {
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
539 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
540 goto error_exit;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
541 }
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
542
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
543 dmDrawBox3D(engine.screen, 0, 0, engine.screen->w - 1, engine.screen->h - 1,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
544 col.boxBg, col.box1, col.box2);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
545
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
546 dmDrawBMText(engine.screen, font, DMD_SATURATE, 5, 5, "%s v%s by ccr/TNSP - (c) Copyright 2012 TNSP", dmProgDesc, dmProgVersion);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
547
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
548
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
549 JSS_LOCK(dev);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
550 JSS_LOCK(plr);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
551
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
552 dmDrawBMText(engine.screen, font, DMD_SATURATE, 5, 5 + 9,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
553 "Tempo %3d | Speed: %3d | Row: %3d | Order: %d",
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
554 plr->tempo, plr->speed, plr->row, plr->order
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
555 );
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
556
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
557 dmDisplayPattern(engine.screen, 5, 30, engine.screen->w - 6, engine.screen->h - 10,
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
558 plr->pattern, plr->row, 0);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
559 JSS_UNLOCK(plr);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
560 JSS_UNLOCK(dev);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
561
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
562 // Flip screen
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
563 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
564 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
565
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
566 SDL_Flip(engine.screen);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
567 SDL_Delay(10);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
568 }
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 error_exit:
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
571 SDL_PauseAudio(1);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
572
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
573 if (engine.screen)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
574 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
575
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
576 SDL_LockAudio();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
577 jmpClose(plr);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
578 jvmClose(dev);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
579 jssFreeModule(mod);
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
580 SDL_UnlockAudio();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
581
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
582 dmFreeBitmapFont(font);
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 if (initSDL)
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
585 SDL_Quit();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
586
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
587 jssClose();
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
588
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
589 return 0;
b908fda1036e Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff changeset
590 }