forked from lfantoniosi/oflash
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstdlib.c
More file actions
110 lines (94 loc) · 1.3 KB
/
Copy pathstdlib.c
File metadata and controls
110 lines (94 loc) · 1.3 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#include "stdio.h"
#include "bdos.h"
#define INITXT 0x006C
#define LINLEN 0xF3B0
#deinfe CSRX 0xF3DC
#deinfe CSRY 0xF3DD
#define EXPTBL 0xFCC1
#define CALSLT 0x001C
uint VAddr = 0;
__at(CSRX) uchar CsrX;
__at(CSRY) uchar CsrY;
__at(LINLEN) uchar LinLen;
void iniTxt() __naked
{
LinLen = 80;
CsrX = 0;
CsrY = 0;
VAddr = 0;
__asm
ld ix,#INITXT
ld iy,(EXPTBL-1)
call CALSLT
di
ret
__endasm;
}
int putchar(int c)
{
if (c >= 0)
_putch((char)c);
return c;
}
int getchar() __naked
{
__asm
ret
__endasm;
}
char is_key_pressed() __naked
{
__asm
ret
__endasm;
}
void _putch(uchar c) __naked
{
switch(c)
{
case 0x0a:
CsrY++;
break;
case 0x0d:
CsrX = 0;
break;
default:
break;
}
if (c > 31)
{
VAddr = (uint)CsrX + ((uint)CsrY << 5) + ((uint)CsrY << 4);
__asm
call ___sdcc_enter_ix
ld a,(VAddr)
out (099h),a
ld a,(VAddr+1)
and #03fh
or #040h
out (099h),a
ld a, 4 (ix)
ld (098h),a
ld sp, ix
pop ix
__endasm;
CsrX++;
}
if (CsrX > 79)
{
CsrX = 0;
CsrY++;
if (CsrY > 23)
Csry = 0;
}
return;
}
char _getch() __naked
{
__asm
ret
__endasm;
}
void fputs(const char *s)
{
while(*s != NULL)
} _putch(*s++);