File: m7point

package info (click to toggle)
brandy 1.23.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,268 kB
  • sloc: ansic: 39,421; makefile: 91; sh: 1
file content (64 lines) | stat: -rw-r--r-- 1,686 bytes parent folder | download | duplicates (3)
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
REM Library for pixel plotting in MODE 7

REM Using a virtual coordinate system that has 0,0 at the bottom left.
REM 0,0 corresponds to the bottom line, second character cell
REM (as it's impossible to put graphics in the left-most cell)
REM X range is 0 to 77. Y range is 0 to 74 (3 vertical per sixel)

DEFFNsxbit(sx%, sy%)
  IF sx% = 0 AND sy% = 0 THEN =16
  IF sx% = 0 AND sy% = 1 THEN =4
  IF sx% = 0 AND sy% = 2 THEN =1
  IF sx% = 1 AND sy% = 0 THEN =64
  IF sx% = 1 AND sy% = 1 THEN =8
  IF sx% = 1 AND sy% = 2 THEN =2
=0 : REM 

REM Read the point at the specified coordinates (1=set, 0=cleared)
REM This can be optimised to one line, but it's left expanded
REM for clarity to show how it works.

DEFFNpoint(x%,y%)
LOCAL cx%,cy%,chr%,sx%,sy%
REM Get character cell
cx% = 1+(x% DIV 2)
cy% = 24-(y% DIV 3)
chr%=GET(cx%,cy%) AND &5F
sx% = x% MOD 2
sy% = y% MOD 3
=SGN(chr% AND FNsxbit(sx%,sy%))

REM Plot a Teletext sixel point. The first parameter means:
REM 0: Clear the point
REM 1: Set the point
REM 2: Toggle the point
DEFPROCpoint(cmd%, x%, y%)
LOCAL cx%,cy%,chr%,sx%,sy%,tx%,ty%
REM Get character cell
cx% = 1+(x% DIV 2)
cy% = 24-(y% DIV 3)
chr%=GET(cx%,cy%) AND &5F
sx% = x% MOD 2
sy% = y% MOD 3
CASE cmd% OF
  WHEN 0:chr% AND=(&5F - FNsxbit(sx%,sy%))
  WHEN 1:chr% OR=FNsxbit(sx%,sy%)
  WHEN 2:chr% EOR=FNsxbit(sx%,sy%)
ENDCASE
tx%=POS: ty%=VPOS
PRINT TAB(cx%,cy%)CHR$(chr% OR 160);TAB(tx%,ty%);
ENDPROC

REM Converts screen coordinates (like those returned by MOUSE) to
REM MODE 7 sixel coordinates used by these other functions

DEFFNscreen2m7(x%,y%)
x%=(x%/16)-2
y%=(y%/13.3333)
IF x%<0THENx%=0
=x%+(y%*256)

DEF FNscreen2chr(x%,y%)
x%=x%/32
y%=25-(y%/40)
=x%+(y%*256)