|
|
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()
1.1.1.5 ! root 21: : inherited("GVRAM")
1.1 root 22: {
23: devaddr = 0xc00000;
24: devlen = 0x200000; // XXX とりあえず
25:
1.1.1.2 root 26: mem.reset(new uint8[devlen]);
1.1 root 27: }
28:
29: GVRAMDevice::~GVRAMDevice()
30: {
31: }
32:
33: uint64
34: GVRAMDevice::Read8(uint32 addr)
35: {
1.1.1.4 root 36: gMPU->AddCycle(9); // Inside/Out p.135
1.1 root 37: uint32 offset = addr - devaddr;
38: return mem[HB(offset)];
39: }
40:
41: uint64
42: GVRAMDevice::Read16(uint32 addr)
43: {
1.1.1.4 root 44: gMPU->AddCycle(9); // Inside/Out p.135
1.1 root 45: uint32 offset = addr - devaddr;
46: return *(uint16 *)&mem[offset];
47: }
48:
49: uint64
50: GVRAMDevice::Write8(uint32 addr, uint32 data)
51: {
1.1.1.4 root 52: gMPU->AddCycle(9); // Inside/Out p.135
1.1 root 53: uint32 offset = addr - devaddr;
54: mem[HB(offset)] = data;
55: return 0;
56: }
57:
58: uint64
59: GVRAMDevice::Write16(uint32 addr, uint32 data)
60: {
1.1.1.4 root 61: gMPU->AddCycle(9); // Inside/Out p.135
1.1 root 62: uint32 offset = addr - devaddr;
63: *(uint16 *)&mem[offset] = data;
64: return 0;
65: }
66:
67: uint64
68: GVRAMDevice::Peek8(uint32 addr)
69: {
70: return mem[HB(addr - devaddr)];
71: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.