forked from sin365/AxibugEmuOnline
Compare commits
7 Commits
3e91952330
...
e5e7beb52c
| Author | SHA1 | Date | |
|---|---|---|---|
| e5e7beb52c | |||
| f705b947c3 | |||
| 8191ff4b57 | |||
| 7c1a2af6f0 | |||
| af82cff70a | |||
| 765b62c7cc | |||
| ad5d2cf35a |
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -249,7 +249,7 @@ namespace VirtualNes.Core
|
|||||||
LoadDISK();
|
LoadDISK();
|
||||||
|
|
||||||
{
|
{
|
||||||
// Pad・ッ・鬣ケトレ、タ、ネウ<EFBFBD>レサッ・ソ・、・゚・<EFBFBD>ー、ャ゚W、、、ホ、ヌ、ウ、ウ、ヌ
|
// Padクラス内だと初期化タイミングが遅いのでここで
|
||||||
uint crc = rom.GetPROM_CRC();
|
uint crc = rom.GetPROM_CRC();
|
||||||
if (
|
if (
|
||||||
crc == 0xe792de94 // Best Play - Pro Yakyuu (New) (J)
|
crc == 0xe792de94 // Best Play - Pro Yakyuu (New) (J)
|
||||||
@ -275,7 +275,7 @@ namespace VirtualNes.Core
|
|||||||
|
|
||||||
LoadTurboFile();
|
LoadTurboFile();
|
||||||
|
|
||||||
// VS-Unisystem、ホ・ヌ・ユ・ゥ・<EFBFBD>ネヤOカィ
|
// VS-Unisystemのデフォルト設定
|
||||||
if (rom.IsVSUNISYSTEM())
|
if (rom.IsVSUNISYSTEM())
|
||||||
{
|
{
|
||||||
uint crc = rom.GetPROM_CRC();
|
uint crc = rom.GetPROM_CRC();
|
||||||
@ -286,13 +286,13 @@ namespace VirtualNes.Core
|
|||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
|
|
||||||
// ・イゥ`・犹フモミ、ホ・ヌ・ユ・ゥ・<EFBDA9>ネ・ェ・ラ・キ・逾<EFBDA5><E980BE>Oカィ(ヤOカィ諾、ケ瓶、ヒハケ、ヲ樣)
|
// ゲーム固有のデフォルトオプションを設定(設定戻す時に使う為)
|
||||||
GameOption.defRenderMethod = (int)GetRenderMethod();
|
GameOption.defRenderMethod = (int)GetRenderMethod();
|
||||||
GameOption.defIRQtype = GetIrqType();
|
GameOption.defIRQtype = GetIrqType();
|
||||||
GameOption.defFrameIRQ = GetFrameIRQmode();
|
GameOption.defFrameIRQ = GetFrameIRQmode();
|
||||||
GameOption.defVideoMode = GetVideoMode();
|
GameOption.defVideoMode = GetVideoMode();
|
||||||
|
|
||||||
// ヤOカィ、<EFBFBD>愰`・ノ、キ、ニヤOカィ、ケ、<EFBDB9>(・ィ・<EFBDA8>ネ・熙ャ殪、ア、<EFBDB1>ミ・ヌ・ユ・ゥ・<EFBDA9>ネ、ャネ<EFBDAC><EFBE88>)
|
// 設定をロードして設定する(エントリが無ければデフォルトが入る)
|
||||||
if (rom.GetMapperNo() != 20)
|
if (rom.GetMapperNo() != 20)
|
||||||
{
|
{
|
||||||
GameOption.Load(rom.GetPROM_CRC());
|
GameOption.Load(rom.GetPROM_CRC());
|
||||||
@ -331,12 +331,12 @@ namespace VirtualNes.Core
|
|||||||
{
|
{
|
||||||
if (fp == null)
|
if (fp == null)
|
||||||
{
|
{
|
||||||
// xxx ・ユ・。・、・<EFBFBD><EFBFBD>_、ア、゙、サ、<EFBFBD>
|
// xxx ファイルを開けません
|
||||||
throw new Exception($"Can Not Open File [TurboFile.vtf]");
|
throw new Exception($"Can Not Open File [TurboFile.vtf]");
|
||||||
}
|
}
|
||||||
|
|
||||||
long size = fp.Length;
|
long size = fp.Length;
|
||||||
// ・ユ・。・、・<EFBFBD>オ・、・コネ。オテ
|
// ファイルサイズ取得
|
||||||
if (size > 32 * 1024)
|
if (size > 32 * 1024)
|
||||||
{
|
{
|
||||||
size = 32 * 1024;
|
size = 32 * 1024;
|
||||||
@ -354,7 +354,7 @@ namespace VirtualNes.Core
|
|||||||
|
|
||||||
private void LoadDISK()
|
private void LoadDISK()
|
||||||
{
|
{
|
||||||
//todo : エナオ忞巐チネ。ヨァウヨ
|
//todo : 磁碟机读取支持
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadSRAM()
|
private void LoadSRAM()
|
||||||
@ -400,7 +400,7 @@ namespace VirtualNes.Core
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// メモリクリア
|
// 儊儌儕僋儕傾
|
||||||
MemoryUtility.ZEROMEMORY(MMU.RAM, MMU.RAM.Length);
|
MemoryUtility.ZEROMEMORY(MMU.RAM, MMU.RAM.Length);
|
||||||
MemoryUtility.ZEROMEMORY(MMU.WRAM, MMU.WRAM.Length);
|
MemoryUtility.ZEROMEMORY(MMU.WRAM, MMU.WRAM.Length);
|
||||||
MemoryUtility.ZEROMEMORY(MMU.DRAM, MMU.DRAM.Length);
|
MemoryUtility.ZEROMEMORY(MMU.DRAM, MMU.DRAM.Length);
|
||||||
@ -420,11 +420,11 @@ namespace VirtualNes.Core
|
|||||||
|
|
||||||
MMU.PROM = MMU.VROM = null;
|
MMU.PROM = MMU.VROM = null;
|
||||||
|
|
||||||
// 0 除算防止対策
|
// 0 彍嶼杊巭懳嶔
|
||||||
MMU.PROM_8K_SIZE = MMU.PROM_16K_SIZE = MMU.PROM_32K_SIZE = 1;
|
MMU.PROM_8K_SIZE = MMU.PROM_16K_SIZE = MMU.PROM_32K_SIZE = 1;
|
||||||
MMU.VROM_1K_SIZE = MMU.VROM_2K_SIZE = MMU.VROM_4K_SIZE = MMU.VROM_8K_SIZE = 1;
|
MMU.VROM_1K_SIZE = MMU.VROM_2K_SIZE = MMU.VROM_4K_SIZE = MMU.VROM_8K_SIZE = 1;
|
||||||
|
|
||||||
// デフォルトバンク設定
|
// 僨僼僅儖僩僶儞僋愝掕
|
||||||
for (i = 0; i < 8; i++)
|
for (i = 0; i < 8; i++)
|
||||||
{
|
{
|
||||||
MMU.CPU_MEM_BANK[i] = null;
|
MMU.CPU_MEM_BANK[i] = null;
|
||||||
@ -432,11 +432,11 @@ namespace VirtualNes.Core
|
|||||||
MMU.CPU_MEM_PAGE[i] = 0;
|
MMU.CPU_MEM_PAGE[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 内臓RAM/WRAM
|
// 撪憻RAM/WRAM
|
||||||
MMU.SetPROM_Bank(0, MMU.RAM, MMU.BANKTYPE_RAM);
|
MMU.SetPROM_Bank(0, MMU.RAM, MMU.BANKTYPE_RAM);
|
||||||
MMU.SetPROM_Bank(3, MMU.WRAM, MMU.BANKTYPE_RAM);
|
MMU.SetPROM_Bank(3, MMU.WRAM, MMU.BANKTYPE_RAM);
|
||||||
|
|
||||||
// ダミー
|
// 僟儈乕
|
||||||
MMU.SetPROM_Bank(1, MMU.XRAM, MMU.BANKTYPE_ROM);
|
MMU.SetPROM_Bank(1, MMU.XRAM, MMU.BANKTYPE_ROM);
|
||||||
MMU.SetPROM_Bank(2, MMU.XRAM, MMU.BANKTYPE_ROM);
|
MMU.SetPROM_Bank(2, MMU.XRAM, MMU.BANKTYPE_ROM);
|
||||||
|
|
||||||
@ -522,7 +522,7 @@ namespace VirtualNes.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ppu.ScanlineNext(); // これの位置でラスター系は画面が違う
|
ppu.ScanlineNext(); // 偙傟偺埵抲偱儔僗僞乕宯偼夋柺偑堘偆
|
||||||
if (RenderMethod == EnumRenderMethod.PRE_ALL_RENDER)
|
if (RenderMethod == EnumRenderMethod.PRE_ALL_RENDER)
|
||||||
EmulationCPU(nescfg.ScanlineCycles);
|
EmulationCPU(nescfg.ScanlineCycles);
|
||||||
|
|
||||||
@ -583,7 +583,7 @@ namespace VirtualNes.Core
|
|||||||
{
|
{
|
||||||
pad.VSync();
|
pad.VSync();
|
||||||
|
|
||||||
// VBLANK期間
|
// VBLANK婜娫
|
||||||
if (scanline == nescfg.TotalScanlines - 1)
|
if (scanline == nescfg.TotalScanlines - 1)
|
||||||
{
|
{
|
||||||
ppu.VBlankEnd();
|
ppu.VBlankEnd();
|
||||||
@ -642,7 +642,7 @@ namespace VirtualNes.Core
|
|||||||
|
|
||||||
if (scanline == 0)
|
if (scanline == 0)
|
||||||
{
|
{
|
||||||
// ダミースキャンライン
|
// 僟儈乕僗僉儍儞儔僀儞
|
||||||
// H-Draw (4fetches*32)
|
// H-Draw (4fetches*32)
|
||||||
EmulationCPU(FETCH_CYCLES * 128);
|
EmulationCPU(FETCH_CYCLES * 128);
|
||||||
ppu.FrameStart();
|
ppu.FrameStart();
|
||||||
@ -655,7 +655,7 @@ namespace VirtualNes.Core
|
|||||||
}
|
}
|
||||||
else if (scanline < 240)
|
else if (scanline < 240)
|
||||||
{
|
{
|
||||||
// スクリーン描画(Scanline 1~239)
|
// 僗僋儕乕儞昤夋(Scanline 1乣239)
|
||||||
if (bDraw)
|
if (bDraw)
|
||||||
{
|
{
|
||||||
ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip);
|
ppu.Scanline(scanline, Supporter.Config.graphics.bAllSprite, Supporter.Config.graphics.bLeftClip);
|
||||||
@ -707,7 +707,7 @@ namespace VirtualNes.Core
|
|||||||
}
|
}
|
||||||
else if (scanline == 240)
|
else if (scanline == 240)
|
||||||
{
|
{
|
||||||
// ダミースキャンライン (Scanline 240)
|
// 僟儈乕僗僉儍儞儔僀儞 (Scanline 240)
|
||||||
mapper.VSync();
|
mapper.VSync();
|
||||||
|
|
||||||
EmulationCPU(nescfg.HDrawCycles);
|
EmulationCPU(nescfg.HDrawCycles);
|
||||||
@ -720,7 +720,7 @@ namespace VirtualNes.Core
|
|||||||
{
|
{
|
||||||
pad.VSync();
|
pad.VSync();
|
||||||
|
|
||||||
// VBLANK期間
|
// VBLANK婜娫
|
||||||
if (scanline == nescfg.TotalScanlines - 1)
|
if (scanline == nescfg.TotalScanlines - 1)
|
||||||
{
|
{
|
||||||
ppu.VBlankEnd();
|
ppu.VBlankEnd();
|
||||||
@ -864,7 +864,7 @@ namespace VirtualNes.Core
|
|||||||
MMU.VROM_4K_SIZE = rom.GetVROM_SIZE() * 2;
|
MMU.VROM_4K_SIZE = rom.GetVROM_SIZE() * 2;
|
||||||
MMU.VROM_8K_SIZE = rom.GetVROM_SIZE();
|
MMU.VROM_8K_SIZE = rom.GetVROM_SIZE();
|
||||||
|
|
||||||
// デフォルトバンク
|
// 僨僼僅儖僩僶儞僋
|
||||||
if (MMU.VROM_8K_SIZE != 0)
|
if (MMU.VROM_8K_SIZE != 0)
|
||||||
{
|
{
|
||||||
MMU.SetVROM_8K_Bank(0);
|
MMU.SetVROM_8K_Bank(0);
|
||||||
@ -874,7 +874,7 @@ namespace VirtualNes.Core
|
|||||||
MMU.SetCRAM_8K_Bank(0);
|
MMU.SetCRAM_8K_Bank(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ミラー
|
// 儈儔乕
|
||||||
if (rom.Is4SCREEN())
|
if (rom.Is4SCREEN())
|
||||||
{
|
{
|
||||||
MMU.SetVRAM_Mirror(MMU.VRAM_MIRROR4);
|
MMU.SetVRAM_Mirror(MMU.VRAM_MIRROR4);
|
||||||
@ -976,13 +976,13 @@ namespace VirtualNes.Core
|
|||||||
reg.S = 0xFF;
|
reg.S = 0xFF;
|
||||||
reg.P = CPU.Z_FLAG | CPU.R_FLAG | CPU.I_FLAG;
|
reg.P = CPU.Z_FLAG | CPU.R_FLAG | CPU.I_FLAG;
|
||||||
|
|
||||||
// 安全対策を兼ねてあえてループに(1秒分)
|
// 埨慡懳嶔傪寭偹偰偁偊偰儖乕僾偵(1昩暘)
|
||||||
for (int i = 0; i < nescfg.TotalScanlines * 60; i++)
|
for (int i = 0; i < nescfg.TotalScanlines * 60; i++)
|
||||||
{
|
{
|
||||||
EmulationCPU(nescfg.ScanlineCycles);
|
EmulationCPU(nescfg.ScanlineCycles);
|
||||||
cpu.GetContext(ref reg);
|
cpu.GetContext(ref reg);
|
||||||
|
|
||||||
// 無限ループに入ったことを確認したら抜ける
|
// 柍尷儖乕僾偵擖偭偨偙偲傪妋擣偟偨傜敳偗傞
|
||||||
if (reg.PC == 0x4700)
|
if (reg.PC == 0x4700)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@ -993,7 +993,7 @@ namespace VirtualNes.Core
|
|||||||
}
|
}
|
||||||
|
|
||||||
cpu.GetContext(ref reg);
|
cpu.GetContext(ref reg);
|
||||||
// 無限ループに入っていたら再設定する
|
// 柍尷儖乕僾偵擖偭偰偄偨傜嵞愝掕偡傞
|
||||||
if (reg.PC == 0x4700)
|
if (reg.PC == 0x4700)
|
||||||
{
|
{
|
||||||
reg.PC = 0x4720; // Play Address
|
reg.PC = 0x4720; // Play Address
|
||||||
@ -1009,7 +1009,7 @@ namespace VirtualNes.Core
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
cpu.GetContext(ref reg);
|
cpu.GetContext(ref reg);
|
||||||
reg.PC = 0x4700; // 無限ループ
|
reg.PC = 0x4700; // 柍尷儖乕僾
|
||||||
reg.S = 0xFF;
|
reg.S = 0xFF;
|
||||||
|
|
||||||
EmulationCPU(nescfg.ScanlineCycles * nescfg.TotalScanlines);
|
EmulationCPU(nescfg.ScanlineCycles * nescfg.TotalScanlines);
|
||||||
@ -1186,7 +1186,7 @@ namespace VirtualNes.Core
|
|||||||
if (m_BarcodeCycles > 1000)
|
if (m_BarcodeCycles > 1000)
|
||||||
{
|
{
|
||||||
m_BarcodeCycles = 0;
|
m_BarcodeCycles = 0;
|
||||||
// 停止?
|
// 掆巭丠
|
||||||
if (m_BarcodeData[m_BarcodePtr] != 0xFF)
|
if (m_BarcodeData[m_BarcodePtr] != 0xFF)
|
||||||
{
|
{
|
||||||
m_BarcodeOut = m_BarcodeData[m_BarcodePtr++];
|
m_BarcodeOut = m_BarcodeData[m_BarcodePtr++];
|
||||||
@ -1227,7 +1227,7 @@ namespace VirtualNes.Core
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
m_TapeCycles += (nescfg.CpuClock / 32000.0);
|
m_TapeCycles += (nescfg.CpuClock / 32000.0);
|
||||||
// m_TapeCycles += (nescfg.CpuClock / 22050.0); // 遅すぎてダメっぽい
|
// m_TapeCycles += (nescfg.CpuClock / 22050.0); // 抶偡偓偰僟儊偭傐偄
|
||||||
|
|
||||||
if (m_bTapePlay)
|
if (m_bTapePlay)
|
||||||
{
|
{
|
||||||
@ -1293,7 +1293,7 @@ namespace VirtualNes.Core
|
|||||||
return MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF];
|
return MMU.CPU_MEM_BANK[addr >> 13][addr & 0x1FFF];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0x00; // Warning予防
|
return 0x00; // Warning梊杊
|
||||||
}
|
}
|
||||||
|
|
||||||
private byte ReadReg(ushort addr)
|
private byte ReadReg(ushort addr)
|
||||||
@ -1504,7 +1504,7 @@ namespace VirtualNes.Core
|
|||||||
pad.Write(addr, data);
|
pad.Write(addr, data);
|
||||||
apu.Write(addr, data);
|
apu.Write(addr, data);
|
||||||
break;
|
break;
|
||||||
// VirtuaNES固有ポート
|
// VirtuaNES屌桳億乕僩
|
||||||
case 0x18:
|
case 0x18:
|
||||||
apu.Write(addr, data);
|
apu.Write(addr, data);
|
||||||
break;
|
break;
|
||||||
@ -1596,7 +1596,7 @@ namespace VirtualNes.Core
|
|||||||
ref state.reg.cpureg.FrameIRQ_type,
|
ref state.reg.cpureg.FrameIRQ_type,
|
||||||
ref state.reg.cpureg.FrameIRQ,
|
ref state.reg.cpureg.FrameIRQ,
|
||||||
ref state.reg.cpureg.FrameIRQ_occur);
|
ref state.reg.cpureg.FrameIRQ_occur);
|
||||||
state.reg.cpureg.FrameIRQ_cycles = cycles; // イホユユ、ャINT、ハ樣」ィ、ゥ
|
state.reg.cpureg.FrameIRQ_cycles = cycles; // 参照がINTな為(ぉ
|
||||||
|
|
||||||
state.reg.cpureg.DMA_cycles = cpu.GetDmaCycles();
|
state.reg.cpureg.DMA_cycles = cpu.GetDmaCycles();
|
||||||
state.reg.cpureg.emul_cycles = emul_cycles;
|
state.reg.cpureg.emul_cycles = emul_cycles;
|
||||||
@ -1625,7 +1625,7 @@ namespace VirtualNes.Core
|
|||||||
MemoryUtility.memcpy(state.ram.SPPAL, MMU.SPPAL, state.ram.SPPAL.Length);
|
MemoryUtility.memcpy(state.ram.SPPAL, MMU.SPPAL, state.ram.SPPAL.Length);
|
||||||
MemoryUtility.memcpy(state.ram.SPRAM, MMU.SPRAM, state.ram.SPRAM.Length);
|
MemoryUtility.memcpy(state.ram.SPRAM, MMU.SPRAM, state.ram.SPRAM.Length);
|
||||||
|
|
||||||
// S-RAM STATE(ハケモテ/ホエハケモテ、ヒ騅、<E9A885>鬢コエ贇レ、ケ、<EFBDB9>ミ・サゥ`・ヨ、ケ、<EFBDB9>)
|
// S-RAM STATE(使用/未使用に関わらず存在すればセーブする)
|
||||||
if (rom.IsSAVERAM())
|
if (rom.IsSAVERAM())
|
||||||
{
|
{
|
||||||
size = (uint)SAVERAM_SIZE;
|
size = (uint)SAVERAM_SIZE;
|
||||||
@ -1649,9 +1649,9 @@ namespace VirtualNes.Core
|
|||||||
uint size = 0;
|
uint size = 0;
|
||||||
|
|
||||||
// SAVE CPU MEMORY BANK DATA
|
// SAVE CPU MEMORY BANK DATA
|
||||||
// BANK0,1,2、マ・ミ・<EFBFBD>ッ・サゥ`・ヨ、ヒ騅4、ハ、キ
|
// BANK0,1,2はバンクセーブに関係なし
|
||||||
// VirtuaNES0.30、ォ、<EFBFBD>
|
// VirtuaNES0.30から
|
||||||
// ・ミ・<EFBFBD>ッ」ウ、マSRAMハケモテ、ヒ騅、<EFBFBD>鬢コ・サゥ`・ヨ
|
// バンク3はSRAM使用に関わらずセーブ
|
||||||
for (int i = 3; i < 8; i++)
|
for (int i = 3; i < 8; i++)
|
||||||
{
|
{
|
||||||
state.mmu.CPU_MEM_TYPE[i] = MMU.CPU_MEM_TYPE[i];
|
state.mmu.CPU_MEM_TYPE[i] = MMU.CPU_MEM_TYPE[i];
|
||||||
@ -1696,7 +1696,7 @@ namespace VirtualNes.Core
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// WRITE VRAM MEMORY(ウ」、ヒ4Kキヨ、ケ、ル、ニ抱、ュ゙z、<EFBFBD>)
|
// WRITE VRAM MEMORY(常に4K分すべて書き込む)
|
||||||
state.VRAM = new byte[4 * 1024];
|
state.VRAM = new byte[4 * 1024];
|
||||||
Array.Copy(MMU.VRAM, state.VRAM, state.VRAM.Length);
|
Array.Copy(MMU.VRAM, state.VRAM, state.VRAM.Length);
|
||||||
|
|
||||||
@ -1764,7 +1764,7 @@ namespace VirtualNes.Core
|
|||||||
int DiskSize = 16 + 65500 * rom.GetDiskNo();
|
int DiskSize = 16 + 65500 * rom.GetDiskNo();
|
||||||
|
|
||||||
|
|
||||||
// マ珀`ハ<>、<EFBFBD>ォ・ヲ・<EFBDA6>ネ
|
// 相違数をカウント
|
||||||
for (int i = 16; i < DiskSize; i++)
|
for (int i = 16; i < DiskSize; i++)
|
||||||
{
|
{
|
||||||
if (lpWrite[i] != 0)
|
if (lpWrite[i] != 0)
|
||||||
@ -1874,9 +1874,9 @@ namespace VirtualNes.Core
|
|||||||
//BANK STATE
|
//BANK STATE
|
||||||
{
|
{
|
||||||
// SAVE CPU MEMORY BANK DATA
|
// SAVE CPU MEMORY BANK DATA
|
||||||
// BANK0,1,2、マ・ミ・<EFBFBD>ッ・サゥ`・ヨ、ヒ騅4、ハ、キ
|
// BANK0,1,2はバンクセーブに関係なし
|
||||||
// VirtuaNES0.30、ォ、<EFBFBD>
|
// VirtuaNES0.30から
|
||||||
// ・ミ・<EFBFBD>ッ」ウ、マSRAMハケモテ、ヒ騅、<EFBFBD>鬢コ・サゥ`・ヨ
|
// バンク3はSRAM使用に関わらずセーブ
|
||||||
for (byte i = 3; i < 8; i++)
|
for (byte i = 3; i < 8; i++)
|
||||||
{
|
{
|
||||||
MMU.CPU_MEM_TYPE[i] = state.mmu.CPU_MEM_TYPE[i];
|
MMU.CPU_MEM_TYPE[i] = state.mmu.CPU_MEM_TYPE[i];
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
namespace VirtualNes.Core
|
namespace VirtualNes.Core
|
||||||
{
|
{
|
||||||
public struct ControllerState
|
public struct ControllerState : IEquatable<ControllerState>
|
||||||
{
|
{
|
||||||
public uint raw0;
|
public uint raw0;
|
||||||
public uint raw1;
|
public uint raw1;
|
||||||
@ -11,19 +11,73 @@ namespace VirtualNes.Core
|
|||||||
|
|
||||||
public bool valid;
|
public bool valid;
|
||||||
|
|
||||||
public ControllerState(
|
public ControllerState(EnumButtonType[] states)
|
||||||
EnumButtonType player0_buttons,
|
|
||||||
EnumButtonType player1_buttons,
|
|
||||||
EnumButtonType player2_buttons,
|
|
||||||
EnumButtonType player3_buttons)
|
|
||||||
{
|
{
|
||||||
raw0 = (uint)player0_buttons;
|
raw0 = (uint)states[0];
|
||||||
raw1 = (uint)player1_buttons;
|
raw1 = (uint)states[1];
|
||||||
raw2 = (uint)player2_buttons;
|
raw2 = (uint)states[2];
|
||||||
raw3 = (uint)player3_buttons;
|
raw3 = (uint)states[3];
|
||||||
valid = true;
|
valid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasButton(int player, EnumButtonType button)
|
||||||
|
{
|
||||||
|
uint raw;
|
||||||
|
|
||||||
|
switch (player)
|
||||||
|
{
|
||||||
|
case 0: raw = raw0; break;
|
||||||
|
case 1: raw = raw1; break;
|
||||||
|
case 2: raw = raw2; break;
|
||||||
|
case 3: raw = raw3; break;
|
||||||
|
default:
|
||||||
|
raw = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return (raw & (uint)button) == (uint)button;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{raw0}|{raw1}|{raw2}|{raw3}";
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Impl_Equals
|
||||||
|
public bool Equals(ControllerState other)
|
||||||
|
{
|
||||||
|
return raw0 == other.raw0 && raw1 == other.raw1 && raw2 == other.raw2 && raw3 == other.raw3 && valid == other.valid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Equals(object obj)
|
||||||
|
{
|
||||||
|
return obj is ControllerState other && Equals(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int GetHashCode()
|
||||||
|
{
|
||||||
|
//return HashCode.Combine(raw0, raw1, raw2, raw3, valid);
|
||||||
|
return ComputeHashCode(raw0, raw1, raw2, raw3, valid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int ComputeHashCode(uint raw0, uint raw1, uint raw2, uint raw3, bool valid)
|
||||||
|
{
|
||||||
|
unchecked // 允许溢出,使得哈希码计算更加合理
|
||||||
|
{
|
||||||
|
int hash = 17; // 选择一个非零的初始值
|
||||||
|
|
||||||
|
// 将每个 uint 类型的值转换为 int 并合并到哈希码中
|
||||||
|
hash = hash * 31 + (int)raw0;
|
||||||
|
hash = hash * 31 + (int)raw1;
|
||||||
|
hash = hash * 31 + (int)raw2;
|
||||||
|
hash = hash * 31 + (int)raw3;
|
||||||
|
|
||||||
|
// 将 bool 类型的值转换为 int 并合并到哈希码中
|
||||||
|
hash = hash * 31 + (valid ? 1 : 0);
|
||||||
|
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static bool operator ==(ControllerState left, ControllerState right)
|
public static bool operator ==(ControllerState left, ControllerState right)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
@ -37,24 +91,7 @@ namespace VirtualNes.Core
|
|||||||
{
|
{
|
||||||
return !(left == right);
|
return !(left == right);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
public override string ToString()
|
|
||||||
{
|
|
||||||
return $"{raw0}|{raw1}|{raw2}|{raw3}";
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool HasButton(int player, EnumButtonType button)
|
|
||||||
{
|
|
||||||
uint raw = 0;
|
|
||||||
switch (player)
|
|
||||||
{
|
|
||||||
case 0: raw = raw0; break;
|
|
||||||
case 1: raw = raw1; break;
|
|
||||||
case 2: raw = raw2; break;
|
|
||||||
case 3: raw = raw3; break;
|
|
||||||
}
|
|
||||||
return (raw & (uint)button) == (uint)button;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
|
|||||||
@ -5,6 +5,7 @@ namespace VirtualNes.Core
|
|||||||
public static class Supporter
|
public static class Supporter
|
||||||
{
|
{
|
||||||
private static ISupporterImpl s_support;
|
private static ISupporterImpl s_support;
|
||||||
|
|
||||||
public static void Setup(ISupporterImpl supporter)
|
public static void Setup(ISupporterImpl supporter)
|
||||||
{
|
{
|
||||||
s_support = supporter;
|
s_support = supporter;
|
||||||
@ -44,6 +45,7 @@ namespace VirtualNes.Core
|
|||||||
{
|
{
|
||||||
s_support.SaveFile(fileData, directPath, fileName);
|
s_support.SaveFile(fileData, directPath, fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Stream OpenFile(string directPath, string fileName)
|
public static Stream OpenFile(string directPath, string fileName)
|
||||||
{
|
{
|
||||||
return s_support.OpenFile(directPath, fileName);
|
return s_support.OpenFile(directPath, fileName);
|
||||||
@ -64,6 +66,11 @@ namespace VirtualNes.Core
|
|||||||
s_support.SampleInput(frameCount);
|
s_support.SampleInput(frameCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static IControllerSetuper GetControllerSetuper()
|
||||||
|
{
|
||||||
|
return s_support.GetControllerSetuper();
|
||||||
|
}
|
||||||
|
|
||||||
public static EmulatorConfig Config => s_support.Config;
|
public static EmulatorConfig Config => s_support.Config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,5 +89,21 @@ namespace VirtualNes.Core
|
|||||||
bool TryGetMapperNo(ROM rom, out int mapperNo);
|
bool TryGetMapperNo(ROM rom, out int mapperNo);
|
||||||
ControllerState GetControllerState();
|
ControllerState GetControllerState();
|
||||||
void SampleInput(uint frameCount);
|
void SampleInput(uint frameCount);
|
||||||
|
IControllerSetuper GetControllerSetuper();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 负责管理本地控制器与具体游戏之间的槽位分配
|
||||||
|
/// </summary>
|
||||||
|
public interface IControllerSetuper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设置本地手柄与游戏手柄槽位的映射
|
||||||
|
/// </summary>
|
||||||
|
void SetConnect(
|
||||||
|
uint? con0ToSlot = null,
|
||||||
|
uint? con1ToSlot = null,
|
||||||
|
uint? con2ToSlot = null,
|
||||||
|
uint? con3ToSlot = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -86,7 +86,7 @@ public class AxiProjectTools : EditorWindow
|
|||||||
static void LoopPrefabNode(string rootPath, GameObject trans, int depth)
|
static void LoopPrefabNode(string rootPath, GameObject trans, int depth)
|
||||||
{
|
{
|
||||||
string nodename = $"{rootPath}>{trans.name}";
|
string nodename = $"{rootPath}>{trans.name}";
|
||||||
|
#if UNITY_5_4_OR_NEWER && !UNITY_2018_4_OR_NEWER
|
||||||
GameObject prefabRoot = trans.gameObject;
|
GameObject prefabRoot = trans.gameObject;
|
||||||
int comCount = prefabRoot.GetComponentCount();
|
int comCount = prefabRoot.GetComponentCount();
|
||||||
for (int i = 0; i < comCount; i++)
|
for (int i = 0; i < comCount; i++)
|
||||||
@ -130,6 +130,9 @@ public class AxiProjectTools : EditorWindow
|
|||||||
//遍历
|
//遍历
|
||||||
foreach (Transform child in trans.transform)
|
foreach (Transform child in trans.transform)
|
||||||
LoopPrefabNode(nodename, child.gameObject, depth + 1);
|
LoopPrefabNode(nodename, child.gameObject, depth + 1);
|
||||||
|
#else
|
||||||
|
Debug.Log("低版本不要执行本函数");
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
[MenuItem("Axibug移植工具/[2]生成中间脚本代码")]
|
[MenuItem("Axibug移植工具/[2]生成中间脚本代码")]
|
||||||
|
|||||||
@ -36,7 +36,7 @@ namespace AxibugEmuOnline.Client.ClientCore
|
|||||||
private static CoroutineRunner coRunner;
|
private static CoroutineRunner coRunner;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#if UNITY_PSP2
|
#if UNITY_PSP2 && !UNITY_EDITOR //PSV真机
|
||||||
public static string PersistentDataPath => "ux0:data/AxibugEmu";
|
public static string PersistentDataPath => "ux0:data/AxibugEmu";
|
||||||
#else
|
#else
|
||||||
public static string PersistentDataPath => Application.persistentDataPath;
|
public static string PersistentDataPath => Application.persistentDataPath;
|
||||||
@ -45,6 +45,12 @@ namespace AxibugEmuOnline.Client.ClientCore
|
|||||||
{
|
{
|
||||||
PlayerPrefs.DeleteAll();
|
PlayerPrefs.DeleteAll();
|
||||||
|
|
||||||
|
if (UnityEngine.Application.platform == RuntimePlatform.PSP2)
|
||||||
|
{
|
||||||
|
//PSV 等平台需要手动创建目录
|
||||||
|
PSP2Init();
|
||||||
|
}
|
||||||
|
|
||||||
settings = new AppSettings();
|
settings = new AppSettings();
|
||||||
|
|
||||||
log = new LogManager();
|
log = new LogManager();
|
||||||
@ -68,11 +74,6 @@ namespace AxibugEmuOnline.Client.ClientCore
|
|||||||
tickLoop = go.AddComponent<TickLoop>();
|
tickLoop = go.AddComponent<TickLoop>();
|
||||||
coRunner = go.AddComponent<CoroutineRunner>();
|
coRunner = go.AddComponent<CoroutineRunner>();
|
||||||
|
|
||||||
if (UnityEngine.Application.platform == RuntimePlatform.PSP2)
|
|
||||||
{
|
|
||||||
//PSV 等平台需要手动创建目录
|
|
||||||
PersistentDataPathDir();
|
|
||||||
}
|
|
||||||
|
|
||||||
var importNode = GameObject.Find("IMPORTENT");
|
var importNode = GameObject.Find("IMPORTENT");
|
||||||
if (importNode != null) GameObject.DontDestroyOnLoad(importNode);
|
if (importNode != null) GameObject.DontDestroyOnLoad(importNode);
|
||||||
@ -81,12 +82,17 @@ namespace AxibugEmuOnline.Client.ClientCore
|
|||||||
RePullNetInfo();
|
RePullNetInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void PersistentDataPathDir()
|
|
||||||
|
private static void PSP2Init()
|
||||||
{
|
{
|
||||||
|
//PSVita最好手动创建目录
|
||||||
if (!Directory.Exists(PersistentDataPath))
|
if (!Directory.Exists(PersistentDataPath))
|
||||||
{
|
|
||||||
Directory.CreateDirectory(PersistentDataPath);
|
Directory.CreateDirectory(PersistentDataPath);
|
||||||
}
|
|
||||||
|
#if UNITY_PSP2
|
||||||
|
//释放解码 FMV的26M内存,一般游戏用不上(PSP才用那破玩意儿)
|
||||||
|
UnityEngine.PSVita.PSVitaVideoPlayer.TransferMemToMonoHeap();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IEnumerator AppTickFlow()
|
private static IEnumerator AppTickFlow()
|
||||||
|
|||||||
@ -1,19 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "AxibugEmuOnline.Client",
|
"name": "AxibugEmuOnline.Client",
|
||||||
"rootNamespace": "AxibugEmuOnline.Client",
|
|
||||||
"references": [
|
"references": [
|
||||||
"VirtualNes.Core",
|
|
||||||
"UIEffect",
|
"UIEffect",
|
||||||
"AxiReplay",
|
"AxiReplay",
|
||||||
"Unity.Postprocessing.Runtime"
|
"Unity.Postprocessing.Runtime"
|
||||||
],
|
],
|
||||||
|
"optionalUnityReferences": [],
|
||||||
"includePlatforms": [],
|
"includePlatforms": [],
|
||||||
"excludePlatforms": [],
|
"excludePlatforms": [],
|
||||||
"allowUnsafeCode": true,
|
"allowUnsafeCode": true
|
||||||
"overrideReferences": false,
|
|
||||||
"precompiledReferences": [],
|
|
||||||
"autoReferenced": true,
|
|
||||||
"defineConstraints": [],
|
|
||||||
"versionDefines": [],
|
|
||||||
"noEngineReferences": false
|
|
||||||
}
|
}
|
||||||
@ -249,6 +249,18 @@ Shader "PostEffect/FixingPixcelArtGrille"
|
|||||||
else if(pos.x<0.666)mask.g=_maskLight;
|
else if(pos.x<0.666)mask.g=_maskLight;
|
||||||
else mask.b=_maskLight;
|
else mask.b=_maskLight;
|
||||||
return mask;}
|
return mask;}
|
||||||
|
#else
|
||||||
|
// VGA style shadow mask.
|
||||||
|
float3 Mask(float2 pos){
|
||||||
|
pos.xy=floor(pos.xy*float2(1.0,0.5));
|
||||||
|
pos.x+=pos.y*3.0;
|
||||||
|
float3 mask=float3(_maskDark,_maskDark,_maskDark);
|
||||||
|
pos.x=fract(pos.x/6.0);
|
||||||
|
if(pos.x<0.333)mask.r=_maskLight;
|
||||||
|
else if(pos.x<0.666)mask.g=_maskLight;
|
||||||
|
else mask.b=_maskLight;
|
||||||
|
return mask;}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private IEmuCore m_emuCore;
|
private IEmuCore m_emuCore;
|
||||||
|
|
||||||
private IControllerSetuper m_controllerSetuper;
|
private VirtualNes.Core.IControllerSetuper m_controllerSetuper;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// unity的c#实现有bug,以接口类型保存的monobehaviour引用,!=和==运算符没有调用到monobehaviour重写过的运算符
|
/// unity的c#实现有bug,以接口类型保存的monobehaviour引用,!=和==运算符没有调用到monobehaviour重写过的运算符
|
||||||
@ -84,10 +84,15 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
else //在房间中则使用服务器下发的手柄槽位信息分配本地手柄
|
else //在房间中则使用服务器下发的手柄槽位信息分配本地手柄
|
||||||
{
|
{
|
||||||
long selfUID = App.user.userdata.UID;
|
long selfUID = App.user.userdata.UID;
|
||||||
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 0, out var con0Slot);
|
uint? con0Slot;
|
||||||
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 1, out var con1Slot);
|
uint? con1Slot;
|
||||||
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 2, out var con2Slot);
|
uint? con2Slot;
|
||||||
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 3, out var con3Slot);
|
uint? con3Slot;
|
||||||
|
|
||||||
|
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 0, out con0Slot);
|
||||||
|
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 1, out con1Slot);
|
||||||
|
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 2, out con2Slot);
|
||||||
|
App.roomMgr.mineRoomMiniInfo.GetPlayerSlotIdxByUid(selfUID, 3, out con3Slot);
|
||||||
|
|
||||||
m_controllerSetuper.SetConnect(con0Slot, con1Slot, con2Slot, con3Slot);
|
m_controllerSetuper.SetConnect(con0Slot, con1Slot, con2Slot, con3Slot);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,8 +63,11 @@ namespace AxibugEmuOnline.Client
|
|||||||
private Dictionary<string, object> cachesInMemory = new Dictionary<string, object>();
|
private Dictionary<string, object> cachesInMemory = new Dictionary<string, object>();
|
||||||
void GetCacheData<T>(string url, string path, Action<T, string> callback) where T : class
|
void GetCacheData<T>(string url, string path, Action<T, string> callback) where T : class
|
||||||
{
|
{
|
||||||
if (cachesInMemory.TryGetValue(url, out var cacheObj) && cacheObj is T obj)
|
object cacheObj;
|
||||||
|
|
||||||
|
if (cachesInMemory.TryGetValue(url, out cacheObj) && cacheObj is T)
|
||||||
{
|
{
|
||||||
|
T obj = (T)cacheObj;
|
||||||
callback.Invoke(obj, url);
|
callback.Invoke(obj, url);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,6 +22,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
public FilterManager(PostProcessVolume filterVolume, CanvasGroup filterPreview, CanvasGroup mainBg)
|
public FilterManager(PostProcessVolume filterVolume, CanvasGroup filterPreview, CanvasGroup mainBg)
|
||||||
{
|
{
|
||||||
|
if (filterVolume == null)
|
||||||
|
return;
|
||||||
m_filterPorfile = filterVolume.profile;
|
m_filterPorfile = filterVolume.profile;
|
||||||
m_filters = m_filterPorfile.settings.Where(setting => setting is FilterEffect).Select(setting => new Filter(setting as FilterEffect)).ToList();
|
m_filters = m_filterPorfile.settings.Where(setting => setting is FilterEffect).Select(setting => new Filter(setting as FilterEffect)).ToList();
|
||||||
var json = PlayerPrefs.GetString(nameof(FilterRomSetting));
|
var json = PlayerPrefs.GetString(nameof(FilterRomSetting));
|
||||||
@ -86,20 +88,37 @@ namespace AxibugEmuOnline.Client
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="rom">rom对象</param>
|
/// <param name="rom">rom对象</param>
|
||||||
/// <returns>此元组任意内任意成员都有可能为空</returns>
|
/// <returns>此元组任意内任意成员都有可能为空</returns>
|
||||||
public (Filter filter, FilterPreset preset) GetFilterSetting(RomFile rom)
|
public GetFilterSetting_result GetFilterSetting(RomFile rom)
|
||||||
{
|
{
|
||||||
var value = m_filterRomSetting.Get(rom);
|
var value = m_filterRomSetting.Get(rom);
|
||||||
Filter filter = null;
|
Filter filter = null;
|
||||||
FilterPreset preset = null;
|
FilterPreset preset = null;
|
||||||
|
|
||||||
filter = Filters.FirstOrDefault(f => f.Name == value.filterName);
|
//filter = Filters.FirstOrDefault(f => f.Name == value.filterName);
|
||||||
|
//if (filter != null)
|
||||||
|
//{
|
||||||
|
// string presetName = value.presetName;
|
||||||
|
// preset = filter.Presets.FirstOrDefault(p => p.Name == presetName);
|
||||||
|
//}
|
||||||
|
|
||||||
|
filter = Filters.FirstOrDefault(f => f.Name == value.Item1);
|
||||||
if (filter != null)
|
if (filter != null)
|
||||||
{
|
{
|
||||||
string presetName = value.presetName;
|
string presetName = value.Item2;
|
||||||
preset = filter.Presets.FirstOrDefault(p => p.Name == presetName);
|
preset = filter.Presets.FirstOrDefault(p => p.Name == presetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (filter, preset);
|
return new GetFilterSetting_result()
|
||||||
|
{
|
||||||
|
filter = filter,
|
||||||
|
preset = preset
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public struct GetFilterSetting_result
|
||||||
|
{
|
||||||
|
public Filter filter;
|
||||||
|
public FilterPreset preset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Filter
|
public class Filter
|
||||||
@ -223,8 +242,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
public string GetParamValueJson(string paramName)
|
public string GetParamValueJson(string paramName)
|
||||||
{
|
{
|
||||||
prepareCache();
|
prepareCache();
|
||||||
|
string value;
|
||||||
m_paramName2ValueJson.TryGetValue(paramName, out var value);
|
m_paramName2ValueJson.TryGetValue(paramName, out value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,7 +254,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
if (valueType == typeof(float))
|
if (valueType == typeof(float))
|
||||||
{
|
{
|
||||||
float.TryParse(rawStr, out var floatVal);
|
float floatVal;
|
||||||
|
float.TryParse(rawStr, out floatVal);
|
||||||
return floatVal;
|
return floatVal;
|
||||||
}
|
}
|
||||||
else if (valueType.IsEnum)
|
else if (valueType.IsEnum)
|
||||||
@ -309,12 +329,13 @@ namespace AxibugEmuOnline.Client
|
|||||||
return JsonUtility.ToJson(this);
|
return JsonUtility.ToJson(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public (string filterName, string presetName) Get(RomFile rom)
|
public ValueTuple<string,string> Get(RomFile rom)
|
||||||
{
|
{
|
||||||
prepareCache();
|
prepareCache();
|
||||||
|
|
||||||
m_cache.TryGetValue(rom.ID, out var item);
|
Item item;
|
||||||
return (item.FilterName, item.PresetName);
|
m_cache.TryGetValue(rom.ID, out item);
|
||||||
|
return new ValueTuple<string, string>(item.FilterName, item.PresetName);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void prepareCache()
|
private void prepareCache()
|
||||||
|
|||||||
@ -5,6 +5,7 @@ using System.Collections;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Networking;
|
using UnityEngine.Networking;
|
||||||
|
using static UnityEngine.EventSystems.EventTrigger;
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client
|
||||||
{
|
{
|
||||||
@ -95,7 +96,9 @@ namespace AxibugEmuOnline.Client
|
|||||||
if (Path.GetExtension(LocalFilePath).ToLower() == ".zip")
|
if (Path.GetExtension(LocalFilePath).ToLower() == ".zip")
|
||||||
{
|
{
|
||||||
var zip = new ZipInputStream(new MemoryStream(bytes));
|
var zip = new ZipInputStream(new MemoryStream(bytes));
|
||||||
while (zip.GetNextEntry() is ZipEntry entry)
|
var entry = zip.GetNextEntry() as ZipEntry;
|
||||||
|
|
||||||
|
while (entry != null)
|
||||||
{
|
{
|
||||||
if (!entry.Name.ToLower().EndsWith(".nes")) continue;
|
if (!entry.Name.ToLower().EndsWith(".nes")) continue;
|
||||||
|
|
||||||
|
|||||||
@ -154,14 +154,16 @@ namespace AxibugEmuOnline.Client.Manager
|
|||||||
for (int i = 0; i < msg.UserList.Count; i++)
|
for (int i = 0; i < msg.UserList.Count; i++)
|
||||||
{
|
{
|
||||||
UserMiniInfo mi = msg.UserList[i];
|
UserMiniInfo mi = msg.UserList[i];
|
||||||
UpdateOrAddUser(mi, out bool isNewUser);
|
bool isNewUser;
|
||||||
|
UpdateOrAddUser(mi, out isNewUser);
|
||||||
}
|
}
|
||||||
Eventer.Instance.PostEvent(EEvent.OnUserListAllUpdate);
|
Eventer.Instance.PostEvent(EEvent.OnUserListAllUpdate);
|
||||||
}
|
}
|
||||||
public void RecvCmdUserJoin(byte[] reqData)
|
public void RecvCmdUserJoin(byte[] reqData)
|
||||||
{
|
{
|
||||||
Protobuf_UserJoin_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_UserJoin_RESP>(reqData);
|
Protobuf_UserJoin_RESP msg = ProtoBufHelper.DeSerizlize<Protobuf_UserJoin_RESP>(reqData);
|
||||||
UpdateOrAddUser(msg.UserInfo, out bool isNewUser);
|
bool isNewUser;
|
||||||
|
UpdateOrAddUser(msg.UserInfo, out isNewUser);
|
||||||
if (isNewUser)
|
if (isNewUser)
|
||||||
{
|
{
|
||||||
Eventer.Instance.PostEvent(EEvent.OnUserLogin, msg.UserInfo.UID, msg.UserInfo.NickName);
|
Eventer.Instance.PostEvent(EEvent.OnUserLogin, msg.UserInfo.UID, msg.UserInfo.NickName);
|
||||||
|
|||||||
@ -6,7 +6,10 @@ public struct MsgBool
|
|||||||
public string ErrorMsg;
|
public string ErrorMsg;
|
||||||
public bool Value;
|
public bool Value;
|
||||||
|
|
||||||
public override readonly string ToString()
|
//low C# readonly
|
||||||
|
//public override readonly string ToString()
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
{
|
{
|
||||||
if (Value)
|
if (Value)
|
||||||
{
|
{
|
||||||
@ -33,10 +36,11 @@ public struct MsgBool
|
|||||||
return msgBool.Value;
|
return msgBool.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static implicit operator (bool, string)(MsgBool msgBool)
|
//low C#
|
||||||
{
|
//public static implicit operator (bool, string)(MsgBool msgBool)
|
||||||
return (msgBool.Value, msgBool.ErrorMsg);
|
//{
|
||||||
}
|
// return (msgBool.Value, msgBool.ErrorMsg);
|
||||||
|
//}
|
||||||
|
|
||||||
public static implicit operator string(MsgBool msgBool)
|
public static implicit operator string(MsgBool msgBool)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using AxibugEmuOnline.Client.ClientCore;
|
using AxibugEmuOnline.Client.ClientCore;
|
||||||
|
using AxiReplay;
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
@ -102,7 +103,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
if (InGameUI.Instance.IsNetPlay)
|
if (InGameUI.Instance.IsNetPlay)
|
||||||
{
|
{
|
||||||
if (App.roomMgr.netReplay.TryGetNextFrame((int)frameIndex, out var replayData, out int frameDiff, out bool inputDiff))
|
int targetFrame; ReplayStep replayData; int frameDiff; bool inputDiff;
|
||||||
|
if (App.roomMgr.netReplay.TryGetNextFrame((int)frameIndex, out replayData, out frameDiff, out inputDiff))
|
||||||
{
|
{
|
||||||
if (inputDiff)
|
if (inputDiff)
|
||||||
{
|
{
|
||||||
@ -112,7 +114,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
m_sampledState = FromNet(replayData);
|
m_sampledState = FromNet(replayData);
|
||||||
}
|
}
|
||||||
else m_sampledState = default;
|
else m_sampledState = default(ControllerState);
|
||||||
|
|
||||||
var localState = ControllerMapper.CreateState();
|
var localState = ControllerMapper.CreateState();
|
||||||
var rawData = ToNet(localState);
|
var rawData = ToNet(localState);
|
||||||
|
|||||||
@ -5,10 +5,10 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
public class NesControllerMapper : IControllerSetuper
|
public class NesControllerMapper : IControllerSetuper
|
||||||
{
|
{
|
||||||
public Controller Controller0 { get; } = new(0);
|
public Controller Controller0 { get; } = new Controller(0);
|
||||||
public Controller Controller1 { get; } = new(1);
|
public Controller Controller1 { get; } = new Controller(1);
|
||||||
public Controller Controller2 { get; } = new(2);
|
public Controller Controller2 { get; } = new Controller(2);
|
||||||
public Controller Controller3 { get; } = new(3);
|
public Controller Controller3 { get; } = new Controller(3);
|
||||||
|
|
||||||
private readonly EnumButtonType[] m_states = new EnumButtonType[4];
|
private readonly EnumButtonType[] m_states = new EnumButtonType[4];
|
||||||
|
|
||||||
@ -137,8 +137,10 @@ namespace AxibugEmuOnline.Client
|
|||||||
m_keyListener = Controller.GetKey(m_hostController.ControllerIndex, m_buttonType);
|
m_keyListener = Controller.GetKey(m_hostController.ControllerIndex, m_buttonType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//low C# readonly
|
||||||
|
//public readonly struct KeyListener
|
||||||
|
|
||||||
public readonly struct KeyListener
|
public struct KeyListener
|
||||||
{
|
{
|
||||||
private readonly KeyCode m_key;
|
private readonly KeyCode m_key;
|
||||||
|
|
||||||
@ -152,7 +154,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
m_key = KeyCode.None;
|
m_key = KeyCode.None;
|
||||||
|
|
||||||
if (int.TryParse(confStr, out int result))
|
int result;
|
||||||
|
if (int.TryParse(confStr, out result))
|
||||||
m_key = (KeyCode)result;
|
m_key = (KeyCode)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +223,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return default;
|
return default(KeyListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,24 +2,19 @@
|
|||||||
%TAG !u! tag:unity3d.com,2011:
|
%TAG !u! tag:unity3d.com,2011:
|
||||||
--- !u!21 &2100000
|
--- !u!21 &2100000
|
||||||
Material:
|
Material:
|
||||||
serializedVersion: 8
|
serializedVersion: 6
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInternal: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_Name: NesEmulator_Screen
|
m_Name: NesEmulator_Screen
|
||||||
m_Shader: {fileID: 4800000, guid: b351396ff606116478d7f4412abe4e2e, type: 3}
|
m_Shader: {fileID: 4800000, guid: b351396ff606116478d7f4412abe4e2e, type: 3}
|
||||||
m_Parent: {fileID: 0}
|
m_ShaderKeywords:
|
||||||
m_ModifiedSerializedProperties: 0
|
|
||||||
m_ValidKeywords: []
|
|
||||||
m_InvalidKeywords: []
|
|
||||||
m_LightmapFlags: 4
|
m_LightmapFlags: 4
|
||||||
m_EnableInstancingVariants: 0
|
m_EnableInstancingVariants: 0
|
||||||
m_DoubleSidedGI: 0
|
m_DoubleSidedGI: 0
|
||||||
m_CustomRenderQueue: -1
|
m_CustomRenderQueue: -1
|
||||||
stringTagMap: {}
|
stringTagMap: {}
|
||||||
disabledShaderPasses: []
|
disabledShaderPasses: []
|
||||||
m_LockedProperties:
|
|
||||||
m_SavedProperties:
|
m_SavedProperties:
|
||||||
serializedVersion: 3
|
serializedVersion: 3
|
||||||
m_TexEnvs:
|
m_TexEnvs:
|
||||||
@ -63,7 +58,6 @@ Material:
|
|||||||
m_Texture: {fileID: 0}
|
m_Texture: {fileID: 0}
|
||||||
m_Scale: {x: 1, y: 1}
|
m_Scale: {x: 1, y: 1}
|
||||||
m_Offset: {x: 0, y: 0}
|
m_Offset: {x: 0, y: 0}
|
||||||
m_Ints: []
|
|
||||||
m_Floats:
|
m_Floats:
|
||||||
- _BumpScale: 1
|
- _BumpScale: 1
|
||||||
- _ColorMask: 15
|
- _ColorMask: 15
|
||||||
@ -91,5 +85,3 @@ Material:
|
|||||||
m_Colors:
|
m_Colors:
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||||
m_BuildTextureStacks: []
|
|
||||||
m_AllowLocking: 1
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ namespace AxibugEmuOnline.Client.Network
|
|||||||
|
|
||||||
private Dictionary<int, List<Delegate>> netEventDic = new Dictionary<int, List<Delegate>>(128);
|
private Dictionary<int, List<Delegate>> netEventDic = new Dictionary<int, List<Delegate>>(128);
|
||||||
|
|
||||||
private Queue<(int, int, byte[])> queueNetMsg = new Queue<(int, int, byte[])>();
|
private Queue<ValueTuple<int, int, byte[]>> queueNetMsg = new Queue<ValueTuple<int, int, byte[]>>();
|
||||||
|
|
||||||
private NetMsg() { }
|
private NetMsg() { }
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ namespace AxibugEmuOnline.Client.Network
|
|||||||
{
|
{
|
||||||
lock (lockQueueObj)
|
lock (lockQueueObj)
|
||||||
{
|
{
|
||||||
queueNetMsg.Enqueue((cmd, ERRCODE, arg));
|
queueNetMsg.Enqueue(new ValueTuple<int,int,byte[]>(cmd, ERRCODE, arg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,7 +76,8 @@ namespace AxibugEmuOnline.Client.Network
|
|||||||
{
|
{
|
||||||
while (queueNetMsg.Count > 0)
|
while (queueNetMsg.Count > 0)
|
||||||
{
|
{
|
||||||
(int, int, byte[]) msgData = queueNetMsg.Dequeue();
|
|
||||||
|
var msgData = queueNetMsg.Dequeue();
|
||||||
PostNetMsgEvent(msgData.Item1, msgData.Item2, msgData.Item3);
|
PostNetMsgEvent(msgData.Item1, msgData.Item2, msgData.Item3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,7 +39,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
public void SetDependencyProperty(object data)
|
public void SetDependencyProperty(object data)
|
||||||
{
|
{
|
||||||
SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index);
|
SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Release()
|
public void Release()
|
||||||
|
|||||||
@ -33,7 +33,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
public void SetDependencyProperty(object data)
|
public void SetDependencyProperty(object data)
|
||||||
{
|
{
|
||||||
SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index);
|
SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index);
|
||||||
|
|
||||||
if (m_select)
|
if (m_select)
|
||||||
{
|
{
|
||||||
@ -87,7 +87,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
OverlayManager.Input((presetName) =>
|
OverlayManager.Input((presetName) =>
|
||||||
{
|
{
|
||||||
var result = m_filter.CreatePreset(presetName, out var newPreset);
|
FilterPreset newPreset;
|
||||||
|
var result = m_filter.CreatePreset(presetName, out newPreset);
|
||||||
if (!result) OverlayManager.PopTip(result);
|
if (!result) OverlayManager.PopTip(result);
|
||||||
else optionUI.AddOptionMenuWhenPoping(new Opt_Presets(m_filter, newPreset));
|
else optionUI.AddOptionMenuWhenPoping(new Opt_Presets(m_filter, newPreset));
|
||||||
}, "为预设设置一个名称", string.Empty);
|
}, "为预设设置一个名称", string.Empty);
|
||||||
|
|||||||
@ -37,12 +37,12 @@ namespace AxibugEmuOnline.Client
|
|||||||
m_romlib.BeginFetchRomInfo(m_romfile);
|
m_romlib.BeginFetchRomInfo(m_romfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index);
|
SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetDependencyProperty(object data)
|
public void SetDependencyProperty(object data)
|
||||||
{
|
{
|
||||||
SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index);
|
SetSelectState(data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Release()
|
public void Release()
|
||||||
|
|||||||
@ -11,7 +11,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
private object m_state;
|
private object m_state;
|
||||||
private StepPerformer m_stepPerformer;
|
private StepPerformer m_stepPerformer;
|
||||||
|
|
||||||
private readonly List<OptionMenu> menus = new();
|
private readonly List<OptionMenu> menus = new List<OptionMenu>();
|
||||||
public static InGameUI Instance { get; private set; }
|
public static InGameUI Instance { get; private set; }
|
||||||
|
|
||||||
public RomFile RomFile { get; private set; }
|
public RomFile RomFile { get; private set; }
|
||||||
|
|||||||
@ -1,9 +1,6 @@
|
|||||||
using AxibugEmuOnline.Client.ClientCore;
|
using AxibugEmuOnline.Client.ClientCore;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using UnityEditor.Presets;
|
|
||||||
using UnityEngine;
|
|
||||||
using VirtualNes.Core;
|
|
||||||
using static AxibugEmuOnline.Client.FilterManager;
|
using static AxibugEmuOnline.Client.FilterManager;
|
||||||
|
|
||||||
namespace AxibugEmuOnline.Client
|
namespace AxibugEmuOnline.Client
|
||||||
|
|||||||
@ -39,8 +39,10 @@ public static class GameObjectPool
|
|||||||
|
|
||||||
public static void Release(GameObject instance)
|
public static void Release(GameObject instance)
|
||||||
{
|
{
|
||||||
s_instanceToSrc.TryGetValue(instance, out var src);
|
GameObject src;
|
||||||
if (src != null && s_poolMap.TryGetValue(src, out var pool))
|
Queue<GameObject> pool;
|
||||||
|
s_instanceToSrc.TryGetValue(instance, out src);
|
||||||
|
if (src != null && s_poolMap.TryGetValue(src, out pool))
|
||||||
{
|
{
|
||||||
pool.Enqueue(instance);
|
pool.Enqueue(instance);
|
||||||
//instance.SetActive(false);
|
//instance.SetActive(false);
|
||||||
|
|||||||
@ -480,8 +480,9 @@ public class ItemPresent : GridLayoutGroup, IVirtualLayout
|
|||||||
if (_dataList != null)
|
if (_dataList != null)
|
||||||
_dataList.Clear();
|
_dataList.Clear();
|
||||||
}
|
}
|
||||||
else if (dataList is IEnumerable ienumrable)
|
else if (dataList is IEnumerable)
|
||||||
{
|
{
|
||||||
|
var ienumrable = (IEnumerable)dataList;
|
||||||
List<object> temp = new List<object>();
|
List<object> temp = new List<object>();
|
||||||
foreach (var item in ienumrable)
|
foreach (var item in ienumrable)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -7,17 +7,17 @@ using UnityEngine.UI;
|
|||||||
public interface IVirtualLayout
|
public interface IVirtualLayout
|
||||||
{
|
{
|
||||||
Dictionary<GameObject, ScripteInterface> CacheItemScripts { get; }
|
Dictionary<GameObject, ScripteInterface> CacheItemScripts { get; }
|
||||||
public List<object> DataList { get; }
|
List<object> DataList { get; }
|
||||||
public object DependencyProperty { get; }
|
object DependencyProperty { get; }
|
||||||
public RectTransform RectTransform { get; }
|
RectTransform RectTransform { get; }
|
||||||
public RectTransform GetTemplate(object data);
|
RectTransform GetTemplate(object data);
|
||||||
public Vector2 GetItemAnchorePos(int index);
|
Vector2 GetItemAnchorePos(int index);
|
||||||
public RectTransform GetItemUIIfExist(int index);
|
RectTransform GetItemUIIfExist(int index);
|
||||||
|
|
||||||
public void UpdateProxyVisualState();
|
void UpdateProxyVisualState();
|
||||||
public void UpdateDependencyProperty(object dp);
|
void UpdateDependencyProperty(object dp);
|
||||||
public void SetData(object dataList);
|
void SetData(object dataList);
|
||||||
public void MoveToScrollViewCenter(ScrollRect scrollRect, int dataIndex);
|
void MoveToScrollViewCenter(ScrollRect scrollRect, int dataIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ItemProxy
|
public class ItemProxy
|
||||||
@ -65,7 +65,9 @@ public class ItemProxy
|
|||||||
{
|
{
|
||||||
if (_runtimeInstance == null) return null;
|
if (_runtimeInstance == null) return null;
|
||||||
|
|
||||||
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out ScripteInterface lfi);
|
ScripteInterface lfi;
|
||||||
|
|
||||||
|
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out lfi);
|
||||||
|
|
||||||
return lfi;
|
return lfi;
|
||||||
}
|
}
|
||||||
@ -159,7 +161,9 @@ public class ItemProxy
|
|||||||
_parent.CacheItemScripts[_runtimeInstance.gameObject] = newSI;
|
_parent.CacheItemScripts[_runtimeInstance.gameObject] = newSI;
|
||||||
}
|
}
|
||||||
|
|
||||||
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out ScripteInterface si);
|
ScripteInterface si;
|
||||||
|
|
||||||
|
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out si);
|
||||||
si.SetDataList(_parent.DataList[Index], Index);
|
si.SetDataList(_parent.DataList[Index], Index);
|
||||||
if (_parent.DependencyProperty != null)
|
if (_parent.DependencyProperty != null)
|
||||||
si.SetDependencyProperty(_parent.DependencyProperty);
|
si.SetDependencyProperty(_parent.DependencyProperty);
|
||||||
@ -169,8 +173,8 @@ public class ItemProxy
|
|||||||
public void UpdateDP()
|
public void UpdateDP()
|
||||||
{
|
{
|
||||||
if (_runtimeInstance == null) return;
|
if (_runtimeInstance == null) return;
|
||||||
|
ScripteInterface luaInterface;
|
||||||
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out ScripteInterface luaInterface);
|
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out luaInterface);
|
||||||
if (luaInterface == null) return;
|
if (luaInterface == null) return;
|
||||||
|
|
||||||
if (_parent.DependencyProperty != null)
|
if (_parent.DependencyProperty != null)
|
||||||
@ -191,7 +195,8 @@ public class ItemProxy
|
|||||||
|
|
||||||
if (Application.isPlaying)
|
if (Application.isPlaying)
|
||||||
{
|
{
|
||||||
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out ScripteInterface si);
|
ScripteInterface si;
|
||||||
|
_parent.CacheItemScripts.TryGetValue(_runtimeInstance.gameObject, out si);
|
||||||
if (si != null) si.Release();
|
if (si != null) si.Release();
|
||||||
GameObjectPool.Release(_runtimeInstance.gameObject);
|
GameObjectPool.Release(_runtimeInstance.gameObject);
|
||||||
_runtimeInstance = null;
|
_runtimeInstance = null;
|
||||||
|
|||||||
@ -269,15 +269,17 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
private void CreateRuntimeMenuItem(OptionMenu menuData)
|
private void CreateRuntimeMenuItem(OptionMenu menuData)
|
||||||
{
|
{
|
||||||
if (menuData is ExecuteMenu executeMenu)
|
if (menuData is ExecuteMenu)
|
||||||
{
|
{
|
||||||
|
ExecuteMenu executeMenu = (ExecuteMenu)menuData;
|
||||||
var menuUI = Instantiate(TEMPLATE_EXECUTEITEM.gameObject, TEMPLATE_EXECUTEITEM.transform.parent).GetComponent<OptionUI_ExecuteItem>();
|
var menuUI = Instantiate(TEMPLATE_EXECUTEITEM.gameObject, TEMPLATE_EXECUTEITEM.transform.parent).GetComponent<OptionUI_ExecuteItem>();
|
||||||
menuUI.gameObject.SetActive(true);
|
menuUI.gameObject.SetActive(true);
|
||||||
menuUI.SetData(this, executeMenu);
|
menuUI.SetData(this, executeMenu);
|
||||||
m_runtimeMenuItems.Add(menuUI);
|
m_runtimeMenuItems.Add(menuUI);
|
||||||
}
|
}
|
||||||
else if (menuData is ValueSetMenu valueSetMenu)
|
else if (menuData is ValueSetMenu)
|
||||||
{
|
{
|
||||||
|
var valueSetMenu = (ValueSetMenu)menuData;
|
||||||
var menuUI = Instantiate(TEMPLATE_VALUEEDITITEM.gameObject, TEMPLATE_VALUEEDITITEM.transform.parent).GetComponent<OptionUI_ValueEditItem>();
|
var menuUI = Instantiate(TEMPLATE_VALUEEDITITEM.gameObject, TEMPLATE_VALUEEDITITEM.transform.parent).GetComponent<OptionUI_ValueEditItem>();
|
||||||
menuUI.gameObject.SetActive(true);
|
menuUI.gameObject.SetActive(true);
|
||||||
menuUI.SetData(this, valueSetMenu);
|
menuUI.SetData(this, valueSetMenu);
|
||||||
|
|||||||
@ -17,8 +17,9 @@ namespace AxibugEmuOnline.Client
|
|||||||
com_floatEdit.gameObject.SetActive(false);
|
com_floatEdit.gameObject.SetActive(false);
|
||||||
com_enumEdit.gameObject.SetActive(false);
|
com_enumEdit.gameObject.SetActive(false);
|
||||||
|
|
||||||
if (menuData is ValueSetMenu valueMenu)
|
if (menuData is ValueSetMenu)
|
||||||
{
|
{
|
||||||
|
var valueMenu = (ValueSetMenu)menuData;
|
||||||
if (valueMenu.ValueType == typeof(float))
|
if (valueMenu.ValueType == typeof(float))
|
||||||
{
|
{
|
||||||
m_currentCom = com_floatEdit;
|
m_currentCom = com_floatEdit;
|
||||||
|
|||||||
@ -18,11 +18,11 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
protected override void OnShow(object param)
|
protected override void OnShow(object param)
|
||||||
{
|
{
|
||||||
(Action<string> callback, string placeHolder, string defaultText) t = ((Action<string> callback, string placeHolder, string defaultText))param;
|
ValueTuple<Action<string>, string, string> t = (ValueTuple<Action<string>, string, string>)param;
|
||||||
|
|
||||||
OnCommit = t.callback;
|
OnCommit = t.Item1;
|
||||||
(m_input.placeholder as Text).text = t.placeHolder;
|
(m_input.placeholder as Text).text = t.Item2;
|
||||||
m_input.text = t.defaultText;
|
m_input.text = t.Item3;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
|
|||||||
@ -22,7 +22,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
public static InputUI Input(Action<string> callback, string placeHolder, string defaultText)
|
public static InputUI Input(Action<string> callback, string placeHolder, string defaultText)
|
||||||
{
|
{
|
||||||
s_ins.m_InputUI.Show((callback, placeHolder, defaultText));
|
s_ins.m_InputUI.Show(new ValueTuple<Action<string>, string, string>(callback, placeHolder, defaultText));
|
||||||
|
|
||||||
return s_ins.m_InputUI;
|
return s_ins.m_InputUI;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,7 +32,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
{
|
{
|
||||||
if (this.RoomID != roomID) return;
|
if (this.RoomID != roomID) return;
|
||||||
|
|
||||||
if (App.roomMgr.GetRoomListMiniInfo(roomID, out var roomInfo))
|
Protobuf_Room_MiniInfo roomInfo;
|
||||||
|
if (App.roomMgr.GetRoomListMiniInfo(roomID, out roomInfo))
|
||||||
UpdateUI(roomInfo);
|
UpdateUI(roomInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,13 +58,14 @@ namespace AxibugEmuOnline.Client
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!App.roomMgr.GetRoomListMiniInfo(RoomID, out Protobuf_Room_MiniInfo MiniInfo))
|
Protobuf_Room_MiniInfo MiniInfo;
|
||||||
|
if (!App.roomMgr.GetRoomListMiniInfo(RoomID, out MiniInfo))
|
||||||
{
|
{
|
||||||
OverlayManager.PopTip("房间不存在");
|
OverlayManager.PopTip("房间不存在");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
int[] freeSlots;
|
||||||
if (!MiniInfo.GetFreeSlot(out var freeSlots))
|
if (!MiniInfo.GetFreeSlot(out freeSlots))
|
||||||
{
|
{
|
||||||
OverlayManager.PopTip("无空闲位置");
|
OverlayManager.PopTip("无空闲位置");
|
||||||
return false;
|
return false;
|
||||||
@ -77,7 +79,9 @@ namespace AxibugEmuOnline.Client
|
|||||||
private void UpdateUI(Protobuf_Room_MiniInfo roomInfo)
|
private void UpdateUI(Protobuf_Room_MiniInfo roomInfo)
|
||||||
{
|
{
|
||||||
var hostNick = roomInfo.GetHostNickName();
|
var hostNick = roomInfo.GetHostNickName();
|
||||||
roomInfo.GetRoomPlayers(out var cur, out var max);
|
int cur; int max;
|
||||||
|
|
||||||
|
roomInfo.GetRoomPlayers(out cur, out max);
|
||||||
SetBaseInfo("--", $"<b>{hostNick}</b>的房间", $"{cur}/{max}");
|
SetBaseInfo("--", $"<b>{hostNick}</b>的房间", $"{cur}/{max}");
|
||||||
SetIcon(null);
|
SetIcon(null);
|
||||||
|
|
||||||
@ -129,7 +133,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
|
|
||||||
public void SetDependencyProperty(object data)
|
public void SetDependencyProperty(object data)
|
||||||
{
|
{
|
||||||
SetSelectState(data is ThirdMenuRoot tr && tr.SelectIndex == Index);
|
SetSelectState((data is ThirdMenuRoot && ((ThirdMenuRoot)data).SelectIndex == Index));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Release()
|
public void Release()
|
||||||
|
|||||||
@ -44,7 +44,7 @@ namespace AxibugEmuOnline.Client
|
|||||||
m_trackTween.Kill();
|
m_trackTween.Kill();
|
||||||
m_trackTween = null;
|
m_trackTween = null;
|
||||||
}
|
}
|
||||||
m_trackTween = DOTween.To(() => m_rect.position, (value) => m_rect.position = value, itemUIRect.position, 0.125f);
|
m_trackTween = DOTween.To(() => m_rect.position, (_value) => m_rect.position = _value, itemUIRect.position, 0.125f);
|
||||||
m_trackTween.onComplete = () => m_trackTween = null;
|
m_trackTween.onComplete = () => m_trackTween = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -184,6 +184,10 @@ namespace AxibugEmuOnline.Client
|
|||||||
private MenuItem Clone(MenuItem template, Transform parent)
|
private MenuItem Clone(MenuItem template, Transform parent)
|
||||||
{
|
{
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
|
|
||||||
|
//========================套娃宏========================
|
||||||
|
#if UNITY_2019_1_OR_NEWER //新版Unity,因UNITY2018.2用不了这玩意儿,编辑器也罢
|
||||||
|
|
||||||
if (Application.isPlaying)
|
if (Application.isPlaying)
|
||||||
{
|
{
|
||||||
var item = GameObject.Instantiate(template.gameObject, parent).GetComponent<MenuItem>();
|
var item = GameObject.Instantiate(template.gameObject, parent).GetComponent<MenuItem>();
|
||||||
@ -196,6 +200,15 @@ namespace AxibugEmuOnline.Client
|
|||||||
clone.transform.localPosition = Vector3.zero;
|
clone.transform.localPosition = Vector3.zero;
|
||||||
return clone.GetComponent<MenuItem>();
|
return clone.GetComponent<MenuItem>();
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
var item = GameObject.Instantiate(template.gameObject, parent).GetComponent<MenuItem>();
|
||||||
|
item.transform.localPosition = Vector3.zero;
|
||||||
|
return item;
|
||||||
|
#endif
|
||||||
|
//========================套娃宏 End========================
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
return GameObject.Instantiate(SubMenuItemTemplate.gameObject, parent).GetComponent<MenuItem>();
|
return GameObject.Instantiate(SubMenuItemTemplate.gameObject, parent).GetComponent<MenuItem>();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -9,7 +9,8 @@ namespace AxibugEmuOnline.Client
|
|||||||
private static Dictionary<Graphic, Material> _caches = new Dictionary<Graphic, Material>();
|
private static Dictionary<Graphic, Material> _caches = new Dictionary<Graphic, Material>();
|
||||||
public static Material GetMaterial(this Graphic graphic)
|
public static Material GetMaterial(this Graphic graphic)
|
||||||
{
|
{
|
||||||
if (_caches.TryGetValue(graphic, out var material))
|
Material material;
|
||||||
|
if (_caches.TryGetValue(graphic, out material))
|
||||||
{
|
{
|
||||||
return material;
|
return material;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,10 @@ public class XMBInfoBar : MonoBehaviour
|
|||||||
RefreshFps();
|
RefreshFps();
|
||||||
}
|
}
|
||||||
|
|
||||||
(uint lastFrame, float lastTime) m_lastFrameInfo;
|
/// <summary>
|
||||||
|
/// (uint lastFrame, float lastTime)
|
||||||
|
/// </summary>
|
||||||
|
ValueTuple<uint,float> m_lastFrameInfo;
|
||||||
private void RefreshFps()
|
private void RefreshFps()
|
||||||
{
|
{
|
||||||
if (App.emu.Core.IsNull())
|
if (App.emu.Core.IsNull())
|
||||||
@ -42,13 +45,17 @@ public class XMBInfoBar : MonoBehaviour
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
FPS.gameObject.SetActiveEx(true);
|
FPS.gameObject.SetActiveEx(true);
|
||||||
var gap = App.emu.Core.Frame - m_lastFrameInfo.lastFrame;
|
//var gap = App.emu.Core.Frame - m_lastFrameInfo.lastFrame;
|
||||||
var time = Time.realtimeSinceStartup - m_lastFrameInfo.lastTime;
|
//var time = Time.realtimeSinceStartup - m_lastFrameInfo.lastTime;
|
||||||
|
var gap = App.emu.Core.Frame - m_lastFrameInfo.Item1;
|
||||||
|
var time = Time.realtimeSinceStartup - m_lastFrameInfo.Item2;
|
||||||
var fps = gap / time;
|
var fps = gap / time;
|
||||||
FPS.text = $"FPS:{fps:.#}";
|
FPS.text = $"FPS:{fps:.#}";
|
||||||
|
|
||||||
m_lastFrameInfo.lastFrame = App.emu.Core.Frame;
|
//m_lastFrameInfo.lastFrame = App.emu.Core.Frame;
|
||||||
m_lastFrameInfo.lastTime = Time.realtimeSinceStartup;
|
//m_lastFrameInfo.lastTime = Time.realtimeSinceStartup;
|
||||||
|
m_lastFrameInfo.Item1 = App.emu.Core.Frame;
|
||||||
|
m_lastFrameInfo.Item2 = Time.realtimeSinceStartup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,9 @@ namespace AxibugEmuOnline.Client
|
|||||||
private static Dictionary<int, RomFile> s_RomFileCahcesInRoomInfo = new Dictionary<int, RomFile>();
|
private static Dictionary<int, RomFile> s_RomFileCahcesInRoomInfo = new Dictionary<int, RomFile>();
|
||||||
public static void FetchRomFileInRoomInfo(this Protobuf_Room_MiniInfo roomInfo, EnumPlatform platform, Action<Protobuf_Room_MiniInfo, RomFile> callback)
|
public static void FetchRomFileInRoomInfo(this Protobuf_Room_MiniInfo roomInfo, EnumPlatform platform, Action<Protobuf_Room_MiniInfo, RomFile> callback)
|
||||||
{
|
{
|
||||||
if (s_RomFileCahcesInRoomInfo.TryGetValue(roomInfo.GameRomID, out RomFile romFile))
|
RomFile romFile;
|
||||||
|
|
||||||
|
if (s_RomFileCahcesInRoomInfo.TryGetValue(roomInfo.GameRomID, out romFile))
|
||||||
{
|
{
|
||||||
callback.Invoke(roomInfo, romFile);
|
callback.Invoke(roomInfo, romFile);
|
||||||
return;
|
return;
|
||||||
@ -46,11 +48,11 @@ namespace AxibugEmuOnline.Client
|
|||||||
case EnumPlatform.NES:
|
case EnumPlatform.NES:
|
||||||
App.StartCoroutine(App.httpAPI.GetNesRomInfo(roomInfo.GameRomID, (romWebData) =>
|
App.StartCoroutine(App.httpAPI.GetNesRomInfo(roomInfo.GameRomID, (romWebData) =>
|
||||||
{
|
{
|
||||||
RomFile romFile = new RomFile(EnumPlatform.NES, 0, 0);
|
RomFile _romFile = new RomFile(EnumPlatform.NES, 0, 0);
|
||||||
romFile.SetWebData(romWebData);
|
_romFile.SetWebData(romWebData);
|
||||||
s_RomFileCahcesInRoomInfo[roomInfo.GameRomID] = romFile;
|
s_RomFileCahcesInRoomInfo[roomInfo.GameRomID] = _romFile;
|
||||||
|
|
||||||
callback.Invoke(roomInfo, romFile);
|
callback.Invoke(roomInfo, _romFile);
|
||||||
}));
|
}));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user