- tex files

This commit is contained in:
peter 1998-09-10 16:36:33 +00:00
parent 4e7516e897
commit a2178ba266
13 changed files with 0 additions and 749 deletions

View File

@ -1,56 +0,0 @@
\begin{FPCList}
\item[Example]
\begin{verbatim}
Program buffer;
uses go32;
procedure dosalloc(var selector : word; var segment : word; size : longint);
var res : longint;
begin
res := global_dos_alloc(size);
selector := word(res);
segment := word(res shr 16);
end;
procedure dosfree(selector : word);
begin
global_dos_free(selector);
end;
type VBEInfoBuf = record
Signature : array[0..3] of char;
Version : Word;
reserved : array[0..505] of byte;
end;
var selector,
segment : Word;
r : trealregs;
infobuf : VBEInfoBuf;
begin
fillchar(r, sizeof(r), 0);
fillchar(infobuf, sizeof(VBEInfoBuf), 0);
dosalloc(selector, segment, sizeof(VBEInfoBuf));
if (int31error<>0) then begin
Writeln('Error while allocating real mode memory, halting');
halt;
end;
infobuf.Signature := 'VBE2';
dosmemput(segment, 0, infobuf, sizeof(infobuf));
r.ax := $4f00; r.es := segment;
realintr($10, r);
dosmemget(segment, 0, infobuf, sizeof(infobuf));
dosfree(selector);
if (r.ax <> $4f) then begin
Writeln('VBE BIOS extension not available, function call failed');
halt;
end;
if (infobuf.signature[0] = 'V') and (infobuf.signature[1] = 'E') and
(infobuf.signature[2] = 'S') and (infobuf.signature[3] = 'A') then begin
Writeln('VBE version ', hi(infobuf.version), '.', lo(infobuf.version), ' detected');
end;
end.\end{verbatim}
\end{FPCList}

View File

