pigfx icon indicating copy to clipboard operation
pigfx copied to clipboard

using h code

Open huskeyw opened this issue 6 years ago • 9 comments

so I am trying to figure out how to use the codes.. maybe I am in the wrong mode.. but I put in

print chr$(27)+"[?#x0;y0;x1;y1l"

and I get x0;y0;x1;y1l as an output

huskeyw avatar Feb 24 '19 18:02 huskeyw

Hello, the sequence for graphic line is <esc>[# not <esc>[?#, and you have to put numeric values. Beware that in Microsoft BASIC, PRINT will insert a space before numeric values, so you have to convert them to raw string using str$(), and separating print arguments with ; is better than adding strings (because of limited string space and garbage collection when out of space) so, if x0, y0 and x1, y1 are variables with your coordinates you put them in a sequence like print chr$(27);"[#";str$(x0);";";str$(y0);";";str$(x1);";";str$(y1);"l";

Be sure to end your print with a ; to avoid a carriage return. And use integer variables for your X and Y, or str$() will put in decimal parts, which will confuse PiGfx at this moment and end the escape sequence prematurely. (I think integer variables can be used by suffixing the name with %.)

You will find the list of supported code here

EDIT: I just checked and the nascom Basic has no specific suffix for integer variables. All numeric variables are single precision with up to 7 decimal digits.

bkg2018 avatar Feb 25 '19 07:02 bkg2018

Thank you for the responses I see the updated codes... but I dont get a line ..

On Sun, Feb 24, 2019, 23:54 Francis Piérot [email protected] wrote:

Hello, the sequence for graphic line is esc[#, not esc[?#.

You will find the list of supported code here https://github.com/fbergama/pigfx/blob/master/doc/terminal_codes.txt

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fbergama/pigfx/issues/15#issuecomment-466906505, or mute the thread https://github.com/notifications/unsubscribe-auth/AteoRqtVnu9PMCt8I7repuh9IBo3P_y_ks5vQ5aZgaJpZM4bOsy- .

huskeyw avatar Feb 25 '19 10:02 huskeyw

I checked and found that STR$() inserts a space before the number too, while print inserts a space beffore and after any numeric value. So to send pure numbers with no space I had to use MID$(STR$(number),2). This is rather annoying but any space will end the escape sequence. Maybe I'll fix that so it's easier to send sequences, but it could have side efffects.

I did a little program to display lines of colors, in 640x480. This will show you how to send sequences to draw lines. Because of some line length limitation I had to break the drawline sequence in two lines : this is easy if you don't forget to end PRINT with a semi-colon ';'. I also end with a 70GOTO70 to avoid breaking the graphics at the end of the program. Just hit Ctrl+C to break away from the endless loop when you're tired of looking at your screen.

9 REM switch to 640x480 10 E$=CHR$(27):PRINTE$;"[=2H"; 20 X=0 30 FOR Y=0 TO 479 39 REM set color: <ESC>[38;5;<n>m 40 PRINT E$;"[38;5;";MID$(STR$(Y AND 255),2);"m"; 49 REM draw line: <ESC>[#<x0>;<y0>;<x1>;<y1>l 50 PRINT E$;"[#";MID$(STR$(X),2);";";MID$(STR$(Y),2);";"; 51 PRINT MID$(STR$(639-X),2);";";MID$(STR$(Y),2);"l"; 60 NEXT Y 70 GOTO 70

bkg2018 avatar Mar 03 '19 13:03 bkg2018

Sorry I did not see this response, just finished my build and will give a try.. also running cpm3 and BBC basic right now, lots of flexibility with BBC basic including in line assembaly.. so hoping to get some software out to test show this solution off..

huskeyw avatar Mar 04 '19 08:03 huskeyw

so I ran the code and this is what I get https://www.dropbox.com/s/hpu5lnojgjyxe7v/20190306_204558.mp4?dl=0

huskeyw avatar Mar 07 '19 04:03 huskeyw

Nice video, it helps to see what happens.

I see the Pi starts fine with the 8x16 font (30 lines of text in 640x480). The difference is you run the test program in CP/M MBASIC, while I was using the ROM basic directly from SCMonitor.

The change of mode doesn't even clear the screen, so obviously something is different in the way both BASICs send their PRINT to the terminal, or maybe it's in CP/M serial driver. My first immediate guess would be that MBASIC or CP/M interprets or intercepts the ESC code or the ESC sequences it doesn't handle. But I have to check that. Most printers of the CP/M era used various control characters so it would have seriously handicaped all softwares.

I will check this as soon as possible.

At worst we could use a useless-as-possible code like CHR$(255) or whatever, which probably neither CP/M nor BASIC would take the risk to intercept. Not sure it would be the greatest idea though, VT100 and related terminals also use characters in the 128+ codes for technical drawing, foreign code pages or whatever.

bkg2018 avatar Mar 07 '19 12:03 bkg2018

let me try it on basic 4.7 not in CPM, I just used CPM so I could save it locally, I'll also look to see if there is a known issues with escape codes and cpm 3.. I could go back to cpm 2.2

William "Steve" Huskey Managing Member Dreadnought Brewing LLC

On Thu, Mar 7, 2019 at 4:44 AM Francis Piérot [email protected] wrote:

Nice video, it helps to see what happens.

I see the Pi starts fine with the 8x16 font (30 lines of text in 640x480). The difference is you run the test program in CP/M MBASIC, while I was using the ROM basic directly from SCMonitor.

The change of mode doesn't even clear the screen, so obviously something is different in the way both BASICs send their PRINT to the terminal, or maybe it's in CP/M serial driver. My first immediate guess would be that MBASIC or CP/M interprets or intercepts the ESC code or the ESC sequences it doesn't handle. But I have to check that. Most printers of the CP/M era used various control characters so it would have seriously handicaped all softwares.

I will check this as soon as possible.

At worst we could use a useless-as-possible code like CHR$(255) or whatever, which probably neither CP/M nor BASIC would take the risk to intercept. Not sure it would be the greatest idea though, VT100 and related terminals also use characters in the 128+ codes for technical drawing, foreign code pages or whatever.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/fbergama/pigfx/issues/15#issuecomment-470511405, or mute the thread https://github.com/notifications/unsubscribe-auth/AteoRiTY-JdgOPCmJBXyqS_8skvGowkLks5vUQmtgaJpZM4bOsy- .

huskeyw avatar Mar 07 '19 15:03 huskeyw

Basic 4.7b loaded from eeprom source and it works https://www.dropbox.com/s/a2xvuei1tv7d37o/20190307_074931.mp4?dl=0

huskeyw avatar Mar 07 '19 15:03 huskeyw

9 REM switch to 640x480 10 E$=CHR$(27):PRINTE$;"[=2H"; 20 X = INT(RND(1)*639)+1 : Y = INT(RND(1)*478)+1 30 CO = INT(RND(1)*254)+1 35 X1 = INT(RND(1)*639)+1 : Y1 = INT(RND(1)*478)+1 39 REM set color: <ESC>[38;5;m 40 PRINT E$;"[38;5;";MID$(STR$(CO),2);"m"; 49 REM draw line: <ESC>[#;;;l 50 PRINT E$;"[#";MID$(STR$(X),2);";";MID$(STR$(Y),2);";"; 51 PRINT MID$(STR$(X1),2);";";MID$(STR$(Y1),2);"l"; 60 GOTO 20 this creates random lines and color.. maybe not the best ways as I guessed on color and lines numbers.. but it works

huskeyw avatar Mar 11 '19 04:03 huskeyw