From ba704cc5a720afd0f756a48e7c02ff47b24cbd4b Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 28 Jun 2020 17:25:40 +0200 Subject: [PATCH] LIST command is now more foolproof --- STATUS.md | 1 + src/basic/ab1e.strout.s | 1 + src/basic/assets/str_rev_question.s | 9 ++++ src/basic/board_m65/mega65_imports.s | 1 + src/basic/print/list_single_line.s | 75 ++++++++++++++++++++++++---- 5 files changed, 76 insertions(+), 11 deletions(-) create mode 100644 src/basic/assets/str_rev_question.s diff --git a/STATUS.md b/STATUS.md index 145e4a86..9f31e493 100644 --- a/STATUS.md +++ b/STATUS.md @@ -22,6 +22,7 @@ Here are the features of the Open ROMs not found in the original ROMs from the 8 * start/end addresses are displayed, in the Final cartridge style * command with just the file name tries to use the last device if it's number seems sane; otherwise uses 8 * command without parameters tries to load first file from drive chosen as above +* `LIST` command should never damage the screen if trying to list memory content which is not a BASIC program * uses RAM under ROM and I/O: 51199 bytes free (up to `$CFFF`) by default, but 61438 is also possible * cold/warm start silences multiple SID chips diff --git a/src/basic/ab1e.strout.s b/src/basic/ab1e.strout.s index 0c2e99b7..9f99e7bf 100644 --- a/src/basic/ab1e.strout.s +++ b/src/basic/ab1e.strout.s @@ -10,6 +10,7 @@ // print string routine STROUT: + // Setup pointer sty FRESPC+1 sta FRESPC+0 diff --git a/src/basic/assets/str_rev_question.s b/src/basic/assets/str_rev_question.s new file mode 100644 index 00000000..ba0c8302 --- /dev/null +++ b/src/basic/assets/str_rev_question.s @@ -0,0 +1,9 @@ +// #LAYOUT# STD * #TAKE +// #LAYOUT# * BASIC_0 #TAKE +// #LAYOUT# * * #IGNORE + +// String - question mark in reverse + +str_rev_question: + + .byte $12, $3F, $92, $00 diff --git a/src/basic/board_m65/mega65_imports.s b/src/basic/board_m65/mega65_imports.s index 4235e8f7..210dac22 100644 --- a/src/basic/board_m65/mega65_imports.s +++ b/src/basic/board_m65/mega65_imports.s @@ -23,3 +23,4 @@ .label print_features = BASIC_0.proxy_B1_print_features #endif .label do_STRING_TOO_LONG_error = BASIC_0.do_STRING_TOO_LONG_error +.label str_rev_question = BASIC_0.str_rev_question diff --git a/src/basic/print/list_single_line.s b/src/basic/print/list_single_line.s index a97077b5..021584fa 100644 --- a/src/basic/print/list_single_line.s +++ b/src/basic/print/list_single_line.s @@ -67,7 +67,9 @@ list_print_loop: lda (OLDTXT),y #endif - beq list_end_of_line + bne !+ + rts // end of line +!: cmp #$22 bne list_not_quote lda QTSW @@ -118,6 +120,10 @@ list_display_token_CC: // Subtract $1 from token to get offset in token list dex + // Check if token is known + cpx #TK__MAXTOKEN_keywords_CC + bcs list_display_unknown_token // XXX consider displaying two question marks here + // Now ask for it to be printed jsr print_packed_keyword_CC @@ -156,6 +162,10 @@ list_display_token_CD: // Subtract $1 from token to get offset in token list dex + // Check if token is known + cpx #TK__MAXTOKEN_keywords_CD + bcs list_display_unknown_token // XXX consider displaying two question marks here + // Now ask for it to be printed jsr print_packed_keyword_CD @@ -174,9 +184,13 @@ list_display_token_V2: // Subtract $80 from token to get offset in token list txa - and #$7f + and #$7F tax + // Check if token is known + cpx #TK__MAXTOKEN_keywords_V2 + bcs list_display_unknown_token + // Now ask for it to be printed jsr print_packed_keyword_V2 @@ -188,12 +202,14 @@ list_token_displayed: ply_trash_a pla - cmp #$8f + cmp #$8F bne list_not_rem // REM command locks quote flag on until the end of the line, allowing // funny characters in REM statements without problem. sta QTSW // Any value other than $00 or $FF will lock quote mode on, so the token value of REM is fine here - // FALL THROUGH + + // FALLTHROUGH + list_not_rem: iny @@ -205,13 +221,50 @@ list_is_pi: // FALLTROUGH list_is_literal: - jsr JCHROUT - iny - bne list_print_loop - -list_end_of_line: - - rts + pha + and #$7F + cmp #$12 + beq list_is_literal_known // branch if quote mode on/off + and #%01100000 + bne list_is_literal_known + pla + + // FALLTROUGH + +list_is_unknown: + + phy_trash_a + lda #str_rev_question + jsr STROUT + ply_trash_a + +#if HAS_OPCODES_65C02 + bra !+ +#else + jmp !+ +#endif + +list_is_literal_known: + + pla + jsr JCHROUT +!: + iny + bne_16 list_print_loop + + rts // end of line + +list_display_unknown_token: + + pla + pla + +#if HAS_OPCODES_65C02 + bra list_is_unknown +#else + jmp list_is_unknown +#endif #endif // ROM layout