Just edit the code so that the row shiftout and the column shiftout are swapped. You may have to invert some bytes.