From 1432935f0327aaaf4cda72b0f082910a4435b02c Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 12 Jul 2020 12:13:04 +0200 Subject: [PATCH] added some Mega65 optimizations in BASIC --- src/basic/engine/fetch_character.s | 6 +++ .../engine/fetch_character_m65_46K_50K.s | 42 +++++++++++++++++++ .../engine/fetch_character_skip_spaces.s | 7 ++++ .../fetch_character_skip_spaces_m65_46K_50K.s | 41 ++++++++++++++++++ ...oke_46k_50k.s => under_rom_peek_46k_50k.s} | 0 5 files changed, 96 insertions(+) create mode 100644 src/basic/engine/fetch_character_m65_46K_50K.s create mode 100644 src/basic/engine/fetch_character_skip_spaces_m65_46K_50K.s rename src/basic/memory/{under_rom_peek_poke_46k_50k.s => under_rom_peek_46k_50k.s} (100%) diff --git a/src/basic/engine/fetch_character.s b/src/basic/engine/fetch_character.s index 68397cc7..8c1dcc99 100644 --- a/src/basic/engine/fetch_character.s +++ b/src/basic/engine/fetch_character.s @@ -7,6 +7,9 @@ // +// For these configurations we have optimized version in another file +#if !(ROM_LAYOUT_M65 && (CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K)) + fetch_character: ldy #0 @@ -46,3 +49,6 @@ consume_character: #endif rts + + +#endif diff --git a/src/basic/engine/fetch_character_m65_46K_50K.s b/src/basic/engine/fetch_character_m65_46K_50K.s new file mode 100644 index 00000000..84363222 --- /dev/null +++ b/src/basic/engine/fetch_character_m65_46K_50K.s @@ -0,0 +1,42 @@ +// #LAYOUT# M65 BASIC_0 #TAKE-HIGH +// #LAYOUT# * * #IGNORE + +// +// Fetches a single character - optimized version +// + + +#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K + + +fetch_character: + + ldy #0 + + // Unmap BASIC lower ROM + + lda #$26 + sta CPU_R6510 + + // Retrieve value from under ROMs + + lda (TXTPTR), y + + // Restore memory mapping + + pha + lda #$27 + sta CPU_R6510 + pla + + // FALLTROUGH + +consume_character: + + // Advance basic text pointer + + inw TXTPTR + rts + + +#endif diff --git a/src/basic/engine/fetch_character_skip_spaces.s b/src/basic/engine/fetch_character_skip_spaces.s index c17eeab7..e67ffc82 100644 --- a/src/basic/engine/fetch_character_skip_spaces.s +++ b/src/basic/engine/fetch_character_skip_spaces.s @@ -6,6 +6,10 @@ // Fetches a single character, but skips spaces // + +// For these configurations we have optimized version in another file +#if !(ROM_LAYOUT_M65 && (CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K)) + fetch_character_skip_spaces: jsr fetch_character @@ -13,3 +17,6 @@ fetch_character_skip_spaces: beq fetch_character_skip_spaces rts + + +#endif diff --git a/src/basic/engine/fetch_character_skip_spaces_m65_46K_50K.s b/src/basic/engine/fetch_character_skip_spaces_m65_46K_50K.s new file mode 100644 index 00000000..9970a5ef --- /dev/null +++ b/src/basic/engine/fetch_character_skip_spaces_m65_46K_50K.s @@ -0,0 +1,41 @@ +// #LAYOUT# M65 BASIC_0 #TAKE-HIGH +// #LAYOUT# * * #IGNORE + +// +// Fetches a single character, but skips spaces - optimized version +// + + +#if CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K + + +fetch_character_skip_spaces: + + ldy #0 + + // Unmap BASIC lower ROM + + lda #$26 + sta CPU_R6510 + + // Retrieve value from under ROMs, advance text pointer +!: + lda (TXTPTR), y + inw TXTPTR + + // Skip space characters + + cmp #$20 + beq !- + + // Restore memory mapping + + pha + lda #$27 + sta CPU_R6510 + pla + + rts + + +#endif diff --git a/src/basic/memory/under_rom_peek_poke_46k_50k.s b/src/basic/memory/under_rom_peek_46k_50k.s similarity index 100% rename from src/basic/memory/under_rom_peek_poke_46k_50k.s rename to src/basic/memory/under_rom_peek_46k_50k.s