DEFINT A-Z
DECLARE SUB MemCopy ALIAS "B$ASSN" (BYVAL FSeg%, BYVAL FOfs%, BYVAL NBytes1%, BYVAL TSeg%, BYVAL TOfs%, BYVAL NBytes2%)

'This declare statement must appear in you program

SUB ScrRest (Buffer(), Page) STATIC

DEF SEG = 0                            'First, we are going to check to
MonType = PEEK(&H463)                  'see if we have a color or mono
DEF SEG

IF MonType = &HB4 THEN                 'monitor. If MonType is B4 then
   ToSeg = &HB000                      'we have a mono. Set display segment.
   IF Page <> 1 THEN                   'Only 1 page with mono monitor
      Page = -1                        'Exit with error by setting Page
      EXIT SUB                         'to -1.
   END IF
ELSE
   ToSeg = &HB800                      'Else we have a color.
END IF

ToOfs = (Page - 1) * &H1000            'Adjust offset for correct page

FromSeg = VARSEG(Buffer(1))            'Get segment of array
FromOfs = VARPTR(Buffer(1))            'And offset

NumBytes = 4000                        'Each page contains 4000 bytes.

CALL MemCopy(FromSeg, FromOfs, NumBytes, ToSeg, ToOfs, NumBytes)

END SUB

SUB ScrSave (Buffer(), Page) STATIC

DEF SEG = 0                            'First, we are going to check to
MonType = PEEK(&H463)                  'see if we have a color or mono
DEF SEG

IF MonType = &HB4 THEN                 'monitor. If MonType is B4 then
   FromSeg = &HB000                    'we have a mono. Set display segment.
   IF Page <> 1 THEN                   'Only 1 page with mono monitor
      Page = -1                        'Exit with error by setting Page
      EXIT SUB                         'to -1.
   END IF
ELSE
   FromSeg = &HB800                    'Else we have a color.
END IF

FromOfs = (Page - 1) * &H1000          'Adjust offset for correct page

ToSeg = VARSEG(Buffer(1))              'Get segment of array
ToOfs = VARPTR(Buffer(1))              'And offset

NumBytes = 4000                        'Each page contains 4000 bytes.

CALL MemCopy(FromSeg, FromOfs, NumBytes, ToSeg, ToOfs, NumBytes)

END SUB                                'Capture screen and return

