Skip to content

Instantly share code, notes, and snippets.

@mezcel
Last active October 2, 2020 13:22
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mezcel/f3efcbcfd66b1f998cbe9575b49a2086 to your computer and use it in GitHub Desktop.
Save mezcel/f3efcbcfd66b1f998cbe9575b49a2086 to your computer and use it in GitHub Desktop.
SmileBASIC program notes
## win10 line endins
*.bat eol=crlf
*.ps1 eol=crlf
## Linux/Posix line endins
*.sh eol=lf
Makefile eol=lf
'
' File: DEMO.PTC
' gist: https://gist.github.com/mezcel/f3efcbcfd66b1f998cbe9575b49a2086
' Playing with screen drawing and editing the UI
'
@INITAPP
ACLS:CLEAR
PNLTYPE "OFF"
G_XMIN=-10
G_XMAX=10
G_YMIN=-10
G_YMAX=10
G_XLINE=0
G_YLINE=0
DIM G_X[255]
DIM G_RAW[255]
DIM G_SCR[255]
PRINT "Splash Heading"
BEEP 7
WAIT 60
COLOR 2
PRINT "splash subheading"
COLOR 15
BEEP 1
GOSUB @AXISDRAW
WAIT 60
CLS
@MAINLOOP
'touch screen display tap
T=TCHTIME==1:TX=FLOOR(TCHX/8):TY=FLOOR(TCHY/8)
PNLSTR 0, 0,"12345678901234567890123456789012",2
PNLSTR 0, 5,"Graph",15
IF T AND TX<=15 AND TY>=3 AND TY<=7 THEN:GOSUB @GRAPH
PNLSTR 0,11,"Clear",15
IF T AND TX<=15 AND TY>=8 AND TY<=13 THEN:ACLS:GOSUB @AXISDRAW
PNLSTR 0,17,"Done",15
IF T AND TX<=15 AND TY>=14 THEN:CLEAR:END
PNLSTR 0,23,"By Mezcel 2020",2
VSYNC 1
GOTO @MAINLOOP
@GRAPH
GOSUB @AXISDRAW
PRINT "G_RAW[I]=G_X[I]+2"
FOR I=0 TO 254
G_X[I]=(((I+1)/255)*(G_XMAX-G_XMIN))+G_XMIN
'- Put function here! ---'
'G_RAW[I]=POW(G_X[I],2)
G_RAW[I]=G_X[I]+2
'- (G_X[I]=X) -----------'
G_SCR[I]=(1-((G_RAW[I]-G_YMIN)/(G_YMAX-G_YMIN)))*191
GPSET I,G_SCR[I],15
NEXT
RETURN
@AXISDRAW
G_XLINE=( ((-G_XMIN)/(G_XMAX-G_XMIN)))*254
G_YLINE=(1-((-G_XMIN)/(G_XMAX-G_XMIN)))*191
GLINE G_XLINE,0,G_XLINE,191,1
GLINE 0,G_YLINE,254,G_YLINE,1
RETURN
' -----------
' --- run ---
' -----------
GOSUB @INITAPP
GOSUB @MAINLOOP
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment