Re-compress all Mame zip roms to 7z format

In advance,

trans_to_7z.sh

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
#!/bin/bash
 
PARENTDIR=$1
TMPDIR=`pwd`/tmp
 
PATH="/d/cext/Program Files/7-Zip:$PATH"
 
ISERR="no"
 
if [ "x$1" = x ] ; then
	echo "Please input dir to transform."
	exit
fi
 
if [ -e "$TMPDIR" ] ; then
	echo "Please rmdir [$TMPDIR] first."
	exit
fi
 
get_win_path()
{
	local win_path="$1"
	win_path="${win_path#/}"
	win_path="${win_path//\//\\}"
	win_path="${win_path/\\/\:\\}"
	echo $win_path
}
 
format_transform()
{
	local file_7z=$1
	local file_zip=$2
	local tmp_dir=$TMPDIR
	mkdir "$tmp_dir"
 
	7z x ${file_7z} -o"`get_win_path \"$tmp_dir\"`"
	(
		cd "$tmp_dir"
		ls
 
		7z a -mx9 "`get_win_path \"${file_zip}\"`" || ( echo "Creating 7z file failed." && ISERR="yes" )
	)
 
	rm -Rf "$tmp_dir"
}
 
cd "$PARENTDIR"
 
for fn in `ls *.zip`; do
 
	echo "$fn"
 
	format_transform $fn "`pwd`/${fn%.zip}.7z"
 
	if [ $ISERR = "yes" ]; then
		exit
	fi
done
 
echo "Transforming done."

How to use?

Copy trans_to_7z.sh to Mame root folder which contains roms sub-directory, right click at blank place of this Mame root window in Explorer, select "Git Bash Here" which prompts bash console, input below and return,

1
./trans_to_7z.sh roms

refer to:
https://www.cnblogs.com/wq242424/p/15564203.html

Switch between GPUs in Fedora35

Install Nvidia driver from rpmfusion,

yum install --nogpgcheck https://mirrors.tuna.tsinghua.edu.cn/rpmfusion/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://mirrors.tuna.tsinghua.edu.cn/rpmfusion/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
dnf install akmod-nvidia

Before rebooting, must sign nividia driver using MOK.der, if not, we will receive at boot, "nvidia kernel module missing. falling back to nouveau".

Or install Nvidia driver from official site,

Clean up akmod-nvidia,

dnf remove akmod-nvidia
dnf remove xorg-x11-drv-nvidia

To blacklist the nouveau drivers,

dracut -v /boot/initramfs-`uname -r`.img `uname -r` --force

/etc/default/grub

GRUB_CMDLINE_LINUX="rhgb quiet rd.driver.blacklist=nouveau modprobe.blacklist=nouveau nvidia-drm.modeset=1"
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

After rebooting, download NVIDIA-Linux-x86_64-XXX.XX.XX.run from official site, install it using /root/signed-modules/MOK.* and reboot,
https://www.nvidia.com/download/index.aspx?lang=en-us

Check current GPU vendor,

1
glxinfo | egrep "OpenGL vendor|OpenGL renderer"

How to dynamically switch GPUs?

I found ue4 selecting /dev/nvidia0 by itself, we needn't care about if switch.

https://pellegrino.link/2015/11/29/signing-nvidia-proprietary-driver-on-fedora.html
https://www.cnblogs.com/Mingxx/p/3192483.html
https://docs.fedoraproject.org/en-US/quick-docs/how-to-set-nvidia-as-primary-gpu-on-optimus-based-laptops/

Play mame in Linux handily

1
dnf install mame

in ~/.bashrc

1
2
MAME_DATABASE=/to/path/of/mame
alias mame_go="mame -window -rompath ${MAME_DATABASE}/roms -snapshot_directory ${MAME_DATABASE}/snap "

how to play,

1
2
3
4
# open game list.
mame_go
# or quickly into play.
mame_go sf2ce

Other emulators,

1
2
3
4
# fc nes
dnf install fceux
# ps2
dnf install pcsx2

Virtualbox memo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
hgcmThread, hgcmServiceThread
	HGCM_MSG_CONNECT
	HGCM_MSG_REGEXT
	SVC_MSG_HOSTCALL // when drag and drop occurs
src/VBox/HostServices/DragAndDrop/VBoxDragAndDropSvc.cpp:1071
	DragAndDropService::hostCall
src/VBox/Frontends/VirtualBox/src/main.cpp:939
src/VBox/Main/src-client/ConsoleImpl.cpp
	VMR3Create
