Fix EOL in sources.
This commit is contained in:
1246
DiskImage.cpp
1246
DiskImage.cpp
File diff suppressed because it is too large
Load Diff
384
DiskImage.h
384
DiskImage.h
@@ -1,192 +1,192 @@
|
||||
#ifndef __DISKIMAGE_H
|
||||
#define __DISKIMAGE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "file_io.h"
|
||||
|
||||
enum TDiskImageType { DIT_UNK, DIT_SCL, DIT_FDI, DIT_TD0, DIT_UDI, DIT_HOB, DIT_FDD };
|
||||
|
||||
struct VGFIND_TRACK
|
||||
{
|
||||
unsigned char *TrackPointer;
|
||||
unsigned char *ClkPointer;
|
||||
unsigned int TrackLength;
|
||||
bool FoundTrack;
|
||||
};
|
||||
|
||||
|
||||
struct VGFIND_ADM
|
||||
{
|
||||
unsigned char* TrackPointer;
|
||||
unsigned char* ClkPointer;
|
||||
unsigned int TrackLength;
|
||||
|
||||
unsigned char *ADMPointer;
|
||||
unsigned int ADMLength;
|
||||
|
||||
unsigned int MarkedOffsetADM;
|
||||
unsigned int OffsetADM;
|
||||
unsigned int OffsetEndADM;
|
||||
bool FoundADM;
|
||||
bool CRCOK;
|
||||
};
|
||||
|
||||
|
||||
struct VGFIND_SECTOR
|
||||
{
|
||||
VGFIND_ADM vgfa;
|
||||
|
||||
unsigned char *SectorPointer;
|
||||
unsigned int SectorLength;
|
||||
|
||||
unsigned int MarkedOffsetSector;
|
||||
unsigned int OffsetSector;
|
||||
unsigned int OffsetEndSector;
|
||||
bool FoundDATA;
|
||||
bool CRCOK;
|
||||
unsigned char DataMarker;
|
||||
};
|
||||
|
||||
|
||||
class TDiskImage
|
||||
{
|
||||
unsigned int FTrackLength[256][256];
|
||||
unsigned char* FTracksPtr[256][256][2];
|
||||
|
||||
TDiskImageType FType;
|
||||
|
||||
unsigned short MakeVGCRC(unsigned char *data, unsigned long length);
|
||||
public:
|
||||
bool Changed;
|
||||
|
||||
bool ReadOnly;
|
||||
bool DiskPresent;
|
||||
unsigned char MaxTrack;
|
||||
unsigned char MaxSide;
|
||||
|
||||
TDiskImage();
|
||||
~TDiskImage();
|
||||
|
||||
bool FindTrack(unsigned char CYL, unsigned char SIDE, VGFIND_TRACK *vgft);
|
||||
bool FindADMark(unsigned char CYL, unsigned char SIDE,
|
||||
unsigned int FromOffset,
|
||||
VGFIND_ADM *vgfa);
|
||||
bool FindSector(unsigned char CYL, unsigned char SIDE,
|
||||
unsigned char SECT,
|
||||
VGFIND_SECTOR *vgfs, unsigned int FromOffset=0);
|
||||
void ApplySectorCRC(VGFIND_SECTOR vgfs);
|
||||
|
||||
|
||||
void Open(const char *filename, bool ReadOnly);
|
||||
|
||||
void writeTRD(fileTYPE *hfile);
|
||||
|
||||
void readSCL(int hfile, bool readonly);
|
||||
void readFDI(int hfile, bool readonly);
|
||||
void readUDI(int hfile, bool readonly);
|
||||
void readTD0(int hfile, bool readonly);
|
||||
void readFDD(int hfile, bool readonly);
|
||||
void readHOB(int hfile);
|
||||
|
||||
void formatTRDOS(unsigned int tracks, unsigned int sides);
|
||||
|
||||
void ShowError(const char *str);
|
||||
};
|
||||
|
||||
#pragma pack(1)
|
||||
struct UDI_HEADER // 16 bytes
|
||||
{
|
||||
unsigned char ID[4];
|
||||
unsigned long UnpackedLength;
|
||||
unsigned char Version;
|
||||
unsigned char MaxCylinder;
|
||||
unsigned char MaxSide;
|
||||
unsigned char _zero;
|
||||
unsigned long ExtHdrLength;
|
||||
};
|
||||
|
||||
struct TD0_MAIN_HEADER // 12 bytes
|
||||
{
|
||||
char ID[2]; // +0: "TD" - 'Normal'; "td" - packed LZH ('New Advanced data compression')
|
||||
unsigned char __t; // +2: = 0x00
|
||||
unsigned char __1; // +3: ???
|
||||
unsigned char Ver; // +4: Source version (1.0 -> 10, ..., 2.1 -> 21)
|
||||
unsigned char __2; // +5: ???
|
||||
unsigned char DiskType; // +6: Source disk type
|
||||
unsigned char Info; // +7: D7- «¨ç¨¥ image info
|
||||
unsigned char DataDOS; // +8: if(=0)'All sectors were copied', else'DOS Allocated sectors were copied'
|
||||
unsigned char ChkdSides; // +9: if(=1)'One side was checked', else'Both sides were checked'
|
||||
unsigned short CRC; // +A: CRC 娤¥à TD0_MAIN_HEADER (ªà®¬¥ ¡ ©â á CRC)
|
||||
};
|
||||
|
||||
struct TD0_INFO_DATA // 10 ¡ ©â ¡¥§ áâப¨ ª®¬¥â à¨ï...
|
||||
{
|
||||
unsigned short CRC; // +0: CRC ¤«ï áâàãªâãàë COMMENT_DATA (¡¥§ ¡ ©â®¢ CRC)
|
||||
unsigned short strLen; // +2: „«¨ áâப¨ ª®¬¥â à¨ï
|
||||
unsigned char Year; // +4: „ â á®§¤ ¨ï - £®¤ (1900 + X)
|
||||
unsigned char Month; // +5: „ â á®§¤ ¨ï - ¬¥áïæ (Ÿ¢ àì=0, ”¥¢à «ì=1,...)
|
||||
unsigned char Day; // +6: „ â á®§¤ ¨ï - ç¨á«®
|
||||
unsigned char Hours; // +7: ‚६ï á®§¤ ¨ï - ç áë
|
||||
unsigned char Minutes; // +8: ‚६ï á®§¤ ¨ï - ¬¨ãâë
|
||||
unsigned char Seconds; // +9: ‚६ï á®§¤ ¨ï - ᥪã¤ë
|
||||
};
|
||||
|
||||
struct TD0_TRACK_HEADER // 4 bytes
|
||||
{
|
||||
unsigned char SectorCount;
|
||||
unsigned char Track;
|
||||
unsigned char Side;
|
||||
unsigned char CRCL;
|
||||
};
|
||||
|
||||
struct TD0_SECT_HEADER // 8 bytes
|
||||
{
|
||||
unsigned char ADRM[6];
|
||||
unsigned short DataLength;
|
||||
};
|
||||
|
||||
struct FDD_MAIN_HEADER
|
||||
{
|
||||
char ID[30]; /* ᨣ âãà */
|
||||
unsigned char MaxTracks; /* ç¨á«® â४®¢ (樫¨¤à®¢) */
|
||||
unsigned char MaxHeads; /* ç¨á«® £®«®¢®ª (1 ¨«¨ 2) */
|
||||
long diskIndex; /* unused */
|
||||
long DataOffset[512*2]; /* ᬥ饨¥ ¢ ä ©«¥ ª áâàãªâãà ¬ § £®«®¢ª®¢ */
|
||||
/* â४®¢ */
|
||||
};
|
||||
|
||||
struct FDD_TRACK_HEADER
|
||||
{
|
||||
unsigned char trkType; /* unused */
|
||||
unsigned char SectNum; /* ç¨á«® ᥪâ®à®¢ â४¥ */
|
||||
struct
|
||||
{
|
||||
/* § £®«®¢®ª ᥪâ®à */
|
||||
unsigned char trk; /* ®¬¥à â४ */
|
||||
unsigned char side; /* ®¬¥à áâ®à®ë */
|
||||
/* 7 ¡¨â í⮣® ¡ ©â 㪠§ë¢ ¥â ¡¨â a */
|
||||
unsigned char sect; /* ®¬¥à ᥪâ®à */
|
||||
unsigned char size; /* à §¬¥à ᥪâ®à (ª®¤) */
|
||||
long SectPos; /* ᬥ饨¥ ¢ ä ©«¥ ª ¤ ë¬ á¥ªâ®à */
|
||||
} sect[256];
|
||||
};
|
||||
|
||||
|
||||
struct TRDOS_DIR_ELEMENT // 16 bytes
|
||||
{
|
||||
char FileName[8];
|
||||
char Type;
|
||||
unsigned short Start;
|
||||
unsigned short Length;
|
||||
unsigned char SecLen;
|
||||
unsigned char FirstSec;
|
||||
unsigned char FirstTrk;
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
int x2trd(const char *name, fileTYPE *f);
|
||||
int x2trd_ext_supp(const char *name);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
#endif
|
||||
#ifndef __DISKIMAGE_H
|
||||
#define __DISKIMAGE_H
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#include "file_io.h"
|
||||
|
||||
enum TDiskImageType { DIT_UNK, DIT_SCL, DIT_FDI, DIT_TD0, DIT_UDI, DIT_HOB, DIT_FDD };
|
||||
|
||||
struct VGFIND_TRACK
|
||||
{
|
||||
unsigned char *TrackPointer;
|
||||
unsigned char *ClkPointer;
|
||||
unsigned int TrackLength;
|
||||
bool FoundTrack;
|
||||
};
|
||||
|
||||
|
||||
struct VGFIND_ADM
|
||||
{
|
||||
unsigned char* TrackPointer;
|
||||
unsigned char* ClkPointer;
|
||||
unsigned int TrackLength;
|
||||
|
||||
unsigned char *ADMPointer;
|
||||
unsigned int ADMLength;
|
||||
|
||||
unsigned int MarkedOffsetADM;
|
||||
unsigned int OffsetADM;
|
||||
unsigned int OffsetEndADM;
|
||||
bool FoundADM;
|
||||
bool CRCOK;
|
||||
};
|
||||
|
||||
|
||||
struct VGFIND_SECTOR
|
||||
{
|
||||
VGFIND_ADM vgfa;
|
||||
|
||||
unsigned char *SectorPointer;
|
||||
unsigned int SectorLength;
|
||||
|
||||
unsigned int MarkedOffsetSector;
|
||||
unsigned int OffsetSector;
|
||||
unsigned int OffsetEndSector;
|
||||
bool FoundDATA;
|
||||
bool CRCOK;
|
||||
unsigned char DataMarker;
|
||||
};
|
||||
|
||||
|
||||
class TDiskImage
|
||||
{
|
||||
unsigned int FTrackLength[256][256];
|
||||
unsigned char* FTracksPtr[256][256][2];
|
||||
|
||||
TDiskImageType FType;
|
||||
|
||||
unsigned short MakeVGCRC(unsigned char *data, unsigned long length);
|
||||
public:
|
||||
bool Changed;
|
||||
|
||||
bool ReadOnly;
|
||||
bool DiskPresent;
|
||||
unsigned char MaxTrack;
|
||||
unsigned char MaxSide;
|
||||
|
||||
TDiskImage();
|
||||
~TDiskImage();
|
||||
|
||||
bool FindTrack(unsigned char CYL, unsigned char SIDE, VGFIND_TRACK *vgft);
|
||||
bool FindADMark(unsigned char CYL, unsigned char SIDE,
|
||||
unsigned int FromOffset,
|
||||
VGFIND_ADM *vgfa);
|
||||
bool FindSector(unsigned char CYL, unsigned char SIDE,
|
||||
unsigned char SECT,
|
||||
VGFIND_SECTOR *vgfs, unsigned int FromOffset=0);
|
||||
void ApplySectorCRC(VGFIND_SECTOR vgfs);
|
||||
|
||||
|
||||
void Open(const char *filename, bool ReadOnly);
|
||||
|
||||
void writeTRD(fileTYPE *hfile);
|
||||
|
||||
void readSCL(int hfile, bool readonly);
|
||||
void readFDI(int hfile, bool readonly);
|
||||
void readUDI(int hfile, bool readonly);
|
||||
void readTD0(int hfile, bool readonly);
|
||||
void readFDD(int hfile, bool readonly);
|
||||
void readHOB(int hfile);
|
||||
|
||||
void formatTRDOS(unsigned int tracks, unsigned int sides);
|
||||
|
||||
void ShowError(const char *str);
|
||||
};
|
||||
|
||||
#pragma pack(1)
|
||||
struct UDI_HEADER // 16 bytes
|
||||
{
|
||||
unsigned char ID[4];
|
||||
unsigned long UnpackedLength;
|
||||
unsigned char Version;
|
||||
unsigned char MaxCylinder;
|
||||
unsigned char MaxSide;
|
||||
unsigned char _zero;
|
||||
unsigned long ExtHdrLength;
|
||||
};
|
||||
|
||||
struct TD0_MAIN_HEADER // 12 bytes
|
||||
{
|
||||
char ID[2]; // +0: "TD" - 'Normal'; "td" - packed LZH ('New Advanced data compression')
|
||||
unsigned char __t; // +2: = 0x00
|
||||
unsigned char __1; // +3: ???
|
||||
unsigned char Ver; // +4: Source version (1.0 -> 10, ..., 2.1 -> 21)
|
||||
unsigned char __2; // +5: ???
|
||||
unsigned char DiskType; // +6: Source disk type
|
||||
unsigned char Info; // +7: D7- «¨ç¨¥ image info
|
||||
unsigned char DataDOS; // +8: if(=0)'All sectors were copied', else'DOS Allocated sectors were copied'
|
||||
unsigned char ChkdSides; // +9: if(=1)'One side was checked', else'Both sides were checked'
|
||||
unsigned short CRC; // +A: CRC 娤¥à TD0_MAIN_HEADER (ªà®¬¥ ¡ ©â á CRC)
|
||||
};
|
||||
|
||||
struct TD0_INFO_DATA // 10 ¡ ©â ¡¥§ áâப¨ ª®¬¥â à¨ï...
|
||||
{
|
||||
unsigned short CRC; // +0: CRC ¤«ï áâàãªâãàë COMMENT_DATA (¡¥§ ¡ ©â®¢ CRC)
|
||||
unsigned short strLen; // +2: „«¨ áâப¨ ª®¬¥â à¨ï
|
||||
unsigned char Year; // +4: „ â á®§¤ ¨ï - £®¤ (1900 + X)
|
||||
unsigned char Month; // +5: „ â á®§¤ ¨ï - ¬¥áïæ (Ÿ¢ àì=0, ”¥¢à «ì=1,...)
|
||||
unsigned char Day; // +6: „ â á®§¤ ¨ï - ç¨á«®
|
||||
unsigned char Hours; // +7: ‚६ï á®§¤ ¨ï - ç áë
|
||||
unsigned char Minutes; // +8: ‚६ï á®§¤ ¨ï - ¬¨ãâë
|
||||
unsigned char Seconds; // +9: ‚६ï á®§¤ ¨ï - ᥪã¤ë
|
||||
};
|
||||
|
||||
struct TD0_TRACK_HEADER // 4 bytes
|
||||
{
|
||||
unsigned char SectorCount;
|
||||
unsigned char Track;
|
||||
unsigned char Side;
|
||||
unsigned char CRCL;
|
||||
};
|
||||
|
||||
struct TD0_SECT_HEADER // 8 bytes
|
||||
{
|
||||
unsigned char ADRM[6];
|
||||
unsigned short DataLength;
|
||||
};
|
||||
|
||||
struct FDD_MAIN_HEADER
|
||||
{
|
||||
char ID[30]; /* ᨣ âãà */
|
||||
unsigned char MaxTracks; /* ç¨á«® â४®¢ (樫¨¤à®¢) */
|
||||
unsigned char MaxHeads; /* ç¨á«® £®«®¢®ª (1 ¨«¨ 2) */
|
||||
long diskIndex; /* unused */
|
||||
long DataOffset[512*2]; /* ᬥ饨¥ ¢ ä ©«¥ ª áâàãªâãà ¬ § £®«®¢ª®¢ */
|
||||
/* â४®¢ */
|
||||
};
|
||||
|
||||
struct FDD_TRACK_HEADER
|
||||
{
|
||||
unsigned char trkType; /* unused */
|
||||
unsigned char SectNum; /* ç¨á«® ᥪâ®à®¢ â४¥ */
|
||||
struct
|
||||
{
|
||||
/* § £®«®¢®ª ᥪâ®à */
|
||||
unsigned char trk; /* ®¬¥à â४ */
|
||||
unsigned char side; /* ®¬¥à áâ®à®ë */
|
||||
/* 7 ¡¨â í⮣® ¡ ©â 㪠§ë¢ ¥â ¡¨â a */
|
||||
unsigned char sect; /* ®¬¥à ᥪâ®à */
|
||||
unsigned char size; /* à §¬¥à ᥪâ®à (ª®¤) */
|
||||
long SectPos; /* ᬥ饨¥ ¢ ä ©«¥ ª ¤ ë¬ á¥ªâ®à */
|
||||
} sect[256];
|
||||
};
|
||||
|
||||
|
||||
struct TRDOS_DIR_ELEMENT // 16 bytes
|
||||
{
|
||||
char FileName[8];
|
||||
char Type;
|
||||
unsigned short Start;
|
||||
unsigned short Length;
|
||||
unsigned char SecLen;
|
||||
unsigned char FirstSec;
|
||||
unsigned char FirstTrk;
|
||||
};
|
||||
#pragma pack()
|
||||
|
||||
int x2trd(const char *name, fileTYPE *f);
|
||||
int x2trd_ext_supp(const char *name);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
#endif
|
||||
|
||||
14
battery.cpp
14
battery.cpp
@@ -95,10 +95,10 @@ static int i2c_smbus_access (int fd, char rw, uint8_t command, int size, union i
|
||||
return ioctl (fd, I2C_SMBUS, &args);
|
||||
}
|
||||
|
||||
static int i2c_smbus_write_quick(int fd, uint8_t value)
|
||||
{
|
||||
return i2c_smbus_access(fd, value, 0, I2C_SMBUS_QUICK, NULL);
|
||||
}
|
||||
static int i2c_smbus_write_quick(int fd, uint8_t value)
|
||||
{
|
||||
return i2c_smbus_access(fd, value, 0, I2C_SMBUS_QUICK, NULL);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -123,12 +123,12 @@ static int smbus_open(int dev_address)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (i2c_smbus_write_quick(fd, I2C_SMBUS_WRITE) < 0)
|
||||
{
|
||||
if (i2c_smbus_write_quick(fd, I2C_SMBUS_WRITE) < 0)
|
||||
{
|
||||
printf("Unable to detect SMBUS device: %s\n", strerror(errno));
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
i2c_handle = fd;
|
||||
}
|
||||
|
||||
462
bootcore.cpp
462
bootcore.cpp
@@ -1,234 +1,234 @@
|
||||
// bootcore.cpp
|
||||
// 2019, Aitor Gomez Garcia (spark2k06@gmail.com)
|
||||
// Thanks to Sorgelig and BBond007 for their help and advice in the development of this feature.
|
||||
|
||||
#include "file_io.h"
|
||||
#include "cfg.h"
|
||||
#include "fpga_io.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dirent.h>
|
||||
|
||||
int16_t btimeout;
|
||||
char bootcoretype[64];
|
||||
|
||||
bool isExactcoreName(char *path)
|
||||
{
|
||||
char *spl = strrchr(path, '.');
|
||||
return (spl && !strcmp(spl, ".rbf"));
|
||||
}
|
||||
|
||||
char *getcoreName(char *path)
|
||||
{
|
||||
char *spl = strrchr(path, '.');
|
||||
if (spl && !strcmp(spl, ".rbf"))
|
||||
{
|
||||
*spl = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if ((spl = strrchr(path, '/')) != NULL)
|
||||
{
|
||||
path = spl + 1;
|
||||
}
|
||||
if ((spl = strrchr(path, '_')) != NULL)
|
||||
{
|
||||
*spl = 0;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
char *getcoreExactName(char *path)
|
||||
{
|
||||
char *spl;
|
||||
if ((spl = strrchr(path, '/')) != NULL)
|
||||
{
|
||||
path = spl + 1;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
char *replaceStr(const char *str, const char *oldstr, const char *newstr)
|
||||
{
|
||||
char *result;
|
||||
int i, cnt = 0;
|
||||
int newstrlen = strlen(newstr);
|
||||
int oldstrlen = strlen(oldstr);
|
||||
|
||||
for (i = 0; str[i] != '\0'; i++)
|
||||
{
|
||||
if (strstr(&str[i], oldstr) == &str[i])
|
||||
{
|
||||
cnt++;
|
||||
i += oldstrlen - 1;
|
||||
}
|
||||
}
|
||||
|
||||
result = new char[i + cnt * (newstrlen - oldstrlen) + 1];
|
||||
|
||||
i = 0;
|
||||
while (*str)
|
||||
{
|
||||
if (strstr(str, oldstr) == str)
|
||||
{
|
||||
strcpy(&result[i], newstr);
|
||||
i += newstrlen;
|
||||
str += oldstrlen;
|
||||
}
|
||||
else
|
||||
result[i++] = *str++;
|
||||
}
|
||||
|
||||
result[i] = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
char* loadLastcore()
|
||||
{
|
||||
char full_path[2100];
|
||||
char path[256] = { CONFIG_DIR"/" };
|
||||
strcat(path, "lastcore.dat");
|
||||
sprintf(full_path, "%s/%s", getRootDir(), path);
|
||||
FILE *fd = fopen(full_path, "r");
|
||||
if (!fd)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
fseek(fd, 0L, SEEK_END);
|
||||
long size = ftell(fd);
|
||||
|
||||
fseek(fd, 0L, SEEK_SET);
|
||||
char *lastcore = new char[size + 1];
|
||||
|
||||
int ret = fread(lastcore, sizeof(char), size, fd);
|
||||
fclose(fd);
|
||||
if (ret == size)
|
||||
{
|
||||
return lastcore;
|
||||
}
|
||||
delete[] lastcore;
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
char *findCore(const char *name, char *coreName, int indent)
|
||||
{
|
||||
char *spl;
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
|
||||
if (!(dir = opendir(name)))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
char *indir;
|
||||
char* path = new char[256];
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
if (entry->d_type == DT_DIR) {
|
||||
if (entry->d_name[0] != '_')
|
||||
continue;
|
||||
snprintf(path, 256, "%s/%s", name, entry->d_name);
|
||||
indir = findCore(path, coreName, indent + 2);
|
||||
if (indir != NULL)
|
||||
{
|
||||
closedir(dir);
|
||||
delete[] path;
|
||||
return indir;
|
||||
}
|
||||
}
|
||||
else {
|
||||
snprintf(path, 256, "%s/%s", name, entry->d_name);
|
||||
if (strstr(path, coreName) != NULL) {
|
||||
spl = strrchr(path, '.');
|
||||
if (spl && !strcmp(spl, ".rbf"))
|
||||
{
|
||||
closedir(dir);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
delete[] path;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void bootcore_init(const char *path)
|
||||
{
|
||||
char *auxpointer;
|
||||
char auxstr[256];
|
||||
char bootcore[256];
|
||||
bool is_lastcore;
|
||||
const char *rootdir = getRootDir();
|
||||
cfg.bootcore_timeout = cfg.bootcore_timeout * 10;
|
||||
btimeout = cfg.bootcore_timeout;
|
||||
strcpy(bootcore, cfg.bootcore);
|
||||
|
||||
is_lastcore = (!strcmp(cfg.bootcore, "lastcore") || !strcmp(cfg.bootcore, "lastexactcore"));
|
||||
|
||||
if (is_lastcore)
|
||||
{
|
||||
strcpy(bootcoretype, cfg.bootcore);
|
||||
auxpointer = loadLastcore();
|
||||
if (auxpointer != NULL)
|
||||
{
|
||||
strcpy(bootcore, auxpointer);
|
||||
delete[] auxpointer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(bootcoretype, isExactcoreName(cfg.bootcore) ? "exactcorename" : "corename");
|
||||
}
|
||||
|
||||
auxpointer = findCore(rootdir, bootcore, 0);
|
||||
if (auxpointer != NULL)
|
||||
{
|
||||
strcpy(bootcore, auxpointer);
|
||||
delete[] auxpointer;
|
||||
|
||||
sprintf(auxstr, "%s/", rootdir);
|
||||
auxpointer = replaceStr(bootcore, auxstr, "");
|
||||
if (auxpointer != NULL)
|
||||
{
|
||||
strcpy(bootcore, auxpointer);
|
||||
delete[] auxpointer;
|
||||
|
||||
if (path[0] == '\0')
|
||||
{
|
||||
if (!cfg.bootcore_timeout)
|
||||
{
|
||||
fpga_load_rbf(bootcore);
|
||||
}
|
||||
|
||||
strcpy(cfg.bootcore, strcmp(bootcore, "menu.rbf") ? bootcore : "");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_lastcore && path[0] != '\0')
|
||||
{
|
||||
|
||||
strcpy(auxstr, path);
|
||||
auxpointer = !strcmp(cfg.bootcore, "lastexactcore") ? getcoreExactName(auxstr) : getcoreName(auxstr);
|
||||
|
||||
if (auxpointer != NULL)
|
||||
{
|
||||
if (strcmp(bootcore, auxpointer))
|
||||
{
|
||||
FileSaveConfig("lastcore.dat", (char*)auxpointer, strlen(auxpointer));
|
||||
}
|
||||
}
|
||||
}
|
||||
strcpy(cfg.bootcore, "");
|
||||
|
||||
}
|
||||
|
||||
|
||||
#include "file_io.h"
|
||||
#include "cfg.h"
|
||||
#include "fpga_io.h"
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dirent.h>
|
||||
|
||||
int16_t btimeout;
|
||||
char bootcoretype[64];
|
||||
|
||||
bool isExactcoreName(char *path)
|
||||
{
|
||||
char *spl = strrchr(path, '.');
|
||||
return (spl && !strcmp(spl, ".rbf"));
|
||||
}
|
||||
|
||||
char *getcoreName(char *path)
|
||||
{
|
||||
char *spl = strrchr(path, '.');
|
||||
if (spl && !strcmp(spl, ".rbf"))
|
||||
{
|
||||
*spl = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
if ((spl = strrchr(path, '/')) != NULL)
|
||||
{
|
||||
path = spl + 1;
|
||||
}
|
||||
if ((spl = strrchr(path, '_')) != NULL)
|
||||
{
|
||||
*spl = 0;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
char *getcoreExactName(char *path)
|
||||
{
|
||||
char *spl;
|
||||
if ((spl = strrchr(path, '/')) != NULL)
|
||||
{
|
||||
path = spl + 1;
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
char *replaceStr(const char *str, const char *oldstr, const char *newstr)
|
||||
{
|
||||
char *result;
|
||||
int i, cnt = 0;
|
||||
int newstrlen = strlen(newstr);
|
||||
int oldstrlen = strlen(oldstr);
|
||||
|
||||
for (i = 0; str[i] != '\0'; i++)
|
||||
{
|
||||
if (strstr(&str[i], oldstr) == &str[i])
|
||||
{
|
||||
cnt++;
|
||||
i += oldstrlen - 1;
|
||||
}
|
||||
}
|
||||
|
||||
result = new char[i + cnt * (newstrlen - oldstrlen) + 1];
|
||||
|
||||
i = 0;
|
||||
while (*str)
|
||||
{
|
||||
if (strstr(str, oldstr) == str)
|
||||
{
|
||||
strcpy(&result[i], newstr);
|
||||
i += newstrlen;
|
||||
str += oldstrlen;
|
||||
}
|
||||
else
|
||||
result[i++] = *str++;
|
||||
}
|
||||
|
||||
result[i] = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
char* loadLastcore()
|
||||
{
|
||||
char full_path[2100];
|
||||
char path[256] = { CONFIG_DIR"/" };
|
||||
strcat(path, "lastcore.dat");
|
||||
sprintf(full_path, "%s/%s", getRootDir(), path);
|
||||
FILE *fd = fopen(full_path, "r");
|
||||
if (!fd)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
fseek(fd, 0L, SEEK_END);
|
||||
long size = ftell(fd);
|
||||
|
||||
fseek(fd, 0L, SEEK_SET);
|
||||
char *lastcore = new char[size + 1];
|
||||
|
||||
int ret = fread(lastcore, sizeof(char), size, fd);
|
||||
fclose(fd);
|
||||
if (ret == size)
|
||||
{
|
||||
return lastcore;
|
||||
}
|
||||
delete[] lastcore;
|
||||
return NULL;
|
||||
|
||||
}
|
||||
|
||||
char *findCore(const char *name, char *coreName, int indent)
|
||||
{
|
||||
char *spl;
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
|
||||
if (!(dir = opendir(name)))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
char *indir;
|
||||
char* path = new char[256];
|
||||
while ((entry = readdir(dir)) != NULL) {
|
||||
if (entry->d_type == DT_DIR) {
|
||||
if (entry->d_name[0] != '_')
|
||||
continue;
|
||||
snprintf(path, 256, "%s/%s", name, entry->d_name);
|
||||
indir = findCore(path, coreName, indent + 2);
|
||||
if (indir != NULL)
|
||||
{
|
||||
closedir(dir);
|
||||
delete[] path;
|
||||
return indir;
|
||||
}
|
||||
}
|
||||
else {
|
||||
snprintf(path, 256, "%s/%s", name, entry->d_name);
|
||||
if (strstr(path, coreName) != NULL) {
|
||||
spl = strrchr(path, '.');
|
||||
if (spl && !strcmp(spl, ".rbf"))
|
||||
{
|
||||
closedir(dir);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir(dir);
|
||||
delete[] path;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void bootcore_init(const char *path)
|
||||
{
|
||||
char *auxpointer;
|
||||
char auxstr[256];
|
||||
char bootcore[256];
|
||||
bool is_lastcore;
|
||||
const char *rootdir = getRootDir();
|
||||
cfg.bootcore_timeout = cfg.bootcore_timeout * 10;
|
||||
btimeout = cfg.bootcore_timeout;
|
||||
strcpy(bootcore, cfg.bootcore);
|
||||
|
||||
is_lastcore = (!strcmp(cfg.bootcore, "lastcore") || !strcmp(cfg.bootcore, "lastexactcore"));
|
||||
|
||||
if (is_lastcore)
|
||||
{
|
||||
strcpy(bootcoretype, cfg.bootcore);
|
||||
auxpointer = loadLastcore();
|
||||
if (auxpointer != NULL)
|
||||
{
|
||||
strcpy(bootcore, auxpointer);
|
||||
delete[] auxpointer;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strcpy(bootcoretype, isExactcoreName(cfg.bootcore) ? "exactcorename" : "corename");
|
||||
}
|
||||
|
||||
auxpointer = findCore(rootdir, bootcore, 0);
|
||||
if (auxpointer != NULL)
|
||||
{
|
||||
strcpy(bootcore, auxpointer);
|
||||
delete[] auxpointer;
|
||||
|
||||
sprintf(auxstr, "%s/", rootdir);
|
||||
auxpointer = replaceStr(bootcore, auxstr, "");
|
||||
if (auxpointer != NULL)
|
||||
{
|
||||
strcpy(bootcore, auxpointer);
|
||||
delete[] auxpointer;
|
||||
|
||||
if (path[0] == '\0')
|
||||
{
|
||||
if (!cfg.bootcore_timeout)
|
||||
{
|
||||
fpga_load_rbf(bootcore);
|
||||
}
|
||||
|
||||
strcpy(cfg.bootcore, strcmp(bootcore, "menu.rbf") ? bootcore : "");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (is_lastcore && path[0] != '\0')
|
||||
{
|
||||
|
||||
strcpy(auxstr, path);
|
||||
auxpointer = !strcmp(cfg.bootcore, "lastexactcore") ? getcoreExactName(auxstr) : getcoreName(auxstr);
|
||||
|
||||
if (auxpointer != NULL)
|
||||
{
|
||||
if (strcmp(bootcore, auxpointer))
|
||||
{
|
||||
FileSaveConfig("lastcore.dat", (char*)auxpointer, strlen(auxpointer));
|
||||
}
|
||||
}
|
||||
}
|
||||
strcpy(cfg.bootcore, "");
|
||||
|
||||
}
|
||||
|
||||
|
||||
2506
file_io.cpp
2506
file_io.cpp
File diff suppressed because it is too large
Load Diff
176
file_io.h
176
file_io.h
@@ -1,88 +1,88 @@
|
||||
#ifndef _FAT16_H_INCLUDED
|
||||
#define _FAT16_H_INCLUDED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include "spi.h"
|
||||
|
||||
struct fileZipArchive;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FILE *filp;
|
||||
int mode;
|
||||
int type;
|
||||
fileZipArchive *zip;
|
||||
__off64_t size;
|
||||
__off64_t offset;
|
||||
char path[1024];
|
||||
char name[261];
|
||||
} fileTYPE;
|
||||
|
||||
int flist_nDirEntries();
|
||||
int flist_iFirstEntry();
|
||||
int flist_iSelectedEntry();
|
||||
dirent* flist_DirItem(int n);
|
||||
dirent* flist_SelectedItem();
|
||||
|
||||
// scanning flags
|
||||
#define SCANF_INIT 0 // start search from beginning of directory
|
||||
#define SCANF_NEXT 1 // find next file in directory
|
||||
#define SCANF_PREV -1 // find previous file in directory
|
||||
#define SCANF_NEXT_PAGE 2 // find next 16 files in directory
|
||||
#define SCANF_PREV_PAGE -2 // find previous 16 files in directory
|
||||
#define SCANF_SET_ITEM 3 // find exact item
|
||||
#define SCANF_END 4 // find last file in directory
|
||||
|
||||
// options flags
|
||||
#define SCANO_DIR 1 // include subdirectories
|
||||
#define SCANO_UMOUNT 2 // allow backspace key
|
||||
#define SCANO_CORES 4 // only include subdirectories with prefix '_'
|
||||
#define SCANO_COEFF 8
|
||||
|
||||
void FindStorage();
|
||||
int getStorage(int from_setting);
|
||||
void setStorage(int dev);
|
||||
int isUSBMounted();
|
||||
|
||||
int FileOpenEx(fileTYPE *file, const char *name, int mode, char mute = 0);
|
||||
int FileOpen(fileTYPE *file, const char *name, char mute = 0);
|
||||
void FileClose(fileTYPE *file);
|
||||
|
||||
__off64_t FileGetSize(fileTYPE *file);
|
||||
|
||||
int FileSeek(fileTYPE *file, __off64_t offset, int origin);
|
||||
int FileSeekLBA(fileTYPE *file, uint32_t offset);
|
||||
|
||||
int FileReadAdv(fileTYPE *file, void *pBuffer, int length);
|
||||
int FileReadSec(fileTYPE *file, void *pBuffer);
|
||||
int FileWriteAdv(fileTYPE *file, void *pBuffer, int length);
|
||||
int FileWriteSec(fileTYPE *file, void *pBuffer);
|
||||
|
||||
int FileCanWrite(const char *name);
|
||||
|
||||
#define SAVE_DIR "saves"
|
||||
void FileGenerateSavePath(const char *name, char* out_name);
|
||||
|
||||
int FileSave(const char *name, void *pBuffer, int size);
|
||||
int FileLoad(const char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading
|
||||
|
||||
//save/load from config dir
|
||||
#define CONFIG_DIR "config"
|
||||
int FileSaveConfig(const char *name, void *pBuffer, int size);
|
||||
int FileLoadConfig(const char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading
|
||||
|
||||
void AdjustDirectory(char *path);
|
||||
int ScanDirectory(char* path, int mode, const char *extension, int options, const char *prefix = NULL);
|
||||
|
||||
const char *getStorageDir(int dev);
|
||||
const char *getRootDir();
|
||||
const char *getFullPath(const char *name);
|
||||
|
||||
uint32_t getFileType(const char *name);
|
||||
|
||||
#define COEFF_DIR "filters"
|
||||
|
||||
#endif
|
||||
#ifndef _FAT16_H_INCLUDED
|
||||
#define _FAT16_H_INCLUDED
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include "spi.h"
|
||||
|
||||
struct fileZipArchive;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FILE *filp;
|
||||
int mode;
|
||||
int type;
|
||||
fileZipArchive *zip;
|
||||
__off64_t size;
|
||||
__off64_t offset;
|
||||
char path[1024];
|
||||
char name[261];
|
||||
} fileTYPE;
|
||||
|
||||
int flist_nDirEntries();
|
||||
int flist_iFirstEntry();
|
||||
int flist_iSelectedEntry();
|
||||
dirent* flist_DirItem(int n);
|
||||
dirent* flist_SelectedItem();
|
||||
|
||||
// scanning flags
|
||||
#define SCANF_INIT 0 // start search from beginning of directory
|
||||
#define SCANF_NEXT 1 // find next file in directory
|
||||
#define SCANF_PREV -1 // find previous file in directory
|
||||
#define SCANF_NEXT_PAGE 2 // find next 16 files in directory
|
||||
#define SCANF_PREV_PAGE -2 // find previous 16 files in directory
|
||||
#define SCANF_SET_ITEM 3 // find exact item
|
||||
#define SCANF_END 4 // find last file in directory
|
||||
|
||||
// options flags
|
||||
#define SCANO_DIR 1 // include subdirectories
|
||||
#define SCANO_UMOUNT 2 // allow backspace key
|
||||
#define SCANO_CORES 4 // only include subdirectories with prefix '_'
|
||||
#define SCANO_COEFF 8
|
||||
|
||||
void FindStorage();
|
||||
int getStorage(int from_setting);
|
||||
void setStorage(int dev);
|
||||
int isUSBMounted();
|
||||
|
||||
int FileOpenEx(fileTYPE *file, const char *name, int mode, char mute = 0);
|
||||
int FileOpen(fileTYPE *file, const char *name, char mute = 0);
|
||||
void FileClose(fileTYPE *file);
|
||||
|
||||
__off64_t FileGetSize(fileTYPE *file);
|
||||
|
||||
int FileSeek(fileTYPE *file, __off64_t offset, int origin);
|
||||
int FileSeekLBA(fileTYPE *file, uint32_t offset);
|
||||
|
||||
int FileReadAdv(fileTYPE *file, void *pBuffer, int length);
|
||||
int FileReadSec(fileTYPE *file, void *pBuffer);
|
||||
int FileWriteAdv(fileTYPE *file, void *pBuffer, int length);
|
||||
int FileWriteSec(fileTYPE *file, void *pBuffer);
|
||||
|
||||
int FileCanWrite(const char *name);
|
||||
|
||||
#define SAVE_DIR "saves"
|
||||
void FileGenerateSavePath(const char *name, char* out_name);
|
||||
|
||||
int FileSave(const char *name, void *pBuffer, int size);
|
||||
int FileLoad(const char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading
|
||||
|
||||
//save/load from config dir
|
||||
#define CONFIG_DIR "config"
|
||||
int FileSaveConfig(const char *name, void *pBuffer, int size);
|
||||
int FileLoadConfig(const char *name, void *pBuffer, int size); // supply pBuffer = 0 to get the file size without loading
|
||||
|
||||
void AdjustDirectory(char *path);
|
||||
int ScanDirectory(char* path, int mode, const char *extension, int options, const char *prefix = NULL);
|
||||
|
||||
const char *getStorageDir(int dev);
|
||||
const char *getRootDir();
|
||||
const char *getFullPath(const char *name);
|
||||
|
||||
uint32_t getFileType(const char *name);
|
||||
|
||||
#define COEFF_DIR "filters"
|
||||
|
||||
#endif
|
||||
|
||||
1306
fpga_io.cpp
1306
fpga_io.cpp
File diff suppressed because it is too large
Load Diff
74
fpga_io.h
74
fpga_io.h
@@ -1,37 +1,37 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef FPGAIO_H
|
||||
#define FPGAIO_H
|
||||
|
||||
#define DISKLED_ON fpga_set_led(1)
|
||||
#define DISKLED_OFF fpga_set_led(0)
|
||||
|
||||
#define BUTTON_OSD 1
|
||||
#define BUTTON_USR 2
|
||||
|
||||
int fpga_io_init();
|
||||
|
||||
void fpga_gpo_write(uint32_t value);
|
||||
uint32_t fpga_gpo_read();
|
||||
int fpga_gpi_read();
|
||||
|
||||
void fpga_set_led(uint32_t on);
|
||||
int fpga_get_buttons();
|
||||
|
||||
void fpga_core_reset(int reset);
|
||||
void fpga_core_write(uint32_t offset, uint32_t value);
|
||||
uint32_t fpga_core_read(uint32_t offset);
|
||||
int fpga_core_id();
|
||||
int is_fpga_ready(int quick);
|
||||
|
||||
int fpga_get_fio_size();
|
||||
int fpga_get_io_version();
|
||||
|
||||
int fpga_load_rbf(const char *name, const char *cfg = NULL);
|
||||
|
||||
void reboot(int cold);
|
||||
void app_restart(const char *path);
|
||||
char *getappname();
|
||||
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef FPGAIO_H
|
||||
#define FPGAIO_H
|
||||
|
||||
#define DISKLED_ON fpga_set_led(1)
|
||||
#define DISKLED_OFF fpga_set_led(0)
|
||||
|
||||
#define BUTTON_OSD 1
|
||||
#define BUTTON_USR 2
|
||||
|
||||
int fpga_io_init();
|
||||
|
||||
void fpga_gpo_write(uint32_t value);
|
||||
uint32_t fpga_gpo_read();
|
||||
int fpga_gpi_read();
|
||||
|
||||
void fpga_set_led(uint32_t on);
|
||||
int fpga_get_buttons();
|
||||
|
||||
void fpga_core_reset(int reset);
|
||||
void fpga_core_write(uint32_t offset, uint32_t value);
|
||||
uint32_t fpga_core_read(uint32_t offset);
|
||||
int fpga_core_id();
|
||||
int is_fpga_ready(int quick);
|
||||
|
||||
int fpga_get_fio_size();
|
||||
int fpga_get_io_version();
|
||||
|
||||
int fpga_load_rbf(const char *name, const char *cfg = NULL);
|
||||
|
||||
void reboot(int cold);
|
||||
void app_restart(const char *path);
|
||||
char *getappname();
|
||||
|
||||
#endif
|
||||
|
||||
154
hardware.cpp
154
hardware.cpp
@@ -1,77 +1,77 @@
|
||||
/*
|
||||
Copyright 2008, 2009 Jakub Bednarski
|
||||
|
||||
This file is part of Minimig
|
||||
|
||||
Minimig is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Minimig is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include "hardware.h"
|
||||
#include "user_io.h"
|
||||
|
||||
uint8_t rstval = 0;
|
||||
|
||||
void hexdump(void *data, uint16_t size, uint16_t offset)
|
||||
{
|
||||
uint8_t i, b2c;
|
||||
uint16_t n = 0;
|
||||
char *ptr = (char*)data;
|
||||
|
||||
if (!size) return;
|
||||
|
||||
while (size>0) {
|
||||
printf("%04x: ", n + offset);
|
||||
|
||||
b2c = (size>16) ? 16 : size;
|
||||
for (i = 0; i<b2c; i++) printf("%02x ", 0xff & ptr[i]);
|
||||
printf(" ");
|
||||
for (i = 0; i<(16 - b2c); i++) printf(" ");
|
||||
for (i = 0; i<b2c; i++) printf("%c", isprint(ptr[i]) ? ptr[i] : '.');
|
||||
printf("\n");
|
||||
ptr += b2c;
|
||||
size -= b2c;
|
||||
n += b2c;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long GetTimer(unsigned long offset)
|
||||
{
|
||||
struct timespec tp;
|
||||
|
||||
clock_gettime(CLOCK_BOOTTIME, &tp);
|
||||
|
||||
uint64_t res;
|
||||
|
||||
res = tp.tv_sec;
|
||||
res *= 1000;
|
||||
res += (tp.tv_nsec / 1000000);
|
||||
|
||||
return (unsigned long)(res + offset);
|
||||
}
|
||||
|
||||
unsigned long CheckTimer(unsigned long time)
|
||||
{
|
||||
return GetTimer(0) >= time;
|
||||
}
|
||||
|
||||
void WaitTimer(unsigned long time)
|
||||
{
|
||||
time = GetTimer(time);
|
||||
while (!CheckTimer(time));
|
||||
}
|
||||
/*
|
||||
Copyright 2008, 2009 Jakub Bednarski
|
||||
|
||||
This file is part of Minimig
|
||||
|
||||
Minimig is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Minimig is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <time.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include "hardware.h"
|
||||
#include "user_io.h"
|
||||
|
||||
uint8_t rstval = 0;
|
||||
|
||||
void hexdump(void *data, uint16_t size, uint16_t offset)
|
||||
{
|
||||
uint8_t i, b2c;
|
||||
uint16_t n = 0;
|
||||
char *ptr = (char*)data;
|
||||
|
||||
if (!size) return;
|
||||
|
||||
while (size>0) {
|
||||
printf("%04x: ", n + offset);
|
||||
|
||||
b2c = (size>16) ? 16 : size;
|
||||
for (i = 0; i<b2c; i++) printf("%02x ", 0xff & ptr[i]);
|
||||
printf(" ");
|
||||
for (i = 0; i<(16 - b2c); i++) printf(" ");
|
||||
for (i = 0; i<b2c; i++) printf("%c", isprint(ptr[i]) ? ptr[i] : '.');
|
||||
printf("\n");
|
||||
ptr += b2c;
|
||||
size -= b2c;
|
||||
n += b2c;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned long GetTimer(unsigned long offset)
|
||||
{
|
||||
struct timespec tp;
|
||||
|
||||
clock_gettime(CLOCK_BOOTTIME, &tp);
|
||||
|
||||
uint64_t res;
|
||||
|
||||
res = tp.tv_sec;
|
||||
res *= 1000;
|
||||
res += (tp.tv_nsec / 1000000);
|
||||
|
||||
return (unsigned long)(res + offset);
|
||||
}
|
||||
|
||||
unsigned long CheckTimer(unsigned long time)
|
||||
{
|
||||
return GetTimer(0) >= time;
|
||||
}
|
||||
|
||||
void WaitTimer(unsigned long time)
|
||||
{
|
||||
time = GetTimer(time);
|
||||
while (!CheckTimer(time));
|
||||
}
|
||||
|
||||
38
hardware.h
38
hardware.h
@@ -1,19 +1,19 @@
|
||||
#ifndef HARDWARE_H
|
||||
#define HARDWARE_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
unsigned long GetTimer(unsigned long offset);
|
||||
unsigned long CheckTimer(unsigned long t);
|
||||
void WaitTimer(unsigned long time);
|
||||
|
||||
void hexdump(void *data, uint16_t size, uint16_t offset = 0);
|
||||
|
||||
// minimig reset stuff
|
||||
#define SPI_RST_USR 0x1
|
||||
#define SPI_RST_CPU 0x2
|
||||
#define SPI_CPU_HLT 0x4
|
||||
extern uint8_t rstval;
|
||||
|
||||
#endif // HARDWARE_H
|
||||
#ifndef HARDWARE_H
|
||||
#define HARDWARE_H
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <stdio.h>
|
||||
|
||||
unsigned long GetTimer(unsigned long offset);
|
||||
unsigned long CheckTimer(unsigned long t);
|
||||
void WaitTimer(unsigned long time);
|
||||
|
||||
void hexdump(void *data, uint16_t size, uint16_t offset = 0);
|
||||
|
||||
// minimig reset stuff
|
||||
#define SPI_RST_USR 0x1
|
||||
#define SPI_RST_CPU 0x2
|
||||
#define SPI_CPU_HLT 0x4
|
||||
extern uint8_t rstval;
|
||||
|
||||
#endif // HARDWARE_H
|
||||
|
||||
40
input.h
40
input.h
@@ -2,24 +2,24 @@
|
||||
#ifndef EVINPUT_H
|
||||
#define EVINPUT_H
|
||||
|
||||
#include <linux/input.h>
|
||||
#include <linux/input.h>
|
||||
|
||||
#define HID_LED_NUM_LOCK 1
|
||||
#define HID_LED_CAPS_LOCK 2
|
||||
#define HID_LED_SCROLL_LOCK 4
|
||||
#define HID_LED_MASK 7
|
||||
|
||||
#define NONE 0xFF
|
||||
#define LCTRL 0x000100
|
||||
#define LSHIFT 0x000200
|
||||
#define LALT 0x000400
|
||||
#define LGUI 0x000800
|
||||
#define RCTRL 0x001000
|
||||
#define RSHIFT 0x002000
|
||||
#define RALT 0x004000
|
||||
#define RGUI 0x008000
|
||||
#define MODMASK 0x00FF00
|
||||
|
||||
#define NONE 0xFF
|
||||
#define LCTRL 0x000100
|
||||
#define LSHIFT 0x000200
|
||||
#define LALT 0x000400
|
||||
#define LGUI 0x000800
|
||||
#define RCTRL 0x001000
|
||||
#define RSHIFT 0x002000
|
||||
#define RALT 0x004000
|
||||
#define RGUI 0x008000
|
||||
#define MODMASK 0x00FF00
|
||||
|
||||
#define OSD 0x010000 // to be used by OSD, not the core itself
|
||||
#define OSD_OPEN 0x020000 // OSD key not forwarded to core, but queued in arm controller
|
||||
#define CAPS_TOGGLE 0x040000 // caps lock toggle behaviour
|
||||
@@ -33,16 +33,16 @@ void set_kbdled(int mask, int state);
|
||||
int get_kbdled(int mask);
|
||||
int toggle_kbdled(int mask);
|
||||
|
||||
void input_notify_mode();
|
||||
void input_notify_mode();
|
||||
int input_poll(int getchar);
|
||||
int is_key_pressed(int key);
|
||||
int is_key_pressed(int key);
|
||||
|
||||
void start_map_setting(int cnt);
|
||||
int get_map_button();
|
||||
int get_map_type();
|
||||
void finish_map_setting(int dismiss);
|
||||
uint16_t get_map_vid();
|
||||
uint16_t get_map_pid();
|
||||
void start_map_setting(int cnt);
|
||||
int get_map_button();
|
||||
int get_map_type();
|
||||
void finish_map_setting(int dismiss);
|
||||
uint16_t get_map_vid();
|
||||
uint16_t get_map_pid();
|
||||
int has_default_map();
|
||||
|
||||
uint32_t get_key_mod();
|
||||
|
||||
190
logo.h
190
logo.h
@@ -1,101 +1,101 @@
|
||||
#ifndef LOGO_H
|
||||
#define LOGO_H
|
||||
const unsigned char logodata[6][227] = {
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00 },
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xF0,
|
||||
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
|
||||
0x80, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00 },
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
|
||||
0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFE,
|
||||
0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0x7F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xF8, 0xF9, 0xF9, 0xF9, 0xFB,
|
||||
0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0x19, 0x01, 0x01, 0x00, 0x00, 0x00, 0x3C, 0x7F, 0x7F, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xF3, 0xF3, 0xE1, 0xE1, 0xE1, 0xC1,
|
||||
0xC1, 0xC3, 0x83, 0x83, 0x03, 0x03, 0x03, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xC3, 0xF3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||
0x03, 0x83, 0xC0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0x78, 0x78, 0x38, 0x38,
|
||||
0x38, 0x38, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xD8,
|
||||
0xE0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0x78, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00 },
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFE, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F,
|
||||
0x07, 0x01, 0x80, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F,
|
||||
0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0x7F, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE1, 0xC1, 0xC1, 0xC3, 0xC3, 0xC3, 0xC3, 0xE7, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0x7F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x7E,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE,
|
||||
0xCE, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xC7, 0xC7, 0xE7, 0x27, 0x03, 0x03, 0x01, 0x00, 0x00, 0xC0,
|
||||
0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x07, 0x03, 0x01,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00 },
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||
0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01,
|
||||
0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00 },
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00 },
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x80, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xE0, 0xE0, 0xF0,
|
||||
0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
|
||||
0x80, 0xC0, 0xC0, 0xC0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x80, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE0, 0xE0, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00 },
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
|
||||
0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x1F, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xC0, 0x00, 0x00, 0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFE,
|
||||
0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0xCF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0x7F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF0, 0xF8, 0xF9, 0xF9, 0xF9, 0xFB,
|
||||
0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0xFB, 0x19, 0x01, 0x01, 0x00, 0x00, 0x00, 0x3C, 0x7F, 0x7F, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFB, 0xF3, 0xF3, 0xE1, 0xE1, 0xE1, 0xC1,
|
||||
0xC1, 0xC3, 0x83, 0x83, 0x03, 0x03, 0x03, 0x07, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0xC3, 0xF3, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x07, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||
0x03, 0x83, 0xC0, 0xE0, 0xE0, 0xE0, 0xF0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0x78, 0x78, 0x38, 0x38,
|
||||
0x38, 0x38, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF0, 0xF0, 0xE0, 0xC0, 0x00, 0x00,
|
||||
0x00, 0x00, 0x80, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0xD8,
|
||||
0xE0, 0xF0, 0xF0, 0xF8, 0xF8, 0xF8, 0xF8, 0xF8, 0x78, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00 },
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF0, 0xFE, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x3F, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0x7F, 0x3F, 0x1F, 0x0F,
|
||||
0x07, 0x01, 0x80, 0xE0, 0xFC, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x3F,
|
||||
0x0F, 0x01, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xF8, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0x7F, 0x1F, 0x03, 0x00, 0x00, 0x00, 0x80, 0xE0, 0xF0, 0xF0, 0xF0, 0xE0, 0xE0, 0xE0,
|
||||
0xE0, 0xE1, 0xC1, 0xC1, 0xC3, 0xC3, 0xC3, 0xC3, 0xE7, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x3E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x80, 0xE0, 0xF8, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
|
||||
0x7F, 0x0F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x7E,
|
||||
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xEF, 0xCE, 0xCE, 0xCE, 0xCE, 0xCE,
|
||||
0xCE, 0xCF, 0xCF, 0xCF, 0xCF, 0xCF, 0xC7, 0xC7, 0xE7, 0x27, 0x03, 0x03, 0x01, 0x00, 0x00, 0xC0,
|
||||
0xF0, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x7F, 0x1F, 0x07, 0x03, 0x01,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00 },
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x02, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||
0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01,
|
||||
0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03,
|
||||
0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00 },
|
||||
{
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00 }
|
||||
};
|
||||
#endif
|
||||
|
||||
138
main.cpp
138
main.cpp
@@ -1,74 +1,74 @@
|
||||
/*
|
||||
Copyright 2005, 2006, 2007 Dennis van Weeren
|
||||
Copyright 2008, 2009 Jakub Bednarski
|
||||
Copyright 2012 Till Harbaum
|
||||
|
||||
This file is part of Minimig
|
||||
|
||||
Minimig is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Minimig is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sched.h>
|
||||
/*
|
||||
Copyright 2005, 2006, 2007 Dennis van Weeren
|
||||
Copyright 2008, 2009 Jakub Bednarski
|
||||
Copyright 2012 Till Harbaum
|
||||
|
||||
This file is part of Minimig
|
||||
|
||||
Minimig is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Minimig is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <sched.h>
|
||||
#include <inttypes.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include "menu.h"
|
||||
#include "user_io.h"
|
||||
#include "input.h"
|
||||
#include "fpga_io.h"
|
||||
#include "scheduler.h"
|
||||
|
||||
const char *version = "$VER:HPS" VDATE;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
#include <string.h>
|
||||
#include "menu.h"
|
||||
#include "user_io.h"
|
||||
#include "input.h"
|
||||
#include "fpga_io.h"
|
||||
#include "scheduler.h"
|
||||
|
||||
const char *version = "$VER:HPS" VDATE;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
// Always pin main worker process to core #1 as core #0 is the
|
||||
// hardware interrupt handler in Linux. This reduces idle latency
|
||||
// in the main loop by about 6-7x.
|
||||
cpu_set_t set;
|
||||
CPU_ZERO(&set);
|
||||
CPU_SET(1, &set);
|
||||
sched_setaffinity(0, sizeof(set), &set);
|
||||
|
||||
fpga_io_init();
|
||||
fpga_gpo_write(0);
|
||||
|
||||
DISKLED_OFF;
|
||||
|
||||
printf("\nMinimig by Dennis van Weeren");
|
||||
printf("\nARM Controller by Jakub Bednarski");
|
||||
printf("\nMiSTer code by Sorgelig\n\n");
|
||||
|
||||
printf("Version %s\n\n", version + 5);
|
||||
|
||||
if (argc > 1) printf("Core path: %s\n", argv[1]);
|
||||
|
||||
if (!is_fpga_ready(1))
|
||||
{
|
||||
printf("\nGPI[31]==1. FPGA is uninitialized or incompatible core loaded.\n");
|
||||
printf("Quitting. Bye bye...\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
FindStorage();
|
||||
user_io_init((argc > 1) ? argv[1] : "");
|
||||
|
||||
scheduler_init();
|
||||
scheduler_run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
cpu_set_t set;
|
||||
CPU_ZERO(&set);
|
||||
CPU_SET(1, &set);
|
||||
sched_setaffinity(0, sizeof(set), &set);
|
||||
|
||||
fpga_io_init();
|
||||
fpga_gpo_write(0);
|
||||
|
||||
DISKLED_OFF;
|
||||
|
||||
printf("\nMinimig by Dennis van Weeren");
|
||||
printf("\nARM Controller by Jakub Bednarski");
|
||||
printf("\nMiSTer code by Sorgelig\n\n");
|
||||
|
||||
printf("Version %s\n\n", version + 5);
|
||||
|
||||
if (argc > 1) printf("Core path: %s\n", argv[1]);
|
||||
|
||||
if (!is_fpga_ready(1))
|
||||
{
|
||||
printf("\nGPI[31]==1. FPGA is uninitialized or incompatible core loaded.\n");
|
||||
printf("Quitting. Bye bye...\n");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
FindStorage();
|
||||
user_io_init((argc > 1) ? argv[1] : "");
|
||||
|
||||
scheduler_init();
|
||||
scheduler_run();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
16
menu.cpp
16
menu.cpp
@@ -652,14 +652,14 @@ const char* get_rbf_name_bootcore(char *str)
|
||||
char *p = strrchr(str, '/');
|
||||
if (!p) return str;
|
||||
|
||||
char *spl = strrchr(p + 1, '.');
|
||||
if (spl && !strcmp(spl, ".rbf"))
|
||||
{
|
||||
*spl = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
char *spl = strrchr(p + 1, '.');
|
||||
if (spl && !strcmp(spl, ".rbf"))
|
||||
{
|
||||
*spl = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
return p + 1;
|
||||
|
||||
|
||||
20
menu.h
20
menu.h
@@ -12,20 +12,20 @@ extern const char *config_hdf_msg[];
|
||||
extern const char *config_chipset_msg[];
|
||||
|
||||
void HandleUI(void);
|
||||
void menu_key_set(unsigned int c);
|
||||
void PrintFileName(char *name, int row, int maxinv);
|
||||
void menu_key_set(unsigned int c);
|
||||
void PrintFileName(char *name, int row, int maxinv);
|
||||
void PrintDirectory(void);
|
||||
void ScrollLongName(void);
|
||||
|
||||
void ErrorMessage(const char *message, unsigned char code);
|
||||
void InfoMessage(const char *message, int timeout = 2000);
|
||||
void Info(const char *message, int timeout = 2000, int width = 0, int height = 0, int frame = 0);
|
||||
|
||||
uint32_t getStatus(char *opt, uint32_t status);
|
||||
void substrcpy(char *d, char *s, char idx);
|
||||
|
||||
extern char joy_bnames[32][32];
|
||||
extern int joy_bcount;
|
||||
void InfoMessage(const char *message, int timeout = 2000);
|
||||
void Info(const char *message, int timeout = 2000, int width = 0, int height = 0, int frame = 0);
|
||||
|
||||
uint32_t getStatus(char *opt, uint32_t status);
|
||||
void substrcpy(char *d, char *s, char idx);
|
||||
|
||||
extern char joy_bnames[32][32];
|
||||
extern int joy_bcount;
|
||||
|
||||
void open_joystick_setup();
|
||||
|
||||
|
||||
6
osd.h
6
osd.h
@@ -72,7 +72,7 @@ void OsdWrite(unsigned char n, const char *s="", unsigned char inver=0, unsigned
|
||||
void OsdWriteOffset(unsigned char n, const char *s, unsigned char inver, unsigned char stipple, char offset, char leftchar, char usebg = 0, int maxinv = 32); // Used for scrolling "Exit" text downwards...
|
||||
void OsdClear(void);
|
||||
void OsdEnable(unsigned char mode);
|
||||
void InfoEnable(int x, int y, int width, int height);
|
||||
void InfoEnable(int x, int y, int width, int height);
|
||||
void OsdDisable(void);
|
||||
void ConfigVideo(unsigned char hires, unsigned char lores, unsigned char scanlines);
|
||||
void ConfigAudio(unsigned char audio);
|
||||
@@ -80,9 +80,9 @@ void ConfigMemory(unsigned char memory);
|
||||
void ConfigCPU(unsigned char cpu);
|
||||
void ConfigChipset(unsigned char chipset);
|
||||
void ConfigFloppy(unsigned char drives, unsigned char speed);
|
||||
void ConfigAutofire(unsigned char autofire, unsigned char mask);
|
||||
void ConfigAutofire(unsigned char autofire, unsigned char mask);
|
||||
void OSD_PrintText(unsigned char line, const char *text, unsigned long start, unsigned long width, unsigned long offset, unsigned char invert);
|
||||
void OSD_PrintInfo(const char *message, int *width, int *height, int frame = 0);
|
||||
void OSD_PrintInfo(const char *message, int *width, int *height, int frame = 0);
|
||||
void OsdDrawLogo(int row);
|
||||
void ScrollText(char n, const char *str, int off, int len, int max_len, unsigned char invert);
|
||||
void ScrollReset();
|
||||
|
||||
662
spi.cpp
662
spi.cpp
@@ -1,331 +1,331 @@
|
||||
#include "spi.h"
|
||||
#include "hardware.h"
|
||||
#include "fpga_io.h"
|
||||
|
||||
#define SSPI_STROBE (1<<17)
|
||||
#define SSPI_ACK SSPI_STROBE
|
||||
|
||||
#define SSPI_FPGA_EN (1<<18)
|
||||
#define SSPI_OSD_EN (1<<19)
|
||||
#define SSPI_IO_EN (1<<20)
|
||||
#define SSPI_DM_EN (1<<21)
|
||||
|
||||
#define SWAPW(a) ((((a)<<8)&0xff00)|(((a)>>8)&0x00ff))
|
||||
|
||||
static void spi_en(uint32_t mask, uint32_t en)
|
||||
{
|
||||
uint32_t gpo = fpga_gpo_read() | 0x80000000;
|
||||
fpga_gpo_write(en ? gpo | mask : gpo & ~mask);
|
||||
}
|
||||
|
||||
uint16_t spi_w(uint16_t word)
|
||||
{
|
||||
uint32_t gpo = (fpga_gpo_read() & ~(0xFFFF | SSPI_STROBE)) | word;
|
||||
|
||||
fpga_gpo_write(gpo);
|
||||
fpga_gpo_write(gpo | SSPI_STROBE);
|
||||
|
||||
int gpi;
|
||||
do
|
||||
{
|
||||
gpi = fpga_gpi_read();
|
||||
if (gpi < 0)
|
||||
{
|
||||
printf("GPI[31]==1. FPGA is uninitialized?\n");
|
||||
return 0;
|
||||
}
|
||||
} while (!(gpi & SSPI_ACK));
|
||||
|
||||
fpga_gpo_write(gpo);
|
||||
|
||||
do
|
||||
{
|
||||
gpi = fpga_gpi_read();
|
||||
if (gpi < 0)
|
||||
{
|
||||
printf("GPI[31]==1. FPGA is uninitialized?\n");
|
||||
return 0;
|
||||
}
|
||||
} while (gpi & SSPI_ACK);
|
||||
|
||||
return (uint16_t)gpi;
|
||||
}
|
||||
|
||||
void spi_init(int enable)
|
||||
{
|
||||
(void)enable;
|
||||
printf("Init SPI.\n");
|
||||
}
|
||||
|
||||
uint8_t spi_b(uint8_t parm)
|
||||
{
|
||||
return (uint8_t)spi_w(parm);
|
||||
}
|
||||
|
||||
void EnableFpga()
|
||||
{
|
||||
spi_en(SSPI_FPGA_EN, 1);
|
||||
}
|
||||
|
||||
void DisableFpga()
|
||||
{
|
||||
spi_en(SSPI_FPGA_EN, 0);
|
||||
}
|
||||
|
||||
void EnableOsd()
|
||||
{
|
||||
spi_en(SSPI_OSD_EN, 1);
|
||||
}
|
||||
|
||||
void DisableOsd()
|
||||
{
|
||||
spi_en(SSPI_OSD_EN, 0);
|
||||
}
|
||||
|
||||
void EnableIO()
|
||||
{
|
||||
spi_en(SSPI_IO_EN, 1);
|
||||
}
|
||||
|
||||
void DisableIO()
|
||||
{
|
||||
spi_en(SSPI_IO_EN, 0);
|
||||
}
|
||||
|
||||
void EnableDMode()
|
||||
{
|
||||
spi_en(SSPI_DM_EN, 1);
|
||||
}
|
||||
|
||||
void DisableDMode()
|
||||
{
|
||||
spi_en(SSPI_DM_EN, 0);
|
||||
}
|
||||
|
||||
uint8_t spi_in()
|
||||
{
|
||||
return spi_b(0);
|
||||
}
|
||||
|
||||
void spi8(uint8_t parm)
|
||||
{
|
||||
spi_b(parm);
|
||||
}
|
||||
|
||||
void spi16(uint16_t parm)
|
||||
{
|
||||
spi8(parm >> 8);
|
||||
spi8(parm >> 0);
|
||||
}
|
||||
|
||||
void spi24(uint32_t parm)
|
||||
{
|
||||
spi8(parm >> 16);
|
||||
spi8(parm >> 8);
|
||||
spi8(parm >> 0);
|
||||
}
|
||||
|
||||
void spi32(uint32_t parm)
|
||||
{
|
||||
spi8(parm >> 24);
|
||||
spi8(parm >> 16);
|
||||
spi8(parm >> 8);
|
||||
spi8(parm >> 0);
|
||||
}
|
||||
|
||||
uint32_t spi32w(uint32_t parm)
|
||||
{
|
||||
uint32_t res;
|
||||
res = spi_w(parm);
|
||||
res |= (spi_w(parm>>16))<<16;
|
||||
return res;
|
||||
}
|
||||
|
||||
// little endian: lsb first
|
||||
void spi32le(uint32_t parm)
|
||||
{
|
||||
spi8(parm >> 0);
|
||||
spi8(parm >> 8);
|
||||
spi8(parm >> 16);
|
||||
spi8(parm >> 24);
|
||||
}
|
||||
|
||||
/* OSD related SPI functions */
|
||||
void spi_osd_cmd_cont(uint8_t cmd)
|
||||
{
|
||||
EnableOsd();
|
||||
spi8(cmd);
|
||||
}
|
||||
|
||||
void spi_osd_cmd(uint8_t cmd)
|
||||
{
|
||||
spi_osd_cmd_cont(cmd);
|
||||
DisableOsd();
|
||||
}
|
||||
|
||||
void spi_osd_cmd8_cont(uint8_t cmd, uint8_t parm)
|
||||
{
|
||||
EnableOsd();
|
||||
spi8(cmd);
|
||||
spi8(parm);
|
||||
}
|
||||
|
||||
void spi_osd_cmd8(uint8_t cmd, uint8_t parm)
|
||||
{
|
||||
spi_osd_cmd8_cont(cmd, parm);
|
||||
DisableOsd();
|
||||
}
|
||||
|
||||
void spi_osd_cmd16(uint8_t cmd, uint16_t parm)
|
||||
{
|
||||
EnableOsd();
|
||||
spi8(cmd);
|
||||
spi_w(parm);
|
||||
DisableOsd();
|
||||
}
|
||||
|
||||
void spi_osd_cmd32_cont(uint8_t cmd, uint32_t parm)
|
||||
{
|
||||
EnableOsd();
|
||||
spi8(cmd);
|
||||
spi32(parm);
|
||||
}
|
||||
|
||||
void spi_osd_cmd32(uint8_t cmd, uint32_t parm)
|
||||
{
|
||||
spi_osd_cmd32_cont(cmd, parm);
|
||||
DisableOsd();
|
||||
}
|
||||
|
||||
void spi_osd_cmd32le_cont(uint8_t cmd, uint32_t parm)
|
||||
{
|
||||
EnableOsd();
|
||||
spi8(cmd);
|
||||
spi32le(parm);
|
||||
}
|
||||
|
||||
void spi_osd_cmd32le(uint8_t cmd, uint32_t parm)
|
||||
{
|
||||
spi_osd_cmd32le_cont(cmd, parm);
|
||||
DisableOsd();
|
||||
}
|
||||
|
||||
/* User_io related SPI functions */
|
||||
uint8_t spi_uio_cmd_cont(uint8_t cmd)
|
||||
{
|
||||
EnableIO();
|
||||
return spi_b(cmd);
|
||||
}
|
||||
|
||||
uint8_t spi_uio_cmd(uint8_t cmd)
|
||||
{
|
||||
uint8_t res = spi_uio_cmd_cont(cmd);
|
||||
DisableIO();
|
||||
return res;
|
||||
}
|
||||
|
||||
void spi_uio_cmd8_cont(uint8_t cmd, uint8_t parm)
|
||||
{
|
||||
EnableIO();
|
||||
spi8(cmd);
|
||||
spi8(parm);
|
||||
}
|
||||
|
||||
void spi_uio_cmd8(uint8_t cmd, uint8_t parm)
|
||||
{
|
||||
spi_uio_cmd8_cont(cmd, parm);
|
||||
DisableIO();
|
||||
}
|
||||
|
||||
void spi_uio_cmd16(uint8_t cmd, uint16_t parm)
|
||||
{
|
||||
spi_uio_cmd_cont(cmd);
|
||||
spi_w(parm);
|
||||
DisableIO();
|
||||
}
|
||||
|
||||
void spi_uio_cmd32(uint8_t cmd, uint32_t parm, int wide)
|
||||
{
|
||||
EnableIO();
|
||||
spi8(cmd);
|
||||
if (wide)
|
||||
{
|
||||
spi_w((uint16_t)parm);
|
||||
spi_w((uint16_t)(parm >> 16));
|
||||
}
|
||||
else
|
||||
{
|
||||
spi8(parm);
|
||||
spi8(parm >> 8);
|
||||
spi8(parm >> 16);
|
||||
spi8(parm >> 24);
|
||||
}
|
||||
DisableIO();
|
||||
}
|
||||
|
||||
void spi_n(uint8_t value, uint16_t cnt)
|
||||
{
|
||||
while (cnt--) spi8(value);
|
||||
}
|
||||
|
||||
void spi_read(uint8_t *addr, uint16_t len, int wide)
|
||||
{
|
||||
if (wide)
|
||||
{
|
||||
uint16_t len16 = len >> 1;
|
||||
uint16_t *a16 = (uint16_t*)addr;
|
||||
while (len16--) *a16++ = spi_w(0);
|
||||
if (len & 1) *((uint8_t*)a16) = spi_w(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (len--) *addr++ = spi_b(0);
|
||||
}
|
||||
}
|
||||
|
||||
void spi_write(const uint8_t *addr, uint16_t len, int wide)
|
||||
{
|
||||
if (wide)
|
||||
{
|
||||
uint16_t len16 = len >> 1;
|
||||
uint16_t *a16 = (uint16_t*)addr;
|
||||
while (len16--) spi_w(*a16++);
|
||||
if(len & 1) spi_w(*((uint8_t*)a16));
|
||||
}
|
||||
else
|
||||
{
|
||||
while (len--) spi8(*addr++);
|
||||
}
|
||||
}
|
||||
|
||||
void spi_block_read(uint8_t *addr, int wide)
|
||||
{
|
||||
spi_read(addr, 512, wide);
|
||||
}
|
||||
|
||||
void spi_block_write(const uint8_t *addr, int wide)
|
||||
{
|
||||
spi_write(addr, 512, wide);
|
||||
}
|
||||
|
||||
void spi_block_write_16be(const uint16_t *addr)
|
||||
{
|
||||
uint16_t len = 256;
|
||||
uint16_t tmp;
|
||||
while (len--)
|
||||
{
|
||||
tmp = *addr++;
|
||||
spi_w(SWAPW(tmp));
|
||||
}
|
||||
}
|
||||
|
||||
void spi_block_read_16be(uint16_t *addr)
|
||||
{
|
||||
uint16_t len = 256;
|
||||
uint16_t tmp;
|
||||
while (len--)
|
||||
{
|
||||
tmp = spi_w(0xFFFF);
|
||||
*addr++ = SWAPW(tmp);
|
||||
}
|
||||
}
|
||||
#include "spi.h"
|
||||
#include "hardware.h"
|
||||
#include "fpga_io.h"
|
||||
|
||||
#define SSPI_STROBE (1<<17)
|
||||
#define SSPI_ACK SSPI_STROBE
|
||||
|
||||
#define SSPI_FPGA_EN (1<<18)
|
||||
#define SSPI_OSD_EN (1<<19)
|
||||
#define SSPI_IO_EN (1<<20)
|
||||
#define SSPI_DM_EN (1<<21)
|
||||
|
||||
#define SWAPW(a) ((((a)<<8)&0xff00)|(((a)>>8)&0x00ff))
|
||||
|
||||
static void spi_en(uint32_t mask, uint32_t en)
|
||||
{
|
||||
uint32_t gpo = fpga_gpo_read() | 0x80000000;
|
||||
fpga_gpo_write(en ? gpo | mask : gpo & ~mask);
|
||||
}
|
||||
|
||||
uint16_t spi_w(uint16_t word)
|
||||
{
|
||||
uint32_t gpo = (fpga_gpo_read() & ~(0xFFFF | SSPI_STROBE)) | word;
|
||||
|
||||
fpga_gpo_write(gpo);
|
||||
fpga_gpo_write(gpo | SSPI_STROBE);
|
||||
|
||||
int gpi;
|
||||
do
|
||||
{
|
||||
gpi = fpga_gpi_read();
|
||||
if (gpi < 0)
|
||||
{
|
||||
printf("GPI[31]==1. FPGA is uninitialized?\n");
|
||||
return 0;
|
||||
}
|
||||
} while (!(gpi & SSPI_ACK));
|
||||
|
||||
fpga_gpo_write(gpo);
|
||||
|
||||
do
|
||||
{
|
||||
gpi = fpga_gpi_read();
|
||||
if (gpi < 0)
|
||||
{
|
||||
printf("GPI[31]==1. FPGA is uninitialized?\n");
|
||||
return 0;
|
||||
}
|
||||
} while (gpi & SSPI_ACK);
|
||||
|
||||
return (uint16_t)gpi;
|
||||
}
|
||||
|
||||
void spi_init(int enable)
|
||||
{
|
||||
(void)enable;
|
||||
printf("Init SPI.\n");
|
||||
}
|
||||
|
||||
uint8_t spi_b(uint8_t parm)
|
||||
{
|
||||
return (uint8_t)spi_w(parm);
|
||||
}
|
||||
|
||||
void EnableFpga()
|
||||
{
|
||||
spi_en(SSPI_FPGA_EN, 1);
|
||||
}
|
||||
|
||||
void DisableFpga()
|
||||
{
|
||||
spi_en(SSPI_FPGA_EN, 0);
|
||||
}
|
||||
|
||||
void EnableOsd()
|
||||
{
|
||||
spi_en(SSPI_OSD_EN, 1);
|
||||
}
|
||||
|
||||
void DisableOsd()
|
||||
{
|
||||
spi_en(SSPI_OSD_EN, 0);
|
||||
}
|
||||
|
||||
void EnableIO()
|
||||
{
|
||||
spi_en(SSPI_IO_EN, 1);
|
||||
}
|
||||
|
||||
void DisableIO()
|
||||
{
|
||||
spi_en(SSPI_IO_EN, 0);
|
||||
}
|
||||
|
||||
void EnableDMode()
|
||||
{
|
||||
spi_en(SSPI_DM_EN, 1);
|
||||
}
|
||||
|
||||
void DisableDMode()
|
||||
{
|
||||
spi_en(SSPI_DM_EN, 0);
|
||||
}
|
||||
|
||||
uint8_t spi_in()
|
||||
{
|
||||
return spi_b(0);
|
||||
}
|
||||
|
||||
void spi8(uint8_t parm)
|
||||
{
|
||||
spi_b(parm);
|
||||
}
|
||||
|
||||
void spi16(uint16_t parm)
|
||||
{
|
||||
spi8(parm >> 8);
|
||||
spi8(parm >> 0);
|
||||
}
|
||||
|
||||
void spi24(uint32_t parm)
|
||||
{
|
||||
spi8(parm >> 16);
|
||||
spi8(parm >> 8);
|
||||
spi8(parm >> 0);
|
||||
}
|
||||
|
||||
void spi32(uint32_t parm)
|
||||
{
|
||||
spi8(parm >> 24);
|
||||
spi8(parm >> 16);
|
||||
spi8(parm >> 8);
|
||||
spi8(parm >> 0);
|
||||
}
|
||||
|
||||
uint32_t spi32w(uint32_t parm)
|
||||
{
|
||||
uint32_t res;
|
||||
res = spi_w(parm);
|
||||
res |= (spi_w(parm>>16))<<16;
|
||||
return res;
|
||||
}
|
||||
|
||||
// little endian: lsb first
|
||||
void spi32le(uint32_t parm)
|
||||
{
|
||||
spi8(parm >> 0);
|
||||
spi8(parm >> 8);
|
||||
spi8(parm >> 16);
|
||||
spi8(parm >> 24);
|
||||
}
|
||||
|
||||
/* OSD related SPI functions */
|
||||
void spi_osd_cmd_cont(uint8_t cmd)
|
||||
{
|
||||
EnableOsd();
|
||||
spi8(cmd);
|
||||
}
|
||||
|
||||
void spi_osd_cmd(uint8_t cmd)
|
||||
{
|
||||
spi_osd_cmd_cont(cmd);
|
||||
DisableOsd();
|
||||
}
|
||||
|
||||
void spi_osd_cmd8_cont(uint8_t cmd, uint8_t parm)
|
||||
{
|
||||
EnableOsd();
|
||||
spi8(cmd);
|
||||
spi8(parm);
|
||||
}
|
||||
|
||||
void spi_osd_cmd8(uint8_t cmd, uint8_t parm)
|
||||
{
|
||||
spi_osd_cmd8_cont(cmd, parm);
|
||||
DisableOsd();
|
||||
}
|
||||
|
||||
void spi_osd_cmd16(uint8_t cmd, uint16_t parm)
|
||||
{
|
||||
EnableOsd();
|
||||
spi8(cmd);
|
||||
spi_w(parm);
|
||||
DisableOsd();
|
||||
}
|
||||
|
||||
void spi_osd_cmd32_cont(uint8_t cmd, uint32_t parm)
|
||||
{
|
||||
EnableOsd();
|
||||
spi8(cmd);
|
||||
spi32(parm);
|
||||
}
|
||||
|
||||
void spi_osd_cmd32(uint8_t cmd, uint32_t parm)
|
||||
{
|
||||
spi_osd_cmd32_cont(cmd, parm);
|
||||
DisableOsd();
|
||||
}
|
||||
|
||||
void spi_osd_cmd32le_cont(uint8_t cmd, uint32_t parm)
|
||||
{
|
||||
EnableOsd();
|
||||
spi8(cmd);
|
||||
spi32le(parm);
|
||||
}
|
||||
|
||||
void spi_osd_cmd32le(uint8_t cmd, uint32_t parm)
|
||||
{
|
||||
spi_osd_cmd32le_cont(cmd, parm);
|
||||
DisableOsd();
|
||||
}
|
||||
|
||||
/* User_io related SPI functions */
|
||||
uint8_t spi_uio_cmd_cont(uint8_t cmd)
|
||||
{
|
||||
EnableIO();
|
||||
return spi_b(cmd);
|
||||
}
|
||||
|
||||
uint8_t spi_uio_cmd(uint8_t cmd)
|
||||
{
|
||||
uint8_t res = spi_uio_cmd_cont(cmd);
|
||||
DisableIO();
|
||||
return res;
|
||||
}
|
||||
|
||||
void spi_uio_cmd8_cont(uint8_t cmd, uint8_t parm)
|
||||
{
|
||||
EnableIO();
|
||||
spi8(cmd);
|
||||
spi8(parm);
|
||||
}
|
||||
|
||||
void spi_uio_cmd8(uint8_t cmd, uint8_t parm)
|
||||
{
|
||||
spi_uio_cmd8_cont(cmd, parm);
|
||||
DisableIO();
|
||||
}
|
||||
|
||||
void spi_uio_cmd16(uint8_t cmd, uint16_t parm)
|
||||
{
|
||||
spi_uio_cmd_cont(cmd);
|
||||
spi_w(parm);
|
||||
DisableIO();
|
||||
}
|
||||
|
||||
void spi_uio_cmd32(uint8_t cmd, uint32_t parm, int wide)
|
||||
{
|
||||
EnableIO();
|
||||
spi8(cmd);
|
||||
if (wide)
|
||||
{
|
||||
spi_w((uint16_t)parm);
|
||||
spi_w((uint16_t)(parm >> 16));
|
||||
}
|
||||
else
|
||||
{
|
||||
spi8(parm);
|
||||
spi8(parm >> 8);
|
||||
spi8(parm >> 16);
|
||||
spi8(parm >> 24);
|
||||
}
|
||||
DisableIO();
|
||||
}
|
||||
|
||||
void spi_n(uint8_t value, uint16_t cnt)
|
||||
{
|
||||
while (cnt--) spi8(value);
|
||||
}
|
||||
|
||||
void spi_read(uint8_t *addr, uint16_t len, int wide)
|
||||
{
|
||||
if (wide)
|
||||
{
|
||||
uint16_t len16 = len >> 1;
|
||||
uint16_t *a16 = (uint16_t*)addr;
|
||||
while (len16--) *a16++ = spi_w(0);
|
||||
if (len & 1) *((uint8_t*)a16) = spi_w(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
while (len--) *addr++ = spi_b(0);
|
||||
}
|
||||
}
|
||||
|
||||
void spi_write(const uint8_t *addr, uint16_t len, int wide)
|
||||
{
|
||||
if (wide)
|
||||
{
|
||||
uint16_t len16 = len >> 1;
|
||||
uint16_t *a16 = (uint16_t*)addr;
|
||||
while (len16--) spi_w(*a16++);
|
||||
if(len & 1) spi_w(*((uint8_t*)a16));
|
||||
}
|
||||
else
|
||||
{
|
||||
while (len--) spi8(*addr++);
|
||||
}
|
||||
}
|
||||
|
||||
void spi_block_read(uint8_t *addr, int wide)
|
||||
{
|
||||
spi_read(addr, 512, wide);
|
||||
}
|
||||
|
||||
void spi_block_write(const uint8_t *addr, int wide)
|
||||
{
|
||||
spi_write(addr, 512, wide);
|
||||
}
|
||||
|
||||
void spi_block_write_16be(const uint16_t *addr)
|
||||
{
|
||||
uint16_t len = 256;
|
||||
uint16_t tmp;
|
||||
while (len--)
|
||||
{
|
||||
tmp = *addr++;
|
||||
spi_w(SWAPW(tmp));
|
||||
}
|
||||
}
|
||||
|
||||
void spi_block_read_16be(uint16_t *addr)
|
||||
{
|
||||
uint16_t len = 256;
|
||||
uint16_t tmp;
|
||||
while (len--)
|
||||
{
|
||||
tmp = spi_w(0xFFFF);
|
||||
*addr++ = SWAPW(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
122
spi.h
122
spi.h
@@ -1,61 +1,61 @@
|
||||
#ifndef SPI_H
|
||||
#define SPI_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/* main init functions */
|
||||
void spi_init(int enable);
|
||||
|
||||
/* chip select functions */
|
||||
void EnableFpga();
|
||||
void DisableFpga();
|
||||
void EnableOsd();
|
||||
void DisableOsd();
|
||||
void EnableDMode();
|
||||
void DisableDMode();
|
||||
void EnableIO();
|
||||
void DisableIO();
|
||||
|
||||
// base functions
|
||||
uint8_t spi_b(uint8_t parm);
|
||||
uint16_t spi_w(uint16_t word);
|
||||
|
||||
// input only helper
|
||||
uint8_t spi_in();
|
||||
|
||||
void spi8(uint8_t parm);
|
||||
void spi16(uint16_t parm);
|
||||
void spi24(uint32_t parm);
|
||||
void spi32(uint32_t parm);
|
||||
void spi32le(uint32_t parm);
|
||||
void spi_n(uint8_t value, uint16_t cnt);
|
||||
uint32_t spi32w(uint32_t parm);
|
||||
|
||||
/* block transfer functions */
|
||||
void spi_block_read(uint8_t *addr, int wide);
|
||||
void spi_read(uint8_t *addr, uint16_t len, int wide);
|
||||
void spi_block_write(const uint8_t *addr, int wide);
|
||||
void spi_write(const uint8_t *addr, uint16_t len, int wide);
|
||||
void spi_block_write_16be(const uint16_t *addr);
|
||||
void spi_block_read_16be(uint16_t *addr);
|
||||
|
||||
/* OSD related SPI functions */
|
||||
void spi_osd_cmd_cont(uint8_t cmd);
|
||||
void spi_osd_cmd(uint8_t cmd);
|
||||
void spi_osd_cmd8_cont(uint8_t cmd, uint8_t parm);
|
||||
void spi_osd_cmd8(uint8_t cmd, uint8_t parm);
|
||||
void spi_osd_cmd16(uint8_t cmd, uint16_t parm);
|
||||
void spi_osd_cmd32_cont(uint8_t cmd, uint32_t parm);
|
||||
void spi_osd_cmd32(uint8_t cmd, uint32_t parm);
|
||||
void spi_osd_cmd32le_cont(uint8_t cmd, uint32_t parm);
|
||||
void spi_osd_cmd32le(uint8_t cmd, uint32_t parm);
|
||||
|
||||
/* User_io related SPI functions */
|
||||
uint8_t spi_uio_cmd_cont(uint8_t cmd);
|
||||
uint8_t spi_uio_cmd(uint8_t cmd);
|
||||
void spi_uio_cmd8(uint8_t cmd, uint8_t parm);
|
||||
void spi_uio_cmd8_cont(uint8_t cmd, uint8_t parm);
|
||||
void spi_uio_cmd16(uint8_t cmd, uint16_t parm);
|
||||
void spi_uio_cmd32(uint8_t cmd, uint32_t parm, int wide);
|
||||
|
||||
#endif // SPI_H
|
||||
#ifndef SPI_H
|
||||
#define SPI_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
/* main init functions */
|
||||
void spi_init(int enable);
|
||||
|
||||
/* chip select functions */
|
||||
void EnableFpga();
|
||||
void DisableFpga();
|
||||
void EnableOsd();
|
||||
void DisableOsd();
|
||||
void EnableDMode();
|
||||
void DisableDMode();
|
||||
void EnableIO();
|
||||
void DisableIO();
|
||||
|
||||
// base functions
|
||||
uint8_t spi_b(uint8_t parm);
|
||||
uint16_t spi_w(uint16_t word);
|
||||
|
||||
// input only helper
|
||||
uint8_t spi_in();
|
||||
|
||||
void spi8(uint8_t parm);
|
||||
void spi16(uint16_t parm);
|
||||
void spi24(uint32_t parm);
|
||||
void spi32(uint32_t parm);
|
||||
void spi32le(uint32_t parm);
|
||||
void spi_n(uint8_t value, uint16_t cnt);
|
||||
uint32_t spi32w(uint32_t parm);
|
||||
|
||||
/* block transfer functions */
|
||||
void spi_block_read(uint8_t *addr, int wide);
|
||||
void spi_read(uint8_t *addr, uint16_t len, int wide);
|
||||
void spi_block_write(const uint8_t *addr, int wide);
|
||||
void spi_write(const uint8_t *addr, uint16_t len, int wide);
|
||||
void spi_block_write_16be(const uint16_t *addr);
|
||||
void spi_block_read_16be(uint16_t *addr);
|
||||
|
||||
/* OSD related SPI functions */
|
||||
void spi_osd_cmd_cont(uint8_t cmd);
|
||||
void spi_osd_cmd(uint8_t cmd);
|
||||
void spi_osd_cmd8_cont(uint8_t cmd, uint8_t parm);
|
||||
void spi_osd_cmd8(uint8_t cmd, uint8_t parm);
|
||||
void spi_osd_cmd16(uint8_t cmd, uint16_t parm);
|
||||
void spi_osd_cmd32_cont(uint8_t cmd, uint32_t parm);
|
||||
void spi_osd_cmd32(uint8_t cmd, uint32_t parm);
|
||||
void spi_osd_cmd32le_cont(uint8_t cmd, uint32_t parm);
|
||||
void spi_osd_cmd32le(uint8_t cmd, uint32_t parm);
|
||||
|
||||
/* User_io related SPI functions */
|
||||
uint8_t spi_uio_cmd_cont(uint8_t cmd);
|
||||
uint8_t spi_uio_cmd(uint8_t cmd);
|
||||
void spi_uio_cmd8(uint8_t cmd, uint8_t parm);
|
||||
void spi_uio_cmd8_cont(uint8_t cmd, uint8_t parm);
|
||||
void spi_uio_cmd16(uint8_t cmd, uint16_t parm);
|
||||
void spi_uio_cmd32(uint8_t cmd, uint32_t parm, int wide);
|
||||
|
||||
#endif // SPI_H
|
||||
|
||||
2790
tzx2wav.cpp
2790
tzx2wav.cpp
File diff suppressed because it is too large
Load Diff
@@ -1,3 +1,3 @@
|
||||
#include "file_io.h"
|
||||
|
||||
int tzx2csw(fileTYPE *f);
|
||||
#include "file_io.h"
|
||||
|
||||
int tzx2csw(fileTYPE *f);
|
||||
|
||||
@@ -702,8 +702,8 @@ void user_io_digital_joystick(unsigned char joystick, uint32_t map, int newdir)
|
||||
return;
|
||||
}
|
||||
|
||||
spi_uio_cmd_cont((joy < 2) ? (UIO_JOYSTICK0 + joy) : (UIO_JOYSTICK2 + joy - 2));
|
||||
spi_w(map);
|
||||
spi_uio_cmd_cont((joy < 2) ? (UIO_JOYSTICK0 + joy) : (UIO_JOYSTICK2 + joy - 2));
|
||||
spi_w(map);
|
||||
if(joy_bcount>12) spi_w(map>>16);
|
||||
DisableIO();
|
||||
|
||||
|
||||
50
user_io.h
50
user_io.h
@@ -161,10 +161,10 @@
|
||||
#define UIO_PRIORITY_KEYBOARD 0
|
||||
#define UIO_PRIORITY_GAMEPAD 1
|
||||
|
||||
#define EMU_NONE 0
|
||||
#define EMU_MOUSE 1
|
||||
#define EMU_JOY0 2
|
||||
#define EMU_JOY1 3
|
||||
#define EMU_NONE 0
|
||||
#define EMU_MOUSE 1
|
||||
#define EMU_JOY0 2
|
||||
#define EMU_JOY1 3
|
||||
|
||||
// serial status data type returned from the core
|
||||
typedef struct {
|
||||
@@ -178,7 +178,7 @@ typedef struct {
|
||||
void user_io_init(const char *path);
|
||||
unsigned char user_io_core_type();
|
||||
char is_minimig();
|
||||
char is_archie();
|
||||
char is_archie();
|
||||
char is_sharpmz();
|
||||
void user_io_poll();
|
||||
char user_io_menu_button();
|
||||
@@ -195,7 +195,7 @@ const char *user_io_get_core_name_ex();
|
||||
char is_menu_core();
|
||||
char is_x86_core();
|
||||
char is_snes_core();
|
||||
char has_menu();
|
||||
char has_menu();
|
||||
|
||||
const char *get_image_name(int i);
|
||||
|
||||
@@ -212,42 +212,42 @@ void user_io_eth_receive_tx_frame(uint8_t *, uint16_t);
|
||||
void user_io_mouse(unsigned char b, int16_t x, int16_t y);
|
||||
void user_io_kbd(uint16_t key, int press);
|
||||
char* user_io_create_config_name();
|
||||
int user_io_get_joy_transl();
|
||||
int user_io_get_joy_transl();
|
||||
void user_io_digital_joystick(unsigned char, uint32_t, int);
|
||||
void user_io_analog_joystick(unsigned char, char, char);
|
||||
void user_io_set_joyswap(int swap);
|
||||
int user_io_get_joyswap();
|
||||
void user_io_set_joyswap(int swap);
|
||||
int user_io_get_joyswap();
|
||||
char user_io_osd_is_visible();
|
||||
void user_io_send_buttons(char);
|
||||
void parse_video_mode();
|
||||
void parse_video_mode();
|
||||
|
||||
void user_io_set_index(unsigned char index);
|
||||
unsigned char user_io_ext_idx(char *, char*);
|
||||
|
||||
void user_io_check_reset(unsigned short modifiers, char useKeys);
|
||||
|
||||
void user_io_rtc_reset();
|
||||
|
||||
int hasAPI1_5();
|
||||
|
||||
const char* get_rbf_dir();
|
||||
const char* get_rbf_name();
|
||||
|
||||
void user_io_check_reset(unsigned short modifiers, char useKeys);
|
||||
|
||||
void user_io_rtc_reset();
|
||||
|
||||
int hasAPI1_5();
|
||||
|
||||
const char* get_rbf_dir();
|
||||
const char* get_rbf_name();
|
||||
|
||||
int user_io_get_scaler_flt();
|
||||
char* user_io_get_scaler_coeff();
|
||||
void user_io_set_scaler_flt(int n);
|
||||
void user_io_set_scaler_coeff(char *name);
|
||||
|
||||
|
||||
void user_io_minimig_set_adjust(char n);
|
||||
char user_io_minimig_get_adjust();
|
||||
|
||||
#define HomeDir (is_minimig() ? "Amiga" : is_archie() ? "Archie" : user_io_get_core_name())
|
||||
|
||||
|
||||
#define HomeDir (is_minimig() ? "Amiga" : is_archie() ? "Archie" : user_io_get_core_name())
|
||||
|
||||
int GetUARTMode();
|
||||
int GetMidiLinkMode();
|
||||
void SetMidiLinkMode(int mode);
|
||||
|
||||
|
||||
void set_volume(int cmd);
|
||||
int get_volume();
|
||||
|
||||
|
||||
#endif // USER_IO_H
|
||||
|
||||
Reference in New Issue
Block a user