From 180c88ef42646b8a60d39c1a15beb407abdd1777 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 1 Sep 2019 16:20:36 +0200 Subject: [PATCH] reenabled BRK handler, now prints BRK address --- STATUS.md | 3 ++- c64/aliases/,aliases_ram_lowmem.s | 6 +----- c64/basic/basic_warm_start.s | 20 +++++++++++++++++-- .../interrupts/fe47.default_nmi_handler.s | 6 +++++- c64/kernal/interrupts/irq_handler.s | 19 ++++++++++++------ src/compress_text.c | 2 +- 6 files changed, 40 insertions(+), 16 deletions(-) diff --git a/STATUS.md b/STATUS.md index 4e9cf6bd..65bf9f8f 100644 --- a/STATUS.md +++ b/STATUS.md @@ -7,6 +7,7 @@ Here are the features of the Open ROMs not found in the original ROMs from the 8 * joystick (port 1) can be used to move text cursor * uses RAM under ROM and I/O: 61436 bytes free * cold/warm start silences multiple SID chips - all $D4xx and $D5xx addresses +* wark start due to BRK prints out the instruction address * extended `LOAD` command * 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 @@ -28,7 +29,7 @@ The following ROM features are currently missing: * tape support * RS-232 support * breaking Kernal routines with RUN/STOP key -* BRK handling; NMI/IRQ handling is incomplete +* NMI andling is incomplete # API status diff --git a/c64/aliases/,aliases_ram_lowmem.s b/c64/aliases/,aliases_ram_lowmem.s index 6108e28e..d72deec7 100644 --- a/c64/aliases/,aliases_ram_lowmem.s +++ b/c64/aliases/,aliases_ram_lowmem.s @@ -34,11 +34,7 @@ .alias IEC_TMP1 $A3 ; temporary variable for tape and IEC .alias IEC_TMP2 $A4 ; temporary variable for tape and IEC - ;; 2-byte location below seems to be a good place for temporary storage, - ;; it seems used for timing during tape reads only - see: - ;; - 'C64 Programmer's Reference Guide', page 314 - ;; - 'Compute's Mapping the Commodore 64', page 32 - .alias CMP0 $B0 ; $B0-$B1 + .alias CMP0 $B0 ; $B0-$B1, temporary tape storage, we use it too for BRK instruction address .alias FNLEN $B7 ; current file name length diff --git a/c64/basic/basic_warm_start.s b/c64/basic/basic_warm_start.s index e8e51b31..adeb329e 100644 --- a/c64/basic/basic_warm_start.s +++ b/c64/basic/basic_warm_start.s @@ -2,6 +2,22 @@ basic_warm_start: jsr install_ram_routines - + + ;; If warm start caused by BRK, print it address + lda CMP0 + ora CMP0+1 + beq + + + ldx #32 + jsr print_packed_message + + lda CMP0+1 + jsr printf_printhexbyte + lda CMP0+0 + jsr printf_printhexbyte + lda #$0D + jsr JCHROUT + +* jmp basic_main_loop - + diff --git a/c64/kernal/interrupts/fe47.default_nmi_handler.s b/c64/kernal/interrupts/fe47.default_nmi_handler.s index 8814ac2c..1a1c915f 100644 --- a/c64/kernal/interrupts/fe47.default_nmi_handler.s +++ b/c64/kernal/interrupts/fe47.default_nmi_handler.s @@ -26,5 +26,9 @@ default_nmi_handler: bcs + jmp return_from_interrupt ; no STOP pressed * - jmp (CBINV) ; STOP + RESTORE + ;; STOP + RESTORE - clean the address of the BRK instruction (it's not BRK) first + lda #$00 + sta CMP0+0 + sta CMP0+1 + jmp (CBINV) diff --git a/c64/kernal/interrupts/irq_handler.s b/c64/kernal/interrupts/irq_handler.s index 99733333..292f88e0 100644 --- a/c64/kernal/interrupts/irq_handler.s +++ b/c64/kernal/interrupts/irq_handler.s @@ -16,12 +16,10 @@ irq_handler: pha ;; Check if caused by BRK - - ;; XXX disabled for now - resets Duotris game, unknown why - ; tsx - ; lda $0104, x ; get the pre-interrupt processor state - ; and #$10 - ; bne irq_handler_brk + tsx + lda $0104, x ; get the pre-interrupt processor state + and #$10 + bne irq_handler_brk ;; Not caused by BRK - call interrupt routine (only if initialised) lda CINV @@ -34,6 +32,15 @@ irq_handler: irq_handler_brk: + ;; Store BRK adddress, to be displayed + sec + lda $0105, x + sbc #$02 + sta CMP0+0 + lda $0106, x + sbc #$00 + sta CMP0+1 + ;; Interrupt caused by BRK jmp (CBINV) diff --git a/src/compress_text.c b/src/compress_text.c index 57c02f19..576d4d09 100644 --- a/src/compress_text.c +++ b/src/compress_text.c @@ -161,7 +161,7 @@ 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 - "", // unused for now + "BRK 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