MCPcopy Create free account
hub / github.com/CE-Programming/CEmu / control_read

Function control_read

core/control.c:21–75  ·  view source on GitHub ↗

Read from the 0x0XXX range of ports */

Source from the content-addressed store, hash-verified

19
20/* Read from the 0x0XXX range of ports */
21static uint8_t control_read(const uint16_t pio, bool peek) {
22 uint8_t index = (uint8_t)pio;
23
24 uint8_t value;
25 (void)peek;
26
27 switch (index) {
28 case 0x02:
29 value = control.readBatteryStatus;
30 break;
31 case 0x03:
32 value = get_device_type() | asic.serFlash << 4;
33 break;
34 case 0x06:
35 value = control.protectedPortsUnlocked;
36 break;
37 case 0x08:
38 value = 0x7F;
39 break;
40 case 0x0B:
41 /* bit 1 set if charging */
42 value = control.ports[index] | control.batteryCharging << 1;
43 break;
44 case 0x0F:
45 value = control.ports[index] | usb_status();
46 //fprintf(stderr, "%06x: %3hx -> %02hhx\n", cpu.registers.PC, pio, value);
47 //debugInstruction();
48 break;
49 case 0x1C:
50 value = 0x80;
51 break;
52 case 0x1D: case 0x1E: case 0x1F:
53 value = read8(control.privileged, (index - 0x1D) << 3);
54 break;
55 case 0x20: case 0x21: case 0x22:
56 value = read8(control.protectedStart, (index - 0x20) << 3);
57 break;
58 case 0x23: case 0x24: case 0x25:
59 value = read8(control.protectedEnd, (index - 0x23) << 3);
60 break;
61 case 0x28:
62 value = control.flashUnlocked;
63 break;
64 case 0x3A: case 0x3B: case 0x3C:
65 value = read8(control.stackLimit, (index - 0x3A) << 3);
66 break;
67 case 0x3D:
68 value = control.protectionStatus;
69 break;
70 default:
71 value = control.ports[index];
72 break;
73 }
74 return value;
75}
76
77/* Write to the 0x0XXX range of ports */
78static void control_write(const uint16_t pio, const uint8_t byte, bool poke) {

Callers

nothing calls this directly

Calls 1

usb_statusFunction · 0.85

Tested by

no test coverage detected