This question is simply about the differences in the tenses.
used to describe an event in the past.
used to describe an event prior to something else in the past. This sentence might continue like this:
I had been studying until midnight, when I decided to stop for something to eat. By the time I was ready to start studying again it was too late so I went to bed instead.
as (1) used to describe an event in the past. There is a slight difference in emphasis, but thatβs all.