-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo_04_sprites1.bas
48 lines (48 loc) · 2.17 KB
/
demo_04_sprites1.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
10 REM ******************************
20 REM * AGON LIGHT 2 *
30 REM * DEMO 04 *
40 REM * BBC BASIC MODE 8 *
50 REM * SPRITES PART 1 *
60 REM * THANKS EIGHTBITSWIDE *
70 REM * BY STEVE LOVEJOY *
80 REM ******************************
90 REM USING VDU DOCUMENTAITION FROM:
100 REM http://agonconsole8.github.io/agon-docs/VDP.html.
110 :
120 MB%=&40000 : REM MEMORY BANK &40000.
130 DIM graphics 1024 : REM ARRAY.
140 :
150 REM LOAD SPRITE TO MEMORY.
160 REM THE PATH BELOW NEEDS TO POINT TO YOUR .rgb IMAGE FILE ON YOUR SDCARD.
170 PROC_LOAD_SPRITE("/B/Images/80A.rgb",0,16,16) : REM CALL PROC_LOAD_SPRITE WITH SPRITE (n,w,h).
180 MODE 8 : REM SET SCREEN MODE.
190 :
1000 REM SET UP A SPRITE.
1100 VDU 23,27,4,0 : REM SELECT SPRITE n (equating to buffer ID numbered 64000+n).
1110 VDU 23,27,5 : REM CLEAR FRAMES FOR CURRENT SPRITE.
1120 VDU 23,27,6,0 : REM ADD BITMAP n AS FRAME n OF SPRITE.
1140 VDU 23,27,11 : REM SHOW THE CURRENT SPRITE.
1150 VDU 23,27,7,1 : REM ACTIVATE n SPRITES (amount).
1180 :
1190 REM MOVE THE SPRITE * GAME LOOP.
1200 FOR X = 1 TO 200
1220 VDU 23,27,13,X;X; : REM MOVE CURRENT SPRITE TO POS X,Y (created by X loop).
1221 VDU 23,27,15 : REM UPDATE THE SPRITES IN THE GPU.
1230 FOR C = 1 TO 500 : NEXT C : REM SMALL DELAY.
1240 NEXT X
1260 STOP
1270 :
1280 REM LOAD BITMAP IMAGE INTO VDP RAM.
1290 REM F$ - FILENAME/PATH OF BITMAP FROM LINE .
1300 DEF PROC_LOAD_SPRITE(F$,N%,W%,H%) : REM ** PROC_LOAD_SPRITE **
1310 OSCLI("LOAD " + F$ + " " + STR$(MB%+graphics)) : REM SYSTEM CALL.
1320 VDU 23,27,0,N% : REM SELECT BITMAP n (equating to buffer ID numbered 64000+n).
1330 VDU 23,27,1,W%;H%; : REM LOAD COLOUR BITMAP DATA INTO CURRENT BITMAP.
1340 FOR I%=0 TO (W%*H%*3)-1 STEP 3 : REM LOOP 16x16x3 EACH PIXEL R,G,B.
1350 r% = ?(graphics+I%+0) : REM VOODOO HAPPENS HERE.
1360 g% = ?(graphics+I%+1) : REM CAN ANYONE EXPLAIN.
1370 b% = ?(graphics+I%+2) : REM AS I HAVE 0 IDEA.
1380 a% = r% OR g% OR b%
1390 VDU r%, g%, b%, a%
1400 NEXT
1410 ENDPROC : REM END PROC_LOAD_SPRITE.