base:reu_detect
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revisionLast revision | |||
— | base:reu_detect [2023-10-26 20:21] – groepaz | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== REU Detect ====== | ||
+ | < | ||
+ | ;ACME 0.97 | ||
+ | |||
+ | !addr | ||
+ | REUCOMMAND_STASH | ||
+ | REUCOMMAND_FETCH | ||
+ | !addr { | ||
+ | reu_c64addr_lo | ||
+ | reu_c64addr_hi | ||
+ | reu_extaddr_lo | ||
+ | reu_extaddr_hi | ||
+ | reu_extaddr_bank | ||
+ | reu_len_lo | ||
+ | reu_len_hi | ||
+ | } | ||
+ | |||
+ | detect_capacity ; returns A = number of RAM banks found in REU (Carry set means 256, 0 means NO REU) | ||
+ | ldx #0 ; pre-init | ||
+ | ; first write signatures to banks in *descending* order (banks 255..0): | ||
+ | ---- dex | ||
+ | stx banknum | ||
+ | lda #< | ||
+ | ldx #> | ||
+ | ldy # | ||
+ | jsr set_registers_AXY | ||
+ | ; all banks written? | ||
+ | ldx banknum | ||
+ | bne ---- | ||
+ | ; now check signatures in *ascending* order: | ||
+ | ; (checking signatures could be shortened by using the REC's " | ||
+ | ; but I'm reluctant to use this function in a "REU detect" | ||
+ | ; be buggy in modern FPGA implementations because it is so seldomly used) | ||
+ | ; banknum just became zero so no need to init it | ||
+ | ---- lda #< | ||
+ | ldx #> | ||
+ | ldy # | ||
+ | jsr set_registers_AXY | ||
+ | ; compare data | ||
+ | ldx # | ||
+ | -- lda sig_candidate_start, | ||
+ | cmp signature_start, | ||
+ | bne @failed | ||
+ | dex | ||
+ | bpl -- | ||
+ | ; bank has correct signature | ||
+ | inc banknum ; next bank (== number of banks already found) | ||
+ | bne ---- | ||
+ | ; there are actually 256 banks! | ||
+ | sec | ||
+ | lda banknum | ||
+ | rts | ||
+ | |||
+ | @failed | ||
+ | lda banknum | ||
+ | rts | ||
+ | |||
+ | set_registers_AXY ; setup REU registers (used for both reading and writing) | ||
+ | ; A/X: c64 address | ||
+ | ; Y: REU command | ||
+ | sta reu_c64addr_lo | ||
+ | stx reu_c64addr_hi | ||
+ | ldx #0 | ||
+ | stx reu_extaddr_lo | ||
+ | stx reu_extaddr_hi | ||
+ | lda banknum | ||
+ | sta reu_extaddr_bank | ||
+ | lda # | ||
+ | sta reu_len_lo | ||
+ | stx reu_len_hi | ||
+ | sty reu_command | ||
+ | rts | ||
+ | |||
+ | ; signature we write to REU banks, first byte is bank number | ||
+ | signature_start | ||
+ | banknum | ||
+ | SIGNATURE_LENGTH_LOW = * - signature_start | ||
+ | |||
+ | ; target buffer when reading signatures back from REU | ||
+ | sig_candidate_start | ||
+ | !tx " | ||
+ | sig_candidate_end | ||
+ | SIGNATURE_LENGTH_LOW = * - sig_candidate_start | ||
+ | </ |
base/reu_detect.txt · Last modified: 2023-10-26 20:24 by groepaz