Sort:  

Given block height X including transaction with TaPoS reference (R=200), then the referenced block number would be (int(X/4096)-(R-127))*4096 assuming R > 127. If R <= 127 then it would be X - R.