Skip to content

Commit

Permalink
Latest Jason fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tschrapel committed Oct 8, 2024
1 parent baa5e8a commit 7b81ee3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 35 deletions.
17 changes: 5 additions & 12 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
40 changes: 19 additions & 21 deletions src/vga/vga.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand All @@ -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;
Expand All @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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)
Expand All @@ -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;
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vga/vga.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)();

Expand Down
2 changes: 1 addition & 1 deletion submodules/vrEmuTms9918

0 comments on commit 7b81ee3

Please sign in to comment.