home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / basic / QBEGASAV.ZIP / QBEGASAV.BAS
Encoding:
BASIC Source File  |  1988-09-23  |  2.5 KB  |  76 lines

  1.  REM
  2.  REM this program saves two pages of graphics to foo files then reads them back in
  3.  REM information on screen mode 9:
  4.  REM 1. each plane is 32K (32767) long
  5.  REM 2. each page is 128K long
  6.  REM 3. offset to page 1 is 32767 when saving 28000 length planes
  7.  REM 4. there are only 2 pages when using this technique
  8.  REM
  9.  DECLARE SUB ega (myFile$, mode!, rw!)
  10.  SCREEN 9
  11.  LINE (0, 0)-(639, 349), , B          'draw a box to page 0
  12.  FOR i = 1 TO 200                     'draw some lines to page 1
  13.      x1 = INT(640 * RND)
  14.      y1 = INT(350 * RND)
  15.      x2 = INT(640 * RND)
  16.      y2 = INT(350 * RND)
  17.      co = INT(15 * RND)
  18.      LINE (x1, y1)-(x2, y2), co
  19.  NEXT i
  20.  INPUT a$                              'pause, input something to stop pause
  21.  SCREEN 9, 1, 1                        'change visual and active pages to 1
  22.  PRINT "hello 9 - 1"
  23.  FOR i = 1 TO 200                      'write some lines to page 1
  24.      x1 = INT(640 * RND)
  25.      y1 = INT(350 * RND)
  26.      x2 = INT(640 * RND)
  27.      y2 = INT(350 * RND)
  28.      co = INT(15 * RND)
  29.      LINE (x1, y1)-(x2, y2), co
  30.  NEXT i
  31.  SCREEN 9, 0, 0                         'change visual and active pages back to 0
  32.  myFile$ = "foo"                        'filename to save graphics to
  33.  mode = 9                               'screen mode 9 is used
  34.  rw = 0                                 'save/load flag 0=save
  35.  CALL ega(myFile$, mode, rw)            'call routine to save pages 1 and 0
  36.  CLS
  37.  INPUT "hit enter to restore the screen", a$
  38.  rw = 1                                 'load in the graphics from foo
  39.  CALL ega(myFile$, mode, rw)            'call routine
  40.                                         'view page 0
  41.  WHILE INKEY$ = "": WEND                'pause, hit key to continue
  42.  SCREEN 9, 0, 1                         'view page 1
  43.  END
  44.  
  45.  SUB ega (myFile$, mode, rw) STATIC
  46.  SELECT CASE mode
  47.     CASE 7
  48.       total = 8000
  49.     CASE 8
  50.        total = 16000
  51.     CASE 9 TO 10
  52.        total = 65535               'save two pages of graphics
  53.     CASE ELSE
  54.        PRINT "error: nonega"
  55.        GOTO noega
  56.  END SELECT
  57.  IF mode = 10 THEN cycle = 1 ELSE cycle = 3
  58.  DEF SEG = &HA000
  59.     FOR i = 0 TO cycle
  60.        IF rw = 1 THEN
  61.          OUT &H3C4, 2
  62.          OUT &H3C5, 2 ^ i
  63.          f$ = myFile$ + CHR$(i + 48) + ".EGA"
  64.          BLOAD f$, 0
  65.        ELSE
  66.          OUT &H3CE, 4
  67.          OUT &H3CF, i
  68.          f$ = myFile$ + CHR$(i + 48) + ".EGA"
  69.          BSAVE f$, 0, total
  70.        END IF
  71.      NEXT i
  72.  DEF SEG
  73. noega:
  74.  END SUB
  75.  
  76.