Skip to content

Commit f3b6aea

Browse files
committed
Improve UI to deal S3M modules
1 parent b77eb1d commit f3b6aea

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

QB64MODPlayer.bas

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ CONST APP_NAME = "QB64 MOD Player" ' application name
4343
CONST TEXT_WIDTH_MIN& = 144& ' minimum width we need
4444
CONST TEXT_LINE_MAX& = 90& ' this the number of lines we need
4545
CONST TEXT_WIDTH_HEADER& = 84& ' width of the main header on the vis screen
46+
CONST MAX_VISIBLE_INSTRUMENTS& = 64& ' maximum number of instruments visible at a time
4647
CONST ANALYZER_SCALE& = 9& ' this is used to scale the fft values
4748
CONST FRAME_RATE& = 60& ' update frame rate
4849
CONST VOLUME_STEP! = 0.01! ' the amount by which the audio volume is increased or decreased
@@ -159,6 +160,10 @@ SUB DrawVisualization
159160
' Note this is only a problem with this demo and not the actual library since we are trying to access internal stuff directly
160161
IF __Song.orderPosition >= __Song.orders THEN EXIT SUB
161162

163+
DIM startPat AS LONG: startPat = __Order(__Song.orderPosition)
164+
165+
IF startPat >= __Song.patterns THEN EXIT SUB ' this can happen when S3M tunes contain marker / end-of-song patterns
166+
162167
CLS , Black ' clear the framebuffer to black color
163168

164169
DIM x AS LONG: x = 1 + WindowWidth \ 2 - TEXT_WIDTH_HEADER \ 2 ' find x so that we can center everything
@@ -171,7 +176,7 @@ SUB DrawVisualization
171176
COLOR Blink, BrightWhite
172177
_PRINTSTRING (x, 2), String_FormatLong(__Song.orderPosition, " ORD: %3d / ") + _
173178
String_FormatLong(__Song.orders - 1, "%3d | ") + _
174-
String_FormatLong(__Order(__Song.orderPosition), "PAT: %3d / ") + _
179+
String_FormatLong(startPat, "PAT: %3d / ") + _
175180
String_FormatLong(__Song.patterns - 1, "%3d | ") + _
176181
String_FormatLong(__Song.patternRow, "ROW: %2d / 63 | ") + _
177182
String_FormatLong(__Song.activeChannels, "CHN: %3d / ") + _
@@ -196,7 +201,7 @@ SUB DrawVisualization
196201

197202
j = 0
198203
WHILE j < __Song.channels
199-
IF i + 1 = __Pattern(__Order(__Song.orderPosition), __Song.patternRow, j).instrument THEN
204+
IF i + 1 = __Pattern(startPat, __Song.patternRow, j).instrument THEN
200205
COLOR LightMagenta, Blue
201206
END IF
202207

@@ -213,6 +218,8 @@ SUB DrawVisualization
213218
String_FormatLong(__Instrument(i).loopEnd, "%9d ")
214219

215220
i = i + 1
221+
222+
IF i >= MAX_VISIBLE_INSTRUMENTS THEN EXIT WHILE ' FIXME: allow user to scroll and see the entire instrument list
216223
WEND
217224

218225
j = 5 + i ' we starting updating from this line next
@@ -227,12 +234,11 @@ SUB DrawVisualization
227234
i = i + 1
228235
WEND
229236

230-
DIM AS LONG startRow, startPat, nNote, nChan, nSample, nEffect, nOperand
237+
DIM AS LONG startRow, nNote, nChan, nSample, nEffect, nOperand
231238

232239
j = j + 1 ' move to the current line number
233240

234241
' Find the pattern and row we need to print
235-
startPat = __Order(__Song.orderPosition)
236242
startRow = __Song.patternRow - (1 + TEXT_LINE_MAX - j) \ 2
237243
IF startRow < 0 THEN
238244
startRow = __Song.rows + startRow
@@ -515,7 +521,7 @@ SUB AdjustWindowSize
515521
IF PatternDisplayWidth <= TEXT_WIDTH_HEADER THEN
516522
FFT.size.y = TEXT_LINE_MAX
517523
ELSE
518-
FFT.size.y = 4 + __Song.instruments
524+
FFT.size.y = 4 + Math_GetMinLong(__Song.instruments, MAX_VISIBLE_INSTRUMENTS)
519525
END IF
520526
ELSE
521527
PatternDisplayWidth = 0

0 commit comments

Comments
 (0)