-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo_12_mapmaker2.bas
165 lines (165 loc) · 7.36 KB
/
demo_12_mapmaker2.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
10 REM ******************************
20 REM * AGON LIGHT 2 *
30 REM * DEMO 12 *
40 REM * BBC BASIC MODE 8 *
50 REM * MAP MAKER 02 *
60 REM * NEEDS SPED >1.02 RGBA8 *
70 REM * BY LOVEJOY777 *
80 REM * MAP MAKER BY 8BITVINO. *
90 REM * SPED BY ROBOGEEK42. *
100 REM ******************************
110 MB%=&40000 : REM MEMORY BANK ADDRESS &40000.
120 DIM graphics 1024 : REM ARRAY FOR BITMAP PIXELS.
130 DIM the_map%(14,14) : REM ARRAY FOR TILE GRID.
140 MYMAP$="utils/mm/maps/plat01.map" : REM CHANGE TO YOUR MAP FILE PATH.
150 TILEPACKPATH$="utils/mm/mt" : REM CHANGE TO YOUR TILES DIRECTORY PATH.
160 XSIZE%=14:YSIZE%=14:XIMP%=0:YIMP%=0:x%=114:y%=96:SPEED%=2 : REM VARS.
170 :
180 VDU 23,27,16 : REM CLEAR ALL SPRITE AND BITMAP DATA.
190 MODE 8 : REM SET SCREEN MODE.
200 CLS : REM CLEAR THE SCREEN.
210 VDU 23,1,0 : REM DISABLE CURSOR.
220 :
230 PROC_LOAD_BITMAPS
240 PROC_LOAD_MAP
250 PROC_LOAD_LEGEND
260 PROC_SETUP_SPRITE_RIGHT : REM SETUP SPRITE 1, RIGHT.
270 PROC_SETUP_SPRITE_LEFT : REM SETUP SPRITE 2, LEFT.
280 PROC_SETUP_SPRITE_UPDOWN : REM SETUP SPRITE 3, UP/DOWN.
290 PROC_MOVE_SPRITE_RIGHT : REM DRAW PLAYER TO THE SCREEN AT START.
300 PROC_SHOW_MAP : REM DRAW MAP TO THE SCREEN.
305 :
310 ON ERROR PROC_SHOW_MAP : GOTO350 :REM used to stop Escape key from stopping program and refreshes instead.
320 :
350 REM **** GAME LOOP ****
360 A%=INKEY(0) : REM GET KEYBOARD INPUT FROM PLAYER.
370 IF A%=21 THEN x%=x%+SPEED% : PROC_MOVE_SPRITE_RIGHT : REM MOVE SPRITE1 RIGHT.
380 IF A%=8 THEN x%=x%-SPEED% : PROC_MOVE_SPRITE_LEFT : REM MOVE SPRITE LEFT.
390 IF A%=10 THEN y%=y%+SPEED% : PROC_MOVE_SPRITE_UPDOWN : REM MOVE SPRITE UP.
400 IF A%=11 THEN y%=y%-SPEED% : PROC_MOVE_SPRITE_UPDOWN : REM MOVE SPRITE DOWN.
410 IF A%=120 OR A%=88 THEN PROC_CHECK_EXIT : REM (X) Exit.
420 :
430 REM KEEP THE SPRITE WITHIN THE SCREEN BOUNDS (320x240 for mode 8 ).
440 IF x%>222 THEN x%=222 : REM SCREEN WIDTH BOUNDS.
450 IF x%<2 THEN x%=2
460 IF y%>222 THEN y%=222 : REM SCREEN HEIGHT BOUNDS.
470 IF y%<2 THEN y%=2
480 :
490 GOTO 350 : REM **** END GAME LOOP ****.
510 :
520 DEF PROC_LOAD_LEGEND
530 PRINT TAB(31,0);"X = eXit"
540 ENDPROC
550 :
560 DEF PROC_LOAD_BITMAPS : REM LOADING BITMAPS SCREEN.
570 PRINT TAB(10,15);" Loading bitmaps...."
580 FOR L%= 24 TO 0 STEP -1
590 PROC_LOAD_BITMAP(STR$(L%),L%,16,16)
600 NEXT
610 COLOUR10 : PRINT TAB(15,18);"GO!"
620 ENDPROC : REM END PROC_LOAD_LEGEND.
630 :
640 DEF PROC_LOAD_BITMAP(F$,N%,W%,H%) : REM LOAD ALL BITMAPS INTO MEMORY.
650 IF N%=9 THEN PRINT TAB(20,18);" "
660 PRINT TAB(19,18);F$; : REM SHOW A COUNTDOWN.
670 OSCLI("LOAD " + TILEPACKPATH$ + "/" + F$ + ".rgb " + STR$(MB%+graphics))
680 VDU 23,27,0,N% : REM SELECT SPRITE n (equating to buffer ID numbered 64000+n).
690 VDU 23,27,1,W%;H%; : REM LOAD COLOUR BITMAP DATA INTO CURRENT SPRITE.
700 FOR I%=0 TO (W%*H%*4) -1 STEP 4 : REM LOOP 16x16x4 EACH PIXEL R,G,B,A.
710 r% = ?(graphics+I%+0) : REM RED DATA.
720 g% = ?(graphics+I%+1) : REM GREEN DATA.
730 b% = ?(graphics+I%+2) : REM BLUE DATA.
740 a% = ?(graphics+I%+3) : REM ALPHA (TRANSPARENCY).
750 VDU r%, g%, b%, a%
760 NEXT
770 ENDPROC : REM END PROC_LOAD_BITMAP.
780 :
790 DEF PROC_SHOW_MAP
800 REM outputs each map location and moves 16 pixels to next. End of each line resets location.
810 XLOC%=0 : YLOC%=0
820 FOR j=0 TO 14
830 FOR i=0 TO 14
840 g%=the_map%(i,j)
850 VDU 23,27,0,g% : REM SELECT THE SPECIFIED BITMAP.
860 VDU 23,27,3,YLOC%;XLOC%; : REM DISPLAY THE BITMAP AT Y,X.
870 XLOC%=XLOC%+16 : REM UPDATE THE X LOCATION TO MOVE TO THE RIGHT.
880 IF i=14 THEN YLOC%=YLOC%+16:XLOC%=0 : REM AT THE END OF THE ROW MOVE TO START THE NEXT LINE DOWN.
890 NEXT
900 NEXT
920 ENDPROC : REM END PROC_SHOW_MAP.
930 :
940 DEF PROC_LOAD_MAP
950 fnum=OPENIN MYMAP$
960 IF fnum=0 THEN PRINTTAB(7,14);"Filename NOT loaded": GOTO1040
970 INPUT#fnum,XIMP% : REM READ X MAP SIZE.
980 INPUT#fnum,YIMP% : REM READ Y MAP SIZE.
990 FOR i=0 TO XIMP% : REM READ X MAP BASED ON THE DEFINED SIZE.
1000 FOR j=0 TO YIMP%
1010 INPUT#fnum,the_map%(i,j) : REM SAVE TO MAP.
1020 NEXT
1030 NEXT
1040 CLOSE#fnum
1050 ENDPROC : REM END PROC_LOAD_MAP.
1060 :
1070 DEF PROC_CHECK_EXIT
1080 PRINT TAB(7,14);"Quit: Are you sure?"
1090 PRINT TAB(7,16);"Press Y to confirm"
1100 N$=GET$
1110 IF N$="y" OR N$= "Y" THEN GOTO 1140
1120 PROC_SHOW_MAP
1130 ENDPROC
1140 MODE8 : P."GOODBYE!" : END
1145 :
1150 REM **** SETUP SPRITE 1 PLAYER RIGHT ****.
1160 DEF PROC_SETUP_SPRITE_RIGHT
1170 VDU 23,27,4,0 : REM SELECT SPRITE 1 (buffer ID number).
1180 VDU 23,27,5 : REM CLEAR FRAMES FOR CURRENT SPRITE.
1190 VDU 23,27,6,19 : REM ADD BITMAP 19 AS FRAME 1 OF SPRITE 1.
1200 VDU 23,27,6,20 : REM ADD BITMAP 20 AS FRAME 2 OF SPRITE 1.
1210 VDU 23,27,7,1 : REM ACTIVATE SPRITE 1 (sprite ID number).
1250 ENDPROC : REM END PROC_SETUP_SPRITE_RIGHT.
1260 :
1270 REM **** SETUP SPRITE 2 PLAYER LEFT ****.
1280 DEF PROC_SETUP_SPRITE_LEFT
1290 VDU 23,27,4,1 : REM SELECT SPRITE 2 (buffer ID number).
1300 VDU 23,27,5 : REM CLEAR FRAMES FOR CURRENT SPRITE.
1310 VDU 23,27,6,21 : REM ADD BITMAP 21 AS FRAME 1 OF SPRITE 2.
1320 VDU 23,27,6,22 : REM ADD BITMAP 22 AS FRAME 2 OF SPRITE 2.
1330 VDU 23,27,7,2 : REM ACTIVATE SPRITE 2 (sprite ID number).
1340 ENDPROC : REM END PROC_SETUP_SPRITE_LEFT.
1350 :
1360 REM **** SETUP SPRITE 3 PLAYER UP/DOWN ****.
1370 DEF PROC_SETUP_SPRITE_UPDOWN
1390 VDU 23,27,4,2 : REM SELECT SPRITE 3 (buffer ID number).
1400 VDU 23,27,5 : REM CLEAR FRAMES FOR CURRENT SPRITE.
1410 VDU 23,27,6,23 : REM ADD BITMAP 23 AS FRAME 1 OF SPRITE 3.
1420 VDU 23,27,6,24 : REM ADD BITMAP 24 AS FRAME 2 OF SPRITE 3.
1430 VDU 23,27,7,3 : REM ACTIVATE SPRITE 3 (sprite ID number).
1440 ENDPROC : REM END PROC_SETUP_SPRITE_UPDOWN.
1450 :
1460 DEF PROC_MOVE_SPRITE_RIGHT : REM **** MOVE PLAYER RIGHT ****.
1470 VDU 23,27,12 : REM HIDE PREVIOUS SPRITE.
1480 VDU 23,27,4,0 : REM SELECT SPRITE 1 (buffer ID number).
1490 VDU 23,27,11 : REM SHOW THE CURRENT SPRITE 1.
1500 VDU 23,27,8 : REM NEXT FRAME.
1510 VDU 23,27,13,x%;y%; : REM MOVE CURRENT SPRITE TO POS X,Y.
1520 VDU 23,27,15 : REM UPDATE THE SPRITES IN THE GPU.
1530 ENDPROC : REM END PROC_MOVE_SPRITE_RIGHT.
1540 :
1550 DEF PROC_MOVE_SPRITE_LEFT : REM **** MOVE PLAYER LEFT ****.
1560 VDU 23,27,12 : REM HIDE PREVIOUS SPRITE.
1570 VDU 23,27,4,1 : REM SELECT SPRITE 2 (buffer ID number).
1580 VDU 23,27,11 : REM SHOW THE CURRENT SPRITE 2.
1590 VDU 23,27,8 : REM NEXT FRAME.
1600 VDU 23,27,13,x%;y%; : REM MOVE CURRENT SPRITE TO POS X,Y.
1610 VDU 23,27,15 : REM UPDATE THE SPRITES IN THE GPU.
1620 ENDPROC : REM END PROC_MOVE_SPRITE_LEFT.
1630 :
1640 DEF PROC_MOVE_SPRITE_UPDOWN : REM **** MOVE PLAYER UP/DOWN ****.
1650 VDU 23,27,12 : REM HIDE PREVIOUS SPRITE.
1660 VDU 23,27,4,2 : REM SELECT SPRITE 3 (buffer ID number).
1670 VDU 23,27,11 : REM SHOW THE CURRENT SPRITE 3.
1680 VDU 23,27,8 : REM NEXT FRAME.
1690 VDU 23,27,13,x%;y%; : REM MOVE CURRENT SPRITE TO POS X,Y.
1700 VDU 23,27,15 : REM UPDATE THE SPRITES IN THE GPU.
1710 ENDPROC : REM END PROC_MOVE_SPRITE_UPDOWN.