File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ #ScrAddress
2+
3+ This function returns the address in screen memory of the TOP line of the character in print position X-Y.
4+ Remember that the next line will be 256 bytes further on, and the 3rd line 256 further again and so forth,
5+ for 7 more lines.
6+
7+ ```
8+ FUNCTION scrAddress(x as uByte, y as uByte) as Uinteger
9+ asm
10+ ; This function returns the address into HL of the screen address
11+ ; x,y in character grid notation.
12+ ; Original code was extracted by BloodBaz
13+ ; x Arrives in A, y is in stack.
14+ and 31
15+ ld l,a
16+ ld a,(IX+7) ; Y value
17+ ld d,a
18+ and 24
19+ add a,64
20+ ld h,a
21+ ld a,d
22+ and 7
23+ rrca
24+ rrca
25+ rrca
26+ or l
27+ ld l,a
28+ end asm
29+ END FUNCTION
30+
31+
32+ FUNCTION attrAddress (x as uByte, y as uByte) as uInteger
33+ ';; This function returns the memory address of the Character Position
34+ ';; x,y in the attribute screen memory.
35+ ';; Adapted from code by Jonathan Cauldwell.
36+
37+ asm
38+ ld a,(IX+7) ;ypos
39+ rrca
40+ rrca
41+ rrca ; Multiply by 32
42+ ld l,a ; Pass to L
43+ and 3 ; Mask with 00000011
44+ add a,88 ; 88 * 256 = 22528 - start of attributes.
45+ ld h,a ; Put it in the High Byte
46+ ld a,l ; We get y value *32
47+ and 224 ; Mask with 11100000
48+ ld l,a ; Put it in L
49+ ld a,(IX+5) ; xpos
50+ add a,l ; Add it to the Low byte
51+ ld l,a ; Put it back in L, and we're done. HL=Address.
52+ end asm
53+ END FUNCTION
54+ ```
55+
56+ Examples of use (though more likely to be used as parameters to other screen handling functions):
57+
58+
59+ ```
60+ Print scrAddress(8,15)
61+ Print attrAddress(8,15)
62+ ```
You can’t perform that action at this time.
0 commit comments