mirror of
https://github.com/LNH-team/pico-loader.git
synced 2026-06-02 09:16:49 +02:00
DATEL: Make read sector function vram safe (#80)
* DATEL: Make read sector function vram safe The platform code was performing reads in single byte units, breaking in case the destination buffer was in vram. This caused issues with some games (e.g. Castelvania Order of Ecclesia), and also broke soft resetting. * Halve wait timeout on sector read since we read 2 bytes at the time
This commit is contained in:
@@ -37,13 +37,13 @@ read_next_sector:
|
||||
cmp r0, DATEL_SPI_START_DATA_TOKEN
|
||||
bne wrong_spi_start_token
|
||||
|
||||
@ preload datel_readSpiByte
|
||||
ldr r7, datel_SDReadMultipleSector_ReadSpiByte
|
||||
@ preload datel_readSpiShort
|
||||
ldr r7, datel_SDReadMultipleSector_ReadSpiShort
|
||||
read_next_byte:
|
||||
bl datel_SDReadMultipleSector_Interwork
|
||||
strb r0, [r4, r5]
|
||||
strh r0, [r4, r5]
|
||||
|
||||
adds r5, #1
|
||||
adds r5, #2
|
||||
@ Shifting left by 0x17 will set the Zero flag if the number that was shifted is a multiple
|
||||
@ of 0x200 (indicating a full sector has been written)
|
||||
lsls r0, r5, #0x17
|
||||
@@ -51,7 +51,6 @@ read_next_byte:
|
||||
|
||||
@ drop crc
|
||||
bl datel_SDReadMultipleSector_Interwork
|
||||
bl datel_SDReadMultipleSector_Interwork
|
||||
|
||||
cmp r3, r5
|
||||
bne read_next_sector
|
||||
@@ -65,8 +64,12 @@ read_next_byte:
|
||||
adds r7, #2
|
||||
bl datel_SDReadMultipleSector_Interwork
|
||||
|
||||
ldr r4, =DATEL_SD_CMD_TIMEOUT_LEN
|
||||
ldr r7, datel_SDReadMultipleSector_ReadSpiByte
|
||||
@ use a timeout of 0x1000 instead of 0xFFF, easier to setup, then halve it
|
||||
@ since we're reading 2 bytes at the time
|
||||
@ ldr r4, =DATEL_SD_CMD_TIMEOUT_LEN
|
||||
movs r4, #1
|
||||
lsls r4, #11
|
||||
ldr r7, datel_SDReadMultipleSector_ReadSpiShort
|
||||
1:
|
||||
bl datel_SDReadMultipleSector_Interwork
|
||||
bne read_timeout_expired
|
||||
@@ -97,6 +100,6 @@ datel_SDReadMultipleSector_SpiSendSDIOCommandR0:
|
||||
.global datel_SDReadMultipleSector_ReadSpiByteTimeout
|
||||
datel_SDReadMultipleSector_ReadSpiByteTimeout:
|
||||
.word 0
|
||||
.global datel_SDReadMultipleSector_ReadSpiByte
|
||||
datel_SDReadMultipleSector_ReadSpiByte:
|
||||
.global datel_SDReadMultipleSector_ReadSpiShort
|
||||
datel_SDReadMultipleSector_ReadSpiShort:
|
||||
.word 0
|
||||
|
||||
Reference in New Issue
Block a user