- while( avail > 3 )
- {
- ((Uint32*)Buffer)[pos] = ((Uint32*)term->InputBuffer)[term->InputRead];
- pos ++;
- term->InputRead ++;
- term->InputRead %= MAX_INPUT_CHARS32;
- avail -= 4;
- }
+ avail = term->InputWrite - term->InputRead;
+ if(avail < 0)
+ avail += MAX_INPUT_CHARS32;
+ if(avail > Length - pos)
+ avail = Length/4 - pos;
+
+
+ while( avail -- )
+ {
+ ((Uint32*)Buffer)[pos] = ((Uint32*)term->InputBuffer)[term->InputRead];
+ pos ++;
+ term->InputRead ++;
+ term->InputRead %= MAX_INPUT_CHARS32;