Jump to content
IGNORED

A (relatively) easy way to read the ID string from CF or SD?


Recommended Posts

For CF: read the Identify Device buffer using command code $EC. You'll need a 16-bit data register or you can switch the drive to 8-bit PIO mode first.

 

Name starts at word 27, IIRC, so that's byte offset 54 into the buffer. The ASCII bytes for the name are stored in reverse order: 2 , 1, 4, 3, etc, etc.

 

Below are some bits of code from the SIDE driver which do this job. GET_MEDIA_NAME actually pulls the media name from the buffer, puts it some place else, then trims it to a manageable length.

 

.local get_drive_model ; if media is a CF card, show the drive info
lda #$80+$20
sta ddevic
jsr id2 ; bios_identify_dev
bcs cfa_rej
jsr get_media_name
clc
cfa_rej
rts
.endl
;
.local id2 ; get device info (bypasses bank switching)
jsr set_internal_buf ; point to internal sector buffer
lda #3 ; read full 512 bytes
sta slenmsb
lda #$EC ; IDENTIFY DEVICE command
jmp sector_rw
.endl
;

.local get_media_name
ldx #0
ldy #54
dn1
lda (bufrlo),y
sta namebuf+1,x
iny
lda (bufrlo),y
sta namebuf,x
iny
inx
inx
cpx #40
bcc dn1
trimsp2 ; get rid of trailing spaces
dex
bmi trimdone2
lda namebuf,x
cmp #32
beq trimsp2
trimdone2
inx
lda #0
sta namebuf,x
cpx #40
bcc trimdone2
rts
.endl
;

 

Unsure what would be different about an SD card: I only use SD cards through an IDE-SD adapter, so the driver protocols are identical there.

Edited by flashjazzcat
  • Like 2
Link to comment
Share on other sites

All the NeoMyth cart menus have SDIO support for SD/SDHC cards. SDIO is using the 4-bit parallel access of the SD card rather than the serial most interfaces use. It's easier to do on "lesser" systems since it just needs GPIO to the SD card. All the NeoMyth menus are open source and found here:

http://code.google.com/p/neo-myth-menu/

 

The N64 menu uses C code everything but the main data transfer loop when reading sectors. The current code can detect and initialize an SD card in less than a second.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...