diff --git a/Makefile b/Makefile index 6b586abb..e3102ca5 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ SRCDIR_BASIC = $(SRCDIR_COMMON) \ c64/basic/math \ c64/basic/math_consts \ c64/basic/math_mov \ + c64/basic/memory \ c64/basic/print \ c64/basic/rom_revision \ c64/basic/tokenizer \ diff --git a/bin/basic_generic.rom b/bin/basic_generic.rom index fa704fb4..68bc99f4 100644 Binary files a/bin/basic_generic.rom and b/bin/basic_generic.rom differ diff --git a/bin/basic_ultimate64.rom b/bin/basic_ultimate64.rom index 0e2d7647..4876d158 100644 Binary files a/bin/basic_ultimate64.rom and b/bin/basic_ultimate64.rom differ diff --git a/bin/kernal_generic.rom b/bin/kernal_generic.rom index 132e1f62..18729a72 100644 Binary files a/bin/kernal_generic.rom and b/bin/kernal_generic.rom differ diff --git a/bin/kernal_ultimate64.rom b/bin/kernal_ultimate64.rom index b2281777..0880452f 100644 Binary files a/bin/kernal_ultimate64.rom and b/bin/kernal_ultimate64.rom differ diff --git a/bin/mega65.rom b/bin/mega65.rom index f28ce902..f70851d7 100644 Binary files a/bin/mega65.rom and b/bin/mega65.rom differ diff --git a/bin/mega65_pxlfont.rom b/bin/mega65_pxlfont.rom index d52ddce0..91d86cbb 100644 Binary files a/bin/mega65_pxlfont.rom and b/bin/mega65_pxlfont.rom differ diff --git a/c64/basic/e000.under_rom_routines_46k_50k.s b/c64/basic/e000.under_rom_routines_46k_50k.s deleted file mode 100644 index 6aef9262..00000000 --- a/c64/basic/e000.under_rom_routines_46k_50k.s +++ /dev/null @@ -1,72 +0,0 @@ -// #LAYOUT# STD * #TAKE -// #LAYOUT# * BASIC_0 #TAKE -// #LAYOUT# * * #IGNORE - -// XXX extend build_segment tool to allow to specify placement range - - -#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K - - -peek_under_roms_via_TXTPTR: - - // Unmap BASIC lower ROM - - lda #$26 - sta CPU_R6510 - - // Retrieve value from under ROMs - - lda (TXTPTR), y - - // FALLTROUGH - -peek_under_roms_finalize: - - // Restore memory mapping - - pha - lda #$27 - sta CPU_R6510 - pla - - // Quit - - rts - -peek_under_roms_via_OLDTXT: - - // Unmap BASIC lower ROM - - lda #$26 - sta CPU_R6510 - - // Retrieve value from under ROMs - - lda (OLDTXT), y - -#if HAS_OPCODES_65C02 - bra peek_under_roms_finalize -#else - jmp peek_under_roms_finalize -#endif - -peek_under_roms_via_FAC1_PLUS_1: - - // Unmap BASIC lower ROM - - lda #$26 - sta CPU_R6510 - - // Retrieve value from under ROMs - - lda (__FAC1 + 1), y - -#if HAS_OPCODES_65C02 - bra peek_under_roms_finalize -#else - jmp peek_under_roms_finalize -#endif - - -#endif diff --git a/c64/basic/memory/e107.under_rom_routines_46k_50k.s b/c64/basic/memory/e107.under_rom_routines_46k_50k.s new file mode 100644 index 00000000..b46a03d1 --- /dev/null +++ b/c64/basic/memory/e107.under_rom_routines_46k_50k.s @@ -0,0 +1,148 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// XXX This can be any address - but definitely $E000 or above +// XXX TODO: extend build_segment tool to allow to specify placement range + + +#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K + + +peek_under_roms_via_TXTPTR: + + // Unmap BASIC lower ROM + + lda #$26 + sta CPU_R6510 + + // Retrieve value from under ROMs + + lda (TXTPTR), y + + // FALLTROUGH + +peek_under_roms_finalize: + + // Restore memory mapping + + pha + lda #$27 + sta CPU_R6510 + pla + + // Quit + + rts + +peek_under_roms_via_OLDTXT: + + // Unmap BASIC lower ROM + + lda #$26 + sta CPU_R6510 + + // Retrieve value from under ROMs + + lda (OLDTXT), y + +#if HAS_OPCODES_65C02 + bra peek_under_roms_finalize +#else + jmp peek_under_roms_finalize +#endif + +peek_under_roms_via_FAC1_PLUS_1: + + // Unmap BASIC lower ROM + + lda #$26 + sta CPU_R6510 + + // Retrieve value from under ROMs + + lda (__FAC1 + 1), y + +#if HAS_OPCODES_65C02 + bra peek_under_roms_finalize +#else + jmp peek_under_roms_finalize +#endif + + + +shift_mem_up: + + // Move __memmove_size bytes from __memmove_src to __memmove_dst, + // where __memmove_dst > __memmove_src + // This means we have to copy from the back end down. + // This routine assumes the pointers are already pointed + // to the end of the areas, and that Y is correctly initialised + // to allow the copy to begin. + + // Unmap BASIC lower ROM + + php + + lda #$26 + sta CPU_R6510 + + // Perform the copying +!: + lda (__memmove_src),y + sta (__memmove_dst),y + dey + bne !- + dec __memmove_src+1 + dec __memmove_dst+1 + dec __memmove_size+1 + bne !- + +#if HAS_OPCODES_65C02 + bra shift_mem_finalize +#else + jmp shift_mem_finalize +#endif + + +shift_mem_down: + + // Move __memmove_size bytes from __memmove_src to __memmove_dst, + // where __memmove_dst > __memmove_src + // This means we have to copy from the back end down. + // This routine assumes the pointers are already pointed + // to the end of the areas, and that Y is correctly initialised + // to allow the copy to begin. + + // Unmap BASIC lower ROM + + php + + lda #$26 + sta CPU_R6510 + + // Perform the copying +!: + lda (__memmove_src),y + sta (__memmove_dst),y + iny + bne !- + inc __memmove_src+1 + inc __memmove_dst+1 + dec __memmove_size+1 + bne !- + // FALLTROUGH + +shift_mem_finalize: + + // Restore memory mapping and quit + + lda #$27 + sta CPU_R6510 + + plp + + rts + + +#endif diff --git a/c64/basic/memory/shift_mem_down_38k.s b/c64/basic/memory/shift_mem_down_38k.s new file mode 100644 index 00000000..471ac56b --- /dev/null +++ b/c64/basic/memory/shift_mem_down_38k.s @@ -0,0 +1,30 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + + +#if CONFIG_MEMORY_MODEL_38K + +shift_mem_down: + + // Move __memmove_size bytes from __memmove_src to __memmove_dst, + // where __memmove_dst > __memmove_src + // This means we have to copy from the back end down. + // This routine assumes the pointers are already pointed + // to the end of the areas, and that Y is correctly initialised + // to allow the copy to begin. + + php +!: + lda (__memmove_src),y + sta (__memmove_dst),y + iny + bne !- + inc __memmove_src+1 + inc __memmove_dst+1 + dec __memmove_size+1 + bne !- + plp + rts + +#endif diff --git a/c64/basic/memory/shift_mem_up_38k.s b/c64/basic/memory/shift_mem_up_38k.s new file mode 100644 index 00000000..c8fab14b --- /dev/null +++ b/c64/basic/memory/shift_mem_up_38k.s @@ -0,0 +1,30 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + + +#if CONFIG_MEMORY_MODEL_38K + +shift_mem_up: + + // Move __memmove_size bytes from __memmove_src to __memmove_dst, + // where __memmove_dst > __memmove_src + // This means we have to copy from the back end down. + // This routine assumes the pointers are already pointed + // to the end of the areas, and that Y is correctly initialised + // to allow the copy to begin. + + php +!: + lda (__memmove_src),y + sta (__memmove_dst),y + dey + bne !- + dec __memmove_src+1 + dec __memmove_dst+1 + dec __memmove_size+1 + bne !- + plp + rts + +#endif diff --git a/c64/basic/under_rom_routines_60k.s b/c64/basic/memory/under_rom_routines_60k.s similarity index 69% rename from c64/basic/under_rom_routines_60k.s rename to c64/basic/memory/under_rom_routines_60k.s index e4458496..0a07dbc7 100644 --- a/c64/basic/under_rom_routines_60k.s +++ b/c64/basic/memory/under_rom_routines_60k.s @@ -113,46 +113,4 @@ smd1: __ram_routines_end: -#else // CONFIG_MEMORY_MODEL_60K - -shift_mem_up: - // Move __memmove_size bytes from __memmove_src to __memmove_dst, - // where __memmove_dst > __memmove_src - // This means we have to copy from the back end down. - // This routine assumes the pointers are already pointed - // to the end of the areas, and that Y is correctly initialised - // to allow the copy to begin. - php -smu1: - lda (__memmove_src),y - sta (__memmove_dst),y - dey - bne smu1 - dec __memmove_src+1 - dec __memmove_dst+1 - dec __memmove_size+1 - bne smu1 - plp - rts - -shift_mem_down: - // Move __memmove_size bytes from __memmove_src to __memmove_dst, - // where __memmove_dst > __memmove_src - // This means we have to copy from the back end down. - // This routine assumes the pointers are already pointed - // to the end of the areas, and that Y is correctly initialised - // to allow the copy to begin. - php -smd1: - lda (__memmove_src),y - sta (__memmove_dst),y - iny - bne smd1 - inc __memmove_src+1 - inc __memmove_dst+1 - dec __memmove_size+1 - bne smd1 - plp - rts - #endif