Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TYPE QBPtr 'Closest we'll get to pointers in QB
- SEG AS LONG
- Addr AS LONG
- END TYPE
- TYPE TxtGFX 'Image Type
- Size AS INTEGER
- iWidth AS INTEGER
- iHeight AS INTEGER
- Image(0) AS INTEGER
- END TYPE
- TYPE BirdChar 'Bird character
- X AS INTEGER
- Y AS INTEGER
- CharBlock AS INTEGER
- END TYPE
- TYPE PipeStruct 'For tracking pipes
- X AS INTEGER
- Height AS INTEGER
- END TYPE
- DECLARE SUB UpdateScreen ()
- DIM SHARED ScreenBuff(80 * 25) AS INTEGER
- DIM SHARED Pipes(1) AS PipeStruct
- DIM BuffPtr AS QBPtr
- DIM Flappy AS BirdChar
- CONST FallSpeed = 5, FlySpeed = 2
- CONST AniSpeed = 5, GroundLevel = 20
- DEFINT A-Z: DEFLNG L: DEFSTR S
- RANDOMIZE TIMER
- SCREEN 0
- 'BuffPtr.Seg = VARSEG(ScreenBuff(0, 0))
- 'BuffPtr.Addr = VARPTR(ScreenBuff(0, 0))
- CLS
- FOR X = 0 TO 80 - 1
- FOR Y = 0 TO 24 - 1
- 'ScreenBuff(X, Y) = &H0
- ScreenBuff(X + (Y * 80)) = &HF0F0 '0
- NEXT Y
- NEXT X
- DIM StartTime AS DOUBLE
- StartTime = TIMER
- FOR X = 0 TO 1000
- UpdateScreen
- NEXT X
- 'PRINT TIMER - StartTime
- SUB UpdateScreen STATIC
- DIM ASM(6) AS LONG
- IF ASM(0) = 0 THEN
- 'ASM(1) = &H1C5E8EE5: ASM(2) = &HBF1A768B
- ' ^^ First Param ^^ Second param
- ASM(0) = &H891E0660: ASM(1) = &H1C5E8EE5: ASM(2) = &HBF1A768B
- ' ^^ First Param ^^ Second param
- ASM(3) = &HB80000: ASM(4) = &HB9C08EB8: ASM(5) = &HA5F307D0
- ASM(6) = &HCB61071F
- END IF
- DEF SEG = VARSEG(ASM(0)): iASMPtr = VARPTR(ASM(0))
- CALL ABSOLUTE(BYVAL VARSEG(ScreenBuff(0)), BYVAL VARPTR(ScreenBuff(0)), iASMPtr)
- END SUB
- ==================================== ASM Source ==========================================
- ORG 0h
- %define _ScreenSize (80*25)
- %define _ScreenSeg 0B800h
- %define _ParamOffset (4+18+2+2) ;(CS/IP)+PUSHA+ES+DS
- %define _BuffSeg BP+_ParamOffset+2
- %define _BuffAddr BP+_ParamOffset+0
- Start:
- PUSHA ;18 bytes
- PUSH ES ;2 bytes
- PUSH DS ;2 bytes
- MOV BP, SP
- MOV DS, WORD [_BuffSeg] ;Buffer segment
- MOV SI, WORD [_BuffAddr] ;Buffer Address
- ;Buffer IS DS:SI
- MOV DI, 00h ;Start drawing at 0
- MOV AX, _ScreenSeg ;Set SCREEN segment
- MOV ES, AX ;SCREEN IS ES:DI
- MOV CX, _ScreenSize
- REP MOVSW ;WRITE buffer TO SCREEN
- END:
- POP DS
- POP ES
- POPA
- RETF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement