Skip to content

Commit 7578cc3

Browse files
Merge branch 'viewport' of https://github.com/leighbb/agon-bbc-basic into leighbb-viewport
2 parents d39c7bd + 32cfe3f commit 7578cc3

1 file changed

Lines changed: 69 additions & 0 deletions

File tree

tests/viewport.bas

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
10 REM Text Viewport Example using VDU 28
2+
20 :
3+
30 CLS
4+
40 :
5+
50 cols%=FN_getScreenCols - 1
6+
60 rows%=FN_getScreenRows - 1
7+
70 :
8+
80 REM Create a border around the screen
9+
90 :
10+
100 REM Top line
11+
110 PROC_fill(0,0,cols%,0)
12+
120 REM Left side
13+
130 PROC_fill(0,rows%-1,0,1)
14+
140 REM Right side
15+
150 PROC_fill(cols%,rows%-1,cols%,1)
16+
160 REM Bottom line
17+
170 PROC_fill(0,rows%,cols%,rows%)
18+
180 :
19+
190 REM Display some text in various sizes of viewport
20+
200 t% = 2
21+
210 b% = 2
22+
220 l% = 2
23+
230 r% = cols% - 2
24+
240 size% = 1
25+
250 REPEAT
26+
260 PROC_stars(l%,b%,r%,t%)
27+
270 t% = b% + 2
28+
280 size% = size% + 1
29+
290 r% = r% - 1
30+
300 b% = t% + size%
31+
310 UNTIL b% > rows% - 1 OR r% < l%
32+
320 :
33+
330 k%=GET
34+
480 END
35+
490 :
36+
500 DEF PROC_fill(L%,B%,R%,T%)
37+
510 VDU 28,L%,B%,R%,T%
38+
520 VDU 17,191,17,0
39+
530 VDU 12
40+
540 VDU 17,128,17,63
41+
550 VDU 26
42+
560 ENDPROC
43+
570 :
44+
600 DEF FN_getScreenCols
45+
610 REM A% is the OSBYTE command to run
46+
620 A%=&A0
47+
630 REM L% is the sysvar to fetch
48+
640 L%=&13
49+
650 =USR(&FFF4)
50+
660 :
51+
700 DEF FN_getScreenRows
52+
710 REM A% is the OSBYTE command to run
53+
720 A%=&A0
54+
730 REM L% is the sysvar to fetch
55+
740 L%=&14
56+
750 =USR(&FFF4)
57+
760 :
58+
800 DEF PROC_stars(L%,B%,R%,T%)
59+
810 VDU 28,L%,B%,R%,T%
60+
820 C% = (R% -L% + 1) * (B% - T% + 1) * 2 - 1
61+
830 PATTERN$ = "/-|\*"
62+
840 J% = 1
63+
850 FOR I% = 1 TO C%
64+
860 PRINT MID$(PATTERN$, J%, 1);
65+
870 J% = J% + 1
66+
880 IF J% = 6 THEN J% = 1
67+
890 NEXT I%
68+
900 VDU 26
69+
910 ENDPROC

0 commit comments

Comments
 (0)