I ported it under FreeBasic, and worked, at least under DosBox. You need three files:
Keep.bas
Code: Select all
' Copyright (C) 2002 Charles Sandmann (sandmann@clio.rice.edu)
' ABSOLUTELY NO WARRANTY. May be redistributed or copied without restriction
' as long as copyright notice kept intact. Hopefully I'll get this in
' the DJGPP library someday.
#include "dos/dpmi.bi"
#include "dos/sys/farptr.bi"
#include "dos/go32.bi"
#include "keep.bi"
sub keep(status as ubyte, size as unsigned integer)
dim regs as __dpmi_regs
_farsetsel(_dos_ds)
' Keep size default is current PSP block size
if _farnspeekw(_go32_info_block.linear_address_of_original_psp - 15) <> _go32_info_block.linear_address_of_original_psp / 16 then
' Not a real PSP? attempt to continue
regs.x.dx = (_go32_info_block.size_of_transfer_buffer + 256) / 16
else
regs.x.dx = _farnspeekw(_go32_info_block.linear_address_of_original_psp - 13)
end if
' Default is to keep PSP and transfer buffer, but the user may want to
' not use and release transfer buffer to decrease DOS footprint.
if size >= 16 andalso size < regs.x.dx then regs.x.dx = size
regs.x.ax = &H3100 + status
__dpmi_int(&H21, @regs)
end sub
Code: Select all
' Copyright (C) 2002 Charles Sandmann (sandmann@clio.rice.edu)
' ABSOLUTELY NO WARRANTY. May be redistributed or copied without restriction
' as long as copyright notice kept intact
declare sub keep(status as ubyte, size as unsigned integer)
Code: Select all
' DJGPPTSR, Nov 1995 Charles Sandmann (sandmann@clio.rice.edu)
' Updated Oct 2002.
' ABSOLULTELY NO WARRANTY. May be redistributed or copied without restriction.
' An example of a DJGPP TSR. This routine changes the video attribute of the
' character in the upper right of the screen once per tick (from protected
' mode). The DPMI provider will be forced to stay resident after this image
' exits. This code also shows an undocumented way to suppress the exception
' code loading to decrease the image footprint size. Not optimal - you can
' do the same thing with a single GAS file with a much smaller image. Left
' as an exercise for the user. Have fun!
#include "crt/stdio.bi"
'#include "crt/io.bi"
#include "dos/dpmi.bi"
#include "dos/sys/farptr.bi"
#include "dos/go32.bi"
#include "dos/pc.bi"
#include "keep.bi"
'' from djgpp/include/crt0.h
#define _CRT0_FLAG_LOCK_MEMORY &h1000
'' linker "magic"
extern _crt0_startup_flags alias "_crt0_startup_flags" as integer
dim shared _crt0_startup_flags as integer = _
_CRT0_FLAG_LOCK_MEMORY
sub int8
dim as uinteger offset = ScreenPrimary+(2*79)+1 ' Video attribute byte
_farsetsel(_dos_ds)
_farnspokeb(offset,1+_farnspeekb(offset))
end sub
dim as _go32_dpmi_seginfo pmint
pmint.pm_selector = _my_cs()
pmint.pm_offset = cast(unsigned integer,@int8)
_go32_dpmi_chain_protected_mode_interrupt_vector(8, @pmint)
print "Installing DJGPP TSR"
keep(0, 16)
end
Code: Select all
fbc fbtsr.bas keep.bas
stubedit fbtsr.exe bufsize=4K