Mercurial > hg > dmlib
annotate tools/ppl.c @ 2408:60e119262c67
Option index re-ordering cleanup work.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 13 Jan 2020 21:21:25 +0200 |
parents | b7cd5dd0b82e |
children | bc05bcfc4598 |
rev | line source |
---|---|
216
247b03797fc9
Rename player, add a copyright note.
Matti Hamalainen <ccr@tnsp.org>
parents:
203
diff
changeset
|
1 /* |
247b03797fc9
Rename player, add a copyright note.
Matti Hamalainen <ccr@tnsp.org>
parents:
203
diff
changeset
|
2 * Cyrbe Pasci Player - A simple SDL-based UI for XM module playing |
247b03797fc9
Rename player, add a copyright note.
Matti Hamalainen <ccr@tnsp.org>
parents:
203
diff
changeset
|
3 * Programmed and designed by Matti 'ccr' Hamalainen |
2283 | 4 * (C) Copyright 2012-2019 Tecnic Software productions (TNSP) |
216
247b03797fc9
Rename player, add a copyright note.
Matti Hamalainen <ccr@tnsp.org>
parents:
203
diff
changeset
|
5 * |
247b03797fc9
Rename player, add a copyright note.
Matti Hamalainen <ccr@tnsp.org>
parents:
203
diff
changeset
|
6 * Please read file 'COPYING' for information on license and distribution. |
247b03797fc9
Rename player, add a copyright note.
Matti Hamalainen <ccr@tnsp.org>
parents:
203
diff
changeset
|
7 */ |
643 | 8 #include "dmlib.h" |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
9 #include <SDL.h> |
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
10 #include "libgutil.h" |
643 | 11 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
12 #include "jss.h" |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
13 #include "jssmod.h" |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
14 #include "jssmix.h" |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
15 #include "jssplr.h" |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
16 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
17 #include "dmargs.h" |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
18 #include "dmimage.h" |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
19 #include "dmtext.h" |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
20 |
584
923d920a8a85
Build setupfont.h and setupimage.h from source data files. Use setupfont in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
559
diff
changeset
|
21 #include "setupfont.h" |
164
a49d431ff40e
Add a hardcoded font to PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
159
diff
changeset
|
22 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
23 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
24 struct |
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 BOOL exitFlag; |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
27 |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
28 SDL_Window *window; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
29 SDL_Renderer *renderer; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
30 SDL_Texture *texture; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
31 SDL_Surface *screen; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
32 SDL_Event event; |
1556 | 33 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
34 int optScrWidth, optScrHeight, optVFlags, optScrDepth; |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
35 |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
36 int actChannel; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
37 BOOL pauseFlag; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
38 |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
39 JSSModule *mod; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
40 JSSMixer *dev; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
41 JSSPlayer *plr; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
42 SDL_AudioSpec afmt; |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
43 } eng; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
44 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
45 struct |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
46 { |
1555
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
47 Uint32 |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
48 boxBg, inboxBg, |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
49 box1, box2, |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
50 viewDiv, |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
51 activeRow, activeChannel, |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
52 scope, muted, black, red; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
53 } col; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
54 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
55 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
56 DMBitmapFont *font = NULL; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
57 |
273 | 58 char *optFilename = NULL; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
59 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
|
60 optOutChannels = 2, |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
61 optOutFreq = 48000, |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
62 optMuteOChannels = -1, |
179
b29c9a2fbeb5
Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
63 optStartOrder = 0; |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
64 BOOL optUsePlayTime = FALSE, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
65 optUseGUI = TRUE; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
66 size_t optPlayTime; |
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 |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
diff
changeset
|
69 static const DMOptArg optList[] = |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
70 { |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
71 { 0, '?', "help" , "Show this help", OPT_NONE }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
72 { 2, 'v', "verbose" , "Be more verbose", OPT_NONE }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
73 |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
74 { 10, 0, "fs" , "Fullscreen", OPT_NONE }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
75 { 12, 'C', "cli" , "Do not open GUI window", OPT_NONE }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
76 { 14, 'w', "window" , "Initial window size/resolution -w 640x480", OPT_ARGREQ }, |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
77 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
78 { 16, '1', "16bit" , "16-bit output", OPT_NONE }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
79 { 18, '8', "8bit" , "8-bit output", OPT_NONE }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
80 { 20, 'm', "mono" , "Mono output", OPT_NONE }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
81 { 22, 's', "stereo" , "Stereo output", OPT_NONE }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
82 { 24, 'f', "freq" , "Output frequency", OPT_ARGREQ }, |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
83 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
84 { 28, 'M', "mute" , "Mute other channels than #", OPT_ARGREQ }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
85 { 30, 'o', "order" , "Start from order #", OPT_ARGREQ }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
86 { 32, 't', "time" , "Play for # seconds", OPT_ARGREQ }, |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
87 }; |
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 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
|
90 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
91 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 void argShowHelp() |
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 dmPrintBanner(stdout, dmProgName, "[options] <module>"); |
2402
b7cd5dd0b82e
Merge one more change from th-libs args processing.
Matti Hamalainen <ccr@tnsp.org>
parents:
2305
diff
changeset
|
95 dmArgsPrintHelp(stdout, optList, optListN, 0, 80 - 2); |
71
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 |
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 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
|
100 { |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
101 switch (optN) |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
102 { |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
103 case 0: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 argShowHelp(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 exit(0); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
108 case 2: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
109 dmVerbosity++; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
110 break; |
1238 | 111 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
112 case 10: |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
113 eng.optVFlags |= SDL_WINDOW_FULLSCREEN_DESKTOP; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
114 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
115 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
116 case 12: |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
117 optUseGUI = FALSE; |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
118 break; |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
119 |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
120 case 14: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
121 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
122 int w, h; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
123 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
|
124 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
125 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
|
126 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
127 dmErrorMsg("Invalid width or height: %d x %d\n", w, h); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
128 return FALSE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
129 } |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
130 eng.optScrWidth = w; |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
131 eng.optScrHeight = h; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
132 } |
1238 | 133 else |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
134 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
135 dmErrorMsg("Invalid size argument '%s'.\n", optArg); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
136 return FALSE; |
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 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
139 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
140 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
141 case 16: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
142 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
|
143 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
144 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
145 case 18: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
146 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
|
147 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
148 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
149 case 20: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
150 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
|
151 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
152 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
153 case 22: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
154 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
|
155 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
156 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
157 case 24: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
158 optOutFreq = atoi(optArg); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
159 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
160 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
161 case 28: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
162 optMuteOChannels = atoi(optArg); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
163 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
164 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
165 case 30: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
166 optStartOrder = atoi(optArg); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
167 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
168 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
169 case 32: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
170 optPlayTime = atoi(optArg); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
171 optUsePlayTime = TRUE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
172 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
173 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
174 default: |
2183
e3f0eaf23f4f
Change the error message for unimplemented option argument.
Matti Hamalainen <ccr@tnsp.org>
parents:
2102
diff
changeset
|
175 dmErrorMsg("Unimplemented option argument '%s'.\n", currArg); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
176 return FALSE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
177 } |
1238 | 178 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
179 return TRUE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
180 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
181 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
182 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
183 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
|
184 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
185 if (!optFilename) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
186 optFilename = currArg; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
187 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
188 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
189 dmErrorMsg("Too many filename arguments '%s'\n", currArg); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
190 return FALSE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
191 } |
1238 | 192 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
193 return TRUE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
194 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
195 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
196 |
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
197 static inline Uint32 dmCol(const float r, const float g, const float b) |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
198 { |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
199 return dmMapRGB(eng.screen, 255.0f * r, 255.0f * g, 255.0f * b); |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
200 } |
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
201 |
130
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
202 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
203 BOOL dmInitializeVideo() |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
204 { |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
205 SDL_DestroyTexture(eng.texture); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
206 SDL_FreeSurface(eng.screen); |
179
b29c9a2fbeb5
Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
207 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
208 if ((eng.texture = SDL_CreateTexture(eng.renderer, |
1561
b6ee934496d1
Make texture/surface creation better.
Matti Hamalainen <ccr@tnsp.org>
parents:
1559
diff
changeset
|
209 SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_STREAMING, |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
210 eng.optScrWidth, eng.optScrHeight)) == NULL) |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
211 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
212 dmErrorMsg("Could not create SDL texture.\n"); |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
213 return FALSE; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
214 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
215 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
216 if ((eng.screen = SDL_CreateRGBSurfaceWithFormat(0, |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
217 eng.optScrWidth, eng.optScrHeight, |
1564
d1e2f7a22fb8
Oops, 8 vs 32bits. Didn't seem to matter anyhow, though.
Matti Hamalainen <ccr@tnsp.org>
parents:
1562
diff
changeset
|
218 32, SDL_PIXELFORMAT_RGBA32)) == NULL) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
219 { |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
220 dmErrorMsg("Could not create SDL surface.\n"); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
221 return FALSE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
222 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
223 |
1555
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
224 col.black = dmCol(0 , 0 , 0); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
225 col.inboxBg = dmCol(0.6, 0.5, 0.2); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
226 col.boxBg = dmCol(0.7, 0.6, 0.3); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
227 col.box1 = dmCol(1.0, 0.9, 0.6); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
228 col.box2 = dmCol(0.3, 0.3, 0.15); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
229 col.viewDiv = dmCol(0 , 0 , 0); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
230 col.activeRow = dmCol(0.5, 0.4, 0.1); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
231 col.activeChannel = dmCol(0.6, 0.8, 0.2); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
232 col.muted = dmCol(0.3, 0.1, 0.1); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
233 col.scope = dmCol(0 , 0.8, 0); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
234 col.red = dmCol(1 , 0 , 0); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
235 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
236 return TRUE; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
237 } |
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 |
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
240 // |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
241 // XXX TODO: To display actual continuous sample data for channel, |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
242 // we would need to have separate "FIFO" buffers for each, updating |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
243 // them with new data from incoming channel data. |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
244 // |
165 | 245 void dmDisplayChn(SDL_Surface *screen, int x0, int y0, int x1, int y1, int nchannel, JSSChannel *chn) |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
246 { |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
247 int yh = y1 - y0 - 2; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
248 if (yh < 10 || chn == NULL) |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
249 return; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
250 |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
251 int xc, ym = y0 + (y1 - y0) / 2, vol = FP_GETH32(chn->chVolume); |
1556 | 252 DMFixedPoint offs = chn->chPos; |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
253 int len = FP_GETH32(chn->chSize); |
1556 | 254 Uint32 pitch = screen->pitch / sizeof(Uint32); |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
255 Uint32 *pix = screen->pixels; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
256 Sint16 *data = chn->chData; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
257 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
258 dmFillBox3D(screen, x0, y0, x1, y1, |
1555
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
259 (chn->chMute ? col.muted : col.black), |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
260 nchannel == eng.actChannel ? col.red : col.box2, |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
261 nchannel == eng.actChannel ? col.red : col.box1); |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
262 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
263 if (chn->chData == NULL || !chn->chPlaying) |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
264 return; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
265 |
274
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
266 if (chn->chDirection) |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
267 { |
274
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
268 for (xc = x0 + 1; xc < x1 - 1; xc++) |
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
269 { |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
270 if (FP_GETH32(offs) >= len) |
274
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
271 break; |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
272 Sint16 val = ym + (data[FP_GETH32(offs)] * yh * vol) / (65535 * 255); |
1555
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
273 pix[xc + val * pitch] = col.scope; |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
274 FP_ADD(offs, chn->chDeltaO); |
274
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
275 } |
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
276 } |
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
277 else |
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
278 { |
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
279 for (xc = x0 + 1; xc < x1 - 1; xc++) |
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
280 { |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
281 if (FP_GETH32(offs) < 0) |
274
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
282 break; |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
283 Sint16 val = ym + (data[FP_GETH32(offs)] * yh * vol) / (65535 * 255); |
1555
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
284 pix[xc + val * pitch] = col.scope; |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
285 FP_SUB(offs, chn->chDeltaO); |
274
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
286 } |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
287 } |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
288 } |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
289 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
290 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
291 void dmDisplayChannels(SDL_Surface *screen, int x0, int y0, int x1, int y1, JSSMixer *dev) |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
292 { |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
293 int nchannel, qx, qy, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
294 qwidth = x1 - x0, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
295 qheight = y1 - y0, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
296 nwidth = jsetNChannels, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
297 nheight = 1; |
1238 | 298 |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
299 if (qheight < 40) |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
300 return; |
1238 | 301 |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
302 while (qwidth / nwidth <= 60 && qheight / nheight >= 40) |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
303 { |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
304 nheight++; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
305 nwidth /= nheight; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
306 } |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
307 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
308 // fprintf(stderr, "%d x %d\n", nwidth, nheight); |
1238 | 309 |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
310 if (qheight / nheight <= 40) |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
311 { |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
312 nwidth = qwidth / 60; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
313 nheight = qheight / 40; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
314 } |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
315 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
316 qwidth /= nwidth; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
317 qheight /= nheight; |
1238 | 318 |
165 | 319 for (nchannel = qy = 0; qy < nheight && nchannel < jsetNChannels; qy++) |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
320 { |
165 | 321 for (qx = 0; qx < nwidth && nchannel < jsetNChannels; qx++) |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
322 { |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
323 int xc = x0 + qx * qwidth, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
324 yc = y0 + qy * qheight; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
325 |
165 | 326 dmDisplayChn(screen, xc + 1, yc + 1, |
327 xc + qwidth - 1, yc + qheight - 1, | |
328 nchannel, &dev->channels[nchannel]); | |
329 | |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
330 nchannel++; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
331 } |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
332 } |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
333 } |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
334 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
335 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
336 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
|
337 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
338 "C-", "C#", "D-", |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
339 "D#", "E-", "F-", |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
340 "F#", "G-", "G#", |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
341 "A-", "A#", "B-" |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
342 }; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
343 |
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 #define jmpNMODEffectTable (36) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
346 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
|
347 |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
348 static const char jmpHexTab[16] = "0123456789ABCDEF"; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
349 |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
350 static inline char dmHexVal(int v) |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
351 { |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
352 return jmpHexTab[v & 15]; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
353 } |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
354 |
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
355 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
356 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
|
357 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
358 char text[32]; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
359 char *ptr = text; |
1238 | 360 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
361 switch (n->note) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
362 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
363 case jsetNotSet: |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
364 strcpy(ptr, "..._"); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
365 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
366 case jsetNoteOff: |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
367 strcpy(ptr, "===_"); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
368 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
369 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
|
370 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
|
371 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
|
372 n->note / 12); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
373 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
374 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
375 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
376 ptr += 4; |
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 if (n->instrument != jsetNotSet) |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
379 { |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
380 int v = n->instrument + 1; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
381 *ptr++ = dmHexVal(v >> 4); |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
382 *ptr++ = dmHexVal(v); |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
383 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
384 else |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
385 { |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
386 *ptr++ = '.'; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
387 *ptr++ = '.'; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
388 } |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
389 *ptr++ = '_'; |
71
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 if (n->volume == jsetNotSet) |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
392 { |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
393 *ptr++ = '.'; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
394 *ptr++ = '.'; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
395 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
396 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
397 if (n->volume >= 0x00 && n->volume <= 0x40) |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
398 { |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
399 *ptr++ = dmHexVal(n->volume >> 4); |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
400 *ptr++ = dmHexVal(n->volume); |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
401 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
402 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
403 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
404 char c; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
405 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
|
406 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
407 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
|
408 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
|
409 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
|
410 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
|
411 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
|
412 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
|
413 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
|
414 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
|
415 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
|
416 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
|
417 default: c = '?'; break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
418 } |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
419 *ptr++ = c; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
420 *ptr++ = dmHexVal(n->volume); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
421 } |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
422 *ptr++ = '_'; |
1238 | 423 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
424 if (n->effect >= 0 && n->effect < jmpNMODEffectTable) |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
425 *ptr++ = jmpMODEffectTable[n->effect]; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
426 else |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
427 *ptr++ = (n->effect == jsetNotSet ? '.' : '?'); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
428 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
429 if (n->param != jsetNotSet) |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
430 { |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
431 *ptr++ = dmHexVal(n->param >> 4); |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
432 *ptr++ = dmHexVal(n->param); |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
433 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
434 else |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
435 { |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
436 *ptr++ = '.'; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
437 *ptr++ = '.'; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
438 } |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
439 |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
440 *ptr = 0; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
441 |
130
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
442 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
|
443 } |
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 |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
446 void dmDisplayPattern(SDL_Surface *screen, int x0, int y0, int x1, int y1, JSSPattern *pat, int row) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
447 { |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
448 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
|
449 lwidth = 6 + font->width * 3, |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
450 qy0 = y0 + font->height + 2, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
451 qy1 = y1 - font->height - 2, |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
452 qwidth = ((x1 - x0 - lwidth) / cwidth), |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
453 qheight = ((qy1 - qy0 - 4) / (font->height + 1)), |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
454 nrow, nchannel, yc, choffs, |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
455 midrow = qheight / 2; |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
456 |
1258
13c274d22a29
Add some extra error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
1238
diff
changeset
|
457 if (pat == NULL) |
13c274d22a29
Add some extra error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
1238
diff
changeset
|
458 return; |
13c274d22a29
Add some extra error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
1238
diff
changeset
|
459 |
1962
951e07b80b40
If pattern has less channels than what fits on the screen, and active
Matti Hamalainen <ccr@tnsp.org>
parents:
1956
diff
changeset
|
460 if (qwidth > pat->nchannels) |
951e07b80b40
If pattern has less channels than what fits on the screen, and active
Matti Hamalainen <ccr@tnsp.org>
parents:
1956
diff
changeset
|
461 qwidth = pat->nchannels; |
951e07b80b40
If pattern has less channels than what fits on the screen, and active
Matti Hamalainen <ccr@tnsp.org>
parents:
1956
diff
changeset
|
462 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
463 if (eng.actChannel < qwidth / 2) |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
464 choffs = 0; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
465 else |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
466 if (eng.actChannel >= pat->nchannels - qwidth/2) |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
467 choffs = pat->nchannels - qwidth; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
468 else |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
469 choffs = eng.actChannel - qwidth/2; |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
470 |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
471 dmDrawBox3D(screen, x0 + lwidth, qy0, x1, qy1, col.box2, col.box1); |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
472 |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
473 for (nchannel = 0; nchannel < qwidth; nchannel++) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
474 { |
1238 | 475 int bx0 = x0 + lwidth + 1 + nchannel * cwidth, |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
476 bx1 = bx0 + cwidth; |
1098 | 477 |
478 dmFillRect(screen, bx0+1, qy0+1, bx1-1, qy1-1, | |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
479 (eng.actChannel == nchannel + choffs) ? col.activeChannel : col.inboxBg); |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
480 } |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
481 |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
482 yc = qy0 + 2 + (font->height + 1) * midrow; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
483 dmFillRect(screen, x0 + lwidth + 1, yc - 1, x1 - 1, yc + font->height, col.activeRow); |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
484 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
485 for (nchannel = 0; nchannel < qwidth; nchannel++) |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
486 { |
1238 | 487 int bx0 = x0 + lwidth + 1 + nchannel * cwidth, |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
488 bx1 = bx0 + cwidth; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
489 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
490 dmDrawVLine(screen, qy0 + 1, qy1 - 1, bx1, col.viewDiv); |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
491 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
492 if (jvmGetMute(eng.dev, nchannel + choffs)) |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
493 { |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
494 dmDrawBMTextConstQ(screen, font, DMD_TRANSPARENT, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
495 bx0 + (cwidth - font->width * 5) / 2, qy1 + 3, "MUTED"); |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
496 } |
1238 | 497 |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
498 dmDrawBMTextQ(screen, font, DMD_TRANSPARENT, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
499 bx0 + (cwidth - font->width * 3) / 2, y0 + 1, "%3d", |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
500 nchannel + choffs); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
501 } |
1238 | 502 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
503 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
|
504 { |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
505 int crow = nrow - midrow + row; |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
506 yc = qy0 + 2 + (font->height + 1) * nrow; |
1238 | 507 |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
508 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
|
509 { |
130
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
510 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
|
511 |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
512 for (nchannel = 0; nchannel < qwidth; nchannel++) |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
513 { |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
514 if (choffs + nchannel >= pat->nchannels) |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
515 break; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
516 |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
517 dmPrintNote(screen, x0 + lwidth + 4 + nchannel * cwidth, yc, |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
518 pat->data + (pat->nchannels * crow) + choffs + nchannel); |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
519 } |
71
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 } |
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 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
525 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
|
526 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
527 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
|
528 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
529 if (d != NULL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
530 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
531 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
|
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 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
535 |
203
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
536 void dmMuteChannels(BOOL mute) |
198
4568c479541c
Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
537 { |
2305 | 538 for (int i = 0; i < eng.mod->nchannels; i++) |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
539 jvmMute(eng.dev, i, mute); |
198
4568c479541c
Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
540 } |
4568c479541c
Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
541 |
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
542 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
543 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
|
544 { |
290 | 545 BOOL initSDL = FALSE, audioInit = FALSE; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
546 DMResource *file = NULL; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
547 int result = -1; |
203
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
548 BOOL muteState = FALSE; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
549 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
550 dmMemset(&eng, 0, sizeof(eng)); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
551 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
552 eng.optScrWidth = 640; |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
553 eng.optScrHeight = 480; |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
554 eng.optScrDepth = 32; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
555 |
1562
83979ecc6576
Bump version and copyright of PPL/CBP.
Matti Hamalainen <ccr@tnsp.org>
parents:
1561
diff
changeset
|
556 dmInitProg("CBP", "Cyrbe Basci Player", "0.2", NULL, NULL); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
557 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
558 // Parse arguments |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
559 if (!dmArgsProcess(argc, argv, optList, optListN, |
860
daebbf28953d
The argument handling API in dmargs* was synced with th-libs.
Matti Hamalainen <ccr@tnsp.org>
parents:
809
diff
changeset
|
560 argHandleOpt, argHandleFile, OPTH_BAILOUT)) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
561 exit(1); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
562 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
563 // Open the files |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
564 if (optFilename == NULL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
565 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
566 dmErrorMsg("No filename specified.\n"); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
567 return 1; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
568 } |
1238 | 569 |
1606
93d1050eac99
Rename dmf_create_*() functions to dmf_open_*().
Matti Hamalainen <ccr@tnsp.org>
parents:
1602
diff
changeset
|
570 if ((result = dmf_open_stdio(optFilename, "rb", &file)) != DMERR_OK) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
571 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
572 dmErrorMsg("Error opening file '%s', %d: (%s)\n", |
730
3d813c81f33c
More work on resources API.
Matti Hamalainen <ccr@tnsp.org>
parents:
652
diff
changeset
|
573 optFilename, result, dmErrorStr(result)); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
574 return 1; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
575 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
576 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
577 // Initialize miniJSS |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
578 jssInit(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
579 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
580 // Read module file |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
581 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
|
582 #ifdef JSS_SUP_XM |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
583 result = jssLoadXM(file, &eng.mod, TRUE); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
584 #endif |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
585 #ifdef JSS_SUP_JSSMOD |
1199
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
1167
diff
changeset
|
586 dmfreset(file); |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
1167
diff
changeset
|
587 if (result != DMERR_OK) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
588 { |
777
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
745
diff
changeset
|
589 dmMsg(1, "* Trying JSSMOD ...\n"); |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
590 result = jssLoadJSSMOD(file, &eng.mod, TRUE); |
1199
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
1167
diff
changeset
|
591 dmfreset(file); |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
1167
diff
changeset
|
592 if (result == DMERR_OK) |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
593 result = jssLoadJSSMOD(file, &eng.mod, FALSE); |
1199
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
1167
diff
changeset
|
594 } |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
1167
diff
changeset
|
595 else |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
1167
diff
changeset
|
596 { |
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
1167
diff
changeset
|
597 dmMsg(2, "* Trying XM...\n"); |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
598 result = jssLoadXM(file, &eng.mod, FALSE); |
71
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 #endif |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
601 dmf_close(file); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
602 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
603 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
|
604 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
605 dmErrorMsg("Error loading module file, %d: %s\n", |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
606 result, dmErrorStr(result)); |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
607 goto exit; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
608 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
609 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
610 // Try to convert it |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
611 if ((result = jssConvertModuleForPlaying(eng.mod)) != DMERR_OK) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
612 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
613 dmErrorMsg("Could not convert module for playing, %d: %s\n", |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
614 result, dmErrorStr(result)); |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
615 goto exit; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
616 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
617 |
1971
c27f7cd25684
Set the PPL font palette to be more appropriate.
Matti Hamalainen <ccr@tnsp.org>
parents:
1970
diff
changeset
|
618 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
619 // Initialize SDL components |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
620 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
|
621 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
622 dmErrorMsg("Could not initialize SDL: %s\n", SDL_GetError()); |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
623 goto exit; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
624 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
625 initSDL = TRUE; |
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 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
628 // Initialize mixing device |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
629 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
|
630 optOutFormat, optOutChannels, optOutFreq); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
631 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
632 eng.dev = jvmInit(optOutFormat, optOutChannels, optOutFreq, JMIX_AUTO); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
633 if (eng.dev == NULL) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
634 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
635 dmErrorMsg("jvmInit() returned NULL\n"); |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
636 goto exit; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
637 } |
1238 | 638 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
639 switch (optOutFormat) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
640 { |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
641 case JSS_AUDIO_S16: eng.afmt.format = AUDIO_S16SYS; break; |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
642 case JSS_AUDIO_U16: eng.afmt.format = AUDIO_U16SYS; break; |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
643 case JSS_AUDIO_S8: eng.afmt.format = AUDIO_S8; break; |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
644 case JSS_AUDIO_U8: eng.afmt.format = AUDIO_U8; break; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
645 default: |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
646 dmErrorMsg("Unsupported audio format %d (could not set matching SDL format)\n", |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
647 optOutFormat); |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
648 goto exit; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
649 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
650 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
651 eng.afmt.freq = optOutFreq; |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
652 eng.afmt.channels = optOutChannels; |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
653 eng.afmt.samples = optOutFreq / 16; |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
654 eng.afmt.callback = audioCallback; |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
655 eng.afmt.userdata = (void *) eng.dev; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
656 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
657 // Open the audio device |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
658 if (SDL_OpenAudio(&eng.afmt, NULL) < 0) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
659 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
660 dmErrorMsg("Couldn't open SDL audio: %s\n", |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
661 SDL_GetError()); |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
662 goto exit; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
663 } |
290 | 664 audioInit = TRUE; |
1238 | 665 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
666 // Initialize player |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
667 if ((eng.plr = jmpInit(eng.dev)) == NULL) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
668 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
669 dmErrorMsg("jmpInit() returned NULL\n"); |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
670 goto exit; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
671 } |
1238 | 672 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
673 jvmSetCallback(eng.dev, jmpExec, eng.plr); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
674 jmpSetModule(eng.plr, eng.mod); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
675 jmpPlayOrder(eng.plr, optStartOrder); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
676 jvmSetGlobalVol(eng.dev, 200); |
190
87b46e61f2c4
Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
677 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
678 if (optMuteOChannels >= 0 && optMuteOChannels < eng.mod->nchannels) |
190
87b46e61f2c4
Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
679 { |
203
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
680 dmMuteChannels(TRUE); |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
681 jvmMute(eng.dev, optMuteOChannels, FALSE); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
682 eng.actChannel = optMuteOChannels; |
203
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
683 muteState = TRUE; |
190
87b46e61f2c4
Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
684 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
685 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
686 if (optUseGUI) |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
687 { |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
688 // Get font |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
689 result = dmf_open_memio(NULL, "pplfont.fnt", engineSetupFont, sizeof(engineSetupFont), &file); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
690 if (result != DMERR_OK) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
691 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
692 dmErrorMsg("Error opening font file 'pplfont.fnt', #%d: %s\n", |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
693 result, dmErrorStr(result)); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
694 goto exit; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
695 } |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
696 result = dmLoadBitmapFont(file, &font); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
697 dmf_close(file); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
698 if (result != DMERR_OK) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
699 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
700 dmErrorMsg("Could not load font from file, %d: %s\n", |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
701 result, dmErrorStr(result)); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
702 goto exit; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
703 } |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
704 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
705 SDL_Color pal[DMFONT_NPALETTE]; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
706 for (int n = 0; n < DMFONT_NPALETTE; n++) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
707 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
708 pal[n].r = pal[n].g = pal[n].b = 0; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
709 pal[n].a = n > 0 ? 255 : 0; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
710 } |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
711 dmSetBitmapFontPalette(font, pal, 0, DMFONT_NPALETTE); |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
712 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
713 // Open window |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
714 if ((eng.window = SDL_CreateWindow(dmProgName, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
715 SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
716 eng.optScrWidth, eng.optScrHeight, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
717 eng.optVFlags | SDL_WINDOW_RESIZABLE |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
718 //| SDL_WINDOW_HIDDEN |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
719 )) == NULL) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
720 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
721 dmErrorMsg("Can't create an SDL window: %s\n", SDL_GetError()); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
722 goto exit; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
723 } |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
724 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
725 SDL_SetWindowTitle(eng.window, dmProgDesc); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
726 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
727 if ((eng.renderer = SDL_CreateRenderer(eng.window, -1, SDL_RENDERER_PRESENTVSYNC)) == NULL) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
728 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
729 dmErrorMsg("Can't create an SDL renderer: %s\n", SDL_GetError()); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
730 goto exit; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
731 } |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
732 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
733 if (!dmInitializeVideo()) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
734 goto exit; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
735 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
736 //SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "best"); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
737 //SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
738 } |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
739 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
740 // okay, main loop here ... "play" module and print out info |
275 | 741 SDL_LockAudio(); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
742 SDL_PauseAudio(0); |
275 | 743 SDL_UnlockAudio(); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
744 |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
745 int currTick, prevTick = 0, prevRow = -1; |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
746 while (!eng.exitFlag) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
747 { |
176 | 748 currTick = SDL_GetTicks(); |
1568
61495ea0767e
Rename some variables to be more meaningful.
Matti Hamalainen <ccr@tnsp.org>
parents:
1564
diff
changeset
|
749 BOOL needUpdate = (currTick - prevTick > 500), |
61495ea0767e
Rename some variables to be more meaningful.
Matti Hamalainen <ccr@tnsp.org>
parents:
1564
diff
changeset
|
750 needRender = FALSE; |
176 | 751 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
752 while (SDL_PollEvent(&eng.event)) |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
753 switch (eng.event.type) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
754 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
755 case SDL_KEYDOWN: |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
756 switch (eng.event.key.keysym.sym) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
757 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
758 case SDLK_ESCAPE: |
1568
61495ea0767e
Rename some variables to be more meaningful.
Matti Hamalainen <ccr@tnsp.org>
parents:
1564
diff
changeset
|
759 case SDLK_q: |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
760 eng.exitFlag = TRUE; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
761 break; |
1238 | 762 |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
763 case SDLK_SPACE: |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
764 eng.pauseFlag = !eng.pauseFlag; |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
765 SDL_PauseAudio(eng.pauseFlag); |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
766 break; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
767 |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
768 case SDLK_LEFT: |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
769 if (eng.actChannel > 0) |
176 | 770 { |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
771 eng.actChannel--; |
1568
61495ea0767e
Rename some variables to be more meaningful.
Matti Hamalainen <ccr@tnsp.org>
parents:
1564
diff
changeset
|
772 needUpdate = TRUE; |
176 | 773 } |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
774 break; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
775 |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
776 case SDLK_RIGHT: |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
777 if (eng.actChannel < eng.mod->nchannels - 1) |
176 | 778 { |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
779 eng.actChannel++; |
1568
61495ea0767e
Rename some variables to be more meaningful.
Matti Hamalainen <ccr@tnsp.org>
parents:
1564
diff
changeset
|
780 needUpdate = TRUE; |
176 | 781 } |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
782 break; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
783 |
198
4568c479541c
Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
784 case SDLK_m: |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
785 if (eng.event.key.keysym.mod & KMOD_SHIFT) |
203
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
786 { |
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
787 muteState = !muteState; |
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
788 dmMuteChannels(muteState); |
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
789 } |
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
790 else |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
791 if (eng.event.key.keysym.mod & KMOD_CTRL) |
203
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
792 { |
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
793 dmMuteChannels(FALSE); |
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
794 } |
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
795 else |
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
796 { |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
797 jvmMute(eng.dev, eng.actChannel, !jvmGetMute(eng.dev, eng.actChannel)); |
203
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
798 } |
1568
61495ea0767e
Rename some variables to be more meaningful.
Matti Hamalainen <ccr@tnsp.org>
parents:
1564
diff
changeset
|
799 needUpdate = TRUE; |
198
4568c479541c
Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
800 break; |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
801 |
167
e281663f04ba
Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
802 case SDLK_PAGEUP: |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
803 JSS_LOCK(eng.dev); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
804 JSS_LOCK(eng.plr); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
805 jmpChangeOrder(eng.plr, dmClamp(eng.plr->order - 1, 0, eng.mod->norders)); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
806 JSS_UNLOCK(eng.plr); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
807 JSS_UNLOCK(eng.dev); |
1568
61495ea0767e
Rename some variables to be more meaningful.
Matti Hamalainen <ccr@tnsp.org>
parents:
1564
diff
changeset
|
808 needUpdate = TRUE; |
167
e281663f04ba
Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
809 break; |
e281663f04ba
Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
810 |
e281663f04ba
Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
811 case SDLK_PAGEDOWN: |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
812 JSS_LOCK(eng.dev); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
813 JSS_LOCK(eng.plr); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
814 jmpChangeOrder(eng.plr, dmClamp(eng.plr->order + 1, 0, eng.mod->norders)); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
815 JSS_UNLOCK(eng.plr); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
816 JSS_UNLOCK(eng.dev); |
1568
61495ea0767e
Rename some variables to be more meaningful.
Matti Hamalainen <ccr@tnsp.org>
parents:
1564
diff
changeset
|
817 needUpdate = TRUE; |
167
e281663f04ba
Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
818 break; |
e281663f04ba
Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
819 |
179
b29c9a2fbeb5
Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
820 case SDLK_f: |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
821 eng.optVFlags ^= SDL_WINDOW_FULLSCREEN_DESKTOP; |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
822 if (SDL_SetWindowFullscreen(eng.window, eng.optVFlags) != 0) |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
823 goto exit; |
1568
61495ea0767e
Rename some variables to be more meaningful.
Matti Hamalainen <ccr@tnsp.org>
parents:
1564
diff
changeset
|
824 needUpdate = TRUE; |
179
b29c9a2fbeb5
Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
825 break; |
b29c9a2fbeb5
Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
826 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
827 default: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
828 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
829 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
830 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
831 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
832 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
833 case SDL_WINDOWEVENT: |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
834 switch (eng.event.window.event) |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
835 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
836 case SDL_WINDOWEVENT_EXPOSED: |
1568
61495ea0767e
Rename some variables to be more meaningful.
Matti Hamalainen <ccr@tnsp.org>
parents:
1564
diff
changeset
|
837 needUpdate = TRUE; |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
838 break; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
839 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
840 case SDL_WINDOWEVENT_RESIZED: |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
841 eng.optScrWidth = eng.event.window.data1; |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
842 eng.optScrHeight = eng.event.window.data2; |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
843 if (!dmInitializeVideo()) |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
844 goto exit; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
845 |
1568
61495ea0767e
Rename some variables to be more meaningful.
Matti Hamalainen <ccr@tnsp.org>
parents:
1564
diff
changeset
|
846 needUpdate = TRUE; |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
847 break; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
848 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
849 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
850 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
851 case SDL_QUIT: |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
852 eng.exitFlag = TRUE; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
853 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
854 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
855 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
856 // Check for end of song |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
857 JSS_LOCK(eng.plr); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
858 if (!eng.plr->isPlaying) |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
859 eng.exitFlag = TRUE; |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
860 JSS_UNLOCK(eng.plr); |
1238 | 861 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
862 if (optUseGUI) |
296
6d62918739c6
Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
863 { |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
864 // Check if we need to update screen |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
865 JSS_LOCK(eng.plr); |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
866 JSSPattern *currPattern = eng.plr->pattern; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
867 int currRow = eng.plr->row; |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
868 JSS_UNLOCK(eng.plr); |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
869 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
870 if (currRow != prevRow || needUpdate) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
871 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
872 prevRow = currRow; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
873 needUpdate = TRUE; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
874 } |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
875 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
876 // Draw frame |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
877 if (needUpdate) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
878 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
879 dmClearSurface(eng.screen, col.boxBg); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
880 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
881 dmDrawBMTextQ(eng.screen, font, DMD_TRANSPARENT, 5, 5, |
2283 | 882 "%s v%s by ccr/TNSP - (c) Copyright 2012-2019 TNSP", |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
883 dmProgDesc, dmProgVersion); |
176 | 884 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
885 dmDrawBMTextQ(eng.screen, font, DMD_TRANSPARENT, 5, 5 + (font->height + 2), |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
886 "Song: '%s'", |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
887 eng.mod->moduleName); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
888 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
889 dmDisplayPattern(eng.screen, 5, 5 + (font->height + 2) * 3 + 4, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
890 eng.screen->w - 6, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
891 eng.screen->h * 0.8, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
892 currPattern, currRow); |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
893 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
894 JSS_LOCK(eng.plr); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
895 dmDrawBMTextQ(eng.screen, font, DMD_TRANSPARENT, 5, 5 + (font->height + 2) * 2, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
896 "Tempo: %3d | Speed: %3d | Row: %3d/%-3d | Order: %3d/%-3d | Pattern: %3d/%-3d", |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
897 eng.plr->tempo, eng.plr->speed, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
898 eng.plr->row, (eng.plr->pattern != NULL) ? eng.plr->pattern->nrows : 0, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
899 eng.plr->order + 1, eng.mod->norders, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
900 eng.plr->npattern, eng.mod->npatterns); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
901 JSS_UNLOCK(eng.plr); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
902 needRender = TRUE; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
903 } |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
904 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
905 if (needUpdate || currTick - prevTick >= (eng.pauseFlag ? 100 : 20)) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
906 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
907 JSS_LOCK(eng.dev); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
908 dmDisplayChannels(eng.screen, 5, eng.screen->h * 0.8 + 5, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
909 eng.screen->w - 5, eng.screen->h - 5, eng.dev); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
910 JSS_UNLOCK(eng.dev); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
911 needRender = TRUE; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
912 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
913 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
914 if (needUpdate) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
915 prevTick = currTick; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
916 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
917 // Flip screen |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
918 if (needRender) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
919 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
920 SDL_Surface dst; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
921 SDL_LockTexture(eng.texture, NULL, &dst.pixels, &dst.pitch); |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
922 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
923 if (dst.pitch != eng.screen->pitch) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
924 eng.exitFlag = TRUE; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
925 else |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
926 memcpy(dst.pixels, eng.screen->pixels, eng.screen->h * dst.pitch); |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
927 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
928 SDL_UnlockTexture(eng.texture); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
929 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
930 //SDL_RenderClear(eng.renderer); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
931 SDL_RenderCopy(eng.renderer, eng.texture, NULL, NULL); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
932 SDL_RenderPresent(eng.renderer); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
933 } |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
934 } // optUseGUI |
296
6d62918739c6
Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
935 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
936 SDL_Delay(eng.pauseFlag ? 100 : 30); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
937 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
938 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
939 exit: |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
940 // Cleanup |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
941 if (optUseGUI) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
942 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
943 dmMsg(1, "GUI shutdown.\n"); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
944 if (eng.texture != NULL) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
945 SDL_DestroyTexture(eng.texture); |
2102
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2089
diff
changeset
|
946 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
947 if (eng.renderer != NULL) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
948 SDL_DestroyRenderer(eng.renderer); |
2102
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2089
diff
changeset
|
949 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
950 if (eng.window != NULL) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
951 SDL_DestroyWindow(eng.window); |
2102
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2089
diff
changeset
|
952 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
953 if (eng.screen != NULL) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
954 SDL_FreeSurface(eng.screen); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
955 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
956 dmFreeBitmapFont(font); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
957 } |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
958 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
959 dmMsg(1, "Audio shutdown.\n"); |
290 | 960 if (audioInit) |
961 { | |
962 SDL_LockAudio(); | |
963 SDL_PauseAudio(1); | |
964 SDL_UnlockAudio(); | |
965 SDL_CloseAudio(); | |
966 } | |
967 | |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
968 jmpClose(eng.plr); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
969 jvmClose(eng.dev); |
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
970 jssFreeModule(eng.mod); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
971 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
972 dmMsg(1, "Shut down SDL.\n"); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
973 if (initSDL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
974 SDL_Quit(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
975 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
976 jssClose(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
977 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
978 return 0; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
979 } |