source: thomson/code/C/HxCHost/macros.h@ 7cabd49

main
Last change on this file since 7cabd49 was 7cabd49, checked in by Adrien Destugues <pulkomandy@…>, 12 years ago

HxC host software : work at Forever XIII party

  • Switch to lwtools gcc toolchain
  • Fix some bugs.
  • Editing the HxC settings works
  • Selecting a floppy image works (sometimes)

git-svn-id: svn://localhost/thomson@24 85ae3b6b-dc8f-4344-a89d-598714f2e4e5

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