
{$X+}
uses tos,system;

const
MIDI = $03;
MIDIBUFFSIZE = 512;

VAR
key_ptr,
MIDI_PTR       :IORECORDPTR;
A              :longint;
MIDI_BUFF_ADR  :pointer;
BLANK          :array[0..MIDIBUFFSIZE] OF WORD;
X              :INTEGER;
ESCAPE         :BOOLEAN;
xx             :longint;
b              :^byte;
adr1,adr2      :longint;


begin;
MIDI_PTR := IOREC(2);
MIDI_BUFF_ADR := ADDR(BLANK[0]);
LONGINT(POINTER(MIDI_ptr)^) := LONGINT(MIDI_BUFF_ADR);
MIDI_PTR^.IBUFSIZ := MIDIBUFFSIZE;
MIDI_PTR^.IBUFHD := 0;
MIDI_PTR^.IBUFTL := 0;
MIDI_PTR^.IBUFLOW := 0;
MIDI_PTR^.IBUFHI := ( MIDIBUFFSIZE - 1 );
key_ptr := iorec(1);
KEY_PTR^.IBUFHD := 0;
KEY_PTR^.IBUFtl := 0;

repeat
{adr1:=longint(pointer(midi_ptr)^);
adr2:=midi_ptr^.ibufhd;
b :=pointer(longint(adr1 + adr2));         
writeln(b^);}
until keypressed;

midiws(midibuffsize-1,midi_buff_adr);

LONGINT(POINTER(MIDI_PTR)^) := LONGINT(3474);
MIDI_PTR^.IBUFSIZ := 128;
MIDI_PTR^.IBUFHD := 0;
MIDI_PTR^.IBUFTL := 0;
MIDI_PTR^.IBUFLOW := 0;
MIDI_PTR^.IBUFHI := 127;
KEY_PTR^.IBUFHD := 0;
KEY_PTR^.IBUFTL := 0;

FOR X := 0 to MIDIBUFFSIZE do
begin;
xx := BLANK[x];
WRITELN((XX DIV 256)AND 255);
WRITELN((XX MOD 256)AND 255) ;
IF boolean(xx) = FALSE then exit;
readkey;
end;



end.
