From e5447b3059d8c7e01d9e5ab8989740820655c230 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 13 Jun 2019 16:46:56 +0200 Subject: [PATCH 01/90] banner changed to generic one, for faster startup --- c64/basic/basic_cold_start.s | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/c64/basic/basic_cold_start.s b/c64/basic/basic_cold_start.s index 187c828e..7ffb94f6 100644 --- a/c64/basic/basic_cold_start.s +++ b/c64/basic/basic_cold_start.s @@ -15,25 +15,26 @@ basic_cold_start: ; Used 217 bytes startup_banner: + ;; Simple banner + .byte $05, " OPEN ROMS, ", $00 + ;; New banner from Retrofan - .byte $9a, $12, $20, $20, $7f, $a9, $20, $20, $1f, $20, $9a, $20, $20, $20 - .byte $20, $1f, $20, $9a, $a9, $20, $20, $20, $92, $a1, $1f, $12, $20, $9a, $a9, $20 - .byte $20, $20, $7f, $1f, $20, $20, $9a, $a3, $a3, $a3, $a3, $a3, $a3, $a3, $1f, $20 - .byte $20, $20, $20, $05, $92, $4d, $45, $47, $41, $9a, $12, $20, $20, $20, $20, $20 - .byte $20, $1f, $20, $9a, $20, $20, $92, $a2, $bb, $1f, $12, $20, $9a, $20, $20, $92 - .byte $ac, $a2, $a2, $1f, $12, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20 - .byte $20, $1e, $a3, $a3, $a3, $a3, $a3, $a3, $1f, $20, $20, $20, $20, $05, $92, $42 - .byte $41, $53, $49, $43, $9a, $12, $20, $20, $92, $7f, $a9, $12, $20, $20, $1f, $20 - .byte $9a, $20, $20, $a2, $92, $be, $1f, $12, $20, $9a, $20, $20, $92, $bc, $12, $20 - .byte $20, $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $20, $9e, $a3, $a3, $a3 - .byte $a3, $a3, $1f, $20, $20, $20, $20, $05, $92, $2d, $2d, $2d, $2d, $2d, $2d, $9a - .byte $12, $20, $20, $1f, $20, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $20, $20 - .byte $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20, $9a - .byte $20, $20, $1f, $20, $20, $96, $a3, $a3, $a3, $a3, $1f - .byte $92, $0D, $0D, $05 + ;; .byte $9a, $12, $20, $20, $7f, $a9, $20, $20, $1f, $20, $9a, $20, $20, $20 + ;; .byte $20, $1f, $20, $9a, $a9, $20, $20, $20, $92, $a1, $1f, $12, $20, $9a, $a9, $20 + ;; .byte $20, $20, $7f, $1f, $20, $20, $9a, $a3, $a3, $a3, $a3, $a3, $a3, $a3, $1f, $20 + ;; .byte $20, $20, $20, $05, $92, $4d, $45, $47, $41, $9a, $12, $20, $20, $20, $20, $20 + ;; .byte $20, $1f, $20, $9a, $20, $20, $92, $a2, $bb, $1f, $12, $20, $9a, $20, $20, $92 + ;; .byte $ac, $a2, $a2, $1f, $12, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20 + ;; .byte $20, $1e, $a3, $a3, $a3, $a3, $a3, $a3, $1f, $20, $20, $20, $20, $05, $92, $42 + ;; .byte $41, $53, $49, $43, $9a, $12, $20, $20, $92, $7f, $a9, $12, $20, $20, $1f, $20 + ;; .byte $9a, $20, $20, $a2, $92, $be, $1f, $12, $20, $9a, $20, $20, $92, $bc, $12, $20 + ;; .byte $20, $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $20, $9e, $a3, $a3, $a3 + ;; .byte $a3, $a3, $1f, $20, $20, $20, $20, $05, $92, $2d, $2d, $2d, $2d, $2d, $2d, $9a + ;; .byte $12, $20, $20, $1f, $20, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $20, $20 + ;; .byte $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20, $9a + ;; .byte $20, $20, $1f, $20, $20, $96, $a3, $a3, $a3, $a3, $1f + ;; .byte $92, $0D, $0D, $05, $00 - .byte $00 - ;; Original Deft-supplied banner ;; .byte $9A,$12,$A3,$A3,$A3,$A3,$A3,$A3,$DF,$9B,$92,$20,$05,$12,$A0,$A0 ;; .byte $DF,$9B,$92,$20,$05,$12,$A0,$A0,$DF,$9B,$92,$20,$05,$12,$A0,$A0 From e49efcce67aed0c2f18acb6424652ce1d6633134 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 13 Jun 2019 17:01:42 +0200 Subject: [PATCH 02/90] implemented SETLFS routine --- c64/kernal/setlfs.s | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/c64/kernal/setlfs.s b/c64/kernal/setlfs.s index 742ef38f..2da967b1 100644 --- a/c64/kernal/setlfs.s +++ b/c64/kernal/setlfs.s @@ -1,3 +1,12 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide + setlfs: + + ;; There are 6 sane ways to implement this routine, + ;; I hope this one won't cause similarity to CBM code + + sta current_logical_filenum + sty current_secondary_address + stx current_device_number + rts From 5accf927b3123518de862fef27f07efd80b19bb1 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 13 Jun 2019 18:09:09 +0200 Subject: [PATCH 03/90] first work towards DOS wedge --- c64/basic/basic_execute_line.s | 24 ++++++++++--- c64/basic/wedge_dos.s | 65 ++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 c64/basic/wedge_dos.s diff --git a/c64/basic/basic_execute_line.s b/c64/basic/basic_execute_line.s index a7689e51..1571575f 100644 --- a/c64/basic/basic_execute_line.s +++ b/c64/basic/basic_execute_line.s @@ -80,9 +80,9 @@ basic_execute_statement: ;; Now consume the character jsr basic_consume_character - rts + rts -not_a_token: +not_a_token: ;; Space, which we can also just ignore cmp #$20 beq basic_skip_char @@ -93,11 +93,27 @@ not_a_token: cmp #$3a beq basic_skip_char +;; START wedge support + + ;; Are we in direct mode? + ;; DOS Wedge is a hacky solution (inelegant, but convenient), + ;; BASIC programmers should implement communication with drives + ;; the standard way, handling channels properly + ldx basic_current_line_number+1 + cpx #$ff + bne + + ;; We are in direct mode, allow wedge to handle '@' sign + ;; XXX Maybe it should be allowed only as the first command? + cmp #$40 + bne + + jsr basic_consume_character + jmp wedge_dos +* +;; END wedge support + ;; If all else fails, it's a syntax error jmp do_SYNTAX_error - jmp basic_main_loop - basic_skip_char: jsr basic_consume_character jmp basic_execute_statement diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s new file mode 100644 index 00000000..2f7a5506 --- /dev/null +++ b/c64/basic/wedge_dos.s @@ -0,0 +1,65 @@ + +;; START wedge support + +wedge_dos: + + ;; Close all the channels, so that wedge has full control + jsr $FFE7 ; CLALL + + ;; Take last device number, make sure it's a drive + ;; If not, set to 8 (first drive number) + lda current_device_number + cmp #$07 + bpl + + lda #$08 +* + ;; Set remaining file parameters + ldx #$0F + ldy #$0F + jsr $FFBA ; SETLFS + + ;; Now we have to check what the user wants us to do + + ;; Check if user asked for a status + ldy #$00 + lda (basic_current_statement_ptr), y + beq wedge_dos_status + cmp #$20 + beq wedge_dos_status + + ;; Check if asked for a directory + cmp #$24 + beq wedge_dos_directory +* + ;; XXX Check if asked to change drive number + +wedge_dos_command: ; default + + ;; XXX - implement this + jsr printf + .byte "DBG: CMD", 0 + jmp do_NOT_IMPLEMENTED_error + +wedge_dos_change_drive: + + ;; XXX - implement this + jsr printf + .byte "DBG: CHANGE DRIVE", 0 + jmp do_NOT_IMPLEMENTED_error + +wedge_dos_status: + + ;; XXX - implement this + jsr printf + .byte "DBG: STATUS", 0 + jmp do_NOT_IMPLEMENTED_error + +wedge_dos_directory: + + ;; XXX - implement this + jsr printf + .byte "DBG: DIR", 0 + jmp do_NOT_IMPLEMENTED_error + +;; END wedge support + From c0d4df362fbe9e9b021bde577fc0f2ddc4be6c59 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 13 Jun 2019 23:32:46 +0200 Subject: [PATCH 04/90] DOS wedge can now change device number --- c64/basic/basic_execute_line.s | 3 ++- c64/basic/wedge_dos.s | 36 ++++++++++++++++++++++++++-------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/c64/basic/basic_execute_line.s b/c64/basic/basic_execute_line.s index 1571575f..749935cb 100644 --- a/c64/basic/basic_execute_line.s +++ b/c64/basic/basic_execute_line.s @@ -98,7 +98,8 @@ not_a_token: ;; Are we in direct mode? ;; DOS Wedge is a hacky solution (inelegant, but convenient), ;; BASIC programmers should implement communication with drives - ;; the standard way, handling channels properly + ;; the standard way, handling channels properly. Besides, + ;; current implementation does not support characters under ROM ldx basic_current_line_number+1 cpx #$ff bne + diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 2f7a5506..191be0f2 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -9,9 +9,9 @@ wedge_dos: ;; Take last device number, make sure it's a drive ;; If not, set to 8 (first drive number) lda current_device_number - cmp #$07 + cmp #$07 ;; XXX allow high device numbers, like 170 bpl + - lda #$08 + lda #$08 * ;; Set remaining file parameters ldx #$0F @@ -26,12 +26,24 @@ wedge_dos: beq wedge_dos_status cmp #$20 beq wedge_dos_status + ;; XXX consider SYNTAX ERROR if anything besides spaces is there ;; Check if asked for a directory cmp #$24 beq wedge_dos_directory * - ;; XXX Check if asked to change drive number + ;; Check if asked to change drive number, or if it is a regular command + cmp #$30 + bmi wedge_dos_command ; char code before 0 + cmp #$3A + bpl wedge_dos_command ; char code after 9 + iny + lda (basic_current_statement_ptr), y + beq wedge_dos_change_drive ; end of buffer + cmp #$20 + beq wedge_dos_change_drive + ;; XXX consider SYNTAX ERROR if anything besides spaces is there + jmp - wedge_dos_command: ; default @@ -42,10 +54,19 @@ wedge_dos_command: ; default wedge_dos_change_drive: - ;; XXX - implement this - jsr printf - .byte "DBG: CHANGE DRIVE", 0 - jmp do_NOT_IMPLEMENTED_error + ;; Reuse the line number parser for device number retrieval + jsr basic_parse_line_number + lda basic_line_number+1 + beq + + jmp do_ILLEGAL_QUANTITY_error +* + lda basic_line_number+0 + cmp #$08 ;; XXX allow high device numbers, like 170 + bpl + + jmp do_ILLEGAL_DEVICE_NUMBER_error +* + sta current_device_number + jmp basic_end_of_line wedge_dos_status: @@ -62,4 +83,3 @@ wedge_dos_directory: jmp do_NOT_IMPLEMENTED_error ;; END wedge support - From 536b82e2e076daa06f50742a021eb177f1278bfe Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 13 Jun 2019 23:33:17 +0200 Subject: [PATCH 05/90] updated .gitignore --- .gitignore | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.gitignore b/.gitignore index 04dc4054..797051dc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,14 @@ c64/basic/combined.s c64/kernal/combined.s +temp.s +temp.map +newbasic +newkern +newrom +src/compress_text +src/preprocess +ophis.bin +c64/basic/OUT.BIN +c64/kernal/OUT.BIN +*project + From 5fcbdb601e39bafce1020401b20c77d062637db3 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 14 Jun 2019 16:52:03 +0200 Subject: [PATCH 06/90] some DOS wedge fixes --- c64/basic/wedge_dos.s | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 191be0f2..9616eb6d 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -4,17 +4,18 @@ wedge_dos: ;; Close all the channels, so that wedge has full control - jsr $FFE7 ; CLALL + jsr $FFE7 ; XXX jump via ICLALL ;; Take last device number, make sure it's a drive ;; If not, set to 8 (first drive number) - lda current_device_number - cmp #$07 ;; XXX allow high device numbers, like 170 + ldx current_device_number + cpx #$07 bpl + - lda #$08 + bcs + + ldx #$08 * ;; Set remaining file parameters - ldx #$0F + lda #$0F ldy #$0F jsr $FFBA ; SETLFS @@ -61,8 +62,9 @@ wedge_dos_change_drive: jmp do_ILLEGAL_QUANTITY_error * lda basic_line_number+0 - cmp #$08 ;; XXX allow high device numbers, like 170 + cmp #$08 bpl + + bcs + jmp do_ILLEGAL_DEVICE_NUMBER_error * sta current_device_number From 8e3b66bd7a5f82fd4444db361c547d81fa674149 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 14 Jun 2019 18:50:53 +0200 Subject: [PATCH 07/90] initial RESTOR routine and $314-$333 vectors support --- c64/basic/,aliases.s | 20 ++++++++++++++++++ c64/basic/wedge_dos.s | 2 +- c64/kernal/,aliases.s | 22 ++++++++++++++++++-- c64/kernal/clall.s | 2 ++ c64/kernal/close_all_files.s | 2 -- c64/kernal/ffe7.s | 2 +- c64/kernal/restor.s | 39 ++++++++++++++++++++++++++++++++++++ c64/kernal/vector.s | 3 +++ 8 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 c64/kernal/clall.s delete mode 100644 c64/kernal/close_all_files.s diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index 712e7c35..6b8abe57 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -133,6 +133,26 @@ .alias sys_reg_p $30f .alias sys_jmp $310 + ;; Kernal vectors - interrupts + .alias CINV $0314 + .alias CBINV $0316 + .alias NMINV $0318 + + ;; Kernal vectors - routines + .alias IOPEN $031A + .alias ICLOSE $031C + .alias ICHKIN $031E + .alias ICKOUT $0320 + .alias ICLRCH $0322 + .alias IBASIN $0324 + .alias IBASOUT $0326 + .alias ISTOP $0328 + .alias IGETIN $032A + .alias ICLALL $032C + .alias USRCMD $032E + .alias ILOAD $0330 + .alias ISAVE $0331 + ;; BASIC uses some extra bytes for memory access under ROMs located at $2A7 onwards ;; IRQs are disabled when doing such accesses, and a default NMI handler only increments ;; a counter, so that if an NMI occurs, it doesn't crash the machine, but can be captured. diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 9616eb6d..f60582e8 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -4,7 +4,7 @@ wedge_dos: ;; Close all the channels, so that wedge has full control - jsr $FFE7 ; XXX jump via ICLALL + jsr (ICLALL) ;; Take last device number, make sure it's a drive ;; If not, set to 8 (first drive number) diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index 4dc694f1..47ca4cc8 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -76,6 +76,26 @@ .alias screen_scroll_disable $0292 .alias pal_or_ntsc $02A6 + ;; Kernal vectors - interrupts + .alias CINV $0314 + .alias CBINV $0316 + .alias NMINV $0318 + + ;; Kernal vectors - routines + .alias IOPEN $031A + .alias ICLOSE $031C + .alias ICHKIN $031E + .alias ICKOUT $0320 + .alias ICLRCH $0322 + .alias IBASIN $0324 + .alias IBASOUT $0326 + .alias ISTOP $0328 + .alias IGETIN $032A + .alias ICLALL $032C + .alias USRCMD $032E + .alias ILOAD $0330 + .alias ISAVE $0331 + ;; Under-ROM routines ;; (BASIC also includes them. XXX - We should de-duplicate them in a safe manner) .alias missed_nmi_flag $2A7 @@ -84,5 +104,3 @@ .alias poke_under_roms tiny_nmi_handler+poke_under_roms_routine-tiny_nmi_handler_routine .alias memmap_allram tiny_nmi_handler+memmap_allram_routine-tiny_nmi_handler_routine .alias memmap_normal tiny_nmi_handler+memmap_normal_routine-tiny_nmi_handler_routine - - diff --git a/c64/kernal/clall.s b/c64/kernal/clall.s new file mode 100644 index 00000000..3a701b3d --- /dev/null +++ b/c64/kernal/clall.s @@ -0,0 +1,2 @@ +clall: + rts diff --git a/c64/kernal/close_all_files.s b/c64/kernal/close_all_files.s deleted file mode 100644 index c0555315..00000000 --- a/c64/kernal/close_all_files.s +++ /dev/null @@ -1,2 +0,0 @@ -close_all_files: - rts diff --git a/c64/kernal/ffe7.s b/c64/kernal/ffe7.s index d333af55..03e1725f 100644 --- a/c64/kernal/ffe7.s +++ b/c64/kernal/ffe7.s @@ -1,3 +1,3 @@ ; $FFE7 - Close all files vector ; (http://codebase64.org/doku.php?id=base:kernalreference) - jmp close_all_files + jmp clall diff --git a/c64/kernal/restor.s b/c64/kernal/restor.s index 0844288b..8b26484a 100644 --- a/c64/kernal/restor.s +++ b/c64/kernal/restor.s @@ -1,3 +1,42 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide restor: + + ;; According to 'Compute's Mapping the Commodore 64' p237 this resets 15 vectors + ;; placed starting from $0314 + + ;; XXX simplify this implementation when vector is implemented + + ;; Make sure the IRQ is disabled - better safe than sorry + php + cli + + ;; Copy vectors in a loop + ldx #$1F +* + lda restor_def_arr, x + sta CINV, x + dex + bpl - + + ;; Restore status register before return + plp rts + +restor_def_arr: + .word $0000 ;; CINV XXX implement this + .word $0000 ;; CBINV XXX implement this + .word $0000 ;; NMINV XXX implement this + + .word open ;; IOPEN + .word close ;; ICLOSE + .word chkin ;; ICHKIN + .word chkout ;; ICKOUT + .word clrchn ;; ICLRCH + .word chrin ;; IBASIN + .word chrout ;; IBASOUT + .word stop ;; ISTOP + .word getin ;; IGETIN + .word clall ;; ICLALL + .word $0000 ;; USRCMD XXX implement this + .word load ;; ILOAD + .word save ;; ISAVE diff --git a/c64/kernal/vector.s b/c64/kernal/vector.s index 8b296793..cacc606f 100644 --- a/c64/kernal/vector.s +++ b/c64/kernal/vector.s @@ -1,3 +1,6 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide vector: + + ;; XXX adapt restor when this is implemented + rts From 0b95f9646fdd783d71fef3032746e5d5f05c9cd3 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 14 Jun 2019 20:59:07 +0200 Subject: [PATCH 08/90] implemented VECTOR routine --- c64/basic/,aliases.s | 7 ++++ c64/kernal/,aliases.s | 5 +++ c64/kernal/restor.s | 42 ----------------------- c64/kernal/vector.s | 78 +++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 88 insertions(+), 44 deletions(-) delete mode 100644 c64/kernal/restor.s diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index 6b8abe57..e91993c0 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -66,6 +66,13 @@ .alias load_or_scroll_temp_pointer $AC ;; We also use the following for temp colour pointer when scrolling .alias load_save_verify_end_address $AE + + ;; 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 cassette_buffer_ptr $B2 .alias current_filename_length $B7 .alias current_logical_filenum $B8 diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index 47ca4cc8..8acaed6e 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -51,6 +51,11 @@ .alias rs232_rx_buffer_ptr $F7 .alias rs232_tx_buffer_ptr $F9 + ;; 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 ; "Compute's Mapping the 64" book .alias keyboard_buffer $0277 diff --git a/c64/kernal/restor.s b/c64/kernal/restor.s deleted file mode 100644 index 8b26484a..00000000 --- a/c64/kernal/restor.s +++ /dev/null @@ -1,42 +0,0 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide -restor: - - ;; According to 'Compute's Mapping the Commodore 64' p237 this resets 15 vectors - ;; placed starting from $0314 - - ;; XXX simplify this implementation when vector is implemented - - ;; Make sure the IRQ is disabled - better safe than sorry - php - cli - - ;; Copy vectors in a loop - ldx #$1F -* - lda restor_def_arr, x - sta CINV, x - dex - bpl - - - ;; Restore status register before return - plp - rts - -restor_def_arr: - .word $0000 ;; CINV XXX implement this - .word $0000 ;; CBINV XXX implement this - .word $0000 ;; NMINV XXX implement this - - .word open ;; IOPEN - .word close ;; ICLOSE - .word chkin ;; ICHKIN - .word chkout ;; ICKOUT - .word clrchn ;; ICLRCH - .word chrin ;; IBASIN - .word chrout ;; IBASOUT - .word stop ;; ISTOP - .word getin ;; IGETIN - .word clall ;; ICLALL - .word $0000 ;; USRCMD XXX implement this - .word load ;; ILOAD - .word save ;; ISAVE diff --git a/c64/kernal/vector.s b/c64/kernal/vector.s index cacc606f..2a8c6e5d 100644 --- a/c64/kernal/vector.s +++ b/c64/kernal/vector.s @@ -1,6 +1,80 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide +; Functions defined on pp272-273 of C64 Programmers Reference Guide + +restor: + + clc ;; clear carry - for writing to system table + ldx #vector_defaults + + ;; FALLTHROUGH + vector: - ;; XXX adapt restor when this is implemented +.scope + ;; Temporary storage location + .alias _caller_arr_ptr CMP0 + + ;; According to 'Compute's Mapping the Commodore 64' page 237, + ;; the CBM implementation does not disable IRQs - yet, the + ;; 'C64 Programmers Reference Guide' does not contain such + ;; warning and does not mention any preparations needed, so... + ;; better safe than sorry, disable the IRQ for the duration + ;; of vector manipulation + php + cli + + ;; Prepare the user data pointer + stx _caller_arr_ptr + 0 + sty _caller_arr_ptr + 1 + + ;; Select routine variant - store or restore vectors + ldy #$1F + bcc vector_restore + + ;; FALLTHROUGH + +vector_store: +* + lda CINV, y + sta (_caller_arr_ptr), y + dey + bpl - + + ;; Restore status register (IRQ) before return + plp rts + +vector_restore: +* + lda (_caller_arr_ptr), y + sta CINV, y + dey + bpl - + + ;; Restore status register (IRQ) before return + plp + rts + +.scend + + ;; XXX below we have quite a lot of data... should we decouple them? + +vector_defaults: + .word $0000 ;; CINV XXX implement this + .word $0000 ;; CBINV XXX implement this + .word $0000 ;; NMINV XXX implement this + + .word open ;; IOPEN + .word close ;; ICLOSE + .word chkin ;; ICHKIN + .word chkout ;; ICKOUT + .word clrchn ;; ICLRCH + .word chrin ;; IBASIN + .word chrout ;; IBASOUT + .word stop ;; ISTOP + .word getin ;; IGETIN + .word clall ;; ICLALL + .word $0000 ;; USRCMD XXX implement this + .word load ;; ILOAD + .word save ;; ISAVE From cac4e5859e7f1344d51e728697e53c473ab9d4a4 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 14 Jun 2019 21:23:02 +0200 Subject: [PATCH 09/90] implemented SETNAM routine --- c64/kernal/setnam.s | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/c64/kernal/setnam.s b/c64/kernal/setnam.s index 8c2d0b86..55ae5b7f 100644 --- a/c64/kernal/setnam.s +++ b/c64/kernal/setnam.s @@ -1,3 +1,12 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide + setnam: + + ;; There are 6 sane ways to implement this routine, + ;; I hope this one won't cause similarity to CBM code + + sta current_filename_length + sty current_filename_ptr + 1 + stx current_filename_ptr + 0 + rts From 6cb5e520dba3f64dc77ebf4f6f43f7a3c3239471 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 14 Jun 2019 21:25:23 +0200 Subject: [PATCH 10/90] DOS wedge compilation fix --- c64/basic/wedge_dos.s | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index f60582e8..ac546a1f 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -4,7 +4,7 @@ wedge_dos: ;; Close all the channels, so that wedge has full control - jsr (ICLALL) + jsr wedge_dos_CLALL ;; Take last device number, make sure it's a drive ;; If not, set to 8 (first drive number) @@ -84,4 +84,7 @@ wedge_dos_directory: .byte "DBG: DIR", 0 jmp do_NOT_IMPLEMENTED_error +wedge_dos_CLALL: + jmp (ICLALL) + ;; END wedge support From 30925a35c8093afe21054fbcab33c999f22ce6d8 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 14 Jun 2019 21:43:56 +0200 Subject: [PATCH 11/90] implemented SCREEN routine --- c64/kernal/ffed.s | 2 +- c64/kernal/get_screen_size.s | 2 -- c64/kernal/screen.s | 11 +++++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) delete mode 100644 c64/kernal/get_screen_size.s create mode 100644 c64/kernal/screen.s diff --git a/c64/kernal/ffed.s b/c64/kernal/ffed.s index a9e258cf..55d44e37 100644 --- a/c64/kernal/ffed.s +++ b/c64/kernal/ffed.s @@ -1,4 +1,4 @@ ; $FFED - Return screen size (X=columns, Y=rows) ; (http://codebase64.org/doku.php?id=base:kernalreference) - jmp get_screen_size + jmp screen diff --git a/c64/kernal/get_screen_size.s b/c64/kernal/get_screen_size.s deleted file mode 100644 index ff7be9a0..00000000 --- a/c64/kernal/get_screen_size.s +++ /dev/null @@ -1,2 +0,0 @@ -get_screen_size: - rts diff --git a/c64/kernal/screen.s b/c64/kernal/screen.s new file mode 100644 index 00000000..19fa509d --- /dev/null +++ b/c64/kernal/screen.s @@ -0,0 +1,11 @@ +; Function defined on p295 of C64 Programmers Reference Guide + +screen: + + ;; There are only 2 sane ways to implement this routine, + ;; I hope this one is different than what Commodore picked :) + + ldy #25 ; 25 columns + ldx #40 ; 40 rows + + rts From e9b3bb42f86f2e0ce52f1b543030d263fb2e87e2 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 15 Jun 2019 13:14:35 +0200 Subject: [PATCH 12/90] implemented READST routine --- c64/basic/,aliases.s | 4 +++- c64/kernal/,aliases.s | 4 +++- c64/kernal/readst.s | 19 +++++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index e91993c0..59fddba5 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -58,7 +58,8 @@ .alias BUCKYSTATUS $91 .alias load_or_verify_flag $93 .alias current_file_num $98 - .alias input_device_number $99 + .alias DFLTN $99 + .alias input_device_number DFLTN ; bit 6 = error messages, bit 7 = control messages .alias kernal_message_control_flags $9d .alias jiffy_clock_24bits $a0 @@ -131,6 +132,7 @@ .alias keyboard_decoding_ptr $028F .alias enable_case_switch $0291 .alias screen_scroll_disable $0292 + .alias RSSTAT $0297 ; RS-232 status .alias pal_or_ntsc $02A6 ;; Registers for SYS call diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index 8acaed6e..be1a53d2 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -9,7 +9,8 @@ .alias BUCKYSTATUS $91 .alias kernal_load_or_verify_flag $93 .alias current_file_num $98 - .alias input_device_number $99 + .alias DFLTN $99 + .alias input_device_number DFLTN ; bit 6 = error messages, bit 7 = control messages .alias kernal_message_control_flags $9d .alias jiffy_clock_24bits $a0 @@ -79,6 +80,7 @@ .alias keyboard_decoding_ptr $028F .alias enable_case_switch $0291 .alias screen_scroll_disable $0292 + .alias RSSTAT $0297 ; RS-232 status .alias pal_or_ntsc $02A6 ;; Kernal vectors - interrupts diff --git a/c64/kernal/readst.s b/c64/kernal/readst.s index 28139f1b..e8e0f164 100644 --- a/c64/kernal/readst.s +++ b/c64/kernal/readst.s @@ -1,3 +1,22 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide + readst: + + ;; Check the current device number + + lda DFLTN + cmp #$02 + bne + + + ;; This is RS-232 device - according to 'Compute's Mapping the Commodore 64' page 239 + ;; it reads status from RSSTAT + lda RSSTAT + rts +* + ;; According to 'Compute's Mapping the Commodore 64' page 239, it usually retrieves + ;; status from IOSTATUS + + ;; XXX is it always the case if device is not RS-232 ? + + lda IOSTATUS rts From e675262b66ece7c5987277bc29eabcb2053fe0f7 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 15 Jun 2019 16:59:19 +0200 Subject: [PATCH 13/90] routine OPEN now reacts on device number --- c64/kernal/open.s | 49 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 3 deletions(-) diff --git a/c64/kernal/open.s b/c64/kernal/open.s index 189e4227..1dc5d99e 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -1,19 +1,62 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide ;; See also http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf + +open: + + ;; Kernal API is shared between several types of devices - we have + ;; to dispatch the call to appropriate subroutine + + lda current_device_number + beq open_keyboard + cmp #$01 + beq open_tape + cmp #$02 + beq open_rs232 + cmp #$03 + beq open_screen + cmp #$1F + bcs + + bmi open_iec +* + ;; Device numbers over 30 are not allowed on IEC bus + + ;; FALLTHROUGH to error routine + +open_keyboard: +open_tape: +open_screen: + + ;; XXX implement support for these devices + lda #$05 ; device not present + sta IOSTATUS + rts + +open_rs232: + + ;; XXX implement support for RS-232 + lda #$FF ; set every single error bit to discourage using RS-232 + sta RSSTAT + rts + +open_iec: + + ;; XXX add FILENAM support, test it + ;; Sequence is: ;; 1. Call current device to attention as LISTENER = $20 + device ;; 2. -open: ;; Disable IRQs, since timing matters! - SEI + sei ;; Begin sending under attention jsr iec_assert_atn ;; CLK is now asserted, and we are ready to transmit a byte - lda #$28 + lda #$20 ; listen + clc + adc current_device_number jsr iec_tx_byte bcs open_error From 5d0df478b02f99f78216274f494e216496f19fd6 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 15 Jun 2019 17:37:17 +0200 Subject: [PATCH 14/90] implemented TALK, LISTEN, UNTLK and UNLSN routines --- c64/kernal/listen.s | 6 +++++- c64/kernal/talk.s | 6 +++++- c64/kernal/unlsn.s | 6 +++++- c64/kernal/untlk.s | 6 +++++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/c64/kernal/listen.s b/c64/kernal/listen.s index 4fc90f42..53dbd21e 100644 --- a/c64/kernal/listen.s +++ b/c64/kernal/listen.s @@ -1,3 +1,7 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide + listen: - rts + + ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 223 + ora $20 + jmp iec_tx_byte diff --git a/c64/kernal/talk.s b/c64/kernal/talk.s index 48a341d6..a51faf8b 100644 --- a/c64/kernal/talk.s +++ b/c64/kernal/talk.s @@ -1,3 +1,7 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide + talk: - rts + + ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 223 + ora $40 + jmp iec_tx_byte diff --git a/c64/kernal/unlsn.s b/c64/kernal/unlsn.s index 31a35a40..c3854f7c 100644 --- a/c64/kernal/unlsn.s +++ b/c64/kernal/unlsn.s @@ -1,3 +1,7 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide + unlsn: - rts + + ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 224 + lda $5F + jmp iec_tx_byte diff --git a/c64/kernal/untlk.s b/c64/kernal/untlk.s index 30a018a4..275adbaa 100644 --- a/c64/kernal/untlk.s +++ b/c64/kernal/untlk.s @@ -1,3 +1,7 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide + untlk: - rts + + ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 224 + lda $5F + jmp iec_tx_byte From 9ee2fd2af53dcb05062093715209ca649a376023 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 16 Jun 2019 19:32:40 +0200 Subject: [PATCH 15/90] implemented CLALL routine, added support for LAT/SAT/FAT and LDTND variables --- c64/basic/,aliases.s | 7 +++++++ c64/kernal/,aliases.s | 6 ++++++ c64/kernal/clall.s | 16 +++++++++++++++- c64/kernal/close.s | 38 ++++++++++++++++++++++++++++++++++++++ c64/kernal/open.s | 42 ++++++++++++++++++++++++++++++++++++------ 5 files changed, 102 insertions(+), 7 deletions(-) diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index 59fddba5..f500a630 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -58,6 +58,7 @@ .alias BUCKYSTATUS $91 .alias load_or_verify_flag $93 .alias current_file_num $98 + .alias LDTND $98 ; number of entries in LAT / FAT / SAT tables .alias DFLTN $99 .alias input_device_number DFLTN ; bit 6 = error messages, bit 7 = control messages @@ -74,6 +75,7 @@ ;; - 'Compute's Mapping the Commodore 64', page 32 .alias CMP0 $B0 ;; $B0-$B1 + .alias cassette_buffer_ptr $B2 .alias current_filename_length $B7 .alias current_logical_filenum $B8 @@ -110,6 +112,11 @@ .alias basic_input_buffer $0200 + ;; Kernal tables for opened files, 10 entries each + .alias LAT $0259 ; logical file numbers + .alias FAT $0263 ; device numbers + .alias SAT $026D ; secondary addresses + ; "Compute's Mapping the 64" book .alias keyboard_buffer $0277 .alias MEMSTR $0281 diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index be1a53d2..d438620d 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -9,6 +9,7 @@ .alias BUCKYSTATUS $91 .alias kernal_load_or_verify_flag $93 .alias current_file_num $98 + .alias LDTND $98 ; number of entries in LAT / FAT / SAT tables .alias DFLTN $99 .alias input_device_number DFLTN ; bit 6 = error messages, bit 7 = control messages @@ -58,6 +59,11 @@ ;; - 'Compute's Mapping the Commodore 64', page 32 .alias CMP0 $B0 ;; $B0-$B1 + ;; Kernal tables for opened files, 10 entries each + .alias LAT $0259 ; logical file numbers + .alias FAT $0263 ; device numbers + .alias SAT $026D ; secondary addresses + ; "Compute's Mapping the 64" book .alias keyboard_buffer $0277 .alias MEMSTR $0281 diff --git a/c64/kernal/clall.s b/c64/kernal/clall.s index 3a701b3d..a24918fb 100644 --- a/c64/kernal/clall.s +++ b/c64/kernal/clall.s @@ -1,2 +1,16 @@ + clall: - rts + + ;; Implemented according to 'C64 Programmer's Reference Guide', page 281 + ;; Not entirely sure if it just sets LDTND to 0 or actually calls CLOSE, + ;; but calling CLOSE for all open channels seems to be the safest + + ldy LDTND + beq + + dey + lda LAT, y + jsr close + jmp clall +* + ;; 'C64 Programmers Reference Guide', page 281, claims it calls CLRCHN too + jmp clrchn diff --git a/c64/kernal/close.s b/c64/kernal/close.s index df7f3603..e89ace83 100644 --- a/c64/kernal/close.s +++ b/c64/kernal/close.s @@ -1,3 +1,41 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide close: + + ;; Implemented accorging to 'C64 Programmers Reference Guide', page 281 + + ;; XXX this needs more testing (opening 10 files at once, closing in various orders, etc) once the code is more mature + + ;; Find the LAT / SAT / FAT entry which LAT corresponds to A + + ldy LDTND + beq close_error_not_found ; table empty +* + dey + bmi close_error_not_found ; no more entries + cmp LAT, y + bne - ; does not match, try the next one + + ;; We have the entry index in Y + + ;; XXX some devices (like IEC) needs special support here, to free their internal resources! + ;; Just make sure the Y register value is kept, or redo ldy DFTLN +* + iny + cpy #$0A + bpl + + lda LAT, y + sta LAT-1, y + lda FAT, y + sta FAT-1, y + lda SAT, y + sta SAT-1, y + jmp - +* + ;; Decrement the list size variable + dec LDTND + ;; FALLTHROUGH (for now) - success + +close_error_not_found: + + ;; XXX it seems that this function can't report errors, am I right? rts diff --git a/c64/kernal/open.s b/c64/kernal/open.s index 1dc5d99e..92981de6 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -4,6 +4,38 @@ open: + ;; LAT / FAT / SAT support implemented according to + ;; 'Compute's Mapping the Commodore 64', page 52 + + ;; Check if we have space in tables + + ldy LDTND + cpy #$0A + bcs + + bmi open_has_space +* + jsr printf + .byte "FULL", $0D, 0 + + ;; Table is full - according to https://codebase64.org/doku.php?id=base:kernalreference + ;; C flag set means error occured + sec + rts + +open_has_space: + + ;; Update the tables + + lda current_logical_filenum + sta LAT, y + lda current_device_number + sta FAT, y + lda current_secondary_address + sta SAT, y + + iny + sty LDTND + ;; Kernal API is shared between several types of devices - we have ;; to dispatch the call to appropriate subroutine @@ -54,17 +86,15 @@ open_iec: jsr iec_assert_atn ;; CLK is now asserted, and we are ready to transmit a byte - lda #$20 ; listen - clc - adc current_device_number - jsr iec_tx_byte - bcs open_error + lda current_device_number + jsr listen + bcs open_iec_error ;; Indicate success lda #$00 clc -open_error: +open_iec_error: ;; Re-enable interrupts and return ;; (iec_tx_byte will have set/cleared C flag and put result code ;; in A if it was an error). From 805fc970ffcc5dffd6995c25d2d49122a08c517d Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 16 Jun 2019 19:56:47 +0200 Subject: [PATCH 16/90] implemented SECOND routine --- c64/kernal/second.s | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/c64/kernal/second.s b/c64/kernal/second.s index 65eb7f88..09ff93bb 100644 --- a/c64/kernal/second.s +++ b/c64/kernal/second.s @@ -1,3 +1,6 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide second: - rts + + ;; This trivial routine is documented in 'C64 Programmer's Reference Guide', page 296 + ora $60 + jmp iec_tx_byte From 86a7af378d6a8644d06e55121df82b3f9784f573 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 16 Jun 2019 20:19:51 +0200 Subject: [PATCH 17/90] more work on DOS wedge Retrieving the status (@) should teoretically work, but several KERNAL routines are still missing or incomplete --- c64/basic/wedge_dos.s | 48 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index ac546a1f..d01967ca 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -8,13 +8,13 @@ wedge_dos: ;; Take last device number, make sure it's a drive ;; If not, set to 8 (first drive number) - ldx current_device_number + ldx DFLTN cpx #$07 bpl + bcs + ldx #$08 * - ;; Set remaining file parameters + ;; Set remaining file parameters; channel 15 is a typical one for commands lda #$0F ldy #$0F jsr $FFBA ; SETLFS @@ -67,15 +67,35 @@ wedge_dos_change_drive: bcs + jmp do_ILLEGAL_DEVICE_NUMBER_error * - sta current_device_number + sta DFLTN jmp basic_end_of_line wedge_dos_status: - ;; XXX - implement this - jsr printf - .byte "DBG: STATUS", 0 - jmp do_NOT_IMPLEMENTED_error + ;; Here the flow is mostly the same as in the example from + ;; https://codebase64.org/doku.php?id=base:reading_the_error_channel_of_a_disk_drive + + ;; Set remaining file parameters, open the channel + lda #$00 ; empty file name + jsr $FFBD ; SETNAM + jsr wedge_dos_OPEN + bcc + + jmp do_DEVICE_NOT_PRESENT_error +* + ;; Set channel for input + ldx #$0F + jsr wedge_dos_CHKIN +* + jsr $FFB7 ; READST - to retrieve errors +* + ;; Print out everything retrieved from the drive + bne + + jsr $FFCF ; CHRIN + jsr $FFD2 ; CHROUT + jmp - +* + ;; Clean-up and exit + jmp wedge_dos_clean_exit wedge_dos_directory: @@ -86,5 +106,19 @@ wedge_dos_directory: wedge_dos_CLALL: jmp (ICLALL) + +wedge_dos_CHKIN: + jmp (ICHKIN) +wedge_dos_CLRCHR: + jmp (ICLRCH) + +wedge_dos_OPEN: + jmp (IOPEN) + +wedge_dos_clean_exit: + jsr wedge_dos_CLALL + jsr wedge_dos_CLRCHR + jmp basic_end_of_line + ;; END wedge support From a0aa91e9c782d24d776a43c11c2d2df015ed6abb Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Tue, 18 Jun 2019 17:04:35 +0200 Subject: [PATCH 18/90] fixed addressing mode in several routines --- c64/kernal/listen.s | 4 ++-- c64/kernal/second.s | 2 +- c64/kernal/talk.s | 4 ++-- c64/kernal/unlsn.s | 4 ++-- c64/kernal/untlk.s | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/c64/kernal/listen.s b/c64/kernal/listen.s index 53dbd21e..a71db073 100644 --- a/c64/kernal/listen.s +++ b/c64/kernal/listen.s @@ -3,5 +3,5 @@ listen: ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 223 - ora $20 - jmp iec_tx_byte + ora #$20 + jmp iec_tx_byte ;; XXX add special routine for commands diff --git a/c64/kernal/second.s b/c64/kernal/second.s index 09ff93bb..a4dbb58f 100644 --- a/c64/kernal/second.s +++ b/c64/kernal/second.s @@ -2,5 +2,5 @@ second: ;; This trivial routine is documented in 'C64 Programmer's Reference Guide', page 296 - ora $60 + ora #$60 jmp iec_tx_byte diff --git a/c64/kernal/talk.s b/c64/kernal/talk.s index a51faf8b..bd487e38 100644 --- a/c64/kernal/talk.s +++ b/c64/kernal/talk.s @@ -3,5 +3,5 @@ talk: ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 223 - ora $40 - jmp iec_tx_byte + ora #$40 + jmp iec_tx_byte ;; XXX add special routine for commands diff --git a/c64/kernal/unlsn.s b/c64/kernal/unlsn.s index c3854f7c..cdf99bc8 100644 --- a/c64/kernal/unlsn.s +++ b/c64/kernal/unlsn.s @@ -3,5 +3,5 @@ unlsn: ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 224 - lda $5F - jmp iec_tx_byte + lda #$5F + jmp iec_tx_byte ;; XXX add special routine for commands diff --git a/c64/kernal/untlk.s b/c64/kernal/untlk.s index 275adbaa..0fdc36c1 100644 --- a/c64/kernal/untlk.s +++ b/c64/kernal/untlk.s @@ -3,5 +3,5 @@ untlk: ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 224 - lda $5F - jmp iec_tx_byte + lda #$5F + jmp iec_tx_byte ;; XXX add special routine for commands From fd04410bd8e65d17728807652c29da9283c67518 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 19 Jun 2019 21:06:26 +0200 Subject: [PATCH 19/90] more work on IEC, fixed command transmission --- c64/kernal/iec_tx_command.s | 153 ++++++++++++++++++++++++++++++++++++ c64/kernal/iec_wait20us.s | 4 +- c64/kernal/iec_wait60us.s | 2 +- c64/kernal/listen.s | 2 +- c64/kernal/open.s | 2 +- c64/kernal/second.s | 2 +- c64/kernal/talk.s | 3 +- c64/kernal/unlsn.s | 3 +- c64/kernal/untlk.s | 3 +- 9 files changed, 165 insertions(+), 9 deletions(-) create mode 100644 c64/kernal/iec_tx_command.s diff --git a/c64/kernal/iec_tx_command.s b/c64/kernal/iec_tx_command.s new file mode 100644 index 00000000..eeba3b95 --- /dev/null +++ b/c64/kernal/iec_tx_command.s @@ -0,0 +1,153 @@ + + +;; XXX - TEMPORARY IMPLEMENTATION + +;; https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc +;; https://www.c64-wiki.com/wiki/CIA#CIA_2 + +.alias CI2PRA $DD00 + +.alias BIT_IEC_ATN_OUT $08 ; 1 - low (pulled), 0 - high (released) +.alias BIT_IEC_CLK_OUT $10 ; 1 - low (pulled), 0 - high (released) +.alias BIT_IEC_DAT_OUT $20 ; 1 - low (pulled), 0 - high (released) +.alias BIT_IEC_CLK_IN $40 ; 0 - low (pulled), 1 - high (released) +.alias BIT_IEC_DAT_IN $80 ; 0 - low (pulled), 1 - high (released) + + +; XXX optimize these below + +xxx_to_idle_state: + lda CI2PRA + ora #BIT_IEC_CLK_OUT ; pull + and #$FF - BIT_IEC_DAT_OUT - BIT_IEC_ATN_OUT ; release + sta CI2PRA + rts + +xxx_pull_atn_clk_release_data: + lda CI2PRA + ora #BIT_IEC_ATN_OUT + BIT_IEC_CLK_OUT ; pull + and #$FF - BIT_IEC_DAT_OUT ; release + sta CI2PRA + rts + +xxx_pull_clk_release_data: + lda CI2PRA + ora #BIT_IEC_CLK_OUT ; pull + and #$FF - BIT_IEC_DAT_OUT ; release + sta CI2PRA + rts + +xxx_release_clk_data: + lda CI2PRA + and #$FF - BIT_IEC_CLK_OUT - BIT_IEC_DAT_OUT ; release + sta CI2PRA + rts + +xxx_release_clk_pull_data: + lda CI2PRA + and #$FF - BIT_IEC_CLK_OUT ; release + ora #BIT_IEC_DAT_OUT ; pull + sta CI2PRA + rts + +xxx_wait_for_data_release: + lda CI2PRA + ;; Check the highest bit, which is DATA IN, + ;; (highest bit set = negative value) + bpl xxx_wait_for_data_release + rts + + + +iec_tx_command: + + pha + + ;; Notify all devices that we are going to send a byte + ;; and it is going to be a command (pulled ATN) + jsr xxx_pull_atn_clk_release_data + + ;; Give devices time to respond (response is mandatory!) + jsr wait1ms + + ;; Did at least one device respond by pulling DATA? + lda CI2PRA + and #BIT_IEC_DAT_IN + beq + + + ;; No devices present on the bus, so we can immediately return with device not found + pla + + jsr printf + .byte "DBG: NO DEVICES AT ALL", $0D, 0 + + jsr xxx_to_idle_state + jmp kernalerror_DEVICE_NOT_FOUND +* + ;; At least one device responded, but they are still allowed to stall + ;; (can be busy processing something), we have to wait till they are all + ;; ready (or bored with DOS attack...) + ;; - release back CLK, keep DATA released + ;; - afterwards wait till all devices also release DATA + + jsr xxx_release_clk_data + jsr xxx_wait_for_data_release + + ;; Pull CLK back to indicate that DATA is not valid, keep it for 60us + ;; Don't wait too long, as 200us or more is considered EOI + + jsr xxx_pull_clk_release_data + jsr iec_wait60us + + ;; Now, we can start transmission of 8 bits of data + ldx #7 + pla + +iec_tx_command_nextbit: + ;; Is next bit 0 or 1? + lsr + pha + bcs + + + ;; Bit is 0 + jsr xxx_release_clk_pull_data + jmp iec_tx_command_bitset +* + ;; Bit is 1 + jsr xxx_release_clk_data + +iec_tx_command_bitset: + + ;; Wait 20us, so that device(s) can pick DATA + jsr iec_wait20us + + ;; Pull CLK for 20us again + jsr xxx_pull_clk_release_data + jsr iec_wait20us + + ;; More bits to send? + pla + dex + bpl iec_tx_command_nextbit + + ;; XXX the flow below is REALLY dangerous, as if there are multiple devices, + ;; one can signal that it's busy much earlier (more than 100ms) than the other. + ;; Can we do something about it? + + ;; All done - give devices time to tell if they are busy by pulling DATA + ;; They should do it within 1ms + ldx #$FF +* lda CI2PRA + ;; BPL here is checking that bit 7 of $DD00 clears, + ;; i.e, that the DATA line is pulled by drive + bpl + + dex + bne - + bpl iec_tx_command_done +* + ;; XXX wait 100ms + +iec_tx_command_done: + + clc + rts diff --git a/c64/kernal/iec_wait20us.s b/c64/kernal/iec_wait20us.s index 86456409..8ea1962b 100644 --- a/c64/kernal/iec_wait20us.s +++ b/c64/kernal/iec_wait20us.s @@ -2,6 +2,6 @@ iec_wait20us: ;; Wait 20usec ;; JSR + RTS already costs 12, so need only 8 more - ldy $dd00 - ldy $dd00 + ldy $dd01 ; reading dd00 makes debugging harder + ldy $dd01 rts diff --git a/c64/kernal/iec_wait60us.s b/c64/kernal/iec_wait60us.s index d1eed334..7e158fb9 100644 --- a/c64/kernal/iec_wait60us.s +++ b/c64/kernal/iec_wait60us.s @@ -2,7 +2,7 @@ iec_wait60us: ;; Waste ~60 clock cycles (including JSR + RTS) ldy #$06 -* lda $dd00 +* lda $dd01 ; reading dd00 makes debugging harder dey bpl - diff --git a/c64/kernal/listen.s b/c64/kernal/listen.s index a71db073..06cc7121 100644 --- a/c64/kernal/listen.s +++ b/c64/kernal/listen.s @@ -4,4 +4,4 @@ listen: ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 223 ora #$20 - jmp iec_tx_byte ;; XXX add special routine for commands + jmp iec_tx_command diff --git a/c64/kernal/open.s b/c64/kernal/open.s index 92981de6..cf9b4389 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -83,7 +83,7 @@ open_iec: sei ;; Begin sending under attention - jsr iec_assert_atn + ;; XXX jsr iec_assert_atn ;; CLK is now asserted, and we are ready to transmit a byte lda current_device_number diff --git a/c64/kernal/second.s b/c64/kernal/second.s index a4dbb58f..1dc7de8a 100644 --- a/c64/kernal/second.s +++ b/c64/kernal/second.s @@ -3,4 +3,4 @@ second: ;; This trivial routine is documented in 'C64 Programmer's Reference Guide', page 296 ora #$60 - jmp iec_tx_byte + jmp iec_tx_command diff --git a/c64/kernal/talk.s b/c64/kernal/talk.s index bd487e38..7a421974 100644 --- a/c64/kernal/talk.s +++ b/c64/kernal/talk.s @@ -4,4 +4,5 @@ talk: ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 223 ora #$40 - jmp iec_tx_byte ;; XXX add special routine for commands + jmp iec_tx_command + diff --git a/c64/kernal/unlsn.s b/c64/kernal/unlsn.s index cdf99bc8..ba72da38 100644 --- a/c64/kernal/unlsn.s +++ b/c64/kernal/unlsn.s @@ -4,4 +4,5 @@ unlsn: ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 224 lda #$5F - jmp iec_tx_byte ;; XXX add special routine for commands + jmp iec_tx_command + diff --git a/c64/kernal/untlk.s b/c64/kernal/untlk.s index 0fdc36c1..3a47ff02 100644 --- a/c64/kernal/untlk.s +++ b/c64/kernal/untlk.s @@ -4,4 +4,5 @@ untlk: ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 224 lda #$5F - jmp iec_tx_byte ;; XXX add special routine for commands + jmp iec_tx_command + From edb0013536d445f16841d61c625f46c80e6688f2 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 20 Jun 2019 11:23:30 +0200 Subject: [PATCH 20/90] more work on IEC, some refactoring and temporary breakage --- c64/kernal/,aliases.s | 10 ++ c64/kernal/fda3.ioinit.s | 3 + c64/kernal/iec_assert_atn.s | 5 - c64/kernal/iec_assert_clk_and_data.s | 6 - c64/kernal/iec_assert_clk_release_data.s | 6 - c64/kernal/iec_assert_data.s | 5 - c64/kernal/iec_pull_atn_clk_release_data.s | 7 + c64/kernal/iec_pull_clk_releasee_data.s | 7 + c64/kernal/iec_release_atn.s | 11 -- c64/kernal/iec_release_clk.s | 5 - c64/kernal/iec_release_clk_and_data.s | 6 - c64/kernal/iec_release_clk_data.s | 6 + c64/kernal/iec_release_clk_pull_data.s | 7 + c64/kernal/iec_rx_byte.s | 186 +++++++++++---------- c64/kernal/iec_set_idle.s | 7 + c64/kernal/iec_tx_byte.s | 89 +--------- c64/kernal/iec_tx_command.s | 81 ++------- c64/kernal/iec_wait100us.s | 25 +++ c64/kernal/iec_wait20us.s | 25 ++- c64/kernal/iec_wait60us.s | 28 +++- c64/kernal/iec_wait_for_clock_assert.s | 5 - c64/kernal/iec_wait_for_clock_release.s | 5 - c64/kernal/iec_wait_for_data_release.s | 8 +- c64/kernal/load.s | 41 ++--- c64/kernal/open.s | 1 + 25 files changed, 248 insertions(+), 337 deletions(-) delete mode 100644 c64/kernal/iec_assert_atn.s delete mode 100644 c64/kernal/iec_assert_clk_and_data.s delete mode 100644 c64/kernal/iec_assert_clk_release_data.s delete mode 100644 c64/kernal/iec_assert_data.s create mode 100644 c64/kernal/iec_pull_atn_clk_release_data.s create mode 100644 c64/kernal/iec_pull_clk_releasee_data.s delete mode 100644 c64/kernal/iec_release_atn.s delete mode 100644 c64/kernal/iec_release_clk.s delete mode 100644 c64/kernal/iec_release_clk_and_data.s create mode 100644 c64/kernal/iec_release_clk_data.s create mode 100644 c64/kernal/iec_release_clk_pull_data.s create mode 100644 c64/kernal/iec_set_idle.s create mode 100644 c64/kernal/iec_wait100us.s delete mode 100644 c64/kernal/iec_wait_for_clock_assert.s delete mode 100644 c64/kernal/iec_wait_for_clock_release.s diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index d438620d..0d3ab8ab 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -117,3 +117,13 @@ .alias poke_under_roms tiny_nmi_handler+poke_under_roms_routine-tiny_nmi_handler_routine .alias memmap_allram tiny_nmi_handler+memmap_allram_routine-tiny_nmi_handler_routine .alias memmap_normal tiny_nmi_handler+memmap_normal_routine-tiny_nmi_handler_routine + + ;; CIA#2 - https://www.c64-wiki.com/wiki/CIA#CIA_2 + + .alias CI2PRA $DD00 ; VIC bank switching and IEC port + + .alias BIT_CI2PRA_ATN_OUT $08 ; 1 - low (pulled), 0 - high (released) + .alias BIT_CI2PRA_CLK_OUT $10 ; 1 - low (pulled), 0 - high (released) + .alias BIT_CI2PRA_DAT_OUT $20 ; 1 - low (pulled), 0 - high (released) + .alias BIT_CI2PRA_CLK_IN $40 ; 0 - low (pulled), 1 - high (released) + .alias BIT_CI2PRA_DAT_IN $80 ; 0 - low (pulled), 1 - high (released) diff --git a/c64/kernal/fda3.ioinit.s b/c64/kernal/fda3.ioinit.s index a63b91a6..2cadb1bc 100644 --- a/c64/kernal/fda3.ioinit.s +++ b/c64/kernal/fda3.ioinit.s @@ -39,4 +39,7 @@ ioinit: lda #$3b sta $dd02 + ;; Set IEC bus oto its initial idle state + jsr iec_set_idle + rts diff --git a/c64/kernal/iec_assert_atn.s b/c64/kernal/iec_assert_atn.s deleted file mode 100644 index 57560c3a..00000000 --- a/c64/kernal/iec_assert_atn.s +++ /dev/null @@ -1,5 +0,0 @@ -iec_assert_atn: - lda $dd00 - ora #$08 - sta $dd00 - rts diff --git a/c64/kernal/iec_assert_clk_and_data.s b/c64/kernal/iec_assert_clk_and_data.s deleted file mode 100644 index 7bb1242a..00000000 --- a/c64/kernal/iec_assert_clk_and_data.s +++ /dev/null @@ -1,6 +0,0 @@ -iec_assert_clk_and_data: - lda $dd00 - and #$0b - ora #$30 - sta $dd00 - rts diff --git a/c64/kernal/iec_assert_clk_release_data.s b/c64/kernal/iec_assert_clk_release_data.s deleted file mode 100644 index 2a33a4f8..00000000 --- a/c64/kernal/iec_assert_clk_release_data.s +++ /dev/null @@ -1,6 +0,0 @@ -iec_assert_clk_release_data: - lda $dd00 - and #$0b - ora #$10 - sta $dd00 - rts diff --git a/c64/kernal/iec_assert_data.s b/c64/kernal/iec_assert_data.s deleted file mode 100644 index 98ef4891..00000000 --- a/c64/kernal/iec_assert_data.s +++ /dev/null @@ -1,5 +0,0 @@ -iec_assert_data: - lda $dd00 - ora #$20 - sta $dd00 - rts diff --git a/c64/kernal/iec_pull_atn_clk_release_data.s b/c64/kernal/iec_pull_atn_clk_release_data.s new file mode 100644 index 00000000..07c98292 --- /dev/null +++ b/c64/kernal/iec_pull_atn_clk_release_data.s @@ -0,0 +1,7 @@ + +iec_pull_atn_clk_release_data: + lda CI2PRA + ora #BIT_CI2PRA_ATN_OUT + BIT_CI2PRA_CLK_OUT ; pull + and #$FF - BIT_CI2PRA_DAT_OUT ; release + sta CI2PRA + rts diff --git a/c64/kernal/iec_pull_clk_releasee_data.s b/c64/kernal/iec_pull_clk_releasee_data.s new file mode 100644 index 00000000..e37f6736 --- /dev/null +++ b/c64/kernal/iec_pull_clk_releasee_data.s @@ -0,0 +1,7 @@ + +iec_pull_clk_release_data: + lda CI2PRA + ora #BIT_CI2PRA_CLK_OUT ; pull + and #$FF - BIT_CI2PRA_DAT_OUT ; release + sta CI2PRA + rts diff --git a/c64/kernal/iec_release_atn.s b/c64/kernal/iec_release_atn.s deleted file mode 100644 index 12c63d02..00000000 --- a/c64/kernal/iec_release_atn.s +++ /dev/null @@ -1,11 +0,0 @@ -iec_release_atn: - lda $dd00 - and #$f7 - sta $dd00 - - ;; Also clear EOI marker - lda IOSTATUS - and #$bf - sta IOSTATUS - - rts diff --git a/c64/kernal/iec_release_clk.s b/c64/kernal/iec_release_clk.s deleted file mode 100644 index a261ee4d..00000000 --- a/c64/kernal/iec_release_clk.s +++ /dev/null @@ -1,5 +0,0 @@ -iec_release_clk: - lda $dd00 - and #$2b - sta $dd00 - rts diff --git a/c64/kernal/iec_release_clk_and_data.s b/c64/kernal/iec_release_clk_and_data.s deleted file mode 100644 index db554a6e..00000000 --- a/c64/kernal/iec_release_clk_and_data.s +++ /dev/null @@ -1,6 +0,0 @@ -iec_release_clk_and_data: - - lda $DD00 - and #$0b - sta $DD00 - rts diff --git a/c64/kernal/iec_release_clk_data.s b/c64/kernal/iec_release_clk_data.s new file mode 100644 index 00000000..65bbb7a7 --- /dev/null +++ b/c64/kernal/iec_release_clk_data.s @@ -0,0 +1,6 @@ + +iec_release_clk_data: + lda CI2PRA + and #$FF - BIT_CI2PRA_CLK_OUT - BIT_CI2PRA_DAT_OUT ; release + sta CI2PRA + rts diff --git a/c64/kernal/iec_release_clk_pull_data.s b/c64/kernal/iec_release_clk_pull_data.s new file mode 100644 index 00000000..ea4dd673 --- /dev/null +++ b/c64/kernal/iec_release_clk_pull_data.s @@ -0,0 +1,7 @@ + +iec_release_clk_pull_data: + lda CI2PRA + and #$FF - BIT_CI2PRA_CLK_OUT ; release + ora #BIT_CI2PRA_DAT_OUT ; pull + sta CI2PRA + rts diff --git a/c64/kernal/iec_rx_byte.s b/c64/kernal/iec_rx_byte.s index 9c7f6768..0646706d 100644 --- a/c64/kernal/iec_rx_byte.s +++ b/c64/kernal/iec_rx_byte.s @@ -3,112 +3,116 @@ ;; page 11. +;; XXX rework this, according to pagetable.com + iec_rx_byte: - ;; First, we wait for the talker to release the CLK line. - jsr iec_wait_for_clock_release - - ;; We then release the data line - ;; (We can use this routine, since we weren't holding CLK, anyway) - jsr iec_release_clk_and_data - - ;; Wait for talker to assert CLK. - ;; If >200usec, then it is EOI and we have to assert the - ;; DATA line for 60 usec to tell the TALKER that we have - ;; acknowledged the EOI. - ldx #20 -iec_rx_clk_wait: - ;; Loop takes 11 usec, so ~20 iterations for 200usec timeout - lda $dd00 - rol - bpl not_eoi - dex - cpx #$21 - bne not_rx_timeout - ;; Time out waiting for CLK to assert again. - ;; = error - sec rts + +; ;; First, we wait for the talker to release the CLK line. +; ;; XXX jsr iec_wait_for_clock_release + +; ;; We then release the data line +; ;; (We can use this routine, since we weren't holding CLK, anyway) +; jsr iec_release_clk_and_data + +; ;; Wait for talker to assert CLK. +; ;; If >200usec, then it is EOI and we have to assert the +; ;; DATA line for 60 usec to tell the TALKER that we have +; ;; acknowledged the EOI. +; ldx #20 +iec_rx_clk_wait: +; ;; Loop takes 11 usec, so ~20 iterations for 200usec timeout +; lda $dd00 +; rol +; bpl not_eoi +; dex +; cpx #$21 +; bne not_rx_timeout +; ;; Time out waiting for CLK to assert again. +; ;; = error +; sec +; rts not_rx_timeout: - cpx #$00 - bpl iec_rx_clk_wait +; cpx #$00 +; bpl iec_rx_clk_wait - ;; Remember EOI condition - lda IOSTATUS - ora #$40 - sta IOSTATUS +; ;; Remember EOI condition +; lda IOSTATUS +; ora #$40 +; sta IOSTATUS - ;; EOI timeout: So pulse DATA line for 60 usec - jsr iec_assert_data - jsr iec_wait60us - jsr iec_release_clk_and_data +; ;; EOI timeout: So pulse DATA line for 60 usec +; jsr iec_assert_data +; jsr iec_wait60us +; jsr iec_release_clk_and_data - ;; And still wait for CLK to be asserted - ;; XXX - This will cause periodic EOI pulses if the sender takes too long. - ;; That is probably ok. - ldx #$7f - jmp iec_rx_clk_wait +; ;; And still wait for CLK to be asserted +; ;; XXX - This will cause periodic EOI pulses if the sender takes too long. +; ;; That is probably ok. +; ldx #$7f +; jmp iec_rx_clk_wait not_eoi: - ;; CLK is now low. Latch input bits in on rising edge - ;; of CLK, eight times for eight bits. - ldx #7 +; ;; CLK is now low. Latch input bits in on rising edge +; ;; of CLK, eight times for eight bits. +; ldx #7 + +; ;; Get empty byte to load into. +; lda #$00 +; pha - ;; Get empty byte to load into. - lda #$00 - pha - iec_rx_bit_loop: - ;; Wait for CLK to release - ;; jsr iec_wait_for_clock_release - ;; (we do this implicitly below, with a tighter routine, - ;; so that we don't have timing problems, as the requirements - ;; are quite tight. Basically we need to read the clock and data - ;; bit from the same byte read. +; ;; Wait for CLK to release +; ;; jsr iec_wait_for_clock_release +; ;; (we do this implicitly below, with a tighter routine, +; ;; so that we don't have timing problems, as the requirements +; ;; are quite tight. Basically we need to read the clock and data +; ;; bit from the same byte read. - ;; DATA now has the next bit, but inverted (well, except that it turns out not to be). - ;; DATA is in bit7, which is a bit annoying. - ;; But we can clock it out with a ROL instruction - ;; so that it is in C. We can then ROR it into the - ;; partial data byte. - ;; We use ROR so that we shift in from the top, so that - ;; the first bit we shift in ends up in bit 0 after all - ;; 8 bits have been read. - ;; ODD: For some reason we don't need to invert the - ;; received bits. This is weird, because we invert them - ;; on the way out, and everything in the protocol seems - ;; to indicate that we sould do so. But experimentation - ;; has confirmed the bits don't need inversion on reception. - - ;; Move data bit into C flag, and loop until bit 6 clears - ;; i.e., the clock has been released. -* LDA $DD00 - ROL - bpl - - - ;; Pull it into the data byte - pla - ROR - pha +; ;; DATA now has the next bit, but inverted (well, except that it turns out not to be). +; ;; DATA is in bit7, which is a bit annoying. +; ;; But we can clock it out with a ROL instruction +; ;; so that it is in C. We can then ROR it into the +; ;; partial data byte. +; ;; We use ROR so that we shift in from the top, so that +; ;; the first bit we shift in ends up in bit 0 after all +; ;; 8 bits have been read. +; ;; ODD: For some reason we don't need to invert the +; ;; received bits. This is weird, because we invert them +; ;; on the way out, and everything in the protocol seems +; ;; to indicate that we sould do so. But experimentation +; ;; has confirmed the bits don't need inversion on reception. - ;; Wait for CLK to re-assert - jsr iec_wait_for_clock_assert +; ;; Move data bit into C flag, and loop until bit 6 clears +; ;; i.e., the clock has been released. +;* LDA $DD00 +; ROL +; bpl - - ;; More bits? - dex - bpl iec_rx_bit_loop +; ;; Pull it into the data byte +;; pla +; ROR +; pha - ;; Then we must within 1000usec acknowledge the frame by - ;; asserting DATA. At this point, CLK is asserted by the - ;; talker and DATA by us, i.e., we are ready to receive - ;; the next byte. (p11). - jsr iec_assert_data +; ;; Wait for CLK to re-assert +; jsr iec_wait_for_clock_assert - ;; Retreive the received byte - PLA +; ;; More bits? +; dex +; bpl iec_rx_bit_loop + +; ;; Then we must within 1000usec acknowledge the frame by +; ;; asserting DATA. At this point, CLK is asserted by the +; ;; talker and DATA by us, i.e., we are ready to receive +; ;; the next byte. (p11). +; jsr iec_assert_data + +; ;; Retreive the received byte +; PLA + +; ;; Return no-error +; CLC +; RTS - ;; Return no-error - CLC - RTS - diff --git a/c64/kernal/iec_set_idle.s b/c64/kernal/iec_set_idle.s new file mode 100644 index 00000000..dd936926 --- /dev/null +++ b/c64/kernal/iec_set_idle.s @@ -0,0 +1,7 @@ + +iec_set_idle: + lda CI2PRA + ora #BIT_CI2PRA_CLK_OUT ; pull + and #$FF - BIT_CI2PRA_DAT_OUT - BIT_CI2PRA_ATN_OUT ; release + sta CI2PRA + rts diff --git a/c64/kernal/iec_tx_byte.s b/c64/kernal/iec_tx_byte.s index 03f35c6d..365f38f0 100644 --- a/c64/kernal/iec_tx_byte.s +++ b/c64/kernal/iec_tx_byte.s @@ -1,87 +1,10 @@ -iec_tx_byte: + +;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc + +iec_tx_byte: pha - jsr iec_assert_clk_release_data - - ;; Give devices time to respond - jsr wait1ms - - ;; Did a device respond? (DATA will be pulled if so) - lda $DD00 - bpl + - - ;; No devices present, so we can immediately return with device not found - pla - jmp kernalerror_DEVICE_NOT_FOUND -* - - ;; Release CLK and wait for DATA to release. - jsr iec_release_clk_and_data - - ;; Wait for DATA to be released - ;; Listener is allowed to hold DATA for as long as they want. - ;; i.e., this is the part of the protocol where the listener indicates - ;; that they are busy doing something, like processing the previous - ;; character. - jsr iec_wait_for_data_release - - ;; We then wait for 60 usec (less than 200usec so we don't - ;; signal EOI), before asserting CLK again. - jsr iec_wait60us - - ;; Do the actual transmission of 8 bits of data - ldx #7 - - pla - -iec_tx_byte_nextbit: - ;; Is next bit 0 or 1? - lsr - pha - bcs + - - ;; Setup 0 - jsr iec_assert_clk_and_data - jmp iec_tx_byte_l1 -* - ;; Setup 1 - jsr iec_assert_clk_release_data -iec_tx_byte_l1: - ;; Clock bit out - jsr iec_wait20us - - jsr iec_release_clk - - jsr iec_wait20us - - ;; More bits to send? - pla - dex - bpl iec_tx_byte_nextbit - - ;; Done sending bits. Assert CLK and wait for acknowledgement - jsr iec_assert_clk_release_data - - ;; Acknowledgement must happen within 1ms, else it - ;; is DEVICE NOT PRESENT - ;; Acknowledgement consists of the DATA line being pulled - ;; by the listener. - ;; We can't easily count rasters here, so we just - ;; try a set number of times - ldx #$ff -* lda $DD00 - ;; BPL here is checking that bit 7 of $DD00 clears, - ;; i.e, that the DATA line is asserted. - bpl + - dex - bne - - - ;; Timeout - DEVICE NOT PRESENT - jmp kernalerror_DEVICE_NOT_FOUND -* - ;; All done. - ;; End state is TALKER is asserting CLK, and listener is asserting DATA - ;; until they are ready for the next byte. - clc +;; XXX to be filled-in rts + diff --git a/c64/kernal/iec_tx_command.s b/c64/kernal/iec_tx_command.s index eeba3b95..9e03974c 100644 --- a/c64/kernal/iec_tx_command.s +++ b/c64/kernal/iec_tx_command.s @@ -1,63 +1,5 @@ - -;; XXX - TEMPORARY IMPLEMENTATION - -;; https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc -;; https://www.c64-wiki.com/wiki/CIA#CIA_2 - -.alias CI2PRA $DD00 - -.alias BIT_IEC_ATN_OUT $08 ; 1 - low (pulled), 0 - high (released) -.alias BIT_IEC_CLK_OUT $10 ; 1 - low (pulled), 0 - high (released) -.alias BIT_IEC_DAT_OUT $20 ; 1 - low (pulled), 0 - high (released) -.alias BIT_IEC_CLK_IN $40 ; 0 - low (pulled), 1 - high (released) -.alias BIT_IEC_DAT_IN $80 ; 0 - low (pulled), 1 - high (released) - - -; XXX optimize these below - -xxx_to_idle_state: - lda CI2PRA - ora #BIT_IEC_CLK_OUT ; pull - and #$FF - BIT_IEC_DAT_OUT - BIT_IEC_ATN_OUT ; release - sta CI2PRA - rts - -xxx_pull_atn_clk_release_data: - lda CI2PRA - ora #BIT_IEC_ATN_OUT + BIT_IEC_CLK_OUT ; pull - and #$FF - BIT_IEC_DAT_OUT ; release - sta CI2PRA - rts - -xxx_pull_clk_release_data: - lda CI2PRA - ora #BIT_IEC_CLK_OUT ; pull - and #$FF - BIT_IEC_DAT_OUT ; release - sta CI2PRA - rts - -xxx_release_clk_data: - lda CI2PRA - and #$FF - BIT_IEC_CLK_OUT - BIT_IEC_DAT_OUT ; release - sta CI2PRA - rts - -xxx_release_clk_pull_data: - lda CI2PRA - and #$FF - BIT_IEC_CLK_OUT ; release - ora #BIT_IEC_DAT_OUT ; pull - sta CI2PRA - rts - -xxx_wait_for_data_release: - lda CI2PRA - ;; Check the highest bit, which is DATA IN, - ;; (highest bit set = negative value) - bpl xxx_wait_for_data_release - rts - - +;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc iec_tx_command: @@ -65,14 +7,14 @@ iec_tx_command: ;; Notify all devices that we are going to send a byte ;; and it is going to be a command (pulled ATN) - jsr xxx_pull_atn_clk_release_data + jsr iec_pull_atn_clk_release_data ;; Give devices time to respond (response is mandatory!) jsr wait1ms ;; Did at least one device respond by pulling DATA? lda CI2PRA - and #BIT_IEC_DAT_IN + and #BIT_CI2PRA_DAT_IN beq + ;; No devices present on the bus, so we can immediately return with device not found @@ -81,7 +23,7 @@ iec_tx_command: jsr printf .byte "DBG: NO DEVICES AT ALL", $0D, 0 - jsr xxx_to_idle_state + jsr iec_set_idle jmp kernalerror_DEVICE_NOT_FOUND * ;; At least one device responded, but they are still allowed to stall @@ -90,13 +32,13 @@ iec_tx_command: ;; - release back CLK, keep DATA released ;; - afterwards wait till all devices also release DATA - jsr xxx_release_clk_data - jsr xxx_wait_for_data_release + jsr iec_release_clk_data + jsr iec_wait_for_data_release ;; Pull CLK back to indicate that DATA is not valid, keep it for 60us ;; Don't wait too long, as 200us or more is considered EOI - jsr xxx_pull_clk_release_data + jsr iec_pull_clk_release_data jsr iec_wait60us ;; Now, we can start transmission of 8 bits of data @@ -110,11 +52,11 @@ iec_tx_command_nextbit: bcs + ;; Bit is 0 - jsr xxx_release_clk_pull_data + jsr iec_release_clk_pull_data jmp iec_tx_command_bitset * ;; Bit is 1 - jsr xxx_release_clk_data + jsr iec_release_clk_data iec_tx_command_bitset: @@ -122,7 +64,7 @@ iec_tx_command_bitset: jsr iec_wait20us ;; Pull CLK for 20us again - jsr xxx_pull_clk_release_data + jsr iec_pull_clk_release_data jsr iec_wait20us ;; More bits to send? @@ -145,7 +87,8 @@ iec_tx_command_bitset: bne - bpl iec_tx_command_done * - ;; XXX wait 100ms + ;; Wait 100us to give busy devices some time + jsr iec_wait100us iec_tx_command_done: diff --git a/c64/kernal/iec_wait100us.s b/c64/kernal/iec_wait100us.s new file mode 100644 index 00000000..7ecc57a5 --- /dev/null +++ b/c64/kernal/iec_wait100us.s @@ -0,0 +1,25 @@ + +iec_wait100us: + + ;; Wait 100usec + + ;; PAL: + ;; - CPU frequency 0.985248 MHz, we need to waste at least 102 cycles + ;; NTSC: + ;; - CPU frequency 1.022727 MHZ, we need to waste at least 98 cycles + + ;; Waste cycles by reading some unimportant memory location + ;; (in a loop) in order not to clutter VICE debug logs + + ;; Waste cycles in a loop + + ldy #$12 ; 2 cycles +* dey ; 2 cycles * 18 + bpl - ; 3 cycles * 17 + 2 cycles + rts ; 6 cycles + + ;; 6 cycles JSR to routine, + ;; 97 cycles routine with RTS + ;; 1 cycle to fetch next instruction + ;; --- + ;; 104 cycles diff --git a/c64/kernal/iec_wait20us.s b/c64/kernal/iec_wait20us.s index 8ea1962b..1d150264 100644 --- a/c64/kernal/iec_wait20us.s +++ b/c64/kernal/iec_wait20us.s @@ -1,7 +1,22 @@ -iec_wait20us: +iec_wait20us: + ;; Wait 20usec - ;; JSR + RTS already costs 12, so need only 8 more - ldy $dd01 ; reading dd00 makes debugging harder - ldy $dd01 - rts + + ;; PAL: + ;; - CPU frequency 0.985248 MHz, we need to waste at least 21 cycles + ;; NTSC: + ;; - CPU frequency 1.022727 MHZ, we need to waste at least 20 cycles + + ;; Waste cycles by reading some unimportant memory location + ;; in order not to clutter VICE debug logs + + ora $03FF ; 4 cycles + ora $03FF ; 4 cycles + rts ; 6 cycles + + ;; 6 cycles JSR to routine, + ;; 14 cycles routine with RTS + ;; 1 cycle to fetch next instruction + ;; --- + ;; 21 cycles diff --git a/c64/kernal/iec_wait60us.s b/c64/kernal/iec_wait60us.s index 7e158fb9..6e77d2b5 100644 --- a/c64/kernal/iec_wait60us.s +++ b/c64/kernal/iec_wait60us.s @@ -1,9 +1,23 @@ -iec_wait60us: - ;; Waste ~60 clock cycles (including JSR + RTS) - ldy #$06 -* lda $dd01 ; reading dd00 makes debugging harder - dey - bpl - +iec_wait60us: + + ;; Wait 60usec + + ;; PAL: + ;; - CPU frequency 0.985248 MHz, we need to waste at least 61 cycles + ;; NTSC: + ;; - CPU frequency 1.022727 MHZ, we need to waste at least 59 cycles + + ;; Waste cycles in a loop + + ldy #$0A ; 2 cycles +* dey ; 2 cycles * 10 + bpl - ; 3 cycles * 9 + 2 cycles + rts ; 6 cycles + + ;; 6 cycles JSR to routine, + ;; 57 cycles routine with RTS + ;; 1 cycle to fetch next instruction + ;; --- + ;; 64 cycles - rts diff --git a/c64/kernal/iec_wait_for_clock_assert.s b/c64/kernal/iec_wait_for_clock_assert.s deleted file mode 100644 index aa661af9..00000000 --- a/c64/kernal/iec_wait_for_clock_assert.s +++ /dev/null @@ -1,5 +0,0 @@ -iec_wait_for_clock_assert: - LDA $DD00 - and #$40 - bne iec_wait_for_clock_assert - rts diff --git a/c64/kernal/iec_wait_for_clock_release.s b/c64/kernal/iec_wait_for_clock_release.s deleted file mode 100644 index cb5d8c72..00000000 --- a/c64/kernal/iec_wait_for_clock_release.s +++ /dev/null @@ -1,5 +0,0 @@ -iec_wait_for_clock_release: - LDA $DD00 - and #$40 - beq iec_wait_for_clock_release - rts diff --git a/c64/kernal/iec_wait_for_data_release.s b/c64/kernal/iec_wait_for_data_release.s index 36232975..e54df9de 100644 --- a/c64/kernal/iec_wait_for_data_release.s +++ b/c64/kernal/iec_wait_for_data_release.s @@ -1,5 +1,7 @@ + iec_wait_for_data_release: - LDA $DD00 - and #$40 - beq iec_wait_for_data_release + lda CI2PRA + ;; Check the highest bit, which is DATA IN, + ;; (highest bit set = negative value) + bpl iec_wait_for_data_release rts diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 4a2ca7c8..29890c34 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -14,6 +14,9 @@ ;; $93 = kernal_load_or_verify_flag ;; $AC = current pointer for loading/verifying ;; $C1 = similar to the above. + +;; XXX rework this, according to pagetable.com + load: ;; Are we loading or verifying? @@ -47,17 +50,11 @@ print_filename_loop: lda #$0d jsr $ffd2 - ;; Begin sending under attention - jsr iec_assert_atn - ;; XXX - Use default device number ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf ;; p13, 16. ;; also p16 tells us this routine doesn't mess with the file table in the C64, ;; only in the drive. - - ;; Begin sending under attention - jsr iec_assert_atn ;; XXX - Use default device number ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf @@ -67,16 +64,15 @@ print_filename_loop: ;; Call device to LISTEN (p16) lda #$28 - jsr iec_tx_byte + jsr iec_tx_command bcs load_error ;; Open channel #0 (p16) lda #$f0 - jsr iec_tx_byte + jsr iec_tx_command bcs load_error - ;; (p16) - jsr iec_release_atn + jsr iec_set_idle ;; Send filename (p16) ldy #0 @@ -103,27 +99,24 @@ send_filename: sent_filename: ;; Command device to unlisten to indicate end of file name. (p16) - jsr iec_assert_atn lda #$3f - jsr iec_tx_byte + jsr iec_tx_command bcs load_error - jsr iec_release_atn + jsr iec_set_idle ;; Now command device to talk (p16) - jsr iec_assert_atn lda #$48 - jsr iec_tx_byte + jsr iec_tx_command bcs load_error lda #$60 ; open channel / data (p3) , required according to p13 - jsr iec_tx_byte + jsr iec_tx_command bcs load_error - jsr iec_release_atn ;; We are currently talker, so do the IEC turn around so that we ;; are the listener (p16) ;; An error here means FILE NOT FOUND ? - jsr iec_turnaround_to_listen + ;; XXX jsr iec_turnaround_to_listen bcs load_error ;; Get load address and store it if secondary address is zero @@ -133,7 +126,7 @@ sent_filename: beq + sta load_save_start_ptr+0 * - jsr iec_rx_byte + jsr iec_tx_command bcs file_not_found_error ldx current_secondary_address beq + @@ -178,17 +171,15 @@ load_done: ;; Close file on drive ;; Command drive to stop talking and to close the file - jsr iec_assert_atn lda #$5f - jsr iec_tx_byte + jsr iec_tx_command lda #$28 - jsr iec_tx_byte + jsr iec_tx_command lda #$e0 - jsr iec_tx_byte + jsr iec_tx_command ;; Tell drive to unlisten lda #$3f - jsr iec_tx_byte - jsr iec_release_atn + jsr iec_tx_command ;; Return last address written to +1 ;; (Even though Compute's Mapping the 64 says without the +1. diff --git a/c64/kernal/open.s b/c64/kernal/open.s index cf9b4389..2c043540 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -1,6 +1,7 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide ;; See also http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf +;; XXX rework this, according to pagetable.com open: From 28ce7e69bf70865a569f6629931203d74daafd5e Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 20 Jun 2019 12:49:44 +0200 Subject: [PATCH 21/90] more work on IEC - finished tx part rework --- .gitignore | 20 ++++++-- c64/kernal/iec_release_atn_clk_data.s | 7 +++ c64/kernal/iec_tx_byte.s | 13 ++++- c64/kernal/iec_tx_command.s | 61 ++-------------------- c64/kernal/iec_tx_common.s | 74 +++++++++++++++++++++++++++ c64/kernal/iec_tx_eoi.s | 11 ++++ 6 files changed, 125 insertions(+), 61 deletions(-) create mode 100644 c64/kernal/iec_release_atn_clk_data.s create mode 100644 c64/kernal/iec_tx_common.s create mode 100644 c64/kernal/iec_tx_eoi.s diff --git a/.gitignore b/.gitignore index 797051dc..a28e5087 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,26 @@ + +# Intermediate compilation files + c64/basic/combined.s c64/kernal/combined.s temp.s temp.map -newbasic -newkern -newrom + src/compress_text +src/pngprepare src/preprocess ophis.bin c64/basic/OUT.BIN c64/kernal/OUT.BIN -*project +# Compilation output + +chargen +newbasic +newkern +newrom + +# Various IDE project files, temporary files, etc. + +*project +.*swp diff --git a/c64/kernal/iec_release_atn_clk_data.s b/c64/kernal/iec_release_atn_clk_data.s new file mode 100644 index 00000000..c35af0da --- /dev/null +++ b/c64/kernal/iec_release_atn_clk_data.s @@ -0,0 +1,7 @@ + +iec_release_atn_clk_data: + lda CI2PRA + and #$FF - BIT_CI2PRA_ATN_OUT - BIT_CI2PRA_CLK_OUT - BIT_CI2PRA_DAT_OUT ; release + sta CI2PRA + rts + diff --git a/c64/kernal/iec_tx_byte.s b/c64/kernal/iec_tx_byte.s index 365f38f0..ed1b0b7a 100644 --- a/c64/kernal/iec_tx_byte.s +++ b/c64/kernal/iec_tx_byte.s @@ -5,6 +5,17 @@ iec_tx_byte: pha -;; XXX to be filled-in + ;; Notify all devices that we are going to send a byte + ;; and it is going to be a data byte (released ATN) + jsr iec_release_atn_clk_data + + ;; Common part of iec_txbyte and iec_tx_common - waits for devices + ;; and transmits a byte + + pla + jsr iec_tx_common + + ;; All done + clc rts diff --git a/c64/kernal/iec_tx_command.s b/c64/kernal/iec_tx_command.s index 9e03974c..d8f4f795 100644 --- a/c64/kernal/iec_tx_command.s +++ b/c64/kernal/iec_tx_command.s @@ -29,68 +29,17 @@ iec_tx_command: ;; At least one device responded, but they are still allowed to stall ;; (can be busy processing something), we have to wait till they are all ;; ready (or bored with DOS attack...) - ;; - release back CLK, keep DATA released - ;; - afterwards wait till all devices also release DATA + ;; Release back CLK, keep DATA released - to ask devices for status. jsr iec_release_clk_data - jsr iec_wait_for_data_release - ;; Pull CLK back to indicate that DATA is not valid, keep it for 60us - ;; Don't wait too long, as 200us or more is considered EOI - - jsr iec_pull_clk_release_data - jsr iec_wait60us - - ;; Now, we can start transmission of 8 bits of data - ldx #7 - pla - -iec_tx_command_nextbit: - ;; Is next bit 0 or 1? - lsr - pha - bcs + - - ;; Bit is 0 - jsr iec_release_clk_pull_data - jmp iec_tx_command_bitset -* - ;; Bit is 1 - jsr iec_release_clk_data + ;; Common part of iec_txbyte and iec_tx_common - waits for devices + ;; and transmits a byte -iec_tx_command_bitset: - - ;; Wait 20us, so that device(s) can pick DATA - jsr iec_wait20us - - ;; Pull CLK for 20us again - jsr iec_pull_clk_release_data - jsr iec_wait20us - - ;; More bits to send? pla - dex - bpl iec_tx_command_nextbit + jsr iec_tx_common - ;; XXX the flow below is REALLY dangerous, as if there are multiple devices, - ;; one can signal that it's busy much earlier (more than 100ms) than the other. - ;; Can we do something about it? - - ;; All done - give devices time to tell if they are busy by pulling DATA - ;; They should do it within 1ms - ldx #$FF -* lda CI2PRA - ;; BPL here is checking that bit 7 of $DD00 clears, - ;; i.e, that the DATA line is pulled by drive - bpl + - dex - bne - - bpl iec_tx_command_done -* - ;; Wait 100us to give busy devices some time - jsr iec_wait100us - -iec_tx_command_done: + ;; All done clc rts diff --git a/c64/kernal/iec_tx_common.s b/c64/kernal/iec_tx_common.s new file mode 100644 index 00000000..05565b80 --- /dev/null +++ b/c64/kernal/iec_tx_common.s @@ -0,0 +1,74 @@ + +;; This is a common part of iec_tx_byte and iec_tx_command +;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc + +iec_tx_common: + + ;; Store the bye to send on a stack + pha + + ;; Wait till all receivers are ready, they should all release DATA + jsr iec_wait_for_data_release + + ;; Pull CLK back to indicate that DATA is not valid, keep it for 60us + ;; Don't wait too long, as 200us or more is considered EOI + + jsr iec_pull_clk_release_data + jsr iec_wait60us + + ;; Now, we can start transmission of 8 bits of data + ldx #7 + pla + +iec_tx_common_sendbit: + ;; Is next bit 0 or 1? + lsr + pha + bcs + + + ;; Bit is 0 + jsr iec_release_clk_pull_data + jmp iec_tx_common_bit_is_sent +* + ;; Bit is 1 + jsr iec_release_clk_data + +iec_tx_common_bit_is_sent: + + ;; Wait 20us, so that device(s) can pick DATA + jsr iec_wait20us + + ;; More bits to send? + pla + dex + bpl iec_tx_common_nextbit + + ;; XXX the flow below is REALLY dangerous, as if there are multiple devices, + ;; one can signal that it's busy much earlier (more than 100ms) than the other. + ;; Can we do something about it? + + ;; All done - give devices time to tell if they are busy by pulling DATA + ;; They should do it within 1ms + ldx #$FF +* lda CI2PRA + ;; BPL here is checking that bit 7 of $DD00 clears, + ;; i.e, that the DATA line is pulled by drive + bpl + + dex + bne - + bpl iec_tx_common_done +* + ;; Wait 100us to give busy devices some time + jsr iec_wait100us + +iec_tx_common_done: + ;; Byte sent, return + rts + +iec_tx_common_nextbit: + + ;; Pull CLK for 20us again, before + jsr iec_pull_clk_release_data + jsr iec_wait20us + + jmp iec_tx_common_sendbit diff --git a/c64/kernal/iec_tx_eoi.s b/c64/kernal/iec_tx_eoi.s new file mode 100644 index 00000000..bb7e3d6d --- /dev/null +++ b/c64/kernal/iec_tx_eoi.s @@ -0,0 +1,11 @@ + +iec_tx_eoi: + + ;; Wait at least 200us + jsr iec_wait100us + jsr iec_wait100us + + ;; Restore the bus to idle state + jsr iec_set_idle + + rts From 5f57f58163586f7c10e2065c98abc1cfe2b7788d Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 20 Jun 2019 16:49:35 +0200 Subject: [PATCH 22/90] fixes for IEC --- c64/kernal/iec_pull_data_release_atn_clock.s | 7 + c64/kernal/iec_rx_byte.s | 181 +++++++++---------- c64/kernal/iec_turnaround_to_listen.s | 50 ++--- c64/kernal/iec_tx_command.s | 2 +- c64/kernal/iec_tx_common.s | 14 +- c64/kernal/iec_tx_eoi.s | 3 +- c64/kernal/iec_wait100us.s | 4 +- c64/kernal/iec_wait20us.s | 4 +- c64/kernal/iec_wait60us.s | 4 +- c64/kernal/iec_wait_for_clk_pull.s | 6 + c64/kernal/iec_wait_for_clk_release.s | 6 + c64/kernal/open.s | 28 +-- c64/kernal/tksa.s | 9 + 13 files changed, 167 insertions(+), 151 deletions(-) create mode 100644 c64/kernal/iec_pull_data_release_atn_clock.s create mode 100644 c64/kernal/iec_wait_for_clk_pull.s create mode 100644 c64/kernal/iec_wait_for_clk_release.s diff --git a/c64/kernal/iec_pull_data_release_atn_clock.s b/c64/kernal/iec_pull_data_release_atn_clock.s new file mode 100644 index 00000000..0e8822da --- /dev/null +++ b/c64/kernal/iec_pull_data_release_atn_clock.s @@ -0,0 +1,7 @@ + +iec_pull_data_release_atn_clock: + lda CI2PRA + ora #BIT_CI2PRA_DAT_OUT ; pull + and #$FF - BIT_CI2PRA_ATN_OUT - BIT_CI2PRA_CLK_OUT ; release + sta CI2PRA + rts diff --git a/c64/kernal/iec_rx_byte.s b/c64/kernal/iec_rx_byte.s index 0646706d..8caf8392 100644 --- a/c64/kernal/iec_rx_byte.s +++ b/c64/kernal/iec_rx_byte.s @@ -1,118 +1,103 @@ ;; Receive a byte from the IEC bus. - ;; reference http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf - ;; page 11. - - -;; XXX rework this, according to pagetable.com + ;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc, + ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf (page 11) iec_rx_byte: + ;; First, we wait for the talker to release the CLK line + jsr iec_wait_for_clk_release + + ;; We then release the DATA to signal we are ready + ;; We can use this routine, since we weren't pulling CLK anyway + jsr iec_release_clk_data + + ;; Wait for talker to pull CLK. + ;; If over 200 usec (205 cycles on NTSC machine) , then it is EOI. + ;; Loop iteraction takes 13 cycles, 17 full iterations are enough + + ldx #$11 ; 2 cycles +iec_rx_clk_wait: + lda CI2PRA ; 4 cycles + rol ; 2 cycles, to put BIT_CI2PRA_CLK_IN as the last bit + bpl iec_rx_not_eoi ; 2 cycles if not jumped + dex ; 2 cycles + bne iec_rx_clk_wait ; 3 cycles if jumped + + ;; Timeout - wait for pulled CLK and pull data for 60 usec to confirm + jsr iec_wait_for_clk_pull + jsr iec_release_clk_pull_data + jsr iec_wait60us + jsr iec_release_clk_data + + ;; Store EOI information in IOSTATUS - XXX this should be done by the caller! + lda IOSTATUS + ora #$40 + sta IOSTATUS + + sec rts -; ;; First, we wait for the talker to release the CLK line. -; ;; XXX jsr iec_wait_for_clock_release +iec_rx_not_eoi: -; ;; We then release the data line -; ;; (We can use this routine, since we weren't holding CLK, anyway) -; jsr iec_release_clk_and_data + ;; Latch input bits in on rising edge of CLK, eight times for eight bits. + ldx #7 -; ;; Wait for talker to assert CLK. -; ;; If >200usec, then it is EOI and we have to assert the -; ;; DATA line for 60 usec to tell the TALKER that we have -; ;; acknowledged the EOI. -; ldx #20 -iec_rx_clk_wait: -; ;; Loop takes 11 usec, so ~20 iterations for 200usec timeout -; lda $dd00 -; rol -; bpl not_eoi -; dex -; cpx #$21 -; bne not_rx_timeout -; ;; Time out waiting for CLK to assert again. -; ;; = error -; sec -; rts -not_rx_timeout: -; cpx #$00 -; bpl iec_rx_clk_wait - -; ;; Remember EOI condition -; lda IOSTATUS -; ora #$40 -; sta IOSTATUS - -; ;; EOI timeout: So pulse DATA line for 60 usec -; jsr iec_assert_data -; jsr iec_wait60us -; jsr iec_release_clk_and_data - -; ;; And still wait for CLK to be asserted -; ;; XXX - This will cause periodic EOI pulses if the sender takes too long. -; ;; That is probably ok. -; ldx #$7f -; jmp iec_rx_clk_wait - -not_eoi: -; ;; CLK is now low. Latch input bits in on rising edge -; ;; of CLK, eight times for eight bits. -; ldx #7 - -; ;; Get empty byte to load into. -; lda #$00 -; pha + ;; Get empty byte to load into. + lda #$00 + pha iec_rx_bit_loop: -; ;; Wait for CLK to release -; ;; jsr iec_wait_for_clock_release -; ;; (we do this implicitly below, with a tighter routine, -; ;; so that we don't have timing problems, as the requirements -; ;; are quite tight. Basically we need to read the clock and data -; ;; bit from the same byte read. + ;; Wait for CLK to release + jsr iec_wait_for_clk_release -; ;; DATA now has the next bit, but inverted (well, except that it turns out not to be). -; ;; DATA is in bit7, which is a bit annoying. -; ;; But we can clock it out with a ROL instruction -; ;; so that it is in C. We can then ROR it into the -; ;; partial data byte. -; ;; We use ROR so that we shift in from the top, so that -; ;; the first bit we shift in ends up in bit 0 after all -; ;; 8 bits have been read. -; ;; ODD: For some reason we don't need to invert the -; ;; received bits. This is weird, because we invert them -; ;; on the way out, and everything in the protocol seems -; ;; to indicate that we sould do so. But experimentation -; ;; has confirmed the bits don't need inversion on reception. + ;; (we do this implicitly below, with a tighter routine, + ;; so that we don't have timing problems, as the requirements + ;; are quite tight. Basically we need to read the clock and data + ;; bit from the same byte read. -; ;; Move data bit into C flag, and loop until bit 6 clears -; ;; i.e., the clock has been released. -;* LDA $DD00 -; ROL -; bpl - + ;; DATA now has the next bit, but inverted (well, except that it turns out not to be). + ;; DATA is in bit 7, which is a bit annoying. + ;; But we can clock it out with a ROL instruction + ;; so that it is in C. We can then ROR it into the + ;; partial data byte. + ;; We use ROR so that we shift in from the top, so that + ;; the first bit we shift in ends up in bit 0 after all + ;; 8 bits have been read. + ;; ODD: For some reason we don't need to invert the + ;; received bits. This is weird, because we invert them + ;; on the way out, and everything in the protocol seems + ;; to indicate that we sould do so. But experimentation + ;; has confirmed the bits don't need inversion on reception. -; ;; Pull it into the data byte -;; pla -; ROR -; pha + ;; Move data bit into C flag, and loop until bit 6 clears + ;; i.e., the clock has been released. +* lda CI2PRA + rol + bpl - -; ;; Wait for CLK to re-assert -; jsr iec_wait_for_clock_assert + ;; Pull it into the data byte + pla + ror + pha -; ;; More bits? -; dex -; bpl iec_rx_bit_loop + ;; Wait for CLK to be pulled again + jsr iec_wait_for_clk_pull -; ;; Then we must within 1000usec acknowledge the frame by -; ;; asserting DATA. At this point, CLK is asserted by the -; ;; talker and DATA by us, i.e., we are ready to receive -; ;; the next byte. (p11). -; jsr iec_assert_data + ;; More bits? + dex + bpl iec_rx_bit_loop -; ;; Retreive the received byte -; PLA + ;; Then we must within 1000 usec acknowledge the frame by + ;; pulling DATA. At this point, CLK is pulled by the + ;; talker and DATA by us, i.e., we are ready to receive + ;; the next byte. (p11). + jsr iec_release_clk_pull_data -; ;; Return no-error -; CLC -; RTS + ;; Retreive the received byte + pla + + ;; Return no-error + clc + rts diff --git a/c64/kernal/iec_turnaround_to_listen.s b/c64/kernal/iec_turnaround_to_listen.s index b65565b7..dcb4f635 100644 --- a/c64/kernal/iec_turnaround_to_listen.s +++ b/c64/kernal/iec_turnaround_to_listen.s @@ -1,39 +1,29 @@ ;; According to http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf ;; pages 7--8. - + ;; See also https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc + iec_turnaround_to_listen: - ;; Assert data and release clock - lda $dd00 - and #$ef ; release clock (bit 4) - ora #$20 ; assert data (bit 5) - sta $dd00 - - ;; Wait for clock line to be asserted by the drive -* lda $dd00 - and #$40 + ;; Pull DATA, release CLK and ATN (we are not sending commands) + jsr iec_pull_data_release_atn_clock + + ;; Wait for clock line to be pulled by the drive + ldx #$FF ; XXX should we really use that high number? +* + lda CI2PRA + rol ; to put BIT_CI2PRA_CLK_IN as the last (sign) bit + bpl + + dex bne - - ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf - ;; page 8 tells us we should not do anything here after waiting for - ;; the clock line to assert. - - ldx #$ff - * lda $dd00 - and #$40 - bne + - dex - bne - + ;; Timeout + jsr printf + .byte "DBG: TURNAROUND FAILED",$0d,$00 + sec + rts - ;; jsr printf - ;; .byte "TURNAROUND FAILED - FILE NOT FOUND?",$0d,$00 - - ;; ;; Timeout = file not found error - ;; ;; (https://www.pagetable.com/?p=1023) - lda #4 - sec - rts -* - ;; ATN turn around successful + ;; CLK is pulled by the device, OK +* clc rts + diff --git a/c64/kernal/iec_tx_command.s b/c64/kernal/iec_tx_command.s index d8f4f795..690fd5a5 100644 --- a/c64/kernal/iec_tx_command.s +++ b/c64/kernal/iec_tx_command.s @@ -35,7 +35,7 @@ iec_tx_command: ;; Common part of iec_txbyte and iec_tx_common - waits for devices ;; and transmits a byte - + pla jsr iec_tx_common diff --git a/c64/kernal/iec_tx_common.s b/c64/kernal/iec_tx_common.s index 05565b80..17a9fcf4 100644 --- a/c64/kernal/iec_tx_common.s +++ b/c64/kernal/iec_tx_common.s @@ -6,11 +6,12 @@ iec_tx_common: ;; Store the bye to send on a stack pha - + ;; Wait till all receivers are ready, they should all release DATA jsr iec_wait_for_data_release - + ;; Pull CLK back to indicate that DATA is not valid, keep it for 60us + ;; We can use this routine as we don't hold DATA anyway (and its state doesn't even matter) ;; Don't wait too long, as 200us or more is considered EOI jsr iec_pull_clk_release_data @@ -42,11 +43,14 @@ iec_tx_common_bit_is_sent: pla dex bpl iec_tx_common_nextbit - + + ;; Whole byte send, make sure ATN is released + jsr iec_release_atn_clk_data + ;; XXX the flow below is REALLY dangerous, as if there are multiple devices, ;; one can signal that it's busy much earlier (more than 100ms) than the other. ;; Can we do something about it? - + ;; All done - give devices time to tell if they are busy by pulling DATA ;; They should do it within 1ms ldx #$FF @@ -62,7 +66,9 @@ iec_tx_common_bit_is_sent: jsr iec_wait100us iec_tx_common_done: + ;; Byte sent, return + clc rts iec_tx_common_nextbit: diff --git a/c64/kernal/iec_tx_eoi.s b/c64/kernal/iec_tx_eoi.s index bb7e3d6d..76169af3 100644 --- a/c64/kernal/iec_tx_eoi.s +++ b/c64/kernal/iec_tx_eoi.s @@ -1,9 +1,10 @@ iec_tx_eoi: - ;; Wait at least 200us + ;; Wait at least 256 usec jsr iec_wait100us jsr iec_wait100us + jsr iec_wait60us ;; Restore the bus to idle state jsr iec_set_idle diff --git a/c64/kernal/iec_wait100us.s b/c64/kernal/iec_wait100us.s index 7ecc57a5..7ccfee98 100644 --- a/c64/kernal/iec_wait100us.s +++ b/c64/kernal/iec_wait100us.s @@ -4,9 +4,9 @@ iec_wait100us: ;; Wait 100usec ;; PAL: - ;; - CPU frequency 0.985248 MHz, we need to waste at least 102 cycles + ;; - CPU frequency 0.985248 MHz, we need to waste at least 99 cycles ;; NTSC: - ;; - CPU frequency 1.022727 MHZ, we need to waste at least 98 cycles + ;; - CPU frequency 1.022727 MHZ, we need to waste at least 103 cycles ;; Waste cycles by reading some unimportant memory location ;; (in a loop) in order not to clutter VICE debug logs diff --git a/c64/kernal/iec_wait20us.s b/c64/kernal/iec_wait20us.s index 1d150264..3ea1349f 100644 --- a/c64/kernal/iec_wait20us.s +++ b/c64/kernal/iec_wait20us.s @@ -4,9 +4,9 @@ iec_wait20us: ;; Wait 20usec ;; PAL: - ;; - CPU frequency 0.985248 MHz, we need to waste at least 21 cycles + ;; - CPU frequency 0.985248 MHz, we need to waste at least 20 cycles ;; NTSC: - ;; - CPU frequency 1.022727 MHZ, we need to waste at least 20 cycles + ;; - CPU frequency 1.022727 MHZ, we need to waste at least 21 cycles ;; Waste cycles by reading some unimportant memory location ;; in order not to clutter VICE debug logs diff --git a/c64/kernal/iec_wait60us.s b/c64/kernal/iec_wait60us.s index 6e77d2b5..0f6cd957 100644 --- a/c64/kernal/iec_wait60us.s +++ b/c64/kernal/iec_wait60us.s @@ -4,9 +4,9 @@ iec_wait60us: ;; Wait 60usec ;; PAL: - ;; - CPU frequency 0.985248 MHz, we need to waste at least 61 cycles + ;; - CPU frequency 0.985248 MHz, we need to waste at least 60 cycles ;; NTSC: - ;; - CPU frequency 1.022727 MHZ, we need to waste at least 59 cycles + ;; - CPU frequency 1.022727 MHZ, we need to waste at least 62 cycles ;; Waste cycles in a loop diff --git a/c64/kernal/iec_wait_for_clk_pull.s b/c64/kernal/iec_wait_for_clk_pull.s new file mode 100644 index 00000000..590903d1 --- /dev/null +++ b/c64/kernal/iec_wait_for_clk_pull.s @@ -0,0 +1,6 @@ + +iec_wait_for_clk_pull: + lda CI2PRA + rol ; to put BIT_CI2PRA_CLK_IN as the last (sign) bit + bmi iec_wait_for_clk_pull + rts diff --git a/c64/kernal/iec_wait_for_clk_release.s b/c64/kernal/iec_wait_for_clk_release.s new file mode 100644 index 00000000..6139dd1d --- /dev/null +++ b/c64/kernal/iec_wait_for_clk_release.s @@ -0,0 +1,6 @@ + +iec_wait_for_clk_release: + lda CI2PRA + and #BIT_CI2PRA_CLK_IN + beq iec_wait_for_clk_release + rts diff --git a/c64/kernal/open.s b/c64/kernal/open.s index 2c043540..a522c778 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -15,9 +15,6 @@ open: bcs + bmi open_has_space * - jsr printf - .byte "FULL", $0D, 0 - ;; Table is full - according to https://codebase64.org/doku.php?id=base:kernalreference ;; C flag set means error occured sec @@ -74,11 +71,9 @@ open_rs232: open_iec: - ;; XXX add FILENAM support, test it + ;; Part implemented according to https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc - ;; Sequence is: - ;; 1. Call current device to attention as LISTENER = $20 + device - ;; 2. + ;; XXX for now for channel 15 only! ;; Disable IRQs, since timing matters! sei @@ -86,14 +81,25 @@ open_iec: ;; Begin sending under attention ;; XXX jsr iec_assert_atn - ;; CLK is now asserted, and we are ready to transmit a byte + ;; Request device to talk lda current_device_number - jsr listen - bcs open_iec_error + jsr talk + bcs open_iec_error ; XXX what about the accumulator? + + jsr printf + .byte "DBG: OPEN 1", $0D, 0 + + ;; Send secondary address + lda current_secondary_address + jsr tksa + bcs open_iec_error ; XXX what about the accumulator? + + jsr printf + .byte "DBG: OPEN 2", $0D, 0 ;; Indicate success lda #$00 - clc + clc open_iec_error: ;; Re-enable interrupts and return diff --git a/c64/kernal/tksa.s b/c64/kernal/tksa.s index 4b599d45..74b2030c 100644 --- a/c64/kernal/tksa.s +++ b/c64/kernal/tksa.s @@ -1,3 +1,12 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide tksa: + + ;; This routine is documented in 'C64 Programmer's Reference Guide', page 302 and + ;; https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc + ora #$F0 + jsr iec_tx_command + bcs tksa_error + jmp iec_turnaround_to_listen + +tksa_error: rts From 56f6dbfd3d226aea73101b0fac435e88f0fd53a7 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 20 Jun 2019 17:40:06 +0200 Subject: [PATCH 23/90] fix for wrong bits sent in iec_tx_common --- c64/kernal/iec_tx_common.s | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/c64/kernal/iec_tx_common.s b/c64/kernal/iec_tx_common.s index 17a9fcf4..7d75892b 100644 --- a/c64/kernal/iec_tx_common.s +++ b/c64/kernal/iec_tx_common.s @@ -40,9 +40,9 @@ iec_tx_common_bit_is_sent: jsr iec_wait20us ;; More bits to send? - pla dex bpl iec_tx_common_nextbit + pla ;; Whole byte send, make sure ATN is released jsr iec_release_atn_clk_data @@ -77,4 +77,5 @@ iec_tx_common_nextbit: jsr iec_pull_clk_release_data jsr iec_wait20us + pla jmp iec_tx_common_sendbit From 339ae0335fdc7ebb1c11da588c60c52858ec3dc2 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 20 Jun 2019 17:59:29 +0200 Subject: [PATCH 24/90] fixed timing in iec_tx_common --- c64/kernal/iec_tx_common.s | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/c64/kernal/iec_tx_common.s b/c64/kernal/iec_tx_common.s index 7d75892b..ca5fb247 100644 --- a/c64/kernal/iec_tx_common.s +++ b/c64/kernal/iec_tx_common.s @@ -38,6 +38,11 @@ iec_tx_common_bit_is_sent: ;; Wait 20us, so that device(s) can pick DATA jsr iec_wait20us + + ;; Pull CLK for 20us again, before sending the next bit + ;; or performing any other action + jsr iec_pull_clk_release_data + jsr iec_wait20us ;; More bits to send? dex @@ -73,9 +78,5 @@ iec_tx_common_done: iec_tx_common_nextbit: - ;; Pull CLK for 20us again, before - jsr iec_pull_clk_release_data - jsr iec_wait20us - pla jmp iec_tx_common_sendbit From 5ae749b552729a459818c27163e4ec15293a6101 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 21 Jun 2019 18:33:42 +0200 Subject: [PATCH 25/90] work on IEC - no auto turnaround --- c64/kernal/open.s | 13 ++++++++++--- c64/kernal/tksa.s | 8 ++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/c64/kernal/open.s b/c64/kernal/open.s index a522c778..a28e438d 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -72,8 +72,8 @@ open_rs232: open_iec: ;; Part implemented according to https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc - - ;; XXX for now for channel 15 only! + ;; XXX note: this is only a temporary test implementation, real 'open' does not send anything to IEC, + ;; see http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf ;; Disable IRQs, since timing matters! sei @@ -91,12 +91,19 @@ open_iec: ;; Send secondary address lda current_secondary_address - jsr tksa + jsr second bcs open_iec_error ; XXX what about the accumulator? jsr printf .byte "DBG: OPEN 2", $0D, 0 + ;; Turnaround + jsr iec_turnaround_to_listen + bcs open_iec_error ; XXX what about the accumulator? + + jsr printf + .byte "DBG: OPEN 3 - DEVICE EXISTS", $0D, 0 + ;; Indicate success lda #$00 clc diff --git a/c64/kernal/tksa.s b/c64/kernal/tksa.s index 74b2030c..49bca787 100644 --- a/c64/kernal/tksa.s +++ b/c64/kernal/tksa.s @@ -4,9 +4,5 @@ tksa: ;; This routine is documented in 'C64 Programmer's Reference Guide', page 302 and ;; https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc ora #$F0 - jsr iec_tx_command - bcs tksa_error - jmp iec_turnaround_to_listen - -tksa_error: - rts + jmp iec_tx_command + From b21ce3116d38ac65e86ccfe818118a8a20bee0af Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 21 Jun 2019 21:47:39 +0200 Subject: [PATCH 26/90] more IEC work - iec_tx_command can now detect missing devices --- ...see_data.s => iec_pull_clk_release_data.s} | 0 c64/kernal/iec_tx_byte.s | 19 ++++++++++++- c64/kernal/iec_tx_command.s | 24 ++++++++++++++-- c64/kernal/iec_tx_common.s | 28 ++----------------- c64/kernal/open.s | 14 +++------- 5 files changed, 46 insertions(+), 39 deletions(-) rename c64/kernal/{iec_pull_clk_releasee_data.s => iec_pull_clk_release_data.s} (100%) diff --git a/c64/kernal/iec_pull_clk_releasee_data.s b/c64/kernal/iec_pull_clk_release_data.s similarity index 100% rename from c64/kernal/iec_pull_clk_releasee_data.s rename to c64/kernal/iec_pull_clk_release_data.s diff --git a/c64/kernal/iec_tx_byte.s b/c64/kernal/iec_tx_byte.s index ed1b0b7a..c422f270 100644 --- a/c64/kernal/iec_tx_byte.s +++ b/c64/kernal/iec_tx_byte.s @@ -14,8 +14,25 @@ iec_tx_byte: pla jsr iec_tx_common - + + ;; All done - give device time to tell if they are busy by pulling DATA + ;; They should do it within 1ms + ldx #$FF +* lda CI2PRA + ;; BPL here is checking that bit 7 of $DD00 clears, + ;; i.e, that the DATA line is pulled by drive + bpl + + dex + bne - + bpl iec_tx_byte_error +* ;; All done clc rts +iec_tx_byte_error: + + jsr iec_set_idle + jmp kernalerror_DEVICE_NOT_FOUND + + diff --git a/c64/kernal/iec_tx_command.s b/c64/kernal/iec_tx_command.s index 690fd5a5..ca50f4a2 100644 --- a/c64/kernal/iec_tx_command.s +++ b/c64/kernal/iec_tx_command.s @@ -14,7 +14,7 @@ iec_tx_command: ;; Did at least one device respond by pulling DATA? lda CI2PRA - and #BIT_CI2PRA_DAT_IN + and #BIT_CI2PRA_DAT_IN ; XXX try to optimize this, move to separate routine beq + ;; No devices present on the bus, so we can immediately return with device not found @@ -39,7 +39,27 @@ iec_tx_command: pla jsr iec_tx_common - ;; All done + ;; According to https://www.pagetable.com/?p=1135 there is some complicated and dangerous + ;; flow here, but http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf (page 6) + ;; advices to just wait 1ms and check the DATA status + jsr wait1ms + lda CI2PRA + and #BIT_CI2PRA_DAT_IN ; XXX try to optimize this, move to separate routine + beq + + + ;; XXX possible optimization of the flow above: for many commands it is enough + ;; to wait for the DATA being pulled, as confirmation is expected from + ;; a single device only - but not sure if it's worth the trouble + + jsr printf + .byte "DBG: NO CONFIRMATION FROM DEVICE", $0D, 0 + + jsr iec_set_idle + jmp kernalerror_DEVICE_NOT_FOUND +* + ;; All done - before exiting wait a moment and restore bus to idle state + jsr iec_wait20us + jsr iec_set_idle clc rts diff --git a/c64/kernal/iec_tx_common.s b/c64/kernal/iec_tx_common.s index ca5fb247..73753f72 100644 --- a/c64/kernal/iec_tx_common.s +++ b/c64/kernal/iec_tx_common.s @@ -1,6 +1,7 @@ ;; This is a common part of iec_tx_byte and iec_tx_command ;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc +;; and http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf iec_tx_common: @@ -48,33 +49,8 @@ iec_tx_common_bit_is_sent: dex bpl iec_tx_common_nextbit pla - - ;; Whole byte send, make sure ATN is released - jsr iec_release_atn_clk_data - - ;; XXX the flow below is REALLY dangerous, as if there are multiple devices, - ;; one can signal that it's busy much earlier (more than 100ms) than the other. - ;; Can we do something about it? - ;; All done - give devices time to tell if they are busy by pulling DATA - ;; They should do it within 1ms - ldx #$FF -* lda CI2PRA - ;; BPL here is checking that bit 7 of $DD00 clears, - ;; i.e, that the DATA line is pulled by drive - bpl + - dex - bne - - bpl iec_tx_common_done -* - ;; Wait 100us to give busy devices some time - jsr iec_wait100us - -iec_tx_common_done: - - ;; Byte sent, return - clc - rts + rts ; Flow continues differently for data/command iec_tx_common_nextbit: diff --git a/c64/kernal/open.s b/c64/kernal/open.s index a28e438d..e10ea78e 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -84,25 +84,19 @@ open_iec: ;; Request device to talk lda current_device_number jsr talk - bcs open_iec_error ; XXX what about the accumulator? + bcs open_iec_error - jsr printf - .byte "DBG: OPEN 1", $0D, 0 - ;; Send secondary address lda current_secondary_address jsr second - bcs open_iec_error ; XXX what about the accumulator? - - jsr printf - .byte "DBG: OPEN 2", $0D, 0 + bcs open_iec_error ;; Turnaround jsr iec_turnaround_to_listen - bcs open_iec_error ; XXX what about the accumulator? + bcs open_iec_error jsr printf - .byte "DBG: OPEN 3 - DEVICE EXISTS", $0D, 0 + .byte "DBG: TURNAROUND SUCCEEDED", $0D, 0 ;; Indicate success lda #$00 From 22e1e201afeb4b52f0fcfa00dc7ead26f50f1c3d Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 22 Jun 2019 14:35:28 +0200 Subject: [PATCH 27/90] robustness improvements in IEC support --- c64/kernal/iec_pull_atn_clk_release_data.s | 12 ++++++++++-- c64/kernal/iec_pull_clk_release_data.s | 6 ++++++ c64/kernal/iec_pull_data_release_atn_clock.s | 14 +++++++++++--- c64/kernal/iec_release_atn_clk_data.s | 11 ++++++++++- c64/kernal/iec_release_clk_data.s | 9 ++++++++- c64/kernal/iec_release_clk_pull_data.s | 8 +++++++- c64/kernal/iec_turnaround_to_listen.s | 2 +- c64/kernal/listen.s | 4 +++- c64/kernal/second.s | 4 +++- c64/kernal/talk.s | 4 +++- c64/kernal/tksa.s | 1 + 11 files changed, 63 insertions(+), 12 deletions(-) diff --git a/c64/kernal/iec_pull_atn_clk_release_data.s b/c64/kernal/iec_pull_atn_clk_release_data.s index 07c98292..7e11d311 100644 --- a/c64/kernal/iec_pull_atn_clk_release_data.s +++ b/c64/kernal/iec_pull_atn_clk_release_data.s @@ -1,7 +1,15 @@ iec_pull_atn_clk_release_data: + + ;; Pulled CLK = DATA considered invalid; for extra robustness on non-emulated + ;; hardware give some lines few more cycles to stabilize; see page 10 of + ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf + lda CI2PRA - ora #BIT_CI2PRA_ATN_OUT + BIT_CI2PRA_CLK_OUT ; pull - and #$FF - BIT_CI2PRA_DAT_OUT ; release + ora #BIT_CI2PRA_ATN_OUT ; pull + sta CI2PRA + ora #BIT_CI2PRA_CLK_OUT ; pull + sta CI2PRA + and #$FF - BIT_CI2PRA_DAT_OUT ; release sta CI2PRA rts diff --git a/c64/kernal/iec_pull_clk_release_data.s b/c64/kernal/iec_pull_clk_release_data.s index e37f6736..613aa4ef 100644 --- a/c64/kernal/iec_pull_clk_release_data.s +++ b/c64/kernal/iec_pull_clk_release_data.s @@ -1,7 +1,13 @@ iec_pull_clk_release_data: + + ;; Pulled CLK = DATA considered invalid; for extra robustness on non-emulated + ;; hardware give some lines few more cycles to stabilize; see page 10 of + ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf + lda CI2PRA ora #BIT_CI2PRA_CLK_OUT ; pull + sta CI2PRA and #$FF - BIT_CI2PRA_DAT_OUT ; release sta CI2PRA rts diff --git a/c64/kernal/iec_pull_data_release_atn_clock.s b/c64/kernal/iec_pull_data_release_atn_clock.s index 0e8822da..7b2a18d0 100644 --- a/c64/kernal/iec_pull_data_release_atn_clock.s +++ b/c64/kernal/iec_pull_data_release_atn_clock.s @@ -1,7 +1,15 @@ -iec_pull_data_release_atn_clock: +iec_pull_data_release_atn_clk: + + ;; Released CLK = DATA considered valid; for extra robustness on non-emulated + ;; hardware give some lines few more cycles to stabilize; see page 10 of + ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf + lda CI2PRA - ora #BIT_CI2PRA_DAT_OUT ; pull - and #$FF - BIT_CI2PRA_ATN_OUT - BIT_CI2PRA_CLK_OUT ; release + ora #BIT_CI2PRA_DAT_OUT ; pull + sta CI2PRA + and #$FF - BIT_CI2PRA_CLK_OUT ; release + sta CI2PRA + and #$FF - BIT_CI2PRA_ATN_OUT ; release sta CI2PRA rts diff --git a/c64/kernal/iec_release_atn_clk_data.s b/c64/kernal/iec_release_atn_clk_data.s index c35af0da..3fccfbcb 100644 --- a/c64/kernal/iec_release_atn_clk_data.s +++ b/c64/kernal/iec_release_atn_clk_data.s @@ -1,7 +1,16 @@ iec_release_atn_clk_data: + + ;; Released CLK = DATA considered valid; for extra robustness on non-emulated + ;; hardware give some lines few more cycles to stabilize; see page 10 of + ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf + lda CI2PRA - and #$FF - BIT_CI2PRA_ATN_OUT - BIT_CI2PRA_CLK_OUT - BIT_CI2PRA_DAT_OUT ; release + and #$FF - BIT_CI2PRA_ATN_OUT ; release + sta CI2PRA + and #$FF - BIT_CI2PRA_DAT_OUT ; release + sta CI2PRA + and #$FF - BIT_CI2PRA_CLK_OUT ; release sta CI2PRA rts diff --git a/c64/kernal/iec_release_clk_data.s b/c64/kernal/iec_release_clk_data.s index 65bbb7a7..e74ff7e4 100644 --- a/c64/kernal/iec_release_clk_data.s +++ b/c64/kernal/iec_release_clk_data.s @@ -1,6 +1,13 @@ iec_release_clk_data: + + ;; Released CLK = DATA considered valid; for extra robustness on non-emulated + ;; hardware give some lines few more cycles to stabilize; see page 10 of + ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf + lda CI2PRA - and #$FF - BIT_CI2PRA_CLK_OUT - BIT_CI2PRA_DAT_OUT ; release + and #$FF - BIT_CI2PRA_DAT_OUT ; release + sta CI2PRA + and #$FF - BIT_CI2PRA_CLK_OUT ; release sta CI2PRA rts diff --git a/c64/kernal/iec_release_clk_pull_data.s b/c64/kernal/iec_release_clk_pull_data.s index ea4dd673..1c167a04 100644 --- a/c64/kernal/iec_release_clk_pull_data.s +++ b/c64/kernal/iec_release_clk_pull_data.s @@ -1,7 +1,13 @@ iec_release_clk_pull_data: + + ;; Released CLK = DATA considered valid; for extra robustness on non-emulated + ;; hardware give some lines few more cycles to stabilize; see page 10 of + ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf + lda CI2PRA - and #$FF - BIT_CI2PRA_CLK_OUT ; release ora #BIT_CI2PRA_DAT_OUT ; pull sta CI2PRA + and #$FF - BIT_CI2PRA_CLK_OUT ; release + sta CI2PRA rts diff --git a/c64/kernal/iec_turnaround_to_listen.s b/c64/kernal/iec_turnaround_to_listen.s index dcb4f635..f8c6f237 100644 --- a/c64/kernal/iec_turnaround_to_listen.s +++ b/c64/kernal/iec_turnaround_to_listen.s @@ -5,7 +5,7 @@ iec_turnaround_to_listen: ;; Pull DATA, release CLK and ATN (we are not sending commands) - jsr iec_pull_data_release_atn_clock + jsr iec_pull_data_release_atn_clk ;; Wait for clock line to be pulled by the drive ldx #$FF ; XXX should we really use that high number? diff --git a/c64/kernal/listen.s b/c64/kernal/listen.s index 06cc7121..10d57fe0 100644 --- a/c64/kernal/listen.s +++ b/c64/kernal/listen.s @@ -2,6 +2,8 @@ listen: - ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 223 + ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 223 and + ;; https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc + and #$1F ; make sure bits encoding the command are cleared out ora #$20 jmp iec_tx_command diff --git a/c64/kernal/second.s b/c64/kernal/second.s index 1dc7de8a..7adadbda 100644 --- a/c64/kernal/second.s +++ b/c64/kernal/second.s @@ -1,6 +1,8 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide second: - ;; This trivial routine is documented in 'C64 Programmer's Reference Guide', page 296 + ;; This trivial routine is documented in 'C64 Programmer's Reference Guide', page 296 and + ;; https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc + and #$1F ; make sure bits encoding the command are cleared out ora #$60 jmp iec_tx_command diff --git a/c64/kernal/talk.s b/c64/kernal/talk.s index 7a421974..0f7fb1e4 100644 --- a/c64/kernal/talk.s +++ b/c64/kernal/talk.s @@ -2,7 +2,9 @@ talk: - ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 223 + ;; This routine is documented in 'Compute's Mapping the Commodore 64', page 223 and + ;; https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc + and #$1F ; make sure bits encoding the command are cleared out ora #$40 jmp iec_tx_command diff --git a/c64/kernal/tksa.s b/c64/kernal/tksa.s index 49bca787..04fff397 100644 --- a/c64/kernal/tksa.s +++ b/c64/kernal/tksa.s @@ -3,6 +3,7 @@ tksa: ;; This routine is documented in 'C64 Programmer's Reference Guide', page 302 and ;; https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc + and #$1F ; make sure bits encoding the command are cleared out ora #$F0 jmp iec_tx_command From a1d3c74a0d1f201db005f8164f39deaf05a6be08 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 22 Jun 2019 15:52:09 +0200 Subject: [PATCH 28/90] more IEC work - the turnaround seems to work now --- ...lease_atn_clock.s => iec_pull_data_release_atn_clk.s} | 0 c64/kernal/iec_release_atn.s | 8 ++++++++ c64/kernal/iec_tx_command.s | 9 ++++++--- c64/kernal/iec_tx_common.s | 2 +- c64/kernal/iec_tx_eoi.s | 3 +++ 5 files changed, 18 insertions(+), 4 deletions(-) rename c64/kernal/{iec_pull_data_release_atn_clock.s => iec_pull_data_release_atn_clk.s} (100%) create mode 100644 c64/kernal/iec_release_atn.s diff --git a/c64/kernal/iec_pull_data_release_atn_clock.s b/c64/kernal/iec_pull_data_release_atn_clk.s similarity index 100% rename from c64/kernal/iec_pull_data_release_atn_clock.s rename to c64/kernal/iec_pull_data_release_atn_clk.s diff --git a/c64/kernal/iec_release_atn.s b/c64/kernal/iec_release_atn.s new file mode 100644 index 00000000..194f3856 --- /dev/null +++ b/c64/kernal/iec_release_atn.s @@ -0,0 +1,8 @@ + +iec_release_atn: + + lda CI2PRA + and #$FF - BIT_CI2PRA_ATN_OUT ; release + sta CI2PRA + rts + diff --git a/c64/kernal/iec_tx_command.s b/c64/kernal/iec_tx_command.s index ca50f4a2..526ae80a 100644 --- a/c64/kernal/iec_tx_command.s +++ b/c64/kernal/iec_tx_command.s @@ -57,9 +57,12 @@ iec_tx_command: jsr iec_set_idle jmp kernalerror_DEVICE_NOT_FOUND * - ;; All done - before exiting wait a moment and restore bus to idle state - jsr iec_wait20us - jsr iec_set_idle + ;; All done + + ;; XXX All the documentation says we should release ATN at this point, but when I do so + ;; the turnaround mechanism does not work. Why??? + ;; jsr iec_wait20us + ;; jsr iec_set_idle clc rts diff --git a/c64/kernal/iec_tx_common.s b/c64/kernal/iec_tx_common.s index 73753f72..a9652d6b 100644 --- a/c64/kernal/iec_tx_common.s +++ b/c64/kernal/iec_tx_common.s @@ -43,7 +43,7 @@ iec_tx_common_bit_is_sent: ;; Pull CLK for 20us again, before sending the next bit ;; or performing any other action jsr iec_pull_clk_release_data - jsr iec_wait20us + jsr iec_wait20us ; XXX this might be an overkill, there is a lot of code besides this wait here - few NOPs might be enough ;; More bits to send? dex diff --git a/c64/kernal/iec_tx_eoi.s b/c64/kernal/iec_tx_eoi.s index 76169af3..5cae87f2 100644 --- a/c64/kernal/iec_tx_eoi.s +++ b/c64/kernal/iec_tx_eoi.s @@ -1,6 +1,9 @@ iec_tx_eoi: + ;; Releasing ATN needed due to current iec_tx_command implementation + jsr iec_release_atn + ;; Wait at least 256 usec jsr iec_wait100us jsr iec_wait100us From e42f63f190e1b5d472e2870438f2361510504e76 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 23 Jun 2019 12:28:03 +0200 Subject: [PATCH 29/90] more error return routines in Kernal --- c64/kernal/errors.s | 47 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/c64/kernal/errors.s b/c64/kernal/errors.s index 751a2194..33666e62 100644 --- a/c64/kernal/errors.s +++ b/c64/kernal/errors.s @@ -1,6 +1,53 @@ +;; Kernal error codes are described in 'Commodore 64 Programmer's Reference Guide', page 306 + +kernalerror_common: + sta DFLTN + sec + rts + +kernalerror_ROUTINE_TERMINATED: ; by a STOP key + lda #$00 + jmp kernalerror_common + +kernalerror_TOO_MANY_OPEN_FILES: + lda #$01 + jmp kernalerror_common + +kernalerror_FILE_ALREADY_OPEN: + lda #$02 + jmp kernalerror_common + +kernalerror_FILE_NOT_OPEN: + lda #$03 + jmp kernalerror_common + +kernalerror_FILE_NOT_FOUND: + lda #$04 + jmp kernalerror_common kernalerror_DEVICE_NOT_FOUND: lda #$05 + jmp kernalerror_common + +kernalerror_FILE_NOT_INPUT: + lda #$06 + jmp kernalerror_common + +kernalerror_FILE_NOT_OUTPUT: + lda #$07 + jmp kernalerror_common + +kernalerror_FILE_NAME_MISSING: + lda #$08 + jmp kernalerror_common + +kernalerror_ILLEGAL_DEVICE_NUMBER: + lda #$09 + jmp kernalerror_common + +kernalerror_TOP_MEM_RS232: + lda #$F0 + sta RSSTAT sec rts From ac1fb40eb6aa3eab65fb2a982adbf9bbb8a24f11 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 24 Jun 2019 19:06:23 +0200 Subject: [PATCH 30/90] work on LOAD routine --- c64/basic/cmd_load.s | 4 ++++ c64/kernal/load.s | 50 +++++++++++++++++++------------------------- c64/kernal/unlsn.s | 2 +- 3 files changed, 26 insertions(+), 30 deletions(-) diff --git a/c64/basic/cmd_load.s b/c64/basic/cmd_load.s index 000743fd..691ba769 100644 --- a/c64/basic/cmd_load.s +++ b/c64/basic/cmd_load.s @@ -11,6 +11,10 @@ cmd_load: ;; middle of a program. For safety, we do. jsr basic_do_clr + ;; XXX temporary, to set valid device number + lda #$08 + sta current_device_number + ;; Set filename and length lda #$00 sta current_filename_length diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 29890c34..37e95336 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -37,7 +37,8 @@ load: .byte "SEARCHING FOR ",0 ldy #$00 -print_filename_loop: +print_filename_loop: + cpy current_filename_length beq + ldx # Date: Sun, 7 Jul 2019 19:01:35 +0200 Subject: [PATCH 31/90] fix for infinite loop in iec_rx_byte on empty stream --- c64/kernal/iec_rx_byte.s | 18 +++++++++++++++--- c64/kernal/load.s | 3 --- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/c64/kernal/iec_rx_byte.s b/c64/kernal/iec_rx_byte.s index 8caf8392..8ffcf3f7 100644 --- a/c64/kernal/iec_rx_byte.s +++ b/c64/kernal/iec_rx_byte.s @@ -11,6 +11,9 @@ iec_rx_byte: ;; We can use this routine, since we weren't pulling CLK anyway jsr iec_release_clk_data + ;; Wait till data line is released (someone else might be holding it) + jsr iec_wait_for_data_release + ;; Wait for talker to pull CLK. ;; If over 200 usec (205 cycles on NTSC machine) , then it is EOI. ;; Loop iteraction takes 13 cycles, 17 full iterations are enough @@ -21,14 +24,23 @@ iec_rx_clk_wait: rol ; 2 cycles, to put BIT_CI2PRA_CLK_IN as the last bit bpl iec_rx_not_eoi ; 2 cycles if not jumped dex ; 2 cycles - bne iec_rx_clk_wait ; 3 cycles if jumped + bne iec_rx_clk_wait ; 3 cycles if jumped - ;; Timeout - wait for pulled CLK and pull data for 60 usec to confirm - jsr iec_wait_for_clk_pull + ;; Timeout - wait a little bit more to see if EOI confirmation is needed + ;; (if CLK not pulled within 256 usec - it's not needed, see + ;; https://www.pagetable.com/?p=1135, chapters End of Stream and Empty Stream) + jsr iec_wait60us + lda CI2PRA + rol + bmi iec_rx_no_eoi_confirmation + + ;; Pull data for 60 usec to confirm jsr iec_release_clk_pull_data jsr iec_wait60us jsr iec_release_clk_data +iec_rx_no_eoi_confirmation: + ;; Store EOI information in IOSTATUS - XXX this should be done by the caller! lda IOSTATUS ora #$40 diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 37e95336..edf2c453 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -111,9 +111,6 @@ sent_filename: jsr iec_turnaround_to_listen bcs load_error - jsr printf - .byte "DBG: LOAD 1", $0D, 0 - ;; Get load address and store it if secondary address is zero jsr iec_rx_byte bcs file_not_found_error From f911eed0c398b267499aca34529216f3ad9340b0 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Tue, 9 Jul 2019 22:48:35 +0200 Subject: [PATCH 32/90] fixes for sending file name to IEC in LOAD --- c64/kernal/iec_tx_byte.s | 4 ++++ c64/kernal/iec_tx_command.s | 1 + c64/kernal/iec_tx_common.s | 27 +++++++++++++++++++++++---- c64/kernal/iec_tx_eoi.s | 15 --------------- c64/kernal/iec_wait100us.s | 3 --- c64/kernal/load.s | 11 +++++++++-- 6 files changed, 37 insertions(+), 24 deletions(-) delete mode 100644 c64/kernal/iec_tx_eoi.s diff --git a/c64/kernal/iec_tx_byte.s b/c64/kernal/iec_tx_byte.s index c422f270..d7e2e183 100644 --- a/c64/kernal/iec_tx_byte.s +++ b/c64/kernal/iec_tx_byte.s @@ -1,9 +1,12 @@ ;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc +;; Carry flag set = signal EOI + iec_tx_byte: pha + php ;; Notify all devices that we are going to send a byte ;; and it is going to be a data byte (released ATN) @@ -12,6 +15,7 @@ iec_tx_byte: ;; Common part of iec_txbyte and iec_tx_common - waits for devices ;; and transmits a byte + plp pla jsr iec_tx_common diff --git a/c64/kernal/iec_tx_command.s b/c64/kernal/iec_tx_command.s index 526ae80a..f68764e5 100644 --- a/c64/kernal/iec_tx_command.s +++ b/c64/kernal/iec_tx_command.s @@ -36,6 +36,7 @@ iec_tx_command: ;; Common part of iec_txbyte and iec_tx_common - waits for devices ;; and transmits a byte + clc ; Carry flag set is used for EOI mark pla jsr iec_tx_common diff --git a/c64/kernal/iec_tx_common.s b/c64/kernal/iec_tx_common.s index a9652d6b..eb1ba991 100644 --- a/c64/kernal/iec_tx_common.s +++ b/c64/kernal/iec_tx_common.s @@ -5,19 +5,38 @@ iec_tx_common: - ;; Store the bye to send on a stack + ;; Store the byte to send on a stack pha + ;; Store the status register - carry flag is used to determine whether + ;; this is the last byte of the stream + php + ;; Wait till all receivers are ready, they should all release DATA jsr iec_wait_for_data_release + ;; At this point a delay 256 usec or more is considered EOI - add waits if necessary + plp + bcc + + jsr iec_wait100us + jsr iec_wait100us + jsr iec_wait60us + + ;; XXX waits above should be enough - why do we need more waits??? + jsr iec_wait100us + jsr iec_wait100us + jsr iec_wait100us + + ;; Receiver should now acknowledge EOI by pulling data for at least 60 usec + jsr iec_wait60us + jsr iec_wait_for_data_release +* ;; Pull CLK back to indicate that DATA is not valid, keep it for 60us ;; We can use this routine as we don't hold DATA anyway (and its state doesn't even matter) - ;; Don't wait too long, as 200us or more is considered EOI jsr iec_pull_clk_release_data jsr iec_wait60us - + ;; Now, we can start transmission of 8 bits of data ldx #7 pla @@ -39,7 +58,7 @@ iec_tx_common_bit_is_sent: ;; Wait 20us, so that device(s) can pick DATA jsr iec_wait20us - + ;; Pull CLK for 20us again, before sending the next bit ;; or performing any other action jsr iec_pull_clk_release_data diff --git a/c64/kernal/iec_tx_eoi.s b/c64/kernal/iec_tx_eoi.s deleted file mode 100644 index 5cae87f2..00000000 --- a/c64/kernal/iec_tx_eoi.s +++ /dev/null @@ -1,15 +0,0 @@ - -iec_tx_eoi: - - ;; Releasing ATN needed due to current iec_tx_command implementation - jsr iec_release_atn - - ;; Wait at least 256 usec - jsr iec_wait100us - jsr iec_wait100us - jsr iec_wait60us - - ;; Restore the bus to idle state - jsr iec_set_idle - - rts diff --git a/c64/kernal/iec_wait100us.s b/c64/kernal/iec_wait100us.s index 7ccfee98..b3101685 100644 --- a/c64/kernal/iec_wait100us.s +++ b/c64/kernal/iec_wait100us.s @@ -8,9 +8,6 @@ iec_wait100us: ;; NTSC: ;; - CPU frequency 1.022727 MHZ, we need to waste at least 103 cycles - ;; Waste cycles by reading some unimportant memory location - ;; (in a loop) in order not to clutter VICE debug logs - ;; Waste cycles in a loop ldy #$12 ; 2 cycles diff --git a/c64/kernal/load.s b/c64/kernal/load.s index edf2c453..b7d68db9 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -76,21 +76,28 @@ send_filename: ldx # Date: Wed, 10 Jul 2019 17:46:44 +0200 Subject: [PATCH 33/90] LOAD command is now able to load file from drive 8 --- bin/basic | Bin 8192 -> 8192 bytes bin/kernal | Bin 8192 -> 8192 bytes c64/kernal/iec_rx_byte.s | 24 +++++++++++++----------- c64/kernal/load.s | 12 ++++++++++-- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/bin/basic b/bin/basic index 2de26fca65877da98a8b7017bdb99069ad551db9..2f38515c7f53f2222863cb9756707f716c5e75cd 100644 GIT binary patch delta 1908 zcmb_dTTB#J7@nPBnY{or)*BU(BNBy*Kx@=>D}-8%SdKTS@u98VT}rz~9!zW>#F!vMXNQ9YF-v4Ke$AC(OzlWTZ0Y@yHNqo37q*r`VtxdWYL(NS67 zCwD{`*n?Dy5egT$wDg<(jp>&DMl>n=43sGX&PLFmuXx9@rpu@|bAf~XD!!tjNpg!_ zRmy90qx35EN}JHJ;iQ#4v}4G;}{oO#2cx5G8l*MMZ(A%1FHArVc4D>Q?x1H+3670@S-HDa~D3 z^mjDUneOW|rcB#NgU!e6gVossF$$ETnq(gG285S`yFu9w$%@-#qZ`d-Nnypl)M$s9? z;+|3PxDs^?Gd8Diim{D5Kyg|P7~RT@2Dmb=jH(O>`$&qfUeT>Y-5KF&Eqqk5Oo7HX ze1^ksD1>tyZXS-I`#ic4!{=fKYZf7RpCh5Gvpk?!>`b_*LWs|>rN^`DRO<1JHiT)( zHN?nu$DaHn@m|)}H7foQ#LMEO#<{qX#Cw@pN<+NM`nkRcg@2N{w9RI?!g*7S&2z`q zYqQ~|I635e$B$YERflu|f;|t-1X=q^L%+#JDfoUxqaD&kdPKT3L$NZFiyq5(GCqDD zkHtY}SY>2e#DQ*R!**>Hk7>u(9IHZ0Rk~WLrIk{h)i@{IE7&2847-JYb4`N$MOrI7s=g9T^TaC9z8bygF1?Is$90RHtSo zFFq}kzWgGh=R3)z{IaS&R7K#Zyd3SJ)N5oj0z{6s?LZ9mDjU(gn3@l42oiz;WQ*NP z$l<)xFT;o$@y$Ul*G6p9)6lfW*4(({fYjIp4=o60NQrBC$?mht4YM33W|`L5)2Q}I z>)>ABT@lhESp+@yt_#^ab$n}p9CNkU4v-&QYeR6-^+KOfWeQXP_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z4q8;DUe&wC@_Qj6!t0>({ep6jE#D0^{c;pMA2Y0uTIfw1T@TmoO5RWNGen zB+a~5Elgt;sguD#RMHDjUx0y@22hLZKX6sI35_&gPJk&TEs)gJimHU*yG|z6^AO=B5;|&#R3-zTq^Jjj@voPKfg`j zHV30FwhIgi^a|7k`UM6BwhG+O@tBK0I{1@=n!s=F;CTn9?qfjU5`oPE2RW|g=n>c< Tut}g#4Bs*dC8Wv+oG^b0F8<3o diff --git a/c64/kernal/iec_rx_byte.s b/c64/kernal/iec_rx_byte.s index 8ffcf3f7..2d28465f 100644 --- a/c64/kernal/iec_rx_byte.s +++ b/c64/kernal/iec_rx_byte.s @@ -32,23 +32,15 @@ iec_rx_clk_wait: jsr iec_wait60us lda CI2PRA rol - bmi iec_rx_no_eoi_confirmation + bmi iec_rx_set_eoi + + jsr iec_rx_set_eoi ;; Pull data for 60 usec to confirm jsr iec_release_clk_pull_data jsr iec_wait60us jsr iec_release_clk_data -iec_rx_no_eoi_confirmation: - - ;; Store EOI information in IOSTATUS - XXX this should be done by the caller! - lda IOSTATUS - ora #$40 - sta IOSTATUS - - sec - rts - iec_rx_not_eoi: ;; Latch input bits in on rising edge of CLK, eight times for eight bits. @@ -84,6 +76,7 @@ iec_rx_bit_loop: ;; Move data bit into C flag, and loop until bit 6 clears ;; i.e., the clock has been released. + * lda CI2PRA rol bpl - @@ -113,3 +106,12 @@ iec_rx_bit_loop: clc rts +iec_rx_set_eoi: + + ;; Store EOI information in IOSTATUS + lda IOSTATUS + ora #$40 + sta IOSTATUS + + clc + rts diff --git a/c64/kernal/load.s b/c64/kernal/load.s index b7d68db9..d6e9b631 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -158,7 +158,7 @@ load_loop: bne + inc load_save_start_ptr+1 ;; If we wrap around to $0000, then this is bad. - beq load_error + beq load_error * ;; Check for EOI -- if so, read one last byte lda IOSTATUS @@ -167,13 +167,21 @@ load_loop: load_done: ;; Close file on drive - + ;; Command drive to stop talking and to close the file jsr untlk + + ;; XXX XXX code below runs into infinite loop - so for now just quit + clc + cli + rts + lda current_device_number jsr listen + lda #$e0 jsr iec_tx_command + ;; Tell drive to unlisten jsr unlsn From ee6e7bc9d580080ed031bea9dc3f86bd4d40e2da Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 12 Jul 2019 19:22:46 +0200 Subject: [PATCH 34/90] implemented SETMSG routine, LOAD command uses it --- c64/basic/,aliases.s | 3 +-- c64/basic/cmd_load.s | 9 +++++++++ c64/kernal/,aliases.s | 3 +-- c64/kernal/load.s | 18 +++++++++++------- c64/kernal/setmsg.s | 1 + 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index f500a630..2e1fee26 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -61,8 +61,7 @@ .alias LDTND $98 ; number of entries in LAT / FAT / SAT tables .alias DFLTN $99 .alias input_device_number DFLTN - ; bit 6 = error messages, bit 7 = control messages - .alias kernal_message_control_flags $9d + .alias MSGFLG $9D ; bit 6 = error messages, bit 7 = control message .alias jiffy_clock_24bits $a0 .alias cassette_buffer_bytes_used $A6 .alias load_or_scroll_temp_pointer $AC diff --git a/c64/basic/cmd_load.s b/c64/basic/cmd_load.s index 691ba769..30cc57b0 100644 --- a/c64/basic/cmd_load.s +++ b/c64/basic/cmd_load.s @@ -11,6 +11,15 @@ cmd_load: ;; middle of a program. For safety, we do. jsr basic_do_clr + ;; Setup Kernal to print control messages or not + lda #$80 ; display control messages and omit error messages + ldx basic_current_line_number+1 + cpx #$FF + beq + + lda #$00 ; direct mode - don't display anything +* + jsr $FF90 ; SETMSG + ;; XXX temporary, to set valid device number lda #$08 sta current_device_number diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index 0d3ab8ab..e4dd19ca 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -12,8 +12,7 @@ .alias LDTND $98 ; number of entries in LAT / FAT / SAT tables .alias DFLTN $99 .alias input_device_number DFLTN - ; bit 6 = error messages, bit 7 = control messages - .alias kernal_message_control_flags $9d + .alias MSGFLG $9D ; bit 6 = error messages, bit 7 = control message .alias jiffy_clock_24bits $a0 .alias cassette_buffer_bytes_used $A6 .alias load_or_scroll_temp_pointer $AC diff --git a/c64/kernal/load.s b/c64/kernal/load.s index d6e9b631..1a853b95 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -15,7 +15,7 @@ ;; $AC = current pointer for loading/verifying ;; $C1 = similar to the above. -;; XXX rework this, according to pagetable.com +;; XXX honor MSGFLG bit 6, add VERIFY support load: @@ -30,12 +30,13 @@ load: jsr install_ram_routines ;; Disable IRQs, since timing matters! - SEI + sei - ;; Display SEARCHING FOR + ;; Display SEARCHING FOR + filename + lda MSGFLG + bpl + jsr printf - .byte "SEARCHING FOR ",0 - + .byte $0D,"SEARCHING FOR ",0 ldy #$00 print_filename_loop: @@ -131,9 +132,12 @@ sent_filename: beq + sta load_save_start_ptr+1 * + ;; Display LOADING + lda MSGFLG + bpl + jsr printf - .byte "LOADING",$0d,0 - + .byte "LOADING",$0D,0 +* load_loop: ;; We are now ready to receive bytes jsr iec_rx_byte diff --git a/c64/kernal/setmsg.s b/c64/kernal/setmsg.s index eb79d7f5..15a3d5b1 100644 --- a/c64/kernal/setmsg.s +++ b/c64/kernal/setmsg.s @@ -1,3 +1,4 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide setmsg: + sta MSGFLG rts From a846d74895a7a81589295d3a8fd81b0632580726 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 12 Jul 2019 20:08:40 +0200 Subject: [PATCH 35/90] aliases for Kernal jump table entries --- c64/basic/,aliases.s | 41 +++++++++++++++++++++++++++ c64/basic/ab1e.print_string.s | 2 +- c64/basic/basic_cold_start.s | 2 +- c64/basic/basic_do_error.s | 10 +++---- c64/basic/basic_main_loop.s | 2 +- c64/basic/cmd_break.s | 2 +- c64/basic/cmd_list.s | 8 +++--- c64/basic/cmd_load.s | 4 +-- c64/basic/cmd_new.s | 2 +- c64/basic/print_integer.s | 4 +-- c64/basic/print_packed_message.s | 12 ++++---- c64/basic/printf.s | 6 ++-- c64/basic/wedge_dos.s | 2 +- c64/kernal/,aliases.s | 41 +++++++++++++++++++++++++++ c64/kernal/{ff81.s => ff81.jcint.s} | 0 c64/kernal/{ff84.s => ff84.jioinit.s} | 0 c64/kernal/{ff87.s => ff87.jramtas.s} | 0 c64/kernal/{ff8a.s => ff8a.jrestor.s} | 0 c64/kernal/{ff8d.s => ff8d.jvector.s} | 0 c64/kernal/{ff90.s => ff90.jsetmsg.s} | 0 c64/kernal/{ff93.s => ff93.jsecond.s} | 0 c64/kernal/{ff96.s => ff96.jtksa.s} | 0 c64/kernal/{ff99.s => ff99.jmemtop.s} | 0 c64/kernal/{ff9c.s => ff9c.jmembot.s} | 0 c64/kernal/{ff9f.s => ff9f.jscnkey.s} | 0 c64/kernal/{ffa2.s => ffa2.jsettmo.s} | 0 c64/kernal/{ffa5.s => ffa5.jacptr.s} | 0 c64/kernal/{ffa8.s => ffa8.jciout.s} | 0 c64/kernal/{ffab.s => ffab.juntlk.s} | 0 c64/kernal/{ffae.s => ffae.junlsn.s} | 0 c64/kernal/{ffb1.s => ffb1.jlisten.s} | 0 c64/kernal/{ffb4.s => ffb4.jtalk.s} | 0 c64/kernal/{ffb7.s => ffb7.jreadst.s} | 0 c64/kernal/{ffba.s => ffba.jsetfls.s} | 2 +- c64/kernal/{ffbd.s => ffbd.setnam.s} | 0 c64/kernal/{ffc0.s => ffc0.jopen.s} | 0 c64/kernal/{ffc3.s => ffc3.jclose.s} | 0 c64/kernal/{ffc6.s => ffc6.jchkin.s} | 0 c64/kernal/{ffc9.s => ffc9.jchkout.s} | 0 c64/kernal/{ffcc.s => ffcc.jclrchn.s} | 0 c64/kernal/{ffcf.s => ffcf.jchrin.s} | 0 c64/kernal/{ffd2.s => ffd2.jchrout.s} | 0 c64/kernal/{ffd5.s => ffd5.jload.s} | 0 c64/kernal/{ffd8.s => ffd8.jsave.s} | 0 c64/kernal/{ffdb.s => ffdb.jsettim.s} | 0 c64/kernal/{ffde.s => ffde.jrdtim.s} | 0 c64/kernal/{ffe1.s => ffe1.jstop.s} | 0 c64/kernal/{ffe4.s => ffe4.jgetin.s} | 0 c64/kernal/{ffe7.s => ffe7.jclall.s} | 0 c64/kernal/{ffea.s => ffea.judtim.s} | 0 c64/kernal/{ffed.s => ffed.jscreen.s} | 0 c64/kernal/{fff0.s => fff0.jplot.s} | 0 c64/kernal/{fff3.s => fff3.jiobase.s} | 6 ++-- c64/kernal/load.s | 4 +-- c64/kernal/printf.s | 6 ++-- c64/kernal/{setlfs.s => setfls.s} | 2 +- 56 files changed, 120 insertions(+), 38 deletions(-) rename c64/kernal/{ff81.s => ff81.jcint.s} (100%) rename c64/kernal/{ff84.s => ff84.jioinit.s} (100%) rename c64/kernal/{ff87.s => ff87.jramtas.s} (100%) rename c64/kernal/{ff8a.s => ff8a.jrestor.s} (100%) rename c64/kernal/{ff8d.s => ff8d.jvector.s} (100%) rename c64/kernal/{ff90.s => ff90.jsetmsg.s} (100%) rename c64/kernal/{ff93.s => ff93.jsecond.s} (100%) rename c64/kernal/{ff96.s => ff96.jtksa.s} (100%) rename c64/kernal/{ff99.s => ff99.jmemtop.s} (100%) rename c64/kernal/{ff9c.s => ff9c.jmembot.s} (100%) rename c64/kernal/{ff9f.s => ff9f.jscnkey.s} (100%) rename c64/kernal/{ffa2.s => ffa2.jsettmo.s} (100%) rename c64/kernal/{ffa5.s => ffa5.jacptr.s} (100%) rename c64/kernal/{ffa8.s => ffa8.jciout.s} (100%) rename c64/kernal/{ffab.s => ffab.juntlk.s} (100%) rename c64/kernal/{ffae.s => ffae.junlsn.s} (100%) rename c64/kernal/{ffb1.s => ffb1.jlisten.s} (100%) rename c64/kernal/{ffb4.s => ffb4.jtalk.s} (100%) rename c64/kernal/{ffb7.s => ffb7.jreadst.s} (100%) rename c64/kernal/{ffba.s => ffba.jsetfls.s} (87%) rename c64/kernal/{ffbd.s => ffbd.setnam.s} (100%) rename c64/kernal/{ffc0.s => ffc0.jopen.s} (100%) rename c64/kernal/{ffc3.s => ffc3.jclose.s} (100%) rename c64/kernal/{ffc6.s => ffc6.jchkin.s} (100%) rename c64/kernal/{ffc9.s => ffc9.jchkout.s} (100%) rename c64/kernal/{ffcc.s => ffcc.jclrchn.s} (100%) rename c64/kernal/{ffcf.s => ffcf.jchrin.s} (100%) rename c64/kernal/{ffd2.s => ffd2.jchrout.s} (100%) rename c64/kernal/{ffd5.s => ffd5.jload.s} (100%) rename c64/kernal/{ffd8.s => ffd8.jsave.s} (100%) rename c64/kernal/{ffdb.s => ffdb.jsettim.s} (100%) rename c64/kernal/{ffde.s => ffde.jrdtim.s} (100%) rename c64/kernal/{ffe1.s => ffe1.jstop.s} (100%) rename c64/kernal/{ffe4.s => ffe4.jgetin.s} (100%) rename c64/kernal/{ffe7.s => ffe7.jclall.s} (100%) rename c64/kernal/{ffea.s => ffea.judtim.s} (100%) rename c64/kernal/{ffed.s => ffed.jscreen.s} (100%) rename c64/kernal/{fff0.s => fff0.jplot.s} (100%) rename c64/kernal/{fff3.s => fff3.jiobase.s} (85%) rename c64/kernal/{setlfs.s => setfls.s} (97%) diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index 2e1fee26..8a4733fc 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -168,6 +168,47 @@ .alias ILOAD $0330 .alias ISAVE $0331 + ;; Kernal jump table + .alias JCINT $FF81 + .alias JIOINIT $FF84 + .alias JRAMTAS $FF87 + .alias JRESTOR $FF8A + .alias JVECTOR $FF8D + .alias JSETMSG $FF90 + .alias JSECOND $FF93 + .alias JTKSA $FF96 + .alias JMEMTOP $FF99 + .alias JMEMBOT $FF9C + .alias JSCNKEY $FF9F + .alias JSETTMO $FFA2 + .alias JACPTR $FFA5 + .alias JCIOUT $FFA8 + .alias JUNTLK $FFAB + .alias JUNLSN $FFAE + .alias JLISTEN $FFB1 + .alias JTALK $FFB4 + .alias JREADST $FFB7 + .alias JSETFLS $FFBA + .alias JSETNAM $FFBD + .alias JOPEN $FFC0 + .alias JCLOSE $FFC3 + .alias JCHKIN $FFC6 + .alias JCHKOUT $FFC9 + .alias JCLRCHN $FFCC + .alias JCHRIN $FFCF + .alias JCHROUT $FFD2 + .alias JLOAD $FFD5 + .alias JSAVE $FFD8 + .alias JSETTIM $FFDB + .alias JRDTIM $FFDE + .alias JSTOP $FFE1 + .alias JGETIN $FFE4 + .alias JCLALL $FFE7 + .alias JUDTIM $FFEA + .alias JSCREEN $FFED + .alias JPLOT $FFF0 + .alias JIOBASE $FFF3 + ;; BASIC uses some extra bytes for memory access under ROMs located at $2A7 onwards ;; IRQs are disabled when doing such accesses, and a default NMI handler only increments ;; a counter, so that if an NMI occurs, it doesn't crash the machine, but can be captured. diff --git a/c64/basic/ab1e.print_string.s b/c64/basic/ab1e.print_string.s index 9ca8a586..0ea252a3 100644 --- a/c64/basic/ab1e.print_string.s +++ b/c64/basic/ab1e.print_string.s @@ -20,7 +20,7 @@ print_string_loop: lda (temp_string_ptr),y beq print_string_end - jsr $FFD2 ; KERNAL CHROUT + jsr JCHROUT txa tay diff --git a/c64/basic/basic_cold_start.s b/c64/basic/basic_cold_start.s index 7ffb94f6..6e231458 100644 --- a/c64/basic/basic_cold_start.s +++ b/c64/basic/basic_cold_start.s @@ -64,7 +64,7 @@ startup_banner: jsr print_integer lda #$20 - jsr $ffd2 + jsr JCHROUT ;; Print the rest of the start up message ldx #34 diff --git a/c64/basic/basic_do_error.s b/c64/basic/basic_do_error.s index 584bfe19..731f99c2 100644 --- a/c64/basic/basic_do_error.s +++ b/c64/basic/basic_do_error.s @@ -7,9 +7,9 @@ basic_do_error: ;; Print ? at start lda #$0d - jsr $ffd2 + jsr JCHROUT lda #$3f - jsr $ffd2 + jsr JCHROUT ;; Print main part of error message pla @@ -18,7 +18,7 @@ basic_do_error: ;; Print ERROR at end lda #$20 - jsr $ffd2 + jsr JCHROUT ldx #33 jsr print_packed_message @@ -27,9 +27,9 @@ basic_do_error: ;; XXX print line number if not in direct mode lda #$0d - jsr $ffd2 + jsr JCHROUT lda #$0d - jsr $ffd2 + jsr JCHROUT ;; Reset stack, and go back to main loop ldx #$fe diff --git a/c64/basic/basic_main_loop.s b/c64/basic/basic_main_loop.s index 233bd60c..69e12c9d 100644 --- a/c64/basic/basic_main_loop.s +++ b/c64/basic/basic_main_loop.s @@ -52,7 +52,7 @@ rsl_l1: lda $0200,x * ;; Do printing of the new line lda #$0d - jsr $ffd2 + jsr JCHROUT ;; Ignore empty lines lda tokenise_work1 diff --git a/c64/basic/cmd_break.s b/c64/basic/cmd_break.s index 38c7bd3d..36128422 100644 --- a/c64/basic/cmd_break.s +++ b/c64/basic/cmd_break.s @@ -17,7 +17,7 @@ basic_do_break: * lda #$0d - jsr $ffd2 + jsr JCHROUT cmd_end: jmp basic_main_loop diff --git a/c64/basic/cmd_list.s b/c64/basic/cmd_list.s index ba02f675..f93ee033 100644 --- a/c64/basic/cmd_list.s +++ b/c64/basic/cmd_list.s @@ -36,7 +36,7 @@ list_more_lines: pla jsr print_integer lda #$20 - jsr $ffd2 + jsr JCHROUT ;; Iterate through printing out the line ;; contents @@ -105,17 +105,17 @@ list_not_rem: bne list_print_loop list_is_literal: - jsr $ffd2 + jsr JCHROUT iny bne list_print_loop list_end_of_line: ;; Clear reverse flag lda #$92 - jsr $ffd2 + jsr JCHROUT ;; Print end of line lda #$0d - jsr $ffd2 + jsr JCHROUT ;; Now link to the next line jsr basic_find_next_line diff --git a/c64/basic/cmd_load.s b/c64/basic/cmd_load.s index 30cc57b0..9713a41b 100644 --- a/c64/basic/cmd_load.s +++ b/c64/basic/cmd_load.s @@ -18,7 +18,7 @@ cmd_load: beq + lda #$00 ; direct mode - don't display anything * - jsr $FF90 ; SETMSG + jsr JSETMSG ;; XXX temporary, to set valid device number lda #$08 @@ -69,7 +69,7 @@ got_filename: ldx #<$0801 ; LOAD address = $0801 ldy #>$0801 - jsr $ffd5 + jsr JLOAD bcc + ;; A = KERNAL error code, which also almost match diff --git a/c64/basic/cmd_new.s b/c64/basic/cmd_new.s index ce355946..9d5f9d94 100644 --- a/c64/basic/cmd_new.s +++ b/c64/basic/cmd_new.s @@ -41,7 +41,7 @@ basic_do_new: ;; (same story), expression value cache? sec ; Read, not write value - jsr $ff99 ; KERNAL MEMTOP routine + jsr JMEMTOP cpx #$80 beq + lda #>$f7ff diff --git a/c64/basic/print_integer.s b/c64/basic/print_integer.s index 739f8b8b..f5d93fa7 100644 --- a/c64/basic/print_integer.s +++ b/c64/basic/print_integer.s @@ -58,7 +58,7 @@ hi_loop: pha ldx #4 clc -hi_add_loop: +hi_add_loop: lda $0100,x adc number_table_hi,y sta $0100,x @@ -115,7 +115,7 @@ found_start_of_number: ;; Print digits * lda $0100,y ora #$30 - jsr $ffd2 + jsr JCHROUT iny cpy #5 bne - diff --git a/c64/basic/print_packed_message.s b/c64/basic/print_packed_message.s index 58481e82..006bf70e 100644 --- a/c64/basic/print_packed_message.s +++ b/c64/basic/print_packed_message.s @@ -38,7 +38,7 @@ found_message_in_token_stream: beq + jsr print_packed_word lda #$20 - jsr $ffd2 + jsr JCHROUT pla tay iny @@ -47,7 +47,7 @@ found_message_in_token_stream: pla ;; Rub out space at the end lda #$14 - jsr $ffd2 + jsr JCHROUT rts print_packed_word: @@ -138,13 +138,13 @@ next_packed_word_char: lsr tax - ;; Save Y so it doesn't get clobbered by $FFD2 + ;; Save Y so it doesn't get clobbered by CHROUT tya pha ;; X=1-14 = first 14 chars, so subtract one lda packed_message_chars-1,x - jsr $FFD2 + jsr JCHROUT ;; See if there is a char in the low nybl to print pla @@ -171,7 +171,7 @@ has_nybl: ;; X=1-14 = first 14 chars, so subtract one lda packed_message_chars-1,x - jsr $FFD2 + jsr JCHROUT * pla tay @@ -207,7 +207,7 @@ unpack_literal_char: tya pha lda (temp_string_ptr),y - jsr $ffd2 + jsr JCHROUT pla tay rts diff --git a/c64/basic/printf.s b/c64/basic/printf.s index c1edc71c..ceb4337b 100644 --- a/c64/basic/printf.s +++ b/c64/basic/printf.s @@ -112,7 +112,7 @@ not_hexword: not_pointer: ;; Print character - jsr $ffd2 + jsr JCHROUT printf_nextchar: jsr printf_advance @@ -148,11 +148,11 @@ printf_printhexbyte: cmp #$3A bcc + adc #6 -* jsr $ffd2 +* jsr JCHROUT pla and #$0f ora #$30 cmp #$3A bcc + adc #6 -* jmp $ffd2 +* jmp JCHROUT diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index d01967ca..5914c280 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -17,7 +17,7 @@ wedge_dos: ;; Set remaining file parameters; channel 15 is a typical one for commands lda #$0F ldy #$0F - jsr $FFBA ; SETLFS + jsr JSETFLS ;; Now we have to check what the user wants us to do diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index e4dd19ca..3f6150db 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -108,6 +108,47 @@ .alias ILOAD $0330 .alias ISAVE $0331 + ;; Kernal jump table + .alias JCINT $FF81 + .alias JIOINIT $FF84 + .alias JRAMTAS $FF87 + .alias JRESTOR $FF8A + .alias JVECTOR $FF8D + .alias JSETMSG $FF90 + .alias JSECOND $FF93 + .alias JTKSA $FF96 + .alias JMEMTOP $FF99 + .alias JMEMBOT $FF9C + .alias JSCNKEY $FF9F + .alias JSETTMO $FFA2 + .alias JACPTR $FFA5 + .alias JCIOUT $FFA8 + .alias JUNTLK $FFAB + .alias JUNLSN $FFAE + .alias JLISTEN $FFB1 + .alias JTALK $FFB4 + .alias JREADST $FFB7 + .alias JSETFLS $FFBA + .alias JSETNAM $FFBD + .alias JOPEN $FFC0 + .alias JCLOSE $FFC3 + .alias JCHKIN $FFC6 + .alias JCHKOUT $FFC9 + .alias JCLRCHN $FFCC + .alias JCHRIN $FFCF + .alias JCHROUT $FFD2 + .alias JLOAD $FFD5 + .alias JSAVE $FFD8 + .alias JSETTIM $FFDB + .alias JRDTIM $FFDE + .alias JSTOP $FFE1 + .alias JGETIN $FFE4 + .alias JCLALL $FFE7 + .alias JUDTIM $FFEA + .alias JSCREEN $FFED + .alias JPLOT $FFF0 + .alias JIOBASE $FFF3 + ;; Under-ROM routines ;; (BASIC also includes them. XXX - We should de-duplicate them in a safe manner) .alias missed_nmi_flag $2A7 diff --git a/c64/kernal/ff81.s b/c64/kernal/ff81.jcint.s similarity index 100% rename from c64/kernal/ff81.s rename to c64/kernal/ff81.jcint.s diff --git a/c64/kernal/ff84.s b/c64/kernal/ff84.jioinit.s similarity index 100% rename from c64/kernal/ff84.s rename to c64/kernal/ff84.jioinit.s diff --git a/c64/kernal/ff87.s b/c64/kernal/ff87.jramtas.s similarity index 100% rename from c64/kernal/ff87.s rename to c64/kernal/ff87.jramtas.s diff --git a/c64/kernal/ff8a.s b/c64/kernal/ff8a.jrestor.s similarity index 100% rename from c64/kernal/ff8a.s rename to c64/kernal/ff8a.jrestor.s diff --git a/c64/kernal/ff8d.s b/c64/kernal/ff8d.jvector.s similarity index 100% rename from c64/kernal/ff8d.s rename to c64/kernal/ff8d.jvector.s diff --git a/c64/kernal/ff90.s b/c64/kernal/ff90.jsetmsg.s similarity index 100% rename from c64/kernal/ff90.s rename to c64/kernal/ff90.jsetmsg.s diff --git a/c64/kernal/ff93.s b/c64/kernal/ff93.jsecond.s similarity index 100% rename from c64/kernal/ff93.s rename to c64/kernal/ff93.jsecond.s diff --git a/c64/kernal/ff96.s b/c64/kernal/ff96.jtksa.s similarity index 100% rename from c64/kernal/ff96.s rename to c64/kernal/ff96.jtksa.s diff --git a/c64/kernal/ff99.s b/c64/kernal/ff99.jmemtop.s similarity index 100% rename from c64/kernal/ff99.s rename to c64/kernal/ff99.jmemtop.s diff --git a/c64/kernal/ff9c.s b/c64/kernal/ff9c.jmembot.s similarity index 100% rename from c64/kernal/ff9c.s rename to c64/kernal/ff9c.jmembot.s diff --git a/c64/kernal/ff9f.s b/c64/kernal/ff9f.jscnkey.s similarity index 100% rename from c64/kernal/ff9f.s rename to c64/kernal/ff9f.jscnkey.s diff --git a/c64/kernal/ffa2.s b/c64/kernal/ffa2.jsettmo.s similarity index 100% rename from c64/kernal/ffa2.s rename to c64/kernal/ffa2.jsettmo.s diff --git a/c64/kernal/ffa5.s b/c64/kernal/ffa5.jacptr.s similarity index 100% rename from c64/kernal/ffa5.s rename to c64/kernal/ffa5.jacptr.s diff --git a/c64/kernal/ffa8.s b/c64/kernal/ffa8.jciout.s similarity index 100% rename from c64/kernal/ffa8.s rename to c64/kernal/ffa8.jciout.s diff --git a/c64/kernal/ffab.s b/c64/kernal/ffab.juntlk.s similarity index 100% rename from c64/kernal/ffab.s rename to c64/kernal/ffab.juntlk.s diff --git a/c64/kernal/ffae.s b/c64/kernal/ffae.junlsn.s similarity index 100% rename from c64/kernal/ffae.s rename to c64/kernal/ffae.junlsn.s diff --git a/c64/kernal/ffb1.s b/c64/kernal/ffb1.jlisten.s similarity index 100% rename from c64/kernal/ffb1.s rename to c64/kernal/ffb1.jlisten.s diff --git a/c64/kernal/ffb4.s b/c64/kernal/ffb4.jtalk.s similarity index 100% rename from c64/kernal/ffb4.s rename to c64/kernal/ffb4.jtalk.s diff --git a/c64/kernal/ffb7.s b/c64/kernal/ffb7.jreadst.s similarity index 100% rename from c64/kernal/ffb7.s rename to c64/kernal/ffb7.jreadst.s diff --git a/c64/kernal/ffba.s b/c64/kernal/ffba.jsetfls.s similarity index 87% rename from c64/kernal/ffba.s rename to c64/kernal/ffba.jsetfls.s index 4e68df53..6ad1fe44 100644 --- a/c64/kernal/ffba.s +++ b/c64/kernal/ffba.jsetfls.s @@ -1,3 +1,3 @@ ; Set logical, first and second addresses ; C64 Programmer's Reference Guide Page 273 - jmp setlfs + jmp setfls diff --git a/c64/kernal/ffbd.s b/c64/kernal/ffbd.setnam.s similarity index 100% rename from c64/kernal/ffbd.s rename to c64/kernal/ffbd.setnam.s diff --git a/c64/kernal/ffc0.s b/c64/kernal/ffc0.jopen.s similarity index 100% rename from c64/kernal/ffc0.s rename to c64/kernal/ffc0.jopen.s diff --git a/c64/kernal/ffc3.s b/c64/kernal/ffc3.jclose.s similarity index 100% rename from c64/kernal/ffc3.s rename to c64/kernal/ffc3.jclose.s diff --git a/c64/kernal/ffc6.s b/c64/kernal/ffc6.jchkin.s similarity index 100% rename from c64/kernal/ffc6.s rename to c64/kernal/ffc6.jchkin.s diff --git a/c64/kernal/ffc9.s b/c64/kernal/ffc9.jchkout.s similarity index 100% rename from c64/kernal/ffc9.s rename to c64/kernal/ffc9.jchkout.s diff --git a/c64/kernal/ffcc.s b/c64/kernal/ffcc.jclrchn.s similarity index 100% rename from c64/kernal/ffcc.s rename to c64/kernal/ffcc.jclrchn.s diff --git a/c64/kernal/ffcf.s b/c64/kernal/ffcf.jchrin.s similarity index 100% rename from c64/kernal/ffcf.s rename to c64/kernal/ffcf.jchrin.s diff --git a/c64/kernal/ffd2.s b/c64/kernal/ffd2.jchrout.s similarity index 100% rename from c64/kernal/ffd2.s rename to c64/kernal/ffd2.jchrout.s diff --git a/c64/kernal/ffd5.s b/c64/kernal/ffd5.jload.s similarity index 100% rename from c64/kernal/ffd5.s rename to c64/kernal/ffd5.jload.s diff --git a/c64/kernal/ffd8.s b/c64/kernal/ffd8.jsave.s similarity index 100% rename from c64/kernal/ffd8.s rename to c64/kernal/ffd8.jsave.s diff --git a/c64/kernal/ffdb.s b/c64/kernal/ffdb.jsettim.s similarity index 100% rename from c64/kernal/ffdb.s rename to c64/kernal/ffdb.jsettim.s diff --git a/c64/kernal/ffde.s b/c64/kernal/ffde.jrdtim.s similarity index 100% rename from c64/kernal/ffde.s rename to c64/kernal/ffde.jrdtim.s diff --git a/c64/kernal/ffe1.s b/c64/kernal/ffe1.jstop.s similarity index 100% rename from c64/kernal/ffe1.s rename to c64/kernal/ffe1.jstop.s diff --git a/c64/kernal/ffe4.s b/c64/kernal/ffe4.jgetin.s similarity index 100% rename from c64/kernal/ffe4.s rename to c64/kernal/ffe4.jgetin.s diff --git a/c64/kernal/ffe7.s b/c64/kernal/ffe7.jclall.s similarity index 100% rename from c64/kernal/ffe7.s rename to c64/kernal/ffe7.jclall.s diff --git a/c64/kernal/ffea.s b/c64/kernal/ffea.judtim.s similarity index 100% rename from c64/kernal/ffea.s rename to c64/kernal/ffea.judtim.s diff --git a/c64/kernal/ffed.s b/c64/kernal/ffed.jscreen.s similarity index 100% rename from c64/kernal/ffed.s rename to c64/kernal/ffed.jscreen.s diff --git a/c64/kernal/fff0.s b/c64/kernal/fff0.jplot.s similarity index 100% rename from c64/kernal/fff0.s rename to c64/kernal/fff0.jplot.s diff --git a/c64/kernal/fff3.s b/c64/kernal/fff3.jiobase.s similarity index 85% rename from c64/kernal/fff3.s rename to c64/kernal/fff3.jiobase.s index 4870c7ba..ee3a1730 100644 --- a/c64/kernal/fff3.s +++ b/c64/kernal/fff3.jiobase.s @@ -3,7 +3,7 @@ ; (http://codebase64.org/doku.php?id=base:kernalreference) ; ; As there is nothing between here and $FFFA, we can just hard code this in place. -LDY #$DC -LDX #$00 -RTS + ldy #$DC + ldx #$00 + rts diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 1a853b95..7068cc72 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -44,12 +44,12 @@ print_filename_loop: beq + ldx # Date: Fri, 12 Jul 2019 21:17:09 +0200 Subject: [PATCH 36/90] improved LOAD routine, now prints out start/end addresses in Final cart style --- c64/kernal/load.s | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 7068cc72..f75c4c1d 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -15,7 +15,9 @@ ;; $AC = current pointer for loading/verifying ;; $C1 = similar to the above. -;; XXX honor MSGFLG bit 6, add VERIFY support + ;; XXX honor MSGFLG bit 6, add VERIFY support + ;; XXX rework the message print-out to be shared with SAVE + ;; XXX add VERIFY support load: @@ -120,6 +122,7 @@ sent_filename: bcs load_error ;; Get load address and store it if secondary address is zero + ;; XXX add secondary address check jsr iec_rx_byte bcs file_not_found_error ldx current_secondary_address @@ -132,12 +135,25 @@ sent_filename: beq + sta load_save_start_ptr+1 * - ;; Display LOADING + ;; Display LOADING / VERIFYING and start address lda MSGFLG - bpl + + bpl load_loop + lda kernal_load_or_verify_flag + beq + jsr printf - .byte "LOADING",$0D,0 + .byte "VERIFYING", 0 + jmp load_print_start_addr * + jsr printf + .byte "LOADING", 0 +load_print_start_addr: + jsr printf + .byte " FROM $",0 + lda load_save_start_ptr+1 + jsr printf_printhexbyte + lda load_save_start_ptr+0 + jsr printf_printhexbyte + load_loop: ;; We are now ready to receive bytes jsr iec_rx_byte @@ -170,6 +186,18 @@ load_loop: beq load_loop load_done: + ;; Display end address + lda MSGFLG + bpl + + jsr printf + .byte " TO $",0 + lda load_save_start_ptr+1 + jsr printf_printhexbyte + lda load_save_start_ptr+0 + jsr printf_printhexbyte + lda #$0D + jsr JCHROUT +* ;; Close file on drive ;; Command drive to stop talking and to close the file @@ -201,6 +229,12 @@ load_done: load_error: + ;; Advance cursor to next line, if needed + lda MSGFLG + bpl + + lda #$0D + jsr JCHROUT +* ;; XXX - Indicate KERNAL (not BASIC) LOAD error condtion sec lda #28 From 6d521967e5c47c16dd13321236f4993527c69d4a Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 12 Jul 2019 23:09:27 +0200 Subject: [PATCH 37/90] implemented CIOUT routine --- c64/basic/,aliases.s | 2 ++ c64/kernal/,aliases.s | 2 ++ c64/kernal/ciout.s | 28 ++++++++++++++++++++++++++++ c64/kernal/unlsn.s | 15 ++++++++++++++- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index 8a4733fc..a9898755 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -57,6 +57,8 @@ ; Keys down clears bits. STOP=bit 7, C= bit 6, SPACE bit 4, CTRL bit 2 .alias BUCKYSTATUS $91 .alias load_or_verify_flag $93 + .alias C3PO $94 ; flag - is BSOUR content valid + .alias BSOUR $95 ; serial bus buffered output byte .alias current_file_num $98 .alias LDTND $98 ; number of entries in LAT / FAT / SAT tables .alias DFLTN $99 diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index 3f6150db..e5616ae3 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -8,6 +8,8 @@ ; Keys down clears bits. STOP=bit 7, C= bit 6, SPACE bit 4, CTRL bit 2 .alias BUCKYSTATUS $91 .alias kernal_load_or_verify_flag $93 + .alias C3PO $94 ; flag - is BSOUR content valid + .alias BSOUR $95 ; serial bus buffered output byte .alias current_file_num $98 .alias LDTND $98 ; number of entries in LAT / FAT / SAT tables .alias DFLTN $99 diff --git a/c64/kernal/ciout.s b/c64/kernal/ciout.s index e389806a..cc6f666a 100644 --- a/c64/kernal/ciout.s +++ b/c64/kernal/ciout.s @@ -1,3 +1,31 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide ciout: + + ;; This routine is documented in 'Compute's Mapping the Commodore 64', page 224 + + pha + lda C3PO + bne ciout_send_byte + + ;; Nothing to send - set buffer as valid, store byte there + inc + sta C3PO + + ;; Clear carry flag to indicate success + clc + +ciout_store_in_buffer: + + ;; Store in the buffer data to be sent next, return + pla + sta BSOUR rts + +ciout_send_byte: + + ;; Send previous data + lda BSOUR + clc ; don't send with EOI + jsr iec_tx_byte + jmp ciout_store_in_buffer + diff --git a/c64/kernal/unlsn.s b/c64/kernal/unlsn.s index 24180aa5..8dc84fcf 100644 --- a/c64/kernal/unlsn.s +++ b/c64/kernal/unlsn.s @@ -2,7 +2,20 @@ unlsn: - ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 224 + ;; This routine is documented in 'Compute's Mapping the Commodore 64', page 224 + + ;; First check whether we have something to be sent in the buffer + lda C3PO + beq + + lda BSOUR + sec ; send it with EOI + jsr iec_tx_byte ; XXX what about the status of this operation? + ;; Mark the buffer as invalid + lda #$00 + sta C3PO +* + ;; Buffer empty send the command lda #$3F jmp iec_tx_command + From ef10c90ee64ecd472f27a4efb1c02a3b32c9a99f Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 13 Jul 2019 13:48:03 +0200 Subject: [PATCH 38/90] compilation fix --- c64/kernal/ciout.s | 7 +++---- c64/kernal/iec_turnaround_to_talk.s | 12 ++++++++++++ c64/kernal/load.s | 3 ++- 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 c64/kernal/iec_turnaround_to_talk.s diff --git a/c64/kernal/ciout.s b/c64/kernal/ciout.s index cc6f666a..7894c5eb 100644 --- a/c64/kernal/ciout.s +++ b/c64/kernal/ciout.s @@ -6,11 +6,10 @@ ciout: pha lda C3PO bne ciout_send_byte - + ;; Nothing to send - set buffer as valid, store byte there - inc - sta C3PO - + inc C3PO + ;; Clear carry flag to indicate success clc diff --git a/c64/kernal/iec_turnaround_to_talk.s b/c64/kernal/iec_turnaround_to_talk.s new file mode 100644 index 00000000..d372ad00 --- /dev/null +++ b/c64/kernal/iec_turnaround_to_talk.s @@ -0,0 +1,12 @@ + ;; According to http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf + ;; pages 7--8. + ;; See also https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc + +iec_turnaround_to_talk: + + ;; XXX implement this + + clc + rts + + diff --git a/c64/kernal/load.s b/c64/kernal/load.s index f75c4c1d..72db27b7 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -198,7 +198,8 @@ load_done: lda #$0D jsr JCHROUT * - ;; Close file on drive + ;; Close file on drive - start by turnaround to talker + jsr iec_turnaround_to_talk ;; Command drive to stop talking and to close the file jsr untlk From b1e882b02128c106dbe5689cc569349c78bf279f Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 15 Jul 2019 20:14:52 +0200 Subject: [PATCH 39/90] added turnaround to talker to IEC support --- c64/kernal/iec_turnaround_to_talk.s | 14 ++++++++++---- c64/kernal/iec_wait_for_data_pull.s | 7 +++++++ c64/kernal/load.s | 22 ++++++++++------------ 3 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 c64/kernal/iec_wait_for_data_pull.s diff --git a/c64/kernal/iec_turnaround_to_talk.s b/c64/kernal/iec_turnaround_to_talk.s index d372ad00..c8cc9b47 100644 --- a/c64/kernal/iec_turnaround_to_talk.s +++ b/c64/kernal/iec_turnaround_to_talk.s @@ -4,9 +4,15 @@ iec_turnaround_to_talk: - ;; XXX implement this - + ;; First make sure both CLK, DATA and ATN are released at our side + jsr iec_release_atn + jsr iec_release_clk_data + + ;; Wait till device releases CLK line + jsr iec_wait_for_clk_release + + ;; Pull CLK line, it should be held by talker + jsr iec_pull_clk_release_data + clc rts - - diff --git a/c64/kernal/iec_wait_for_data_pull.s b/c64/kernal/iec_wait_for_data_pull.s new file mode 100644 index 00000000..d83b57d4 --- /dev/null +++ b/c64/kernal/iec_wait_for_data_pull.s @@ -0,0 +1,7 @@ + +iec_wait_for_data_pull: + lda CI2PRA + ;; Check the highest bit, which is DATA IN, + ;; (highest bit set = negative value) + bmi iec_wait_for_data_pull + rts diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 72db27b7..ccf77051 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -198,20 +198,18 @@ load_done: lda #$0D jsr JCHROUT * - ;; Close file on drive - start by turnaround to talker - jsr iec_turnaround_to_talk - + ;; Close file on drive + ;; Command drive to stop talking and to close the file jsr untlk - - ;; XXX XXX code below runs into infinite loop - so for now just quit - clc - cli - rts - + + ;; Turnaround to talker - according to https://www.pagetable.com/?p=1135 + ;; the turnaround only happens after a command + jsr iec_turnaround_to_talk + lda current_device_number jsr listen - + lda #$e0 jsr iec_tx_command @@ -227,7 +225,7 @@ load_done: clc cli rts - + load_error: ;; Advance cursor to next line, if needed @@ -239,7 +237,7 @@ load_error: ;; XXX - Indicate KERNAL (not BASIC) LOAD error condtion sec lda #28 - + ;; Re-enable interrupts and return cli ;; (iec_tx_byte will have set/cleared C flag and put result code From 51dc3fabf4b451ecb04eedd75869b051f31ccfca Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 15 Jul 2019 20:38:37 +0200 Subject: [PATCH 40/90] LOAD routine now properly closes drive communication --- bin/basic | Bin 8192 -> 8192 bytes bin/chargen | Bin 0 -> 4096 bytes bin/kernal | Bin 8192 -> 8192 bytes c64/kernal/load.s | 7 +++++++ 4 files changed, 7 insertions(+) create mode 100644 bin/chargen diff --git a/bin/basic b/bin/basic index 2f38515c7f53f2222863cb9756707f716c5e75cd..ce99e4f6bbd5c6a47185e8e68c13dcab42c02c07 100644 GIT binary patch delta 1003 zcmc(dPe>F|9LMLc`_J8(Xth;KpJIe%Qg(86H~(yC^aK&YONHwiC@j*UJ!Hs=G!g}} z_KK(omZ@jXtg}0!WvwmbA#&}|5_p#mVnMieFd}Svx*629L%iYfo8P?moiCs7Z@6)| zkyGQY*fjTmp-WJd@$mx+9MjN8rYh`Iah+6;-BJU1tYZ)F&9Km^Mk(0?hIDgml@G!o^u=*4keV~3HOSTWfTfT48<%Z6-t@|Lvn!+~Ia>o^5pn#<|98o~o6JK+y8??0hD0o=|O*$?hE^cbrnKp|& zi8-Q4_n_?&F`Y7iStVv~Yq9_s70ekK3wURM_Xhl+K%2U&Z0-Ii&vn)6thx^dDwXl!?=>r?8Yie=1G6gf+RGU}hWz%uXxdtgURkZ^t+m7CRONFiDvqw$2hbTuH{FJ&97T*PhTb?% z5ed6cV*L>ZZ3*H7gix&zU_u(YE0l3#ggr_M?X(k_#e?8tCj z;|KIXbC|!+T5KrHdIg^bCkgt@mh_4QS1C2PTB!xMP3#stNe+r6%&2bAWtwX?cIR~R zN)UTG8Kp;chgtBHRjQ`e=4yCPEj5S#YG+Ki<1_(+lpx|blR5B7i(Y{ zb=!{iUe`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tx_command.s | 9 ++------- c64/kernal/iec_tx_common.s | 7 +------ c64/kernal/irq_handler.s | 8 ++++---- c64/kernal/open.s | 3 --- c64/kernal/vector.s | 6 +++--- 7 files changed, 11 insertions(+), 27 deletions(-) diff --git a/c64/kernal/iec_turnaround_to_listen.s b/c64/kernal/iec_turnaround_to_listen.s index f8c6f237..964ef0ed 100644 --- a/c64/kernal/iec_turnaround_to_listen.s +++ b/c64/kernal/iec_turnaround_to_listen.s @@ -17,8 +17,6 @@ iec_turnaround_to_listen: bne - ;; Timeout - jsr printf - .byte "DBG: TURNAROUND FAILED",$0d,$00 sec rts diff --git a/c64/kernal/iec_tx_byte.s b/c64/kernal/iec_tx_byte.s index d7e2e183..946c248d 100644 --- a/c64/kernal/iec_tx_byte.s +++ b/c64/kernal/iec_tx_byte.s @@ -5,8 +5,8 @@ iec_tx_byte: + ;; Store byte to send on the stack pha - php ;; Notify all devices that we are going to send a byte ;; and it is going to be a data byte (released ATN) @@ -15,7 +15,6 @@ iec_tx_byte: ;; Common part of iec_txbyte and iec_tx_common - waits for devices ;; and transmits a byte - plp pla jsr iec_tx_common diff --git a/c64/kernal/iec_tx_command.s b/c64/kernal/iec_tx_command.s index f68764e5..7cde1dce 100644 --- a/c64/kernal/iec_tx_command.s +++ b/c64/kernal/iec_tx_command.s @@ -3,6 +3,7 @@ iec_tx_command: + ;; Store command to send on the stack pha ;; Notify all devices that we are going to send a byte @@ -20,9 +21,6 @@ iec_tx_command: ;; No devices present on the bus, so we can immediately return with device not found pla - jsr printf - .byte "DBG: NO DEVICES AT ALL", $0D, 0 - jsr iec_set_idle jmp kernalerror_DEVICE_NOT_FOUND * @@ -47,14 +45,11 @@ iec_tx_command: lda CI2PRA and #BIT_CI2PRA_DAT_IN ; XXX try to optimize this, move to separate routine beq + - + ;; XXX possible optimization of the flow above: for many commands it is enough ;; to wait for the DATA being pulled, as confirmation is expected from ;; a single device only - but not sure if it's worth the trouble - jsr printf - .byte "DBG: NO CONFIRMATION FROM DEVICE", $0D, 0 - jsr iec_set_idle jmp kernalerror_DEVICE_NOT_FOUND * diff --git a/c64/kernal/iec_tx_common.s b/c64/kernal/iec_tx_common.s index eb1ba991..8de7c891 100644 --- a/c64/kernal/iec_tx_common.s +++ b/c64/kernal/iec_tx_common.s @@ -7,16 +7,11 @@ iec_tx_common: ;; Store the byte to send on a stack pha - - ;; Store the status register - carry flag is used to determine whether - ;; this is the last byte of the stream - php - + ;; Wait till all receivers are ready, they should all release DATA jsr iec_wait_for_data_release ;; At this point a delay 256 usec or more is considered EOI - add waits if necessary - plp bcc + jsr iec_wait100us jsr iec_wait100us diff --git a/c64/kernal/irq_handler.s b/c64/kernal/irq_handler.s index 1b8b4730..82bbaac7 100644 --- a/c64/kernal/irq_handler.s +++ b/c64/kernal/irq_handler.s @@ -6,7 +6,7 @@ irq_handler: ;; $EA61 - Check keyboard, but don't update timer? https://github.com/cc65/cc65/issues/324 ;; $EA81 - https://www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb ;; Also the $0314 vector is widely used (e.g., https://www.lemon64.com/forum/viewtopic.php?t=2112&sid=6ea01982b26da69783120a7923ca46fb) - + ;; Save registers ;; Sequence according to Compute's Mapping the 64 p73 pha @@ -17,7 +17,7 @@ irq_handler: ;; Call interrupt routine ;; (but only if initialised) - lda $0314 - ora $0315 + lda CINV + ora CINV+1 beq default_irq_handler - jmp ($0314) + jmp (CINV) diff --git a/c64/kernal/open.s b/c64/kernal/open.s index e10ea78e..7875943b 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -95,9 +95,6 @@ open_iec: jsr iec_turnaround_to_listen bcs open_iec_error - jsr printf - .byte "DBG: TURNAROUND SUCCEEDED", $0D, 0 - ;; Indicate success lda #$00 clc diff --git a/c64/kernal/vector.s b/c64/kernal/vector.s index 2a8c6e5d..027bf14a 100644 --- a/c64/kernal/vector.s +++ b/c64/kernal/vector.s @@ -61,9 +61,9 @@ vector_restore: ;; XXX below we have quite a lot of data... should we decouple them? vector_defaults: - .word $0000 ;; CINV XXX implement this - .word $0000 ;; CBINV XXX implement this - .word $0000 ;; NMINV XXX implement this + .word default_irq_handler ;; CINV + .word $0000 ;; CBINV XXX implement this + .word $0000 ;; NMINV XXX implement this .word open ;; IOPEN .word close ;; ICLOSE From 8cb91d0139fd50d9742b9741815bf29406829abd Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Tue, 16 Jul 2019 18:26:51 +0200 Subject: [PATCH 42/90] LOAD command can now report file not found error --- c64/kernal/iec_rx_byte.s | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/c64/kernal/iec_rx_byte.s b/c64/kernal/iec_rx_byte.s index 2d28465f..446956ce 100644 --- a/c64/kernal/iec_rx_byte.s +++ b/c64/kernal/iec_rx_byte.s @@ -113,5 +113,6 @@ iec_rx_set_eoi: ora #$40 sta IOSTATUS - clc + sec ; XXX check if ACPTR also uses Carry flag to indicate problems, + ; currently this is used by our LOAD routine to detect file not found rts From 3e9ada4a95fa1380ca6ccb9838f3e43b2b501e28 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Tue, 16 Jul 2019 18:52:02 +0200 Subject: [PATCH 43/90] Revert last commit, caused regressions This reverts commit 8cb91d0139fd50d9742b9741815bf29406829abd. --- c64/kernal/iec_rx_byte.s | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/c64/kernal/iec_rx_byte.s b/c64/kernal/iec_rx_byte.s index 446956ce..2d28465f 100644 --- a/c64/kernal/iec_rx_byte.s +++ b/c64/kernal/iec_rx_byte.s @@ -113,6 +113,5 @@ iec_rx_set_eoi: ora #$40 sta IOSTATUS - sec ; XXX check if ACPTR also uses Carry flag to indicate problems, - ; currently this is used by our LOAD routine to detect file not found + clc rts From 3cae7f7366556e184cde3753eaba348ba06427dd Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Tue, 16 Jul 2019 20:08:42 +0200 Subject: [PATCH 44/90] another attempt to fix file not found case --- c64/kernal/iec_rx_byte.s | 52 +++++++++++++++++------------- c64/kernal/iec_wait_for_clk_pull.s | 6 ---- 2 files changed, 30 insertions(+), 28 deletions(-) delete mode 100644 c64/kernal/iec_wait_for_clk_pull.s diff --git a/c64/kernal/iec_rx_byte.s b/c64/kernal/iec_rx_byte.s index 2d28465f..943ce880 100644 --- a/c64/kernal/iec_rx_byte.s +++ b/c64/kernal/iec_rx_byte.s @@ -18,25 +18,21 @@ iec_rx_byte: ;; If over 200 usec (205 cycles on NTSC machine) , then it is EOI. ;; Loop iteraction takes 13 cycles, 17 full iterations are enough - ldx #$11 ; 2 cycles -iec_rx_clk_wait: - lda CI2PRA ; 4 cycles - rol ; 2 cycles, to put BIT_CI2PRA_CLK_IN as the last bit - bpl iec_rx_not_eoi ; 2 cycles if not jumped - dex ; 2 cycles - bne iec_rx_clk_wait ; 3 cycles if jumped - - ;; Timeout - wait a little bit more to see if EOI confirmation is needed - ;; (if CLK not pulled within 256 usec - it's not needed, see - ;; https://www.pagetable.com/?p=1135, chapters End of Stream and Empty Stream) - jsr iec_wait60us - lda CI2PRA - rol - bmi iec_rx_set_eoi + ldx #$11 ; 2 cycles +iec_rx_clk_wait1: + lda CI2PRA ; 4 cycles + rol ; 2 cycles, to put BIT_CI2PRA_CLK_IN as the last bit + bpl iec_rx_not_eoi ; 2 cycles if not jumped + dex ; 2 cycles + bne iec_rx_clk_wait1 ; 3 cycles if jumped + ;; Timeout - either this is the last byte of stream, or the stream is empty at all. + ;; Mark end of stream in IOSTATUS jsr iec_rx_set_eoi - - ;; Pull data for 60 usec to confirm + +iec_rx_not_empty: + + ;; Pull data for 60 usec to confirm it jsr iec_release_clk_pull_data jsr iec_wait60us jsr iec_release_clk_data @@ -86,9 +82,22 @@ iec_rx_bit_loop: ror pha - ;; Wait for CLK to be pulled again - jsr iec_wait_for_clk_pull - + ;; Wait for CLK to be pulled again, over 300 usec (307 cycles on NTSC) + ;; consider this a timeout + ldy #$19 ; 2 cycles +iec_rx_clk_wait2: + lda CI2PRA ; 4 cycles + rol ; 2 cycles, to put BIT_CI2PRA_CLK_IN as the last bit + bpl + ; 2 cycles if not jumped + dey ; 2 cycles + bne iec_rx_clk_wait2 ; 3 cycles if jumped + + ;; Timeout + jsr iec_rx_set_eoi + pla + sec ; XXX confirm that sec is really a way to report timeout here + rts +* ;; More bits? dex bpl iec_rx_bit_loop @@ -112,6 +121,5 @@ iec_rx_set_eoi: lda IOSTATUS ora #$40 sta IOSTATUS - - clc + rts diff --git a/c64/kernal/iec_wait_for_clk_pull.s b/c64/kernal/iec_wait_for_clk_pull.s deleted file mode 100644 index 590903d1..00000000 --- a/c64/kernal/iec_wait_for_clk_pull.s +++ /dev/null @@ -1,6 +0,0 @@ - -iec_wait_for_clk_pull: - lda CI2PRA - rol ; to put BIT_CI2PRA_CLK_IN as the last (sign) bit - bmi iec_wait_for_clk_pull - rts From ecf1b3aa50809d789deaf45b9d42790e864c361b Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Tue, 16 Jul 2019 22:22:01 +0200 Subject: [PATCH 45/90] small improvements for LOAD command and IEC routines --- c64/basic/cmd_load.s | 5 ++--- c64/basic/set_sane_devnum.s | 17 +++++++++++++++++ c64/basic/wedge_dos.s | 24 ++++++++++-------------- c64/kernal/chkin.s | 16 ++++++++++++++++ c64/kernal/chkout.s | 14 ++++++++++++++ c64/kernal/close.s | 25 ++++++++++--------------- c64/kernal/findfls.s | 23 +++++++++++++++++++++++ c64/kernal/load.s | 12 ++++-------- 8 files changed, 96 insertions(+), 40 deletions(-) create mode 100644 c64/basic/set_sane_devnum.s create mode 100644 c64/kernal/findfls.s diff --git a/c64/basic/cmd_load.s b/c64/basic/cmd_load.s index 9713a41b..fa5748c6 100644 --- a/c64/basic/cmd_load.s +++ b/c64/basic/cmd_load.s @@ -20,9 +20,8 @@ cmd_load: * jsr JSETMSG - ;; XXX temporary, to set valid device number - lda #$08 - sta current_device_number + ;; XXX handle device number from arguments, if not present, use the call below + jsr set_sane_devnum ;; Set filename and length lda #$00 diff --git a/c64/basic/set_sane_devnum.s b/c64/basic/set_sane_devnum.s new file mode 100644 index 00000000..501bc5d1 --- /dev/null +++ b/c64/basic/set_sane_devnum.s @@ -0,0 +1,17 @@ + +set_sane_devnum: + + ;; Take last device number, make sure it's a drive + ;; If not, set to 8 (first drive number) + ;; Device number is left in X, for SETFLS Kernal routine + + ;; Note: if tape support is introduced here, make sure DOS wedge won't get broken + + ldx current_device_number + cpx #$07 + bpl + + bcs + + ldx #$08 + stx current_device_number +* + rts diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 5914c280..167338f7 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -5,16 +5,12 @@ wedge_dos: ;; Close all the channels, so that wedge has full control jsr wedge_dos_CLALL - - ;; Take last device number, make sure it's a drive - ;; If not, set to 8 (first drive number) - ldx DFLTN - cpx #$07 - bpl + - bcs + - ldx #$08 -* - ;; Set remaining file parameters; channel 15 is a typical one for commands + + ;; Make sure current device number is sane + jsr set_sane_devnum + + ;; Set remaining file parameters (X already set by set_sane_devnum); + ;; channel 15 is a typical one for commands lda #$0F ldy #$0F jsr JSETFLS @@ -67,7 +63,7 @@ wedge_dos_change_drive: bcs + jmp do_ILLEGAL_DEVICE_NUMBER_error * - sta DFLTN + sta current_device_number jmp basic_end_of_line wedge_dos_status: @@ -77,7 +73,7 @@ wedge_dos_status: ;; Set remaining file parameters, open the channel lda #$00 ; empty file name - jsr $FFBD ; SETNAM + jsr JSETNAM jsr wedge_dos_OPEN bcc + jmp do_DEVICE_NOT_PRESENT_error @@ -90,8 +86,8 @@ wedge_dos_status: * ;; Print out everything retrieved from the drive bne + - jsr $FFCF ; CHRIN - jsr $FFD2 ; CHROUT + jsr JCHRIN + jsr JCHROUT jmp - * ;; Clean-up and exit diff --git a/c64/kernal/chkin.s b/c64/kernal/chkin.s index 99937d2e..ffa509d7 100644 --- a/c64/kernal/chkin.s +++ b/c64/kernal/chkin.s @@ -1,3 +1,19 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide + chkin: + + ;; Implemented according to 'C64 Programmers Reference Guide', page 277 + + ;; First retrieve the FAT/LAT/SAT table index (and check if file is open) + + ; txa + ; jsr find_fls + ; bcs kernalerror_FILE_NOT_OPEN + + ;; Now we have table index in Y - check if file is open for reading + + ;; XXX continue implementation + rts + + diff --git a/c64/kernal/chkout.s b/c64/kernal/chkout.s index 262a4c59..36b5a683 100644 --- a/c64/kernal/chkout.s +++ b/c64/kernal/chkout.s @@ -1,3 +1,17 @@ ; Function defined on pp272-273 of C64 Programmers Reference Guide + chkout: + + ;; Implemented according to 'C64 Programmers Reference Guide', page 278 + + ;; First retrieve the FAT/LAT/SAT table index (and check if file is open) + + ; txa + ; jsr find_fls + ; bcs kernalerror_FILE_NOT_OPEN + + ;; Now we have table index in Y - check if file is open for writing + + ;; XXX continue implementation + rts diff --git a/c64/kernal/close.s b/c64/kernal/close.s index e89ace83..c2b7a245 100644 --- a/c64/kernal/close.s +++ b/c64/kernal/close.s @@ -4,19 +4,14 @@ close: ;; Implemented accorging to 'C64 Programmers Reference Guide', page 281 ;; XXX this needs more testing (opening 10 files at once, closing in various orders, etc) once the code is more mature - + ;; Find the LAT / SAT / FAT entry which LAT corresponds to A - - ldy LDTND - beq close_error_not_found ; table empty -* - dey - bmi close_error_not_found ; no more entries - cmp LAT, y - bne - ; does not match, try the next one - + + jsr find_fls + bcs close_error_not_found ;; XXX can we report error in IOSTATUS here? + ;; We have the entry index in Y - + ;; XXX some devices (like IEC) needs special support here, to free their internal resources! ;; Just make sure the Y register value is kept, or redo ldy DFTLN * @@ -33,9 +28,9 @@ close: * ;; Decrement the list size variable dec LDTND - ;; FALLTHROUGH (for now) - success - + + ;; FALLTHROUGH - success + close_error_not_found: - - ;; XXX it seems that this function can't report errors, am I right? + rts diff --git a/c64/kernal/findfls.s b/c64/kernal/findfls.s new file mode 100644 index 00000000..b0ad82a6 --- /dev/null +++ b/c64/kernal/findfls.s @@ -0,0 +1,23 @@ + +;; Just a helper routine + +;; Find the LAT / SAT / FAT entry index where LAT corresponds to A, returns index in Y +;; Carry flag set means not found + +find_fls: + + ldy LDTND + beq find_fls_not_found ; table empty +* + dey + bmi find_fls_not_found ; no more entries + cmp LAT, y + bne - ; does not match, try the next one + + clc + rts + +find_fls_not_found: + + sec + rts diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 192397b4..bc6b3ac6 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -54,9 +54,6 @@ print_filename_loop: iny jmp print_filename_loop * - lda #$0d - jsr JCHROUT - ;; XXX - Use default device number ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf ;; p13, 16. @@ -145,11 +142,11 @@ sent_filename: lda kernal_load_or_verify_flag beq + jsr printf - .byte "VERIFYING", 0 + .byte $0D, "VERIFYING", 0 jmp load_print_start_addr * jsr printf - .byte "LOADING", 0 + .byte $0D, "LOADING", 0 load_print_start_addr: jsr printf .byte " FROM $",0 @@ -223,9 +220,8 @@ load_done: ;; Set IEC status back to idle jsr iec_set_idle - ;; Return last address written to +1 - ;; (Even though Compute's Mapping the 64 says without the +1. - ;; I'm suspicious. Will have to check behavour on an original C64) + ;; Return last address - Compute's Mapping the 64 says without the '+1', + ;; checked on original ROMs that this is really the case ldx load_save_start_ptr+0 ldy load_save_start_ptr+1 From 152120a3fe1ee6116bb8dcf761f64d7d2754cf27 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 17 Jul 2019 16:56:44 +0200 Subject: [PATCH 46/90] more IEC error reporting work --- bin/basic | Bin 8192 -> 8192 bytes bin/kernal | Bin 8192 -> 8192 bytes c64/basic/,aliases.s | 63 ++++++++- c64/basic/cmd_load.s | 5 +- .../{set_sane_devnum.s => select_device.s} | 3 +- c64/basic/wedge_dos.s | 7 +- c64/kernal/,aliases.s | 61 +++++++++ c64/kernal/errors.s | 123 +++++++++++------- c64/kernal/iec_rx_byte.s | 12 +- c64/kernal/load.s | 78 ++++++----- 10 files changed, 252 insertions(+), 100 deletions(-) rename c64/basic/{set_sane_devnum.s => select_device.s} (87%) diff --git a/bin/basic b/bin/basic index ce99e4f6bbd5c6a47185e8e68c13dcab42c02c07..5563b9cd74e92ecafd57e28af98f9bb8953c3bd6 100644 GIT binary patch delta 648 zcmZp0XmDUzwQk#njVuqCn9NsCe#WGul)rMRWvlg4t5zF@B^#F7vf5o>_Q_wlfMJoX zLhXhPAogSvX2tr$8&F~5hB&y$felh%_O2DEYObz!Tz`1OK_CV}YbcGXhDcsL+%h6H zP+9%vV3rCN76qZzZIjP&=;^Yoe74=^-HMeAtvgpTEMi>1p>Xy81lCojeAcdQ({0gH z&|0}vyVZ87POBX#{4_b86^vFY?Afr0LE-%W4ZlzFeh_#NFoAWEn9qmxa~YUk_>`=i zY{Zq#RJ3yPd@j++=G^l|fktO2yk514eQVOx@KXXmfoz4>lTUKVGW}mQ`308&&$3+) z*acWNFfHOpV3;h&Ey<>Ea5d0^YPU{^)PoYvR%Nau!iX*12{Qse#7m> z$i8lsPvTmIb(3v*l|ZgYL`L6o$B3W#zP SC}mT4wH6o_o3{zL@B;v*>R93c delta 687 zcmZp0XmDUzwN7I7MwSOmOnECOKV#BS5?Qs>vekO2RjZA{k_}63S?w+``-rSsz_7?x zp?1Rt5PPx-vts?;4X7}2LmXUW*9Ivtd)Eq7HCI%xrbeUH^+wSvr#Y%?Oohum@F)rXxxcYwr>#9>eYuC2vw&*En zu3W0!YP(dY)eaPVTAa@OhAS2RuUt0s0lNUp2Bt+ElWn=xnI^29oW`x{JJW}I@k$1T zz5f+BR!v~`nX+~fzXH=Lh3)?@a4MYtuW;$V&!d$-+^ZDim%BK*TPe7B1~K@Qtj*D3 z&XHrzQDV-KVg?$mz`6=(jKa3bg`84MlB*{7a%OvruL3%-Y9&)^HITM#wOjeW)yikq zA|NM2;p3`B>|2wjhMyAn31kD&0_H^w5?hl>!>1;_=n(j}G$S>xHDhVU1ty6E1=iJ* zA8{G5DZE+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:42 +0200 Subject: [PATCH 47/90] IEC routines can now be called with enabled IRQs --- c64/kernal/iec_rx_byte.s | 6 ++++++ c64/kernal/iec_tx_common.s | 5 +++++ c64/kernal/load.s | 12 +++--------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/c64/kernal/iec_rx_byte.s b/c64/kernal/iec_rx_byte.s index d91a857d..4a7eb996 100644 --- a/c64/kernal/iec_rx_byte.s +++ b/c64/kernal/iec_rx_byte.s @@ -4,6 +4,10 @@ iec_rx_byte: + ;; Timing is critical here - execute on disabled IRQs + php + sei + ;; First, we wait for the talker to release the CLK line jsr iec_wait_for_clk_release @@ -95,6 +99,7 @@ iec_rx_clk_wait2: ;; Timeout jsr kernalstatus_EOI pla + plp sec ; XXX confirm that sec is really a way to report timeout here rts * @@ -112,6 +117,7 @@ iec_rx_clk_wait2: pla ;; Return no-error + plp clc rts diff --git a/c64/kernal/iec_tx_common.s b/c64/kernal/iec_tx_common.s index 8de7c891..ef9a5097 100644 --- a/c64/kernal/iec_tx_common.s +++ b/c64/kernal/iec_tx_common.s @@ -5,6 +5,10 @@ iec_tx_common: + ;; Timing is critical here - execute on disabled IRQs + php + sei + ;; Store the byte to send on a stack pha @@ -64,6 +68,7 @@ iec_tx_common_bit_is_sent: bpl iec_tx_common_nextbit pla + plp rts ; Flow continues differently for data/command iec_tx_common_nextbit: diff --git a/c64/kernal/load.s b/c64/kernal/load.s index d9097d95..e075180d 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -33,9 +33,6 @@ load: ;; We need our helpers to get to filenames under ROMs or IO area jsr install_ram_routines - - ;; Disable IRQs, since timing matters! - sei ;; Display SEARCHING FOR + filename lda MSGFLG @@ -162,12 +159,15 @@ load_loop: ;; to do the memory access ;; Save byte under ROMs and IO if required + php + sei ldx #$33 stx $01 ldy #0 sta (load_save_start_ptr),y ldx #$37 stx $01 + plp ;; Advance pointer inc load_save_start_ptr @@ -221,34 +221,28 @@ load_done: ldy load_save_start_ptr+1 clc - cli rts load_wrap_around_error: ;; This error is probably not even detected by C64 Kernal; ;; report BASIC error code that looks the most sane - cli lda #B_ERR_OVERFLOW sec rts - rts load_device_not_found_error: - cli jsr kernalstatus_DEVICE_NOT_FOUND jmp kernalerror_DEVICE_NOT_FOUND load_file_not_found_error: - cli jmp kernalerror_FILE_NOT_FOUND load_error: ;; XXX should we really return BASIC error code here? - cli lda kernal_load_or_verify_flag beq load_verify_error lda #B_ERR_LOAD From 47019cc25d7c44b4ded68134bdf56fe35ca9f5df Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 17 Jul 2019 23:04:04 +0200 Subject: [PATCH 48/90] more comments, slightly safer IEC --- bin/kernal | Bin 8192 -> 8192 bytes c64/kernal/acptr.s | 11 ++++++++++- c64/kernal/chkin.s | 10 +++++++++- c64/kernal/chkout.s | 10 +++++++++- c64/kernal/chrin.s | 13 +++++++++++-- c64/kernal/chrout.s | 12 +++++++++++- c64/kernal/cint.s | 13 +++++++++++-- c64/kernal/fda3.ioinit.s | 11 ++++++++++- c64/kernal/iec_turnaround_to_listen.s | 8 +++++++- c64/kernal/iec_turnaround_to_talk.s | 5 +++++ c64/kernal/ramtas.s | 11 ++++++++++- c64/kernal/vector.s | 10 +++++++++- 12 files changed, 102 insertions(+), 12 deletions(-) diff --git a/bin/kernal b/bin/kernal index b992407fc68a9447757675ac94314744bfb3cbbb..b169ad255553ccf808ff4860bb28ea4feb8e634f 100644 GIT binary patch delta 1104 zcmYjOZ)g)|7{6STrpBhZ)H+UV@hNngcB>Rtw@_hC*R4z4Q|sJZ>saB`xgDGPybLy) z4<>f_rQ=dCAJmfe#49*b0;^FgCZn4MgfI~tEc^2zWeqjCyZ0U4zs|jv=-6@G^Sr;` z^Zef5^ISL(4kQO0wlU=;#{qZDgt<-Fs6bx{8dGsc&c0(p-)CMZUM%*M&aN#L?~z_I zL^y6`{iO1#YrmtlvasBmy5SP|t$PhPXQ=0er=df6(Ad7cw60zQFP*MKXIbN**UAK? z$t_NXO!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/acptr.s +++ b/c64/kernal/acptr.s @@ -1,3 +1,12 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 274 +;; - [CM64] Compute's Mapping the Commodore 64 - page 224/225 +;; +;; CPU registers that has to be preserved (see [RG64]): .Y +;; + acptr: rts diff --git a/c64/kernal/chkin.s b/c64/kernal/chkin.s index ffa509d7..f48b8b5e 100644 --- a/c64/kernal/chkin.s +++ b/c64/kernal/chkin.s @@ -1,4 +1,12 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 275 +;; - [CM64] Compute's Mapping the Commodore 64 - page 229 +;; +;; CPU registers that has to be preserved (see [RG64]): .Y +;; chkin: diff --git a/c64/kernal/chkout.s b/c64/kernal/chkout.s index 36b5a683..0f1f2e58 100644 --- a/c64/kernal/chkout.s +++ b/c64/kernal/chkout.s @@ -1,4 +1,12 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 276 +;; - [CM64] Compute's Mapping the Commodore 64 - page 229 +;; +;; CPU registers that has to be preserved (see [RG64]): .Y +;; chkout: diff --git a/c64/kernal/chrin.s b/c64/kernal/chrin.s index c60c5040..761c7c79 100644 --- a/c64/kernal/chrin.s +++ b/c64/kernal/chrin.s @@ -1,5 +1,14 @@ - ; Function defined on pp272-273 of C64 Programmers Reference Guide - ;; Compute's Mapping the 64, p228 + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 277/278 +;; - [CM64] Compute's Mapping the Commodore 64 - page 228 +;; +;; CPU registers that has to be preserved (see [RG64]): .Y +;; + + ;; Reads a byte of input, unless from keyboard. ;; If from keyboard, then it gets a whole line of input, and returns the first char. ;; Repeated calls after that read out the successive bytes of the line of input. diff --git a/c64/kernal/chrout.s b/c64/kernal/chrout.s index 02503fa7..926a9391 100644 --- a/c64/kernal/chrout.s +++ b/c64/kernal/chrout.s @@ -1,4 +1,14 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 278/279 +;; - [CM64] Compute's Mapping the Commodore 64 - page 228 +;; +;; CPU registers that has to be preserved (see [RG64]): .Y +;; + + chrout: ;; Crude implementation of character output diff --git a/c64/kernal/cint.s b/c64/kernal/cint.s index bf760279..7dd92f46 100644 --- a/c64/kernal/cint.s +++ b/c64/kernal/cint.s @@ -1,5 +1,14 @@ - ;; Function defined on pp272-273 of C64 Programmers Reference Guide - ;; Compute's Mapping the 64 p215 + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 280 +;; - [CM64] Compute's Mapping the Commodore 64 - page 242 +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + + cint: jsr setup_vicii diff --git a/c64/kernal/fda3.ioinit.s b/c64/kernal/fda3.ioinit.s index 2cadb1bc..fd579b03 100644 --- a/c64/kernal/fda3.ioinit.s +++ b/c64/kernal/fda3.ioinit.s @@ -1,4 +1,13 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 285 +;; - [CM64] Compute's Mapping the Commodore 64 - page 238 +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + ioinit: ; Set $00/$01 port mode and value diff --git a/c64/kernal/iec_turnaround_to_listen.s b/c64/kernal/iec_turnaround_to_listen.s index 964ef0ed..b1d0f576 100644 --- a/c64/kernal/iec_turnaround_to_listen.s +++ b/c64/kernal/iec_turnaround_to_listen.s @@ -4,6 +4,10 @@ iec_turnaround_to_listen: + ;; Timing is critical here - execute on disabled IRQs + php + sei + ;; Pull DATA, release CLK and ATN (we are not sending commands) jsr iec_pull_data_release_atn_clk @@ -17,11 +21,13 @@ iec_turnaround_to_listen: bne - ;; Timeout + plp sec rts ;; CLK is pulled by the device, OK -* +* + plp clc rts diff --git a/c64/kernal/iec_turnaround_to_talk.s b/c64/kernal/iec_turnaround_to_talk.s index c8cc9b47..c24639d2 100644 --- a/c64/kernal/iec_turnaround_to_talk.s +++ b/c64/kernal/iec_turnaround_to_talk.s @@ -4,6 +4,10 @@ iec_turnaround_to_talk: + ;; Timing is critical here - execute on disabled IRQs + php + sei + ;; First make sure both CLK, DATA and ATN are released at our side jsr iec_release_atn jsr iec_release_clk_data @@ -14,5 +18,6 @@ iec_turnaround_to_talk: ;; Pull CLK line, it should be held by talker jsr iec_pull_clk_release_data + plp clc rts diff --git a/c64/kernal/ramtas.s b/c64/kernal/ramtas.s index 45de1315..e54f7bd2 100644 --- a/c64/kernal/ramtas.s +++ b/c64/kernal/ramtas.s @@ -1,4 +1,13 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 291 +;; - [CM64] Compute's Mapping the Commodore 64 - page 237 +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + ramtas: ; C64 Programmer's Reference guide p291: ; Clear $0000-$0101, $0200-$03ff diff --git a/c64/kernal/vector.s b/c64/kernal/vector.s index 027bf14a..4a086198 100644 --- a/c64/kernal/vector.s +++ b/c64/kernal/vector.s @@ -1,4 +1,12 @@ -; Functions defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 293 (RESTOR), 304 (VECTOR) +;; - [CM64] Compute's Mapping the Commodore 64 - page 237 +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; restor: From 212724d8f58a33bccea0c7278fbd6fb71f7e2f47 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 18 Jul 2019 19:04:02 +0200 Subject: [PATCH 49/90] documentation update, added STATUS.md document --- STATUS.md | 113 ++++++++++++++++++++++++++++++++ c64/kernal/chrin.s | 1 + c64/kernal/ciout.s | 15 ++++- c64/kernal/clall.s | 19 ++++-- c64/kernal/close.s | 13 +++- c64/kernal/clrchn.s | 11 +++- c64/kernal/fff3.jiobase.s | 20 ++++-- c64/kernal/getin.s | 13 +++- c64/kernal/listen.s | 12 +++- c64/kernal/load.s | 14 +++- c64/kernal/membot.s | 20 ++++-- c64/kernal/memtop.s | 21 ++++-- c64/kernal/open.s | 13 +++- c64/kernal/plot.s | 10 +++ c64/kernal/rdtim.s | 11 +++- c64/kernal/readst.s | 12 +++- c64/kernal/save.s | 12 +++- c64/kernal/scan_keyboard.s | 22 +++++-- c64/kernal/screen.s | 10 ++- c64/kernal/second.s | 17 ++++- c64/kernal/setfls.s | 10 ++- c64/kernal/setmsg.s | 11 +++- c64/kernal/setnam.s | 10 ++- c64/kernal/settim.s | 11 +++- c64/kernal/settmo.s | 11 +++- c64/kernal/stop.s | 15 ++++- c64/kernal/talk.s | 17 ++++- c64/kernal/tksa.s | 18 ++++- c64/kernal/unlsn.s | 12 +++- c64/kernal/untlk.s | 13 +++- c64/kernal/update_jiffy_clock.s | 10 +++ 31 files changed, 452 insertions(+), 65 deletions(-) create mode 100644 STATUS.md diff --git a/STATUS.md b/STATUS.md new file mode 100644 index 00000000..56f5f4e9 --- /dev/null +++ b/STATUS.md @@ -0,0 +1,113 @@ +# New features + + +Here are the features of the Open ROMs not found in the original ROMs from the 80s: + +* improved keyboard scanning, supports multi-key roll-over and rejection of spurious joystick input +* joystick (port 1) can be used to move text cursor +* banking in the BASIC interpreter: 61436 bytes free +* LOAD start/end addresses are displayed, in the Final cartridge style +* LOAD command with just the file name tries to use the last device if it's number seems sane; otherwise uses 8 + + +# Features missing + + +The following ROM features are currently missing: + +* most BASIC commands +* BASIC variables +* BASIC expression parsing +* floating point routines +* tape support +* RS-232 support +* warm start (RUN/STOP + RESTORE) - NMI is not implemented at all +* breaking Kernal routines with RUN/STOP key + +Features currently being worked on: + +* IEC support +* DOS wedge + + +# API status + + +Status of the various APIs and variables from the original ROMs + + +## Page 0 + + +TODO + + +## Pages 2 & 3 + + +TODO + + +## BASIC + + +TODO + + +## Kernal + + +Note: only the jump table addresses are currently supported, real routine addresses are different! + + +### Official Kernal routines + +NOTE: Even the 'DONE' routines won't support features described as missing in one of the previous chapters! + + +| Address | Name | Status | Remarks | +| ------- | :----: | :------: | :-------------------------------------: | +| $FF81 | CINT | PARTIAL | at least PAL/NTSC detection is missing | +| $FF84 | IOINIT | PARTIAL | at least SID volume handling is missing | +| $FF87 | RAMTAS | DONE | | +| $FF8A | RESTOR | PARTIAL | CBINV, NMINV, and USRCMD missing | +| $FF8D | VECTOR | DONE | | +| $FF90 | SETMSG | DONE | | +| $FF93 | SECOND | PARTIAL | * work in progress | +| $FF96 | TKSA | PARTIAL | should probably also do a turnaround | +| $FF99 | MEMTOP | DONE | | +| $FF9C | MEMBOT | DONE | | +| $FF9F | SCNKEY | DONE | could be better integrated with ROM | +| $FFA2 | SETTMO | NOT DONE | | +| $FFA5 | ACPTR | NOT DONE | * work in progress | +| $FFA8 | CIOUT | PARITAL | * work in progress | +| $FFAB | UNTLK | PARITAL | * work in progress | +| $FFAE | UNLSN | PARITAL | * work in progress | +| $FFB1 | LISTEN | PARTIAL | * work in progress | +| $FFB4 | TALK | PARTIAL | * work in progress | +| $FFB7 | READST | DONE | | +| $FFBA | SETFLS | DONE | | +| $FFBD | SETNAM | DONE | | +| $FFC0 | OPEN | NOT DONE | * work in progress | +| $FFC3 | CLOSE | PARTIAL | * work in progress | +| $FFC6 | CHKIN | NOT DONE | * work in progress | +| $FFC9 | CHKOUT | NOT DONE | * work in progress | +| $FFCC | CLRCHN | NOT DONE | * work in progress | +| $FFCF | CHRIN | NOT DONE | * work in progress | +| $FFD2 | CHROUT | NOT DONE | * work in progress | +| $FFD5 | LOAD | PARTIAL | no VERIFY support yet | +| $FFD8 | SAVE | NOT DONE | * work in progress | +| $FFDB | SETTIM | NOT DONE | | +| $FFDE | RDTIM | NOT DONE | | +| $FFE1 | STOP | PARTIAL | no connection with UDTIM | +| $FFE4 | GETIN | PARTIAL | * work in progress | +| $FFE7 | CLALL | PARTIAL | * work in progress | +| $FFEA | UDTIM | NOT DONE | | +| $FFED | SCREEN | DONE | | +| $FFF0 | PLOT | NOT DONE | | +| $FFF3 | IOBASE | DONE | | + + +### Unofficial Kernal locations + +TODO diff --git a/c64/kernal/chrin.s b/c64/kernal/chrin.s index 761c7c79..4121bdc4 100644 --- a/c64/kernal/chrin.s +++ b/c64/kernal/chrin.s @@ -8,6 +8,7 @@ ;; CPU registers that has to be preserved (see [RG64]): .Y ;; +;; XXX currently does not preserve register Y, to be fixed! ;; Reads a byte of input, unless from keyboard. ;; If from keyboard, then it gets a whole line of input, and returns the first char. diff --git a/c64/kernal/ciout.s b/c64/kernal/ciout.s index 7894c5eb..a1cf61f6 100644 --- a/c64/kernal/ciout.s +++ b/c64/kernal/ciout.s @@ -1,7 +1,16 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide -ciout: - ;; This routine is documented in 'Compute's Mapping the Commodore 64', page 224 +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 279/280 +;; - [CM64] Compute's Mapping the Commodore 64 - page 224 +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + +;; XXX currently does not preserve registers, to be fixed! + +ciout: pha lda C3PO diff --git a/c64/kernal/clall.s b/c64/kernal/clall.s index a24918fb..059804ed 100644 --- a/c64/kernal/clall.s +++ b/c64/kernal/clall.s @@ -1,15 +1,26 @@ +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 281 +;; - [CM64] Compute's Mapping the Commodore 64 - page 230 +;; +;; CPU registers that has to be preserved (see [RG64]): .Y +;; + +;; XXX currently does not preserve register Y, to be fixed! + clall: - ;; Implemented according to 'C64 Programmer's Reference Guide', page 281 - ;; Not entirely sure if it just sets LDTND to 0 or actually calls CLOSE, - ;; but calling CLOSE for all open channels seems to be the safest + ;; Original routine probably just sets LDTND to 0, but this is not really safe, + ;; so we actually close all the channels; at least IDE64 does the same for + ;; it's channels, see CLALL description in the IDE64 User's Guide ldy LDTND beq + dey lda LAT, y - jsr close + jsr close ; XXX jump through ICLOSE? jmp clall * ;; 'C64 Programmers Reference Guide', page 281, claims it calls CLRCHN too diff --git a/c64/kernal/close.s b/c64/kernal/close.s index c2b7a245..00485c4c 100644 --- a/c64/kernal/close.s +++ b/c64/kernal/close.s @@ -1,7 +1,14 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide -close: - ;; Implemented accorging to 'C64 Programmers Reference Guide', page 281 +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 281/282 +;; - [CM64] Compute's Mapping the Commodore 64 - page 229/230 +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + +close: ;; XXX this needs more testing (opening 10 files at once, closing in various orders, etc) once the code is more mature diff --git a/c64/kernal/clrchn.s b/c64/kernal/clrchn.s index 729b8dde..8000116e 100644 --- a/c64/kernal/clrchn.s +++ b/c64/kernal/clrchn.s @@ -1,3 +1,12 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 282 +;; - [CM64] Compute's Mapping the Commodore 64 - page 230 +;; +;; CPU registers that has to be preserved (see [RG64]): .Y +;; + clrchn: rts diff --git a/c64/kernal/fff3.jiobase.s b/c64/kernal/fff3.jiobase.s index ee3a1730..1c459c5d 100644 --- a/c64/kernal/fff3.jiobase.s +++ b/c64/kernal/fff3.jiobase.s @@ -1,8 +1,18 @@ -; $FFF3 - Get page of IO devices -; Returns Y=$DC, X=$00 -; (http://codebase64.org/doku.php?id=base:kernalreference) -; -; As there is nothing between here and $FFFA, we can just hard code this in place. + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 284 +;; - [CM64] Compute's Mapping the Commodore 64 - page 214 +;; - http://codebase64.org/doku.php?id=base:kernalreference (original source) +;; +;; CPU registers that has to be preserved (see [RG64]): .A +;; + + +;; As there is nothing between here and $FFFA, we can just hard code this in place. + +iobase: ldy #$DC ldx #$00 rts diff --git a/c64/kernal/getin.s b/c64/kernal/getin.s index 6df398c1..e8961cb4 100644 --- a/c64/kernal/getin.s +++ b/c64/kernal/getin.s @@ -1,4 +1,15 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 283 +;; - [CM64] Compute's Mapping the Commodore 64 - page 227/228 +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + +;; XXX currently does not preserve registers, to be fixed! + getin: ;; Wait for a key diff --git a/c64/kernal/listen.s b/c64/kernal/listen.s index 10d57fe0..92ad77fa 100644 --- a/c64/kernal/listen.s +++ b/c64/kernal/listen.s @@ -1,4 +1,14 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 285 +;; - [CM64] Compute's Mapping the Commodore 64 - page 223 +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + +;; XXX currently does not preserve registers, to be fixed! listen: diff --git a/c64/kernal/load.s b/c64/kernal/load.s index e075180d..ce355cfc 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -1,7 +1,15 @@ - ; Function defined on pp272-273 of C64 Programmers Reference Guide - ;; IEC reference at http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf - ;; Definition of function from Compute's Mapping the 64 p231 +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 286 +;; - [CM64] Compute's Mapping the Commodore 64 - page 231 +;; - IEC reference at http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + + ;; Expects that SETLFS and SETNAM are called before hand. ;; $YYXX = load address. ;; (ignored if SETLFS channel = 1, i.e., like ,8,1) diff --git a/c64/kernal/membot.s b/c64/kernal/membot.s index 476eefab..509e5858 100644 --- a/c64/kernal/membot.s +++ b/c64/kernal/membot.s @@ -1,13 +1,23 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 287/288 +;; - [CM64] Compute's Mapping the Commodore 64 - page 240 +;; +;; CPU registers that has to be preserved (see [RG64]): .A +;; + membot: - ; p287 C64 Programmers reference guide - ;; http://unusedino.de/ec64/technical/project64/mapping_c64.html + bcc membot_set - LDX MEMSTR+0 - LDY MEMSTR+1 + ldx MEMSTR+0 + ldy MEMSTR+1 rts + membot_set: + stx MEMSTR+0 stx MEMSTR+1 diff --git a/c64/kernal/memtop.s b/c64/kernal/memtop.s index 70c94fc3..2672c632 100644 --- a/c64/kernal/memtop.s +++ b/c64/kernal/memtop.s @@ -1,14 +1,23 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 288 +;; - [CM64] Compute's Mapping the Commodore 64 - page 240 +;; +;; CPU registers that has to be preserved (see [RG64]): .A +;; + memtop: - ; p288 C64 Programmer's reference guide - ; but for now we only support reading it - ;; http://unusedino.de/ec64/technical/project64/mapping_c64.html + bcc memtop_set - LDY MEMSIZ+1 - LDX MEMSIZ+0 + ldy MEMSIZ+1 + ldx MEMSIZ+0 rts + memtop_set: + sty MEMSIZ+1 stx MEMSIZ+0 diff --git a/c64/kernal/open.s b/c64/kernal/open.s index 7875943b..d5f99aa7 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -1,7 +1,14 @@ - ; Function defined on pp272-273 of C64 Programmers Reference Guide - ;; See also http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf -;; XXX rework this, according to pagetable.com +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 289 +;; - [CM64] Compute's Mapping the Commodore 64 - page 230/231 +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + +;; XXX this is only a test implementation, does not do what the Kernal does! open: diff --git a/c64/kernal/plot.s b/c64/kernal/plot.s index 95a3cb6d..439b1828 100644 --- a/c64/kernal/plot.s +++ b/c64/kernal/plot.s @@ -1,2 +1,12 @@ + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 290 +;; - [CM64] Compute's Mapping the Commodore 64 - page 215 +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + plot: rts diff --git a/c64/kernal/rdtim.s b/c64/kernal/rdtim.s index 89e78575..a9e40a16 100644 --- a/c64/kernal/rdtim.s +++ b/c64/kernal/rdtim.s @@ -1,3 +1,12 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 291 +;; - [CM64] Compute's Mapping the Commodore 64 - page 232 +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + rdtim: rts diff --git a/c64/kernal/readst.s b/c64/kernal/readst.s index e8e0f164..b3fbaa53 100644 --- a/c64/kernal/readst.s +++ b/c64/kernal/readst.s @@ -1,10 +1,18 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 292 +;; - [CM64] Compute's Mapping the Commodore 64 - page 239 +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; readst: ;; Check the current device number - lda DFLTN + lda current_device_number cmp #$02 bne + diff --git a/c64/kernal/save.s b/c64/kernal/save.s index e8730e78..e98d030f 100644 --- a/c64/kernal/save.s +++ b/c64/kernal/save.s @@ -1,3 +1,13 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 293/294 +;; - [CM64] Compute's Mapping the Commodore 64 - page 231/232 +;; - IEC reference at http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + save: rts diff --git a/c64/kernal/scan_keyboard.s b/c64/kernal/scan_keyboard.s index 61851c3f..ed263c99 100644 --- a/c64/kernal/scan_keyboard.s +++ b/c64/kernal/scan_keyboard.s @@ -1,9 +1,19 @@ - ;; Scan the keyboard.. - ;; Here we don't use the horrible buggy original routine, - ;; not just because of copyright. Instead, we use the - ;; nice one with joystick interference removal and - ;; key roll-over support from - ;; http://codebase64.org/doku.php?id=base:scanning_the_keyboard_the_correct_and_non_kernal_way + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 295 +;; - [CM64] Compute's Mapping the Commodore 64 - page 220 +;; +;; CPU registers that has to be preserved (see [RG64]): none +;; + +;; Scan the keyboard.. +;; Here we don't use the horrible buggy original routine, +;; not just because of copyright. Instead, we use the +;; nice one with joystick interference removal and +;; key roll-over support from +;; http://codebase64.org/doku.php?id=base:scanning_the_keyboard_the_correct_and_non_kernal_way ;; /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ;; Keyboard IO Routine diff --git a/c64/kernal/screen.s b/c64/kernal/screen.s index 19fa509d..b2e793fc 100644 --- a/c64/kernal/screen.s +++ b/c64/kernal/screen.s @@ -1,4 +1,12 @@ -; Function defined on p295 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 295 +;; - [CM64] Compute's Mapping the Commodore 64 - page 215 +;; +;; CPU registers that has to be preserved (see [RG64]): .A +;; screen: diff --git a/c64/kernal/second.s b/c64/kernal/second.s index 7adadbda..d9024dff 100644 --- a/c64/kernal/second.s +++ b/c64/kernal/second.s @@ -1,8 +1,19 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 296 +;; - [CM64] Compute's Mapping the Commodore 64 - page 223/224 +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + +;; XXX currently does not preserve registers, to be fixed! + second: - ;; This trivial routine is documented in 'C64 Programmer's Reference Guide', page 296 and - ;; https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc + ;; see also https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc + and #$1F ; make sure bits encoding the command are cleared out ora #$60 jmp iec_tx_command diff --git a/c64/kernal/setfls.s b/c64/kernal/setfls.s index 2517a650..ce6892a8 100644 --- a/c64/kernal/setfls.s +++ b/c64/kernal/setfls.s @@ -1,4 +1,12 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 297 +;; - [CM64] Compute's Mapping the Commodore 64 - page 238 +;; +;; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y +;; setfls: diff --git a/c64/kernal/setmsg.s b/c64/kernal/setmsg.s index 15a3d5b1..fc20350e 100644 --- a/c64/kernal/setmsg.s +++ b/c64/kernal/setmsg.s @@ -1,4 +1,13 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 298 +;; - [CM64] Compute's Mapping the Commodore 64 - page 239 +;; +;; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y +;; + setmsg: sta MSGFLG rts diff --git a/c64/kernal/setnam.s b/c64/kernal/setnam.s index 55ae5b7f..d15bc1a0 100644 --- a/c64/kernal/setnam.s +++ b/c64/kernal/setnam.s @@ -1,4 +1,12 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 298/299 +;; - [CM64] Compute's Mapping the Commodore 64 - page 238 +;; +;; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y +;; setnam: diff --git a/c64/kernal/settim.s b/c64/kernal/settim.s index bfc95254..804538c1 100644 --- a/c64/kernal/settim.s +++ b/c64/kernal/settim.s @@ -1,3 +1,12 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 299/300 +;; - [CM64] Compute's Mapping the Commodore 64 - page 232 +;; +;; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y +;; + settim: rts diff --git a/c64/kernal/settmo.s b/c64/kernal/settmo.s index ffd76b69..273fbf43 100644 --- a/c64/kernal/settmo.s +++ b/c64/kernal/settmo.s @@ -1,3 +1,12 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 300 +;; - [CM64] Compute's Mapping the Commodore 64 - page 239 +;; +;; CPU registers that has to be preserved (see [RG64]): .A, .X, .Y +;; + settmo: rts diff --git a/c64/kernal/stop.s b/c64/kernal/stop.s index 2f8e82e2..ce4930c0 100644 --- a/c64/kernal/stop.s +++ b/c64/kernal/stop.s @@ -1,4 +1,13 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 301 +;; - [CM64] Compute's Mapping the Commodore 64 - page 232 +;; +;; CPU registers that has to be preserved (see [RG64]): .Y +;; + stop: ;; Bit 7 of BUCKYSTATUS contains the state of the STOP key ;; (Compute's Mapping the 64, p27) @@ -8,10 +17,10 @@ stop: and #$80 beq stop_pressed - ;; By trial and error, we know that Z + C = BREAK + ;; By trial and error, we know that Z + C = BREAK ;; and that neither should be set otherwise lda #$ff - clc + clc rts stop_pressed: diff --git a/c64/kernal/talk.s b/c64/kernal/talk.s index 0f7fb1e4..253cba33 100644 --- a/c64/kernal/talk.s +++ b/c64/kernal/talk.s @@ -1,9 +1,20 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 301/302 +;; - [CM64] Compute's Mapping the Commodore 64 - page 223 +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + +;; XXX currently does not preserve registers, to be fixed! +;; XXX shouldn't this do a turnaround? talk: - ;; This routine is documented in 'Compute's Mapping the Commodore 64', page 223 and - ;; https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc + ;; See also https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc + and #$1F ; make sure bits encoding the command are cleared out ora #$40 jmp iec_tx_command diff --git a/c64/kernal/tksa.s b/c64/kernal/tksa.s index 04fff397..604ad2aa 100644 --- a/c64/kernal/tksa.s +++ b/c64/kernal/tksa.s @@ -1,8 +1,20 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 302 +;; - [CM64] Compute's Mapping the Commodore 64 - page 224 +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + +;; XXX currently does not preserve registers, to be fixed! +;; XXX shouldn't this do a turnaround? + tksa: - ;; This routine is documented in 'C64 Programmer's Reference Guide', page 302 and - ;; https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc + ;; See also https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc + and #$1F ; make sure bits encoding the command are cleared out ora #$F0 jmp iec_tx_command diff --git a/c64/kernal/unlsn.s b/c64/kernal/unlsn.s index 8dc84fcf..05e73cf5 100644 --- a/c64/kernal/unlsn.s +++ b/c64/kernal/unlsn.s @@ -1,4 +1,14 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 303 +;; - [CM64] Compute's Mapping the Commodore 64 - page 224 +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + +;; XXX currently does not preserve registers, to be fixed! unlsn: diff --git a/c64/kernal/untlk.s b/c64/kernal/untlk.s index 3a47ff02..d7276361 100644 --- a/c64/kernal/untlk.s +++ b/c64/kernal/untlk.s @@ -1,4 +1,15 @@ -; Function defined on pp272-273 of C64 Programmers Reference Guide + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 304 +;; - [CM64] Compute's Mapping the Commodore 64 - page 224 +;; +;; CPU registers that has to be preserved (see [RG64]): .X, .Y +;; + +;; XXX currently does not preserve registers, to be fixed! +;; XXX shouldn't this do a turnaround? untlk: diff --git a/c64/kernal/update_jiffy_clock.s b/c64/kernal/update_jiffy_clock.s index 4d5a6dbb..7e05883a 100644 --- a/c64/kernal/update_jiffy_clock.s +++ b/c64/kernal/update_jiffy_clock.s @@ -1,2 +1,12 @@ + +;; +;; Official Kernal routine, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 303 +;; - [CM64] Compute's Mapping the Commodore 64 - page 232 +;; +;; CPU registers that has to be preserved (see [RG64]): .Y +;; + update_jiffy_clock: rts From 4c60ad1653966530e8049d943592f537e4a92f61 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 18 Jul 2019 21:16:37 +0200 Subject: [PATCH 50/90] build system can create different ROMs per platforn --- .gitignore | 21 +- Makefile | 182 ++++++++++++++---- c64/aliases/.dummy | 0 c64/basic/,platform_generic/.dummy | 0 c64/basic/,platform_mega65/.dummy | 0 .../,aliases-ultimate64.s | 10 + c64/basic/packed_messages.s | 126 ------------ c64/kernal/,platform_generic/.dummy | 0 c64/kernal/,platform_mega65/.dummy | 0 .../,aliases-ultimate64.s | 10 + 10 files changed, 166 insertions(+), 183 deletions(-) create mode 100644 c64/aliases/.dummy create mode 100644 c64/basic/,platform_generic/.dummy create mode 100644 c64/basic/,platform_mega65/.dummy create mode 100644 c64/basic/,platform_ultimate64/,aliases-ultimate64.s delete mode 100644 c64/basic/packed_messages.s create mode 100644 c64/kernal/,platform_generic/.dummy create mode 100644 c64/kernal/,platform_mega65/.dummy create mode 100644 c64/kernal/,platform_ultimate64/,aliases-ultimate64.s diff --git a/.gitignore b/.gitignore index 9f325b49..5fdfc0df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,27 +1,12 @@ -# Intermediate compilation files +# Compilation related files -c64/basic/combined.s -c64/kernal/combined.s -padding temp.s temp.map +packed_messages.s -src/collect_data -src/compress_text -src/pngprepare -src/preprocess ophis.bin -c64/basic/OUT.BIN -c64/kernal/OUT.BIN - -# Compilation output - -chargen -newbasic -newkern -newc65 -newrom +build/* # Various IDE project files, temporary files, etc. diff --git a/Makefile b/Makefile index 92d15cae..0dacf6a7 100644 --- a/Makefile +++ b/Makefile @@ -1,61 +1,165 @@ -all: Ophis src/collect_data src/preprocess + +# Source files + +SRC_COMMON = $(wildcard c64/aliases/*.s) +SRC_BASIC_COMMON = $(SRC_COMMON) $(wildcard c64/basic/*.s) +SRC_KERNAL_COMMON = $(SRC_COMMON) $(wildcard c64/kernal/*.s) + +SRC_BASIC_GENERIC = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,platform_generic/*.s) +SRC_BASIC_MEGA65 = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,platform_mega65/*.s) +SRC_BASIC_ULTIMATE64 = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,platform_ultimate64/*.s) + +SRC_KERNAL_GENERIC = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_generic/*.s) +SRC_KERNAL_MEGA65 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_mega65/*.s) +SRC_KERNAL_ULTIMATE64 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_ultimate64/*.s) + +# Rules - maintainance + +all: build/chargen build/newkern_generic build/newbasic_generic build/newkern_mega65 build/newbasic_mega65 build/newkern_ultimate64 build/newbasic_ultimate64 + +clean: + @rm -rf build + @rm -f temp.s + @rm -f temp.map + @rm -f c64/basic/packed_messages.s + +.PHONY: prep +prep: Ophis build/collect_data build/compress_text build/preprocess build/similarity Ophis: git submodule init git submodule update -src/pngprepare: src/pngprepare.c Makefile - $(CC) $(COPT) -I/usr/local/include -L/usr/local/lib -o src/pngprepare src/pngprepare.c -lpng +# Rules - tools -chargen: src/pngprepare assets/8x8font.png - src/pngprepare charrom assets/8x8font.png chargen +build/pngprepare: src/pngprepare.c Makefile + @mkdir -p build + $(CC) $(COPT) -I/usr/local/include -L/usr/local/lib -o build/pngprepare src/pngprepare.c -lpng -src/collect_data: src/collect_data.c Makefile - gcc -Wall -o src/collect_data src/collect_data.c +build/collect_data: src/collect_data.c Makefile + @mkdir -p build + gcc -Wall -o build/collect_data src/collect_data.c -src/preprocess: src/preprocess.c Makefile - gcc -g -Wall -o src/preprocess src/preprocess.c +build/preprocess: src/preprocess.c Makefile + @mkdir -p build + gcc -g -Wall -o build/preprocess src/preprocess.c -src/similarity: src/similarity.c Makefile - gcc -g -Wall -o src/similarity src/similarity.c +build/similarity: src/similarity.c Makefile + @mkdir -p build + gcc -g -Wall -o build/similarity src/similarity.c -src/compress_text: src/compress_text.c Makefile - gcc -g -Wall -o src/compress_text src/compress_text.c -lm +build/compress_text: src/compress_text.c Makefile + @mkdir -p build + gcc -g -Wall -o build/compress_text src/compress_text.c -lm -newrom: c64/kernal/OUT.BIN c64/basic/OUT.BIN - cat c64/basic/OUT.BIN c64/kernal/OUT.BIN >newrom +# Rules - chargen -newkern: newrom Makefile - dd if=newrom bs=8192 count=1 skip=2 of=newkern +build/chargen: build/pngprepare assets/8x8font.png + build/pngprepare charrom assets/8x8font.png build/chargen -newbasic: newrom Makefile - dd if=newrom bs=8192 count=1 skip=0 of=newbasic +# Rules - platform 'generic' -newc65: newkern newbasic chargen Makefile - dd if=/dev/zero bs=4096 count=10 of=newc65 - cat newbasic chargen chargen newkern >>newc65 - dd if=/dev/zero bs=65536 count=1 of=padding - cat padding >>newc65 +build/basic_generic/OUT.BIN: build/preprocess $(SRC_BASIC_GENERIC) c64/basic/packed_messages.s + @mkdir -p build/basic_generic + @rm -f build/basic_generic/* + @for SRC in $(SRC_BASIC_GENERIC); do \ + ln -s ../../$$SRC build/basic_generic/$$(basename $$SRC); \ + done + build/preprocess -d build/basic_generic -l a000 -h e4d2 +build/kernal_generic/OUT.BIN: build/preprocess $(SRC_KERNAL_GENERIC) + @mkdir -p build/kernal_generic + @rm -f build/kernal_generic/* + @for SRC in $(SRC_KERNAL_GENERIC); do \ + ln -s ../../$$SRC build/kernal_generic/$$(basename $$SRC); \ + done + build/preprocess -d build/kernal_generic -l e4d3 -h ffff -c64/basic/packed_messages.s: Makefile src/compress_text - src/compress_text > c64/basic/packed_messages.s +build/newrom_generic: build/basic_generic/OUT.BIN build/kernal_generic/OUT.BIN + cat build/basic_generic/OUT.BIN build/kernal_generic/OUT.BIN > build/newrom_generic -c64/kernal/OUT.BIN: src/preprocess c64/kernal/*.s - src/preprocess -d c64/kernal -l e4d3 -h ffff +build/newkern_generic: build/newrom_generic Makefile + dd if=build/newrom_generic bs=8192 count=1 skip=2 of=build/newkern_generic -c64/basic/OUT.BIN: src/preprocess c64/basic/*.s c64/basic/packed_messages.s - src/preprocess -d c64/basic -l a000 -h e4d2 +build/newbasic_generic: build/newrom_generic Makefile + dd if=build/newrom_generic bs=8192 count=1 skip=0 of=build/newbasic_generic -testremote: newkern newbasic - x64 -kernal newkern -basic newbasic -remotemonitor +# Rules - platform 'Mega 65' -test: newkern newbasic - x64 -kernal newkern -basic newbasic -8 empty.d64 +build/basic_mega65/OUT.BIN: build/preprocess $(SRC_BASIC_MEGA65) c64/basic/packed_messages.s + @mkdir -p build/basic_mega65 + @rm -f build/basic_mega65/* + @for SRC in $(SRC_BASIC_MEGA65); do \ + ln -s ../../$$SRC build/basic_mega65/$$(basename $$SRC); \ + done + build/preprocess -d build/basic_mega65 -l a000 -h e4d2 -testm65: newc65 - m65 -b ../mega65-core/bin/mega65r1.bit -k ../mega65-core/bin/KICKUP.M65 -R newc65 -4 +build/kernal_mega65/OUT.BIN: build/preprocess $(SRC_KERNAL_MEGA65) + @mkdir -p build/kernal_mega65 + @rm -f build/kernal_mega65/* + @for SRC in $(SRC_KERNAL_MEGA65); do \ + ln -s ../../$$SRC build/kernal_mega65/$$(basename $$SRC); \ + done + build/preprocess -d build/kernal_mega65 -l e4d3 -h ffff -testsimilarity: newkern newbasic src/similarity - src/similarity kernal newrom - src/similarity basic newrom +build/newrom_mega65: build/basic_mega65/OUT.BIN build/kernal_mega65/OUT.BIN + cat build/basic_mega65/OUT.BIN build/kernal_mega65/OUT.BIN > build/newrom_mega65 + +build/newkern_mega65: build/newrom_mega65 Makefile + dd if=build/newrom_mega65 bs=8192 count=1 skip=2 of=build/newkern_mega65 + +build/newbasic_mega65: build/newrom_mega65 Makefile + dd if=build/newrom_mega65 bs=8192 count=1 skip=0 of=build/newbasic_mega65 + +build/newc65: build/newkern_mega65 build/newbasic_mega65 build/chargen Makefile + dd if=/dev/zero bs=4096 count=10 of=build/newc65 + cat build/newbasic_mega65 build/chargen build/chargen build/newkern_mega65 >>build/newc65 + dd if=/dev/zero bs=65536 count=1 of=build/padding + cat build/padding >>build/newc65 + +# Rules - platform 'Ultimate 64' + +build/basic_ultimate64/OUT.BIN: build/preprocess $(SRC_BASIC_ULTIMATE64) c64/basic/packed_messages.s + @mkdir -p build/basic_ultimate64 + @rm -f build/basic_ultimate64/* + @for SRC in $(SRC_BASIC_ULTIMATE64); do \ + ln -s ../../$$SRC build/basic_ultimate64/$$(basename $$SRC); \ + done + build/preprocess -d build/basic_ultimate64 -l a000 -h e4d2 + +build/kernal_ultimate64/OUT.BIN: build/preprocess $(SRC_KERNAL_ULTIMATE64) + @mkdir -p build/kernal_ultimate64 + @rm -f build/kernal_ultimate64/* + @for SRC in $(SRC_KERNAL_ULTIMATE64); do \ + ln -s ../../$$SRC build/kernal_ultimate64/$$(basename $$SRC); \ + done + build/preprocess -d build/kernal_ultimate64 -l e4d3 -h ffff + +build/newrom_ultimate64: build/basic_ultimate64/OUT.BIN build/kernal_ultimate64/OUT.BIN + cat build/basic_ultimate64/OUT.BIN build/kernal_ultimate64/OUT.BIN > build/newrom_ultimate64 + +build/newkern_ultimate64: build/newrom_ultimate64 Makefile + dd if=build/newrom_ultimate64 bs=8192 count=1 skip=2 of=build/newkern_ultimate64 + +build/newbasic_ultimate64: build/newrom_ultimate64 Makefile + dd if=build/newrom_ultimate64 bs=8192 count=1 skip=0 of=build/newbasic_ultimate64 + +# Rules - misc + +c64/basic/packed_messages.s: Makefile build/compress_text + build/compress_text > c64/basic/packed_messages.s + +# Rules - tests + +testremote: build/newkern_generic build/newbasic_generic + x64 -kernal build/newkern-generic -basic build/newbasic-generic -remotemonitor + +test: build/newkern_generic build/newbasic_generic + x64 -kernal build/newkern_generic -basic build/newbasic_generic -8 empty.d64 + +testm65: build/newc65 + m65 -b ../mega65-core/bin/mega65r1.bit -k ../mega65-core/bin/KICKUP.M65 -R build/newc65 -4 + +testsimilarity: build/newrom_generic src/similarity + build/similarity kernal build/newrom_generic + build/similarity basic build/newrom_generic diff --git a/c64/aliases/.dummy b/c64/aliases/.dummy new file mode 100644 index 00000000..e69de29b diff --git a/c64/basic/,platform_generic/.dummy b/c64/basic/,platform_generic/.dummy new file mode 100644 index 00000000..e69de29b diff --git a/c64/basic/,platform_mega65/.dummy b/c64/basic/,platform_mega65/.dummy new file mode 100644 index 00000000..e69de29b diff --git a/c64/basic/,platform_ultimate64/,aliases-ultimate64.s b/c64/basic/,platform_ultimate64/,aliases-ultimate64.s new file mode 100644 index 00000000..1f30e332 --- /dev/null +++ b/c64/basic/,platform_ultimate64/,aliases-ultimate64.s @@ -0,0 +1,10 @@ + +;; Registers according to Ultimate 64 Command Interface ddescription, +;; https://1541u-documentation.readthedocs.io/en/latest/command%20interface.html + + .alias U64_CONTROL $DF1C ; write + .alias U64_STATUS $DF1C ; read + .alias U64_COMMAND_DATA $DF1D ; write + .alias U64_IDENTIFICATION $DF1D ; read + .alias U64_RESPONSE_DATA $DF1E ; read only + .alias U64_STATUS_DATA $DF1F ; read only diff --git a/c64/basic/packed_messages.s b/c64/basic/packed_messages.s deleted file mode 100644 index 2747aeda..00000000 --- a/c64/basic/packed_messages.s +++ /dev/null @@ -1,126 +0,0 @@ -packed_message_chars: - .byte $45 ; 'E' = $1 (nybl) - .byte $54 ; 'T' = $2 (nybl) - .byte $4F ; 'O' = $3 (nybl) - .byte $4E ; 'N' = $4 (nybl) - .byte $49 ; 'I' = $5 (nybl) - .byte $52 ; 'R' = $6 (nybl) - .byte $41 ; 'A' = $7 (nybl) - .byte $4C ; 'L' = $8 (nybl) - .byte $53 ; 'S' = $9 (nybl) - .byte $44 ; 'D' = $a (nybl) - .byte $46 ; 'F' = $b (nybl) - .byte $55 ; 'U' = $c (nybl) - .byte $50 ; 'P' = $d (nybl) - .byte $4D ; 'M' = $e (nybl) - .byte $43 ; 'C' = $F1 / $xF $43 - .byte $47 ; 'G' = $F2 / $xF $47 - .byte $59 ; 'Y' = $F3 / $xF $59 - .byte $56 ; 'V' = $F4 / $xF $56 - .byte $42 ; 'B' = $F5 / $xF $42 - .byte $48 ; 'H' = $F6 / $xF $48 - .byte $58 ; 'X' = $F7 / $xF $58 - .byte $57 ; 'W' = $F8 / $xF $57 - .byte $24 ; '$' = $F9 / $xF $24 - .byte $27 ; ''' = $Fa / $xF $27 - .byte $0D ; ' ' = $Fb / $xF $0D - .byte $51 ; 'Q' = $Fc / $xF $51 - .byte $2E ; '.' = $Fd / $xF $2E - .byte $23 ; '#' = $FE/F + $23 - .byte $4B ; 'K' = $FE/F + $4B - .byte $28 ; '(' = $FE/F + $28 - .byte $5A ; 'Z' = $FE/F + $5A - .byte $2B ; '+' = $FE/F + $2B - .byte $2D ; '-' = $FE/F + $2D - .byte $2A ; '*' = $FE/F + $2A - .byte $2F ; '/' = $FE/F + $2F - .byte $5E ; '^' = $FE/F + $5E - .byte $3E ; '>' = $FE/F + $3E - .byte $3D ; '=' = $FE/F + $3D - .byte $3C ; '<' = $FE/F + $3C -packed_message_tokens: - .byte $00,$01,$02,$ff,$03,$04,$ff,$03 - .byte $05,$04,$ff,$03,$05,$06,$ff,$07 - .byte $05,$08,$ff,$05,$09,$03,$ff,$05 - .byte $0a,$03,$ff,$0b,$0c,$ff,$0d,$07 - .byte $0e,$ff,$0f,$10,$11,$ff,$12,$ff - .byte $13,$10,$14,$ff,$15,$16,$17,$ff - .byte $0d,$18,$ff,$19,$ff,$15,$16,$1a - .byte $ff,$1b,$1c,$ff,$1d,$1e,$ff,$1f - .byte $20,$ff,$21,$22,$23,$ff,$0d,$24 - .byte $ff,$25,$26,$ff,$27,$00,$28,$ff - .byte $03,$17,$ff,$29,$00,$2a,$ff,$2b - .byte $2c,$ff,$1b,$2d,$ff,$2e,$ff,$2f - .byte $ff,$30,$ff,$31,$ff,$32,$ff,$33 - .byte $ff,$34,$ff,$35,$36,$ff,$1a,$37 - .byte $ff - .byte $05 - .byte $38 - .byte $ff -packed_message_words: - .byte $23,$30,$e7,$4f,$59,$00,$b5,$81 - .byte $90,$b5,$81,$00,$3d,$14,$00,$43 - .byte $20,$b3,$c4,$a0,$a1,$f4,$5f,$43 - .byte $10,$d6,$19,$14,$20,$54,$dc,$20 - .byte $3c,$2d,$c2,$00,$e5,$99,$54,$f2 - .byte $00,$b5,$81,$47,$e1,$00,$58,$81 - .byte $f2,$78,$00,$4c,$ef,$42,$16,$00 - .byte $41,$f7,$20,$f8,$52,$f6,$3c,$20 - .byte $b3,$60,$9f,$59,$42,$7f,$58,$00 - .byte $61,$2c,$64,$00,$f2,$39,$cf,$42 - .byte $00,$3c,$20,$3b,$00,$a7,$27,$00 - .byte $fc,$c7,$42,$52,$f3,$00,$3f,$56 - .byte $16,$b8,$3f,$57,$00,$e1,$e3,$6f - .byte $59,$00,$c4,$a1,$bf,$27,$a0,$92 - .byte $72,$1e,$14,$20,$f5,$7a,$00,$9c - .byte $f5,$9f,$43,$65,$d2,$00,$61,$a5 - .byte $ef,$27,$a0,$76,$67,$f3,$00,$a5 - .byte $f4,$59,$53,$40,$f5,$f3,$00,$ff - .byte $5a,$16,$30,$a5,$61,$f1,$20,$2f - .byte $59,$d1,$00,$e5,$9e,$72,$f1,$f6 - .byte $00,$92,$65,$4f,$47,$00,$83,$4f - .byte $47,$00,$b3,$6e,$c8,$70,$f1,$3e - .byte $d8,$1f,$58,$00,$f1,$74,$fa,$20 - .byte $f1,$34,$25,$4c,$10,$bc,$4f,$43 - .byte $25,$34,$00,$f4,$16,$5b,$f3,$00 - .byte $83,$7a,$00,$61,$7a,$f3,$fd,$fb - .byte $00,$83,$7a,$54,$f2,$00,$f4,$16 - .byte $5b,$f3,$54,$f2,$00,$97,$f4,$54 - .byte $f2,$00,$16,$63,$60,$f5,$f3,$21 - .byte $90,$b6,$11,$fd,$fb,$fb,$00,$f1 - .byte $36,$6c,$d2,$00,$5e,$d8,$1e,$14 - .byte $21 - .byte $a0 -packed_keywords: - .byte $14,$a0,$b3,$60,$41,$f7,$20,$a7 - .byte $27,$00,$54,$dc,$2f,$23,$00,$54 - .byte $dc,$20,$a5,$e0,$61,$7a,$00,$81 - .byte $20,$f2,$32,$30,$6c,$40,$5b,$00 - .byte $61,$92,$36,$10,$f2,$39,$cf,$42 - .byte $00,$61,$2c,$64,$00,$61,$e0,$92 - .byte $3d,$00,$34,$00,$f8,$75,$20,$83 - .byte $7a,$00,$97,$f4,$10,$f4,$16,$5b - .byte $f3,$00,$a1,$b0,$d3,$ff,$4b,$10 - .byte $d6,$54,$2f,$23,$00,$d6,$54,$20 - .byte $f1,$34,$20,$85,$92,$00,$f1,$86 - .byte $00,$f1,$ea,$00,$9f,$59,$90,$3d - .byte $14,$00,$f1,$83,$91,$00,$f2,$12 - .byte $00,$41,$f8,$00,$27,$f5,$fe,$28 - .byte $23,$00,$b4,$00,$9d,$f1,$fe,$28 - .byte $2f,$48,$14,$00,$43,$20,$92,$1d - .byte $00,$fe,$2b,$fe,$2d,$fe,$2a,$fe - .byte $2f,$fe,$5e,$74,$a0,$36,$00,$fe - .byte $3e,$fe,$3d,$fe,$3c,$9f,$47,$40 - .byte $54,$20,$7f,$42,$90,$c9,$60,$b6 - .byte $10,$d3,$90,$9f,$51,$60,$64,$a0 - .byte $83,$f2,$00,$1f,$58,$d0,$f1,$39 - .byte $00,$95,$40,$27,$40,$72,$40,$d1 - .byte $1f,$4b,$00,$81,$40,$92,$6f,$24 - .byte $00,$f4,$78,$00,$79,$f1,$00,$f1 - .byte $f6,$6f,$24,$00,$81,$b2,$f9,$00 - .byte $65,$f2,$f6,$2f,$24,$00,$e5,$af - .byte $24 - .byte $00 - .byte $f2 - .byte $30 - .alias packed_keyword_table_len $DC diff --git a/c64/kernal/,platform_generic/.dummy b/c64/kernal/,platform_generic/.dummy new file mode 100644 index 00000000..e69de29b diff --git a/c64/kernal/,platform_mega65/.dummy b/c64/kernal/,platform_mega65/.dummy new file mode 100644 index 00000000..e69de29b diff --git a/c64/kernal/,platform_ultimate64/,aliases-ultimate64.s b/c64/kernal/,platform_ultimate64/,aliases-ultimate64.s new file mode 100644 index 00000000..1f30e332 --- /dev/null +++ b/c64/kernal/,platform_ultimate64/,aliases-ultimate64.s @@ -0,0 +1,10 @@ + +;; Registers according to Ultimate 64 Command Interface ddescription, +;; https://1541u-documentation.readthedocs.io/en/latest/command%20interface.html + + .alias U64_CONTROL $DF1C ; write + .alias U64_STATUS $DF1C ; read + .alias U64_COMMAND_DATA $DF1D ; write + .alias U64_IDENTIFICATION $DF1D ; read + .alias U64_RESPONSE_DATA $DF1E ; read only + .alias U64_STATUS_DATA $DF1F ; read only From eb12f332250681b6acd468f02bccf0b5250ffed1 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 18 Jul 2019 22:02:18 +0200 Subject: [PATCH 51/90] pre-build ROMs now have platform-specific banners --- Makefile | 2 +- bin/REEADME.txt | 14 ++++++ bin/{basic => basic_generic.rom} | Bin bin/basic_mega65.rom | Bin 0 -> 8192 bytes bin/basic_ultimate64.rom | Bin 0 -> 8192 bytes bin/{chargen => chargen.rom} | Bin bin/{kernal => kernal_generic.rom} | Bin 8192 -> 8192 bytes bin/kernal_mega65.rom | Bin 0 -> 8192 bytes bin/kernal_ultimate64.rom | Bin 0 -> 8192 bytes c64/basic/,platform_generic/,hooks_generic.s | 9 ++++ c64/basic/,platform_generic/.dummy | 0 c64/basic/,platform_mega65/,hooks_mega65.s | 41 ++++++++++++++++++ c64/basic/,platform_mega65/.dummy | 0 .../,platform_ultimate64/,hooks_ultimate64.s | 9 ++++ c64/basic/basic_cold_start.s | 37 +--------------- .../,aliases-ultimate64.s | 10 ----- .../,aliases_ultimate64.s} | 0 17 files changed, 75 insertions(+), 47 deletions(-) create mode 100644 bin/REEADME.txt rename bin/{basic => basic_generic.rom} (100%) create mode 100644 bin/basic_mega65.rom create mode 100644 bin/basic_ultimate64.rom rename bin/{chargen => chargen.rom} (100%) rename bin/{kernal => kernal_generic.rom} (99%) create mode 100644 bin/kernal_mega65.rom create mode 100644 bin/kernal_ultimate64.rom create mode 100644 c64/basic/,platform_generic/,hooks_generic.s delete mode 100644 c64/basic/,platform_generic/.dummy create mode 100644 c64/basic/,platform_mega65/,hooks_mega65.s delete mode 100644 c64/basic/,platform_mega65/.dummy create mode 100644 c64/basic/,platform_ultimate64/,hooks_ultimate64.s delete mode 100644 c64/kernal/,platform_ultimate64/,aliases-ultimate64.s rename c64/{basic/,platform_ultimate64/,aliases-ultimate64.s => kernal/,platform_ultimate64/,aliases_ultimate64.s} (100%) diff --git a/Makefile b/Makefile index 0dacf6a7..e69e5731 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ SRC_KERNAL_ULTIMATE64 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_ult # Rules - maintainance -all: build/chargen build/newkern_generic build/newbasic_generic build/newkern_mega65 build/newbasic_mega65 build/newkern_ultimate64 build/newbasic_ultimate64 +all: build/chargen build/newkern_generic build/newbasic_generic build/newc65 build/newkern_ultimate64 build/newbasic_ultimate64 clean: @rm -rf build diff --git a/bin/REEADME.txt b/bin/REEADME.txt new file mode 100644 index 00000000..d3a254bc --- /dev/null +++ b/bin/REEADME.txt @@ -0,0 +1,14 @@ + +Follow these rules, or bad things will happen! + + +- Don't mix ROMs for different platforms - use generic BASIC with generic KERNAL, Mega65 BASIC with Mega65 KERNAL, etc. + +- Don't mix these ROMs with any other ROMs; the only exception is CHARGEN, this one is fully interchangeable. + +- Don't mix ROMs from different builds/versions (again, CHARGEN is an exception). + +- The generic ROM set should be compatible with any C64-compatible machine; platform-specific ROMs might not work on other platforms. + + +Have fun! diff --git a/bin/basic b/bin/basic_generic.rom similarity index 100% rename from bin/basic rename to bin/basic_generic.rom diff --git a/bin/basic_mega65.rom b/bin/basic_mega65.rom new file mode 100644 index 0000000000000000000000000000000000000000..ccea4daf4b76615ee1ccbe0452e9319593ccbc3c GIT binary patch literal 8192 zcmeHKeNY?672mr<+=0N7F<`}RU}KYlKftPEFc3rl$F*EvzHB$Kla6!H&`KCPnM~VB zNHfHfoa1_`RM1I_J#{Q(7C2!Esfpv-F|8+)xH@K%TvM91Gs%=pifVhN_K7bib*<~$ z6Szrd+UXztr!yRAZ};tcZ{PmjzPImo^t~9nXY-cErp6uXH}Aaf-mTjk#T|El_3QWF zvuVrj2bxWZYV06l3GI6)TP0665wS8>Ohs;FcPz&}w7N zT4Q;+QDLkzoW@s-^~N2>2BWgdShmryR2wUuf4OfrI(5K*>Hu=(qfPkLw*tM>k8ZMm za7#Yk`5~?=e-lj{**OU;TRuj+4op6U#H&q(sPP*9bo*=_epNcYyQy;*YF_&onyh)R z3Dw~{(LgEs`>&g}PocXWEd0e?5224gd3-l|tM^x>f$k@Z^6^Xu`q|9!O|9>vW^%PO z@V#$OAu_#tN5jk%G9E5;lIA2{xBE9};*}?pv#7iEzAfl^_`SM6{zS6=55>Ds@;iUS z$ql!Q_H*}bx_twhE_`GPJ>P+vJEm@2hYlD^N$~pVG&F_ZlxC)G^S{3M#`WtcS=IhN z+Vh8^{M!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5cS-Vhh;tStEdA9r|V{ z-x}2tT~eJ+yIO0{i370^h>~!w3d0$1iUe(#3**yX61m|65StnnS1m9Vie~ z(yZrDF^$94VUU5AG;76_rTUW7(b^)nKv;99TD<7xmWzk9SwDxrF-)uEcfznvP&t;NuuX;{Sc(N^*A;!pM7+i*AN`pzc3mQ)ds-twBbQ|<&sjb_<6?p5t z7?Ilk8XD9lH=>@}I28QGNF;J>kR7#OQwDu0Lt%Y}Azc|@8-$l$WAS@z4BXp4L6Ghj=vb2H=%wCe8MwSRI*TTWxY(Bc9c= zM{*EPo9qd2XIfC(kro8f5^=dny_*Qt6THJ~afk5lhdeY?%gs=&@R-Rkz(SPeo5526 zZ9*{fK!Ojt;xv{Z_O-uW5FFCYw9A>P_U!^aBf3;uM6=}E`OvpgBhw)VrO4db^FiG} zL#R<2Muxg7Fd*P3|OnreK+7=I2bmTPO3PPtm% z0LN{kd z1ye`q#%c$fwr_6S2B+-bojJ;NI!qq3v|5_MN=Pd-Zmy9QIiGw}E&${1jLu_CzeBBH zBxGVpGF1_=>_qw-7HQdZ>u~o0=r_@Jr?G|`ZXW;7QTor0^Y)A=8x$nm69FrNw~Fu$ qu_A&No&^LJ5LiH90f7Ys77$oKU;%*z1QrljKwtrZ1qA-L2>b)?e2xtO literal 0 HcmV?d00001 diff --git a/bin/basic_ultimate64.rom b/bin/basic_ultimate64.rom new file mode 100644 index 0000000000000000000000000000000000000000..034b50d04e07bc9744e9a164f60b66ed9db6a55e GIT binary patch literal 8192 zcmeHKeQ*>-7VnwKW+vH$T|$5blr$fj@R6`02_dpE2_TCMpNRr`$4#O+cSAsn!z&GC z0f&P*?t)8%5-gF;lHOzz7M4TsKvKt1iaV)NM~t3Ud3RV|_JFH{*?b{#?A+_wgtM%= zk3a8^Y%)FFuixu_{rcCx*Yo3Jk?^ubi%ZK&%V#gDSh0M`>Qb?M;UkZ&T()5Gy2s1h zYu8N8PG6NbWogb6GjgZTT3_s%j~LeAk_^s5pJao#2!L#KB5PVG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97oSdvTK%%Ml~&kT{~w*SXPc7S+N>FCRQw2R$8$L z7tBdd#~9%!j+42C-MMX~usd%Ej)BRrBry_x?Vh*aIyJE=!$Ln%8{r#u$pZZN>^x_l zGd&#Tm8@9E1D1GIc^p)o^IoHnu^JJQYG8)RLU~*%W54a+fUw{v_ zzh4v_($I+klA!GV{%AcZJXRY)Ps#h4P`6SxNzf47cm`3|0M`>xkc&fz0eZI|hs8jo zfpFn7Kw;z=iXhLF^At|b1rFIeBeHi!AwFna-VPU|n=_Sda-lp2fHqftkmSm<xL**N#n5!|tKE|kXQU^@qX{s&Mc@Iyfqh`&J>meo?WdQs_8 zz}LS+8`Vk)k*6)ymP+sv7>=Hpo1{w4Bu~ks!MRtC55<~((^cp)j=*pPh9fW>f#C=Y XM_@Pt!x0#cz;FbHBQP9+p$PmFNqvcw literal 0 HcmV?d00001 diff --git a/bin/chargen b/bin/chargen.rom similarity index 100% rename from bin/chargen rename to bin/chargen.rom diff --git a/bin/kernal b/bin/kernal_generic.rom similarity index 99% rename from bin/kernal rename to bin/kernal_generic.rom index b169ad255553ccf808ff4860bb28ea4feb8e634f..52d24cdc4556ece34391a91eb55995fb46213568 100644 GIT binary patch delta 14 VcmZp0XmHr@NSJZg=EuUaJOD0b1+xGE delta 14 VcmZp0XmHr@NSJZv=EuUaJOC}91(E;& diff --git a/bin/kernal_mega65.rom b/bin/kernal_mega65.rom new file mode 100644 index 0000000000000000000000000000000000000000..52d24cdc4556ece34391a91eb55995fb46213568 GIT binary patch literal 8192 zcmeHLeRLbewI9vemhHsx+Bjh$Uqee9ISo|22G9#1aSEg|Z>Zgb59iT5w$QXPFTB35 z7PmcZ74RD6Lpl<18jIGTE?(E`dK0+>f&s)qi{5v5sf&oqO-x`Q1BnXJ?Jj{BJ%3^BI`W!2g>JC?^b?sGNj{iljd2B>CXa zs!i$>l@sjt-ag)?oMbDAW1=O|*)P3W=?(RFrv1-gtpSJ9V0V(P8U?NLW=kT}uRUW4 zk#tfm0|%;CIst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3g+k2SbGi+|7Ay#60719V}EzId5loTBTJbbXS3%cO!y*P1k(raRLV z{?+7UYcrAfbN(ya!CkB;X@=?kOq-9dLx(8Hs&=Pcc3 l((jn`+a^t<>DsjQRpK$}W|RIT85xlg?31l#!|0;)Ujfm?!-N0; literal 0 HcmV?d00001 diff --git a/bin/kernal_ultimate64.rom b/bin/kernal_ultimate64.rom new file mode 100644 index 0000000000000000000000000000000000000000..52d24cdc4556ece34391a91eb55995fb46213568 GIT binary patch literal 8192 zcmeHLeRLbewI9vemhHsx+Bjh$Uqee9ISo|22G9#1aSEg|Z>Zgb59iT5w$QXPFTB35 z7PmcZ74RD6Lpl<18jIGTE?(E`dK0+>f&s)qi{5v5sf&oqO-x`Q1BnXJ?Jj{BJ%3^BI`W!2g>JC?^b?sGNj{iljd2B>CXa zs!i$>l@sjt-ag)?oMbDAW1=O|*)P3W=?(RFrv1-gtpSJ9V0V(P8U?NLW=kT}uRUW4 zk#tfm0|%;CIst?KWcfW|JrdF&eJBN7Lar( zMbdyu;`{{66GlT}G#p0ngvZ~Bv1z()bV#0gu8uUO$cvZB#VN8bNfxGRwxftBs!RPP zOpW=MFg4FlnEyJaBL8A0y}irb%_1OBdfA3sXYU_HeY8t7E1d%`(vSg-|+;S8XL0UgJJ6s+o+eZueK)G zl9s`Y_ufGmqMVWvkR-5xPD|qWDdSpSth3(-F?XhYp>*u{DK=%fw*2%aEKhGSJ9y)0 z{g}I4WD7h(tv85k|3Fur@yNxee>}nR0u2}p<9tdlWp>E*8_?6A1r}x562>bDq1FLY ze{?20yS|*|kIf>{L##+ixF#%p2AbZ?@_Xm_tJuQqg3apovOIG4s5QgNXeM{>M+@}s zU~c)(0Fho1T;!Ul&`Hp)S426XmbhCIxo?E}l_3N74tey?u{`CiO0V=*X4kY1#_AK@ z4weh~Y)N!i2QA16NIpsY+2LvPv@355V#{FHFycA-;ThEnn*~CUua2O&CA7t3#|N4D zJ~AF~ZiWpc)N;~*q^a*p2PISOminc%6;_9I02b~*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3uT@w}mMW^MQfDg<0fv2#H z0y}WvX{;e{U?kyag*q!jEC4 zEBpkMev@(pYTRZl(y>ttr%@i-Wcm9{qFNATyXRhaG!Fn!Y1)dUFrz3m<2>hah#p!uE#LV1f$8Qp>kXy0`9GOa zv43VpocuMe$PXOC^$+~EF!F)TWMtWu|~lo z?Gu%K0vy#emI9Xr`F?ot@F;%|9-<{8R&UCBT$~kUn2bS2F1oF+Dy@twTFfzy-jv*4 z#wm?Pp|Z~fjv+UV>Uw&5TIppuaFr0@F6D-slm{;NO-7*)azSoR(T!>9Oaj=C($>nt zPF2%@Q|7f&)>q1mOF-jrp~(z!+K0Db25&x>7_=YQfjgeUqE%i%g7%JjeBfy;?y0xR zEfc_J!np$WXMz)z5Uh5NIs;w-q;dq#nj8%ZN(pA2l)rst^p*_X9v_KCGaUSh&o>>3jy}Gcccl`3%fwU_Jx$8JN$&-^+lyO8&BBYe4GH{6!<`U;H^E>Uw|f zh`Ph-miQNqXh3g+k2SbGi+|7Ay#60719V}EzId5loTBTJbbXS3%cO!y*P1k(raRLV z{?+7UYcrAfbN(ya!CkB;X@=?kOq-9dLx(8Hs&=Pcc3 l((jn`+a^t<>DsjQRpK$}W|RIT85xlg?31l#!|0;)Ujfm?!-N0; literal 0 HcmV?d00001 diff --git a/c64/basic/,platform_generic/,hooks_generic.s b/c64/basic/,platform_generic/,hooks_generic.s new file mode 100644 index 00000000..4f743e84 --- /dev/null +++ b/c64/basic/,platform_generic/,hooks_generic.s @@ -0,0 +1,9 @@ + +;; Platform-specific hooks + + +.macro PLATFORM_HOOK_BANNER + + .byte $05, " OPEN ROMS, ", $00 + +.macend diff --git a/c64/basic/,platform_generic/.dummy b/c64/basic/,platform_generic/.dummy deleted file mode 100644 index e69de29b..00000000 diff --git a/c64/basic/,platform_mega65/,hooks_mega65.s b/c64/basic/,platform_mega65/,hooks_mega65.s new file mode 100644 index 00000000..d8eecbaf --- /dev/null +++ b/c64/basic/,platform_mega65/,hooks_mega65.s @@ -0,0 +1,41 @@ + +;; Platform-specific hooks + + +.macro PLATFORM_HOOK_BANNER + + ;; New banner from Retrofan + .byte $9a, $12, $20, $20, $7f, $a9, $20, $20, $1f, $20, $9a, $20, $20, $20 + .byte $20, $1f, $20, $9a, $a9, $20, $20, $20, $92, $a1, $1f, $12, $20, $9a, $a9, $20 + .byte $20, $20, $7f, $1f, $20, $20, $9a, $a3, $a3, $a3, $a3, $a3, $a3, $a3, $1f, $20 + .byte $20, $20, $20, $05, $92, $4d, $45, $47, $41, $9a, $12, $20, $20, $20, $20, $20 + .byte $20, $1f, $20, $9a, $20, $20, $92, $a2, $bb, $1f, $12, $20, $9a, $20, $20, $92 + .byte $ac, $a2, $a2, $1f, $12, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20 + .byte $20, $1e, $a3, $a3, $a3, $a3, $a3, $a3, $1f, $20, $20, $20, $20, $05, $92, $42 + .byte $41, $53, $49, $43, $9a, $12, $20, $20, $92, $7f, $a9, $12, $20, $20, $1f, $20 + .byte $9a, $20, $20, $a2, $92, $be, $1f, $12, $20, $9a, $20, $20, $92, $bc, $12, $20 + .byte $20, $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $20, $9e, $a3, $a3, $a3 + .byte $a3, $a3, $1f, $20, $20, $20, $20, $05, $92, $2d, $2d, $2d, $2d, $2d, $2d, $9a + .byte $12, $20, $20, $1f, $20, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $20, $20 + .byte $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20, $9a + .byte $20, $20, $1f, $20, $20, $96, $a3, $a3, $a3, $a3, $1f + .byte $92, $0D, $0D, $05, $00 + + ;; Original Deft-supplied banner + ;; .byte $9A,$12,$A3,$A3,$A3,$A3,$A3,$A3,$DF,$9B,$92,$20,$05,$12,$A0,$A0 + ;; .byte $DF,$9B,$92,$20,$05,$12,$A0,$A0,$DF,$9B,$92,$20,$05,$12,$A0,$A0 + ;; .byte $DF,$9B,$92,$20,$05,$12,$A0,$A0,$DF,$9A,$92,$20,$05,$20,$20,$20 + ;; .byte $4D,$20,$45,$20,$47,$20,$41,$0D,$99,$12,$A3,$A3,$A3,$A3,$A3,$A3 + ;; .byte $A3,$DF,$92,$7F,$12,$CD,$CD,$DF,$92,$7F,$12,$DF,$05,$92,$20,$20 + ;; .byte $99,$7F,$12,$DF,$05,$92,$20,$20,$99,$7F,$12,$DF,$92,$7F,$12,$DF + ;; .byte $05,$92,$20,$20,$99,$42,$20,$41,$20,$53,$20,$49,$20,$43,$0D,$9E + ;; .byte $12,$A3,$A3,$A3,$A3,$A3,$A3,$A3,$A3,$DF,$9B,$92,$7F,$12,$DF,$92 + ;; .byte $7F,$12,$DF,$92,$7F,$12,$CD,$05,$92,$20,$20,$9B,$7F,$12,$CD,$92 + ;; .byte $7F,$12,$DF,$92,$7F,$12,$CD,$92,$7F,$12,$DF,$9A,$92,$20,$05,$20 + ;; .byte $9A,$2D,$2D,$2D,$2D,$2D,$2D,$2D,$0D,$96,$12,$A3,$A3,$A3,$A3,$A3 + ;; .byte $A3,$A3,$A3,$A3,$DF,$9A,$92,$7F,$12,$DF,$92,$7F,$9B,$20,$9A,$7F + ;; .byte $12,$A0,$A0,$9B,$92,$20,$9A,$7F,$12,$A0,$A0,$9B,$92,$20,$9A,$7F + ;; .byte $12,$DF,$92,$7F,$9B,$20,$9A,$20,$9B,"0.2.0.0",$0D + ;; .byte $0D,$05,$92,$00 + +.macend diff --git a/c64/basic/,platform_mega65/.dummy b/c64/basic/,platform_mega65/.dummy deleted file mode 100644 index e69de29b..00000000 diff --git a/c64/basic/,platform_ultimate64/,hooks_ultimate64.s b/c64/basic/,platform_ultimate64/,hooks_ultimate64.s new file mode 100644 index 00000000..717d70bc --- /dev/null +++ b/c64/basic/,platform_ultimate64/,hooks_ultimate64.s @@ -0,0 +1,9 @@ + +;; Platform-specific hooks + + +.macro PLATFORM_HOOK_BANNER + + .byte $05, " OPEN ROMS FOR ULTIMATE 64", $0D, $0D, " ", $00 + +.macend diff --git a/c64/basic/basic_cold_start.s b/c64/basic/basic_cold_start.s index 6e231458..de4faf76 100644 --- a/c64/basic/basic_cold_start.s +++ b/c64/basic/basic_cold_start.s @@ -15,42 +15,7 @@ basic_cold_start: ; Used 217 bytes startup_banner: - ;; Simple banner - .byte $05, " OPEN ROMS, ", $00 - - ;; New banner from Retrofan - ;; .byte $9a, $12, $20, $20, $7f, $a9, $20, $20, $1f, $20, $9a, $20, $20, $20 - ;; .byte $20, $1f, $20, $9a, $a9, $20, $20, $20, $92, $a1, $1f, $12, $20, $9a, $a9, $20 - ;; .byte $20, $20, $7f, $1f, $20, $20, $9a, $a3, $a3, $a3, $a3, $a3, $a3, $a3, $1f, $20 - ;; .byte $20, $20, $20, $05, $92, $4d, $45, $47, $41, $9a, $12, $20, $20, $20, $20, $20 - ;; .byte $20, $1f, $20, $9a, $20, $20, $92, $a2, $bb, $1f, $12, $20, $9a, $20, $20, $92 - ;; .byte $ac, $a2, $a2, $1f, $12, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20 - ;; .byte $20, $1e, $a3, $a3, $a3, $a3, $a3, $a3, $1f, $20, $20, $20, $20, $05, $92, $42 - ;; .byte $41, $53, $49, $43, $9a, $12, $20, $20, $92, $7f, $a9, $12, $20, $20, $1f, $20 - ;; .byte $9a, $20, $20, $a2, $92, $be, $1f, $12, $20, $9a, $20, $20, $92, $bc, $12, $20 - ;; .byte $20, $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $20, $9e, $a3, $a3, $a3 - ;; .byte $a3, $a3, $1f, $20, $20, $20, $20, $05, $92, $2d, $2d, $2d, $2d, $2d, $2d, $9a - ;; .byte $12, $20, $20, $1f, $20, $20, $9a, $20, $20, $1f, $20, $9a, $20, $20, $20, $20 - ;; .byte $1f, $20, $9a, $20, $20, $20, $20, $20, $1f, $20, $9a, $20, $20, $1f, $20, $9a - ;; .byte $20, $20, $1f, $20, $20, $96, $a3, $a3, $a3, $a3, $1f - ;; .byte $92, $0D, $0D, $05, $00 - - ;; Original Deft-supplied banner - ;; .byte $9A,$12,$A3,$A3,$A3,$A3,$A3,$A3,$DF,$9B,$92,$20,$05,$12,$A0,$A0 - ;; .byte $DF,$9B,$92,$20,$05,$12,$A0,$A0,$DF,$9B,$92,$20,$05,$12,$A0,$A0 - ;; .byte $DF,$9B,$92,$20,$05,$12,$A0,$A0,$DF,$9A,$92,$20,$05,$20,$20,$20 - ;; .byte $4D,$20,$45,$20,$47,$20,$41,$0D,$99,$12,$A3,$A3,$A3,$A3,$A3,$A3 - ;; .byte $A3,$DF,$92,$7F,$12,$CD,$CD,$DF,$92,$7F,$12,$DF,$05,$92,$20,$20 - ;; .byte $99,$7F,$12,$DF,$05,$92,$20,$20,$99,$7F,$12,$DF,$92,$7F,$12,$DF - ;; .byte $05,$92,$20,$20,$99,$42,$20,$41,$20,$53,$20,$49,$20,$43,$0D,$9E - ;; .byte $12,$A3,$A3,$A3,$A3,$A3,$A3,$A3,$A3,$DF,$9B,$92,$7F,$12,$DF,$92 - ;; .byte $7F,$12,$DF,$92,$7F,$12,$CD,$05,$92,$20,$20,$9B,$7F,$12,$CD,$92 - ;; .byte $7F,$12,$DF,$92,$7F,$12,$CD,$92,$7F,$12,$DF,$9A,$92,$20,$05,$20 - ;; .byte $9A,$2D,$2D,$2D,$2D,$2D,$2D,$2D,$0D,$96,$12,$A3,$A3,$A3,$A3,$A3 - ;; .byte $A3,$A3,$A3,$A3,$DF,$9A,$92,$7F,$12,$DF,$92,$7F,$9B,$20,$9A,$7F - ;; .byte $12,$A0,$A0,$9B,$92,$20,$9A,$7F,$12,$A0,$A0,$9B,$92,$20,$9A,$7F - ;; .byte $12,$DF,$92,$7F,$9B,$20,$9A,$20,$9B,"0.2.0.0",$0D - ;; .byte $0D,$05,$92,$00 + `PLATFORM_HOOK_BANNER ;; Work out free bytes, and display jsr basic_do_new diff --git a/c64/kernal/,platform_ultimate64/,aliases-ultimate64.s b/c64/kernal/,platform_ultimate64/,aliases-ultimate64.s deleted file mode 100644 index 1f30e332..00000000 --- a/c64/kernal/,platform_ultimate64/,aliases-ultimate64.s +++ /dev/null @@ -1,10 +0,0 @@ - -;; Registers according to Ultimate 64 Command Interface ddescription, -;; https://1541u-documentation.readthedocs.io/en/latest/command%20interface.html - - .alias U64_CONTROL $DF1C ; write - .alias U64_STATUS $DF1C ; read - .alias U64_COMMAND_DATA $DF1D ; write - .alias U64_IDENTIFICATION $DF1D ; read - .alias U64_RESPONSE_DATA $DF1E ; read only - .alias U64_STATUS_DATA $DF1F ; read only diff --git a/c64/basic/,platform_ultimate64/,aliases-ultimate64.s b/c64/kernal/,platform_ultimate64/,aliases_ultimate64.s similarity index 100% rename from c64/basic/,platform_ultimate64/,aliases-ultimate64.s rename to c64/kernal/,platform_ultimate64/,aliases_ultimate64.s From cf795d5f3c9745e136476a81c15c29b2cf4d8bf0 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 18 Jul 2019 23:29:35 +0200 Subject: [PATCH 52/90] started cleanup of aliases, build system fixes --- .gitignore | 1 - Makefile | 47 ++++-- c64/aliases/,aliases_error_codes.s | 63 ++++++++ c64/aliases/,aliases_hardware.s | 154 +++++++++++++++++++ c64/aliases/,aliases_ram_lowmem.s | 33 ++++ c64/aliases/{.dummy => ,aliases_rom_basic.s} | 0 c64/aliases/,aliases_rom_kernal.s | 41 +++++ c64/basic/,aliases.s | 130 ---------------- c64/kernal/,aliases.s | 131 ---------------- c64/kernal/iec_pull_atn_clk_release_data.s | 14 +- c64/kernal/iec_pull_clk_release_data.s | 10 +- c64/kernal/iec_pull_data_release_atn_clk.s | 14 +- c64/kernal/iec_release_atn.s | 6 +- c64/kernal/iec_release_atn_clk_data.s | 14 +- c64/kernal/iec_release_clk_data.s | 10 +- c64/kernal/iec_release_clk_pull_data.s | 10 +- c64/kernal/iec_rx_byte.s | 10 +- c64/kernal/iec_set_idle.s | 8 +- c64/kernal/iec_turnaround_to_listen.s | 4 +- c64/kernal/iec_tx_byte.s | 4 +- c64/kernal/iec_tx_command.s | 8 +- c64/kernal/iec_wait_for_clk_release.s | 5 +- c64/kernal/iec_wait_for_data_pull.s | 3 +- c64/kernal/iec_wait_for_data_release.s | 3 +- c64/kernal/ramtas.s | 42 ++--- 25 files changed, 410 insertions(+), 355 deletions(-) create mode 100644 c64/aliases/,aliases_error_codes.s create mode 100644 c64/aliases/,aliases_hardware.s create mode 100644 c64/aliases/,aliases_ram_lowmem.s rename c64/aliases/{.dummy => ,aliases_rom_basic.s} (100%) create mode 100644 c64/aliases/,aliases_rom_kernal.s diff --git a/.gitignore b/.gitignore index 5fdfc0df..8066747b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ temp.s temp.map -packed_messages.s ophis.bin build/* diff --git a/Makefile b/Makefile index e69e5731..b7b0637e 100644 --- a/Makefile +++ b/Makefile @@ -13,6 +13,10 @@ SRC_KERNAL_GENERIC = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_gen SRC_KERNAL_MEGA65 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_mega65/*.s) SRC_KERNAL_ULTIMATE64 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_ultimate64/*.s) +# List of tools + +TOOLS_LIST = build/collect_data build/compress_text build/preprocess build/similarity + # Rules - maintainance all: build/chargen build/newkern_generic build/newbasic_generic build/newc65 build/newkern_ultimate64 build/newbasic_ultimate64 @@ -21,10 +25,7 @@ clean: @rm -rf build @rm -f temp.s @rm -f temp.map - @rm -f c64/basic/packed_messages.s - -.PHONY: prep -prep: Ophis build/collect_data build/compress_text build/preprocess build/similarity + @rm -f ophis.bin Ophis: git submodule init @@ -59,15 +60,22 @@ build/chargen: build/pngprepare assets/8x8font.png # Rules - platform 'generic' -build/basic_generic/OUT.BIN: build/preprocess $(SRC_BASIC_GENERIC) c64/basic/packed_messages.s +build/basic_generic/OUT.BIN: $(TOOLS_LIST) $(SRC_BASIC_GENERIC) build/basic/packed_messages.s + @echo + @echo ### Building BASIC for generic systems + @echo @mkdir -p build/basic_generic @rm -f build/basic_generic/* @for SRC in $(SRC_BASIC_GENERIC); do \ ln -s ../../$$SRC build/basic_generic/$$(basename $$SRC); \ done + @ln -s ../../build/basic/packed_messages.s build/basic_generic/packed_messages.s build/preprocess -d build/basic_generic -l a000 -h e4d2 -build/kernal_generic/OUT.BIN: build/preprocess $(SRC_KERNAL_GENERIC) +build/kernal_generic/OUT.BIN: $(TOOLS_LIST) $(SRC_KERNAL_GENERIC) + @echo + @echo ### Building KERNAL for generic systems + @echo @mkdir -p build/kernal_generic @rm -f build/kernal_generic/* @for SRC in $(SRC_KERNAL_GENERIC); do \ @@ -86,15 +94,22 @@ build/newbasic_generic: build/newrom_generic Makefile # Rules - platform 'Mega 65' -build/basic_mega65/OUT.BIN: build/preprocess $(SRC_BASIC_MEGA65) c64/basic/packed_messages.s +build/basic_mega65/OUT.BIN: $(TOOLS_LIST) $(SRC_BASIC_MEGA65) build/basic/packed_messages.s + @echo + @echo ### Building BASIC for Mega65 + @echo @mkdir -p build/basic_mega65 @rm -f build/basic_mega65/* @for SRC in $(SRC_BASIC_MEGA65); do \ ln -s ../../$$SRC build/basic_mega65/$$(basename $$SRC); \ done + @ln -s ../../build/basic/packed_messages.s build/basic_mega65/packed_messages.s build/preprocess -d build/basic_mega65 -l a000 -h e4d2 -build/kernal_mega65/OUT.BIN: build/preprocess $(SRC_KERNAL_MEGA65) +build/kernal_mega65/OUT.BIN: $(TOOLS_LIST) $(SRC_KERNAL_MEGA65) + @echo + @echo ### Building KERNAL for Mega65 + @echo @mkdir -p build/kernal_mega65 @rm -f build/kernal_mega65/* @for SRC in $(SRC_KERNAL_MEGA65); do \ @@ -119,15 +134,22 @@ build/newc65: build/newkern_mega65 build/newbasic_mega65 build/chargen Makefile # Rules - platform 'Ultimate 64' -build/basic_ultimate64/OUT.BIN: build/preprocess $(SRC_BASIC_ULTIMATE64) c64/basic/packed_messages.s +build/basic_ultimate64/OUT.BIN: $(TOOLS_LIST) $(SRC_BASIC_ULTIMATE64) build/basic/packed_messages.s + @echo + @echo ### Building BASIC for Ultimate 64 + @echo @mkdir -p build/basic_ultimate64 @rm -f build/basic_ultimate64/* @for SRC in $(SRC_BASIC_ULTIMATE64); do \ ln -s ../../$$SRC build/basic_ultimate64/$$(basename $$SRC); \ done + @ln -s ../../build/basic/packed_messages.s build/basic_ultimate64/packed_messages.s build/preprocess -d build/basic_ultimate64 -l a000 -h e4d2 -build/kernal_ultimate64/OUT.BIN: build/preprocess $(SRC_KERNAL_ULTIMATE64) +build/kernal_ultimate64/OUT.BIN: $(TOOLS_LIST) $(SRC_KERNAL_ULTIMATE64) + @echo + @echo ### Building KERNAL for Ultimate 64 + @echo @mkdir -p build/kernal_ultimate64 @rm -f build/kernal_ultimate64/* @for SRC in $(SRC_KERNAL_ULTIMATE64); do \ @@ -146,8 +168,9 @@ build/newbasic_ultimate64: build/newrom_ultimate64 Makefile # Rules - misc -c64/basic/packed_messages.s: Makefile build/compress_text - build/compress_text > c64/basic/packed_messages.s +build/basic/packed_messages.s: Makefile build/compress_text + @mkdir -p build/basic + build/compress_text > build/basic/packed_messages.s # Rules - tests diff --git a/c64/aliases/,aliases_error_codes.s b/c64/aliases/,aliases_error_codes.s new file mode 100644 index 00000000..e27f5373 --- /dev/null +++ b/c64/aliases/,aliases_error_codes.s @@ -0,0 +1,63 @@ + + ;; Kernal error codes - returned in the A register + ;; Described in 'Commodore 64 Programmer's Reference Guide', page 306 + + .alias K_ERR_ROUTINE_TERMINATED $00 + .alias K_ERR_TOO_MANY_OPEN_FILES $01 + .alias K_ERR_FILE_ALREADY_OPEN $02 + .alias K_ERR_FILE_NOT_OPEN $03 + .alias K_ERR_FILE_NOT_FOUND $04 + .alias K_ERR_DEVICE_NOT_FOUND $05 + .alias K_ERR_FILE_NOT_INPUT $06 + .alias K_ERR_FILE_NOT_OUTPUT $07 + .alias K_ERR_FILE_NAME_MISSING $08 + .alias K_ERR_ILLEGAL_DEVICE_NUMBER $09 + .alias K_ERR_TOP_MEM_RS232 $F0 + + ;; Kernal status codes for READST routine (IOSTATUS) + ;; Described in 'Commodore 64 Programmer's Reference Guide', page 292 + + ;; For IEC devices + .alias K_STS_TIMEOUT_WRITE $01 + .alias K_STS_TIMEOUT_READ $02 + .alias K_STS_EOI $40 + .alias K_STS_DEVICE_NOT_FOUND $80 + ;; For tape deck + .alias K_STS_SHORT_BLOCK $04 + .alias K_STS_LONG_BLOCK $08 + .alias K_STS_READ_ERROR $10 + .alias K_STS_CHECKSUM_ERROR $20 + .alias K_STS_END_OF_FILE $40 + .alias K_STS_END_OF_TAPE $80 + + ;; BASIC error codes, taken from http://sta.c64.org/cbm64baserr.html + .alias B_ERR_TOO_MANY_FILES $01 + .alias B_ERR_FILE_OPEN $02 + .alias B_ERR_FILE_NOT_OPEN $03 + .alias B_ERR_FILE_NOT_FOUND $04 + .alias B_ERR_DEVICE_NOT_PRESENT $05 + .alias B_ERR_NOT_INPUT_FILE $06 + .alias B_ERR_NOT_OUTPUT_FILE $07 + .alias B_ERR_MISSING_FILENAME $08 + .alias B_ERR_ILLEGAL_DEVICE_NUMBER $09 + .alias B_ERR_NEXT_WITHOUT_FOR $0A + .alias B_ERR_SYNTAX $0B + .alias B_ERR_RETURN_WITHOUT_GOSUB $0C + .alias B_ERR_OUT_OF_DATA $0D + .alias B_ERR_ILLEGAL_QUANTITY $0E + .alias B_ERR_OVERFLOW $0F + .alias B_ERR_OUT_OF_MEMORY $10 + .alias B_ERR_UNDEFD_STATEMENT $11 + .alias B_ERR_BAD_SUBSCRIPT $12 + .alias B_ERR_REDIMD_ARRAY $13 + .alias B_ERR_DIVISION_BY_ZERO $14 + .alias B_ERR_ILLEGAL_DIRECT $15 + .alias B_ERR_TYPE_MISMATCH $16 + .alias B_ERR_STRING_TOO_LONG $17 + .alias B_ERR_FILE_DATA $18 + .alias B_ERR_FORMULA_TOO_COMPLEX $19 + .alias B_ERR_CANT_CONTINUE $1A + .alias B_ERR_UNDEFD_FUNCTION $1B + .alias B_ERR_VERIFY $1C + .alias B_ERR_LOAD $1D + .alias B_ERR_BREAK $1E diff --git a/c64/aliases/,aliases_hardware.s b/c64/aliases/,aliases_hardware.s new file mode 100644 index 00000000..ee6ceddb --- /dev/null +++ b/c64/aliases/,aliases_hardware.s @@ -0,0 +1,154 @@ + +;; +;; Names of hardware registers - slightly modified names from C64 Programmer's Reference Guide +;; + + ;; CPU memory registers + + .alias CPU_D6510 $0000 + .alias CPU_R6510 $0001 + + ;; VIC-II registers + + .alias VIC_SP0X $D000 + .alias VIC_SP0Y $D001 + .alias VIC_SP1X $D002 + .alias VIC_SP1Y $D003 + .alias VIC_SP2X $D004 + .alias VIC_SP2Y $D005 + .alias VIC_SP3X $D006 + .alias VIC_SP3Y $D007 + .alias VIC_SP4X $D008 + .alias VIC_SP4Y $D009 + .alias VIC_SP5X $D00A + .alias VIC_SP5Y $D00B + .alias VIC_SP6X $D00C + .alias VIC_SP6Y $D00D + .alias VIC_SP7X $D00E + .alias VIC_SP7Y $D00F + + .alias VIC_MSIGX $D010 + .alias VIC_SCROLLY $D011 + .alias VIC_RASTER $D012 + .alias VIC_LPENX $D013 + .alias VIC_LPENY $D014 + .alias VIC_SPENA $D015 + .alias VIC_SCROLX $D016 + .alias VIC_YXPAND $D017 + .alias VIC_YMCSB $D018 + .alias VIC_IRQ $D019 + .alias VIC_IRQMSK $D01A + .alias VIC_SPBGPR $D01B + .alias VIC_SPMC $D01C + .alias VIC_XXPAND $D01D + .alias VIC_SPSPCL $D01E + .alias VIC_SPBGCL $D01F + + .alias VIC_EXTCOL $D020 + .alias VIC_BGCOL0 $D021 + .alias VIC_BGCOL1 $D022 + .alias VIC_BGCOL2 $D023 + .alias VIC_BGCOL3 $D024 + .alias VIC_SPMC0 $D025 + .alias VIC_SPMC1 $D026 + .alias VIC_SP0COL $D027 + .alias VIC_SP1COL $D028 + .alias VIC_SP2COL $D029 + .alias VIC_SP3COL $D02A + .alias VIC_SP4COL $D02B + .alias VIC_SP5COL $D02C + .alias VIC_SP6COL $D02D + .alias VIC_SP7COL $D02E + + ;; SID #1 registers + + .alias SID1_FRELO1 $D400 + .alias SID1_FREHI1 $D401 + .alias SID1_PWLO1 $D402 + .alias SID1_PWHI1 $D403 + .alias SID1_VCREG1 $D404 + .alias SID1_ATDCY1 $D405 + .alias SID1_SUREL1 $D406 + + .alias SID1_FRELO2 $D407 + .alias SID1_FREHI2 $D408 + .alias SID1_PWLO2 $D409 + .alias SID1_PWHI2 $D40A + .alias SID1_VCREG2 $D40B + .alias SID1_ATDCY2 $D40C + .alias SID1_SUREL2 $D40D + + .alias SID1_FRELO3 $D40E + .alias SID1_FREHI3 $D40F + .alias SID1_PWLO3 $D410 + .alias SID1_PWHI3 $D411 + .alias SID1_VCREG3 $D412 + .alias SID1_ATDCY3 $D413 + .alias SID1_SUREL3 $D414 + + .alias SID1_CUTLO $D415 + .alias SID1_CUTHI $D416 + .alias SID1_RESON $D417 + .alias SID1_SIGVOL $D418 + .alias SID1_POTX $D419 + .alias SID1_POTY $D41A + .alias SID1_RANDOM $D41B + .alias SID1_ENV3 $D41C + + ;; SID #2, #3, #4 registers + + .alias SID2_SIGVOL $D438 + .alias SID3_SIGVOL $D458 + .alias SID4_SIGVOL $D478 + + ;; CIA #1 registers + + .alias CIA1_PRA $DC00 + .alias CIA1_PRB $DC01 + .alias CIA1_DDRA $DC02 + .alias CIA1_DDRB $DC03 + + .alias CIA1_TIMALO $DC04 + .alias CIA1_TIMAHI $DC05 + .alias CIA1_TIMBLO $DC06 + .alias CIA1_TIMBHI $DC07 + + .alias CIA1_TODTEN $DC08 + .alias CIA1_TODSEC $DC09 + .alias CIA1_TODMIN $DC0A + .alias CIA1_TODHRS $DC0B + + .alias CIA1_SDR $DC0C + .alias CIA1_ICR $DC0D + .alias CIA1_CRA $DC0E + .alias CIA1_CRB $DC0F + + ;; CIA #2 registers + + .alias CIA2_PRA $DD00 ; VIC bank switching and IEC port + .alias CIA2_PRB $DD01 + .alias CIA2_DDRA $DD02 + .alias CIA2_DDRB $DD03 + + .alias CIA2_TIMALO $DD04 + .alias CIA2_TIMAHI $DD05 + .alias CIA2_TIMBLO $DD06 + .alias CIA2_TIMBHI $DD07 + + .alias CIA2_TODTEN $DD08 + .alias CIA2_TODSEC $DD09 + .alias CIA2_TODMIN $DD0A + .alias CIA2_TODHRS $DD0B + + .alias CIA2_SDR $DD0C + .alias CIA2_ICR $DD0D + .alias CIA2_CRA $DD0E + .alias CIA2_CRB $DD0F + + ;; CIA #2 helper bits - IEC bus + + .alias BIT_CIA2_PRA_ATN_OUT $08 ; 1 - low (pulled), 0 - high (released) + .alias BIT_CIA2_PRA_CLK_OUT $10 ; 1 - low (pulled), 0 - high (released) + .alias BIT_CIA2_PRA_DAT_OUT $20 ; 1 - low (pulled), 0 - high (released) + .alias BIT_CIA2_PRA_CLK_IN $40 ; 0 - low (pulled), 1 - high (released) + .alias BIT_CIA2_PRA_DAT_IN $80 ; 0 - low (pulled), 1 - high (released) diff --git a/c64/aliases/,aliases_ram_lowmem.s b/c64/aliases/,aliases_ram_lowmem.s new file mode 100644 index 00000000..a024d66f --- /dev/null +++ b/c64/aliases/,aliases_ram_lowmem.s @@ -0,0 +1,33 @@ +;; +;; Names of ZP and low memory locations (only the implemented ones) +;; (https://www.c64-wiki.com/wiki/Zeropage) +;; + + ;; $000-$001 - 6502 CPU registers + + ;; Registers for SYS call + .alias sys_reg_a $30c + .alias sys_reg_x $30d + .alias sys_reg_y $30e + .alias sys_reg_p $30f + .alias sys_jmp $310 + + ;; Kernal vectors - interrupts + .alias CINV $0314 + .alias CBINV $0316 + .alias NMINV $0318 + + ;; Kernal vectors - routines + .alias IOPEN $031A + .alias ICLOSE $031C + .alias ICHKIN $031E + .alias ICKOUT $0320 + .alias ICLRCH $0322 + .alias IBASIN $0324 + .alias IBASOUT $0326 + .alias ISTOP $0328 + .alias IGETIN $032A + .alias ICLALL $032C + .alias USRCMD $032E + .alias ILOAD $0330 + .alias ISAVE $0331 diff --git a/c64/aliases/.dummy b/c64/aliases/,aliases_rom_basic.s similarity index 100% rename from c64/aliases/.dummy rename to c64/aliases/,aliases_rom_basic.s diff --git a/c64/aliases/,aliases_rom_kernal.s b/c64/aliases/,aliases_rom_kernal.s new file mode 100644 index 00000000..bb2bd4e4 --- /dev/null +++ b/c64/aliases/,aliases_rom_kernal.s @@ -0,0 +1,41 @@ + + ;; Kernal jump table + .alias JCINT $FF81 + .alias JIOINIT $FF84 + .alias JRAMTAS $FF87 + .alias JRESTOR $FF8A + .alias JVECTOR $FF8D + .alias JSETMSG $FF90 + .alias JSECOND $FF93 + .alias JTKSA $FF96 + .alias JMEMTOP $FF99 + .alias JMEMBOT $FF9C + .alias JSCNKEY $FF9F + .alias JSETTMO $FFA2 + .alias JACPTR $FFA5 + .alias JCIOUT $FFA8 + .alias JUNTLK $FFAB + .alias JUNLSN $FFAE + .alias JLISTEN $FFB1 + .alias JTALK $FFB4 + .alias JREADST $FFB7 + .alias JSETFLS $FFBA + .alias JSETNAM $FFBD + .alias JOPEN $FFC0 + .alias JCLOSE $FFC3 + .alias JCHKIN $FFC6 + .alias JCHKOUT $FFC9 + .alias JCLRCHN $FFCC + .alias JCHRIN $FFCF + .alias JCHROUT $FFD2 + .alias JLOAD $FFD5 + .alias JSAVE $FFD8 + .alias JSETTIM $FFDB + .alias JRDTIM $FFDE + .alias JSTOP $FFE1 + .alias JGETIN $FFE4 + .alias JCLALL $FFE7 + .alias JUDTIM $FFEA + .alias JSCREEN $FFED + .alias JPLOT $FFF0 + .alias JIOBASE $FFF3 diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index bbee542e..d3b76eab 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -143,135 +143,6 @@ .alias RSSTAT $0297 ; RS-232 status .alias pal_or_ntsc $02A6 - ;; Registers for SYS call - .alias sys_reg_a $30c - .alias sys_reg_x $30d - .alias sys_reg_y $30e - .alias sys_reg_p $30f - .alias sys_jmp $310 - - ;; Kernal vectors - interrupts - .alias CINV $0314 - .alias CBINV $0316 - .alias NMINV $0318 - - ;; Kernal vectors - routines - .alias IOPEN $031A - .alias ICLOSE $031C - .alias ICHKIN $031E - .alias ICKOUT $0320 - .alias ICLRCH $0322 - .alias IBASIN $0324 - .alias IBASOUT $0326 - .alias ISTOP $0328 - .alias IGETIN $032A - .alias ICLALL $032C - .alias USRCMD $032E - .alias ILOAD $0330 - .alias ISAVE $0331 - - ;; Kernal jump table - .alias JCINT $FF81 - .alias JIOINIT $FF84 - .alias JRAMTAS $FF87 - .alias JRESTOR $FF8A - .alias JVECTOR $FF8D - .alias JSETMSG $FF90 - .alias JSECOND $FF93 - .alias JTKSA $FF96 - .alias JMEMTOP $FF99 - .alias JMEMBOT $FF9C - .alias JSCNKEY $FF9F - .alias JSETTMO $FFA2 - .alias JACPTR $FFA5 - .alias JCIOUT $FFA8 - .alias JUNTLK $FFAB - .alias JUNLSN $FFAE - .alias JLISTEN $FFB1 - .alias JTALK $FFB4 - .alias JREADST $FFB7 - .alias JSETFLS $FFBA - .alias JSETNAM $FFBD - .alias JOPEN $FFC0 - .alias JCLOSE $FFC3 - .alias JCHKIN $FFC6 - .alias JCHKOUT $FFC9 - .alias JCLRCHN $FFCC - .alias JCHRIN $FFCF - .alias JCHROUT $FFD2 - .alias JLOAD $FFD5 - .alias JSAVE $FFD8 - .alias JSETTIM $FFDB - .alias JRDTIM $FFDE - .alias JSTOP $FFE1 - .alias JGETIN $FFE4 - .alias JCLALL $FFE7 - .alias JUDTIM $FFEA - .alias JSCREEN $FFED - .alias JPLOT $FFF0 - .alias JIOBASE $FFF3 - - ;; Kernal error codes - returned in the A register - ;; Described in 'Commodore 64 Programmer's Reference Guide', page 306 - .alias K_ERR_ROUTINE_TERMINATED $00 - .alias K_ERR_TOO_MANY_OPEN_FILES $01 - .alias K_ERR_FILE_ALREADY_OPEN $02 - .alias K_ERR_FILE_NOT_OPEN $03 - .alias K_ERR_FILE_NOT_FOUND $04 - .alias K_ERR_DEVICE_NOT_FOUND $05 - .alias K_ERR_FILE_NOT_INPUT $06 - .alias K_ERR_FILE_NOT_OUTPUT $07 - .alias K_ERR_FILE_NAME_MISSING $08 - .alias K_ERR_ILLEGAL_DEVICE_NUMBER $09 - .alias K_ERR_TOP_MEM_RS232 $F0 - - ;; Kernal status codes for READST routine (IOSTATUS) - ;; Described in 'Commodore 64 Programmer's Reference Guide', page 292 - ;; For IEC devices - .alias K_STS_TIMEOUT_WRITE $01 - .alias K_STS_TIMEOUT_READ $02 - .alias K_STS_EOI $40 - .alias K_STS_DEVICE_NOT_FOUND $80 - ;; For tape deck - .alias K_STS_SHORT_BLOCK $04 - .alias K_STS_LONG_BLOCK $08 - .alias K_STS_READ_ERROR $10 - .alias K_STS_CHECKSUM_ERROR $20 - .alias K_STS_END_OF_FILE $40 - .alias K_STS_END_OF_TAPE $80 - - ;; BASIC error codes, taken from http://sta.c64.org/cbm64baserr.html - .alias B_ERR_TOO_MANY_FILES $01 - .alias B_ERR_FILE_OPEN $02 - .alias B_ERR_FILE_NOT_OPEN $03 - .alias B_ERR_FILE_NOT_FOUND $04 - .alias B_ERR_DEVICE_NOT_PRESENT $05 - .alias B_ERR_NOT_INPUT_FILE $06 - .alias B_ERR_NOT_OUTPUT_FILE $07 - .alias B_ERR_MISSING_FILENAME $08 - .alias B_ERR_ILLEGAL_DEVICE_NUMBER $09 - .alias B_ERR_NEXT_WITHOUT_FOR $0A - .alias B_ERR_SYNTAX $0B - .alias B_ERR_RETURN_WITHOUT_GOSUB $0C - .alias B_ERR_OUT_OF_DATA $0D - .alias B_ERR_ILLEGAL_QUANTITY $0E - .alias B_ERR_OVERFLOW $0F - .alias B_ERR_OUT_OF_MEMORY $10 - .alias B_ERR_UNDEFD_STATEMENT $11 - .alias B_ERR_BAD_SUBSCRIPT $12 - .alias B_ERR_REDIMD_ARRAY $13 - .alias B_ERR_DIVISION_BY_ZERO $14 - .alias B_ERR_ILLEGAL_DIRECT $15 - .alias B_ERR_TYPE_MISMATCH $16 - .alias B_ERR_STRING_TOO_LONG $17 - .alias B_ERR_FILE_DATA $18 - .alias B_ERR_FORMULA_TOO_COMPLEX $19 - .alias B_ERR_CANT_CONTINUE $1A - .alias B_ERR_UNDEFD_FUNCTION $1B - .alias B_ERR_VERIFY $1C - .alias B_ERR_LOAD $1D - .alias B_ERR_BREAK $1E - ;; BASIC uses some extra bytes for memory access under ROMs located at $2A7 onwards ;; IRQs are disabled when doing such accesses, and a default NMI handler only increments ;; a counter, so that if an NMI occurs, it doesn't crash the machine, but can be captured. @@ -283,4 +154,3 @@ .alias poke_under_roms tiny_nmi_handler+poke_under_roms_routine-tiny_nmi_handler_routine .alias memmap_allram tiny_nmi_handler+memmap_allram_routine-tiny_nmi_handler_routine .alias memmap_normal tiny_nmi_handler+memmap_normal_routine-tiny_nmi_handler_routine - diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index b76ce732..0c30eca1 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -90,128 +90,6 @@ .alias RSSTAT $0297 ; RS-232 status .alias pal_or_ntsc $02A6 - ;; Kernal vectors - interrupts - .alias CINV $0314 - .alias CBINV $0316 - .alias NMINV $0318 - - ;; Kernal vectors - routines - .alias IOPEN $031A - .alias ICLOSE $031C - .alias ICHKIN $031E - .alias ICKOUT $0320 - .alias ICLRCH $0322 - .alias IBASIN $0324 - .alias IBASOUT $0326 - .alias ISTOP $0328 - .alias IGETIN $032A - .alias ICLALL $032C - .alias USRCMD $032E - .alias ILOAD $0330 - .alias ISAVE $0331 - - ;; Kernal jump table - .alias JCINT $FF81 - .alias JIOINIT $FF84 - .alias JRAMTAS $FF87 - .alias JRESTOR $FF8A - .alias JVECTOR $FF8D - .alias JSETMSG $FF90 - .alias JSECOND $FF93 - .alias JTKSA $FF96 - .alias JMEMTOP $FF99 - .alias JMEMBOT $FF9C - .alias JSCNKEY $FF9F - .alias JSETTMO $FFA2 - .alias JACPTR $FFA5 - .alias JCIOUT $FFA8 - .alias JUNTLK $FFAB - .alias JUNLSN $FFAE - .alias JLISTEN $FFB1 - .alias JTALK $FFB4 - .alias JREADST $FFB7 - .alias JSETFLS $FFBA - .alias JSETNAM $FFBD - .alias JOPEN $FFC0 - .alias JCLOSE $FFC3 - .alias JCHKIN $FFC6 - .alias JCHKOUT $FFC9 - .alias JCLRCHN $FFCC - .alias JCHRIN $FFCF - .alias JCHROUT $FFD2 - .alias JLOAD $FFD5 - .alias JSAVE $FFD8 - .alias JSETTIM $FFDB - .alias JRDTIM $FFDE - .alias JSTOP $FFE1 - .alias JGETIN $FFE4 - .alias JCLALL $FFE7 - .alias JUDTIM $FFEA - .alias JSCREEN $FFED - .alias JPLOT $FFF0 - .alias JIOBASE $FFF3 - - ;; Kernal error codes - returned in the A register - ;; Described in 'Commodore 64 Programmer's Reference Guide', page 306 - .alias K_ERR_ROUTINE_TERMINATED $00 - .alias K_ERR_TOO_MANY_OPEN_FILES $01 - .alias K_ERR_FILE_ALREADY_OPEN $02 - .alias K_ERR_FILE_NOT_OPEN $03 - .alias K_ERR_FILE_NOT_FOUND $04 - .alias K_ERR_DEVICE_NOT_FOUND $05 - .alias K_ERR_FILE_NOT_INPUT $06 - .alias K_ERR_FILE_NOT_OUTPUT $07 - .alias K_ERR_FILE_NAME_MISSING $08 - .alias K_ERR_ILLEGAL_DEVICE_NUMBER $09 - .alias K_ERR_TOP_MEM_RS232 $F0 - - ;; Kernal status codes for READST routine (IOSTATUS) - ;; Described in 'Commodore 64 Programmer's Reference Guide', page 292 - ;; For IEC devices - .alias K_STS_TIMEOUT_WRITE $01 - .alias K_STS_TIMEOUT_READ $02 - .alias K_STS_EOI $40 - .alias K_STS_DEVICE_NOT_FOUND $80 - ;; For tape deck - .alias K_STS_SHORT_BLOCK $04 - .alias K_STS_LONG_BLOCK $08 - .alias K_STS_READ_ERROR $10 - .alias K_STS_CHECKSUM_ERROR $20 - .alias K_STS_END_OF_FILE $40 - .alias K_STS_END_OF_TAPE $80 - - ;; BASIC error codes, taken from http://sta.c64.org/cbm64baserr.html - .alias B_ERR_TOO_MANY_FILES $01 - .alias B_ERR_FILE_OPEN $02 - .alias B_ERR_FILE_NOT_OPEN $03 - .alias B_ERR_FILE_NOT_FOUND $04 - .alias B_ERR_DEVICE_NOT_PRESENT $05 - .alias B_ERR_NOT_INPUT_FILE $06 - .alias B_ERR_NOT_OUTPUT_FILE $07 - .alias B_ERR_MISSING_FILENAME $08 - .alias B_ERR_ILLEGAL_DEVICE_NUMBER $09 - .alias B_ERR_NEXT_WITHOUT_FOR $0A - .alias B_ERR_SYNTAX $0B - .alias B_ERR_RETURN_WITHOUT_GOSUB $0C - .alias B_ERR_OUT_OF_DATA $0D - .alias B_ERR_ILLEGAL_QUANTITY $0E - .alias B_ERR_OVERFLOW $0F - .alias B_ERR_OUT_OF_MEMORY $10 - .alias B_ERR_UNDEFD_STATEMENT $11 - .alias B_ERR_BAD_SUBSCRIPT $12 - .alias B_ERR_REDIMD_ARRAY $13 - .alias B_ERR_DIVISION_BY_ZERO $14 - .alias B_ERR_ILLEGAL_DIRECT $15 - .alias B_ERR_TYPE_MISMATCH $16 - .alias B_ERR_STRING_TOO_LONG $17 - .alias B_ERR_FILE_DATA $18 - .alias B_ERR_FORMULA_TOO_COMPLEX $19 - .alias B_ERR_CANT_CONTINUE $1A - .alias B_ERR_UNDEFD_FUNCTION $1B - .alias B_ERR_VERIFY $1C - .alias B_ERR_LOAD $1D - .alias B_ERR_BREAK $1E - ;; Under-ROM routines ;; (BASIC also includes them. XXX - We should de-duplicate them in a safe manner) .alias missed_nmi_flag $2A7 @@ -221,12 +99,3 @@ .alias memmap_allram tiny_nmi_handler+memmap_allram_routine-tiny_nmi_handler_routine .alias memmap_normal tiny_nmi_handler+memmap_normal_routine-tiny_nmi_handler_routine - ;; CIA#2 - https://www.c64-wiki.com/wiki/CIA#CIA_2 - - .alias CI2PRA $DD00 ; VIC bank switching and IEC port - - .alias BIT_CI2PRA_ATN_OUT $08 ; 1 - low (pulled), 0 - high (released) - .alias BIT_CI2PRA_CLK_OUT $10 ; 1 - low (pulled), 0 - high (released) - .alias BIT_CI2PRA_DAT_OUT $20 ; 1 - low (pulled), 0 - high (released) - .alias BIT_CI2PRA_CLK_IN $40 ; 0 - low (pulled), 1 - high (released) - .alias BIT_CI2PRA_DAT_IN $80 ; 0 - low (pulled), 1 - high (released) diff --git a/c64/kernal/iec_pull_atn_clk_release_data.s b/c64/kernal/iec_pull_atn_clk_release_data.s index 7e11d311..7d00da80 100644 --- a/c64/kernal/iec_pull_atn_clk_release_data.s +++ b/c64/kernal/iec_pull_atn_clk_release_data.s @@ -5,11 +5,11 @@ iec_pull_atn_clk_release_data: ;; hardware give some lines few more cycles to stabilize; see page 10 of ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf - lda CI2PRA - ora #BIT_CI2PRA_ATN_OUT ; pull - sta CI2PRA - ora #BIT_CI2PRA_CLK_OUT ; pull - sta CI2PRA - and #$FF - BIT_CI2PRA_DAT_OUT ; release - sta CI2PRA + lda CIA2_PRA + ora #BIT_CIA2_PRA_ATN_OUT ; pull + sta CIA2_PRA + ora #BIT_CIA2_PRA_CLK_OUT ; pull + sta CIA2_PRA + and #$FF - BIT_CIA2_PRA_DAT_OUT ; release + sta CIA2_PRA rts diff --git a/c64/kernal/iec_pull_clk_release_data.s b/c64/kernal/iec_pull_clk_release_data.s index 613aa4ef..38be0f89 100644 --- a/c64/kernal/iec_pull_clk_release_data.s +++ b/c64/kernal/iec_pull_clk_release_data.s @@ -5,9 +5,9 @@ iec_pull_clk_release_data: ;; hardware give some lines few more cycles to stabilize; see page 10 of ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf - lda CI2PRA - ora #BIT_CI2PRA_CLK_OUT ; pull - sta CI2PRA - and #$FF - BIT_CI2PRA_DAT_OUT ; release - sta CI2PRA + lda CIA2_PRA + ora #BIT_CIA2_PRA_CLK_OUT ; pull + sta CIA2_PRA + and #$FF - BIT_CIA2_PRA_DAT_OUT ; release + sta CIA2_PRA rts diff --git a/c64/kernal/iec_pull_data_release_atn_clk.s b/c64/kernal/iec_pull_data_release_atn_clk.s index 7b2a18d0..14e0e236 100644 --- a/c64/kernal/iec_pull_data_release_atn_clk.s +++ b/c64/kernal/iec_pull_data_release_atn_clk.s @@ -5,11 +5,11 @@ iec_pull_data_release_atn_clk: ;; hardware give some lines few more cycles to stabilize; see page 10 of ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf - lda CI2PRA - ora #BIT_CI2PRA_DAT_OUT ; pull - sta CI2PRA - and #$FF - BIT_CI2PRA_CLK_OUT ; release - sta CI2PRA - and #$FF - BIT_CI2PRA_ATN_OUT ; release - sta CI2PRA + lda CIA2_PRA + ora #BIT_CIA2_PRA_DAT_OUT ; pull + sta CIA2_PRA + and #$FF - BIT_CIA2_PRA_CLK_OUT ; release + sta CIA2_PRA + and #$FF - BIT_CIA2_PRA_ATN_OUT ; release + sta CIA2_PRA rts diff --git a/c64/kernal/iec_release_atn.s b/c64/kernal/iec_release_atn.s index 194f3856..2aef8984 100644 --- a/c64/kernal/iec_release_atn.s +++ b/c64/kernal/iec_release_atn.s @@ -1,8 +1,8 @@ iec_release_atn: - lda CI2PRA - and #$FF - BIT_CI2PRA_ATN_OUT ; release - sta CI2PRA + lda CIA2_PRA + and #$FF - BIT_CIA2_PRA_ATN_OUT ; release + sta CIA2_PRA rts diff --git a/c64/kernal/iec_release_atn_clk_data.s b/c64/kernal/iec_release_atn_clk_data.s index 3fccfbcb..904ee13f 100644 --- a/c64/kernal/iec_release_atn_clk_data.s +++ b/c64/kernal/iec_release_atn_clk_data.s @@ -5,12 +5,12 @@ iec_release_atn_clk_data: ;; hardware give some lines few more cycles to stabilize; see page 10 of ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf - lda CI2PRA - and #$FF - BIT_CI2PRA_ATN_OUT ; release - sta CI2PRA - and #$FF - BIT_CI2PRA_DAT_OUT ; release - sta CI2PRA - and #$FF - BIT_CI2PRA_CLK_OUT ; release - sta CI2PRA + lda CIA2_PRA + and #$FF - BIT_CIA2_PRA_ATN_OUT ; release + sta CIA2_PRA + and #$FF - BIT_CIA2_PRA_DAT_OUT ; release + sta CIA2_PRA + and #$FF - BIT_CIA2_PRA_CLK_OUT ; release + sta CIA2_PRA rts diff --git a/c64/kernal/iec_release_clk_data.s b/c64/kernal/iec_release_clk_data.s index e74ff7e4..f48daa6c 100644 --- a/c64/kernal/iec_release_clk_data.s +++ b/c64/kernal/iec_release_clk_data.s @@ -5,9 +5,9 @@ iec_release_clk_data: ;; hardware give some lines few more cycles to stabilize; see page 10 of ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf - lda CI2PRA - and #$FF - BIT_CI2PRA_DAT_OUT ; release - sta CI2PRA - and #$FF - BIT_CI2PRA_CLK_OUT ; release - sta CI2PRA + lda CIA2_PRA + and #$FF - BIT_CIA2_PRA_DAT_OUT ; release + sta CIA2_PRA + and #$FF - BIT_CIA2_PRA_CLK_OUT ; release + sta CIA2_PRA rts diff --git a/c64/kernal/iec_release_clk_pull_data.s b/c64/kernal/iec_release_clk_pull_data.s index 1c167a04..9f252ed3 100644 --- a/c64/kernal/iec_release_clk_pull_data.s +++ b/c64/kernal/iec_release_clk_pull_data.s @@ -5,9 +5,9 @@ iec_release_clk_pull_data: ;; hardware give some lines few more cycles to stabilize; see page 10 of ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf - lda CI2PRA - ora #BIT_CI2PRA_DAT_OUT ; pull - sta CI2PRA - and #$FF - BIT_CI2PRA_CLK_OUT ; release - sta CI2PRA + lda CIA2_PRA + ora #BIT_CIA2_PRA_DAT_OUT ; pull + sta CIA2_PRA + and #$FF - BIT_CIA2_PRA_CLK_OUT ; release + sta CIA2_PRA rts diff --git a/c64/kernal/iec_rx_byte.s b/c64/kernal/iec_rx_byte.s index 4a7eb996..9819636c 100644 --- a/c64/kernal/iec_rx_byte.s +++ b/c64/kernal/iec_rx_byte.s @@ -24,8 +24,8 @@ iec_rx_byte: ldx #$11 ; 2 cycles iec_rx_clk_wait1: - lda CI2PRA ; 4 cycles - rol ; 2 cycles, to put BIT_CI2PRA_CLK_IN as the last bit + lda CIA2_PRA ; 4 cycles + rol ; 2 cycles, to put CLK in as the last bit bpl iec_rx_not_eoi ; 2 cycles if not jumped dex ; 2 cycles bne iec_rx_clk_wait1 ; 3 cycles if jumped @@ -77,7 +77,7 @@ iec_rx_bit_loop: ;; Move data bit into C flag, and loop until bit 6 clears ;; i.e., the clock has been released. -* lda CI2PRA +* lda CIA2_PRA rol bpl - @@ -90,8 +90,8 @@ iec_rx_bit_loop: ;; consider this a timeout ldy #$19 ; 2 cycles iec_rx_clk_wait2: - lda CI2PRA ; 4 cycles - rol ; 2 cycles, to put BIT_CI2PRA_CLK_IN as the last bit + lda CIA2_PRA ; 4 cycles + rol ; 2 cycles, to put CLK in as the last bit bpl + ; 2 cycles if not jumped dey ; 2 cycles bne iec_rx_clk_wait2 ; 3 cycles if jumped diff --git a/c64/kernal/iec_set_idle.s b/c64/kernal/iec_set_idle.s index dd936926..1604306d 100644 --- a/c64/kernal/iec_set_idle.s +++ b/c64/kernal/iec_set_idle.s @@ -1,7 +1,7 @@ iec_set_idle: - lda CI2PRA - ora #BIT_CI2PRA_CLK_OUT ; pull - and #$FF - BIT_CI2PRA_DAT_OUT - BIT_CI2PRA_ATN_OUT ; release - sta CI2PRA + lda CIA2_PRA + ora #BIT_CIA2_PRA_CLK_OUT ; pull + and #$FF - BIT_CIA2_PRA_DAT_OUT - BIT_CIA2_PRA_ATN_OUT ; release + sta CIA2_PRA rts diff --git a/c64/kernal/iec_turnaround_to_listen.s b/c64/kernal/iec_turnaround_to_listen.s index b1d0f576..1033b720 100644 --- a/c64/kernal/iec_turnaround_to_listen.s +++ b/c64/kernal/iec_turnaround_to_listen.s @@ -14,8 +14,8 @@ iec_turnaround_to_listen: ;; Wait for clock line to be pulled by the drive ldx #$FF ; XXX should we really use that high number? * - lda CI2PRA - rol ; to put BIT_CI2PRA_CLK_IN as the last (sign) bit + lda CIA2_PRA + rol ; to put BIT_CIA2_PRA_CLK_IN as the last (sign) bit bpl + dex bne - diff --git a/c64/kernal/iec_tx_byte.s b/c64/kernal/iec_tx_byte.s index 946c248d..b827d8c2 100644 --- a/c64/kernal/iec_tx_byte.s +++ b/c64/kernal/iec_tx_byte.s @@ -21,8 +21,8 @@ iec_tx_byte: ;; All done - give device time to tell if they are busy by pulling DATA ;; They should do it within 1ms ldx #$FF -* lda CI2PRA - ;; BPL here is checking that bit 7 of $DD00 clears, +* lda CIA2_PRA + ;; BPL here is checking that bit 7 clears, ;; i.e, that the DATA line is pulled by drive bpl + dex diff --git a/c64/kernal/iec_tx_command.s b/c64/kernal/iec_tx_command.s index 7cde1dce..0e92e2db 100644 --- a/c64/kernal/iec_tx_command.s +++ b/c64/kernal/iec_tx_command.s @@ -14,8 +14,8 @@ iec_tx_command: jsr wait1ms ;; Did at least one device respond by pulling DATA? - lda CI2PRA - and #BIT_CI2PRA_DAT_IN ; XXX try to optimize this, move to separate routine + lda CIA2_PRA + and #BIT_CIA2_PRA_DAT_IN ; XXX try to optimize this, move to separate routine beq + ;; No devices present on the bus, so we can immediately return with device not found @@ -42,8 +42,8 @@ iec_tx_command: ;; flow here, but http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf (page 6) ;; advices to just wait 1ms and check the DATA status jsr wait1ms - lda CI2PRA - and #BIT_CI2PRA_DAT_IN ; XXX try to optimize this, move to separate routine + lda CIA2_PRA + and #BIT_CIA2_PRA_DAT_IN ; XXX try to optimize this, move to separate routine beq + ;; XXX possible optimization of the flow above: for many commands it is enough diff --git a/c64/kernal/iec_wait_for_clk_release.s b/c64/kernal/iec_wait_for_clk_release.s index 6139dd1d..22edfdfa 100644 --- a/c64/kernal/iec_wait_for_clk_release.s +++ b/c64/kernal/iec_wait_for_clk_release.s @@ -1,6 +1,7 @@ iec_wait_for_clk_release: - lda CI2PRA - and #BIT_CI2PRA_CLK_IN + + lda CIA2_PRA + and #BIT_CIA2_PRA_CLK_IN beq iec_wait_for_clk_release rts diff --git a/c64/kernal/iec_wait_for_data_pull.s b/c64/kernal/iec_wait_for_data_pull.s index d83b57d4..93bbabe9 100644 --- a/c64/kernal/iec_wait_for_data_pull.s +++ b/c64/kernal/iec_wait_for_data_pull.s @@ -1,6 +1,7 @@ iec_wait_for_data_pull: - lda CI2PRA + + lda CIA2_PRA ;; Check the highest bit, which is DATA IN, ;; (highest bit set = negative value) bmi iec_wait_for_data_pull diff --git a/c64/kernal/iec_wait_for_data_release.s b/c64/kernal/iec_wait_for_data_release.s index e54df9de..dc89638a 100644 --- a/c64/kernal/iec_wait_for_data_release.s +++ b/c64/kernal/iec_wait_for_data_release.s @@ -1,6 +1,7 @@ iec_wait_for_data_release: - lda CI2PRA + + lda CIA2_PRA ;; Check the highest bit, which is DATA IN, ;; (highest bit set = negative value) bpl iec_wait_for_data_release diff --git a/c64/kernal/ramtas.s b/c64/kernal/ramtas.s index e54f7bd2..81f4dfde 100644 --- a/c64/kernal/ramtas.s +++ b/c64/kernal/ramtas.s @@ -12,12 +12,12 @@ ramtas: ; C64 Programmer's Reference guide p291: ; Clear $0000-$0101, $0200-$03ff ; PGS: $0000, $0001 are CPU IO ports, so shouldn't get written to - LDY #$02 - LDA #$00 + ldy #$02 + lda #$00 ramtas_l1: - STA $00,Y - INY - BNE ramtas_l1 + sta $00,Y + iny + bne ramtas_l1 ramtas_l2: ;; How many ways are there to efficiently erase these two pages ;; of RAM? We would like to avoid any unnecessary byte similarity @@ -25,41 +25,41 @@ ramtas_l2: ;; with the longer sequence of identicale bytes we see no basis for ;; it being copyrightable. Again, we just want to redue the attack ;; surface for any misguided suit. - STA $0300,Y - STA $0200,Y - INY - BNE ramtas_l2 + sta $0300,Y + sta $0200,Y + iny + bne ramtas_l2 ; allocate cassette buffer ;; "Mapping the C128", p61 lda #<$033C - STA cassette_buffer_ptr+0 + sta cassette_buffer_ptr+0 lda #>$033C - STA cassette_buffer_ptr+1 + sta cassette_buffer_ptr+1 ; set screen address to $0400 ; https://www.c64-wiki.com/wiki/Screen_RAM ; Since we are setting $D018, we also make sure we are using the ; ROM character set (C64 Programmer's Reference Guide p322) - LDA #$14 - STA $D018 + lda #$14 + sta VIC_YMCSB ; Make sure we have the correct VIC-II memory bank for the screen to really be at $0400 ; and not $4400, $8400 or $C400 ; https://www.c64-wiki.com/wiki/VIC_bank#Selecting_VIC_banks - LDA $DD02 - ORA #$03 - STA $DD02 - LDA $DD00 - ORA #$03 - STA $DD00 + lda CIA2_DDRA + ora #$03 + sta CIA2_DDRA + lda CIA2_PRA + ora #$03 + sta CIA2_PRA ;; Set screen address pointer ("Compute's Mapping the 64" p238) ;; This is obvious boiler plate containing no creative input, but to avoid ;; unnecessarily similarity to the C64 KERNAL, we use X instead of A to do this, ;; and several following - LDX #>$0400 - STX HIBASE + ldx #>$0400 + stx HIBASE ;; Work out RAM size and put in MEMSTR and MEMSIZ ;; "Compute's Mapping the 64", p54 From 66047996bb90dfc26b2e80dcaf1d3f6b0132712e Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 19 Jul 2019 06:05:08 +0200 Subject: [PATCH 53/90] simplified the makefile, fixed some glitches --- Makefile | 213 ++++++++++++++++++++----------------------------------- 1 file changed, 76 insertions(+), 137 deletions(-) diff --git a/Makefile b/Makefile index b7b0637e..364bb3e6 100644 --- a/Makefile +++ b/Makefile @@ -5,184 +5,123 @@ SRC_COMMON = $(wildcard c64/aliases/*.s) SRC_BASIC_COMMON = $(SRC_COMMON) $(wildcard c64/basic/*.s) SRC_KERNAL_COMMON = $(SRC_COMMON) $(wildcard c64/kernal/*.s) -SRC_BASIC_GENERIC = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,platform_generic/*.s) -SRC_BASIC_MEGA65 = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,platform_mega65/*.s) -SRC_BASIC_ULTIMATE64 = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,platform_ultimate64/*.s) +SRC_BASIC_generic = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,platform_generic/*.s) +SRC_BASIC_mega65 = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,platform_mega65/*.s) +SRC_BASIC_ultimate64 = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,platform_ultimate64/*.s) -SRC_KERNAL_GENERIC = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_generic/*.s) -SRC_KERNAL_MEGA65 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_mega65/*.s) -SRC_KERNAL_ULTIMATE64 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_ultimate64/*.s) +SRC_KERNAL_generic = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_generic/*.s) +SRC_KERNAL_mega65 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_mega65/*.s) +SRC_KERNAL_ultimate64 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_ultimate64/*.s) # List of tools -TOOLS_LIST = build/collect_data build/compress_text build/preprocess build/similarity +TOOL_COLLECT_DATA = build/tools/collect_data +TOOL_COMPRESS_TEXT = build/tools/compress_text +TOOL_PNGPREPARE = build/tools/pngprepare +TOOL_PREPROCESS = build/tools/preprocess +TOOL_SIMILARITY = build/tools/similarity -# Rules - maintainance +TOOLS_LIST = $(TOOL_COLLECT_DATA) $(TOOL_COMPRESS_TEXT) $(TOOL_PNGPREPARE) $(TOOL_PREPROCESS) $(TOOL_SIMILARITY) + +# Rules - main + +.PHONY: all clean all: build/chargen build/newkern_generic build/newbasic_generic build/newc65 build/newkern_ultimate64 build/newbasic_ultimate64 +Ophis: + git submodule init + git submodule update + clean: @rm -rf build @rm -f temp.s @rm -f temp.map @rm -f ophis.bin -Ophis: - git submodule init - git submodule update - # Rules - tools -build/pngprepare: src/pngprepare.c Makefile - @mkdir -p build - $(CC) $(COPT) -I/usr/local/include -L/usr/local/lib -o build/pngprepare src/pngprepare.c -lpng +$(TOOL_COLLECT_DATA): src/collect_data.c Makefile + @mkdir -p build/tools + gcc -Wall -o $(TOOL_COLLECT_DATA) src/collect_data.c -build/collect_data: src/collect_data.c Makefile - @mkdir -p build - gcc -Wall -o build/collect_data src/collect_data.c +$(TOOL_COMPRESS_TEXT): src/compress_text.c Makefile + @mkdir -p build/tools + gcc -g -Wall -o $(TOOL_COMPRESS_TEXT) src/compress_text.c -lm -build/preprocess: src/preprocess.c Makefile - @mkdir -p build - gcc -g -Wall -o build/preprocess src/preprocess.c +$(TOOL_PNGPREPARE): src/pngprepare.c Makefile + @mkdir -p build/tools + $(CC) $(COPT) -I/usr/local/include -L/usr/local/lib -o $(TOOL_PNGPREPARE) src/pngprepare.c -lpng -build/similarity: src/similarity.c Makefile - @mkdir -p build - gcc -g -Wall -o build/similarity src/similarity.c +$(TOOL_PREPROCESS): src/preprocess.c Makefile + @mkdir -p build/tools + gcc -g -Wall -o $(TOOL_PREPROCESS) src/preprocess.c -build/compress_text: src/compress_text.c Makefile - @mkdir -p build - gcc -g -Wall -o build/compress_text src/compress_text.c -lm +$(TOOL_SIMILARITY): src/similarity.c Makefile + @mkdir -p build/tools + gcc -g -Wall -o $(TOOL_SIMILARITY) src/similarity.c -# Rules - chargen +# Rules - CHARGEN -build/chargen: build/pngprepare assets/8x8font.png - build/pngprepare charrom assets/8x8font.png build/chargen +build/chargen: $(TOOL_PNGPREPARE) assets/8x8font.png + $(TOOL_PNGPREPARE) charrom assets/8x8font.png build/chargen -# Rules - platform 'generic' +# Rules - BASIC and KERNAL -build/basic_generic/OUT.BIN: $(TOOLS_LIST) $(SRC_BASIC_GENERIC) build/basic/packed_messages.s - @echo - @echo ### Building BASIC for generic systems - @echo - @mkdir -p build/basic_generic - @rm -f build/basic_generic/* - @for SRC in $(SRC_BASIC_GENERIC); do \ - ln -s ../../$$SRC build/basic_generic/$$(basename $$SRC); \ +build/basic/packed_messages.s: $(TOOL_COMPRESS_TEXT) + @mkdir -p build/basic + $(TOOL_COMPRESS_TEXT) > build/basic/packed_messages.s + +.PRECIOUS: build/basic_%/OUT.BIN +build/basic_%/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_%) build/basic/packed_messages.s + @mkdir -p build/basic_$* + @rm -f build/basic_$*/* + @for SRC in $(SRC_BASIC_$*); do \ + ln -s ../../$$SRC build/basic_$*/$$(basename $$SRC); \ done - @ln -s ../../build/basic/packed_messages.s build/basic_generic/packed_messages.s - build/preprocess -d build/basic_generic -l a000 -h e4d2 + @ln -s ../../build/basic/packed_messages.s build/basic_$*/packed_messages.s + $(TOOL_PREPROCESS) -d build/basic_$* -l a000 -h e4d2 -build/kernal_generic/OUT.BIN: $(TOOLS_LIST) $(SRC_KERNAL_GENERIC) - @echo - @echo ### Building KERNAL for generic systems - @echo - @mkdir -p build/kernal_generic - @rm -f build/kernal_generic/* - @for SRC in $(SRC_KERNAL_GENERIC); do \ - ln -s ../../$$SRC build/kernal_generic/$$(basename $$SRC); \ +.PRECIOUS: build/kernal_%/OUT.BIN +build/kernal_%/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_KERNAL_%) + @mkdir -p build/kernal_$* + @rm -f build/kernal_$*/* + @for SRC in $(SRC_KERNAL_$*); do \ + ln -s ../../$$SRC build/kernal_$*/$$(basename $$SRC); \ done - build/preprocess -d build/kernal_generic -l e4d3 -h ffff + $(TOOL_PREPROCESS) -d build/kernal_$* -l e4d3 -h ffff -build/newrom_generic: build/basic_generic/OUT.BIN build/kernal_generic/OUT.BIN - cat build/basic_generic/OUT.BIN build/kernal_generic/OUT.BIN > build/newrom_generic +.PRECIOUS: build/newrom_% +build/newrom_%: build/basic_%/OUT.BIN build/kernal_%/OUT.BIN + cat build/basic_$*/OUT.BIN build/kernal_$*/OUT.BIN > build/newrom_$* -build/newkern_generic: build/newrom_generic Makefile - dd if=build/newrom_generic bs=8192 count=1 skip=2 of=build/newkern_generic +.PRECIOUS: build/newkern_% +build/newkern_%: build/newrom_% Makefile + dd if=build/newrom_$* bs=8192 count=1 skip=2 of=build/newkern_$* -build/newbasic_generic: build/newrom_generic Makefile - dd if=build/newrom_generic bs=8192 count=1 skip=0 of=build/newbasic_generic +.PRECIOUS: build/newbasic_% +build/newbasic_%: build/newrom_% Makefile + dd if=build/newrom_$* bs=8192 count=1 skip=0 of=build/newbasic_$* -# Rules - platform 'Mega 65' - -build/basic_mega65/OUT.BIN: $(TOOLS_LIST) $(SRC_BASIC_MEGA65) build/basic/packed_messages.s - @echo - @echo ### Building BASIC for Mega65 - @echo - @mkdir -p build/basic_mega65 - @rm -f build/basic_mega65/* - @for SRC in $(SRC_BASIC_MEGA65); do \ - ln -s ../../$$SRC build/basic_mega65/$$(basename $$SRC); \ - done - @ln -s ../../build/basic/packed_messages.s build/basic_mega65/packed_messages.s - build/preprocess -d build/basic_mega65 -l a000 -h e4d2 - -build/kernal_mega65/OUT.BIN: $(TOOLS_LIST) $(SRC_KERNAL_MEGA65) - @echo - @echo ### Building KERNAL for Mega65 - @echo - @mkdir -p build/kernal_mega65 - @rm -f build/kernal_mega65/* - @for SRC in $(SRC_KERNAL_MEGA65); do \ - ln -s ../../$$SRC build/kernal_mega65/$$(basename $$SRC); \ - done - build/preprocess -d build/kernal_mega65 -l e4d3 -h ffff - -build/newrom_mega65: build/basic_mega65/OUT.BIN build/kernal_mega65/OUT.BIN - cat build/basic_mega65/OUT.BIN build/kernal_mega65/OUT.BIN > build/newrom_mega65 - -build/newkern_mega65: build/newrom_mega65 Makefile - dd if=build/newrom_mega65 bs=8192 count=1 skip=2 of=build/newkern_mega65 - -build/newbasic_mega65: build/newrom_mega65 Makefile - dd if=build/newrom_mega65 bs=8192 count=1 skip=0 of=build/newbasic_mega65 +# Rules - platform 'Mega 65' specific build/newc65: build/newkern_mega65 build/newbasic_mega65 build/chargen Makefile dd if=/dev/zero bs=4096 count=10 of=build/newc65 - cat build/newbasic_mega65 build/chargen build/chargen build/newkern_mega65 >>build/newc65 - dd if=/dev/zero bs=65536 count=1 of=build/padding - cat build/padding >>build/newc65 - -# Rules - platform 'Ultimate 64' - -build/basic_ultimate64/OUT.BIN: $(TOOLS_LIST) $(SRC_BASIC_ULTIMATE64) build/basic/packed_messages.s - @echo - @echo ### Building BASIC for Ultimate 64 - @echo - @mkdir -p build/basic_ultimate64 - @rm -f build/basic_ultimate64/* - @for SRC in $(SRC_BASIC_ULTIMATE64); do \ - ln -s ../../$$SRC build/basic_ultimate64/$$(basename $$SRC); \ - done - @ln -s ../../build/basic/packed_messages.s build/basic_ultimate64/packed_messages.s - build/preprocess -d build/basic_ultimate64 -l a000 -h e4d2 - -build/kernal_ultimate64/OUT.BIN: $(TOOLS_LIST) $(SRC_KERNAL_ULTIMATE64) - @echo - @echo ### Building KERNAL for Ultimate 64 - @echo - @mkdir -p build/kernal_ultimate64 - @rm -f build/kernal_ultimate64/* - @for SRC in $(SRC_KERNAL_ULTIMATE64); do \ - ln -s ../../$$SRC build/kernal_ultimate64/$$(basename $$SRC); \ - done - build/preprocess -d build/kernal_ultimate64 -l e4d3 -h ffff - -build/newrom_ultimate64: build/basic_ultimate64/OUT.BIN build/kernal_ultimate64/OUT.BIN - cat build/basic_ultimate64/OUT.BIN build/kernal_ultimate64/OUT.BIN > build/newrom_ultimate64 - -build/newkern_ultimate64: build/newrom_ultimate64 Makefile - dd if=build/newrom_ultimate64 bs=8192 count=1 skip=2 of=build/newkern_ultimate64 - -build/newbasic_ultimate64: build/newrom_ultimate64 Makefile - dd if=build/newrom_ultimate64 bs=8192 count=1 skip=0 of=build/newbasic_ultimate64 - -# Rules - misc - -build/basic/packed_messages.s: Makefile build/compress_text - @mkdir -p build/basic - build/compress_text > build/basic/packed_messages.s + cat build/newbasic_mega65 build/chargen build/chargen build/newkern_mega65 >> build/newc65 + dd if=/dev/zero bs=65536 count=1 of=build/basic/padding + cat build/basic/padding >> build/newc65 # Rules - tests -testremote: build/newkern_generic build/newbasic_generic - x64 -kernal build/newkern-generic -basic build/newbasic-generic -remotemonitor - test: build/newkern_generic build/newbasic_generic x64 -kernal build/newkern_generic -basic build/newbasic_generic -8 empty.d64 +testremote: build/newkern_generic build/newbasic_generic + x64 -kernal build/newkern-generic -basic build/newbasic-generic -remotemonitor + testm65: build/newc65 m65 -b ../mega65-core/bin/mega65r1.bit -k ../mega65-core/bin/KICKUP.M65 -R build/newc65 -4 testsimilarity: build/newrom_generic src/similarity - build/similarity kernal build/newrom_generic - build/similarity basic build/newrom_generic + $(TOOL_SIMILARITY) kernal build/newrom_generic + $(TOOL_SIMILARITY) basic build/newrom_generic From da4cc3a89bc727dc780c05bd6875854b7d840b93 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 19 Jul 2019 17:23:11 +0200 Subject: [PATCH 54/90] refactored LOAD routine so that it's parts are reuseable --- c64/aliases/,aliases_ram_lowmem.s | 105 +++++++++++++++---- c64/basic/,aliases.s | 32 +----- c64/basic/basic_execute_line.s | 2 +- c64/basic/cmd_list.s | 2 +- c64/basic/cmd_load.s | 4 +- c64/basic/cmd_sys.s | 18 ++-- c64/kernal/,aliases.s | 28 ----- c64/kernal/load.s | 169 +++++++----------------------- c64/kernal/lvs_helpers.s | 128 ++++++++++++++++++++++ c64/kernal/scan_keyboard.s | 2 +- c64/kernal/setnam.s | 6 +- c64/kernal/stop.s | 4 +- 12 files changed, 269 insertions(+), 231 deletions(-) create mode 100644 c64/kernal/lvs_helpers.s diff --git a/c64/aliases/,aliases_ram_lowmem.s b/c64/aliases/,aliases_ram_lowmem.s index a024d66f..60c67bb4 100644 --- a/c64/aliases/,aliases_ram_lowmem.s +++ b/c64/aliases/,aliases_ram_lowmem.s @@ -1,33 +1,92 @@ ;; -;; Names of ZP and low memory locations (only the implemented ones) +;; Names of ZP and low memory locations ;; (https://www.c64-wiki.com/wiki/Zeropage) ;; - ;; $000-$001 - 6502 CPU registers + ;; $00-$01 - 6502 CPU registers are here + ;; + ;; Page 0 - BASIC area ($02-$8F) + ;; + + .alias TXTTAB $2B + + ;; + ;; Page 0 - Kernal area ($90-$FF) + ;; + + .alias IOSTATUS $90 + .alias STKEY $91 ; Keys down clears bits. STOP - bit 7, C= - bit 6, SPACE - bit 4, CTRL - bit 2 + + .alias VERCK $93 ; 0 = LOAD, 1 = VERIVY + + .alias C3PO $94 ; flag - is BSOUR content valid + .alias BSOUR $95 ; serial bus buffered output byte + + .alias LDTND $98 ; number of entries in LAT / FAT / SAT tables + .alias DFLTN $99 + .alias DFLTO $9A + + .alias MSGFLG $9D ; bit 6 = error messages, bit 7 = control message + + .alias TIME $A0 ; $A0-$A2, jiffy clock + + ;; 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 FNLEN $B7 ; current file name length + + .alias STAL $C1 ; $C1-$C2 LOAD/SAVE start address + + ;; + ;; Other low memory addresses + ;; + + ;; Kernal tables for opened files, 10 entries each + .alias LAT $259 ; logical file numbers + .alias FAT $263 ; device numbers + .alias SAT $26D ; secondary addresses + + .alias MEMSTR $281 + .alias MEMSIZ $283 ; NOTE: Mapping the 64 erroniously has the hex as $282, while the DEC is correct + + .alias HIBASE $288 ; high byte of start of screen + + .alias RSSTAT $297 ; RS-232 status + + .alias PALNTSC $2A6 ; 0 = NTSC, 1 = PAL + + ;; Registers for SYS call - .alias sys_reg_a $30c - .alias sys_reg_x $30d - .alias sys_reg_y $30e - .alias sys_reg_p $30f - .alias sys_jmp $310 + .alias SAREG $30C + .alias SXREG $30D + .alias SYREG $30E + .alias SPREG $30F + .alias USRPOK $310 ; JMP instruction + .alias USRADD $311 ; $311 - $312 + ;; Kernal vectors - interrupts - .alias CINV $0314 - .alias CBINV $0316 - .alias NMINV $0318 + .alias CINV $314 + .alias CBINV $316 + .alias NMINV $318 ;; Kernal vectors - routines - .alias IOPEN $031A - .alias ICLOSE $031C - .alias ICHKIN $031E - .alias ICKOUT $0320 - .alias ICLRCH $0322 - .alias IBASIN $0324 - .alias IBASOUT $0326 - .alias ISTOP $0328 - .alias IGETIN $032A - .alias ICLALL $032C - .alias USRCMD $032E - .alias ILOAD $0330 - .alias ISAVE $0331 + .alias IOPEN $31A + .alias ICLOSE $31C + .alias ICHKIN $31E + .alias ICKOUT $320 + .alias ICLRCH $322 + .alias IBASIN $324 + .alias IBASOUT $326 + .alias ISTOP $328 + .alias IGETIN $32A + .alias ICLALL $32C + .alias USRCMD $32E + .alias ILOAD $330 + .alias ISAVE $331 + + .alias TBUFFR $33C ; $33C-$3FB, tape buffer diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index d3b76eab..6f98fbf4 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -52,33 +52,13 @@ .alias memmove_dst $6b .alias memmove_size $6d - .alias TXTTAB $2B - .alias IOSTATUS $90 - ; Keys down clears bits. STOP=bit 7, C= bit 6, SPACE bit 4, CTRL bit 2 - .alias BUCKYSTATUS $91 - .alias load_or_verify_flag $93 - .alias C3PO $94 ; flag - is BSOUR content valid - .alias BSOUR $95 ; serial bus buffered output byte .alias current_file_num $98 - .alias LDTND $98 ; number of entries in LAT / FAT / SAT tables - .alias DFLTN $99 - .alias input_device_number DFLTN - .alias MSGFLG $9D ; bit 6 = error messages, bit 7 = control message - .alias jiffy_clock_24bits $a0 .alias cassette_buffer_bytes_used $A6 .alias load_or_scroll_temp_pointer $AC ;; We also use the following for temp colour pointer when scrolling .alias load_save_verify_end_address $AE - ;; 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 cassette_buffer_ptr $B2 - .alias current_filename_length $B7 .alias current_logical_filenum $B8 .alias current_secondary_address $B9 .alias current_device_number $BA @@ -112,19 +92,11 @@ .alias rs232_tx_buffer_ptr $F9 .alias basic_input_buffer $0200 - - ;; Kernal tables for opened files, 10 entries each - .alias LAT $0259 ; logical file numbers - .alias FAT $0263 ; device numbers - .alias SAT $026D ; secondary addresses - + ; "Compute's Mapping the 64" book .alias keyboard_buffer $0277 - .alias MEMSTR $0281 - .alias MEMSIZ $0283 ; NOTE: Mapping the 64 erroniously has the hex as $282, while the DEC is correct .alias text_colour $0286 ; p55 .alias colour_under_cursor $0287 ; p56 - .alias HIBASE $0288 ; p56 (high byte of start of screen) .alias key_buffer_size $0289 ; p57 ;; 0 = cursor keys, insert, delete and space repeat, but nothing else @@ -140,8 +112,6 @@ .alias keyboard_decoding_ptr $028F .alias enable_case_switch $0291 .alias screen_scroll_disable $0292 - .alias RSSTAT $0297 ; RS-232 status - .alias pal_or_ntsc $02A6 ;; BASIC uses some extra bytes for memory access under ROMs located at $2A7 onwards ;; IRQs are disabled when doing such accesses, and a default NMI handler only increments diff --git a/c64/basic/basic_execute_line.s b/c64/basic/basic_execute_line.s index 749935cb..5ea0aafb 100644 --- a/c64/basic/basic_execute_line.s +++ b/c64/basic/basic_execute_line.s @@ -29,7 +29,7 @@ no_space_to_skip: basic_execute_statement: ;; Check for RUN/STOP - lda BUCKYSTATUS + lda STKEY bpl basic_do_break ;; Skip over any white space and : diff --git a/c64/basic/cmd_list.s b/c64/basic/cmd_list.s index f93ee033..d58af209 100644 --- a/c64/basic/cmd_list.s +++ b/c64/basic/cmd_list.s @@ -22,7 +22,7 @@ list_loop: jmp basic_main_loop list_more_lines: - lda BUCKYSTATUS + lda STKEY bmi + jmp basic_do_break * diff --git a/c64/basic/cmd_load.s b/c64/basic/cmd_load.s index 5eb5b7f0..22b648eb 100644 --- a/c64/basic/cmd_load.s +++ b/c64/basic/cmd_load.s @@ -26,7 +26,7 @@ cmd_load: ;; Set filename and length lda #$00 - sta current_filename_length + sta FNLEN ;; Without tape support, LOAD must have a filename ;; (This also skips any leading spaces) @@ -57,7 +57,7 @@ getting_filename: jmp got_filename * - inc current_filename_length + inc FNLEN jmp getting_filename got_filename: diff --git a/c64/basic/cmd_sys.s b/c64/basic/cmd_sys.s index 86830bd0..2328a0a4 100644 --- a/c64/basic/cmd_sys.s +++ b/c64/basic/cmd_sys.s @@ -10,22 +10,22 @@ cmd_sys: jsr basic_parse_line_number ;; setup call - lda #$4c ;JMP - sta sys_jmp + lda #$4C ;JMP + sta USRPOK lda basic_line_number+0 - sta sys_jmp+1 + sta USRADD+0 lda basic_line_number+1 - sta sys_jmp+2 + sta USRADD+1 ;; Setup the register values - lda sys_reg_p + lda SPREG pha - ldy sys_reg_y - ldx sys_reg_x - lda sys_reg_a + ldy SYREG + ldx SXREG + lda SAREG plp ;; Call the routine. - jsr sys_jmp + jsr USRPOK jmp basic_execute_statement diff --git a/c64/kernal/,aliases.s b/c64/kernal/,aliases.s index 0c30eca1..b769b149 100644 --- a/c64/kernal/,aliases.s +++ b/c64/kernal/,aliases.s @@ -3,30 +3,18 @@ ; (And only those for now that we feel the need to implement initially) ; (https://www.c64-wiki.com/wiki/Zeropage) - .alias TXTTAB $2B - .alias IOSTATUS $90 - ; Keys down clears bits. STOP=bit 7, C= bit 6, SPACE bit 4, CTRL bit 2 - .alias BUCKYSTATUS $91 .alias kernal_load_or_verify_flag $93 - .alias C3PO $94 ; flag - is BSOUR content valid - .alias BSOUR $95 ; serial bus buffered output byte .alias current_file_num $98 - .alias LDTND $98 ; number of entries in LAT / FAT / SAT tables - .alias DFLTN $99 .alias input_device_number DFLTN - .alias MSGFLG $9D ; bit 6 = error messages, bit 7 = control message - .alias jiffy_clock_24bits $a0 .alias cassette_buffer_bytes_used $A6 .alias load_or_scroll_temp_pointer $AC ;; We also use the following for temp colour pointer when scrolling .alias load_save_verify_end_address $AE .alias cassette_buffer_ptr $B2 - .alias current_filename_length $B7 .alias current_logical_filenum $B8 .alias current_secondary_address $B9 .alias current_device_number $BA .alias current_filename_ptr $BB - .alias load_save_start_ptr $C1 .alias load_save_end_ptr $C3 .alias last_key_matrix_position $C5 .alias keys_in_key_buffer $C6 @@ -53,25 +41,11 @@ .alias keyboard_decoding_table_ptr $F5 .alias rs232_rx_buffer_ptr $F7 .alias rs232_tx_buffer_ptr $F9 - - ;; 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 - - ;; Kernal tables for opened files, 10 entries each - .alias LAT $0259 ; logical file numbers - .alias FAT $0263 ; device numbers - .alias SAT $026D ; secondary addresses ; "Compute's Mapping the 64" book .alias keyboard_buffer $0277 - .alias MEMSTR $0281 - .alias MEMSIZ $0283 ; NOTE: Mapping the 64 erroniously has the hex as $282, while the DEC is correct .alias text_colour $0286 ; p55 .alias colour_under_cursor $0287 ; p56 - .alias HIBASE $0288 ; p56 (high byte of start of screen) .alias key_buffer_size $0289 ; p57 ;; 0 = cursor keys, insert, delete and space repeat, but nothing else @@ -87,8 +61,6 @@ .alias keyboard_decoding_ptr $028F .alias enable_case_switch $0291 .alias screen_scroll_disable $0292 - .alias RSSTAT $0297 ; RS-232 status - .alias pal_or_ntsc $02A6 ;; Under-ROM routines ;; (BASIC also includes them. XXX - We should de-duplicate them in a safe manner) diff --git a/c64/kernal/load.s b/c64/kernal/load.s index ce355cfc..d5f8553a 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -19,7 +19,7 @@ ;; Searching through Compute's Mapping the 64, we find the following ;; things are used: - ;; $93 = kernal_load_or_verify_flag + ;; $93 = VERCK ;; $AC = current pointer for loading/verifying ;; $C1 = similar to the above. @@ -30,11 +30,11 @@ load: ;; Are we loading or verifying? - sta kernal_load_or_verify_flag + sta VERCK ;; Store start address of LOAD - stx load_save_start_ptr+0 - sty load_save_start_ptr+1 + stx STAL+0 + sty STAL+1 ;; Reset status jsr kernalstatus_reset @@ -43,21 +43,8 @@ load: jsr install_ram_routines ;; Display SEARCHING FOR + filename - lda MSGFLG - bpl + - jsr printf - .byte $0D,"SEARCHING FOR ",0 - ldy #$00 -print_filename_loop: + jsr lvs_display_searching_for - cpy current_filename_length - beq + - ldx # Date: Fri, 19 Jul 2019 17:43:28 +0200 Subject: [PATCH 55/90] temporary fix for dependencies calculation --- Makefile | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 364bb3e6..cadc7677 100644 --- a/Makefile +++ b/Makefile @@ -66,6 +66,27 @@ $(TOOL_SIMILARITY): src/similarity.c Makefile build/chargen: $(TOOL_PNGPREPARE) assets/8x8font.png $(TOOL_PNGPREPARE) charrom assets/8x8font.png build/chargen +# Dependencies - XXX, why they need to be stated separately? + +build/basic_generic/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_generic) build/basic/packed_messages.s +build/kernal_generic/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_KERNAL_generic) +build/newrom_generic: build/basic_generic/OUT.BIN build/kernal_generic/OUT.BIN +build/newkern_generic: build/newrom_generic Makefile +build/newbasic_generic: build/newrom_generic Makefile + +build/basic_mega65/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_mega65) build/basic/packed_messages.s +build/kernal_mega65/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_KERNAL_mega65) +build/newrom_mega65: build/basic_mega65/OUT.BIN build/kernal_mega65/OUT.BIN +build/newkern_mega65: build/newrom_mega65 Makefile +build/newbasic_mega65: build/newrom_mega65 Makefile + +build/basic_ultimate64/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_ultimate64) build/basic/packed_messages.s +build/kernal_ultimate64/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_KERNAL_ultimate64) +build/newrom_ultimate64: build/basic_ultimate64/OUT.BIN build/kernal_ultimate64/OUT.BIN +build/newkern_ultimate64: build/newrom_ultimate64 Makefile +build/newbasic_ultimate64: build/newrom_ultimate64 Makefile + + # Rules - BASIC and KERNAL build/basic/packed_messages.s: $(TOOL_COMPRESS_TEXT) @@ -73,7 +94,7 @@ build/basic/packed_messages.s: $(TOOL_COMPRESS_TEXT) $(TOOL_COMPRESS_TEXT) > build/basic/packed_messages.s .PRECIOUS: build/basic_%/OUT.BIN -build/basic_%/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_%) build/basic/packed_messages.s +build/basic_%/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_$*) build/basic/packed_messages.s @mkdir -p build/basic_$* @rm -f build/basic_$*/* @for SRC in $(SRC_BASIC_$*); do \ @@ -83,7 +104,7 @@ build/basic_%/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_%) build/basic/packed_mes $(TOOL_PREPROCESS) -d build/basic_$* -l a000 -h e4d2 .PRECIOUS: build/kernal_%/OUT.BIN -build/kernal_%/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_KERNAL_%) +build/kernal_%/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_KERNAL_$*) @mkdir -p build/kernal_$* @rm -f build/kernal_$*/* @for SRC in $(SRC_KERNAL_$*); do \ From 4a040ac935763401b8c5ac541113092b958f0b9f Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 19 Jul 2019 21:23:43 +0200 Subject: [PATCH 56/90] work towards Ultimate 64 LOAD support --- c64/kernal/,platform_generic/,hooks_generic.s | 6 + c64/kernal/,platform_generic/.dummy | 0 c64/kernal/,platform_mega65/,hooks_mega65.s | 6 + c64/kernal/,platform_mega65/.dummy | 0 .../,aliases_ultimate64.s | 61 +++++++- .../,platform_ultimate64/,hooks_ultimate64.s | 7 + c64/kernal/,platform_ultimate64/u64_load.s | 140 ++++++++++++++++++ c64/kernal/load.s | 12 +- c64/kernal/lvs_helpers.s | 2 + 9 files changed, 219 insertions(+), 15 deletions(-) create mode 100644 c64/kernal/,platform_generic/,hooks_generic.s delete mode 100644 c64/kernal/,platform_generic/.dummy create mode 100644 c64/kernal/,platform_mega65/,hooks_mega65.s delete mode 100644 c64/kernal/,platform_mega65/.dummy create mode 100644 c64/kernal/,platform_ultimate64/,hooks_ultimate64.s create mode 100644 c64/kernal/,platform_ultimate64/u64_load.s diff --git a/c64/kernal/,platform_generic/,hooks_generic.s b/c64/kernal/,platform_generic/,hooks_generic.s new file mode 100644 index 00000000..7de47686 --- /dev/null +++ b/c64/kernal/,platform_generic/,hooks_generic.s @@ -0,0 +1,6 @@ + +;; Platform-specific hooks + + +.macro PLATFORM_HOOK_LOAD +.macend diff --git a/c64/kernal/,platform_generic/.dummy b/c64/kernal/,platform_generic/.dummy deleted file mode 100644 index e69de29b..00000000 diff --git a/c64/kernal/,platform_mega65/,hooks_mega65.s b/c64/kernal/,platform_mega65/,hooks_mega65.s new file mode 100644 index 00000000..7de47686 --- /dev/null +++ b/c64/kernal/,platform_mega65/,hooks_mega65.s @@ -0,0 +1,6 @@ + +;; Platform-specific hooks + + +.macro PLATFORM_HOOK_LOAD +.macend diff --git a/c64/kernal/,platform_mega65/.dummy b/c64/kernal/,platform_mega65/.dummy deleted file mode 100644 index e69de29b..00000000 diff --git a/c64/kernal/,platform_ultimate64/,aliases_ultimate64.s b/c64/kernal/,platform_ultimate64/,aliases_ultimate64.s index 1f30e332..a4aabfaf 100644 --- a/c64/kernal/,platform_ultimate64/,aliases_ultimate64.s +++ b/c64/kernal/,platform_ultimate64/,aliases_ultimate64.s @@ -1,10 +1,57 @@ -;; Registers according to Ultimate 64 Command Interface ddescription, +;; Registers according to Ultimate 64 Command Interface description, ;; https://1541u-documentation.readthedocs.io/en/latest/command%20interface.html +;; and ultimate_dos_v1.0.pdf and command_interface_v1.0.pdf by Gideon Zweijtzer - .alias U64_CONTROL $DF1C ; write - .alias U64_STATUS $DF1C ; read - .alias U64_COMMAND_DATA $DF1D ; write - .alias U64_IDENTIFICATION $DF1D ; read - .alias U64_RESPONSE_DATA $DF1E ; read only - .alias U64_STATUS_DATA $DF1F ; read only + ;; Command interface registers + .alias U64_CONTROL $DF1C ; write + .alias U64_STATUS $DF1C ; read + .alias U64_COMMAND_DATA $DF1D ; write + .alias U64_IDENTIFICATION $DF1D ; read + .alias U64_RESPONSE_DATA $DF1E ; read only + .alias U64_STATUS_DATA $DF1F ; read only + + ;; Constant for U64_IDENTIFICATION register + .alias U64_MAGIC_ID $C9 + + ;; Constants for U64_CONTROL register + .alias U64_CTRL_BIT_PUSH_CMD $01 + .alias U64_CTRL_BIT_DATA_ACC $02 + .alias U64_CTRL_BIT_ABORT $04 + .alias U64_CTRL_BIT_CLR_ERR $08 + + ;; Constants for U64_STATUS register + .alias U64_STAT_BIT_CMD_BUSY $01 + .alias U64_STAT_BIT_DATA_ACC $02 + .alias U64_STAT_BIT_ABORT_P $04 + .alias U64_STAT_BIT_ERROR $08 + .alias U64_STAT_MASK_STATE $30 ; two bits! + .alias U64_STAT_BIT_STAT_AV $40 + .alias U64_STAT_BIT_DATA_AV $80 + + ;; Interface targets + .alias U64_TARGET_DOS1 $01 + .alias U64_TARGET_DOS2 $02 + + ;; DOS command codes + .alias U64_DOS_CMD_IDENTIFY $01 + .alias U64_DOS_CMD_OPEN_FILE $02 + .alias U64_DOS_CMD_CLOSE_FILE $03 + .alias U64_DOS_CMD_READ_DATA $04 + .alias U64_DOS_CMD_WRITE_DATA $05 + .alias U64_DOS_CMD_FILE_SEEK $06 + .alias U64_DOS_CMD_FILE_INFO $07 + .alias U64_DOS_CMD_CHANGE_DIR $11 + .alias U64_DOS_CMD_GET_PATH $12 + .alias U64_DOS_CMD_OPEN_DIR $13 + .alias U64_DOS_CMD_READ_DIR $14 + .alias U64_DOS_CMD_COPY_UI_PATH $15 + .alias U64_DOS_CMD_LOAD_REU $21 + .alias U64_DOS_CMD_SAVE_REU $22 + .alias U64_DOS_CMD_ECHO $F0 + + ;; DOS file opening constants + .alias U64_FA_READ $01 + .alias U64_FA_WRITE $02 + .alias U64_FA_CREATE_NEW $03 + .alias U64_FA_CREATE_ALWAYS $04 diff --git a/c64/kernal/,platform_ultimate64/,hooks_ultimate64.s b/c64/kernal/,platform_ultimate64/,hooks_ultimate64.s new file mode 100644 index 00000000..50f780b7 --- /dev/null +++ b/c64/kernal/,platform_ultimate64/,hooks_ultimate64.s @@ -0,0 +1,7 @@ + +;; Platform-specific hooks + + +.macro PLATFORM_HOOK_LOAD + jsr u64_load +.macend diff --git a/c64/kernal/,platform_ultimate64/u64_load.s b/c64/kernal/,platform_ultimate64/u64_load.s new file mode 100644 index 00000000..19764034 --- /dev/null +++ b/c64/kernal/,platform_ultimate64/u64_load.s @@ -0,0 +1,140 @@ + +;; +;; LOAD routine hook for fast loading via UltiDOS +;; + + +u64_load: + + jsr printf + .byte "DGB: 0",$0D,0 + + ;; First check whether the command interface is enabled + ;; XXX identification does not work, why? + ;; lda U64_IDENTIFICATION + ;; cmp U64_MAGIC_ID + ;; beq + + +u64_load_skip: + ;; rts +* + jsr printf + .byte "DGB: 1",$0D,0 + + ;; XXX find out which device number softIEC is mapped to + lda current_device_number + cmp #$20 ; for now use device number 32 + beq u64_load_skip + + .byte "DGB: 2",$0D,0 + + ;; Takeover the flow completely + pla + pla + + ;; Display SEARCHING FOR + filename + jsr lvs_display_searching_for + + .byte "DGB: 3",$0D,0 + + ;; Whatever the interface was doing - ask to abort it + jsr u64_load_abort + + .byte "DGB: 4",$0D,0 + + ;; Send a command to open the file + lda #U64_DOS_CMD_OPEN_FILE + jsr u64_load_send_cmd + lda #U64_FA_READ + jsr u64_load_send_cmd + jsr u64_load_send_filename + jsr u64_load_finalize_cmd + + .byte "DGB: 5",$0D,0 + + ;; Check status + jsr u64_load_check_status + bcs lvs_file_not_found_error + + ;; Load first two bytes to determine start address + + ;; XXX + + .byte "DGB: 6",$0D,0 + + jmp lvs_wrap_around_error + rts + +u64_load_abort: + lda #U64_CTRL_BIT_ABORT + sta U64_CONTROL +* + lda U64_STATUS + bne - + rts + +u64_load_send_cmd: + + ldx #U64_TARGET_DOS2 + stx U64_COMMAND_DATA ; target + sta U64_COMMAND_DATA ; command code + rts + +u64_load_send_filename: + ldy #0 +u64_load_send_filename_loop: + cpy FNLEN + bne+ + rts +* + ldx # Date: Fri, 19 Jul 2019 21:58:54 +0200 Subject: [PATCH 57/90] fixed Ultimate 64 detection --- c64/kernal/,platform_ultimate64/u64_load.s | 42 +++++++++++----------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/c64/kernal/,platform_ultimate64/u64_load.s b/c64/kernal/,platform_ultimate64/u64_load.s index 19764034..dc5af5f8 100644 --- a/c64/kernal/,platform_ultimate64/u64_load.s +++ b/c64/kernal/,platform_ultimate64/u64_load.s @@ -6,27 +6,18 @@ u64_load: - jsr printf - .byte "DGB: 0",$0D,0 - ;; First check whether the command interface is enabled - ;; XXX identification does not work, why? - ;; lda U64_IDENTIFICATION - ;; cmp U64_MAGIC_ID - ;; beq + + lda U64_IDENTIFICATION + cmp #U64_MAGIC_ID + beq + u64_load_skip: - ;; rts + rts * - jsr printf - .byte "DGB: 1",$0D,0 - ;; XXX find out which device number softIEC is mapped to lda current_device_number cmp #$20 ; for now use device number 32 - beq u64_load_skip - - .byte "DGB: 2",$0D,0 + bne u64_load_skip ;; Takeover the flow completely pla @@ -35,12 +26,14 @@ u64_load_skip: ;; Display SEARCHING FOR + filename jsr lvs_display_searching_for - .byte "DGB: 3",$0D,0 + jsr printf + .byte $0D,"DBG: 1",$0D,0 ;; Whatever the interface was doing - ask to abort it jsr u64_load_abort - .byte "DGB: 4",$0D,0 + jsr printf + .byte "DBG: 2",$0D,0 ;; Send a command to open the file lda #U64_DOS_CMD_OPEN_FILE @@ -50,7 +43,8 @@ u64_load_skip: jsr u64_load_send_filename jsr u64_load_finalize_cmd - .byte "DGB: 5",$0D,0 + jsr printf + .byte "DBG: 3",$0D,0 ;; Check status jsr u64_load_check_status @@ -60,7 +54,8 @@ u64_load_skip: ;; XXX - .byte "DGB: 6",$0D,0 + jsr printf + .byte "DBG: 4",$0D,0 jmp lvs_wrap_around_error rts @@ -110,12 +105,15 @@ u64_load_check_status: lda U64_STATUS and #U64_STAT_BIT_STAT_AV beq u64_load_check_status - + ;; Status is ready - check the first character lda U64_STATUS_DATA cmp #$30 ; '0' bne u64_load_check_status_wrong - + + jsr printf + .byte "DBG: X1 OK",$0D,0 + ;; Check the second status character lda U64_STATUS and #U64_STAT_BIT_STAT_AV @@ -123,6 +121,10 @@ u64_load_check_status: lda U64_STATUS_DATA cmp #$30 ; '0' beq u64_load_check_status_ok + + jsr printf + .byte "DBG: X2 NOK",$0D,0 + ;; FALLTROUGH u64_load_check_status_wrong: sec From eb8eefff827e0e521da1e281c4c184bf9e16e9f7 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 20 Jul 2019 12:48:44 +0200 Subject: [PATCH 58/90] disabled the prototype U64 fastloader --- .../,platform_ultimate64/,hooks_ultimate64.s | 4 +++- .../{u64_load.s => u64_load.s.disabled} | 20 ++++--------------- 2 files changed, 7 insertions(+), 17 deletions(-) rename c64/kernal/,platform_ultimate64/{u64_load.s => u64_load.s.disabled} (91%) diff --git a/c64/kernal/,platform_ultimate64/,hooks_ultimate64.s b/c64/kernal/,platform_ultimate64/,hooks_ultimate64.s index 50f780b7..2c092fc0 100644 --- a/c64/kernal/,platform_ultimate64/,hooks_ultimate64.s +++ b/c64/kernal/,platform_ultimate64/,hooks_ultimate64.s @@ -3,5 +3,7 @@ .macro PLATFORM_HOOK_LOAD - jsr u64_load + ;; XXX disabled for now - the current file opening API is not + ;; really suitable for easy usage from Kernal + ;; jsr u64_load .macend diff --git a/c64/kernal/,platform_ultimate64/u64_load.s b/c64/kernal/,platform_ultimate64/u64_load.s.disabled similarity index 91% rename from c64/kernal/,platform_ultimate64/u64_load.s rename to c64/kernal/,platform_ultimate64/u64_load.s.disabled index dc5af5f8..07ddc298 100644 --- a/c64/kernal/,platform_ultimate64/u64_load.s +++ b/c64/kernal/,platform_ultimate64/u64_load.s.disabled @@ -26,14 +26,8 @@ u64_load_skip: ;; Display SEARCHING FOR + filename jsr lvs_display_searching_for - jsr printf - .byte $0D,"DBG: 1",$0D,0 - ;; Whatever the interface was doing - ask to abort it jsr u64_load_abort - - jsr printf - .byte "DBG: 2",$0D,0 ;; Send a command to open the file lda #U64_DOS_CMD_OPEN_FILE @@ -42,9 +36,6 @@ u64_load_skip: jsr u64_load_send_cmd jsr u64_load_send_filename jsr u64_load_finalize_cmd - - jsr printf - .byte "DBG: 3",$0D,0 ;; Check status jsr u64_load_check_status @@ -55,7 +46,7 @@ u64_load_skip: ;; XXX jsr printf - .byte "DBG: 4",$0D,0 + .byte "DBG: NOT IMPLEMENTED",$0D,0 jmp lvs_wrap_around_error rts @@ -108,23 +99,19 @@ u64_load_check_status: ;; Status is ready - check the first character lda U64_STATUS_DATA + jsr JCHROUT ; XXX for test only cmp #$30 ; '0' bne u64_load_check_status_wrong - jsr printf - .byte "DBG: X1 OK",$0D,0 - ;; Check the second status character lda U64_STATUS and #U64_STAT_BIT_STAT_AV beq u64_load_check_status_ok lda U64_STATUS_DATA + jsr JCHROUT ; XXX for test only cmp #$30 ; '0' beq u64_load_check_status_ok - jsr printf - .byte "DBG: X2 NOK",$0D,0 - ;; FALLTROUGH u64_load_check_status_wrong: sec @@ -137,6 +124,7 @@ u64_load_check_status_ok: and #U64_STAT_BIT_STAT_AV beq + lda U64_STATUS_DATA + jsr JCHROUT ; XXX for test only jmp - * rts From f26431b5027b1205bf2a94eb239dbced56ff6a5a Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 20 Jul 2019 15:25:43 +0200 Subject: [PATCH 59/90] several IEC routines now properly preserve X/Y registers --- STATUS.md | 12 ++++++------ c64/kernal/ciout.s | 4 +--- c64/kernal/iec_return.s | 38 +++++++++++++++++++++++++++++++++++++ c64/kernal/iec_tx_byte.s | 23 ++++++++++------------ c64/kernal/iec_tx_command.s | 24 ++++++++++++----------- c64/kernal/iec_tx_common.s | 20 ++++++++----------- c64/kernal/listen.s | 5 ++--- c64/kernal/load.s | 14 +++++--------- c64/kernal/open.s | 11 +---------- c64/kernal/second.s | 5 ++--- c64/kernal/talk.s | 7 +++---- c64/kernal/tksa.s | 6 +++--- c64/kernal/unlsn.s | 9 +++------ c64/kernal/untlk.s | 5 +++-- 14 files changed, 98 insertions(+), 85 deletions(-) create mode 100644 c64/kernal/iec_return.s diff --git a/STATUS.md b/STATUS.md index 56f5f4e9..ab419717 100644 --- a/STATUS.md +++ b/STATUS.md @@ -73,18 +73,18 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on | $FF8A | RESTOR | PARTIAL | CBINV, NMINV, and USRCMD missing | | $FF8D | VECTOR | DONE | | | $FF90 | SETMSG | DONE | | -| $FF93 | SECOND | PARTIAL | * work in progress | -| $FF96 | TKSA | PARTIAL | should probably also do a turnaround | +| $FF93 | SECOND | DONE | | +| $FF96 | TKSA | PARTIAL | should it do a turnaround? | | $FF99 | MEMTOP | DONE | | | $FF9C | MEMBOT | DONE | | | $FF9F | SCNKEY | DONE | could be better integrated with ROM | | $FFA2 | SETTMO | NOT DONE | | | $FFA5 | ACPTR | NOT DONE | * work in progress | -| $FFA8 | CIOUT | PARITAL | * work in progress | +| $FFA8 | CIOUT | DONE | | | $FFAB | UNTLK | PARITAL | * work in progress | -| $FFAE | UNLSN | PARITAL | * work in progress | -| $FFB1 | LISTEN | PARTIAL | * work in progress | -| $FFB4 | TALK | PARTIAL | * work in progress | +| $FFAE | UNLSN | DONE | | +| $FFB1 | LISTEN | DONE | | +| $FFB4 | TALK | PARTIAL | should it do a turnaround? | | $FFB7 | READST | DONE | | | $FFBA | SETFLS | DONE | | | $FFBD | SETNAM | DONE | | diff --git a/c64/kernal/ciout.s b/c64/kernal/ciout.s index a1cf61f6..26095a85 100644 --- a/c64/kernal/ciout.s +++ b/c64/kernal/ciout.s @@ -8,7 +8,6 @@ ;; CPU registers that has to be preserved (see [RG64]): .X, .Y ;; -;; XXX currently does not preserve registers, to be fixed! ciout: @@ -31,9 +30,8 @@ ciout_store_in_buffer: ciout_send_byte: - ;; Send previous data - lda BSOUR clc ; don't send with EOI jsr iec_tx_byte + inc C3PO ; iec_tx_byte sets it to 0, but we still have something to send jmp ciout_store_in_buffer diff --git a/c64/kernal/iec_return.s b/c64/kernal/iec_return.s new file mode 100644 index 00000000..a89a1336 --- /dev/null +++ b/c64/kernal/iec_return.s @@ -0,0 +1,38 @@ + +;; +;; Helper routines to return with error/success +;; +;; All of them restore X/Y registers from stack, +;; they take care about Carry flag, +;; error return reeset IEC line to default state, +;; take care about .A and IOSTATUS +;; + +iec_return_success: + + ;; BSOUR is certainly not valid anymore + lda #$00 + sta C3PO + ;; Restore registers + pla + tay + pla + tax + ;; Report success + clc + rts + +iec_return_DEVICE_NOT_FOUND: + + ;; Set IEC line to normal idle state + jsr iec_set_idle + ;; BSOUR is certainly not valid anymore + lda #$00 + sta C3PO + ;; Restore registers + pla + tay + pla + tax + ;; Report error + jmp kernalerror_DEVICE_NOT_FOUND diff --git a/c64/kernal/iec_tx_byte.s b/c64/kernal/iec_tx_byte.s index b827d8c2..a1eac09b 100644 --- a/c64/kernal/iec_tx_byte.s +++ b/c64/kernal/iec_tx_byte.s @@ -1,11 +1,16 @@ ;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc -;; Carry flag set = signal EOI +;; Expects byte to send in BSOUR; Carry flag set = signal EOI +;; Preserves .X and .Y registers + iec_tx_byte: - ;; Store byte to send on the stack + ;; Store .X and .Y on the stack - preserve them + txa + pha + tya pha ;; Notify all devices that we are going to send a byte @@ -15,10 +20,9 @@ iec_tx_byte: ;; Common part of iec_txbyte and iec_tx_common - waits for devices ;; and transmits a byte - pla jsr iec_tx_common - ;; All done - give device time to tell if they are busy by pulling DATA + ;; Give device time to tell if they are busy by pulling DATA ;; They should do it within 1ms ldx #$FF * lda CIA2_PRA @@ -27,15 +31,8 @@ iec_tx_byte: bpl + dex bne - - bpl iec_tx_byte_error + bpl iec_return_DEVICE_NOT_FOUND * - ;; All done - clc - rts - -iec_tx_byte_error: - - jsr iec_set_idle - jmp kernalerror_DEVICE_NOT_FOUND + jmp iec_return_success diff --git a/c64/kernal/iec_tx_command.s b/c64/kernal/iec_tx_command.s index 0e92e2db..f785d736 100644 --- a/c64/kernal/iec_tx_command.s +++ b/c64/kernal/iec_tx_command.s @@ -1,9 +1,16 @@ ;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc +;; Expects command to send in BSOUR; Carry flag set = signal EOI +;; Preserves .X and .Y registers + + iec_tx_command: - ;; Store command to send on the stack + ;; Store .X and .Y on the stack - preserve them + txa + pha + tya pha ;; Notify all devices that we are going to send a byte @@ -18,11 +25,8 @@ iec_tx_command: and #BIT_CIA2_PRA_DAT_IN ; XXX try to optimize this, move to separate routine beq + - ;; No devices present on the bus, so we can immediately return with device not found - pla - - jsr iec_set_idle - jmp kernalerror_DEVICE_NOT_FOUND + ;; No devices present on the bus, so we can immediately return with device not found + jmp iec_return_DEVICE_NOT_FOUND * ;; At least one device responded, but they are still allowed to stall ;; (can be busy processing something), we have to wait till they are all @@ -35,7 +39,6 @@ iec_tx_command: ;; and transmits a byte clc ; Carry flag set is used for EOI mark - pla jsr iec_tx_common ;; According to https://www.pagetable.com/?p=1135 there is some complicated and dangerous @@ -50,8 +53,7 @@ iec_tx_command: ;; to wait for the DATA being pulled, as confirmation is expected from ;; a single device only - but not sure if it's worth the trouble - jsr iec_set_idle - jmp kernalerror_DEVICE_NOT_FOUND + jmp iec_return_DEVICE_NOT_FOUND * ;; All done @@ -60,5 +62,5 @@ iec_tx_command: ;; jsr iec_wait20us ;; jsr iec_set_idle - clc - rts + jmp iec_return_success + diff --git a/c64/kernal/iec_tx_common.s b/c64/kernal/iec_tx_common.s index ef9a5097..50d5edca 100644 --- a/c64/kernal/iec_tx_common.s +++ b/c64/kernal/iec_tx_common.s @@ -3,15 +3,15 @@ ;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc ;; and http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf +;; Expects byte to send in BSOUR; Carry flag set = signal EOI + + iec_tx_common: ;; Timing is critical here - execute on disabled IRQs php sei - ;; Store the byte to send on a stack - pha - ;; Wait till all receivers are ready, they should all release DATA jsr iec_wait_for_data_release @@ -38,13 +38,14 @@ iec_tx_common: ;; Now, we can start transmission of 8 bits of data ldx #7 - pla iec_tx_common_sendbit: ;; Is next bit 0 or 1? + lda BSOUR lsr - pha + sta BSOUR bcs + + ;; XXX we are actually destroying BSOUR here... is it allowed? ;; Bit is 0 jsr iec_release_clk_pull_data @@ -65,13 +66,8 @@ iec_tx_common_bit_is_sent: ;; More bits to send? dex - bpl iec_tx_common_nextbit - pla - + bpl iec_tx_common_sendbit + plp rts ; Flow continues differently for data/command - -iec_tx_common_nextbit: - pla - jmp iec_tx_common_sendbit diff --git a/c64/kernal/listen.s b/c64/kernal/listen.s index 92ad77fa..7f71c941 100644 --- a/c64/kernal/listen.s +++ b/c64/kernal/listen.s @@ -4,16 +4,15 @@ ;; ;; - [RG64] C64 Programmer's Reference Guide - page 285 ;; - [CM64] Compute's Mapping the Commodore 64 - page 223 +;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc ;; ;; CPU registers that has to be preserved (see [RG64]): .X, .Y ;; -;; XXX currently does not preserve registers, to be fixed! listen: - ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 223 and - ;; https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc and #$1F ; make sure bits encoding the command are cleared out ora #$20 + sta BSOUR jmp iec_tx_command diff --git a/c64/kernal/load.s b/c64/kernal/load.s index df29f688..131e987f 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -67,22 +67,16 @@ load_send_filename: jsr peek_under_roms iny - ;; Save Y because iec_tx_byte will corrupt it - tax - tya - pha - ;; Set Carry flag on the last file name character, to mark EOI - cmp FNLEN + cpy FNLEN clc bne + sec * - txa + ;; Transmit one character + sta BSOUR jsr iec_tx_byte - pla - tay jmp load_send_filename load_filename_sent: @@ -98,6 +92,7 @@ load_filename_sent: bcs lvs_load_verify_error lda #$60 ; open channel / data (p3) , required according to p13 + sta BSOUR jsr iec_tx_command bcs lvs_load_verify_error @@ -156,6 +151,7 @@ load_loop: jsr listen lda #$E0 + sta BSOUR jsr iec_tx_command ;; Tell drive to unlisten diff --git a/c64/kernal/open.s b/c64/kernal/open.s index d5f99aa7..6ae6ac7e 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -82,12 +82,6 @@ open_iec: ;; XXX note: this is only a temporary test implementation, real 'open' does not send anything to IEC, ;; see http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf - ;; Disable IRQs, since timing matters! - sei - - ;; Begin sending under attention - ;; XXX jsr iec_assert_atn - ;; Request device to talk lda current_device_number jsr talk @@ -107,8 +101,5 @@ open_iec: clc open_iec_error: - ;; Re-enable interrupts and return - ;; (iec_tx_byte will have set/cleared C flag and put result code - ;; in A if it was an error). - cli + ;; Carry flag will be set by low-level routines rts diff --git a/c64/kernal/second.s b/c64/kernal/second.s index d9024dff..53d1391e 100644 --- a/c64/kernal/second.s +++ b/c64/kernal/second.s @@ -4,16 +4,15 @@ ;; ;; - [RG64] C64 Programmer's Reference Guide - page 296 ;; - [CM64] Compute's Mapping the Commodore 64 - page 223/224 +;; - https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc ;; ;; CPU registers that has to be preserved (see [RG64]): .X, .Y ;; -;; XXX currently does not preserve registers, to be fixed! second: - ;; see also https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc - and #$1F ; make sure bits encoding the command are cleared out ora #$60 + sta BSOUR jmp iec_tx_command diff --git a/c64/kernal/talk.s b/c64/kernal/talk.s index 253cba33..67a87bd9 100644 --- a/c64/kernal/talk.s +++ b/c64/kernal/talk.s @@ -4,18 +4,17 @@ ;; ;; - [RG64] C64 Programmer's Reference Guide - page 301/302 ;; - [CM64] Compute's Mapping the Commodore 64 - page 223 +;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc ;; ;; CPU registers that has to be preserved (see [RG64]): .X, .Y ;; -;; XXX currently does not preserve registers, to be fixed! + ;; XXX shouldn't this do a turnaround? talk: - ;; See also https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc - and #$1F ; make sure bits encoding the command are cleared out ora #$40 + sta BSOUR jmp iec_tx_command - diff --git a/c64/kernal/tksa.s b/c64/kernal/tksa.s index 604ad2aa..d003cfbb 100644 --- a/c64/kernal/tksa.s +++ b/c64/kernal/tksa.s @@ -4,18 +4,18 @@ ;; ;; - [RG64] C64 Programmer's Reference Guide - page 302 ;; - [CM64] Compute's Mapping the Commodore 64 - page 224 +;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc ;; ;; CPU registers that has to be preserved (see [RG64]): .X, .Y ;; -;; XXX currently does not preserve registers, to be fixed! + ;; XXX shouldn't this do a turnaround? tksa: - ;; See also https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc - and #$1F ; make sure bits encoding the command are cleared out ora #$F0 + sta BSOUR jmp iec_tx_command diff --git a/c64/kernal/unlsn.s b/c64/kernal/unlsn.s index 05e73cf5..32f0b0f5 100644 --- a/c64/kernal/unlsn.s +++ b/c64/kernal/unlsn.s @@ -4,11 +4,11 @@ ;; ;; - [RG64] C64 Programmer's Reference Guide - page 303 ;; - [CM64] Compute's Mapping the Commodore 64 - page 224 +;; - https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc ;; ;; CPU registers that has to be preserved (see [RG64]): .X, .Y ;; -;; XXX currently does not preserve registers, to be fixed! unlsn: @@ -17,15 +17,12 @@ unlsn: ;; First check whether we have something to be sent in the buffer lda C3PO beq + - lda BSOUR sec ; send it with EOI jsr iec_tx_byte ; XXX what about the status of this operation? - ;; Mark the buffer as invalid - lda #$00 - sta C3PO * - ;; Buffer empty send the command + ;; Buffer empty, send the command lda #$3F + sta BSOUR jmp iec_tx_command diff --git a/c64/kernal/untlk.s b/c64/kernal/untlk.s index d7276361..7f421bb7 100644 --- a/c64/kernal/untlk.s +++ b/c64/kernal/untlk.s @@ -4,16 +4,17 @@ ;; ;; - [RG64] C64 Programmer's Reference Guide - page 304 ;; - [CM64] Compute's Mapping the Commodore 64 - page 224 +;; - https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc ;; ;; CPU registers that has to be preserved (see [RG64]): .X, .Y ;; -;; XXX currently does not preserve registers, to be fixed! + ;; XXX shouldn't this do a turnaround? untlk: - ;; This trivial routine is documented in 'Compute's Mapping the Commodore 64', page 224 lda #$5F + sta BSOUR jmp iec_tx_command From 2613553ef33ecf445324bd706309b4e7f8b93c63 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 20 Jul 2019 16:30:58 +0200 Subject: [PATCH 60/90] added full protection against illegal IEC device numbers --- c64/kernal/iec_devnum_check.s | 24 ++++++++++++++++++++++++ c64/kernal/listen.s | 5 ++++- c64/kernal/load.s | 12 ++++++++++++ c64/kernal/lvs_helpers.s | 5 +++++ c64/kernal/talk.s | 5 ++++- 5 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 c64/kernal/iec_devnum_check.s diff --git a/c64/kernal/iec_devnum_check.s b/c64/kernal/iec_devnum_check.s new file mode 100644 index 00000000..8fffb64e --- /dev/null +++ b/c64/kernal/iec_devnum_check.s @@ -0,0 +1,24 @@ + +;; +;; Checks whether device numbe (in .A) is a correct IEC device number +;; +;; Preserves .A, .X and .Y +;; + +iec_devnum_check: + ;; 0, 1, 2, or 3 are illegal - reserved for non-IEC devices on Commodore + cmp #$03 + bpl + + bcs + + ;; FALLTROUGH +iec_devnum_check_failed: + sec + rts +* + ;; 30 and above are illegal too, due to IEC command encoding scheme, + ;; see https://www.pagetable.com/?p=1031 + cmp #$1E + bpl iec_devnum_check_failed + bcs iec_devnum_check_failed + clc + rts diff --git a/c64/kernal/listen.s b/c64/kernal/listen.s index 7f71c941..5e2c1bd1 100644 --- a/c64/kernal/listen.s +++ b/c64/kernal/listen.s @@ -12,7 +12,10 @@ listen: - and #$1F ; make sure bits encoding the command are cleared out + ;; First check whether device number is correct + jsr iec_devnum_check + bcs kernalerror_DEVICE_NOT_FOUND + ;; Encode and execute the command ora #$20 sta BSOUR jmp iec_tx_command diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 131e987f..4a946263 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -38,6 +38,18 @@ load: ;; Allow platform-specific routine to takeover the flow `PLATFORM_HOOK_LOAD + ;; Check whether we support the requested device + lda current_device_number + and #$FC + beq lvs_illegal_device_number ; device number below 4, not an IEC device + + ;; Device numbers above 30 are also illegal (see https://www.pagetable.com/?p=1031), + ;; as the protocol combines device number with command code int one byte, + ;; above 30 it is no longer possible (UNLISTEN and UNTALK codes prevent using + ;; number 31), yet original ROMs show ILLEGAL DEVICE NUMBER error only + ;; for devices 0-3; in our implementation LISTEN / TALK will cause device + ;; not present detected for numbers above 30 + ;; Display SEARCHING FOR + filename jsr lvs_display_searching_for diff --git a/c64/kernal/lvs_helpers.s b/c64/kernal/lvs_helpers.s index 85329bf9..e39bb15e 100644 --- a/c64/kernal/lvs_helpers.s +++ b/c64/kernal/lvs_helpers.s @@ -114,6 +114,11 @@ lvs_device_not_found_error: jsr kernalstatus_DEVICE_NOT_FOUND jmp kernalerror_DEVICE_NOT_FOUND +lvs_illegal_device_number: + + jsr kernalstatus_DEVICE_NOT_FOUND + jmp kernalerror_ILLEGAL_DEVICE_NUMBER + .alias lvs_file_not_found_error kernalerror_FILE_NOT_FOUND lvs_load_verify_error: diff --git a/c64/kernal/talk.s b/c64/kernal/talk.s index 67a87bd9..3952ed0c 100644 --- a/c64/kernal/talk.s +++ b/c64/kernal/talk.s @@ -14,7 +14,10 @@ talk: - and #$1F ; make sure bits encoding the command are cleared out + ;; First check whether device number is correct + jsr iec_devnum_check + bcs kernalerror_DEVICE_NOT_FOUND + ;; Encode and execute the command ora #$40 sta BSOUR jmp iec_tx_command From c7727d4f0f4c21b3234e0a48c38eb019fb3dbc3c Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 20 Jul 2019 17:59:24 +0200 Subject: [PATCH 61/90] LOAD command understands device number and secondary address --- STATUS.md | 2 +- c64/basic/cmd_load.s | 49 ++++++++++++++++++++++++++++++++-------- c64/basic/injest_comma.s | 20 ++++++++++++++++ 3 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 c64/basic/injest_comma.s diff --git a/STATUS.md b/STATUS.md index ab419717..281a9951 100644 --- a/STATUS.md +++ b/STATUS.md @@ -8,7 +8,7 @@ Here are the features of the Open ROMs not found in the original ROMs from the 8 * banking in the BASIC interpreter: 61436 bytes free * LOAD start/end addresses are displayed, in the Final cartridge style * LOAD command with just the file name tries to use the last device if it's number seems sane; otherwise uses 8 - +* LOAD secondary address over 255 is considered a start address; NOTE: syntax will most likely change here in the future! # Features missing diff --git a/c64/basic/cmd_load.s b/c64/basic/cmd_load.s index 22b648eb..2931b607 100644 --- a/c64/basic/cmd_load.s +++ b/c64/basic/cmd_load.s @@ -19,10 +19,6 @@ cmd_load: lda #$00 ; direct mode - don't display anything * jsr JSETMSG - - ;; XXX handle device number from arguments, if not present, use the call below - jsr select_device - stx current_device_number ;; Set filename and length lda #$00 @@ -47,7 +43,7 @@ cmd_load: ;; Now search for end of line or closing quote ;; so that we know the length of the filename -getting_filename: +getting_filename: jsr basic_fetch_and_consume_character cmp #$22 beq got_filename @@ -60,15 +56,48 @@ getting_filename: inc FNLEN jmp getting_filename -got_filename: +got_filename: - ;; Try to load an IEC file - lda #0 ; use supplied load address, not the one from the file + ;; Now fetch the file number, start from the default one + jsr select_device + stx current_device_number + jsr injest_comma + bcs got_devicenumber + + jsr basic_parse_line_number + lda basic_line_number+1 + bne do_ILLEGAL_QUANTITY_error + lda basic_line_number+0 + sta current_device_number + +got_devicenumber: + + ;; Now fetch the secondary address + lda #$00 sta current_secondary_address - lda #$00 ; LOAD not verify - ldx #<$0801 ; LOAD address = $0801 + jsr injest_comma + bcs got_secondaryaddress + jsr basic_parse_line_number + lda basic_line_number+1 + bne + + lda basic_line_number+0 + sta current_secondary_address + jmp got_secondaryaddress +* + ;; Second parameter is above 255, this can't be a secondary address + ;; Use it as load address instead + ;; XXX temporary syntax, it would be better to use something + ;; XXX like 'LOAD"FILE",8 TO 49152' + ldx basic_line_number+0 + ldy basic_line_number+1 + bne got_loadaddress + +got_secondaryaddress: + ldx #<$0801 ldy #>$0801 +got_loadaddress: + lda #$00 ; LOAD not verify jsr JLOAD bcc + diff --git a/c64/basic/injest_comma.s b/c64/basic/injest_comma.s new file mode 100644 index 00000000..43be5113 --- /dev/null +++ b/c64/basic/injest_comma.s @@ -0,0 +1,20 @@ + +;; Consummes a comma in a BASIC code, C set for no coma found + +injest_comma: + + jsr basic_fetch_and_consume_character + cmp #$2C ; comma character + beq injest_comma_found + cmp #$20 + beq injest_comma ; space, can always be skipped + + ;; not found + jsr basic_unconsume_character + sec + rts + +injest_comma_found: + clc + rts + From c30d4b31c9ab009bbf05cc46767d12d28a0b00f4 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 20 Jul 2019 22:25:57 +0200 Subject: [PATCH 62/90] directory structure cleanup --- Makefile | 32 +++++++++---------- c64/basic/,platform_generic/,hooks_generic.s | 9 ------ c64/basic/,target_generic/,hooks_generic.s | 9 ++++++ .../,hooks_mega65.s | 4 +-- .../,hooks_ultimate64.s | 4 +-- c64/basic/basic_cold_start.s | 2 +- c64/kernal/,platform_generic/,hooks_generic.s | 6 ---- c64/kernal/,platform_mega65/,hooks_mega65.s | 6 ---- c64/kernal/,target_generic/,hooks_generic.s | 6 ++++ c64/kernal/,target_mega65/,hooks_mega65.s | 6 ++++ .../,aliases_ultimate64.s | 0 .../,hooks_ultimate64.s | 4 +-- .../u64_load.s.disabled | 0 c64/kernal/{ => iec}/iec_devnum_check.s | 0 .../{ => iec}/iec_pull_atn_clk_release_data.s | 0 .../{ => iec}/iec_pull_clk_release_data.s | 0 .../{ => iec}/iec_pull_data_release_atn_clk.s | 0 c64/kernal/{ => iec}/iec_release_atn.s | 0 .../{ => iec}/iec_release_atn_clk_data.s | 0 c64/kernal/{ => iec}/iec_release_clk_data.s | 0 .../{ => iec}/iec_release_clk_pull_data.s | 0 c64/kernal/{ => iec}/iec_return.s | 0 c64/kernal/{ => iec}/iec_rx_byte.s | 0 c64/kernal/{ => iec}/iec_set_idle.s | 0 .../{ => iec}/iec_turnaround_to_listen.s | 0 c64/kernal/{ => iec}/iec_turnaround_to_talk.s | 0 c64/kernal/{ => iec}/iec_tx_byte.s | 0 c64/kernal/{ => iec}/iec_tx_command.s | 0 c64/kernal/{ => iec}/iec_tx_common.s | 0 c64/kernal/{ => iec}/iec_wait100us.s | 0 c64/kernal/{ => iec}/iec_wait20us.s | 0 c64/kernal/{ => iec}/iec_wait60us.s | 0 .../{ => iec}/iec_wait_for_clk_release.s | 0 c64/kernal/{ => iec}/iec_wait_for_data_pull.s | 0 .../{ => iec}/iec_wait_for_data_release.s | 0 c64/kernal/{ => jumptable}/ff81.jcint.s | 0 c64/kernal/{ => jumptable}/ff84.jioinit.s | 0 c64/kernal/{ => jumptable}/ff87.jramtas.s | 0 c64/kernal/{ => jumptable}/ff8a.jrestor.s | 0 c64/kernal/{ => jumptable}/ff8d.jvector.s | 0 c64/kernal/{ => jumptable}/ff90.jsetmsg.s | 0 c64/kernal/{ => jumptable}/ff93.jsecond.s | 0 c64/kernal/{ => jumptable}/ff96.jtksa.s | 0 c64/kernal/{ => jumptable}/ff99.jmemtop.s | 0 c64/kernal/{ => jumptable}/ff9c.jmembot.s | 0 c64/kernal/{ => jumptable}/ff9f.jscnkey.s | 0 c64/kernal/{ => jumptable}/ffa2.jsettmo.s | 0 c64/kernal/{ => jumptable}/ffa5.jacptr.s | 0 c64/kernal/{ => jumptable}/ffa8.jciout.s | 0 c64/kernal/{ => jumptable}/ffab.juntlk.s | 0 c64/kernal/{ => jumptable}/ffae.junlsn.s | 0 c64/kernal/{ => jumptable}/ffb1.jlisten.s | 0 c64/kernal/{ => jumptable}/ffb4.jtalk.s | 0 c64/kernal/{ => jumptable}/ffb7.jreadst.s | 0 c64/kernal/{ => jumptable}/ffba.jsetfls.s | 0 .../ffbd.jsetnam.s} | 0 c64/kernal/{ => jumptable}/ffc0.jopen.s | 0 c64/kernal/{ => jumptable}/ffc3.jclose.s | 0 c64/kernal/{ => jumptable}/ffc6.jchkin.s | 0 c64/kernal/{ => jumptable}/ffc9.jchkout.s | 0 c64/kernal/{ => jumptable}/ffcc.jclrchn.s | 0 c64/kernal/{ => jumptable}/ffcf.jchrin.s | 0 c64/kernal/{ => jumptable}/ffd2.jchrout.s | 0 c64/kernal/{ => jumptable}/ffd5.jload.s | 0 c64/kernal/{ => jumptable}/ffd8.jsave.s | 0 c64/kernal/{ => jumptable}/ffdb.jsettim.s | 0 c64/kernal/{ => jumptable}/ffde.jrdtim.s | 0 c64/kernal/{ => jumptable}/ffe1.jstop.s | 0 c64/kernal/{ => jumptable}/ffe4.jgetin.s | 0 c64/kernal/{ => jumptable}/ffe7.jclall.s | 0 c64/kernal/{ => jumptable}/ffea.judtim.s | 0 c64/kernal/{ => jumptable}/ffed.jscreen.s | 0 c64/kernal/{ => jumptable}/fff0.jplot.s | 0 c64/kernal/{ => jumptable}/fff3.jiobase.s | 0 c64/kernal/load.s | 2 +- 75 files changed, 45 insertions(+), 45 deletions(-) delete mode 100644 c64/basic/,platform_generic/,hooks_generic.s create mode 100644 c64/basic/,target_generic/,hooks_generic.s rename c64/basic/{,platform_mega65 => ,target_mega65}/,hooks_mega65.s (97%) rename c64/basic/{,platform_ultimate64 => ,target_ultimate64}/,hooks_ultimate64.s (58%) delete mode 100644 c64/kernal/,platform_generic/,hooks_generic.s delete mode 100644 c64/kernal/,platform_mega65/,hooks_mega65.s create mode 100644 c64/kernal/,target_generic/,hooks_generic.s create mode 100644 c64/kernal/,target_mega65/,hooks_mega65.s rename c64/kernal/{,platform_ultimate64 => ,target_ultimate64}/,aliases_ultimate64.s (100%) rename c64/kernal/{,platform_ultimate64 => ,target_ultimate64}/,hooks_ultimate64.s (72%) rename c64/kernal/{,platform_ultimate64 => ,target_ultimate64}/u64_load.s.disabled (100%) rename c64/kernal/{ => iec}/iec_devnum_check.s (100%) rename c64/kernal/{ => iec}/iec_pull_atn_clk_release_data.s (100%) rename c64/kernal/{ => iec}/iec_pull_clk_release_data.s (100%) rename c64/kernal/{ => iec}/iec_pull_data_release_atn_clk.s (100%) rename c64/kernal/{ => iec}/iec_release_atn.s (100%) rename c64/kernal/{ => iec}/iec_release_atn_clk_data.s (100%) rename c64/kernal/{ => iec}/iec_release_clk_data.s (100%) rename c64/kernal/{ => iec}/iec_release_clk_pull_data.s (100%) rename c64/kernal/{ => iec}/iec_return.s (100%) rename c64/kernal/{ => iec}/iec_rx_byte.s (100%) rename c64/kernal/{ => iec}/iec_set_idle.s (100%) rename c64/kernal/{ => iec}/iec_turnaround_to_listen.s (100%) rename c64/kernal/{ => iec}/iec_turnaround_to_talk.s (100%) rename c64/kernal/{ => iec}/iec_tx_byte.s (100%) rename c64/kernal/{ => iec}/iec_tx_command.s (100%) rename c64/kernal/{ => iec}/iec_tx_common.s (100%) rename c64/kernal/{ => iec}/iec_wait100us.s (100%) rename c64/kernal/{ => iec}/iec_wait20us.s (100%) rename c64/kernal/{ => iec}/iec_wait60us.s (100%) rename c64/kernal/{ => iec}/iec_wait_for_clk_release.s (100%) rename c64/kernal/{ => iec}/iec_wait_for_data_pull.s (100%) rename c64/kernal/{ => iec}/iec_wait_for_data_release.s (100%) rename c64/kernal/{ => jumptable}/ff81.jcint.s (100%) rename c64/kernal/{ => jumptable}/ff84.jioinit.s (100%) rename c64/kernal/{ => jumptable}/ff87.jramtas.s (100%) rename c64/kernal/{ => jumptable}/ff8a.jrestor.s (100%) rename c64/kernal/{ => jumptable}/ff8d.jvector.s (100%) rename c64/kernal/{ => jumptable}/ff90.jsetmsg.s (100%) rename c64/kernal/{ => jumptable}/ff93.jsecond.s (100%) rename c64/kernal/{ => jumptable}/ff96.jtksa.s (100%) rename c64/kernal/{ => jumptable}/ff99.jmemtop.s (100%) rename c64/kernal/{ => jumptable}/ff9c.jmembot.s (100%) rename c64/kernal/{ => jumptable}/ff9f.jscnkey.s (100%) rename c64/kernal/{ => jumptable}/ffa2.jsettmo.s (100%) rename c64/kernal/{ => jumptable}/ffa5.jacptr.s (100%) rename c64/kernal/{ => jumptable}/ffa8.jciout.s (100%) rename c64/kernal/{ => jumptable}/ffab.juntlk.s (100%) rename c64/kernal/{ => jumptable}/ffae.junlsn.s (100%) rename c64/kernal/{ => jumptable}/ffb1.jlisten.s (100%) rename c64/kernal/{ => jumptable}/ffb4.jtalk.s (100%) rename c64/kernal/{ => jumptable}/ffb7.jreadst.s (100%) rename c64/kernal/{ => jumptable}/ffba.jsetfls.s (100%) rename c64/kernal/{ffbd.setnam.s => jumptable/ffbd.jsetnam.s} (100%) rename c64/kernal/{ => jumptable}/ffc0.jopen.s (100%) rename c64/kernal/{ => jumptable}/ffc3.jclose.s (100%) rename c64/kernal/{ => jumptable}/ffc6.jchkin.s (100%) rename c64/kernal/{ => jumptable}/ffc9.jchkout.s (100%) rename c64/kernal/{ => jumptable}/ffcc.jclrchn.s (100%) rename c64/kernal/{ => jumptable}/ffcf.jchrin.s (100%) rename c64/kernal/{ => jumptable}/ffd2.jchrout.s (100%) rename c64/kernal/{ => jumptable}/ffd5.jload.s (100%) rename c64/kernal/{ => jumptable}/ffd8.jsave.s (100%) rename c64/kernal/{ => jumptable}/ffdb.jsettim.s (100%) rename c64/kernal/{ => jumptable}/ffde.jrdtim.s (100%) rename c64/kernal/{ => jumptable}/ffe1.jstop.s (100%) rename c64/kernal/{ => jumptable}/ffe4.jgetin.s (100%) rename c64/kernal/{ => jumptable}/ffe7.jclall.s (100%) rename c64/kernal/{ => jumptable}/ffea.judtim.s (100%) rename c64/kernal/{ => jumptable}/ffed.jscreen.s (100%) rename c64/kernal/{ => jumptable}/fff0.jplot.s (100%) rename c64/kernal/{ => jumptable}/fff3.jiobase.s (100%) diff --git a/Makefile b/Makefile index cadc7677..ca8a7df0 100644 --- a/Makefile +++ b/Makefile @@ -3,15 +3,15 @@ SRC_COMMON = $(wildcard c64/aliases/*.s) SRC_BASIC_COMMON = $(SRC_COMMON) $(wildcard c64/basic/*.s) -SRC_KERNAL_COMMON = $(SRC_COMMON) $(wildcard c64/kernal/*.s) +SRC_KERNAL_COMMON = $(SRC_COMMON) $(wildcard c64/kernal/*.s c64/kernal/jumptable/*.s c64/kernal/iec/*.s) -SRC_BASIC_generic = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,platform_generic/*.s) -SRC_BASIC_mega65 = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,platform_mega65/*.s) -SRC_BASIC_ultimate64 = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,platform_ultimate64/*.s) +SRC_BASIC_generic = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,target_generic/*.s) +SRC_BASIC_mega65 = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,target_mega65/*.s) +SRC_BASIC_ultimate64 = $(SRC_BASIC_COMMON) $(wildcard c64/basic/,target_ultimate64/*.s) -SRC_KERNAL_generic = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_generic/*.s) -SRC_KERNAL_mega65 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_mega65/*.s) -SRC_KERNAL_ultimate64 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,platform_ultimate64/*.s) +SRC_KERNAL_generic = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,target_generic/*.s) +SRC_KERNAL_mega65 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,target_mega65/*.s) +SRC_KERNAL_ultimate64 = $(SRC_KERNAL_COMMON) $(wildcard c64/kernal/,target_ultimate64/*.s) # List of tools @@ -68,22 +68,22 @@ build/chargen: $(TOOL_PNGPREPARE) assets/8x8font.png # Dependencies - XXX, why they need to be stated separately? -build/basic_generic/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_generic) build/basic/packed_messages.s +build/basic_generic/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_generic) build/basic/packed_messages.s build/kernal_generic/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_KERNAL_generic) -build/newrom_generic: build/basic_generic/OUT.BIN build/kernal_generic/OUT.BIN -build/newkern_generic: build/newrom_generic Makefile +build/newrom_generic: build/basic_generic/OUT.BIN build/kernal_generic/OUT.BIN +build/newkern_generic: build/newrom_generic Makefile build/newbasic_generic: build/newrom_generic Makefile -build/basic_mega65/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_mega65) build/basic/packed_messages.s +build/basic_mega65/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_mega65) build/basic/packed_messages.s build/kernal_mega65/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_KERNAL_mega65) -build/newrom_mega65: build/basic_mega65/OUT.BIN build/kernal_mega65/OUT.BIN -build/newkern_mega65: build/newrom_mega65 Makefile +build/newrom_mega65: build/basic_mega65/OUT.BIN build/kernal_mega65/OUT.BIN +build/newkern_mega65: build/newrom_mega65 Makefile build/newbasic_mega65: build/newrom_mega65 Makefile -build/basic_ultimate64/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_ultimate64) build/basic/packed_messages.s +build/basic_ultimate64/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_ultimate64) build/basic/packed_messages.s build/kernal_ultimate64/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_KERNAL_ultimate64) -build/newrom_ultimate64: build/basic_ultimate64/OUT.BIN build/kernal_ultimate64/OUT.BIN -build/newkern_ultimate64: build/newrom_ultimate64 Makefile +build/newrom_ultimate64: build/basic_ultimate64/OUT.BIN build/kernal_ultimate64/OUT.BIN +build/newkern_ultimate64: build/newrom_ultimate64 Makefile build/newbasic_ultimate64: build/newrom_ultimate64 Makefile diff --git a/c64/basic/,platform_generic/,hooks_generic.s b/c64/basic/,platform_generic/,hooks_generic.s deleted file mode 100644 index 4f743e84..00000000 --- a/c64/basic/,platform_generic/,hooks_generic.s +++ /dev/null @@ -1,9 +0,0 @@ - -;; Platform-specific hooks - - -.macro PLATFORM_HOOK_BANNER - - .byte $05, " OPEN ROMS, ", $00 - -.macend diff --git a/c64/basic/,target_generic/,hooks_generic.s b/c64/basic/,target_generic/,hooks_generic.s new file mode 100644 index 00000000..186b29d0 --- /dev/null +++ b/c64/basic/,target_generic/,hooks_generic.s @@ -0,0 +1,9 @@ + +;; Target-specific hooks + + +.macro TARGET_HOOK_BANNER + + .byte $05, " OPEN ROMS, ", $00 + +.macend diff --git a/c64/basic/,platform_mega65/,hooks_mega65.s b/c64/basic/,target_mega65/,hooks_mega65.s similarity index 97% rename from c64/basic/,platform_mega65/,hooks_mega65.s rename to c64/basic/,target_mega65/,hooks_mega65.s index d8eecbaf..97c859e5 100644 --- a/c64/basic/,platform_mega65/,hooks_mega65.s +++ b/c64/basic/,target_mega65/,hooks_mega65.s @@ -1,8 +1,8 @@ -;; Platform-specific hooks +;; Target-specific hooks -.macro PLATFORM_HOOK_BANNER +.macro TARGET_HOOK_BANNER ;; New banner from Retrofan .byte $9a, $12, $20, $20, $7f, $a9, $20, $20, $1f, $20, $9a, $20, $20, $20 diff --git a/c64/basic/,platform_ultimate64/,hooks_ultimate64.s b/c64/basic/,target_ultimate64/,hooks_ultimate64.s similarity index 58% rename from c64/basic/,platform_ultimate64/,hooks_ultimate64.s rename to c64/basic/,target_ultimate64/,hooks_ultimate64.s index 717d70bc..519d07e9 100644 --- a/c64/basic/,platform_ultimate64/,hooks_ultimate64.s +++ b/c64/basic/,target_ultimate64/,hooks_ultimate64.s @@ -1,8 +1,8 @@ -;; Platform-specific hooks +;; Target-specific hooks -.macro PLATFORM_HOOK_BANNER +.macro TARGET_HOOK_BANNER .byte $05, " OPEN ROMS FOR ULTIMATE 64", $0D, $0D, " ", $00 diff --git a/c64/basic/basic_cold_start.s b/c64/basic/basic_cold_start.s index de4faf76..341e0909 100644 --- a/c64/basic/basic_cold_start.s +++ b/c64/basic/basic_cold_start.s @@ -15,7 +15,7 @@ basic_cold_start: ; Used 217 bytes startup_banner: - `PLATFORM_HOOK_BANNER + `TARGET_HOOK_BANNER ;; Work out free bytes, and display jsr basic_do_new diff --git a/c64/kernal/,platform_generic/,hooks_generic.s b/c64/kernal/,platform_generic/,hooks_generic.s deleted file mode 100644 index 7de47686..00000000 --- a/c64/kernal/,platform_generic/,hooks_generic.s +++ /dev/null @@ -1,6 +0,0 @@ - -;; Platform-specific hooks - - -.macro PLATFORM_HOOK_LOAD -.macend diff --git a/c64/kernal/,platform_mega65/,hooks_mega65.s b/c64/kernal/,platform_mega65/,hooks_mega65.s deleted file mode 100644 index 7de47686..00000000 --- a/c64/kernal/,platform_mega65/,hooks_mega65.s +++ /dev/null @@ -1,6 +0,0 @@ - -;; Platform-specific hooks - - -.macro PLATFORM_HOOK_LOAD -.macend diff --git a/c64/kernal/,target_generic/,hooks_generic.s b/c64/kernal/,target_generic/,hooks_generic.s new file mode 100644 index 00000000..a2c8c1a6 --- /dev/null +++ b/c64/kernal/,target_generic/,hooks_generic.s @@ -0,0 +1,6 @@ + +;; Target-specific hooks + + +.macro TARGET_HOOK_LOAD +.macend diff --git a/c64/kernal/,target_mega65/,hooks_mega65.s b/c64/kernal/,target_mega65/,hooks_mega65.s new file mode 100644 index 00000000..a2c8c1a6 --- /dev/null +++ b/c64/kernal/,target_mega65/,hooks_mega65.s @@ -0,0 +1,6 @@ + +;; Target-specific hooks + + +.macro TARGET_HOOK_LOAD +.macend diff --git a/c64/kernal/,platform_ultimate64/,aliases_ultimate64.s b/c64/kernal/,target_ultimate64/,aliases_ultimate64.s similarity index 100% rename from c64/kernal/,platform_ultimate64/,aliases_ultimate64.s rename to c64/kernal/,target_ultimate64/,aliases_ultimate64.s diff --git a/c64/kernal/,platform_ultimate64/,hooks_ultimate64.s b/c64/kernal/,target_ultimate64/,hooks_ultimate64.s similarity index 72% rename from c64/kernal/,platform_ultimate64/,hooks_ultimate64.s rename to c64/kernal/,target_ultimate64/,hooks_ultimate64.s index 2c092fc0..03f6eeb8 100644 --- a/c64/kernal/,platform_ultimate64/,hooks_ultimate64.s +++ b/c64/kernal/,target_ultimate64/,hooks_ultimate64.s @@ -1,8 +1,8 @@ -;; Platform-specific hooks +;; Target-specific hooks -.macro PLATFORM_HOOK_LOAD +.macro TARGET_HOOK_LOAD ;; XXX disabled for now - the current file opening API is not ;; really suitable for easy usage from Kernal ;; jsr u64_load diff --git a/c64/kernal/,platform_ultimate64/u64_load.s.disabled b/c64/kernal/,target_ultimate64/u64_load.s.disabled similarity index 100% rename from c64/kernal/,platform_ultimate64/u64_load.s.disabled rename to c64/kernal/,target_ultimate64/u64_load.s.disabled diff --git a/c64/kernal/iec_devnum_check.s b/c64/kernal/iec/iec_devnum_check.s similarity index 100% rename from c64/kernal/iec_devnum_check.s rename to c64/kernal/iec/iec_devnum_check.s diff --git a/c64/kernal/iec_pull_atn_clk_release_data.s b/c64/kernal/iec/iec_pull_atn_clk_release_data.s similarity index 100% rename from c64/kernal/iec_pull_atn_clk_release_data.s rename to c64/kernal/iec/iec_pull_atn_clk_release_data.s diff --git a/c64/kernal/iec_pull_clk_release_data.s b/c64/kernal/iec/iec_pull_clk_release_data.s similarity index 100% rename from c64/kernal/iec_pull_clk_release_data.s rename to c64/kernal/iec/iec_pull_clk_release_data.s diff --git a/c64/kernal/iec_pull_data_release_atn_clk.s b/c64/kernal/iec/iec_pull_data_release_atn_clk.s similarity index 100% rename from c64/kernal/iec_pull_data_release_atn_clk.s rename to c64/kernal/iec/iec_pull_data_release_atn_clk.s diff --git a/c64/kernal/iec_release_atn.s b/c64/kernal/iec/iec_release_atn.s similarity index 100% rename from c64/kernal/iec_release_atn.s rename to c64/kernal/iec/iec_release_atn.s diff --git a/c64/kernal/iec_release_atn_clk_data.s b/c64/kernal/iec/iec_release_atn_clk_data.s similarity index 100% rename from c64/kernal/iec_release_atn_clk_data.s rename to c64/kernal/iec/iec_release_atn_clk_data.s diff --git a/c64/kernal/iec_release_clk_data.s b/c64/kernal/iec/iec_release_clk_data.s similarity index 100% rename from c64/kernal/iec_release_clk_data.s rename to c64/kernal/iec/iec_release_clk_data.s diff --git a/c64/kernal/iec_release_clk_pull_data.s b/c64/kernal/iec/iec_release_clk_pull_data.s similarity index 100% rename from c64/kernal/iec_release_clk_pull_data.s rename to c64/kernal/iec/iec_release_clk_pull_data.s diff --git a/c64/kernal/iec_return.s b/c64/kernal/iec/iec_return.s similarity index 100% rename from c64/kernal/iec_return.s rename to c64/kernal/iec/iec_return.s diff --git a/c64/kernal/iec_rx_byte.s b/c64/kernal/iec/iec_rx_byte.s similarity index 100% rename from c64/kernal/iec_rx_byte.s rename to c64/kernal/iec/iec_rx_byte.s diff --git a/c64/kernal/iec_set_idle.s b/c64/kernal/iec/iec_set_idle.s similarity index 100% rename from c64/kernal/iec_set_idle.s rename to c64/kernal/iec/iec_set_idle.s diff --git a/c64/kernal/iec_turnaround_to_listen.s b/c64/kernal/iec/iec_turnaround_to_listen.s similarity index 100% rename from c64/kernal/iec_turnaround_to_listen.s rename to c64/kernal/iec/iec_turnaround_to_listen.s diff --git a/c64/kernal/iec_turnaround_to_talk.s b/c64/kernal/iec/iec_turnaround_to_talk.s similarity index 100% rename from c64/kernal/iec_turnaround_to_talk.s rename to c64/kernal/iec/iec_turnaround_to_talk.s diff --git a/c64/kernal/iec_tx_byte.s b/c64/kernal/iec/iec_tx_byte.s similarity index 100% rename from c64/kernal/iec_tx_byte.s rename to c64/kernal/iec/iec_tx_byte.s diff --git a/c64/kernal/iec_tx_command.s b/c64/kernal/iec/iec_tx_command.s similarity index 100% rename from c64/kernal/iec_tx_command.s rename to c64/kernal/iec/iec_tx_command.s diff --git a/c64/kernal/iec_tx_common.s b/c64/kernal/iec/iec_tx_common.s similarity index 100% rename from c64/kernal/iec_tx_common.s rename to c64/kernal/iec/iec_tx_common.s diff --git a/c64/kernal/iec_wait100us.s b/c64/kernal/iec/iec_wait100us.s similarity index 100% rename from c64/kernal/iec_wait100us.s rename to c64/kernal/iec/iec_wait100us.s diff --git a/c64/kernal/iec_wait20us.s b/c64/kernal/iec/iec_wait20us.s similarity index 100% rename from c64/kernal/iec_wait20us.s rename to c64/kernal/iec/iec_wait20us.s diff --git a/c64/kernal/iec_wait60us.s b/c64/kernal/iec/iec_wait60us.s similarity index 100% rename from c64/kernal/iec_wait60us.s rename to c64/kernal/iec/iec_wait60us.s diff --git a/c64/kernal/iec_wait_for_clk_release.s b/c64/kernal/iec/iec_wait_for_clk_release.s similarity index 100% rename from c64/kernal/iec_wait_for_clk_release.s rename to c64/kernal/iec/iec_wait_for_clk_release.s diff --git a/c64/kernal/iec_wait_for_data_pull.s b/c64/kernal/iec/iec_wait_for_data_pull.s similarity index 100% rename from c64/kernal/iec_wait_for_data_pull.s rename to c64/kernal/iec/iec_wait_for_data_pull.s diff --git a/c64/kernal/iec_wait_for_data_release.s b/c64/kernal/iec/iec_wait_for_data_release.s similarity index 100% rename from c64/kernal/iec_wait_for_data_release.s rename to c64/kernal/iec/iec_wait_for_data_release.s diff --git a/c64/kernal/ff81.jcint.s b/c64/kernal/jumptable/ff81.jcint.s similarity index 100% rename from c64/kernal/ff81.jcint.s rename to c64/kernal/jumptable/ff81.jcint.s diff --git a/c64/kernal/ff84.jioinit.s b/c64/kernal/jumptable/ff84.jioinit.s similarity index 100% rename from c64/kernal/ff84.jioinit.s rename to c64/kernal/jumptable/ff84.jioinit.s diff --git a/c64/kernal/ff87.jramtas.s b/c64/kernal/jumptable/ff87.jramtas.s similarity index 100% rename from c64/kernal/ff87.jramtas.s rename to c64/kernal/jumptable/ff87.jramtas.s diff --git a/c64/kernal/ff8a.jrestor.s b/c64/kernal/jumptable/ff8a.jrestor.s similarity index 100% rename from c64/kernal/ff8a.jrestor.s rename to c64/kernal/jumptable/ff8a.jrestor.s diff --git a/c64/kernal/ff8d.jvector.s b/c64/kernal/jumptable/ff8d.jvector.s similarity index 100% rename from c64/kernal/ff8d.jvector.s rename to c64/kernal/jumptable/ff8d.jvector.s diff --git a/c64/kernal/ff90.jsetmsg.s b/c64/kernal/jumptable/ff90.jsetmsg.s similarity index 100% rename from c64/kernal/ff90.jsetmsg.s rename to c64/kernal/jumptable/ff90.jsetmsg.s diff --git a/c64/kernal/ff93.jsecond.s b/c64/kernal/jumptable/ff93.jsecond.s similarity index 100% rename from c64/kernal/ff93.jsecond.s rename to c64/kernal/jumptable/ff93.jsecond.s diff --git a/c64/kernal/ff96.jtksa.s b/c64/kernal/jumptable/ff96.jtksa.s similarity index 100% rename from c64/kernal/ff96.jtksa.s rename to c64/kernal/jumptable/ff96.jtksa.s diff --git a/c64/kernal/ff99.jmemtop.s b/c64/kernal/jumptable/ff99.jmemtop.s similarity index 100% rename from c64/kernal/ff99.jmemtop.s rename to c64/kernal/jumptable/ff99.jmemtop.s diff --git a/c64/kernal/ff9c.jmembot.s b/c64/kernal/jumptable/ff9c.jmembot.s similarity index 100% rename from c64/kernal/ff9c.jmembot.s rename to c64/kernal/jumptable/ff9c.jmembot.s diff --git a/c64/kernal/ff9f.jscnkey.s b/c64/kernal/jumptable/ff9f.jscnkey.s similarity index 100% rename from c64/kernal/ff9f.jscnkey.s rename to c64/kernal/jumptable/ff9f.jscnkey.s diff --git a/c64/kernal/ffa2.jsettmo.s b/c64/kernal/jumptable/ffa2.jsettmo.s similarity index 100% rename from c64/kernal/ffa2.jsettmo.s rename to c64/kernal/jumptable/ffa2.jsettmo.s diff --git a/c64/kernal/ffa5.jacptr.s b/c64/kernal/jumptable/ffa5.jacptr.s similarity index 100% rename from c64/kernal/ffa5.jacptr.s rename to c64/kernal/jumptable/ffa5.jacptr.s diff --git a/c64/kernal/ffa8.jciout.s b/c64/kernal/jumptable/ffa8.jciout.s similarity index 100% rename from c64/kernal/ffa8.jciout.s rename to c64/kernal/jumptable/ffa8.jciout.s diff --git a/c64/kernal/ffab.juntlk.s b/c64/kernal/jumptable/ffab.juntlk.s similarity index 100% rename from c64/kernal/ffab.juntlk.s rename to c64/kernal/jumptable/ffab.juntlk.s diff --git a/c64/kernal/ffae.junlsn.s b/c64/kernal/jumptable/ffae.junlsn.s similarity index 100% rename from c64/kernal/ffae.junlsn.s rename to c64/kernal/jumptable/ffae.junlsn.s diff --git a/c64/kernal/ffb1.jlisten.s b/c64/kernal/jumptable/ffb1.jlisten.s similarity index 100% rename from c64/kernal/ffb1.jlisten.s rename to c64/kernal/jumptable/ffb1.jlisten.s diff --git a/c64/kernal/ffb4.jtalk.s b/c64/kernal/jumptable/ffb4.jtalk.s similarity index 100% rename from c64/kernal/ffb4.jtalk.s rename to c64/kernal/jumptable/ffb4.jtalk.s diff --git a/c64/kernal/ffb7.jreadst.s b/c64/kernal/jumptable/ffb7.jreadst.s similarity index 100% rename from c64/kernal/ffb7.jreadst.s rename to c64/kernal/jumptable/ffb7.jreadst.s diff --git a/c64/kernal/ffba.jsetfls.s b/c64/kernal/jumptable/ffba.jsetfls.s similarity index 100% rename from c64/kernal/ffba.jsetfls.s rename to c64/kernal/jumptable/ffba.jsetfls.s diff --git a/c64/kernal/ffbd.setnam.s b/c64/kernal/jumptable/ffbd.jsetnam.s similarity index 100% rename from c64/kernal/ffbd.setnam.s rename to c64/kernal/jumptable/ffbd.jsetnam.s diff --git a/c64/kernal/ffc0.jopen.s b/c64/kernal/jumptable/ffc0.jopen.s similarity index 100% rename from c64/kernal/ffc0.jopen.s rename to c64/kernal/jumptable/ffc0.jopen.s diff --git a/c64/kernal/ffc3.jclose.s b/c64/kernal/jumptable/ffc3.jclose.s similarity index 100% rename from c64/kernal/ffc3.jclose.s rename to c64/kernal/jumptable/ffc3.jclose.s diff --git a/c64/kernal/ffc6.jchkin.s b/c64/kernal/jumptable/ffc6.jchkin.s similarity index 100% rename from c64/kernal/ffc6.jchkin.s rename to c64/kernal/jumptable/ffc6.jchkin.s diff --git a/c64/kernal/ffc9.jchkout.s b/c64/kernal/jumptable/ffc9.jchkout.s similarity index 100% rename from c64/kernal/ffc9.jchkout.s rename to c64/kernal/jumptable/ffc9.jchkout.s diff --git a/c64/kernal/ffcc.jclrchn.s b/c64/kernal/jumptable/ffcc.jclrchn.s similarity index 100% rename from c64/kernal/ffcc.jclrchn.s rename to c64/kernal/jumptable/ffcc.jclrchn.s diff --git a/c64/kernal/ffcf.jchrin.s b/c64/kernal/jumptable/ffcf.jchrin.s similarity index 100% rename from c64/kernal/ffcf.jchrin.s rename to c64/kernal/jumptable/ffcf.jchrin.s diff --git a/c64/kernal/ffd2.jchrout.s b/c64/kernal/jumptable/ffd2.jchrout.s similarity index 100% rename from c64/kernal/ffd2.jchrout.s rename to c64/kernal/jumptable/ffd2.jchrout.s diff --git a/c64/kernal/ffd5.jload.s b/c64/kernal/jumptable/ffd5.jload.s similarity index 100% rename from c64/kernal/ffd5.jload.s rename to c64/kernal/jumptable/ffd5.jload.s diff --git a/c64/kernal/ffd8.jsave.s b/c64/kernal/jumptable/ffd8.jsave.s similarity index 100% rename from c64/kernal/ffd8.jsave.s rename to c64/kernal/jumptable/ffd8.jsave.s diff --git a/c64/kernal/ffdb.jsettim.s b/c64/kernal/jumptable/ffdb.jsettim.s similarity index 100% rename from c64/kernal/ffdb.jsettim.s rename to c64/kernal/jumptable/ffdb.jsettim.s diff --git a/c64/kernal/ffde.jrdtim.s b/c64/kernal/jumptable/ffde.jrdtim.s similarity index 100% rename from c64/kernal/ffde.jrdtim.s rename to c64/kernal/jumptable/ffde.jrdtim.s diff --git a/c64/kernal/ffe1.jstop.s b/c64/kernal/jumptable/ffe1.jstop.s similarity index 100% rename from c64/kernal/ffe1.jstop.s rename to c64/kernal/jumptable/ffe1.jstop.s diff --git a/c64/kernal/ffe4.jgetin.s b/c64/kernal/jumptable/ffe4.jgetin.s similarity index 100% rename from c64/kernal/ffe4.jgetin.s rename to c64/kernal/jumptable/ffe4.jgetin.s diff --git a/c64/kernal/ffe7.jclall.s b/c64/kernal/jumptable/ffe7.jclall.s similarity index 100% rename from c64/kernal/ffe7.jclall.s rename to c64/kernal/jumptable/ffe7.jclall.s diff --git a/c64/kernal/ffea.judtim.s b/c64/kernal/jumptable/ffea.judtim.s similarity index 100% rename from c64/kernal/ffea.judtim.s rename to c64/kernal/jumptable/ffea.judtim.s diff --git a/c64/kernal/ffed.jscreen.s b/c64/kernal/jumptable/ffed.jscreen.s similarity index 100% rename from c64/kernal/ffed.jscreen.s rename to c64/kernal/jumptable/ffed.jscreen.s diff --git a/c64/kernal/fff0.jplot.s b/c64/kernal/jumptable/fff0.jplot.s similarity index 100% rename from c64/kernal/fff0.jplot.s rename to c64/kernal/jumptable/fff0.jplot.s diff --git a/c64/kernal/fff3.jiobase.s b/c64/kernal/jumptable/fff3.jiobase.s similarity index 100% rename from c64/kernal/fff3.jiobase.s rename to c64/kernal/jumptable/fff3.jiobase.s diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 4a946263..9675f2df 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -36,7 +36,7 @@ load: jsr install_ram_routines ;; Allow platform-specific routine to takeover the flow - `PLATFORM_HOOK_LOAD + `TARGET_HOOK_LOAD ;; Check whether we support the requested device lda current_device_number From 273eb3ee6ae11c18d706bb672e51123cb65040d7 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 21 Jul 2019 18:07:03 +0200 Subject: [PATCH 63/90] work towards CHKIN, CHKOUT and CLRCHN --- STATUS.md | 8 +-- c64/kernal/chkin.s | 27 --------- c64/kernal/chkinout.s | 133 ++++++++++++++++++++++++++++++++++++++++++ c64/kernal/chkout.s | 25 -------- c64/kernal/clrchn.s | 23 ++++++++ c64/kernal/findfls.s | 5 +- c64/kernal/open.s | 86 ++++++--------------------- 7 files changed, 182 insertions(+), 125 deletions(-) delete mode 100644 c64/kernal/chkin.s create mode 100644 c64/kernal/chkinout.s delete mode 100644 c64/kernal/chkout.s diff --git a/STATUS.md b/STATUS.md index 281a9951..829bf221 100644 --- a/STATUS.md +++ b/STATUS.md @@ -88,11 +88,11 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on | $FFB7 | READST | DONE | | | $FFBA | SETFLS | DONE | | | $FFBD | SETNAM | DONE | | -| $FFC0 | OPEN | NOT DONE | * work in progress | +| $FFC0 | OPEN | DONE | | | $FFC3 | CLOSE | PARTIAL | * work in progress | -| $FFC6 | CHKIN | NOT DONE | * work in progress | -| $FFC9 | CHKOUT | NOT DONE | * work in progress | -| $FFCC | CLRCHN | NOT DONE | * work in progress | +| $FFC6 | CHKIN | PARTIAL | * work in progress | +| $FFC9 | CHKOUT | PARTIAL | * work in progress | +| $FFCC | CLRCHN | PARTIAL | * work in progress | | $FFCF | CHRIN | NOT DONE | * work in progress | | $FFD2 | CHROUT | NOT DONE | * work in progress | | $FFD5 | LOAD | PARTIAL | no VERIFY support yet | diff --git a/c64/kernal/chkin.s b/c64/kernal/chkin.s deleted file mode 100644 index f48b8b5e..00000000 --- a/c64/kernal/chkin.s +++ /dev/null @@ -1,27 +0,0 @@ - -;; -;; Official Kernal routine, described in: -;; -;; - [RG64] C64 Programmer's Reference Guide - page 275 -;; - [CM64] Compute's Mapping the Commodore 64 - page 229 -;; -;; CPU registers that has to be preserved (see [RG64]): .Y -;; - -chkin: - - ;; Implemented according to 'C64 Programmers Reference Guide', page 277 - - ;; First retrieve the FAT/LAT/SAT table index (and check if file is open) - - ; txa - ; jsr find_fls - ; bcs kernalerror_FILE_NOT_OPEN - - ;; Now we have table index in Y - check if file is open for reading - - ;; XXX continue implementation - - rts - - diff --git a/c64/kernal/chkinout.s b/c64/kernal/chkinout.s new file mode 100644 index 00000000..059d2409 --- /dev/null +++ b/c64/kernal/chkinout.s @@ -0,0 +1,133 @@ + +;; +;; Official Kernal routines, described in: +;; +;; - [RG64] C64 Programmer's Reference Guide - page 275 (CHKIN) / 276 (CHKOUT) +;; - [CM64] Compute's Mapping the Commodore 64 - page 229 +;; +;; CPU registers that has to be preserved (see [RG64]): .Y +;; + + +;; CHKIN implementation + +chkin: + + ;; Store Y for preservation + tya + pha + + ;; Reset status + jsr kernalstatus_reset + + ;; First retrieve the FAT/LAT/SAT table index (and check if file is open) + + txa + jsr find_fls + bcs chkinout_file_not_open + + ;; Now we have table index in Y - first filter out unsuitable devices + + lda FAT,Y + cmp #$01 + beq chkinout_device_not_present ; tape not implemented + cmp #$02 + beq chkinout_device_not_present ; RS-232 not implemented + + ;; Fail if the file is open for writing (secondary address 1) + + lda LAT, Y + cmp #$01 + beq chkinout_file_not_input + + ;; For IEC devices, send TALK first + lda FAT,Y + jsr iec_devnum_check + bcs chkin_set_device + + jsr talk + bcs chkinout_end ; don't set DFLTN in case of failure + +chkin_set_device: + lda FAT,Y + sta DFLTN + clc ; for success + ;; FALLTROUGH + +;; Common part for booth CHKIN and CHKOUT + +chkinout_end: + pla + tay + rts + +chkinout_file_not_open: + pla + tay + jmp kernalerror_FILE_NOT_OPEN + +chkinout_device_not_present: + pla + tay + jsr kernalstatus_DEVICE_NOT_FOUND + jmp kernalerror_DEVICE_NOT_FOUND + +chkinout_file_not_input: + pla + tay + jmp kernalerror_FILE_NOT_INPUT + +chkinout_file_not_output: + pla + tay + jmp kernalerror_FILE_NOT_OUTPUT + +chkinout_common: + +;; CHKOUT implementation + +chkout: + + ;; Store Y for preservation + tya + pha + + ;; Reset status + jsr kernalstatus_reset + + ;; First retrieve the FAT/LAT/SAT table index (and check if file is open) + + txa + jsr find_fls + bcs chkinout_file_not_open + + ;; Now we have table index in Y - first filter out unsuitable devices + + lda FAT,Y + cmp #$01 + beq chkinout_device_not_present ; tape not implemented + cmp #$02 + beq chkinout_device_not_present ; RS-232 not implemented + + cmp #$00 + beq chkinout_file_not_output ; cannot output to keyboard - XXX check real ROM behaviour + + ;; Fail if the file is open for reading (secondary address 0) + + lda LAT, Y + beq chkinout_file_not_output + + ;; For IEC devices, send LISTEN first + lda FAT,Y + jsr iec_devnum_check + bcs chkin_set_device + + jsr listen + bcs chkinout_end ; don't set DFLTO in case of failure + +chkout_set_device: + lda FAT,Y + sta DFLTO + clc ; for success + + jmp chkinout_end diff --git a/c64/kernal/chkout.s b/c64/kernal/chkout.s deleted file mode 100644 index 0f1f2e58..00000000 --- a/c64/kernal/chkout.s +++ /dev/null @@ -1,25 +0,0 @@ - -;; -;; Official Kernal routine, described in: -;; -;; - [RG64] C64 Programmer's Reference Guide - page 276 -;; - [CM64] Compute's Mapping the Commodore 64 - page 229 -;; -;; CPU registers that has to be preserved (see [RG64]): .Y -;; - -chkout: - - ;; Implemented according to 'C64 Programmers Reference Guide', page 278 - - ;; First retrieve the FAT/LAT/SAT table index (and check if file is open) - - ; txa - ; jsr find_fls - ; bcs kernalerror_FILE_NOT_OPEN - - ;; Now we have table index in Y - check if file is open for writing - - ;; XXX continue implementation - - rts diff --git a/c64/kernal/clrchn.s b/c64/kernal/clrchn.s index 8000116e..ce1452d0 100644 --- a/c64/kernal/clrchn.s +++ b/c64/kernal/clrchn.s @@ -9,4 +9,27 @@ ;; clrchn: + + ;; Restore input device to default + lda DFLTN + jsr iec_devnum_check + bcs + + ;; Previous device was IEC one - send UNTALK first + jsr untlk +* + ;; Set input device number to keyboard + lda #$00 + sta DFLTN + + ;; Restore output device to default + lda DFLTO + jsr iec_devnum_check + bcs + + ;; Previous device was IEC one - send UNLISTEN first + jsr unlsn +* + ;; Set output device number to screen + lda #$03 + sta DFLTO + rts diff --git a/c64/kernal/findfls.s b/c64/kernal/findfls.s index b0ad82a6..403139e0 100644 --- a/c64/kernal/findfls.s +++ b/c64/kernal/findfls.s @@ -1,5 +1,5 @@ -;; Just a helper routine +;; Just a helper routines ;; Find the LAT / SAT / FAT entry index where LAT corresponds to A, returns index in Y ;; Carry flag set means not found @@ -13,7 +13,7 @@ find_fls: bmi find_fls_not_found ; no more entries cmp LAT, y bne - ; does not match, try the next one - + clc rts @@ -21,3 +21,4 @@ find_fls_not_found: sec rts + diff --git a/c64/kernal/open.s b/c64/kernal/open.s index 6ae6ac7e..507d63e9 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -8,13 +8,23 @@ ;; CPU registers that has to be preserved (see [RG64]): none ;; -;; XXX this is only a test implementation, does not do what the Kernal does! open: - ;; LAT / FAT / SAT support implemented according to - ;; 'Compute's Mapping the Commodore 64', page 52 + ;; Reset status + jsr kernalstatus_reset + ;; Check if the logical file number is unique + ldy LDTND +* + beq + + dey + lda LAT, y + cmp current_logical_filenum + beq kernalerror_FILE_ALREADY_OPEN + cpy #$00 + jmp - +* ;; Check if we have space in tables ldy LDTND @@ -22,15 +32,16 @@ open: bcs + bmi open_has_space * - ;; Table is full - according to https://codebase64.org/doku.php?id=base:kernalreference - ;; C flag set means error occured - sec - rts + ;; Table is full + jmp kernalerror_TOO_MANY_OPEN_FILES open_has_space: ;; Update the tables + ;; LAT / FAT / SAT support implemented according to + ;; 'Compute's Mapping the Commodore 64', page 52 + lda current_logical_filenum sta LAT, y lda current_device_number @@ -40,66 +51,7 @@ open_has_space: iny sty LDTND - - ;; Kernal API is shared between several types of devices - we have - ;; to dispatch the call to appropriate subroutine - - lda current_device_number - beq open_keyboard - cmp #$01 - beq open_tape - cmp #$02 - beq open_rs232 - cmp #$03 - beq open_screen - cmp #$1F - bcs + - bmi open_iec -* - ;; Device numbers over 30 are not allowed on IEC bus - - ;; FALLTHROUGH to error routine - -open_keyboard: -open_tape: -open_screen: - - ;; XXX implement support for these devices - lda #$05 ; device not present - sta IOSTATUS - rts -open_rs232: - - ;; XXX implement support for RS-232 - lda #$FF ; set every single error bit to discourage using RS-232 - sta RSSTAT - rts - -open_iec: - - ;; Part implemented according to https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc - ;; XXX note: this is only a temporary test implementation, real 'open' does not send anything to IEC, - ;; see http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf - - ;; Request device to talk - lda current_device_number - jsr talk - bcs open_iec_error - - ;; Send secondary address - lda current_secondary_address - jsr second - bcs open_iec_error - - ;; Turnaround - jsr iec_turnaround_to_listen - bcs open_iec_error - - ;; Indicate success - lda #$00 clc - -open_iec_error: - ;; Carry flag will be set by low-level routines rts + From 4a12719986fbc6704ad9e2dbfd4ad8b3e92a7795 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 22 Jul 2019 19:16:41 +0200 Subject: [PATCH 64/90] improved initialization and Kernal vector handling --- c64/basic/cmd_load.s | 2 +- c64/basic/via_vector.s | 40 +++++++++++++++++++++++++++++++ c64/basic/wedge_dos.s | 54 ++++++++++++++++++++++++------------------ c64/kernal/cint.s | 3 +++ c64/kernal/clrchn.s | 12 +++++----- 5 files changed, 81 insertions(+), 30 deletions(-) create mode 100644 c64/basic/via_vector.s diff --git a/c64/basic/cmd_load.s b/c64/basic/cmd_load.s index 2931b607..dc900c54 100644 --- a/c64/basic/cmd_load.s +++ b/c64/basic/cmd_load.s @@ -98,7 +98,7 @@ got_secondaryaddress: got_loadaddress: lda #$00 ; LOAD not verify - jsr JLOAD + jsr via_ILOAD bcc + ;; A = KERNAL error code, which also almost match diff --git a/c64/basic/via_vector.s b/c64/basic/via_vector.s new file mode 100644 index 00000000..d17e36a5 --- /dev/null +++ b/c64/basic/via_vector.s @@ -0,0 +1,40 @@ + +;; +;; Helper routines for jumping via vectors, to be used with JSR +;; + +via_IOPEN: + jmp (IOPEN) + +via_ICLOSE: + jmp (ICLOSE) + +via_ICHKIN: + jmp (ICHKIN) + +via_ICKOUT: + jmp (ICKOUT) + +via_ICLRCH: + jmp (ICLRCH) + +via_IBASIN: + jmp (IBASIN) + +via_IBASOUT: + jmp (IBASOUT) + +via_ISTOP: + jmp (ISTOP) + +via_IGETIN: + jmp (IGETIN) + +via_ICLALL: + jmp (ICLALL) + +via_ILOAD: + jmp (ILOAD) + +via_ISAVE: + jmp (ISAVE) diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index da0d3788..1c7726ec 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -4,7 +4,7 @@ wedge_dos: ;; Close all the channels, so that wedge has full control - jsr wedge_dos_CLALL + jsr via_ICLALL ;; Set file parameters, channel 15 is a typical one for commands jsr select_device ; sets X register @@ -39,12 +39,31 @@ wedge_dos: ;; XXX consider SYNTAX ERROR if anything besides spaces is there jmp - -wedge_dos_command: ; default +wedge_dos_command: - ;; XXX - implement this - jsr printf - .byte "DBG: CMD", 0 - jmp do_NOT_IMPLEMENTED_error + ;; Set remaining file parameters, open the channel + lda #$00 ; empty file name + jsr JSETNAM + jsr via_IOPEN + bcc + + jmp do_DEVICE_NOT_PRESENT_error +* + ;; Set channel for output + ldx #$0F + jsr via_ICKOUT +* + jsr JREADST ; retrieve errors + ;; XXX error in case of status != 0 +* + jsr basic_fetch_and_consume_character + beq + + jsr JCHROUT + ;; XXX check errors here + jmp - +* + ;; XXX check status - print it if not OK + ;; Clean-up and exit + jmp wedge_dos_clean_exit wedge_dos_change_drive: @@ -71,15 +90,16 @@ wedge_dos_status: ;; Set remaining file parameters, open the channel lda #$00 ; empty file name jsr JSETNAM - jsr wedge_dos_OPEN + jsr via_IOPEN bcc + jmp do_DEVICE_NOT_PRESENT_error * ;; Set channel for input ldx #$0F - jsr wedge_dos_CHKIN + jsr via_ICHKIN * - jsr $FFB7 ; READST - to retrieve errors + jsr JREADST ; retrieve errors + ;; XXX error in case of status != 0 * ;; Print out everything retrieved from the drive bne + @@ -97,21 +117,9 @@ wedge_dos_directory: .byte "DBG: DIR", 0 jmp do_NOT_IMPLEMENTED_error -wedge_dos_CLALL: - jmp (ICLALL) - -wedge_dos_CHKIN: - jmp (ICHKIN) - -wedge_dos_CLRCHR: - jmp (ICLRCH) - -wedge_dos_OPEN: - jmp (IOPEN) - wedge_dos_clean_exit: - jsr wedge_dos_CLALL - jsr wedge_dos_CLRCHR + jsr via_ICLALL + jsr via_ICLRCH jmp basic_end_of_line ;; END wedge support diff --git a/c64/kernal/cint.s b/c64/kernal/cint.s index 7dd92f46..973def0d 100644 --- a/c64/kernal/cint.s +++ b/c64/kernal/cint.s @@ -43,6 +43,9 @@ cint: ;; Put non-zero value in enable_case_switch stx enable_case_switch + ;; Set default I/O devices (see SCINIT description at http://sta.c64.org/cbm64krnfunc.html) + jsr clrchn_reset + ;; Fallthrough/jump to screen clear routine (Compute's Mapping the 64 p215) jmp clear_screen diff --git a/c64/kernal/clrchn.s b/c64/kernal/clrchn.s index ce1452d0..d0cd0243 100644 --- a/c64/kernal/clrchn.s +++ b/c64/kernal/clrchn.s @@ -10,24 +10,24 @@ clrchn: - ;; Restore input device to default + ;; Handle IEC input device lda DFLTN jsr iec_devnum_check bcs + ;; Previous device was IEC one - send UNTALK first jsr untlk * - ;; Set input device number to keyboard - lda #$00 - sta DFLTN - ;; Restore output device to default lda DFLTO jsr iec_devnum_check bcs + - ;; Previous device was IEC one - send UNLISTEN first + ;; Handle IEC output device jsr unlsn * +clrchn_reset: + ;; Set input device number to keyboard + lda #$00 + sta DFLTN ;; Set output device number to screen lda #$03 sta DFLTO From 1bb195a9c4f5faa62c9ad762753a58334e8c5b8c Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 22 Jul 2019 19:24:21 +0200 Subject: [PATCH 65/90] CHKIN / CKOUT now send secondary addresses --- c64/aliases/,aliases_rom_kernal.s | 2 +- c64/kernal/chkinout.s | 25 +++++++++++++------ .../{ffc9.jchkout.s => ffc9.jckout.s} | 2 +- c64/kernal/vector.s | 2 +- 4 files changed, 21 insertions(+), 10 deletions(-) rename c64/kernal/jumptable/{ffc9.jchkout.s => ffc9.jckout.s} (85%) diff --git a/c64/aliases/,aliases_rom_kernal.s b/c64/aliases/,aliases_rom_kernal.s index bb2bd4e4..91c601d9 100644 --- a/c64/aliases/,aliases_rom_kernal.s +++ b/c64/aliases/,aliases_rom_kernal.s @@ -24,7 +24,7 @@ .alias JOPEN $FFC0 .alias JCLOSE $FFC3 .alias JCHKIN $FFC6 - .alias JCHKOUT $FFC9 + .alias JCKOUT $FFC9 .alias JCLRCHN $FFCC .alias JCHRIN $FFCF .alias JCHROUT $FFD2 diff --git a/c64/kernal/chkinout.s b/c64/kernal/chkinout.s index 059d2409..d384b975 100644 --- a/c64/kernal/chkinout.s +++ b/c64/kernal/chkinout.s @@ -2,7 +2,7 @@ ;; ;; Official Kernal routines, described in: ;; -;; - [RG64] C64 Programmer's Reference Guide - page 275 (CHKIN) / 276 (CHKOUT) +;; - [RG64] C64 Programmer's Reference Guide - page 275 (CHKIN) / 276 (CKOUT) ;; - [CM64] Compute's Mapping the Commodore 64 - page 229 ;; ;; CPU registers that has to be preserved (see [RG64]): .Y @@ -40,7 +40,7 @@ chkin: cmp #$01 beq chkinout_file_not_input - ;; For IEC devices, send TALK first + ;; For IEC devices, send TALK + TKSA first lda FAT,Y jsr iec_devnum_check bcs chkin_set_device @@ -48,13 +48,20 @@ chkin: jsr talk bcs chkinout_end ; don't set DFLTN in case of failure + lda LAT, Y + jsr tksa + bcs chkinout_end + + jsr iec_turnaround_to_listen ;; XXX shouldn't this be sent by TALK/TKSA??? + bcs chkinout_end + chkin_set_device: lda FAT,Y sta DFLTN clc ; for success ;; FALLTROUGH -;; Common part for booth CHKIN and CHKOUT +;; Common part for booth CHKIN and CKOUT chkinout_end: pla @@ -84,9 +91,9 @@ chkinout_file_not_output: chkinout_common: -;; CHKOUT implementation +;; CKOUT implementation -chkout: +ckout: ;; Store Y for preservation tya @@ -117,7 +124,7 @@ chkout: lda LAT, Y beq chkinout_file_not_output - ;; For IEC devices, send LISTEN first + ;; For IEC devices, send LISTEN + SECOND first lda FAT,Y jsr iec_devnum_check bcs chkin_set_device @@ -125,7 +132,11 @@ chkout: jsr listen bcs chkinout_end ; don't set DFLTO in case of failure -chkout_set_device: + lda LAT, Y + jsr second + bcs chkinout_end + +hkout_set_device: lda FAT,Y sta DFLTO clc ; for success diff --git a/c64/kernal/jumptable/ffc9.jchkout.s b/c64/kernal/jumptable/ffc9.jckout.s similarity index 85% rename from c64/kernal/jumptable/ffc9.jchkout.s rename to c64/kernal/jumptable/ffc9.jckout.s index 1b76a8dc..ccfe9a2f 100644 --- a/c64/kernal/jumptable/ffc9.jchkout.s +++ b/c64/kernal/jumptable/ffc9.jckout.s @@ -1,3 +1,3 @@ ; Open channel for output ; C64 Programmer's Reference Guide Page 272 - jmp chkout + jmp ckout diff --git a/c64/kernal/vector.s b/c64/kernal/vector.s index 4a086198..c0ad2d58 100644 --- a/c64/kernal/vector.s +++ b/c64/kernal/vector.s @@ -76,7 +76,7 @@ vector_defaults: .word open ;; IOPEN .word close ;; ICLOSE .word chkin ;; ICHKIN - .word chkout ;; ICKOUT + .word ckout ;; ICKOUT .word clrchn ;; ICLRCH .word chrin ;; IBASIN .word chrout ;; IBASOUT From 4980dff3bf91cfa2c95035d7d3946145d4eaa655 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 22 Jul 2019 19:45:38 +0200 Subject: [PATCH 66/90] added IEC support to CHRIN and CHROUT --- c64/kernal/chrin.s | 31 +++++++++++++++++++++++++++++-- c64/kernal/chrout.s | 38 +++++++++++++++++++++++++++++++++++--- c64/kernal/clrchn.s | 3 ++- 3 files changed, 66 insertions(+), 6 deletions(-) diff --git a/c64/kernal/chrin.s b/c64/kernal/chrin.s index 4121bdc4..8bd4850b 100644 --- a/c64/kernal/chrin.s +++ b/c64/kernal/chrin.s @@ -10,15 +10,42 @@ ;; XXX currently does not preserve register Y, to be fixed! - ;; Reads a byte of input, unless from keyboard. + ;; Reads a byte of input, unless from keyboard. ;; If from keyboard, then it gets a whole line of input, and returns the first char. ;; Repeated calls after that read out the successive bytes of the line of input. + chrin: + ;; First determine the device number + lda DFLTN + + beq chrin_keyboard ; #$00 - keyboard + ;; XXX add screen support + + jsr iec_devnum_check + bcs chrin_done_fail ; not a supported device + +chrin_iec: + + jsr JACPTR + bcs chrin_done_fail + ;; FALLTROUGH + +chrin_done: + clc ; indicate success + rts + +chrin_done_fail: + sec ; indicate failure + rts + +chrin_keyboard: + ;; Save X txa pha -chrin_repeat: +chrin_repeat: + ;; Do we have a line of input we are currently returning? ;; If so, return the next byte, and clear the flag when we reach the end. diff --git a/c64/kernal/chrout.s b/c64/kernal/chrout.s index 926a9391..b7266a66 100644 --- a/c64/kernal/chrout.s +++ b/c64/kernal/chrout.s @@ -10,7 +10,6 @@ chrout: - ;; Crude implementation of character output ;; Save X and Y values ;; (Confirmed by writing a test program that X and Y @@ -22,7 +21,27 @@ chrout: tya pha php - sei + + ;; First determine the device number + lda DFLTO + + cmp #$03 ; screen + beq chrout_screen + + jsr iec_devnum_check + bcs chrout_done_fail ; not a supported device + +chrout_iec: + + lda last_printed_character_ascii + jsr JCIOUT + bcs chrout_done_fail + jmp chrout_done + +chrout_screen: + + ;; Crude implementation of character output + sei ;; XXX why do we need to disable interrupts? jsr hide_cursor_if_visible @@ -392,7 +411,20 @@ chrout_done: pla tax lda last_printed_character_ascii - clc ; indicate success + clc ; indicate success + rts + +chrout_done_fail: + jsr show_cursor_if_enabled + + plp + + ;; Restore X and Y, set carry to mark success on exit + pla + tay + pla + tax + sec ; indicate failure rts screen_grow_logical_line: diff --git a/c64/kernal/clrchn.s b/c64/kernal/clrchn.s index d0cd0243..22b4c9e0 100644 --- a/c64/kernal/clrchn.s +++ b/c64/kernal/clrchn.s @@ -8,6 +8,7 @@ ;; CPU registers that has to be preserved (see [RG64]): .Y ;; + clrchn: ;; Handle IEC input device @@ -24,7 +25,7 @@ clrchn: ;; Handle IEC output device jsr unlsn * -clrchn_reset: +clrchn_reset: ;; entry needed by CHRIN ;; Set input device number to keyboard lda #$00 sta DFLTN From 15021939ceb067fbeedd18c328a04375fb24b607 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 22 Jul 2019 22:25:53 +0200 Subject: [PATCH 67/90] fixed 1ms wait --- c64/kernal/iec/iec_tx_command.s | 4 ++-- c64/kernal/iec/iec_wait1ms.s | 20 ++++++++++++++++++++ c64/kernal/wait1ms.s | 14 -------------- 3 files changed, 22 insertions(+), 16 deletions(-) create mode 100644 c64/kernal/iec/iec_wait1ms.s delete mode 100644 c64/kernal/wait1ms.s diff --git a/c64/kernal/iec/iec_tx_command.s b/c64/kernal/iec/iec_tx_command.s index f785d736..153d0f6e 100644 --- a/c64/kernal/iec/iec_tx_command.s +++ b/c64/kernal/iec/iec_tx_command.s @@ -18,7 +18,7 @@ iec_tx_command: jsr iec_pull_atn_clk_release_data ;; Give devices time to respond (response is mandatory!) - jsr wait1ms + jsr iec_wait1ms ;; Did at least one device respond by pulling DATA? lda CIA2_PRA @@ -44,7 +44,7 @@ iec_tx_command: ;; According to https://www.pagetable.com/?p=1135 there is some complicated and dangerous ;; flow here, but http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf (page 6) ;; advices to just wait 1ms and check the DATA status - jsr wait1ms + jsr iec_wait1ms lda CIA2_PRA and #BIT_CIA2_PRA_DAT_IN ; XXX try to optimize this, move to separate routine beq + diff --git a/c64/kernal/iec/iec_wait1ms.s b/c64/kernal/iec/iec_wait1ms.s new file mode 100644 index 00000000..a492df7f --- /dev/null +++ b/c64/kernal/iec/iec_wait1ms.s @@ -0,0 +1,20 @@ + +;; +;; Wait 1 ms (1000 usec) +;; +;; On NTSC this means 1023 cycles (slightly less on PAL, but we have to be sure). +;; We can't count on badlines, as the screen might be disabled. +;; Delay here is implemeented using VIC-II raster register. Since one raster is +;; 63 cycles, we need at least 17 full rasters to be 100% sure we wait enough + + +iec_wait1ms: + ldx #18 ; we probably won't start with the beginning of raster + lda VIC_RASTER +* + cmp VIC_RASTER + beq - + lda VIC_RASTER + dex + bne - + rts diff --git a/c64/kernal/wait1ms.s b/c64/kernal/wait1ms.s deleted file mode 100644 index c2a24d44..00000000 --- a/c64/kernal/wait1ms.s +++ /dev/null @@ -1,14 +0,0 @@ - ;; 16 rasters = 16 x 63 cycles = ~1ms - ;; (Probably 2 will be bad lines, so we will over-estimate the delay a bit) - -wait1ms: - ldx #16 - lda $d012 -* - cmp $d012 - beq - - lda $d012 - dex - bne - - rts - From f4db0f31c656c6c05b5aca1d4304b76a30ebd368 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Tue, 23 Jul 2019 17:12:30 +0200 Subject: [PATCH 68/90] various character handling fixes --- STATUS.md | 6 +++--- c64/aliases/,aliases_ram_lowmem.s | 2 +- c64/basic/ab1e.print_string.s | 2 +- c64/basic/basic_cold_start.s | 2 +- c64/basic/basic_do_error.s | 10 +++++----- c64/basic/basic_main_loop.s | 2 +- c64/basic/cmd_break.s | 2 +- c64/basic/cmd_list.s | 8 ++++---- c64/basic/print_integer.s | 2 +- c64/basic/print_packed_message.s | 10 +++++----- c64/basic/printf.s | 6 +++--- c64/basic/via_vector.s | 4 ++-- c64/basic/wedge_dos.s | 12 ++++++++---- c64/kernal/acptr.s | 7 ++++++- c64/kernal/vector.s | 2 +- 15 files changed, 43 insertions(+), 34 deletions(-) diff --git a/STATUS.md b/STATUS.md index 829bf221..74180053 100644 --- a/STATUS.md +++ b/STATUS.md @@ -79,7 +79,7 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on | $FF9C | MEMBOT | DONE | | | $FF9F | SCNKEY | DONE | could be better integrated with ROM | | $FFA2 | SETTMO | NOT DONE | | -| $FFA5 | ACPTR | NOT DONE | * work in progress | +| $FFA5 | ACPTR | PARTIAL | * work in progress | | $FFA8 | CIOUT | DONE | | | $FFAB | UNTLK | PARITAL | * work in progress | | $FFAE | UNLSN | DONE | | @@ -93,8 +93,8 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on | $FFC6 | CHKIN | PARTIAL | * work in progress | | $FFC9 | CHKOUT | PARTIAL | * work in progress | | $FFCC | CLRCHN | PARTIAL | * work in progress | -| $FFCF | CHRIN | NOT DONE | * work in progress | -| $FFD2 | CHROUT | NOT DONE | * work in progress | +| $FFCF | CHRIN | PARTIAL | | +| $FFD2 | CHROUT | PARTIAL | | | $FFD5 | LOAD | PARTIAL | no VERIFY support yet | | $FFD8 | SAVE | NOT DONE | * work in progress | | $FFDB | SETTIM | NOT DONE | | diff --git a/c64/aliases/,aliases_ram_lowmem.s b/c64/aliases/,aliases_ram_lowmem.s index 60c67bb4..c0a88d1d 100644 --- a/c64/aliases/,aliases_ram_lowmem.s +++ b/c64/aliases/,aliases_ram_lowmem.s @@ -81,7 +81,7 @@ .alias ICKOUT $320 .alias ICLRCH $322 .alias IBASIN $324 - .alias IBASOUT $326 + .alias IBSOUT $326 .alias ISTOP $328 .alias IGETIN $32A .alias ICLALL $32C diff --git a/c64/basic/ab1e.print_string.s b/c64/basic/ab1e.print_string.s index 0ea252a3..83f8d366 100644 --- a/c64/basic/ab1e.print_string.s +++ b/c64/basic/ab1e.print_string.s @@ -20,7 +20,7 @@ print_string_loop: lda (temp_string_ptr),y beq print_string_end - jsr JCHROUT + jsr via_IBSOUT txa tay diff --git a/c64/basic/basic_cold_start.s b/c64/basic/basic_cold_start.s index 341e0909..325bd1ed 100644 --- a/c64/basic/basic_cold_start.s +++ b/c64/basic/basic_cold_start.s @@ -29,7 +29,7 @@ startup_banner: jsr print_integer lda #$20 - jsr JCHROUT + jsr via_IBSOUT ;; Print the rest of the start up message ldx #34 diff --git a/c64/basic/basic_do_error.s b/c64/basic/basic_do_error.s index 731f99c2..92d7e46d 100644 --- a/c64/basic/basic_do_error.s +++ b/c64/basic/basic_do_error.s @@ -7,9 +7,9 @@ basic_do_error: ;; Print ? at start lda #$0d - jsr JCHROUT + jsr via_IBSOUT lda #$3f - jsr JCHROUT + jsr via_IBSOUT ;; Print main part of error message pla @@ -18,7 +18,7 @@ basic_do_error: ;; Print ERROR at end lda #$20 - jsr JCHROUT + jsr via_IBSOUT ldx #33 jsr print_packed_message @@ -27,9 +27,9 @@ basic_do_error: ;; XXX print line number if not in direct mode lda #$0d - jsr JCHROUT + jsr via_IBSOUT lda #$0d - jsr JCHROUT + jsr via_IBSOUT ;; Reset stack, and go back to main loop ldx #$fe diff --git a/c64/basic/basic_main_loop.s b/c64/basic/basic_main_loop.s index 69e12c9d..2d7afdd6 100644 --- a/c64/basic/basic_main_loop.s +++ b/c64/basic/basic_main_loop.s @@ -52,7 +52,7 @@ rsl_l1: lda $0200,x * ;; Do printing of the new line lda #$0d - jsr JCHROUT + jsr via_IBSOUT ;; Ignore empty lines lda tokenise_work1 diff --git a/c64/basic/cmd_break.s b/c64/basic/cmd_break.s index 36128422..31194132 100644 --- a/c64/basic/cmd_break.s +++ b/c64/basic/cmd_break.s @@ -17,7 +17,7 @@ basic_do_break: * lda #$0d - jsr JCHROUT + jsr via_IBSOUT cmd_end: jmp basic_main_loop diff --git a/c64/basic/cmd_list.s b/c64/basic/cmd_list.s index d58af209..13038f54 100644 --- a/c64/basic/cmd_list.s +++ b/c64/basic/cmd_list.s @@ -36,7 +36,7 @@ list_more_lines: pla jsr print_integer lda #$20 - jsr JCHROUT + jsr via_IBSOUT ;; Iterate through printing out the line ;; contents @@ -105,17 +105,17 @@ list_not_rem: bne list_print_loop list_is_literal: - jsr JCHROUT + jsr via_IBSOUT iny bne list_print_loop list_end_of_line: ;; Clear reverse flag lda #$92 - jsr JCHROUT + jsr via_IBSOUT ;; Print end of line lda #$0d - jsr JCHROUT + jsr via_IBSOUT ;; Now link to the next line jsr basic_find_next_line diff --git a/c64/basic/print_integer.s b/c64/basic/print_integer.s index f5d93fa7..7e897243 100644 --- a/c64/basic/print_integer.s +++ b/c64/basic/print_integer.s @@ -115,7 +115,7 @@ found_start_of_number: ;; Print digits * lda $0100,y ora #$30 - jsr JCHROUT + jsr via_IBSOUT iny cpy #5 bne - diff --git a/c64/basic/print_packed_message.s b/c64/basic/print_packed_message.s index 006bf70e..7aac0876 100644 --- a/c64/basic/print_packed_message.s +++ b/c64/basic/print_packed_message.s @@ -38,7 +38,7 @@ found_message_in_token_stream: beq + jsr print_packed_word lda #$20 - jsr JCHROUT + jsr via_IBSOUT pla tay iny @@ -47,7 +47,7 @@ found_message_in_token_stream: pla ;; Rub out space at the end lda #$14 - jsr JCHROUT + jsr via_IBSOUT rts print_packed_word: @@ -144,7 +144,7 @@ next_packed_word_char: ;; X=1-14 = first 14 chars, so subtract one lda packed_message_chars-1,x - jsr JCHROUT + jsr via_IBSOUT ;; See if there is a char in the low nybl to print pla @@ -171,7 +171,7 @@ has_nybl: ;; X=1-14 = first 14 chars, so subtract one lda packed_message_chars-1,x - jsr JCHROUT + jsr via_IBSOUT * pla tay @@ -207,7 +207,7 @@ unpack_literal_char: tya pha lda (temp_string_ptr),y - jsr JCHROUT + jsr via_IBSOUT pla tay rts diff --git a/c64/basic/printf.s b/c64/basic/printf.s index ceb4337b..85fa0cf8 100644 --- a/c64/basic/printf.s +++ b/c64/basic/printf.s @@ -112,7 +112,7 @@ not_hexword: not_pointer: ;; Print character - jsr JCHROUT + jsr via_IBSOUT printf_nextchar: jsr printf_advance @@ -148,11 +148,11 @@ printf_printhexbyte: cmp #$3A bcc + adc #6 -* jsr JCHROUT +* jsr via_IBSOUT pla and #$0f ora #$30 cmp #$3A bcc + adc #6 -* jmp JCHROUT +* jmp via_IBSOUT diff --git a/c64/basic/via_vector.s b/c64/basic/via_vector.s index d17e36a5..e6a0be1a 100644 --- a/c64/basic/via_vector.s +++ b/c64/basic/via_vector.s @@ -21,8 +21,8 @@ via_ICLRCH: via_IBASIN: jmp (IBASIN) -via_IBASOUT: - jmp (IBASOUT) +via_IBSOUT: + jmp (IBSOUT) via_ISTOP: jmp (ISTOP) diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 1c7726ec..172c50e1 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -55,9 +55,10 @@ wedge_dos_command: jsr JREADST ; retrieve errors ;; XXX error in case of status != 0 * + ;; XXX this loop does not seem to work, check it jsr basic_fetch_and_consume_character beq + - jsr JCHROUT + jsr via_IBSOUT ;; XXX check errors here jmp - * @@ -100,13 +101,16 @@ wedge_dos_status: * jsr JREADST ; retrieve errors ;; XXX error in case of status != 0 -* ;; Print out everything retrieved from the drive bne + - jsr JCHRIN - jsr JCHROUT + jsr via_IBASIN + jsr via_IBSOUT jmp - * + ;; Print new line + lda #$0D + jsr via_IBSOUT + ;; Clean-up and exit jmp wedge_dos_clean_exit diff --git a/c64/kernal/acptr.s b/c64/kernal/acptr.s index b6fd88be..028233c2 100644 --- a/c64/kernal/acptr.s +++ b/c64/kernal/acptr.s @@ -8,5 +8,10 @@ ;; CPU registers that has to be preserved (see [RG64]): .Y ;; +;; XXX preserve register Y! + acptr: - rts + ;; XXX temporary implementation + jsr kernalstatus_reset + jmp iec_rx_byte + diff --git a/c64/kernal/vector.s b/c64/kernal/vector.s index c0ad2d58..5fb49426 100644 --- a/c64/kernal/vector.s +++ b/c64/kernal/vector.s @@ -79,7 +79,7 @@ vector_defaults: .word ckout ;; ICKOUT .word clrchn ;; ICLRCH .word chrin ;; IBASIN - .word chrout ;; IBASOUT + .word chrout ;; IBSOUT .word stop ;; ISTOP .word getin ;; IGETIN .word clall ;; ICLALL From 44db729d5cbf7578cb0d2d7bdc7d4651886d9f13 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Tue, 23 Jul 2019 20:56:28 +0200 Subject: [PATCH 69/90] fixed incorrect byte comparing --- c64/basic/select_device.s | 11 +++++++---- c64/kernal/iec/iec_devnum_check.s | 12 +++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/c64/basic/select_device.s b/c64/basic/select_device.s index 48061f8a..f5939033 100644 --- a/c64/basic/select_device.s +++ b/c64/basic/select_device.s @@ -1,15 +1,18 @@ select_device: - ;; Take last device number, make sure it's a drive - ;; If not, set to 8 (first drive number) + ;; Take last device number, make sure it's a drive - 8 or above. Above 30, + ;; although illegal for IEC we also consider a drive, as they exists + ;; drivers assigning these numbers to CBM-DOS capable devices - like some + ;; IEEE-488 carts. + ;; + ;; If current device is not a drive, set device to 8 (first drive number) ;; Device number is left in X, for SETFLS Kernal routine ;; Note: if tape support is introduced here, make sure DOS wedge won't get broken ldx current_device_number - cpx #$07 - bpl + + cpx #$08 bcs + ldx #$08 * diff --git a/c64/kernal/iec/iec_devnum_check.s b/c64/kernal/iec/iec_devnum_check.s index 8fffb64e..84cd506b 100644 --- a/c64/kernal/iec/iec_devnum_check.s +++ b/c64/kernal/iec/iec_devnum_check.s @@ -7,18 +7,16 @@ iec_devnum_check: ;; 0, 1, 2, or 3 are illegal - reserved for non-IEC devices on Commodore - cmp #$03 - bpl + + cmp #$04 bcs + ;; FALLTROUGH iec_devnum_check_failed: - sec + sec ; indicate non-IEC device rts * - ;; 30 and above are illegal too, due to IEC command encoding scheme, + ;; 31 and above are illegal too, due to IEC command encoding scheme, ;; see https://www.pagetable.com/?p=1031 - cmp #$1E - bpl iec_devnum_check_failed + cmp #$1F bcs iec_devnum_check_failed - clc + ;; Carry is clear here - indicates IEC device rts From c909f323cecbb3fd3acadffcd91656eeed319441 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Tue, 23 Jul 2019 21:16:03 +0200 Subject: [PATCH 70/90] updated documentation and pre-built binaries --- STATUS.md | 2 +- bin/basic_generic.rom | Bin 8192 -> 8192 bytes bin/basic_mega65.rom | Bin 8192 -> 8192 bytes bin/basic_ultimate64.rom | Bin 8192 -> 8192 bytes bin/kernal_generic.rom | Bin 8192 -> 8192 bytes bin/kernal_mega65.rom | Bin 8192 -> 8192 bytes bin/kernal_ultimate64.rom | Bin 8192 -> 8192 bytes c64/kernal/open.s | 1 + 8 files changed, 2 insertions(+), 1 deletion(-) diff --git a/STATUS.md b/STATUS.md index 74180053..1173fed9 100644 --- a/STATUS.md +++ b/STATUS.md @@ -88,7 +88,7 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on | $FFB7 | READST | DONE | | | $FFBA | SETFLS | DONE | | | $FFBD | SETNAM | DONE | | -| $FFC0 | OPEN | DONE | | +| $FFC0 | OPEN | PARTIAL | * work in progress | | $FFC3 | CLOSE | PARTIAL | * work in progress | | $FFC6 | CHKIN | PARTIAL | * work in progress | | $FFC9 | CHKOUT | PARTIAL | * work in progress |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ztkbe1uU^_IcgHTqobfXYgRzKGu2d@+HgWHm%AT@R81fUrk^IGh5sL}WW!RRn=5eq+ z2|AP91>y-%lwjL)Kx6zKHw`(TTb@&bzrBA2BpJO!f3v^glJ<$#2wb+LCy!kIDf-`zMWVHd|rwnkKk^`&PI z9jHEf;DzTf*nVF#z}l+)+7{`c`cQ2RD8jgLa3{fyp#=pBy>9XZcC_gHSld`&cZ<$3 zJ0@n#j!RE-zLHAm7ZjY-s4v$3kH}lWja5*mf+JelHkH2%qFa-w8PrGbSkE{~@i{IE zxRY>W655lfybQiT#QA&|H4x4|s5|s+0;on*0lbnBaB&kr`-diQZ4E;f4VHYHN^<(r zFtf5I|LI>zv$Z;q-+=^seBB;4WPZ8v6{!{T2E1pRajK_t)Dps-xQpVhbREUH;jTAu zZm8=WJlx#L4NG=GC#@53DM!#t26P#4XBMBy_$Yq0^&C!lQUeL)a6^DpLnaWELwX(~ z>nM{4;3^nYK#dx(UB;rNM9!4B1ger?LIG7}8Wccx$Bn#F=%4g)xBu~!YB`;9q#Z75 ziue`zvlF(%(2XMbNbr=Zy;Z68kzS($9z|6HM*4Yo$bcx2NovV0DZrvm5qjD|(a@6& zY#;e5$x`;pGB>y-16n~TOT3biMnge!KqQg|waG_-A#G=G+KY{Fe~bd}DXcR$53i6} zm|Ilu27k$#e_$2GAu^}L2Lz68U@BH1V+8j`dt@6y zk)SReB<1GXMdNHcNi!W3*FmB$ABJT%o?GK?mn>X|3mMQ)p`G6gqe*U3%y99Tc17Lj zg3{=R(2TbmKE&)&Kgnf1>?RH&IKx!sCIDXsUV zhf1ZiOj%d;=%q>u%>X4rfR|wO%+BI bSgvUO(<(fy!c%eo&jF0WuzIy6wodsM(Oq5s diff --git a/bin/kernal_ultimate64.rom b/bin/kernal_ultimate64.rom index 52d24cdc4556ece34391a91eb55995fb46213568..28d6bb76b3aa0640845792716dbfa80a92969813 100644 GIT binary patch delta 2167 zcmY*Ze{2)i9Y3Fw_y-NSB!qgDz>}cDjs`@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P91>y-%lwjL)Kx6zKHw`(TTb@&bzrBA2BpJO!f3v^glJ<$#2wb+LCy!kIDf-`zMWVHd|rwnkKk^`&PI z9jHEf;DzTf*nVF#z}l+)+7{`c`cQ2RD8jgLa3{fyp#=pBy>9XZcC_gHSld`&cZ<$3 zJ0@n#j!RE-zLHAm7ZjY-s4v$3kH}lWja5*mf+JelHkH2%qFa-w8PrGbSkE{~@i{IE zxRY>W655lfybQiT#QA&|H4x4|s5|s+0;on*0lbnBaB&kr`-diQZ4E;f4VHYHN^<(r zFtf5I|LI>zv$Z;q-+=^seBB;4WPZ8v6{!{T2E1pRajK_t)Dps-xQpVhbREUH;jTAu zZm8=WJlx#L4NG=GC#@53DM!#t26P#4XBMBy_$Yq0^&C!lQUeL)a6^DpLnaWELwX(~ z>nM{4;3^nYK#dx(UB;rNM9!4B1ger?LIG7}8Wccx$Bn#F=%4g)xBu~!YB`;9q#Z75 ziue`zvlF(%(2XMbNbr=Zy;Z68kzS($9z|6HM*4Yo$bcx2NovV0DZrvm5qjD|(a@6& zY#;e5$x`;pGB>y-16n~TOT3biMnge!KqQg|waG_-A#G=G+KY{Fe~bd}DXcR$53i6} zm|Ilu27k$#e_$2GAu^}L2Lz68U@BH1V+8j`dt@6y zk)SReB<1GXMdNHcNi!W3*FmB$ABJT%o?GK?mn>X|3mMQ)p`G6gqe*U3%y99Tc17Lj zg3{=R(2TbmKE&)&Kgnf1>?RH&IKx!sCIDXsUV zhf1ZiOj%d;=%q>u%>X4rfR|wO%+BI bSgvUO(<(fy!c%eo&jF0WuzIy6wodsM(Oq5s diff --git a/c64/kernal/open.s b/c64/kernal/open.s index 507d63e9..3f54a917 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -8,6 +8,7 @@ ;; CPU registers that has to be preserved (see [RG64]): none ;; +;; XXX send the name to the drive (if it's length is non-zero) open: From 5b704045633baa5be2842031dd35c8861c246cd6 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 24 Jul 2019 18:02:38 +0200 Subject: [PATCH 71/90] IEC turnaround move to proper (I hope...) places --- c64/kernal/chkinout.s | 3 --- c64/kernal/iec/iec_turnaround_to_listen.s | 15 ++++++++++----- c64/kernal/iec/iec_turnaround_to_talk.s | 10 ++++++++-- c64/kernal/iec/iec_tx_command.s | 8 +------- c64/kernal/iec/iec_tx_command_finalize.s | 20 ++++++++++++++++++++ c64/kernal/load.s | 9 +++------ c64/kernal/second.s | 12 ++++++++++-- c64/kernal/talk.s | 2 -- c64/kernal/tksa.s | 19 +++++++++++++++---- c64/kernal/unlsn.s | 8 +++++--- c64/kernal/untlk.s | 9 +++++---- 11 files changed, 77 insertions(+), 38 deletions(-) create mode 100644 c64/kernal/iec/iec_tx_command_finalize.s diff --git a/c64/kernal/chkinout.s b/c64/kernal/chkinout.s index d384b975..9a267264 100644 --- a/c64/kernal/chkinout.s +++ b/c64/kernal/chkinout.s @@ -52,9 +52,6 @@ chkin: jsr tksa bcs chkinout_end - jsr iec_turnaround_to_listen ;; XXX shouldn't this be sent by TALK/TKSA??? - bcs chkinout_end - chkin_set_device: lda FAT,Y sta DFLTN diff --git a/c64/kernal/iec/iec_turnaround_to_listen.s b/c64/kernal/iec/iec_turnaround_to_listen.s index 1033b720..0e66047a 100644 --- a/c64/kernal/iec/iec_turnaround_to_listen.s +++ b/c64/kernal/iec/iec_turnaround_to_listen.s @@ -4,6 +4,12 @@ iec_turnaround_to_listen: + ;; Store .X and .Y on the stack - preserve them + txa + pha + tya + pha + ;; Timing is critical here - execute on disabled IRQs php sei @@ -20,14 +26,13 @@ iec_turnaround_to_listen: dex bne - - ;; Timeout + ;; Timeout - XXX what errors do original Kernal report? plp - sec - rts + jmp iec_return_DEVICE_NOT_FOUND ;; CLK is pulled by the device, OK * plp - clc - rts + jmp iec_return_success + diff --git a/c64/kernal/iec/iec_turnaround_to_talk.s b/c64/kernal/iec/iec_turnaround_to_talk.s index c24639d2..666c89e2 100644 --- a/c64/kernal/iec/iec_turnaround_to_talk.s +++ b/c64/kernal/iec/iec_turnaround_to_talk.s @@ -4,6 +4,12 @@ iec_turnaround_to_talk: + ;; Store .X and .Y on the stack - preserve them + txa + pha + tya + pha + ;; Timing is critical here - execute on disabled IRQs php sei @@ -19,5 +25,5 @@ iec_turnaround_to_talk: jsr iec_pull_clk_release_data plp - clc - rts + jmp iec_return_success + diff --git a/c64/kernal/iec/iec_tx_command.s b/c64/kernal/iec/iec_tx_command.s index 153d0f6e..0e27f6af 100644 --- a/c64/kernal/iec/iec_tx_command.s +++ b/c64/kernal/iec/iec_tx_command.s @@ -55,12 +55,6 @@ iec_tx_command: jmp iec_return_DEVICE_NOT_FOUND * - ;; All done - - ;; XXX All the documentation says we should release ATN at this point, but when I do so - ;; the turnaround mechanism does not work. Why??? - ;; jsr iec_wait20us - ;; jsr iec_set_idle + ;; Done jmp iec_return_success - diff --git a/c64/kernal/iec/iec_tx_command_finalize.s b/c64/kernal/iec/iec_tx_command_finalize.s new file mode 100644 index 00000000..91ef8446 --- /dev/null +++ b/c64/kernal/iec/iec_tx_command_finalize.s @@ -0,0 +1,20 @@ + +;; Routine to finalize these IEC commands which do not end in turnaround +;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc + + +iec_tx_command_finalize: + + ;; Store .X and .Y on the stack - preserve them + txa + pha + tya + pha + + ;; Give device some time to complete command reception, release ATN, + ;; give it some time again before (possible) next command + jsr iec_wait20us + jsr iec_set_idle + jsr iec_wait20us + + jmp iec_return_success diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 9675f2df..e83d3a6b 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -63,8 +63,9 @@ load: bcs lvs_device_not_found_error ;; Open channel #0 (p16) - lda #$00 - jsr tksa + lda #$F0 ; $F0 for TKSA + 0 for channel number + sta BSOUR + jsr iec_tx_command bcs lvs_load_verify_error ;; Send filename (p16) @@ -155,10 +156,6 @@ load_loop: ;; Command drive to stop talking and to close the file jsr untlk - ;; Turnaround to talker - according to https://www.pagetable.com/?p=1135 - ;; the turnaround only happens after a command - jsr iec_turnaround_to_talk - lda current_device_number jsr listen diff --git a/c64/kernal/second.s b/c64/kernal/second.s index 53d1391e..819fdc24 100644 --- a/c64/kernal/second.s +++ b/c64/kernal/second.s @@ -12,7 +12,15 @@ second: - and #$1F ; make sure bits encoding the command are cleared out + ;; Due to TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031), + ;; allowed channels are 0-15; report error if out of range + cmp #$10 + bcs kernalerror_FILE_NOT_INPUT + ora #$60 sta BSOUR - jmp iec_tx_command + jsr iec_tx_command + bcs + ; branch if error + jmp iec_tx_command_finalize +* + rts diff --git a/c64/kernal/talk.s b/c64/kernal/talk.s index 3952ed0c..46c26c35 100644 --- a/c64/kernal/talk.s +++ b/c64/kernal/talk.s @@ -10,8 +10,6 @@ ;; -;; XXX shouldn't this do a turnaround? - talk: ;; First check whether device number is correct diff --git a/c64/kernal/tksa.s b/c64/kernal/tksa.s index d003cfbb..06953f7d 100644 --- a/c64/kernal/tksa.s +++ b/c64/kernal/tksa.s @@ -10,12 +10,23 @@ ;; -;; XXX shouldn't this do a turnaround? - tksa: - and #$1F ; make sure bits encoding the command are cleared out + ;; Due to TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031), + ;; allowed channels are 0-15; report error if out of range + cmp #$10 + bcs kernalerror_FILE_NOT_INPUT + ora #$F0 sta BSOUR - jmp iec_tx_command + jsr iec_tx_command + bcs + ; branch if error + ;; XXX - is it really the right place to do a turnaround? I've got some doubts + ;; (it forces us to send the TKSA command 'manually' sometimes), but + ;; Luigi Di Fraia (https://luigidifraia.wordpress.com/2017/06/27/codebase64-on-the-kernal-behaviour/) + ;; claims TKSA Kernal routine actually does the turnaround + jmp iec_turnaround_to_listen +* + rts + diff --git a/c64/kernal/unlsn.s b/c64/kernal/unlsn.s index 32f0b0f5..5aa2cfdc 100644 --- a/c64/kernal/unlsn.s +++ b/c64/kernal/unlsn.s @@ -23,6 +23,8 @@ unlsn: ;; Buffer empty, send the command lda #$3F sta BSOUR - jmp iec_tx_command - - + jsr iec_tx_command + bcs + ; branch if error + jmp iec_tx_command_finalize +* + rts diff --git a/c64/kernal/untlk.s b/c64/kernal/untlk.s index 7f421bb7..4ec846a8 100644 --- a/c64/kernal/untlk.s +++ b/c64/kernal/untlk.s @@ -10,11 +10,12 @@ ;; -;; XXX shouldn't this do a turnaround? - untlk: lda #$5F sta BSOUR - jmp iec_tx_command - + jsr iec_tx_command + bcs + ; branch if error + jmp iec_turnaround_to_listen +* + rts From 431e5384a208dae9e148c14a70545a209bac3e22 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 24 Jul 2019 18:28:53 +0200 Subject: [PATCH 72/90] added IEC support to CLOSE routine --- STATUS.md | 82 +++++++++++++++++++++++----------------------- c64/kernal/close.s | 28 +++++++++++++--- c64/kernal/unlsn.s | 2 +- 3 files changed, 66 insertions(+), 46 deletions(-) diff --git a/STATUS.md b/STATUS.md index 1173fed9..813b8708 100644 --- a/STATUS.md +++ b/STATUS.md @@ -65,47 +65,47 @@ Note: only the jump table addresses are currently supported, real routine addres NOTE: Even the 'DONE' routines won't support features described as missing in one of the previous chapters! -| Address | Name | Status | Remarks | -| ------- | :----: | :------: | :-------------------------------------: | -| $FF81 | CINT | PARTIAL | at least PAL/NTSC detection is missing | -| $FF84 | IOINIT | PARTIAL | at least SID volume handling is missing | -| $FF87 | RAMTAS | DONE | | -| $FF8A | RESTOR | PARTIAL | CBINV, NMINV, and USRCMD missing | -| $FF8D | VECTOR | DONE | | -| $FF90 | SETMSG | DONE | | -| $FF93 | SECOND | DONE | | -| $FF96 | TKSA | PARTIAL | should it do a turnaround? | -| $FF99 | MEMTOP | DONE | | -| $FF9C | MEMBOT | DONE | | -| $FF9F | SCNKEY | DONE | could be better integrated with ROM | -| $FFA2 | SETTMO | NOT DONE | | -| $FFA5 | ACPTR | PARTIAL | * work in progress | -| $FFA8 | CIOUT | DONE | | -| $FFAB | UNTLK | PARITAL | * work in progress | -| $FFAE | UNLSN | DONE | | -| $FFB1 | LISTEN | DONE | | -| $FFB4 | TALK | PARTIAL | should it do a turnaround? | -| $FFB7 | READST | DONE | | -| $FFBA | SETFLS | DONE | | -| $FFBD | SETNAM | DONE | | -| $FFC0 | OPEN | PARTIAL | * work in progress | -| $FFC3 | CLOSE | PARTIAL | * work in progress | -| $FFC6 | CHKIN | PARTIAL | * work in progress | -| $FFC9 | CHKOUT | PARTIAL | * work in progress | -| $FFCC | CLRCHN | PARTIAL | * work in progress | -| $FFCF | CHRIN | PARTIAL | | -| $FFD2 | CHROUT | PARTIAL | | -| $FFD5 | LOAD | PARTIAL | no VERIFY support yet | -| $FFD8 | SAVE | NOT DONE | * work in progress | -| $FFDB | SETTIM | NOT DONE | | -| $FFDE | RDTIM | NOT DONE | | -| $FFE1 | STOP | PARTIAL | no connection with UDTIM | -| $FFE4 | GETIN | PARTIAL | * work in progress | -| $FFE7 | CLALL | PARTIAL | * work in progress | -| $FFEA | UDTIM | NOT DONE | | -| $FFED | SCREEN | DONE | | -| $FFF0 | PLOT | NOT DONE | | -| $FFF3 | IOBASE | DONE | | +| Address | Name | Status | Remarks | +| ------- | :----: | :------: | :-------------------------------------------: | +| $FF81 | CINT | PARTIAL | at least PAL/NTSC detection is missing | +| $FF84 | IOINIT | PARTIAL | at least SID volume handling is missing | +| $FF87 | RAMTAS | DONE | | +| $FF8A | RESTOR | PARTIAL | CBINV, NMINV, and USRCMD missing | +| $FF8D | VECTOR | DONE | | +| $FF90 | SETMSG | DONE | | +| $FF93 | SECOND | DONE | | +| $FF96 | TKSA | DONE | | +| $FF99 | MEMTOP | DONE | | +| $FF9C | MEMBOT | DONE | | +| $FF9F | SCNKEY | DONE | could be better integrated with ROM (aliases) | +| $FFA2 | SETTMO | NOT DONE | | +| $FFA5 | ACPTR | PARTIAL | * work in progress | +| $FFA8 | CIOUT | DONE | | +| $FFAB | UNTLK | DONE | | +| $FFAE | UNLSN | DONE | | +| $FFB1 | LISTEN | DONE | | +| $FFB4 | TALK | DONE | | +| $FFB7 | READST | DONE | | +| $FFBA | SETFLS | DONE | | +| $FFBD | SETNAM | DONE | | +| $FFC0 | OPEN | PARTIAL | * work in progress | +| $FFC3 | CLOSE | DONE | | +| $FFC6 | CHKIN | PARTIAL | * work in progress | +| $FFC9 | CHKOUT | PARTIAL | * work in progress | +| $FFCC | CLRCHN | PARTIAL | * work in progress | +| $FFCF | CHRIN | PARTIAL | | +| $FFD2 | CHROUT | PARTIAL | | +| $FFD5 | LOAD | PARTIAL | no VERIFY support yet | +| $FFD8 | SAVE | NOT DONE | * work in progress | +| $FFDB | SETTIM | NOT DONE | | +| $FFDE | RDTIM | NOT DONE | | +| $FFE1 | STOP | PARTIAL | no connection with UDTIM | +| $FFE4 | GETIN | PARTIAL | * work in progress | +| $FFE7 | CLALL | PARTIAL | * work in progress | +| $FFEA | UDTIM | NOT DONE | | +| $FFED | SCREEN | DONE | | +| $FFF0 | PLOT | NOT DONE | | +| $FFF3 | IOBASE | DONE | | ### Unofficial Kernal locations diff --git a/c64/kernal/close.s b/c64/kernal/close.s index 00485c4c..a4b81d08 100644 --- a/c64/kernal/close.s +++ b/c64/kernal/close.s @@ -4,6 +4,7 @@ ;; ;; - [RG64] C64 Programmer's Reference Guide - page 281/282 ;; - [CM64] Compute's Mapping the Commodore 64 - page 229/230 +;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc (IEC command) ;; ;; CPU registers that has to be preserved (see [RG64]): none ;; @@ -17,11 +18,28 @@ close: jsr find_fls bcs close_error_not_found ;; XXX can we report error in IOSTATUS here? - ;; We have the entry index in Y + ;; We have the entry index in Y - check whether this is IEC device + lda FAT, y + jsr iec_devnum_check + bcs close_remove_from_table - ;; XXX some devices (like IEC) needs special support here, to free their internal resources! - ;; Just make sure the Y register value is kept, or redo ldy DFTLN + ;; IEC device + + ;; First check whether we have something to be sent in the buffer + lda C3PO + beq + + sec ; send it with EOI + jsr iec_tx_byte ; send the command regardless of the status * + lda SAT, y ; get secondary address + ora $E0 ; CLOSE command + sta BSOUR + jsr iec_tx_command + bcs close_remove_from_table + jsr iec_tx_command_finalize + +close_remove_from_table: + ;; Remove channel from the table iny cpy #$0A bpl + @@ -36,8 +54,10 @@ close: ;; Decrement the list size variable dec LDTND - ;; FALLTHROUGH - success + clc ; report success - not sure if original CLOSE does this, but it's nevertheless a good practice + rts close_error_not_found: + sec ; report success - not sure if original CLOSE does this, but it's nevertheless a good practice rts diff --git a/c64/kernal/unlsn.s b/c64/kernal/unlsn.s index 5aa2cfdc..e7ec1955 100644 --- a/c64/kernal/unlsn.s +++ b/c64/kernal/unlsn.s @@ -18,7 +18,7 @@ unlsn: lda C3PO beq + sec ; send it with EOI - jsr iec_tx_byte ; XXX what about the status of this operation? + jsr iec_tx_byte ; send the command regardless of the status * ;; Buffer empty, send the command lda #$3F From fea097e795a8919673a802bde7fb1c3eb393c8b2 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Wed, 24 Jul 2019 20:48:38 +0200 Subject: [PATCH 73/90] various IEC and DOS wedge fixes --- c64/basic/wedge_dos.s | 45 ++++++++++++++++++++++++------------------- c64/kernal/chkinout.s | 2 ++ c64/kernal/load.s | 11 +++++------ c64/kernal/open.s | 3 +-- 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 172c50e1..3d6c0c84 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -18,9 +18,6 @@ wedge_dos: ldy #$00 lda (basic_current_statement_ptr), y beq wedge_dos_status - cmp #$20 - beq wedge_dos_status - ;; XXX consider SYNTAX ERROR if anything besides spaces is there ;; Check if asked for a directory cmp #$24 @@ -28,15 +25,14 @@ wedge_dos: * ;; Check if asked to change drive number, or if it is a regular command cmp #$30 - bmi wedge_dos_command ; char code before 0 + bcc wedge_dos_command ; char code before 0 cmp #$3A - bpl wedge_dos_command ; char code after 9 + bcs wedge_dos_command ; char code after 9 iny lda (basic_current_statement_ptr), y beq wedge_dos_change_drive ; end of buffer cmp #$20 beq wedge_dos_change_drive - ;; XXX consider SYNTAX ERROR if anything besides spaces is there jmp - wedge_dos_command: @@ -45,24 +41,27 @@ wedge_dos_command: lda #$00 ; empty file name jsr JSETNAM jsr via_IOPEN - bcc + - jmp do_DEVICE_NOT_PRESENT_error + bcs wedge_dos_basic_error * ;; Set channel for output ldx #$0F jsr via_ICKOUT -* - jsr JREADST ; retrieve errors - ;; XXX error in case of status != 0 + bcs wedge_dos_basic_error * - ;; XXX this loop does not seem to work, check it jsr basic_fetch_and_consume_character + cmp #$00 beq + + jsr via_IBSOUT - ;; XXX check errors here + bcs wedge_dos_basic_error jmp - * - ;; XXX check status - print it if not OK + ;; Finalize command + lda #$0D + jsr via_IBSOUT + bcs wedge_dos_basic_error + + ;; XXX close here, check status - print it if not OK ;; Clean-up and exit jmp wedge_dos_clean_exit @@ -92,15 +91,15 @@ wedge_dos_status: lda #$00 ; empty file name jsr JSETNAM jsr via_IOPEN - bcc + - jmp do_DEVICE_NOT_PRESENT_error -* + bcs wedge_dos_basic_error + ;; Set channel for input ldx #$0F jsr via_ICHKIN + bcs wedge_dos_basic_error * jsr JREADST ; retrieve errors - ;; XXX error in case of status != 0 + ;; XXX error in case of status != EOF ;; Print out everything retrieved from the drive bne + jsr via_IBASIN @@ -117,8 +116,6 @@ wedge_dos_status: wedge_dos_directory: ;; XXX - implement this - jsr printf - .byte "DBG: DIR", 0 jmp do_NOT_IMPLEMENTED_error wedge_dos_clean_exit: @@ -126,4 +123,12 @@ wedge_dos_clean_exit: jsr via_ICLRCH jmp basic_end_of_line +wedge_dos_basic_error: + tax + dex + jsr do_basic_error + jsr via_ICLALL + jsr via_ICLRCH + jmp basic_end_of_line + ;; END wedge support diff --git a/c64/kernal/chkinout.s b/c64/kernal/chkinout.s index 9a267264..4004df20 100644 --- a/c64/kernal/chkinout.s +++ b/c64/kernal/chkinout.s @@ -61,8 +61,10 @@ chkin_set_device: ;; Common part for booth CHKIN and CKOUT chkinout_end: + tax pla tay + txa rts chkinout_file_not_open: diff --git a/c64/kernal/load.s b/c64/kernal/load.s index e83d3a6b..b3137cfe 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -42,7 +42,7 @@ load: lda current_device_number and #$FC beq lvs_illegal_device_number ; device number below 4, not an IEC device - + ;; Device numbers above 30 are also illegal (see https://www.pagetable.com/?p=1031), ;; as the protocol combines device number with command code int one byte, ;; above 30 it is no longer possible (UNLISTEN and UNTALK codes prevent using @@ -56,7 +56,7 @@ load: ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf ;; p13, 16; also p16 tells us this routine doesn't mess with the file table ;; in the C64, only in the drive. - + ;; Call device to LISTEN (p16) lda current_device_number jsr listen @@ -67,6 +67,8 @@ load: sta BSOUR jsr iec_tx_command bcs lvs_load_verify_error + jsr iec_tx_command_finalize + bcs lvs_load_verify_error ;; Send filename (p16) ldy #0 @@ -97,7 +99,6 @@ load_filename_sent: ;; Command device to unlisten to indicate end of file name. (p16) jsr unlsn bcs lvs_load_verify_error - jsr iec_set_idle ;; XXX is it needed? ;; Now command device to talk (p16) lda current_device_number @@ -162,12 +163,10 @@ load_loop: lda #$E0 sta BSOUR jsr iec_tx_command + jsr iec_tx_command_finalize ;; Tell drive to unlisten jsr unlsn - - ;; Set IEC status back to idle - jsr iec_set_idle ;; Return last address jmp lvs_return_last_address diff --git a/c64/kernal/open.s b/c64/kernal/open.s index 3f54a917..1205a7f6 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -30,8 +30,7 @@ open: ldy LDTND cpy #$0A - bcs + - bmi open_has_space + bcc open_has_space * ;; Table is full jmp kernalerror_TOO_MANY_OPEN_FILES From 504f0ffb814ddb0d197f74087b018138f624fef8 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 25 Jul 2019 17:07:33 +0200 Subject: [PATCH 74/90] added proper buffer handling to several IEC commands --- c64/kernal/close.s | 6 +----- c64/kernal/iec/iec_tx_command_finalize.s | 2 +- c64/kernal/iec/iec_tx_common.s | 1 + c64/kernal/iec/iec_tx_flush.s | 15 +++++++++++++++ c64/kernal/listen.s | 14 +++++++++++--- c64/kernal/second.s | 9 +++------ c64/kernal/talk.s | 12 +++++++++++- c64/kernal/tksa.s | 13 +++---------- c64/kernal/unlsn.s | 17 +++++++++-------- c64/kernal/untlk.s | 12 ++++++++++++ 10 files changed, 67 insertions(+), 34 deletions(-) create mode 100644 c64/kernal/iec/iec_tx_flush.s diff --git a/c64/kernal/close.s b/c64/kernal/close.s index a4b81d08..d1aed3ac 100644 --- a/c64/kernal/close.s +++ b/c64/kernal/close.s @@ -25,11 +25,7 @@ close: ;; IEC device - ;; First check whether we have something to be sent in the buffer - lda C3PO - beq + - sec ; send it with EOI - jsr iec_tx_byte ; send the command regardless of the status + jsr iec_tx_flush ; make sure no byte is awaiting * lda SAT, y ; get secondary address ora $E0 ; CLOSE command diff --git a/c64/kernal/iec/iec_tx_command_finalize.s b/c64/kernal/iec/iec_tx_command_finalize.s index 91ef8446..e0ad0c35 100644 --- a/c64/kernal/iec/iec_tx_command_finalize.s +++ b/c64/kernal/iec/iec_tx_command_finalize.s @@ -1,5 +1,5 @@ -;; Routine to finalize these IEC commands which do not end in turnaround +;; Routine to finalize some IEC commands - which do not end in turnaround and are not followed by others ;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc diff --git a/c64/kernal/iec/iec_tx_common.s b/c64/kernal/iec/iec_tx_common.s index 50d5edca..87b0aef1 100644 --- a/c64/kernal/iec/iec_tx_common.s +++ b/c64/kernal/iec/iec_tx_common.s @@ -5,6 +5,7 @@ ;; Expects byte to send in BSOUR; Carry flag set = signal EOI +;; XXX is it OK to use BSOUR for data exchange? Maybe there is a better way? iec_tx_common: diff --git a/c64/kernal/iec/iec_tx_flush.s b/c64/kernal/iec/iec_tx_flush.s new file mode 100644 index 00000000..95395f77 --- /dev/null +++ b/c64/kernal/iec/iec_tx_flush.s @@ -0,0 +1,15 @@ + +;; Flush the IEC output buffer (if not empty) - send byte with EOI +;; +;; Preserves .X, .Y and .A registers + +iec_tx_flush: + + pha + lda C3PO + beq + + sec ; send it with EOI + jsr iec_tx_byte ; send the command regardless of the status +* + pla + rts diff --git a/c64/kernal/listen.s b/c64/kernal/listen.s index 5e2c1bd1..7ba96f11 100644 --- a/c64/kernal/listen.s +++ b/c64/kernal/listen.s @@ -5,6 +5,7 @@ ;; - [RG64] C64 Programmer's Reference Guide - page 285 ;; - [CM64] Compute's Mapping the Commodore 64 - page 223 ;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc +;; - http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf ;; ;; CPU registers that has to be preserved (see [RG64]): .X, .Y ;; @@ -12,10 +13,17 @@ listen: - ;; First check whether device number is correct + ;; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer + jsr iec_tx_flush + + ;; Check whether device number is correct jsr iec_devnum_check bcs kernalerror_DEVICE_NOT_FOUND + ;; Encode and execute the command ora #$20 - sta BSOUR - jmp iec_tx_command + + jmp common_talk_listen + + + diff --git a/c64/kernal/second.s b/c64/kernal/second.s index 819fdc24..27585a4c 100644 --- a/c64/kernal/second.s +++ b/c64/kernal/second.s @@ -18,9 +18,6 @@ second: bcs kernalerror_FILE_NOT_INPUT ora #$60 - sta BSOUR - jsr iec_tx_command - bcs + ; branch if error - jmp iec_tx_command_finalize -* - rts + + jmp common_unlsn_second + diff --git a/c64/kernal/talk.s b/c64/kernal/talk.s index 46c26c35..d4ca5742 100644 --- a/c64/kernal/talk.s +++ b/c64/kernal/talk.s @@ -5,6 +5,7 @@ ;; - [RG64] C64 Programmer's Reference Guide - page 301/302 ;; - [CM64] Compute's Mapping the Commodore 64 - page 223 ;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc +;; - http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf ;; ;; CPU registers that has to be preserved (see [RG64]): .X, .Y ;; @@ -12,10 +13,19 @@ talk: - ;; First check whether device number is correct + ;; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer + jsr iec_tx_flush + + ;; Check whether device number is correct jsr iec_devnum_check bcs kernalerror_DEVICE_NOT_FOUND + ;; Encode and execute the command ora #$40 + +common_talk_listen: ; common part of TALK and LISTEN + sta BSOUR jmp iec_tx_command + + diff --git a/c64/kernal/tksa.s b/c64/kernal/tksa.s index 06953f7d..94d635cd 100644 --- a/c64/kernal/tksa.s +++ b/c64/kernal/tksa.s @@ -18,15 +18,8 @@ tksa: bcs kernalerror_FILE_NOT_INPUT ora #$F0 - sta BSOUR - jsr iec_tx_command - bcs + ; branch if error - ;; XXX - is it really the right place to do a turnaround? I've got some doubts - ;; (it forces us to send the TKSA command 'manually' sometimes), but - ;; Luigi Di Fraia (https://luigidifraia.wordpress.com/2017/06/27/codebase64-on-the-kernal-behaviour/) - ;; claims TKSA Kernal routine actually does the turnaround - jmp iec_turnaround_to_listen -* - rts + + jmp common_untlk_tksa + diff --git a/c64/kernal/unlsn.s b/c64/kernal/unlsn.s index e7ec1955..fd4e4480 100644 --- a/c64/kernal/unlsn.s +++ b/c64/kernal/unlsn.s @@ -5,6 +5,7 @@ ;; - [RG64] C64 Programmer's Reference Guide - page 303 ;; - [CM64] Compute's Mapping the Commodore 64 - page 224 ;; - https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc +;; - http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf ;; ;; CPU registers that has to be preserved (see [RG64]): .X, .Y ;; @@ -12,19 +13,19 @@ unlsn: - ;; This routine is documented in 'Compute's Mapping the Commodore 64', page 224 - - ;; First check whether we have something to be sent in the buffer - lda C3PO - beq + - sec ; send it with EOI - jsr iec_tx_byte ; send the command regardless of the status -* + ;; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer + jsr iec_tx_flush + ;; Buffer empty, send the command lda #$3F + +common_unlsn_second: ; common part of UNSLS and SECOND + sta BSOUR jsr iec_tx_command bcs + ; branch if error jmp iec_tx_command_finalize * rts + + diff --git a/c64/kernal/untlk.s b/c64/kernal/untlk.s index 4ec846a8..4085698e 100644 --- a/c64/kernal/untlk.s +++ b/c64/kernal/untlk.s @@ -5,6 +5,7 @@ ;; - [RG64] C64 Programmer's Reference Guide - page 304 ;; - [CM64] Compute's Mapping the Commodore 64 - page 224 ;; - https://www.pagetable.com/?p=1031, , https://github.com/mist64/cbmbus_doc +;; - http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf ;; ;; CPU registers that has to be preserved (see [RG64]): .X, .Y ;; @@ -12,10 +13,21 @@ untlk: + ;; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer + jsr iec_tx_flush + + ;; Buffer empty, send the command lda #$5F + +common_untlk_tksa: ; common part of UNTLK and TKSA + sta BSOUR jsr iec_tx_command bcs + ; branch if error + ;; XXX - for TKSA, is it really the right place to do a turnaround? I've got some doubts + ;; (it forces us to send the TKSA command 'manually' sometimes), but + ;; Luigi Di Fraia (https://luigidifraia.wordpress.com/2017/06/27/codebase64-on-the-kernal-behaviour/) + ;; claims TKSA Kernal routine actually does the turnaround jmp iec_turnaround_to_listen * rts From a2c02bde97a43cf422735fcf32fadb527313eb0d Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 25 Jul 2019 17:38:00 +0200 Subject: [PATCH 75/90] ACPTR now preserves registers, changed IEC temporary byte storage --- STATUS.md | 2 +- c64/aliases/,aliases_ram_lowmem.s | 3 +++ c64/kernal/acptr.s | 2 -- c64/kernal/close.s | 2 +- c64/kernal/iec/iec_rx_byte.s | 42 ++++++++++++++++++++++++------- c64/kernal/iec/iec_tx_byte.s | 4 ++- c64/kernal/iec/iec_tx_command.s | 4 ++- c64/kernal/iec/iec_tx_common.s | 10 +++----- c64/kernal/load.s | 8 +++--- c64/kernal/talk.s | 2 +- c64/kernal/unlsn.s | 2 +- c64/kernal/untlk.s | 2 +- 12 files changed, 55 insertions(+), 28 deletions(-) diff --git a/STATUS.md b/STATUS.md index 813b8708..e0d57f7b 100644 --- a/STATUS.md +++ b/STATUS.md @@ -79,7 +79,7 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on | $FF9C | MEMBOT | DONE | | | $FF9F | SCNKEY | DONE | could be better integrated with ROM (aliases) | | $FFA2 | SETTMO | NOT DONE | | -| $FFA5 | ACPTR | PARTIAL | * work in progress | +| $FFA5 | ACPTR | DONE | | | $FFA8 | CIOUT | DONE | | | $FFAB | UNTLK | DONE | | | $FFAE | UNLSN | DONE | | diff --git a/c64/aliases/,aliases_ram_lowmem.s b/c64/aliases/,aliases_ram_lowmem.s index c0a88d1d..ac9f8dd8 100644 --- a/c64/aliases/,aliases_ram_lowmem.s +++ b/c64/aliases/,aliases_ram_lowmem.s @@ -31,6 +31,9 @@ .alias TIME $A0 ; $A0-$A2, jiffy clock + .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 diff --git a/c64/kernal/acptr.s b/c64/kernal/acptr.s index 028233c2..8d3da68f 100644 --- a/c64/kernal/acptr.s +++ b/c64/kernal/acptr.s @@ -8,10 +8,8 @@ ;; CPU registers that has to be preserved (see [RG64]): .Y ;; -;; XXX preserve register Y! acptr: - ;; XXX temporary implementation jsr kernalstatus_reset jmp iec_rx_byte diff --git a/c64/kernal/close.s b/c64/kernal/close.s index d1aed3ac..523b8b3d 100644 --- a/c64/kernal/close.s +++ b/c64/kernal/close.s @@ -29,7 +29,7 @@ close: * lda SAT, y ; get secondary address ora $E0 ; CLOSE command - sta BSOUR + sta IEC_TMP2 jsr iec_tx_command bcs close_remove_from_table jsr iec_tx_command_finalize diff --git a/c64/kernal/iec/iec_rx_byte.s b/c64/kernal/iec/iec_rx_byte.s index 9819636c..c9a3b501 100644 --- a/c64/kernal/iec/iec_rx_byte.s +++ b/c64/kernal/iec/iec_rx_byte.s @@ -1,9 +1,17 @@ - ;; Receive a byte from the IEC bus. - ;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc, - ;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf (page 11) +;; Receive a byte from the IEC bus. +;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc, +;; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf (page 11) +;; +;; Preserves .X and .Y registers iec_rx_byte: + ;; Store .X and .Y on the stack - preserve them + txa + pha + tya + pha + ;; Timing is critical here - execute on disabled IRQs php sei @@ -96,12 +104,19 @@ iec_rx_clk_wait2: dey ; 2 cycles bne iec_rx_clk_wait2 ; 3 cycles if jumped - ;; Timeout - jsr kernalstatus_EOI - pla - plp - sec ; XXX confirm that sec is really a way to report timeout here - rts + ;; Timeout + jsr kernalstatus_EOI + pla + plp + + ;; Restore registers + pla + tay + pla + tax + + sec ; XXX confirm that sec is really a way to report timeout here + rts * ;; More bits? dex @@ -118,6 +133,15 @@ iec_rx_clk_wait2: ;; Return no-error plp + + ;; Restore registers + sta IEC_TMP2 ; $A4 is a byte buffer according to http://sta.c64.org/cbm64mem.html + pla + tay + pla + tax + lda IEC_TMP2 + clc rts diff --git a/c64/kernal/iec/iec_tx_byte.s b/c64/kernal/iec/iec_tx_byte.s index a1eac09b..767dce76 100644 --- a/c64/kernal/iec/iec_tx_byte.s +++ b/c64/kernal/iec/iec_tx_byte.s @@ -1,7 +1,9 @@ ;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc -;; Expects byte to send in BSOUR; Carry flag set = signal EOI +;; Expects byte to send in IEC_TMP2 ($A4 is a byte buffer according to http://sta.c64.org/cbm64mem.html) +;; Carry flag set = signal EOI +;; ;; Preserves .X and .Y registers diff --git a/c64/kernal/iec/iec_tx_command.s b/c64/kernal/iec/iec_tx_command.s index 0e27f6af..e2da97f2 100644 --- a/c64/kernal/iec/iec_tx_command.s +++ b/c64/kernal/iec/iec_tx_command.s @@ -1,7 +1,9 @@ ;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc -;; Expects command to send in BSOUR; Carry flag set = signal EOI +;; Expects byte to send in IEC_TMP2 ($A4 is a byte buffer according to http://sta.c64.org/cbm64mem.html) +;; Carry flag set = signal EOI +;; ;; Preserves .X and .Y registers diff --git a/c64/kernal/iec/iec_tx_common.s b/c64/kernal/iec/iec_tx_common.s index 87b0aef1..8cc63e0f 100644 --- a/c64/kernal/iec/iec_tx_common.s +++ b/c64/kernal/iec/iec_tx_common.s @@ -3,9 +3,8 @@ ;; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc ;; and http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf -;; Expects byte to send in BSOUR; Carry flag set = signal EOI - -;; XXX is it OK to use BSOUR for data exchange? Maybe there is a better way? +;; Expects byte to send in IEC_TMP2 ($A4 is a byte buffer according to http://sta.c64.org/cbm64mem.html) +;; Carry flag set = signal EOI iec_tx_common: @@ -42,11 +41,10 @@ iec_tx_common: iec_tx_common_sendbit: ;; Is next bit 0 or 1? - lda BSOUR + lda IEC_TMP2 lsr - sta BSOUR + sta IEC_TMP2 bcs + - ;; XXX we are actually destroying BSOUR here... is it allowed? ;; Bit is 0 jsr iec_release_clk_pull_data diff --git a/c64/kernal/load.s b/c64/kernal/load.s index b3137cfe..59ae8715 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -64,7 +64,7 @@ load: ;; Open channel #0 (p16) lda #$F0 ; $F0 for TKSA + 0 for channel number - sta BSOUR + sta IEC_TMP2 jsr iec_tx_command bcs lvs_load_verify_error jsr iec_tx_command_finalize @@ -89,7 +89,7 @@ load_send_filename: sec * ;; Transmit one character - sta BSOUR + sta IEC_TMP2 jsr iec_tx_byte jmp load_send_filename @@ -106,7 +106,7 @@ load_filename_sent: bcs lvs_load_verify_error lda #$60 ; open channel / data (p3) , required according to p13 - sta BSOUR + sta IEC_TMP2 jsr iec_tx_command bcs lvs_load_verify_error @@ -161,7 +161,7 @@ load_loop: jsr listen lda #$E0 - sta BSOUR + sta IEC_TMP2 jsr iec_tx_command jsr iec_tx_command_finalize diff --git a/c64/kernal/talk.s b/c64/kernal/talk.s index d4ca5742..fbd0fabc 100644 --- a/c64/kernal/talk.s +++ b/c64/kernal/talk.s @@ -25,7 +25,7 @@ talk: common_talk_listen: ; common part of TALK and LISTEN - sta BSOUR + sta IEC_TMP2 jmp iec_tx_command diff --git a/c64/kernal/unlsn.s b/c64/kernal/unlsn.s index fd4e4480..1cc9b998 100644 --- a/c64/kernal/unlsn.s +++ b/c64/kernal/unlsn.s @@ -21,7 +21,7 @@ unlsn: common_unlsn_second: ; common part of UNSLS and SECOND - sta BSOUR + sta IEC_TMP2 jsr iec_tx_command bcs + ; branch if error jmp iec_tx_command_finalize diff --git a/c64/kernal/untlk.s b/c64/kernal/untlk.s index 4085698e..e8054e0d 100644 --- a/c64/kernal/untlk.s +++ b/c64/kernal/untlk.s @@ -21,7 +21,7 @@ untlk: common_untlk_tksa: ; common part of UNTLK and TKSA - sta BSOUR + sta IEC_TMP2 jsr iec_tx_command bcs + ; branch if error ;; XXX - for TKSA, is it really the right place to do a turnaround? I've got some doubts From 893371733b3141f948512f6ea6be0a106a759614 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 25 Jul 2019 18:12:39 +0200 Subject: [PATCH 76/90] more work on register preservation --- STATUS.md | 10 +++++----- c64/kernal/chrin.s | 14 +++++++------- c64/kernal/clall.s | 13 ++++++++++--- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/STATUS.md b/STATUS.md index e0d57f7b..3bbd5099 100644 --- a/STATUS.md +++ b/STATUS.md @@ -90,18 +90,18 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on | $FFBD | SETNAM | DONE | | | $FFC0 | OPEN | PARTIAL | * work in progress | | $FFC3 | CLOSE | DONE | | -| $FFC6 | CHKIN | PARTIAL | * work in progress | -| $FFC9 | CHKOUT | PARTIAL | * work in progress | -| $FFCC | CLRCHN | PARTIAL | * work in progress | +| $FFC6 | CHKIN | DONE | | +| $FFC9 | CHKOUT | PARTIAL | | +| $FFCC | CLRCHN | DONE | | | $FFCF | CHRIN | PARTIAL | | | $FFD2 | CHROUT | PARTIAL | | -| $FFD5 | LOAD | PARTIAL | no VERIFY support yet | +| $FFD5 | LOAD | PARTIAL | * work in progress, no VERIFY support yet | | $FFD8 | SAVE | NOT DONE | * work in progress | | $FFDB | SETTIM | NOT DONE | | | $FFDE | RDTIM | NOT DONE | | | $FFE1 | STOP | PARTIAL | no connection with UDTIM | | $FFE4 | GETIN | PARTIAL | * work in progress | -| $FFE7 | CLALL | PARTIAL | * work in progress | +| $FFE7 | CLALL | DONE | | | $FFEA | UDTIM | NOT DONE | | | $FFED | SCREEN | DONE | | | $FFF0 | PLOT | NOT DONE | | diff --git a/c64/kernal/chrin.s b/c64/kernal/chrin.s index 8bd4850b..591936d2 100644 --- a/c64/kernal/chrin.s +++ b/c64/kernal/chrin.s @@ -8,11 +8,11 @@ ;; CPU registers that has to be preserved (see [RG64]): .Y ;; -;; XXX currently does not preserve register Y, to be fixed! +;; XXX keyboard part currently does not preserve register Y, to be fixed! - ;; Reads a byte of input, unless from keyboard. - ;; If from keyboard, then it gets a whole line of input, and returns the first char. - ;; Repeated calls after that read out the successive bytes of the line of input. +;; Reads a byte of input, unless from keyboard. +;; If from keyboard, then it gets a whole line of input, and returns the first char. +;; Repeated calls after that read out the successive bytes of the line of input. chrin: ;; First determine the device number @@ -202,7 +202,7 @@ not_shifted: clc adc #$40 + ;; FALLTROUGH +not_vendor: rts -not_vendor: - - rts + diff --git a/c64/kernal/clall.s b/c64/kernal/clall.s index 059804ed..01145a00 100644 --- a/c64/kernal/clall.s +++ b/c64/kernal/clall.s @@ -8,20 +8,27 @@ ;; CPU registers that has to be preserved (see [RG64]): .Y ;; -;; XXX currently does not preserve register Y, to be fixed! clall: + ;; Store .Y register + tya + pha + ;; Original routine probably just sets LDTND to 0, but this is not really safe, ;; so we actually close all the channels; at least IDE64 does the same for ;; it's channels, see CLALL description in the IDE64 User's Guide - +* ldy LDTND beq + dey lda LAT, y jsr close ; XXX jump through ICLOSE? - jmp clall + jmp - * + ;; Restore .Y register + pla + tay + ;; 'C64 Programmers Reference Guide', page 281, claims it calls CLRCHN too jmp clrchn From 32fbed93f7e21aa46606af12be5c719de636e19d Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Thu, 25 Jul 2019 21:40:24 +0200 Subject: [PATCH 77/90] finished OPEN routine, some IEC cleanups --- STATUS.md | 2 +- c64/kernal/chkinout.s | 4 +- c64/kernal/chrin.s | 2 +- c64/kernal/chrout.s | 64 ++++++++++--------- c64/kernal/close.s | 2 +- c64/kernal/clrchn.s | 4 +- ...{iec_devnum_check.s => iec_check_devnum.s} | 8 +-- c64/kernal/iec/iec_cmd_close.s | 20 ++++++ c64/kernal/iec/iec_cmd_open.s | 29 +++++++++ c64/kernal/listen.s | 7 +- c64/kernal/load.s | 39 ++--------- c64/kernal/lvs_helpers.s | 22 +++++++ c64/kernal/open.s | 31 ++++++++- c64/kernal/second.s | 10 +-- c64/kernal/talk.s | 7 +- c64/kernal/tksa.s | 7 +- c64/kernal/unlsn.s | 8 +-- 17 files changed, 169 insertions(+), 97 deletions(-) rename c64/kernal/iec/{iec_devnum_check.s => iec_check_devnum.s} (71%) create mode 100644 c64/kernal/iec/iec_cmd_close.s create mode 100644 c64/kernal/iec/iec_cmd_open.s diff --git a/STATUS.md b/STATUS.md index 3bbd5099..c4d99e8d 100644 --- a/STATUS.md +++ b/STATUS.md @@ -88,7 +88,7 @@ NOTE: Even the 'DONE' routines won't support features described as missing in on | $FFB7 | READST | DONE | | | $FFBA | SETFLS | DONE | | | $FFBD | SETNAM | DONE | | -| $FFC0 | OPEN | PARTIAL | * work in progress | +| $FFC0 | OPEN | DONE | | | $FFC3 | CLOSE | DONE | | | $FFC6 | CHKIN | DONE | | | $FFC9 | CHKOUT | PARTIAL | | diff --git a/c64/kernal/chkinout.s b/c64/kernal/chkinout.s index 4004df20..1af2fc02 100644 --- a/c64/kernal/chkinout.s +++ b/c64/kernal/chkinout.s @@ -42,7 +42,7 @@ chkin: ;; For IEC devices, send TALK + TKSA first lda FAT,Y - jsr iec_devnum_check + jsr iec_check_devnum bcs chkin_set_device jsr talk @@ -125,7 +125,7 @@ ckout: ;; For IEC devices, send LISTEN + SECOND first lda FAT,Y - jsr iec_devnum_check + jsr iec_check_devnum bcs chkin_set_device jsr listen diff --git a/c64/kernal/chrin.s b/c64/kernal/chrin.s index 591936d2..b20014e2 100644 --- a/c64/kernal/chrin.s +++ b/c64/kernal/chrin.s @@ -21,7 +21,7 @@ chrin: beq chrin_keyboard ; #$00 - keyboard ;; XXX add screen support - jsr iec_devnum_check + jsr iec_check_devnum bcs chrin_done_fail ; not a supported device chrin_iec: diff --git a/c64/kernal/chrout.s b/c64/kernal/chrout.s index b7266a66..48f5a606 100644 --- a/c64/kernal/chrout.s +++ b/c64/kernal/chrout.s @@ -27,16 +27,44 @@ chrout: cmp #$03 ; screen beq chrout_screen - - jsr iec_devnum_check + + jsr iec_check_devnum bcs chrout_done_fail ; not a supported device chrout_iec: lda last_printed_character_ascii jsr JCIOUT - bcs chrout_done_fail - jmp chrout_done + bcc chrout_done + + ;; FALLTROUGH + +chrout_done_fail: + jsr show_cursor_if_enabled + + plp + + ;; Restore X and Y, set carry to mark success on exit + pla + tay + pla + tax + sec ; indicate failure + rts + +chrout_done: + jsr show_cursor_if_enabled + + plp + + ;; Restore X and Y, set carry to mark success on exit + pla + tay + pla + tax + lda last_printed_character_ascii + clc ; indicate success + rts chrout_screen: @@ -399,33 +427,7 @@ not_quote: sta current_screen_x jmp screen_advance_to_next_line no_screen_advance_to_next_line: - -chrout_done: - jsr show_cursor_if_enabled - - plp - - ;; Restore X and Y, set carry to mark success on exit - pla - tay - pla - tax - lda last_printed_character_ascii - clc ; indicate success - rts - -chrout_done_fail: - jsr show_cursor_if_enabled - - plp - - ;; Restore X and Y, set carry to mark success on exit - pla - tay - pla - tax - sec ; indicate failure - rts + jmp chrout_done screen_grow_logical_line: ldy current_screen_y diff --git a/c64/kernal/close.s b/c64/kernal/close.s index 523b8b3d..ad218fec 100644 --- a/c64/kernal/close.s +++ b/c64/kernal/close.s @@ -20,7 +20,7 @@ close: ;; We have the entry index in Y - check whether this is IEC device lda FAT, y - jsr iec_devnum_check + jsr iec_check_devnum bcs close_remove_from_table ;; IEC device diff --git a/c64/kernal/clrchn.s b/c64/kernal/clrchn.s index 22b4c9e0..3cc53078 100644 --- a/c64/kernal/clrchn.s +++ b/c64/kernal/clrchn.s @@ -13,14 +13,14 @@ clrchn: ;; Handle IEC input device lda DFLTN - jsr iec_devnum_check + jsr iec_check_devnum bcs + ;; Previous device was IEC one - send UNTALK first jsr untlk * ;; Restore output device to default lda DFLTO - jsr iec_devnum_check + jsr iec_check_devnum bcs + ;; Handle IEC output device jsr unlsn diff --git a/c64/kernal/iec/iec_devnum_check.s b/c64/kernal/iec/iec_check_devnum.s similarity index 71% rename from c64/kernal/iec/iec_devnum_check.s rename to c64/kernal/iec/iec_check_devnum.s index 84cd506b..e5e354fa 100644 --- a/c64/kernal/iec/iec_devnum_check.s +++ b/c64/kernal/iec/iec_check_devnum.s @@ -1,22 +1,22 @@ ;; -;; Checks whether device numbe (in .A) is a correct IEC device number +;; Checks whether device number (in .A) is a correct IEC device number ;; ;; Preserves .A, .X and .Y ;; -iec_devnum_check: +iec_check_devnum: ;; 0, 1, 2, or 3 are illegal - reserved for non-IEC devices on Commodore cmp #$04 bcs + ;; FALLTROUGH -iec_devnum_check_failed: +iec_check_devnum_failed: sec ; indicate non-IEC device rts * ;; 31 and above are illegal too, due to IEC command encoding scheme, ;; see https://www.pagetable.com/?p=1031 cmp #$1F - bcs iec_devnum_check_failed + bcs iec_check_devnum_failed ;; Carry is clear here - indicates IEC device rts diff --git a/c64/kernal/iec/iec_cmd_close.s b/c64/kernal/iec/iec_cmd_close.s new file mode 100644 index 00000000..552428a2 --- /dev/null +++ b/c64/kernal/iec/iec_cmd_close.s @@ -0,0 +1,20 @@ + +;; +;; Kernal internal IEC routine +;; +;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc +;; + +iec_cmd_close: + + jsr iec_tx_flush + + ;; Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031), + ;; allowed channels are 0-15; report error if out of range + cmp #$10 + bcc + + jmp kernalerror_FILE_NOT_INPUT +* + ora #$E0 + + jmp common_open_close_unlsn_second diff --git a/c64/kernal/iec/iec_cmd_open.s b/c64/kernal/iec/iec_cmd_open.s new file mode 100644 index 00000000..cd184307 --- /dev/null +++ b/c64/kernal/iec/iec_cmd_open.s @@ -0,0 +1,29 @@ + +;; +;; Kernal internal IEC routine +;; +;; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc +;; + + +iec_cmd_open: ; similar to TKSA, but without turnaround + + ;; Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031), + ;; allowed channels are 0-15; report error if out of range + cmp #$10 + bcc + + jmp kernalerror_FILE_NOT_INPUT +* + ora #$F0 + + ;; FALLTROUGH + +common_open_close_unlsn_second: ; common part of several commands + + sta IEC_TMP2 + jsr iec_tx_command + bcs + ; branch if error + jmp iec_tx_command_finalize +* + rts + diff --git a/c64/kernal/listen.s b/c64/kernal/listen.s index 7ba96f11..dd240070 100644 --- a/c64/kernal/listen.s +++ b/c64/kernal/listen.s @@ -17,9 +17,10 @@ listen: jsr iec_tx_flush ;; Check whether device number is correct - jsr iec_devnum_check - bcs kernalerror_DEVICE_NOT_FOUND - + jsr iec_check_devnum + bcc + + jmp kernalerror_DEVICE_NOT_FOUND +* ;; Encode and execute the command ora #$20 diff --git a/c64/kernal/load.s b/c64/kernal/load.s index 59ae8715..e845b546 100644 --- a/c64/kernal/load.s +++ b/c64/kernal/load.s @@ -62,42 +62,13 @@ load: jsr listen bcs lvs_device_not_found_error - ;; Open channel #0 (p16) - lda #$F0 ; $F0 for TKSA + 0 for channel number - sta IEC_TMP2 - jsr iec_tx_command - bcs lvs_load_verify_error - jsr iec_tx_command_finalize + ;; Open channel 0 (reserved for file reading) + lda #$00 + jsr iec_cmd_open bcs lvs_load_verify_error - ;; Send filename (p16) - ldy #0 - -load_send_filename: - - cpy FNLEN - beq load_filename_sent - - ldx # Date: Fri, 26 Jul 2019 17:34:24 +0200 Subject: [PATCH 78/90] more work towards DOS wedge --- c64/aliases/,aliases_ram_lowmem.s | 8 ++-- c64/basic/,aliases.s | 2 +- c64/basic/cmd_list.s | 11 +++-- c64/basic/wedge_dos.s | 74 ++++++++++++++++++++++++++++--- 4 files changed, 82 insertions(+), 13 deletions(-) diff --git a/c64/aliases/,aliases_ram_lowmem.s b/c64/aliases/,aliases_ram_lowmem.s index ac9f8dd8..0cef3f43 100644 --- a/c64/aliases/,aliases_ram_lowmem.s +++ b/c64/aliases/,aliases_ram_lowmem.s @@ -44,10 +44,12 @@ .alias STAL $C1 ; $C1-$C2 LOAD/SAVE start address - ;; + ;; ;; Other low memory addresses - ;; - + ;; + + .alias BUF $200 ; $200-$250 (81 bytes), BASIC line editor input buffer + ;; Kernal tables for opened files, 10 entries each .alias LAT $259 ; logical file numbers .alias FAT $263 ; device numbers diff --git a/c64/basic/,aliases.s b/c64/basic/,aliases.s index 6f98fbf4..e54dd5a9 100644 --- a/c64/basic/,aliases.s +++ b/c64/basic/,aliases.s @@ -91,7 +91,7 @@ .alias rs232_rx_buffer_ptr $F7 .alias rs232_tx_buffer_ptr $F9 - .alias basic_input_buffer $0200 + .alias basic_input_buffer BUF ; "Compute's Mapping the 64" book .alias keyboard_buffer $0277 diff --git a/c64/basic/cmd_list.s b/c64/basic/cmd_list.s index 13038f54..a1be1724 100644 --- a/c64/basic/cmd_list.s +++ b/c64/basic/cmd_list.s @@ -26,6 +26,12 @@ list_more_lines: bmi + jmp basic_do_break * + jsr list_single_line + ;; Now link to the next line + jsr basic_find_next_line + jmp list_loop + +list_single_line: ; entry point needed by DOS wedge ;; Print line number ldy #3 jsr peek_under_roms @@ -116,8 +122,5 @@ list_end_of_line: ;; Print end of line lda #$0d jsr via_IBSOUT + rts - ;; Now link to the next line - jsr basic_find_next_line - jmp list_loop - diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 3d6c0c84..041949c7 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -61,7 +61,7 @@ wedge_dos_command: jsr via_IBSOUT bcs wedge_dos_basic_error - ;; XXX close here, check status - print it if not OK + ;; XXX check status - print it if not OK ;; Clean-up and exit jmp wedge_dos_clean_exit @@ -115,12 +115,77 @@ wedge_dos_status: wedge_dos_directory: - ;; XXX - implement this - jmp do_NOT_IMPLEMENTED_error + ;; First change the secondary address to the one suitable for + ;; directory loading + lda #$00 + sta current_secondary_address + + ;; Now determine the length of the 'file' name + ldy #$FF +* + iny + lda (basic_current_statement_ptr), y + bne - + + ;; Set the name to open + tya + ldx basic_current_statement_ptr+0 + ldy basic_current_statement_ptr+1 + jsr JSETNAM + + ;; Open the file + jsr via_IOPEN + bcs wedge_dos_basic_error + + ;; Set channel for input + ldx #$0F + jsr via_ICHKIN + bcs wedge_dos_basic_error + + ;; Ignore start address (2 first bytes) - XXX check for errors + jsr via_IBASIN + bcs wedge_dos_basic_error + jsr via_IBASIN + bcs wedge_dos_basic_error + +wedge_dos_directory_line: + + ;; Load a single line, reuse BASIC input buffer + ldy #$FF +* + iny + jsr via_IBASIN + bcs wedge_dos_basic_error + sta BUF, y + cpy #$50 + beq + ; line too long, terminate loading file + jsr JREADST + beq + ; end of file + lda BUF, y + bne - + ;; End of line, but not end of file + beq wedge_dos_directory_display +* + lda #K_STS_END_OF_FILE + sta IOSTATUS ; make sure end of file is marked + ;; FALLTROUGH + +wedge_dos_directory_display: + + lda #$00 ; extra protection + sta BUF, y + + ;; Display line + ldx # Date: Fri, 26 Jul 2019 18:30:07 +0200 Subject: [PATCH 79/90] fixes to Kernal character handling routines --- c64/basic/wedge_dos.s | 1 + c64/kernal/chkinout.s | 14 +++++++------- c64/kernal/chrin.s | 6 ++++-- c64/kernal/chrout.s | 43 +++++++++++++++++++++++++++++-------------- c64/kernal/clall.s | 6 +++++- 5 files changed, 46 insertions(+), 24 deletions(-) diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 041949c7..5408f8bb 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -103,6 +103,7 @@ wedge_dos_status: ;; Print out everything retrieved from the drive bne + jsr via_IBASIN + bcs wedge_dos_basic_error jsr via_IBSOUT jmp - * diff --git a/c64/kernal/chkinout.s b/c64/kernal/chkinout.s index 1af2fc02..1075665c 100644 --- a/c64/kernal/chkinout.s +++ b/c64/kernal/chkinout.s @@ -44,13 +44,13 @@ chkin: lda FAT,Y jsr iec_check_devnum bcs chkin_set_device - + jsr talk - bcs chkinout_end ; don't set DFLTN in case of failure + bcs chkinout_device_not_present ; don't set DFLTN in case of failure lda LAT, Y jsr tksa - bcs chkinout_end + bcs chkinout_device_not_present chkin_set_device: lda FAT,Y @@ -126,16 +126,16 @@ ckout: ;; For IEC devices, send LISTEN + SECOND first lda FAT,Y jsr iec_check_devnum - bcs chkin_set_device + bcs chkout_set_device jsr listen - bcs chkinout_end ; don't set DFLTO in case of failure + bcs chkinout_device_not_present ; don't set DFLTO in case of failure lda LAT, Y jsr second - bcs chkinout_end + bcs chkinout_device_not_present -hkout_set_device: +chkout_set_device: lda FAT,Y sta DFLTO clc ; for success diff --git a/c64/kernal/chrin.s b/c64/kernal/chrin.s index b20014e2..8a84f5d6 100644 --- a/c64/kernal/chrin.s +++ b/c64/kernal/chrin.s @@ -15,14 +15,16 @@ ;; Repeated calls after that read out the successive bytes of the line of input. chrin: - ;; First determine the device number + + ;; Determine the device number lda DFLTN beq chrin_keyboard ; #$00 - keyboard ;; XXX add screen support jsr iec_check_devnum - bcs chrin_done_fail ; not a supported device + bcc chrin_iec + jmp lvs_device_not_found_error ; not a supported device chrin_iec: diff --git a/c64/kernal/chrout.s b/c64/kernal/chrout.s index 48f5a606..6f340a0f 100644 --- a/c64/kernal/chrout.s +++ b/c64/kernal/chrout.s @@ -11,40 +11,41 @@ chrout: + sta last_printed_character_ascii + ;; Save X and Y values ;; (Confirmed by writing a test program that X and Y ;; don't get modified, in agreement with C64 PRG's ;; description of CHROUT) - sta last_printed_character_ascii txa pha tya pha php - ;; First determine the device number + ;; Determine the device number lda DFLTO cmp #$03 ; screen beq chrout_screen jsr iec_check_devnum - bcs chrout_done_fail ; not a supported device + bcs chrout_done_unknown_device ; not a supported device chrout_iec: lda last_printed_character_ascii jsr JCIOUT bcc chrout_done - + ;; FALLTROUGH chrout_done_fail: jsr show_cursor_if_enabled - + plp - - ;; Restore X and Y, set carry to mark success on exit + + ;; Restore X and Y pla tay pla @@ -52,12 +53,26 @@ chrout_done_fail: sec ; indicate failure rts +chrout_done_unknown_device: + jsr show_cursor_if_enabled + + plp + + ;; Restore X and Y + pla + tay + pla + tax + + ;; End wioth error + jmp lvs_device_not_found_error + chrout_done: jsr show_cursor_if_enabled - + plp - - ;; Restore X and Y, set carry to mark success on exit + + ;; Restore X and Y pla tay pla @@ -70,12 +85,12 @@ chrout_screen: ;; Crude implementation of character output sei ;; XXX why do we need to disable interrupts? - + jsr hide_cursor_if_visible - + lda last_printed_character_ascii tax - + ;; Check for special characters cmp #$00 @@ -89,7 +104,7 @@ not_00: bne not_0a jmp chrout_done not_0a: - + ;; Carriage return cmp #$0d bne not_0d diff --git a/c64/kernal/clall.s b/c64/kernal/clall.s index 01145a00..ba595c20 100644 --- a/c64/kernal/clall.s +++ b/c64/kernal/clall.s @@ -31,4 +31,8 @@ clall: tay ;; 'C64 Programmers Reference Guide', page 281, claims it calls CLRCHN too - jmp clrchn + jsr clrchn + + ;; Not sure whether original Kernal does so, but it seems sane to also clear possible errors + jmp kernalstatus_reset + From c355b3e46e1cc2111216157dc70ee358010d9cde Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 26 Jul 2019 19:06:26 +0200 Subject: [PATCH 80/90] fix for error reporting in DOS wedge --- c64/basic/wedge_dos.s | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 5408f8bb..0a5261dc 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -190,10 +190,11 @@ wedge_dos_clean_exit: jmp basic_end_of_line wedge_dos_basic_error: + pha + jsr via_ICLALL + pla tax dex - jsr do_basic_error - jsr via_ICLALL - jmp basic_end_of_line + jmp do_basic_error ;; END wedge support From 0396127e69e99190a25630b8430cf651173bab88 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 26 Jul 2019 19:43:04 +0200 Subject: [PATCH 81/90] print status if command failed in DOS wedge --- c64/basic/wedge_dos.s | 45 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 0a5261dc..2eb93cba 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -61,7 +61,16 @@ wedge_dos_command: jsr via_IBSOUT bcs wedge_dos_basic_error - ;; XXX check status - print it if not OK + ;; Retrieve status, print it if not OK + jsr via_ICLALL + jsr wedge_dos_status_get + lda BUF+0 + cmp #$30 ; '0' + bne wedge_dos_status_print + lda BUF+1 + cmp #$30 ; '0' + bne wedge_dos_status_print + ;; Clean-up and exit jmp wedge_dos_clean_exit @@ -82,7 +91,7 @@ wedge_dos_change_drive: sta current_device_number jmp basic_end_of_line -wedge_dos_status: +wedge_dos_status_get: ;; Here the flow is mostly the same as in the example from ;; https://codebase64.org/doku.php?id=base:reading_the_error_channel_of_a_disk_drive @@ -97,20 +106,39 @@ wedge_dos_status: ldx #$0F jsr via_ICHKIN bcs wedge_dos_basic_error + + ldy #$00 * + cpy #$50 ; buffer overflow protection + beq + jsr JREADST ; retrieve errors ;; XXX error in case of status != EOF ;; Print out everything retrieved from the drive bne + jsr via_IBASIN bcs wedge_dos_basic_error - jsr via_IBSOUT + sta BUF, y + iny jmp - * - ;; Print new line - lda #$0D - jsr via_IBSOUT + rts +wedge_dos_status: + jsr wedge_dos_status_get + ;; FALLTROUGH + +wedge_dos_status_print: + + ;; Print buffered status + ldx #$00 +* + dey + bmi + + lda BUF, x + jsr via_IBSOUT + inx + bne - +* ;; Clean-up and exit jmp wedge_dos_clean_exit @@ -173,7 +201,7 @@ wedge_dos_directory_line: wedge_dos_directory_display: - lda #$00 ; extra protection + lda #$00 ; extra protection agains buffer overflow sta BUF, y ;; Display line @@ -187,6 +215,9 @@ wedge_dos_directory_display: wedge_dos_clean_exit: jsr via_ICLALL + ;; Print new line + lda #$0D + jsr via_IBSOUT jmp basic_end_of_line wedge_dos_basic_error: From aa7e2205758bf113cc2a5319360e7887078b8b93 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Fri, 26 Jul 2019 21:18:01 +0200 Subject: [PATCH 82/90] shortened DOS wedge implementation --- c64/basic/wedge_dos.s | 51 ++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 2eb93cba..5c58829e 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -37,29 +37,12 @@ wedge_dos: wedge_dos_command: - ;; Set remaining file parameters, open the channel - lda #$00 ; empty file name + ;; Provide command name + jsr wedge_dos_setnam + jsr JSETNAM jsr via_IOPEN bcs wedge_dos_basic_error -* - ;; Set channel for output - ldx #$0F - jsr via_ICKOUT - bcs wedge_dos_basic_error -* - jsr basic_fetch_and_consume_character - cmp #$00 - beq + - - jsr via_IBSOUT - bcs wedge_dos_basic_error - jmp - -* - ;; Finalize command - lda #$0D - jsr via_IBSOUT - bcs wedge_dos_basic_error ;; Retrieve status, print it if not OK jsr via_ICLALL @@ -149,18 +132,8 @@ wedge_dos_directory: lda #$00 sta current_secondary_address - ;; Now determine the length of the 'file' name - ldy #$FF -* - iny - lda (basic_current_statement_ptr), y - bne - - - ;; Set the name to open - tya - ldx basic_current_statement_ptr+0 - ldy basic_current_statement_ptr+1 - jsr JSETNAM + ;; Provide file name + jsr wedge_dos_setnam ;; Open the file jsr via_IOPEN @@ -228,4 +201,18 @@ wedge_dos_basic_error: dex jmp do_basic_error +wedge_dos_setnam: + ;; Now determine the length of the 'file' name + ldy #$FF +* + iny + lda (basic_current_statement_ptr), y + bne - + + ;; Set the name to open + tya + ldx basic_current_statement_ptr+0 + ldy basic_current_statement_ptr+1 + jmp JSETNAM + ;; END wedge support From 9ea1c04da3609fad527a519727c4017e69ec5b39 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 27 Jul 2019 21:14:35 +0200 Subject: [PATCH 83/90] fixed SETNAM storing pointer in wrong place --- c64/aliases/,aliases_ram_lowmem.s | 4 +++- c64/kernal/setnam.s | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/c64/aliases/,aliases_ram_lowmem.s b/c64/aliases/,aliases_ram_lowmem.s index 0cef3f43..311fbf87 100644 --- a/c64/aliases/,aliases_ram_lowmem.s +++ b/c64/aliases/,aliases_ram_lowmem.s @@ -41,7 +41,9 @@ .alias CMP0 $B0 ; $B0-$B1 .alias FNLEN $B7 ; current file name length - + + .alias FNADDR $BB ; $BB-$BC, current file name pointer + .alias STAL $C1 ; $C1-$C2 LOAD/SAVE start address ;; diff --git a/c64/kernal/setnam.s b/c64/kernal/setnam.s index 49a47da0..0cbead31 100644 --- a/c64/kernal/setnam.s +++ b/c64/kernal/setnam.s @@ -14,7 +14,7 @@ setnam: ;; I hope this one won't cause similarity to CBM code sta FNLEN - sty STAL + 1 - stx STAL + 0 + sty FNADDR + 1 + stx FNADDR + 0 rts From ccb78c10b4e884e58672a5f41704eb1da498f3e5 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 28 Jul 2019 11:18:21 +0200 Subject: [PATCH 84/90] DOS wedge can now display directories --- STATUS.md | 13 ++++++++----- c64/basic/wedge_dos.s | 22 +++++++++++++++++----- c64/kernal/iec/iec_cmd_close.s | 8 ++------ c64/kernal/iec/iec_cmd_open.s | 21 +++++++++++++++++---- c64/kernal/open.s | 6 ++++-- 5 files changed, 48 insertions(+), 22 deletions(-) diff --git a/STATUS.md b/STATUS.md index c4d99e8d..5132287c 100644 --- a/STATUS.md +++ b/STATUS.md @@ -5,10 +5,14 @@ Here are the features of the Open ROMs not found in the original ROMs from the 8 * improved keyboard scanning, supports multi-key roll-over and rejection of spurious joystick input * joystick (port 1) can be used to move text cursor -* banking in the BASIC interpreter: 61436 bytes free -* LOAD start/end addresses are displayed, in the Final cartridge style -* LOAD command with just the file name tries to use the last device if it's number seems sane; otherwise uses 8 -* LOAD secondary address over 255 is considered a start address; NOTE: syntax will most likely change here in the future! +* uses RAM under ROM and I/O: 61436 bytes free +* 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 + * secondary address over 255 is considered a start address +* DOS wedge (direct mode only) - `@`, `@`, `@$`, `@$`, `@` + +NOTE: extra features and their syntax can change in the future! # Features missing @@ -27,7 +31,6 @@ The following ROM features are currently missing: Features currently being worked on: * IEC support -* DOS wedge # API status diff --git a/c64/basic/wedge_dos.s b/c64/basic/wedge_dos.s index 5c58829e..e147e9fe 100644 --- a/c64/basic/wedge_dos.s +++ b/c64/basic/wedge_dos.s @@ -129,8 +129,11 @@ wedge_dos_directory: ;; First change the secondary address to the one suitable for ;; directory loading - lda #$00 - sta current_secondary_address + ;; XXX + lda #$00 ; logical device number + ldx current_device_number + ldy #$60 + jsr JSETFLS ;; Provide file name jsr wedge_dos_setnam @@ -139,8 +142,8 @@ wedge_dos_directory: jsr via_IOPEN bcs wedge_dos_basic_error - ;; Set channel for input - ldx #$0F + ;; Set channel for file reading + ldx #$00 jsr via_ICHKIN bcs wedge_dos_basic_error @@ -162,7 +165,9 @@ wedge_dos_directory_line: cpy #$50 beq + ; line too long, terminate loading file jsr JREADST - beq + ; end of file + bne + ; end of file + cpy #$04 ; 2 bytes (pointer to next line) + 2 bytes (line number) + bcc - lda BUF, y bne - ;; End of line, but not end of file @@ -174,11 +179,18 @@ wedge_dos_directory_line: wedge_dos_directory_display: + cpy #$05 ; protection against malformed directory + bcc wedge_dos_clean_exit + lda #$00 ; extra protection agains buffer overflow sta BUF, y ;; Display line ldx #BUF + stx basic_current_line_ptr+1 + ldx #basic_current_line_ptr jsr list_single_line ;; Read & display next line or quit diff --git a/c64/kernal/iec/iec_cmd_close.s b/c64/kernal/iec/iec_cmd_close.s index 552428a2..60c30a96 100644 --- a/c64/kernal/iec/iec_cmd_close.s +++ b/c64/kernal/iec/iec_cmd_close.s @@ -7,12 +7,8 @@ iec_cmd_close: - jsr iec_tx_flush - - ;; Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031), - ;; allowed channels are 0-15; report error if out of range - cmp #$10 - bcc + + jsr iec_check_channel_openclose + bcc + jmp kernalerror_FILE_NOT_INPUT * ora #$E0 diff --git a/c64/kernal/iec/iec_cmd_open.s b/c64/kernal/iec/iec_cmd_open.s index cd184307..aa23a2c5 100644 --- a/c64/kernal/iec/iec_cmd_open.s +++ b/c64/kernal/iec/iec_cmd_open.s @@ -8,10 +8,8 @@ iec_cmd_open: ; similar to TKSA, but without turnaround - ;; Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031), - ;; allowed channels are 0-15; report error if out of range - cmp #$10 - bcc + + jsr iec_check_channel_openclose + bcc + jmp kernalerror_FILE_NOT_INPUT * ora #$F0 @@ -27,3 +25,18 @@ common_open_close_unlsn_second: ; common part of several commands * rts +iec_check_channel_openclose: + ;; Due to OPEN/CLOSE/TKSA/SECOND command encoding (see https://www.pagetable.com/?p=1031), + ;; allowed channels are 0-15; report error if out of range + cmp #$10 + bcc + + ;; Workaround to allow reading executable files and disk directory + ;; using OPEN routine - see https://www.pagetable.com/?p=273 for + ;; example usage + cmp #$60 + beq + + sec ; mark unsuitable channel number + rts +* + clc ; mark suitable channel number + rts diff --git a/c64/kernal/open.s b/c64/kernal/open.s index 4cecbfe3..8d494dfe 100644 --- a/c64/kernal/open.s +++ b/c64/kernal/open.s @@ -78,9 +78,11 @@ open_iec: bcc + jmp kernalerror_DEVICE_NOT_FOUND ; XXX find a better error message for wrong channel (create new one?) * + + ;; We need our helpers to get to filenames under ROMs or IO area + jsr install_ram_routines + ;; Send command ('file name') jsr lvs_send_file_name jmp open_done_success - - From 73cd1131d4b4b496203897117e64b4e8e673a345 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 28 Jul 2019 11:49:35 +0200 Subject: [PATCH 85/90] fix for improper loop in CLOSE routine --- c64/kernal/close.s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/c64/kernal/close.s b/c64/kernal/close.s index ad218fec..fc8e0a8c 100644 --- a/c64/kernal/close.s +++ b/c64/kernal/close.s @@ -45,7 +45,7 @@ close_remove_from_table: sta FAT-1, y lda SAT, y sta SAT-1, y - jmp - + jmp close_remove_from_table * ;; Decrement the list size variable dec LDTND From 9529d0589dd9b40bcea5af388b1baf499ee61421 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 28 Jul 2019 20:27:33 +0200 Subject: [PATCH 86/90] updated documentation and pre-built binaries --- CONTRIBUTORS.md | 2 + STATUS.md | 87 +++++++++++++++++++------------------- bin/basic_generic.rom | Bin 8192 -> 8192 bytes bin/basic_mega65.rom | Bin 8192 -> 8192 bytes bin/basic_ultimate64.rom | Bin 8192 -> 8192 bytes bin/kernal_generic.rom | Bin 8192 -> 8192 bytes bin/kernal_mega65.rom | Bin 8192 -> 8192 bytes bin/kernal_ultimate64.rom | Bin 8192 -> 8192 bytes 8 files changed, 46 insertions(+), 43 deletions(-) create mode 100644 CONTRIBUTORS.md diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md new file mode 100644 index 00000000..2bb826fe --- /dev/null +++ b/CONTRIBUTORS.md @@ -0,0 +1,2 @@ + +Although the project itself is LGPL3, I (FeralChild64) allow to redistribute my contributions to this project under any OSI (Open Source Initiative) approved open source license. diff --git a/STATUS.md b/STATUS.md index 5132287c..286da229 100644 --- a/STATUS.md +++ b/STATUS.md @@ -30,8 +30,7 @@ The following ROM features are currently missing: Features currently being worked on: -* IEC support - +* IEC support needs more testing ang bugfixing; alternative drive ROMs (JiffyDOS, DolphinDOS, etc) usually don't work with current implementation, `@$` leaves the drive led on, most likely other problems can be found # API status @@ -67,49 +66,51 @@ Note: only the jump table addresses are currently supported, real routine addres NOTE: Even the 'DONE' routines won't support features described as missing in one of the previous chapters! +
-| Address | Name | Status | Remarks | -| ------- | :----: | :------: | :-------------------------------------------: | -| $FF81 | CINT | PARTIAL | at least PAL/NTSC detection is missing | -| $FF84 | IOINIT | PARTIAL | at least SID volume handling is missing | -| $FF87 | RAMTAS | DONE | | -| $FF8A | RESTOR | PARTIAL | CBINV, NMINV, and USRCMD missing | -| $FF8D | VECTOR | DONE | | -| $FF90 | SETMSG | DONE | | -| $FF93 | SECOND | DONE | | -| $FF96 | TKSA | DONE | | -| $FF99 | MEMTOP | DONE | | -| $FF9C | MEMBOT | DONE | | -| $FF9F | SCNKEY | DONE | could be better integrated with ROM (aliases) | -| $FFA2 | SETTMO | NOT DONE | | -| $FFA5 | ACPTR | DONE | | -| $FFA8 | CIOUT | DONE | | -| $FFAB | UNTLK | DONE | | -| $FFAE | UNLSN | DONE | | -| $FFB1 | LISTEN | DONE | | -| $FFB4 | TALK | DONE | | -| $FFB7 | READST | DONE | | -| $FFBA | SETFLS | DONE | | -| $FFBD | SETNAM | DONE | | -| $FFC0 | OPEN | DONE | | -| $FFC3 | CLOSE | DONE | | -| $FFC6 | CHKIN | DONE | | -| $FFC9 | CHKOUT | PARTIAL | | -| $FFCC | CLRCHN | DONE | | -| $FFCF | CHRIN | PARTIAL | | -| $FFD2 | CHROUT | PARTIAL | | -| $FFD5 | LOAD | PARTIAL | * work in progress, no VERIFY support yet | -| $FFD8 | SAVE | NOT DONE | * work in progress | -| $FFDB | SETTIM | NOT DONE | | -| $FFDE | RDTIM | NOT DONE | | -| $FFE1 | STOP | PARTIAL | no connection with UDTIM | -| $FFE4 | GETIN | PARTIAL | * work in progress | -| $FFE7 | CLALL | DONE | | -| $FFEA | UDTIM | NOT DONE | | -| $FFED | SCREEN | DONE | | -| $FFF0 | PLOT | NOT DONE | | -| $FFF3 | IOBASE | DONE | | +| Address | Name | Status | Remarks | +| --------- | :------- | :------: | :------------------------------------------------: | +| `$FF81` | `CINT` | PARTIAL | at least PAL/NTSC detection is missing | +| `$FF84` | `IOINIT` | PARTIAL | at least SID volume handling is missing | +| `$FF87` | `RAMTAS` | DONE | | +| `$FF8A` | `RESTOR` | PARTIAL | CBINV, NMINV, and USRCMD missing | +| `$FF8D` | `VECTOR` | DONE | | +| `$FF90` | `SETMSG` | DONE | | +| `$FF93` | `SECOND` | DONE | | +| `$FF96` | `TKSA` | DONE | | +| `$FF99` | `MEMTOP` | DONE | | +| `$FF9C` | `MEMBOT` | DONE | | +| `$FF9F` | `SCNKEY` | DONE | could be better integrated with ROM (aliases) | +| `$FFA2` | `SETTMO` | NOT DONE | | +| `$FFA5` | `ACPTR` | DONE | | +| `$FFA8` | `CIOUT` | DONE | | +| `$FFAB` | `UNTLK` | DONE | | +| `$FFAE` | `UNLSN` | DONE | | +| `$FFB1` | `LISTEN` | DONE | | +| `$FFB4` | `TALK` | DONE | | +| `$FFB7` | `READST` | DONE | | +| `$FFBA` | `SETFLS` | DONE | | +| `$FFBD` | `SETNAM` | DONE | | +| `$FFC0` | `OPEN` | DONE | | +| `$FFC3` | `CLOSE` | PARTIAL | most likely incompleete, @$ doesn't end properly | +| `$FFC6` | `CHKIN` | DONE | | +| `$FFC9` | `CHKOUT` | PARTIAL | | +| `$FFCC` | `CLRCHN` | DONE | | +| `$FFCF` | `CHRIN` | PARTIAL | | +| `$FFD2` | `CHROUT` | PARTIAL | | +| `$FFD5` | `LOAD` | PARTIAL | no VERIFY support yet | +| `$FFD8` | `SAVE` | NOT DONE | | +| `$FFDB` | `SETTIM` | NOT DONE | | +| `$FFDE` | `RDTIM` | NOT DONE | | +| `$FFE1` | `STOP` | PARTIAL | no connection with UDTIM | +| `$FFE4` | `GETIN` | PARTIAL | only some devices supported | +| `$FFE7` | `CLALL` | DONE | | +| `$FFEA` | `UDTIM` | NOT DONE | | +| `$FFED` | `SCREEN` | DONE | | +| `$FFF0` | `PLOT` | NOT DONE | | +| `$FFF3` | `IOBASE` | DONE | | +
### Unofficial Kernal locations diff --git a/bin/basic_generic.rom b/bin/basic_generic.rom index 03de6613748c144323724a5c6387d7ee08b6c64c..eeacf26d0890b752594523e8702d2bde4200c278 100644 GIT binary patch delta 2218 zcmcf?TWlLub{?LLT_>?yB_${h(E-L>XRPEm1q1aR{Ok zUwo|Wx#!;Vy61fl^d9KtUn@>n{85hmT#~u1!j2qnH>9t)rgY~h-9$FiF4B#LE!rc* z9Uga%%8b&3_E@IBr#%h(0%VZJ_c3I@(j#+dj3b*${@R5PE1vm|b@lHr*4AG!D@M;$ z=sOEn^E@@i1O9n4y@0-4yqf%fJEecM^p9VOR$9ogw1^x*lb+02gAl?WbN2NBLey@{ zM(r-Mx?~Ny%{Fp3;3snEIf|w{#9LWDjsHe{`I+1}!`W@l{o||;`f-Y)^%kvnd3>`$ z>+E1ufMncikVzc=kH##DgR~MsAy5Q6nVIf$>(GSfM9{JY)FFl|;WN1;=vSCbTWE^m zP`x$h`~dnjMxB(?NwC?shqui86$Vt9{UB`K=`RV{EBUY&)PU-!uR1&($X+;4I??X7LlMv|ZS+>|IquV0NldaxSE_I@n4Xp_ThkmEICIa&U5m#%(^` z>HzVG8=Cf<(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ivp v!tLZ3V}Ny<11JYH4Rg3zB>~r37rL*S_)f)eTgQ3mozK5>%`G4Uu2260R~TZ; diff --git a/bin/basic_mega65.rom b/bin/basic_mega65.rom index 3569d43b1404f7907c216ea92c2c50c655fc6ccb..26fe93850970a05ad1f778df21c788e885132d7e 100644 GIT binary patch delta 2065 zcmc&#eQeZZ7;k%bYj4Na-m;AohP(_WOg_Ajz&>PisKg__k}-^g#F!guatl$2{$U(3 z#~*ZAQ1I}L1~Hhk+`DVLk82NwY_eo(G}jZg>J(#iGc%A0h*c(r5ILXTn32RkO-$SO zNcE(Dp2C@wM6> zTsn|slok}u8t$65gu1+PH*M`=~?2W_(mRV;;`l`c!6ve^U-+wIcr+ z?N*t{pluw^wwv);avnDS%Mdkh22sNud`g8Z98(OnBn>S?cP4kQ!t-D{Su=WZkI)$0(XHX_e!_T!vO!g5-l> z@ELgo2aapZoH}SLBKjH(!79m&wL6vQRKXU}zJO$%Q9dQ@VS1ZuRFCD0|s0}KY7GE zS##E)4UOkk>$LIQ8njK<5GX3ONK51WS+do)m?m8%D}vvri!Q~~oP8mtRiY`Pl-$Klr^%Nk z>)9z%%GboF%$RDfs~0WN@sAbk{wV5J-4E|lb4McPI=E3xjk*${u5$fI1aDU0Ff zn+abr_&uxluR-NHT`9NFRdOrz7V?#_l)Xl-35&UEo&4;t34f;_5?DI4FG3KTWB~7KbhX(Y#bRo$AGPW-_=C!Z77=w z({SsYeNuY`=3===$%(RU?x{lg+C}gS`7{)@*4QEyt%Ada++-K=H$$N)nk3uHR|?}9 z*rD+ZIZ(c&s?I=H75v%|NGZaroq6fHyeCTDD_=@}EU#Ouxi$DjL0JNAfi{CV5jFIq z&07#doBNvFE0h5n67Guvq?YpN=yRl5+zs7Hj-jBT@bBz=b$edA25Wf9nbMj-opHXC zc1piuHbbtIF0Y_15!xD|LgP6;)a8rlNGI=#kGq#a(t^N21D!R%GN4U1Njrs0Lo@&~ z6C@+u=JjRJ3^^m!L!`BP0E?IoUe2~L*WV&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a5536cb00e4045f1a2c027fdb0fe Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 29 Jul 2019 18:25:32 +0200 Subject: [PATCH 87/90] explained some similarity tool positive results --- strings/000000A9 | 1 + strings/0000A9 | 1 + strings/0220DA | 3 +++ strings/034C37 | 3 +++ strings/034C48 | 3 +++ strings/034C73 | 3 +++ strings/29EF8D | 3 +++ strings/60AD00DD09 | 4 ++++ strings/7AA47B | 3 +++ strings/AA208E | 3 +++ strings/BAFF20 | 3 +++ strings/F7206F | 3 +++ 12 files changed, 33 insertions(+) create mode 100644 strings/000000A9 create mode 100644 strings/0000A9 create mode 100644 strings/0220DA create mode 100644 strings/034C37 create mode 100644 strings/034C48 create mode 100644 strings/034C73 create mode 100644 strings/29EF8D create mode 100644 strings/60AD00DD09 create mode 100644 strings/7AA47B create mode 100644 strings/AA208E create mode 100644 strings/BAFF20 create mode 100644 strings/F7206F diff --git a/strings/000000A9 b/strings/000000A9 new file mode 100644 index 00000000..88f49cb5 --- /dev/null +++ b/strings/000000A9 @@ -0,0 +1 @@ +A string of empty bytes followed by half an instruction. Not copyrightable diff --git a/strings/0000A9 b/strings/0000A9 new file mode 100644 index 00000000..88f49cb5 --- /dev/null +++ b/strings/0000A9 @@ -0,0 +1 @@ +A string of empty bytes followed by half an instruction. Not copyrightable diff --git a/strings/0220DA b/strings/0220DA new file mode 100644 index 00000000..ab518d6c --- /dev/null +++ b/strings/0220DA @@ -0,0 +1,3 @@ +fragment + JSR + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034C37 b/strings/034C37 new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034C37 @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034C48 b/strings/034C48 new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034C48 @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034C73 b/strings/034C73 new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034C73 @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/29EF8D b/strings/29EF8D new file mode 100644 index 00000000..8e99ad35 --- /dev/null +++ b/strings/29EF8D @@ -0,0 +1,3 @@ +AND #$EF + STA without address + +Clear a bit + a half of other instruction - not copyrightable. diff --git a/strings/60AD00DD09 b/strings/60AD00DD09 new file mode 100644 index 00000000..47b2fff5 --- /dev/null +++ b/strings/60AD00DD09 @@ -0,0 +1,4 @@ +fragment (or, most likely, RTS belonging to previous routine) + LDA $DD00 + ORA without matching argument + +$DD00 is a register for VIC bank switching and IEC access, using it typically requires bit manipulation. +Nothing creative here - not copyrightable. diff --git a/strings/7AA47B b/strings/7AA47B new file mode 100644 index 00000000..ea849b8b --- /dev/null +++ b/strings/7AA47B @@ -0,0 +1,3 @@ +Access to $7A (but instruction opcode does not match) + LDY $7B ($7A-$7B is a documented vector) + +Instruction and a half, clearly a zeropage vector access - not copyrightable. diff --git a/strings/AA208E b/strings/AA208E new file mode 100644 index 00000000..46ef467b --- /dev/null +++ b/strings/AA208E @@ -0,0 +1,3 @@ +TAX (or instruction fragment) + JSR + lower byte of jump address + +At most instruction and a half - not copyrightable. diff --git a/strings/BAFF20 b/strings/BAFF20 new file mode 100644 index 00000000..95fcfa02 --- /dev/null +++ b/strings/BAFF20 @@ -0,0 +1,3 @@ +address $FFBA (jump table position of SETLFS) + JSR without address + +Not even a full instruction - not copyrightable. diff --git a/strings/F7206F b/strings/F7206F new file mode 100644 index 00000000..ab518d6c --- /dev/null +++ b/strings/F7206F @@ -0,0 +1,3 @@ +fragment + JSR + lower byte of jump address + +Not even a full instruction - not copyrightable. From 49c6f4d081e3e532bb0e57895fa70f17fcc8dfc9 Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sat, 3 Aug 2019 22:02:56 +0200 Subject: [PATCH 88/90] all >3 length similarities explained, reworked via_vector to avoid accidental similarity, small project files fixes --- .gitignore | 5 +++ Makefile | 2 +- bin/basic_generic.rom | Bin 8192 -> 8192 bytes bin/basic_mega65.rom | Bin 8192 -> 8192 bytes bin/basic_ultimate64.rom | Bin 8192 -> 8192 bytes c64/basic/via_vector.s | 44 +++++++++++++------------ strings/00003C | 3 ++ strings/0002A2 | 3 ++ strings/002090FF | 3 ++ strings/006020 | 3 ++ strings/00990001 | 3 ++ strings/00990002 | 3 ++ strings/00DD60AD00DD09 | 5 +++ strings/026020 | 3 ++ strings/02B96302 | 4 +++ strings/02B96D02 | 3 ++ strings/032060 | 3 ++ strings/034C09 | 3 ++ strings/034C33 | 3 ++ strings/034C83 | 3 ++ strings/034C9E | 3 ++ strings/034CFB | 3 ++ strings/034CFC | 3 ++ strings/036C1C036C | 3 ++ strings/036C1E036C | 3 ++ strings/036C20036C | 3 ++ strings/036C22036C | 3 ++ strings/036C24036C | 3 ++ strings/036C2603 | 3 ++ strings/036C2A036C | 4 +++ strings/036C2C03 | 3 ++ strings/090185 | 3 ++ strings/093020 | 4 +++ strings/098085 | 3 ++ strings/0A90034C | 4 +++ strings/0D4C4F4144494E | 5 +++ strings/0D534541524348494E47 | 3 ++ strings/0D564552494659494E | 3 ++ strings/108D00DD | 3 ++ strings/18607820 | 3 ++ strings/1860A59D10 | 3 ++ strings/2046524F4D20 | 3 ++ strings/204F5045 | 3 ++ strings/208EA6A9 | 3 ++ strings/20BDFF20 | 3 ++ strings/29DF8D00DD | 3 ++ strings/29DF8D00DD60AD00DD | 5 +++ strings/29EF8D00DD60 | 5 +++ strings/29EF8D00DD60AD00DD09 | 5 +++ strings/29F78D00DD | 3 ++ strings/29F78D00DD60 | 5 +++ strings/386020 | 3 ++ strings/3ED0034C37 | 3 ++ strings/4CBDFFA9 | 3 ++ strings/4F5045 | 3 ++ strings/524F4D | 3 ++ strings/564552 | 3 ++ strings/5645524946 | 3 ++ strings/5902D0F8 | 3 ++ strings/6020A0E5A900 | 0 strings/6031EA | 3 ++ strings/60A59D10 | 3 ++ strings/60A59D10FB | 3 ++ strings/60AD00DD0910 | 5 +++ strings/60AD00DD09108D00DD | 5 +++ strings/630285 | 3 ++ strings/686020 | 3 ++ strings/6C1A036C | 3 ++ strings/7AD0034C | 3 ++ strings/9914038810 | 3 ++ strings/A000B17AD0 | 3 ++ strings/A59AC903 | 3 ++ strings/A5BAC902D0 | 3 ++ strings/A67AA47B | 5 +++ strings/A90020BDFF | 4 +++ strings/A90020BDFF20 | 3 ++ strings/A9009900 | 3 ++ strings/B190034C | 3 ++ strings/B1B0034C | 3 ++ strings/BAA90085 | 3 ++ strings/C8B17AF0 | 3 ++ strings/C8C4B7 | 3 ++ strings/D0034C37 | 3 ++ strings/DD09108D00DD | 5 +++ strings/DD29DF8D00DD60AD00DD | 5 +++ strings/DD29DF8D00DD60AD00DD09208D00DD | 5 +++ strings/DD29EF8D00DD | 5 +++ strings/DD29EF8D00DD60 | 5 +++ strings/DD29EF8D00DD60AD00DD09 | 5 +++ strings/DD29F78D00DD60 | 5 +++ strings/DD60AD00DD09208D00DD | 5 +++ strings/DF8D00DD | 3 ++ strings/DF8D00DD60AD00DD | 5 +++ strings/E5C91DD0 | 3 ++ strings/EF8D00DD60AD00DD09 | 5 +++ strings/F6A90085 | 3 ++ strings/F78D00DD60 | 5 +++ 97 files changed, 344 insertions(+), 22 deletions(-) create mode 100644 strings/00003C create mode 100644 strings/0002A2 create mode 100644 strings/002090FF create mode 100644 strings/006020 create mode 100644 strings/00990001 create mode 100644 strings/00990002 create mode 100644 strings/00DD60AD00DD09 create mode 100644 strings/026020 create mode 100644 strings/02B96302 create mode 100644 strings/02B96D02 create mode 100644 strings/032060 create mode 100644 strings/034C09 create mode 100644 strings/034C33 create mode 100644 strings/034C83 create mode 100644 strings/034C9E create mode 100644 strings/034CFB create mode 100644 strings/034CFC create mode 100644 strings/036C1C036C create mode 100644 strings/036C1E036C create mode 100644 strings/036C20036C create mode 100644 strings/036C22036C create mode 100644 strings/036C24036C create mode 100644 strings/036C2603 create mode 100644 strings/036C2A036C create mode 100644 strings/036C2C03 create mode 100644 strings/090185 create mode 100644 strings/093020 create mode 100644 strings/098085 create mode 100644 strings/0A90034C create mode 100644 strings/0D4C4F4144494E create mode 100644 strings/0D534541524348494E47 create mode 100644 strings/0D564552494659494E create mode 100644 strings/108D00DD create mode 100644 strings/18607820 create mode 100644 strings/1860A59D10 create mode 100644 strings/2046524F4D20 create mode 100644 strings/204F5045 create mode 100644 strings/208EA6A9 create mode 100644 strings/20BDFF20 create mode 100644 strings/29DF8D00DD create mode 100644 strings/29DF8D00DD60AD00DD create mode 100644 strings/29EF8D00DD60 create mode 100644 strings/29EF8D00DD60AD00DD09 create mode 100644 strings/29F78D00DD create mode 100644 strings/29F78D00DD60 create mode 100644 strings/386020 create mode 100644 strings/3ED0034C37 create mode 100644 strings/4CBDFFA9 create mode 100644 strings/4F5045 create mode 100644 strings/524F4D create mode 100644 strings/564552 create mode 100644 strings/5645524946 create mode 100644 strings/5902D0F8 create mode 100644 strings/6020A0E5A900 create mode 100644 strings/6031EA create mode 100644 strings/60A59D10 create mode 100644 strings/60A59D10FB create mode 100644 strings/60AD00DD0910 create mode 100644 strings/60AD00DD09108D00DD create mode 100644 strings/630285 create mode 100644 strings/686020 create mode 100644 strings/6C1A036C create mode 100644 strings/7AD0034C create mode 100644 strings/9914038810 create mode 100644 strings/A000B17AD0 create mode 100644 strings/A59AC903 create mode 100644 strings/A5BAC902D0 create mode 100644 strings/A67AA47B create mode 100644 strings/A90020BDFF create mode 100644 strings/A90020BDFF20 create mode 100644 strings/A9009900 create mode 100644 strings/B190034C create mode 100644 strings/B1B0034C create mode 100644 strings/BAA90085 create mode 100644 strings/C8B17AF0 create mode 100644 strings/C8C4B7 create mode 100644 strings/D0034C37 create mode 100644 strings/DD09108D00DD create mode 100644 strings/DD29DF8D00DD60AD00DD create mode 100644 strings/DD29DF8D00DD60AD00DD09208D00DD create mode 100644 strings/DD29EF8D00DD create mode 100644 strings/DD29EF8D00DD60 create mode 100644 strings/DD29EF8D00DD60AD00DD09 create mode 100644 strings/DD29F78D00DD60 create mode 100644 strings/DD60AD00DD09208D00DD create mode 100644 strings/DF8D00DD create mode 100644 strings/DF8D00DD60AD00DD create mode 100644 strings/E5C91DD0 create mode 100644 strings/EF8D00DD60AD00DD09 create mode 100644 strings/F6A90085 create mode 100644 strings/F78D00DD60 diff --git a/.gitignore b/.gitignore index 8066747b..fe4f9202 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,11 @@ temp.map ophis.bin build/* +# Input to the similarity tool - copyrighted material, we can't check it in! + +basic +kernal + # Various IDE project files, temporary files, etc. *project diff --git a/Makefile b/Makefile index ca8a7df0..62d70ab1 100644 --- a/Makefile +++ b/Makefile @@ -143,6 +143,6 @@ testremote: build/newkern_generic build/newbasic_generic testm65: build/newc65 m65 -b ../mega65-core/bin/mega65r1.bit -k ../mega65-core/bin/KICKUP.M65 -R build/newc65 -4 -testsimilarity: build/newrom_generic src/similarity +testsimilarity: build/newrom_generic $(TOOL_SIMILARITY) $(TOOL_SIMILARITY) kernal build/newrom_generic $(TOOL_SIMILARITY) basic build/newrom_generic diff --git a/bin/basic_generic.rom b/bin/basic_generic.rom index eeacf26d0890b752594523e8702d2bde4200c278..29d891b14b253a4c8bb483069f8d0b857bb2b031 100644 GIT binary patch delta 297 zcmZp0XmHpN!osLHIh4hWlV{@uW}o7v3W}4bu$Xc~d5icJ_$Oas(Uq0n_~ODBpNyp| z8J6u@kf5;Zze4R&1)hx?A{Q|LRmib=^D1s!$*Ul}(T97nhl1kfGFCfA9_fu4D^6T^ zm9bJpL3;85wsc16$r|i3K+=_6fl+#M8ha5VBirPg93O!~r#TJyf$BB+ISo!)O<>Ao z^O2s+#nl9q>E&7gB=xvmfLe;Vtr>xw^*la&(i=})*tT*K&`OZKn>l&UF#%<6@ZXmQ zir52%Ggc||EnBGoWGzwzu|Tc^5tFY8XlMW(YQ8$hkU7VIIY)*$M~XQ|jyXq#IY)~* XM}av^;4MA?z)4>E delta 297 zcmZp0XmHpN!onywIh4hWlX>F=W}o7v3UZUDu$Xc~d5icJI456W(Ule5_~ODBpNyp| z8J6u@kf5;Zze4R&1?G(#A{Q|LRmib=^U7^p$*Ul`(T97nhl1SZGFCfA9?^{%D^6T^ zm9bJpL3Hu~wsc0($r|i3K+=_6fl+jG8ha5VqvGV793O!~r#TJyf$BB+ISo!)O<>Ao z^AVlQ#nl9q>E&7gB=xvmfLe;Vtr>xw^*la&q8m?K*tT*K&`OZKn>l&UF#%<6@ZXmQ zir52%Ggc||EnBGoWGzwzu|Tc^5tFY8XlMW(YQ8#0iaAGyIY*8;M}avi#bP!ImduG$8fWn;4MA?Qx0BI diff --git a/bin/basic_mega65.rom b/bin/basic_mega65.rom index 26fe93850970a05ad1f778df21c788e885132d7e..a72bf16dec2554796fc9a9aecff28a81c3081bd4 100644 GIT binary patch delta 321 zcmZp0XmHpN!ov7&awv-#=go~1n0<KoxSV-n{QNuH;pCvC)Tnv4_ID&1I}yjEpZfH?sLL z^1RrXvEsyqR~ais6kbfe&7Lj?64+>}$^Sw5B>xBDRWm#u@PFWX!0>@>FZTkVk^~L~ zkXDW&M#jsNzi>Wad@=bdR|JsMyc+sa8m2Z3C*`3~<2W_cjn9w?BpN@3;ll?p)CB1I4jKoxSV-n_3juH;pCw9$uqv4_Iz&1I}yjEs*qH?sLL z@;us@vEsyqR~ais6dp~!&7Lj?64+>}$^Sw5B>xBDRWm#u@PFWX!0>@>FZTkVk^~L~ zkXDW&M#guOzi>Wad^GtgR|JsM2wsc0_$r|i3K+=_6fl+sJ8ha5Vqr~K!93O!~r#TJyf$BB+ISo!)O<>Ao z^UE&7gB=xvmfLe;Vtr>xw^*la&x*Jbi*tT*K&`OZKn>l$WGXWLM<=0`9 z2MXB(#WPkZ^etPd0Awvv1hGKQ0}+#72xw>kU248M$B;S4fH_BoIY){)M~*p1g*iuy YIY)sxM~yj0i8)7yIY(o&h2RN305|?%XaE2J delta 298 zcmZp0XmHpN!op}UIh4hWQ*`45W}o7v3I>y>u$Xc~d5icJq$git(Un!-_~ODBpNyp| z8J6u@kf5;Zze4R&1<{QgA{Q|LRmib=^BQbi$*Z8g(T97nhl0W8GFCfA9`%hGD^6T^ zm9bJpL4EQ8wsc1I$r|i3K+=_6fl+;P8ha5Vqw(aM93O!~r#TJyf$BB+ISo!)O<>Ao z^HHD7#nl9q>E&7gB=xvmfLe;Vtr>xw^*la&>Kjj7*tT*K&`OZKn>l$WGXWLM<=0`9 z2MXB(#WPkZ^etPd0Awvv1hGKQ0}+#72xw>kU248MM~XQ|hB-%$IY)sxM~OK{g*iu! YIY)yzM~gW}hdIZ9Imd9bh2RN30Ln05zyJUM diff --git a/c64/basic/via_vector.s b/c64/basic/via_vector.s index e6a0be1a..3cfc7480 100644 --- a/c64/basic/via_vector.s +++ b/c64/basic/via_vector.s @@ -2,39 +2,41 @@ ;; ;; Helper routines for jumping via vectors, to be used with JSR ;; +;; Note: they are not in the order of low memory vectors, to avoid +;; similarity with the original ROMs -via_IOPEN: - jmp (IOPEN) +via_ISAVE: + jmp (ISAVE) + +via_ILOAD: + jmp (ILOAD) via_ICLOSE: jmp (ICLOSE) +via_IOPEN: + jmp (IOPEN) + via_ICHKIN: jmp (ICHKIN) -via_ICKOUT: - jmp (ICKOUT) - -via_ICLRCH: - jmp (ICLRCH) - via_IBASIN: jmp (IBASIN) -via_IBSOUT: - jmp (IBSOUT) - -via_ISTOP: - jmp (ISTOP) - via_IGETIN: jmp (IGETIN) - + +via_ICKOUT: + jmp (ICKOUT) + +via_IBSOUT: + jmp (IBSOUT) + +via_ICLRCH: + jmp (ICLRCH) + via_ICLALL: jmp (ICLALL) - -via_ILOAD: - jmp (ILOAD) - -via_ISAVE: - jmp (ISAVE) + +via_ISTOP: + jmp (ISTOP) diff --git a/strings/00003C b/strings/00003C new file mode 100644 index 00000000..0ae5a8af --- /dev/null +++ b/strings/00003C @@ -0,0 +1,3 @@ +$3C byte after some leading $00s + +Not creative. Not copyrightable. diff --git a/strings/0002A2 b/strings/0002A2 new file mode 100644 index 00000000..ef2431f1 --- /dev/null +++ b/strings/0002A2 @@ -0,0 +1,3 @@ +address $0200 + LDX# (argument does not match) + +Not even a full instruction - not copyrightable. diff --git a/strings/002090FF b/strings/002090FF new file mode 100644 index 00000000..4cb0adc7 --- /dev/null +++ b/strings/002090FF @@ -0,0 +1,3 @@ +$00 + JSR $FF90 (SETMSG) + +Instruction (jump to an official, docummented location) and some part. Not copyrightable. diff --git a/strings/006020 b/strings/006020 new file mode 100644 index 00000000..f5f52edc --- /dev/null +++ b/strings/006020 @@ -0,0 +1,3 @@ +$00 + RTS (or instruction part) + JSR xxxx + +Single byte instruction with two halfs, or half of the instruction + half of other. Not copyrightable. diff --git a/strings/00990001 b/strings/00990001 new file mode 100644 index 00000000..08241cc8 --- /dev/null +++ b/strings/00990001 @@ -0,0 +1,3 @@ +$00 + STA $0100, Y + +Single instruction and some part. Not copyrightable. diff --git a/strings/00990002 b/strings/00990002 new file mode 100644 index 00000000..8f8f4711 --- /dev/null +++ b/strings/00990002 @@ -0,0 +1,3 @@ +$00 + STA $0200, Y + +Single instruction and some part. Not copyrightable. diff --git a/strings/00DD60AD00DD09 b/strings/00DD60AD00DD09 new file mode 100644 index 00000000..64861d09 --- /dev/null +++ b/strings/00DD60AD00DD09 @@ -0,0 +1,5 @@ +address $DD00 (from previous instruction) + RTS (end of the routine, new one starting) + LDA $DD00 + ORA # (argument does not match) + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/026020 b/strings/026020 new file mode 100644 index 00000000..e0fe475c --- /dev/null +++ b/strings/026020 @@ -0,0 +1,3 @@ +byte $02 + RTS + JSR (address does not match) + +One instruction + some fragments. Not copyrightable. diff --git a/strings/02B96302 b/strings/02B96302 new file mode 100644 index 00000000..cb17a83e --- /dev/null +++ b/strings/02B96302 @@ -0,0 +1,4 @@ +$02 + LDA $0263, X (FAT table access) + +Single instruction (indexed access to a documented table) + some part. Not copyrightable. + diff --git a/strings/02B96D02 b/strings/02B96D02 new file mode 100644 index 00000000..8ceebc31 --- /dev/null +++ b/strings/02B96D02 @@ -0,0 +1,3 @@ +$02 + LDA $026D, X (SAT table access) + +Single instruction (indexed access to a documented table) + some part. Not copyrightable. diff --git a/strings/032060 b/strings/032060 new file mode 100644 index 00000000..ab518d6c --- /dev/null +++ b/strings/032060 @@ -0,0 +1,3 @@ +fragment + JSR + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034C09 b/strings/034C09 new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034C09 @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034C33 b/strings/034C33 new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034C33 @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034C83 b/strings/034C83 new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034C83 @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034C9E b/strings/034C9E new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034C9E @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034CFB b/strings/034CFB new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034CFB @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/034CFC b/strings/034CFC new file mode 100644 index 00000000..132c73fd --- /dev/null +++ b/strings/034CFC @@ -0,0 +1,3 @@ +fragment + JMP + lower byte of jump address + +Not even a full instruction - not copyrightable. diff --git a/strings/036C1C036C b/strings/036C1C036C new file mode 100644 index 00000000..ebb399e0 --- /dev/null +++ b/strings/036C1C036C @@ -0,0 +1,3 @@ +$03 (most likely adddress higher byte) + JMP ($031C) (via public, documented vector) + JMP (address does not match) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/036C1E036C b/strings/036C1E036C new file mode 100644 index 00000000..e6f9e218 --- /dev/null +++ b/strings/036C1E036C @@ -0,0 +1,3 @@ +$03 (most likely adddress higher byte) + JMP ($031E) (via public, documented vector) + JMP (address does not match) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/036C20036C b/strings/036C20036C new file mode 100644 index 00000000..ab5ed572 --- /dev/null +++ b/strings/036C20036C @@ -0,0 +1,3 @@ +$03 (most likely adddress higher byte) + JMP ($0320) (via public, documented vector) + JMP (address does not match) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/036C22036C b/strings/036C22036C new file mode 100644 index 00000000..f05b4581 --- /dev/null +++ b/strings/036C22036C @@ -0,0 +1,3 @@ +$03 (most likely adddress higher byte) + JMP ($0322) (via public, documented vector) + JMP (address does not match) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/036C24036C b/strings/036C24036C new file mode 100644 index 00000000..4b11242c --- /dev/null +++ b/strings/036C24036C @@ -0,0 +1,3 @@ +03 (most likely adddress higher byte) + JMP ($0324) (via public, documented vector) + JMP (address does not match) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/036C2603 b/strings/036C2603 new file mode 100644 index 00000000..3271b1af --- /dev/null +++ b/strings/036C2603 @@ -0,0 +1,3 @@ +$03 (most likely adddress higher byte) + JMP ($0326) (via public, documented vector) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/036C2A036C b/strings/036C2A036C new file mode 100644 index 00000000..552a4b08 --- /dev/null +++ b/strings/036C2A036C @@ -0,0 +1,4 @@ +$03 (most likely adddress higher byte) + JMP ($032A) (via public, documented vector) + JMP (address does not match) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. + diff --git a/strings/036C2C03 b/strings/036C2C03 new file mode 100644 index 00000000..3bf23438 --- /dev/null +++ b/strings/036C2C03 @@ -0,0 +1,3 @@ +$03 (most likely adddress higher byte) + JMP ($032C) (via public, documented vector) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/090185 b/strings/090185 new file mode 100644 index 00000000..46ebeb00 --- /dev/null +++ b/strings/090185 @@ -0,0 +1,3 @@ +ORA #$01 (or part of another instruction) + STA (address does not match) + +At most one instruction and a half - not copyrightable. diff --git a/strings/093020 b/strings/093020 new file mode 100644 index 00000000..e020853f --- /dev/null +++ b/strings/093020 @@ -0,0 +1,4 @@ +ORA #$30 + JSR without address +alternatively a value (part of the instruction) followed by a conditional jump + +Instruction and a half. Not copyrightable. diff --git a/strings/098085 b/strings/098085 new file mode 100644 index 00000000..00d602b9 --- /dev/null +++ b/strings/098085 @@ -0,0 +1,3 @@ +ORA #$80 (or part of another instruction) + STA (address does not match) + +At most one instruction and a half - not copyrightable. diff --git a/strings/0A90034C b/strings/0A90034C new file mode 100644 index 00000000..e9598dd7 --- /dev/null +++ b/strings/0A90034C @@ -0,0 +1,4 @@ +$0A + BCC addr + JMP (address does not match) + +Some part + BCC / JMP combo (typical construction on a 6502, where there is no conditional far jump), even the address does not match. Not copyrightable. + diff --git a/strings/0D4C4F4144494E b/strings/0D4C4F4144494E new file mode 100644 index 00000000..5eae602c --- /dev/null +++ b/strings/0D4C4F4144494E @@ -0,0 +1,5 @@ + / last 'jsr printf' instruction byte (pure coincidence) + "LOADIN" PETSCII string + +Not copyrightable. + + diff --git a/strings/0D534541524348494E47 b/strings/0D534541524348494E47 new file mode 100644 index 00000000..240ea5a8 --- /dev/null +++ b/strings/0D534541524348494E47 @@ -0,0 +1,3 @@ + / last 'jsr printf' instruction byte (pure coincidence) + "SEARCHING" PETSCII string + +Not copyrightable. diff --git a/strings/0D564552494659494E b/strings/0D564552494659494E new file mode 100644 index 00000000..38121d93 --- /dev/null +++ b/strings/0D564552494659494E @@ -0,0 +1,3 @@ + / last 'jsr printf' instruction byte (pure coincidence) + "VERIFYIN" PETSCII string + +Not copyrightable. diff --git a/strings/108D00DD b/strings/108D00DD new file mode 100644 index 00000000..b0d7830a --- /dev/null +++ b/strings/108D00DD @@ -0,0 +1,3 @@ +part of previous instruction + STA $DD00 + +Instruction (storing register in a well-known I/O register) preceeded by a half of another one - not copyrightable. diff --git a/strings/18607820 b/strings/18607820 new file mode 100644 index 00000000..2a01aa66 --- /dev/null +++ b/strings/18607820 @@ -0,0 +1,3 @@ +CLC + RTS (end of subroutine, another one starts) + SEI + JSR (address does not match) + +Nothing creative here. First 2 instruction, which is are a common way to end a subroutine and indicate a success. Afterwards a start of new subroutine, which starts with disabling interrupts. Not copyrightable. diff --git a/strings/1860A59D10 b/strings/1860A59D10 new file mode 100644 index 00000000..e7a89a08 --- /dev/null +++ b/strings/1860A59D10 @@ -0,0 +1,3 @@ +CLC + RTS + LDA $9D + BPL + +Nothing creative here. First 2 instruction, which is are a common way to end a subroutine and indicate a success. Afterwards a start of new subroutine, which starts by checking a documented zeropage variable. Not copyrightable. diff --git a/strings/2046524F4D20 b/strings/2046524F4D20 new file mode 100644 index 00000000..d2c609c4 --- /dev/null +++ b/strings/2046524F4D20 @@ -0,0 +1,3 @@ + + FROM + - PETSCII string + +Not copyrightable. diff --git a/strings/204F5045 b/strings/204F5045 new file mode 100644 index 00000000..bd9f84dd --- /dev/null +++ b/strings/204F5045 @@ -0,0 +1,3 @@ + + OPE - PETSCII string + +Syllable starting a word is definitely not copyrightable. diff --git a/strings/208EA6A9 b/strings/208EA6A9 new file mode 100644 index 00000000..809ed04c --- /dev/null +++ b/strings/208EA6A9 @@ -0,0 +1,3 @@ +JSR $A68E + LDA # (value does not match) + +Instruction and a half. Not copyrightable. diff --git a/strings/20BDFF20 b/strings/20BDFF20 new file mode 100644 index 00000000..77b74280 --- /dev/null +++ b/strings/20BDFF20 @@ -0,0 +1,3 @@ +JSR $FFBD (SETNAM) + JSR (address does not match) + +Instruction (jump to official, documented location) + one byte of another one. Not copyrightable. diff --git a/strings/29DF8D00DD b/strings/29DF8D00DD new file mode 100644 index 00000000..b159a7ac --- /dev/null +++ b/strings/29DF8D00DD @@ -0,0 +1,3 @@ +AND #$DF + STA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. Here we just have a trivial bit manipulation - not creeative, not copyrightable. diff --git a/strings/29DF8D00DD60AD00DD b/strings/29DF8D00DD60AD00DD new file mode 100644 index 00000000..8701bf28 --- /dev/null +++ b/strings/29DF8D00DD60AD00DD @@ -0,0 +1,5 @@ +AND #$DF + STA $DD00 + RTS + LDA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/29EF8D00DD60 b/strings/29EF8D00DD60 new file mode 100644 index 00000000..3a45bb8d --- /dev/null +++ b/strings/29EF8D00DD60 @@ -0,0 +1,5 @@ +AND #$EF + STA $DD00 + RTS + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/29EF8D00DD60AD00DD09 b/strings/29EF8D00DD60AD00DD09 new file mode 100644 index 00000000..6fb7f246 --- /dev/null +++ b/strings/29EF8D00DD60AD00DD09 @@ -0,0 +1,5 @@ +AND #$EF + STA $DD00 + RTS + LDA $DD00 + ORA# + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/29F78D00DD b/strings/29F78D00DD new file mode 100644 index 00000000..58a79f31 --- /dev/null +++ b/strings/29F78D00DD @@ -0,0 +1,3 @@ +AND #$F7 + STA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. Here we just have a trivial bit manipulation - not creeative, not copyrightable. diff --git a/strings/29F78D00DD60 b/strings/29F78D00DD60 new file mode 100644 index 00000000..bada463b --- /dev/null +++ b/strings/29F78D00DD60 @@ -0,0 +1,5 @@ +(beginning of the routine not matching) + AND #$F7 + STA $DD00 + RTS + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/386020 b/strings/386020 new file mode 100644 index 00000000..3693f9aa --- /dev/null +++ b/strings/386020 @@ -0,0 +1,3 @@ +SEC + RTS (end of subroutine, new one starts from the next byte) + JSR (address not matching) + +One subroutine ends with carry clear, second starts with JSR, but to a different address - accidental similarity, code most likely performs something different in both cases. diff --git a/strings/3ED0034C37 b/strings/3ED0034C37 new file mode 100644 index 00000000..3850ac4b --- /dev/null +++ b/strings/3ED0034C37 @@ -0,0 +1,3 @@ +$3E + BNE addr + JMP $xx37 + +Some part + BNE / JMP combo (typical construction on a 6502, where there is no conditional far jump), even the address does not fully match. Not copyrightable. diff --git a/strings/4CBDFFA9 b/strings/4CBDFFA9 new file mode 100644 index 00000000..4caa0103 --- /dev/null +++ b/strings/4CBDFFA9 @@ -0,0 +1,3 @@ +JMP $FFBD (SETNAM) + LDA #$ (value does not match) + +Instruction (jump to an official, documented location) + opcode of another one. Not copyrightable. diff --git a/strings/4F5045 b/strings/4F5045 new file mode 100644 index 00000000..b7ca79b9 --- /dev/null +++ b/strings/4F5045 @@ -0,0 +1,3 @@ +ORE - PETSCII string + +Not copyrightable. diff --git a/strings/524F4D b/strings/524F4D new file mode 100644 index 00000000..b4fe5d3c --- /dev/null +++ b/strings/524F4D @@ -0,0 +1,3 @@ +ROM - PETSCII string + +Not copyrightable. diff --git a/strings/564552 b/strings/564552 new file mode 100644 index 00000000..fd01de08 --- /dev/null +++ b/strings/564552 @@ -0,0 +1,3 @@ +VER - PETSCII string + +Not copyrightable. diff --git a/strings/5645524946 b/strings/5645524946 new file mode 100644 index 00000000..c9039b3d --- /dev/null +++ b/strings/5645524946 @@ -0,0 +1,3 @@ +VERIF - PETSCII string, part of 'VERIFY' + +Not copyrightable. diff --git a/strings/5902D0F8 b/strings/5902D0F8 new file mode 100644 index 00000000..8b870d15 --- /dev/null +++ b/strings/5902D0F8 @@ -0,0 +1,3 @@ +$0259 (LAT table address) + BNE $F8 (few bytes back) + +Instruction + some parts (revealing that this is some manipulation on documented Kernal table). Not copyrightable. diff --git a/strings/6020A0E5A900 b/strings/6020A0E5A900 new file mode 100644 index 00000000..e69de29b diff --git a/strings/6031EA b/strings/6031EA new file mode 100644 index 00000000..e3398d10 --- /dev/null +++ b/strings/6031EA @@ -0,0 +1,3 @@ +RTS (ending a subroutine, new one starts) + conditional jump + +Nothing creative here - not copyrightable. diff --git a/strings/60A59D10 b/strings/60A59D10 new file mode 100644 index 00000000..bcc0416b --- /dev/null +++ b/strings/60A59D10 @@ -0,0 +1,3 @@ +RTS (belonging to previopus subroutine) + LDA $9D (MSGFLG) + BPL + +The only similarity here is, that the subroutine starts by checking a documented variable. Not copyrightable. diff --git a/strings/60A59D10FB b/strings/60A59D10FB new file mode 100644 index 00000000..3dc7afb7 --- /dev/null +++ b/strings/60A59D10FB @@ -0,0 +1,3 @@ +RTS + LDA $9D (MSGFLG) + BPL $FB + +Check documented variable value, utilize nearest RTS (a very common optimization, mentionedd for example here just few days ago: https://gitlab.com/mkslack/Area6510/commit/9bdc624574c76661db302cdbf85559fb0e9e309a) to quit subroutine if the highest bit is not 1 (the easiest way to distinguish 2 documented values of the MSGFLG: $00 and $80). Nothing creative here - not copyrightable. diff --git a/strings/60AD00DD0910 b/strings/60AD00DD0910 new file mode 100644 index 00000000..465ca2c5 --- /dev/null +++ b/strings/60AD00DD0910 @@ -0,0 +1,5 @@ +RTS (end of the routine, new one starting) + LDA $DD00 + ORA #$10 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/60AD00DD09108D00DD b/strings/60AD00DD09108D00DD new file mode 100644 index 00000000..d2e3ec90 --- /dev/null +++ b/strings/60AD00DD09108D00DD @@ -0,0 +1,5 @@ +RTS (end of the routine, new one starting) + LDA $DD00 + ORA #$10 + STA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/630285 b/strings/630285 new file mode 100644 index 00000000..1eeb6590 --- /dev/null +++ b/strings/630285 @@ -0,0 +1,3 @@ +address $0263 + STA (address does not match) + +Not even a full instruction. Not copyrightable. diff --git a/strings/686020 b/strings/686020 new file mode 100644 index 00000000..a2a6d383 --- /dev/null +++ b/strings/686020 @@ -0,0 +1,3 @@ +PLA + RTS (end of subroutine, another one starting) + JSR (address does not match) + +End of a routine preserving .A register + part of instruction belonging to another subroutine. Not copyrightable. diff --git a/strings/6C1A036C b/strings/6C1A036C new file mode 100644 index 00000000..b2044ce0 --- /dev/null +++ b/strings/6C1A036C @@ -0,0 +1,3 @@ +JMP ($031A) (via public, documented vector) + JMP (address does not match) + +Code similarity due to Kernal API usage convention. Since 6510 CPU does not have indirect JSR, the only sane possibility to use Kernal API vectors in RAM ($0314-$0333) is to have JMP ($address) hardcoded somewhere. The jump table has intentionally strange order (to avoid code similarity as much as possible), but some small similarities can't be avoided in any reasonable way. diff --git a/strings/7AD0034C b/strings/7AD0034C new file mode 100644 index 00000000..48d269ae --- /dev/null +++ b/strings/7AD0034C @@ -0,0 +1,3 @@ +$7A + BNE with matching address + JMP + +Single instruction + some matching parts of two others. Not copyrightable. diff --git a/strings/9914038810 b/strings/9914038810 new file mode 100644 index 00000000..83b907e4 --- /dev/null +++ b/strings/9914038810 @@ -0,0 +1,3 @@ +STA $0314, Y + DEY + BPL addr + +Part of memory copy routine to set/initialize vector table in RAM (a documented one). There is a limited amount of sane ways to implement this code - ours is clearly different from the original, or there would be more similarities. Such a small fragment of rather common routine is definitely not copyrightable. diff --git a/strings/A000B17AD0 b/strings/A000B17AD0 new file mode 100644 index 00000000..bece149c --- /dev/null +++ b/strings/A000B17AD0 @@ -0,0 +1,3 @@ +LDY #$00 + LDA ($7A), Y + BNE (offset does not match) + +Small part of a loop processing data pointed by TEXTPTR - not creative, not copyrightable. diff --git a/strings/A59AC903 b/strings/A59AC903 new file mode 100644 index 00000000..09302357 --- /dev/null +++ b/strings/A59AC903 @@ -0,0 +1,3 @@ +LDA $9A (DFLTO) + CMP #$03 + +Check whether the default output device is screen - not even fully matching the original ROM (different branch instruction used) - might be one onstruction on other architecture. Not copyrightable. diff --git a/strings/A5BAC902D0 b/strings/A5BAC902D0 new file mode 100644 index 00000000..95880faa --- /dev/null +++ b/strings/A5BAC902D0 @@ -0,0 +1,3 @@ +LDA $BA + CMP #$02 + BNE (offset does not match) + +Check whether the current device number is 2 (RS-232). Not creative - not copyrightablee. diff --git a/strings/A67AA47B b/strings/A67AA47B new file mode 100644 index 00000000..4c546a62 --- /dev/null +++ b/strings/A67AA47B @@ -0,0 +1,5 @@ +LDX $7A + LDY $7B + +Loading TXTPTR value to X/Y registers, would be 1 instruction on any 16-bit CPU. Not creative - not copyrightable. + + diff --git a/strings/A90020BDFF b/strings/A90020BDFF new file mode 100644 index 00000000..3d2e939f --- /dev/null +++ b/strings/A90020BDFF @@ -0,0 +1,4 @@ +LDA #$00 + JSR $FFBD (SETNAM routine) + +Code to set the file name as empty ($FFBD is a standard, documented address). Trivial - not copyrightable. + diff --git a/strings/A90020BDFF20 b/strings/A90020BDFF20 new file mode 100644 index 00000000..52da1afa --- /dev/null +++ b/strings/A90020BDFF20 @@ -0,0 +1,3 @@ +LDA #$00 + JSR $FFBD (SETNAM routine) + JSR (address differs) + +Code to set the file name as empty ($FFBD is a standard, documented address), followed by jump to subroutine (but placed elsewere). Trivial - not copyrightable. diff --git a/strings/A9009900 b/strings/A9009900 new file mode 100644 index 00000000..3801d04d --- /dev/null +++ b/strings/A9009900 @@ -0,0 +1,3 @@ +LDA #$00 + STA xx00, Y + +Instruction and a half (probably a loop zeroing something - but something different in both cases). Not copyrightable. diff --git a/strings/B190034C b/strings/B190034C new file mode 100644 index 00000000..b4bf4caa --- /dev/null +++ b/strings/B190034C @@ -0,0 +1,3 @@ +LDA ($0390), Y + JMP (address does not match) + +Instruction and a half - not copyrightable. diff --git a/strings/B1B0034C b/strings/B1B0034C new file mode 100644 index 00000000..4df42d32 --- /dev/null +++ b/strings/B1B0034C @@ -0,0 +1,3 @@ +LDA ($03B0), Y + JMP (address does not match) + +Instruction and a half - not copyrightable. diff --git a/strings/BAA90085 b/strings/BAA90085 new file mode 100644 index 00000000..007ab7ac --- /dev/null +++ b/strings/BAA90085 @@ -0,0 +1,3 @@ +$BA + LDA #$00 + STA (address does not match) + +One full instruction (loading acumulator with 0) and some parts - not copyrightable. diff --git a/strings/C8B17AF0 b/strings/C8B17AF0 new file mode 100644 index 00000000..f39a32bf --- /dev/null +++ b/strings/C8B17AF0 @@ -0,0 +1,3 @@ +INY + LDA ($7A),Y + BEQ (offset does not match) + +Small part of a loop processing data pointed by TEXTPTR - not creative, not copyrightable. diff --git a/strings/C8C4B7 b/strings/C8C4B7 new file mode 100644 index 00000000..c18389c8 --- /dev/null +++ b/strings/C8C4B7 @@ -0,0 +1,3 @@ +INY + CPY $B7 (FNLEN documented variable) + +Tiny part of the loop processing file name or IEC command. Not creative - not copyrightable. diff --git a/strings/D0034C37 b/strings/D0034C37 new file mode 100644 index 00000000..6fe14834 --- /dev/null +++ b/strings/D0034C37 @@ -0,0 +1,3 @@ +BNE $03 + JMP xx37 + +Instruction and a half - part of a common workaround for conditional jumps not reaching far. Not copyrightable. diff --git a/strings/DD09108D00DD b/strings/DD09108D00DD new file mode 100644 index 00000000..f263c197 --- /dev/null +++ b/strings/DD09108D00DD @@ -0,0 +1,5 @@ +$DD + ORA #$10 + STA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DD29DF8D00DD60AD00DD b/strings/DD29DF8D00DD60AD00DD new file mode 100644 index 00000000..9979799f --- /dev/null +++ b/strings/DD29DF8D00DD60AD00DD @@ -0,0 +1,5 @@ +$DD + AND #$DF + STA $DD00 + RTS (end of the routine, new one starting) + LDA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DD29DF8D00DD60AD00DD09208D00DD b/strings/DD29DF8D00DD60AD00DD09208D00DD new file mode 100644 index 00000000..fc3ddb19 --- /dev/null +++ b/strings/DD29DF8D00DD60AD00DD09208D00DD @@ -0,0 +1,5 @@ +$DD + AND #$DF + STA $DD00 + RTS (end of the routine, new one starting) + LDA $DD00 + ORA #$20 + STA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DD29EF8D00DD b/strings/DD29EF8D00DD new file mode 100644 index 00000000..6fcdcaaa --- /dev/null +++ b/strings/DD29EF8D00DD @@ -0,0 +1,5 @@ +$DD + AND #$EF + STA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DD29EF8D00DD60 b/strings/DD29EF8D00DD60 new file mode 100644 index 00000000..4ad51171 --- /dev/null +++ b/strings/DD29EF8D00DD60 @@ -0,0 +1,5 @@ +$DD + AND #$EF + STA $DD00 + RTS + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DD29EF8D00DD60AD00DD09 b/strings/DD29EF8D00DD60AD00DD09 new file mode 100644 index 00000000..903213d1 --- /dev/null +++ b/strings/DD29EF8D00DD60AD00DD09 @@ -0,0 +1,5 @@ +$DD + AND #$EF + STA $DD00 + RTS + LDA #$DD00 + ORA # (argument does not match) + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DD29F78D00DD60 b/strings/DD29F78D00DD60 new file mode 100644 index 00000000..20b06c7a --- /dev/null +++ b/strings/DD29F78D00DD60 @@ -0,0 +1,5 @@ +$DD + AND #$F7 + STA $DD00 + RTS + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DD60AD00DD09208D00DD b/strings/DD60AD00DD09208D00DD new file mode 100644 index 00000000..f885c7da --- /dev/null +++ b/strings/DD60AD00DD09208D00DD @@ -0,0 +1,5 @@ +$DD + RTS (end of the routine, new one starting) + LDA $DD00 + ORA #$20 + STA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/DF8D00DD b/strings/DF8D00DD new file mode 100644 index 00000000..a3426d59 --- /dev/null +++ b/strings/DF8D00DD @@ -0,0 +1,3 @@ +$EF + STA $DD00 + +Instruction (storing acumulator in a documented I/O register) and some part. Not copyrightable. diff --git a/strings/DF8D00DD60AD00DD b/strings/DF8D00DD60AD00DD new file mode 100644 index 00000000..63207a43 --- /dev/null +++ b/strings/DF8D00DD60AD00DD @@ -0,0 +1,5 @@ +$DF + STA $DD00 + RTS + LDA $DD00 + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/E5C91DD0 b/strings/E5C91DD0 new file mode 100644 index 00000000..18aee6b1 --- /dev/null +++ b/strings/E5C91DD0 @@ -0,0 +1,3 @@ +$E5 + CMP #$1D + BNE (offset does not match) + +Instruction + some parts. Not copyrightable. diff --git a/strings/EF8D00DD60AD00DD09 b/strings/EF8D00DD60AD00DD09 new file mode 100644 index 00000000..d8780b0e --- /dev/null +++ b/strings/EF8D00DD60AD00DD09 @@ -0,0 +1,5 @@ +$EF + STA $DD00 + RTS + LDA $DD00 + ORA # (value does not match) + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. diff --git a/strings/F6A90085 b/strings/F6A90085 new file mode 100644 index 00000000..815dc515 --- /dev/null +++ b/strings/F6A90085 @@ -0,0 +1,3 @@ +$F6 + LDA #$00 + STA ... + +A part + instruction to clear the accumulator + opcode of another instruction. Not copyrightable. diff --git a/strings/F78D00DD60 b/strings/F78D00DD60 new file mode 100644 index 00000000..f7b83ec1 --- /dev/null +++ b/strings/F78D00DD60 @@ -0,0 +1,5 @@ +$F7 + STA $DD00 + RTS + +$DD00 is a hardware register, where one typically set/unset/read individual bits. +Having a set of trivial helper subroutines to set/clear individual bits (or groups of bits) is an obvious solution (thus not copyrightable), some similarities are unevitable. +Besides, in this case (since the similarity does not even cover a single subroutine from start to end) it is clear that the similar code actually performs slightly different actions. From fb9caa7602d260927d1d13fdcd17be03f5b7ee6c Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Sun, 4 Aug 2019 09:12:06 +0200 Subject: [PATCH 89/90] added 'updatebin' make target --- Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 62d70ab1..7e68ac85 100644 --- a/Makefile +++ b/Makefile @@ -25,7 +25,7 @@ TOOLS_LIST = $(TOOL_COLLECT_DATA) $(TOOL_COMPRESS_TEXT) $(TOOL_PNGPREPARE) $(TOO # Rules - main -.PHONY: all clean +.PHONY: all clean updatebin all: build/chargen build/newkern_generic build/newbasic_generic build/newc65 build/newkern_ultimate64 build/newbasic_ultimate64 @@ -39,6 +39,15 @@ clean: @rm -f temp.map @rm -f ophis.bin +updatebin: build/chargen build/newbasic_generic build/newkern_generic build/newbasic_mega65 build/newkern_mega65 build/newbasic_ultimate64 build/newkern_ultimate64 + cp build/chargen bin/chargen.rom + cp build/newbasic_generic bin/basic_generic.rom + cp build/newkern_generic bin/kernal_generic.rom + cp build/newbasic_mega65 bin/basic_mega65.rom + cp build/newkern_mega65 bin/kernal_mega65.rom + cp build/newbasic_ultimate64 bin/basic_ultimate64.rom + cp build/newkern_ultimate64 bin/kernal_ultimate64.rom + # Rules - tools $(TOOL_COLLECT_DATA): src/collect_data.c Makefile @@ -66,7 +75,7 @@ $(TOOL_SIMILARITY): src/similarity.c Makefile build/chargen: $(TOOL_PNGPREPARE) assets/8x8font.png $(TOOL_PNGPREPARE) charrom assets/8x8font.png build/chargen -# Dependencies - XXX, why they need to be stated separately? +# Dependencies build/basic_generic/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_BASIC_generic) build/basic/packed_messages.s build/kernal_generic/OUT.BIN: Ophis $(TOOLS_LIST) $(SRC_KERNAL_generic) From b055a83eea2c7396eda3c82916bb8699fad2e30a Mon Sep 17 00:00:00 2001 From: FeralChild64 Date: Mon, 5 Aug 2019 18:38:01 +0200 Subject: [PATCH 90/90] fix for improper rule in .gitignore --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index fe4f9202..1d25926a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,8 +9,8 @@ build/* # Input to the similarity tool - copyrighted material, we can't check it in! -basic -kernal +/basic +/kernal # Various IDE project files, temporary files, etc.