diff --git a/src/main.c b/src/main.c index 9c87a7b..2dadbdf 100644 --- a/src/main.c +++ b/src/main.c @@ -127,14 +127,14 @@ //#define PICO_CLOCK_PLL 984000000 // 328MHz - 1.15v //#define PICO_CLOCK_PLL_DIV1 3 -//#define PICO_CLOCK_PLL 1056000000 // 352MHz - 1.3v -//#define PICO_CLOCK_PLL_DIV1 3 +#define PICO_CLOCK_PLL 1056000000 // 352MHz - 1.3v +#define PICO_CLOCK_PLL_DIV1 3 //#define PICO_CLOCK_PLL 1128000000 // 376MHz - 1.3v //#define PICO_CLOCK_PLL_DIV1 3 -#define PICO_CLOCK_PLL 1512000000 // 378MHz - 1.3v -#define PICO_CLOCK_PLL_DIV1 4 +//#define PICO_CLOCK_PLL 1512000000 // 378MHz - 1.3v +//#define PICO_CLOCK_PLL_DIV1 4 //#define PICO_CLOCK_PLL 804000000 // 402MHz - DOES NOT WORK //#define PICO_CLOCK_PLL_DIV1 2 @@ -364,15 +364,8 @@ inline uint32_t bigRgb2LittleBgr(uint32_t val) return val | ((val >> 12) << 4); } -static void tmsPorch(uint16_t* pixels) +static void tmsPorch() { - uint32_t* dPixels = (uint32_t*)pixels; - //bg = bigRgb2LittleBgr(tms9918->pram[vrEmuTms9918RegValue(TMS_REG_FG_BG_COLOR) & 0x0f]); - bg = 0;//bg | (bg << 16); - dma_channel_wait_for_finish_blocking(dma32); - dma_channel_set_write_addr(dma32, dPixels, false); - dma_channel_set_trans_count(dma32, VIRTUAL_PIXELS_X / 2, true); - tms9918->blanking = 1; // V tms9918->scanline = 255; // F18A value for vsync tms9918->status [0x03] = 255; diff --git a/src/vga/vga.c b/src/vga/vga.c index c4963e8..ffbf315 100644 --- a/src/vga/vga.c +++ b/src/vga/vga.c @@ -329,6 +329,7 @@ static void __isr __time_critical_func(dmaIrqHandler)(void) if (currentTimingLine + 2 == (vgaParams.params.vSyncParams.syncPixels + vgaParams.params.vSyncParams.backPorchPixels)) { multicore_fifo_push_timeout_us(0, 0); + multicore_fifo_push_timeout_us(1, 0); } } else if (currentTimingLine < (vgaParams.params.vSyncParams.totalPixels - vgaParams.params.vSyncParams.frontPorchPixels)) @@ -340,7 +341,7 @@ static void __isr __time_critical_func(dmaIrqHandler)(void) dma_channel_set_read_addr(syncDmaChan, syncDataPorch, true); if (currentTimingLine == (vgaParams.params.vSyncParams.totalPixels - vgaParams.params.vSyncParams.frontPorchPixels) + 2) { - multicore_fifo_push_timeout_us(FRONT_PORCH_MSG | 1, 0); + multicore_fifo_push_timeout_us(FRONT_PORCH_MSG, 0); } } #if VGA_SCANLINE_CB_ENABLE @@ -352,6 +353,7 @@ static void __isr __time_critical_func(dmaIrqHandler)(void) { dma_hw->ints0 = rgbDmaChanMask; + currentDisplayLine++; #if VGA_HARDCODED_640 uint32_t pxLine = currentDisplayLine >> 1; uint32_t pxLineRpt = currentDisplayLine & 0x01; @@ -362,7 +364,6 @@ static void __isr __time_critical_func(dmaIrqHandler)(void) #endif uint32_t* currentBuffer = (uint32_t*)rgbDataBuffer[pxLine & 0x01]; - currentDisplayLine++; #if VGA_CRT_EFFECT if (vgaParams.scanlines && pxLineRpt != 0) @@ -382,22 +383,16 @@ static void __isr __time_critical_func(dmaIrqHandler)(void) } #endif - if (currentDisplayLine == VIRTUAL_PIXELS_Y * 2) - { - currentBuffer [0] = 0; - currentBuffer [1] = 0; - currentBuffer [2] = 0; - currentBuffer [3] = 0; - currentBuffer [4] = 0; - } dma_channel_set_read_addr(rgbDmaChan, currentBuffer, true); // need a new line every X display lines - if ((pxLineRpt == 0)) + if (pxLineRpt == 0) { uint32_t requestLine = pxLine + 1; if (requestLine < VIRTUAL_PIXELS_Y) + { multicore_fifo_push_timeout_us(requestLine, 0); + } #if VGA_SCANLINE_TIME_DEBUG hasRenderedNext = false; @@ -449,11 +444,11 @@ void __time_critical_func(vgaLoop)() { uint32_t message = multicore_fifo_pop_blocking(); - if ((message & ~1) == FRONT_PORCH_MSG) + if (message == FRONT_PORCH_MSG) { if (vgaParams.porchFn) { - vgaParams.porchFn(rgbDataBuffer[message & 1]); + vgaParams.porchFn(); } } else if (message == END_OF_FRAME_MSG) @@ -476,16 +471,19 @@ void __time_critical_func(vgaLoop)() else { bool doEof = false; - while (multicore_fifo_rvalid()) // if we dropped a scanline, no point rendering it now + if (message != 0) { - uint32_t nextMessage = sio_hw->fifo_rd; - if (nextMessage == END_OF_FRAME_MSG) - { - doEof = true; - } - else + while (multicore_fifo_rvalid()) // if we dropped a scanline, no point rendering it now { - message = nextMessage; + uint32_t nextMessage = sio_hw->fifo_rd; + if (nextMessage == END_OF_FRAME_MSG) + { + doEof = true; + } + else + { + message = nextMessage; + } } } diff --git a/src/vga/vga.h b/src/vga/vga.h index 1130319..8441361 100644 --- a/src/vga/vga.h +++ b/src/vga/vga.h @@ -43,7 +43,7 @@ typedef struct typedef void (*vgaScanlineRgbFn)(uint16_t y, VgaParams* params, uint16_t* pixels); typedef void (*vgaEndOfFrameFn)(uint32_t frameNumber); -typedef void (*vgaPorchFn)(uint16_t* pixels); +typedef void (*vgaPorchFn)(); typedef void (*vgaInitFn)(); typedef void (*vgaEndOfScanlineFn)(); diff --git a/submodules/vrEmuTms9918 b/submodules/vrEmuTms9918 index 874e1d0..91c0737 160000 --- a/submodules/vrEmuTms9918 +++ b/submodules/vrEmuTms9918 @@ -1 +1 @@ -Subproject commit 874e1d0f02946b203d93fb8d0a0246aaa55ba636 +Subproject commit 91c073770ee13abff04bd8463b75f3d88f771107