Fixed bug with PRG files not loading from USB drives.

This commit is contained in:
Stephen White 2018-11-25 15:40:45 +11:00
parent fb22d24c6c
commit e3e25b8b5a
5 changed files with 13 additions and 42 deletions

View file

@ -157,7 +157,7 @@ DRESULT disk_read (
} }
else else
{ {
unsigned bytes = (unsigned)USPiMassStorageDeviceRead(sector << UMSD_BLOCK_SHIFT, buff, count << UMSD_BLOCK_SHIFT, pdrv - 1); unsigned bytes = (unsigned)USPiMassStorageDeviceRead((unsigned long long )(sector << UMSD_BLOCK_SHIFT), buff, count << UMSD_BLOCK_SHIFT, pdrv - 1);
if (bytes != (count << UMSD_BLOCK_SHIFT)) if (bytes != (count << UMSD_BLOCK_SHIFT))
return RES_ERROR; return RES_ERROR;

View file

@ -5,16 +5,6 @@
#include "types.h" #include "types.h"
/*
#include <circle/device.h>
//#include <circle/interrupt.h>
#include <circle/timer.h>
#include <circle/actled.h>
#include <circle/fs/partitionmanager.h>
#include <circle/logger.h>
#include <circle/types.h>
*/
#define BOOT_SIGNATURE 0xAA55 #define BOOT_SIGNATURE 0xAA55
struct TSCR // SD configuration register struct TSCR // SD configuration register

View file

@ -1541,14 +1541,18 @@ void IEC_Commands::LoadFile()
if (channel.filInfo.fname[0] != 0) if (channel.filInfo.fname[0] != 0)
{ {
FSIZE_t size = f_size(&channel.file);
FSIZE_t sizeRemaining = size;
u32 bytesRead; u32 bytesRead;
do do
{ {
f_read(&channel.file, channel.buffer, sizeof(channel.buffer), &bytesRead); f_read(&channel.file, channel.buffer, sizeof(channel.buffer), &bytesRead);
if (bytesRead > 0) if (bytesRead > 0)
{ {
//DEBUG_LOG("%d %d %d\r\n", (int)size, bytesRead, (int)sizeRemaining);
sizeRemaining -= bytesRead;
channel.cursor = bytesRead; channel.cursor = bytesRead;
if (SendBuffer(channel, true)) if (SendBuffer(channel, sizeRemaining <= 0))
return; return;
} }
} }

View file

@ -112,16 +112,16 @@ protected:
struct Channel struct Channel
{ {
FILINFO filInfo;
FIL file;
bool writing;
u32 cursor;
u32 bytesSent;
bool open;
u8 buffer[0x1000]; u8 buffer[0x1000];
u8 command[0x100]; u8 command[0x100];
FILINFO filInfo;
FIL file;
u32 cursor;
u32 bytesSent;
u32 open : 1;
u32 writing : 1;
void Close(); void Close();
bool WriteFull() const { return cursor >= sizeof(buffer); } bool WriteFull() const { return cursor >= sizeof(buffer); }
bool CanFit(u32 bytes) const { return bytes <= sizeof(buffer) - cursor; } bool CanFit(u32 bytes) const { return bytes <= sizeof(buffer) - cursor; }

View file

@ -20,23 +20,7 @@
#ifndef _kernel_h #ifndef _kernel_h
#define _kernel_h #define _kernel_h
//#include <circle/memory.h>
//#include <circle/actled.h>
//#include <circle/devicenameservice.h>
//#include <circle/koptions.h>
//#include <circle/screen.h>
//#include <circle/serial.h>
//#include <circle/exceptionhandler.h>
//#include <circle/interrupt.h>
//#include <circle/logger.h>
//#include <circle/types.h>
//#include <circle/gpiomanager.h>
#include "emmc.h" #include "emmc.h"
//#include <SDCard/emmc.h>
//#include <circle/fs/fat/fatfs.h>
//#include <circle/multicore.h>
//#include <circle/usb/dwhcidevice.h>
#include "iec_bus.h" #include "iec_bus.h"
#include "iec_commands.h" #include "iec_commands.h"
@ -60,13 +44,6 @@ public:
TShutdownMode Run (void); TShutdownMode Run (void);
//private:
// static void KeyPressedHandler(const char *pString);
// static void ShutdownHandler(void);
//
// static void KeyStatusHandlerRaw(unsigned char ucModifiers, const unsigned char RawKeys[6]);
private: private:
// do not change this order // do not change this order