diff --git a/CONFIG.md b/CONFIG.md index 199220f2..4b8a320d 100644 --- a/CONFIG.md +++ b/CONFIG.md @@ -94,7 +94,7 @@ On the most widespread CPUs the D flag is not cleared upon entering interrupts. Feature needs 2 bytes in KERNAL segmment (for CPUs needing the patch), but at the same time allows optimizations allowing to gain some more bytes. If unsure - enable. -### `CONFIG_STUBS_BRK` +### `CONFIG_DBG_STUBS_BRK` Option just for debugging purposes - replaces `RTS` stubbed routines implementation with one causing a break. diff --git a/c64/,,config_generic.s b/c64/,,config_generic.s index d9cfb900..5f5b261f 100644 --- a/c64/,,config_generic.s +++ b/c64/,,config_generic.s @@ -23,4 +23,5 @@ #define CONFIG_DOS_WEDGE #define CONFIG_BCD_SAFE_INTERRUPTS -// #define CONFIG_STUBS_BRK +// #define CONFIG_DBG_STUBS_BRK +#define CONFIG_DBG_PRINTF diff --git a/c64/,,config_mega65.s b/c64/,,config_mega65.s index 4a54f292..94b3d725 100644 --- a/c64/,,config_mega65.s +++ b/c64/,,config_mega65.s @@ -23,4 +23,5 @@ #define CONFIG_DOS_WEDGE #define CONFIG_BCD_SAFE_INTERRUPTS -// #define CONFIG_STUBS_BRK +// #define CONFIG_DBG_STUBS_BRK +#define CONFIG_DBG_PRINTF diff --git a/c64/,,config_ultimate64.s b/c64/,,config_ultimate64.s index 2351e37a..bce0b758 100644 --- a/c64/,,config_ultimate64.s +++ b/c64/,,config_ultimate64.s @@ -23,4 +23,5 @@ #define CONFIG_DOS_WEDGE #define CONFIG_BCD_SAFE_INTERRUPTS -// #define CONFIG_STUBS_BRK +// #define CONFIG_DBG_STUBS_BRK +#define CONFIG_DBG_PRINTF diff --git a/c64/aliases/,aliases_config.s b/c64/aliases/,aliases_config.s index f7a70eda..868fc670 100644 --- a/c64/aliases/,aliases_config.s +++ b/c64/aliases/,aliases_config.s @@ -75,7 +75,7 @@ .macro STUB_IMPLEMENTATION() { -#if CONFIG_STUBS_BRK +#if CONFIG_DBG_STUBS_BRK STUB_IMPLEMENTATION_BRK() #else STUB_IMPLEMENTATION_RTS() diff --git a/c64/basic/,imports.s b/c64/basic/,imports.s index 81d75baf..0c14f4b0 100644 --- a/c64/basic/,imports.s +++ b/c64/basic/,imports.s @@ -3,5 +3,9 @@ #import "KERNAL_combined.sym" + +#if CONFIG_DBG_PRINTF .label printf = KERNAL.printf -.label printf_printhexbyte = KERNAL.printf_printhexbyte +#endif + +.label print_hex_byte = KERNAL.print_hex_byte diff --git a/c64/basic/basic_warm_start.s b/c64/basic/basic_warm_start.s index 55ca0a7f..eeabd60a 100644 --- a/c64/basic/basic_warm_start.s +++ b/c64/basic/basic_warm_start.s @@ -16,12 +16,11 @@ basic_warm_start: jsr print_packed_message lda CMP0+1 - jsr printf_printhexbyte + jsr print_hex_byte lda CMP0+0 - jsr printf_printhexbyte + jsr print_hex_byte lda #$0D jsr JCHROUT !: jmp basic_main_loop - diff --git a/c64/basic/cmd_break.s b/c64/basic/cmd_break.s index 3ab1bae3..ffcab37f 100644 --- a/c64/basic/cmd_break.s +++ b/c64/basic/cmd_break.s @@ -1,17 +1,16 @@ cmd_stop: - jsr printf // XXX don't use printf, use packed messages! - .text "BREAK" - .byte 0 + ldx #38 // "BREAK" + jsr print_packed_message - // Check for direct mode // Are we in direct mode lda CURLIN+1 cmp #$FF beq !+ + // Not direct mode - jsr printf // XXX don't use printf, use packed messages! - .text " IN " - .byte 0 + ldx #37 + jsr print_packed_message + lda CURLIN+1 ldx CURLIN+0 jsr print_integer diff --git a/c64/basic/do_basic_error.s b/c64/basic/do_basic_error.s index 296241c1..f598247a 100644 --- a/c64/basic/do_basic_error.s +++ b/c64/basic/do_basic_error.s @@ -152,9 +152,8 @@ do_basic_error: beq !+ // We were in a program, so show IN - jsr printf // XXX don't use printf, use packed messages - .text " IN " - .byte 0 + ldx #37 + jsr print_packed_message lda CURLIN+1 ldx CURLIN+0 diff --git a/c64/kernal/lvs_helpers.s b/c64/kernal/lvs_helpers.s index ef47ebf4..c662d65b 100644 --- a/c64/kernal/lvs_helpers.s +++ b/c64/kernal/lvs_helpers.s @@ -117,9 +117,9 @@ lvs_display_start_addr: .text " FROM $" .byte 0 lda STAL+1 - jsr printf_printhexbyte + jsr print_hex_byte lda STAL+0 - jmp printf_printhexbyte + jmp print_hex_byte lvs_display_done: // Display end address @@ -129,9 +129,9 @@ lvs_display_done: .text " TO $" .byte 0 lda STAL+1 - jsr printf_printhexbyte + jsr print_hex_byte lda STAL+0 - jsr printf_printhexbyte + jsr print_hex_byte lda #$0D jmp JCHROUT diff --git a/c64/kernal/print_hex_byte.s b/c64/kernal/print_hex_byte.s new file mode 100644 index 00000000..d5d53760 --- /dev/null +++ b/c64/kernal/print_hex_byte.s @@ -0,0 +1,48 @@ + +// +// Print the hex value in .A as two digits +// + +print_hex_byte: + +#if HAS_BCD_SAFE_INTERRUPTS + + // Idea by Haubitze + + sed + pha + lsr + lsr + lsr + lsr + cmp #$0A + adc #$30 + jsr JCHROUT + pla + and #$0F + cmp #$0A + adc #$30 + cld + jmp JCHROUT + +#else + + pha + lsr + lsr + lsr + lsr + ora #$30 + cmp #$3A + bcc !+ + adc #6 +!: jsr JCHROUT + pla + and #$0f + ora #$30 + cmp #$3A + bcc !+ + adc #6 +!: jmp JCHROUT + +#endif diff --git a/c64/kernal/printf.s b/c64/kernal/printf.s index 599e4e15..44738e47 100644 --- a/c64/kernal/printf.s +++ b/c64/kernal/printf.s @@ -9,6 +9,8 @@ // .byte 2,$low,$hi = display word as hex // .byte $f0+n,$low,$hi = display byte at $hi$lo+n as hex +#if CONFIG_DBG_PRINTF + printf: // Temporary storage is between end of screen at $0400 // and the sprite pointers at $7f8 @@ -63,7 +65,7 @@ printf_continues: // Read the low byte jsr $7f4 // Print as hex - jsr printf_printhexbyte + jsr print_hex_byte jmp printf_nextchar not_hexbyte: @@ -77,13 +79,13 @@ not_hexbyte: // Read the high byte jsr $7f4 // Print as hex - jsr printf_printhexbyte + jsr print_hex_byte // Skip the token jsr printf_retreat // Read the low byte jsr $7f4 // Print as hex - jsr printf_printhexbyte + jsr print_hex_byte jsr printf_advance jmp printf_nextchar @@ -107,7 +109,7 @@ not_hexword: sta $fe lda ($fd),y - jsr printf_printhexbyte + jsr print_hex_byte jmp printf_nextchar not_pointer: @@ -118,7 +120,6 @@ printf_nextchar: jsr printf_advance jmp printf_loop - printf_advance: // Advance pointer to next character inc $7f5 @@ -138,48 +139,5 @@ printf_retreat: sta $7f6 rts -printf_printhexbyte: +#endif // CONFIG_DBG_PRINTF - // Print the hex value in .A as two digits - -#if HAS_BCD_SAFE_INTERRUPTS - - // Idea by Haubitze - - sed - pha - lsr - lsr - lsr - lsr - cmp #$0A - adc #$30 - jsr JCHROUT - pla - and #$0F - cmp #$0A - adc #$30 - cld - jmp JCHROUT - -#else - - pha - lsr - lsr - lsr - lsr - ora #$30 - cmp #$3A - bcc !+ - adc #6 -!: jsr JCHROUT - pla - and #$0f - ora #$30 - cmp #$3A - bcc !+ - adc #6 -!: jmp JCHROUT - -#endif diff --git a/src/compress_text.c b/src/compress_text.c index cf7e4751..85a62d06 100644 --- a/src/compress_text.c +++ b/src/compress_text.c @@ -24,7 +24,7 @@ LOAD and SAVE. Indeed, that this is so is highlighted by the fact that it was used in the C64 ROM. Therefore there is no exercise of creativity here, and a reasonable person would likely select this name independently. Also, single words cannot be copyright. - + Further, the list is a list of facts, and thus not copyrightable. We sourced the list from a public source, https://www.c64-wiki.com/wiki/BASIC, which has @@ -161,11 +161,13 @@ char *error_list[]={ "READY.\r", // #29 // https://www.ibm.com/support/knowledgecenter/zosbasics/com.ibm.zos.zconcepts/zconc_whatistsonative.htm https://github.com/stefanhaustein/expressionparser "NTSC, ", // #30 "PAL, ", // #31 - "BRK AT $", // #32 + "BREAK AT $", // #32 "ERROR", // #33 // Simply the word error that is attached to the other parts of messages https://fjkraan.home.xs4all.nl/comp/apple2faq/app2asoftfaq.html "BYTES FREE\r\r", // #34 // https://github.com/stefanhaustein/expressionparser "MEMORY CORRUPT", // #35 "NOT IMPLEMENTED", // #36 + " IN ", // #37 + "BREAK", // #38 NULL}; // XXX: create separate list for Kernal