src/VBox/HostServices/GuestProperties/VBoxGuestPropSvc.cpp
	Service::call
		GUEST_PROP_FN_GET_PROP
		GUEST_PROP_FN_SET_PROP
		GUEST_PROP_FN_SET_PROP_VALUE
		GUEST_PROP_FN_DEL_PROP
		GUEST_PROP_FN_ENUM_PROPS
		GUEST_PROP_FN_GET_NOTIFICATION

Build virtualbox in fedora35

Download VirtualBox source and extract it to /home/work/vb/VirtualBox-6.1.32.

Involve qt,

# read in ./configure
#	for q in $QT5DIR "$DEVDIR/linux.$TARGET_MACHINE"/qt/v5.*; do
# so download qt5.9.2 and install to /home/work/qt/Qt5.9.2
wget http://download.qt.io/archive/qt/5.9/5.9.2/qt-opensource-linux-x64-5.9.2.run
# make a link to qt5.9.2
cd /home/work/vb/VirtualBox-6.1.32/tools/linux.amd64
mkdir qt
ln -s /home/work/qt/Qt5.9.2/5.9.2/gcc_64 `pwd`/qt/v5.9.2

Build it,

# must add '--skip-broken', or else our fedora os will be mute curiously, suddenly
# in the subsequent experience.
yum install gcc-c++ subversion subversion-gnome kernel-devel which tar gzip bzip2 \
  doxygen mscgen wine-core \
  glibc-devel libcap-devel libcurl-devel libIDL-devel \
  libstdc++-static libxslt-devel libvpx-devel libXmu-devel \
  pam-devel pulseaudio-libs-devel python-devel qt-devel rpm-build SDL_ttf-devel \
  SDL-static device-mapper-devel glibc-static zlib-static \
  glibc-devel.i686 libstdc++.i686 pulseaudio \
  texlive texlive-latex texlive-latex-bin texlive-ec \
  texlive-collection-fontsrecommended texlive-pdftex-def texlive-fancybox texlive-tabulary \
  libpng-devel openssl-devel acpica-tools opus opus-devel --skip-broken

# in addition to offical prerequisites
yum install python3-devel libXcursor-devel libXinerama-devel libXrandr-devel alsa-lib-devel makeself yasm

cd /home/work/vb/VirtualBox-6.1.32

# modify ./configure
#SUPPYTHONLIBS="python3.10 python2.7 ..."

# RTAssertShouldPanic error: this statement may fall through [-Werror=implicit-fallthrough=]
# modify ./Config.kmk
# uncomment below line
#VBOX_WITH_TESTCASES = 1

./configure --disable-hardening --disable-docs --disable-java
source ./env.sh
kmk BUILD_TYPE=debug -j 1

how to run,

cd out/linux.x86/release/bin/src
make
sudo make install

#sign generated vbox kernel modules

cd ..
export LD_LIBRARY_PATH=/home/work/qt/Qt5.9.2/5.9.2/gcc_64/lib:LD_LIBRARY_PATH
./VirtualBox

VERR_VM_DRIVER_NOT_ACCESSIBLE?

chmod ugo+rw /dev/vboxdrv

The VM session was aborted?

Maybe we forgot load vboxnetadp and vboxnetflt,

#modprobe vboxdrv
#modprobe vboxnetadp
#modprobe vboxnetflt

or the shared folder locates in U-disk but we have not mounted it.

Where to get guest additions iso?

http://download.virtualbox.org/virtualbox/6.1.32/VBoxGuestAdditions_6.1.32.iso

But why my Fedora os often drops dead?

What can make system dead must be that the modules we insert to kernel have problem.

The correct way to insert modules is that we should install official bundle first which will insert an configuation file in /etc/udev, modify /etc/udev/rules.d/60-vboxdrv.rules, give current user read and write permission and reboot system that will effect the rule. Then install the vbox*.ko we built.

refer to:
https://www.virtualbox.org/wiki/Downloads
https://download.virtualbox.org/virtualbox
How to sign module
https://www.virtualbox.org/wiki/Linux%20build%20instructions
https://blog.csdn.net/u013004700/article/details/81943881
https://www.linuxidc.com/Linux/2008-05/13132.htm

Install bare metal Linux dual booting with Windows

Installing Fedora is very straight forward, but

  • When clicking some avi suffix video file, I was prompted a GStreamer page, but no link to install missing plugins.

However I learnt

  • One disk must have its own EFI partition. For nowaday notebook usually has an SSD and an HDD, while SSD already has an EFI partition, when we have to install the second OS in HDD, the HDD must allocate an EFI partition too.
  • When we burn OS iso image into U-disk using UltraIso tool, we must select "RAW" mode, not others like "HDD+" mode.

'vboxdrv': Key was rejected by service

sudo dnf update
sudo dnf install mokutil

