add wait_end_of_frame and its demo

This commit is contained in:
nino-porcino 2021-12-17 10:23:18 +01:00
parent 0d5a9d6ecd
commit 478cb1ecff
3 changed files with 31 additions and 1 deletions

View File

@ -6,6 +6,7 @@
#include "demo_interrupt.h" #include "demo_interrupt.h"
#include "demo_extvid.h" #include "demo_extvid.h"
#include "demo_blank.h" #include "demo_blank.h"
#include "demo_end_of_frame.h"
void help() { void help() {
woz_puts( woz_puts(
@ -16,6 +17,7 @@ void help() {
"A AMIGA HAND\r" "A AMIGA HAND\r"
"I INTERRUPT\r" "I INTERRUPT\r"
"E FLIP EXT VIDEO\r" "E FLIP EXT VIDEO\r"
"F TEST END-OF-FRAME\r"
"B BLANK ON/OFF\r" "B BLANK ON/OFF\r"
"H HELP\r" "H HELP\r"
"0 EXITS\r\r" "0 EXITS\r\r"
@ -35,6 +37,7 @@ void main() {
else if(key == 'A') demo_amiga_hand(); else if(key == 'A') demo_amiga_hand();
else if(key == 'I') demo_interrupt(); else if(key == 'I') demo_interrupt();
else if(key == 'E') flip_external_input(); else if(key == 'E') flip_external_input();
else if(key == 'F') demo_end_of_frame();
else if(key == 'B') flip_blank(); else if(key == 'B') flip_blank();
else if(key == 'H') help(); else if(key == 'H') help();
else if(key == '0') break; else if(key == '0') break;

26
demo/demo_end_of_frame.h Normal file
View File

@ -0,0 +1,26 @@
void demo_end_of_frame() {
tms_init_regs(SCREEN1_TABLE);
screen1_prepare();
screen1_load_font();
screen1_puts(
CLS "\n"
"Waitining for 600 ticks by\n"
"counting the " REVERSE_ON "END-OF-FRAME" REVERSE_OFF " bit.\n\n"
"It will take about 10 seconds.\n\n"
);
word secs = 0;
word ticks = 0;
while(secs<10) {
tms_wait_end_of_frame();
ticks++;
if(ticks==60) {
secs++;
ticks = 0;
screen1_puts("60 ticks!\n");
}
}
screen1_puts("\n\nDONE!");
}

View File

@ -8,6 +8,7 @@
// TODO finalize hexdump.js and update README.md // TODO finalize hexdump.js and update README.md
// TODO allow redefinition of I/O ports // TODO allow redefinition of I/O ports
// TODO wait_end_of_frame() // TODO wait_end_of_frame()
// TODO screen1() and screen2() helpers
#pragma encoding(ascii) // encode strings in plain ascii #pragma encoding(ascii) // encode strings in plain ascii
@ -157,7 +158,7 @@ void tms_set_external_video(byte val) {
tms_write_reg(0, regvalue); tms_write_reg(0, regvalue);
} }
void tms_wait_end_of_frame() { inline void tms_wait_end_of_frame() {
while(!FRAME_BIT(TMS_READ_CTRL_PORT)); while(!FRAME_BIT(TMS_READ_CTRL_PORT));
} }