@ -1,151 +0,0 @@
\begin{FPCList}
\item[Example]
\begin{verbatim}
Program callback;
uses crt,
go32;
const mouseint = $33;
var mouse_regs : trealregs;
mouse_seginfo : tseginfo;
var mouse_numbuttons : longint;
mouse_action : word;
mouse_x, mouse_y : Word;
mouse_b : Word;
userproc_installed : Longbool;
userproc_length : Longint;
userproc_proc : pointer;
{$ASMMODE DIRECT}
procedure callback_handler; assembler;
asm
pushw %es
pushw %ds
pushl %edi
pushl %esi
cmpl $1, _USERPROC_INSTALLED
je .LNoCallback
pushal
movw %es, %ax
movw %ax, %ds
movw U_GO32_DOSMEMSELECTOR, %ax
movw %ax, %fs
call *_USERPROC_PROC
popal
.LNoCallback:
popl %esi
popl %edi
popw %ds
popw %es
movl (%esi), %eax
movl %eax, %es: 42(%edi)
addw $4, %es: 46(%edi)
iret
end;
procedure mouse_dummy; begin end;
procedure textuserproc;
begin
mouse_b := mouse_regs.bx;
mouse_x := (mouse_regs.cx shr 3) + 1;
mouse_y := (mouse_regs.dx shr 3) + 1;
end;
procedure install_mouse (userproc : pointer;
userproclen : longint);
var r : trealregs;
begin
r.eax := $0; realintr(mouseint, r);
if (r.eax <> $FFFF) then begin
Writeln('No Mircosoft compatible mouse found');
Write('A Mircosoft compatible mouse driver is');
writeln(' necessary to run this example');
halt;
end;
if (r.bx = $ffff) then mouse_numbuttons := 2
else mouse_numbuttons := r.bx;
Writeln(mouse_numbuttons,
' button Mircosoft compatible mouse found.');
if (userproc <> nil) then begin
userproc_proc := userproc;
userproc_installed := true;
userproc_length := userproclen;
lock_code(userproc_proc, userproc_length);
end else begin
userproc_proc := nil;
userproc_length := 0;
userproc_installed := false;
end;
lock_data(mouse_x, sizeof(mouse_x));
lock_data(mouse_y, sizeof(mouse_y));
lock_data(mouse_b, sizeof(mouse_b));
lock_data(mouse_action, sizeof(mouse_action));
lock_data(userproc_installed, sizeof(userproc_installed));
lock_data(@userproc_proc, sizeof(userproc_proc));
lock_data(mouse_regs, sizeof(mouse_regs));
lock_data(mouse_seginfo, sizeof(mouse_seginfo));
lock_code(@callback_handler,
longint(@mouse_dummy)
- longint(@callback_handler));
get_rm_callback(@callback_handler, mouse_regs, mouse_seginfo);
r.eax := $0c; r.ecx := $7f; r.edx := longint(mouse_seginfo.offset);
r.es := mouse_seginfo.segment;
realintr(mouseint, r);
r.eax := $01;
realintr(mouseint, r);
end;
procedure remove_mouse;
var r : trealregs;
begin
r.eax := $02; realintr(mouseint, r);
r.eax := $0c; r.ecx := 0; r.edx := 0; r.es := 0;
realintr(mouseint, r);
free_rm_callback(mouse_seginfo);
if (userproc_installed) then begin
unlock_code(userproc_proc, userproc_length);
userproc_proc := nil;
userproc_length := 0;
userproc_installed := false;
end;
unlock_data(mouse_x, sizeof(mouse_x));
unlock_data(mouse_y, sizeof(mouse_y));
unlock_data(mouse_b, sizeof(mouse_b));
unlock_data(mouse_action, sizeof(mouse_action));
unlock_data(@userproc_proc, sizeof(userproc_proc));
unlock_data(userproc_installed,
sizeof(userproc_installed));
unlock_data(mouse_regs, sizeof(mouse_regs));
unlock_data(mouse_seginfo, sizeof(mouse_seginfo));
unlock_code(@callback_handler,
longint(@mouse_dummy)
- longint(@callback_handler));
fillchar(mouse_seginfo, sizeof(mouse_seginfo), 0);
end;
begin
install_mouse(@textuserproc, 400);
Writeln('Press any key to exit...');
while (not keypressed) do begin
{ write mouse state info }
gotoxy(1, wherey);
write('MouseX : ', mouse_x:2,
' MouseY : ', mouse_y:2,
' Buttons : ', mouse_b:2);
end;
remove_mouse;
end.\end{verbatim}
\end{FPCList}

View File

@ -1,22 +0,0 @@
\begin{FPCList}
\item[Example]
\begin{verbatim}
Program flags;
uses go32;
var r : trealregs;
begin
r.ax := $5300;
r.bx := 0;
realintr($15, r);
{ check if carry clear and write a suited message }
if ((r.flags and carryflag)=0) then begin
Writeln('APM v',(r.ah and $f),
'.', (r.al shr 4), (r.al and $f),
' detected');
end else
Writeln('APM not present');
end.\end{verbatim}
\end{FPCList}

View File

@ -1,30 +0,0 @@
\begin{FPCList}
\item[Example]
\begin{verbatim}
Program getrunmd;
uses go32;
begin
{
depending on the detected environment,
we simply write another message
}
case (get_run_mode) of
rm_unknown :
Writeln('Unknown environment found');
rm_raw :
Writeln('You are currently running in raw mode',
' (without HIMEM)');
rm_xms :
Writeln('You are currently using HIMEM.SYS only');
rm_vcpi :
Writeln('VCPI server detected.',
' You''re using HIMEM and EMM386');
rm_dpmi :
Writeln('DPMI detected.',
' You''re using a DPMI host like ',
'a windows DOS box or CWSDPMI');
end;
end.\end{verbatim}
\end{FPCList}

View File

