1 | // 5 : MO5 / 8: TO8
|
---|
2 |
|
---|
3 | #ifndef PLATFORM
|
---|
4 | #error "make TARGET=TO8 or make TARGET=MO5"
|
---|
5 | #endif
|
---|
6 |
|
---|
7 | ///////////////////////////////////////
|
---|
8 | // THOMSON.H
|
---|
9 | ///////////////////////////////////////
|
---|
10 |
|
---|
11 | /* MONITOR ZERO-PAGE */
|
---|
12 | #define KEY (*(volatile unsigned char*)(MONBASE + 0x37))
|
---|
13 | #define DKOPC (*(volatile unsigned char*)(MONBASE + 0x48))
|
---|
14 | #define DKDRV (*(volatile unsigned char*)(MONBASE + 0x49))
|
---|
15 | /* 204A is unused */
|
---|
16 | #define DKTRK (*(volatile unsigned char*)(MONBASE + 0x4B))
|
---|
17 | #define DKSEC (*(volatile unsigned char*)(MONBASE + 0x4C))
|
---|
18 | #define DKSTA (*(volatile unsigned char*)(MONBASE + 0x4E))
|
---|
19 | #define DKBUF (*(volatile unsigned int*)(MONBASE + 0x4F))
|
---|
20 |
|
---|
21 | #define DKint1 (*(volatile unsigned int*)(MONBASE + 0x52))
|
---|
22 |
|
---|
23 | void printhex(unsigned char i);
|
---|
24 | extern unsigned char mark[];
|
---|
25 |
|
---|
26 | /* HARDWARE */
|
---|
27 | #define FDC_STATUS (*(volatile unsigned char*)(FDCBASE))
|
---|
28 |
|
---|
29 | ////////////////////////////////////////
|
---|
30 | // MO5.H
|
---|
31 | ////////////////////////////////////////
|
---|
32 |
|
---|
33 | #if PLATFORM == 5
|
---|
34 | /*****************************************************************************
|
---|
35 | * MOx CODE
|
---|
36 | ****************************************************************************/
|
---|
37 | #define MONBASE 0x2000
|
---|
38 | #define FDCBASE 0xA7D0
|
---|
39 |
|
---|
40 | /* MONITOR ENTRY POINTS */
|
---|
41 | #define mon_putc(car) { \
|
---|
42 | asm("swi \t \t; MO5 monitor\n"\
|
---|
43 | ".fcb \t2 \t; putc"\
|
---|
44 | ::"B" ((unsigned char) (car))\
|
---|
45 | ); \
|
---|
46 | }
|
---|
47 |
|
---|
48 |
|
---|
49 | #define write(track, sector, buffer) {\
|
---|
50 | DKTRK = (unsigned char)track;\
|
---|
51 | DKSEC = (unsigned char)sector;\
|
---|
52 | DKOPC = 8;\
|
---|
53 | DKBUF = (unsigned int)buffer;\
|
---|
54 | \
|
---|
55 | asm("swi \t \t; MO5 monitor\n"\
|
---|
56 | ".fcb \t0x26 \t; DKCONT"\
|
---|
57 | ); \
|
---|
58 | }
|
---|
59 |
|
---|
60 | /* FLOPPY DRIVE MONITOR ROM */
|
---|
61 | inline void read(unsigned char track, unsigned char sector, unsigned char* output)
|
---|
62 | {
|
---|
63 | for(;;)
|
---|
64 | {
|
---|
65 | DKTRK = (unsigned char)track;
|
---|
66 | DKSEC = (unsigned char)sector;
|
---|
67 | DKOPC = 2;
|
---|
68 | DKBUF = (unsigned int)output;
|
---|
69 |
|
---|
70 | asm("swi \t \t; MO5 monitor\n"
|
---|
71 | ".fcb \t0x26 \t; DKCONT"
|
---|
72 | );
|
---|
73 |
|
---|
74 | if (DKSTA == 0x44 || DKSTA == 0) return; // Sector read ok!
|
---|
75 | printhex(DKSTA);
|
---|
76 | }
|
---|
77 | }
|
---|
78 |
|
---|
79 |
|
---|
80 | /*
|
---|
81 | #define write(track, sector, buffer) {\
|
---|
82 | DKBUF = (unsigned int)buffer; \
|
---|
83 | asm("ORCC \t#0x50 \t \n"\
|
---|
84 | "LDX \t#0xA7D0 \t \n"\
|
---|
85 | "LDU \t0x204F \t;DKBUF \n"\
|
---|
86 | "STD \t1,X \t \n"\
|
---|
87 | "LEAY \t3,X \t \n"\
|
---|
88 | "LDA \t#0xA8 \t \n"\
|
---|
89 | "STA \t,X \t \n"\
|
---|
90 | "BSR \t_delay \t \n"\
|
---|
91 | "BRA \tdo \t \n"\
|
---|
92 | "load: \tSTA \t,U+ \n"\
|
---|
93 | "do: \tLDA \t,Y\n"\
|
---|
94 | "wai: \tLDB \t,X\n"\
|
---|
95 | "BITB \t#2 \t \n"\
|
---|
96 | "BNE \tload \t \n"\
|
---|
97 | "BITB \t#1 \t \n"\
|
---|
98 | "BNE \twai \t \n"\
|
---|
99 | "ANDCC \t#0xAF \t \n"\
|
---|
100 | ::"d" ((unsigned int)(track<<8|sector))\
|
---|
101 | :"x","y","u");\
|
---|
102 | }*/
|
---|
103 |
|
---|
104 | // seeking with the system functions work fine on MO5
|
---|
105 | #define seek() ;
|
---|
106 |
|
---|
107 | #else
|
---|
108 | /*****************************************************************************
|
---|
109 | * TOx CODE
|
---|
110 | ****************************************************************************/
|
---|
111 | /* MONITOR ENTRY POINTS */
|
---|
112 | #define mon_putc(car) { \
|
---|
113 | asm("JSR \t0xE803 \t; TO8 PUTC\n"\
|
---|
114 | ::"B" ((unsigned char) (car))\
|
---|
115 | ); \
|
---|
116 | }
|
---|
117 |
|
---|
118 | #define MONBASE 0x6000
|
---|
119 |
|
---|
120 | #define write(track, sector, buffer) {\
|
---|
121 | DKTRK = (unsigned char)track;\
|
---|
122 | DKSEC = (unsigned char)sector;\
|
---|
123 | DKOPC = 8;\
|
---|
124 | DKBUF = (unsigned int)buffer;\
|
---|
125 | \
|
---|
126 | asm("JSR \t 0xE004 \t; TO8 DKCONT\n"\
|
---|
127 | ); \
|
---|
128 | }
|
---|
129 |
|
---|
130 | /* FLOPPY DRIVE MONITOR ROM */
|
---|
131 | inline void read(unsigned char track, unsigned char sector,
|
---|
132 | unsigned char* output)
|
---|
133 | {
|
---|
134 | for(;;)
|
---|
135 | {
|
---|
136 | DKTRK = (unsigned char)track;
|
---|
137 | DKSEC = (unsigned char)sector;
|
---|
138 | DKOPC = 2;
|
---|
139 | DKBUF = (unsigned int)output;
|
---|
140 |
|
---|
141 | asm("JSR \t 0xE004 \t \n"); \
|
---|
142 |
|
---|
143 | if (DKSTA == 0x44 || DKSTA == 0) return; // Sector read ok!
|
---|
144 | printhex(DKSTA);
|
---|
145 | }
|
---|
146 | }
|
---|
147 |
|
---|
148 | // The TO8 floppy ROM has a limitation at 127 tracks. We have to hack around
|
---|
149 | // it. to get to track 255.
|
---|
150 | inline void seek()
|
---|
151 | {
|
---|
152 | // first, go on track 127
|
---|
153 | DKTRK = 127;
|
---|
154 | DKOPC = 2;
|
---|
155 | asm("JSR \t 0xE004 \t \n"); \
|
---|
156 |
|
---|
157 | // Make the system think it's on track 79 (as that's what it will read from the HxC)
|
---|
158 | DKint1 = 79;
|
---|
159 | // Ask it to go to track 127 again (so we get to 127+127 = 254)
|
---|
160 | DKTRK = 127;
|
---|
161 | DKOPC = 2;
|
---|
162 | asm("JSR \t 0xE004 \t \n"); \
|
---|
163 | DKint1 = 79;
|
---|
164 | // Ask it to go to track 127 again (so we get to 127+127 = 254)
|
---|
165 | DKTRK = 127;
|
---|
166 | DKOPC = 2;
|
---|
167 | asm("JSR \t 0xE004 \t \n"); \
|
---|
168 | DKint1 = 79;
|
---|
169 | // Ask it to go to track 127 again (so we get to 127+127 = 254)
|
---|
170 | DKTRK = 127;
|
---|
171 | DKOPC = 2;
|
---|
172 | asm("JSR \t 0xE004 \t \n"); \
|
---|
173 | DKint1 = 79;
|
---|
174 | // Ask it to go to track 127 again (so we get to 127+127 = 254)
|
---|
175 | DKTRK = 127;
|
---|
176 | DKOPC = 2;
|
---|
177 | asm("JSR \t 0xE004 \t \n"); \
|
---|
178 | DKint1 = 79;
|
---|
179 | // Ask it to go to track 127 again (so we get to 127+127 = 254)
|
---|
180 | DKTRK = 127;
|
---|
181 | DKOPC = 2;
|
---|
182 | asm("JSR \t 0xE004 \t \n"); \
|
---|
183 |
|
---|
184 | // Make the system think it's on track 255, so next commands don't try to
|
---|
185 | // seek to it again the broken way
|
---|
186 | DKint1 = 255;
|
---|
187 | }
|
---|
188 | #endif
|
---|
189 |
|
---|