Skip to content

Instantly share code, notes, and snippets.

@Inori
Inori / defer.hpp
Created July 4, 2023 04:05 — forked from pmttavara/defer.hpp
The definitive defer implementation for C++. Syntax: defer { statements; };
#ifndef defer
struct defer_dummy {};
template <class F> struct deferrer { F f; ~deferrer() { f(); } };
template <class F> deferrer<F> operator*(defer_dummy, F f) { return {f}; }
#define DEFER_(LINE) zz_defer##LINE
#define DEFER(LINE) DEFER_(LINE)
#define defer auto DEFER(__LINE__) = defer_dummy{} *[&]()
#endif // defer
@Inori
Inori / FullScreenQuad.hlsl
Created April 18, 2020 22:42 — forked from rorydriscoll/FullScreenQuad.hlsl
A vertex shader that uses the vertex ID to generate a full-screen quad. Don't bind vertex buffer, index buffer or input layout. Just render three vertices!
struct Output
{
float4 position_cs : SV_POSITION;
float2 texcoord : TEXCOORD;
};
Output main(uint id: SV_VertexID)
{
Output output;
@Inori
Inori / ExtractAudio.bat
Created March 15, 2020 08:29
Add ExtractAudio ability to right click SendTo menu by calling FFmpeg
@echo off
set SCRIPT_ROOT=%~dp0
set FFMPEG=%SCRIPT_ROOT%ffmpeg.exe
set INPUT_FULLPATH=%1
set INPUT_FILENAME=%~n1
set INPUT_FOLDER=%~dp1
set OUTPUT_FULLPATH="%INPUT_FOLDER%%INPUT_FILENAME%.mp3"
echo Extraction audio from %INPUT_FULLPATH%
@Inori
Inori / vk.cpp
Created October 20, 2019 17:14 — forked from SaschaWillems/vk.cpp
Multiple Vulkan buffer binding points
Shader
layout (location = 0) in vec3 inPos;
layout (location = 1) in vec3 inColor;
layout (location = 2) in vec3 inPosB;
layout (location = 3) in vec3 inColorB;
...
Application
首先说明LBA保护是什么。讲到这里就插入一点背景知识。
PSP的UMD数据基于ISO9660格式存储。(关于ISO9660的具体信息请查阅相关资料)
众所周知,ISO9660的数据存储基于逻辑块(Logical Block)。数据必须以逻辑块为单位对齐。
其大小可在VolumeDescriptor结构的logical_block_size中获得。
在PSP上,这个值是0x800,也就是2048字节。
sony为PSP的isofs驱动(在用户层一般由disc0访问)提供了一种特殊的访问模式。
这种模式就是LBA,也就是Logical Block Addressing,即逻辑块寻址模式。
可以使用户通过提供逻辑块编号和文件长度,直接访问相应位置的数据,而不需要沿ISO数据结构下溯。
(事实上,下溯的结果也只是这两个数据而已。)
但事实上,提供这种方法的主要目的并不是节约寻址时间。
@Inori
Inori / rebuild_jis_filename.py
Created May 1, 2018 13:52
Rename wrong jis codec file
import os
import sys
def jis_rename(root):
for root,dirs,files in os.walk(root):
for file in files:
file = os.path.join(root, file)
d = os.path.dirname(file)
f = os.path.basename(file)
@Inori
Inori / switch-gpu.sh
Last active April 8, 2024 07:32
Switch GPU on Debian system with reboot (same as nvidia-prime)
#!/bin/bash
# Switch GPU on Debian system with reboot.
# Because there's no nvidia-prime package for Debian distro,
# I did some work to achieve the same functionality as nvidia-prime provide.
# Follow the instructions here:
# 1. Follow instructions here to install nvidia proprietary driver: