Initial commit
This commit is contained in:
commit
8fe453d373
13 changed files with 344 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
*.~*
|
||||
BIN
MainWindow.dcu
Executable file
BIN
MainWindow.dcu
Executable file
Binary file not shown.
BIN
MainWindow.dfm
Executable file
BIN
MainWindow.dfm
Executable file
Binary file not shown.
71
MainWindow.pas
Executable file
71
MainWindow.pas
Executable file
|
|
@ -0,0 +1,71 @@
|
|||
unit MainWindow;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
||||
StdCtrls, Picogus;
|
||||
|
||||
type
|
||||
TPicoGusForm = class(TForm)
|
||||
CDImageList: TListBox;
|
||||
Label1: TLabel;
|
||||
LblFirmwareVersion: TLabel;
|
||||
BtnLoad: TButton;
|
||||
BtnRefresh: TButton;
|
||||
procedure FormCreate(Sender: TObject);
|
||||
procedure CDImageListDblClick(Sender: TObject);
|
||||
procedure BtnRefreshClick(Sender: TObject);
|
||||
procedure BtnLoadClick(Sender: TObject);
|
||||
private
|
||||
procedure Refresh;
|
||||
procedure LoadCD;
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
PicoGusForm: TPicoGusForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.DFM}
|
||||
|
||||
procedure TPicoGusForm.Refresh;
|
||||
begin
|
||||
if DetectPicoGUS then
|
||||
begin
|
||||
Self.LblFirmwareVersion.Caption := ReadModeString(MODE_FWSTRING);
|
||||
Self.CDImageList.Items := ReadCDList;
|
||||
Self.CDImageList.ItemIndex := SelectedCD - 1;
|
||||
end
|
||||
else
|
||||
Self.LblFirmwareVersion.Caption := 'PicoGUS not detected!';
|
||||
end;
|
||||
|
||||
procedure TPicoGusForm.LoadCD;
|
||||
begin
|
||||
SelectCD(CDImageList.ItemIndex + 1);
|
||||
end;
|
||||
|
||||
procedure TPicoGusForm.FormCreate(Sender: TObject);
|
||||
begin
|
||||
Self.Refresh;
|
||||
end;
|
||||
|
||||
procedure TPicoGusForm.CDImageListDblClick(Sender: TObject);
|
||||
begin
|
||||
Self.LoadCD;
|
||||
end;
|
||||
|
||||
procedure TPicoGusForm.BtnRefreshClick(Sender: TObject);
|
||||
begin
|
||||
Self.Refresh;
|
||||
end;
|
||||
|
||||
procedure TPicoGusForm.BtnLoadClick(Sender: TObject);
|
||||
begin
|
||||
Self.LoadCD;
|
||||
end;
|
||||
|
||||
end.
|
||||
BIN
Picogus.dcu
Executable file
BIN
Picogus.dcu
Executable file
Binary file not shown.
146
Picogus.pas
Executable file
146
Picogus.pas
Executable file
|
|
@ -0,0 +1,146 @@
|
|||
unit Picogus;
|
||||
|
||||
interface
|
||||
uses classes, windows;
|
||||
const
|
||||
MODE_MAGIC = $00;
|
||||
MODE_PROTOCOL = $01;
|
||||
MODE_FWSTRING = $02;
|
||||
MODE_BOOTMODE = $03;
|
||||
|
||||
MODE_CDPORT = $60;
|
||||
MODE_CDSTATUS = $61;
|
||||
MODE_CDERROR = $62;
|
||||
MODE_CDLIST = $63;
|
||||
MODE_CDLOAD = $64;
|
||||
MODE_CDNAME = $65;
|
||||
MODE_CDAUTOADV = $66;
|
||||
|
||||
function DetectPicoGUS: Boolean;
|
||||
function ReadModeString(mode: byte): string;
|
||||
function ReadCDList: TStringList;
|
||||
function SelectedCD: Byte;
|
||||
procedure SelectCD(index: Byte);
|
||||
|
||||
implementation
|
||||
const
|
||||
CONTROL_PORT = $1d0;
|
||||
DATA_PORT_LOW = $1d1;
|
||||
DATA_PORT_HIGH = $1d2;
|
||||
PICOGUS_PROTOCOL_VER = 4;
|
||||
|
||||
CDSTATUS_ERROR = $ff;
|
||||
CDSTATUS_READY = 2;
|
||||
|
||||
procedure outb(port: Integer; val: byte);
|
||||
begin
|
||||
asm
|
||||
MOV EDX, port
|
||||
MOV AL, val
|
||||
OUT DX, AL
|
||||
end;
|
||||
end;
|
||||
|
||||
function inb(port: Integer): byte;
|
||||
var
|
||||
b: byte;
|
||||
begin
|
||||
asm
|
||||
MOV EDX, port
|
||||
IN AL, DX
|
||||
MOV b, AL
|
||||
end;
|
||||
Result := b;
|
||||
end;
|
||||
procedure SetMode(mode: byte);
|
||||
begin
|
||||
outb(CONTROL_PORT, $cc);
|
||||
outb(CONTROL_PORT, mode);
|
||||
end;
|
||||
|
||||
function DetectPicoGUS: Boolean;
|
||||
begin
|
||||
SetMode(MODE_MAGIC);
|
||||
Result := (inb(DATA_PORT_HIGH) = $dd)
|
||||
end;
|
||||
|
||||
function ReadDataPortString: string;
|
||||
var
|
||||
b: byte;
|
||||
begin
|
||||
Result := '';
|
||||
b := inb(DATA_PORT_HIGH);
|
||||
while b <> 0 do
|
||||
begin
|
||||
Result := Result + Chr(b);
|
||||
if b = 4 then Break;
|
||||
b := inb(DATA_PORT_HIGH);
|
||||
end;
|
||||
end;
|
||||
|
||||
function ReadModeString(mode: byte): string;
|
||||
begin
|
||||
SetMode(mode);
|
||||
Result := ReadDataPortString;
|
||||
end;
|
||||
|
||||
function ReadModeStrings(mode: byte): TStringList;
|
||||
var
|
||||
str: string;
|
||||
begin
|
||||
Result := TStringList.Create;
|
||||
SetMode(mode);
|
||||
repeat
|
||||
str := ReadDataPortString;
|
||||
if str = #4 then Break;
|
||||
Result.Add(str);
|
||||
until False;
|
||||
end;
|
||||
|
||||
function AwaitCDStatus: byte;
|
||||
var
|
||||
i: Integer;
|
||||
begin
|
||||
Sleep(10);
|
||||
SetMode(MODE_CDSTATUS);
|
||||
for i := 0 to 100 do
|
||||
begin
|
||||
Result := inb(DATA_PORT_HIGH);
|
||||
if (Result = CDSTATUS_READY) or (Result = CDSTATUS_ERROR) then Break;
|
||||
Sleep(1);
|
||||
end;
|
||||
end;
|
||||
|
||||
function ReadCDList: TStringList;
|
||||
var
|
||||
status: Byte;
|
||||
begin
|
||||
SetMode(MODE_CDLIST);
|
||||
status := AwaitCDStatus;
|
||||
if status = CDSTATUS_READY then
|
||||
Result := ReadModeStrings(MODE_CDLIST)
|
||||
else
|
||||
begin
|
||||
Result := TStringList.Create;
|
||||
if status = CDSTATUS_ERROR then
|
||||
begin;
|
||||
Result.Add('Error reading list:');
|
||||
Result.Add(ReadModeString(MODE_CDERROR));
|
||||
end
|
||||
else
|
||||
Result.Add('Timed out reading list');
|
||||
end;
|
||||
end;
|
||||
|
||||
function SelectedCD: Byte;
|
||||
begin
|
||||
SetMode(MODE_CDLOAD);
|
||||
Result := inb(DATA_PORT_HIGH);
|
||||
end;
|
||||
|
||||
procedure SelectCD(index: Byte);
|
||||
begin
|
||||
SetMode(MODE_CDLOAD);
|
||||
outb(DATA_PORT_HIGH, index);
|
||||
end;
|
||||
end.
|
||||
BIN
WinPicoGUS.dcu
Executable file
BIN
WinPicoGUS.dcu
Executable file
Binary file not shown.
BIN
WinPicoGUS.dfm
Executable file
BIN
WinPicoGUS.dfm
Executable file
Binary file not shown.
80
WinPicoGUS.dof
Executable file
80
WinPicoGUS.dof
Executable file
|
|
@ -0,0 +1,80 @@
|
|||
[Compiler]
|
||||
A=1
|
||||
B=0
|
||||
C=1
|
||||
D=1
|
||||
E=0
|
||||
F=0
|
||||
G=1
|
||||
H=1
|
||||
I=1
|
||||
J=1
|
||||
K=0
|
||||
L=1
|
||||
M=0
|
||||
N=1
|
||||
O=1
|
||||
P=1
|
||||
Q=0
|
||||
R=0
|
||||
S=0
|
||||
T=0
|
||||
U=0
|
||||
V=1
|
||||
W=0
|
||||
X=1
|
||||
Y=0
|
||||
Z=1
|
||||
ShowHints=1
|
||||
ShowWarnings=1
|
||||
UnitAliases=WinTypes=Windows;WinProcs=Windows;DbiTypes=BDE;DbiProcs=BDE;DbiErrs=BDE;
|
||||
|
||||
[Linker]
|
||||
MapFile=0
|
||||
OutputObjs=0
|
||||
ConsoleApp=1
|
||||
DebugInfo=0
|
||||
MinStackSize=16384
|
||||
MaxStackSize=1048576
|
||||
ImageBase=4194304
|
||||
ExeDescription=
|
||||
|
||||
[Directories]
|
||||
OutputDir=
|
||||
UnitOutputDir=
|
||||
SearchPath=
|
||||
Packages=
|
||||
Conditionals=
|
||||
DebugSourceDirs=
|
||||
UsePackages=0
|
||||
|
||||
[Parameters]
|
||||
RunParams=
|
||||
HostApplication=
|
||||
|
||||
[Version Info]
|
||||
IncludeVerInfo=0
|
||||
AutoIncBuild=0
|
||||
MajorVer=1
|
||||
MinorVer=0
|
||||
Release=0
|
||||
Build=0
|
||||
Debug=0
|
||||
PreRelease=0
|
||||
Special=0
|
||||
Private=0
|
||||
DLL=0
|
||||
Locale=1033
|
||||
CodePage=1252
|
||||
|
||||
[Version Info Keys]
|
||||
CompanyName=
|
||||
FileDescription=
|
||||
FileVersion=1.0.0.0
|
||||
InternalName=
|
||||
LegalCopyright=
|
||||
LegalTrademarks=
|
||||
OriginalFilename=
|
||||
ProductName=
|
||||
ProductVersion=1.0.0.0
|
||||
Comments=
|
||||
14
WinPicoGUS.dpr
Executable file
14
WinPicoGUS.dpr
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
program WinPicoGUS;
|
||||
|
||||
uses
|
||||
Forms,
|
||||
MainWindow in 'MainWindow.pas' {PicoGusForm},
|
||||
Picogus in 'Picogus.pas';
|
||||
|
||||
{$R *.RES}
|
||||
|
||||
begin
|
||||
Application.Initialize;
|
||||
Application.CreateForm(TPicoGusForm, PicoGusForm);
|
||||
Application.Run;
|
||||
end.
|
||||
BIN
WinPicoGUS.exe
Executable file
BIN
WinPicoGUS.exe
Executable file
Binary file not shown.
32
WinPicoGUS.pas
Executable file
32
WinPicoGUS.pas
Executable file
|
|
@ -0,0 +1,32 @@
|
|||
unit WinPicoGUS;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
|
||||
StdCtrls, Picogus;
|
||||
|
||||
type
|
||||
TPicoGusForm = class(TForm)
|
||||
CDImageList: TListBox;
|
||||
Label1: TLabel;
|
||||
LblFirmwareVersion: TLabel;
|
||||
private
|
||||
{ Private declarations }
|
||||
public
|
||||
{ Public declarations }
|
||||
end;
|
||||
|
||||
var
|
||||
PicoGusForm: TPicoGusForm;
|
||||
|
||||
implementation
|
||||
|
||||
{$R *.DFM}
|
||||
|
||||
initialization
|
||||
if DetectPicoGUS then
|
||||
PicoGusForm.LblFirmwareVersion.Caption := ReadModeString(MODE_FWSTRING)
|
||||
else
|
||||
PicoGusForm.LblFirmwareVersion.Caption := 'PicoGUS not detected!';
|
||||
end.
|
||||
BIN
WinPicoGUS.res
Executable file
BIN
WinPicoGUS.res
Executable file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue