Advertisement
em00k

Untitled

Jan 23rd, 2021
2,054
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ' ------------------------------------------------------------------------------
  2. ' - Sprite Test ----------------------------------------------------------------
  3. ' ------------------------------------------------------------------------------
  4. '
  5. '!sna "h:\test.snx" -a
  6.  
  7. #incluDe <nextlib.bas>
  8.  
  9. CONST sprX2=%01000
  10. CONST sprX4=%10000 
  11. CONST sprX8=%11000
  12. CONST sprY2=%00100
  13. CONST sprY4=%00010
  14. CONST sprY8=%00110
  15.    
  16.  
  17. ' The following MACRO can be used to SCALE / ROT MIRROR by a CONST no good for vars
  18.  
  19. ' #DEFINE SpriteScale(spr_spriteid,spr_scalefactor) \
  20. '       NextReg($34,spr_spriteid) \
  21. '       NextReg($39,spr_scalefactor)
  22. '
  23. ' #DEFINE SpriteRotate(spr_spriteid,rot_factor) \
  24. '       NextReg($34,spr_spriteid) \
  25. '       NextReg($37,rot_factor)
  26.        
  27. SpriteTest()
  28.  
  29. dim r as ubyte = 0
  30.  
  31. DO
  32.     ' zoom up
  33.     FOR x = 0 to 3
  34.         SpriteAtrrib(0,x<<1 BOR x<<3,r<<1 )
  35.         Pause 5
  36.     next x
  37.     r=r+1
  38.     ' unzoom
  39.     FOR x = 0 to 3
  40.         SpriteAtrrib(0,3-x<<1 BOR 3-x<<3,r<<1 )
  41.         Pause 5
  42.     next x
  43.     r=r+1
  44. Loop
  45.  
  46. Sub fastcall SpriteAtrrib(sprID as ubyte, sprScale as ubyte,rotFactor as ubyte)
  47.     ' This routine sets scale, mirror and rotate, can also do palette oofset
  48.     asm
  49.             PROC
  50.             LOCAL sprID, sprScale, rotFact
  51.             exx
  52.             ld (sprID),a        ; store at sprID
  53.             pop de             
  54.             pop af                ; get second param in af
  55.             ld (sprScale),a ; store at sprScale
  56.             pop af                ; get second param in af
  57.             ld (rotFact),a  ; store at sprScale
  58.             DW $91ED              ; Nextreg nn
  59.             DB $34                ; select sprite
  60.             sprID: DB 0       ;
  61.             DW $91ED              ; Nextreg nn
  62.             DB $39                ; sprite attribute 4
  63.             sprScale: DB 0
  64.             DW $91ED              ; Nextreg nn
  65.             DB $37                ; sprite attribute 2
  66.             rotFact: DB 0
  67.             push de               ; fix stack before leaving
  68.             exx
  69.             ENDP
  70.     end asm    
  71.  
  72. end sub
  73.  
  74. sub SpriteTest()
  75.     border 6: paper 7: ink 0: cls
  76.     print at 0,0;"Scale Test"
  77.    
  78.     ' Registers
  79.     NextReg($7,$3)  ' 0=3.5Mhz, 1=7Mhz, 2=14Mhz, 3=28 Mhz
  80.     NextReg($15,%00111001)  ' Sprite and Layer Setup: ClipSprites, S(U+L-5), Sprites not border
  81.    
  82.     ' Layer2
  83.     ShowLayer2(1)
  84.    
  85.     ' Init Sprites
  86.     InitSprites(1,@Sprites)
  87.    
  88.    
  89.     ' Show Sprites Mirror and rotation
  90.     '                            X  Y S P R  XXYY
  91.     UpdateSprite(40,56,0,0,0,sprX2)
  92.  
  93. end sub
  94.  
  95.  
  96. Sprites:
  97. asm
  98. Sprite1:
  99.     db  $E3, $E3, $E3, $E3, $E3, $E3, $00, $FC, $FC, $00, $E3, $E3, $E3, $E3, $E3, $E3;
  100.     db  $E3, $E3, $E3, $E3, $E3, $00, $FC, $FC, $FC, $FC, $00, $E3, $E3, $E3, $E3, $E3;
  101.     db  $E3, $E3, $E3, $E3, $00, $FC, $FC, $FC, $FC, $FC, $FC, $00, $E3, $E3, $E3, $E3;
  102.     db  $E3, $E3, $E3, $00, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $00, $E3, $E3, $E3;
  103.     db  $E3, $E3, $00, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $00, $E3, $E3;
  104.     db  $E3, $00, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $00, $E3;
  105.     db  $00, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $FC, $00;
  106.     db  $6C, $6C, $6C, $6C, $6C, $6C, $6C, $6C, $6C, $6C, $6C, $6C, $6C, $6C, $6C, $6C;
  107.     db  $E3, $E3, $E3, $E3, $E3, $E3, $6C, $FC, $FC, $6C, $E3, $E3, $E3, $E3, $E3, $E3;
  108.     db  $E3, $E3, $E3, $E3, $E3, $E3, $6C, $FC, $FC, $6C, $E3, $E3, $E3, $E3, $E3, $E3;
  109.     db  $E3, $E3, $E3, $E3, $E3, $E3, $6C, $FC, $FC, $6C, $E3, $E3, $E3, $E3, $E3, $E3;
  110.     db  $E3, $E3, $E3, $E3, $E3, $E3, $6C, $FC, $FC, $6C, $E3, $E3, $E3, $E3, $E3, $E3;
  111.     db  $E3, $E3, $E3, $E3, $E3, $E3, $6C, $FC, $FC, $6C, $E3, $E3, $E3, $E3, $E3, $E3;
  112.     db  $E3, $E3, $E3, $E3, $E3, $E3, $6C, $FC, $FC, $6C, $E3, $E3, $E3, $E3, $E3, $E3;
  113.     db  $E3, $E3, $E3, $E3, $E3, $E3, $6C, $FC, $FC, $6C, $E3, $E3, $E3, $E3, $E3, $E3;
  114.     db  $E3, $E3, $E3, $E3, $E3, $E3, $6C, $6C, $6C, $6C, $E3, $E3, $E3, $E3, $E3, $E3;
  115. END asm
  116.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement