From 6753d9042ed784b823a9c859273d83dff32da015 Mon Sep 17 00:00:00 2001 From: Christopher Bonhage Date: Tue, 5 Sep 2023 22:25:28 -0400 Subject: [PATCH] Resolve deprecation warnings in mempak and tpak subsystems --- src/mempak.c | 14 +++++++------- src/tpak.c | 20 ++++++++++---------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/mempak.c b/src/mempak.c index 1bab669ffb..5adefaf594 100644 --- a/src/mempak.c +++ b/src/mempak.c @@ -70,7 +70,7 @@ int read_mempak_sector( int controller, int sector, uint8_t *sector_data ) /* Sectors are 256 bytes, a mempak reads 32 bytes at a time */ for( int i = 0; i < 8; i++ ) { - if( read_mempak_address( controller, (sector * MEMPAK_BLOCK_SIZE) + (i * 32), sector_data + (i * 32) ) ) + if( joybus_accessory_read_sync( controller, (sector * MEMPAK_BLOCK_SIZE) + (i * 32), sector_data + (i * 32) ) ) { /* Failed to read a block */ return -2; @@ -105,7 +105,7 @@ int write_mempak_sector( int controller, int sector, uint8_t *sector_data ) /* Sectors are 256 bytes, a mempak writes 32 bytes at a time */ for( int i = 0; i < 8; i++ ) { - if( write_mempak_address( controller, (sector * MEMPAK_BLOCK_SIZE) + (i * 32), sector_data + (i * 32) ) ) + if( joybus_accessory_write_sync( controller, (sector * MEMPAK_BLOCK_SIZE) + (i * 32), sector_data + (i * 32) ) ) { /* Failed to read a block */ return -2; @@ -768,7 +768,7 @@ int get_mempak_entry( int controller, int entry, entry_structure_t *entry_data ) /* Entries are spread across two sectors, but we can luckly grab just one with a single mempak read */ - if( read_mempak_address( controller, (3 * MEMPAK_BLOCK_SIZE) + (entry * 32), data ) ) + if( joybus_accessory_read_sync( controller, (3 * MEMPAK_BLOCK_SIZE) + (entry * 32), data ) ) { /* Couldn't read note database */ return -2; @@ -1097,7 +1097,7 @@ int write_mempak_entry_data( int controller, entry_structure_t *entry, uint8_t * { entry_structure_t tmp_entry; - if( read_mempak_address( controller, (3 * MEMPAK_BLOCK_SIZE) + (i * 32), tmp_data ) ) + if( joybus_accessory_read_sync( controller, (3 * MEMPAK_BLOCK_SIZE) + (i * 32), tmp_data ) ) { /* Couldn't read note database */ return -2; @@ -1140,7 +1140,7 @@ int write_mempak_entry_data( int controller, entry_structure_t *entry, uint8_t * __write_note( entry, tmp_data ); /* Store entry to empty slot on mempak */ - if( write_mempak_address( controller, (3 * MEMPAK_BLOCK_SIZE) + (entry->entry_id * 32), tmp_data ) ) + if( joybus_accessory_write_sync( controller, (3 * MEMPAK_BLOCK_SIZE) + (entry->entry_id * 32), tmp_data ) ) { /* Couldn't update note database */ return -2; @@ -1177,7 +1177,7 @@ int delete_mempak_entry( int controller, entry_structure_t *entry ) if( entry->inode < BLOCK_VALID_FIRST || entry->inode > BLOCK_VALID_LAST ) { return -1; } /* Ensure that the entry passed in matches what's on the mempak */ - if( read_mempak_address( controller, (3 * MEMPAK_BLOCK_SIZE) + (entry->entry_id * 32), data ) ) + if( joybus_accessory_read_sync( controller, (3 * MEMPAK_BLOCK_SIZE) + (entry->entry_id * 32), data ) ) { /* Couldn't read note database */ return -2; @@ -1197,7 +1197,7 @@ int delete_mempak_entry( int controller, entry_structure_t *entry ) /* The entry matches, so blank it */ memset( data, 0, 32 ); - if( write_mempak_address( controller, (3 * MEMPAK_BLOCK_SIZE) + (entry->entry_id * 32), data ) ) + if( joybus_accessory_write_sync( controller, (3 * MEMPAK_BLOCK_SIZE) + (entry->entry_id * 32), data ) ) { /* Couldn't update note database */ return -2; diff --git a/src/tpak.c b/src/tpak.c index 24c6ef3ba3..dc4350d51d 100755 --- a/src/tpak.c +++ b/src/tpak.c @@ -86,7 +86,7 @@ int tpak_set_value(int controller, uint16_t address, uint8_t value) { uint8_t block[TPAK_BLOCK_SIZE]; memset(block, value, TPAK_BLOCK_SIZE); - return write_mempak_address(controller, address, block); + return joybus_accessory_write_sync(controller, address, block); } /** @@ -103,18 +103,18 @@ int tpak_init(int controller) { int result = 0; - int accessory = identify_accessory(controller); - if (accessory != ACCESSORY_TRANSFERPAK) return TPAK_ERROR_NO_TPAK; + int accessory = joypad_get_accessory_type(controller); + if (accessory != JOYPAD_ACCESSORY_TYPE_TRANSFER_PAK) { return TPAK_ERROR_NO_TPAK; } result = tpak_set_power(controller, true); - if (result) return result; + if (result) { return result; } result = tpak_set_access(controller, true); - if (result) return result; + if (result) { return result; } uint8_t status = tpak_get_status(controller); - if (status & TPAK_STATUS_REMOVED) return TPAK_ERROR_NO_CARTRIDGE; - if (!(status & TPAK_STATUS_READY)) return TPAK_ERROR_UNKNOWN_BEHAVIOUR; + if (status & TPAK_STATUS_REMOVED) { return TPAK_ERROR_NO_CARTRIDGE; } + if (!(status & TPAK_STATUS_READY)) { return TPAK_ERROR_UNKNOWN_BEHAVIOUR; } return 0; } @@ -176,7 +176,7 @@ int tpak_set_bank(int controller, int bank) uint8_t tpak_get_status(int controller) { uint8_t block[TPAK_BLOCK_SIZE]; - read_mempak_address(controller, TPAK_ADDRESS_STATUS, block); + joybus_accessory_read_sync(controller, TPAK_ADDRESS_STATUS, block); return block[0]; } @@ -245,7 +245,7 @@ int tpak_write(int controller, uint16_t address, uint8_t* data, uint16_t size) adjusted_address = TPAK_ADDRESS_DATA; } - write_mempak_address(controller, adjusted_address, cursor); + joybus_accessory_write_sync(controller, adjusted_address, cursor); address += TPAK_BLOCK_SIZE; cursor += TPAK_BLOCK_SIZE; adjusted_address += TPAK_BLOCK_SIZE; @@ -295,7 +295,7 @@ int tpak_read(int controller, uint16_t address, uint8_t* buffer, uint16_t size) adjusted_address = TPAK_ADDRESS_DATA; } - read_mempak_address(controller, adjusted_address, cursor); + joybus_accessory_read_sync(controller, adjusted_address, cursor); address += TPAK_BLOCK_SIZE; cursor += TPAK_BLOCK_SIZE; adjusted_address += TPAK_BLOCK_SIZE;