-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_05_sprites2.bas
67 lines (67 loc) · 3.24 KB
/
demo_05_sprites2.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
10 REM ******************************
20 REM * AGON LIGHT 2 *
30 REM * DEMO 05 *
40 REM * BBC BASIC MODE 8 *
50 REM * SPRITES PART 2 *
60 REM * THANKS EIGHTBITSWIDE *
70 REM * BY LOVEJOY777 *
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 FOR PIXELS ?.
140 X%=152 : Y%=112 : REM VARS FOR THE SPRITE POSITION (start at center of screen - 8 pixels).
150 :
160 REM LOAD BITMAP TO MEMORY.
170 REM THE PATHS BELOW NEEDS TO POINT TO YOUR .rgb IMAGE FILES ON YOUR SDCARD.
180 PROC_LOAD_BITMAP("/B/Images/bombw2.rgb",0,16,16) : REM CALL PROC_LOAD_BITMAP (n,w,h).
190 PROC_LOAD_BITMAP("/B/Images/bombw1.rgb",1,16,16) : REM CALL PROC_LOAD_BITMAP (n,w,h).
200 MODE 8 : REM SET SCREEN MODE.
210 VDU 17,128+7 : REM SET BG COLOUR TO GRAY.
220 CLS : REM CLEAR THE SCREEN.
230 VDU 23,1,0 : REM DISABLE CURSOR.
240 :
1000 REM SET UP A SPRITE.
1010 VDU 23,27,4,0 : REM SELECT SPRITE n (equating to buffer ID numbered 64000+n).
1020 VDU 23,27,5 : REM CLEAR FRAMES FOR CURRENT SPRITE.
1030 VDU 23,27,6,0 : REM ADD BITMAP n=0 AS FRAME 0 OF SPRITE 1.
1040 VDU 23,27,6,1 : REM ADD BITMAP n=1 AS FRAME 1 OF SPRITE 1.
1050 VDU 23,27,11 : REM SHOW THE CURRENT SPRITE.
1060 VDU 23,27,7,1 : REM ACTIVATE n SPRITE 1.
1070 :
1100 REM GAME LOOP.
1110 A%=INKEY(0) : REM GET KEYBOARD INPUT FROM PLAYER.
1120 IF A%=21 THEN X%=X%+1 : VDU 23,27,8 : REM 21 RIGHT ARROW KEY & NEXT FRAME.
1130 IF A%=8 THEN X%=X%-1 : VDU 23,27,8 : REM 8 LEFT ARROW KEY & NEXT FRAME.
1140 IF A%=10 THEN Y%=Y%+1 : VDU 23,27,8: REM 10 UP ARROW KEY & NEXT FRAME.
1150 IF A%=11 THEN Y%=Y%-1 : VDU 23,27,8 : REM 11 DOWN ARROW KEY & NEXT FRAME.
1160 :
1200 REM KEEP THE SPRITE WITHIN THE SCREEN BOUNDS (320x240 for mode 8).
1210 IF X%>304 THEN X%=304 : REM SCREEN WIDTH - 16 PIXELS
1220 IF X%<0 THEN X%=0
1230 IF Y%>224 THEN Y%=224 : REM SCREEN HEIGHT - 16 PIXELS
1240 IF Y%<0 THEN Y%=0
1250 :
1300 VDU 23,27,13,X%;Y%; : REM MOVE CURRENT SPRITE TO POS X,Y (created by cursor keys).
1310 VDU 23,27,15 : REM UPDATE THE SPRITES IN THE GPU.
1320 GOTO 1100 : REM GAME LOOP.
1330 :
2400 REM LOAD BITMAP IMAGE INTO VDP RAM.
2410 REM F$ = FILENAME/PATH OF BITMAP FROM LINES 180/190.
2420 REM N% - BITMAP NUMBER.
2430 REM W% - BITMAP WIDTH.
2440 REM H% - BITMAP HEIGHT.
2450 :
2500 DEF PROC_LOAD_BITMAP(F$,N%,W%,H%) : REM ** PROC_LOAD_BITMAP **
2510 OSCLI("LOAD " + F$ + " " + STR$(MB%+graphics)) : REM OPERATING SYSTEM CLI COMMAND.
2520 VDU 23,27,0,N% : REM SELECT SPRITE n (equating to buffer ID numbered 64000+n).
2530 VDU 23,27,1,W%;H%; : REM LOAD COLOUR BITMAP DATA INTO CURRENT SPRITE.
2540 FOR I%=0 TO (W%*H%*3)-1 STEP 3 : REM LOOP 16x16x3 EACH PIXEL R,G,B - 1 FOR LINE END.
2550 r% = ?(graphics+I%+0) : REM RED DATA.
2560 g% = ?(graphics+I%+1) : REM GREEN DATA.
2570 b% = ?(graphics+I%+2) : REM BLUE DATA.
2580 a% = r% OR g% OR b% : REM alpha ?.
2590 VDU r%, g%, b%, a% : REM unsure ?.
2600 NEXT : REM LOOP NEXT PIXEL.
2610 ENDPROC : REM END PROC_LOAD_BITMAP.