diff --git a/libsrc/apple2/crt0.s b/libsrc/apple2/crt0.s index 42e26c27b..4b9a59153 100644 --- a/libsrc/apple2/crt0.s +++ b/libsrc/apple2/crt0.s @@ -10,6 +10,7 @@ .import initlib, _exit .import zerobss, callmain + .import bltu2 .import __ONCE_LOAD__, __ONCE_SIZE__ ; Linker generated .import __LC_START__, __LC_LAST__ ; Linker generated @@ -93,6 +94,7 @@ basic: lda HIMEM ; Call the module constructors. jsr initlib + ; Copy the LC segment to its destination ; Switch in LC bank 2 for W/O. bit $C081 bit $C081 @@ -120,7 +122,7 @@ basic: lda HIMEM ; Call into Applesoft Block Transfer Up -- which handles zero- ; sized blocks well -- to move the content of the LC memory area. - jsr $D39A ; BLTU2 + jsr bltu2 ; BLTU2 ; Switch in LC bank 2 for R/O and return. bit $C080 diff --git a/libsrc/apple2/extra/lc-copy-memcpy.s b/libsrc/apple2/extra/lc-copy-memcpy.s new file mode 100644 index 000000000..c4dc8d8ef --- /dev/null +++ b/libsrc/apple2/extra/lc-copy-memcpy.s @@ -0,0 +1,33 @@ +; +; Colin Leroy-Mira, 06.03.2025 +; +; Copy the LC segment from the end of the binary to the Language Card +; using _memcpy. This allows running apple2 programs on the original +; Integer ROM Apple ][. +; + + .export bltu2 + + .import _memcpy, pushax + .import __ONCE_LOAD__, __ONCE_SIZE__ ; Linker generated + .import __LC_START__, __LC_LAST__ ; Linker generated + + .segment "ONCE" + +bltu2: + ; Get the destination start address. + lda #<__LC_START__ + ldx #>__LC_START__ + jsr pushax + + ; Get the source start address. + lda #<(__ONCE_LOAD__ + __ONCE_SIZE__) + ldx #>(__ONCE_LOAD__ + __ONCE_SIZE__) + jsr pushax + + ; Set the length + lda #<(__LC_LAST__ - __LC_START__) + ldx #>(__LC_LAST__ - __LC_START__) + + ; And do the copy + jmp _memcpy diff --git a/libsrc/apple2/lc-copy-applesoft.s b/libsrc/apple2/lc-copy-applesoft.s new file mode 100644 index 000000000..70a04431d --- /dev/null +++ b/libsrc/apple2/lc-copy-applesoft.s @@ -0,0 +1,9 @@ +; +; Oliver Schmidt, 15.09.2009 +; +; Copy the LC segment from the end of the binary to the Language Card +; using AppleSoft's BLTU2 routine. +; + .export bltu2 + +bltu2 := $D39A