-
Notifications
You must be signed in to change notification settings - Fork 0
/
dsr_dsrlnk.c
43 lines (36 loc) · 1.06 KB
/
dsr_dsrlnk.c
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
// DSR interface code for the TI-99/4A by Tursi
// You can copy this file and use it at will ;)
#include "files.h"
#include "vdp.h"
#include "string.h"
// NOTE: because this does not return the entire PAB back to you,
// if you need data from the DSR other than the error byte
// (ie: RECORD NUMBER), then you have to get it yourself!
unsigned char dsrlnk(struct PAB *pab, unsigned int vdp) {
unsigned char x;
// copies your PAB to VDP and then executes the call through dsrlnkraw
vdpmemcpy(vdp, (const unsigned char*)pab, 9);
// assumes vdpmemcpy leaves the VDP address in the right place!
if (pab->NameLength == 0) {
x = strlen((char*)pab->pName);
} else {
x= pab->NameLength;
}
VDPWD(x);
// and the filename itself - note we assume 'x' is valid!
unsigned char *p = pab->pName;
while (x--) {
VDPWD(*(p++));
}
// now we can call it
if (dsrlnkraw(vdp)) {
return DSR_ERR_DSRNOTFOUND;
}
unsigned char ret = vdpreadchar(vdp+1);
ret = GET_ERROR(ret);
if (ret != 0) {
return ret;
}
// all good, presumably
return DSR_ERR_NONE;
}