//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit1.h" //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; unsigned char inp(unsigned short addr) { _EDX = addr ; __emit__(0xEC); // in al, dx return _AL; } void outp(unsigned short addr,unsigned char data){ _EDX = addr; _AL = data; __emit__(0xEE); // out dx, al } //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { } //--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { if(OpenDialog1->Execute() == true){ AnsiString CurrentFile = OpenDialog1->FileName; Image1->Picture->LoadFromFile(CurrentFile); } } //--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender) { Byte cmdport = inp(0x37a); cmdport &= 0xcf; Byte a; for(int y=0;y<480;y++){ for(int x=0;x<768;x++){ long c; if(y < 240){ c = Image1->Canvas->Pixels[x][y*2+1]; } else{ c = Image1->Canvas->Pixels[x][(y-240)*2]; } Byte R,G,B; R = (c >> 0 ) & 0xff; G = (c >> 8 ) & 0xff; B = (c >> 16) & 0xff; while((inp(0x379) & 0x80) == 0x00){ // BUSYがHならWAIT } a = +0.299*R +0.587*G +0.114*B; outp(0x378,a); outp(0x37a, cmdport | 0x01); //STB信号をLにする outp(0x37a, cmdport & 0xfe); //STB信号をHにする } } } //---------------------------------------------------------------------------