@@ -11,14 +11,20 @@ export const gameState: Stateful<{
1111 initting : boolean ;
1212 playing : boolean ;
1313 hasEverest : boolean ;
14+ memory : number ;
1415} > = $state ( {
1516 ready : false ,
1617 initting : false ,
1718 playing : false ,
1819 hasEverest : false ,
20+ memory : - 1 ,
1921} ) ;
22+ ( globalThis as any ) . gameState = gameState ;
2023export const loglisteners : ( ( log : Log ) => void ) [ ] = [ ] ;
2124
25+ let logs : string [ ] = [ ] ;
26+ ( globalThis as any ) . logs = logs ;
27+
2228function proxyConsole ( name : string , color : string ) {
2329 // @ts -expect-error ts sucks
2430 const old = console [ name ] . bind ( console ) ;
@@ -34,6 +40,7 @@ function proxyConsole(name: string, color: string) {
3440 for ( const logger of loglisteners ) {
3541 logger ( { color, log : str } ) ;
3642 }
43+ logs . push ( str ) ;
3744 } ;
3845 return old ;
3946}
@@ -42,6 +49,7 @@ export const bypassWarn = proxyConsole("warn", "var(--warning)");
4249export const bypassLog = proxyConsole ( "log" , "var(--fg)" ) ;
4350export const bypassInfo = proxyConsole ( "info" , "var(--info)" ) ;
4451export const bypassDebug = proxyConsole ( "debug" , "var(--fg4)" ) ;
52+ ( globalThis as any ) . bypassLog = bypassLog ;
4553
4654function hookfmod ( ) {
4755 let contexts : AudioContext [ ] = [ ] ;
@@ -200,6 +208,7 @@ export async function preInit() {
200208 console . debug ( "initializing dotnet" ) ;
201209 const runtime = await dotnet
202210 . withConfig ( {
211+ pthreadPoolInitialSize : 16
203212 } )
204213 . withRuntimeOptions ( [
205214 // jit functions quickly and jit more functions
@@ -391,14 +400,25 @@ export async function UploadSteamCloud() {
391400
392401const SEAMLESSCOUNT = 5 ;
393402
403+ function monitorMem ( ) : ( ) => void {
404+ let stop = false ;
405+ exports . CelesteLoader . WatchMemoryUsage ( ( mem : number ) => {
406+ gameState . memory = mem ;
407+ return stop ;
408+ } )
409+ return ( ) => stop = true ;
410+ }
411+
394412export async function play ( ) {
395413 gameState . playing = true ;
396414 gameState . initting = true ;
397415
416+ let stopMonitoring = monitorMem ( ) ;
417+
398418 console . debug ( "Init..." ) ;
399419 const before = performance . now ( ) ;
400420
401- await exports . CelesteLoader . Init ( ) ;
421+ await exports . CelesteLoader . Init ( false ) ;
402422
403423 // run some frames for seamless transition
404424 for ( let i = 0 ; i < SEAMLESSCOUNT ; i ++ ) {
@@ -413,8 +433,9 @@ export async function play() {
413433
414434 await exports . CelesteLoader . MainLoop ( ) ;
415435
416- console . debug ( "Cleanup..." ) ;
436+ stopMonitoring ( ) ;
417437
438+ console . debug ( "Cleanup..." ) ;
418439 await exports . CelesteLoader . Cleanup ( ) ;
419440 gameState . ready = false ;
420441 gameState . playing = false ;
0 commit comments