Skip to content

Commit 7b81ee3

Browse files
committed
Latest Jason fixes
1 parent baa5e8a commit 7b81ee3

File tree

4 files changed

+26
-35
lines changed

4 files changed

+26
-35
lines changed

src/main.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@
127127
//#define PICO_CLOCK_PLL 984000000 // 328MHz - 1.15v
128128
//#define PICO_CLOCK_PLL_DIV1 3
129129

130-
//#define PICO_CLOCK_PLL 1056000000 // 352MHz - 1.3v
131-
//#define PICO_CLOCK_PLL_DIV1 3
130+
#define PICO_CLOCK_PLL 1056000000 // 352MHz - 1.3v
131+
#define PICO_CLOCK_PLL_DIV1 3
132132

133133
//#define PICO_CLOCK_PLL 1128000000 // 376MHz - 1.3v
134134
//#define PICO_CLOCK_PLL_DIV1 3
135135

136-
#define PICO_CLOCK_PLL 1512000000 // 378MHz - 1.3v
137-
#define PICO_CLOCK_PLL_DIV1 4
136+
//#define PICO_CLOCK_PLL 1512000000 // 378MHz - 1.3v
137+
//#define PICO_CLOCK_PLL_DIV1 4
138138

139139
//#define PICO_CLOCK_PLL 804000000 // 402MHz - DOES NOT WORK
140140
//#define PICO_CLOCK_PLL_DIV1 2
@@ -364,15 +364,8 @@ inline uint32_t bigRgb2LittleBgr(uint32_t val)
364364
return val | ((val >> 12) << 4);
365365
}
366366

367-
static void tmsPorch(uint16_t* pixels)
367+
static void tmsPorch()
368368
{
369-
uint32_t* dPixels = (uint32_t*)pixels;
370-
//bg = bigRgb2LittleBgr(tms9918->pram[vrEmuTms9918RegValue(TMS_REG_FG_BG_COLOR) & 0x0f]);
371-
bg = 0;//bg | (bg << 16);
372-
dma_channel_wait_for_finish_blocking(dma32);
373-
dma_channel_set_write_addr(dma32, dPixels, false);
374-
dma_channel_set_trans_count(dma32, VIRTUAL_PIXELS_X / 2, true);
375-
376369
tms9918->blanking = 1; // V
377370
tms9918->scanline = 255; // F18A value for vsync
378371
tms9918->status [0x03] = 255;

src/vga/vga.c

Lines changed: 19 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ static void __isr __time_critical_func(dmaIrqHandler)(void)
329329
if (currentTimingLine + 2 == (vgaParams.params.vSyncParams.syncPixels + vgaParams.params.vSyncParams.backPorchPixels))
330330
{
331331
multicore_fifo_push_timeout_us(0, 0);
332+
multicore_fifo_push_timeout_us(1, 0);
332333
}
333334
}
334335
else if (currentTimingLine < (vgaParams.params.vSyncParams.totalPixels - vgaParams.params.vSyncParams.frontPorchPixels))
@@ -340,7 +341,7 @@ static void __isr __time_critical_func(dmaIrqHandler)(void)
340341
dma_channel_set_read_addr(syncDmaChan, syncDataPorch, true);
341342
if (currentTimingLine == (vgaParams.params.vSyncParams.totalPixels - vgaParams.params.vSyncParams.frontPorchPixels) + 2)
342343
{
343-
multicore_fifo_push_timeout_us(FRONT_PORCH_MSG | 1, 0);
344+
multicore_fifo_push_timeout_us(FRONT_PORCH_MSG, 0);
344345
}
345346
}
346347
#if VGA_SCANLINE_CB_ENABLE
@@ -352,6 +353,7 @@ static void __isr __time_critical_func(dmaIrqHandler)(void)
352353
{
353354
dma_hw->ints0 = rgbDmaChanMask;
354355

356+
currentDisplayLine++;
355357
#if VGA_HARDCODED_640
356358
uint32_t pxLine = currentDisplayLine >> 1;
357359
uint32_t pxLineRpt = currentDisplayLine & 0x01;
@@ -362,7 +364,6 @@ static void __isr __time_critical_func(dmaIrqHandler)(void)
362364
#endif
363365

364366
uint32_t* currentBuffer = (uint32_t*)rgbDataBuffer[pxLine & 0x01];
365-
currentDisplayLine++;
366367

367368
#if VGA_CRT_EFFECT
368369
if (vgaParams.scanlines && pxLineRpt != 0)
@@ -382,22 +383,16 @@ static void __isr __time_critical_func(dmaIrqHandler)(void)
382383
}
383384
#endif
384385

385-
if (currentDisplayLine == VIRTUAL_PIXELS_Y * 2)
386-
{
387-
currentBuffer [0] = 0;
388-
currentBuffer [1] = 0;
389-
currentBuffer [2] = 0;
390-
currentBuffer [3] = 0;
391-
currentBuffer [4] = 0;
392-
}
393386
dma_channel_set_read_addr(rgbDmaChan, currentBuffer, true);
394387

395388
// need a new line every X display lines
396-
if ((pxLineRpt == 0))
389+
if (pxLineRpt == 0)
397390
{
398391
uint32_t requestLine = pxLine + 1;
399392
if (requestLine < VIRTUAL_PIXELS_Y)
393+
{
400394
multicore_fifo_push_timeout_us(requestLine, 0);
395+
}
401396

402397
#if VGA_SCANLINE_TIME_DEBUG
403398
hasRenderedNext = false;
@@ -449,11 +444,11 @@ void __time_critical_func(vgaLoop)()
449444
{
450445
uint32_t message = multicore_fifo_pop_blocking();
451446

452-
if ((message & ~1) == FRONT_PORCH_MSG)
447+
if (message == FRONT_PORCH_MSG)
453448
{
454449
if (vgaParams.porchFn)
455450
{
456-
vgaParams.porchFn(rgbDataBuffer[message & 1]);
451+
vgaParams.porchFn();
457452
}
458453
}
459454
else if (message == END_OF_FRAME_MSG)
@@ -476,16 +471,19 @@ void __time_critical_func(vgaLoop)()
476471
else
477472
{
478473
bool doEof = false;
479-
while (multicore_fifo_rvalid()) // if we dropped a scanline, no point rendering it now
474+
if (message != 0)
480475
{
481-
uint32_t nextMessage = sio_hw->fifo_rd;
482-
if (nextMessage == END_OF_FRAME_MSG)
483-
{
484-
doEof = true;
485-
}
486-
else
476+
while (multicore_fifo_rvalid()) // if we dropped a scanline, no point rendering it now
487477
{
488-
message = nextMessage;
478+
uint32_t nextMessage = sio_hw->fifo_rd;
479+
if (nextMessage == END_OF_FRAME_MSG)
480+
{
481+
doEof = true;
482+
}
483+
else
484+
{
485+
message = nextMessage;
486+
}
489487
}
490488
}
491489

src/vga/vga.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ typedef struct
4343

4444
typedef void (*vgaScanlineRgbFn)(uint16_t y, VgaParams* params, uint16_t* pixels);
4545
typedef void (*vgaEndOfFrameFn)(uint32_t frameNumber);
46-
typedef void (*vgaPorchFn)(uint16_t* pixels);
46+
typedef void (*vgaPorchFn)();
4747
typedef void (*vgaInitFn)();
4848
typedef void (*vgaEndOfScanlineFn)();
4949

submodules/vrEmuTms9918

0 commit comments

Comments
 (0)