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
|
// license:BSD-3-Clause
// copyright-holders:Carl,psxAuthor,R. Belmont
#ifndef MAME_BUS_PSX_MEMCARD_H
#define MAME_BUS_PSX_MEMCARD_H
#pragma once
#include "imagedev/memcard.h"
class psx_controller_port_device;
class psxcard_device : public device_t,
public device_memcard_image_interface
{
public:
psxcard_device(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);
virtual bool is_reset_on_load() const noexcept override { return false; }
virtual const char *file_extensions() const noexcept override { return "mc"; }
virtual image_init_result call_load() override;
virtual image_init_result call_create(int format_type, util::option_resolution *format_options) override;
void disable(bool state) { m_disabled = state; if(state) unload(); }
void clock_w(bool state) { if(!m_clock && !m_sel && state && !m_pad) do_card(); m_clock = state; }
void sel_w(bool state);
bool rx_r() { return m_rx; }
bool ack_r() { return m_ack; }
protected:
virtual void device_start() override;
virtual void device_reset() override;
private:
void read_card(const unsigned short addr, unsigned char *buf);
void write_card(const unsigned short addr, unsigned char *buf);
unsigned char checksum_data(const unsigned char *buf, const unsigned int sz);
void do_card();
bool transfer(uint8_t to, uint8_t *from);
void ack_timer(int32_t param);
unsigned char pkt[0x8b], pkt_ptr, pkt_sz, cmd;
unsigned short addr;
int state;
bool m_disabled;
uint8_t m_odata;
uint8_t m_idata;
int m_bit;
int m_count;
bool m_pad;
bool m_clock;
bool m_sel;
bool m_ack;
bool m_rx;
emu_timer *m_ack_timer;
psx_controller_port_device *m_owner;
};
// device type definition
DECLARE_DEVICE_TYPE(PSXCARD, psxcard_device)
#endif // MAME_BUS_PSX_MEMCARD_H
|