From 870de4e4323e16ab44c1cf307d69285b1d783d4b Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 4 Jan 2020 11:22:33 +0100 Subject: [PATCH] do not output unneeded spaces in BASIC messages --- c64/basic/print_packed_message.s | 36 +++++++++++++++++++------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/c64/basic/print_packed_message.s b/c64/basic/print_packed_message.s index efed0e6a..2f44a411 100644 --- a/c64/basic/print_packed_message.s +++ b/c64/basic/print_packed_message.s @@ -30,22 +30,34 @@ packed_message_search: sec rts -found_message_in_token_stream: +found_message_in_token_stream: // XXX size-optimize this // Now print each word in the message phy_trash_a lda packed_message_tokens,y - cmp #$ff - beq !+ + cmp #$FF + beq found_message_in_token_stream_done + jsr print_packed_word - jsr print_space ply_trash_a iny - bne found_message_in_token_stream + beq found_message_in_token_stream_done !: + phy_trash_a + lda packed_message_tokens,y + cmp #$FF + beq found_message_in_token_stream_done + + pha + jsr print_space + pla + + jsr print_packed_word + ply_trash_a + iny + bne !- + +found_message_in_token_stream_done: pla - // Rub out space at the end - lda #$14 - jsr JCHROUT rts print_packed_word: @@ -93,7 +105,7 @@ packed_word_search: found_packed_word: // Get pointer to start of packed word - // Make sure we don't wrap on a page boundary + // Make sure we do not wrap on a page boundary tya clc adc FRESPC+0 @@ -136,15 +148,11 @@ next_packed_word_char: lsr tax - // Save Y so it doesn't get clobbered by CHROUT - phy_trash_a - // X=1-14 = first 14 chars, so subtract one lda packed_message_chars-1,x - jsr JCHROUT + jsr JCHROUT // preserves .Y // See if there is a char in the low nybl to print - ply_trash_a lda (FRESPC),y and #$0f beq end_of_packed_word