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