migrated to ACME assembler
commit 145d64aa6e78838ed07cefed372f0ad6a4687e97 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 20:16:57 2020 +0200 ACME adaptation commit 885209d7822286744ea53232ae7461472a01d5d6 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 19:57:25 2020 +0200 ACME adaptation commit 334d84486bc603551887e7cbeb59d329f2224cc7 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 18:29:15 2020 +0200 ACME adaptation commit b5966f49bcd8f0ca79cbec93819a31238924707e Author: FeralChild64 <you@example.com> Date: Sun Sep 20 18:09:31 2020 +0200 ACME adaptation commit 786536a93a5eab5e676fca99625b4eb094a554e7 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 17:24:48 2020 +0200 ACME adaptation commit 704c70dfb1f5d68775d6f3da220803b8a3990f56 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 15:07:12 2020 +0200 ACME adaptation commit 136874964c9083b375f151475310f9636871fc72 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 14:45:14 2020 +0200 ACME adaptation commit 8eca0d5700b72d04336e72c5cd3a68e18b85f96d Author: FeralChild64 <you@example.com> Date: Sun Sep 20 14:06:52 2020 +0200 ACME adaptation commit 11d29eb7ee318239d782f85498b6d0524624d5c4 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 13:56:45 2020 +0200 ACME apaptation commit c9b5e5e04cceb92c66bc027e6440bc0f7c5a499f Author: FeralChild64 <you@example.com> Date: Sun Sep 20 13:49:04 2020 +0200 ACME adaptation commit f5cc254cbc921f07863807468cb3fe26b410b409 Author: FeralChild64 <you@example.com> Date: Sun Sep 20 13:01:18 2020 +0200 ACME adaptation commit e135a27bf9c30cc0965379c954564e06406303b1 Author: FeralChild64 <you@example.com> Date: Sat Sep 19 21:55:01 2020 +0200 ACME adaptation commit e9dfddf90d9e2795e88b7da40ae050d733faeb56 Author: FeralChild64 <you@example.com> Date: Sat Sep 19 21:48:47 2020 +0200 Makefile fix commit 07030104c65cf5e5beeacf6d629ccb9245e58657 Author: FeralChild64 <you@example.com> Date: Sat Sep 19 21:42:00 2020 +0200 ACME adaptation commit f824362ee5bcfbffca86c430b57773b2ffd65655 Author: FeralChild64 <you@example.com> Date: Sat Sep 19 20:14:56 2020 +0200 ACME adaptation commit 3a3c59007dcd4940d89b8669f34ca56b61c25fdf Author: FeralChild64 <you@example.com> Date: Fri Sep 18 21:51:45 2020 +0200 ACME adaptation commit 6790ef7bc88a41de2881c69b7524dd4ab8c74b5d Author: FeralChild64 <you@example.com> Date: Fri Sep 18 20:35:23 2020 +0200 ACME adaptation commit 38ad18b90e9ec713aa7ca49576b3388ce1733357 Author: FeralChild64 <you@example.com> Date: Fri Sep 18 18:46:20 2020 +0200 ACME adaptation commit 541340371122a9702f7b2d9771c298223cffd0e9 Author: FeralChild64 <you@example.com> Date: Fri Sep 18 16:49:46 2020 +0200 ACME adaptation commit 25cfd5e186459be1a260d3eb8cfff767838de370 Author: FeralChild64 <you@example.com> Date: Thu Sep 17 20:13:33 2020 +0200 ACME adaptation commit f61599444d5b1d03d8fd8e4a6a7c3b85069bedb3 Author: FeralChild64 <you@example.com> Date: Thu Sep 17 19:29:23 2020 +0200 ACME adaptation commit b290be31ec7bb2e5723607697da1bbc621c84429 Author: FeralChild64 <you@example.com> Date: Thu Sep 17 17:20:14 2020 +0200 ACME adaptation commit 877be9e856880d98fd4bcb25b42aaaacda9dc463 Author: FeralChild64 <you@example.com> Date: Wed Sep 16 21:47:38 2020 +0200 ACME adaptation commit bb20edaf85d386e41d5c2f715b745b68fbd3362e Author: FeralChild64 <you@example.com> Date: Wed Sep 16 21:31:30 2020 +0200 ACME adaptation commit c5d31bd8685abce37c8e254d15aac20bd1570d9f Author: FeralChild64 <you@example.com> Date: Wed Sep 16 18:40:49 2020 +0200 ACME adaptation commit 29349826b38f8a89649171559dc8cf24c560aff1 Author: FeralChild64 <you@example.com> Date: Mon Sep 14 23:35:47 2020 +0200 ACME adaptation commit 8bcd6a621c4b11766d0cf34f79858ba90a67248e Author: FeralChild64 <you@example.com> Date: Mon Sep 14 22:52:25 2020 +0200 ACME adaptation commit e87a69edc2ce4bfcc460c31e08dcc352a985f88d Author: FeralChild64 <you@example.com> Date: Mon Sep 14 22:43:27 2020 +0200 ACME adaptation commit f49a097bd52e96d00b866c02bda7121e4543233c Author: FeralChild64 <you@example.com> Date: Mon Sep 14 19:02:07 2020 +0200 ACME adaptation commit fa0e9214a633b8e8f867cc70925b390940dcd426 Author: FeralChild64 <you@example.com> Date: Mon Sep 14 17:47:19 2020 +0200 ACME adaptation commit 1b763b91e7a03e426227129c7f22f0ce57a4c197 Author: FeralChild64 <you@example.com> Date: Mon Sep 14 17:17:10 2020 +0200 ACME adaptation commit e92a4b57b232cd85eb1e71090b8a89c7c8461ebc Author: FeralChild64 <you@example.com> Date: Mon Sep 14 17:15:37 2020 +0200 ACME adaptation commit de3c693e8a7e73ea5289198946058e3240894e6a Author: FeralChild64 <you@example.com> Date: Mon Sep 14 17:10:05 2020 +0200 ACME adaptation commit f9bd7ae0f04e932d613be9ed5cb19af9be5d338e Author: FeralChild64 <you@example.com> Date: Sun Sep 13 14:34:44 2020 +0200 ACME adaptation commit 694dee52555dbfc2b1f7f452a9671ff51106c057 Author: FeralChild64 <you@example.com> Date: Sun Sep 13 14:16:14 2020 +0200 ACME adaptation commit 0af2c55edfcd22942d9f25417eb0d35f55b71604 Author: FeralChild64 <you@example.com> Date: Fri Sep 11 17:38:09 2020 +0200 ACME adaptation commit 2015e17334bd56a1e8a13a5abc098d9c2e7ea44f Author: FeralChild64 <you@example.com> Date: Fri Sep 11 16:46:05 2020 +0200 ACME adaptation commit b1e972162798d60f4483cd6cc261e856c20c2c8c Author: FeralChild64 <you@example.com> Date: Fri Sep 11 16:24:31 2020 +0200 ACME adaptation commit 9d027e868466901ba53bf074a79ec8cf16273021 Author: FeralChild64 <you@example.com> Date: Fri Sep 11 15:04:31 2020 +0200 ACME adaptation commit 957186deddd1aa4f3b4f1aa1f421e4239a584e57 Author: FeralChild64 <you@example.com> Date: Thu Sep 10 22:49:07 2020 +0200 ACME adaptation commit b8060f67a455cfac109f08d96b62c360d693b931 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 23:07:28 2020 +0200 ACME adaptation commit e54d004568f44bbfe5c070ef1d7cf3544112e497 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 22:58:20 2020 +0200 ACME adaptation commit f90b77f073c5a605cb31c6ee451f65c8a8aff7d8 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 22:12:09 2020 +0200 ACME adaptation commit b211bb4afcd9c58fe1f5c92f3007717d611cd531 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 22:01:40 2020 +0200 ACME adaptation commit 8d7ea343b07e9e08e5f77f3c414758a6cffd0440 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 21:38:34 2020 +0200 ACME adaptation commit 46413eb0d92d6400aba0ff8dfe556e61e8a44d78 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 21:07:47 2020 +0200 ACME adaptation commit 9f98f69ecc21f7b74a5eb89e247f5a2c6fcb655d Author: FeralChild64 <you@example.com> Date: Wed Sep 9 20:05:03 2020 +0200 ACME adaptation commit 7bb9f1cadc682c7e0a4a6796739d860d473ca110 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 19:55:12 2020 +0200 ACME adaptation commit 5fc115392b5bdca6b56f67ad866b1884d2d2bdf8 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 19:31:10 2020 +0200 ACME adaptation commit b7940fc60e568d859df9e3156f6bacc6d685b2cc Author: FeralChild64 <you@example.com> Date: Wed Sep 9 19:16:09 2020 +0200 ACME adaptation commit 56288cb97197561afa0816b29c134ec1190e8eab Author: FeralChild64 <you@example.com> Date: Wed Sep 9 18:48:23 2020 +0200 ACME adaptation commit 10401a60fc7922a53d782120ef6795d889140218 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 16:34:16 2020 +0200 ACME adaptation commit 8ce76e4d2b56837a691ae84b1a412a2ae32a157b Author: FeralChild64 <you@example.com> Date: Wed Sep 9 16:20:44 2020 +0200 ACME adaptation commit 33fade899fa6172ea6b5b5f6683bb61f544429fd Author: FeralChild64 <you@example.com> Date: Wed Sep 9 15:28:46 2020 +0200 ACME adaptation commit a416f04734402fcfbc57a933731376df2e0180a1 Author: FeralChild64 <you@example.com> Date: Wed Sep 9 12:40:03 2020 +0200 ACME adaptation commit f8daee005b1d29f6912723be2ac94bc5fbeb0508 Author: FeralChild64 <you@example.com> Date: Mon Sep 7 23:29:54 2020 +0200 ACME adaptation commit 83fe6bdd0b08a44fdbfc6eefe323a4b194ccaf5b Author: FeralChild64 <you@example.com> Date: Mon Sep 7 22:23:16 2020 +0200 ACME adaptation commit cb1f75620b9c83000a15c9c7f7acefdfee79a979 Author: FeralChild64 <you@example.com> Date: Mon Sep 7 19:23:12 2020 +0200 ACME adaptation commit e524d517c933ae1f0aeb49764d307fadb4845025 Author: FeralChild64 <you@example.com> Date: Sun Sep 6 08:24:25 2020 +0200 ACME adaptation - replaced comments commit 2ab572c3a21f4a78a7312d0e684bc11d91d1717a Author: FeralChild64 <you@example.com> Date: Sat Sep 5 17:59:10 2020 +0200 ACME adaptation - replaced the assembler
This commit is contained in:
1 parent
bfc8291e41
commit
c8d255130c
685 files changed
+15835
-16296
No files matched your search
+23
-23
@@ -1,38 +1,38 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Official Kernal routine, described in:
|
||||
//
|
||||
// - [RG64] C64 Programmers Reference Guide - page 274
|
||||
// - [CM64] Computes Mapping the Commodore 64 - page 224/225
|
||||
//
|
||||
// CPU registers that has to be preserved (see [RG64]): .Y
|
||||
//
|
||||
;
|
||||
; Official Kernal routine, described in:
|
||||
;
|
||||
; - [RG64] C64 Programmers Reference Guide - page 274
|
||||
; - [CM64] Computes Mapping the Commodore 64 - page 224/225
|
||||
;
|
||||
; CPU registers that has to be preserved (see [RG64]): .Y
|
||||
;
|
||||
|
||||
|
||||
ACPTR:
|
||||
|
||||
lda IOSTATUS
|
||||
beq !+
|
||||
beq @1
|
||||
|
||||
clc
|
||||
lda #$0D // tested on real ROMs
|
||||
lda #$0D ; tested on real ROMs
|
||||
rts
|
||||
!:
|
||||
@1:
|
||||
|
||||
#if ROM_LAYOUT_M65
|
||||
!ifdef CONFIG_MB_M65 {
|
||||
jsr m65dos_check
|
||||
bcc_16 m65dos_acptr // branch if device is handeld by internal DOS
|
||||
#endif
|
||||
+bcc m65dos_acptr ; branch if device is handeld by internal DOS
|
||||
}
|
||||
|
||||
#if CONFIG_IEC
|
||||
#if CONFIG_IEC_JIFFYDOS
|
||||
!ifdef CONFIG_IEC {
|
||||
!ifdef CONFIG_IEC_JIFFYDOS {
|
||||
jmp iec_rx_dispatch
|
||||
#else
|
||||
} else {
|
||||
jmp iec_rx_byte
|
||||
#endif
|
||||
#else
|
||||
}
|
||||
} else { ; no CONFIG_IEC
|
||||
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||
#endif
|
||||
}
|
||||
+13
-13
@@ -1,34 +1,34 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// IEC part of the CHKIN routine
|
||||
//
|
||||
;
|
||||
; IEC part of the CHKIN routine
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
chkin_iec:
|
||||
|
||||
// Fail if the file is open for writing (secondary address 1)
|
||||
; Fail if the file is open for writing (secondary address 1)
|
||||
|
||||
lda LAT, Y
|
||||
cmp #$01
|
||||
beq_16 chkin_file_not_input
|
||||
+beq chkin_file_not_input
|
||||
|
||||
// Send TALK + TKSA first
|
||||
; Send TALK + TKSA first
|
||||
lda FAT,Y
|
||||
|
||||
jsr TALK
|
||||
bcs_16 chkinout_device_not_present
|
||||
+bcs chkinout_device_not_present
|
||||
|
||||
lda LAT, Y
|
||||
ora #$60
|
||||
jsr TKSA
|
||||
bcs_16 chkinout_device_not_present
|
||||
+bcs chkinout_device_not_present
|
||||
|
||||
jmp chkin_set_device
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
} ; CONFIG_IEC
|
||||
@@ -1,13 +1,13 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// IEC part of the CHRIN routine
|
||||
//
|
||||
;
|
||||
; IEC part of the CHRIN routine
|
||||
;
|
||||
|
||||
|
||||
chrin_iec:
|
||||
|
||||
// XXX is this really all?
|
||||
; XXX is this really all?
|
||||
jmp JACPTR
|
||||
@@ -1,15 +1,15 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// IEC part of the CHROUT routine
|
||||
//
|
||||
;
|
||||
; IEC part of the CHROUT routine
|
||||
;
|
||||
|
||||
|
||||
chrout_iec:
|
||||
|
||||
lda SCHAR
|
||||
jsr JCIOUT
|
||||
bcc_16 chrout_done_success
|
||||
+bcc chrout_done_success
|
||||
jmp chrout_done_fail
|
||||
+26
-27
@@ -1,57 +1,56 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Official Kernal routine, described in:
|
||||
//
|
||||
// - [RG64] C64 Programmers Reference Guide - page 279/280
|
||||
// - [CM64] Computes Mapping the Commodore 64 - page 224
|
||||
//
|
||||
// CPU registers that has to be preserved (see [RG64]): .X, .Y
|
||||
//
|
||||
;
|
||||
; Official Kernal routine, described in:
|
||||
;
|
||||
; - [RG64] C64 Programmers Reference Guide - page 279/280
|
||||
; - [CM64] Computes Mapping the Commodore 64 - page 224
|
||||
;
|
||||
; CPU registers that has to be preserved (see [RG64]): .X, .Y
|
||||
;
|
||||
|
||||
|
||||
CIOUT:
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
pha
|
||||
lda C3PO
|
||||
bne ciout_send_byte
|
||||
|
||||
// Nothing to send - set buffer as valid, store byte there
|
||||
; Nothing to send - set buffer as valid, store byte there
|
||||
inc C3PO
|
||||
|
||||
// Clear carry flag to indicate success
|
||||
; Clear carry flag to indicate success
|
||||
clc
|
||||
|
||||
ciout_store_in_buffer:
|
||||
|
||||
// Store in the buffer data to be sent next, return
|
||||
; Store in the buffer data to be sent next, return
|
||||
pla
|
||||
sta BSOUR
|
||||
rts
|
||||
|
||||
ciout_send_byte:
|
||||
|
||||
#if ROM_LAYOUT_M65
|
||||
!ifdef CONFIG_MB_M65 {
|
||||
jsr m65dos_check
|
||||
bcc_16 m65dos_ciout // branch if device is handeld by internal DOS
|
||||
#endif
|
||||
+bcc m65dos_ciout ; branch if device is handeld by internal DOS
|
||||
}
|
||||
|
||||
clc // send without EOI
|
||||
#if CONFIG_IEC_JIFFYDOS
|
||||
clc ; send without EOI
|
||||
!ifdef CONFIG_IEC_JIFFYDOS {
|
||||
jsr iec_tx_dispatch
|
||||
#else
|
||||
} else {
|
||||
jsr iec_tx_byte
|
||||
#endif
|
||||
inc C3PO // tx byte routine sets to 0, but we still have something to send
|
||||
}
|
||||
inc C3PO ; tx byte routine sets to 0, but we still have something to send
|
||||
jmp ciout_store_in_buffer
|
||||
|
||||
#else
|
||||
} else {
|
||||
|
||||
sec // indicate failure
|
||||
sec ; indicate failure
|
||||
rts
|
||||
|
||||
#endif
|
||||
}
|
||||
+13
-13
@@ -1,34 +1,34 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// IEC part of the CKOUT routine
|
||||
//
|
||||
;
|
||||
; IEC part of the CKOUT routine
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
ckout_iec:
|
||||
|
||||
// Fail if the file is open for reading (secondary address 0)
|
||||
; Fail if the file is open for reading (secondary address 0)
|
||||
|
||||
lda LAT, Y
|
||||
beq_16 ckout_file_not_output
|
||||
+beq ckout_file_not_output
|
||||
|
||||
// Send LISTEN + SECOND first
|
||||
; Send LISTEN + SECOND first
|
||||
lda FAT,Y
|
||||
|
||||
jsr LISTEN
|
||||
bcs_16 chkinout_device_not_present
|
||||
+bcs chkinout_device_not_present
|
||||
|
||||
lda LAT, Y
|
||||
ora #$60
|
||||
jsr SECOND
|
||||
bcs_16 chkinout_device_not_present
|
||||
+bcs chkinout_device_not_present
|
||||
|
||||
jmp ckout_set_device
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
} ; CONFIG_IEC
|
||||
+17
-16
@@ -1,38 +1,39 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// IEC part of the CLOSE routine
|
||||
//
|
||||
;
|
||||
; IEC part of the CLOSE routine
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
// .Y contains LAT/FAT/SAT table index, it should stay this way
|
||||
; .Y contains LAT/FAT/SAT table index, it should stay this way
|
||||
|
||||
close_iec:
|
||||
|
||||
jsr iec_tx_flush // make sure no byte is awaiting
|
||||
lda SAT, y // get secondary address
|
||||
jsr iec_tx_flush ; make sure no byte is awaiting
|
||||
lda SAT, y ; get secondary address
|
||||
cmp #$60
|
||||
bne !+
|
||||
bne @1
|
||||
|
||||
// workaround for using CLOSE on reading executable - XXX is this a proper way?
|
||||
; workaround for using CLOSE on reading executable - XXX is this a proper way?
|
||||
jsr iec_close_load
|
||||
jmp close_remove_from_table
|
||||
|
||||
!:
|
||||
ora $E0 // CLOSE command
|
||||
@1:
|
||||
ora $E0 ; CLOSE command
|
||||
sta TBTCNT
|
||||
jsr iec_tx_command
|
||||
bcs close_iec_end
|
||||
jsr iec_tx_command_finalize
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
close_iec_end:
|
||||
|
||||
jmp close_remove_from_table
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
} ; CONFIG_IEC
|
||||
+15
-15
@@ -1,33 +1,33 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// IEC part of the CLRCHN routine
|
||||
//
|
||||
;
|
||||
; IEC part of the CLRCHN routine
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
clrchn_iec:
|
||||
|
||||
// Check input device
|
||||
; Check input device
|
||||
lda DFLTN
|
||||
jsr iec_check_devnum_oc
|
||||
bcs !+
|
||||
bcs @1
|
||||
|
||||
// It was IEC device - send UNTALK first
|
||||
; It was IEC device - send UNTALK first
|
||||
jsr UNTLK
|
||||
!:
|
||||
// Check output device
|
||||
@1:
|
||||
; Check output device
|
||||
lda DFLTO
|
||||
jsr iec_check_devnum_oc
|
||||
|
||||
// If it was IEC device - send UNLSN first
|
||||
bcc_16 UNLSN
|
||||
; If it was IEC device - send UNLSN first
|
||||
+bcc UNLSN
|
||||
|
||||
rts
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
} ; CONFIG_IEC
|
||||
@@ -1,36 +1,36 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Checks whether device number (in .A) is a correct IEC device number
|
||||
//
|
||||
// Preserves .A, .X and .Y
|
||||
//
|
||||
;
|
||||
; Checks whether device number (in .A) is a correct IEC device number
|
||||
;
|
||||
; Preserves .A, .X and .Y
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
iec_check_devnum_lvs: // for load/verify/save
|
||||
iec_check_devnum_lvs: ; for load/verify/save
|
||||
|
||||
cmp #$08 // below 8 are illegal for load/save
|
||||
cmp #$08 ; below 8 are illegal for load/save
|
||||
bcc iec_check_devnum_failed
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
iec_check_devnum_oc: // for open/close
|
||||
iec_check_devnum_oc: ; for open/close
|
||||
|
||||
cmp #$04 // below 4 are illegal, reserved for non-IEC devices on Commodore
|
||||
cmp #$04 ; below 4 are illegal, reserved for non-IEC devices on Commodore
|
||||
bcc iec_check_devnum_failed
|
||||
|
||||
// 31 and above are illegal too, due to IEC command encoding scheme,
|
||||
// see https://www.pagetable.com/?p=1031
|
||||
cmp #$1F // sets carry for 31 or above
|
||||
; 31 and above are illegal too, due to IEC command encoding scheme,
|
||||
; see https://www.pagetable.com/?p=1031
|
||||
cmp #$1F ; sets carry for 31 or above
|
||||
rts
|
||||
|
||||
iec_check_devnum_failed:
|
||||
|
||||
sec // indicate non-IEC device
|
||||
sec ; indicate non-IEC device
|
||||
rts
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
} ; CONFIG_IEC
|
||||
@@ -1,34 +1,34 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Common part of CLOSE and LOAD/SAVE routines for IEC
|
||||
//
|
||||
;
|
||||
; Common part of CLOSE and LOAD/SAVE routines for IEC
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_close_load:
|
||||
|
||||
tax
|
||||
|
||||
// Command drive to stop talking before closing the file
|
||||
; Command drive to stop talking before closing the file
|
||||
jsr UNTLK
|
||||
|
||||
txa
|
||||
jsr LISTEN
|
||||
|
||||
lda #$E0 // CLOSE command
|
||||
lda #$E0 ; CLOSE command
|
||||
sta TBTCNT
|
||||
jsr iec_tx_command
|
||||
jsr iec_tx_command_finalize
|
||||
|
||||
// Tell drive to unlisten
|
||||
; Tell drive to unlisten
|
||||
jsr UNLSN
|
||||
|
||||
rts
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
} ; CONFIG_IEC
|
||||
@@ -1,33 +1,29 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Kernal internal IEC routine
|
||||
//
|
||||
// - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc
|
||||
//
|
||||
;
|
||||
; Kernal internal IEC routine
|
||||
;
|
||||
; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_cmd_close:
|
||||
|
||||
jsr iec_check_channel_openclose
|
||||
bcc !+
|
||||
jmp kernalerror_FILE_NOT_INPUT
|
||||
!:
|
||||
+bcs kernalerror_FILE_NOT_INPUT
|
||||
|
||||
ora #$E0
|
||||
|
||||
#if ROM_LAYOUT_M65
|
||||
!ifdef CONFIG_MB_M65 {
|
||||
|
||||
jsr m65dos_check
|
||||
bcc_16 m65dos_second // branch if device is handeld by internal DOS
|
||||
|
||||
#endif
|
||||
+bcc m65dos_second ; branch if device is handeld by internal DOS
|
||||
}
|
||||
|
||||
jmp common_open_close_unlsn_second
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
@@ -1,78 +1,73 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Kernal internal IEC routine
|
||||
//
|
||||
// - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc
|
||||
//
|
||||
;
|
||||
; Kernal internal IEC routine
|
||||
;
|
||||
; - https://www.pagetable.com/?p=1031, https://github.com/mist64/cbmbus_doc
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_cmd_open: // similar to TKSA, but without turnaround
|
||||
iec_cmd_open: ; similar to TKSA, but without turnaround
|
||||
|
||||
jsr iec_check_channel_openclose
|
||||
bcc !+
|
||||
jmp kernalerror_FILE_NOT_INPUT
|
||||
!:
|
||||
+bcs kernalerror_FILE_NOT_INPUT
|
||||
|
||||
ora #$F0
|
||||
|
||||
#if ROM_LAYOUT_M65
|
||||
!ifdef CONFIG_MB_M65 {
|
||||
|
||||
jsr m65dos_check
|
||||
bcc_16 m65dos_second // branch if device is handeld by internal DOS
|
||||
+bcc m65dos_second ; branch if device is handeld by internal DOS
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if CONFIG_IEC_BURST_CIA1 || CONFIG_IEC_BURST_CIA2 || CONFIG_IEC_BURST_MEGA_65
|
||||
!ifdef HAS_IEC_BURST {
|
||||
pha
|
||||
jsr burst_advertise
|
||||
pla
|
||||
#endif
|
||||
}
|
||||
|
||||
#if CONFIG_IEC_DOLPHINDOS
|
||||
!ifdef CONFIG_IEC_DOLPHINDOS {
|
||||
|
||||
sta TBTCNT
|
||||
jsr iec_tx_command
|
||||
bcs !+ // branch if error
|
||||
|
||||
bcs common_open_close_unlsn_second_done
|
||||
jsr dolphindos_detect
|
||||
|
||||
jmp iec_tx_command_finalize
|
||||
}
|
||||
; FALLTROUGH
|
||||
|
||||
#else
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
#endif
|
||||
|
||||
common_open_close_unlsn_second: // common part of several commands
|
||||
common_open_close_unlsn_second: ; common part of several commands
|
||||
|
||||
sta TBTCNT
|
||||
jsr iec_tx_command
|
||||
bcs !+ // branch if error
|
||||
jmp iec_tx_command_finalize
|
||||
!:
|
||||
+bcc iec_tx_command_finalize
|
||||
|
||||
// FALLTROUGH
|
||||
|
||||
common_open_close_unlsn_second_done:
|
||||
|
||||
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
|
||||
; 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
|
||||
bcc @1
|
||||
; 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
|
||||
beq @1
|
||||
sec ; mark unsuitable channel number
|
||||
rts
|
||||
!:
|
||||
clc // mark suitable channel number
|
||||
@1:
|
||||
clc ; mark suitable channel number
|
||||
rts
|
||||
}
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
@@ -1,88 +1,90 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Helper IEC routines to pull/release certain lines
|
||||
//
|
||||
// Order of operation is set for extra robustness, on non-emulated hardware
|
||||
// lines might need few cycles to stabilize (released CLK = DATA considered valid),
|
||||
// see page 10 of http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
|
||||
//
|
||||
;
|
||||
; Helper IEC routines to pull/release certain lines
|
||||
;
|
||||
; Order of operation is set for extra robustness, on non-emulated hardware
|
||||
; lines might need few cycles to stabilize (released CLK = DATA considered valid),
|
||||
; see page 10 of http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
|
||||
;
|
||||
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_pull_atn_clk_release_data:
|
||||
|
||||
lda CIA2_PRA
|
||||
ora #BIT_CIA2_PRA_ATN_OUT // pull
|
||||
ora #BIT_CIA2_PRA_ATN_OUT ; pull
|
||||
sta CIA2_PRA
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
iec_pull_clk_release_data:
|
||||
|
||||
lda CIA2_PRA
|
||||
ora #BIT_CIA2_PRA_CLK_OUT // pull
|
||||
ora #BIT_CIA2_PRA_CLK_OUT ; pull
|
||||
sta CIA2_PRA
|
||||
!:
|
||||
and #$FF - BIT_CIA2_PRA_DAT_OUT // release
|
||||
bne iec_pull_release_end // branch always
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
iec_pull_clk_release_data_1:
|
||||
|
||||
and #$FF - BIT_CIA2_PRA_DAT_OUT ; release
|
||||
bne iec_pull_release_end ; branch always
|
||||
|
||||
iec_pull_clk_release_data_oneshot:
|
||||
|
||||
lda CIA2_PRA
|
||||
ora #BIT_CIA2_PRA_CLK_OUT // pull
|
||||
bne !- // branch always
|
||||
ora #BIT_CIA2_PRA_CLK_OUT ; pull
|
||||
bne iec_pull_clk_release_data_1 ; branch always
|
||||
|
||||
iec_release_atn_clk_data:
|
||||
|
||||
lda CIA2_PRA
|
||||
and #$FF - BIT_CIA2_PRA_ATN_OUT // release
|
||||
and #$FF - BIT_CIA2_PRA_ATN_OUT ; release
|
||||
sta CIA2_PRA
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
iec_release_clk_data:
|
||||
|
||||
lda CIA2_PRA
|
||||
and #$FF - BIT_CIA2_PRA_DAT_OUT // release
|
||||
and #$FF - BIT_CIA2_PRA_DAT_OUT ; release
|
||||
sta CIA2_PRA
|
||||
and #$FF - BIT_CIA2_PRA_CLK_OUT // release
|
||||
and #$FF - BIT_CIA2_PRA_CLK_OUT ; release
|
||||
jmp iec_pull_release_end
|
||||
|
||||
iec_release_clk_pull_data:
|
||||
|
||||
lda CIA2_PRA
|
||||
ora #BIT_CIA2_PRA_DAT_OUT // pull
|
||||
ora #BIT_CIA2_PRA_DAT_OUT ; pull
|
||||
sta CIA2_PRA
|
||||
and #$FF - BIT_CIA2_PRA_CLK_OUT // release
|
||||
bne iec_pull_release_end // branch always
|
||||
and #$FF - BIT_CIA2_PRA_CLK_OUT ; release
|
||||
bne iec_pull_release_end ; branch always
|
||||
|
||||
iec_pull_data_release_atn_clk:
|
||||
|
||||
lda CIA2_PRA
|
||||
ora #BIT_CIA2_PRA_DAT_OUT // pull
|
||||
ora #BIT_CIA2_PRA_DAT_OUT ; pull
|
||||
sta CIA2_PRA
|
||||
and #$FF - BIT_CIA2_PRA_CLK_OUT // release
|
||||
and #$FF - BIT_CIA2_PRA_CLK_OUT ; release
|
||||
sta CIA2_PRA
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
iec_release_atn:
|
||||
|
||||
lda CIA2_PRA
|
||||
and #$FF - BIT_CIA2_PRA_ATN_OUT // release
|
||||
and #$FF - BIT_CIA2_PRA_ATN_OUT ; release
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
iec_pull_release_end:
|
||||
|
||||
sta CIA2_PRA
|
||||
rts
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
+24
-26
@@ -1,44 +1,42 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// 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
|
||||
//
|
||||
;
|
||||
; 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
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_return_success:
|
||||
|
||||
// BSOUR is certainly not valid anymore
|
||||
; BSOUR is certainly not valid anymore
|
||||
lda #$00
|
||||
sta C3PO
|
||||
// Restore registers
|
||||
ply_trash_a
|
||||
plx_trash_a
|
||||
// Report success
|
||||
; Restore registers
|
||||
+ply_trash_a
|
||||
+plx_trash_a
|
||||
; Report success
|
||||
clc
|
||||
rts
|
||||
|
||||
iec_return_DEVICE_NOT_FOUND:
|
||||
|
||||
// Set IEC line to normal idle state
|
||||
; Set IEC line to normal idle state
|
||||
jsr iec_set_idle
|
||||
// BSOUR is certainly not valid anymore
|
||||
; BSOUR is certainly not valid anymore
|
||||
lda #$00
|
||||
sta C3PO
|
||||
// Restore registers
|
||||
ply_trash_a
|
||||
plx_trash_a
|
||||
// Report error
|
||||
; Restore registers
|
||||
+ply_trash_a
|
||||
+plx_trash_a
|
||||
; Report error
|
||||
jmp kernalerror_DEVICE_NOT_FOUND
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
@@ -1,161 +1,160 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
// 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
|
||||
; 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
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
#if CONFIG_IEC_JIFFYDOS
|
||||
!ifdef CONFIG_IEC_JIFFYDOS {
|
||||
|
||||
iec_rx_dispatch:
|
||||
|
||||
lda IECPROTO
|
||||
cmp #IEC_JIFFY
|
||||
beq_16 jiffydos_rx_byte
|
||||
+beq jiffydos_rx_byte
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
#endif // CONFIG_IEC_JIFFYDOS
|
||||
} ; CONFIG_IEC_JIFFYDOS
|
||||
|
||||
|
||||
iec_rx_byte:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
phx_trash_a
|
||||
phy_trash_a
|
||||
; Store .X and .Y on the stack - preserve them
|
||||
+phx_trash_a
|
||||
+phy_trash_a
|
||||
|
||||
// Timing is critical here - execute on disabled IRQs
|
||||
// The best practice would be to do PHP first, but it seems this is not
|
||||
// what the original ROM does; furthermore, pushing additional bytes to
|
||||
// stack can wreck autostart softwaree loading at $0100
|
||||
; Timing is critical here - execute on disabled IRQs
|
||||
; The best practice would be to do PHP first, but it seems this is not
|
||||
; what the original ROM does; furthermore, pushing additional bytes to
|
||||
; stack can wreck autostart softwaree loading at $0100
|
||||
sei
|
||||
|
||||
// First, we wait for the talker to release the CLK line
|
||||
; 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 were not pulling CLK anyway
|
||||
; We then release the DATA to signal we are ready
|
||||
; We can use this routine, since we were not pulling CLK anyway
|
||||
jsr iec_release_clk_data
|
||||
|
||||
// Wait till data line is released (someone else might be holding it)
|
||||
; Wait till data line is released (someone else might be holding it)
|
||||
jsr iec_wait_for_data_release
|
||||
|
||||
// Check if EOI
|
||||
; Check if EOI
|
||||
jsr iec_rx_check_eoi
|
||||
|
||||
#if CONFIG_IEC_DOLPHINDOS
|
||||
!ifdef CONFIG_IEC_DOLPHINDOS {
|
||||
|
||||
// Check if DolphinDOS was detected
|
||||
; Check if DolphinDOS was detected
|
||||
lda IECPROTO
|
||||
cmp #IEC_DOLPHIN
|
||||
bne iec_rx_no_dolphindos
|
||||
|
||||
// For DolphinDOS just fetch the byte from parallel port
|
||||
; For DolphinDOS just fetch the byte from parallel port
|
||||
lda CIA2_PRB
|
||||
pha
|
||||
jmp iec_rx_acknowledge
|
||||
|
||||
iec_rx_no_dolphindos:
|
||||
|
||||
#endif // CONFIG_IEC_DOLPHINDOS
|
||||
} ; CONFIG_IEC_DOLPHINDOS
|
||||
|
||||
// Latch input bits in on rising edge of CLK, eight times for eight bits.
|
||||
; Latch input bits in on rising edge of CLK, eight times for eight bits.
|
||||
ldx #7
|
||||
|
||||
// Get empty byte to load into.
|
||||
; Get empty byte to load into.
|
||||
lda #$00
|
||||
pha
|
||||
|
||||
iec_rx_bit_loop:
|
||||
|
||||
// Wait for CLK to release
|
||||
; Wait for CLK to release
|
||||
jsr iec_wait_for_clk_release
|
||||
|
||||
// (we do this implicitly below, with a tighter routine,
|
||||
// so that we do not have timing problems, as the requirements
|
||||
// are quite tight. Basically we need to read the clock and data
|
||||
// bit from the same byte read.
|
||||
; (we do this implicitly below, with a tighter routine,
|
||||
; so that we do not 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 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.
|
||||
; 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.
|
||||
|
||||
// Move data bit into C flag, and loop until bit 6 clears
|
||||
// i.e., the clock has been released.
|
||||
; Move data bit into C flag, and loop until bit 6 clears
|
||||
; i.e., the clock has been released.
|
||||
|
||||
!: lda CIA2_PRA
|
||||
@1:
|
||||
lda CIA2_PRA
|
||||
rol
|
||||
bpl !-
|
||||
bpl @1
|
||||
|
||||
// Pull it into the data byte
|
||||
; Pull it into the data byte
|
||||
pla
|
||||
ror
|
||||
pha
|
||||
|
||||
// Wait for CLK to be pulled again, over 300 usec (307 cycles on NTSC)
|
||||
// consider this a timeout
|
||||
ldy #$19 // 2 cycles
|
||||
; 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 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
|
||||
lda CIA2_PRA ; 4 cycles
|
||||
rol ; 2 cycles, to put CLK in as the last bit
|
||||
bpl @2 ; 2 cycles if not jumped
|
||||
dey ; 2 cycles
|
||||
bne iec_rx_clk_wait2 ; 3 cycles if jumped
|
||||
|
||||
// Timeout
|
||||
; Timeout
|
||||
jsr kernalstatus_EOI
|
||||
pla
|
||||
|
||||
jmp iec_rx_end
|
||||
!:
|
||||
// More bits?
|
||||
@2:
|
||||
; More bits?
|
||||
dex
|
||||
bpl iec_rx_bit_loop
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
iec_rx_acknowledge:
|
||||
|
||||
// Then we must within 1000 usec acknowledge the byte 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).
|
||||
; Then we must within 1000 usec acknowledge the byte 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
|
||||
|
||||
// Retrieve the received byte
|
||||
; Retrieve the received byte
|
||||
pla
|
||||
|
||||
// Restore registers
|
||||
sta TBTCNT // $A4 is a byte buffer according to http://sta.c64.org/cbm64mem.html
|
||||
; Restore registers
|
||||
sta TBTCNT ; $A4 is a byte buffer according to http://sta.c64.org/cbm64mem.html
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
iec_rx_end:
|
||||
|
||||
ply_trash_a
|
||||
plx_trash_a
|
||||
+ply_trash_a
|
||||
+plx_trash_a
|
||||
lda TBTCNT
|
||||
|
||||
clc
|
||||
cli
|
||||
rts
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
@@ -1,37 +1,36 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Helper routine to check for EOI while receiving byte from IEC
|
||||
//
|
||||
;
|
||||
; Helper routine to check for EOI while receiving byte from IEC
|
||||
;
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_rx_check_eoi:
|
||||
|
||||
// Wait for talker to pull CLK.
|
||||
// If over 200 usec (205 cycles on NTSC machine) , then it is EOI.
|
||||
// Loop iteraction takes 11 cycles, 19 full iterations are enough
|
||||
; Wait for talker to pull CLK.
|
||||
; If over 200 usec (205 cycles on NTSC machine) , then it is EOI.
|
||||
; Loop iteraction takes 11 cycles, 19 full iterations are enough
|
||||
|
||||
ldx #$13 // 2 cycles
|
||||
ldx #$13 ; 2 cycles
|
||||
@1:
|
||||
bit CIA2_PRA ; 4 cycles
|
||||
bvc iec_rx_check_eoi_done ; 2 cycles if not jumped
|
||||
dex ; 2 cycles
|
||||
bne @1 ; 3 cycles if jumped
|
||||
|
||||
!:
|
||||
bit CIA2_PRA // 4 cycles
|
||||
bvc iec_rx_check_eoi_done // 2 cycles if not jumped
|
||||
dex // 2 cycles
|
||||
bne !- // 3 cycles if jumped
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
iec_rx_check_eoi_confirm:
|
||||
|
||||
// Timeout - either this is the last byte of stream, or the stream is empty at all.
|
||||
// Mark end of stream in IOSTATUS
|
||||
; Timeout - either this is the last byte of stream, or the stream is empty at all.
|
||||
; Mark end of stream in IOSTATUS
|
||||
jsr kernalstatus_EOI
|
||||
|
||||
// Pull data for 60 usec to confirm it
|
||||
; Pull data for 60 usec to confirm it
|
||||
jsr iec_release_clk_pull_data
|
||||
jsr iec_wait60us
|
||||
jsr iec_release_clk_data
|
||||
@@ -39,6 +38,4 @@ iec_rx_check_eoi_confirm:
|
||||
iec_rx_check_eoi_done:
|
||||
|
||||
rts
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
@@ -1,13 +1,13 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Sends file (stream) name to IEC device
|
||||
//
|
||||
;
|
||||
; Sends file (stream) name to IEC device
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_send_file_name:
|
||||
@@ -17,33 +17,31 @@ iec_send_file_name_loop:
|
||||
cpy FNLEN
|
||||
beq iec_send_file_name_done
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
!ifdef CONFIG_MEMORY_MODEL_60K {
|
||||
ldx #<FNADDR+0
|
||||
jsr peek_under_roms
|
||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K {
|
||||
jsr peek_under_roms_via_FNADDR
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
} else { ; CONFIG_MEMORY_MODEL_38K
|
||||
lda (FNADDR),y
|
||||
#endif
|
||||
}
|
||||
|
||||
iny
|
||||
// Set Carry flag on the last file name character, to mark EOI
|
||||
; Set Carry flag on the last file name character, to mark EOI
|
||||
cpy FNLEN
|
||||
clc
|
||||
bne !+
|
||||
bne @1
|
||||
sec
|
||||
!:
|
||||
// Transmit one character
|
||||
@1:
|
||||
; Transmit one character
|
||||
sta TBTCNT
|
||||
#if CONFIG_IEC_JIFFYDOS
|
||||
!ifdef CONFIG_IEC_JIFFYDOS {
|
||||
jsr iec_tx_dispatch
|
||||
#else
|
||||
} else {
|
||||
jsr iec_tx_byte
|
||||
#endif
|
||||
}
|
||||
jmp iec_send_file_name_loop
|
||||
|
||||
iec_send_file_name_done:
|
||||
jmp UNLSN
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_set_idle:
|
||||
|
||||
lda CIA2_PRA
|
||||
ora #BIT_CIA2_PRA_CLK_OUT // pull
|
||||
and #$FF - BIT_CIA2_PRA_DAT_OUT - BIT_CIA2_PRA_ATN_OUT // release
|
||||
ora #BIT_CIA2_PRA_CLK_OUT ; pull
|
||||
and #$FF - BIT_CIA2_PRA_DAT_OUT - BIT_CIA2_PRA_ATN_OUT ; release
|
||||
sta CIA2_PRA
|
||||
rts
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
@@ -1,45 +1,43 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
// 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
|
||||
; 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
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_turnaround_to_listen:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
phx_trash_a
|
||||
phy_trash_a
|
||||
; Store .X and .Y on the stack - preserve them
|
||||
+phx_trash_a
|
||||
+phy_trash_a
|
||||
|
||||
// Timing is critical here - execute on disabled IRQs
|
||||
; Timing is critical here - execute on disabled IRQs
|
||||
php
|
||||
sei
|
||||
|
||||
// Pull DATA, release CLK and ATN (we are not sending commands)
|
||||
; Pull DATA, release CLK and ATN (we are not sending commands)
|
||||
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?
|
||||
!:
|
||||
; Wait for clock line to be pulled by the drive
|
||||
ldx #$FF ; XXX should we really use that high number?
|
||||
@1:
|
||||
lda CIA2_PRA
|
||||
rol // to put BIT_CIA2_PRA_CLK_IN as the last (sign) bit
|
||||
bpl !+
|
||||
rol ; to put BIT_CIA2_PRA_CLK_IN as the last (sign) bit
|
||||
bpl @2
|
||||
dex
|
||||
bne !-
|
||||
bne @1
|
||||
|
||||
// Timeout - XXX what errors do original Kernal report?
|
||||
; Timeout - XXX what errors do original Kernal report?
|
||||
plp
|
||||
jmp iec_return_DEVICE_NOT_FOUND
|
||||
|
||||
// CLK is pulled by the device, OK
|
||||
!:
|
||||
; CLK is pulled by the device, OK
|
||||
@2:
|
||||
plp
|
||||
jmp iec_return_success
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
@@ -1,37 +1,35 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
// 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
|
||||
; 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
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_turnaround_to_talk:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
phx_trash_a
|
||||
phy_trash_a
|
||||
; Store .X and .Y on the stack - preserve them
|
||||
+phx_trash_a
|
||||
+phy_trash_a
|
||||
|
||||
// Timing is critical here - execute on disabled IRQs
|
||||
; Timing is critical here - execute on disabled IRQs
|
||||
php
|
||||
sei
|
||||
|
||||
// First make sure both CLK, DATA and ATN are released at our side
|
||||
; 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
|
||||
; Wait till device releases CLK line
|
||||
jsr iec_wait_for_clk_release
|
||||
|
||||
// Pull CLK line, it should be held by talker
|
||||
; Pull CLK line, it should be held by talker
|
||||
jsr iec_pull_clk_release_data
|
||||
|
||||
plp
|
||||
jmp iec_return_success
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
@@ -1,166 +1,164 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
// Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc
|
||||
; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc
|
||||
|
||||
// Expects byte to send in TBTCNT ($A4 is a byte buffer according to http://sta.c64.org/cbm64mem.html)
|
||||
// Carry flag set = signal EOI
|
||||
//
|
||||
// Preserves .X and .Y registers
|
||||
; Expects byte to send in TBTCNT ($A4 is a byte buffer according to http://sta.c64.org/cbm64mem.html)
|
||||
; Carry flag set = signal EOI
|
||||
;
|
||||
; Preserves .X and .Y registers
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
#if CONFIG_IEC_JIFFYDOS
|
||||
!ifdef CONFIG_IEC_JIFFYDOS {
|
||||
|
||||
iec_tx_dispatch:
|
||||
|
||||
php // preserve C flag for EOI indication
|
||||
php ; preserve C flag for EOI indication
|
||||
lda IECPROTO
|
||||
cmp #IEC_JIFFY
|
||||
bne !+
|
||||
bne @1
|
||||
|
||||
plp
|
||||
jmp jiffydos_tx_byte
|
||||
!:
|
||||
@1:
|
||||
plp
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
#endif // CONFIG_IEC_JIFFYDOS
|
||||
} ; CONFIG_IEC_JIFFYDOS
|
||||
|
||||
|
||||
iec_tx_byte:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
phx_trash_a
|
||||
phy_trash_a
|
||||
; Store .X and .Y on the stack - preserve them
|
||||
+phx_trash_a
|
||||
+phy_trash_a
|
||||
|
||||
// Notify all devices that we are going to send a byte
|
||||
// and it is going to be a data byte (released ATN)
|
||||
; 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_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
|
||||
; 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:
|
||||
|
||||
// Timing is critical here - execute on disabled IRQs
|
||||
// The best practice would be to do PHP first, but it seems this is not
|
||||
// what the original ROM does; furthermore, pushing additional bytes to
|
||||
// stack can wreck autostart software loading at $0100
|
||||
; Timing is critical here - execute on disabled IRQs
|
||||
; The best practice would be to do PHP first, but it seems this is not
|
||||
; what the original ROM does; furthermore, pushing additional bytes to
|
||||
; stack can wreck autostart software loading at $0100
|
||||
sei
|
||||
|
||||
// Wait till all receivers are ready, they should all release DATA
|
||||
; Wait till all receivers are ready, they should all release DATA
|
||||
jsr iec_wait_for_data_release
|
||||
|
||||
bcc !+
|
||||
bcc @2
|
||||
|
||||
// At this point a delay 256 usec or more is considered EOI,
|
||||
// receiver should now acknowledge it by pulling data for at least 60 usec
|
||||
// Keep the implementation as simple as possible: data should be released now
|
||||
// so wait until it is pushed and released again
|
||||
; At this point a delay 256 usec or more is considered EOI,
|
||||
; receiver should now acknowledge it by pulling data for at least 60 usec
|
||||
; Keep the implementation as simple as possible: data should be released now
|
||||
; so wait until it is pushed and released again
|
||||
|
||||
jsr iec_wait_for_data_pull
|
||||
jsr iec_wait_for_data_release
|
||||
!:
|
||||
#if CONFIG_IEC_DOLPHINDOS
|
||||
@2:
|
||||
!ifdef CONFIG_IEC_DOLPHINDOS {
|
||||
|
||||
// Check if DolphinDOS was detected
|
||||
; Check if DolphinDOS was detected
|
||||
lda IECPROTO
|
||||
cmp #IEC_DOLPHIN
|
||||
bne iec_tx_no_dolphindos
|
||||
|
||||
// For DolphinDOS just push the byte to parallel port (set it to output first)
|
||||
; For DolphinDOS just push the byte to parallel port (set it to output first)
|
||||
lda #$FF
|
||||
sta CIA2_DDRB
|
||||
lda TBTCNT
|
||||
sta CIA2_PRB
|
||||
|
||||
// Pull CLK to indicate data is now valid (we should not hold DATA nevertheless)
|
||||
; Pull CLK to indicate data is now valid (we should not hold DATA nevertheless)
|
||||
jsr iec_pull_clk_release_data_oneshot
|
||||
|
||||
// Finish the flow
|
||||
; Finish the flow
|
||||
jmp iec_tx_common_finalize
|
||||
|
||||
iec_tx_no_dolphindos:
|
||||
|
||||
#endif // CONFIG_IEC_DOLPHINDOS
|
||||
} ; CONFIG_IEC_DOLPHINDOS
|
||||
|
||||
// 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)
|
||||
; 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)
|
||||
|
||||
jsr iec_pull_clk_release_data_oneshot
|
||||
jsr iec_wait60us
|
||||
|
||||
// Now, we can start transmission of 8 bits of data
|
||||
; Now, we can start transmission of 8 bits of data
|
||||
ldx #7
|
||||
|
||||
iec_tx_common_sendbit:
|
||||
|
||||
#if CONFIG_IEC_JIFFYDOS
|
||||
!ifdef CONFIG_IEC_JIFFYDOS {
|
||||
|
||||
bne !+ // branch if not sending the last bit
|
||||
bne @3 ; branch if not sending the last bit
|
||||
lda IECPROTO
|
||||
beq !+ // branch if standard protocol
|
||||
beq @3 ; branch if standard protocol
|
||||
|
||||
// JiffyDOS ROM performs detection loop on every command; it seems we have to
|
||||
// replicate this behaviour for compatibility with at least 1541 JiffyDOS ROM
|
||||
; JiffyDOS ROM performs detection loop on every command; it seems we have to
|
||||
; replicate this behaviour for compatibility with at least 1541 JiffyDOS ROM
|
||||
|
||||
jsr jiffydos_detect
|
||||
!:
|
||||
#endif // CONFIG_IEC_JIFFYDOS
|
||||
@3:
|
||||
} ; CONFIG_IEC_JIFFYDOS
|
||||
|
||||
// Is next bit 0 or 1?
|
||||
; Is next bit 0 or 1?
|
||||
lda TBTCNT
|
||||
lsr
|
||||
sta TBTCNT
|
||||
bcs !+
|
||||
bcs @4
|
||||
|
||||
// Bit is 0
|
||||
; Bit is 0
|
||||
jsr iec_release_clk_pull_data
|
||||
jmp iec_tx_common_bit_is_sent
|
||||
!:
|
||||
// Bit is 1
|
||||
@4:
|
||||
; Bit is 1
|
||||
jsr iec_release_clk_data
|
||||
|
||||
iec_tx_common_bit_is_sent:
|
||||
|
||||
// Wait 20us, so that device(s) can pick DATA
|
||||
; 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
|
||||
; Pull CLK for 20us again, before sending the next bit
|
||||
; or performing any other action
|
||||
jsr iec_pull_clk_release_data_oneshot
|
||||
jsr iec_wait20us
|
||||
|
||||
// More bits to send?
|
||||
; More bits to send?
|
||||
dex
|
||||
bpl iec_tx_common_sendbit
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
iec_tx_common_finalize:
|
||||
|
||||
cli
|
||||
|
||||
// Give devices time to tell if they are busy by pulling DATA
|
||||
// They should do it within 1ms
|
||||
; Give devices time to tell if they are busy by pulling DATA
|
||||
; They should do it within 1ms
|
||||
ldx #$FF
|
||||
!:
|
||||
@5:
|
||||
lda CIA2_PRA
|
||||
// BPL here is checking that bit 7 clears,
|
||||
// i.e, that the DATA line is pulled by drive
|
||||
bpl !+
|
||||
; BPL here is checking that bit 7 clears,
|
||||
; i.e, that the DATA line is pulled by drive
|
||||
bpl @6
|
||||
dex
|
||||
bne !-
|
||||
bmi !+
|
||||
bne @5
|
||||
bmi @6
|
||||
jmp iec_return_DEVICE_NOT_FOUND
|
||||
!:
|
||||
@6:
|
||||
jmp iec_return_success
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
@@ -1,46 +1,43 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
// Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc
|
||||
; Implemented based on https://www.pagetable.com/?p=1135, https://github.com/mist64/cbmbus_doc
|
||||
|
||||
// Expects byte to send in TBTCNT ($A4 is a byte buffer according to http://sta.c64.org/cbm64mem.html)
|
||||
// Carry flag set = signal EOI
|
||||
//
|
||||
// Preserves .X and .Y registers
|
||||
; Expects byte to send in TBTCNT ($A4 is a byte buffer according to http://sta.c64.org/cbm64mem.html)
|
||||
; Carry flag set = signal EOI
|
||||
;
|
||||
; Preserves .X and .Y registers
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_tx_command:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
phx_trash_a
|
||||
phy_trash_a
|
||||
; Store .X and .Y on the stack - preserve them
|
||||
+phx_trash_a
|
||||
+phy_trash_a
|
||||
|
||||
// Notify all devices that we are going to send a byte
|
||||
// and it is going to be a command (pulled ATN)
|
||||
; Notify all devices that we are going to send a byte
|
||||
; and it is going to be a command (pulled ATN)
|
||||
jsr iec_pull_atn_clk_release_data
|
||||
|
||||
// Give devices time to respond (response is mandatory!) by pulling DATA
|
||||
; Give devices time to respond (response is mandatory!) by pulling DATA
|
||||
jsr iec_wait1ms
|
||||
lda CIA2_PRA // pulled DATA = highest bit 0 = 'plus'
|
||||
bpl !+
|
||||
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
|
||||
// ready (or bored with DOS attack...)
|
||||
// Release back CLK, keep DATA released - to ask devices for status.
|
||||
lda CIA2_PRA ; pulled DATA = highest bit 0 = 'plus'
|
||||
+bmi 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
|
||||
; ready (or bored with DOS attack...)
|
||||
; Release back CLK, keep DATA released - to ask devices for status.
|
||||
|
||||
jsr iec_release_clk_data
|
||||
|
||||
// Common part of iec_txbyte and iec_tx_common - waits for devices
|
||||
// and transmits a byte
|
||||
; 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
|
||||
clc ; Carry flag set is used for EOI mark
|
||||
jmp iec_tx_common
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
@@ -1,27 +1,25 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
// 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
|
||||
; 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
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_tx_command_finalize:
|
||||
|
||||
// Store .X and .Y on the stack - preserve them
|
||||
phx_trash_a
|
||||
phy_trash_a
|
||||
; Store .X and .Y on the stack - preserve them
|
||||
+phx_trash_a
|
||||
+phy_trash_a
|
||||
|
||||
// Give device some time to complete command reception, release ATN,
|
||||
// give it some time again before (possible) next command
|
||||
; 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
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
@@ -1,25 +1,23 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
// Flush the IEC output buffer (if not empty) - send byte with EOI
|
||||
//
|
||||
// Preserves .X, .Y and .A registers
|
||||
; Flush the IEC output buffer (if not empty) - send byte with EOI
|
||||
;
|
||||
; Preserves .X, .Y and .A registers
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_tx_flush:
|
||||
|
||||
pha
|
||||
lda C3PO
|
||||
beq !+
|
||||
sec // send it with EOI
|
||||
jsr iec_tx_byte // send the command regardless of the status
|
||||
!:
|
||||
beq @1
|
||||
sec ; send it with EOI
|
||||
jsr iec_tx_byte ; send the command regardless of the status
|
||||
@1:
|
||||
pla
|
||||
rts
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
@@ -1,24 +1,22 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Common EAL update routine
|
||||
//
|
||||
;
|
||||
; Common EAL update routine
|
||||
;
|
||||
|
||||
|
||||
#if (CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS) && !CONFIG_MEMORY_MODEL_60K
|
||||
!ifdef CONFIG_IEC_JIFFYDOS_OR_DOLPHINDOS { !ifndef CONFIG_MEMORY_MODEL_60K {
|
||||
|
||||
|
||||
iec_update_EAL_by_Y: // note: Carry has to be set by caller!
|
||||
iec_update_EAL_by_Y: ; note: Carry has to be set by caller!
|
||||
|
||||
tya
|
||||
adc EAL+0
|
||||
sta EAL+0
|
||||
bcc !+
|
||||
bcc @1
|
||||
inc EAL+1
|
||||
!:
|
||||
@1:
|
||||
rts
|
||||
|
||||
|
||||
#endif
|
||||
} }
|
||||
@@ -1,37 +1,41 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# X16 * #IGNORE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# X16 * #IGNORE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Wait 1 ms (1000 usec)
|
||||
//
|
||||
// On NTSC this means 1023 cycles (slightly less on PAL, but we have to be sure).
|
||||
// We cant count on badlines, as the screen might be disabled.
|
||||
// Delay here is implemented 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
|
||||
;
|
||||
; Wait 1 ms (1000 usec)
|
||||
;
|
||||
; On NTSC this means 1023 cycles (slightly less on PAL, but we have to be sure).
|
||||
; We cant count on badlines, as the screen might be disabled.
|
||||
; Delay here is implemented 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
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_wait1ms:
|
||||
|
||||
ldx #18 // we probably won't start with the beginning of raster
|
||||
ldx #18 ; we probably won't start with the beginning of raster
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
} ; CONFIG_IEC
|
||||
|
||||
wait_x_bars: // additional entry point for delayy in screen and tape support
|
||||
// has to preserve .Y and put .X to 0
|
||||
; FALLTROUGH
|
||||
|
||||
wait_x_bars: ; additional entry point for delayy in screen and tape support
|
||||
; has to preserve .Y and put .X to 0
|
||||
|
||||
lda VIC_RASTER
|
||||
!:
|
||||
@1:
|
||||
cmp VIC_RASTER
|
||||
beq !-
|
||||
beq @1
|
||||
lda VIC_RASTER
|
||||
dex
|
||||
bne !-
|
||||
bne @1
|
||||
|
||||
iec_wait_rts: // dummy RTS, for very short waits
|
||||
; FALLTROUGH
|
||||
|
||||
iec_wait_rts: ; dummy RTS, for very short waits
|
||||
|
||||
rts
|
||||
@@ -1,31 +1,30 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_wait20us:
|
||||
|
||||
// Wait 20usec
|
||||
; Wait 20usec
|
||||
|
||||
// PAL:
|
||||
// - 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 21 cycles
|
||||
; PAL:
|
||||
; - 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 21 cycles
|
||||
|
||||
// Waste cycles by reading some unimportant memory location
|
||||
// in order not to clutter VICE debug logs
|
||||
; 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
|
||||
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
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
; 6 cycles JSR to routine,
|
||||
; 14 cycles routine with RTS
|
||||
; 1 cycle to fetch next instruction
|
||||
; ---
|
||||
; 21 cycles
|
||||
}
|
||||
@@ -1,36 +1,35 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Note: damages .X
|
||||
//
|
||||
;
|
||||
; Note: damages .X
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_wait60us:
|
||||
|
||||
// Wait 60usec
|
||||
; Wait 60usec
|
||||
|
||||
// PAL:
|
||||
// - 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 62 cycles
|
||||
; PAL:
|
||||
; - 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 62 cycles
|
||||
|
||||
// Waste cycles in a loop
|
||||
; Waste cycles in a loop
|
||||
|
||||
ldx #$0A // 2 cycles
|
||||
!: dex // 2 cycles * 10
|
||||
bpl !- // 3 cycles * 9 + 2 cycles
|
||||
rts // 6 cycles
|
||||
ldx #$0A ; 2 cycles
|
||||
@1:
|
||||
dex ; 2 cycles * 10
|
||||
bpl @1 ; 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
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
; 6 cycles JSR to routine,
|
||||
; 57 cycles routine with RTS
|
||||
; 1 cycle to fetch next instruction
|
||||
; ---
|
||||
; 64 cycles
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_wait_for_clk_release:
|
||||
@@ -11,6 +11,4 @@ iec_wait_for_clk_release:
|
||||
bit CIA2_PRA
|
||||
bvc iec_wait_for_clk_release
|
||||
rts
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
@@ -1,18 +1,16 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_wait_for_data_pull:
|
||||
|
||||
lda CIA2_PRA
|
||||
// Check the highest bit, which is DATA IN,
|
||||
// (highest bit set = negative value)
|
||||
; Check the highest bit, which is DATA IN,
|
||||
; (highest bit set = negative value)
|
||||
bmi iec_wait_for_data_pull
|
||||
rts
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
@@ -1,17 +1,16 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
iec_wait_for_data_release:
|
||||
|
||||
lda CIA2_PRA
|
||||
// Check the highest bit, which is DATA IN,
|
||||
// (highest bit set = negative value)
|
||||
; Check the highest bit, which is DATA IN,
|
||||
; (highest bit set = negative value)
|
||||
bpl iec_wait_for_data_release
|
||||
rts
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
+29
-29
@@ -1,49 +1,49 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Official Kernal routine, described in:
|
||||
//
|
||||
// - [RG64] C64 Programmers Reference Guide - page 285
|
||||
// - [CM64] Computes 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
|
||||
//
|
||||
;
|
||||
; Official Kernal routine, described in:
|
||||
;
|
||||
; - [RG64] C64 Programmers Reference Guide - page 285
|
||||
; - [CM64] Computes 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
|
||||
;
|
||||
|
||||
|
||||
LISTEN:
|
||||
|
||||
#if CONFIG_IEC || ROM_LAYOUT_M65
|
||||
!ifdef CONFIG_MB_M65 {
|
||||
|
||||
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||
; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||
jsr iec_tx_flush
|
||||
|
||||
#endif
|
||||
|
||||
#if ROM_LAYOUT_M65
|
||||
|
||||
jsr m65dos_detect
|
||||
bcc_16 m65dos_listen // branch if device is handeld by internal DOS
|
||||
+bcc m65dos_listen ; branch if device is handeld by internal DOS
|
||||
|
||||
#endif
|
||||
} else ifdef CONFIG_IEC {
|
||||
|
||||
#if CONFIG_IEC
|
||||
; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||
jsr iec_tx_flush
|
||||
}
|
||||
|
||||
// Check whether device number is correct
|
||||
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
; Check whether device number is correct
|
||||
jsr iec_check_devnum_oc
|
||||
bcc !+
|
||||
bcc @1
|
||||
jmp kernalerror_DEVICE_NOT_FOUND
|
||||
!:
|
||||
// Encode and execute the command
|
||||
@1:
|
||||
; Encode and execute the command
|
||||
ora #$20
|
||||
|
||||
jmp common_talk_listen
|
||||
|
||||
#else
|
||||
} else {
|
||||
|
||||
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||
|
||||
#endif
|
||||
}
|
||||
+74
-75
@@ -1,13 +1,13 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// IEC part of the LOAD routine
|
||||
//
|
||||
;
|
||||
; IEC part of the LOAD routine
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
load_iec_dev_not_found:
|
||||
@@ -30,55 +30,55 @@ load_break_error:
|
||||
|
||||
load_iec:
|
||||
|
||||
// Check file name
|
||||
; Check file name
|
||||
lda FNLEN
|
||||
beq_16 kernalerror_FILE_NAME_MISSING
|
||||
+beq kernalerror_FILE_NAME_MISSING
|
||||
|
||||
// Display SEARCHING FOR + filename
|
||||
; Display SEARCHING FOR + filename
|
||||
jsr lvs_display_searching_for
|
||||
|
||||
// http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
|
||||
// p13, 16; also p16 tells us this routine does not mess with the file
|
||||
// table in the C64, only in the drive.
|
||||
; http://www.zimmers.net/anonftp/pub/cbm/programming/serial-bus.pdf
|
||||
; p13, 16; also p16 tells us this routine does not mess with the file
|
||||
; table in the C64, only in the drive.
|
||||
|
||||
// Call device to LISTEN (p16)
|
||||
; Call device to LISTEN (p16)
|
||||
lda FA
|
||||
jsr LISTEN
|
||||
bcs load_iec_dev_not_found
|
||||
|
||||
// Open channel 0 (reserved for file reading)
|
||||
; Open channel 0 (reserved for file reading)
|
||||
lda #$00
|
||||
jsr iec_cmd_open
|
||||
bcs load_iec_dev_not_found
|
||||
|
||||
// Send file name
|
||||
; Send file name
|
||||
jsr iec_send_file_name
|
||||
bcs load_iec_error
|
||||
|
||||
// Now command device to talk (p16)
|
||||
; Now command device to talk (p16)
|
||||
lda FA
|
||||
jsr TALK
|
||||
bcs load_iec_error
|
||||
|
||||
#if CONFIG_IEC_BURST_CIA1 || CONFIG_IEC_BURST_CIA2 || CONFIG_IEC_BURST_MEGA_65
|
||||
!ifdef HAS_IEC_BURST {
|
||||
jsr burst_advertise
|
||||
#endif
|
||||
}
|
||||
|
||||
lda #$60 // open channel / data (p3) , required according to p13
|
||||
lda #$60 ; open channel / data (p3) , required according to p13
|
||||
sta TBTCNT
|
||||
jsr iec_tx_command
|
||||
bcs load_iec_error
|
||||
|
||||
#if CONFIG_IEC_DOLPHINDOS
|
||||
!ifdef CONFIG_IEC_DOLPHINDOS {
|
||||
jsr dolphindos_detect
|
||||
#endif
|
||||
}
|
||||
|
||||
// We are currently talker, so do the IEC turn around so that we
|
||||
// are the listener (p16)
|
||||
; We are currently talker, so do the IEC turn around so that we
|
||||
; are the listener (p16)
|
||||
jsr iec_turnaround_to_listen
|
||||
bcs load_iec_error
|
||||
|
||||
// Get load address
|
||||
; Get load address
|
||||
|
||||
jsr load_iec_get_addr_byte
|
||||
sta EAL+0
|
||||
@@ -86,121 +86,120 @@ load_iec:
|
||||
jsr load_iec_get_addr_byte
|
||||
sta EAL+1
|
||||
|
||||
// If secondary address is 0, override EAL with STAL
|
||||
; If secondary address is 0, override EAL with STAL
|
||||
|
||||
lda SA
|
||||
bne !+
|
||||
bne @1
|
||||
lda STAL+0
|
||||
sta EAL+0
|
||||
lda STAL+1
|
||||
sta EAL+1
|
||||
!:
|
||||
#if ROM_LAYOUT_M65
|
||||
@1:
|
||||
!ifdef CONFIG_MB_M65 {
|
||||
|
||||
// Switch to legacy mode if needed
|
||||
; Switch to legacy mode if needed
|
||||
|
||||
jsr m65_load_autoswitch
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Display start address
|
||||
; Display start address
|
||||
|
||||
jsr lvs_display_loading_verifying
|
||||
|
||||
#if (CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS) && !CONFIG_MEMORY_MODEL_60K
|
||||
!ifdef CONFIG_IEC_JIFFYDOS_OR_DOLPHINDOS { !ifndef CONFIG_MEMORY_MODEL_60K {
|
||||
|
||||
// If feasible, use protocol-specific optimized LOAD loop
|
||||
; If feasible, use protocol-specific optimized LOAD loop
|
||||
|
||||
lda VERCKK
|
||||
bne load_iec_loop // branch if VERIFY
|
||||
bne load_iec_loop ; branch if VERIFY
|
||||
lda IECPROTO
|
||||
|
||||
#if CONFIG_IEC_JIFFYDOS
|
||||
!ifdef CONFIG_IEC_JIFFYDOS {
|
||||
cmp #IEC_JIFFY
|
||||
beq_16 jiffydos_load // branch if JiffyDOS
|
||||
#endif
|
||||
+beq jiffydos_load ; branch if JiffyDOS
|
||||
}
|
||||
|
||||
#if CONFIG_IEC_DOLPHINDOS
|
||||
!ifdef CONFIG_IEC_DOLPHINDOS {
|
||||
cmp #IEC_DOLPHIN
|
||||
beq_16 dolphindos_load // branch if DolphinDOS
|
||||
#endif
|
||||
+beq dolphindos_load ; branch if DolphinDOS
|
||||
}
|
||||
|
||||
} }
|
||||
|
||||
#endif
|
||||
|
||||
load_iec_loop:
|
||||
|
||||
// We are now ready to receive bytes
|
||||
#if CONFIG_IEC_JIFFYDOS
|
||||
; We are now ready to receive bytes
|
||||
!ifdef CONFIG_IEC_JIFFYDOS {
|
||||
jsr iec_rx_dispatch
|
||||
#else
|
||||
} else {
|
||||
jsr iec_rx_byte
|
||||
#endif
|
||||
}
|
||||
bcs load_iec_error
|
||||
|
||||
// Handle the byte (store in memory / verify)
|
||||
; Handle the byte (store in memory / verify)
|
||||
jsr lvs_handle_byte_load_verify
|
||||
bcs load_iec_error
|
||||
|
||||
// Advance pointer to data; it is OK if it advances past $FFFF,
|
||||
// one autostart technique does exactly this
|
||||
#if !HAS_OPCODES_65CE02
|
||||
; Advance pointer to data; it is OK if it advances past $FFFF,
|
||||
; one autostart technique does exactly this
|
||||
!ifndef HAS_OPCODES_65CE02 {
|
||||
inc EAL+0
|
||||
bne !+
|
||||
bne @2
|
||||
inc EAL+1
|
||||
!:
|
||||
#else
|
||||
@2:
|
||||
} else {
|
||||
inw EAL+0
|
||||
#endif
|
||||
}
|
||||
|
||||
// Handle STOP key; it is probably an overkill to do it
|
||||
// with every byte, once per 32 bytes should be enough
|
||||
; Handle STOP key; it is probably an overkill to do it
|
||||
; with every byte, once per 32 bytes should be enough
|
||||
lda EAL
|
||||
and #$1F
|
||||
bne !+
|
||||
phx_trash_a
|
||||
bne @3
|
||||
+phx_trash_a
|
||||
jsr udtim_keyboard
|
||||
jsr STOP
|
||||
bcs_16 load_break_error
|
||||
plx_trash_a
|
||||
!:
|
||||
// Check for EOI - if so, this was the last byte
|
||||
+bcs load_break_error
|
||||
+plx_trash_a
|
||||
@3:
|
||||
; Check for EOI - if so, this was the last byte
|
||||
bit IOSTATUS
|
||||
bvc load_iec_loop
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
load_iec_loop_end:
|
||||
|
||||
// Display end address
|
||||
; Display end address
|
||||
jsr lvs_display_done
|
||||
|
||||
// Close file on drive
|
||||
; Close file on drive
|
||||
|
||||
lda FA
|
||||
jsr iec_close_load
|
||||
|
||||
// Return last address
|
||||
; Return last address
|
||||
jmp lvs_return_last_address
|
||||
|
||||
|
||||
load_iec_get_addr_byte:
|
||||
|
||||
#if CONFIG_IEC_JIFFYDOS
|
||||
!ifdef CONFIG_IEC_JIFFYDOS {
|
||||
jsr iec_rx_dispatch
|
||||
#else // no turbo supported
|
||||
} else {
|
||||
jsr iec_rx_byte
|
||||
#endif
|
||||
|
||||
bcs !+
|
||||
}
|
||||
bcs @4
|
||||
lda IOSTATUS
|
||||
and #K_STS_EOI
|
||||
bne !+
|
||||
bne @4
|
||||
lda TBTCNT
|
||||
rts
|
||||
!:
|
||||
@4:
|
||||
pla
|
||||
pla
|
||||
jmp load_iec_file_not_found
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
} ; CONFIG_IEC
|
||||
+18
-20
@@ -1,43 +1,41 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// IEC part of the OPEN routine
|
||||
//
|
||||
;
|
||||
; IEC part of the OPEN routine
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
open_iec:
|
||||
|
||||
// Check for command to send
|
||||
; Check for command to send
|
||||
ldy FNLEN
|
||||
beq open_iec_done
|
||||
|
||||
// We have a command to send to IEC device
|
||||
; We have a command to send to IEC device
|
||||
jsr LISTEN
|
||||
bcc !+
|
||||
bcc @1
|
||||
jmp kernalerror_DEVICE_NOT_FOUND
|
||||
!:
|
||||
@1:
|
||||
lda SA
|
||||
jsr iec_cmd_open
|
||||
bcc !+
|
||||
bcc @2
|
||||
jmp kernalerror_DEVICE_NOT_FOUND
|
||||
!:
|
||||
@2:
|
||||
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
// We need our helpers to get to filenames under ROMs or IO area
|
||||
!ifdef CONFIG_MEMORY_MODEL_60K {
|
||||
; We need our helpers to get to filenames under ROMs or IO area
|
||||
jsr install_ram_routines
|
||||
#endif
|
||||
}
|
||||
|
||||
// Send command ('file name')
|
||||
; Send command ('file name')
|
||||
jsr iec_send_file_name
|
||||
|
||||
open_iec_done:
|
||||
|
||||
jmp open_done_success
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
+47
-46
@@ -1,13 +1,13 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// IEC part of the SAVE routine
|
||||
//
|
||||
;
|
||||
; IEC part of the SAVE routine
|
||||
;
|
||||
|
||||
|
||||
#if CONFIG_IEC
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
|
||||
save_iec_dev_not_found:
|
||||
@@ -16,117 +16,118 @@ save_iec_dev_not_found:
|
||||
|
||||
save_iec:
|
||||
|
||||
// Check file name
|
||||
; Check file name
|
||||
lda FNLEN
|
||||
beq_16 kernalerror_FILE_NAME_MISSING
|
||||
+beq kernalerror_FILE_NAME_MISSING
|
||||
|
||||
// Display SAVING
|
||||
; Display SAVING
|
||||
jsr lvs_display_saving
|
||||
|
||||
// Call device to LISTEN
|
||||
; Call device to LISTEN
|
||||
lda FA
|
||||
jsr LISTEN
|
||||
bcs save_iec_dev_not_found
|
||||
|
||||
// Open channel 1 (reserved for file writing)
|
||||
; Open channel 1 (reserved for file writing)
|
||||
lda #$01
|
||||
jsr iec_cmd_open
|
||||
bcs save_iec_dev_not_found
|
||||
|
||||
// Send file name
|
||||
; Send file name
|
||||
jsr iec_send_file_name
|
||||
bcs save_iec_dev_not_found
|
||||
|
||||
// Call device to LISTEN once again
|
||||
; Call device to LISTEN once again
|
||||
lda FA
|
||||
jsr LISTEN
|
||||
bcs save_iec_dev_not_found
|
||||
|
||||
#if CONFIG_IEC_BURST_CIA1 || CONFIG_IEC_BURST_CIA2 || CONFIG_IEC_BURST_MEGA_65
|
||||
!ifdef HAS_BURST {
|
||||
jsr burst_advertise
|
||||
#endif
|
||||
}
|
||||
|
||||
lda #$61 // open channel / data (p3) , required according to p13
|
||||
lda #$61 ; open channel / data (p3) , required according to p13
|
||||
sta TBTCNT
|
||||
jsr iec_tx_command
|
||||
bcs save_iec_dev_not_found
|
||||
|
||||
#if CONFIG_IEC_DOLPHINDOS
|
||||
!ifdef CONFIG_IEC_DOLPHINDOS {
|
||||
jsr dolphindos_detect
|
||||
#endif
|
||||
}
|
||||
|
||||
// Save start address
|
||||
; Save start address
|
||||
lda STAL+0
|
||||
sta TBTCNT
|
||||
clc
|
||||
#if CONFIG_IEC_JIFFYDOS
|
||||
!ifdef CONFIG_IEC_JIFFYDOS {
|
||||
jsr iec_tx_dispatch
|
||||
#else
|
||||
} else {
|
||||
jsr iec_tx_byte
|
||||
#endif
|
||||
}
|
||||
|
||||
lda STAL+1
|
||||
sta TBTCNT
|
||||
clc
|
||||
#if CONFIG_IEC_JIFFYDOS
|
||||
!ifdef CONFIG_IEC_JIFFYDOS {
|
||||
jsr iec_tx_dispatch
|
||||
#else
|
||||
} else {
|
||||
jsr iec_tx_byte
|
||||
#endif
|
||||
}
|
||||
|
||||
jsr lvs_STAL_to_MEMUSS
|
||||
ldy #$00
|
||||
|
||||
; FALLTROUGH
|
||||
|
||||
iec_save_loop:
|
||||
|
||||
// Retrieve byte to send
|
||||
#if CONFIG_MEMORY_MODEL_60K
|
||||
; Retrieve byte to send
|
||||
!ifdef CONFIG_MEMORY_MODEL_60K {
|
||||
ldx #<MEMUSS+0
|
||||
jsr peek_under_roms
|
||||
#elif CONFIG_MEMORY_MODEL_46K || CONFIG_MEMORY_MODEL_50K
|
||||
} else ifdef CONFIG_MEMORY_MODEL_46K_OR_50K {
|
||||
jsr peek_under_roms_via_MEMUSS
|
||||
#else // CONFIG_MEMORY_MODEL_38K
|
||||
} else { ; CONFIG_MEMORY_MODEL_38K
|
||||
lda (MEMUSS),y
|
||||
#endif
|
||||
}
|
||||
|
||||
// Send the byte
|
||||
; Send the byte
|
||||
sta TBTCNT
|
||||
clc
|
||||
#if CONFIG_IEC_JIFFYDOS
|
||||
!ifdef CONFIG_IEC_JIFFYDOS {
|
||||
jsr iec_tx_dispatch
|
||||
#else
|
||||
} else {
|
||||
jsr iec_tx_byte
|
||||
#endif
|
||||
}
|
||||
|
||||
// Next iteration
|
||||
#if !HAS_OPCODES_65CE02
|
||||
; Next iteration
|
||||
!ifndef HAS_OPCODES_65CE02 {
|
||||
jsr lvs_advance_MEMUSS
|
||||
#else
|
||||
} else {
|
||||
inw MEMUSS+0
|
||||
#endif
|
||||
}
|
||||
jsr lvs_check_EAL
|
||||
bne iec_save_loop
|
||||
|
||||
iec_save_loop_end:
|
||||
|
||||
// Close file on drive
|
||||
; Close file on drive
|
||||
lda FA
|
||||
jsr UNLSN
|
||||
|
||||
lda FA
|
||||
jsr LISTEN
|
||||
|
||||
lda #$E1 // CLOSE command
|
||||
lda #$E1 ; CLOSE command
|
||||
sta TBTCNT
|
||||
jsr iec_tx_command
|
||||
jsr iec_tx_command_finalize
|
||||
|
||||
// Tell drive to unlisten
|
||||
; Tell drive to unlisten
|
||||
lda FA
|
||||
jsr UNLSN
|
||||
|
||||
// Return success
|
||||
; Return success
|
||||
clc
|
||||
rts
|
||||
|
||||
|
||||
#endif // CONFIG_IEC
|
||||
}
|
||||
+23
-25
@@ -1,41 +1,39 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Official Kernal routine, described in:
|
||||
//
|
||||
// - [RG64] C64 Programmers Reference Guide - page 296
|
||||
// - [CM64] Computes 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
|
||||
//
|
||||
;
|
||||
; Official Kernal routine, described in:
|
||||
;
|
||||
; - [RG64] C64 Programmers Reference Guide - page 296
|
||||
; - [CM64] Computes 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 cleanup: iec_cmd_open and iec_cmd_close should just do ORA and jump directly here
|
||||
; XXX cleanup: iec_cmd_open and iec_cmd_close should just do ORA and jump directly here
|
||||
|
||||
|
||||
SECOND:
|
||||
|
||||
#if ROM_LAYOUT_M65
|
||||
!ifdef CONFIG_MB_M65 {
|
||||
|
||||
jsr m65dos_check
|
||||
bcc_16 m65dos_second // branch if device is handeld by internal DOS
|
||||
+bcc m65dos_second ; branch if device is handeld by internal DOS
|
||||
}
|
||||
|
||||
#endif
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
#if CONFIG_IEC
|
||||
|
||||
// Due to OPEN/CLOSE/TKSA/SECOND command encoding, allowed channels are 0-15; it is the caller
|
||||
// responsibility, hovewer, to provide value ORed with $60
|
||||
// - https://www.lemon64.com/forum/viewtopic.php?t=57694&sid=531ba3592bcffadef2ac8b9162f2e529
|
||||
// - https://www.pagetable.com/?p=1031 (Kernal API description)
|
||||
; Due to OPEN/CLOSE/TKSA/SECOND command encoding, allowed channels are 0-15; it is the caller
|
||||
; responsibility, hovewer, to provide value ORed with $60
|
||||
; - https://www.lemon64.com/forum/viewtopic.php?t=57694&sid=531ba3592bcffadef2ac8b9162f2e529
|
||||
; - https://www.pagetable.com/?p=1031 (Kernal API description)
|
||||
|
||||
jmp common_open_close_unlsn_second
|
||||
|
||||
#else
|
||||
} else {
|
||||
|
||||
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||
|
||||
#endif
|
||||
}
|
||||
+34
-36
@@ -1,62 +1,60 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Official Kernal routine, described in:
|
||||
//
|
||||
// - [RG64] C64 Programmers Reference Guide - page 301/302
|
||||
// - [CM64] Computes 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
|
||||
//
|
||||
;
|
||||
; Official Kernal routine, described in:
|
||||
;
|
||||
; - [RG64] C64 Programmers Reference Guide - page 301/302
|
||||
; - [CM64] Computes 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
|
||||
;
|
||||
|
||||
|
||||
TALK:
|
||||
|
||||
#if CONFIG_IEC || ROM_LAYOUT_M65
|
||||
|
||||
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||
!ifdef CONFIG_MB_M65 {
|
||||
|
||||
; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||
jsr iec_tx_flush
|
||||
|
||||
#endif
|
||||
|
||||
#if ROM_LAYOUT_M65
|
||||
|
||||
jsr m65dos_detect
|
||||
bcc_16 m65dos_talk // branch if device is handeld by internal DOS
|
||||
+bcc m65dos_talk ; branch if device is handeld by internal DOS
|
||||
|
||||
#endif
|
||||
} else ifdef CONFIG_IEC {
|
||||
|
||||
#if CONFIG_IEC
|
||||
; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||
jsr iec_tx_flush
|
||||
}
|
||||
|
||||
// Check whether device number is correct
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
; Check whether device number is correct
|
||||
jsr iec_check_devnum_oc
|
||||
bcc !+
|
||||
jmp kernalerror_DEVICE_NOT_FOUND
|
||||
!:
|
||||
// Encode and execute the command
|
||||
+bcs kernalerror_DEVICE_NOT_FOUND
|
||||
|
||||
; Encode and execute the command
|
||||
ora #$40
|
||||
|
||||
// FALLTROUGH
|
||||
; FALLTROUGH
|
||||
|
||||
common_talk_listen: // common part of TALK and LISTEN
|
||||
common_talk_listen: ; common part of TALK and LISTEN
|
||||
|
||||
sta TBTCNT
|
||||
|
||||
#if CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS
|
||||
!ifdef CONFIG_IEC_JIFFYDOS_OR_DOLPHINDOS {
|
||||
|
||||
lda #$FF // force JiffyDOS detection, clear DolphinDOS mark
|
||||
lda #$FF ; force JiffyDOS detection, clear DolphinDOS mark
|
||||
sta IECPROTO
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
jmp iec_tx_command
|
||||
|
||||
#else
|
||||
} else {
|
||||
|
||||
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||
|
||||
#endif
|
||||
}
|
||||
+22
-24
@@ -1,40 +1,38 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Official Kernal routine, described in:
|
||||
//
|
||||
// - [RG64] C64 Programmers Reference Guide - page 302
|
||||
// - [CM64] Computes 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
|
||||
//
|
||||
;
|
||||
; Official Kernal routine, described in:
|
||||
;
|
||||
; - [RG64] C64 Programmers Reference Guide - page 302
|
||||
; - [CM64] Computes 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
|
||||
;
|
||||
|
||||
|
||||
TKSA:
|
||||
|
||||
#if ROM_LAYOUT_M65
|
||||
!ifdef CONFIG_MB_MEGA65 {
|
||||
|
||||
jsr m65dos_check
|
||||
bcc_16 m65dos_tksa // branch if device is handeld by internal DOS
|
||||
+bcc m65dos_tksa ; branch if device is handeld by internal DOS
|
||||
}
|
||||
|
||||
#endif
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
#if CONFIG_IEC
|
||||
|
||||
// Due to OPEN/CLOSE/TKSA/SECOND command encoding, allowed channels are 0-15; it is the caller
|
||||
// responsibility, hovewer, to provide value ORed with $60
|
||||
// - https://www.lemon64.com/forum/viewtopic.php?t=57694&sid=531ba3592bcffadef2ac8b9162f2e529
|
||||
// - https://www.pagetable.com/?p=1031 (Kernal API description)
|
||||
; Due to OPEN/CLOSE/TKSA/SECOND command encoding, allowed channels are 0-15; it is the caller
|
||||
; responsibility, hovewer, to provide value ORed with $60
|
||||
; - https://www.lemon64.com/forum/viewtopic.php?t=57694&sid=531ba3592bcffadef2ac8b9162f2e529
|
||||
; - https://www.pagetable.com/?p=1031 (Kernal API description)
|
||||
|
||||
ora #$90
|
||||
|
||||
jmp common_untlk_tksa
|
||||
|
||||
#else
|
||||
} else {
|
||||
|
||||
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||
|
||||
#endif
|
||||
}
|
||||
+29
-30
@@ -1,51 +1,50 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Official Kernal routine, described in:
|
||||
//
|
||||
// - [RG64] C64 Programmers Reference Guide - page 303
|
||||
// - [CM64] Computes 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
|
||||
//
|
||||
;
|
||||
; Official Kernal routine, described in:
|
||||
;
|
||||
; - [RG64] C64 Programmers Reference Guide - page 303
|
||||
; - [CM64] Computes 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
|
||||
;
|
||||
|
||||
|
||||
UNLSN:
|
||||
|
||||
#if CONFIG_IEC || ROM_LAYOUT_M65
|
||||
!ifdef CONFIG_MB_M65 {
|
||||
|
||||
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||
; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||
jsr iec_tx_flush
|
||||
|
||||
#endif
|
||||
|
||||
#if ROM_LAYOUT_M65
|
||||
|
||||
jsr m65dos_check
|
||||
bcc_16 m65dos_unlsn // branch if device is handeld by internal DOS
|
||||
+bcc m65dos_unlsn ; branch if device is handeld by internal DOS
|
||||
|
||||
#endif
|
||||
} else ifdef CONFIG_IEC {
|
||||
|
||||
#if CONFIG_IEC
|
||||
; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||
jsr iec_tx_flush
|
||||
}
|
||||
|
||||
#if CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS
|
||||
|
||||
lda #$FF // do not use JiffyDOS / DolphinDOS anymore, trigger JiffyDOS detection
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
!ifdef CONFIG_IEC_JIFFYDOS_OR_DOLPHINDOS {
|
||||
|
||||
lda #$FF ; do not use JiffyDOS / DolphinDOS anymore, trigger JiffyDOS detection
|
||||
sta IECPROTO
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Buffer empty, send the command
|
||||
; Buffer empty, send the command
|
||||
lda #$3F
|
||||
|
||||
jmp common_open_close_unlsn_second
|
||||
|
||||
#else
|
||||
} else {
|
||||
|
||||
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||
|
||||
#endif
|
||||
}
|
||||
+37
-38
@@ -1,62 +1,61 @@
|
||||
// #LAYOUT# STD * #TAKE
|
||||
// #LAYOUT# * KERNAL_0 #TAKE
|
||||
// #LAYOUT# * * #IGNORE
|
||||
;; #LAYOUT# STD * #TAKE
|
||||
;; #LAYOUT# * KERNAL_0 #TAKE
|
||||
;; #LAYOUT# * * #IGNORE
|
||||
|
||||
//
|
||||
// Official Kernal routine, described in:
|
||||
//
|
||||
// - [RG64] C64 Programmers Reference Guide - page 304
|
||||
// - [CM64] Computes 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
|
||||
//
|
||||
;
|
||||
; Official Kernal routine, described in:
|
||||
;
|
||||
; - [RG64] C64 Programmers Reference Guide - page 304
|
||||
; - [CM64] Computes 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
|
||||
;
|
||||
|
||||
|
||||
UNTLK:
|
||||
|
||||
#if CONFIG_IEC || ROM_LAYOUT_M65
|
||||
!ifdef CONFIG_MB_M65 {
|
||||
|
||||
// According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||
; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||
jsr iec_tx_flush
|
||||
|
||||
#endif
|
||||
|
||||
#if ROM_LAYOUT_M65
|
||||
|
||||
jsr m65dos_check
|
||||
bcc_16 m65dos_untlk // branch if device is handeld by internal DOS
|
||||
+bcc m65dos_untlk ; branch if device is handeld by internal DOS
|
||||
|
||||
#endif
|
||||
} else ifdef CONFIG_IEC {
|
||||
|
||||
#if CONFIG_IEC
|
||||
; According to serial-bus.pdf (page 15) this routine flushes the IEC out buffer
|
||||
jsr iec_tx_flush
|
||||
}
|
||||
|
||||
#if CONFIG_IEC_JIFFYDOS || CONFIG_IEC_DOLPHINDOS
|
||||
|
||||
lda #$FF // do not use JiffyDOS / DolphinDOS anymore, trigger JiffyDOS detection
|
||||
!ifdef CONFIG_IEC {
|
||||
|
||||
!ifdef CONFIG_IEC_JIFFYDOS_OR_DOLPHINDOS {
|
||||
|
||||
lda #$FF ; do not use JiffyDOS / DolphinDOS anymore, trigger JiffyDOS detection
|
||||
sta IECPROTO
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// Buffer empty, send the command
|
||||
; Buffer empty, send the command
|
||||
lda #$5F
|
||||
|
||||
common_untlk_tksa: // common part of UNTLK and TKSA
|
||||
common_untlk_tksa: ; common part of UNTLK and TKSA
|
||||
|
||||
; XXX - for TKSA, is it really the right place to do a turnaround? I have 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
|
||||
|
||||
sta TBTCNT
|
||||
jsr iec_tx_command
|
||||
bcs !+ // branch if error
|
||||
// XXX - for TKSA, is it really the right place to do a turnaround? I have 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
|
||||
!:
|
||||
+bcc iec_turnaround_to_listen
|
||||
|
||||
rts
|
||||
|
||||
#else
|
||||
} else {
|
||||
|
||||
jmp kernalerror_ILLEGAL_DEVICE_NUMBER
|
||||
|
||||
#endif
|
||||
}
|
||||
Reference in new issue
Block a user