Mercurial > hg > dmlib
annotate ppl.c @ 71:b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 01 Oct 2012 13:43:09 +0300 |
parents | |
children | 3b3908d28a4b |
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 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
161 BOOL dmInitializeVideo() |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
162 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
163 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
|
164 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
|
165 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
|
166 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 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
|
168 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
169 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
|
170 return FALSE; |
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 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
173 col.inboxBg = dmMapRGB(engine.screen, 0, 0, 0); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
174 col.boxBg = dmMapRGB(engine.screen, 200, 100, 30); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
175 col.box1 = dmMapRGB(engine.screen, 250, 250, 200); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
176 col.box2 = dmMapRGB(engine.screen, 100, 50, 0); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
177 col.viewDiv = dmMapRGB(engine.screen, 0,0,0); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
178 col.activeRow = dmMapRGB(engine.screen, 150,80,0); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
179 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
180 return TRUE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
181 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
182 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
183 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
184 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
|
185 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
186 "C-", "C#", "D-", |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
187 "D#", "E-", "F-", |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
188 "F#", "G-", "G#", |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
189 "A-", "A#", "B-" |
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 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
192 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
193 #define jmpNMODEffectTable (36) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
194 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
|
195 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
196 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
|
197 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
198 char text[32]; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
199 char *ptr = text; |
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 switch (n->note) |
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 case jsetNotSet: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
204 sprintf(ptr, "...§"); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
205 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
206 case jsetNoteOff: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
207 sprintf(ptr, "===§"); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
208 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
209 default: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
210 sprintf(ptr, "%s%i§", |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
211 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
|
212 n->note / 12); |
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 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
215 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
216 ptr += 4; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
217 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
218 if (n->instrument != jsetNotSet) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
219 sprintf(ptr, "%.2x§", n->instrument + 1); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
220 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
221 sprintf(ptr, "..§"); |
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 ptr += 3; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
224 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
225 if (n->volume == jsetNotSet) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
226 sprintf(ptr, "..§"); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
227 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
228 if (n->volume >= 0x00 && n->volume <= 0x40) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
229 sprintf(ptr, "%.2x§", n->volume); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
230 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
231 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
232 char c; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
233 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
|
234 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
235 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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 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
|
241 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
|
242 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
|
243 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
|
244 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
|
245 default: c = '?'; break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
246 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
247 sprintf(ptr, "%c%x§", c, (n->volume & 0x0f)); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
248 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
249 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
250 ptr += 3; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
251 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
252 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
|
253 *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
|
254 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
255 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
|
256 *ptr = '.'; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
257 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
258 *ptr = '?'; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
259 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
260 ptr += 1; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
261 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
262 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
|
263 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
|
264 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
265 sprintf(ptr, ".."); |
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 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
|
268 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
269 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
270 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
271 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
|
272 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
273 int cwidth = (font->width * 10 + 3 * font->width + 5), |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
274 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
|
275 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
|
276 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
|
277 nrow, nchannel, |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
278 midrow = qheight / 2; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
279 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
280 dmDrawBox3D(screen, x0 + lwidth, y0, x1, y1, |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
281 col.boxBg, col.box2, col.box1); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
282 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
283 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
|
284 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
285 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
|
286 } |
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 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
289 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
|
290 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
291 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
|
292 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
293 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
|
294 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
295 if (nrow == row) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
296 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
297 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
|
298 } |
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 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
|
301 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
302 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
|
303 break; |
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 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
|
306 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
|
307 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
308 } |
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 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
311 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
312 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
|
313 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
314 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
|
315 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
316 if (d != NULL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
317 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
318 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
|
319 } |
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 |
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 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
|
324 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
325 BOOL initSDL = FALSE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
326 DMResource *file = NULL; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
327 JSSModule *mod = NULL; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
328 JSSMixer *dev = NULL; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
329 JSSPlayer *plr = NULL; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
330 SDL_AudioSpec afmt; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
331 int result = -1; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
332 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
333 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
|
334 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
|
335 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
336 engine.optScrWidth = 640; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
337 engine.optScrHeight = 480; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
338 engine.optScrDepth = 32; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
339 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
340 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
|
341 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
342 // Parse arguments |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
343 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
|
344 argHandleOpt, argHandleFile, TRUE)) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
345 exit(1); |
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 // Open the files |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
348 if (optFilename == NULL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
349 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
350 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
|
351 return 1; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
352 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
353 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
354 if ((file = dmf_create_stdio(optFilename)) == NULL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
355 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
356 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
|
357 optFilename, strerror(errno)); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
358 return 1; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
359 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
360 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
361 if ((file = dmf_create_stdio(optFilename)) == NULL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
362 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
363 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
|
364 optFilename, strerror(errno)); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
365 return 1; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
366 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
367 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
368 // Initialize miniJSS |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
369 jssInit(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
370 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
371 // Read module file |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
372 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
|
373 #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
|
374 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
|
375 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
|
376 #endif |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
377 #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
|
378 if (result != 0) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
379 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
380 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
|
381 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
|
382 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
|
383 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
|
384 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
|
385 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
386 dmf_close(file); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
387 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
|
388 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
|
389 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
390 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
391 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
|
392 dmFree(buf); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
393 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
394 #endif |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
395 dmf_close(file); |
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 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
|
398 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
399 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
|
400 result, dmErrorStr(result)); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
401 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
402 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
403 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
404 // 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
|
405 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
|
406 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
407 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
|
408 result, dmErrorStr(result)); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
409 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
410 } |
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 if ((file = dmf_create_stdio(optFontFilename)) == NULL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
413 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
414 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
|
415 optFontFilename, strerror(errno)); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
416 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
417 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
418 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
|
419 dmf_close(file); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
420 if (fontbmap == NULL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
421 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
422 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
|
423 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
424 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
425 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
426 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
|
427 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
428 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
|
429 result, dmErrorStr(result)); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
430 goto error_exit; |
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 SDL_FreeSurface(fontbmap); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
433 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
434 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
435 // Initialize SDL components |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
436 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
|
437 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
438 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
|
439 goto error_exit; |
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 initSDL = TRUE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
442 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
443 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
444 // Initialize mixing device |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
445 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
|
446 optOutFormat, optOutChannels, optOutFreq); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
447 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
448 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
|
449 if (dev == NULL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
450 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
451 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
|
452 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
453 } |
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 switch (optOutFormat) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
456 { |
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_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
|
458 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
|
459 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
|
460 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
|
461 default: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
462 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
|
463 optOutFormat); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
464 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
465 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
466 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
467 afmt.freq = optOutFreq; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
468 afmt.channels = optOutChannels; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
469 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
|
470 afmt.callback = audioCallback; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
471 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
|
472 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
473 // 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
|
474 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
|
475 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
476 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
|
477 SDL_GetError()); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
478 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
479 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
480 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
481 // Initialize player |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
482 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
|
483 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
484 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
|
485 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
486 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
487 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
488 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
|
489 jmpSetModule(plr, mod); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
490 jmpPlayOrder(plr, 0); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
491 jvmSetGlobalVol(dev, 60); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
492 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
493 // Initialize video |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
494 if (!dmInitializeVideo()) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
495 goto error_exit; |
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 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
|
498 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
499 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
500 // 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
|
501 SDL_PauseAudio(0); |
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 (!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
|
504 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
505 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
|
506 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
|
507 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
508 case SDL_KEYDOWN: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
509 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
|
510 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
511 case SDLK_ESCAPE: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
512 engine.exitFlag = TRUE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
513 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
514 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
515 default: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
516 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
517 } |
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 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
520 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
521 case SDL_VIDEORESIZE: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
522 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
|
523 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
|
524 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
525 if (!dmInitializeVideo()) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
526 goto error_exit; |
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 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
529 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
530 case SDL_VIDEOEXPOSE: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
531 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
532 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
533 case SDL_QUIT: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
534 engine.exitFlag = TRUE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
535 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
536 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
537 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
538 // Draw frame |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
539 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
|
540 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
541 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
|
542 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
543 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
544 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
545 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
|
546 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
|
547 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
548 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
|
549 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
550 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
551 JSS_LOCK(dev); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
552 JSS_LOCK(plr); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
553 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
554 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
|
555 "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
|
556 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
|
557 ); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
558 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
559 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
|
560 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
|
561 JSS_UNLOCK(plr); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
562 JSS_UNLOCK(dev); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
563 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
564 // Flip screen |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
565 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
|
566 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
|
567 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
568 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
|
569 SDL_Delay(10); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
570 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
571 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
572 error_exit: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
573 SDL_PauseAudio(1); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
574 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
575 if (engine.screen) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
576 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
|
577 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
578 SDL_LockAudio(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
579 jmpClose(plr); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
580 jvmClose(dev); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
581 jssFreeModule(mod); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
582 SDL_UnlockAudio(); |
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 dmFreeBitmapFont(font); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
585 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
586 if (initSDL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
587 SDL_Quit(); |
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 jssClose(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
590 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
591 return 0; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
592 } |