Mercurial > hg > dmlib
annotate tools/ppl.c @ 2634:f3c7115cbf85 default tip
Fix verbose build echos.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 29 Feb 2024 21:47:31 +0200 |
parents | 9807ae37ad69 |
children |
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 { |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
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; |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
37 bool pauseFlag; |
147
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; |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
64 bool optUsePlayTime = false, |
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
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 }, |
2410
bc05bcfc4598
Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents:
2408
diff
changeset
|
72 { 1, 0, "license" , "Print out this program's license agreement", OPT_NONE }, |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
73 { 2, 'v', "verbose" , "Be more verbose", OPT_NONE }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
74 |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
75 { 10, 0, "fs" , "Fullscreen", OPT_NONE }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
76 { 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
|
77 { 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
|
78 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
79 { 16, '1', "16bit" , "16-bit output", OPT_NONE }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
80 { 18, '8', "8bit" , "8-bit output", OPT_NONE }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
81 { 20, 'm', "mono" , "Mono output", OPT_NONE }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
82 { 22, 's', "stereo" , "Stereo output", OPT_NONE }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
83 { 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
|
84 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
85 { 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
|
86 { 30, 'o', "order" , "Start from order #", OPT_ARGREQ }, |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
87 { 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
|
88 }; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
89 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
90 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
|
91 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
92 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
93 void argShowHelp() |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
94 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
95 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
|
96 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
|
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 |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
100 bool argHandleOpt(const int optN, char *optArg, char *currArg) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
101 { |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
102 switch (optN) |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
103 { |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
104 case 0: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
105 argShowHelp(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
106 exit(0); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
107 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
108 |
2410
bc05bcfc4598
Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents:
2408
diff
changeset
|
109 case 1: |
bc05bcfc4598
Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents:
2408
diff
changeset
|
110 dmPrintLicense(stdout); |
bc05bcfc4598
Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents:
2408
diff
changeset
|
111 exit(0); |
bc05bcfc4598
Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents:
2408
diff
changeset
|
112 break; |
bc05bcfc4598
Add a C file with the generic BSD license text and a function for
Matti Hamalainen <ccr@tnsp.org>
parents:
2408
diff
changeset
|
113 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
114 case 2: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
115 dmVerbosity++; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
116 break; |
1238 | 117 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
118 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
|
119 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
|
120 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
121 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
122 case 12: |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
123 optUseGUI = false; |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
124 break; |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
125 |
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
126 case 14: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
127 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
128 int w, h; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
129 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
|
130 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
131 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
|
132 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
133 dmErrorMsg("Invalid width or height: %d x %d\n", w, h); |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
134 return false; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
135 } |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
136 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
|
137 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
|
138 } |
1238 | 139 else |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
140 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
141 dmErrorMsg("Invalid size argument '%s'.\n", optArg); |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
142 return false; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
143 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
144 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
145 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
146 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
147 case 16: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
148 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
|
149 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
150 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
151 case 18: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
152 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
|
153 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
154 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
155 case 20: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
156 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
|
157 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
158 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
159 case 22: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
160 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
|
161 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
162 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
163 case 24: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
164 optOutFreq = atoi(optArg); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
165 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
166 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
167 case 28: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
168 optMuteOChannels = atoi(optArg); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
169 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
170 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
171 case 30: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
172 optStartOrder = atoi(optArg); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
173 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
174 |
2408
60e119262c67
Option index re-ordering cleanup work.
Matti Hamalainen <ccr@tnsp.org>
parents:
2402
diff
changeset
|
175 case 32: |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
176 optPlayTime = atoi(optArg); |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
177 optUsePlayTime = true; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
178 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
179 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
180 default: |
2183
e3f0eaf23f4f
Change the error message for unimplemented option argument.
Matti Hamalainen <ccr@tnsp.org>
parents:
2102
diff
changeset
|
181 dmErrorMsg("Unimplemented option argument '%s'.\n", currArg); |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
182 return false; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
183 } |
1238 | 184 |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
185 return true; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
186 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
187 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
188 |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
189 bool argHandleFile(char *currArg) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
190 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
191 if (!optFilename) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
192 optFilename = currArg; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
193 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
194 { |
958
985225a93aeb
Add error code parameter to dmError() and dmErrorVA().
Matti Hamalainen <ccr@tnsp.org>
parents:
860
diff
changeset
|
195 dmErrorMsg("Too many filename arguments '%s'\n", currArg); |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
196 return false; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
197 } |
1238 | 198 |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
199 return true; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
200 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
201 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
202 |
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
203 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
|
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 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
|
206 } |
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
207 |
130
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
208 |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
209 bool dmInitializeVideo() |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
210 { |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
211 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
|
212 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
|
213 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
214 if ((eng.texture = SDL_CreateTexture(eng.renderer, |
1561
b6ee934496d1
Make texture/surface creation better.
Matti Hamalainen <ccr@tnsp.org>
parents:
1559
diff
changeset
|
215 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
|
216 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
|
217 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
218 dmErrorMsg("Could not create SDL texture.\n"); |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
219 return false; |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
220 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
221 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
222 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
|
223 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
|
224 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
|
225 { |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
226 dmErrorMsg("Could not create SDL surface.\n"); |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
227 return false; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
228 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
229 |
1555
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
230 col.black = dmCol(0 , 0 , 0); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
231 col.inboxBg = dmCol(0.6, 0.5, 0.2); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
232 col.boxBg = dmCol(0.7, 0.6, 0.3); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
233 col.box1 = dmCol(1.0, 0.9, 0.6); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
234 col.box2 = dmCol(0.3, 0.3, 0.15); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
235 col.viewDiv = dmCol(0 , 0 , 0); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
236 col.activeRow = dmCol(0.5, 0.4, 0.1); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
237 col.activeChannel = dmCol(0.6, 0.8, 0.2); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
238 col.muted = dmCol(0.3, 0.1, 0.1); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
239 col.scope = dmCol(0 , 0.8, 0); |
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
240 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
|
241 |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
242 return true; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
243 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
244 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
245 |
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
246 // |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
247 // 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
|
248 // 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
|
249 // them with new data from incoming channel data. |
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
250 // |
165 | 251 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
|
252 { |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
253 int yh = y1 - y0 - 2; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
254 if (yh < 10 || chn == NULL) |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
255 return; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
256 |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
257 int xc, ym = y0 + (y1 - y0) / 2, vol = FP_GETH32(chn->chVolume); |
1556 | 258 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
|
259 int len = FP_GETH32(chn->chSize); |
1556 | 260 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
|
261 Uint32 *pix = screen->pixels; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
262 Sint16 *data = chn->chData; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
263 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
264 dmFillBox3D(screen, x0, y0, x1, y1, |
1555
813244726b32
Remove useless dmCol() calls.
Matti Hamalainen <ccr@tnsp.org>
parents:
1409
diff
changeset
|
265 (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
|
266 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
|
267 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
|
268 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
269 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
|
270 return; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
271 |
274
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
272 if (chn->chDirection) |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
273 { |
274
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
274 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
|
275 { |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
276 if (FP_GETH32(offs) >= len) |
274
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
277 break; |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
278 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
|
279 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
|
280 FP_ADD(offs, chn->chDeltaO); |
274
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
281 } |
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
282 } |
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
283 else |
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
284 { |
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
285 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
|
286 { |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
287 if (FP_GETH32(offs) < 0) |
274
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
288 break; |
809
eba3b87f3f84
Add some separate macros for 64/32 precision fixed point types.
Matti Hamalainen <ccr@tnsp.org>
parents:
797
diff
changeset
|
289 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
|
290 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
|
291 FP_SUB(offs, chn->chDeltaO); |
274
31e62b1f1b6e
Add boundary checks for the scope drawing.
Matti Hamalainen <ccr@tnsp.org>
parents:
273
diff
changeset
|
292 } |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
293 } |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
294 } |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
295 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
296 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
297 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
|
298 { |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
299 int nchannel, qx, qy, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
300 qwidth = x1 - x0, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
301 qheight = y1 - y0, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
302 nwidth = jsetNChannels, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
303 nheight = 1; |
1238 | 304 |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
305 if (qheight < 40) |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
306 return; |
1238 | 307 |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
308 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
|
309 { |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
310 nheight++; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
311 nwidth /= nheight; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
312 } |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
313 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
314 // fprintf(stderr, "%d x %d\n", nwidth, nheight); |
1238 | 315 |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
316 if (qheight / nheight <= 40) |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
317 { |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
318 nwidth = qwidth / 60; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
319 nheight = qheight / 40; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
320 } |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
321 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
322 qwidth /= nwidth; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
323 qheight /= nheight; |
1238 | 324 |
165 | 325 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
|
326 { |
165 | 327 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
|
328 { |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
329 int xc = x0 + qx * qwidth, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
330 yc = y0 + qy * qheight; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
331 |
165 | 332 dmDisplayChn(screen, xc + 1, yc + 1, |
333 xc + qwidth - 1, yc + qheight - 1, | |
334 nchannel, &dev->channels[nchannel]); | |
335 | |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
336 nchannel++; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
337 } |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
338 } |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
339 } |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
340 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
341 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
342 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
|
343 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
344 "C-", "C#", "D-", |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
345 "D#", "E-", "F-", |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
346 "F#", "G-", "G#", |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
347 "A-", "A#", "B-" |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
348 }; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
349 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
350 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
351 #define jmpNMODEffectTable (36) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
352 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
|
353 |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
354 static const char jmpHexTab[16] = "0123456789ABCDEF"; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
355 |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
356 static inline char dmHexVal(int v) |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
357 { |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
358 return jmpHexTab[v & 15]; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
359 } |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
360 |
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
361 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
362 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
|
363 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
364 char text[32]; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
365 char *ptr = text; |
1238 | 366 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
367 switch (n->note) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
368 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
369 case jsetNotSet: |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
370 strcpy(ptr, "..._"); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
371 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
372 case jsetNoteOff: |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
373 strcpy(ptr, "===_"); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
374 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
375 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
|
376 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
|
377 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
|
378 n->note / 12); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
379 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
380 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
381 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
382 ptr += 4; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
383 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
384 if (n->instrument != jsetNotSet) |
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 int v = n->instrument + 1; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
387 *ptr++ = dmHexVal(v >> 4); |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
388 *ptr++ = dmHexVal(v); |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
389 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
390 else |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
391 { |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
392 *ptr++ = '.'; |
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 } |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
395 *ptr++ = '_'; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
396 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
397 if (n->volume == jsetNotSet) |
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++ = '.'; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
400 *ptr++ = '.'; |
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 if (n->volume >= 0x00 && n->volume <= 0x40) |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
404 { |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
405 *ptr++ = dmHexVal(n->volume >> 4); |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
406 *ptr++ = dmHexVal(n->volume); |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
407 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
408 else |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
409 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
410 char c; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
411 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
|
412 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
413 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
|
414 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
|
415 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
|
416 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
|
417 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
|
418 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
|
419 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
|
420 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
|
421 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
|
422 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
|
423 default: c = '?'; break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
424 } |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
425 *ptr++ = c; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
426 *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
|
427 } |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
428 *ptr++ = '_'; |
1238 | 429 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
430 if (n->effect >= 0 && n->effect < jmpNMODEffectTable) |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
431 *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
|
432 else |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
433 *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
|
434 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
435 if (n->param != jsetNotSet) |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
436 { |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
437 *ptr++ = dmHexVal(n->param >> 4); |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
438 *ptr++ = dmHexVal(n->param); |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
439 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
440 else |
201
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
441 { |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
442 *ptr++ = '.'; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
443 *ptr++ = '.'; |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
444 } |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
445 |
844f38cbff65
Optimize pattern drawing a bit.
Matti Hamalainen <ccr@tnsp.org>
parents:
199
diff
changeset
|
446 *ptr = 0; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
447 |
130
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
448 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
|
449 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
450 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
451 |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
452 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
|
453 { |
78
3b3908d28a4b
PPL now looks a bit saner, but does not do anything interesting yet.
Matti Hamalainen <ccr@tnsp.org>
parents:
71
diff
changeset
|
454 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
|
455 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
|
456 qy0 = y0 + font->height + 2, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
457 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
|
458 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
|
459 qheight = ((qy1 - qy0 - 4) / (font->height + 1)), |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
460 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
|
461 midrow = qheight / 2; |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
462 |
1258
13c274d22a29
Add some extra error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
1238
diff
changeset
|
463 if (pat == NULL) |
13c274d22a29
Add some extra error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
1238
diff
changeset
|
464 return; |
13c274d22a29
Add some extra error checking.
Matti Hamalainen <ccr@tnsp.org>
parents:
1238
diff
changeset
|
465 |
1962
951e07b80b40
If pattern has less channels than what fits on the screen, and active
Matti Hamalainen <ccr@tnsp.org>
parents:
1956
diff
changeset
|
466 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
|
467 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
|
468 |
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 if (eng.actChannel < qwidth / 2) |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
470 choffs = 0; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
471 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
|
472 if (eng.actChannel >= pat->nchannels - qwidth/2) |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
473 choffs = pat->nchannels - qwidth; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
474 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
|
475 choffs = eng.actChannel - qwidth/2; |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
476 |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
477 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
|
478 |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
479 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
|
480 { |
1238 | 481 int bx0 = x0 + lwidth + 1 + nchannel * cwidth, |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
482 bx1 = bx0 + cwidth; |
1098 | 483 |
484 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
|
485 (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
|
486 } |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
487 |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
488 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
|
489 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
|
490 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
491 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
|
492 { |
1238 | 493 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
|
494 bx1 = bx0 + cwidth; |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
495 |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
496 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
|
497 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
498 if (jvmGetMute(eng.dev, nchannel + choffs)) |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
499 { |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
500 dmDrawBMTextConstQ(screen, font, DMD_TRANSPARENT, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
501 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
|
502 } |
1238 | 503 |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
504 dmDrawBMTextQ(screen, font, DMD_TRANSPARENT, |
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
505 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
|
506 nchannel + choffs); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
507 } |
1238 | 508 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
509 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
|
510 { |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
511 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
|
512 yc = qy0 + 2 + (font->height + 1) * nrow; |
1238 | 513 |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
514 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
|
515 { |
130
1d7dc7c8745c
Move custom bitmap font text rendering functions into PPL code itself.
Matti Hamalainen <ccr@tnsp.org>
parents:
99
diff
changeset
|
516 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
|
517 |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
518 for (nchannel = 0; nchannel < qwidth; nchannel++) |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
519 { |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
520 if (choffs + nchannel >= pat->nchannels) |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
521 break; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
522 |
99
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
523 dmPrintNote(screen, x0 + lwidth + 4 + nchannel * cwidth, yc, |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
524 pat->data + (pat->nchannels * crow) + choffs + nchannel); |
7a59611f9d4f
Various minor improvements in PPL.
Matti Hamalainen <ccr@tnsp.org>
parents:
80
diff
changeset
|
525 } |
71
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 } |
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 |
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 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
|
532 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
533 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
|
534 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
535 if (d != NULL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
536 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
537 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
|
538 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
539 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
540 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
541 |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
542 void dmMuteChannels(bool mute) |
198
4568c479541c
Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
543 { |
2305 | 544 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
|
545 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
|
546 } |
4568c479541c
Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
547 |
1327
59e9ad13b50e
Move common functions to libgutil.
Matti Hamalainen <ccr@tnsp.org>
parents:
1323
diff
changeset
|
548 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
549 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
|
550 { |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
551 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
|
552 DMResource *file = NULL; |
2565 | 553 int res = DMERR_OK; |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
554 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
|
555 |
2414
69a5af2eb1ea
Remove useless dmMemset().
Matti Hamalainen <ccr@tnsp.org>
parents:
2410
diff
changeset
|
556 memset(&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
|
557 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
558 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
|
559 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
|
560 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
|
561 |
1562
83979ecc6576
Bump version and copyright of PPL/CBP.
Matti Hamalainen <ccr@tnsp.org>
parents:
1561
diff
changeset
|
562 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
|
563 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
564 // Parse arguments |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
565 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
|
566 argHandleOpt, argHandleFile, OPTH_BAILOUT)) |
2565 | 567 goto out; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
568 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
569 // Open the files |
2441
275374725598
Show help when no arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2414
diff
changeset
|
570 if (optFilename == NULL || argc < 2) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
571 { |
2441
275374725598
Show help when no arguments.
Matti Hamalainen <ccr@tnsp.org>
parents:
2414
diff
changeset
|
572 argShowHelp(); |
2565 | 573 res = dmError(DMERR_INVALID_ARGS, |
574 "No filename specified.\n"); | |
575 goto out; | |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
576 } |
1238 | 577 |
2530 | 578 if ((res = 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
|
579 { |
2477
0ab24caf7fdf
Clean up various error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
2441
diff
changeset
|
580 dmErrorMsg("Error opening file '%s': %s\n", |
2530 | 581 optFilename, dmErrorStr(res)); |
2565 | 582 goto out; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
583 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
584 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
585 // Initialize miniJSS |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
586 jssInit(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
587 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
588 // Read module file |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
589 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
|
590 #ifdef JSS_SUP_XM |
2530 | 591 if (eng.mod == NULL) |
592 { | |
593 dmMsg(2, "* Trying XM...\n"); | |
594 dmfreset(file); | |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
595 if ((res = jssLoadXM(file, &eng.mod, true)) == DMERR_OK) |
2530 | 596 { |
597 dmfreset(file); | |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
598 res = jssLoadXM(file, &eng.mod, false); |
2530 | 599 } |
600 } | |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
601 #endif |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
602 #ifdef JSS_SUP_JSSMOD |
2530 | 603 if (eng.mod == NULL) |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
604 { |
777
ed60a7ee3ebb
Change JSSMOD loader to use DMResources.
Matti Hamalainen <ccr@tnsp.org>
parents:
745
diff
changeset
|
605 dmMsg(1, "* Trying JSSMOD ...\n"); |
1199
a79edf59d5d8
Improve use of probing in dumpmod, mod2wav and ppl.
Matti Hamalainen <ccr@tnsp.org>
parents:
1167
diff
changeset
|
606 dmfreset(file); |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
607 if ((res = jssLoadJSSMOD(file, &eng.mod, true)) == DMERR_OK) |
2530 | 608 { |
609 dmfreset(file); | |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
610 res = jssLoadJSSMOD(file, &eng.mod, false); |
2530 | 611 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
612 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
613 #endif |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
614 dmf_close(file); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
615 |
2530 | 616 // Check for errors, we still might have some data tho |
617 if (res != DMERR_OK) | |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
618 { |
2477
0ab24caf7fdf
Clean up various error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
2441
diff
changeset
|
619 dmErrorMsg("Error loading module file: %s\n", |
2530 | 620 dmErrorStr(res)); |
2565 | 621 goto out; |
2530 | 622 } |
623 | |
624 // Check if we have anything | |
625 if (eng.mod == NULL) | |
626 { | |
627 res = dmError(DMERR_INIT_FAIL, | |
628 "Could not load module file.\n"); | |
2565 | 629 goto out; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
630 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
631 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
632 // Try to convert it |
2530 | 633 if ((res = 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
|
634 { |
2477
0ab24caf7fdf
Clean up various error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
2441
diff
changeset
|
635 dmErrorMsg("Could not convert module for playing: %s\n", |
2530 | 636 dmErrorStr(res)); |
2565 | 637 goto out; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
638 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
639 |
1971
c27f7cd25684
Set the PPL font palette to be more appropriate.
Matti Hamalainen <ccr@tnsp.org>
parents:
1970
diff
changeset
|
640 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
641 // Initialize SDL components |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
642 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
|
643 { |
2530 | 644 res = dmError(DMERR_INIT_FAIL, |
645 "Could not initialize SDL: %s\n", | |
2477
0ab24caf7fdf
Clean up various error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
2441
diff
changeset
|
646 SDL_GetError()); |
2565 | 647 goto out; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
648 } |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
649 initSDL = true; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
650 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
651 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
652 // Initialize mixing device |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
653 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
|
654 optOutFormat, optOutChannels, optOutFreq); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
655 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
656 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
|
657 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
|
658 { |
2530 | 659 res = dmError(DMERR_INIT_FAIL, |
660 "jvmInit() returned NULL\n"); | |
2565 | 661 goto out; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
662 } |
1238 | 663 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
664 switch (optOutFormat) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
665 { |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
666 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
|
667 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
|
668 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
|
669 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
|
670 default: |
2530 | 671 res = dmError(DMERR_NOT_SUPPORTED, |
672 "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
|
673 optOutFormat); |
2565 | 674 goto out; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
675 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
676 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
677 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
|
678 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
|
679 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
|
680 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
|
681 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
|
682 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
683 // 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
|
684 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
|
685 { |
2530 | 686 res = dmError(DMERR_INIT_FAIL, |
687 "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
|
688 SDL_GetError()); |
2565 | 689 goto out; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
690 } |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
691 audioInit = true; |
1238 | 692 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
693 // 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
|
694 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
|
695 { |
2530 | 696 res = dmError(DMERR_INIT_FAIL, |
697 "jmpInit() returned NULL\n"); | |
2565 | 698 goto out; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
699 } |
1238 | 700 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
701 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
|
702 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
|
703 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
|
704 jvmSetGlobalVol(eng.dev, 200); |
190
87b46e61f2c4
Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
705 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
706 if (optMuteOChannels >= 0 && optMuteOChannels < eng.mod->nchannels) |
190
87b46e61f2c4
Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
707 { |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
708 dmMuteChannels(true); |
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
709 jvmMute(eng.dev, optMuteOChannels, false); |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
710 eng.actChannel = optMuteOChannels; |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
711 muteState = true; |
190
87b46e61f2c4
Make it possible to mute channels.
Matti Hamalainen <ccr@tnsp.org>
parents:
185
diff
changeset
|
712 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
713 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
714 if (optUseGUI) |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
715 { |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
716 // Get font |
2477
0ab24caf7fdf
Clean up various error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
2441
diff
changeset
|
717 static const char *engineFontName = "pplfont.fnt"; |
2530 | 718 res = dmf_open_memio(NULL, engineFontName, engineSetupFont, sizeof(engineSetupFont), &file); |
719 if (res != DMERR_OK) | |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
720 { |
2477
0ab24caf7fdf
Clean up various error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
2441
diff
changeset
|
721 dmErrorMsg("Error opening font file '%s': %s\n", |
2530 | 722 engineFontName, dmErrorStr(res)); |
2565 | 723 goto out; |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
724 } |
2530 | 725 res = dmLoadBitmapFont(file, &font); |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
726 dmf_close(file); |
2530 | 727 if (res != DMERR_OK) |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
728 { |
2477
0ab24caf7fdf
Clean up various error messages.
Matti Hamalainen <ccr@tnsp.org>
parents:
2441
diff
changeset
|
729 dmErrorMsg("Could not load font data from '%s': %s\n", |
2530 | 730 engineFontName, dmErrorStr(res)); |
2565 | 731 goto out; |
2275
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 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
734 SDL_Color pal[DMFONT_NPALETTE]; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
735 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
|
736 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
737 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
|
738 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
|
739 } |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
740 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
|
741 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
742 // Open window |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
743 if ((eng.window = SDL_CreateWindow(dmProgName, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
744 SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
745 eng.optScrWidth, eng.optScrHeight, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
746 eng.optVFlags | SDL_WINDOW_RESIZABLE |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
747 //| SDL_WINDOW_HIDDEN |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
748 )) == NULL) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
749 { |
2530 | 750 res = dmError(DMERR_INIT_FAIL, |
751 "Can't create an SDL window: %s\n", | |
752 SDL_GetError()); | |
2565 | 753 goto out; |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
754 } |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
755 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
756 SDL_SetWindowTitle(eng.window, dmProgDesc); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
757 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
758 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
|
759 { |
2530 | 760 res = dmError(DMERR_INIT_FAIL, |
761 "Can't create an SDL renderer: %s\n", | |
762 SDL_GetError()); | |
2565 | 763 goto out; |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
764 } |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
765 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
766 if (!dmInitializeVideo()) |
2530 | 767 { |
768 res = DMERR_INIT_FAIL; | |
2565 | 769 goto out; |
2530 | 770 } |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
771 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
772 //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
|
773 //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
|
774 } |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
775 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
776 // okay, main loop here ... "play" module and print out info |
275 | 777 SDL_LockAudio(); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
778 SDL_PauseAudio(0); |
275 | 779 SDL_UnlockAudio(); |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
780 |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
781 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
|
782 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
|
783 { |
176 | 784 currTick = SDL_GetTicks(); |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
785 bool needUpdate = (currTick - prevTick > 500), |
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
786 needRender = false; |
176 | 787 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
788 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
|
789 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
|
790 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
791 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
|
792 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
|
793 { |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
794 case SDLK_ESCAPE: |
1568
61495ea0767e
Rename some variables to be more meaningful.
Matti Hamalainen <ccr@tnsp.org>
parents:
1564
diff
changeset
|
795 case SDLK_q: |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
796 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
|
797 break; |
1238 | 798 |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
799 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
|
800 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
|
801 SDL_PauseAudio(eng.pauseFlag); |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
802 break; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
803 |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
804 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
|
805 if (eng.actChannel > 0) |
176 | 806 { |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
807 eng.actChannel--; |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
808 needUpdate = true; |
176 | 809 } |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
810 break; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
811 |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
812 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
|
813 if (eng.actChannel < eng.mod->nchannels - 1) |
176 | 814 { |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
815 eng.actChannel++; |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
816 needUpdate = true; |
176 | 817 } |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
818 break; |
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
819 |
198
4568c479541c
Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
820 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
|
821 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
|
822 { |
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
823 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
|
824 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
|
825 } |
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
826 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
|
827 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
|
828 { |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
829 dmMuteChannels(false); |
203
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
830 } |
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
831 else |
bed7457cd8da
Improve channel mute control. Now shift+M will toggle mute of all channels,
Matti Hamalainen <ccr@tnsp.org>
parents:
201
diff
changeset
|
832 { |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
833 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
|
834 } |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
835 needUpdate = true; |
198
4568c479541c
Make 'm' key mute all but selected active channel.
Matti Hamalainen <ccr@tnsp.org>
parents:
190
diff
changeset
|
836 break; |
147
ead759da30b4
Various improvements, implement channel muting.
Matti Hamalainen <ccr@tnsp.org>
parents:
137
diff
changeset
|
837 |
167
e281663f04ba
Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
838 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
|
839 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
|
840 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
|
841 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
|
842 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
|
843 JSS_UNLOCK(eng.dev); |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
844 needUpdate = true; |
167
e281663f04ba
Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
845 break; |
e281663f04ba
Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
846 |
e281663f04ba
Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
847 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
|
848 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
|
849 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
|
850 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
|
851 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
|
852 JSS_UNLOCK(eng.dev); |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
853 needUpdate = true; |
167
e281663f04ba
Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
854 break; |
e281663f04ba
Implement moving around in order list via pageup/down.
Matti Hamalainen <ccr@tnsp.org>
parents:
165
diff
changeset
|
855 |
179
b29c9a2fbeb5
Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
856 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
|
857 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
|
858 if (SDL_SetWindowFullscreen(eng.window, eng.optVFlags) != 0) |
2565 | 859 goto out; |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
860 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
|
861 break; |
b29c9a2fbeb5
Add full screen switching to PPL via 'f' key, and various other
Matti Hamalainen <ccr@tnsp.org>
parents:
176
diff
changeset
|
862 |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
863 default: |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
864 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
865 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
866 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
867 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
868 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
869 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
|
870 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
|
871 { |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
872 case SDL_WINDOWEVENT_EXPOSED: |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
873 needUpdate = true; |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
874 break; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
875 |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
876 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
|
877 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
|
878 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
|
879 if (!dmInitializeVideo()) |
2565 | 880 goto out; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
881 |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
882 needUpdate = true; |
1557
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
883 break; |
5e5f75b45f8d
Initial port to SDL2. Many things will not work now.
Matti Hamalainen <ccr@tnsp.org>
parents:
1556
diff
changeset
|
884 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
885 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
886 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
887 case SDL_QUIT: |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
888 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
|
889 break; |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
890 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
891 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
892 // 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
|
893 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
|
894 if (!eng.plr->isPlaying) |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
895 eng.exitFlag = 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
|
896 JSS_UNLOCK(eng.plr); |
1238 | 897 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
898 if (optUseGUI) |
296
6d62918739c6
Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
899 { |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
900 // 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
|
901 JSS_LOCK(eng.plr); |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
902 JSSPattern *currPattern = eng.plr->pattern; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
903 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
|
904 JSS_UNLOCK(eng.plr); |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
905 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
906 if (currRow != prevRow || needUpdate) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
907 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
908 prevRow = currRow; |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
909 needUpdate = true; |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
910 } |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
911 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
912 // Draw frame |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
913 if (needUpdate) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
914 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
915 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
|
916 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
917 dmDrawBMTextQ(eng.screen, font, DMD_TRANSPARENT, 5, 5, |
2283 | 918 "%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
|
919 dmProgDesc, dmProgVersion); |
176 | 920 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
921 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
|
922 "Song: '%s'", |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
923 eng.mod->moduleName); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
924 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
925 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
|
926 eng.screen->w - 6, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
927 eng.screen->h * 0.8, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
928 currPattern, currRow); |
151
8708b0354eb8
Various improvements and small optimizations in display drawing/updating.
Matti Hamalainen <ccr@tnsp.org>
parents:
148
diff
changeset
|
929 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
930 JSS_LOCK(eng.plr); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
931 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
|
932 "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
|
933 eng.plr->tempo, eng.plr->speed, |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
934 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
|
935 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
|
936 eng.plr->npattern, eng.mod->npatterns); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
937 JSS_UNLOCK(eng.plr); |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
938 needRender = true; |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
939 } |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
940 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
941 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
|
942 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
943 JSS_LOCK(eng.dev); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
944 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
|
945 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
|
946 JSS_UNLOCK(eng.dev); |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
947 needRender = true; |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
948 } |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
949 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
950 if (needUpdate) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
951 prevTick = currTick; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
952 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
953 // Flip screen |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
954 if (needRender) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
955 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
956 SDL_Surface dst; |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
957 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
|
958 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
959 if (dst.pitch != eng.screen->pitch) |
2586
9807ae37ad69
Require stdbool.h, we require C11 now.
Matti Hamalainen <ccr@tnsp.org>
parents:
2565
diff
changeset
|
960 eng.exitFlag = true; |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
961 else |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
962 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
|
963 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
964 SDL_UnlockTexture(eng.texture); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
965 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
966 //SDL_RenderClear(eng.renderer); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
967 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
|
968 SDL_RenderPresent(eng.renderer); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
969 } |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
970 } // optUseGUI |
296
6d62918739c6
Improve screen update logic.
Matti Hamalainen <ccr@tnsp.org>
parents:
293
diff
changeset
|
971 |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
972 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
|
973 } |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
974 |
2565 | 975 out: |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
976 // Cleanup |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
977 if (optUseGUI) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
978 { |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
979 dmMsg(1, "GUI shutdown.\n"); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
980 if (eng.texture != NULL) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
981 SDL_DestroyTexture(eng.texture); |
2102
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2089
diff
changeset
|
982 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
983 if (eng.renderer != NULL) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
984 SDL_DestroyRenderer(eng.renderer); |
2102
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2089
diff
changeset
|
985 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
986 if (eng.window != NULL) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
987 SDL_DestroyWindow(eng.window); |
2102
e0281dae2cb8
Backed out changeset dcca36701cdd
Matti Hamalainen <ccr@tnsp.org>
parents:
2089
diff
changeset
|
988 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
989 if (eng.screen != NULL) |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
990 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
|
991 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
992 dmFreeBitmapFont(font); |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
993 } |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
994 |
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
995 dmMsg(1, "Audio shutdown.\n"); |
290 | 996 if (audioInit) |
997 { | |
998 SDL_LockAudio(); | |
999 SDL_PauseAudio(1); | |
1000 SDL_UnlockAudio(); | |
1001 SDL_CloseAudio(); | |
1002 } | |
1003 | |
2017
3a768f8d409d
Rename variable s/engine/eng/g to avoid aliasing with dmsimple::engine. This
Matti Hamalainen <ccr@tnsp.org>
parents:
1971
diff
changeset
|
1004 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
|
1005 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
|
1006 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
|
1007 |
2275
ba696835f66d
Add CLI-only mode to PPL (-C option).
Matti Hamalainen <ccr@tnsp.org>
parents:
2183
diff
changeset
|
1008 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
|
1009 if (initSDL) |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1010 SDL_Quit(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1011 |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1012 jssClose(); |
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1013 |
2530 | 1014 return res; |
71
b908fda1036e
Add a simplistic skeleton of a module player with SDL-based view.
Matti Hamalainen <ccr@tnsp.org>
parents:
diff
changeset
|
1015 } |