OpenCores
URL https://opencores.org/ocsvn/z80soc/z80soc/trunk

Subversion Repositories z80soc

[/] [z80soc/] [trunk/] [V0.7.3/] [Software/] [C/] [testsys/] [z80soc.c] - Blame information for rev 46

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 46 rrred
#include <z80soc.h>
2
#include <stdio.h>
3
#include <string.h>
4
 
5
void cls(void) {
6
        __asm
7
    push    hl
8
    push    bc
9
    push    af
10
        ld              hl,(#0x57D4)
11
    ld          bc,#4799
12
cls1::
13
        ld              a,#0x20
14
        ld              (hl),a
15
    inc     hl
16
    dec     bc
17
    ld      a,b
18
    or      c
19
    jr      nz,cls1
20
    pop    af
21
    pop    bc
22
    pop    hl
23
        __endasm;
24
}
25
 
26
 
27
void writeMemory(unsigned int address, unsigned char byte)
28
{
29
    address;
30
    byte;
31
 
32
 // *(unsigned int*)address = byte;
33
 
34
    __asm
35
    pop     bc
36
    pop     hl
37
    push        hl
38
    push        bc
39
    ld      iy,#4
40
    add     iy,sp
41
    ld      d,0 (iy)
42
    ld      (hl),d
43
    __endasm;
44
}
45
 
46
unsigned char readMemory(unsigned int address) {
47
    return *(unsigned int*)address;
48
}
49
 
50
void writeMemoryInt(unsigned int address, unsigned int value)
51
{
52
    address;
53
    value;
54
 
55
   /* __asm
56
    ;asmStore16bitValue.c:4: hl = address;
57
    ld          b,-3 (ix)
58
    ld          c,-4 (ix)
59
    ;asmStore16bitValue.c:5: bc = value;
60
    ld          h,-5 (ix)
61
    ld          l,-6 (ix)
62
    ld          (hl),c
63
    inc         hl
64
    ld          (hl),b
65
    __endasm;*/
66
 
67
    __asm
68
    pop     de
69
    pop     hl
70
    pop     bc
71
    push    bc
72
    push    hl
73
    push    de
74
    ld      (hl),c
75
    inc     hl
76
    ld      (hl),b
77
    __endasm;
78
}
79
 
80
unsigned int readMemoryInt(unsigned int address) {
81
    return *(unsigned int*)address;
82
}
83
 
84
void cursorxy(short int x, short int y) {
85
        writeMemory(0x57CE, y);
86
        writeMemory(0x57CF, x);
87
        writeMemoryInt(0x57D0, readMemoryInt(0x57D4) + ( readMemory(0x57CC) * y ) + x);
88
        // printf("DEBUG: NEW VIDEO MEMORY ADDRESS:%x",readMemoryInt(0x52C6));
89
}
90
 
91
unsigned char inkey(void) {
92
        __sfr __at KBDPORT static KBDIOPort;
93
        return KBDIOPort;
94
}
95
 
96
char getchar(void) {
97
    char key;
98
        key=inkey();
99
    while (key == 0 ) {
100
        key = inkey();
101
    }
102
        return key;
103
}
104
 
105
 
106
void greenLeds(unsigned char byte) {
107
        __sfr __at GLEDSPORT static GLEDIOPort;
108
        GLEDIOPort = byte;
109
}
110
 
111
unsigned char pushButton(void) {
112
        __sfr __at PBUTTPORT static PB;
113
        return PB;
114
}
115
 
116
unsigned char dipSwitchA(void) {
117
        __sfr __at DPSWPORTA static SW;
118
        return SW;
119
}
120
 
121
void redLedsA(unsigned char byte) {
122
    __sfr __at RLEDSPORTA static RLEDIOPort;
123
    RLEDIOPort = byte;
124
}
125
 
126
void redLedsB(unsigned char byte) {
127
    __sfr __at RLEDSPORTB static RLEDIOPort;
128
    RLEDIOPort = byte;
129
}
130
 
131
void hexlsb0(unsigned char byte) {
132
    __sfr __at CHEXLSB0 static HEX01;
133
    HEX01 = byte;
134
}
135
 
136
void hexmsb0(unsigned char byte) {
137
    __sfr __at CHEXMSB0 static HEX23;
138
    HEX23 = byte;
139
}
140
 
141
void hexlsb1(unsigned char byte) {
142
    __sfr __at CHEXLSB1 static HEX01;
143
    HEX01 = byte;
144
}
145
 
146
void hexmsb1(unsigned char byte) {
147
    __sfr __at CHEXMSB1 static HEX23;
148
    HEX23 = byte;
149
}
150
 
151
unsigned char dipSwitchB(void) {
152
    __sfr __at DPSWPORTB static SW;
153
    return SW;
154
}
155
 
156
void lcdonoff(unsigned char byte) {
157
    __sfr __at LCDCTLPORT static LCDOnOffPort;
158
    LCDOnOffPort = byte;
159
}
160
 
161
void printlcd(unsigned char pos, char s[]) {
162
    unsigned char i;
163
    unsigned int lcdmem = readMemoryInt(0x57DC) + pos;
164
    for (i = 0;i < strlen(s); i++) {
165
        writeMemory(lcdmem + i, s[i]);
166
    }
167
}
168
 
169
unsigned char rotaryButton(void) {
170
    __sfr __at ROTARY static ROT;
171
    return ROT;
172
}
173
 
174
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.