Nugget
Loading...
Searching...
No Matches
cdrom.hh
Go to the documentation of this file.
1/*
2
3MIT License
4
5Copyright (c) 2023 PCSX-Redux authors
6
7Permission is hereby granted, free of charge, to any person obtaining a copy
8of this software and associated documentation files (the "Software"), to deal
9in the Software without restriction, including without limitation the rights
10to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11copies of the Software, and to permit persons to whom the Software is
12furnished to do so, subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23SOFTWARE.
24
25*/
26
27#pragma once
28
30
32
33enum class CDL : uint8_t {
34 SYNC = 0,
35 NOP = 1,
36 SETLOC = 2,
37 PLAY = 3,
38 FORWARD = 4,
39 BACKWARD = 5,
40 READN = 6,
41 STANDBY = 7,
42 STOP = 8,
43 PAUSE = 9,
44 INIT = 10,
45 MUTE = 11,
46 UNMUTE = 12,
47 SETFILTER = 13,
48 SETMODE = 14,
49 GETMODE = 15,
50 GETLOCL = 16,
51 GETLOCP = 17,
52 READT = 18,
53 GETTN = 19,
54 GETTD = 20,
55 SEEKL = 21,
56 SEEKP = 22,
57 SETCLOCK = 23,
58 GETCLOCK = 24,
59 TEST = 25,
60 GETID = 26,
61 READS = 27,
62 RESET = 28,
63 GETQ = 29,
64 READTOC = 30,
65};
66
71
72template <typename Reg, unsigned m>
73struct Access {
74 static volatile uint8_t& access(int index = 0) {
75 Ctrl = m;
76 return Reg::access(index);
77 }
78};
79
81 void send(CDL cmd) {
82 Ctrl = 0;
83 Response = static_cast<uint8_t>(cmd);
84 }
85 template <typename... Args>
86 void send(CDL cmd, Args... args) {
87 Ctrl = 0;
88 recursiveSend(args...);
89 Response = static_cast<uint8_t>(cmd);
90 }
91
92 private:
93 void recursiveSend(uint8_t arg) { Fifo = arg; }
94 template <typename... Args>
95 void recursiveSend(uint8_t arg, Args... args) {
96 Fifo = arg;
97 recursiveSend(args...);
98 }
99};
100
101extern CommandFifo Command;
102extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0803, 0xbf801000, uint8_t>, 0>> DataRequest;
103extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0802, 0xbf801000, uint8_t>, 1>> CauseMask;
104extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0803, 0xbf801000, uint8_t>, 1>> Cause;
105extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0802, 0xbf801000, uint8_t>, 2>> LeftToLeftVolume;
106extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0803, 0xbf801000, uint8_t>, 2>> LeftToRightVolume;
107extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0801, 0xbf801000, uint8_t>, 3>> RightToRightVolume;
108extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0802, 0xbf801000, uint8_t>, 3>> RightToLeftVolume;
109extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0803, 0xbf801000, uint8_t>, 3>> VolumeSettings;
110
111} // namespace psyqo::Hardware::CDRom
uint32_t cmd
Definition dma.c:108
Definition cdrom.hh:31
CDL
Definition cdrom.hh:33
Register< 0, uint8_t, WriteQueue::Bypass, Access< BasicAccess< 0x0802, 0xbf801000, uint8_t >, 2 > > LeftToLeftVolume
Definition cdrom.cpp:48
Hardware::Register< 0x0800, uint8_t, WriteQueue::Bypass > Ctrl
Definition cdrom.cpp:29
Register< 0, uint8_t, WriteQueue::Bypass, Access< BasicAccess< 0x0803, 0xbf801000, uint8_t >, 3 > > VolumeSettings
Definition cdrom.cpp:60
Hardware::Register< 0x0802, uint8_t, WriteQueue::Bypass > Fifo
Definition cdrom.cpp:31
Register< 0, uint8_t, WriteQueue::Bypass, Access< BasicAccess< 0x0801, 0xbf801000, uint8_t >, 3 > > RightToRightVolume
Definition cdrom.cpp:54
CommandFifo Command
Definition cdrom.cpp:35
Hardware::Register< 0x0801, uint8_t, WriteQueue::Bypass > Response
Definition cdrom.cpp:30
Register< 0, uint8_t, WriteQueue::Bypass, Access< BasicAccess< 0x0803, 0xbf801000, uint8_t >, 1 > > Cause
Definition cdrom.cpp:44
Register< 0, uint8_t, WriteQueue::Bypass, Access< BasicAccess< 0x0802, 0xbf801000, uint8_t >, 3 > > RightToLeftVolume
Definition cdrom.cpp:57
Register< 0, uint8_t, WriteQueue::Bypass, Access< BasicAccess< 0x0803, 0xbf801000, uint8_t >, 0 > > DataRequest
Definition cdrom.cpp:38
Hardware::Register< 0x0803, uint8_t, WriteQueue::Bypass > InterruptControl
Definition cdrom.cpp:33
Register< 0, uint8_t, WriteQueue::Bypass, Access< BasicAccess< 0x0803, 0xbf801000, uint8_t >, 2 > > LeftToRightVolume
Definition cdrom.cpp:51
Register< 0, uint8_t, WriteQueue::Bypass, Access< BasicAccess< 0x0802, 0xbf801000, uint8_t >, 1 > > CauseMask
Definition cdrom.cpp:41
Definition cdrom.hh:73
static volatile uint8_t & access(int index=0)
Definition cdrom.hh:74
void send(CDL cmd, Args... args)
Definition cdrom.hh:86
void send(CDL cmd)
Definition cdrom.hh:81
Definition hwregs.hh:46