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
29#include <stdint.h>
30
31#include <concepts>
32#include <type_traits>
33
36
37namespace psyqo::Hardware::CDRom {
38
39enum class CDL : uint8_t {
40 SYNC = 0,
41 NOP = 1,
42 SETLOC = 2,
43 PLAY = 3,
44 FORWARD = 4,
45 BACKWARD = 5,
46 READN = 6,
47 STANDBY = 7,
48 STOP = 8,
49 PAUSE = 9,
50 INIT = 10,
51 MUTE = 11,
52 UNMUTE = 12,
53 SETFILTER = 13,
54 SETMODE = 14,
55 GETMODE = 15,
56 GETLOCL = 16,
57 GETLOCP = 17,
58 READT = 18,
59 GETTN = 19,
60 GETTD = 20,
61 SEEKL = 21,
62 SEEKP = 22,
63 SETCLOCK = 23,
64 GETCLOCK = 24,
65 TEST = 25,
66 GETID = 26,
67 READS = 27,
68 RESET = 28,
69 GETQ = 29,
70 READTOC = 30,
71};
72
77
78template <typename Reg, unsigned m>
79struct Access {
80 static volatile uint8_t& access(int index = 0) {
81 Ctrl = m;
82 return Reg::access(index);
83 }
84};
85
87 void send(CDL cmd, const CDRomCommandBuffer& commandBuffer) {
88 Ctrl = 0;
89 for (unsigned i = 0; i < commandBuffer.size; i++) {
90 Fifo = commandBuffer.buffer[i];
91 }
92 Response = static_cast<uint8_t>(cmd);
93 }
94 void send(CDL cmd) {
95 Ctrl = 0;
96 Response = static_cast<uint8_t>(cmd);
97 }
98 template <typename... Args>
99 void send(CDL cmd, Args... args) {
100 Ctrl = 0;
101 recursiveSend(args...);
102 Response = static_cast<uint8_t>(cmd);
103 }
104
105 private:
106 void recursiveSend(uint8_t arg) { Fifo = arg; }
107 template <typename... Args>
108 void recursiveSend(uint8_t arg, Args... args) {
109 Fifo = arg;
110 recursiveSend(args...);
111 }
112};
113
114extern CommandFifo Command;
115extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0803, 0xbf801000, uint8_t>, 0>> DataRequest;
116extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0802, 0xbf801000, uint8_t>, 1>> CauseMask;
117extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0803, 0xbf801000, uint8_t>, 1>> Cause;
118extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0802, 0xbf801000, uint8_t>, 2>> LeftToLeftVolume;
119extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0803, 0xbf801000, uint8_t>, 2>> LeftToRightVolume;
120extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0801, 0xbf801000, uint8_t>, 3>> RightToRightVolume;
121extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0802, 0xbf801000, uint8_t>, 3>> RightToLeftVolume;
122extern Register<0, uint8_t, WriteQueue::Bypass, Access<BasicAccess<0x0803, 0xbf801000, uint8_t>, 3>> VolumeSettings;
123
124} // namespace psyqo::Hardware::CDRom
uint32_t cmd
Definition dma.c:108
Definition cdrom-commandbuffer.hh:34
CDL
Definition cdrom.hh:39
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:79
static volatile uint8_t & access(int index=0)
Definition cdrom.hh:80
Definition cdrom-commandbuffer.hh:39
uint8_t buffer[16]
Definition cdrom-commandbuffer.hh:46
uint8_t size
Definition cdrom-commandbuffer.hh:47
void send(CDL cmd, Args... args)
Definition cdrom.hh:99
void send(CDL cmd)
Definition cdrom.hh:94
void send(CDL cmd, const CDRomCommandBuffer &commandBuffer)
Definition cdrom.hh:87
Definition hwregs.hh:46