[go: up one dir, main page]

Menu

[r813]: / src / lib / coco / locate.c  Maximize  Restore  History

Download this file

41 lines (36 with data), 996 Bytes

 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
#include "_coco.h"
byte locate(byte column, byte row)
{
byte hrwidth;
if (isCoCo3) {
hrwidth = * (byte*) 0x00E7;
} else {
hrwidth = 0;
}
if (hrwidth == 0) { // if 32 col mode
if (column >= 32) {
return FALSE;
}
if (row >= 16) {
return FALSE;
}
* (word*) 0x0088 = 1024 + (((word) row) << 5) + column;
} else {
if (column >= 80) {
return FALSE;
}
if (row >= 24) {
return FALSE;
}
if (hrwidth == 1) // if 40 col mode
if (column >= 40) {
return FALSE;
}
asm("PSHS", "U,Y"); // protect against BASIC routine
asm("LDA", column);
asm("LDB", row);
asm("JSR", "$F8F7"); // inside the LOCATE command
asm("PULS", "Y,U");
}
return TRUE;
}