From 1941f613d8a4688966cfa24440324ad0916b9b34 Mon Sep 17 00:00:00 2001 From: nino-porcino Date: Thu, 16 Dec 2021 18:33:56 +0100 Subject: [PATCH] rename symbols, add string input demo --- demo/demo.c | 6 ++---- demo/demo_amiga_hand.h | 2 +- demo/demo_extvid.h | 2 +- demo/demo_screen1.h | 34 ++++++++++++++++++++++++++-------- demo/demo_screen2.h | 20 ++++++++++---------- 5 files changed, 40 insertions(+), 24 deletions(-) diff --git a/demo/demo.c b/demo/demo.c index 66e7c74..d23e5b4 100644 --- a/demo/demo.c +++ b/demo/demo.c @@ -1,5 +1,3 @@ -// TODO make screen tables parametric (fixed values calculated by macros) - #include "../lib/utils.h" #include "../lib/apple1.h" #include "../lib/tms9918.h" @@ -38,8 +36,8 @@ void main() { byte key = 'H'; for(;;) { - if(key == '1') prova_screen1(); - else if(key == '2') prova_screen2(); + if(key == '1') demo_screen1(); + else if(key == '2') demo_screen2(); else if(key == 'A') demo_amiga_hand(); else if(key == 'I') demo_interrupt(); else if(key == 'E') flip_external_input(); diff --git a/demo/demo_amiga_hand.h b/demo/demo_amiga_hand.h index 58d79a6..83f43e4 100644 --- a/demo/demo_amiga_hand.h +++ b/demo/demo_amiga_hand.h @@ -163,7 +163,7 @@ void demo_amiga_hand() { screen2_puts(0, 4, FG_BG(COLOR_BLACK,COLOR_WHITE), "READY."); for(word p=0;p<612;p+=4) { - vti_line(amiga_data[p],amiga_data[p+1],amiga_data[p+2],amiga_data[p+3]); + screen2_line(amiga_data[p],amiga_data[p+1],amiga_data[p+2],amiga_data[p+3]); } screen2_puts(18, 12, FG_BG(COLOR_DARK_BLUE, COLOR_WHITE), "APPLE1"); } diff --git a/demo/demo_extvid.h b/demo/demo_extvid.h index 78d8f37..3973364 100644 --- a/demo/demo_extvid.h +++ b/demo/demo_extvid.h @@ -8,7 +8,7 @@ void flip_external_input() { else woz_puts("EXT INPUT OFF\r"); // fill color table with transparent color so that external input can be seen - tms_set_vram_write_addr(SCREEN1_COLOR_TABLE); + tms_set_vram_write_addr(TMS_COLOR_TABLE); for(byte i=32;i!=0;i--) { TMS_WRITE_DATA_PORT(FG_BG(COLOR_DARK_YELLOW, COLOR_TRANSPARENT)); } diff --git a/demo/demo_screen1.h b/demo/demo_screen1.h index cfe3283..3176f9f 100644 --- a/demo/demo_screen1.h +++ b/demo/demo_screen1.h @@ -1,12 +1,14 @@ +#include + void screen1_square_sprites() { // fills first sprite pattern with 255 - tms_set_vram_write_addr(SCREEN1_SPRITE_PATTERNS); // start writing in the sprite patterns + tms_set_vram_write_addr(TMS_SPRITE_PATTERNS); // start writing in the sprite patterns for(byte i=0;i<8;i++) { TMS_WRITE_DATA_PORT(255); } // set sprite coordinates - tms_set_vram_write_addr(SCREEN1_SPRITE_ATTRS); // start writing in the sprite attribute + tms_set_vram_write_addr(TMS_SPRITE_ATTRS); // start writing in the sprite attribute for(byte i=0;i<32;i++) { TMS_WRITE_DATA_PORT((6+i)*8); NOP; NOP; NOP; NOP; // y coordinate TMS_WRITE_DATA_PORT((6+i)*8); NOP; NOP; NOP; NOP; // x coordinate @@ -15,18 +17,34 @@ void screen1_square_sprites() { } } -void prova_screen1() { +byte buffer[32]; +void demo_screen1() { tms_init_regs(SCREEN1_TABLE); screen1_prepare(); screen1_load_font(); - screen1_home(); screen1_puts("*** P-LAB VIDEO CARD SYSTEM ***"); - screen1_locate(0, 2); screen1_puts("16K VRAM BYTES FREE"); - screen1_locate(0, 4); screen1_puts("READY."); + screen1_putc(CHR_CLS); + screen1_puts( + "*** P-LAB VIDEO CARD SYSTEM ***\n" + "16K VRAM BYTES FREE\n\n" + "READY.\n\n\n" + ); - screen1_locate(0, 10); - for(word i=0;i<256;i++) screen1_putc((byte)i); + screen1_puts("what about " REVERSE_ON " REVERSE text " REVERSE_OFF " ?\n\n\n\n"); + + for(word i=32;i<128;i++) screen1_putc((byte)i); + screen1_puts("\n\n" REVERSE_ON); + for(word i=32;i<128;i++) screen1_putc((byte)i); screen1_square_sprites(); + + while(1) { + screen1_puts(REVERSE_OFF "\n\nWRITE HERE: >"); + screen1_strinput(buffer,16); + if(strlen(buffer)==0) break; + screen1_puts("\n\n\nyou wrote: '"); + screen1_puts(buffer); + screen1_puts("'"); + } } diff --git a/demo/demo_screen2.h b/demo/demo_screen2.h index 9ef1862..194a8a0 100644 --- a/demo/demo_screen2.h +++ b/demo/demo_screen2.h @@ -1,4 +1,4 @@ -void prova_screen2() { +void demo_screen2() { tms_init_regs(SCREEN2_TABLE); byte text_color = FG_BG(COLOR_BLACK,COLOR_WHITE); @@ -13,20 +13,20 @@ void prova_screen2() { screen2_puts(5,(byte)(6+i),(byte)(((15-i)<<4)+i)," SCREEN 2 "); } - vti_line(18, 45,232,187); - vti_line(18,187,232, 45); + screen2_line(18, 45,232,187); + screen2_line(18,187,232, 45); - SCREEN2_PLOT_MODE = PLOT_MODE_RESET; + screen2_plot_mode = PLOT_MODE_RESET; - vti_line(18+5, 45,232+5,187); - vti_line(18+5,187,232+5, 45); + screen2_line(18+5, 45,232+5,187); + screen2_line(18+5,187,232+5, 45); - SCREEN2_PLOT_MODE = PLOT_MODE_INVERT; + screen2_plot_mode = PLOT_MODE_INVERT; - vti_line(18+5+5, 45,232+5+5,187); - vti_line(18+5+5,187,232+5+5, 45); + screen2_line(18+5+5, 45,232+5+5,187); + screen2_line(18+5+5,187,232+5+5, 45); - SCREEN2_PLOT_MODE = PLOT_MODE_SET; + screen2_plot_mode = PLOT_MODE_SET; //vti_ellipse_rect(7,9,202,167); }