diff --git a/src/devices/video/EmuNV2A_PBUS.cpp b/src/devices/video/EmuNV2A_PBUS.cpp index 604731bb2..a30fc2099 100644 --- a/src/devices/video/EmuNV2A_PBUS.cpp +++ b/src/devices/video/EmuNV2A_PBUS.cpp @@ -1,3 +1,4 @@ +/* PBUS - bus control */ DEVICE_READ32(PBUS) { DEVICE_READ32_SWITCH() { diff --git a/src/devices/video/EmuNV2A_PCRTC.cpp b/src/devices/video/EmuNV2A_PCRTC.cpp index c61eb608e..353412f62 100644 --- a/src/devices/video/EmuNV2A_PCRTC.cpp +++ b/src/devices/video/EmuNV2A_PCRTC.cpp @@ -36,6 +36,10 @@ DEVICE_WRITE32(PCRTC) value &= 0x07FFFFFF; // assert(val < memory_region_size(d->vram)); d->pcrtc.start = value; + + NV2A_DPRINTF("PCRTC_START - %x %x %x %x\n", + d->vram_ptr[value+64], d->vram_ptr[value+64+1], + d->vram_ptr[value+64+2], d->vram_ptr[value+64+3]); break; default: diff --git a/src/devices/video/EmuNV2A_PFIFO.cpp b/src/devices/video/EmuNV2A_PFIFO.cpp index 8392c6644..a7f1ccf54 100644 --- a/src/devices/video/EmuNV2A_PFIFO.cpp +++ b/src/devices/video/EmuNV2A_PFIFO.cpp @@ -11,6 +11,7 @@ int pfifo_puller_thread(NV2AState *d); static uint32_t ramht_hash(NV2AState *d, uint32_t handle); static RAMHTEntry ramht_lookup(NV2AState *d, uint32_t handle); // forward declaration +/* PFIFO - MMIO and DMA FIFO submission to PGRAPH and VPE */ DEVICE_READ32(PFIFO) { DEVICE_READ32_SWITCH() { @@ -277,7 +278,6 @@ static void pfifo_run_pusher(NV2AState *d) { if (!state->method_nonincreasing) { state->method += 4; } - state->method_count--; state->dcount++; } else { @@ -320,8 +320,7 @@ static void pfifo_run_pusher(NV2AState *d) { state->method_count = (word >> 18) & 0x7ff; state->method_nonincreasing = false; state->dcount = 0; - } - else if ((word & 0xe0030003) == 0x40000000) { + } else if ((word & 0xe0030003) == 0x40000000) { /* non-increasing methods */ state->method = word & 0x1fff; state->subchannel = (word >> 13) & 7; @@ -361,9 +360,14 @@ int pfifo_puller_thread(NV2AState *d) while (true) { state->cache_lock.lock(); - while (state->cache.empty() || !state->pull_enabled) { state->cache_cond.wait(state->cache_lock); + + if (d->exiting) { + state->cache_lock.unlock(); + // glo_set_current(NULL); + return 0; + } } // Copy cache to working_cache diff --git a/src/devices/video/EmuNV2A_PGRAPH.cpp b/src/devices/video/EmuNV2A_PGRAPH.cpp index 9c990334f..a6afc410c 100644 --- a/src/devices/video/EmuNV2A_PGRAPH.cpp +++ b/src/devices/video/EmuNV2A_PGRAPH.cpp @@ -2581,12 +2581,12 @@ static void pgraph_context_switch(NV2AState *d, unsigned int channel_id) { bool valid; - d->pgraph.lock.lock(); // TODO : This isn't in xqemu / OpenXbox? + // Cxbx Note : This isn't present in xqemu / OpenXbox : d->pgraph.lock.lock(); valid = d->pgraph.channel_valid && d->pgraph.channel_id == channel_id; if (!valid) { d->pgraph.trapped_channel_id = channel_id; } - d->pgraph.lock.unlock(); // TODO : This isn't in xqemu / OpenXbox? + // Cxbx Note : This isn't present in xqemu / OpenXbox : d->pgraph.lock.unlock(); if (!valid) { NV2A_DPRINTF("puller needs to switch to ch %d\n", channel_id); diff --git a/src/devices/video/EmuNV2A_PMC.cpp b/src/devices/video/EmuNV2A_PMC.cpp index a5dfaaf80..4b8719b2f 100644 --- a/src/devices/video/EmuNV2A_PMC.cpp +++ b/src/devices/video/EmuNV2A_PMC.cpp @@ -1,3 +1,4 @@ +/* PMC - card master control */ DEVICE_READ32(PMC) { DEVICE_READ32_SWITCH() { diff --git a/src/devices/video/EmuNV2A_PTIMER.cpp b/src/devices/video/EmuNV2A_PTIMER.cpp index 16baa64d0..db3b0777b 100644 --- a/src/devices/video/EmuNV2A_PTIMER.cpp +++ b/src/devices/video/EmuNV2A_PTIMER.cpp @@ -17,13 +17,15 @@ static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c) return res.ll; } -/* PIMTER - time measurement and time-based alarms */ -static uint32_t ptimer_get_clock(NV2AState * d) +/* PTIMER - time measurement and time-based alarms */ +static uint64_t ptimer_get_clock(NV2AState * d) { // Get time in nanoseconds long int time = static_cast(std::chrono::duration_cast(std::chrono::high_resolution_clock::now().time_since_epoch()).count()); - return muldiv64(time, d->pramdac.core_clock_freq * d->ptimer.numerator, CLOCKS_PER_SEC * d->ptimer.denominator); + return muldiv64(time, + d->pramdac.core_clock_freq * d->ptimer.numerator, + CLOCKS_PER_SEC * d->ptimer.denominator); } DEVICE_READ32(PTIMER) diff --git a/src/devices/video/EmuNV2A_USER.cpp b/src/devices/video/EmuNV2A_USER.cpp index 4aae56fc4..140d66a00 100644 --- a/src/devices/video/EmuNV2A_USER.cpp +++ b/src/devices/video/EmuNV2A_USER.cpp @@ -1,3 +1,4 @@ +/* USER - PFIFO MMIO and DMA submission area */ DEVICE_READ32(USER) { unsigned int channel_id = addr >> 16; diff --git a/src/devices/video/nv2a.cpp b/src/devices/video/nv2a.cpp index e9c125c09..6c904ca0e 100644 --- a/src/devices/video/nv2a.cpp +++ b/src/devices/video/nv2a.cpp @@ -181,14 +181,14 @@ static void *nv_dma_map(NV2AState *d, xbaddr dma_obj_address, xbaddr *len) DMAObject dma = nv_dma_load(d, dma_obj_address); /* TODO: Handle targets and classes properly */ - printf("dma_map %x, %x, %x %x\n", + NV2A_DPRINTF("dma_map %x, %x, %x %x\n", dma.dma_class, dma.dma_target, dma.address, dma.limit); dma.address &= 0x07FFFFFF; // assert(dma.address + dma.limit < memory_region_size(d->vram)); *len = dma.limit; - return (void*)(MM_SYSTEM_PHYSICAL_MAP + dma.address); + return d->vram_ptr + dma.address; } #include "EmuNV2A_PBUS.cpp"