Skip to content

Commit

Permalink
Fix SuperCard CF driver (#20)
Browse files Browse the repository at this point in the history
It wasn't ensuring the cart was in the media state for its operations, possibly leading to issues
  • Loading branch information
edo9300 authored Dec 18, 2024
1 parent ebbd7b4 commit 4232b33
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
10 changes: 5 additions & 5 deletions source/sccf/source/dldi_header.s
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@
.ascii "SCCF"
.word FEATURE_MEDIUM_CANREAD | FEATURE_MEDIUM_CANWRITE | FEATURE_SLOT_GBA
.word startup @
.word _CF_isInserted @
.word _CF_readSectors @ Function pointers to standard device driver functions
.word _CF_writeSectors @
.word _CF_clearStatus @
.word _CF_shutdown @
.word isInserted @
.word readSectors @ Function pointers to standard device driver functions
.word writeSectors @
.word clearStatus @
.word shutdown @

@---------------------------------------------------------------------------------
_start:
Expand Down
36 changes: 27 additions & 9 deletions source/sccf/source/iointerface.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,40 @@ Modified again by loopy
#define SC_MODE_RAM 0x5
#define SC_MODE_MEDIA 0x3
#define SC_MODE_RAM_RO 0x1
void changeMode(u8 mode) {
static void changeMode(u8 mode) {
vu16 *unlockAddress = (vu16*)0x09FFFFFE;
*unlockAddress = 0xA55A ;
*unlockAddress = 0xA55A ;
*unlockAddress = mode ;
*unlockAddress = mode ;
}

}

/*-----------------------------------------------------------------
startUp
Initializes the CF interface
returns true if successful, otherwise returns false
-----------------------------------------------------------------*/
bool startup(void) {
changeMode (SC_MODE_MEDIA);
changeMode(SC_MODE_MEDIA);
return _CF_startup(&_SCCF_Registers);
}

bool isInserted(void) {
changeMode(SC_MODE_MEDIA);
return _CF_isInserted();
}

bool clearStatus(void) {
changeMode(SC_MODE_MEDIA);
return _CF_clearStatus();
}

bool readSectors(u32 sector, u32 numSectors, void* buffer) {
changeMode(SC_MODE_MEDIA);
return _CF_readSectors(sector, numSectors, buffer);
}

bool writeSectors(u32 sector, u32 numSectors, void* buffer) {
changeMode(SC_MODE_MEDIA);
return _CF_writeSectors(sector, numSectors, buffer);
}

bool shutdown(void) {
changeMode(SC_MODE_MEDIA);
return _CF_shutdown();
}

0 comments on commit 4232b33

Please sign in to comment.