ceda2vga/src/main.c

46 lines
759 B
C
Raw Normal View History

/**
* @file main.c
* @author giomba@glgprograms.it
* @brief
*
* @copyright Copyright Retrofficina GLG Programs (c) 2022
*
*/
#include "pico/stdlib.h"
2022-10-10 17:10:52 +00:00
#include <stdint.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
2022-10-10 17:10:52 +00:00
#include "draw_demo.h"
#include "framebuffer.h"
2022-12-03 19:52:47 +00:00
#include "vga.h"
2022-10-10 19:48:16 +00:00
2022-12-02 21:34:00 +00:00
int main()
{
stdio_init_all();
draw_demo();
2022-10-10 17:10:52 +00:00
2022-12-03 19:52:47 +00:00
vga_machines_init();
2022-10-10 17:10:52 +00:00
2022-10-15 22:09:51 +00:00
for (;;)
{
2022-12-02 21:34:00 +00:00
// moving sine
const uint16_t fc = frame_counter;
const uint16_t x = fc % 640;
2022-12-02 21:34:00 +00:00
const uint16_t y = 380 + 100 * (abs(320 - x) / 640.0) * sin((fc % 640) / 12.738);
2022-12-03 19:52:47 +00:00
set_pixel(x, y);
// 13 ms <=> 75 Hz
// Actually, there is a point in going in sync with vertical refresh,
// but let's just forget this for the demo.
sleep_ms(13);
clear_pixel(x, y);
}
}