Advertisement
Ham62

OFFVIDEO.BAS

Jan 29th, 2017
862
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 3.49 KB | None | 0 0
  1. DECLARE SUB SetVideoSeg (sNewSeg() AS INTEGER)
  2. DECLARE SUB UpdateLine (SegArray() AS INTEGER, iLine AS INTEGER)
  3. REM $INCLUDE: 'qbx.bi'
  4. DEFINT A-Z
  5. DEFLNG L, P
  6. DEFSNG F
  7.  
  8. REM $DYNAMIC
  9.  
  10. CLS
  11.  
  12. REDIM SHARED iBuff(32766) AS INTEGER
  13. iBuff(0) = 10
  14.  
  15. DIM REGS AS RegType
  16. DIM SHARED iScreenSeg AS INTEGER
  17. DIM SHARED fTime
  18. DIM SHARED iSegSeg AS INTEGER, iSegPtr AS INTEGER
  19.  
  20. REGS.ax = &H5100
  21. CALL Interrupt(&H21, REGS, REGS)
  22.  
  23. SCREEN 13
  24.  
  25. iSegSeg = 0: iSegPtr = 0
  26. IF VARPTR(iBuff(0)) <> 0 THEN END
  27.  
  28. 'FF 0F A0 7D
  29. fTime = TIMER
  30. FOR lSeg = REGS.bx TO &HA000& STEP 64
  31.   DEF SEG = lSeg
  32.   FOR i = 0 TO 1023 STEP 2
  33.      IF PEEK(i) = &HFF THEN
  34.         IF PEEK(i + 1) = &HF THEN
  35.     IF PEEK(i + 2) = &HA0 THEN
  36.       IF PEEK(i + 3) = &H7D THEN
  37.          PRINT ".";
  38.          IF PEEK(i + 4) = &H0 THEN
  39.             IF PEEK(i + 5) = &HA0 THEN
  40.         lBuff = CLNG(VARSEG(iBuff(0))) AND &HFFFF&
  41.         iBL = lBuff AND &HFF&: iBH = lBuff \ 256
  42.         POKE i + 4, iBL: POKE i + 5, iBH
  43.         IF POINT(0, 0) = 10 THEN
  44.           PRINT : PRINT HEX$(lSeg) + ":" + HEX$(i)
  45.           POKE i + 4, 0: POKE i + 5, &HA0
  46.           iSegSeg = lSeg: iSegPtr = i + 4
  47.           GOTO Found
  48.         END IF
  49.              POKE i + 4, 0: POKE i + 5, &HA0
  50.             END IF
  51.          END IF
  52.       END IF
  53.     END IF
  54.         END IF
  55.      END IF
  56.   NEXT i
  57. NEXT lSeg
  58.  
  59. Found:
  60. SetVideoSeg iBuff()
  61. PRINT "Buffered Graphics!"
  62. LINE (0, 0)-(319, 199), 15, B
  63. FOR i = 0 TO 31
  64.   CIRCLE (-160 + RND * 640, -100 + RND * 400), 40 + RND * 100, 15
  65.   LINE (-160 + RND * 640, -100 + RND * 400)-(-160 + RND * 640, -100 + RND * 400), 15
  66.   LINE (-160 + RND * 640, -100 + RND * 400)-(-160 + RND * 640, -100 + RND * 400), 15, B
  67. NEXT i
  68. PRINT : PRINT " what? you see nothing?"
  69. WHILE ABS(TIMER - fTime) < 2: WAIT &H3DA, 8: WAIT &H3DA, 8, 8: WEND: fTime = TIMER
  70.  
  71. FOR iX = 0 TO 319 STEP 1
  72.   SELECT CASE iX
  73.   CASE 105
  74.      PRINT : PRINT " oh! i see it's buffering!!!"
  75.      WHILE ABS(TIMER - fTime) < 2: WAIT &H3DA, 8: WAIT &H3DA, 8, 8: WEND: fTime = TIMER
  76.   CASE 213
  77.      PRINT : PRINT " wait for it, and..."
  78.      WHILE ABS(TIMER - fTime) < 2: WAIT &H3DA, 8: WAIT &H3DA, 8, 8: WEND: fTime = TIMER
  79.   END SELECT
  80.   FOR iY = 3 TO 197 STEP 3
  81.      IF POINT(iX, iY) = 0 THEN PAINT (iX, iY), 31 + RND * 224, 15
  82.   NEXT iY
  83. NEXT iX
  84.  
  85. DIM iScan(255) AS INTEGER
  86. FOR i = 0 TO 255: iScan(i) = i: NEXT i
  87. FOR i = 0 TO 255: SWAP iScan(i), iScan(RND * 255): NEXT i
  88.  
  89. FOR i = 0 TO 255
  90.   UpdateLine iBuff(), iScan(i)
  91.   WAIT &H3DA, 8: WAIT &H3DA, 8, 8
  92.   IF LEN(INKEY$) THEN END
  93. NEXT i
  94. SLEEP
  95.  
  96. REM $STATIC
  97. SUB SetVideoSeg (sNewSeg() AS INTEGER)
  98.   DEF SEG = iSegSeg
  99.   lBuff = CLNG(VARSEG(sNewSeg(0))) AND &HFFFF&
  100.   iBL = lBuff AND &HFF&: iBH = lBuff \ 256
  101.   POKE iSegPtr, iBL
  102.   POKE iSegPtr + 1, iBH
  103. END SUB
  104.  
  105. SUB UpdateLine (SegArray() AS INTEGER, iLine AS INTEGER)
  106.   STATIC iInit AS INTEGER
  107.   STATIC asm() AS INTEGER
  108.   IF iInit = 0 THEN
  109.      REDIM asm(12) AS INTEGER
  110.      iInit = 1
  111.      asm(0) = &HBE60       'pusha     | mov si, ...
  112.      asm(1) = &HFFFF       '0x????
  113.      asm(2) = &H1E06       'push es   | push ds
  114.      asm(3) = &HFE8B       'mov di,si
  115.      asm(4) = &H6836       'push ...
  116.      asm(5) = &HA000       '0xA000
  117.      asm(6) = &H6807       'pop es    | push ...
  118.      asm(7) = &HFFFF       '0x????
  119.      asm(8) = &HB91F       'pop ds    | mov cx, ...
  120.      asm(9) = &HA0         '0x00A0
  121.      asm(10) = &HA5F3      'rep movsw
  122.      asm(11) = &H71F       'pop ds    | pop es
  123.      asm(12) = &HCB61      'popa      | retf
  124.   END IF
  125.   IF iLine < 103 THEN
  126.      asm(1) = (iLine * 320&)
  127.   ELSE
  128.      asm(1) = -65536 + (iLine * 320&)
  129.   END IF
  130.   asm(7) = VARSEG(SegArray(0))
  131.  
  132.   DEF SEG = VARSEG(asm(0))
  133.   CALL ABSOLUTE(VARPTR(asm(0)))
  134.  
  135. END SUB
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement