Advertisement
LBASIC

ANIMA6.BAS

Jun 5th, 2023
608
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
QBasic 4.18 KB | Software | 0 0
  1. 'From: TONY CAVE                 Conference: QUIK_BAS -Qui (298)
  2. 'Date: 07-02-97 23:51              BBS Name: YE OLDE PAWN SHOPPE ]I[
  3. 'Subject: anima5.bas (1/3)              BBS ID: YOPSIII
  4. 'The following is by no means a finished product.  I just thought
  5. 'you might want to see the no-flicker animation and page swapping
  6. 'on screen 13.  The program uses PUT to copy the page to the screen.
  7. 'Copying a whole page, though, slows down the animation considerably.
  8. 'Any suggestions would be appreciated.  Just bear in mind that the
  9. 'program is not finished, and some of the subs with "Page" in the name
  10. 'only work with page one.  The animaiton is done by:
  11. '1 copy screen to memory pages, page1 and page2
  12. '2 do
  13. '3  place a sprite on page1 (color 0 is transparent).
  14. '4  copy page1 to the screen
  15. '5  erase the sprite from page1 by copying part of page2 (PageCopyBox)
  16. '6 loop
  17. '''Begin ANIMA5.BAS
  18. COMMON SHARED snap() AS INTEGER, leaf() AS INTEGER, swp() AS INTEGER
  19. COMMON SHARED OldX AS INTEGER, OldY AS INTEGER
  20. COMMON SHARED Page1() AS INTEGER, Page2() AS INTEGER
  21. COMMON SHARED CurrentSegment AS LONG
  22. DIM Page1(32001) AS INTEGER, Page2(32001) AS INTEGER
  23. DIM snap(15, 15, 20) AS INTEGER, x AS INTEGER, y AS INTEGER
  24. DIM leaf(10, 10, 20) AS INTEGER, swp(10, 10, 20) AS INTEGER
  25. DIM t AS INTEGER, T2 AS INTEGER, T3  AS INTEGER: SCREEN 13
  26. CurrentSegment = &HA000: DrawSprite: InitPalette: DrawBackdrop
  27. GET (0, 0)-(319, 199), Page1(0): GET (0, 0)-(319, 199), Page2(0)
  28. step1 = 3
  29. DO: FOR t = 0 TO 628 STEP step1: y = COS(t / 100) * 320 / step1 + 100
  30.     x = SIN(t / 100) * 240 / step1 + 160: Stamp2 x, y, t / step1 MOD 5
  31.     PUT (0, 0), Page1(0), PSET: PageCopyBox x, y, 1
  32.     IF INKEY$ > "" THEN DEF SEG : EXIT DO
  33.   NEXT: LOOP: SCREEN 0: WIDTH 80, 25: SYSTEM
  34. SUB Attrib (Attribute%, r%, g%, b%)
  35.   IF -1 < Attribute% AND Attribute% < 256 THEN
  36.     OUT &H3C8, Attribute%: OUT &H3C9, r%
  37.     OUT &H3C9, g%: OUT &H3C9, b%
  38.   END IF: END SUB
  39. SUB DrawBackdrop
  40.   FOR y = 0 TO 199: LINE (0, y)-(319, y), y + 56: NEXT  'Draw Sky
  41.   CIRCLE (160, 800), 770, 2: PAINT (160, 190), 2, 2     'Draw Planet
  42.   FOR y = 0 TO 5: CIRCLE (160, 800), 770 + y, 50 + y: NEXT: END SUB
  43. SUB DrawSprite : DIM t AS INTEGER
  44.   FOR t = 0 TO 2: CIRCLE (6, 5), t, 21 - t * 3 + 16
  45.     CIRCLE (5, 5), t, 21 - t * 3 + 16
  46.     CIRCLE (6, 4), t, 18 - t * 3 + 16
  47.     CIRCLE (5, 4), t, 18 - t * 3 + 16
  48.     IF t > 4 THEN Snapshot 0, 0, t    '  X, Y, snapshot#
  49.   NEXT:FOR t=3 TO 4:LINE(-t+6,2+t)-(t+6,2+t),21-t*3+16:NEXT
  50.   FOR t=0 TO 4:LINE(-4+6,7)-(3+6,2+4),21-4*3+16,BF
  51.     LINE (t * 2 + 2, 6)-(t * 2 + 3, 7), 14, BF
  52.     Snapshot 0, 0, t: NEXT: END SUB   'X, Y, snapshot#
  53. SUB InitPalette : DIM pu AS INTEGER
  54.   FOR y=0 TO 199: Attrib y+56,0,0,INT(y*63/199): NEXT
  55.   FOR y=0 TO 5:Attrib 50+y,0,(5-y)/5*20+20,y/5*40+15:NEXT: END SUB
  56. SUB PageCopy (PageNm AS INTEGER)
  57.   IF PageNm=1 THEN FOR c%=0 TO 32001:Page1(c%)=Page2(c%):NEXT
  58.   IF PageNm<>1 THEN FOR c%=0 TO 32001:Page2(c%)=Page1(c%):NEXT
  59.   END SUB
  60. SUB PageCopyBox (x AS INTEGER, y AS INTEGER, PageNumber AS INTEGER)
  61.   DIM xt AS INTEGER, yt AS INTEGER, P AS LONG, c1 AS LONG
  62.   PCBSeg& = CurrentSegment
  63.   FOR xt = 0 TO 10: FOR yt = 0 TO 10: P = 320& * (y + yt) + x + xt
  64.     IF P < 32000 THEN
  65.       CurrentSegment = VARSEG(Page2(0)): DEF SEG = CurrentSegment
  66.       PagePSet3 x + xt, y + yt, 1, PEEK(P + 4)
  67.     ELSE
  68.       CurrentSegment=VARSEG(Page2(0)):CurrentSegment=CurrentSegment+2000
  69.       DEF SEG = CurrentSegment:PagePSet3 x+xt,y+yt,1,PEEK(P-31996)
  70.     END IF: NEXT: NEXT
  71.   CurrentSegment = PCBSeg&: DEF SEG = CurrentSegment: END SUB
  72. SUB PagePSet3 (x AS INTEGER, y AS INTEGER, Page AS INTEGER, C AS INTEGER)
  73.   IF (x < 0) OR (y < 0) OR (x > 319) OR (y > 199) THEN EXIT SUB
  74.   DIM P AS LONG, c1 AS LONG: c1 = VARSEG(Page1(0)): P = 320& * y + x
  75.   IF P < 32000 THEN DEF SEG = VARSEG(Page1(0)): POKE P + 4, C
  76.   IF P > 31999 THEN DEF SEG = c1 + 2000: POKE P - 31996, C
  77.   DEF SEG = CurrentSegment: END SUB
  78. SUB Snapshot (x%, y%, s%)
  79.   FOR xt% = 0 TO 10: FOR yt% = 0 TO 10
  80.     snap(xt%,yt%,s%)=POINT(xt%+x%,yt%+y%):NEXT:NEXT:END SUB
  81. SUB Stamp2 (x%, y%, s%)
  82.   FOR xt% = 0 TO 10: FOR yt% = 0 TO 10
  83.     IF snap(xt%, yt%, s%) > 0 THEN
  84.       PagePSet3 x% + xt%, y% + yt%, 1, snap(xt%, yt%, s%)
  85.     END IF: NEXT: NEXT: END SUB
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement