| 1 |
;ACME 0.96.4 |
| 2 |
|
| 3 |
!ifdef lib_cbm_c64_memcopy_a !eof |
| 4 |
lib_cbm_c64_memcopy_a = 1 |
| 5 |
|
| 6 |
; this macro inserts code to copy a memory block. |
| 7 |
; it calls a function from the basic interpreter, so: |
| 8 |
; - BASIC ROM must be banked in |
| 9 |
; - the source block must be readable (so no RAM hidden under BASIC, Kernal, or I/O) |
| 10 |
; - the target block must be writable (so no RAM hidden under I/O) |
| 11 |
; higher addresses are copied first, so: |
| 12 |
; - moving data to higher addresses works even if areas overlap |
| 13 |
; - moving data to lower addresses only works if areas do not overlap |
| 14 |
!macro basic_memcopy @src_start, @src_end, @target_start { |
| 15 |
!addr @z_target_end = $58 |
| 16 |
!addr @z_src_end = $5a |
| 17 |
!addr @z_src_start = $5f |
| 18 |
!addr @fn = $a3bf |
| 19 |
|
| 20 |
lda #<@src_start |
| 21 |
ldx #>@src_start |
| 22 |
sta @z_src_start |
| 23 |
stx @z_src_start + 1 |
| 24 |
lda #<@src_end |
| 25 |
ldx #>@src_end |
| 26 |
sta @z_src_end |
| 27 |
stx @z_src_end + 1 |
| 28 |
lda #<(@target_start + @src_end - @src_start) |
| 29 |
ldx #>(@target_start + @src_end - @src_start) |
| 30 |
sta @z_target_end |
| 31 |
stx @z_target_end + 1 |
| 32 |
jsr @fn |
| 33 |
} |