83Plus:Software:usb8x/Asm Interface/MSD/msdDetect

From WikiTI
Revision as of 08:16, 19 November 2006 by Brandonw (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Synopsis

Name: msdDetect

Minimum usb8x version: 0.12

Detects and loads 83P/8XP levels from specified directory based on detection string. This is the mass storage version of ionDetect.

Inputs

  • HL is starting cluster of directory to search (obtained with [[../FAT_getStartingCluster|FAT_getStartingCluster]])
  • BC is entry number of level (pass -1 on first call to this entry point)
  • DE points to zero-terminated detection string

Outputs

  • Level/variable data is loaded into temporary RAM
  • BC is entry number of this variable (to be passed in subsequent calls to this function)
  • HL points to variable data (just beyond detection string)
  • C set if problems
  • A contains error code
0 No more 83P/8XP files in specified directory
1 Not enough free memory to load level (for found level; subsequent calls may succeed)

Destroys

  • AF, BC, DE, HL, IX

Notes

This is the mass storage version of ionDetect. It works exactly the same in that it loads the current level to (tempMem) if possible.

Pass -1 in BC on first call to this entry point, and then its BC output on future calls. When the carry flag is set and A = 0, you have gone through all the variables in that directory.

Example code to search for first BYTES level in the "\FILES\" subdirectory:

    ld hl,sDir
    rst 20h
    ld hl,OP1
    U_CALL FAT_getStartingCluster ;get starting cluster of this directory
    push hl
    ld hl,sDetectString
    rst 20h
    pop hl
    ld bc,-1
    ld de,OP1
    U_CALL msdDetect
    ret c ;no variables found
;HL now points to level data
...
sDir:
    DB "\FILES",0
sDetectString:
    DB "BY1JW",0 ;detection string for BYTES levels

Strings are copied to RAM first so they can be seen from usb8x.

See Also

  • [[../MSD_Initialize|MSD_Initialize]] - Initialize mass storage driver