Skip to content

Instantly share code, notes, and snippets.

View wwylele's full-sized avatar
🐟
Eating fish

Weiyi Wang wwylele

🐟
Eating fish
View GitHub Profile
@wwylele
wwylele / 3ds-0004009B00010402.txt
Created September 22, 2017 13:31
3DS "area:" archive research
"$(country_id)_LZ.bin"
[LZ]{
struct {
u32 entry_count?;
struct { // size=0x818
struct {
u8 zero?
u8 zero?
u8 region_id;
@wwylele
wwylele / lut_cp.md
Last active September 19, 2022 17:27

GPU_LUTINPUT_CP

GPU_LUTINPUT_CP (= "cos(phi)") is used for anisotropic reflection, based on Schlick's model. According to the paper, the input value should be T * H', where T is the tangent vector, and H' is the projection of half-angle vector on to the tangent plane.

Here are some (strange) details:

  • GPU_LUTINPUT_CP is only available under configuration 7
  • H' is not normalized. This is found when replicating the output from 3ds in citra. Unormalized H' produces the same result, while normalized H' doesn't. This means the angle phi is not the angle between T and H' anymore. On Schlick's paper, it is unclear whether this is the case.
  • Also found when implementing in citra: when using normal mapping, it seems that the tangent vector stays (1, 0, 0) in surface-local space, instead of rotating with the normal vector. This means the normal and tangent vectors are not perpendicular anymore
  • Dispite the point above,
@wwylele
wwylele / config_block.py
Created November 22, 2016 18:21
3DS config savegame parser
# Python 3
import struct
import sys
import os
if len(sys.argv)<2:
print("No input file")
exit()
flen=os.path.getsize(sys.argv[1])
f=open(sys.argv[1], 'rb');

3DS CRO Information

AKA reference for citra CRO code.

wwylele: I am not a English native speaker, so there can be some strange words and sentences below. Suggestions for improvement are welcome.

Warning: CRO is still not completely understood, and there can be mistakes below. Please keep the sense of suspecting.

Terminology

Note: some terms are given by comparing the behavior with similar concept. They may be inaccurate, or even incorrect.

  • Module is a chunk of executable code and data. Modules can be linked to each other.
@wwylele
wwylele / bit_trie.cpp
Last active January 1, 2018 17:14
"Bit trie" a trie-like structure
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <stdexcept>
#include <string>
#include <vector>
/*
bit_trie
@wwylele
wwylele / expressionSearch.cpp
Last active October 24, 2015 10:21
A stupid searcher for expressions containing specified numbers and resulting in specified number
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <sstream>
using namespace std;
bool next_operatorPostion(int* operatorPostion,int numberCount){
int counter = numberCount-2;
while(1){