Use new IO Port related types and further improvements of readability #1

Merged
jaby merged 18 commits from Overlay-The-Beginning_CDDrive_EndOfIO into Overlay-The-Beginning_CDDrive 2023-03-23 19:43:52 +00:00
Owner

Before this PR the access to the IOPorts of the Playstation were handled via ComplexBitMap and VolatilePOD. Both types in combination were supposed to create a construct that allows:

  • Reading volatile from an IOPort into a non-volatile copy
  • Writing volatile a non-volatile copy of the IOPort
  • Setting and clearing Bits via the Bit structure
  • Reading values via BitRange
    • These values get normalized depending on the position in the bit pattern

However this lead to strange and hard to understand constructs to please the compiler. For new types it would often be very unclear which cast is expected by the type.

The new IOPort types are based on macros and garantee to be POD for the cost of being more difficult to find errors inside the macro. However thanks to more macros the creation and extension of these values should be easy and intuitive now.

The ComplexBitMap type was removed complete because it really does not has any benefit over directly using the Bit and BitRange types

Before this PR the access to the IOPorts of the Playstation were handled via `ComplexBitMap` and `VolatilePOD`. Both types in combination were supposed to create a construct that allows: * Reading volatile from an IOPort into a non-volatile copy * Writing volatile a non-volatile copy of the IOPort * Setting and clearing Bits via the Bit structure * Reading values via BitRange * These values get normalized depending on the position in the bit pattern However this lead to strange and hard to understand constructs to please the compiler. For new types it would often be very unclear which cast is expected by the type. The new IOPort types are based on macros and garantee to be POD for the cost of being more difficult to find errors inside the macro. However thanks to more macros the creation and extension of these values should be easy and intuitive now. The `ComplexBitMap` type was removed complete because it really does not has any benefit over directly using the `Bit` and `BitRange` types
cody was assigned by jaby 2023-03-22 20:39:29 +00:00
jaby added 18 commits 2023-03-22 20:39:29 +00:00
cody reviewed 2023-03-22 23:56:40 +00:00
@ -23,3 +23,3 @@
static void enable() {
GPU_IO::GP1.write(GPU_IO::Command::GP1::SetDisplayState(GPU_IO::DisplayState::On));
GPU_IO::GP1 = GPU_IO::Command::SetDisplayState(GPU_IO::DisplayState::On);
Collaborator

This is definitely way nicer looking to me vs using a write method!

This is definitely way nicer looking to me vs using a write method!
cody marked this conversation as resolved
cody reviewed 2023-03-22 23:59:22 +00:00
@ -59,0 +39,4 @@
static constexpr auto HasResponseFifoData = Bit(5);
static constexpr auto HasDataFifoData = Bit(6);
static constexpr auto IsTransmissionBusy = Bit(7);
);
Collaborator

Very good readability with this style of types and instantiation

Very good readability with this style of types and instantiation
cody approved these changes 2023-03-23 19:18:54 +00:00
@ -125,3 +120,1 @@
static constexpr Info Pause{0x09, Interrupt::Type::Complete};
static constexpr Info Init{0x0A, Interrupt::Type::Complete};
static constexpr Info SetMode{0x0E, Interrupt::Type::Acknowledge};
static constexpr Desc GetStat{0x01, Interrupt::Type::Acknowledge};
Collaborator

what is Desc?

what is Desc?
Author
Owner

It's the description of a CD command. I wanted to keep Command as the parent so developers can type Command::GetStat but then needed a sub type for the pair of the Command ID and the IRQ that indicates completion.
Better names are very welcome!

It's the description of a CD command. I wanted to keep `Command` as the parent so developers can type `Command::GetStat` but then needed a sub type for the pair of the Command ID and the IRQ that indicates completion. Better names are very welcome!
Collaborator

Oh ok that totally makes sense as is. I just didn't understand why there would be a Description here at first.

Oh ok that totally makes sense as is. I just didn't understand why there would be a Description here at first.
cody marked this conversation as resolved
jaby merged commit 7879c2b338 into Overlay-The-Beginning_CDDrive 2023-03-23 19:43:52 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: jaby/jabyengine#1
No description provided.