Pixels in sync with VSYNC and HSYNC.

This commit is contained in:
giomba 2022-10-15 15:08:22 +02:00
parent 6b6b76b212
commit 9b596c80aa
2 changed files with 14 additions and 8 deletions

View File

@ -22,7 +22,7 @@
#define FRAMES 2 #define FRAMES 2
#define HPIXEL 640 #define HPIXEL 640
#define VPIXEL 480 #define VPIXEL 500
#define BPP 1 #define BPP 1
typedef struct Frame typedef struct Frame
@ -93,11 +93,11 @@ int main()
// "draw" an horizontal dotted line (?) // "draw" an horizontal dotted line (?)
for (unsigned int c = 0; c < 20; c += 3) for (unsigned int c = 0; c < 20; c += 3)
{ {
frames[0].data[80 * 64 + 20 + c] = 0x55; frames[0].data[80 * 64 + 50 + c] = 0x55;
} }
for (unsigned int c = 0; c < 20; c += 3) for (unsigned int c = 0; c < 20; c += 3)
{ {
frames[0].data[80 * 128 + 20 + c] = 0x99; frames[0].data[80 * 128 + 50 + c] = 0x99;
} }
// PIO and state machines // PIO and state machines
@ -124,12 +124,14 @@ int main()
// low pulse assert lasts for 3 horizontal lines, then adjust by one // low pulse assert lasts for 3 horizontal lines, then adjust by one
pio_sm_put_blocking(pio, sm2, 3 - 1); pio_sm_put_blocking(pio, sm2, 3 - 1);
pio_sm_put_blocking(pio, sm2, 500 - 3 - 1); pio_sm_put_blocking(pio, sm2, 500 - 3 - 1);
printf("OK\n");
// VGA pixel program // VGA pixel program
uint offset0 = pio_add_program(pio, &vga_free_run_program); uint offset0 = pio_add_program(pio, &vga_free_run_program);
uint sm0 = pio_claim_unused_sm(pio, true); uint sm0 = pio_claim_unused_sm(pio, false);
printf("Starting VGA pixel machine on %u...\n", sm0); printf("Starting VGA pixel machine on %u...\n", sm0);
vga_pixel_program_init(pio, sm0, offset0); vga_pixel_program_init(pio, sm0, offset0);
pio_sm_put_blocking(pio, sm0, 640 - 1);
printf("Start!\n"); printf("Start!\n");

View File

@ -1,11 +1,15 @@
.program vga_free_run .program vga_free_run
entrypoint_vga_free_run: entrypoint_vga_free_run:
pull
mov y, osr
loope:
mov x, y
wait irq 0
loop: loop:
out pins, 1 [2] out pins, 1
nop jmp x-- loop
nop jmp loope
jmp loop
.program vga_hsync .program vga_hsync