Fix relocation

This commit is contained in:
Joshua Bell 2019-09-30 20:20:59 -07:00
parent 754d267c1e
commit ba0c5e53d3

View File

@ -27,13 +27,14 @@
;;; Relocate from $2000 to $1000 ;;; Relocate from $2000 to $1000
.proc relocate .proc relocate
src := SYS_ADDR src := reloc_start
dst := dst_addr
ldx #(sys_end - sys_start + $FF) / $100 ; pages ldx #(reloc_end - reloc_start + $FF) / $100 ; pages
ldy #0 ldy #0
load: lda sys_start,y ; self-modified load: lda src,y ; self-modified
load_hi := *-1 load_hi := *-1
sta dst_addr,y ; self-modified sta dst,y ; self-modified
store_hi := *-1 store_hi := *-1
iny iny
bne load bne load
@ -49,17 +50,16 @@ load: lda sys_start,y ; self-modified
;;; Start of relocated code ;;; Start of relocated code
;;; ;;;
sys_start: reloc_start := *
pushorg dst_addr pushorg dst_addr
;;; ============================================================ ;;; ============================================================
;;; Main routine ;;; Main routine
;;; ============================================================ ;;; ============================================================
.proc main .proc main
jsr setup jsr setup
jsr install_driver jsr maybe_install_driver
jsr launch_next jsr launch_next
brk brk
.endproc .endproc
@ -124,7 +124,7 @@ self_name: .res 16
.proc quit .proc quit
MLI_CALL QUIT, quit_params MLI_CALL QUIT, quit_params
.byte 0 ; crash if QUIT fails brk ; crash if QUIT fails
DEFINE_QUIT_PARAMS quit_params DEFINE_QUIT_PARAMS quit_params
.endproc .endproc
@ -255,7 +255,7 @@ next: lda ptr
bcs not_found bcs not_found
;; Set up pointers to entry ;; Set up pointers to entry
: lda #0 lda #0
sta num sta num
lda #<(dir_buf + $04) lda #<(dir_buf + $04)
sta ptr sta ptr
@ -354,7 +354,7 @@ found_self_flag:
;;; ============================================================ ;;; ============================================================
;;; ;;;
;;; Driver ;;; Driver Installer
;;; ;;;
;;; ============================================================ ;;; ============================================================
@ -381,7 +381,7 @@ unitnum: .byte $03 ; S3D1; could be $B for S3D2
;;; ============================================================ ;;; ============================================================
;;; Install the driver ;;; Install the driver
.proc install_driver .proc maybe_install_driver
sta CLR80COL sta CLR80COL
ldy #0 ldy #0
@ -735,7 +735,7 @@ finish: bit ROMIN2
stx $06 stx $06
stx BANKSEL stx BANKSEL
stx vol_dir_header+VolumeDirectoryHeader::total_blocks stx vol_dir_header+VolumeDirectoryHeader::total_blocks
jmp install_driver ; retry??? jmp maybe_install_driver ; retry???
install_success: install_success:
sta ALTZPOFF sta ALTZPOFF
@ -1072,5 +1072,6 @@ stash_01 := *+2+$180 ; len: $80
;;; ============================================================ ;;; ============================================================
;;; End of relocated code ;;; End of relocated code
poporg poporg
sys_end: reloc_end := *