diff --git a/src/diskio.cpp b/src/diskio.cpp index a1480de..8fefd40 100644 --- a/src/diskio.cpp +++ b/src/diskio.cpp @@ -157,7 +157,7 @@ DRESULT disk_read ( } 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)) return RES_ERROR; diff --git a/src/emmc.h b/src/emmc.h index 2b6ec3c..df40d0d 100644 --- a/src/emmc.h +++ b/src/emmc.h @@ -5,16 +5,6 @@ #include "types.h" -/* -#include -//#include -#include -#include -#include -#include -#include -*/ - #define BOOT_SIGNATURE 0xAA55 struct TSCR // SD configuration register diff --git a/src/iec_commands.cpp b/src/iec_commands.cpp index eed365d..30bac63 100644 --- a/src/iec_commands.cpp +++ b/src/iec_commands.cpp @@ -1541,14 +1541,18 @@ void IEC_Commands::LoadFile() if (channel.filInfo.fname[0] != 0) { + FSIZE_t size = f_size(&channel.file); + FSIZE_t sizeRemaining = size; u32 bytesRead; do { f_read(&channel.file, channel.buffer, sizeof(channel.buffer), &bytesRead); if (bytesRead > 0) { + //DEBUG_LOG("%d %d %d\r\n", (int)size, bytesRead, (int)sizeRemaining); + sizeRemaining -= bytesRead; channel.cursor = bytesRead; - if (SendBuffer(channel, true)) + if (SendBuffer(channel, sizeRemaining <= 0)) return; } } diff --git a/src/iec_commands.h b/src/iec_commands.h index e6d6308..cb04db4 100644 --- a/src/iec_commands.h +++ b/src/iec_commands.h @@ -112,16 +112,16 @@ protected: struct Channel { - FILINFO filInfo; - FIL file; - bool writing; - u32 cursor; - u32 bytesSent; - bool open; - u8 buffer[0x1000]; u8 command[0x100]; + FILINFO filInfo; + FIL file; + u32 cursor; + u32 bytesSent; + u32 open : 1; + u32 writing : 1; + void Close(); bool WriteFull() const { return cursor >= sizeof(buffer); } bool CanFit(u32 bytes) const { return bytes <= sizeof(buffer) - cursor; } diff --git a/src/kernel.h b/src/kernel.h index ed26e28..ce54164 100644 --- a/src/kernel.h +++ b/src/kernel.h @@ -20,23 +20,7 @@ #ifndef _kernel_h #define _kernel_h -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include -//#include #include "emmc.h" -//#include -//#include -//#include - -//#include #include "iec_bus.h" #include "iec_commands.h" @@ -60,13 +44,6 @@ public: 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: // do not change this order