@ -1,49 +0,0 @@
\begin{FPCList}
\item[Example]
\begin{verbatim}
Program int_pm;
uses crt, go32;
const int1c = $1c;
var oldint1c : tseginfo;
newint1c : tseginfo;
int1c_counter : Longint;
{$ASMMODE DIRECT}
procedure int1c_handler; assembler;
asm
cli
pushw %ds
pushw %ax
movw %cs:INT1C_DS, %ax
movw %ax, %ds
incl _INT1C_COUNTER
popw %ax
popw %ds
sti
iret
INT1C_DS: .word 0
end;
var i : Longint;
begin
newint1c.offset := @int1c_handler;
newint1c.segment := get_cs;
get_pm_interrupt(int1c, oldint1c);
asm
movw %ds, %ax
movw %ax, INT1C_DS
end;
Writeln('-- Press any key to exit --');
set_pm_interrupt(int1c, newint1c);
while (not keypressed) do begin
gotoxy(1, wherey);
write('Number of interrupts occured : ',
int1c_counter);
end;
set_pm_interrupt(int1c, oldint1c);
end.\end{verbatim}
\end{FPCList}

View File

@ -1,96 +0,0 @@
\begin{FPCList}
\item[Example]
\begin{verbatim}
Program Keyclick;
uses crt,
go32;
const kbdint = $9;
var oldint9_handler : tseginfo;
newint9_handler : tseginfo;
clickproc : pointer;
{$ASMMODE DIRECT}
procedure int9_handler; assembler;
asm
cli
pushal
movw %cs:INT9_DS, %ax
movw %ax, %ds
movw %ax, %es
movw U_GO32_DOSMEMSELECTOR, %ax
movw %ax, %fs
call *_CLICKPROC
popal
ljmp %cs:OLDHANDLER
INT9_DS: .word 0
OLDHANDLER:
.long 0
.word 0
end;
procedure int9_dummy; begin end;
procedure clicker;
begin
sound(500); delay(10); nosound;
end;
procedure clicker_dummy; begin end;
procedure install_click;
begin
clickproc := @clicker;
lock_data(clickproc, sizeof(clickproc));
lock_data(dosmemselector, sizeof(dosmemselector));
lock_code(@clicker,
longint(@clicker_dummy)-longint(@clicker));
lock_code(@int9_handler,
longint(@int9_dummy)
- longint(@int9_handler));
newint9_handler.offset := @int9_handler;
newint9_handler.segment := get_cs;
get_pm_interrupt(kbdint, oldint9_handler);
asm
movw %ds, %ax
movw %ax, INT9_DS
movl _OLDINT9_HANDLER, %eax
movl %eax, OLDHANDLER
movw 4+_OLDINT9_HANDLER, %ax
movw %ax, 4+OLDHANDLER
end;
set_pm_interrupt(kbdint, newint9_handler);
end;
procedure remove_click;
begin
set_pm_interrupt(kbdint, oldint9_handler);
unlock_data(dosmemselector, sizeof(dosmemselector));
unlock_data(clickproc, sizeof(clickproc));
unlock_code(@clicker,
longint(@clicker_dummy)
- longint(@clicker));
unlock_code(@int9_handler,
longint(@int9_dummy)
- longint(@int9_handler));
end;
var ch : char;
begin
install_click;
Writeln('Enter any message.',
' Press return when finished');
while (ch <> #13) do begin
ch := readkey; write(ch);
end;
remove_click;
end.
\end{verbatim}
\end{FPCList}

View File

@ -1,51 +0,0 @@
\begin{FPCList}
\item[Example]
\begin{verbatim}
Program meminf;
uses go32;
var meminfo : tmeminfo;
begin
get_meminfo(meminfo);
if (int31error <> 0) then
begin
Writeln('Error getting DPMI memory information... Halting');
Writeln('DPMI error number : ', int31error);
end
else
with meminfo do
begin
Writeln('Largest available free block : ',
available_memory div 1024, ' kbytes');
if (available_pages <> -1) then
Writeln('Maximum available unlocked pages : ',
available_pages);
if (available_lockable_pages <> -1) then
Writeln('Maximum lockable available pages : ',
available_lockable_pages);
if (linear_space <> -1) then
Writeln('Linear address space size : ',
linear_space*get_page_size div 1024,
' kbytes');
if (unlocked_pages <> -1) then
Writeln('Total number of unlocked pages : ',
unlocked_pages);
if (available_physical_pages <> -1) then
Writeln('Total number of free pages : ',
available_physical_pages);
if (total_physical_pages <> -1) then
Writeln('Total number of physical pages : ',
total_physical_pages);
if (free_linear_space <> -1) then
Writeln('Free linear address space : ',
free_linear_space*get_page_size div 1024,
' kbytes');
if (max_pages_in_paging_file <> -1) then
Writeln('Maximum size of paging file : ',
max_pages_in_paging_file*get_page_size div 1024,
' kbytes');
end;
end.\end{verbatim}
\end{FPCList}

View File

@ -1,16 +0,0 @@
\begin{FPCList}
\item[Example]
\begin{verbatim}
program outport;
uses crt, go32;
begin
{ turn on speaker }
outportb($61, $ff);
{ wait a little bit }
delay(50);
{ turn it off again }
outportb($61, $0);
end.\end{verbatim}
\end{FPCList}

View File

@ -1,96 +0,0 @@
\begin{FPCList}
\item[Example]
\begin{verbatim}
Program rmpm_int;
uses crt, go32;
{$ASMMODE DIRECT}
var r : trealregs;
axreg : Word;
oldint21h : tseginfo;
newint21h : tseginfo;
procedure int21h_handler; assembler;
asm
cmpw $0x3001, %ax
jne CallOld
movw $0x3112, %ax
iret
CallOld:
ljmp %cs:OLDHANDLER
OLDHANDLER: .long 0
.word 0
end;
procedure resume;
begin
Writeln;
Write('-- press any key to resume --'); readkey;
gotoxy(1, wherey); clreol;
end;
begin
clrscr;
Writeln('Executing real mode interrupt');
resume;
r.ah := $30; r.al := $01; realintr($21, r);
Writeln('DOS v', r.al,'.',r.ah, ' detected');
resume;
Writeln('Executing protected mode interrupt',
' without our own handler');
Writeln;
asm
movb $0x30, %ah
movb $0x01, %al
int $0x21
movw %ax, _AXREG
end;
Writeln('DOS v', r.al,'.',r.ah, ' detected');
resume;
Writeln('As you can see the DPMI hosts',
' default protected mode handler');
Writeln('simply redirects it to the real mode handler');
resume;
Writeln('Now exchanging the protected mode',
'interrupt with our own handler');
resume;
newint21h.offset := @int21h_handler;
newint21h.segment := get_cs;
get_pm_interrupt($21, oldint21h);
asm
movl _OLDINT21H, %eax
movl %eax, OLDHANDLER
movw 4+_OLDINT21H, %ax
movw %ax, 4+OLDHANDLER
end;
set_pm_interrupt($21, newint21h);
Writeln('Executing real mode interrupt again');
resume;
r.ah := $30; r.al := $01; realintr($21, r);
Writeln('DOS v', r.al,'.',r.ah, ' detected');
Writeln;
Writeln('See, it didn''t change in any way.');
resume;
Writeln('Now calling protected mode interrupt');
resume;
asm
movb $0x30, %ah
movb $0x01, %al
int $0x21
movw %ax, _AXREG
end;
Writeln('DOS v', lo(axreg),'.',hi(axreg), ' detected');
Writeln;
Writeln('Now you can see that there''s',
' a distinction between the two ways of ');
Writeln('calling interrupts...');
set_pm_interrupt($21, oldint21h);
end.\end{verbatim}
\end{FPCList}

View File

@ -1,105 +0,0 @@
\begin{FPCList}
\item[Example]
\begin{verbatim}
Program sel_des;
uses crt,
go32;
const maxx = 80;
maxy = 25;
bytespercell = 2;
screensize = maxx * maxy * bytespercell;
linB8000 = $B800 * 16;
type string80 = string[80];
var
text_save : array[0..screensize-1] of byte;
text_oldx, text_oldy : Word;
text_sel : Word;
procedure status(s : string80);
begin
gotoxy(1, 1);
clreol;
write(s);
readkey;
end;
procedure selinfo(sel : Word);
begin
gotoxy(1, 24);
clreol;
writeln('Descriptor base address : $',
hexstr(get_segment_base_address(sel), 8));
clreol;
write('Descriptor limit : ',
get_segment_limit(sel));
end;
function makechar(ch : char; color : byte) : Word;
begin
result := byte(ch) or (color shl 8);
end;
begin
seg_move(dosmemselector, linB8000,
get_ds, longint(@text_save), screensize);
text_oldx := wherex; text_oldy := wherey;
seg_fillword(dosmemselector, linB8000,
screensize div 2,
makechar(' ', Black or (Black shl 4)));
status('Creating selector ' +
'''text_sel'' to a part of text screen memory');
text_sel := allocate_ldt_descriptors(1);
set_segment_base_address(text_sel, linB8000
+ bytespercell * maxx * 1);
set_segment_limit(text_sel,
screensize-1-bytespercell*maxx*3);
selinfo(text_sel);
status('and clearing entire memory ' +
'selected by ''text_sel'' descriptor');
seg_fillword(text_sel, 0,
(get_segment_limit(text_sel)+1) div 2,
makechar(' ', LightBlue shl 4));
status('Notice that only the memory described'+
' by the descriptor changed, nothing else');
status('Now reducing it''s limit and base and '+
'setting it''s described memory');
set_segment_base_address(text_sel,
get_segment_base_address(text_sel)
+ bytespercell * maxx);
set_segment_limit(text_sel,
get_segment_limit(text_sel)
- bytespercell * maxx * 2);
selinfo(text_sel);
status('Notice that the base addr increased by '+
'one line but the limit decreased by 2 lines');
status('This should give you the hint that the '+
'limit is relative to the base');
seg_fillword(text_sel, 0,
(get_segment_limit(text_sel)+1) div 2,
makechar(#176, LightMagenta or Brown shl 4));
status('Now let''s get crazy and copy 10 lines'+
' of data from the previously saved screen');
seg_move(get_ds, longint(@text_save),
text_sel, maxx * bytespercell * 2,
maxx * bytespercell * 10);
status('At last freeing the descriptor and '+
'restoring the old screen contents..');
status('I hope this little program may give '+
'you some hints on working with descriptors');
free_ldt_descriptor(text_sel);
seg_move(get_ds, longint(@text_save),
dosmemselector, linB8000, screensize);
gotoxy(text_oldx, text_oldy);
end.\end{verbatim}
\end{FPCList}

View File

@ -1,15 +0,0 @@
\begin{FPCList}
\item[Example]
\begin{verbatim}
Program softint;
uses go32;
var r : trealregs;
begin
r.al := $01;
realintr($21, r);
Writeln('DOS v', r.al,'.',r.ah, ' detected');
end.\end{verbatim}
\end{FPCList}

View File

@ -1,41 +0,0 @@
\begin{FPCList}
\item[Example]
\begin{verbatim}
Program textmess;
uses crt, go32;
const columns = 80;
rows = 25;
screensize = rows*columns*2;
text = '! Hello world !';
var textofs : Longint;
save_screen : array[0..screensize-1] of byte;
curx, cury : Integer;
begin
randomize;
dosmemget($B800, 0, save_screen, screensize);
curx := wherex; cury := wherey;
gotoxy(1, 1); Write(text);
textofs := screensize + length(text)*2;
dosmemmove($B800, 0, $B800, textofs, length(text)*2);
dosmemfillchar($B800, 0, screensize, #0);
while (not keypressed) do
begin
dosmemfillchar($B800,
textofs + random(length(text))*2 + 1,
1, char(random(255)));
dosmemmove($B800, textofs, $B800,
random(columns)*2+random(rows)*columns*2,
length(text)*2);
delay(1);
end;
readkey;
readkey;
dosmemput($B800, 0, save_screen, screensize);
gotoxy(curx, cury);
end.\end{verbatim}
\end{FPCList}

View File

@ -1,21 +0,0 @@
\begin{FPCList}
\item[Example]
\begin{verbatim}
Program svgasel;
uses go32;
var vgasel : Word;
r : trealregs;
begin
r.eax := $13; realintr($10, r);
vgasel := segment_to_descriptor($A000);
{ simply fill the screen memory with color 15 }
seg_fillchar(vgasel, 0, 64000, #15);
readln;
{ back to text mode }
r.eax := $3;
realintr($10, r);
end.\end{verbatim}
\end{FPCList}