Ford Rangers and Mazda b-series vehicles are the same. I would be willing to bet it is a problem with your shift motor. There is a sensor on the motor that tells the "shift computer" where it is in regards to position. The sensor has a ceramic disk that is glued to a shaft. The glue dries out and the disk doesn't spin with the shaft, so the computer doesn't know the position. You can disassemble the shift motor and re-glue, or just replace the entire shift motor assembly. It's $85 - $100 for a remanufactured unit from Napa (or similar). I just did this for my '94 Ranger, tore it apart and fixed it.
Before doing any of that I would check the 4x4 fuse in the box under the hood. The other fuse to check is inside the cab. It is on the same circuit as the warning lights (if your dash warning lights work, that fuse is fine).
Here's a guide for troubleshooting other transfer case issues. Transfer Case Troubleshooting The Ranger Station