-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMMC_ElkPlus1.asm
98 lines (83 loc) · 1.36 KB
/
MMC_ElkPlus1.asm
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
\\ EXPERIMENTAL DRIVER FOR ELK PLUS 1
\\ WITH MMC CONNECTED TO PRINTER PORT
IF _ELECTRON_
data%=&FC71
status%=&FC72
ELSE
data%=&FEDC
status%=&FEDC
ENDIF
\\ MOSI is connected to D0
\\ SCK is connected to D1
\\ MISO is connected to Ack
clockbit%=&02
one_clockhigh%=&FF
one_clocklow%=&FF-clockbit%
\\ This is unused on the Electron, according to the EAUG
sr%=&F8
\\ Start of Plus One specific code
MACRO READ_BIT
STX data%
STA data%
ROL status%
ROL sr%
ENDMACRO
\\ Read byte (User Port)
\\ Write FF
.MMC_GetByte
.P1_ReadByte
LDA #one_clockhigh%
LDX #one_clocklow%
\\ Read first bit
READ_BIT
\\ Fall through to...
\\ This is always entered with A and X with the correct values
.P1_ReadBits7
READ_BIT
READ_BIT
READ_BIT
READ_BIT
READ_BIT
READ_BIT
READ_BIT
LDA sr%
RTS
\\ wait for response bit
\\ ie for clear bit
.P1_WaitResp
{
LDA #one_clockhigh%
LDX #one_clocklow%
LDY #0
.loop
DEY
BEQ timeout
STX data%
STA data%
ROL status%
BCS loop
.timeout
ROL sr%
RTS
}
\\ Write byte (User Port)
\\ Ignore byte in
.P1_WriteByte
{
ASL A
FOR N, 0, 7
ROL A
AND #&FD
STA data%
ORA #clockbit%
STA data%
NEXT
RTS
}
\\ RESET DEVICE
.MMC_DEVICE_RESET
RTS
\\ INITIALIZE DEVICE IN SPI MODE
.MMC_SlowClocks
JMP MMC_Clocks
INCLUDE "MMC_PrinterCommon.asm"