@@ -301,15 +301,15 @@ optional_lib_clear:
301301 ld de , 0
302302 ld (hl) , e ; mark optional library as not found
303303 pop hl
304- inc hl ; skip version byte
304+ ld a , JP_OPCODE
305+ ; inc hl ; skip version byte
305306. loop :
306- ld a , (hl)
307- cp a , JP_OPCODE ; jp byte ($C3)
307+ inc hl
308+ cp a , (hl) ; jp byte ($C3)
308309 jr nz , .done
309310 inc hl
310311 ld (hl) , de ; make the vector zero
311312 inc hl
312- inc hl
313313 inc hl ; move to next jump
314314 jr . loop
315315
@@ -445,12 +445,12 @@ enqueue_all_deps: ; we don't need to store anything if we are here
445445 ex de , hl
446446.skip:
447447 move_string_to_end
448- inc hl ; move to start of dependency jump table
448+ ld a , JP_OPCODE
449+ ; inc hl ; move to start of dependency jump table
449450.next:
450- ld a , (hl)
451- cp a , JP_OPCODE
452- jr nz , . loop
453451 inc hl
452+ cp a , (hl) ; jp byte ($C3)
453+ jr nz , . loop
454454 inc hl
455455 inc hl
456456 inc hl ; jp address
@@ -464,15 +464,15 @@ enqueue_all_deps: ; we don't need to store anything if we are here
464464resolve_entry_points_enqueued:
465465
466466 ld hl , (jump_tbl_ptr) ; hl->start of function jump table
467+ ld bc , 3
468+ ld a , JP_OPCODE
467469. loop :
468- ld a , (hl)
469- cp a , JP_OPCODE ; jp byte ($C3)
470+ cp a , (hl) ; jp byte ($C3)
470471 jr nz , .done
471472 inc hl ; bypass jp byte ($C3)
472473 push hl
473474 ld hl , (hl) ; offset in vector table (0, 3, 6, etc.)
474- ld bc , 3
475- call ti._idivs ; originally the offset was just added because vectors were stored in three bytes, now it is just 2 to save space
475+ call ti._idivu ; originally the offset was just added because vectors were stored in three bytes, now it is just 2 to save space
476476 add hl , hl ; (offset/3) * 2
477477 ld de , (vector_tbl_ptr) ; hl->start of vector table
478478 add hl , de ; hl->correct vector entry
@@ -482,9 +482,7 @@ resolve_entry_points_enqueued:
482482 ex de , hl ; de->function in ram
483483 pop hl ; restore jump offset
484484 ld (hl) , de ; de=resolved address
485- inc hl
486- inc hl
487- inc hl ; move to next jump
485+ add hl , bc ; move to next jump
488486 jr . loop
489487
490488.done: ; finished resolving entry points
0 commit comments