Mercurial > hg > dmlib
annotate ppl.c @ 137:f721f9f7838a
Remove toupper() from custom text drawing.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Fri, 05 Oct 2012 05:26:54 +0300 |
parents | 1d7dc7c8745c |
children | ead759da30b4 |
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 |
130
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
161 void dmDrawBMTextConstQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt) |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
162 { |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
163 const char *ptr = fmt; |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
164 DMUnscaledBlitFunc blit = NULL; |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
165 |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
166 while (*ptr) |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
167 { |
137
f721f9f7838a
Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
130
diff
changeset
|
168 int ch = *ptr++; |
130
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
169 SDL_Surface *glyph; |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
170 |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
171 if (ch == '_') |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
172 { |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
173 xc += 4; |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
174 continue; |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
175 } |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
176 |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
177 if (ch >= 0 && ch < font->nglyphs && (glyph = font->glyphs[ch]) != NULL) |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
178 { |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
179 if (blit == NULL) |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
180 blit = dmGetUnscaledBlitFunc(glyph->format, screen->format, mode); |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
181 |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
182 blit(glyph, xc, yc, screen); |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
183 xc += font->width; |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
184 } |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
185 else |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
186 xc += font->width; |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
187 } |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
188 } |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
189 |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
190 |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
191 void dmDrawBMTextVAQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, va_list ap) |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
192 { |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
193 char *tmp = dm_strdup_vprintf(fmt, ap); |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
194 if (tmp != NULL) |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
195 { |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
196 dmDrawBMTextConstQ(screen, font, mode, xc, yc, tmp); |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
197 dmFree(tmp); |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
198 } |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
199 } |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
200 |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
201 |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
202 void dmDrawBMTextQ(SDL_Surface *screen, DMBitmapFont *font, int mode, int xc, int yc, const char *fmt, ...) |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
203 { |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
204 va_list ap; |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
205 |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
206 va_start(ap, fmt); |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
207 dmDrawBMTextVAQ(screen, font, mode, xc, yc, fmt, ap); |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
208 va_end(ap); |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
209 } |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
210 |
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
211 |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
212 Uint32 dmCol(float r, float g, float b) |
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
213 { |
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
214 return dmMapRGB(engine.screen, 255.0f * r, 255.0f * g, 255.0f * b); |
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
215 } |
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
216 |
130
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
217 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
218 BOOL dmInitializeVideo() |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
219 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
220 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
|
221 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
|
222 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
|
223 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
224 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
|
225 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
226 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
|
227 return FALSE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
228 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
229 |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
230 col.inboxBg = dmCol(0.6, 0.5, 0.2); |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
231 col.boxBg = dmCol(0.7, 0.6, 0.3); |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
232 col.box1 = dmCol(1.0, 0.9, 0.6); |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
233 col.box2 = dmCol(0.3, 0.3, 0.15); |
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
234 col.viewDiv = dmCol(0,0,0); |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
235 col.activeRow = dmCol(0.5,0.4,0.1); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
236 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
237 return TRUE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
238 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
239 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
240 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
241 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
|
242 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
243 "C-", "C#", "D-", |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
244 "D#", "E-", "F-", |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
245 "F#", "G-", "G#", |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
246 "A-", "A#", "B-" |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
247 }; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
248 |
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 #define jmpNMODEffectTable (36) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
251 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
|
252 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
253 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
|
254 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
255 char text[32]; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
256 char *ptr = text; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
257 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
258 switch (n->note) |
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 case jsetNotSet: |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
261 sprintf(ptr, "..._"); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
262 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
263 case jsetNoteOff: |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
264 sprintf(ptr, "===_"); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
265 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
266 default: |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
267 sprintf(ptr, "%s%i_", |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
268 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
|
269 n->note / 12); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
270 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
271 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
272 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
273 ptr += 4; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
274 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
275 if (n->instrument != jsetNotSet) |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
276 sprintf(ptr, "%.2x_", n->instrument + 1); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
277 else |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
278 sprintf(ptr, ".._"); |
71
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 ptr += 3; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
281 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
282 if (n->volume == jsetNotSet) |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
283 sprintf(ptr, ".._"); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
284 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
285 if (n->volume >= 0x00 && n->volume <= 0x40) |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
286 sprintf(ptr, "%.2x_", n->volume); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
287 else |
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 char c; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
290 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
|
291 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
292 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
|
293 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
|
294 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
|
295 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
|
296 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
|
297 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
|
298 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
|
299 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
|
300 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
|
301 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
|
302 default: c = '?'; break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
303 } |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
304 sprintf(ptr, "%c%x_", c, (n->volume & 0x0f)); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
305 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
306 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
307 ptr += 3; |
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 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
|
310 *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
|
311 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
312 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
|
313 *ptr = '.'; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
314 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
315 *ptr = '?'; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
316 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
317 ptr += 1; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
318 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
319 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
|
320 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
|
321 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
322 sprintf(ptr, ".."); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
323 |
130
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
324 dmDrawBMTextConstQ(screen, font, DMD_TRANSPARENT, xc, yc, text); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
325 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
326 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
327 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
328 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
|
329 { |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
330 int cwidth = (font->width * 10 + 3 * 4 + 5), |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
331 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
|
332 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
|
333 qheight = ((y1 - y0 - 4) / (font->height + 1)), |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
334 nrow, nchannel, yc, |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
335 midrow = qheight / 2; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
336 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
337 dmDrawBox3D(screen, x0 + lwidth, y0, x1, y1, |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
338 col.inboxBg, col.box2, col.box1); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
339 |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
340 yc = y0 + 2 + (font->height + 1) * midrow; |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
341 dmFillRect(screen, x0 + lwidth + 1, yc - 1, x1 - 1, yc + font->height, col.activeRow); |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
342 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
343 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
|
344 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
345 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
|
346 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
347 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
348 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
|
349 { |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
350 int crow = nrow - midrow + row; |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
351 yc = y0 + 2 + (font->height + 1) * nrow; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
352 |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
353 if (crow >= 0 && crow < pat->nrows) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
354 { |
130
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
355 dmDrawBMTextQ(screen, font, DMD_TRANSPARENT, x0, yc, "%03d", crow); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
356 |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
357 for (nchannel = 0; nchannel < qwidth; nchannel++) |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
358 { |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
359 if (choffs + nchannel >= pat->nchannels) |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
360 break; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
361 |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
362 dmPrintNote(screen, x0 + lwidth + 4 + nchannel * cwidth, yc, |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
363 pat->data + (pat->nchannels * crow) + choffs + nchannel); |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
364 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
365 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
366 } |
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 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
369 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
370 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
|
371 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
372 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
|
373 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
374 if (d != NULL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
375 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
376 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
|
377 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
378 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
379 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
380 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
381 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
|
382 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
383 BOOL initSDL = FALSE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
384 DMResource *file = NULL; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
385 JSSModule *mod = NULL; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
386 JSSMixer *dev = NULL; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
387 JSSPlayer *plr = NULL; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
388 SDL_AudioSpec afmt; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
389 int result = -1; |
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 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
|
392 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
|
393 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
394 engine.optScrWidth = 640; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
395 engine.optScrHeight = 480; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
396 engine.optScrDepth = 32; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
397 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
398 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
|
399 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
400 // Parse arguments |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
401 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
|
402 argHandleOpt, argHandleFile, TRUE)) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
403 exit(1); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
404 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
405 // Open the files |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
406 if (optFilename == NULL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
407 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
408 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
|
409 return 1; |
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 |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
412 if ((file = dmf_create_stdio(optFilename, "rb")) == NULL) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
413 { |
80 | 414 dmError("Error opening file '%s', %d: (%s)\n", |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
415 optFilename, errno, strerror(errno)); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
416 return 1; |
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 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
419 // Initialize miniJSS |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
420 jssInit(); |
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 // Read module file |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
423 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
|
424 #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
|
425 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
|
426 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
|
427 #endif |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
428 #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
|
429 if (result != 0) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
430 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
431 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
|
432 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
|
433 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
|
434 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
|
435 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
|
436 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
437 dmf_close(file); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
438 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
|
439 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
|
440 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
441 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
442 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
|
443 dmFree(buf); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
444 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
445 #endif |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
446 dmf_close(file); |
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 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
|
449 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
450 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
|
451 result, dmErrorStr(result)); |
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 // 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
|
456 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
|
457 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
458 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
|
459 result, dmErrorStr(result)); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
460 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
461 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
462 |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
463 #if 0 |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
464 if ((file = dmf_create_stdio(optFontFilename, "rb")) == NULL) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
465 { |
80 | 466 dmError("Error opening font file '%s', %d: %s\n", |
467 optFontFilename, errno, strerror(errno)); | |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
468 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
469 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
470 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
|
471 dmf_close(file); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
472 if (fontbmap == NULL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
473 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
474 dmError("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
|
475 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
476 } |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
477 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
478 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
|
479 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
480 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
|
481 result, dmErrorStr(result)); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
482 goto error_exit; |
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 SDL_FreeSurface(fontbmap); |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
485 #else |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
486 if ((file = dmf_create_stdio("fnsmall.fnt", "rb")) == NULL) |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
487 { |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
488 dmError("Error opening font file '%s', %d: %s\n", |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
489 optFontFilename, errno, strerror(errno)); |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
490 goto error_exit; |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
491 } |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
492 result = dmLoadBitmapFont(file, &font); |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
493 dmf_close(file); |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
494 if (result != DMERR_OK) |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
495 { |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
496 dmError("Could not load font from file, %d: %s\n", |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
497 result, dmErrorStr(result)); |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
498 goto error_exit; |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
499 } |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
500 #endif |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
501 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
502 // Initialize SDL components |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
503 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
|
504 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
505 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
|
506 goto error_exit; |
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 initSDL = TRUE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
509 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
510 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
511 // Initialize mixing device |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
512 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
|
513 optOutFormat, optOutChannels, optOutFreq); |
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 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
|
516 if (dev == NULL) |
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 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
|
519 goto error_exit; |
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 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
522 switch (optOutFormat) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
523 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
524 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
|
525 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
|
526 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
|
527 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
|
528 default: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
529 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
|
530 optOutFormat); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
531 goto error_exit; |
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 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
534 afmt.freq = optOutFreq; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
535 afmt.channels = optOutChannels; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
536 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
|
537 afmt.callback = audioCallback; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
538 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
|
539 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
540 // 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
|
541 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
|
542 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
543 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
|
544 SDL_GetError()); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
545 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
546 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
547 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
548 // Initialize player |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
549 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
|
550 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
551 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
|
552 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
553 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
554 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
555 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
|
556 jmpSetModule(plr, mod); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
557 jmpPlayOrder(plr, 0); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
558 jvmSetGlobalVol(dev, 60); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
559 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
560 // Initialize video |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
561 if (!dmInitializeVideo()) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
562 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
563 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
564 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
|
565 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
566 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
567 // 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
|
568 SDL_PauseAudio(0); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
569 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
570 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
|
571 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
572 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
|
573 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
|
574 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
575 case SDL_KEYDOWN: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
576 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
|
577 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
578 case SDLK_ESCAPE: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
579 engine.exitFlag = TRUE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
580 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
581 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
582 default: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
583 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
584 } |
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 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
587 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
588 case SDL_VIDEORESIZE: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
589 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
|
590 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
|
591 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
592 if (!dmInitializeVideo()) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
593 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
594 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
595 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
596 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
597 case SDL_VIDEOEXPOSE: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
598 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
599 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
600 case SDL_QUIT: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
601 engine.exitFlag = TRUE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
602 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
603 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
604 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
605 // Draw frame |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
606 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
|
607 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
608 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
|
609 goto error_exit; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
610 } |
137
f721f9f7838a
Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
130
diff
changeset
|
611 |
f721f9f7838a
Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
130
diff
changeset
|
612 #if 1 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
613 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
|
614 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
|
615 |
130
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
616 dmDrawBMTextQ(engine.screen, font, DMD_TRANSPARENT, 5, 5, "%s v%s by ccr/TNSP - (c) Copyright 2012 TNSP", dmProgDesc, dmProgVersion); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
617 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
618 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
619 JSS_LOCK(dev); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
620 JSS_LOCK(plr); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
621 |
130
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
622 dmDrawBMTextQ(engine.screen, font, DMD_TRANSPARENT, 5, 5 + 12, |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
623 "Tempo: %3d | Speed: %3d | Row: %3d | Order: %d", |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
624 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
|
625 ); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
626 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
627 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
|
628 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
|
629 JSS_UNLOCK(plr); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
630 JSS_UNLOCK(dev); |
137
f721f9f7838a
Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
130
diff
changeset
|
631 #endif |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
632 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
633 // Flip screen |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
634 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
|
635 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
|
636 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
637 SDL_Flip(engine.screen); |
137
f721f9f7838a
Remove toupper() from custom text drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
130
diff
changeset
|
638 SDL_Delay(16); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
639 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
640 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
641 error_exit: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
642 SDL_PauseAudio(1); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
643 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
644 if (engine.screen) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
645 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
|
646 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
647 SDL_LockAudio(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
648 jmpClose(plr); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
649 jvmClose(dev); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
650 jssFreeModule(mod); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
651 SDL_UnlockAudio(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
652 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
653 dmFreeBitmapFont(font); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
654 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
655 if (initSDL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
656 SDL_Quit(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
657 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
658 jssClose(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
659 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
660 return 0; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
661 } |