summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/machine/naomim1.h
blob: 4e062e1fd039539600e91f37eb4c3e09697bd1b1 (plain) (blame)
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
// license:BSD-3-Clause
// copyright-holders:Olivier Galibert
#ifndef MAME_MACHINE_NAOMIM1_H
#define MAME_MACHINE_NAOMIM1_H

#pragma once

#include "naomibd.h"


class naomi_m1_board : public naomi_board
{
public:
	template <typename T>
	naomi_m1_board(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock, T &&eeprom_tag)
		: naomi_m1_board(mconfig, tag, owner, clock)
	{
		eeprom.set_tag(std::forward<T>(eeprom_tag));
	}

	naomi_m1_board(const machine_config &mconfig, const char *tag, device_t *owner, uint32_t clock);

	virtual void submap(address_map &map) override;

	uint16_t actel_id_r();

protected:
	virtual void device_start() override;
	virtual void device_reset() override;

	virtual void board_setup_address(uint32_t address, bool is_dma) override;
	virtual void board_get_buffer(uint8_t *&base, uint32_t &limit) override;
	virtual void board_advance(uint32_t size) override;

private:
	enum { BUFFER_SIZE = 32768 };
	uint32_t key;
	uint16_t actel_id;

	std::unique_ptr<uint8_t[]> buffer;
	uint8_t dict[111], hist[2];
	uint64_t avail_val;
	uint32_t rom_cur_address, buffer_actual_size, avail_bits;
	bool encryption, stream_ended, has_history;

	required_memory_region m_region;

	void gb_reset();
	uint32_t lookb(int bits);
	void skipb(int bits);
	uint32_t getb(int bits);

	void enc_reset();
	void enc_fill();

	uint32_t get_decrypted_32b();

	void wb(uint8_t byte);
};

DECLARE_DEVICE_TYPE(NAOMI_M1_BOARD, naomi_m1_board)

#endif // MAME_MACHINE_NAOMIM1_H