CALL SPRENABLE
This page was last modified 07:29, 17 January 2024 by Mars2000you.

Contents

Effect

Enables the Artisan BASIC sprite handling system that replaces the PUT SPRITE instructions (only for the sprites type 1) by an array that keeps the sprite attributes.

When this system is active:

  • don't run instructions that modify VRAM to avoid possible collision with sprite update
  • don't declare new variables as this will cause corruption of the sprite control system

Syntax

CALL SPRENABLE(<SpriteArray>,<UpdateFlag>,<FlickerFlag>,<HandledSprites>)

Parameters

<SpriteArray> is an integer array of size (3,31) corresponding to (<SpriteNumber>,<SpriteAttributes>) as follows:

  • n = Sprite number between 0 and 31
  • (0,n) - Y coordinate between 0 and 191
  • (1,n) - X coordinate between 0 and 255
  • (2,n) - Pattern between 0 and 255
  • (3,n) - Color between 0 and 15

<UpdateFlag> is a number between 0 and 255 to update sprite attributes in VRAM during vertical blank:

  • When set to a number different from zero, an update will occur and the value will be set to 0
  • The use of animations will update this flag to 1 as needed too

<FlickerFlag> is a number between 0 and 255 to specify if sprite attributes are applied to VRAM in the same order as in <SpriteArray> or not

  • 0 = yes
  • other values = no, what means they will be updated cyclically, effectively alleviating 4 sprites per line limitation

<HandledSprites> is a number between 0 and 31 to specify how many sprites are updated in each cycle. Use this for perfomance reasons if you don't work with full 32 sprites.

Example

10 REM SPRITE GROUP AND ANIMATION HANDLING TEST 20 COLOR 15,1,1:SCREEN 2,2 25 DEFINT A-Z 30 REM DEFINE ALL VARIABLES USED 31 REM THIS PREVENTS VARIABLES 32 REM CHANGING MEMORY LOCATION 40 J=0:I=0:X=0:Y=0:VX=1:VY=1:SU=0 41 REM DEFINE SPRITE ATTRIBUTE TABLE 42 REM FOR 32 SPRITES IN FORMAT 43 REM (Y,X,PATTERN,COLOR) 44 DIM SA(3,31) 45 REM DEFINE SPRITE GROUP IN FORMAT 46 REM (SPRITE NUM, DELTA Y, DELTA X) 47 DIM SG(2,31) 49 REM INIT SPRITE ROUTINES 50 SU=0:REM SPRITE UPDATE FLAG 51 _SPRENABLE (SA,SU,1,32) 52 ON STOP GOSUB 2000:STOP ON 58 REM SET INITIAL POSITIONS, 59 REM PATTERNS AND COLORS 60 FOR I=0 TO 31 70 SA(0,I)=256:SA(1,I)=256:SA(2,I)=I:SA(3,I)=4 80 NEXT 88 REM DEFINE RELATIVE POSITIONS OF 89 REM SPRITES IN A GROUP 90 FOR I=0 TO 7:FOR J=0 TO 3 91 REM SET SPRITE NUMBER 92 SG(0,I*4+J)=I*4+J 93 REM SET Y OFFSET 94 SG(1,I*4+J)=I*16 95 REM SET X OFFSET 96 SG(2,I*4+J)=J*16 105 NEXT J:NEXT I 110 BLOAD "MSXLOGOV.BIN",&HB001 120 _MEMVRM(&HB001,BASE(14),32*32,0) 130 _SPRGRPMOV (X,Y,32,SG) 180 SU=1:GOSUB 1000 190 IF SU=1 GOTO 190 ELSE 130 1000 X=X+VX:IF X<0 OR X>192 THEN VX=-VX 1010 Y=Y+VY:IF Y<0 OR Y>64 THEN VY=-VY 1020 RETURN 2000 _SPRDISABLE:END

Related to

CALL COLL, CALL SPRDISABLE, CALL SPRGRPMOV

Compatibility

Artisan BASIC