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