Well Silas, you did not reply back. Maybe you resolved the issue. DTC 13 is an RPM Signal fault code. You can see more about it in the list of DTC's for a 5th Gen Celica 4A-FE engine attached. The NE signal is generated within the distributor by one of two hall-effect sensors. As such, DTC 13 can set if the hall effect signal is no longer capable of being generated by the hall effect sensor in the distributor, or there is a short or open in the wiring between the distributor and the ECM, or the ECM is faulty.
I would suggest you remove your distributor cap and see if you have any oil residue inside the cap. If you do, that oil residue could be causing the issue with the hall effect sensor. You would have an oil o'ring problem on the inside of your distributor, between the distributor shaft and the distributor housing. You can clean the inside of the distributor with a choke/carb cleaning solvent, and you can disassemble the distributor to replace that o-ring.
Given you have times when the engine runs well (which I am assuming from your original post), then I don't think you would have a wiring issue between the distributor and the ECM.
You could have an ECM issue - as ECM failures were common back in the early 1990's Toyotoa ECM's due to circuit board capacitor failures. You can replace all the capacitors, or you can send your ECM out to have all the capacitors replaced. Or you can try finding an ECM from a salvage car and hope that it is a good ECM.
Can't help you much more if you don't respond back to questions to get a better understanding of the car/symptoms though.