|
|
1.1 root 1: //
2: // nono
1.1.1.3 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
7: #include "gvram.h"
1.1.1.4 ! root 8: #include "mpu.h"
1.1.1.3 root 9: #include "videoctlr.h"
1.1 root 10:
11: //
12: // GVRAM
13: //
14: // GVRAM はワード単位でホストバイトオーダ配置なので、
15: // バイトアクセス時は HB() マクロを使用のこと。
16: //
17:
1.1.1.2 root 18: std::unique_ptr<GVRAMDevice> gGVRAM;
1.1 root 19:
20: GVRAMDevice::GVRAMDevice()
21: {
22: logname = "gvram";
23: devname = "GVRAM";
24: devaddr = 0xc00000;
25: devlen = 0x200000; // XXX とりあえず
26:
1.1.1.2 root 27: mem.reset(new uint8[devlen]);
1.1 root 28: }
29:
30: GVRAMDevice::~GVRAMDevice()
31: {
32: }
33:
34: uint64
35: GVRAMDevice::Read8(uint32 addr)
36: {
1.1.1.4 ! root 37: gMPU->AddCycle(9); // Inside/Out p.135
1.1 root 38: uint32 offset = addr - devaddr;
39: return mem[HB(offset)];
40: }
41:
42: uint64
43: GVRAMDevice::Read16(uint32 addr)
44: {
1.1.1.4 ! root 45: gMPU->AddCycle(9); // Inside/Out p.135
1.1 root 46: uint32 offset = addr - devaddr;
47: return *(uint16 *)&mem[offset];
48: }
49:
50: uint64
51: GVRAMDevice::Write8(uint32 addr, uint32 data)
52: {
1.1.1.4 ! root 53: gMPU->AddCycle(9); // Inside/Out p.135
1.1 root 54: uint32 offset = addr - devaddr;
55: mem[HB(offset)] = data;
56: return 0;
57: }
58:
59: uint64
60: GVRAMDevice::Write16(uint32 addr, uint32 data)
61: {
1.1.1.4 ! root 62: gMPU->AddCycle(9); // Inside/Out p.135
1.1 root 63: uint32 offset = addr - devaddr;
64: *(uint16 *)&mem[offset] = data;
65: return 0;
66: }
67:
68: uint64
69: GVRAMDevice::Peek8(uint32 addr)
70: {
71: return mem[HB(addr - devaddr)];
72: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.