Advertisement
Ham62

Untitled

Jan 28th, 2017
543
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 2.40 KB | None | 0 0
  1. TYPE QBPtr      'Closest we'll get to pointers in QB
  2.    SEG AS LONG
  3.    Addr AS LONG
  4. END TYPE
  5.  
  6. TYPE TxtGFX     'Image Type
  7.    Size AS INTEGER
  8.    iWidth AS INTEGER
  9.    iHeight AS INTEGER
  10.    Image(0) AS INTEGER
  11. END TYPE
  12.  
  13. TYPE BirdChar   'Bird character
  14.    X AS INTEGER
  15.    Y AS INTEGER
  16.    CharBlock AS INTEGER
  17. END TYPE
  18.  
  19. TYPE PipeStruct 'For tracking pipes
  20.    X AS INTEGER
  21.    Height AS INTEGER
  22. END TYPE
  23.  
  24. DECLARE SUB UpdateScreen ()
  25. DIM SHARED ScreenBuff(80 * 25) AS INTEGER
  26. DIM SHARED Pipes(1) AS PipeStruct
  27. DIM BuffPtr AS QBPtr
  28. DIM Flappy AS BirdChar
  29.  
  30. CONST FallSpeed = 5, FlySpeed = 2
  31. CONST AniSpeed = 5, GroundLevel = 20
  32. DEFINT A-Z: DEFLNG L: DEFSTR S
  33.  
  34. RANDOMIZE TIMER
  35. SCREEN 0
  36.  
  37. 'BuffPtr.Seg = VARSEG(ScreenBuff(0, 0))
  38. 'BuffPtr.Addr = VARPTR(ScreenBuff(0, 0))
  39. CLS
  40. FOR X = 0 TO 80 - 1
  41.    FOR Y = 0 TO 24 - 1
  42.       'ScreenBuff(X, Y) = &H0
  43.       ScreenBuff(X + (Y * 80)) = &HF0F0 '0
  44.    NEXT Y
  45. NEXT X
  46.  
  47. DIM StartTime AS DOUBLE
  48. StartTime = TIMER
  49. FOR X = 0 TO 1000
  50.    UpdateScreen
  51. NEXT X
  52. 'PRINT TIMER - StartTime
  53.  
  54. SUB UpdateScreen STATIC
  55.     DIM ASM(6) AS LONG
  56.     IF ASM(0) = 0 THEN
  57.       'ASM(1) = &H1C5E8EE5: ASM(2) = &HBF1A768B
  58.       '           ^^ First Param         ^^ Second param
  59.       ASM(0) = &H891E0660: ASM(1) = &H1C5E8EE5: ASM(2) = &HBF1A768B
  60.       '                               ^^ First Param         ^^ Second param
  61.       ASM(3) = &HB80000: ASM(4) = &HB9C08EB8: ASM(5) = &HA5F307D0
  62.       ASM(6) = &HCB61071F
  63.     END IF
  64.     DEF SEG = VARSEG(ASM(0)): iASMPtr = VARPTR(ASM(0))
  65.     CALL ABSOLUTE(BYVAL VARSEG(ScreenBuff(0)), BYVAL VARPTR(ScreenBuff(0)), iASMPtr)
  66. END SUB
  67.  
  68. ==================================== ASM Source ==========================================
  69.  
  70. ORG 0h
  71.  
  72. %define _ScreenSize (80*25)
  73. %define _ScreenSeg 0B800h
  74.  
  75. %define _ParamOffset (4+18+2+2) ;(CS/IP)+PUSHA+ES+DS
  76.  
  77. %define _BuffSeg  BP+_ParamOffset+2
  78. %define _BuffAddr BP+_ParamOffset+0
  79.  
  80. Start:
  81.     PUSHA    ;18 bytes
  82.     PUSH ES  ;2 bytes
  83.     PUSH DS  ;2 bytes
  84.     MOV BP, SP
  85.  
  86.     MOV DS, WORD [_BuffSeg]  ;Buffer segment
  87.     MOV SI, WORD [_BuffAddr] ;Buffer Address
  88.                              ;Buffer IS DS:SI
  89.  
  90.     MOV DI, 00h              ;Start drawing at 0
  91.     MOV AX, _ScreenSeg       ;Set SCREEN segment
  92.     MOV ES, AX               ;SCREEN IS ES:DI
  93.  
  94.     MOV CX, _ScreenSize
  95.  
  96.     REP MOVSW                ;WRITE buffer TO SCREEN
  97.  
  98. END:
  99.     POP DS
  100.     POP ES
  101.     POPA
  102.     RETF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement