mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-06 05:28:31 +09:00
taut: sample RAM numbers
This commit is contained in:
@@ -1048,6 +1048,7 @@ const colTabBarBack2 = 136
|
||||
const colTabBarOrn = 136
|
||||
const colBrand = 211
|
||||
const colPopupBack = 244
|
||||
const colPopupBack2 = 243
|
||||
const colTabActive = 239
|
||||
const colTabInactive = 45
|
||||
|
||||
@@ -2909,9 +2910,9 @@ function makeExternalPanelDraw(progName) {
|
||||
}
|
||||
|
||||
// Row offsets (within the meta block at the top of the Project panel) of the editable rows.
|
||||
const PROJ_META_ROW_FLAGS = 5
|
||||
const PROJ_META_ROW_GVOL = 6
|
||||
const PROJ_META_ROW_MVOL = 7
|
||||
const PROJ_META_ROW_FLAGS = 6
|
||||
const PROJ_META_ROW_GVOL = 7
|
||||
const PROJ_META_ROW_MVOL = 8
|
||||
const PROJ_META_VALUE_X = 12
|
||||
|
||||
function drawProjectContents(wo) {
|
||||
@@ -2922,6 +2923,8 @@ function drawProjectContents(wo) {
|
||||
let toneModeStr = ['Linear pitch','Amiga pitch','Linear freq',''][mixerflag & 3]
|
||||
let intpModeStr = ['Default','None','A500','A1200','SNES','DPCM','',''][(mixerflag >>> 2) & 7]
|
||||
let flagStrSelected = [toneModeStr, intpModeStr]
|
||||
const sampleCount = (samplesCache || []).length
|
||||
const sampleKStr = formatSampleRamK(computeSampleRAMBytes())
|
||||
|
||||
|
||||
let projMeta = {
|
||||
@@ -2929,6 +2932,7 @@ function drawProjectContents(wo) {
|
||||
ProjName: songsMeta.projectName || '(unnamed)',
|
||||
Patterns: `${song.numPats}/4095 ($${song.numPats.hex03()})`,
|
||||
Cues: `${song.lastActiveCue}/1024 ($${song.lastActiveCue.hex03()})`,
|
||||
Samples: `${sampleCount} (${sampleKStr}k/${SMP_RAM_MAX_K}k)`,
|
||||
Notation: pitchTablePresets[PITCH_PRESET_IDX].name,
|
||||
Flags: `${flagStrSelected.join(', ')} ($${mixerflag.hex02()})`,
|
||||
GlobalVol: `$${initialGlobalVolume.hex02()}`,
|
||||
@@ -2961,7 +2965,7 @@ function drawProjectContents(wo) {
|
||||
con.color_pair(colStatus, 255) // reset colour
|
||||
}
|
||||
|
||||
const PROJ_SONGLIST_Y = PTNVIEW_OFFSET_Y + 9 // header row of the song list
|
||||
const PROJ_SONGLIST_Y = PTNVIEW_OFFSET_Y + 10 // header row of the song list
|
||||
const PROJ_SONGLIST_X = 2
|
||||
|
||||
function projectSongListRowsVisible() {
|
||||
@@ -3548,6 +3552,34 @@ function tickFunkWaveform() {
|
||||
if (funking || funkWaveLast) drawSampleWaveform()
|
||||
}
|
||||
|
||||
function computeSampleRAMBytes() {
|
||||
if (!samplesCache) return 0
|
||||
let total = 0
|
||||
for (let i = 0; i < samplesCache.length; i++) total += samplesCache[i].len
|
||||
return total
|
||||
}
|
||||
|
||||
// 16 banks x 524288 = 8 MB = 8192k. Hardcoded to match the user-visible budget.
|
||||
const SMP_RAM_MAX_K = 8192
|
||||
|
||||
function formatSampleRamK(bytes) {
|
||||
const k = bytes / 1024
|
||||
return (k < 10 ? k.toFixed(2)
|
||||
: k < 100 ? k.toFixed(1)
|
||||
: Math.round(k).toString())
|
||||
}
|
||||
|
||||
function drawSamplesRamFooter() {
|
||||
const bytes = computeSampleRAMBytes()
|
||||
const ramStr = formatSampleRamK(bytes) + 'k / ' + SMP_RAM_MAX_K + 'k'
|
||||
const y = PTNVIEW_OFFSET_Y//SMP_RIGHT_Y + SMP_PROP_H - 1
|
||||
con.move(y, SCRW - 13)
|
||||
// con.color_pair(colSmpPropLabel, colBackPtn)
|
||||
// print(('Sample RAM' + ' ').substring(0, 10))
|
||||
con.color_pair(colSmpPropValue, colBackPtn)
|
||||
print(ramStr)
|
||||
}
|
||||
|
||||
function drawSamplesEditButton() {
|
||||
const y = SMP_BTN_Y
|
||||
con.move(y, SMP_RIGHT_X)
|
||||
@@ -3572,6 +3604,7 @@ function drawSamplesContents(wo) {
|
||||
drawSamplesListColumn()
|
||||
drawSamplesSeparator()
|
||||
drawSamplesProperties()
|
||||
drawSamplesRamFooter()
|
||||
drawSamplesUsedBy()
|
||||
drawSampleWaveform()
|
||||
drawSamplesEditButton()
|
||||
@@ -5327,6 +5360,7 @@ function openFlagsPopup() {
|
||||
items: items,
|
||||
height: items.length,
|
||||
width: 22,
|
||||
drawWell: false,
|
||||
showScrollbar: false,
|
||||
selectable: (it) => it.kind === 'tone' || it.kind === 'intp',
|
||||
renderItem: (ctx) => {
|
||||
|
||||
@@ -217,6 +217,7 @@ function scrollHorz(dx, stringSize, stringViewSize, currentCursorPos, currentScr
|
||||
// action string to close the dialog,
|
||||
// or null to stay open.
|
||||
// showScrollbar: bool?, -- default: auto (true when overflowing).
|
||||
// drawWell: bool?, -- draw the list background
|
||||
// bg: number?, -- list background colour (default 242).
|
||||
// },
|
||||
//
|
||||
@@ -287,6 +288,8 @@ function showDialog(opts) {
|
||||
: Array.isArray(message) ? message
|
||||
: ('' + message).split('\n')
|
||||
|
||||
const list = opts.list || null
|
||||
const drawWell = list?.drawWell ?? true
|
||||
const c = opts.colours || {}
|
||||
const fg = (c.fg != null) ? c.fg : 254
|
||||
const bg = (c.bg != null) ? c.bg : 244
|
||||
@@ -294,11 +297,10 @@ function showDialog(opts) {
|
||||
const dimFg = (c.dimFg != null) ? c.dimFg : 249
|
||||
const hlFg = (c.hlFg != null) ? c.hlFg : 240
|
||||
const focusBg = (c.focusBg != null) ? c.focusBg : 253
|
||||
const listBg = (c.listBg != null) ? c.listBg : 243
|
||||
const listBg = (c.listBg != null) ? c.listBg : (drawWell) ? 243 : bg
|
||||
const listSelBg = (c.listSelBg != null) ? c.listSelBg : focusBg
|
||||
|
||||
// List state
|
||||
const list = opts.list || null
|
||||
const listItems = list ? (list.items || []) : []
|
||||
const listSelectable = list && list.selectable ? list.selectable : (() => true)
|
||||
const listHeight = list ? (list.height || Math.min(8, listItems.length)) : 0
|
||||
@@ -474,17 +476,21 @@ function showDialog(opts) {
|
||||
const sbar = listScrollbarNeeded()
|
||||
|
||||
// Top border (drawField style)
|
||||
if (drawWell) {
|
||||
con.color_pair(listBgColour, bg)
|
||||
con.move(lbRow, lbCol)
|
||||
print('\u00EC' + '\u00A9'.repeat(lw - 2) + '\u00ED')
|
||||
}
|
||||
|
||||
// Side borders + rows
|
||||
for (let r = 0; r < listHeight; r++) {
|
||||
if (drawWell) {
|
||||
con.color_pair(listBgColour, bg)
|
||||
con.move(lbRow + 1 + r, lbCol)
|
||||
print('\u00AB')
|
||||
con.move(lbRow + 1 + r, lbCol + lw - 1)
|
||||
print('\u00AA')
|
||||
}
|
||||
|
||||
const idx = listScroll + r
|
||||
con.move(lbRow + 1 + r, lbCol + 1)
|
||||
@@ -531,11 +537,13 @@ function showDialog(opts) {
|
||||
}
|
||||
|
||||
// Bottom border
|
||||
if (drawWell) {
|
||||
con.color_pair(listBgColour, bg)
|
||||
con.move(lbRow + 1 + listHeight, lbCol)
|
||||
print('\u00F4' + '\u00AC'.repeat(lw - 2) + '\u00F5')
|
||||
con.color_pair(fg, bg)
|
||||
}
|
||||
}
|
||||
|
||||
function drawButton(i, regions) {
|
||||
const b = buttons[i]
|
||||
|
||||
Reference in New Issue
Block a user