.data brTestPath db 'build\scratch\backrooms-native.bin',0 brTestFrame db 'build\scratch\backrooms-frame.bin',0 brTestExitFrame db 'build\scratch\backrooms-exit.bin',0 brTestIo dd 0 brTestSeeds dd 256 brTestStage dd 91 brTestRows dd 0 brTestLuckPath db 'build\scratch\backrooms-luck.bin',0 brTestProfileDir db 'build\scratch',0 brTestProfileName db 'backrooms-profile.dat',0 brTestProfilePath db 'build\scratch\backrooms-profile.dat',0 brTestPreviewPath db 'build\scratch\br-preview.dat',0 brTestFacesPath db 'build\scratch\backrooms-exit-faces.bin',0 brTestFaceNeighbors dd -32,32,-1,1 brTestFaceAngles dd 384,128,256,0 .code include tools/tests/backrooms_extended_test.inc RunBackroomsTest3D PROC uses ebx esi edi invoke CreateFileA,OFFSET brTestPath,40000000h,0,0,2,80h,0 mov ebx,eax cmp eax,-1 je br_test_fail mov rngSeed3D,12345 br_test_seed: call GenerateBackrooms3D invoke WriteFile,ebx,OFFSET brMap3D,1024,OFFSET brTestIo,0 invoke WriteFile,ebx,OFFSET brExitCell3D,4,OFFSET brTestIo,0 invoke WriteFile,ebx,OFFSET brGameCells3D,24,OFFSET brTestIo,0 dec brTestSeeds jnz br_test_seed invoke CloseHandle,ebx mov brTestStage,92 mov obsActive3D,0 mov tournamentMode,0 mov brActive3D,0 mov engineMode,MODE_WALK mov hallLevel3D,0 mov playerX,16*FP_1+FP_HALF mov playerY,30*FP_1-11000 mov playerAngle,128 mov keys3D[57h],1 mov deltaTime3D,50 mov esi,39 br_test_entry: call BackroomsEntry3D cmp brActive3D,0 jne br_test_fail dec esi jnz br_test_entry cmp brEntryHold3D,1950 jne br_test_fail mov brTestStage,93 mov playerAngle,129 call BackroomsEntry3D cmp brEntryHold3D,0 jne br_test_fail mov playerAngle,128 call BackroomsEntry3D cmp brEntryHold3D,50 jne br_test_fail mov keys3D[57h],0 call BackroomsEntry3D cmp brEntryHold3D,0 jne br_test_fail mov brTestStage,94 mov keys3D[57h],1 mov brEntryHold3D,1950 mov brEntryAngle3D,128 call BackroomsEntry3D cmp brActive3D,1 jne br_test_fail cmp brCutscene3D,1 jne br_test_fail mov brClock3D,900 call HandleBackrooms3D mov brTestStage,95 invoke CanWalk3D,FP_1+FP_HALF,FP_1+FP_HALF cmp eax,1 jne br_test_fail invoke CanWalk3D,FP_HALF,FP_HALF test eax,eax jnz br_test_fail mov brTestStage,96 ; Set up standard projection LUT through the real hall initializer first. call InitHall3D call RunBackroomsWallTest3D test eax,eax jnz br_test_return mov brActive3D,1 mov hallLevel3D,HALL_BACKROOMS mov worldMap3D,OFFSET brMap3D mov floorTexture3D,BR_FLOOR mov viewHorizon3D,HALF_H mov brClock3D,8100 mov brDialogue3D,2500 mov brCutscene3D,0 mov playerX,FP_1+FP_HALF mov playerY,FP_1+FP_HALF mov playerAngle,64 call RenderBackrooms3D invoke CreateFileA,OFFSET brTestFrame,40000000h,0,0,2,80h,0 mov ebx,eax invoke WriteFile,ebx,OFFSET screenBuffer,SCREEN_SIZE*4,OFFSET brTestIo,0 invoke CloseHandle,ebx ; Door capture from its reachable exit cell, facing a neighboring wall. mov ebx,brExitCell3D mov eax,ebx and eax,31 shl eax,16 add eax,FP_HALF mov playerX,eax mov eax,ebx shr eax,5 shl eax,16 add eax,FP_HALF mov playerY,eax mov playerAngle,384 cmp brMap3D[ebx-32],0 jne br_test_exit_camera mov playerAngle,128 cmp brMap3D[ebx+32],0 jne br_test_exit_camera mov playerAngle,256 cmp brMap3D[ebx-1],0 jne br_test_exit_camera mov playerAngle,0 br_test_exit_camera: mov brDialogue3D,10000 call RenderBackrooms3D invoke CreateFileA,OFFSET brTestExitFrame,40000000h,0,0,2,80h,0 mov ebx,eax invoke WriteFile,ebx,OFFSET screenBuffer,SCREEN_SIZE*4,OFFSET brTestIo,0 invoke CloseHandle,ebx mov arrivalConfirmed3D,0 call RunBackroomsDoorFrames3D invoke LeaveBackrooms3D,1 cmp brOwned3D,1 jne br_test_fail cmp brActive3D,0 jne br_test_fail cmp hallLevel3D,0 jne br_test_fail mov brTestStage,97 call RunBackroomsContextTest3D test eax,eax jnz br_test_return mov brActive3D,1 call BackroomsLuck3D cmp eax,-1 jne br_test_fail mov brActive3D,0 mov tournamentMode,1 call BackroomsLuck3D cmp eax,-1 jne br_test_fail mov tournamentMode,0 xor edi,edi mov esi,100000 br_test_luck: call BackroomsLuck3D add edi,eax dec esi jnz br_test_luck cmp edi,89000 jb br_test_fail cmp edi,91000 ja br_test_fail call RunBackroomsExtendedTest3D test eax,eax jnz br_test_return mov brTestStage,98 call LoadNativeCoinArt3D call InitNativeSlots3D call InitNativeClover3D call InitNativeBlackjack3D call InitNativePoker3D invoke CreateFileA,OFFSET brTestLuckPath,40000000h,0,0,2,80h,0 mov ebx,eax mov brTestRows,1000 br_test_rounds: mov bankroll,1000000 mov coin3d_choice,1 mov coin3d_state,COIN_IDLE mov pressedKeys3D[20h],1 call HandleNativeCoin3D invoke WriteFile,ebx,OFFSET coin3d_result,4,OFFSET brTestIo,0 mov dice3d_state,0 mov dice3d_choice,1 mov pressedKeys3D[20h],1 call HandleDiceRules3D invoke WriteFile,ebx,OFFSET dice3d_val1,8,OFFSET brTestIo,0 mov slotSpinState,SLOT_READY call StartNativeSlots3D invoke WriteFile,ebx,OFFSET slotReel1,12,OFFSET brTestIo,0 mov clpState3D,SLOT_READY call StartNativeClover3D call CloverEvaluate3D invoke WriteFile,ebx,OFFSET clpTotal3D,4,OFFSET brTestIo,0 mov cbBotCount3D,0 mov cbState3D,CB_IDLE call StartNativeBlackjack3D invoke WriteFile,ebx,OFFSET cbPlayerScore3D,4,OFFSET brTestIo,0 invoke WriteFile,ebx,OFFSET cbDeck3D,208,OFFSET brTestIo,0 mov pkState3D,PK_IDLE call StartNativePoker3D invoke WriteFile,ebx,OFFSET pkDeck3D,208,OFFSET brTestIo,0 invoke WriteFile,ebx,OFFSET pkButton3D,4,OFFSET brTestIo,0 dec brTestRows jnz br_test_rounds invoke CloseHandle,ebx mov brTestStage,99 mov nativeProfilesDirPtr3D,OFFSET brTestProfileDir invoke CopyCString,OFFSET saveFileName,OFFSET brTestProfileName mov nativeProfileActive3D,1 mov brOwned3D,1 mov brEnabled3D,0 call SaveGame mov brOwned3D,0 mov brEnabled3D,1 call LoadSave cmp brOwned3D,1 jne br_test_fail cmp brEnabled3D,0 jne br_test_fail invoke ValidateGraphicProfile3D,OFFSET brTestProfilePath cmp eax,1 jne br_test_fail call RunBackroomsSaveTest3D test eax,eax jnz br_test_return xor eax,eax ret br_test_fail: mov eax,brTestStage br_test_return: ret RunBackroomsTest3D ENDP ; Identical door/camera distance on every face, VHS off/on pairs. RunBackroomsDoorFrames3D PROC uses ebx esi edi local face:DWORD,effect:DWORD invoke CreateFileA,OFFSET brTestFacesPath,40000000h,0,0,2,80h,0 mov ebx,eax mov face,0 br_test_door_face: lea edi,brMap3D xor eax,eax mov ecx,256 rep stosd ; Keep all rays inside the fixture map, including peripheral FOV rays. xor esi,esi br_test_door_border: mov brMap3D[esi],BR_WALL mov brMap3D[esi+31*32],BR_WALL mov eax,esi shl eax,5 mov brMap3D[eax],BR_WALL mov brMap3D[eax+31],BR_WALL inc esi cmp esi,32 jb br_test_door_border mov brExitCell3D,16*32+16 mov esi,face mov eax,brTestFaceNeighbors[esi*4] mov brMap3D[eax+16*32+16],BR_WALL mov playerX,16*FP_1+FP_HALF mov playerY,16*FP_1+FP_HALF mov eax,brTestFaceAngles[esi*4] mov playerAngle,eax mov viewEye3D,HALL_STANDING_EYE mov viewHorizon3D,HALF_H mov brDialogue3D,10000 mov effect,0 br_test_door_effect: mov eax,effect mov brVhs3D,eax call RenderBackrooms3D invoke WriteFile,ebx,OFFSET screenBuffer,SCREEN_SIZE*4,OFFSET brTestIo,0 inc effect cmp effect,2 jb br_test_door_effect inc face cmp face,4 jb br_test_door_face invoke CloseHandle,ebx ret RunBackroomsDoorFrames3D ENDP