comparison win95kggui/src/win95kggui.c @ 75:dbf5ce219fe3

Switch from BASS to ft2play
author Paper <mrpapersonic@gmail.com>
date Sat, 25 Jun 2022 22:09:45 -0400
parents 1508aee998df
children 677f84ada082
comparison
equal deleted inserted replaced
74:2057ab53f04e 75:dbf5ce219fe3
25 #include <stdint.h> 25 #include <stdint.h>
26 #include <stdbool.h> 26 #include <stdbool.h>
27 #include <commdlg.h> 27 #include <commdlg.h>
28 #include <math.h> 28 #include <math.h>
29 #include <time.h> 29 #include <time.h>
30 #include <bass.h> 30 #include "../sub/ft2play/pmplay.h"
31 #include <resource.h> 31 #include <resource.h>
32 #include "bergsm.h"
33 #ifndef WIN32_LEAN_AND_MEAN
34 #define WIN32_LEAN_AND_MEAN
35 #endif
32 #define _WIN32_WINNT 0x0400 36 #define _WIN32_WINNT 0x0400
33 #define ARRAYSIZE(a) \ 37 #define ARRAYSIZE(a) \
34 sizeof(a)/sizeof(a[0]) 38 sizeof(a)/sizeof(a[0])
35 #define CONCAT_INTS(x, y) \ 39 #define CONCAT_INTS(x, y) \
36 x * pow(10, log10(y)+1) + y 40 x * pow(10, log10(y)+1) + y
40 #define GENERATE_KEY 1 44 #define GENERATE_KEY 1
41 #define LISTBOX 2 45 #define LISTBOX 2
42 #define KEY 3 46 #define KEY 3
43 int type; 47 int type;
44 HWND hWndListBox, key_box; 48 HWND hWndListBox, key_box;
45 HMUSIC music;
46
47 extern char binary_src_bergsm_xm_start[];
48 extern char binary_src_bergsm_xm_end[];
49 49
50 int get_sum(int n) { 50 int get_sum(int n) {
51 int sum; 51 int sum;
52 for (sum = 0; n > 0; sum += n % 10, n /= 10); // copied this from google. sorry not sorry 52 for (sum = 0; n > 0; sum += n % 10, n /= 10); // copied this from google. sorry not sorry
53 return sum; 53 return sum;
163 case KEY: 163 case KEY:
164 break; 164 break;
165 } 165 }
166 break; 166 break;
167 case WM_CREATE: { 167 case WM_CREATE: {
168 if (!BASS_Init(-1, 48000, 0, hWnd, NULL)) { 168 /* freq, buf, inter, ramp */
169 if (!initMusic(44100, 1024, false, true)) {
170 printf("init music\n");
169 EndDialog(hWnd, 0); 171 EndDialog(hWnd, 0);
170 break; 172 break;
171 } 173 }
172 AddControls(hWnd); 174 AddControls(hWnd);
173 EnumChildWindows(hWnd, (WNDENUMPROC)SetFont, (LPARAM)GetStockObject(DEFAULT_GUI_FONT)); 175 EnumChildWindows(hWnd, (WNDENUMPROC)SetFont, (LPARAM)GetStockObject(DEFAULT_GUI_FONT));
174 music = BASS_MusicLoad(true, &binary_src_bergsm_xm_start, 0, (unsigned int)(binary_src_bergsm_xm_end - binary_src_bergsm_xm_start), BASS_SAMPLE_LOOP | BASS_MUSIC_FT2PAN | BASS_MUSIC_NONINTER | BASS_SAMPLE_FLOAT, 1); 176 if (!loadMusicFromData(hdata, ARRAYSIZE(hdata))) {
175 BASS_ChannelPlay(music, FALSE); 177 printf("load music\n");
178 EndDialog(hWnd, 0);
179 break;
180 }
181 if (!startMusic())
182 {
183 printf("start music\n");
184 freeMusic();
185 EndDialog(hWnd, 0);
186 break;
187 }
188 startPlaying();
176 break; 189 break;
177 } 190 }
178 case WM_DESTROY: 191 case WM_DESTROY:
179 BASS_MusicFree(music); 192 stopMusic();
180 BASS_Free(); 193 freeMusic();
181 PostQuitMessage(0); 194 PostQuitMessage(0);
182 break; 195 break;
183 default: 196 default:
184 return DefWindowProcA(hWnd, msg, wParam, lParam); 197 return DefWindowProcA(hWnd, msg, wParam, lParam);
185 } 198 }