mkdir /root/signed-modules
cd /root/signed-modules
openssl req -new -x509 -newkey rsa:2048 -keyout MOK.priv -outform DER -out MOK.der -nodes -days 36500 -subj "/CN=VirtualBox/"
chmod 600 MOK.priv

mokutil --import MOK.der

#After rebooting system

for modfile in $(dirname $(modinfo -n vboxdrv))/*.ko; do
  echo "Signing $modfile"
  /usr/src/kernels/$(uname -r)/scripts/sign-file sha256 \
                                /root/signed-modules/MOK.priv \
                                /root/signed-modules/MOK.der "$modfile"
done

To play avi, rmvb files and so on,

dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm
dnf install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
dnf install vlc

Not set default editor to nano in cscope,

cd /etc/profile.d
mv nano-default-editor.sh nano-default-editor.sh0

No sound?

vi /etc/pulse/default.pa
	load-module module-alsa-sink device=dmix
	load-module module-alsa-source device=dsnoop
reboot

This method doesn't go very well, but I know the reason, I had replaced pipewire with pulseaudio while pipewire is the next generation.

Update grub,

grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg

refer to:
https://www.tecmint.com/install-vmware-workstation-in-linux/
https://stackoverflow.com/questions/61248315/sign-virtual-box-modules-vboxdrv-vboxnetflt-vboxnetadp-vboxpci-centos-8
https://www.videolan.org/vlc/download-fedora.html
https://blog.csdn.net/weixin_41446370/article/details/116711350
http://blog.sina.com.cn/s/blog_628ba3e00102xvnk.html
https://blog.csdn.net/wujuncheng1996/article/details/83546929
https://mirror.tuna.tsinghua.edu.cn/help/rpmfusion/

video_tdr_failure nvlddmkm.sys

不一定是显卡烧了。不要用Windows Update安装显卡驱动。

先彻底将显卡驱动卸载干净。右键点击“此电脑” -> “管理” -> “设备管理器” -> “显示适配器” -> 右键点击“NVIDIA GeForce XXX” -> “卸载设备” -> 勾选“尝试删除此设备的驱动程序” -> “卸载”。

再到英伟达官网下载英文版驱动安装:

https://www.nvidia.com/download/index.aspx?lang=en-us

我的配置是1050 Ti, ok, it's already cost me an arm and a leg.
下载的驱动名是
511.23-notebook-win10-win11-64bit-international-dch-whql.exe
安装后至今没出现什么问题。

另外,确定蓝屏原因的方法:

  1. 启动 windbg,菜单file -> symbol file path输入:

    1
    
    SRV*c:\temp*http://msdl.microsoft.com/download/symbols

    然后确定。

  2. windbg菜单file -> open crash dump,选择C:\Windows\MEMORY.DMP后,等待

    1
    
    Use !analyze -v to get detailed debugging information...

    字样出现后,点击“!analyze -v”超链接,可看到nvlddmkm.sys出现,说明是显卡驱动那里崩了。

确定蓝屏DUMP文件路径的方法:

右键点击“此电脑” -> “属性” -> “高级系统设置” -> “高级” -> “启动和故障恢复”中“设置” -> “写入调试信息”……

refer to:
https://social.technet.microsoft.com/Forums/windows/th-TH/f2212753-9cf5-4659-9c55-258329b0ff48/31995324793401323631?forum=vistazhchs

ue4 memo

Terms,

1
2
3
4
5
6
7
8
9
10
11
12
XGE
RHI: Render Hardware Interface
IncrediBuild
fastbuild
反射系统
蓝图系统
UBT: Unreal Build Tool
UHT: Unreal Heading Tool
CDO: Class Default Object
NM: Net Mode
LLM: Low Level Mem
GEngineIni: ThirdPerson01/Saved/Config/Windows/Engine.ini

Apis

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
GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, FString::Printf(TEXT("Hello, %s."), TEXT("Euhat")));
 
TRACE_OBJECT_EVEN
UE_TRACE_CHANNELEXPR_IS_ENABLED(ObjectChannel)
 
FD3D11DynamicRHI::RHIBeginFrame
 
UWorld
	PlayerControllerList
		PlayerController_0
			AGameplayDebuggerCategoryReplicator
	for (ULevel* Level : InWorld->GetLevels())
		Level->Actors
			WorldInfo_0			{AWorldSettings}
			Brush_0				{ABrush}
			LightmassImportanceVolume_0	{ALightmassImportanceVolume}
			AtmosphericFog_1		{AAtmosphericFog}
			SkySphereBlueprint		AActor *
			SphereReflectionCapture		{ASphereReflectionCapture}
			NetworkPlayerStart		{APlayerStart}
			DocumentationActor1		{ADocumentationActor}
			Linear_Stair_StaticMesh		{AStaticMeshActor}
			Bump_StaticMesh			{AStaticMeshActor}
			LeftArm_StaticMesh		{AStaticMeshActor}
			RightArm_StaticMesh		{AStaticMeshActor}
			Ramp_StaticMesh			{AStaticMeshActor}
			CubeMesh_5			{AStaticMeshActor}
			LightSource_0			{ADirectionalLight}
			PostProcessVolume_0		{APostProcessVolume}
			SkyLight_0			{ASkyLight}
			Floor_1				{AStaticMeshActor}
			Wall7_4				{AStaticMeshActor}
			Wall9				{AStaticMeshActor}
			Wall10				{AStaticMeshActor}
			Wall11				{AStaticMeshActor}
			TextRenderActor_1		{ATextRenderActor}
			AMyActor_9			{UE4Editor-ThirdPerson01-0013-Win64-Debug.dll!AAMyActor}
			DefaultPhysicsVolume_0		{ADefaultPhysicsVolume}
			GameplayDebuggerPlayerManager_0	{UE4Editor-GameplayDebugger-Win64-Debug.dll!AGameplayDebuggerPlayerManager}
			ThirdPersonGameMode_C_0		{AGameModeBase}
			GameSession_0			{AGameSession}
			ParticleEventManager_0		{AParticleEventManager}
			GameNetworkManager_0		{AGameNetworkManager}
			ThirdPersonCharacter_167	{ACharacter}
			ThirdPersonExampleMap_C_0	{ALevelScriptActor}
			GameStateBase_0			{AGameStateBase}
			AbstractNavData-Default		{UE4Editor-NavigationSystem-Win64-Debug.dll!AAbstractNavData}
			PlayerController_0		{APlayerController}
			PlayerState_0			{APlayerState}
			PlayerCameraManager_0		{APlayerCameraManager}
			CameraActor_0			{ACameraActor}
			HUD_0				{AHUD}
 
AActor
	RootComponent
	OwnedComponents : TSet<UActorComponent*>
	InstanceComponents 
	Children
 
UActorComponent
	OnRegister
	CreateRenderState
	OnCreatePhysicsState
	OnUnregister
	DestroyRenderState
	OnDestroyPhysicsState
	TickComponent
	PrimaryComponentTick.bCanEverTick
	PrimaryComponentTick.SetTickFunctionEnable(true)
	MarkRenderStateDirty
 
USceneComponent : UActorComponent
	SetupAttachment
	AttachToComponent
 
	FTransform
 
UPrimitiveComponent : USceneComponent
	ShouldCreatePhysicsState
 
	Box Component
	Capsule Component
	Mesh Component
	Skeletal Mesh Component
 
UDrawFrustumComponent : UPrimitiveComponent

stat

1
2
3
stat unit
stat SceneRendering
stat gpu

LineTraceSingle

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
void AMyCharacter::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
 
	const float TRACE_LINE_LENGTH = 1000.0f;
	FRotator actorRotator = GetActorRotation();
	const FRotator YawRotation(0, actorRotator.Yaw, 0);
	const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
	FVector lineStartPos = GetActorLocation();
	FVector lineEndPos = lineStartPos + TRACE_LINE_LENGTH * Direction;
	TArray<AActor*> arrayIgnoreActor;
	FHitResult outResult;
	if (UKismetSystemLibrary::LineTraceSingle(GetWorld(), lineStartPos, lineEndPos, 
			ETraceTypeQuery::TraceTypeQuery1, true, arrayIgnoreActor, 
			EDrawDebugTrace::ForDuration, outResult, true, 
			FLinearColor::Red, FLinearColor::Green, 0.1f))
	{
		FString locationString = outResult.Location.ToString();
		UE_LOG111(LogTemp, Error, TEXT("location = %s"), *locationString);
	}
}

refer to:
https://www.cnblogs.com/fjz13/p/5956393.html
https://blog.csdn.net/qq_29523119/article/details/85957072

unicode in ctex

在英文Windows中,特别是使用了“用utf8提供全球语言支持”时,系统会把所有保存为GBK的api忽略掉,此时CTex只会识别utf8的文档,而utf16不会被编译识别。

同时在tex文件头部documentclass后要申明本文档为utf8格式。

%!Mode:: "TeX:UTF-8"
\documentclass[UTF8]{article}
\usepackage{CTEX}
\begin{document}
这是一个CTEX的utf-8编码例子,{\kaishu 这里是楷体显示},{\songti 这里是宋体显示},{\heiti 这里是黑体显示},{\fangsong 这里是仿宋显示},{\lishu 这里是隶书显示},{\youyuan 这里是幼圆显示}。
\end{document}

refer to:
冰原狼
https://www.pianshen.com/article/97651577419/