--- nono/vm/sprite.cpp 2026/04/29 17:04:28 1.1 +++ nono/vm/sprite.cpp 2026/04/29 17:05:18 1.1.1.10 @@ -1,38 +1,46 @@ // // nono -// Copyright (C) 2017 isaki@NetBSD.org +// Copyright (C) 2020 nono project +// Licensed under nono-license.txt +// + +// +// スプライトコントローラ // #include "sprite.h" -#include +#include "mpu.h" +// コンストラクタ SpriteDevice::SpriteDevice() + : inherited(OBJ_SPRITE) { - logname = "sprite"; - devname = "Sprite"; - devaddr = baseaddr; - devlen = 0x010000; - - mem = (uint8 *)malloc(4 * 8192); + mem.reset(new uint8[4 * 8192]); } +// デストラクタ SpriteDevice::~SpriteDevice() { - free(mem); } +// XXX ResetHard() 未調査 + uint64 SpriteDevice::Read8(uint32 addr) { if (addr >= 0xeb8000) { return mem[HB(addr - 0xeb8000)]; } - PANIC("not impl"); + VMPANIC("not impl"); } uint64 SpriteDevice::Read16(uint32 addr) { + // スプライトの Read はレジスタ、VRAM とも 17 ウェイト。 + // InsideOut p.135 + mpu->AddCycle(17); + if (addr >= 0xeb8000) { return *(uint16 *)&mem[addr - 0xeb8000]; } @@ -79,16 +87,22 @@ uint64 SpriteDevice::Write8(uint32 addr, uint32 data) { if (addr >= 0xeb8000) { + // スプライト VRAM への書き込み (InsideOut p.135) + mpu->AddCycle(18); mem[HB(addr - 0xeb8000)] = data; return 0; } - PANIC("not impl"); + + // スプライトレジスタへの書き込み (InsideOut p.135) + mpu->AddCycle(20); + + VMPANIC("not impl"); } uint64 SpriteDevice::Write16(uint32 addr, uint32 data) { - putlog(2, "Write16 $%06x <- $%04x", addr, data); + putlog(2, "$%06x <- $%04x", addr, data); if (addr >= 0xeb8000) { *(uint16 *)&mem[addr - 0xeb8000] = data; return 0;