File:  [Isaki's NoNo m68k/m88k emulator] / nono / vm / bankram.h
Revision 1.1.1.4 (vendor branch): download - view: text, annotated - select for diffs
Wed Apr 29 17:05:50 2026 UTC (2 months, 3 weeks ago) by root
Branches: MAIN, Isaki
CVS tags: v027, v026, v025, HEAD
nono 1.5.0

//
// nono
// Copyright (C) 2023 nono project
// Licensed under nono-license.txt
//

//
// Nereid バンクメモリ
//

#pragma once

#include "device.h"
#include "mainbus.h"

class BankRAMDevice : public IODevice
{
	using inherited = IODevice;
 public:
	BankRAMDevice(uint objid_, int ram_size_MB);
	~BankRAMDevice() override;

	bool Init() override;
	void ResetHard(bool poweron) override;

	busdata Read(busaddr addr) override;
	busdata Write(busaddr addr, uint32 data) override;
	busdata Peek1(uint32 addr) override;
	bool Poke1(uint32 addr, uint32 data) override;

	// バンクページ取得・設定
	uint32 GetPage() const { return page; }
	void SetPage(uint32 page);

	// バンクメモリ容量 [MB]を取得 (負数は扱わない)
	uint GetSize() const { return ram_size / 1024 / 1024; }

	// アクセス状況の取得とクリア
	void FetchAccStat(uint8 *buf);

 private:
	// アドレスデコーダ
	inline uint32 Decoder(uint32 addr) const;

	std::unique_ptr<uint8[]> ram {};
	uint ram_size {};

	// ページ番号 (レジスタ値、マスク前)
	uint32 page {};

	// ページ番号をリニアアドレスにした状態で保持。
	uint32 pageaddr {};

	// ウェイト [nsec]
	busdata wait {};

	// アクセス状況
	alignas(8) uint8 accstat_read[AccStat::BANKLEN] {};
	alignas(8) uint8 accstat_write[AccStat::BANKLEN] {};
};

// GetBankRAMDevice() は用意していない。
// BankRAMDevice は存在しない場合があるので FindObject() を使うこと。

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.