State lawmakers have approved making California the first state to write into law much of the national mortgage settlement negotiated this year with the nation's top five banks.