Prior to radar, the ships had to be able to see each other. In theory, they could have used aircraft but those arrived equipped for fire control basically when radar did.
The main director on an iowa-class battleship can see to 27,000 yds. to the horizon. That's about the distance when the ships opened fire at Denmark straight (where radar was used) At Jutland, the battle began at about 15,000 yds. At Guadalcanal, the range was about 18,000. At Surigao Strait the opening range was about 23,000.
Even with radar, engagement ranges were within visual detection.
Fire control computers started to appear in the early 20th century and increased in complexity throughout the battleship era.
The Dumaresq went to sea in 1905.
The Dreyer table in 1916.
The Rangekeeper in 1917.