started separating 'printf' as debug-only routine

This commit is contained in:
FeralChild64 committed 2019-10-03 21:21:34 +02:00
1 parent c3cbfcebfb
commit c173540fac
13 files changed
+86 -74

No files matched your search

+1 -1
View File
@@ -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. 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. Option just for debugging purposes - replaces `RTS` stubbed routines implementation with one causing a break.
+2 -1
View File
@@ -23,4 +23,5 @@
#define CONFIG_DOS_WEDGE #define CONFIG_DOS_WEDGE
#define CONFIG_BCD_SAFE_INTERRUPTS #define CONFIG_BCD_SAFE_INTERRUPTS
// #define CONFIG_STUBS_BRK // #define CONFIG_DBG_STUBS_BRK
#define CONFIG_DBG_PRINTF
+2 -1
View File
@@ -23,4 +23,5 @@
#define CONFIG_DOS_WEDGE #define CONFIG_DOS_WEDGE
#define CONFIG_BCD_SAFE_INTERRUPTS #define CONFIG_BCD_SAFE_INTERRUPTS
// #define CONFIG_STUBS_BRK // #define CONFIG_DBG_STUBS_BRK
#define CONFIG_DBG_PRINTF
+2 -1
View File
@@ -23,4 +23,5 @@
#define CONFIG_DOS_WEDGE #define CONFIG_DOS_WEDGE
#define CONFIG_BCD_SAFE_INTERRUPTS #define CONFIG_BCD_SAFE_INTERRUPTS
// #define CONFIG_STUBS_BRK // #define CONFIG_DBG_STUBS_BRK
#define CONFIG_DBG_PRINTF
+1 -1
View File
@@ -75,7 +75,7 @@
.macro STUB_IMPLEMENTATION() .macro STUB_IMPLEMENTATION()
{ {
#if CONFIG_STUBS_BRK #if CONFIG_DBG_STUBS_BRK
STUB_IMPLEMENTATION_BRK() STUB_IMPLEMENTATION_BRK()
#else #else
STUB_IMPLEMENTATION_RTS() STUB_IMPLEMENTATION_RTS()
+5 -1
View File
@@ -3,5 +3,9 @@
#import "KERNAL_combined.sym" #import "KERNAL_combined.sym"
#if CONFIG_DBG_PRINTF
.label printf = KERNAL.printf .label printf = KERNAL.printf
.label printf_printhexbyte = KERNAL.printf_printhexbyte #endif
.label print_hex_byte = KERNAL.print_hex_byte
+2 -3
View File
@@ -16,12 +16,11 @@ basic_warm_start:
jsr print_packed_message jsr print_packed_message
lda CMP0+1 lda CMP0+1
jsr printf_printhexbyte jsr print_hex_byte
lda CMP0+0 lda CMP0+0
jsr printf_printhexbyte jsr print_hex_byte
lda #$0D lda #$0D
jsr JCHROUT jsr JCHROUT
!: !:
jmp basic_main_loop jmp basic_main_loop
+6 -7
View File
@@ -1,17 +1,16 @@
cmd_stop: cmd_stop:
jsr printf // XXX don't use printf, use packed messages! ldx #38 // "BREAK"
.text "BREAK" jsr print_packed_message
.byte 0
// Check for direct mode
// Are we in direct mode // Are we in direct mode
lda CURLIN+1 lda CURLIN+1
cmp #$FF cmp #$FF
beq !+ beq !+
// Not direct mode // Not direct mode
jsr printf // XXX don't use printf, use packed messages! ldx #37
.text " IN " jsr print_packed_message
.byte 0
lda CURLIN+1 lda CURLIN+1
ldx CURLIN+0 ldx CURLIN+0
jsr print_integer jsr print_integer
+2 -3
View File
@@ -152,9 +152,8 @@ do_basic_error:
beq !+ beq !+
// We were in a program, so show IN <line> // We were in a program, so show IN <line>
jsr printf // XXX don't use printf, use packed messages ldx #37
.text " IN " jsr print_packed_message
.byte 0
lda CURLIN+1 lda CURLIN+1
ldx CURLIN+0 ldx CURLIN+0
+4 -4
View File
@@ -117,9 +117,9 @@ lvs_display_start_addr:
.text " FROM $" .text " FROM $"
.byte 0 .byte 0
lda STAL+1 lda STAL+1
jsr printf_printhexbyte jsr print_hex_byte
lda STAL+0 lda STAL+0
jmp printf_printhexbyte jmp print_hex_byte
lvs_display_done: lvs_display_done:
// Display end address // Display end address
@@ -129,9 +129,9 @@ lvs_display_done:
.text " TO $" .text " TO $"
.byte 0 .byte 0
lda STAL+1 lda STAL+1
jsr printf_printhexbyte jsr print_hex_byte
lda STAL+0 lda STAL+0
jsr printf_printhexbyte jsr print_hex_byte
lda #$0D lda #$0D
jmp JCHROUT jmp JCHROUT
+48
View File
@@ -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
+7 -49
View File
@@ -9,6 +9,8 @@
// .byte 2,$low,$hi = display word as hex // .byte 2,$low,$hi = display word as hex
// .byte $f0+n,$low,$hi = display byte at $hi$lo+n as hex // .byte $f0+n,$low,$hi = display byte at $hi$lo+n as hex
#if CONFIG_DBG_PRINTF
printf: printf:
// Temporary storage is between end of screen at $0400 // Temporary storage is between end of screen at $0400
// and the sprite pointers at $7f8 // and the sprite pointers at $7f8
@@ -63,7 +65,7 @@ printf_continues:
// Read the low byte // Read the low byte
jsr $7f4 jsr $7f4
// Print as hex // Print as hex
jsr printf_printhexbyte jsr print_hex_byte
jmp printf_nextchar jmp printf_nextchar
not_hexbyte: not_hexbyte:
@@ -77,13 +79,13 @@ not_hexbyte:
// Read the high byte // Read the high byte
jsr $7f4 jsr $7f4
// Print as hex // Print as hex
jsr printf_printhexbyte jsr print_hex_byte
// Skip the token // Skip the token
jsr printf_retreat jsr printf_retreat
// Read the low byte // Read the low byte
jsr $7f4 jsr $7f4
// Print as hex // Print as hex
jsr printf_printhexbyte jsr print_hex_byte
jsr printf_advance jsr printf_advance
jmp printf_nextchar jmp printf_nextchar
@@ -107,7 +109,7 @@ not_hexword:
sta $fe sta $fe
lda ($fd),y lda ($fd),y
jsr printf_printhexbyte jsr print_hex_byte
jmp printf_nextchar jmp printf_nextchar
not_pointer: not_pointer:
@@ -118,7 +120,6 @@ printf_nextchar:
jsr printf_advance jsr printf_advance
jmp printf_loop jmp printf_loop
printf_advance: printf_advance:
// Advance pointer to next character // Advance pointer to next character
inc $7f5 inc $7f5
@@ -138,48 +139,5 @@ printf_retreat:
sta $7f6 sta $7f6
rts 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
+4 -2
View File
@@ -24,7 +24,7 @@
LOAD and SAVE. Indeed, that this is so is highlighted by the fact that it was used in the 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 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. likely select this name independently. Also, single words cannot be copyright.
Further, the list is a list of facts, and thus not copyrightable. 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 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 "READY.\r", // #29 // https://www.ibm.com/support/knowledgecenter/zosbasics/com.ibm.zos.zconcepts/zconc_whatistsonative.htm https://github.com/stefanhaustein/expressionparser
"NTSC, ", // #30 "NTSC, ", // #30
"PAL, ", // #31 "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 "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 "BYTES FREE\r\r", // #34 // https://github.com/stefanhaustein/expressionparser
"MEMORY CORRUPT", // #35 "MEMORY CORRUPT", // #35
"NOT IMPLEMENTED", // #36 "NOT IMPLEMENTED", // #36
" IN ", // #37
"BREAK", // #38
NULL}; NULL};
// XXX: create separate list for Kernal // XXX: create separate list for Kernal