EGFX · FUNCTION 2ALPHA · USE AT YOUR OWN RISK
SPRITE
Draw a masked sprite.
PX/PY are the signed pixel position. IMAGE selects a frame of the registered 16×16 EGSP v3 resource (functions 16–18 or 33). In 0.6 this goes through the compact renderer (37): a 4-pixel-aligned, untransformed, fully visible MODE 1 sprite uses the fast screen-byte blitter, and anything else uses the pixel-run blitter. Clipping keeps the visible part on screen.
Sprite image IDs
EGFX does not contain built-in sprite artwork. Before calling SPRITE, initialise the resource bank, upload a complete sprite set, and call RESOURCE_READY. Image IDs are assigned in upload order: the first uploaded frame is image 0, the second is 1, the third is 2, and so on. Therefore the example requests the third frame in the resource set; its appearance depends on the sprite data you uploaded.
| Image ID | Resource frame |
|---|---|
0 | First uploaded sprite frame |
1 | Second uploaded sprite frame |
2 | Third uploaded sprite frame |
Parameters
| Name | Order | Description |
|---|---|---|
PX | 1–2 | Signed X coordinate in pixels. |
PY | 3–4 | Signed Y coordinate in pixels. |
IMAGE | 5 | Loaded sprite image number. |
BASIC example
Tested listing: basic-demo.bas.
5 REM Set HIMEM before PROCs: reserve host graphics RAM.
10 MODE 1:HIMEM=&2400
15 REM Initialise ROM and effects; t% is animation phase.
20 PROCeginit:PROCegloadsprites("SPRITES",6):PROCegreset:t%=0
30 REPEAT
35 REM Begin clears frame; Master draws on hidden page.
40 PROCegbegin
45 REM Text needs 8-pixel alignment; sprite image is 0-7.
50 PROCegtext("EG GFX FROM BBC BASIC",8,8)
60 PROCegsprite(120+80*SIN(t%/10),110+60*COS(t%/10),t% MOD 8)
62 REM Trail remembers positions; dot uses logical colour 2.
65 PROCegtrail(120+80*SIN(t%/10),110+60*COS(t%/10))
66 REM Negative X tests left-edge clipping.
67 PROCegdot(240,64,2)
68 PROCegsprite(-4,48,4)
70 PROCegline(16,40,280,200,1)
75 REM Emit two particles with gravity, then update/draw pool.
80 PROCegemit(160,176,2,1):PROCegparticles
85 REM Present at vsync; wrap phase. Q quits to MODE 7.
90 PROCegpresent:t%=(t%+1) MOD 256
100 UNTIL INKEY(0)=81
110 MODE 7:END
In PROCegsprite(120,96,2), 120 is X, 96 is Y, and the final 2 selects sprite image 2. In the Assembly example, block+5 = 2 selects SPRITE; block+8/9 are X=120; block+10/11 are Y=96; and block+12 = 2 selects image 2.
Assembly example
JSR init_egfx
JSR begin_frame
LDA #2 : STA block+5
LDA #120 : STA block+8
LDA #0 : STA block+9
LDA #96 : STA block+10
LDA #0 : STA block+11
LDA #2 : STA block+12
JSR eg_call
JSR present_frame
RTS