-
Notifications
You must be signed in to change notification settings - Fork 1
/
gestport.c
110 lines (83 loc) · 2.58 KB
/
gestport.c
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 "plateform.h"
#include "config.h"
#include "ppi.h"
#include "crtc.h"
#include "upd.h"
#include "vga.h"
#include "gestport.h"
u8 ReadPort( core_crocods_t *core, u16 port )
{
if (port==0xfefe) {
return 0xaa; // CrocoDS Rompack
}
if ( ! ( port & 0x0480 ) ) {
return( ReadUPD( core, port ) );
}
if ( ! ( port & 0x0800 ) ) {
u16 index = (port & 0x0300) >> 8;
if (index == 3)
{
printf("index 3\n");
// Data = PPI_ReadControl();
return( ReadPPI( core, port ) );
} else {
// Data = PPI_ReadPort(Index);
return( ReadPPI( core, port ) );
}
}
// Kempston Mouse http://www.cpcwiki.eu/index.php/Kempston_Mouse - test4.dsk in Arnold "acid" test and with Carrier.DSK
if (port == 0xFBEE) { // I/O port for X position is decoded as xxxx x0x1 xxx0 xxx0
return core->kempstonMouseX;
}
if (port == 0xFBEF) { // I/O port for Y position is decoded as xxxx x0x1 xxx0 xxx1
return core->kempstonMouseY;
}
if (port == 0xFAEF) { // I/O port for Buttons is decoded as xxxx x0x0 xxx0 xxxx
u8 button = core->kempstonMouseButton;
core->kempstonMouseButton = 0;
return button;
}
printf("Read P%04X\n", port);
return( 0xFF );
}
void WritePort( core_crocods_t *core, u16 port, u8 val )
{
// port=0; // A effacer
// http://cpcwiki.eu/index.php/Default_I/O_Port_Summary
// http://cpcwiki.eu/index.php/I/O_Port_Summary
// http://www.cpcwiki.eu/index.php/M4_Board <-- for the M4
if ( ( port & 0xC000 ) == 0x04000 ) {
// strcat(chaine, " VGA");
WriteVGA( core, port, val );
return;
}
if ( ! ( port & 0x4000 ) ) {
// strcat(chaine, " CRC");
WriteCRTC( core, port, val );
return;
}
if ( ! ( port & 0x2000 ) ) {
// strcat(chaine, " ROM");
WriteROM( core, val );
return;
}
if ( ! ( port & 0x1000 ) ) {
// strcat(chaine, " PRN");
// PrintVal( val );
return;
}
if ( ! ( port & 0x0800 ) ) {
// strcat(chaine, " PPI");
WritePPI( core, port, val );
return;
}
if ( ! ( port & 0x0480 ) ) {
// strcat(chaine, " UPD");
WriteUPD( core, port, val );
return;
}
if (port==0xF8FF) { // Peripheral Soft Reset -> Do nothing
return;
}
printf("Write P%04X %d\n", port, val);
}