Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 | 43x 43x 43x 12x 5x 4x 11x 11x 11x 1x 2x 2x 1x 2x 2x 1x 87x 87x 87x 87x 87x 87x 87x 87x 164x 166x 5x 5x 87x 71x 43x 2x 1x 1x 48x 2x 7x 7x 3x 1x 1x 1x 1x 11x 4x 1x 9x 13x 2x 1x 10x 3x 1x 1x 1x 2x 2x 26x 14x 21x 21x 21x 19x 21x 31x 1x 1x 1x 1x 1x 4x 7x 7x 4x 1x 3x 3x 2x | import { isSPToDPBattleMode } from '@be-music/player-engine/lanes';
import {
LR2_GAUGE_TYPES,
gaugePickType,
optionValueName,
type GaugePick,
type GaugeType,
} from '@be-music/player-engine/ruleset';
import {
BGA_CYCLE,
BGA_SIZE_CYCLE,
DIFFICULTY_FILTER_CYCLE,
HIDDEN_SUDDEN_CYCLE,
HISPEED_MAX,
HISPEED_MIN,
HS_FIX_CYCLE,
KEYS_FILTER_CYCLE,
RANDOM_CYCLE,
SORT_CYCLE,
type BGAMode,
type DifficultyFilter,
type PlayOptions,
} from '@be-music/player-scene-model';
import { LR2_BUTTON, LR2_NUM, LR2_OP, LR2_SLIDER, LR2_TEXT } from '../ids/index.ts';
/**
* LR2's BATTLE button cycle (`config.play.battle` 0-3): OFF, BATTLE (two players), D-BATTLE and SP TO DP. G-BATTLE
* (4), a ghost battle against a rival's score, is not offered.
*/
export const LR2_BATTLE_CYCLE: readonly PlayOptions['battleMode'][] = ['OFF', 'TWO-PLAYER', 'D-BATTLE', 'SP-TO-DP'];
/**
* LR2's automatic judge-timing button cycle (`config.play.autojudge` 0-2): OFF, ON and SILENT. beatoraja's calibration
* is not on it, and reads as OFF.
*/
export const LR2_JUDGE_TIMING_AUTO_ADJUST_CYCLE: readonly PlayOptions['judgeTimingAutoAdjust'][] = [
'OFF',
'LR2-ON',
'LR2-SILENT',
];
/** The range LR2's JUDGE TIMING button (74) steps the judge timing within, in milliseconds either way. */
export const LR2_JUDGE_TIMING_LIMIT_MS = 99;
/**
* The judge timing after a click on LR2's JUDGE TIMING button (74): 1 ms up or down (`step`'s sign), stopping at ±99
* (OpenLR2 `LR2f.cpp` 10617). A timing the automatic adjustment carried past the range only moves back toward it.
*/
export function stepLR2JudgeTiming(currentMs: number, step: number): number {
if (step > 0) return currentMs < LR2_JUDGE_TIMING_LIMIT_MS ? currentMs + 1 : currentMs;
Eif (step < 0) return currentMs > -LR2_JUDGE_TIMING_LIMIT_MS ? currentMs - 1 : currentMs;
return currentMs;
}
/** The automatic judge-timing label of the option panel (text 80): OFF, ON or SILENT. */
function judgeAutoAdjustLabel(mode: PlayOptions['judgeTimingAutoAdjust']): string {
return mode === 'LR2-ON' ? 'ON' : mode === 'LR2-SILENT' ? 'SILENT' : 'OFF';
}
/**
* The BATTLE label of the option panel (text 69) as LR2's `optionstr.csv` names it for the selected chart's key mode:
* BATTLE on a double-play chart is COUPLE, SP TO DP is DP-TO-SP or 9-TO-7, and an option the chart cannot take is
* DISABLE (`SetObjectStrings_SongSelect`).
*/
function battleLabel(battle: PlayOptions['battleMode'], keyModeOp: number | undefined): string {
const double = keyModeOp === LR2_OP.KEYS_10 || keyModeOp === LR2_OP.KEYS_14;
const nine = keyModeOp === LR2_OP.KEYS_9;
switch (battle) {
case 'AUTO':
return 'CHART';
case 'COUPLE':
return nine ? 'DISABLE' : 'COUPLE';
case 'TWO-PLAYER':
return double ? 'COUPLE' : nine ? 'DISABLE' : 'BATTLE';
case 'D-BATTLE':
return double || nine ? 'DISABLE' : 'D-BATTLE';
case 'BATTLE':
case 'beatoraja:BATTLE':
case '____:BATTLE':
// beatoraja's and That-Which-Must-Not-Be-Named's one-player BATTLE, picked from the Options dialog: the nearest LR2
// label is its own BATTLE (ADR 0019).
return double || nine ? 'DISABLE' : 'BATTLE';
case 'SP-TO-DP':
case 'SP-TO-DP-CORRECTED':
return double ? 'DP-TO-SP' : nine ? '9-TO-7' : 'SP-TO-DP';
default:
return 'OFF';
}
}
/**
* LR2's battle ops (10-13) for the key filter and BATTLE option: op 10 a double-play filter (DOUBLE, 14KEYS, 10KEYS)
* or D-BATTLE / SP TO DP, op 11 and 13 BATTLE, op 12 either. LR2 reads them off the select screen's settings on every
* screen.
*/
export function resolveLR2BattleOps(options: Partial<Pick<PlayOptions, 'keysFilter' | 'battleMode'>>): number[] {
const doubleFilter = options.keysFilter === 'KEYS_10' || options.keysFilter === 'KEYS_14';
const battle = options.battleMode === 'TWO-PLAYER' || options.battleMode === 'COUPLE';
const doubleBattle = options.battleMode === 'D-BATTLE' || isSPToDPBattleMode(options.battleMode);
const ops: number[] = [];
if (doubleFilter || doubleBattle) ops.push(LR2_OP.DOUBLE);
if (battle) ops.push(LR2_OP.BATTLE, LR2_OP.GHOST_BATTLE_OR_BATTLE);
if (doubleFilter || battle || doubleBattle) ops.push(LR2_OP.DOUBLE_OR_BATTLE);
return ops;
}
/**
* Whether a gauge is one of LR2's red (survival) gauges: HARD and DEATH (corrected or not). A source-qualified pick
* (`beatoraja:HARD`) reads as its gauge type.
*/
export function isLR2RedGauge(pick: GaugePick): boolean {
// A bare pick is its own gauge type; only a source-qualified one needs splitting.
return isRedGaugeType(pick) || (pick.includes(':') && isRedGaugeType(gaugePickType(pick)));
}
function isRedGaugeType(gauge: string): boolean {
return gauge === 'HARD' || gauge === 'DEATH' || gauge === 'DEATH-CORRECTED' || gauge === 'EX-HARD';
}
/**
* The LR2 gauge cell a pick draws on: beatoraja's and AC's extra gauges and the corrected HAZARD on their nearest, and a
* source-qualified pick on its gauge type's (ADR 0019).
*/
function lr2GaugeCell(pick: GaugePick): GaugeType {
const gauge = gaugePickType(pick);
return gauge === 'EX-HARD'
? 'HARD'
: gauge === 'ASSIST-EASY'
? 'EASY'
: gauge === 'DEATH-CORRECTED'
? 'DEATH'
: gauge;
}
/** Whether the BGA shows: ON, or AUTOPLAY ONLY while AUTOPLAY is on. */
export function isLR2BGAShown(bga: BGAMode, autoPlay: boolean): boolean {
return bga === 'ON' || (bga === 'AUTOPLAY_ONLY' && autoPlay);
}
/**
* The play-option ops a select screen lights from the player's options: the BGA (40 / 41) and its size (30 / 31), the
* score graph (38 / 39), each side's auto scratch (54-57) and gauge (42-45: HARD and DEATH are the red gauges) and the
* difficulty filter (46 / 47).
*/
export function resolveLR2PlayOptionOps(options: PlayOptions): number[] {
return [
...resolveLR2BattleOps(options),
isLR2BGAShown(options.bga, options.autoPlay) ? LR2_OP.BGA_ON : LR2_OP.BGA_OFF,
options.bgaSize === 'EXTEND' ? LR2_OP.BGA_EXTEND : LR2_OP.BGA_NORMAL,
options.scoreGraph ? LR2_OP.SCORE_GRAPH_ON : LR2_OP.SCORE_GRAPH_OFF,
options.autoScratch1P ? LR2_OP.AUTO_SCRATCH_1P_ON : LR2_OP.AUTO_SCRATCH_1P_OFF,
options.autoScratch2P ? LR2_OP.AUTO_SCRATCH_2P_ON : LR2_OP.AUTO_SCRATCH_2P_OFF,
isLR2RedGauge(options.gauge1P) ? LR2_OP.GAUGE_1P_RED : LR2_OP.GAUGE_1P_NORMAL,
isLR2RedGauge(options.gauge2P) ? LR2_OP.GAUGE_2P_RED : LR2_OP.GAUGE_2P_NORMAL,
options.difficultyFilter !== 'ALL' ? LR2_OP.DIFFICULTY_FILTER_ON : LR2_OP.DIFFICULTY_FILTER_OFF,
];
}
/** The difficulty filter each of LR2's direct difficulty buttons (91 ALL … 96 INSANE) sets. */
export const LR2_DIFFICULTY_FILTER_BUTTONS: Readonly<Record<number, DifficultyFilter>> = {
[LR2_BUTTON.DIFFICULTY_FILTER_ALL]: 'ALL',
[LR2_BUTTON.DIFFICULTY_FILTER_BEGINNER]: 'BEGINNER',
[LR2_BUTTON.DIFFICULTY_FILTER_NORMAL]: 'NORMAL',
[LR2_BUTTON.DIFFICULTY_FILTER_HYPER]: 'HYPER',
[LR2_BUTTON.DIFFICULTY_FILTER_ANOTHER]: 'ANOTHER',
[LR2_BUTTON.DIFFICULTY_FILTER_INSANE]: 'INSANE',
};
/** The play-style label of the option panel (text 60) for a key-mode op. */
function playStyleLabel(keyModeOp: number | undefined): string {
switch (keyModeOp) {
case LR2_OP.KEYS_5:
return '5KEYS';
case LR2_OP.KEYS_7:
return '7KEYS';
case LR2_OP.KEYS_10:
return '10KEYS';
case LR2_OP.KEYS_14:
return '14KEYS';
case LR2_OP.KEYS_9:
return '9KEYS';
default:
return 'SINGLE';
}
}
/**
* The option panel's labels (texts 60-85): each option's setting as the LR2 default skin names it, the play style from
* the selected chart's key-mode op (`SINGLE` without one). The options Be-Music does not have read as their off
* setting. `undefined` for any other text.
*/
export function resolveLR2OptionText(
st: number,
options: PlayOptions,
keyModeOp: number | undefined,
): string | undefined {
switch (st) {
case LR2_TEXT.OPTION_PLAY_STYLE:
return playStyleLabel(keyModeOp);
case LR2_TEXT.OPTION_SORT:
return options.sort;
case LR2_TEXT.OPTION_DIFFICULTY_FILTER:
return options.difficultyFilter;
// A source-qualified lane option reads as its bare name (`beatoraja:S-RANDOM` as S-RANDOM, ADR 0019).
case LR2_TEXT.OPTION_RANDOM_1P:
return optionValueName(options.random1P);
case LR2_TEXT.OPTION_RANDOM_2P:
return optionValueName(options.random2P);
// A source-qualified gauge reads as its gauge type (`beatoraja:EX-HARD` as EX-HARD, ADR 0019).
case LR2_TEXT.OPTION_GAUGE_1P:
return gaugePickType(options.gauge1P);
case LR2_TEXT.OPTION_GAUGE_2P:
return gaugePickType(options.gauge2P);
case LR2_TEXT.OPTION_ASSIST_1P:
return options.autoScratch1P ? 'AUTOSCRATCH' : 'OFF';
case LR2_TEXT.OPTION_ASSIST_2P:
return options.autoScratch2P ? 'AUTOSCRATCH' : 'OFF';
case LR2_TEXT.OPTION_FLIP:
return options.dpFlip ? 'ON' : 'OFF';
case LR2_TEXT.OPTION_SCORE_GRAPH:
return options.scoreGraph ? 'ON' : 'OFF';
case LR2_TEXT.OPTION_LANE_COVER:
// The ON / OFF switch; the height is the slider next to it.
return options.laneCover ? 'ON' : 'OFF';
case LR2_TEXT.OPTION_BGA_SIZE:
return options.bgaSize;
case LR2_TEXT.OPTION_BGA:
return options.bga === 'AUTOPLAY_ONLY' ? 'AUTOPLAY' : options.bga;
case LR2_TEXT.OPTION_EFFECT_1P:
return options.hiddenSudden1P;
case LR2_TEXT.OPTION_EFFECT_2P:
return options.hiddenSudden2P;
case LR2_TEXT.OPTION_BATTLE:
return battleLabel(options.battleMode, keyModeOp);
case LR2_TEXT.OPTION_JUDGE_AUTO_ADJUST:
return judgeAutoAdjustLabel(options.judgeTimingAutoAdjust);
case LR2_TEXT.OPTION_GHOST:
case LR2_TEXT.OPTION_SCROLL_TYPE:
case LR2_TEXT.OPTION_REPLAY_SAVE:
return 'OFF';
case LR2_TEXT.OPTION_COLOR_DEPTH:
return '32 BIT';
case LR2_TEXT.OPTION_VSYNC:
return 'ON';
case LR2_TEXT.OPTION_SCREEN_MODE:
return 'FULL';
case LR2_TEXT.OPTION_TRIAL_LINE_1:
case LR2_TEXT.OPTION_TRIAL_LINE_2:
return '';
default:
return undefined;
}
}
/**
* The option numbers (10-15): each side's hi-speed × 100 (both sides read the one hi-speed) and the judge timing in
* milliseconds (12). The target rate and the lane cover numbers read 0 until the options exist. `undefined` for any
* other number.
*/
export function resolveLR2OptionNumber(
num: number,
options: Pick<PlayOptions, 'hiSpeed' | 'judgeTimingMs'>,
): number | undefined {
switch (num) {
case LR2_NUM.HISPEED_1P:
case LR2_NUM.HISPEED_2P:
return Math.round(options.hiSpeed * 100);
case LR2_NUM.JUDGE_TIMING:
return options.judgeTimingMs;
case LR2_NUM.TARGET_RATE:
case LR2_NUM.LANE_COVER_1P:
case LR2_NUM.LANE_COVER_2P:
return 0;
default:
return undefined;
}
}
/**
* The hi-speed and lane cover sliders (2-5): each side's hi-speed over the hi-speed range and the lane cover height
* (both sides read the one setting). `undefined` for any other slider.
*/
export function resolveLR2OptionSlider(
type: number,
options: Pick<PlayOptions, 'hiSpeed' | 'shutter'>,
): number | undefined {
switch (type) {
case LR2_SLIDER.HISPEED_1P:
case LR2_SLIDER.HISPEED_2P:
return lr2HiSpeedSlider(options.hiSpeed);
case LR2_SLIDER.LANE_COVER_1P:
case LR2_SLIDER.LANE_COVER_2P:
return Math.max(0, Math.min(1, options.shutter));
default:
return undefined;
}
}
/** A hi-speed as a slider position: its place in the hi-speed range, 0..1. */
export function lr2HiSpeedSlider(hiSpeed: number): number {
const span = HISPEED_MAX - HISPEED_MIN;
return span <= 0 ? 0 : Math.max(0, Math.min(1, (hiSpeed - HISPEED_MIN) / span));
}
/** The index of `value` in `choices`, 0 when it is not one of them. */
function cell<T>(choices: readonly T[], value: T): number {
return Math.max(0, choices.indexOf(value));
}
/** The lane option cell of LR2's RANDOM buttons (42 / 43): by the bare name, so any source's S-RANDOM draws S-RANDOM. */
function laneCell(value: PlayOptions['random1P'] | undefined): number {
return value === undefined ? 0 : cell(RANDOM_CYCLE.map(optionValueName), optionValueName(value));
}
/**
* The lane option a click on LR2's RANDOM button (42 / 43) moves to: the next of LR2's own values (`RANDOM_CYCLE`), one
* step from the cell `current` draws, in `step`'s direction. Another source's RANDOM, S-RANDOM or CONVERGE steps from the
* cell of its bare name, and a value LR2 does not have (SPIRAL, H-RANDOM, ...) moves to OFF (ADR 0019).
*/
export function stepLR2LaneOption(current: PlayOptions['random1P'] | undefined, step: number): PlayOptions['random1P'] {
const names = RANDOM_CYCLE.map(optionValueName);
const index = current === undefined ? 0 : names.indexOf(optionValueName(current));
if (index < 0) return RANDOM_CYCLE[0]!;
const delta = step < 0 ? -1 : 1;
return RANDOM_CYCLE[(index + delta + RANDOM_CYCLE.length) % RANDOM_CYCLE.length]!;
}
/**
* The cell an option button draws (`#SRC_BUTTON` types 10-12, 40-46, 50-55, 70-73, 75, 91-96): the index of the option's
* value in its LR2 cycle order (an on / off option: 0 off, 1 on; a direct difficulty button: 1 while its difficulty
* is the filter). `undefined` for any other button; the caller clamps it to the button's cells.
*/
export function resolveLR2OptionButton(type: number, options: PlayOptions): number | undefined {
switch (type) {
case LR2_BUTTON.BGA:
return cell(BGA_CYCLE, options.bga);
case LR2_BUTTON.BGA_SIZE:
return cell(BGA_SIZE_CYCLE, options.bgaSize);
case LR2_BUTTON.SCORE_GRAPH:
return options.scoreGraph ? 1 : 0;
case LR2_BUTTON.DIFFICULTY_FILTER:
return cell(DIFFICULTY_FILTER_CYCLE, options.difficultyFilter);
case LR2_BUTTON.KEY_MODE_FILTER:
return cell(KEYS_FILTER_CYCLE, options.keysFilter);
case LR2_BUTTON.SORT:
return cell(SORT_CYCLE, options.sort);
case LR2_BUTTON.HS_FIX:
return cell(HS_FIX_CYCLE, options.hsFix);
case LR2_BUTTON.EFFECT_1P:
return cell(HIDDEN_SUDDEN_CYCLE, options.hiddenSudden1P);
case LR2_BUTTON.EFFECT_2P:
return cell(HIDDEN_SUDDEN_CYCLE, options.hiddenSudden2P);
case LR2_BUTTON.LANE_COVER:
return options.laneCover ? 1 : 0;
case LR2_BUTTON.AUTO_SCRATCH_1P:
return options.autoScratch1P ? 1 : 0;
case LR2_BUTTON.AUTO_SCRATCH_2P:
return options.autoScratch2P ? 1 : 0;
case LR2_BUTTON.FLIP:
return options.dpFlip ? 1 : 0;
case LR2_BUTTON.BATTLE:
return Math.max(0, LR2_BATTLE_CYCLE.indexOf(options.battleMode));
case LR2_BUTTON.JUDGE_AUTO_ADJUST:
return cell(LR2_JUDGE_TIMING_AUTO_ADJUST_CYCLE, options.judgeTimingAutoAdjust);
case LR2_BUTTON.RANDOM_1P:
return laneCell(options.random1P);
case LR2_BUTTON.RANDOM_2P:
return laneCell(options.random2P);
case LR2_BUTTON.GAUGE_1P:
return cell(LR2_GAUGE_TYPES, lr2GaugeCell(options.gauge1P));
case LR2_BUTTON.GAUGE_2P:
return cell(LR2_GAUGE_TYPES, lr2GaugeCell(options.gauge2P));
default: {
const difficulty = LR2_DIFFICULTY_FILTER_BUTTONS[type];
if (difficulty === undefined) return undefined;
return options.difficultyFilter === difficulty ? 1 : 0;
}
}
}
|