Wow man. I recently did a d15b vtec swap in my '93 and it was easy as fuck. I don't know how you could fuck that up.
Anyway, are you sure it's a '97 motor? If it is then it's just an economy vtec I believe and won't be as fast as a 5th gen. Shit I'd just buy a 5th gen (92-95) OBD-1 D15b Vtec with the p08 ecu that's what I did with mine but I swapped over from a d15b7 nonvtec.
Code 21 is a vtec code at least mine is anyway.
Code 20 is knock sensor I believe which means you probably do have the obd-2 motor because I think the 5th gens didn't even have a knock sensor.
It'd be best to either convert to OBD-1 or just buy an OBD-1 D15B motor, they're only $400 and supposedly the best d-series motor stock.
Oh, and how do you know it won't pass smog? The guy that swapped it should have kept the 4-wire o2 sensor so that shouldn't have been a problem.
Good luck with the car.